diff --git a/CMakeLists.txt b/CMakeLists.txt index 88066b5f782ccdc1cb7ceb60cdb50125261ef34b..71d382f68e1bc67d1964112468ef298f6d4e16fb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -153,11 +153,12 @@ include_directories ( Framework/Kernel/inc ) include_directories ( Framework/HistogramData/inc ) include_directories ( Framework/Indexing/inc ) include_directories ( Framework/Parallel/inc ) +include_directories ( Framework/Beamline/inc ) include_directories ( Framework/Geometry/inc ) include_directories ( Framework/API/inc ) include_directories ( Framework/Types/inc ) -set ( CORE_MANTIDLIBS Kernel HistogramData Indexing Geometry API Types ) +set ( CORE_MANTIDLIBS Kernel HistogramData Indexing Beamline Geometry API Types ) if ( ENABLE_MANTIDPLOT AND MAKE_VATES ) diff --git a/Framework/API/inc/MantidAPI/Algorithm.h b/Framework/API/inc/MantidAPI/Algorithm.h index 8115702290f435c1799a47ed17d6563c9693d1bb..a86aab5736417dc15bd658a00fa8d2713501af14 100644 --- a/Framework/API/inc/MantidAPI/Algorithm.h +++ b/Framework/API/inc/MantidAPI/Algorithm.h @@ -183,6 +183,9 @@ public: /// Function to return the separator token for the category string. A default /// implementation ';' is provided const std::string categorySeparator() const override { return ";"; } + /// Function to return all of the seeAlso (these are not validated) algorithms + /// related to this algorithm.A default implementation is provided. + const std::vector<std::string> seeAlso() const override { return {}; }; /// function to return any aliases to the algorithm; A default implementation /// is provided const std::string alias() const override { return ""; } diff --git a/Framework/API/inc/MantidAPI/AlgorithmProxy.h b/Framework/API/inc/MantidAPI/AlgorithmProxy.h index 6c2cac0c6ba5c9f7beb5231719172bce2aa793d3..08cba70c8aa4ddb9ddf0041cbcc9c26798219983 100644 --- a/Framework/API/inc/MantidAPI/AlgorithmProxy.h +++ b/Framework/API/inc/MantidAPI/AlgorithmProxy.h @@ -79,11 +79,13 @@ public: const std::string category() const override { return m_category; } /// Function to return all of the categories that contain this algorithm const std::vector<std::string> categories() const override; - /// Function to return the sperator token for the category string. A default + /// Function to return the seperator token for the category string. A default /// implementation ',' is provided const std::string categorySeparator() const override { return m_categorySeparator; } + /// Function to return all of the seeAlso algorithms related to this algorithm + const std::vector<std::string> seeAlso() const override { return m_seeAlso; }; /// Aliases to the algorithm const std::string alias() const override { return m_alias; } /// Optional documentation URL for the real algorithm @@ -183,9 +185,10 @@ private: const std::string m_name; ///< name of the real algorithm const std::string m_category; ///< category of the real algorithm const std::string - m_categorySeparator; ///< category seperator of the real algorithm - const std::string m_alias; ///< alias to the algorithm - const std::string m_helpURL; ///< Optional documentation URL + m_categorySeparator; ///< category seperator of the real algorithm + const std::vector<std::string> m_seeAlso; ///< seeAlso of the real algorithm + const std::string m_alias; ///< alias to the algorithm + const std::string m_helpURL; ///< Optional documentation URL const std::string m_summary; ///<Message to display in GUI and help. const int m_version; ///< version of the real algorithm diff --git a/Framework/API/inc/MantidAPI/CompositeDomainMD.h b/Framework/API/inc/MantidAPI/CompositeDomainMD.h index aadf666d4ec8e7b7fbcc29ab358cb4af56cd7e26..5fffbaf394f2a56a6c0a5c38f2de9dbf87b38e81 100644 --- a/Framework/API/inc/MantidAPI/CompositeDomainMD.h +++ b/Framework/API/inc/MantidAPI/CompositeDomainMD.h @@ -53,8 +53,8 @@ public: const FunctionDomain &getDomain(size_t i) const override; protected: - mutable IMDIterator *m_iterator; ///< IMDIterator - size_t m_totalSize; ///< The total size of the domain + mutable std::unique_ptr<IMDIterator> m_iterator; ///< IMDIterator + size_t m_totalSize; ///< The total size of the domain mutable std::vector<FunctionDomainMD *> m_domains; ///< smaller parts of the domain }; diff --git a/Framework/API/inc/MantidAPI/FunctionDomainMD.h b/Framework/API/inc/MantidAPI/FunctionDomainMD.h index fa52a8a36689278f9a2ab7e01ee33a19badbbc9e..adc80e5bed649ccf48ecff7ef505b91e7450e606 100644 --- a/Framework/API/inc/MantidAPI/FunctionDomainMD.h +++ b/Framework/API/inc/MantidAPI/FunctionDomainMD.h @@ -53,7 +53,7 @@ public: protected: /// IMDIterator - mutable IMDIterator *m_iterator; + mutable std::unique_ptr<IMDIterator> m_iterator; /// start of the domain, 0 <= m_startIndex < m_iterator->getDataSize() const size_t m_startIndex; /// track the iterator's index, 0 <= m_currentIndex < m_size. diff --git a/Framework/API/inc/MantidAPI/FunctionProperty.h b/Framework/API/inc/MantidAPI/FunctionProperty.h index 7d254fce7c864af3fc292154e4385c9e4827d825..64189b6038e7e3ac2ab5920afacd5dc624e7d902 100644 --- a/Framework/API/inc/MantidAPI/FunctionProperty.h +++ b/Framework/API/inc/MantidAPI/FunctionProperty.h @@ -56,7 +56,7 @@ public: /// Bring in the PropertyWithValue assignment operator explicitly (avoids /// VSC++ warning) - boost::shared_ptr<IFunction> & + FunctionProperty & operator=(const boost::shared_ptr<IFunction> &value) override; /// Add the value of another property diff --git a/Framework/API/inc/MantidAPI/IAlgorithm.h b/Framework/API/inc/MantidAPI/IAlgorithm.h index 376780fda330c8ba5d3c8195c2e56fc3c741aa48..5f8888f7643d113677ab062e2e9591a43ff474c7 100644 --- a/Framework/API/inc/MantidAPI/IAlgorithm.h +++ b/Framework/API/inc/MantidAPI/IAlgorithm.h @@ -77,6 +77,9 @@ public: /// Function to return the separator token for the category string virtual const std::string categorySeparator() const = 0; + /// Function to return all of the seeAlso algorithms related to this algorithm + virtual const std::vector<std::string> seeAlso() const = 0; + /// function to return any aliases of the algorithm. virtual const std::string alias() const = 0; diff --git a/Framework/API/inc/MantidAPI/IMDIterator.h b/Framework/API/inc/MantidAPI/IMDIterator.h index 85d50481879e5824c1e63a9cdf8e01f37cf47ff3..ea8ca2a3ff172de36c622526fc10b380ed487769 100644 --- a/Framework/API/inc/MantidAPI/IMDIterator.h +++ b/Framework/API/inc/MantidAPI/IMDIterator.h @@ -5,7 +5,6 @@ // Includes //---------------------------------------------------------------------- #include "MantidAPI/DllConfig.h" -#include "MantidAPI/IMDWorkspace.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" #include "MantidGeometry/MDGeometry/MDTypes.h" #include "MantidKernel/VMD.h" @@ -14,10 +13,18 @@ namespace Mantid { namespace API { -//---------------------------------------------------------------------- -// Forward declaration -//---------------------------------------------------------------------- -class IMDWorkspace; + +/** Enum describing different ways to normalize the signal + * in a MDWorkspace. + */ +enum MDNormalization { + /// Don't normalize = return raw counts + NoNormalization = 0, + /// Divide the signal by the volume of the box/bin + VolumeNormalization = 1, + /// Divide the signal by the number of events that contributed to it. + NumEventsNormalization = 2 +}; /** This is an interface to an iterator of an IMDWorkspace @@ -83,13 +90,14 @@ public: virtual signal_t getError() const = 0; /// Return a list of vertexes defining the volume pointed to - virtual coord_t *getVertexesArray(size_t &numVertices) const = 0; + virtual std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const = 0; /// Return a list of vertexes defining the volume pointed to, enable masking /// of dimensions. - virtual coord_t *getVertexesArray(size_t &numVertices, - const size_t outDimensions, - const bool *maskDim) const = 0; + virtual std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const = 0; /// Returns the position of the center of the box pointed to. virtual Mantid::Kernel::VMD getCenter() const = 0; diff --git a/Framework/API/inc/MantidAPI/IMDNode.h b/Framework/API/inc/MantidAPI/IMDNode.h index a7e1a9f8ad4a50957db71cd524bbdd8d851acad6..09678f09d8aed97e699c8cd0b5de454ecf34217d 100644 --- a/Framework/API/inc/MantidAPI/IMDNode.h +++ b/Framework/API/inc/MantidAPI/IMDNode.h @@ -3,6 +3,7 @@ #include <algorithm> #include <string> +#include <memory> #include <vector> #include "MantidKernel/VMD.h" #include "MantidGeometry/MDGeometry/MDTypes.h" @@ -277,10 +278,11 @@ public: // -------------------------------- Geometry/vertexes-Related // ------------------------------------------- virtual std::vector<Mantid::Kernel::VMD> getVertexes() const = 0; - virtual coord_t *getVertexesArray(size_t &numVertices) const = 0; - virtual coord_t *getVertexesArray(size_t &numVertices, - const size_t outDimensions, - const bool *maskDim) const = 0; + virtual std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const = 0; + virtual std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const = 0; virtual void transformDimensions(std::vector<double> &scaling, std::vector<double> &offset) = 0; diff --git a/Framework/API/inc/MantidAPI/IMDWorkspace.h b/Framework/API/inc/MantidAPI/IMDWorkspace.h index 6c5441eda94a75dae05295c7b230f032d0db52d9..8e6069d642a03ee7ee883f74ba5549c3c982bfd8 100644 --- a/Framework/API/inc/MantidAPI/IMDWorkspace.h +++ b/Framework/API/inc/MantidAPI/IMDWorkspace.h @@ -1,6 +1,7 @@ #ifndef MANTID_API_IMDWORKSPACE_H_ #define MANTID_API_IMDWORKSPACE_H_ +#include "MantidAPI/IMDIterator.h" #include "MantidAPI/ITableWorkspace_fwd.h" #include "MantidAPI/MDGeometry.h" #include "MantidAPI/Workspace.h" @@ -16,20 +17,6 @@ class MDImplicitFunction; namespace API { -class IMDIterator; - -/** Enum describing different ways to normalize the signal - * in a MDWorkspace. - */ -enum MDNormalization { - /// Don't normalize = return raw counts - NoNormalization = 0, - /// Divide the signal by the volume of the box/bin - VolumeNormalization = 1, - /// Divide the signal by the number of events that contributed to it. - NumEventsNormalization = 2 -}; - static const signal_t MDMaskValue = std::numeric_limits<double>::quiet_NaN(); /** Basic MD Workspace Abstract Class. @@ -106,7 +93,7 @@ public: virtual uint64_t getNEvents() const = 0; /// Creates a new iterator pointing to the first cell in the workspace - virtual std::vector<IMDIterator *> createIterators( + virtual std::vector<std::unique_ptr<IMDIterator>> createIterators( size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const = 0; @@ -126,7 +113,7 @@ public: const Mantid::Kernel::VMD &end, Mantid::API::MDNormalization normalize) const; - IMDIterator *createIterator( + std::unique_ptr<IMDIterator> createIterator( Mantid::Geometry::MDImplicitFunction *function = nullptr) const; std::string getConvention() const; diff --git a/Framework/API/inc/MantidAPI/IMaskWorkspace.h b/Framework/API/inc/MantidAPI/IMaskWorkspace.h index afb86d897521922829b52cf98473e92d4d3d596b..333a9abbf6d704ff4a3160e181306c543f6539dd 100644 --- a/Framework/API/inc/MantidAPI/IMaskWorkspace.h +++ b/Framework/API/inc/MantidAPI/IMaskWorkspace.h @@ -38,6 +38,7 @@ class DLLExport IMaskWorkspace { public: IMaskWorkspace() = default; IMaskWorkspace &operator=(const IMaskWorkspace &) = delete; + virtual ~IMaskWorkspace() = default; /// Return the workspace typeID virtual const std::string id() const { return "IMaskWorkspace"; } /// Total number of masked pixels diff --git a/Framework/API/inc/MantidAPI/IndexProperty.h b/Framework/API/inc/MantidAPI/IndexProperty.h index 1952a88d54c173ceae0e07af0c54bd02043681ce..dad8fdd724cf12eb035ae65e8a4a535310a4f5c2 100644 --- a/Framework/API/inc/MantidAPI/IndexProperty.h +++ b/Framework/API/inc/MantidAPI/IndexProperty.h @@ -57,7 +57,7 @@ public: bool isDefault() const override; std::string isValid() const override; - std::string operator=(const std::string &rhs); + IndexProperty &operator=(const std::string &rhs); operator Indexing::SpectrumIndexSet() const; Indexing::SpectrumIndexSet getIndices() const; Indexing::IndexInfo getFilteredIndexInfo() const; diff --git a/Framework/API/inc/MantidAPI/IndexTypeProperty.h b/Framework/API/inc/MantidAPI/IndexTypeProperty.h index 4ee308d2584ad4289e862356b3a48fd615d5d544..4ad313bfd15b157b4cf794a3eaddb33ee5f1e330 100644 --- a/Framework/API/inc/MantidAPI/IndexTypeProperty.h +++ b/Framework/API/inc/MantidAPI/IndexTypeProperty.h @@ -52,7 +52,7 @@ public: using PropertyWithValue<std::string>::operator=; - std::string &operator=(API::IndexType type); + IndexTypeProperty &operator=(API::IndexType type); static std::string generatePropertyName(const std::string &name = ""); @@ -63,4 +63,4 @@ private: } // namespace API } // namespace Mantid -#endif /* MANTID_API_INDEXTYPEPROPERTY_H_ */ \ No newline at end of file +#endif /* MANTID_API_INDEXTYPEPROPERTY_H_ */ diff --git a/Framework/API/inc/MantidAPI/MatrixWorkspace.h b/Framework/API/inc/MantidAPI/MatrixWorkspace.h index ad3657c215ddd708d1d344769899916b28c7367f..3fe921d12c0c643e8d0db88fcab6cb146e07c6dc 100644 --- a/Framework/API/inc/MantidAPI/MatrixWorkspace.h +++ b/Framework/API/inc/MantidAPI/MatrixWorkspace.h @@ -499,7 +499,7 @@ public: const Mantid::API::MDNormalization &normalization) const override; /// Create iterators. Partitions the iterators according to the number of /// cores. - std::vector<IMDIterator *> createIterators( + std::vector<std::unique_ptr<IMDIterator>> createIterators( size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const override; diff --git a/Framework/API/inc/MantidAPI/MatrixWorkspaceMDIterator.h b/Framework/API/inc/MantidAPI/MatrixWorkspaceMDIterator.h index 7bcde9b23863f237fa13299422bde7cf00cb29bd..0432b6eefd1d1f7f3895507eebde59c3e7d22c65 100644 --- a/Framework/API/inc/MantidAPI/MatrixWorkspaceMDIterator.h +++ b/Framework/API/inc/MantidAPI/MatrixWorkspaceMDIterator.h @@ -60,10 +60,12 @@ public: signal_t getError() const override; - coord_t *getVertexesArray(size_t &numVertices) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const override; - coord_t *getVertexesArray(size_t &numVertices, const size_t outDimensions, - const bool *maskDim) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const override; Mantid::Kernel::VMD getCenter() const override; diff --git a/Framework/API/inc/MantidAPI/WorkspaceGroup.h b/Framework/API/inc/MantidAPI/WorkspaceGroup.h index 1235c04c8cf11e13f0834be867a981fd8b7cad36..4686b006f59552e94e5b506e67debdaff4d00b40 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceGroup.h +++ b/Framework/API/inc/MantidAPI/WorkspaceGroup.h @@ -76,6 +76,8 @@ public: Workspace_sptr getItem(const size_t index) const; /// Return the workspace by name Workspace_sptr getItem(const std::string wsName) const; + /// Return all workspaces in the group as one call for thread safety + std::vector<Workspace_sptr> getAllItems() const; /// Remove a workspace from the group void removeItem(const size_t index); /// Remove all names from the group but do not touch the ADS diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.h b/Framework/API/inc/MantidAPI/WorkspaceProperty.h index 75a5d27dfe5373a77687b6f78eeaccd8b61f5cd9..fc9a66d00dff7b8fa0309a6e24532993fafc086f 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.h +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.h @@ -95,8 +95,7 @@ public: WorkspaceProperty &operator=(const WorkspaceProperty &right); - boost::shared_ptr<TYPE> & - operator=(const boost::shared_ptr<TYPE> &value) override; + WorkspaceProperty &operator=(const boost::shared_ptr<TYPE> &value) override; WorkspaceProperty &operator+=(Kernel::Property const *) override; diff --git a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc index 1dbcb92a0223ffe7d98ac37911be1082c1cc5218..1894b6dded19fe397cfe069421575a33afcee2fd 100644 --- a/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc +++ b/Framework/API/inc/MantidAPI/WorkspaceProperty.tcc @@ -107,13 +107,14 @@ operator=(const WorkspaceProperty &right) { * @return assigned PropertyWithValue */ template <typename TYPE> -boost::shared_ptr<TYPE> &WorkspaceProperty<TYPE>:: +WorkspaceProperty<TYPE> &WorkspaceProperty<TYPE>:: operator=(const boost::shared_ptr<TYPE> &value) { std::string wsName = value->getName(); if (this->direction() == Kernel::Direction::Input && !wsName.empty()) { m_workspaceName = wsName; } - return Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value); + Kernel::PropertyWithValue<boost::shared_ptr<TYPE>>::operator=(value); + return *this; } //-------------------------------------------------------------------------------------- diff --git a/Framework/API/src/AlgorithmProxy.cpp b/Framework/API/src/AlgorithmProxy.cpp index adf89ce8ac2aebaef3e5280dc1a9f4c0b945c199..94c4df66b0bce314bcad941643edfc42f4144769 100644 --- a/Framework/API/src/AlgorithmProxy.cpp +++ b/Framework/API/src/AlgorithmProxy.cpp @@ -19,9 +19,10 @@ AlgorithmProxy::AlgorithmProxy(Algorithm_sptr alg) m_executeAsync(new Poco::ActiveMethod<bool, Poco::Void, AlgorithmProxy>( this, &AlgorithmProxy::executeAsyncImpl)), m_name(alg->name()), m_category(alg->category()), - m_categorySeparator(alg->categorySeparator()), m_alias(alg->alias()), - m_summary(alg->summary()), m_version(alg->version()), m_alg(alg), - m_isExecuted(), m_isLoggingEnabled(true), m_loggingOffset(0), + m_categorySeparator(alg->categorySeparator()), m_seeAlso(alg->seeAlso()), + m_alias(alg->alias()), m_summary(alg->summary()), + m_version(alg->version()), m_alg(alg), m_isExecuted(), + m_isLoggingEnabled(true), m_loggingOffset(0), m_isAlgStartupLoggingEnabled(true), m_rethrow(false), m_isChild(false), m_setAlwaysStoreInADS(true) { if (!alg) { diff --git a/Framework/API/src/EqualBinSizesValidator.cpp b/Framework/API/src/EqualBinSizesValidator.cpp index 7415acc1b181f67eef1dc55ca3494b4e5f8c43c1..034cdc8acca2a8ab44ff456526e7bdcc3545c3cd 100644 --- a/Framework/API/src/EqualBinSizesValidator.cpp +++ b/Framework/API/src/EqualBinSizesValidator.cpp @@ -25,10 +25,10 @@ std::string EqualBinSizesValidator::checkValidity(const MatrixWorkspace_sptr &value) const { if (!value) return "Enter an existing workspace"; - if (value->getNumberHistograms() == 0 || value->blocksize() == 0) - return "Enter a workspace with some data in it"; if (!value->isCommonBins()) return "The workspace must have common bin boundaries for all histograms"; + if (value->getNumberHistograms() == 0 || value->blocksize() == 0) + return "Enter a workspace with some data in it"; Kernel::EqualBinsChecker checker(value->readX(0), m_errorLevel, m_warningLevel); diff --git a/Framework/API/src/FunctionDomainMD.cpp b/Framework/API/src/FunctionDomainMD.cpp index 55f26e7bcc07c67bfe08d0640cb8c7f05a451cfd..73652eb0e78d8a55d87ba06ec21736bd79d9189e 100644 --- a/Framework/API/src/FunctionDomainMD.cpp +++ b/Framework/API/src/FunctionDomainMD.cpp @@ -34,7 +34,7 @@ FunctionDomainMD::FunctionDomainMD(IMDWorkspace_const_sptr ws, size_t start, /** Destructor. */ -FunctionDomainMD::~FunctionDomainMD() { delete m_iterator; } +FunctionDomainMD::~FunctionDomainMD() = default; /// Reset the iterator to point to the start of the domain. void FunctionDomainMD::reset() const { @@ -53,14 +53,14 @@ void FunctionDomainMD::reset() const { const IMDIterator *FunctionDomainMD::getNextIterator() const { if (m_justReset) { m_justReset = false; - return m_iterator; + return m_iterator.get(); } ++m_currentIndex; if (!m_iterator->next() || m_currentIndex >= m_size) { m_currentIndex = m_size; return nullptr; } - return m_iterator; + return m_iterator.get(); } /// Returns the pointer to the original workspace diff --git a/Framework/API/src/FunctionProperty.cpp b/Framework/API/src/FunctionProperty.cpp index 3a51eec83738b00a39cb56a55d1c5fc741b403ae..a2f62efc1b4a420c41ae28c27b58f39ea76e00cd 100644 --- a/Framework/API/src/FunctionProperty.cpp +++ b/Framework/API/src/FunctionProperty.cpp @@ -31,10 +31,10 @@ FunctionProperty &FunctionProperty::operator=(const FunctionProperty &right) { * @param value :: The value to set to * @return assigned PropertyWithValue */ -boost::shared_ptr<IFunction> &FunctionProperty:: +FunctionProperty &FunctionProperty:: operator=(const boost::shared_ptr<IFunction> &value) { - return Kernel::PropertyWithValue<boost::shared_ptr<IFunction>>::operator=( - value); + Kernel::PropertyWithValue<boost::shared_ptr<IFunction>>::operator=(value); + return *this; } //-------------------------------------------------------------------------------------- diff --git a/Framework/API/src/IMDWorkspace.cpp b/Framework/API/src/IMDWorkspace.cpp index 033a160b5ba81cddce13f31d625d50eb48d064f0..1285b43072c7d63c6dc48c300af54b6bb057ac98 100644 --- a/Framework/API/src/IMDWorkspace.cpp +++ b/Framework/API/src/IMDWorkspace.cpp @@ -26,15 +26,16 @@ IMDWorkspace::IMDWorkspace(const Parallel::StorageMode storageMode) * @param function :: Implicit function limiting space to look at * @return a single IMDIterator pointer */ -IMDIterator *IMDWorkspace::createIterator( +std::unique_ptr<IMDIterator> IMDWorkspace::createIterator( Mantid::Geometry::MDImplicitFunction *function) const { - std::vector<IMDIterator *> iterators = this->createIterators(1, function); + std::vector<std::unique_ptr<IMDIterator>> iterators = + this->createIterators(1, function); if (iterators.empty()) throw std::runtime_error("IMDWorkspace::createIterator(): iterator " "creation was not successful. No iterators " "returned by " + this->id()); - return iterators[0]; + return std::move(iterators[0]); } //--------------------------------------------------------------------------------------------- diff --git a/Framework/API/src/IndexProperty.cpp b/Framework/API/src/IndexProperty.cpp index fa8dedb614158378416296d0df4446720019eea6..ea0cefaa7863d0cac86eb220b7699fe3eca4340b 100644 --- a/Framework/API/src/IndexProperty.cpp +++ b/Framework/API/src/IndexProperty.cpp @@ -33,8 +33,9 @@ std::string IndexProperty::isValid() const { return error; } -std::string IndexProperty::operator=(const std::string &rhs) { - return setValue(rhs); +IndexProperty &IndexProperty::operator=(const std::string &rhs) { + setValue(rhs); + return *this; } IndexProperty::operator Indexing::SpectrumIndexSet() const { diff --git a/Framework/API/src/IndexTypeProperty.cpp b/Framework/API/src/IndexTypeProperty.cpp index 26b14da4fa8868164b5181210776be05949a068d..8df2a25296aa9d6e85edd121a9bbda0dad1c20d6 100644 --- a/Framework/API/src/IndexTypeProperty.cpp +++ b/Framework/API/src/IndexTypeProperty.cpp @@ -50,7 +50,7 @@ std::vector<std::string> IndexTypeProperty::allowedValues() const { bool IndexTypeProperty::isMultipleSelectionAllowed() { return false; } -std::string &IndexTypeProperty::operator=(API::IndexType type) { +IndexTypeProperty &IndexTypeProperty::operator=(API::IndexType type) { std::string val; switch (type) { @@ -62,7 +62,8 @@ std::string &IndexTypeProperty::operator=(API::IndexType type) { break; } - return *this = val; + *this = val; + return *this; } std::string IndexTypeProperty::generatePropertyName(const std::string &name) { diff --git a/Framework/API/src/MatrixWorkspace.cpp b/Framework/API/src/MatrixWorkspace.cpp index 12a2ba68ac45b9e2ac0a1882c6106994b2106654..5cd215f3e506f526c3b18f8e549323b89284ba23 100644 --- a/Framework/API/src/MatrixWorkspace.cpp +++ b/Framework/API/src/MatrixWorkspace.cpp @@ -1466,7 +1466,7 @@ MatrixWorkspace::getDimensionWithId(std::string id) const { * @param function :: implicit function to limit range * @return MatrixWorkspaceMDIterator vector */ -std::vector<IMDIterator *> MatrixWorkspace::createIterators( +std::vector<std::unique_ptr<IMDIterator>> MatrixWorkspace::createIterators( size_t suggestedNumCores, Mantid::Geometry::MDImplicitFunction *function) const { // Find the right number of cores to use @@ -1480,13 +1480,14 @@ std::vector<IMDIterator *> MatrixWorkspace::createIterators( numCores = 1; // Create one iterator per core, splitting evenly amongst spectra - std::vector<IMDIterator *> out; + std::vector<std::unique_ptr<IMDIterator>> out; for (size_t i = 0; i < numCores; i++) { size_t begin = (i * numElements) / numCores; size_t end = ((i + 1) * numElements) / numCores; if (end > numElements) end = numElements; - out.push_back(new MatrixWorkspaceMDIterator(this, function, begin, end)); + out.push_back(Kernel::make_unique<MatrixWorkspaceMDIterator>(this, function, + begin, end)); } return out; } @@ -2000,8 +2001,8 @@ void MatrixWorkspace::rebuildDetectorIDGroupings() { const auto &allDetIDs = detInfo.detectorIDs(); const auto &specDefs = m_indexInfo->spectrumDefinitions(); const auto size = static_cast<int64_t>(m_indexInfo->size()); - std::atomic<bool> parallelException{false}; - std::string error; + enum class ErrorCode { None, InvalidDetIndex, InvalidTimeIndex }; + std::atomic<ErrorCode> errorValue(ErrorCode::None); #pragma omp parallel for for (int64_t i = 0; i < size; ++i) { auto &spec = getSpectrum(i); @@ -2013,23 +2014,29 @@ void MatrixWorkspace::rebuildDetectorIDGroupings() { const size_t detIndex = index.first; const size_t timeIndex = index.second; if (detIndex >= allDetIDs.size()) { - parallelException = true; - error = "MatrixWorkspace: SpectrumDefinition contains an out-of-range " - "detector index, i.e., the spectrum definition does not match " - "the instrument in the workspace."; + errorValue = ErrorCode::InvalidDetIndex; } else if (timeIndex >= detInfo.scanCount(detIndex)) { - parallelException = true; - error = "MatrixWorkspace: SpectrumDefinition contains an out-of-range " - "time index for a detector, i.e., the spectrum definition does " - "not match the instrument in the workspace."; + errorValue = ErrorCode::InvalidTimeIndex; } else { detIDs.insert(allDetIDs[detIndex]); } } spec.setDetectorIDs(std::move(detIDs)); } - if (parallelException) - throw std::invalid_argument(error); + switch (errorValue) { + case ErrorCode::InvalidDetIndex: + throw std::invalid_argument( + "MatrixWorkspace: SpectrumDefinition contains an out-of-range " + "detector index, i.e., the spectrum definition does not match " + "the instrument in the workspace."); + case ErrorCode::InvalidTimeIndex: + throw std::invalid_argument( + "MatrixWorkspace: SpectrumDefinition contains an out-of-range " + "time index for a detector, i.e., the spectrum definition does " + "not match the instrument in the workspace."); + case ErrorCode::None: + ; // nothing to do + } } } // namespace API diff --git a/Framework/API/src/MatrixWorkspaceMDIterator.cpp b/Framework/API/src/MatrixWorkspaceMDIterator.cpp index 7fd7e4291a4abda9b9a3acfa7001974d9027006e..c08e275918258db4e74624b2d89b1e388398071c 100644 --- a/Framework/API/src/MatrixWorkspaceMDIterator.cpp +++ b/Framework/API/src/MatrixWorkspaceMDIterator.cpp @@ -204,13 +204,13 @@ signal_t MatrixWorkspaceMDIterator::getError() const { //---------------------------------------------------------------------------------------------- /// Return a list of vertexes defining the volume pointed to -coord_t * +std::unique_ptr<coord_t[]> MatrixWorkspaceMDIterator::getVertexesArray(size_t & /*numVertices*/) const { throw std::runtime_error( "MatrixWorkspaceMDIterator::getVertexesArray() not implemented yet"); } -coord_t * +std::unique_ptr<coord_t[]> MatrixWorkspaceMDIterator::getVertexesArray(size_t & /*numVertices*/, const size_t /*outDimensions*/, const bool * /*maskDim*/) const { diff --git a/Framework/API/src/MultipleFileProperty.cpp b/Framework/API/src/MultipleFileProperty.cpp index 6f92bac63f3e9d1a9cbfdced5e235a1c409d7b7c..7d0d7ac5b540f89c973114b11bffecdcbd80ca18 100644 --- a/Framework/API/src/MultipleFileProperty.cpp +++ b/Framework/API/src/MultipleFileProperty.cpp @@ -37,18 +37,18 @@ bool doesNotContainWildCard(const std::string &ext) { static const std::string SUCCESS(""); // Regular expressions for any adjacent + or , operators -const std::string INVALID = "\\+\\+|,,|\\+,|,\\+"; +const std::string INVALID = R"(\+\+|,,|\+,|,\+)"; static const boost::regex REGEX_INVALID(INVALID); // Regular expressions that represent the allowed instances of , operators -const std::string NUM_COMMA_ALPHA("(?<=\\d)\\s*,\\s*(?=\\D)"); -const std::string ALPHA_COMMA_ALPHA("(?<=\\D)\\s*,\\s*(?=\\D)"); +const std::string NUM_COMMA_ALPHA(R"((?<=\d)\s*,\s*(?=\D))"); +const std::string ALPHA_COMMA_ALPHA(R"((?<=\D)\s*,\s*(?=\D))"); const std::string COMMA_OPERATORS = NUM_COMMA_ALPHA + "|" + ALPHA_COMMA_ALPHA; static const boost::regex REGEX_COMMA_OPERATORS(COMMA_OPERATORS); // Regular expressions that represent the allowed instances of + operators -const std::string NUM_PLUS_ALPHA("(?<=\\d)\\s*\\+\\s*(?=\\D)"); -const std::string ALPHA_PLUS_ALPHA("(?<=\\D)\\s*\\+\\s*(?=\\D)"); +const std::string NUM_PLUS_ALPHA(R"((?<=\d)\s*\+\s*(?=\D))"); +const std::string ALPHA_PLUS_ALPHA(R"((?<=\D)\s*\+\s*(?=\D))"); const std::string PLUS_OPERATORS = NUM_PLUS_ALPHA + "|" + ALPHA_PLUS_ALPHA; static const boost::regex REGEX_PLUS_OPERATORS(PLUS_OPERATORS, boost::regex_constants::perl); diff --git a/Framework/API/src/ParameterTie.cpp b/Framework/API/src/ParameterTie.cpp index 56b2bfb5dd7a501f351deafe205ef76a5f0690f4..1716b93639f3e702cf6454048791fc69cde5e481 100644 --- a/Framework/API/src/ParameterTie.cpp +++ b/Framework/API/src/ParameterTie.cpp @@ -81,7 +81,7 @@ void ParameterTie::set(const std::string &expr) { } // Create the template m_expression - boost::regex rx("\\b(([[:alpha:]]|_)([[:alnum:]]|_|\\.)*)\\b(?!(\\s*\\())"); + boost::regex rx(R"(\b(([[:alpha:]]|_)([[:alnum:]]|_|\.)*)\b(?!(\s*\()))"); std::string input = expr; boost::smatch res; std::string::const_iterator start = input.begin(); diff --git a/Framework/API/src/WorkspaceGroup.cpp b/Framework/API/src/WorkspaceGroup.cpp index 172d62382ad26aa4fa325c8a76ff3561f6141e50..f8d33ea0ec4e1752d37bc8dcba21183ff721d199 100644 --- a/Framework/API/src/WorkspaceGroup.cpp +++ b/Framework/API/src/WorkspaceGroup.cpp @@ -195,6 +195,13 @@ Workspace_sptr WorkspaceGroup::getItem(const std::string wsName) const { " not contained in the group"); } +/** Return all workspaces in the group as one call for thread safety + */ +std::vector<Workspace_sptr> WorkspaceGroup::getAllItems() const { + std::lock_guard<std::recursive_mutex> _lock(m_mutex); + return m_workspaces; +} + /// Empty all the entries out of the workspace group. Does not remove the /// workspaces from the ADS. void WorkspaceGroup::removeAll() { m_workspaces.clear(); } diff --git a/Framework/API/test/AlgorithmManagerTest.h b/Framework/API/test/AlgorithmManagerTest.h index fcdbcdcb517c2be1450ddaa158082765143d565f..281451bef434cd7cbd53ea9a93b274855b880418 100644 --- a/Framework/API/test/AlgorithmManagerTest.h +++ b/Framework/API/test/AlgorithmManagerTest.h @@ -139,13 +139,13 @@ public: TS_ASSERT_THROWS_NOTHING( alg = AlgorithmManager::Instance().create("AlgTest", 1)); TS_ASSERT_DIFFERS(dynamic_cast<AlgorithmProxy *>(alg.get()), - static_cast<AlgorithmProxy *>(0)); + static_cast<AlgorithmProxy *>(nullptr)); TS_ASSERT_THROWS_NOTHING( alg = AlgorithmManager::Instance().create("AlgTestSecond", 1)); TS_ASSERT_DIFFERS(dynamic_cast<AlgorithmProxy *>(alg.get()), - static_cast<AlgorithmProxy *>(0)); + static_cast<AlgorithmProxy *>(nullptr)); TS_ASSERT_DIFFERS(dynamic_cast<IAlgorithm *>(alg.get()), - static_cast<IAlgorithm *>(0)); + static_cast<IAlgorithm *>(nullptr)); TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 2); // To check that crea is called on local objects } @@ -157,8 +157,8 @@ public: Bptr = AlgorithmManager::Instance().createUnmanaged("AlgTest"); TS_ASSERT_DIFFERS(Aptr, Bptr); TS_ASSERT_EQUALS(AlgorithmManager::Instance().size(), 1); - TS_ASSERT_DIFFERS(Aptr.get(), static_cast<Algorithm *>(0)); - TS_ASSERT_DIFFERS(Bptr.get(), static_cast<Algorithm *>(0)); + TS_ASSERT_DIFFERS(Aptr.get(), static_cast<Algorithm *>(nullptr)); + TS_ASSERT_DIFFERS(Bptr.get(), static_cast<Algorithm *>(nullptr)); } void testCreateNoProxy() { @@ -169,7 +169,7 @@ public: TSM_ASSERT("Was created as a AlgorithmProxy", dynamic_cast<AlgorithmProxy *>(Aptr.get())); TSM_ASSERT("Was NOT created as a AlgorithmProxy", - dynamic_cast<AlgorithmProxy *>(Bptr.get()) == NULL); + dynamic_cast<AlgorithmProxy *>(Bptr.get()) == nullptr); } // This will be called back when an algo starts diff --git a/Framework/API/test/AlgorithmProxyTest.h b/Framework/API/test/AlgorithmProxyTest.h index d8d745c15a792e855eb84fe363c7aff5bc925fab..58b97aa90b343835ef79e2371bfd2b7827f4b8af 100644 --- a/Framework/API/test/AlgorithmProxyTest.h +++ b/Framework/API/test/AlgorithmProxyTest.h @@ -29,6 +29,9 @@ public: const std::string category() const override { return "ProxyCat"; } ///< Algorithm's category for identification + const std::vector<std::string> seeAlso() const override { + return {"elephant", "seal"}; + } ///< Algorithm's seeAlso const std::string alias() const override { return "Dog"; } ///< Algorithm's alias @@ -134,6 +137,8 @@ public: TS_ASSERT_EQUALS(alg->version(), 1); TS_ASSERT_EQUALS(alg->category(), "ProxyCat"); TS_ASSERT_EQUALS(alg->alias(), "Dog"); + std::vector<std::string> seeAlsoList{"elephant", "seal"}; + TS_ASSERT_EQUALS(alg->seeAlso(), seeAlsoList); TS_ASSERT(alg->isInitialized()); TS_ASSERT(alg->existsProperty("prop1")); TS_ASSERT(alg->existsProperty("prop2")); diff --git a/Framework/API/test/AlgorithmTest.h b/Framework/API/test/AlgorithmTest.h index 92f3c17252ceb9c6a6e124cc28390e644b356b16..bac48ae042bb14ff67f076267cb1c510a09c411f 100644 --- a/Framework/API/test/AlgorithmTest.h +++ b/Framework/API/test/AlgorithmTest.h @@ -241,6 +241,13 @@ public: TS_ASSERT_EQUALS(algv3.categories(), result); } + void testSeeAlso() { + std::vector<std::string> result{"rabbit"}; + result.emplace_back("goldfish"); + result.emplace_back("Spotted Hyena"); + TS_ASSERT_EQUALS(alg.seeAlso(), result); + } + void testAlias() { TS_ASSERT_EQUALS(alg.alias(), "Dog"); } void testIsChild() { @@ -361,7 +368,7 @@ public: } void test_Construction_Via_Valid_String_With_No_Properties() { - IAlgorithm_sptr testAlg = runFromString("{\"name\":\"ToyAlgorithm\"}"); + IAlgorithm_sptr testAlg = runFromString(R"({"name":"ToyAlgorithm"})"); TS_ASSERT_EQUALS(testAlg->name(), "ToyAlgorithm"); TS_ASSERT_EQUALS(testAlg->version(), 2); } @@ -808,10 +815,10 @@ public: IAlgorithm_sptr algNonConst; TS_ASSERT_THROWS_NOTHING( algConst = manager.getValue<IAlgorithm_const_sptr>(algName)); - TS_ASSERT(algConst != NULL); + TS_ASSERT(algConst != nullptr); TS_ASSERT_THROWS_NOTHING(algNonConst = manager.getValue<IAlgorithm_sptr>(algName)); - TS_ASSERT(algNonConst != NULL); + TS_ASSERT(algNonConst != nullptr); TS_ASSERT_EQUALS(algConst, algNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -819,9 +826,9 @@ public: IAlgorithm_const_sptr algCastConst; IAlgorithm_sptr algCastNonConst; TS_ASSERT_THROWS_NOTHING(algCastConst = (IAlgorithm_const_sptr)val); - TS_ASSERT(algCastConst != NULL); + TS_ASSERT(algCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(algCastNonConst = (IAlgorithm_sptr)val); - TS_ASSERT(algCastNonConst != NULL); + TS_ASSERT(algCastNonConst != nullptr); TS_ASSERT_EQUALS(algCastConst, algCastNonConst); } diff --git a/Framework/API/test/ExperimentInfoTest.h b/Framework/API/test/ExperimentInfoTest.h index 8941eb1eb703072d3fa0975588b1fc08104de21c..71806ba8cc0a38e91d3d733c74df8d705ba91b91 100644 --- a/Framework/API/test/ExperimentInfoTest.h +++ b/Framework/API/test/ExperimentInfoTest.h @@ -129,7 +129,7 @@ public: void test_Setting_A_New_Chopper_With_NULL_Ptr_Throws() { ExperimentInfo_sptr ws = createTestInfoWithChopperPoints(1); - TS_ASSERT_THROWS(ws->setChopperModel(NULL), std::invalid_argument); + TS_ASSERT_THROWS(ws->setChopperModel(nullptr), std::invalid_argument); } void test_Setting_A_New_Chopper_To_Point_Lower_Point_Succeeds() { @@ -526,9 +526,8 @@ public: std::pair<std::unordered_multimap<std::string, fromToEntry>::iterator, std::unordered_multimap<std::string, fromToEntry>::iterator> ret; - for (auto setIt = idfIdentifiers.begin(); setIt != idfIdentifiers.end(); - setIt++) { - ret = idfFiles.equal_range(*setIt); + for (const auto &idfIdentifier : idfIdentifiers) { + ret = idfFiles.equal_range(idfIdentifier); for (it1 = ret.first; it1 != ret.second; ++it1) { for (it2 = ret.first; it2 != ret.second; ++it2) { if (it1 != it2) { @@ -729,10 +728,10 @@ public: ExperimentInfo_sptr eiNonConst; TS_ASSERT_THROWS_NOTHING( eiConst = manager.getValue<ExperimentInfo_const_sptr>(eiName)); - TS_ASSERT(eiConst != NULL); + TS_ASSERT(eiConst != nullptr); TS_ASSERT_THROWS_NOTHING(eiNonConst = manager.getValue<ExperimentInfo_sptr>(eiName)); - TS_ASSERT(eiNonConst != NULL); + TS_ASSERT(eiNonConst != nullptr); TS_ASSERT_EQUALS(eiConst, eiNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -740,9 +739,9 @@ public: ExperimentInfo_const_sptr eiCastConst; ExperimentInfo_sptr eiCastNonConst; TS_ASSERT_THROWS_NOTHING(eiCastConst = (ExperimentInfo_const_sptr)val); - TS_ASSERT(eiCastConst != NULL); + TS_ASSERT(eiCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(eiCastNonConst = (ExperimentInfo_sptr)val); - TS_ASSERT(eiCastNonConst != NULL); + TS_ASSERT(eiCastNonConst != nullptr); TS_ASSERT_EQUALS(eiCastConst, eiCastNonConst); } diff --git a/Framework/API/test/FakeAlgorithms.h b/Framework/API/test/FakeAlgorithms.h index 8c3744aa40f17c07ccf658d03c5a8741cea4e598..706ea9e8f5a2ab977e9da2634338c97731424a6e 100644 --- a/Framework/API/test/FakeAlgorithms.h +++ b/Framework/API/test/FakeAlgorithms.h @@ -23,6 +23,9 @@ public: } ///< Algorithm's category for identification const std::string alias() const override { return "Dog"; } const std::string summary() const override { return "Test summary"; } + const std::vector<std::string> seeAlso() const override { + return {"rabbit", "goldfish", "Spotted Hyena"}; + } void init() override { declareProperty("prop1", "value"); diff --git a/Framework/API/test/FunctionTest.h b/Framework/API/test/FunctionTest.h index 5fddb7db7ede1ded85bc67723df7603676bfcaf1..7b770abc57554c6061e88db687fa472238d6771e 100644 --- a/Framework/API/test/FunctionTest.h +++ b/Framework/API/test/FunctionTest.h @@ -411,10 +411,10 @@ public: IFunction_sptr funcNonConst; TS_ASSERT_THROWS_NOTHING( funcConst = manager.getValue<IFunction_const_sptr>(funcName)); - TS_ASSERT(funcConst != NULL); + TS_ASSERT(funcConst != nullptr); TS_ASSERT_THROWS_NOTHING(funcNonConst = manager.getValue<IFunction_sptr>(funcName)); - TS_ASSERT(funcNonConst != NULL); + TS_ASSERT(funcNonConst != nullptr); TS_ASSERT_EQUALS(funcConst, funcNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -422,9 +422,9 @@ public: IFunction_const_sptr funcCastConst; IFunction_sptr funcCastNonConst; TS_ASSERT_THROWS_NOTHING(funcCastConst = (IFunction_const_sptr)val); - TS_ASSERT(funcCastConst != NULL); + TS_ASSERT(funcCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(funcCastNonConst = (IFunction_sptr)val); - TS_ASSERT(funcCastNonConst != NULL); + TS_ASSERT(funcCastNonConst != nullptr); TS_ASSERT_EQUALS(funcCastConst, funcCastNonConst); } diff --git a/Framework/API/test/GroupingLoaderTest.h b/Framework/API/test/GroupingLoaderTest.h index c6aa0e50d51f0eb689f9b89a80fba6d220d48da5..4258fb1cbf2d0b1679c9d325a2e55abba787356d 100644 --- a/Framework/API/test/GroupingLoaderTest.h +++ b/Framework/API/test/GroupingLoaderTest.h @@ -25,11 +25,11 @@ public: auto dataPaths = ConfigService::Instance().getDataSearchDirs(); // Find the path of AutoTestData - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path path(*it); + for (auto &dataPath : dataPaths) { + Poco::Path path(dataPath); if (path.directory(path.depth() - 1) == "UnitTest") { - m_testDataDir = *it; + m_testDataDir = dataPath; break; } } diff --git a/Framework/API/test/IMDWorkspaceTest.h b/Framework/API/test/IMDWorkspaceTest.h index b7476124c4b20b73fc1add3603d20e1520dbac84..e8b9d8aa3e3055937968eb58d982e0d0665161e1 100644 --- a/Framework/API/test/IMDWorkspaceTest.h +++ b/Framework/API/test/IMDWorkspaceTest.h @@ -125,10 +125,10 @@ public: IMDWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<IMDWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<IMDWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -136,9 +136,9 @@ public: IMDWorkspace_const_sptr wsCastConst; IMDWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (IMDWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (IMDWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h index 5d1f3979ffd901762e948ea5a47ca148c73f9883..3a9cdaa5cbf1a2537bd0d7318361f02ada776a1b 100644 --- a/Framework/API/test/MatrixWorkspaceMDIteratorTest.h +++ b/Framework/API/test/MatrixWorkspaceMDIteratorTest.h @@ -52,8 +52,8 @@ public: void test_iterating() { boost::shared_ptr<MatrixWorkspace> ws = makeFakeWS(); - IMDIterator *it = nullptr; - TS_ASSERT_THROWS_NOTHING(it = ws->createIterator(NULL)); + std::unique_ptr<IMDIterator> it; + TS_ASSERT_THROWS_NOTHING(it = ws->createIterator(nullptr)); TS_ASSERT_EQUALS(it->getDataSize(), 20); TS_ASSERT_DELTA(it->getSignal(), 0.0, 1e-5); it->next(); @@ -83,24 +83,21 @@ public: TS_ASSERT_DELTA(it->getError(), 22.0, 1e-5); TS_ASSERT_DELTA(it->getCenter()[0], 3.0, 1e-5); TS_ASSERT_DELTA(it->getCenter()[1], 2.0, 1e-5); - delete it; } /** Create a set of iterators that can be applied in parallel */ void test_parallel_iterators() { boost::shared_ptr<MatrixWorkspace> ws = makeFakeWS(); // The number of output cannot be larger than the number of histograms - std::vector<IMDIterator *> it = ws->createIterators(10, NULL); + auto it = ws->createIterators(10, nullptr); TS_ASSERT_EQUALS(it.size(), 4); - for (size_t i = 0; i < it.size(); ++i) - delete it[i]; // Split in 4 iterators - std::vector<IMDIterator *> iterators = ws->createIterators(4, NULL); + auto iterators = ws->createIterators(4, nullptr); TS_ASSERT_EQUALS(iterators.size(), 4); for (size_t i = 0; i < iterators.size(); i++) { - IMDIterator *it = iterators[i]; + IMDIterator *it = iterators[i].get(); const double i_d = static_cast<double>(i); // Only 5 elements per each iterator TS_ASSERT_EQUALS(it->getDataSize(), 5); @@ -116,19 +113,17 @@ public: TS_ASSERT(it->next()); TS_ASSERT(it->next()); TS_ASSERT(!it->next()); - delete it; } } void test_get_is_masked() { boost::shared_ptr<MatrixWorkspace> ws = makeFakeWS(); - IMDIterator *it = ws->createIterator(NULL); + auto it = ws->createIterator(nullptr); const auto &spectrumInfo = ws->spectrumInfo(); for (size_t i = 0; i < ws->getNumberHistograms(); ++i) { TS_ASSERT_EQUALS(spectrumInfo.isMasked(i), it->getIsMasked()); it->next(); } - delete it; } void testUnequalBins() { @@ -141,11 +136,11 @@ public: TS_ASSERT_THROWS(ws->blocksize(), std::logic_error); TS_ASSERT_EQUALS(ws->size(), 17); // Split in 4 iterators - std::vector<IMDIterator *> iterators = ws->createIterators(4, nullptr); + auto iterators = ws->createIterators(4, nullptr); TS_ASSERT_EQUALS(iterators.size(), 4); for (size_t i = 0; i < iterators.size(); i++) { - IMDIterator *it = iterators[i]; + auto it = iterators[i].get(); const double i_d = static_cast<double>(i); if (i == 0) { // Only 5 elements per each iterator @@ -174,7 +169,6 @@ public: TS_ASSERT(it->next()); } TS_ASSERT(!it->next()); - delete it; } } }; diff --git a/Framework/API/test/MatrixWorkspaceTest.h b/Framework/API/test/MatrixWorkspaceTest.h index ae4ccae9b724eb02919a1b458e9505a3974c39ad..15181c2648700c1cdb313ce461372d7b897d3b18 100644 --- a/Framework/API/test/MatrixWorkspaceTest.h +++ b/Framework/API/test/MatrixWorkspaceTest.h @@ -1018,7 +1018,7 @@ public: void test_setMDMasking() { WorkspaceTester ws; TSM_ASSERT_THROWS("Characterisation test. This is not implemented.", - ws.setMDMasking(NULL), std::runtime_error); + ws.setMDMasking(nullptr), std::runtime_error); } void test_clearMDMasking() { @@ -1569,10 +1569,10 @@ public: MatrixWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<MatrixWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<MatrixWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -1580,9 +1580,9 @@ public: MatrixWorkspace_const_sptr wsCastConst; MatrixWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (MatrixWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (MatrixWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } diff --git a/Framework/API/test/MultiPeriodGroupAlgorithmTest.h b/Framework/API/test/MultiPeriodGroupAlgorithmTest.h index 6bd1b7a2ac46be60fb2eda3dd2eb79e650a5dcfb..baff00192e9550f93c063ce15346afd4c13279a6 100644 --- a/Framework/API/test/MultiPeriodGroupAlgorithmTest.h +++ b/Framework/API/test/MultiPeriodGroupAlgorithmTest.h @@ -214,7 +214,7 @@ public: WorkspaceGroup_sptr wsgroup = Mantid::API::AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( "outWS"); - TS_ASSERT(wsgroup != NULL); + TS_ASSERT(wsgroup != nullptr); TS_ASSERT_EQUALS(a->size(), wsgroup->size()); } @@ -241,7 +241,7 @@ public: WorkspaceGroup_sptr wsgroup = Mantid::API::AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( "outWS"); - TS_ASSERT(wsgroup != NULL); + TS_ASSERT(wsgroup != nullptr); TS_ASSERT_EQUALS(a->size(), wsgroup->size()); } }; diff --git a/Framework/API/test/NotebookBuilderTest.h b/Framework/API/test/NotebookBuilderTest.h index 4de0ec170fd49a35242bbae09e4f01626cd5b3c3..7ae7f7ecff6cbd89b16b409312aa4926402c03e6 100644 --- a/Framework/API/test/NotebookBuilderTest.h +++ b/Framework/API/test/NotebookBuilderTest.h @@ -211,7 +211,7 @@ public: void test_Build_Unrolled() { std::string result_markdown = - " \"source\" : \"Child algorithms of TopLevelAlgorithm\""; + R"( "source" : "Child algorithms of TopLevelAlgorithm")"; std::string result_code = " \"input\" : \"BasicAlgorithm(PropertyA='FirstOne')\","; @@ -254,7 +254,7 @@ public: void test_Partially_Unrolled() { std::string result_markdown = - " \"source\" : \"Child algorithms of TopLevelAlgorithm\""; + R"( "source" : "Child algorithms of TopLevelAlgorithm")"; std::string result_code = " \"input\" : \"BasicAlgorithm(PropertyA='FirstOne')\","; diff --git a/Framework/API/test/WorkspaceGroupTest.h b/Framework/API/test/WorkspaceGroupTest.h index b04f5dc32c96b306f906d08533fc880416da71c1..9cffbe83d9ca782a1632ce7c21f1a9ffdd0a3b3f 100644 --- a/Framework/API/test/WorkspaceGroupTest.h +++ b/Framework/API/test/WorkspaceGroupTest.h @@ -241,6 +241,17 @@ public: AnalysisDataService::Instance().clear(); } + void test_getAllItems() { + WorkspaceGroup_sptr group = makeGroup(); + auto items = group->getAllItems(); + TS_ASSERT_EQUALS(group->size(), 3); + TS_ASSERT_EQUALS(items.size(), 3); + TS_ASSERT_EQUALS(items[0], group->getItem(0)); + TS_ASSERT_EQUALS(items[1], group->getItem(1)); + TS_ASSERT_EQUALS(items[2], group->getItem(2)); + AnalysisDataService::Instance().clear(); + } + void test_deleting_workspaces() { WorkspaceGroup_sptr group = makeGroup(); TS_ASSERT(AnalysisDataService::Instance().doesExist("group")); @@ -368,10 +379,10 @@ public: WorkspaceGroup_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<WorkspaceGroup_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<WorkspaceGroup_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -379,9 +390,9 @@ public: WorkspaceGroup_const_sptr wsCastConst; WorkspaceGroup_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (WorkspaceGroup_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (WorkspaceGroup_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } @@ -400,10 +411,10 @@ public: Workspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<Workspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<Workspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -411,9 +422,9 @@ public: Workspace_const_sptr wsCastConst; Workspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (Workspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (Workspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/Algorithms/CMakeLists.txt b/Framework/Algorithms/CMakeLists.txt index 5ecfac48d9482a8f4e31436084f61b53f4eaf60c..715f5776a75d20f662f7253d5761e7d3881ed553 100644 --- a/Framework/Algorithms/CMakeLists.txt +++ b/Framework/Algorithms/CMakeLists.txt @@ -241,9 +241,7 @@ set ( SRC_FILES src/RebinToWorkspace.cpp src/Rebunch.cpp src/RecordPythonScript.cpp - src/ReflectometryReductionOne.cpp src/ReflectometryReductionOne2.cpp - src/ReflectometryReductionOneAuto.cpp src/ReflectometryReductionOneAuto2.cpp src/ReflectometryWorkflowBase.cpp src/ReflectometryWorkflowBase2.cpp @@ -578,9 +576,7 @@ set ( INC_FILES inc/MantidAlgorithms/RebinToWorkspace.h inc/MantidAlgorithms/Rebunch.h inc/MantidAlgorithms/RecordPythonScript.h - inc/MantidAlgorithms/ReflectometryReductionOne.h inc/MantidAlgorithms/ReflectometryReductionOne2.h - inc/MantidAlgorithms/ReflectometryReductionOneAuto.h inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h inc/MantidAlgorithms/ReflectometryWorkflowBase.h inc/MantidAlgorithms/ReflectometryWorkflowBase2.h @@ -917,8 +913,6 @@ set ( TEST_FILES RectangularBeamProfileTest.h ReflectometryReductionOne2Test.h ReflectometryReductionOneAuto2Test.h - ReflectometryReductionOneAutoTest.h - ReflectometryReductionOneTest.h RegroupTest.h RemoveBackgroundTest.h RemoveBinsTest.h diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddLogDerivative.h b/Framework/Algorithms/inc/MantidAlgorithms/AddLogDerivative.h index c8b36aa070b09584f11a75574c24e8353bb2f07b..f582c8c6c1b21c70d8d2868753d3ddb692a4c3e4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddLogDerivative.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddLogDerivative.h @@ -47,6 +47,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLog"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddNote.h b/Framework/Algorithms/inc/MantidAlgorithms/AddNote.h index da8a8f5d8f5793c167452bdbc7d0a3bdaa7ea162..c43944616a49e17a9fe74d6433d5e99cfb2bff6f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddNote.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddNote.h @@ -42,6 +42,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Comment"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddPeak.h b/Framework/Algorithms/inc/MantidAlgorithms/AddPeak.h index 7e93f7274f5446dcb25705a6e958acdf0532a2cc..ebf67e387d92590d308b26a398a3e6baa4578028 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddPeak.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddPeak.h @@ -43,6 +43,9 @@ public: } /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"AddPeakHKL", "CalculatePeaksHKL"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h index d9bbd4035431d0a4af7f0a4f5243f387af32dffa..651547a0d1b13b492501230c7d46031175a36f09 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddSampleLog.h @@ -57,6 +57,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLogMultiple", "AddTimeSeriesLog", "DeleteLog", "LoadLog"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AddTimeSeriesLog.h b/Framework/Algorithms/inc/MantidAlgorithms/AddTimeSeriesLog.h index 5ac9b054c3e85f217ed704fe0b399cbe278f2636..a5ab0398aedd48646ef213e247205b156df757f0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AddTimeSeriesLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AddTimeSeriesLog.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLog", "GetTimeSeriesLogInformation", "MergeLogs"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h index 6d5dd1fb37c9a8fd5a1ecf8dfae60517a5243065..5e8d7abfde3b88f2f0a8dd33ab065cd712039946 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AlignDetectors.h @@ -67,6 +67,9 @@ public: /// Algorithm's version for identification. @see Algorithm::version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"DiffractionFocussing", "AlignAndFocusPowder"}; + } /// Algorithm's category for identification. @see Algorithm::category const std::string category() const override; /// Cross-check properties with each other @see IAlgorithm::validateInputs diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AnnularRingAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/AnnularRingAbsorption.h index 8da2489d4b9fe35e61927ab61ce785dd927a38e5..63fbee31b02bc5db32ffcaa90c8428286ee7bdba 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AnnularRingAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AnnularRingAbsorption.h @@ -43,6 +43,9 @@ class DLLExport AnnularRingAbsorption : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AnyShapeAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/AnyShapeAbsorption.h index 8e387758a60503d2437da2242522f064c77aad04..358ccc766114e8b7d389235c086dfcd4b7abca9f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AnyShapeAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AnyShapeAbsorption.h @@ -88,6 +88,14 @@ public: AnyShapeAbsorption(); /// Algorithm's name const std::string name() const override { return "AbsorptionCorrection"; } + + const std::vector<std::string> seeAlso() const override { + return {"SetSampleMaterial", "CreateSampleShape", + "DefineGaugeVolume", "CylinderAbsorption", + "FlatPlateAbsorption", "AnnularRingAbsorption", + "CuboidGaugeVolumeAbsorption"}; + } + /// Summary of algorithms purpose const std::string summary() const override { return "Calculates an approximation of the attenuation due to absorption " diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AppendSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/AppendSpectra.h index 0fa090ffc8cf29425346d97bdeb52b6f9bd73c40..a69fd074bb4446ccefe64f29b86a25049acd2b4d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AppendSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AppendSpectra.h @@ -46,6 +46,9 @@ class DLLExport AppendSpectra : public WorkspaceJoiners { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConjoinSpectra"}; + } private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ApplyDeadTimeCorr.h b/Framework/Algorithms/inc/MantidAlgorithms/ApplyDeadTimeCorr.h index 92565b4245ccb79dab76a5d92b0a409f560aadf8..d5ab58b031d0b0acbc80ce46f94b3d15c30fcdcb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ApplyDeadTimeCorr.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ApplyDeadTimeCorr.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CalMuonDeadTime"}; + } /// Algorithm's category for identification const std::string category() const override { return "Muon;CorrectionFunctions\\EfficiencyCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ApplyTransmissionCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/ApplyTransmissionCorrection.h index 0e72040355f20b22cd4fb4dfec83e8c5c867383f..8de12765a49ff9b324d9a258e8f72b82a9681e15 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ApplyTransmissionCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ApplyTransmissionCorrection.h @@ -55,6 +55,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CalculateTransmission", "CalculateTransmissionBeamSpreader"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS;CorrectionFunctions\\TransmissionCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/AsymmetryCalc.h b/Framework/Algorithms/inc/MantidAlgorithms/AsymmetryCalc.h index 66d57249ef52277cd27220bafac69e5c709f66a7..753103dba02176380d1662e1d318e7d55386de30 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/AsymmetryCalc.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/AsymmetryCalc.h @@ -61,6 +61,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CalculateMuonAsymmetry"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h index 5ce3d96a863ea66b1de46d70cbe86b16b14cb16b..86a6004356e20972c6ebe031703c52cf49b1d0b3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Bin2DPowderDiffraction.h @@ -40,6 +40,9 @@ class MANTID_ALGORITHMS_DLL Bin2DPowderDiffraction : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Rebin2D"}; + } const std::string category() const override; const std::string summary() const override; /// Cross-check properties with each other @see IAlgorithm::validateInputs diff --git a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperateMasks.h b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperateMasks.h index 812134927adde97d30329ebe61e199c59ffa041b..67d854720a0c7e49d205142a547ba6e585d28606 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperateMasks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/BinaryOperateMasks.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"InvertMask"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalMuonDeadTime.h b/Framework/Algorithms/inc/MantidAlgorithms/CalMuonDeadTime.h index 32cfe9bfe32fdaf1cb0fc97fe040f99526042646..b69e9cb25e1e29f9c4a080923be0f7b9b8bfc5bd 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalMuonDeadTime.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalMuonDeadTime.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ApplyDeadTimeCorr"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h index 0c6a6270046151f56a61891836b4a31d41a1521a..f0a7e0990b59bcd5e1be5486e20815624bf8bbfd 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateCountRate.h @@ -47,6 +47,9 @@ class DLLExport CalculateCountRate : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ChangePulsetime"}; + } const std::string category() const override; const std::string summary() const override; /// Helper function: true if count rate should be normalized and false diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDIFC.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDIFC.h index 257cce3dfbfeb9a3902d5070fd1ec04aa2dfeaac..155ac49fbaeb558c3e8d5990c9faebe5ca0061d4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateDIFC.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateDIFC.h @@ -38,6 +38,9 @@ public: const std::string name() const override; /// Algorithm's version for identification. @see Algorithm::version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertDiffCal"}; + } const std::string category() const override; /// Algorithm's summary for use in the GUI and help. @see Algorithm::summary const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateMuonAsymmetry.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateMuonAsymmetry.h index 8945063171207f13bec4ba99e5bb5e2d6c9488d6..86c75f949426c50e72b3566871f9ad96a0527c4c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateMuonAsymmetry.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateMuonAsymmetry.h @@ -70,6 +70,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"AsymmetryCalc"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculatePolynomialBackground.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculatePolynomialBackground.h index f5b5ebf757d71358a161a6d93e69031c6ba33ff1..40c82fc53e6a1425bcec5e5eeef2ed33bb9c00fb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculatePolynomialBackground.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculatePolynomialBackground.h @@ -37,6 +37,9 @@ class MANTID_ALGORITHMS_DLL CalculatePolynomialBackground public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RemoveBackground", "CreateUserDefinedBackground"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateSlits.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateSlits.h index f4654b9b73521c63128283a49bfae837c8a61858..7482d0f0294f4aca0714df98226b98cd88694a0f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateSlits.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateSlits.h @@ -40,6 +40,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"NRCalculateSlitResolution"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h index 803747c9ca562babc5b6e91f3029a169c5ed2a60..a29fd88d5ea5f33dc4a64da992932e18cb24e43b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmission.h @@ -76,6 +76,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CalculateTransmissionBeamSpreader", "ApplyTransmissionCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS;CorrectionFunctions\\TransmissionCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h index 58f4637c9a08493c2fdc3acf147433c27ce2d35d..919bc42fb6d77c2cb4f094194652c3365e0e7efc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CalculateTransmissionBeamSpreader.h @@ -85,6 +85,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CalculateTransmission", "ApplyTransmissionCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS;CorrectionFunctions\\TransmissionCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangeBinOffset.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangeBinOffset.h index c9f8d162a279f6eb480492feae001fc866f190dd..60e7c39ce6ac1f282d56eb936b13badf720dd378 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangeBinOffset.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangeBinOffset.h @@ -51,6 +51,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"ScaleX"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Axes"; } /// Algorithm's Alternate Name diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangeLogTime.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangeLogTime.h index 3fbcf270422f8b233d64176fc6c959cc2c002f95..4e0d49695fd47b59348f6d419886b7e7bd0c0152 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangeLogTime.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangeLogTime.h @@ -10,6 +10,9 @@ class DLLExport ChangeLogTime : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateLogTimeCorrection", "ChangePulsetime", "ShiftLogTime"}; + } const std::string category() const override; /// Algorithm's summary const std::string summary() const override { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChangePulsetime.h b/Framework/Algorithms/inc/MantidAlgorithms/ChangePulsetime.h index 0b0e66481946e0e204b1bc26956669be10199028..55cbc9c2fbfbbb78f1913c93158c5b1031a36609 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChangePulsetime.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChangePulsetime.h @@ -24,6 +24,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CreateLogTimeCorrection", "CalculateCountRate"}; + } /// Algorithm's category for identification const std::string category() const override { return "Events;Transforms\\Axes"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CheckWorkspacesMatch.h b/Framework/Algorithms/inc/MantidAlgorithms/CheckWorkspacesMatch.h index 6a8b8a95df0ce2e34954b287e76f0b74dc470278..8a53f4d604ddba775fe55ab9ce8c0b7522c73ea3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CheckWorkspacesMatch.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CheckWorkspacesMatch.h @@ -87,6 +87,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CompareWorkspaces"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ChopData.h b/Framework/Algorithms/inc/MantidAlgorithms/ChopData.h index 290523641391b8d74ed4650deffb4f5c2c9c841e..37a04194b3db0fa4ce081732f7f0e3f0775dc674 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ChopData.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ChopData.h @@ -44,8 +44,13 @@ public: return "Transforms\\Splitting"; } ///< @return the algorithms category int version() const override { + return (1); } ///< @return version number of algorithm + + const std::vector<std::string> seeAlso() const override { + return {"ExtractSpectra"}; + } /// Algorithm's summary const std::string summary() const override { return "Splits an input workspace into a grouped workspace, where each " diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ClearCache.h b/Framework/Algorithms/inc/MantidAlgorithms/ClearCache.h index c6487ce37ce1bbdb2056feac8390029108401c21..c18ef3f0588a2e824b4c7c86b71bf61a4f00845f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ClearCache.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ClearCache.h @@ -33,6 +33,9 @@ class MANTID_ALGORITHMS_DLL ClearCache final : public API::Algorithm { public: const std::string name() const override final; int version() const override final; + const std::vector<std::string> seeAlso() const override { + return {"CleanFileCache"}; + } const std::string category() const override final; const std::string summary() const override final; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ClearInstrumentParameters.h b/Framework/Algorithms/inc/MantidAlgorithms/ClearInstrumentParameters.h index b39849874d698a9fc4e89bb8ee5ac8cd664786a8..d24d9dd115be8e5dbe1417443c611f1e278fb803 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ClearInstrumentParameters.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ClearInstrumentParameters.h @@ -40,6 +40,9 @@ public: const std::string summary() const override; const std::string category() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CopyInstrumentParameters"}; + } private: void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskFlag.h b/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskFlag.h index 99eb3d1fb125b485d7c45aef974d596d27e8b90e..d50afc77ffae7a1cb9212ab1ce34e8d40fd236b8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskFlag.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskFlag.h @@ -34,6 +34,9 @@ class DLLExport ClearMaskFlag : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors"}; + } const std::string category() const override; /// Algorithm's summary const std::string summary() const override { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskedSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskedSpectra.h index fa27e65da2241cd37e2829ac752ddadb2cd43e28..95dd39b1fb7406006a159466524050fd8960a77e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskedSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ClearMaskedSpectra.h @@ -40,6 +40,9 @@ class MANTID_ALGORITHMS_DLL ClearMaskedSpectra public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors", "MaskInstrument"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CloneWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CloneWorkspace.h index d22e997dd59359ed7faecf90ec1a62eb4bf0504a..3152a123de2825f876e7014cf185b2755488c14b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CloneWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CloneWorkspace.h @@ -51,6 +51,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CompareWorkspaces"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Comment.h b/Framework/Algorithms/inc/MantidAlgorithms/Comment.h index 6db408913c375d7497e58e41431b4180075ab000..d8e7bb888d3ed5a597b351bc6a7a11cba97fae65 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Comment.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Comment.h @@ -33,6 +33,9 @@ class DLLExport Comment : public API::DistributedAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RemoveWorkspaceHistory"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h index 88b4ec69a721b78b49cb1bca33d67ba1e1acd7f8..dd7b806f982572a5941fb1febd33ac7a272dd0be 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CompareWorkspaces.h @@ -76,6 +76,9 @@ public: /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CheckWorkspacesMatch", "CompareSampleLogs", "CloneWorkspace"}; + } /// Algorithm's category for identification. @see Algorithm::category const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinWorkspaces.h index ff4dfcc488bb339bae0eca58993833cd1ab813aa..ac635cd6b76ed5d1b1ca9d740d61cd4b43f97033 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConjoinWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConjoinWorkspaces.h @@ -64,6 +64,9 @@ public: const std::string name() const override { return "ConjoinWorkspaces"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ConjoinSpectra", "ConjoinXRuns", "MergeRuns"}; + } private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxesToRealSpace.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxesToRealSpace.h index 082160564d16f3e5f29dcf1aa7927a6f8248b697..87f2f1774bc610813ccd143d2c8133e640902837 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxesToRealSpace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxesToRealSpace.h @@ -39,6 +39,9 @@ class DLLExport ConvertAxesToRealSpace : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertSpectrumAxis", "ConvertUnits"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxisByFormula.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxisByFormula.h index ada468038c9f62ff5016d25db915f3856f93053b..b60657819969531f1fc58fe87fe57e14acc89155 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxisByFormula.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertAxisByFormula.h @@ -51,6 +51,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertUnits"}; + } const std::string category() const override; protected: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertDiffCal.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertDiffCal.h index 9efc415141be4b49c3b8547f75c5223e07820d8e..3244c5f8c1b3cb77648612c241b62b2b89828c6c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertDiffCal.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertDiffCal.h @@ -33,6 +33,9 @@ class DLLExport ConvertDiffCal : public API::ParallelAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalculateDIFC"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertFromDistribution.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertFromDistribution.h index 19bfe10f0f90261a62fd1564db9dc96360a89cab..77212c5bdb6f08d6fead74609fed98ce5ef81260 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertFromDistribution.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertFromDistribution.h @@ -51,6 +51,9 @@ public: } /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToDistribution"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Distribution"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis2.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis2.h index b104840265ffd0444140bc4e3e149c1a3b57b010..2184cbfa9420a3c9a7fc7f1a7c939bc5e070e337 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertSpectrumAxis2.h @@ -61,6 +61,9 @@ public: /// Algorithm's version int version() const override { return (2); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertAxesToRealSpace", "ConvertUnits"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Units;Transforms\\Axes"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertTableToMatrixWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertTableToMatrixWorkspace.h index 1d2071bff6c690ff6f7278892bfd342a4dea0d64..96b38bf7aa85300b852551c8f623a633975761c2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertTableToMatrixWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertTableToMatrixWorkspace.h @@ -59,6 +59,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertMDHistoToMatrixWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h index bc00562a1017bfc3d6d384f1e9e2ffdf1473d87b..115e0ee62a74b2c6fa97bb3ca0af2768b758623d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToConstantL2.h @@ -53,6 +53,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CorrectTOFAxis"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Inelastic\\Corrections;CorrectionFunctions\\InstrumentCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToDistribution.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToDistribution.h index 1a73ad98da0e1c47691ea5afdefb871b1c58f503..dc2d624acc14fe17f3b92e5af7c6498401d09e3d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToDistribution.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToDistribution.h @@ -50,6 +50,9 @@ public: } /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertFromDistribution"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Distribution"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToEventWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToEventWorkspace.h index 002d9a88f3458c7e9ef0c8d2423121ca84dc3a81..25fc51d41746eb1f39a3f12903c9b4f8904ef180 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToEventWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToEventWorkspace.h @@ -47,6 +47,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMatrixWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "Events"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToHistogram.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToHistogram.h index 762f8298b577c9a06930351f268f0ea7e7ddd0ff..54a0e7c764948939d8b441d088f86221e3d4890f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToHistogram.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToHistogram.h @@ -46,7 +46,9 @@ public: return "Converts a workspace containing point data into one containing " "histograms."; } - + const std::vector<std::string> seeAlso() const override { + return {"ConvertToPointData"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Axes"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToMatrixWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToMatrixWorkspace.h index b54ea719a056ab866beb37df3c5f519b46888f47..b678284d18aa43cb0e83664f24f32554fffe4124 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToMatrixWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToMatrixWorkspace.h @@ -55,6 +55,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToEventWorkspace", "Rebin"}; + } /// Algorithm's category for identification const std::string category() const override { return "Events"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToPointData.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToPointData.h index ad628c2de7a59a68778ea2814b7599ba6b65b955..052d24418f4dd1555aa43df57117096b64cd52e4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertToPointData.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertToPointData.h @@ -46,7 +46,9 @@ public: return "Converts a workspace containing histogram data into one containing " "point data."; } - + const std::vector<std::string> seeAlso() const override { + return {"ConvertToHistogram"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Axes"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h index 17b12f37a7c0fd720ce38d0adf29c2676b61c32b..9d856b2453fdecd1ca88473ac6f57dc3882f5738 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ConvertUnits.h @@ -75,6 +75,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ConvertAxisByFormula", "ConvertAxesToRealSpace", + "ConvertSpectrumAxis", "ConvertToYSpace"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Units"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CopyDetectorMapping.h b/Framework/Algorithms/inc/MantidAlgorithms/CopyDetectorMapping.h index 9dd9c12630537fbdbe80c27e512708491e1e4e25..d162e7172f1805bb79918fd3b44d988220fba2d1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CopyDetectorMapping.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CopyDetectorMapping.h @@ -48,6 +48,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CopyLogs"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CopyInstrumentParameters.h b/Framework/Algorithms/inc/MantidAlgorithms/CopyInstrumentParameters.h index 5740e3cae41ea0a185d546a855f46748172558e0..56a41ccf8a8a04af4abb1598dea9b4fec65041a7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CopyInstrumentParameters.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CopyInstrumentParameters.h @@ -67,6 +67,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ClearInstrumentParameters"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CopyLogs.h b/Framework/Algorithms/inc/MantidAlgorithms/CopyLogs.h index 9ac0cda49912afd79fa61048eb6f2dc9a1144cba..0bdae1199d34e136b0fb2c546ded484fdf366971 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CopyLogs.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CopyLogs.h @@ -51,6 +51,10 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateLogPropertyTable", "CopyDetectorMapping", + "CheckForSampleLogs", "CopySample"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CopySample.h b/Framework/Algorithms/inc/MantidAlgorithms/CopySample.h index 0fd33a490570e6d4db633771b8270fc9e951588d..8b2a8cdfd4ceaa2f15dc946110174fdd58f9777a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CopySample.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CopySample.h @@ -57,6 +57,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CompareSampleLogs", "CopyLogs", "CheckForSampleLogs"}; + } /// Algorithm's category for identification const std::string category() const override { return "Sample;Utility\\Workspaces"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h index 1c0ebc3900a32fcc0c2f372c3f5f91700a6e8302..53d13250b5cbaede15a2aae3ee2ff080e8c024bb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CorrectTOFAxis.h @@ -43,6 +43,9 @@ class MANTID_ALGORITHMS_DLL CorrectTOFAxis : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToConstantL2"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h index 72d23586f7a857c9dd57c0f34edb9f71170660cc..2a6b275cbb34c7ceb56b54ec493b26fc04d1e260 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateCalFileByNames.h @@ -73,6 +73,11 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ReadGroupsFromFile", "CreateDummyCalFile", "AlignDetectors", + "DiffractionFocussing", "LoadCalFile", "SaveCalFile", + "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling\\CalFiles"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h index 819b5a10844783e2b88af6c3120e917ec0044302..6b85d2588603c831ad8f507350e8fe78197a1a3d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateDummyCalFile.h @@ -72,6 +72,11 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ReadGroupsFromFile", "CreateCalFileByNames", "AlignDetectors", + "DiffractionFocussing", "LoadCalFile", "SaveCalFile", + "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling\\CalFiles"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateEPP.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateEPP.h index 7c8303357864322e7688f356067e181b641fb8b5..defb4365f0d401199088d6c8dd3a7908a92fb413 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateEPP.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateEPP.h @@ -36,6 +36,9 @@ class MANTID_ALGORITHMS_DLL CreateEPP : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FindEPP"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateGroupingWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateGroupingWorkspace.h index 3114ba65dc9e1807839efe7ab7f53692710b64a3..3ea99f0c802613edfe9e3735d08c9232a6a1130a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateGroupingWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateGroupingWorkspace.h @@ -27,6 +27,9 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"DiffractionFocussing", "LoadCalFile"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogPropertyTable.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogPropertyTable.h index 9e1b2ab1af49b2e732d541fc2fd7ac53cf5348ae..aa1126df4a5c04bb8d5f2d924ab3a96e05d0d335 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogPropertyTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogPropertyTable.h @@ -40,6 +40,9 @@ public: const std::string name() const override { return "CreateLogPropertyTable"; }; /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CopyLogs"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h index a854f532299e4b25c48d494510855cdf909e37a5..69b99c16991f186b6fef18453b589400417e35c0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateLogTimeCorrection.h @@ -54,6 +54,9 @@ public: } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ChangePulsetime", "ShiftLogTime"}; + } const std::string category() const override { return "Events\\EventFiltering"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h index 05a492c96117909428bebbee9de939962af8a97a..1b77bb1653b388237d7ef5b3af94641e89110292 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreatePSDBleedMask.h @@ -57,7 +57,9 @@ public: return "Runs a diagnostic test for saturation of PSD tubes and creates a " "MaskWorkspace marking the failed tube spectra."; } - + const std::vector<std::string> seeAlso() const override { + return {"IdentifyNoisyDetectors"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreatePeaksWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreatePeaksWorkspace.h index c89ea8575bb787006aedc1ac3dd6ff1e48441023..b82ffbe83ab095d0847d2895c903c4edea9b7587 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreatePeaksWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreatePeaksWorkspace.h @@ -23,6 +23,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SortPeaksWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks;Utility\\Workspaces"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h index 097365525c3fca27085ceddb2f081be04890a088..c6af3b525d9b6bd70d4fce979de05bd5f6c097f9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateSampleWorkspace.h @@ -43,6 +43,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateWorkspace"}; + } const std::string category() const override; /// Algorithm's summary const std::string summary() const override { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateSingleValuedWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateSingleValuedWorkspace.h index 6f12e8453a57d28a3c54df065907b76b6e9d4a31..177f8fcab211cefe2b8c2b6b209756c9df6346b6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateSingleValuedWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateSingleValuedWorkspace.h @@ -53,6 +53,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CreateWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h index 03d9025360afc8c886d55c8c92622e2e7d02463d..c366d823bd5982c0dce231d20aefd351116f5cf9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspace2.h @@ -36,6 +36,9 @@ public: const std::string name() const override; const std::string summary() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateTransmissionWorkspaceAuto"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto2.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto2.h index d70bbe6c2c9e0ff7685909718dd32e46e98c3f78..ce18cd219a09f6397ccc603af4f8a5e68b447fe8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateTransmissionWorkspaceAuto2.h @@ -40,6 +40,9 @@ public: } /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"CreateTransmissionWorkspace"}; + } /// Algorithm's category for identification. @see Algorithm::category const std::string category() const override { return "Reflectometry\\ISIS"; } /// Algorithm's summary for documentation diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateUserDefinedBackground.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateUserDefinedBackground.h index 1c23eefb9575c3965b1cc8c99a103f5e748adee0..d69dce914417d3e51dd157228ba5a91fd56b3d39 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateUserDefinedBackground.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateUserDefinedBackground.h @@ -44,6 +44,9 @@ public: const std::string name() const override; /// Version number int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RemoveBackground", "CalculatePolynomialBackground"}; + } /// Category algorithm belongs to const std::string category() const override; /// Description of algorithm diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CreateWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CreateWorkspace.h index 7e4f3c1169f436be53ef6277993e75e07a420504..fba8eb347f2bf2cfe35d6adb192df9ff02416858 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CreateWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CreateWorkspace.h @@ -9,7 +9,7 @@ namespace Algorithms { * CreateWorkspace Algorithm * * This algorithm constructs a MatrixWorkspace when passed a vector for each of -*the X, Y, and E +*the X, Y, E, and Dx * data values. The unit for the X Axis can optionally be specified as any of *the units in the * Kernel's UnitFactory. @@ -65,6 +65,9 @@ public: return (1); } ///< @return version number of algorithm + const std::vector<std::string> seeAlso() const override { + return {"CreateSingleValuedWorkspace", "CreateSampleWorkspace"}; + } std::map<std::string, std::string> validateInputs() override; protected: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CropToComponent.h b/Framework/Algorithms/inc/MantidAlgorithms/CropToComponent.h index d847fa91c390f3628483bdbc7f883fe77771a368..330848923dfc58d9e8ea33be43548e240d2840b4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CropToComponent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CropToComponent.h @@ -35,6 +35,9 @@ class MANTID_ALGORITHMS_DLL CropToComponent final public: const std::string name() const override final; int version() const override final; + const std::vector<std::string> seeAlso() const override { + return {"CropWorkspace"}; + } const std::string category() const override final; const std::string summary() const override final; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CropWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/CropWorkspace.h index f4917f1b15db944956c8f01f73982562ed29c6e6..cec199a358a3f63c65354548feabae165f7af150 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CropWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CropWorkspace.h @@ -75,6 +75,10 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CropWorkspaceRagged", "CropToComponent", "RemoveBins", + "ExtractSingleSpectrum", "ExtractSpectra"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Splitting"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CrossCorrelate.h b/Framework/Algorithms/inc/MantidAlgorithms/CrossCorrelate.h index 199d1651a759dcb73bf0cbe6840f4192d311ddfb..64a710667f309cdcf8e597444ed2927f990eb8ad 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CrossCorrelate.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CrossCorrelate.h @@ -72,6 +72,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"GetDetectorOffsets"}; + } /// Algorithm's category for identification const std::string category() const override { return "Arithmetic"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CuboidGaugeVolumeAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/CuboidGaugeVolumeAbsorption.h index 9496e24b5dbe25bcd9333a8403a780ba8a0a5233..a9eaaa3fe70d980c72fefe5f27f1213d680fb0e8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CuboidGaugeVolumeAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CuboidGaugeVolumeAbsorption.h @@ -57,6 +57,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } private: std::string sampleXML() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/CylinderAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/CylinderAbsorption.h index 3f6a68b2fcfd42f5e7998da53a7b08c2ddc1d8c9..002d5d2ca357fce25d7fc17edf3750ae09ee8705 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/CylinderAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/CylinderAbsorption.h @@ -100,6 +100,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } private: void defineProperties() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DeleteLog.h b/Framework/Algorithms/inc/MantidAlgorithms/DeleteLog.h index 12c5a0dedef05d34d7505a61e6dd4874790659fe..35bf4200a4eaf21f6777155285b994366e56cffa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DeleteLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DeleteLog.h @@ -37,6 +37,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLog", "RenameLog"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspace.h index 045f2df92cbd500891068a2589dfe8a70fff2797..406e0a2c29bb16c7b8b73d8b600ef9990a6a2dde 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspace.h @@ -47,6 +47,9 @@ public: const std::string category() const override { return "Utility\\Workspaces"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"DeleteWorkspaces"}; + } private: /// Overridden init diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspaces.h index 5fb03e7629060c25327a550019f952636d83ece2..af374634491729601114dc224d3f7d978a1608ef 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DeleteWorkspaces.h @@ -48,6 +48,9 @@ public: const std::string category() const override { return "Utility\\Workspaces"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"DeleteWorkspace"}; + } private: /// Overridden init diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h index 6c25619a6d391ca6835f0aba7ba2e216cda25ad9..8f8d42bebc65ec80921043a687142d54fdec165a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorDiagnostic.h @@ -59,6 +59,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FindDetectorsOutsideLimits", "FindDeadDetectors", + "MedianDetectorTest", "DetectorEfficiencyVariation"}; + } private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCor.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCor.h index 473265ec925b9b3141b8099a11f484b9e0215901..de8a1a4827be8274e7842bef989f5c8ae26f5f17 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCor.h @@ -97,6 +97,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"He3TubeEfficiency", "DetectorEfficiencyCorUser"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\EfficiencyCorrections;Inelastic\\Corrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCorUser.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCorUser.h index d37642568e5bcd836788de722336507fc0aa11a9..875e336428328fc7cf3fef125cb46ed9bfb2148c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCorUser.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyCorUser.h @@ -62,6 +62,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"DetectorEfficiencyCor"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h index ea4732a42848d1f62f61853b9f7e1c3866232119..cb57fadb7dfe44b91c47754755a52c51d0263370 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DetectorEfficiencyVariation.h @@ -73,6 +73,9 @@ public: const std::string category() const override; /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"DetectorDiagnostic"}; + } protected: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h index 2f574ba31e8dec2f3c8b1e2016970ff2389e5b93..f6df300325a8bcc93a37c93a367db419e6997704 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionEventCalibrateDetectors.h @@ -53,6 +53,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"AlignComponents", "GetDetOffsetsMultiPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Calibration;" diff --git a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h index bc4b37726ca0bc21abade33c8642590cf3004975..93be5a461032abbee24bffbfa8ec4982abd07504 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/DiffractionFocussing2.h @@ -90,6 +90,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"AlignDetectors", "AlignAndFocusPowder", "LoadCalFile"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Focussing"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Divide.h b/Framework/Algorithms/inc/MantidAlgorithms/Divide.h index eec9111b43acb9165aa489f1febaa71a1636ce1f..58ed5e56097ccf1e4bfca2cfb1416f4ee08dc6bc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Divide.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Divide.h @@ -56,6 +56,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Plus", "Minus", "Multiply"}; + } private: void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSResolution.h b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSResolution.h index 8eca5028f2c1abb2d994679901b58ee22376e44f..b4a839b7704ea5cbdf8cfa6238ffd30585cf1ffa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EQSANSResolution.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EQSANSResolution.h @@ -44,6 +44,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ReactorSANSResolution"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ElasticWindow.h b/Framework/Algorithms/inc/MantidAlgorithms/ElasticWindow.h index 8db8dcae7ecea95bdee1115f0a6ea5b817566719..d7d1ee0e14e3b844d2f331f99e3061bf04f0b542 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ElasticWindow.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ElasticWindow.h @@ -50,6 +50,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Integration"}; + } /// Algorithm's category for identification const std::string category() const override { return "Inelastic\\Indirect"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EstimateDivergence.h b/Framework/Algorithms/inc/MantidAlgorithms/EstimateDivergence.h index b6f1f75ddcedbdb58771a6d5c9f1744304ceedc4..d8ca4d92550e4bbeee653c9cda2d4d73e7eb4ca3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EstimateDivergence.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EstimateDivergence.h @@ -35,6 +35,9 @@ class MANTID_ALGORITHMS_DLL EstimateDivergence : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"EstimateResolutionDiffraction"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/EstimateResolutionDiffraction.h b/Framework/Algorithms/inc/MantidAlgorithms/EstimateResolutionDiffraction.h index ce8ec2d8d919f0416bd0ef6c475c28b96be0e532..dca712bdd1c95eceee2a312403d2355ee3536b87 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/EstimateResolutionDiffraction.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/EstimateResolutionDiffraction.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"EstimateDivergence"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Exponential.h b/Framework/Algorithms/inc/MantidAlgorithms/Exponential.h index 784a465f25696fcc8d45fc79622e7520f2c24d1c..f68b314d3527c11278bfca92b8c9b4b52615bfed 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Exponential.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Exponential.h @@ -58,6 +58,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Power", "Logarithm"}; + } private: // Overridden UnaryOperation methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExponentialCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/ExponentialCorrection.h index d0471988b87cd7edb8ccfbf0ab44adc767615d34..426525e90b60fe0d434ccba5a951ff3d8ccdad0b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExponentialCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExponentialCorrection.h @@ -65,6 +65,10 @@ public: } /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"MagFormFactorCorrection", "PowerLawCorrection", + "OneMinusExponentialCor", "PolynomialCorrection"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h index eb102b7b5e10c0fa2c8a0a16e2c1b4254e6d4d74..3c08034cfc17018f5cab197d078ce7bd9a1d46da 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExportTimeSeriesLog.h @@ -41,6 +41,9 @@ public: const std::string name() const override { return "ExportTimeSeriesLog"; }; int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"GetTimeSeriesLogInformation"}; + } const std::string category() const override { return "Diffraction\\DataHandling;Events\\EventFiltering"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractFFTSpectrum.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractFFTSpectrum.h index 03273d2ac66807e3ef4a45a96fc9b4e0620db168..f2c655866554c50e28a389ade2763d35a5fc9b00 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractFFTSpectrum.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractFFTSpectrum.h @@ -55,6 +55,10 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FFT", "FFTDerivative", "MaxEnt", + "RealFFT", "SassenaFFT", "FFTSmooth"}; + } /// Algorithm's category for identification const std::string category() const override { return "Arithmetic\\FFT"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMask.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMask.h index 1395599033b26dce0b15867f0d2bd38e075d45e9..db6ed184f7cb74531b96fd1ebb85d14b6b8261e8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMask.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMask.h @@ -56,6 +56,9 @@ public: /// Algorithm's version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ExtractMaskToTable"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h index a2da267a776c2492fd65a0a0e8ea990409f9a4cf..a1b87289f1d9f77a6a740ddef66bcc5a0c01bf65 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractMaskToTable.h @@ -46,6 +46,9 @@ public: /// Algorithm's version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ExtractMask"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractSingleSpectrum.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractSingleSpectrum.h index 298ca2bf47705f6bd356f9d3fad5c5fb2f195240..2ef1ec068764c442453bbfc084126c03ae52c41b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractSingleSpectrum.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractSingleSpectrum.h @@ -52,6 +52,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CropWorkspace", "ExtractSpectra", "PerformIndexOperations"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Splitting"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractSpectra.h index 39bf1d6753d15bdab7612b2dcafe362b2f2ea386..e34b54c0b0685ef518c5d8fd6a916c2d872f19f6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractSpectra.h @@ -37,6 +37,10 @@ class DLLExport ExtractSpectra : public API::DistributedAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CropWorkspace", "ExtractSingleSpectrum", "ExtractUnmaskedSpectra", + "PerformIndexOperations"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ExtractUnmaskedSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/ExtractUnmaskedSpectra.h index ca372477cfadb1e9bacaa585660d33e5df6ccb95..1b52e0c51b17887ffe8436180ad29430e65c4afe 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ExtractUnmaskedSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ExtractUnmaskedSpectra.h @@ -34,6 +34,9 @@ class MANTID_ALGORITHMS_DLL ExtractUnmaskedSpectra : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RemoveMaskedSpectra"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FFT.h b/Framework/Algorithms/inc/MantidAlgorithms/FFT.h index 072ce8cdd3ab980fe77fff6e8c7e4c5c0aa58dc6..82f6aedf00c51173c515e26a6154fedc9a4be81f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FFT.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FFT.h @@ -60,6 +60,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ExtractFFTSpectrum", "FFTDerivative", "MaxEnt", "RealFFT", + "SassenaFFT", "FFTSmooth"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic\\FFT"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FFTDerivative.h b/Framework/Algorithms/inc/MantidAlgorithms/FFTDerivative.h index 00b88117866498d833085b87f0cf90c87ee74148..6f5b3c06070b816bc41839313f8ef2c64b31ecb2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FFTDerivative.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FFTDerivative.h @@ -53,6 +53,10 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ExtractFFTSpectrum", "FFT", "MaxEnt", "RealFFT", "SassenaFFT", + "FFTSmooth"}; + } /// Algorithm's category for identification const std::string category() const override { return "Arithmetic\\FFT"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FFTSmooth2.h b/Framework/Algorithms/inc/MantidAlgorithms/FFTSmooth2.h index 5706a7006eb243e93b7ee7df0b61b4646c86b22f..2fc57c42ca5ab3efb508dcabb7bd46d9c1719d2b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FFTSmooth2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FFTSmooth2.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"FFT", "WienerSmooth"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic\\FFT;Transforms\\Smoothing"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterBadPulses.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterBadPulses.h index c57eab8d1130f311f8c863d0a03b048c26c67092..a2344de1000c29cece3077291443f93838df89da 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterBadPulses.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterBadPulses.h @@ -56,6 +56,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FilterByTime", "FilterByLogValue"}; + } const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterByLogValue.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterByLogValue.h index 0e9eb5773cee83b4d2ccdf38b5ae7635a8245cc1..adae9416d81ebec063b9cee2a9281b238cb137a7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterByLogValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterByLogValue.h @@ -42,6 +42,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"FilterByXValue", "FilterEvents", "FilterLogByTime", + "FilterBadPulses", "FilterByTime"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events\\EventFiltering"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime.h index 8bd8398a9e1dcefa106277551c8057e008ab5f1e..9177dd53f8d4c685ab8b9e78b6d661d6aaff7dcc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterByTime.h @@ -49,6 +49,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadEventNexus", "FilterByXValue", "FilterEvents", + "FilterLogByTime", "FilterBadPulses"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events\\EventFiltering"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterByXValue.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterByXValue.h index 95e703d2c46fb9526fd66281490d956679c4fdf1..73648a3f59d6bc14ea47438e336a8a3f9a9883b6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterByXValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterByXValue.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FilterByTime", "FilterByLogValue", "FilterBadPulses"}; + } const std::string category() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h index f7cb0a4ee73de572529e2750786c89e2dbb5fcc9..08d166fdcaaae2a30017c8c010d840308cf54071 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FilterEvents.h @@ -67,6 +67,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"GenerateEventsFilter", "FilterByTime", "FilterByLogValue"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindCenterOfMassPosition2.h b/Framework/Algorithms/inc/MantidAlgorithms/FindCenterOfMassPosition2.h index a1cd8654046a9fbac7b1ac67adedd599fbcd543f..f5893103918f5e05ce15bce4d93bfe82df6c9f46 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindCenterOfMassPosition2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindCenterOfMassPosition2.h @@ -50,6 +50,7 @@ public: /// Algorithm's version int version() const override { return (2); } + /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindDeadDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/FindDeadDetectors.h index 9581d8fd6d84ada45dbce3ec9788f9da18fe51f3..cfbbd00da511d56ee99ca75cb3002d88dd65c7c2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindDeadDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindDeadDetectors.h @@ -75,6 +75,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FindDetectorsOutsideLimits", "DetectorDiagnostic"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diagnostics"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindDetectorsOutsideLimits.h b/Framework/Algorithms/inc/MantidAlgorithms/FindDetectorsOutsideLimits.h index aaca7555e042c8af83ada6b50759a2accd66174d..ffe28acd94d40804b52ecb999fb10a1b8b199cb9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindDetectorsOutsideLimits.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindDetectorsOutsideLimits.h @@ -79,6 +79,9 @@ public: const std::string category() const override; /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FindDeadDetectors", "DetectorDiagnostic"}; + } private: /// Overridden init diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindPeakBackground.h b/Framework/Algorithms/inc/MantidAlgorithms/FindPeakBackground.h index d2737dc9b9912c4300da78081506f77d8a2f595b..a7ce1365d6c2ea6da1edf4ad43b962c9158437d0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindPeakBackground.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindPeakBackground.h @@ -49,6 +49,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Utility\\Calculation"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h index 7cdaf8d08bb3ac3487f964e3a49bd302c51e002b..3a5aeafd2926662ced520b98f7ddc35ec9415006 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FindPeaks.h @@ -78,6 +78,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"MatchPeaks", "FindPeaksMD", "GeneratePeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Optimization\\PeakFinding"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h index f89d0d207afd0ad63543b6d6180f196d18b35bd4..abb09b22a1de96badcd49aa2c62674da09c5b811 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FitPeak.h @@ -80,6 +80,7 @@ private: /// Version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } /// Init void init() override; /// Exec diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FixGSASInstrumentFile.h b/Framework/Algorithms/inc/MantidAlgorithms/FixGSASInstrumentFile.h index 7376307abd1519d0c6b6ff150636fab8b7fda685..7743225df33a2726ace2f0bff280cbd92a3aff5e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FixGSASInstrumentFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FixGSASInstrumentFile.h @@ -41,6 +41,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadGSASInstrumentFile"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/Algorithms/inc/MantidAlgorithms/FlatPlateAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/FlatPlateAbsorption.h index 4253708e9012be597cdacccfe2c95a74981e593c..e043d49b51ff8b49a769b688a0f47ba114a28624 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/FlatPlateAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/FlatPlateAbsorption.h @@ -88,6 +88,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } protected: void initialiseCachedDistances() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h index 7c8f6930d787d34d67ee92772b05c6ae093b569d..9e12f0b9e998bc9723cb78bf13ca72f545fa9bce 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GenerateEventsFilter.h @@ -73,6 +73,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"FilterEvents", "FilterByTime", "FilterByLogValue"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events\\EventFiltering"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GenerateIPythonNotebook.h b/Framework/Algorithms/inc/MantidAlgorithms/GenerateIPythonNotebook.h index 882baeea5390607278bccd072ab339d8abba6a3e..93e9b72a6f886489caa51b2378d5857af04a8392 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GenerateIPythonNotebook.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GenerateIPythonNotebook.h @@ -51,6 +51,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RecordPythonScript", "GeneratePythonScript"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Python"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h index a7dbfa7302535af666521ac015bf69a6c6bf8ffd..0a921362f4ce3a3eff49d7d0371be05fad61f046 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePeaks.h @@ -53,6 +53,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"FindPeaks", "MatchPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePythonScript.h b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePythonScript.h index 90db547f68428134283aef4b81e233d45fe064e3..4e98759a22659360a539e8e9edd6f1f8666a58d7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GeneratePythonScript.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GeneratePythonScript.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RecordPythonScript", "GenerateIPythonNotebook"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Python"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h b/Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h index 7cdd5ef79a4488cb70af5e7809ea319364ac7aff..10d97d6341a887f026229b8298401ebc20ff8d62 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetAllEi.h @@ -55,6 +55,7 @@ public: } /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { return {"GetEi"}; } /// Algorithm's category for identification. @see Algorithm::category const std::string category() const override { return "Inelastic\\Ei"; }; /// Cross-check properties with each other @see IAlgorithm::validateInputs diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h index fe45add3a6220f0b6dfeba044ad29a73dc2c28af..35faf98d455cd34f4bd6956ce0a797e7495413fe 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetDetOffsetsMultiPeaks.h @@ -70,6 +70,9 @@ public: const std::string name() const override { return "GetDetOffsetsMultiPeaks"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"GetDetectorOffsets"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Calibration"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h b/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h index f7b2392926d0514e94827017d5393070106b44c2..0e08637ad9b5717926a57a5c8928f68d4de6d694 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetDetectorOffsets.h @@ -47,6 +47,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"GetDetOffsetsMultiPeaks", "CalibrateRectangularDetectors", + "AlignComponents"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Calibration"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h index c717122ebd9bc0c80f36732f0e8eaadae56db7ee..57ac117c7915a97b907e596622c973e46e803ddf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEi2.h @@ -80,6 +80,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"GetAllEi", "GetEiMonDet", "GetEiT0atSNS"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Inelastic\\Ei"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetEiMonDet2.h b/Framework/Algorithms/inc/MantidAlgorithms/GetEiMonDet2.h index fc8b693dd75203792788ce866656159f0981f2a2..66e032bb63737df399c6e89201c9fa42e8244355 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetEiMonDet2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetEiMonDet2.h @@ -56,6 +56,7 @@ public: /// Returns algorithm's version for identification int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { return {"GetEi"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Inelastic\\Ei"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h index 8776e174d15550dfe8091e085dbe28578fcb0a71..169b4bbb421779289e2c551214ec3c921a6e35b6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GetTimeSeriesLogInformation.h @@ -50,6 +50,9 @@ public: } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLogMultiple"}; + } const std::string category() const override { return "Diffraction\\Utility;Events\\EventFiltering"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/GroupWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/GroupWorkspaces.h index 97a25bb314f68d4ae5767296cf0052384e957aff..b7e5f75380aa2be52ce31b91662d3fb4860bb2c7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/GroupWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/GroupWorkspaces.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"UnGroupWorkspace"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Grouping;Utility\\Workspaces"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/HRPDSlabCanAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/HRPDSlabCanAbsorption.h index 5496735501c4494fc91b25e97190bc3af34a978f..9aec8352820aa25e99cb4cf4a5351bf6f27c1c30 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/HRPDSlabCanAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/HRPDSlabCanAbsorption.h @@ -79,6 +79,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\AbsorptionCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h index 275d5bdce0ac6acaf4c7609b10e85c24baa4d2cb..b3372121aa92d471e1dfdfea464310de8b091fcb 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/He3TubeEfficiency.h @@ -73,6 +73,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"DetectorEfficiencyCor"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\EfficiencyCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h index 429d437f9547b0023a09498bbe04ba7244fde975..020a2193d25ad2c269657f9ada15bfe536480b73 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IdentifyNoisyDetectors.h @@ -55,6 +55,10 @@ public: return (1); } ///< @return version number of algorithm + const std::vector<std::string> seeAlso() const override { + return {"CreatePSDBleedMask"}; + } + private: void init() override; ///< Initialise the algorithm. Declare properties, etc. void exec() override; ///< Executes the algorithm. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h index caa647670c595e8c6abc692385689f563eec0a29..4610fa03e45c81060b99a272bc162ef3f9711f2f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/IntegrateByComponent.h @@ -40,6 +40,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Integration"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h index 37eae9987736f8baa0d236acd6024b017a2bf853..20a1320c1dc3d7d4d00bb8bac34bcc468cd20505 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Integration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Integration.h @@ -67,6 +67,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"IntegrateByComponent", "Rebin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic;Transforms\\Rebin"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h index 458b4b79d752326a88b25f659c0b7c5e499778a8..55adc55e8e0c5de5793b53dbcb55782242a35fcc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/InterpolatingRebin.h @@ -79,6 +79,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Rebin"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Rebin"; } /// Alias for the algorithm. Must override so it doesn't get parent class's diff --git a/Framework/Algorithms/inc/MantidAlgorithms/InvertMask.h b/Framework/Algorithms/inc/MantidAlgorithms/InvertMask.h index 5fbb20ac6df707bc8a9050c2636476ca150d65e9..8790333978911704950397a26651c5ec70cbc0c8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/InvertMask.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/InvertMask.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"BinaryOperateMasks", "MaskDetectors"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/LineProfile.h b/Framework/Algorithms/inc/MantidAlgorithms/LineProfile.h index e2da673079df0d129e3cd05df8c44e6658d2a895..d1921f4400f55c978522221b563cc36c9d6c14bf 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/LineProfile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/LineProfile.h @@ -35,6 +35,9 @@ class MANTID_ALGORITHMS_DLL LineProfile : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RingProfile"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Logarithm.h b/Framework/Algorithms/inc/MantidAlgorithms/Logarithm.h index 4831106bddb4fc7c75dff091ac016eb2beb0c49c..c5cf955fc3f4f1ac7d049ae48b7a69c4e514ef24 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Logarithm.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Logarithm.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Power", "Exponential"}; + } /// Algorithm's category for identification const std::string category() const override { return "Arithmetic"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/LorentzCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/LorentzCorrection.h index ba973bfdf0ed4f4c7dfc5e3a3bbd5f0626b1e6f2..e7f64c86975de8b9b2c0a45ec1f2cfd8903b7059 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/LorentzCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/LorentzCorrection.h @@ -35,6 +35,9 @@ class DLLExport LorentzCorrection : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AnvredCorrection"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h index 98d2ac575b8eefa7635f4d3a804dadf725a3bb44..0799f810be77a87aff597ceb02fd13a3d7f9af69 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MagFormFactorCorrection.h @@ -56,6 +56,7 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"SofQW"}; } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskBins.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskBins.h index 743d0a81787122f2c4cabb96a3c9b53f3051b82a..85e5b5b1082961c7759cfbd2112ece8d0f902b74 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskBins.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskBins.h @@ -64,6 +64,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"MaskBinsFromTable"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h index 740c88c9d8c1184f114f4a9b3d39ed54675b257a..c8974c5b7eb50fa40f0ef6d84a5d3d1bb42e9546 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskBinsFromTable.h @@ -46,6 +46,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MaskBins"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskDetectorsIf.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskDetectorsIf.h index fba8e6c81c1a4e24ab8134939633c2b9d5999bd0..d4fd299ed3b8e218d96b32a4546fccf2922e18df 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskDetectorsIf.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskDetectorsIf.h @@ -57,6 +57,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Masking;Transforms\\Masking"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaskInstrument.h b/Framework/Algorithms/inc/MantidAlgorithms/MaskInstrument.h index ef6837232280d79e99b2ce84335c6890cc1aecdb..1c3c0493bee19553e8d3e769b284fa5b975ee4b9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaskInstrument.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaskInstrument.h @@ -39,6 +39,9 @@ class MANTID_ALGORITHMS_DLL MaskInstrument : public API::DistributedAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors", "ClearMaskedSpectra"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Max.h b/Framework/Algorithms/inc/MantidAlgorithms/Max.h index 8f3a089b5b330808be03cdbb9d73989be672f567..ad8c92dcb33dc3cd4b0de0b2dedf487a70fcba3e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Max.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Max.h @@ -58,6 +58,9 @@ public: const std::string name() const override { return "Max"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Min", "MaxMin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic"; } /// Summary of algorithms purpose diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h index 14582e526742301a99018823c6f50467dc7850ea..3980cda6bcf3eab7bb86a6697d3f05dda9af6e38 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxEnt.h @@ -43,6 +43,10 @@ public: const std::string name() const override; /// Algorithm's version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ExtractFFTSpectrum", "FFT", "FFTDerivative", "RealFFT", + "SassenaFFT", "FFTSmooth"}; + } /// Algorithm's category const std::string category() const override; /// Algorithm's summary diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MaxMin.h b/Framework/Algorithms/inc/MantidAlgorithms/MaxMin.h index f2cb873b2f86f158612941a7cdce8aa49ba51981..32a59b4c69333fe288219c52f0106fee76e8987d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MaxMin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MaxMin.h @@ -65,6 +65,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Max", "Min"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h index 695b0320bb1f5c544d6cdb8c61894fb89aab8523..dba48a980ca7d7012a1320dc427c647507732a95 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MedianDetectorTest.h @@ -77,6 +77,9 @@ public: const std::string category() const override; /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"DetectorDiagnostic"}; + } private: // Overridden Algorithm methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h b/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h index d3d22f26abca4c34535361e6c8b5860e6ab7dc2f..8165863d77555247ec954431ad17e014827e89c9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MergeRuns.h @@ -74,6 +74,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ConjoinWorkspaces"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Merging"; } // Overriden MultiPeriodGroupAlgorithm method. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Min.h b/Framework/Algorithms/inc/MantidAlgorithms/Min.h index 4787828eb9da7394e20169ecebc296fc261e4452..f218d65f67967922353b27cbabbb0ef6230a232f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Min.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Min.h @@ -58,6 +58,9 @@ public: const std::string name() const override { return "Min"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Max", "MaxMin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic"; } /// Summary of algorithms purpose diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h index 5e6a402ccb6eaf08b051171cab30a1467916d3f8..bd9acf03cbe136b5a45d225e7d5bce4364841a80 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Minus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Minus.h @@ -58,6 +58,9 @@ public: const std::string alias() const override; /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Plus", "Divide", "Multiply"}; + } private: // Overridden BinaryOperation methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzero.h b/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzero.h index fd98511d3727727ad96f5072f6c06a7b57e396df..97af2302028da11342b46616260191abb16f8b6d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzero.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzero.h @@ -86,6 +86,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ModeratorTzeroLinear"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\InstrumentCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzeroLinear.h b/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzeroLinear.h index 9a3ead956e753515297df78533816916d46f2687..f0fb409e222298646c75b36eb34e75dc274a1742 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzeroLinear.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ModeratorTzeroLinear.h @@ -88,6 +88,9 @@ public: const std::string summary() const override; /// Algorithm's version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ModeratorTzero"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MonitorEfficiencyCorUser.h b/Framework/Algorithms/inc/MantidAlgorithms/MonitorEfficiencyCorUser.h index 1b9c80ef93b430614ee09d73a63df5f4ff5c7a49..75ede8e3a45bbcf339800a81ac65d5c3ac086c57 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MonitorEfficiencyCorUser.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MonitorEfficiencyCorUser.h @@ -26,6 +26,9 @@ public: /// Algorithm's version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"NormaliseToMonitor"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\NormalisationCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MonteCarloAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/MonteCarloAbsorption.h index 179ca161b01bc2ec2207527a7bee08c921f96728..2d627213fc7646f145c00c5b2be2deb4c2932f6d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MonteCarloAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MonteCarloAbsorption.h @@ -49,6 +49,10 @@ public: const std::string name() const override { return "MonteCarloAbsorption"; } /// Algorithm's version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"MayersSampleCorrection", "MultipleScatteringCylinderAbsorption", + "PearlMCAbsorption", "VesuvioCalculateMS"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\AbsorptionCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MostLikelyMean.h b/Framework/Algorithms/inc/MantidAlgorithms/MostLikelyMean.h index f673f021c8179e5e42628164f1829598e3ebc9de..0d71ccd28e6c53d24fc0fd96fee1833a442e0fb0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MostLikelyMean.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MostLikelyMean.h @@ -35,6 +35,7 @@ class MANTID_ALGORITHMS_DLL MostLikelyMean : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { return {"Mean"}; } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MultipleScatteringCylinderAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/MultipleScatteringCylinderAbsorption.h index ab2190f5bf9fa46fadddf2d3a6e49d054f002728..c3bf17eb48b23974a9bd5e755017b37ac9ce140f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MultipleScatteringCylinderAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MultipleScatteringCylinderAbsorption.h @@ -49,6 +49,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MonteCarloAbsorption", "MayersSampleCorrection", + "PearlMCAbsorption", "VesuvioCalculateMS"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Multiply.h b/Framework/Algorithms/inc/MantidAlgorithms/Multiply.h index 716a97bb14ae4c4516d060f139a180b83b655b94..4300b55bbe16ad6f9f6a7275f65c80e4f7daab28 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Multiply.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Multiply.h @@ -56,6 +56,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Plus", "Minus", "Divide"}; + } private: // Overridden BinaryOperation methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/MultiplyRange.h b/Framework/Algorithms/inc/MantidAlgorithms/MultiplyRange.h index 3ff7887c9dec03a9fb5b7aa1aae874221f0864d3..a1345d9249284008f0a7d5e4d2a0f152023adcb3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/MultiplyRange.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/MultiplyRange.h @@ -54,6 +54,9 @@ public: } int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Multiply"}; + } const std::string category() const override { return "Arithmetic;CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NRCalculateSlitResolution.h b/Framework/Algorithms/inc/MantidAlgorithms/NRCalculateSlitResolution.h index e8f6eeab26bd38282bb880220c4761f68af15985..8a2a880bd6a519ced4d0ab3d924d82ed3142add4 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NRCalculateSlitResolution.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NRCalculateSlitResolution.h @@ -37,6 +37,9 @@ class DLLExport NRCalculateSlitResolution : public API::DataProcessorAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalculateSlits"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h index c41872d84f016b308ff7653a6b127eee2d2dbf39..46c22074df6fa513d04abd8e8e737a193c8cd408 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByCurrent.h @@ -58,6 +58,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Divide"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\NormalisationCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h index 70f9574d2b755e2464085a93f4e89b1988e2f65a..802dd0dce9f58faa89d1e830cbb4b0fdb3db9fec 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseByDetector.h @@ -55,6 +55,7 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { return {"Divide"}; } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h index 0d62e5d949d7d81b28b2dcc154dbafa34ad152bf..c99bc15fc87a6c61ecaac68c0355fd88d73280c0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToMonitor.h @@ -88,6 +88,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Divide"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\NormalisationCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToUnity.h b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToUnity.h index c3719f59bfc343e84e2093473d2941562f469d45..ca93683fcb2eab5f47e4cac7504f0fefc647c0e5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToUnity.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/NormaliseToUnity.h @@ -67,6 +67,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"Divide"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\NormalisationCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/OneMinusExponentialCor.h b/Framework/Algorithms/inc/MantidAlgorithms/OneMinusExponentialCor.h index e6f247584e89e4124ba7ccbd1fbd0ce3efda0dbc..b6dfe1d62ce70270bc7ee5621c11aa2a34bb1233 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/OneMinusExponentialCor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/OneMinusExponentialCor.h @@ -65,6 +65,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"MagFormFactorCorrection", "ExponentialCorrection", + "PowerLawCorrection"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h index bacf0c065f8bf982a47d449cedecf52ab227a13f..bb44e769669dbfb7f44e40037a9202b2762ce418 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PDCalibration.h @@ -41,6 +41,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalibrateRectangularDetectors"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PDFFourierTransform.h b/Framework/Algorithms/inc/MantidAlgorithms/PDFFourierTransform.h index fb7dd244241e88c5266cc3baadc5e7b73e918463..4fc13a297bc9316b7f751c07edc03acb45008e41 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PDFFourierTransform.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PDFFourierTransform.h @@ -22,6 +22,7 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { return {"FFT"}; } /// Algorithm's category for identification const std::string category() const override; /// @copydoc Algorithm::validateInputs() diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PerformIndexOperations.h b/Framework/Algorithms/inc/MantidAlgorithms/PerformIndexOperations.h index fa32a9e561a6977ada13500e89cd61dcc05920fb..62fe4913a32832a292f971dab5bcb4eef44e3712 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PerformIndexOperations.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PerformIndexOperations.h @@ -40,6 +40,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ExtractSpectra"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PhaseQuadMuon.h b/Framework/Algorithms/inc/MantidAlgorithms/PhaseQuadMuon.h index d47ca50770df2ce0664f44d5d00f3a376ef35a3c..8b9ffafb6b58e2918fac970b76ee09232462dc25 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PhaseQuadMuon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PhaseQuadMuon.h @@ -44,7 +44,9 @@ public: const std::string summary() const override { return "Generates a quadrature phase signal."; } - + const std::vector<std::string> seeAlso() const override { + return {"MuonMaxent"}; + } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } /// Algorithm's category for identification overriding a virtual method diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PlotAsymmetryByLogValue.h b/Framework/Algorithms/inc/MantidAlgorithms/PlotAsymmetryByLogValue.h index e23fc5a28264cdddbbe250b781dab83b2a34fa76..f804ee642d97f165e1ea1ac3625c2827c66c7610 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PlotAsymmetryByLogValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PlotAsymmetryByLogValue.h @@ -69,6 +69,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"AsymmetryCalc", "CalculateMuonAsymmetry", "PlotPeakByLogValue"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h index c06e1cbe8ea3c99f3e5426d391486b9300206c48..1e6239de2bf991966994b182fef7775ec15f158c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Plus.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Plus.h @@ -58,6 +58,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Divide", "Minus", "Multiply"}; + } private: // Overridden BinaryOperation methods diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrection.h index 82a9adc2c20e83e65221a9d0ce6e0fb67196004a..07a29b9ac673c631055fc1bef90e9b75fe0a5c06 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationCorrection.h @@ -41,6 +41,9 @@ class DLLExport PolarizationCorrection : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PolarizationEfficiencyCor"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h index 53ed383886519c6642b7644a94f9188e6b000d3a..a84f32e031f8438b57c56ca2048771cc9befbc91 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolarizationEfficiencyCor.h @@ -42,6 +42,9 @@ class MANTID_ALGORITHMS_DLL PolarizationEfficiencyCor : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PolarizationCorrection"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PolynomialCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/PolynomialCorrection.h index 9461f9ba196522cd56c579c3cc12f299dc4fe34a..b287e7bdf302398033a2794a68f83f535dfecc6b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PolynomialCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PolynomialCorrection.h @@ -63,6 +63,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"OneMinusExponentialCor", "MagFormFactorCorrection", + "ExponentialCorrection", "PowerLawCorrection"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Power.h b/Framework/Algorithms/inc/MantidAlgorithms/Power.h index 193cb7458748a104e30c35d12d7818d2a393282d..ece61ba23d36f25de04213a4f14372acbe3657c3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Power.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Power.h @@ -59,6 +59,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Exponential", "Logarithm"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/PowerLawCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/PowerLawCorrection.h index ae78311091a8a653ed333886e30af9b782a8ab77..970c63de36c7228541db3793ec86a22dd37680da 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/PowerLawCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/PowerLawCorrection.h @@ -63,6 +63,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"PolynomialCorrection", "OneMinusExponentialCor", + "MagFormFactorCorrection", "ExponentialCorrection"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h index e0779024764f9147a15978c86755ba7033597e43..75184ff5b4d5d35ebff108a6563d53ad11fd383b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1D2.h @@ -52,6 +52,9 @@ public: /// Algorithm's version int version() const override { return (2); } + const std::vector<std::string> seeAlso() const override { + return {"Q1DWeighted", "Qxy"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h index e0ca710e74cdd010deb044563101a4b2837b4ccf..02dbe13c83fec21905ac38a009389d4d88244db7 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Q1DWeighted.h @@ -56,6 +56,7 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"Q1D"}; } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h index fe36eda1772cc38252b9a66c58f47bf80de86ffb..f91222a9542ad6c7881ec70aff8005568169443a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Qxy.h @@ -58,6 +58,7 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"Q1D"}; } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RRFMuon.h b/Framework/Algorithms/inc/MantidAlgorithms/RRFMuon.h index f23184aafc15adabd0a598e6ecdfa780268fe121..3fe15b988d54022df644550bb5456aa69796be96 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RRFMuon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RRFMuon.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CalculateMuonAsymmetry"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h index af0fc0257a7b3dc1c45123cb20a2ab739c7de655..8f1eba680b5a35ff100373f561069986bc262803 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RadiusSum.h @@ -46,6 +46,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RingProfile", "RadiusSum"}; + } const std::string category() const override; static bool inputWorkspaceHasInstrumentAssociated(API::MatrixWorkspace_sptr); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h index 11505f00e7c90f8a3280013bdbcf4936a0debbfa..6ba55dde1feb5755b7927aadcca62321539d0623 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReadGroupsFromFile.h @@ -90,6 +90,11 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CreateDummyCalFile", "CreateCalFileByNames", "AlignDetectors", + "DiffractionFocussing", "LoadCalFile", "SaveCalFile", + "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling\\CalFiles"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RealFFT.h b/Framework/Algorithms/inc/MantidAlgorithms/RealFFT.h index bba0209f62036629b7956d220a3fce703d3e484a..2c6201579c94b3a6db1bc8656d38d549d69669e8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RealFFT.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RealFFT.h @@ -44,6 +44,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ExtractFFTSpectrum", "FFT", "FFTDerivative", "MaxEnt", + "SassenaFFT", "FFTSmooth"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic\\FFT"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h index 51240422723fff002224841577099ecf5c786564..585cc66d27981fd28792f12157f5b768cf386257 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Rebin.h @@ -67,6 +67,11 @@ public: const std::string category() const override { return "Transforms\\Rebin"; } /// Algorithm's aliases const std::string alias() const override { return "rebin"; } + /// Algorithm's seeAlso + const std::vector<std::string> seeAlso() const override { + return {"RebinToWorkspace", "Rebin2D", "Rebunch", + "Regroup", "RebinByPulseTimes", "RebinByTimeAtSample"}; + } static std::vector<double> rebinParamsFromInput(const std::vector<double> &inParams, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Rebin2D.h b/Framework/Algorithms/inc/MantidAlgorithms/Rebin2D.h index d5e0b2c3206d122a2e5b5eb9acde5b24463e6750..59981e907cef251590101342d7e12a34505d0e75 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Rebin2D.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Rebin2D.h @@ -48,6 +48,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Rebin", "SofQW"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Rebin"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RebinByPulseTimes.h b/Framework/Algorithms/inc/MantidAlgorithms/RebinByPulseTimes.h index 711aabe826fcfc11cc2fda25fe6c1fd9f74bf7e1..74a7579fd416e0b9bcdcc0351e9cad1131d5a43d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RebinByPulseTimes.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RebinByPulseTimes.h @@ -41,7 +41,12 @@ public: } int version() const override; + const std::string category() const override; + /// Algorithm's seeAlso + const std::vector<std::string> seeAlso() const override { + return {"Rebin", "RebinByTimeAtSample"}; + } private: /// Do the algorithm specific histogramming. diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RebinByTimeAtSample.h b/Framework/Algorithms/inc/MantidAlgorithms/RebinByTimeAtSample.h index 6bca5d6b0e0f19593b7a6e6c80fb14508ce1724d..7316a4e271260dcd864b72be7c05e26e2062bc60 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RebinByTimeAtSample.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RebinByTimeAtSample.h @@ -36,8 +36,13 @@ class DLLExport RebinByTimeAtSample : public RebinByTimeBase { public: const std::string name() const override; int version() const override; + const std::string category() const override; const std::string summary() const override; + /// Algorithm's seeAlso + const std::vector<std::string> seeAlso() const override { + return {"Rebin", "RebinByPulseTimes"}; + } private: void doHistogramming(Mantid::API::IEventWorkspace_sptr inWS, diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RebinToWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/RebinToWorkspace.h index 62cf3439e3cde365de2a34bfca9db9bc014f5891..3518bb59c6ccfcdfee42e308999b06ba2098cc81 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RebinToWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RebinToWorkspace.h @@ -57,8 +57,11 @@ public: /// Algorithm's version int version() const override { return (1); } + /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Rebin"; } + /// Algorithm's seeAlso + const std::vector<std::string> seeAlso() const override { return {"Rebin"}; } protected: Parallel::ExecutionMode getParallelExecutionMode( diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Rebunch.h b/Framework/Algorithms/inc/MantidAlgorithms/Rebunch.h index 6ab2eec810516b9831da8158261a60ec28e484f3..51d1ca1c91c438783b4a30bf582214d62808898f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Rebunch.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Rebunch.h @@ -67,6 +67,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Rebin"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Rebin"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RecordPythonScript.h b/Framework/Algorithms/inc/MantidAlgorithms/RecordPythonScript.h index f60f3d88c2376b233d497f26824252b9f6b75c14..5acc3d276ed77c313a2cfa071c26e9b8cbcfcee2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RecordPythonScript.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RecordPythonScript.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"GenerateIPythonNotebook", "GeneratePythonScript"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Python"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne.h deleted file mode 100644 index 0a0c6854d40826e5b7cd823d1b79b7a9510333ee..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONE_H_ -#define MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONE_H_ - -#include "MantidKernel/System.h" -#include "MantidAlgorithms/DllConfig.h" -#include "MantidAPI/MatrixWorkspace_fwd.h" -#include "MantidGeometry/Instrument.h" -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidAlgorithms/ReflectometryWorkflowBase.h" - -namespace Mantid { -namespace Algorithms { - -/** ReflectometryReductionOne : Reflectometry reduction of a single input TOF - workspace to an IvsQ workspace. - - Copyright © 2013 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> - Code Documentation is available at: <http://doxygen.mantidproject.org> - */ -class DLLExport ReflectometryReductionOne : public ReflectometryWorkflowBase { -public: - const std::string name() const override; - /// Summary of algorithms purpose - const std::string summary() const override { - return "Reduces a single TOF/Lambda reflectometry run into a mod Q vs I/I0 " - "workspace. Performs transmission corrections."; - } - - int version() const override; - const std::string category() const override; - - /// Convert to an IvsQ workspace. Performs detector positional corrections - /// based on the component name and the theta value. - Mantid::API::MatrixWorkspace_sptr toIvsQ(API::MatrixWorkspace_sptr &toConvert, - const bool bCorrectPosition, - OptionalDouble &thetaInDeg, - const bool isPointDetector); - -private: - /** Overridden Algorithm methods **/ - - void init() override; - - void exec() override; - - /// Get the surface sample component - Mantid::Geometry::IComponent_const_sptr - getSurfaceSampleComponent(Mantid::Geometry::Instrument_const_sptr inst); - - /// Get the detector component - Mantid::Geometry::IComponent_const_sptr - getDetectorComponent(Mantid::Geometry::Instrument_const_sptr inst, - const bool isPointDetector); - - /// Correct detector positions. - API::MatrixWorkspace_sptr - correctPosition(API::MatrixWorkspace_sptr &toCorrect, - const double &thetaInDeg, const bool isPointDetector); - - /// Perform a transmission correction on the input IvsLam workspace - API::MatrixWorkspace_sptr transmissonCorrection( - API::MatrixWorkspace_sptr IvsLam, const MinMax &wavelengthInterval, - const OptionalMinMax &wavelengthMonitorBackgroundInterval, - const OptionalMinMax &wavelengthMonitorIntegrationInterval, - const OptionalInteger &i0MonitorIndex, - API::MatrixWorkspace_sptr firstTransmissionRun, - OptionalMatrixWorkspace_sptr secondTransmissionRun, - const OptionalDouble &stitchingStart, - const OptionalDouble &stitchingDelta, const OptionalDouble &stitchingEnd, - const OptionalDouble &stitchingStartOverlap, - const OptionalDouble &stitchingEndOverlap, - const std::string &numeratorProcessingCommands); - - /// Perform transmission correction using either PolynomialCorrection - /// or ExponentialCorrection. - API::MatrixWorkspace_sptr - algorithmicCorrection(API::MatrixWorkspace_sptr IvsLam); - - /// Verify spectrum maps - void verifySpectrumMaps(API::MatrixWorkspace_const_sptr ws1, - API::MatrixWorkspace_const_sptr ws2, - const bool severe = false); - /// returns angle for source rotation - double getAngleForSourceRotation(API::MatrixWorkspace_sptr toConvert, - double thetaOut); -}; - -} // namespace Algorithms -} // namespace Mantid - -#endif /* MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONE_H_ */ diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h index 49a8f680da0f60ef7bbbee69bdc303e11b73c018..d947f14b6381a0561b867d645542233ef62dfe35 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOne2.h @@ -56,6 +56,9 @@ public: } /// Algorithm's version for identification. int version() const override { return 2; }; + const std::vector<std::string> seeAlso() const override { + return {"ReflectometryReductionOneAuto"}; + } /// Algorithm's category for identification. const std::string category() const override { return "Reflectometry"; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto.h deleted file mode 100644 index 5b84f40d83371650a724a21303f6dbd34a8bdb05..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto.h +++ /dev/null @@ -1,70 +0,0 @@ -#ifndef MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTO_H_ -#define MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTO_H_ - -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/DataProcessorAlgorithm.h" -#include "MantidAPI/WorkspaceGroup_fwd.h" -#include "MantidKernel/System.h" - -#include <boost/optional.hpp> - -namespace Mantid { -namespace Algorithms { - -/** ReflectometryReductionOneAuto : Algorithm to run ReflectometryReductionOne, -attempting to pick instrument parameters for - * missing properties. - -Copyright © 2014 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -Code Documentation is available at: <http://doxygen.mantidproject.org> -*/ -class DLLExport ReflectometryReductionOneAuto - : public API::DataProcessorAlgorithm { -public: - const std::string name() const override; - int version() const override; - const std::string category() const override; - const std::string summary() const override; - - // For (multiperiod) workspace groups - bool checkGroups() override; - bool processGroups() override; - -private: - void init() override; - void exec() override; - template <typename T> boost::optional<T> isSet(std::string propName) const; - Mantid::API::Workspace_sptr - sumOverTransmissionGroup(Mantid::API::WorkspaceGroup_sptr &transGroup); - - std::string pNRLabel() const { return "PNR"; } - std::string pALabel() const { return "PA"; } - std::string crhoLabel() const { return "CRho"; } - std::string cppLabel() const { return "CPp"; } - std::string cAlphaLabel() const { return "CAlpha"; } - std::string cApLabel() const { return "CAp"; } - std::string noPolarizationCorrectionMode() const { return "None"; } -}; - -} // namespace Algorithms -} // namespace Mantid - -#endif /* MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTO_H_ */ diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h index dddab606aeaacc25ae2bb1059c2259cc3163112b..6cca5e217006f13101bf89d05de85ca7ad2cf764 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ReflectometryReductionOneAuto2.h @@ -36,6 +36,9 @@ class DLLExport ReflectometryReductionOneAuto2 public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ReflectometryReductionOne"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Regroup.h b/Framework/Algorithms/inc/MantidAlgorithms/Regroup.h index a301f7c678caac0359c55a1efa977069a6ede356..9818529a54a9b3e3291d99469c722e85c4e76eee 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Regroup.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Regroup.h @@ -60,6 +60,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Rebin"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Rebin"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RemoveBins.h b/Framework/Algorithms/inc/MantidAlgorithms/RemoveBins.h index 79fa181b28f224c50297b7bdd67132bf0f538ffe..d208dbfa4451d45a8398077e137d814c0298ff45 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RemoveBins.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RemoveBins.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CropWorkspace"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Splitting"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RemoveExpDecay.h b/Framework/Algorithms/inc/MantidAlgorithms/RemoveExpDecay.h index 7ab51404be3088ff5e2a128d3faac92c7a795845..21769da0facb552071b2646d032c5bee4b5b5bc6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RemoveExpDecay.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RemoveExpDecay.h @@ -59,6 +59,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Muon"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RemoveMaskedSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/RemoveMaskedSpectra.h index 95d106f840ebd5416081e928a1790b0b4d3c3473..2a1f98e0a90b2ca4cc7c370204f3e264d49b7db2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RemoveMaskedSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RemoveMaskedSpectra.h @@ -34,6 +34,9 @@ class DLLExport RemoveMaskedSpectra : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ExtractUnmaskedSpectra"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RemoveWorkspaceHistory.h b/Framework/Algorithms/inc/MantidAlgorithms/RemoveWorkspaceHistory.h index 5c2e4ffaa0197583288fb557bd597ad45fc8ad93..cde17cd34f02db2de43d7574e38ca8ca3a447c5a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RemoveWorkspaceHistory.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RemoveWorkspaceHistory.h @@ -38,6 +38,9 @@ public: const std::string name() const override; const std::string summary() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Comment"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspace.h index fcde2879ca7e806c156052801f926bd8ff3b8bf5..324819fb3e1f03895f7883b0dfbb30eb6495e7e1 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspace.h @@ -47,6 +47,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"RenameWorkspaces"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Utility\\Workspaces"; } /// Check that input params are valid diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspaces.h b/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspaces.h index 59e5f4f39e0e88d2d467ca7a494def39c224306f..052e3e015760631e6a88c089a6d780708b49f5e2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspaces.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RenameWorkspaces.h @@ -57,6 +57,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"RenameWorkspace"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ResampleX.h b/Framework/Algorithms/inc/MantidAlgorithms/ResampleX.h index ec56de62ac3e1d6ce808dfb0f627cf400f43041e..4a9d517a0782bc6b98e2a8edf9e24ef249126f9f 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ResampleX.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ResampleX.h @@ -37,6 +37,10 @@ class DLLExport ResampleX : public Algorithms::Rebin { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RebinToWorkspace", "Rebin2D", "Rebunch", + "Regroup", "RebinByPulseTimes", "RebinByTimeAtSample"}; + } const std::string category() const override; const std::string alias() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ResizeRectangularDetector.h b/Framework/Algorithms/inc/MantidAlgorithms/ResizeRectangularDetector.h index 1d4e8b3d43fffbf854d6daf6d7816e67ca6fbafc..c3def823b2d1c3aac682345b9cbf569781beacb2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ResizeRectangularDetector.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ResizeRectangularDetector.h @@ -41,6 +41,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ModifyDetectorDotDatFile"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h index e5a96681c94f9c219c4fda3a88adc5f64ed331d6..7e0be63d5420e9c41ba38992375a9ff0d48a0c34 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RingProfile.h @@ -47,6 +47,9 @@ public: } int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LineProfile"}; + } const std::string category() const override { return "Transforms\\Grouping"; }; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h index 7093a030439be1cc9dd394771052b7b2cbbb0d51..3b2e9a7eebcc2d1e217af5a965b036efef6f9b08 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h @@ -64,6 +64,7 @@ private: std::string m_instrumentName; bool m_isHistogramData; bool m_isScanning; + std::vector<bool> m_hasDx; }; } // namespace Algorithms diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MayersSampleCorrection.h b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MayersSampleCorrection.h index 9d336dc788650a1714a71adfae24b5d4f18b746a..19719ae48c055eb4b7f33bc770d7c4225719cec8 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MayersSampleCorrection.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SampleCorrections/MayersSampleCorrection.h @@ -39,6 +39,9 @@ public: int version() const override; const std::string category() const override; const std::string summary() const override; + const std::vector<std::string> seeAlso() const override { + return {"MonteCarloAbsorption", "MultipleScatteringCylinderAbsorption"}; + } private: void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SassenaFFT.h b/Framework/Algorithms/inc/MantidAlgorithms/SassenaFFT.h index e1b131edc2cbb04e8900055e6d7b79a6b20fbcaa..254c77abb8be5520e019472d048448eae3f14142 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SassenaFFT.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SassenaFFT.h @@ -47,6 +47,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ExtractFFTSpectrum", "FFT", "FFTDerivative", "MaxEnt", "RealFFT", + "FFTSmooth"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic\\FFT"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Scale.h b/Framework/Algorithms/inc/MantidAlgorithms/Scale.h index 5c451b14fcb7b6895775c1e3e2c7f039f50c2ce8..f87b8a15d9cb62857babdad4b908cd03e96e5640 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Scale.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Scale.h @@ -55,6 +55,7 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"ScaleX"}; } /// Algorithm's category for identification const std::string category() const override { return "Arithmetic;CorrectionFunctions"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ScaleX.h b/Framework/Algorithms/inc/MantidAlgorithms/ScaleX.h index f1ea4fa1da59fd253e59bb028009aac2c0e413e9..82c1995077e284a857000f031c963fd14792d388 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ScaleX.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ScaleX.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ChangeBinOffset", "Scale"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic;CorrectionFunctions"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SetInstrumentParameter.h b/Framework/Algorithms/inc/MantidAlgorithms/SetInstrumentParameter.h index 316649738e8fdb9136f4a3a85c015768c5a88260..ec65580bc127e1bb7198d7c5b8cbf72d060eb361 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SetInstrumentParameter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SetInstrumentParameter.h @@ -46,6 +46,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"RotateInstrumentComponent", "MoveInstrumentComponent"}; + } const std::string category() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/ShiftLogTime.h b/Framework/Algorithms/inc/MantidAlgorithms/ShiftLogTime.h index 8b233e6439095cb5159d570e0263c473bb81240e..eff5195d540a13a0854bda1022f5e2767e7693ca 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/ShiftLogTime.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/ShiftLogTime.h @@ -36,6 +36,9 @@ class DLLExport ShiftLogTime : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateLogTimeCorrection", "ChangePulsetime", "ChangeLogTime"}; + } const std::string category() const override; /// Summary of algorithms purpose diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SmoothData.h b/Framework/Algorithms/inc/MantidAlgorithms/SmoothData.h index 6624446363e44ab68dd1476378d140045405dccb..851e655056075e7584f2b7443fa480e9025ca98c 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SmoothData.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SmoothData.h @@ -63,6 +63,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SmoothNeighbours"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Smoothing"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h index 5a9375d1842ec9b4a063474d2ab483bd026db7fd..4c9c7781fb160df162546e0c3b407e332f6e17a5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SmoothNeighbours.h @@ -92,6 +92,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SmoothData"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Smoothing"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQW.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQW.h index 2326fc7fb2b37ce8293f76ca4e4bf3fde87f5580..c7d91346c7bdb692e5d2e7eaa7da6fc164819b5b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQW.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQW.h @@ -57,6 +57,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SofQWCentre", "SofQWPolygon", "SofQWNormalisedPolygon", "Rebin2D"}; + } /// Algorithm's category for identification const std::string category() const override { return "Inelastic\\SofQW"; } /// Create the output workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQWCentre.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQWCentre.h index f850e0d0329099d4d79859534889cccd6c6b1e08..b63f12fe518c22d546484e2972e371aa8de854e0 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQWCentre.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQWCentre.h @@ -62,6 +62,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SofQW", "Rebin2D"}; + } /// Algorithm's category for identification const std::string category() const override { return "Inelastic\\SofQW"; } /// Create the output workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQWNormalisedPolygon.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQWNormalisedPolygon.h index e3a4a37bb9a2cf7b74136e77c18b71ba3d722683..932e6ecf33801430e38b84554f549cbac7a4294a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQWNormalisedPolygon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQWNormalisedPolygon.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SofQW", "SofQWPolygon", "Rebin2D"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h index 250dd2cc982abde0737101181198ee2d684bb8ed..e4124966553cc660583f4fb019d1debbb3191e65 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SofQWPolygon.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SofQW", "SofQWNormalisedPolygon", "Rebin2D"}; + } /// Algorithm's category for identification const std::string category() const override { return "Inelastic\\SofQW"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SolidAngle.h b/Framework/Algorithms/inc/MantidAlgorithms/SolidAngle.h index 18553ffd1bdbd83d506d92d6014972b54cbaaaa7..1538828b14863dc9efca9589a6409c8d28c46f53 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SolidAngle.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SolidAngle.h @@ -57,6 +57,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Divide"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\InstrumentCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SortEvents.h b/Framework/Algorithms/inc/MantidAlgorithms/SortEvents.h index 9401200dad195a49a800b07a538c1dc488185eb7..757f1bd48ad427ae075558884a1841ab40d67fdc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SortEvents.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SortEvents.h @@ -50,6 +50,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadEventNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events;Utility\\Sorting"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpatialGrouping.h b/Framework/Algorithms/inc/MantidAlgorithms/SpatialGrouping.h index 3171b7d784d40c6246a05de736583e709108b42f..298627ace522469244953a2cb5b821a77e0d9e12 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpatialGrouping.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpatialGrouping.h @@ -61,6 +61,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"GroupDetectors"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Grouping"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionCalculateTheta2.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionCalculateTheta2.h index f42949c5a556d6a9941825ea728003e3d55e071a..b19f06488580088dfa9d8265309e2fa0e1460b05 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionCalculateTheta2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionCalculateTheta2.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SpecularReflectionPositionCorrect"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect2.h b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect2.h index e015c4d451ae3e334da49534a59faf3f8fd3fb98..850bcd3b154302c8a33133d47b3231e452f7f344 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SpecularReflectionPositionCorrect2.h @@ -38,6 +38,9 @@ public: const std::string summary() const override; /// Version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SpecularReflectionCalculateTheta"}; + } /// Category const std::string category() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SphericalAbsorption.h b/Framework/Algorithms/inc/MantidAlgorithms/SphericalAbsorption.h index 84431eefc0ea8ef28d899250434850d888b60ba4..273c57b45b377243fc73e1b19ddbf0710b1beee6 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SphericalAbsorption.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SphericalAbsorption.h @@ -96,6 +96,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } protected: API::MatrixWorkspace_sptr m_inputWS; ///< A pointer to the input workspace diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h index 973bd63c7cc8a34fd8b42037856129deedade364..28d040083b0c027238ef87b6f48d0f07376289cd 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1D.h @@ -43,6 +43,9 @@ public: const std::string summary() const override { return "Stitches single histogram matrix workspaces together"; } + const std::vector<std::string> seeAlso() const override { + return {"Stitch1DMany"}; + } /// Does the x-axis have non-zero errors bool hasNonzeroErrors(Mantid::API::MatrixWorkspace_sptr ws); diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1DMany.h b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1DMany.h index 47761af10a6e545b7624ee3737c10a10d62c653a..d0008c838cd6bf7987ec327774291b144a9ef9d2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Stitch1DMany.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Stitch1DMany.h @@ -38,6 +38,9 @@ public: const std::string name() const override { return "Stitch1DMany"; } /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Stitch1D"}; + } /// Algorithm's category for identification. @see Algorithm::category const std::string category() const override { return "Reflectometry"; } /// Summary of algorithm's purpose diff --git a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h index aea54a092d9a594203e67038b0910e8d009f29c4..e1239529cc27f591028dffa361c7d0889ae0f74e 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/StripPeaks.h @@ -63,6 +63,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FindPeaks", "StripVanadiumPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\PeakCorrections;Optimization\\PeakFinding"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/StripVanadiumPeaks2.h b/Framework/Algorithms/inc/MantidAlgorithms/StripVanadiumPeaks2.h index da5ac35ef604e883add0d998da14deaa12591e09..b180b29dc9218b25e1a508e2c3efc37c727aa33b 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/StripVanadiumPeaks2.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/StripVanadiumPeaks2.h @@ -39,6 +39,9 @@ public: const std::string name() const override { return "StripVanadiumPeaks"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"FindPeaks", "StripPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "CorrectionFunctions\\PeakCorrections;Optimization\\PeakFinding;" diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h index 12d4de12a8e3759960f0a25b2f58230117cda933..dc6aeeb2f98b2fa958dbe965284f8d3e0de2266a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumEventsByLogValue.h @@ -43,6 +43,9 @@ public: const std::string name() const override { return "SumEventsByLogValue"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FilterByLogValue"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events"; } /// Summary of algorithms purpose diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumNeighbours.h b/Framework/Algorithms/inc/MantidAlgorithms/SumNeighbours.h index 2f91f202760f6e43cf3e5dbfee719fcc39c4f87e..c8686555f233ce57ca883292877c272eb6f9d634 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumNeighbours.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumNeighbours.h @@ -55,6 +55,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SumSpectra", "SumRowColumn"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Grouping"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumOverlappingTubes.h b/Framework/Algorithms/inc/MantidAlgorithms/SumOverlappingTubes.h index 6f014d7e1538ac7ee6c34ea9b71a789dc62261dc..08b79627cb4f144b3be749c49b02d0564898876a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumOverlappingTubes.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumOverlappingTubes.h @@ -48,6 +48,9 @@ public: "supported."; } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SumSpectra"}; + } private: void init() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h b/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h index b0f4e1c2a2d3a41b72facfeac2c8cff569ba02f0..a718e8722144b91a243ba5d6c0815c5697d8e2d2 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumRowColumn.h @@ -74,6 +74,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SumSpectra", "SumNeighbours"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS;Transforms\\Grouping"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h index 16d6b3cb000610a6689d3a72c78f2e616f1d6313..c9cdefd880ae8f7e8efffaedc9843ebe6829f93a 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/SumSpectra.h @@ -65,6 +65,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SumNeighbours"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Grouping"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolution.h b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolution.h index 101fda8c0b0175a0b8aacbd99a8868c6fdce2c0a..1079f291e9f87848c2b36da59baa61d09b0b2cd3 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolution.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolution.h @@ -46,6 +46,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"TOFSANSResolutionByPixel"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h index f30e41a307e3a58af4af8f597b8dde4f5f09af30..107c9e7f2d56d324150eb03eb5c418c73996a301 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/TOFSANSResolutionByPixel.h @@ -30,6 +30,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"TOFSANSResolution"}; + } /// Algorithm's category for identification const std::string category() const override { return "SANS"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h index dd5678552f5a6aca225a8571dfc18a5f53fb9d5d..5e9c8f42af954fdc1feea888df4fdbcc503b7bd9 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/Transpose.h @@ -57,6 +57,10 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"Transpose3D", "TransposeMD", "ConvertUnits", "ConvertSpectrumAxis", + "ConvertAxesToRealSpace"}; + } /// Algorithm's category for identification const std::string category() const override { return "Transforms\\Axes"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/UnGroupWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/UnGroupWorkspace.h index 1dce4cfb17114184a71d37cd5f46cbc04b9fca9c..756753c15353b756b8e42bb5a3669353897a9436 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/UnGroupWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/UnGroupWorkspace.h @@ -50,6 +50,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"GroupWorkspaces"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Grouping;Utility\\Workspaces"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitor.h b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitor.h index 15645cf61399d617a3a6a693180ba8233cfaf630..83c3747b8defefd594f7a7b44785251229831919 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitor.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitor.h @@ -61,6 +61,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"UnwrapMonitorsInTOF", "UnwrapSNS"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "CorrectionFunctions\\InstrumentCorrections"; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitorsInTOF.h b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitorsInTOF.h index 25382da7a800d27c809236b4e56a1b09dba370a0..b8ccd3b95339108c4a473cb0da252fd1e872de8d 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitorsInTOF.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapMonitorsInTOF.h @@ -38,6 +38,9 @@ class MANTID_ALGORITHMS_DLL UnwrapMonitorsInTOF : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"UnwrapMonitor", "UnwrapSNS"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapSNS.h b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapSNS.h index a2fa09ad8fda193d2b10575a3abcdea95b5f30e9..51d555418235a8ead93763737a79c74d49bf9fea 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/UnwrapSNS.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/UnwrapSNS.h @@ -60,6 +60,7 @@ public: } int version() const override { return 1; } + const std::string category() const override { return "CorrectionFunctions\\InstrumentCorrections"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/UpdateScriptRepository.h b/Framework/Algorithms/inc/MantidAlgorithms/UpdateScriptRepository.h index 8fe8749094d8bdb276eeca9e64cd078c4c8d9be2..d3cc774266662034fcc379e23018fc37d8103999 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/UpdateScriptRepository.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/UpdateScriptRepository.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"DownloadInstrument"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/WeightedMean.h b/Framework/Algorithms/inc/MantidAlgorithms/WeightedMean.h index fdd1a7a39a150bca603152a7fdcdcf4f85cbbd26..e3872f59bf26293ac0f76318490ce7d22b7432ec 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/WeightedMean.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/WeightedMean.h @@ -51,6 +51,7 @@ public: } int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { return {"Mean"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Arithmetic"; } diff --git a/Framework/Algorithms/inc/MantidAlgorithms/WeightedMeanOfWorkspace.h b/Framework/Algorithms/inc/MantidAlgorithms/WeightedMeanOfWorkspace.h index e61de16ed746b3dcd3cfc6c8824dcad9e002f631..21cfe3befca51fa127892e06f048973757a5dba5 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/WeightedMeanOfWorkspace.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/WeightedMeanOfWorkspace.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Mean", "WeightedMean"}; + } const std::string category() const override; private: diff --git a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h index 6390c452d1e153f46c1e664dbfd1eca76b597914..d37bcde93b5b502de6fdabdac05efe441f3828fa 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/WienerSmooth.h @@ -37,6 +37,9 @@ class DLLExport WienerSmooth : public API::Algorithm { public: const std::string name() const override { return "WienerSmooth"; } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FFTSmooth"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h index 89030b9cee06fab5de9bb6415a7cd1a66245fd60..dd4cc1b0f358cebe2dad1d666681f5ddaf3242dc 100644 --- a/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h +++ b/Framework/Algorithms/inc/MantidAlgorithms/XDataConverter.h @@ -6,6 +6,7 @@ namespace Mantid { namespace HistogramData { +class HistogramDx; class HistogramX; } namespace Algorithms { diff --git a/Framework/Algorithms/src/ConjoinXRuns.cpp b/Framework/Algorithms/src/ConjoinXRuns.cpp index a19028d9bc86e5ee875f18d840e475502ea454fb..b9fc326800d0c28120bc9f78085fd9a4785ba6d1 100644 --- a/Framework/Algorithms/src/ConjoinXRuns.cpp +++ b/Framework/Algorithms/src/ConjoinXRuns.cpp @@ -10,6 +10,10 @@ #include "MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h" #include "MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h" #include "MantidGeometry/Instrument.h" +#include "MantidHistogramData/HistogramDx.h" +#include "MantidHistogramData/HistogramE.h" +#include "MantidHistogramData/HistogramX.h" +#include "MantidHistogramData/HistogramY.h" #include "MantidKernel/ArrayProperty.h" #include "MantidKernel/Exception.h" #include "MantidKernel/ListValidator.h" @@ -254,8 +258,8 @@ void ConjoinXRuns::fillHistory() { if (!isChild()) { // Loop over the input workspaces, making the call that copies their // history to the output one - for (auto inWS = m_inputWS.begin(); inWS != m_inputWS.end(); ++inWS) { - m_outWS->history().addHistory((*inWS)->getHistory()); + for (auto &inWS : m_inputWS) { + m_outWS->history().addHistory(inWS->getHistory()); } // Add the history for the current algorithm to the output m_outWS->history().addHistory(m_history); @@ -274,25 +278,31 @@ void ConjoinXRuns::joinSpectrum(int64_t wsIndex) { std::vector<double> spectrum; std::vector<double> errors; std::vector<double> axis; + std::vector<double> x; + std::vector<double> xerrors; spectrum.reserve(m_outWS->blocksize()); errors.reserve(m_outWS->blocksize()); axis.reserve(m_outWS->blocksize()); size_t index = static_cast<size_t>(wsIndex); - for (const auto &input : m_inputWS) { - auto y = input->y(index).rawData(); - auto e = input->e(index).rawData(); - std::vector<double> x; + const auto &y = input->y(index); + spectrum.insert(spectrum.end(), y.begin(), y.end()); + const auto &e = input->e(index); + errors.insert(errors.end(), e.begin(), e.end()); if (m_logEntry.empty()) { - x = input->x(index).rawData(); + const auto &x = input->x(index); + axis.insert(axis.end(), x.begin(), x.end()); } else { x = m_axisCache[input->getName()]; + axis.insert(axis.end(), x.begin(), x.end()); + } + if (input->hasDx(index)) { + const auto &dx = input->dx(index); + xerrors.insert(xerrors.end(), dx.begin(), dx.end()); } - spectrum.insert(spectrum.end(), y.begin(), y.end()); - errors.insert(errors.end(), e.begin(), e.end()); - axis.insert(axis.end(), x.begin(), x.end()); } - + if (!xerrors.empty()) + m_outWS->setPointStandardDeviations(index, xerrors); m_outWS->mutableY(index) = spectrum; m_outWS->mutableE(index) = errors; m_outWS->mutableX(index) = axis; diff --git a/Framework/Algorithms/src/CreateWorkspace.cpp b/Framework/Algorithms/src/CreateWorkspace.cpp index 768ebe0b2095c84f4bd10ad661262e0f4ea6fcb4..ca572b5f910b21c0137de45514dc418de5316c97 100644 --- a/Framework/Algorithms/src/CreateWorkspace.cpp +++ b/Framework/Algorithms/src/CreateWorkspace.cpp @@ -17,7 +17,6 @@ #include "MantidIndexing/IndexInfo.h" #include "MantidIndexing/SpectrumIndexSet.h" #include "MantidHistogramData/HistogramBuilder.h" -#include "MantidTypes/SpectrumDefinition.h" namespace Mantid { namespace Algorithms { @@ -47,7 +46,7 @@ void CreateWorkspace::init() { declareProperty(Kernel::make_unique<ArrayProperty<double>>("DataY", required), "Y-axis data values for workspace (measures)."); declareProperty(make_unique<ArrayProperty<double>>("DataE"), - "Error values for workspace. Optional."); + "Error values for workspace."); declareProperty(make_unique<PropertyWithValue<int>>("NSpec", 1), "Number of spectra to divide data into."); declareProperty("UnitX", "", "The unit to assign to the XAxis"); @@ -70,6 +69,8 @@ void CreateWorkspace::init() { Direction::Input, PropertyMode::Optional), "Name of a parent workspace."); + declareProperty(Kernel::make_unique<ArrayProperty<double>>("Dx"), + "X error values for workspace (optional)."); std::vector<std::string> propOptions{ Parallel::toString(Parallel::StorageMode::Cloned), Parallel::toString(Parallel::StorageMode::Distributed), @@ -102,6 +103,7 @@ void CreateWorkspace::exec() { const Property *const dataXprop = getProperty("DataX"); const Property *const dataYprop = getProperty("DataY"); const Property *const dataEprop = getProperty("DataE"); + const Property *const errorDxprop = getProperty("Dx"); const ArrayProperty<double> *pCheck = nullptr; @@ -120,6 +122,11 @@ void CreateWorkspace::exec() { throw std::invalid_argument("DataE cannot be casted to a double vector"); const std::vector<double> &dataE = *pCheck; + pCheck = dynamic_cast<const ArrayProperty<double> *>(errorDxprop); + if (!pCheck) + throw std::invalid_argument("Dx cannot be casted to a double vector"); + const std::vector<double> &dX = *pCheck; + const int nSpec = getProperty("NSpec"); const std::string xUnit = getProperty("UnitX"); const std::string vUnit = getProperty("VerticalAxisUnit"); @@ -159,6 +166,13 @@ void CreateWorkspace::exec() { histogramBuilder.setX(xSize); } histogramBuilder.setY(ySize); + + if (!dX.empty()) { + if (dX.size() != dataY.size()) + throw std::runtime_error("Dx must have the same size as DataY"); + histogramBuilder.setDx(ySize); + } + histogramBuilder.setDistribution(getProperty("Distribution")); auto histogram = histogramBuilder.build(); @@ -212,6 +226,10 @@ void CreateWorkspace::exec() { outputWS->mutableE(local_i) .assign(dataE.begin() + yStart, dataE.begin() + yEnd); + if (!dX.empty()) + outputWS->mutableDx(local_i) + .assign(dX.begin() + yStart, dX.begin() + yEnd); + progress.report(); PARALLEL_END_INTERUPT_REGION } diff --git a/Framework/Algorithms/src/CylinderAbsorption.cpp b/Framework/Algorithms/src/CylinderAbsorption.cpp index b8653ecc69e99a7d56f5bdb75c894efaa39cc97e..731b7fc4ff8d5fae054a28ab7c1f6a67017374a7 100644 --- a/Framework/Algorithms/src/CylinderAbsorption.cpp +++ b/Framework/Algorithms/src/CylinderAbsorption.cpp @@ -82,7 +82,7 @@ std::string CylinderAbsorption::sampleXML() { xmlShapeStream << "<cylinder id=\"detector-shape\"> " << "<centre-of-bottom-base x=\"" << samplePos.X() << "\" y=\"" << cylinderBase << "\" z=\"" << samplePos.Z() << "\" /> " - << "<axis x=\"0\" y=\"1\" z=\"0\" /> " + << R"(<axis x="0" y="1" z="0" /> )" << "<radius val=\"" << m_cylRadius << "\" /> " << "<height val=\"" << m_cylHeight << "\" /> " << "</cylinder>"; diff --git a/Framework/Algorithms/src/DiffractionFocussing.cpp b/Framework/Algorithms/src/DiffractionFocussing.cpp index b4cac6232c9d4fa8ee992438e889ef0fdd733c72..354ba051a11408e58f45f100753e07d0e7455e94 100644 --- a/Framework/Algorithms/src/DiffractionFocussing.cpp +++ b/Framework/Algorithms/src/DiffractionFocussing.cpp @@ -83,12 +83,12 @@ void DiffractionFocussing::exec() { if (iprogress_step == 0) iprogress_step = 1; std::vector<int64_t> resultIndeces; - for (auto g = groupNumbers.cbegin(); g != groupNumbers.end(); ++g) { + for (auto groupNumber : groupNumbers) { if (iprogress++ % iprogress_step == 0) { progress(0.68 + double(iprogress) / iprogress_count / 3); } - auto from = detectorGroups.lower_bound(*g); - auto to = detectorGroups.upper_bound(*g); + auto from = detectorGroups.lower_bound(groupNumber); + auto to = detectorGroups.upper_bound(groupNumber); std::vector<detid_t> detectorList; for (auto d = from; d != to; ++d) detectorList.push_back(static_cast<detid_t>(d->second)); diff --git a/Framework/Algorithms/src/ExtractMask.cpp b/Framework/Algorithms/src/ExtractMask.cpp index c595ccdad76938f19932bd873cdbfb7bc8bc72ac..2d474bf92b4c81227dcf97f01509a07d7ce648c5 100644 --- a/Framework/Algorithms/src/ExtractMask.cpp +++ b/Framework/Algorithms/src/ExtractMask.cpp @@ -54,9 +54,12 @@ void ExtractMask::exec() { std::vector<detid_t> detectorList; const auto &detInfo = inputWS->detectorInfo(); const auto &detIds = detInfo.detectorIDs(); - for (size_t i = 0; i < detInfo.size(); ++i) - if (detInfo.isMasked(i)) + for (size_t i = 0; i < detInfo.size(); ++i) { + if ((inputWSIsSpecial && inputMaskWS->isMasked(detIds[i])) || + detInfo.isMasked(i)) { detectorList.push_back(detIds[i]); + } + } // Create a new workspace for the results, copy from the input to ensure // that we copy over the instrument and current masking diff --git a/Framework/Algorithms/src/MagFormFactorCorrection.cpp b/Framework/Algorithms/src/MagFormFactorCorrection.cpp index ed5942f120738cef99b2c1a83917f8dda51feda5..cacd1d509d9f2e28abf8781e684fcb900462ec9f 100644 --- a/Framework/Algorithms/src/MagFormFactorCorrection.cpp +++ b/Framework/Algorithms/src/MagFormFactorCorrection.cpp @@ -84,8 +84,8 @@ void MagFormFactorCorrection::exec() { // Gets the vector of form factor values std::vector<double> FF; FF.reserve(Qvals.size()); - for (int64_t iQ = 0; iQ < (int64_t)Qvals.size(); iQ++) { - FF.push_back(ion.analyticalFormFactor(Qvals[iQ] * Qvals[iQ])); + for (double Qval : Qvals) { + FF.push_back(ion.analyticalFormFactor(Qval * Qval)); } if (!ffwsStr.empty()) { MatrixWorkspace_sptr ffws = API::WorkspaceFactory::Instance().create( diff --git a/Framework/Algorithms/src/MaxEnt.cpp b/Framework/Algorithms/src/MaxEnt.cpp index a87781e0f0bf5a2e7cfc7071efcfe2602e1df43c..c6d708b81a3877fc27f798b9d7e83b2181edea8e 100644 --- a/Framework/Algorithms/src/MaxEnt.cpp +++ b/Framework/Algorithms/src/MaxEnt.cpp @@ -53,39 +53,35 @@ const double THRESHOLD = 1E-6; /** removes zeros from converged results * @param ws :: [input] The input workspace with zeros -* @param maxIt :: [input] The max number of iteration this alg used +* @param itCount [input] The number of iterations this alg used for each +* spectrum * @param yLabel :: [input] y-label to use for returned ws * @return : ws cut down in lenght to maxIt */ -MatrixWorkspace_sptr removeZeros(const MatrixWorkspace_sptr &ws, - const size_t maxIt, - const ::std::string yLabel) { +MatrixWorkspace_sptr removeZeros(MatrixWorkspace_sptr &ws, + const std::vector<size_t> &itCount, + const std::string &yLabel) { ws->setYUnitLabel(yLabel); - try { - ws->getAxis(0)->unit() = - UnitFactory::Instance().create("Number of Iterations"); - } catch (Exception::NotFoundError &) { - ws->getAxis(0)->unit() = UnitFactory::Instance().create("Label"); - Unit_sptr unit = ws->getAxis(0)->unit(); - boost::shared_ptr<Units::Label> label = - boost::dynamic_pointer_cast<Units::Label>(unit); - label->setLabel("Number of Iterations", ""); - } + ws->getAxis(0)->unit() = UnitFactory::Instance().create("Label"); + Unit_sptr unit = ws->getAxis(0)->unit(); + boost::shared_ptr<Units::Label> label = + boost::dynamic_pointer_cast<Units::Label>(unit); + label->setLabel("Number of Iterations", ""); - if (maxIt == ws->readY(0).size()) { - return ws; - } const size_t nspec = ws->getNumberHistograms(); - MatrixWorkspace_sptr outWS = - WorkspaceFactory::Instance().create(ws, nspec, maxIt, maxIt); + if (itCount.empty()) { + return ws; // In case, we don't have any spectra + } for (size_t spec = 0; spec < nspec; spec++) { - outWS->setPoints(spec, Points(maxIt, LinearGenerator(0.0, 1.0))); - auto Data = ws->readY(spec); - outWS->setCounts(spec, - std::vector<double>(Data.begin(), Data.begin() + maxIt)); + auto &dataX = ws->dataX(spec); + dataX.resize(itCount[spec]); + auto &dataY = ws->dataY(spec); + dataY.resize(itCount[spec]); + auto &dataE = ws->dataE(spec); + dataE.resize(itCount[spec]); } - return outWS; + return ws; } } @@ -274,14 +270,14 @@ void MaxEnt::exec() { // Distance penalty for current image const double distEps = getProperty("DistancePenalty"); // Maximum number of iterations - const size_t niter = getProperty("MaxIterations"); + const size_t nIter = getProperty("MaxIterations"); // Maximum number of iterations in alpha chop const size_t alphaIter = getProperty("AlphaChopIterations"); // Number of spectra and datapoints // Read input workspace MatrixWorkspace_const_sptr inWS = getProperty("InputWorkspace"); // Number of spectra - size_t nspec = inWS->getNumberHistograms(); + size_t nSpec = inWS->getNumberHistograms(); // Number of data points - assumed to be constant between spectra or // this will throw an exception size_t npoints = inWS->blocksize() * resolutionFactor; @@ -290,7 +286,7 @@ void MaxEnt::exec() { // For now have the requirement that data must have non-zero // (and positive!) errors - for (size_t s = 0; s < nspec; s++) { + for (size_t s = 0; s < nSpec; s++) { auto errors = inWS->e(s).rawData(); size_t npoints = errors.size(); @@ -337,22 +333,24 @@ void MaxEnt::exec() { MatrixWorkspace_sptr outEvolChi; MatrixWorkspace_sptr outEvolTest; - nspec = complexData ? nspec / 2 : nspec; + nSpec = complexData ? nSpec / 2 : nSpec; outImageWS = - WorkspaceFactory::Instance().create(inWS, 2 * nspec, npoints, npoints); + WorkspaceFactory::Instance().create(inWS, 2 * nSpec, npoints, npoints); for (size_t i = 0; i < outImageWS->getNumberHistograms(); ++i) outImageWS->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); outDataWS = - WorkspaceFactory::Instance().create(inWS, 2 * nspec, npointsX, npoints); + WorkspaceFactory::Instance().create(inWS, 2 * nSpec, npointsX, npoints); for (size_t i = 0; i < outDataWS->getNumberHistograms(); ++i) outDataWS->getSpectrum(i).setDetectorID(static_cast<detid_t>(i + 1)); - outEvolChi = WorkspaceFactory::Instance().create(inWS, nspec, niter, niter); - outEvolTest = WorkspaceFactory::Instance().create(inWS, nspec, niter, niter); + outEvolChi = WorkspaceFactory::Instance().create(inWS, nSpec, nIter, nIter); + outEvolTest = WorkspaceFactory::Instance().create(inWS, nSpec, nIter, nIter); npoints = complexImage ? npoints * 2 : npoints; - size_t maxIt = 0; // used to determine max iterations used by alg - outEvolChi->setPoints(0, Points(niter, LinearGenerator(0.0, 1.0))); - for (size_t s = 0; s < nspec; s++) { + std::vector<size_t> iterationCounts; + iterationCounts.reserve(nSpec); + outEvolChi->setPoints(0, Points(nIter, LinearGenerator(0.0, 1.0))); + + for (size_t spec = 0; spec < nSpec; spec++) { // Start distribution (flat background) std::vector<double> image(npoints, background); @@ -360,22 +358,22 @@ void MaxEnt::exec() { std::vector<double> data; std::vector<double> errors; if (complexData) { - data = toComplex(inWS, s, false); // false -> data - errors = toComplex(inWS, s, true); // true -> errors + data = toComplex(inWS, spec, false); // false -> data + errors = toComplex(inWS, spec, true); // true -> errors } else { - data = inWS->y(s).rawData(); - errors = inWS->e(s).rawData(); + data = inWS->y(spec).rawData(); + errors = inWS->e(spec).rawData(); } // To record the algorithm's progress - std::vector<double> evolChi(niter, 0.); - std::vector<double> evolTest(niter, 0.); + std::vector<double> evolChi(nIter, 0.); + std::vector<double> evolTest(nIter, 0.); // Progress - Progress progress(this, 0.0, 1.0, niter); + Progress progress(this, 0.0, 1.0, nIter); // Run maxent algorithm - for (size_t it = 0; it < niter; it++) { + for (size_t it = 0; it < nIter; it++) { // Iterates one step towards the solution. This means calculating // quadratic coefficients, search directions, angle and chi-sq @@ -397,15 +395,15 @@ void MaxEnt::exec() { double currAngle = maxentCalculator.getAngle(); evolChi[it] = currChisq; evolTest[it] = currAngle; - if (it > maxIt) { - maxIt = it; - } + // Stop condition, solution found if ((std::abs(currChisq / ChiTargetOverN - 1.) < chiEps) && (currAngle < angle)) { - g_log.information() << "Stopped after " << it << " iterations" + // it + 1 iterations have been done because we count from zero + g_log.information() << "Stopped after " << it + 1 << " iterations" << std::endl; + iterationCounts.push_back(it + 1); break; } @@ -416,32 +414,32 @@ void MaxEnt::exec() { progress.report(); - } // iterations + } // Next Iteration // Get calculated data auto solData = maxentCalculator.getReconstructedData(); auto solImage = maxentCalculator.getImage(); // Populate the output workspaces - populateDataWS(inWS, s, nspec, solData, complexData, outDataWS); - populateImageWS(inWS, s, nspec, solImage, complexImage, outImageWS, + populateDataWS(inWS, spec, nSpec, solData, complexData, outDataWS); + populateImageWS(inWS, spec, nSpec, solImage, complexImage, outImageWS, autoShift); // Populate workspaces recording the evolution of Chi and Test // X values - outEvolChi->setSharedX(s, outEvolChi->sharedX(0)); - outEvolTest->setSharedX(s, outEvolChi->sharedX(0)); + outEvolChi->setSharedX(spec, outEvolChi->sharedX(0)); + outEvolTest->setSharedX(spec, outEvolChi->sharedX(0)); // Y values - outEvolChi->setCounts(s, std::move(evolChi)); - outEvolTest->setCounts(s, std::move(evolTest)); + outEvolChi->setCounts(spec, std::move(evolChi)); + outEvolTest->setCounts(spec, std::move(evolTest)); // No errors } // Next spectrum - // add 1 to maxIt to account for starting at 0 - maxIt++; - setProperty("EvolChi", removeZeros(outEvolChi, maxIt, "Chi squared")); - setProperty("EvolAngle", removeZeros(outEvolTest, maxIt, "Maximum Angle")); + setProperty("EvolChi", + removeZeros(outEvolChi, iterationCounts, "Chi squared")); + setProperty("EvolAngle", + removeZeros(outEvolTest, iterationCounts, "Maximum Angle")); setProperty("ReconstructedImage", outImageWS); setProperty("ReconstructedData", outDataWS); } diff --git a/Framework/Algorithms/src/PDFFourierTransform.cpp b/Framework/Algorithms/src/PDFFourierTransform.cpp index efd92caa5d60349175f4d818fa922c8ba6abaed3..58d8c50d48233879f78eb923962c184edfbf80e3 100644 --- a/Framework/Algorithms/src/PDFFourierTransform.cpp +++ b/Framework/Algorithms/src/PDFFourierTransform.cpp @@ -257,7 +257,7 @@ void PDFFourierTransform::exec() { } else { std::stringstream msg; msg << "Input data x-axis with unit \"" << inputXunit - << "\" is not supported (use \"MomentumTransfer\" or \"dSpacing\")"; + << R"(" is not supported (use "MomentumTransfer" or "dSpacing"))"; throw std::invalid_argument(msg.str()); } g_log.debug() << "Input unit is " << inputXunit << "\n"; diff --git a/Framework/Algorithms/src/PerformIndexOperations.cpp b/Framework/Algorithms/src/PerformIndexOperations.cpp index b00698a069e3c1f70b918a1b321861d9a0ed1baf..22ed20a842f082700d746bae1f7e887abbb1cad0 100644 --- a/Framework/Algorithms/src/PerformIndexOperations.cpp +++ b/Framework/Algorithms/src/PerformIndexOperations.cpp @@ -172,7 +172,7 @@ class AdditionParserRange : public CommandParserBase<AdditionCommand> { public: private: boost::regex getRegex() const override { - return boost::regex("^\\s*[0-9]+\\s*\\-\\s*[0-9]+\\s*$"); + return boost::regex(R"(^\s*[0-9]+\s*\-\s*[0-9]+\s*$)"); } std::string getSeparator() const override { return "-"; } }; @@ -184,7 +184,7 @@ class AdditionParser : public CommandParser { public: Command *interpret(const std::string &instruction) const override { Command *command = nullptr; - boost::regex ex("^\\s*[0-9]+\\s*\\+\\s*[0-9]+\\s*$"); + boost::regex ex(R"(^\s*[0-9]+\s*\+\s*[0-9]+\s*$)"); if (boost::regex_match(instruction, ex)) { std::vector<std::string> arguments; boost::split(arguments, instruction, boost::is_any_of("+")); @@ -210,7 +210,7 @@ class CropParserRange : public CommandParserBase<CropCommand> { public: private: boost::regex getRegex() const override { - return boost::regex("^\\s*[0-9]+\\s*:\\s*[0-9]+\\s*$"); + return boost::regex(R"(^\s*[0-9]+\s*:\s*[0-9]+\s*$)"); } std::string getSeparator() const override { return ":"; } }; @@ -319,7 +319,7 @@ void PerformIndexOperations::exec() { this->getProperty("ProcessingInstructions"); boost::regex re( - "^\\s*[0-9]+\\s*$|^(\\s*,*[0-9]+(\\s*(,|:|\\+|\\-)\\s*)*[0-9]*)*$"); + R"(^\s*[0-9]+\s*$|^(\s*,*[0-9]+(\s*(,|:|\+|\-)\s*)*[0-9]*)*$)"); if (!boost::regex_match(processingInstructions, re)) { throw std::invalid_argument("ProcessingInstructions are not well formed: " + processingInstructions); diff --git a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp index 553dcd3ab9573e8e92ee3d3fe285e4610c53fd5e..8a143b35f67b0825a31152b1d68be1cbaafeb94f 100644 --- a/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp +++ b/Framework/Algorithms/src/PolarizationEfficiencyCor.cpp @@ -557,13 +557,13 @@ void PolarizationEfficiencyCor::checkConsistentX( const auto &P2x = efficiencies.P2->x(); checkX(P2x, "P2"); // A local helper function to check an input workspace against F1. - auto checkWS = [&F1x, &checkX](const API::MatrixWorkspace_sptr &ws, - const std::string &tag) { - const auto nHist = ws->getNumberHistograms(); - for (size_t i = 0; i != nHist; ++i) { - checkX(ws->x(i), tag); - } - }; + auto checkWS = + [&checkX](const API::MatrixWorkspace_sptr &ws, const std::string &tag) { + const auto nHist = ws->getNumberHistograms(); + for (size_t i = 0; i != nHist; ++i) { + checkX(ws->x(i), tag); + } + }; if (inputs.mmWS) { checkWS(inputs.mmWS, Flippers::OffOff); } diff --git a/Framework/Algorithms/src/RealFFT.cpp b/Framework/Algorithms/src/RealFFT.cpp index 4c8d099ca5f9c651223820a16236832e40745501..43df23eaba2906f532251afb6c3f09c01fdbad8e 100644 --- a/Framework/Algorithms/src/RealFFT.cpp +++ b/Framework/Algorithms/src/RealFFT.cpp @@ -52,7 +52,7 @@ void RealFFT::init() { std::vector<std::string> fft_dir{"Forward", "Backward"}; declareProperty( "Transform", "Forward", boost::make_shared<StringListValidator>(fft_dir), - "The direction of the transform: \"Forward\" or \"Backward\"."); + R"(The direction of the transform: "Forward" or "Backward".)"); declareProperty( "IgnoreXBins", false, "Ignores the requirement that X bins be linear and of the same size. " diff --git a/Framework/Algorithms/src/ReflectometryReductionOne.cpp b/Framework/Algorithms/src/ReflectometryReductionOne.cpp deleted file mode 100644 index 3d8e2a2dc971cb8260577504d599e7df3bdaac57..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/src/ReflectometryReductionOne.cpp +++ /dev/null @@ -1,855 +0,0 @@ -#include "MantidAlgorithms/BoostOptionalToAlgorithmProperty.h" -#include "MantidAlgorithms/ReflectometryReductionOne.h" -#include "MantidAPI/Axis.h" -#include "MantidAPI/WorkspaceUnitValidator.h" -#include "MantidGeometry/Instrument/ReferenceFrame.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/EnabledWhenProperty.h" -#include "MantidKernel/Tolerance.h" -#include "MantidKernel/Unit.h" - -using namespace Mantid::Kernel; -using namespace Mantid::API; -using namespace Mantid::Geometry; - -namespace Mantid { -namespace Algorithms { - -/*Anonomous namespace */ -namespace { -/** -* Helper non-member function for translating all the workspace indexes in an -*origin workspace into workspace indexes -* of a host end-point workspace. This is done using spectrum numbers as the -*intermediate. -* -* This function will throw a runtime error if the specId are not found to exist -*on the host end-point workspace. -* -* @param originWS : Origin workspace, which provides the original workspace -*index to spectrum number mapping. -* @param hostWS : Workspace onto which the resulting workspace indexes will be -*hosted -* @return Remapped workspace indexes applicable for the host workspace. results -*as comma separated string. -*/ -std::string createWorkspaceIndexListFromDetectorWorkspace( - MatrixWorkspace_const_sptr originWS, MatrixWorkspace_const_sptr hostWS) { - auto spectrumMap = originWS->getSpectrumToWorkspaceIndexMap(); - auto it = spectrumMap.begin(); - std::stringstream result; - specnum_t specId = (*it).first; - result << static_cast<int>(hostWS->getIndexFromSpectrumNumber(specId)); - ++it; - for (; it != spectrumMap.end(); ++it) { - specId = (*it).first; - result << "," - << static_cast<int>(hostWS->getIndexFromSpectrumNumber(specId)); - } - return result.str(); -} - -const std::string multiDetectorAnalysis = "MultiDetectorAnalysis"; -const std::string pointDetectorAnalysis = "PointDetectorAnalysis"; -const std::string tofUnitId = "TOF"; -const std::string wavelengthUnitId = "Wavelength"; - -/** -* Helper free function to get the ordered spectrum numbers from a workspace. -* @param ws -* @return -*/ -std::vector<int> getSpectrumNumbers(MatrixWorkspace_sptr &ws) { - auto specToWSIndexMap = ws->getSpectrumToWorkspaceIndexMap(); - std::vector<int> keys(specToWSIndexMap.size()); - size_t i = 0; - for (auto it = specToWSIndexMap.begin(); it != specToWSIndexMap.end(); - ++it, ++i) { - keys[i] = static_cast<int>(it->first); - } - std::sort( - keys.begin(), - keys.end()); // Sort the keys, as the order is not guaranteed in the map. - - return keys; -} - -/** -* Helper free function to calculate MomentumTransfer from lambda and theta -* @param lambda : Value in wavelength -* @param theta : Value in Degrees -* @return MomentumTransfer -* @ -*/ -double calculateQ(double lambda, double theta) { - if (lambda == 0.0) - throw std::runtime_error("Minimum/Maximum value of the IvsLambda Workspace " - "is 0. Cannot calculate Q"); - double thetaInRad = theta * M_PI / 180; - return (4 * M_PI * sin(thetaInRad)) / lambda; -} -} -/* End of ananomous namespace */ - -// Register the algorithm into the AlgorithmFactory -DECLARE_ALGORITHM(ReflectometryReductionOne) - -//---------------------------------------------------------------------------------------------- -/// Algorithm's name for identification. @see Algorithm::name -const std::string ReflectometryReductionOne::name() const { - return "ReflectometryReductionOne"; -} - -/// Algorithm's version for identification. @see Algorithm::version -int ReflectometryReductionOne::version() const { return 1; } - -/// Algorithm's category for identification. @see Algorithm::category -const std::string ReflectometryReductionOne::category() const { - return "Reflectometry"; -} - -//---------------------------------------------------------------------------------------------- - -//---------------------------------------------------------------------------------------------- -/** Initialize the algorithm's properties. -*/ -void ReflectometryReductionOne::init() { - - declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( - "InputWorkspace", "", Direction::Input), - "Run to reduce."); - - std::vector<std::string> propOptions; - propOptions.push_back(pointDetectorAnalysis); - propOptions.push_back(multiDetectorAnalysis); - - declareProperty( - "AnalysisMode", "PointDetectorAnalysis", - boost::make_shared<StringListValidator>(propOptions), - "The type of analysis to perform. Point detector or multi detector."); - - declareProperty(make_unique<ArrayProperty<int>>("RegionOfDirectBeam"), - "Indices of the spectra a pair (lower, upper) that mark the " - "ranges that correspond to the direct beam in multi-detector " - "mode."); - - this->initIndexInputs(); - this->initWavelengthInputs(); - - declareProperty(make_unique<PropertyWithValue<std::string>>( - "DetectorComponentName", "", Direction::Input), - "Name of the detector component i.e. point-detector. If " - "these are not specified, the algorithm will attempt lookup " - "using a standard naming convention."); - - declareProperty(make_unique<PropertyWithValue<std::string>>( - "SampleComponentName", "", Direction::Input), - "Name of the sample component i.e. some-surface-holder. If " - "these are not specified, the algorithm will attempt lookup " - "using a standard naming convention."); - - declareProperty(make_unique<WorkspaceProperty<>>("OutputWorkspace", "", - Direction::Output), - "Output Workspace IvsQ."); - - declareProperty(make_unique<WorkspaceProperty<>>("OutputWorkspaceWavelength", - "", Direction::Output, - PropertyMode::Optional), - "Output Workspace IvsLam. Intermediate workspace."); - - declareProperty(make_unique<PropertyWithValue<double>>( - "ThetaIn", Mantid::EMPTY_DBL(), Direction::Input), - "Final theta value in degrees. Optional, this value will be " - "calculated internally and provided as ThetaOut if not " - "provided."); - - declareProperty(make_unique<PropertyWithValue<double>>( - "ThetaOut", Mantid::EMPTY_DBL(), Direction::Output), - "Calculated final theta in degrees."); - - declareProperty("NormalizeByIntegratedMonitors", true, - "Normalize by dividing by the integrated monitors."); - - declareProperty(make_unique<PropertyWithValue<bool>>( - "CorrectDetectorPositions", true, Direction::Input), - "Correct detector positions using ThetaIn (if given)"); - - declareProperty( - make_unique<WorkspaceProperty<MatrixWorkspace>>( - "FirstTransmissionRun", "", Direction::Input, PropertyMode::Optional), - "First transmission run, or the low wavelength transmission run if " - "SecondTransmissionRun is also provided."); - - auto inputValidator = boost::make_shared<WorkspaceUnitValidator>(tofUnitId); - declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( - "SecondTransmissionRun", "", Direction::Input, - PropertyMode::Optional, inputValidator), - "Second, high wavelength transmission run. Optional. Causes " - "the FirstTransmissionRun to be treated as the low " - "wavelength transmission run."); - - this->initStitchingInputs(); - - declareProperty(make_unique<PropertyWithValue<bool>>("StrictSpectrumChecking", - true, Direction::Input), - "Enforces spectrum number checking prior to normalization"); - - std::vector<std::string> correctionAlgorithms = { - "None", "PolynomialCorrection", "ExponentialCorrection"}; - declareProperty("CorrectionAlgorithm", "None", - boost::make_shared<StringListValidator>(correctionAlgorithms), - "The type of correction to perform."); - - declareProperty(make_unique<ArrayProperty<double>>("Polynomial"), - "Coefficients to be passed to the PolynomialCorrection" - " algorithm."); - - declareProperty( - make_unique<PropertyWithValue<double>>("C0", 0.0, Direction::Input), - "C0 value to be passed to the ExponentialCorrection algorithm."); - - declareProperty( - make_unique<PropertyWithValue<double>>("C1", 0.0, Direction::Input), - "C1 value to be passed to the ExponentialCorrection algorithm."); - - setPropertyGroup("CorrectionAlgorithm", "Polynomial Corrections"); - setPropertyGroup("Polynomial", "Polynomial Corrections"); - setPropertyGroup("C0", "Polynomial Corrections"); - setPropertyGroup("C1", "Polynomial Corrections"); - - setPropertySettings( - "Polynomial", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "PolynomialCorrection")); - setPropertySettings( - "C0", Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "ExponentialCorrection")); - setPropertySettings( - "C1", Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "ExponentialCorrection")); - - setPropertyGroup("FirstTransmissionRun", "Transmission"); - setPropertyGroup("SecondTransmissionRun", "Transmission"); - setPropertyGroup("Params", "Transmission"); - setPropertyGroup("StartOverlap", "Transmission"); - setPropertyGroup("EndOverlap", "Transmission"); - - // Only ask for transmission parameters when a FirstTranmissionRun has been - // provided - setPropertySettings("SecondTransmissionRun", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "FirstTransmissionRun", IS_NOT_DEFAULT)); - setPropertySettings("Params", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "FirstTransmissionRun", IS_NOT_DEFAULT)); - setPropertySettings("StartOverlap", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "FirstTransmissionRun", IS_NOT_DEFAULT)); - setPropertySettings("EndOverlap", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "FirstTransmissionRun", IS_NOT_DEFAULT)); - - // Only use region of direct beam when in multi-detector analysis mode. - setPropertySettings( - "RegionOfDirectBeam", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "AnalysisMode", IS_EQUAL_TO, "MultiDetectorAnalysis")); - declareProperty("ScaleFactor", Mantid::EMPTY_DBL(), - "Factor you wish to scale Q workspace by.", Direction::Input); - declareProperty("MomentumTransferMinimum", Mantid::EMPTY_DBL(), - "Minimum Q value in IvsQ " - "Workspace. Used for Rebinning " - "the IvsQ Workspace", - Direction::Input); - declareProperty("MomentumTransferStep", Mantid::EMPTY_DBL(), - "Resolution value in IvsQ Workspace. Used for Rebinning the " - "IvsQ Workspace. This value will be made minus to apply " - "logarithmic rebinning. If you wish to have linear " - "bin-widths then please provide a negative DQQ", - Direction::Input); - declareProperty("MomentumTransferMaximum", Mantid::EMPTY_DBL(), - "Maximum Q value in IvsQ " - "Workspace. Used for Rebinning " - "the IvsQ Workspace", - Direction::Input); -} - -/** -* Correct the position of the detectors based on the input theta value. -* @param toCorrect : Workspace to correct detector positions on. -* @param thetaInDeg : Theta in degrees to use in correction calculations. -* @param isPointDetector : True if using point detector analysis -* @return Copy with positions corrected. -*/ -MatrixWorkspace_sptr -ReflectometryReductionOne::correctPosition(API::MatrixWorkspace_sptr &toCorrect, - const double &thetaInDeg, - const bool isPointDetector) { - g_log.debug("Correcting position using theta."); - - auto correctPosAlg = this->createChildAlgorithm( - "SpecularReflectionPositionCorrect", -1, -1, true, 1); - correctPosAlg->initialize(); - correctPosAlg->setProperty("InputWorkspace", toCorrect); - - const std::string analysisMode = this->getProperty("AnalysisMode"); - correctPosAlg->setProperty("AnalysisMode", analysisMode); - auto instrument = toCorrect->getInstrument(); - IComponent_const_sptr sample = this->getSurfaceSampleComponent(instrument); - correctPosAlg->setProperty("SampleComponentName", sample->getName()); - correctPosAlg->setProperty("TwoThetaIn", thetaInDeg * 2); - - if (isPointDetector) { - IComponent_const_sptr detector = - this->getDetectorComponent(instrument, isPointDetector); - correctPosAlg->setProperty("DetectorComponentName", detector->getName()); - } else { - auto specNumbers = getSpectrumNumbers(toCorrect); - correctPosAlg->setProperty("SpectrumNumbersOfDetectors", specNumbers); - for (auto specNumber : specNumbers) { - std::stringstream buffer; - buffer << "Writing out: " << specNumber; - g_log.notice(buffer.str()); - } - } - correctPosAlg->execute(); - MatrixWorkspace_sptr corrected = - correctPosAlg->getProperty("OutputWorkspace"); - - return corrected; -} -/** -* @param toConvert : workspace used to get instrument components -* @param thetaOut : angle between sample and detectors (in Degrees) -* @return Theta : the value by which we rotate the source (in Degrees) -*/ -double ReflectometryReductionOne::getAngleForSourceRotation( - MatrixWorkspace_sptr toConvert, double thetaOut) { - auto instrument = toConvert->getInstrument(); - auto instrumentUpVector = instrument->getReferenceFrame()->vecPointingUp(); - // check to see if calculated theta is the same as theta from instrument setup - auto instrumentBeamDirection = instrument->getBeamDirection(); - double currentThetaInFromInstrument = - instrumentUpVector.angle(instrumentBeamDirection) * (180 / M_PI) - 90; - bool isInThetaEqualToOutTheta = - std::abs(currentThetaInFromInstrument - thetaOut) < - Mantid::Kernel::Tolerance; - // the angle by which we rotate the source - double rotationTheta = 0.0; - if (!isInThetaEqualToOutTheta /*source needs rotation*/) { - rotationTheta = thetaOut - currentThetaInFromInstrument; - } - return rotationTheta; -} - -/** -* Convert an input workspace into an IvsQ workspace. -* -* @param toConvert : Workspace to convert -* @param bCorrectPosition : Flag to indicate that detector positions should be -*corrected based on the input theta values. -* @param thetaInDeg : Theta in Degrees. Used for correction. -* @param isPointDetector: Is point detector analysis -* @return -*/ -Mantid::API::MatrixWorkspace_sptr ReflectometryReductionOne::toIvsQ( - API::MatrixWorkspace_sptr &toConvert, const bool bCorrectPosition, - OptionalDouble &thetaInDeg, const bool isPointDetector) { - /* - * Can either calculate a missing theta value for the purposes of reporting, - * or correct positions based on a theta value, - * but not both. The processing is effectively circular if both are applied. - */ - if (!thetaInDeg.is_initialized()) { - g_log.debug("Calculating final theta."); - - auto correctThetaAlg = this->createChildAlgorithm( - "SpecularReflectionCalculateTheta", -1, -1, true, 1); - correctThetaAlg->initialize(); - correctThetaAlg->setProperty("InputWorkspace", toConvert); - const std::string analysisMode = this->getProperty("AnalysisMode"); - correctThetaAlg->setProperty("AnalysisMode", analysisMode); - const std::string sampleComponentName = - this->getProperty("SampleComponentName"); - correctThetaAlg->setProperty("SampleComponentName", sampleComponentName); - if (isPointDetector) { - const std::string detectorComponentName = - this->getPropertyValue("DetectorComponentName"); - correctThetaAlg->setProperty("DetectorComponentName", - detectorComponentName); - } else { - std::vector<int> spectrumNumbers = getSpectrumNumbers(toConvert); - correctThetaAlg->setProperty("SpectrumNumbersOfDetectors", - spectrumNumbers); - } - correctThetaAlg->execute(); - const double twoTheta = correctThetaAlg->getProperty("TwoTheta"); - - thetaInDeg = twoTheta / 2; - - } else if (bCorrectPosition) { - toConvert = correctPosition(toConvert, thetaInDeg.get(), isPointDetector); - } - - // Rotate the source (needed before ConvertUnits) - double rotationTheta = getAngleForSourceRotation(toConvert, thetaInDeg.get()); - if (rotationTheta != 0.0) { - auto rotateSource = this->createChildAlgorithm("RotateSource"); - rotateSource->setChild(true); - rotateSource->initialize(); - rotateSource->setProperty("Workspace", toConvert); - rotateSource->setProperty("Angle", rotationTheta); - rotateSource->execute(); - } - - // Always convert units. - auto convertUnits = this->createChildAlgorithm("ConvertUnits"); - convertUnits->initialize(); - convertUnits->setProperty("InputWorkspace", toConvert); - convertUnits->setProperty("Target", "MomentumTransfer"); - convertUnits->execute(); - MatrixWorkspace_sptr inQ = convertUnits->getProperty("OutputWorkspace"); - - // Rotate the source back to its original position - if (rotationTheta != 0.0) { - // for IvsLam Workspace - auto rotateSource = this->createChildAlgorithm("RotateSource"); - rotateSource->setChild(true); - rotateSource->initialize(); - rotateSource->setProperty("Workspace", toConvert); - rotateSource->setProperty("Angle", -rotationTheta); - rotateSource->execute(); - // for IvsQ Workspace - rotateSource->setProperty("Workspace", inQ); - rotateSource->setProperty("Angle", -rotationTheta); - rotateSource->execute(); - } - - return inQ; -} - -/** -* Get the sample component. Use the name provided as a property as the basis -*for the lookup as a priority. -* -* Throws if the name is invalid. -* @param inst : Instrument to search through -* @return : The component : The component object found. -*/ -Mantid::Geometry::IComponent_const_sptr -ReflectometryReductionOne::getSurfaceSampleComponent( - Mantid::Geometry::Instrument_const_sptr inst) { - std::string sampleComponent = "some-surface-holder"; - if (!isPropertyDefault("SampleComponentName")) { - sampleComponent = this->getPropertyValue("SampleComponentName"); - } - auto searchResult = inst->getComponentByName(sampleComponent); - if (searchResult == nullptr) { - throw std::invalid_argument(sampleComponent + - " does not exist. Check input properties."); - } - return searchResult; -} - -/** -* Get the detector component. Use the name provided as a property as the basis -*for the lookup as a priority. -* -* Throws if the name is invalid. -* @param inst : Instrument to search through. -* @param isPointDetector : True if this is a point detector. Used to guess a -*name. -* @return The component : The component object found. -*/ -boost::shared_ptr<const Mantid::Geometry::IComponent> -ReflectometryReductionOne::getDetectorComponent( - Mantid::Geometry::Instrument_const_sptr inst, const bool isPointDetector) { - std::string componentToCorrect = - isPointDetector ? "point-detector" : "line-detector"; - if (!isPropertyDefault("DetectorComponentName")) { - componentToCorrect = this->getPropertyValue("DetectorComponentName"); - } - boost::shared_ptr<const IComponent> searchResult = - inst->getComponentByName(componentToCorrect); - if (searchResult == nullptr) { - throw std::invalid_argument(componentToCorrect + - " does not exist. Check input properties."); - } - return searchResult; -} - -//---------------------------------------------------------------------------------------------- -/** Execute the algorithm. -*/ -void ReflectometryReductionOne::exec() { - MatrixWorkspace_sptr runWS = getProperty("InputWorkspace"); - - OptionalMatrixWorkspace_sptr firstTransmissionRun; - OptionalMatrixWorkspace_sptr secondTransmissionRun; - OptionalDouble stitchingStart; - OptionalDouble stitchingDelta; - OptionalDouble stitchingEnd; - OptionalDouble stitchingStartOverlap; - OptionalDouble stitchingEndOverlap; - - getTransmissionRunInfo(firstTransmissionRun, secondTransmissionRun, - stitchingStart, stitchingDelta, stitchingEnd, - stitchingStartOverlap, stitchingEndOverlap); - - OptionalDouble theta; - if (!isPropertyDefault("ThetaIn")) { - double temp = this->getProperty("ThetaIn"); - theta = temp; - } - const std::string strAnalysisMode = getProperty("AnalysisMode"); - const bool isPointDetector = (pointDetectorAnalysis == strAnalysisMode); - const bool isMultiDetector = (multiDetectorAnalysis == strAnalysisMode); - - const MinMax wavelengthInterval = - this->getMinMax("WavelengthMin", "WavelengthMax"); - - const std::string processingCommands = getWorkspaceIndexList(); - - OptionalWorkspaceIndexes directBeam; - fetchOptionalLowerUpperPropertyValue("RegionOfDirectBeam", isPointDetector, - directBeam); - - auto instrument = runWS->getInstrument(); - - const OptionalInteger i0MonitorIndex = checkForOptionalInstrumentDefault<int>( - this, "I0MonitorIndex", instrument, "I0MonitorIndex"); - - const OptionalMinMax monitorBackgroundWavelengthInterval = getOptionalMinMax( - this, "MonitorBackgroundWavelengthMin", "MonitorBackgroundWavelengthMax", - instrument, "MonitorBackgroundWavelengthMin", - "MonitorBackgroundWavelengthMax"); - const OptionalMinMax monitorIntegrationWavelengthInterval = getOptionalMinMax( - this, "MonitorIntegrationWavelengthMin", - "MonitorIntegrationWavelengthMax", instrument, - "MonitorIntegrationWavelengthMin", "MonitorIntegrationWavelengthMax"); - - const bool correctDetectorPositions = getProperty("CorrectDetectorPositions"); - - MatrixWorkspace_sptr IvsLam; // Output workspace - MatrixWorkspace_sptr IvsQ; // Output workspace - - auto xUnitID = runWS->getAxis(0)->unit()->unitID(); - - if (xUnitID == "Wavelength") { - // If the input workspace is in lambda, we don't need to do any corrections, - // just use it as is. - g_log.information("Input workspace already in unit 'Wavelength'. Skipping " - "lambda conversions."); - IvsLam = runWS; - } else if (xUnitID == "TOF") { - // If the input workspace is in TOF, do some corrections and generate IvsLam - // from it. - DetectorMonitorWorkspacePair inLam = - toLam(runWS, processingCommands, i0MonitorIndex, wavelengthInterval, - monitorBackgroundWavelengthInterval); - auto detectorWS = inLam.get<0>(); - auto monitorWS = inLam.get<1>(); - - if (isMultiDetector) { - if (directBeam.is_initialized()) { - // Sum over the direct beam. - WorkspaceIndexList db = directBeam.get(); - std::stringstream buffer; - buffer << db.front() << "-" << db.back(); - MatrixWorkspace_sptr regionOfDirectBeamWS = - this->toLamDetector(buffer.str(), runWS, wavelengthInterval); - - // Rebin to the detector workspace - auto rebinToWorkspaceAlg = - this->createChildAlgorithm("RebinToWorkspace"); - rebinToWorkspaceAlg->initialize(); - rebinToWorkspaceAlg->setProperty("WorkspaceToRebin", - regionOfDirectBeamWS); - rebinToWorkspaceAlg->setProperty("WorkspaceToMatch", detectorWS); - rebinToWorkspaceAlg->execute(); - regionOfDirectBeamWS = - rebinToWorkspaceAlg->getProperty("OutputWorkspace"); - - // Normalize by the direct beam. - detectorWS = divide(detectorWS, regionOfDirectBeamWS); - } - } - - const bool normalizeByIntMon = getProperty("NormalizeByIntegratedMonitors"); - if (normalizeByIntMon) { - auto integrationAlg = this->createChildAlgorithm("Integration"); - integrationAlg->initialize(); - integrationAlg->setProperty("InputWorkspace", monitorWS); - if (monitorIntegrationWavelengthInterval.is_initialized()) { - integrationAlg->setProperty( - "RangeLower", monitorIntegrationWavelengthInterval.get().get<0>()); - integrationAlg->setProperty( - "RangeUpper", monitorIntegrationWavelengthInterval.get().get<1>()); - } - integrationAlg->execute(); - MatrixWorkspace_sptr integratedMonitor = - integrationAlg->getProperty("OutputWorkspace"); - - IvsLam = divide( - detectorWS, - integratedMonitor); // Normalize by the integrated monitor counts. - } else { - IvsLam = divide(detectorWS, monitorWS); - } - } else { - // Neither TOF or Lambda? Abort. - throw std::invalid_argument( - "InputWorkspace must have units of TOF or Wavelength"); - } - - if (firstTransmissionRun.is_initialized()) { - // Perform transmission correction. - IvsLam = this->transmissonCorrection( - IvsLam, wavelengthInterval, monitorBackgroundWavelengthInterval, - monitorIntegrationWavelengthInterval, i0MonitorIndex, - firstTransmissionRun.get(), secondTransmissionRun, stitchingStart, - stitchingDelta, stitchingEnd, stitchingStartOverlap, - stitchingEndOverlap, processingCommands); - } else if (getPropertyValue("CorrectionAlgorithm") != "None") { - IvsLam = algorithmicCorrection(IvsLam); - } else { - g_log.warning("No transmission correction will be applied."); - } - - IvsQ = this->toIvsQ(IvsLam, correctDetectorPositions, theta, isPointDetector); - double momentumTransferMinimum = getProperty("MomentumTransferMinimum"); - double momentumTransferStep = getProperty("MomentumTransferStep"); - double momentumTransferMaximum = getProperty("MomentumTransferMaximum"); - MantidVec QParams; - if (isDefault("MomentumTransferMinimum")) - momentumTransferMinimum = calculateQ(IvsLam->x(0).back(), theta.get()); - if (isDefault("MomentumTransferMaximum")) - momentumTransferMaximum = calculateQ(IvsLam->x(0).front(), theta.get()); - if (isDefault("MomentumTransferStep")) { - // if the DQQ is not given for this run. - // we will use NRCalculateSlitResolution to produce this value - // for us. - IAlgorithm_sptr calcResAlg = - createChildAlgorithm("NRCalculateSlitResolution"); - calcResAlg->setProperty("Workspace", runWS); - calcResAlg->setProperty("TwoTheta", theta.get()); - calcResAlg->execute(); - if (!calcResAlg->isExecuted()) - throw std::runtime_error( - "NRCalculateSlitResolution failed. Please manually " - "enter a value for MomentumTransferStep."); - momentumTransferStep = calcResAlg->getProperty("Resolution"); - } - if (momentumTransferMinimum > momentumTransferMaximum) - throw std::invalid_argument("MomentumTransferMinimum must be less than " - "MomentumTransferMaximum. Please check your " - "inputs for these Properties."); - QParams.push_back(momentumTransferMinimum); - QParams.push_back(-momentumTransferStep); - QParams.push_back(momentumTransferMaximum); - IAlgorithm_sptr algRebin = this->createChildAlgorithm("Rebin"); - algRebin->initialize(); - algRebin->setProperty("InputWorkspace", IvsQ); - algRebin->setProperty("OutputWorkspace", IvsQ); - algRebin->setProperty("Params", QParams); - algRebin->execute(); - if (!algRebin->isExecuted()) - throw std::runtime_error("Failed to run Rebin algorithm"); - IvsQ = algRebin->getProperty("OutputWorkspace"); - double scaleFactor = getProperty("ScaleFactor"); - if (!isDefault("ScaleFactor")) { - IAlgorithm_sptr algScale = this->createChildAlgorithm("Scale"); - algScale->initialize(); - algScale->setProperty("InputWorkspace", IvsQ); - algScale->setProperty("OutputWorkspace", IvsQ); - algScale->setProperty("Factor", 1.0 / scaleFactor); - algScale->execute(); - if (!algScale->isExecuted()) - throw std::runtime_error("Failed to run Scale algorithm"); - IvsQ = algScale->getProperty("OutputWorkspace"); - } - setProperty("ThetaOut", theta.get()); - setProperty("OutputWorkspaceWavelength", IvsLam); - setProperty("OutputWorkspace", IvsQ); - // setting these values so the Interface can retrieve them from - // ReflectometryReductionOneAuto. - setProperty("MomentumTransferMinimum", momentumTransferMinimum); - setProperty("MomentumTransferStep", momentumTransferStep); - setProperty("MomentumTransferMaximum", momentumTransferMaximum); -} - -/** -* Perform Transmission Corrections. -* @param IvsLam : Run workspace which is to be normalized by the results of the -* transmission corrections. -* @param wavelengthInterval : Wavelength interval for the run workspace. -* @param wavelengthMonitorBackgroundInterval : Wavelength interval for the -* monitor background -* @param wavelengthMonitorIntegrationInterval : Wavelength interval for the -* monitor integration -* @param i0MonitorIndex : Monitor index for the I0 monitor -* @param firstTransmissionRun : The first transmission run -* @param secondTransmissionRun : The second transmission run (optional) -* @param stitchingStart : Stitching start in wavelength (optional but dependent -* on secondTransmissionRun) -* @param stitchingDelta : Stitching delta in wavelength (optional but dependent -* on secondTransmissionRun) -* @param stitchingEnd : Stitching end in wavelength (optional but dependent on -* secondTransmissionRun) -* @param stitchingStartOverlap : Stitching start wavelength overlap (optional -* but dependent on secondTransmissionRun) -* @param stitchingEndOverlap : Stitching end wavelength overlap (optional but -* dependent on secondTransmissionRun) -* @param numeratorProcessingCommands: Processing commands used on detector -* workspace. -* @return Normalized run workspace by the transmission workspace, which have -* themselves been converted to Lam, normalized by monitors and possibly -* stitched together. -*/ -MatrixWorkspace_sptr ReflectometryReductionOne::transmissonCorrection( - MatrixWorkspace_sptr IvsLam, const MinMax &wavelengthInterval, - const OptionalMinMax &wavelengthMonitorBackgroundInterval, - const OptionalMinMax &wavelengthMonitorIntegrationInterval, - const OptionalInteger &i0MonitorIndex, - MatrixWorkspace_sptr firstTransmissionRun, - OptionalMatrixWorkspace_sptr secondTransmissionRun, - const OptionalDouble &stitchingStart, const OptionalDouble &stitchingDelta, - const OptionalDouble &stitchingEnd, - const OptionalDouble &stitchingStartOverlap, - const OptionalDouble &stitchingEndOverlap, - const std::string &numeratorProcessingCommands) { - g_log.debug( - "Extracting first transmission run workspace indexes from spectra"); - - const bool strictSpectrumChecking = getProperty("StrictSpectrumChecking"); - - MatrixWorkspace_sptr denominator = firstTransmissionRun; - Unit_const_sptr xUnit = firstTransmissionRun->getAxis(0)->unit(); - if (xUnit->unitID() == tofUnitId) { - std::string spectrumProcessingCommands = numeratorProcessingCommands; - /* - If we have strict spectrum checking, the processing commands need to be - made from the - numerator workspace AND the transmission workspace based on matching - spectrum numbers. - */ - if (strictSpectrumChecking) { - spectrumProcessingCommands = - createWorkspaceIndexListFromDetectorWorkspace(IvsLam, - firstTransmissionRun); - } - - // Make the transmission run. - auto alg = this->createChildAlgorithm("CreateTransmissionWorkspace", -1, -1, - true, 1); - alg->initialize(); - alg->setProperty("FirstTransmissionRun", firstTransmissionRun); - if (secondTransmissionRun.is_initialized()) { - alg->setProperty("SecondTransmissionRun", secondTransmissionRun.get()); - - if (stitchingStart.is_initialized() && stitchingEnd.is_initialized() && - stitchingDelta.is_initialized()) { - const std::vector<double> params = { - stitchingStart.get(), stitchingDelta.get(), stitchingEnd.get()}; - alg->setProperty("Params", params); - } else if (stitchingDelta.is_initialized()) { - alg->setProperty("Params", - std::vector<double>(1, stitchingDelta.get())); - } - if (stitchingStartOverlap.is_initialized()) { - alg->setProperty("StartOverlap", stitchingStartOverlap.get()); - } - if (stitchingEndOverlap.is_initialized()) { - alg->setProperty("EndOverlap", stitchingEndOverlap.get()); - } - } - alg->setProperty("ProcessingInstructions", spectrumProcessingCommands); - if (i0MonitorIndex.is_initialized()) { - alg->setProperty("I0MonitorIndex", i0MonitorIndex.get()); - } - alg->setProperty("WavelengthMin", wavelengthInterval.get<0>()); - alg->setProperty("WavelengthMax", wavelengthInterval.get<1>()); - if (wavelengthMonitorBackgroundInterval.is_initialized()) { - alg->setProperty("MonitorBackgroundWavelengthMin", - wavelengthMonitorBackgroundInterval.get().get<0>()); - alg->setProperty("MonitorBackgroundWavelengthMax", - wavelengthMonitorBackgroundInterval.get().get<1>()); - } - if (wavelengthMonitorIntegrationInterval.is_initialized()) { - alg->setProperty("MonitorIntegrationWavelengthMin", - wavelengthMonitorIntegrationInterval.get().get<0>()); - alg->setProperty("MonitorIntegrationWavelengthMax", - wavelengthMonitorIntegrationInterval.get().get<1>()); - } - alg->execute(); - denominator = alg->getProperty("OutputWorkspace"); - } - - // Rebin the transmission run to be the same as the input. - auto rebinToWorkspaceAlg = this->createChildAlgorithm("RebinToWorkspace"); - rebinToWorkspaceAlg->initialize(); - rebinToWorkspaceAlg->setProperty("WorkspaceToMatch", IvsLam); - rebinToWorkspaceAlg->setProperty("WorkspaceToRebin", denominator); - rebinToWorkspaceAlg->execute(); - denominator = rebinToWorkspaceAlg->getProperty("OutputWorkspace"); - - verifySpectrumMaps(IvsLam, denominator, strictSpectrumChecking); - - // Do normalization. - MatrixWorkspace_sptr normalizedIvsLam = divide(IvsLam, denominator); - return normalizedIvsLam; -} - -/** -* Perform transmission correction using alternative correction algorithms. -* @param IvsLam : Run workspace which is to be normalized by the results of the -* transmission corrections. -* @return Corrected workspace -*/ -MatrixWorkspace_sptr -ReflectometryReductionOne::algorithmicCorrection(MatrixWorkspace_sptr IvsLam) { - - const std::string corrAlgName = getProperty("CorrectionAlgorithm"); - - IAlgorithm_sptr corrAlg = createChildAlgorithm(corrAlgName); - corrAlg->initialize(); - if (corrAlgName == "PolynomialCorrection") { - corrAlg->setPropertyValue("Coefficients", getPropertyValue("Polynomial")); - } else if (corrAlgName == "ExponentialCorrection") { - corrAlg->setPropertyValue("C0", getPropertyValue("C0")); - corrAlg->setPropertyValue("C1", getPropertyValue("C1")); - } else { - throw std::runtime_error("Unknown correction algorithm: " + corrAlgName); - } - - corrAlg->setProperty("InputWorkspace", IvsLam); - corrAlg->setProperty("Operation", "Divide"); - corrAlg->execute(); - - return corrAlg->getProperty("OutputWorkspace"); -} - -/** -@param ws1 : First workspace to compare -@param ws2 : Second workspace to compare against -@param severe: True to indicate that failure to verify should result in an -exception. Otherwise a warning is generated. -*/ -void ReflectometryReductionOne::verifySpectrumMaps( - MatrixWorkspace_const_sptr ws1, MatrixWorkspace_const_sptr ws2, - const bool severe) { - auto map1 = ws1->getSpectrumToWorkspaceIndexMap(); - auto map2 = ws2->getSpectrumToWorkspaceIndexMap(); - if (map1 != map2) { - std::string message = "Spectrum maps between workspaces do NOT match up."; - if (severe) { - throw std::invalid_argument(message); - } else { - this->g_log.warning(message); - } - } -} - -} // namespace Algorithms -} // namespace Mantid diff --git a/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp b/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp deleted file mode 100644 index d2a2701bda63b4f12f4ac9a603b86d1ada1277d9..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/src/ReflectometryReductionOneAuto.cpp +++ /dev/null @@ -1,848 +0,0 @@ -#include "MantidAlgorithms/BoostOptionalToAlgorithmProperty.h" -#include "MantidAlgorithms/ReflectometryReductionOneAuto.h" -#include "MantidAPI/WorkspaceGroup.h" -#include "MantidAPI/WorkspaceUnitValidator.h" -#include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/BoundedValidator.h" -#include "MantidKernel/EnabledWhenProperty.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/RebinParamsValidator.h" -#include <boost/optional.hpp> - -/*Anonymous namespace*/ -namespace { -/** -* Helper free function to calculate MomentumTransfer from lambda and theta -* @param lambda : Value in wavelength -* @param theta : Value in Degrees -* @return MomentumTransfer -* @ -*/ -double calculateQ(double lambda, double theta) { - if (lambda == 0.0) - throw std::runtime_error("Minimum/Maximum value of the IvsLambda Workspace " - "is 0. Cannot calculate Q"); - double thetaInRad = theta * M_PI / 180; - return (4 * M_PI * sin(thetaInRad)) / lambda; -} -} -/*end of Anonymous namespace*/ -namespace Mantid { -namespace Algorithms { - -using namespace Mantid::Kernel; -using namespace Mantid::API; - -// Register the algorithm into the AlgorithmFactory -DECLARE_ALGORITHM(ReflectometryReductionOneAuto) - -//---------------------------------------------------------------------------------------------- - -/// Algorithm's name for identification. @see Algorithm::name -const std::string ReflectometryReductionOneAuto::name() const { - return "ReflectometryReductionOneAuto"; -} - -/// Algorithm's version for identification. @see Algorithm::version -int ReflectometryReductionOneAuto::version() const { return 1; } - -/// Algorithm's category for identification. @see Algorithm::category -const std::string ReflectometryReductionOneAuto::category() const { - return "Reflectometry\\ISIS"; -} - -/// Algorithm's summary for use in the GUI and help. @see Algorithm::summary -const std::string ReflectometryReductionOneAuto::summary() const { - return "Reduces a single TOF/Lambda reflectometry run into a mod Q vs I/I0 " - "workspace. Performs transmission corrections."; -} - -//---------------------------------------------------------------------------------------------- -/** Initialize the algorithm's properties. -*/ -void ReflectometryReductionOneAuto::init() { - declareProperty( - make_unique<WorkspaceProperty<MatrixWorkspace>>( - "InputWorkspace", "", Direction::Input, PropertyMode::Mandatory), - "Input run in TOF or Lambda"); - - std::vector<std::string> analysis_modes{"PointDetectorAnalysis", - "MultiDetectorAnalysis"}; - auto analysis_mode_validator = - boost::make_shared<StringListValidator>(analysis_modes); - - declareProperty( - make_unique<ArrayProperty<int>>("RegionOfDirectBeam", Direction::Input), - "Indices of the spectra a pair (lower, upper) that mark the ranges that " - "correspond to the direct beam in multi-detector mode."); - - declareProperty("AnalysisMode", analysis_modes[0], analysis_mode_validator, - "Analysis Mode to Choose", Direction::Input); - - declareProperty( - make_unique<WorkspaceProperty<MatrixWorkspace>>( - "FirstTransmissionRun", "", Direction::Input, PropertyMode::Optional), - "First transmission run workspace in TOF or Wavelength"); - - auto tof_validator = boost::make_shared<WorkspaceUnitValidator>("TOF"); - declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( - "SecondTransmissionRun", "", Direction::Input, - PropertyMode::Optional, tof_validator), - "Second transmission run workspace in TOF"); - declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( - "OutputWorkspace", "", Direction::Output), - "Output workspace in wavelength q"); - declareProperty(make_unique<WorkspaceProperty<MatrixWorkspace>>( - "OutputWorkspaceWavelength", "", Direction::Output), - "Output workspace in wavelength"); - - declareProperty( - make_unique<ArrayProperty<double>>( - "Params", boost::make_shared<RebinParamsValidator>(true)), - "A comma separated list of first bin boundary, width, last bin boundary. " - "These parameters are used for stitching together transmission runs. " - "Values are in wavelength (angstroms). This input is only needed if a " - "SecondTransmission run is provided."); - - declareProperty("StartOverlap", Mantid::EMPTY_DBL(), "Overlap in Q.", - Direction::Input); - - declareProperty("EndOverlap", Mantid::EMPTY_DBL(), "End overlap in Q.", - Direction::Input); - declareProperty("ScaleFactor", 1.0, - "Factor you wish to scale Q workspace by.", Direction::Input); - auto index_bounds = boost::make_shared<BoundedValidator<int>>(); - index_bounds->setLower(0); - - declareProperty(make_unique<PropertyWithValue<int>>( - "I0MonitorIndex", Mantid::EMPTY_INT(), Direction::Input), - "I0 monitor workspace index. Optional."); - declareProperty(make_unique<PropertyWithValue<std::string>>( - "ProcessingInstructions", "", Direction::Input), - "Grouping pattern of workspace indices to yield only the" - " detectors of interest. See GroupDetectors for syntax."); - declareProperty("WavelengthMin", Mantid::EMPTY_DBL(), - "Wavelength Min in angstroms", Direction::Input); - declareProperty("WavelengthMax", Mantid::EMPTY_DBL(), - "Wavelength Max in angstroms", Direction::Input); - declareProperty("WavelengthStep", Mantid::EMPTY_DBL(), - "Wavelength step in angstroms", Direction::Input); - declareProperty("MomentumTransferMinimum", Mantid::EMPTY_DBL(), - "Minimum Q value in IvsQ " - "Workspace. Used for Rebinning " - "the IvsQ Workspace", - Direction::Input); - declareProperty("MomentumTransferStep", Mantid::EMPTY_DBL(), - "Resolution value in IvsQ Workspace. Used for Rebinning the " - "IvsQ Workspace. This value will be made minus to apply " - "logarithmic rebinning. If you wish to have linear " - "bin-widths then please provide a negative DQQ", - Direction::Input); - declareProperty("MomentumTransferMaximum", Mantid::EMPTY_DBL(), - "Maximum Q value in IvsQ " - "Workspace. Used for Rebinning " - "the IvsQ Workspace", - Direction::Input); - declareProperty("MonitorBackgroundWavelengthMin", Mantid::EMPTY_DBL(), - "Monitor wavelength background min in angstroms", - Direction::Input); - declareProperty("MonitorBackgroundWavelengthMax", Mantid::EMPTY_DBL(), - "Monitor wavelength background max in angstroms", - Direction::Input); - declareProperty("MonitorIntegrationWavelengthMin", Mantid::EMPTY_DBL(), - "Monitor integral min in angstroms", Direction::Input); - declareProperty("MonitorIntegrationWavelengthMax", Mantid::EMPTY_DBL(), - "Monitor integral max in angstroms", Direction::Input); - declareProperty(make_unique<PropertyWithValue<std::string>>( - "DetectorComponentName", "", Direction::Input), - "Name of the detector component i.e. point-detector. If " - "these are not specified, the algorithm will attempt lookup " - "using a standard naming convention."); - declareProperty(make_unique<PropertyWithValue<std::string>>( - "SampleComponentName", "", Direction::Input), - "Name of the sample component i.e. some-surface-holder. If " - "these are not specified, the algorithm will attempt lookup " - "using a standard naming convention."); - - declareProperty("ThetaIn", Mantid::EMPTY_DBL(), "Final theta in degrees", - Direction::Input); - declareProperty("ThetaOut", Mantid::EMPTY_DBL(), - "Calculated final theta in degrees.", Direction::Output); - - declareProperty("NormalizeByIntegratedMonitors", true, - "Normalize by dividing by the integrated monitors."); - - declareProperty("CorrectDetectorPositions", true, - "Correct detector positions using ThetaIn (if given)"); - - declareProperty("StrictSpectrumChecking", true, - "Strict checking between spectrum numbers in input " - "workspaces and transmission workspaces."); - std::vector<std::string> correctionAlgorithms = { - "None", "AutoDetect", "PolynomialCorrection", "ExponentialCorrection"}; - declareProperty("CorrectionAlgorithm", "AutoDetect", - boost::make_shared<StringListValidator>(correctionAlgorithms), - "The type of correction to perform."); - - declareProperty(make_unique<ArrayProperty<double>>("Polynomial"), - "Coefficients to be passed to the PolynomialCorrection" - " algorithm."); - - declareProperty( - make_unique<PropertyWithValue<double>>("C0", 0.0, Direction::Input), - "C0 value to be passed to the ExponentialCorrection algorithm."); - - declareProperty( - make_unique<PropertyWithValue<double>>("C1", 0.0, Direction::Input), - "C1 value to be passed to the ExponentialCorrection algorithm."); - - setPropertyGroup("CorrectionAlgorithm", "Polynomial Corrections"); - setPropertyGroup("Polynomial", "Polynomial Corrections"); - setPropertyGroup("C0", "Polynomial Corrections"); - setPropertyGroup("C1", "Polynomial Corrections"); - - setPropertySettings( - "Polynomial", - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "PolynomialCorrection")); - setPropertySettings( - "C0", Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "ExponentialCorrection")); - setPropertySettings( - "C1", Kernel::make_unique<Kernel::EnabledWhenProperty>( - "CorrectionAlgorithm", IS_EQUAL_TO, "ExponentialCorrection")); - - // Polarization correction inputs -------------- - std::vector<std::string> propOptions; - propOptions.push_back(noPolarizationCorrectionMode()); - propOptions.push_back(pALabel()); - propOptions.push_back(pNRLabel()); - - declareProperty("PolarizationAnalysis", noPolarizationCorrectionMode(), - boost::make_shared<StringListValidator>(propOptions), - "What Polarization mode will be used?\n" - "None: No correction\n" - "PNR: Polarized Neutron Reflectivity mode\n" - "PA: Full Polarization Analysis PNR-PA"); - declareProperty( - Kernel::make_unique<ArrayProperty<double>>(cppLabel(), Direction::Input), - "Effective polarizing power of the polarizing system. " - "Expressed as a ratio 0 < Pp < 1"); - declareProperty( - Kernel::make_unique<ArrayProperty<double>>(cApLabel(), Direction::Input), - "Effective polarizing power of the analyzing system. " - "Expressed as a ratio 0 < Ap < 1"); - declareProperty( - Kernel::make_unique<ArrayProperty<double>>(crhoLabel(), Direction::Input), - "Ratio of efficiencies of polarizer spin-down to polarizer " - "spin-up. This is characteristic of the polarizer flipper. " - "Values are constants for each term in a polynomial " - "expression."); - declareProperty(Kernel::make_unique<ArrayProperty<double>>(cAlphaLabel(), - Direction::Input), - "Ratio of efficiencies of analyzer spin-down to analyzer " - "spin-up. This is characteristic of the analyzer flipper. " - "Values are factors for each term in a polynomial " - "expression."); - setPropertyGroup("PolarizationAnalysis", "Polarization Corrections"); - setPropertyGroup(cppLabel(), "Polarization Corrections"); - setPropertyGroup(cApLabel(), "Polarization Corrections"); - setPropertyGroup(crhoLabel(), "Polarization Corrections"); - setPropertyGroup(cAlphaLabel(), "Polarization Corrections"); - setPropertySettings(cppLabel(), - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "PolarizationAnalysis", IS_NOT_EQUAL_TO, - noPolarizationCorrectionMode())); - setPropertySettings(cApLabel(), - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "PolarizationAnalysis", IS_NOT_EQUAL_TO, - noPolarizationCorrectionMode())); - setPropertySettings(crhoLabel(), - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "PolarizationAnalysis", IS_NOT_EQUAL_TO, - noPolarizationCorrectionMode())); - setPropertySettings(cAlphaLabel(), - Kernel::make_unique<Kernel::EnabledWhenProperty>( - "PolarizationAnalysis", IS_NOT_EQUAL_TO, - noPolarizationCorrectionMode())); -} - -//---------------------------------------------------------------------------------------------- -/** Execute the algorithm. -*/ -void ReflectometryReductionOneAuto::exec() { - MatrixWorkspace_sptr in_ws = getProperty("InputWorkspace"); - auto instrument = in_ws->getInstrument(); - - // Get all the inputs. - - std::string output_workspace_name = getPropertyValue("OutputWorkspace"); - std::string output_workspace_lam_name = - getPropertyValue("OutputWorkspaceWavelength"); - std::string analysis_mode = getPropertyValue("AnalysisMode"); - MatrixWorkspace_sptr first_ws = getProperty("FirstTransmissionRun"); - MatrixWorkspace_sptr second_ws = getProperty("SecondTransmissionRun"); - auto start_overlap = isSet<double>("StartOverlap"); - auto end_overlap = isSet<double>("EndOverlap"); - auto params = isSet<MantidVec>("Params"); - auto i0_monitor_index = checkForOptionalInstrumentDefault<int>( - this, "I0MonitorIndex", instrument, "I0MonitorIndex"); - - std::string processing_commands; - if (this->getPointerToProperty("ProcessingInstructions")->isDefault()) { - if (analysis_mode == "PointDetectorAnalysis") { - std::vector<double> pointStart = - instrument->getNumberParameter("PointDetectorStart"); - std::vector<double> pointStop = - instrument->getNumberParameter("PointDetectorStop"); - - if (pointStart.empty() || pointStop.empty()) - throw std::runtime_error( - "If ProcessingInstructions is not specified, BOTH " - "PointDetectorStart " - "and PointDetectorStop must exist as instrument parameters.\n" - "Please check if you meant to enter ProcessingInstructions or " - "if your instrument parameter file is correct."); - - const int detStart = static_cast<int>(pointStart[0]); - const int detStop = static_cast<int>(pointStop[0]); - - if (detStart == detStop) { - // If the range given only specifies one detector, we pass along just - // that one detector - processing_commands = std::to_string(detStart); - } else { - // Otherwise, we create a range. - processing_commands = - std::to_string(detStart) + ":" + std::to_string(detStop); - } - } else { - std::vector<double> multiStart = - instrument->getNumberParameter("MultiDetectorStart"); - if (multiStart.empty()) - throw std::runtime_error( - "If ProcessingInstructions is not specified, MultiDetectorStart" - "must exist as an instrument parameter.\n" - "Please check if you meant to enter ProcessingInstructions or " - "if your instrument parameter file is correct."); - processing_commands = std::to_string(static_cast<int>(multiStart[0])) + - ":" + - std::to_string(in_ws->getNumberHistograms() - 1); - } - } else { - std::string processing_commands_temp = - this->getProperty("ProcessingInstructions"); - processing_commands = processing_commands_temp; - } - - double wavelength_min = checkForMandatoryInstrumentDefault<double>( - this, "WavelengthMin", instrument, "LambdaMin"); - double wavelength_max = checkForMandatoryInstrumentDefault<double>( - this, "WavelengthMax", instrument, "LambdaMax"); - auto wavelength_step = isSet<double>("WavelengthStep"); - auto wavelength_back_min = checkForOptionalInstrumentDefault<double>( - this, "MonitorBackgroundWavelengthMin", instrument, - "MonitorBackgroundMin"); - auto wavelength_back_max = checkForOptionalInstrumentDefault<double>( - this, "MonitorBackgroundWavelengthMax", instrument, - "MonitorBackgroundMax"); - auto wavelength_integration_min = checkForOptionalInstrumentDefault<double>( - this, "MonitorIntegrationWavelengthMin", instrument, - "MonitorIntegralMin"); - auto wavelength_integration_max = checkForOptionalInstrumentDefault<double>( - this, "MonitorIntegrationWavelengthMax", instrument, - "MonitorIntegralMax"); - - auto detector_component_name = isSet<std::string>("DetectorComponentName"); - auto sample_component_name = isSet<std::string>("SampleComponentName"); - auto theta_in = isSet<double>("ThetaIn"); - auto region_of_direct_beam = isSet<std::vector<int>>("RegionOfDirectBeam"); - - bool correct_positions = this->getProperty("CorrectDetectorPositions"); - bool strict_spectrum_checking = this->getProperty("StrictSpectrumChecking"); - bool norm_by_int_mons = getProperty("NormalizeByIntegratedMonitors"); - const std::string correction_algorithm = getProperty("CorrectionAlgorithm"); - - // Pass the arguments and execute the main algorithm. - - IAlgorithm_sptr refRedOne = - createChildAlgorithm("ReflectometryReductionOne", -1, -1, true, 1); - refRedOne->initialize(); - if (refRedOne->isInitialized()) { - refRedOne->setProperty("InputWorkspace", in_ws); - refRedOne->setProperty("AnalysisMode", analysis_mode); - refRedOne->setProperty("OutputWorkspace", output_workspace_name); - refRedOne->setProperty("OutputWorkspaceWavelength", - output_workspace_lam_name); - refRedOne->setProperty("NormalizeByIntegratedMonitors", norm_by_int_mons); - - if (i0_monitor_index.is_initialized()) { - if (i0_monitor_index.get() >= 0) - refRedOne->setProperty("I0MonitorIndex", i0_monitor_index.get()); - else - throw std::invalid_argument( - "I0MonitorIndex must be an integer greater than or equal to 0"); - } - refRedOne->setProperty("ProcessingInstructions", processing_commands); - refRedOne->setProperty("WavelengthMin", wavelength_min); - refRedOne->setProperty("WavelengthMax", wavelength_max); - if (wavelength_back_min.is_initialized()) - refRedOne->setProperty("MonitorBackgroundWavelengthMin", - wavelength_back_min.get()); - if (wavelength_back_max.is_initialized()) - refRedOne->setProperty("MonitorBackgroundWavelengthMax", - wavelength_back_max.get()); - if (wavelength_integration_min.is_initialized()) - refRedOne->setProperty("MonitorIntegrationWavelengthMin", - wavelength_integration_min.get()); - if (wavelength_integration_max.is_initialized()) - refRedOne->setProperty("MonitorIntegrationWavelengthMax", - wavelength_integration_max.get()); - refRedOne->setProperty("CorrectDetectorPositions", correct_positions); - refRedOne->setProperty("StrictSpectrumChecking", strict_spectrum_checking); - if (correction_algorithm == "PolynomialCorrection") { - // Copy across the polynomial - refRedOne->setProperty("CorrectionAlgorithm", "PolynomialCorrection"); - refRedOne->setProperty("Polynomial", getPropertyValue("Polynomial")); - } else if (correction_algorithm == "ExponentialCorrection") { - // Copy across c0 and c1 - refRedOne->setProperty("CorrectionAlgorithm", "ExponentialCorrection"); - refRedOne->setProperty("C0", getPropertyValue("C0")); - refRedOne->setProperty("C1", getPropertyValue("C1")); - } else if (correction_algorithm == "AutoDetect") { - // Figure out what to do from the instrument - try { - auto inst = in_ws->getInstrument(); - - const std::vector<std::string> corrVec = - inst->getStringParameter("correction"); - const std::string correctionStr = !corrVec.empty() ? corrVec[0] : ""; - - if (correctionStr.empty()) - throw std::runtime_error( - "'correction' instrument parameter was not found."); - - const std::vector<std::string> polyVec = - inst->getStringParameter("polynomial"); - const std::string polyStr = !polyVec.empty() ? polyVec[0] : ""; - - const std::vector<std::string> c0Vec = inst->getStringParameter("C0"); - const std::string c0Str = !c0Vec.empty() ? c0Vec[0] : ""; - - const std::vector<std::string> c1Vec = inst->getStringParameter("C1"); - const std::string c1Str = !c1Vec.empty() ? c1Vec[0] : ""; - - if (correctionStr == "polynomial" && polyStr.empty()) - throw std::runtime_error( - "'polynomial' instrument parameter was not found."); - - if (correctionStr == "exponential" && (c0Str.empty() || c1Str.empty())) - throw std::runtime_error( - "'C0' or 'C1' instrument parameter was not found."); - - if (correctionStr == "polynomial") { - refRedOne->setProperty("CorrectionAlgorithm", "PolynomialCorrection"); - refRedOne->setProperty("Polynomial", polyStr); - } else if (correctionStr == "exponential") { - refRedOne->setProperty("CorrectionAlgorithm", - "ExponentialCorrection"); - refRedOne->setProperty("C0", c0Str); - refRedOne->setProperty("C1", c1Str); - } - - } catch (std::runtime_error &e) { - g_log.warning() << "Could not autodetect polynomial correction method. " - "Polynomial correction will not be performed. " - "Reason for failure: " << e.what() << '\n'; - refRedOne->setProperty("CorrectionAlgorithm", "None"); - } - - } else { - // None was selected - refRedOne->setProperty("CorrectionAlgorithm", "None"); - } - - if (first_ws) { - refRedOne->setProperty("FirstTransmissionRun", first_ws); - } - - if (second_ws) { - refRedOne->setProperty("SecondTransmissionRun", second_ws); - } - - if (start_overlap.is_initialized()) { - refRedOne->setProperty("StartOverlap", start_overlap.get()); - } - - if (end_overlap.is_initialized()) { - refRedOne->setProperty("EndOverlap", end_overlap.get()); - } - - if (params.is_initialized()) { - refRedOne->setProperty("Params", params.get()); - } - - if (wavelength_step.is_initialized()) { - refRedOne->setProperty("WavelengthStep", wavelength_step.get()); - } - - if (region_of_direct_beam.is_initialized()) { - refRedOne->setProperty("RegionOfDirectBeam", region_of_direct_beam.get()); - } - - if (detector_component_name.is_initialized()) { - refRedOne->setProperty("DetectorComponentName", - detector_component_name.get()); - } - - if (sample_component_name.is_initialized()) { - refRedOne->setProperty("SampleComponentName", - sample_component_name.get()); - } - - if (theta_in.is_initialized()) { - refRedOne->setProperty("ThetaIn", theta_in.get()); - } - double scaleFactor = getProperty("ScaleFactor"); - if (scaleFactor != 1.0) { - refRedOne->setProperty("ScaleFactor", scaleFactor); - } - auto momentumTransferMinimum = isSet<double>("MomentumTransferMinimum"); - auto momentumTransferStep = isSet<double>("MomentumTransferStep"); - auto momentumTransferMaximum = isSet<double>("MomentumTransferMaximum"); - - if (momentumTransferStep.is_initialized()) { - refRedOne->setProperty("MomentumTransferStep", - momentumTransferStep.get()); - } - if (momentumTransferMinimum.is_initialized()) - refRedOne->setProperty("MomentumTransferMinimum", - momentumTransferMinimum.get()); - if (momentumTransferMaximum.is_initialized()) - refRedOne->setProperty("MomentumTransferMaximum", - momentumTransferMaximum.get()); - if (theta_in.is_initialized()) { - if (!momentumTransferMinimum.is_initialized()) - momentumTransferMinimum = calculateQ(wavelength_max, theta_in.get()); - if (!momentumTransferStep.is_initialized()) { - IAlgorithm_sptr calcResAlg = - AlgorithmManager::Instance().create("NRCalculateSlitResolution"); - calcResAlg->setProperty("Workspace", in_ws); - calcResAlg->setProperty("TwoTheta", theta_in.get()); - calcResAlg->execute(); - if (!calcResAlg->isExecuted()) - throw std::runtime_error( - "NRCalculateSlitResolution failed. Please manually " - "enter a value in the dQ/Q column."); - double resolution = calcResAlg->getProperty("Resolution"); - momentumTransferStep = resolution; - } - if (!momentumTransferMaximum.is_initialized()) - momentumTransferMaximum = calculateQ(wavelength_min, theta_in.get()); - refRedOne->setProperty("MomentumTransferMinimum", - momentumTransferMinimum.get()); - refRedOne->setProperty("MomentumTransferStep", - momentumTransferStep.get()); - refRedOne->setProperty("MomentumTransferMaximum", - momentumTransferMaximum.get()); - } - refRedOne->execute(); - if (!refRedOne->isExecuted()) { - throw std::runtime_error( - "ReflectometryReductionOne did not execute sucessfully"); - } - - MatrixWorkspace_sptr new_IvsQ1 = refRedOne->getProperty("OutputWorkspace"); - MatrixWorkspace_sptr new_IvsLam1 = - refRedOne->getProperty("OutputWorkspaceWavelength"); - double thetaOut1 = refRedOne->getProperty("ThetaOut"); - setProperty("OutputWorkspace", new_IvsQ1); - setProperty("OutputWorkspaceWavelength", new_IvsLam1); - setProperty("ThetaOut", thetaOut1); - // set properties so they can be retrieved by GenericDataProcesser if - // necessary. - setProperty("MomentumTransferMinimum", - boost::lexical_cast<double>( - refRedOne->getPropertyValue("MomentumTransferMinimum"))); - setProperty("MomentumTransferStep", - boost::lexical_cast<double>( - refRedOne->getPropertyValue("MomentumTransferStep"))); - setProperty("MomentumTransferMaximum", - boost::lexical_cast<double>( - refRedOne->getPropertyValue("MomentumTransferMaximum"))); - if (theta_in.is_initialized()) - setProperty("ThetaIn", theta_in.get()); - else - setProperty("ThetaIn", thetaOut1 / 2.); - - } else { - throw std::runtime_error( - "ReflectometryReductionOne could not be initialised"); - } -} - -template <typename T> -boost::optional<T> -ReflectometryReductionOneAuto::isSet(std::string propName) const { - auto algProperty = this->getPointerToProperty(propName); - if (algProperty->isDefault()) { - return boost::optional<T>(); - } else { - T value = this->getProperty(propName); - return boost::optional<T>(value); - } -} - -bool ReflectometryReductionOneAuto::checkGroups() { - std::string wsName = getPropertyValue("InputWorkspace"); - - try { - auto ws = - AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>(wsName); - if (ws) - return true; - } catch (...) { - } - return false; -} -/** - * Sum over transmission group workspaces to produce one - * workspace. - * @param transGroup : The transmission group to be processed - * @return A workspace pointer containing the sum of transmission workspaces. - */ -Mantid::API::Workspace_sptr -ReflectometryReductionOneAuto::sumOverTransmissionGroup( - WorkspaceGroup_sptr &transGroup) { - // Handle transmission runs - - // we clone the first member of transmission group as to - // avoid addition in place which would affect the original - // workspace member. - // - // We used .release because clone() will return a unique_ptr. - // we need to release the ownership of the pointer so that it - // can be cast into a shared_ptr of type Workspace. - Workspace_sptr transmissionRunSum(transGroup->getItem(0)->clone()); - - // make a variable to store the overall total of the summation - MatrixWorkspace_sptr total; - // set up and initialize plus algorithm. - auto plusAlg = this->createChildAlgorithm("Plus"); - plusAlg->setChild(true); - // plusAlg->setRethrows(true); - plusAlg->initialize(); - // now accumalate the group members - for (size_t item = 1; item < transGroup->size(); ++item) { - plusAlg->setProperty("LHSWorkspace", transmissionRunSum); - plusAlg->setProperty("RHSWorkspace", transGroup->getItem(item)); - plusAlg->setProperty("OutputWorkspace", transmissionRunSum); - plusAlg->execute(); - total = plusAlg->getProperty("OutputWorkspace"); - } - return total; -} - -bool ReflectometryReductionOneAuto::processGroups() { - // isPolarizationCorrectionOn is used to decide whether - // we should process our Transmission WorkspaceGroup members - // as individuals (not multiperiod) when PolarizationCorrection is off, - // or sum over all of the workspaces in the group - // and used that sum as our TransmissionWorkspace when PolarizationCorrection - // is on. - const bool isPolarizationCorrectionOn = - this->getPropertyValue("PolarizationAnalysis") != - noPolarizationCorrectionMode(); - - // this algorithm effectively behaves as MultiPeriodGroupAlgorithm - m_usingBaseProcessGroups = true; - - // Get our input workspace group - auto group = AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( - getPropertyValue("InputWorkspace")); - // Get name of IvsQ workspace - const std::string outputIvsQ = this->getPropertyValue("OutputWorkspace"); - // Get name of IvsLam workspace - const std::string outputIvsLam = - this->getPropertyValue("OutputWorkspaceWavelength"); - - // Create a copy of ourselves - Algorithm_sptr alg = this->createChildAlgorithm( - this->name(), -1, -1, this->isLogging(), this->version()); - alg->setChild(false); - alg->setRethrows(true); - - // Copy all the non-workspace properties over - std::vector<Property *> props = this->getProperties(); - for (auto &prop : props) { - if (prop) { - IWorkspaceProperty *wsProp = dynamic_cast<IWorkspaceProperty *>(prop); - if (!wsProp) - alg->setPropertyValue(prop->name(), prop->value()); - } - } - - // Check if the transmission runs are groups or not - const std::string firstTrans = this->getPropertyValue("FirstTransmissionRun"); - WorkspaceGroup_sptr firstTransG; - if (!firstTrans.empty()) { - auto firstTransWS = - AnalysisDataService::Instance().retrieveWS<Workspace>(firstTrans); - firstTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(firstTransWS); - - if (!firstTransG) { - // we only have one transmission workspace, so we use it as it is. - alg->setProperty("FirstTransmissionRun", firstTrans); - } else if (group->size() != firstTransG->size() && - !isPolarizationCorrectionOn) { - // if they are not the same size then we cannot associate a transmission - // group workspace member with every input group workpspace member. - throw std::runtime_error("FirstTransmissionRun WorkspaceGroup must be " - "the same size as the InputWorkspace " - "WorkspaceGroup"); - } - } - - const std::string secondTrans = - this->getPropertyValue("SecondTransmissionRun"); - WorkspaceGroup_sptr secondTransG; - if (!secondTrans.empty()) { - auto secondTransWS = - AnalysisDataService::Instance().retrieveWS<Workspace>(secondTrans); - secondTransG = boost::dynamic_pointer_cast<WorkspaceGroup>(secondTransWS); - - if (!secondTransG) - // we only have one transmission workspace, so we use it as it is. - alg->setProperty("SecondTransmissionRun", secondTrans); - - else if (group->size() != secondTransG->size() && - !isPolarizationCorrectionOn) { - // if they are not the same size then we cannot associate a transmission - // group workspace member with every input group workpspace member. - throw std::runtime_error("SecondTransmissionRun WorkspaceGroup must be " - "the same size as the InputWorkspace " - "WorkspaceGroup"); - } - } - std::vector<std::string> IvsQGroup, IvsLamGroup; - - // Execute algorithm over each group member (or period, if this is - // multiperiod) - size_t numMembers = group->size(); - for (size_t i = 0; i < numMembers; ++i) { - const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1); - const std::string IvsLamName = outputIvsLam + "_" + std::to_string(i + 1); - - // If our transmission run is a group and PolarizationCorrection is on - // then we sum our transmission group members. - // - // This is done inside of the for loop to avoid the wrong workspace being - // used when these arguments are passed through to the exec() method. - // If this is not set in the loop, exec() will fetch the first workspace - // from the specified Transmission Group workspace that the user entered. - if (firstTransG && isPolarizationCorrectionOn) { - auto firstTransmissionSum = sumOverTransmissionGroup(firstTransG); - alg->setProperty("FirstTransmissionRun", firstTransmissionSum); - } - if (secondTransG && isPolarizationCorrectionOn) { - auto secondTransmissionSum = sumOverTransmissionGroup(secondTransG); - alg->setProperty("SecondTransmissionRun", secondTransmissionSum); - } - - // Otherwise, if polarization correction is off, we process them - // using one transmission group member at a time. - if (firstTransG && !isPolarizationCorrectionOn) // polarization off - alg->setProperty("FirstTransmissionRun", - firstTransG->getItem(i)->getName()); - if (secondTransG && !isPolarizationCorrectionOn) // polarization off - alg->setProperty("SecondTransmissionRun", - secondTransG->getItem(i)->getName()); - - alg->setProperty("InputWorkspace", group->getItem(i)->getName()); - alg->setProperty("OutputWorkspace", IvsQName); - alg->setProperty("OutputWorkspaceWavelength", IvsLamName); - alg->execute(); - - MatrixWorkspace_sptr tempFirstTransWS = - alg->getProperty("FirstTransmissionRun"); - - IvsQGroup.push_back(IvsQName); - IvsLamGroup.push_back(IvsLamName); - - // We use the first group member for our thetaout value - if (i == 0) - this->setPropertyValue("ThetaOut", alg->getPropertyValue("ThetaOut")); - } - - // Group the IvsQ and IvsLam workspaces - Algorithm_sptr groupAlg = this->createChildAlgorithm("GroupWorkspaces"); - groupAlg->setChild(false); - groupAlg->setRethrows(true); - - groupAlg->setProperty("InputWorkspaces", IvsLamGroup); - groupAlg->setProperty("OutputWorkspace", outputIvsLam); - groupAlg->execute(); - - groupAlg->setProperty("InputWorkspaces", IvsQGroup); - groupAlg->setProperty("OutputWorkspace", outputIvsQ); - groupAlg->execute(); - - // If this is a multiperiod workspace and we have polarization corrections - // enabled - if (isPolarizationCorrectionOn) { - if (group->isMultiperiod()) { - // Perform polarization correction over the IvsLam group - Algorithm_sptr polAlg = - this->createChildAlgorithm("PolarizationCorrection"); - polAlg->setChild(false); - polAlg->setRethrows(true); - - polAlg->setProperty("InputWorkspace", outputIvsLam); - polAlg->setProperty("OutputWorkspace", outputIvsLam); - polAlg->setProperty("PolarizationAnalysis", - this->getPropertyValue("PolarizationAnalysis")); - polAlg->setProperty("CPp", this->getPropertyValue(cppLabel())); - polAlg->setProperty("CRho", this->getPropertyValue(crhoLabel())); - polAlg->setProperty("CAp", this->getPropertyValue(cApLabel())); - polAlg->setProperty("CAlpha", this->getPropertyValue(cAlphaLabel())); - polAlg->execute(); - - // Now we've overwritten the IvsLam workspaces, we'll need to recalculate - // the IvsQ ones - alg->setProperty("FirstTransmissionRun", ""); - alg->setProperty("SecondTransmissionRun", ""); - for (size_t i = 0; i < numMembers; ++i) { - const std::string IvsQName = outputIvsQ + "_" + std::to_string(i + 1); - const std::string IvsLamName = - outputIvsLam + "_" + std::to_string(i + 1); - alg->setProperty("InputWorkspace", IvsLamName); - alg->setProperty("OutputWorkspace", IvsQName); - alg->setProperty("CorrectionAlgorithm", "None"); - alg->setProperty("OutputWorkspaceWavelength", IvsLamName); - alg->execute(); - } - } else { - g_log.warning("Polarization corrections can only be performed on " - "multiperiod workspaces."); - } - } - - // We finished successfully - // set the values of these properties so they can be retrieved by the - // Interface. - this->setProperty("MomentumTransferMinimum", - boost::lexical_cast<double>( - alg->getPropertyValue("MomentumTransferMinimum"))); - this->setProperty("MomentumTransferStep", - boost::lexical_cast<double>( - alg->getPropertyValue("MomentumTransferStep"))); - this->setProperty("MomentumTransferMaximum", - boost::lexical_cast<double>( - alg->getPropertyValue("MomentumTransferMaximum"))); - // setting output properties. - this->setPropertyValue("OutputWorkspace", outputIvsQ); - this->setPropertyValue("OutputWorkspaceWavelength", outputIvsLam); - return true; -} -} // namespace Algorithms -} // namespace Mantid diff --git a/Framework/Algorithms/src/RingProfile.cpp b/Framework/Algorithms/src/RingProfile.cpp index b54b772a09f23dfbea72486416c5fffb87407738..8ffb30a6e900a02799ca94be59af26f7e3fffa22 100644 --- a/Framework/Algorithms/src/RingProfile.cpp +++ b/Framework/Algorithms/src/RingProfile.cpp @@ -418,8 +418,8 @@ void RingProfile::processInstrumentRingProfile( const MantidVec &refY = inputWS->getSpectrum(i).dataY(); // accumulate the values of this spectrum inside this bin - for (size_t sp_ind = 0; sp_ind < refY.size(); sp_ind++) - output_bins[bin_n] += refY[sp_ind]; + for (double sp_ind : refY) + output_bins[bin_n] += sp_ind; } } diff --git a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp index adde7248cd6b49cd7d33761001365862c8b6e500..4f8ae81b93dc3130e2744df0dec37505e93362a3 100644 --- a/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp +++ b/Framework/Algorithms/src/RunCombinationHelpers/RunCombinationHelper.cpp @@ -54,6 +54,11 @@ void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { m_isHistogramData = ref->isHistogramData(); m_isScanning = ref->detectorInfo().isScanning(); m_instrumentName = ref->getInstrument()->getName(); + if (m_numberSpectra) { + m_hasDx.reserve(m_numberSpectra); + for (unsigned int i = 0; i < m_numberSpectra; ++i) + m_hasDx.push_back(ref->hasDx(i)); + } } //---------------------------------------------------------------------------------------------- @@ -65,7 +70,7 @@ void RunCombinationHelper::setReferenceProperties(MatrixWorkspace_sptr ref) { std::string RunCombinationHelper::checkCompatibility(MatrixWorkspace_sptr ws, bool checkNumberHistograms) { - std::string errors = ""; + std::string errors; if (ws->getNumberHistograms() != m_numberSpectra && checkNumberHistograms) errors += "different number of histograms; "; if (ws->getAxis(0)->unit()->unitID() != m_xUnit) @@ -83,6 +88,16 @@ RunCombinationHelper::checkCompatibility(MatrixWorkspace_sptr ws, "detectors; "; if (ws->getInstrument()->getName() != m_instrumentName) errors += "different instrument names; "; + if (ws->getNumberHistograms() == m_numberSpectra) { + if (!m_hasDx.empty()) { + for (unsigned int i = 0; i < m_numberSpectra; ++i) { + if (m_hasDx[i] != ws->hasDx(i)) { + errors += "spectra must have either Dx values or not; "; + break; + } + } + } + } return errors; } diff --git a/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp b/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp index 281a0c31ce8dbfd8a1788ee7ffaa3c73af8215a9..6c2580cd1e834a5b88cc81a262223f2feda3796b 100644 --- a/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp +++ b/Framework/Algorithms/src/SampleCorrections/SparseInstrument.cpp @@ -286,8 +286,8 @@ createSparseWS(const API::MatrixWorkspace &modelWS, } const auto e = modelWS.getEFixed(detIDs[0]); const auto &sparseDetIDs = ws->detectorInfo().detectorIDs(); - for (size_t i = 0; i < sparseDetIDs.size(); ++i) { - ws->setEFixed(sparseDetIDs[i], e); + for (int sparseDetID : sparseDetIDs) { + ws->setEFixed(sparseDetID, e); } } return API::MatrixWorkspace_uptr(ws.release()); diff --git a/Framework/Algorithms/src/XDataConverter.cpp b/Framework/Algorithms/src/XDataConverter.cpp index 84a3750a32323dd78699d588a409ada4ba773dc6..06c4dab887f37239bf0eb69df954b830df37185d 100644 --- a/Framework/Algorithms/src/XDataConverter.cpp +++ b/Framework/Algorithms/src/XDataConverter.cpp @@ -69,6 +69,9 @@ void XDataConverter::exec() { outputWS->setSharedY(i, inputWS->sharedY(i)); outputWS->setSharedE(i, inputWS->sharedE(i)); setXData(outputWS, inputWS, i); + if (inputWS->hasDx(i)) { + outputWS->setSharedDx(i, inputWS->sharedDx(i)); + } prog.report(); PARALLEL_END_INTERUPT_REGION diff --git a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h index 04f3c54d9930516ace687dce8c227ad8f6c63659..4cfbbc0ed295cba11a85d8ad64d3f08a17c42849 100644 --- a/Framework/Algorithms/test/AnyShapeAbsorptionTest.h +++ b/Framework/Algorithms/test/AnyShapeAbsorptionTest.h @@ -157,8 +157,8 @@ public: // Now test with a gauge volume used. // Create a small cylinder to be the gauge volume std::string cylinder = "<cylinder id=\"shape\"> "; - cylinder += "<centre-of-bottom-base x=\"0.0\" y=\"-0.01\" z=\"0.0\" /> "; - cylinder += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + cylinder += R"(<centre-of-bottom-base x="0.0" y="-0.01" z="0.0" /> )"; + cylinder += R"(<axis x="0.0" y="0.0" z="1" /> )"; cylinder += "<radius val=\"0.1\" /> "; cylinder += "<height val=\"0.02\" /> "; cylinder += "</cylinder>"; diff --git a/Framework/Algorithms/test/BinaryOperateMasksTest.h b/Framework/Algorithms/test/BinaryOperateMasksTest.h index f5fb9d1ad1eb6c6f070fce4ea860bc332491781b..886f12eef1e7b8db08e559aab2aea50b5d46abbd 100644 --- a/Framework/Algorithms/test/BinaryOperateMasksTest.h +++ b/Framework/Algorithms/test/BinaryOperateMasksTest.h @@ -72,7 +72,7 @@ public: std::cout << "\nTest I Is Completed\n"; - if (ws1 == NULL) { + if (ws1 == nullptr) { std::cout << "\nWorkspace1 is NULL\n"; } @@ -100,13 +100,13 @@ public: ws4 = AnalysisDataService::Instance() .retrieveWS<DataObjects::MaskWorkspace>(ws4name); - if (ws4 == NULL) { + if (ws4 == nullptr) { std::cout << "Workspace4 is NULL\n"; } else { std::cout << "Workspace4 is good at output of NOT. Number Histogram = " << ws4->getNumberHistograms() << '\n'; } - if (ws1 == NULL) { + if (ws1 == nullptr) { std::cout << "Workspace1 is NULL\n"; } else { std::cout << "Workspace1 is good at output of NOT. Number Histogram = " diff --git a/Framework/Algorithms/test/ChangeTimeZeroTest.h b/Framework/Algorithms/test/ChangeTimeZeroTest.h index 88520874edfd302ae7e0121422fd82786aa7e4cf..c0dd81f2f1d66f5b275966ec56bf2ce78eee3fae 100644 --- a/Framework/Algorithms/test/ChangeTimeZeroTest.h +++ b/Framework/Algorithms/test/ChangeTimeZeroTest.h @@ -487,11 +487,11 @@ private: auto logs = ws->run().getLogData(); // Go over each log and check the times - for (auto iter = logs.begin(); iter != logs.end(); ++iter) { - if (dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(*iter)) { - do_check_time_series(*iter, timeShift); - } else if (dynamic_cast<PropertyWithValue<std::string> *>(*iter)) { - do_check_property_with_string_value(*iter, timeShift); + for (auto &log : logs) { + if (dynamic_cast<Mantid::Kernel::ITimeSeriesProperty *>(log)) { + do_check_time_series(log, timeShift); + } else if (dynamic_cast<PropertyWithValue<std::string> *>(log)) { + do_check_property_with_string_value(log, timeShift); } } @@ -509,8 +509,8 @@ private: // Iterator over all entries of the time series and check if they are // altered double secondCounter = timeShift; - for (auto it = times.begin(); it != times.end(); ++it) { - double secs = DateAndTime::secondsFromDuration(*it - m_startTime); + for (auto &time : times) { + double secs = DateAndTime::secondsFromDuration(time - m_startTime); TSM_ASSERT_DELTA("Time series logs should have shifted times.", secs, secondCounter, 1e-5); ++secondCounter; diff --git a/Framework/Algorithms/test/ConjoinXRunsTest.h b/Framework/Algorithms/test/ConjoinXRunsTest.h index 8133133d9614ad865bb76317ee54976b307c5e5a..fd1e397fdc023c13b3409f3dc3fe9a8e0d96696f 100644 --- a/Framework/Algorithms/test/ConjoinXRunsTest.h +++ b/Framework/Algorithms/test/ConjoinXRunsTest.h @@ -8,15 +8,26 @@ #include "MantidAlgorithms/AddSampleLog.h" #include "MantidAlgorithms/AddTimeSeriesLog.h" #include "MantidAlgorithms/ConjoinXRuns.h" +#include "MantidHistogramData/Counts.h" +#include "MantidHistogramData/HistogramDx.h" +#include "MantidHistogramData/HistogramE.h" +#include "MantidHistogramData/HistogramX.h" +#include "MantidHistogramData/HistogramY.h" +#include "MantidHistogramData/Points.h" #include "MantidKernel/Unit.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" using Mantid::Algorithms::ConjoinXRuns; using Mantid::Algorithms::AddSampleLog; using Mantid::Algorithms::AddTimeSeriesLog; +using Mantid::HistogramData::Counts; +using Mantid::HistogramData::HistogramDx; +using Mantid::HistogramData::HistogramE; +using Mantid::HistogramData::HistogramX; +using Mantid::HistogramData::HistogramY; +using Mantid::HistogramData::Points; using namespace Mantid::API; using namespace WorkspaceCreationHelper; -using namespace Mantid::HistogramData; class ConjoinXRunsTest : public CxxTest::TestSuite { public: @@ -26,37 +37,33 @@ public: static void destroySuite(ConjoinXRunsTest *suite) { delete suite; } void setUp() override { - MatrixWorkspace_sptr ws1 = create2DWorkspace123(5, 3); // 3 points - MatrixWorkspace_sptr ws2 = create2DWorkspace154(5, 2); // 2 points - MatrixWorkspace_sptr ws3 = create2DWorkspace123(5, 1); // 1 point - MatrixWorkspace_sptr ws4 = create2DWorkspace154(5, 1); // 1 point - MatrixWorkspace_sptr ws5 = create2DWorkspace123(5, 3); // 3 points - MatrixWorkspace_sptr ws6 = create2DWorkspace123(5, 3); // 3 points - - ws1->getAxis(0)->setUnit("TOF"); - ws2->getAxis(0)->setUnit("TOF"); - ws3->getAxis(0)->setUnit("TOF"); - ws4->getAxis(0)->setUnit("TOF"); - ws5->getAxis(0)->setUnit("TOF"); - ws6->getAxis(0)->setUnit("TOF"); - - storeWS("ws1", ws1); - storeWS("ws2", ws2); - storeWS("ws3", ws3); - storeWS("ws4", ws4); - storeWS("ws5", ws5); - storeWS("ws6", ws6); - + std::vector<MatrixWorkspace_sptr> ws(6); + // Workspaces have 5 spectra must be point data, don't have masks and have + // dx + ws[0] = create2DWorkspace123(5, 3, false, std::set<int64_t>(), + true); // 3 points + ws[1] = create2DWorkspace154(5, 2, false, std::set<int64_t>(), + true); // 2 points + ws[2] = + create2DWorkspace123(5, 1, false, std::set<int64_t>(), true); // 1 point + ws[3] = + create2DWorkspace154(5, 1, false, std::set<int64_t>(), true); // 1 point + ws[4] = create2DWorkspace123(5, 3, false, std::set<int64_t>(), + true); // 3 points + ws[5] = create2DWorkspace123(5, 3, false, std::set<int64_t>(), + true); // 3 points m_testWS = {"ws1", "ws2", "ws3", "ws4", "ws5", "ws6"}; + + for (unsigned int i = 0; i < ws.size(); ++i) { + ws[i]->getAxis(0)->setUnit("TOF"); + storeWS(m_testWS[i], ws[i]); + } } void tearDown() override { - removeWS("ws1"); - removeWS("ws2"); - removeWS("ws3"); - removeWS("ws4"); - removeWS("ws5"); - removeWS("ws6"); + for (unsigned int i = 0; i < m_testWS.size(); ++i) { + removeWS(m_testWS[i]); + } m_testWS.clear(); } @@ -80,34 +87,43 @@ public: TS_ASSERT_EQUALS(out->blocksize(), 7); TS_ASSERT(!out->isHistogramData()); TS_ASSERT_EQUALS(out->getAxis(0)->unit()->unitID(), "TOF"); + std::vector<double> x{1., 2., 3., 1., 2., 1., 1.}; + std::vector<double> y{2., 2., 2., 5., 5., 2., 5.}; + std::vector<double> e{3., 3., 3., 4., 4., 3., 4.}; + TS_ASSERT_EQUALS(out->x(0).rawData(), x); + TS_ASSERT_EQUALS(out->y(0).rawData(), y); + TS_ASSERT_EQUALS(out->e(0).rawData(), e); + TSM_ASSERT_EQUALS("Dx and y values are the same", out->dx(0).rawData(), y); + } + + void testWSWithoutDxValues() { + // Workspaces have 5 spectra must be point data + MatrixWorkspace_sptr ws0 = create2DWorkspace123(5, 3); // 3 points + MatrixWorkspace_sptr ws1 = create2DWorkspace154(5, 2); // 2 points + ws0->getAxis(0)->setUnit("TOF"); + ws1->getAxis(0)->setUnit("TOF"); + storeWS("ws_0", ws0); + storeWS("ws_1", ws1); + m_testee.setProperty("InputWorkspaces", + std::vector<std::string>{"ws_0", "ws_1"}); + m_testee.setProperty("OutputWorkspace", "out"); + TS_ASSERT_THROWS_NOTHING(m_testee.execute()); + TS_ASSERT(m_testee.isExecuted()); + + MatrixWorkspace_sptr out = + AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("out"); - std::vector<double> spectrum = out->y(0).rawData(); - std::vector<double> error = out->e(0).rawData(); - std::vector<double> xaxis = out->x(0).rawData(); - - TS_ASSERT_EQUALS(spectrum[0], 2.); - TS_ASSERT_EQUALS(spectrum[1], 2.); - TS_ASSERT_EQUALS(spectrum[2], 2.); - TS_ASSERT_EQUALS(spectrum[3], 5.); - TS_ASSERT_EQUALS(spectrum[4], 5.); - TS_ASSERT_EQUALS(spectrum[5], 2.); - TS_ASSERT_EQUALS(spectrum[6], 5.); - - TS_ASSERT_EQUALS(error[0], 3.); - TS_ASSERT_EQUALS(error[1], 3.); - TS_ASSERT_EQUALS(error[2], 3.); - TS_ASSERT_EQUALS(error[3], 4.); - TS_ASSERT_EQUALS(error[4], 4.); - TS_ASSERT_EQUALS(error[5], 3.); - TS_ASSERT_EQUALS(error[6], 4.); - - TS_ASSERT_EQUALS(xaxis[0], 1.); - TS_ASSERT_EQUALS(xaxis[1], 2.); - TS_ASSERT_EQUALS(xaxis[2], 3.); - TS_ASSERT_EQUALS(xaxis[3], 1.); - TS_ASSERT_EQUALS(xaxis[4], 2.); - TS_ASSERT_EQUALS(xaxis[5], 1.); - TS_ASSERT_EQUALS(xaxis[6], 1.); + TS_ASSERT(out); + TS_ASSERT_EQUALS(out->getNumberHistograms(), 5); + TS_ASSERT_EQUALS(out->blocksize(), 5); + TS_ASSERT(!out->isHistogramData()); + TS_ASSERT_EQUALS(out->getAxis(0)->unit()->unitID(), "TOF"); + std::vector<double> x{1., 2., 3., 1., 2.}; + std::vector<double> y{2., 2., 2., 5., 5.}; + std::vector<double> e{3., 3., 3., 4., 4.}; + TS_ASSERT_EQUALS(out->x(0).rawData(), x); + TS_ASSERT_EQUALS(out->y(0).rawData(), y); + TS_ASSERT_EQUALS(out->e(0).rawData(), e); } void testFailDifferentNumberBins() { @@ -127,9 +143,11 @@ public: MatrixWorkspace_sptr ws6 = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("ws6"); - Counts counts{{4, 9, 16}}; - Points points{{0.4, 0.9, 1.1}}; - ws6->setHistogram(3, points, counts); + for (auto i = 0; i < 5; + i++) { // modify all 5 spectra of ws6 in terms of y and x + ws6->mutableY(i) = {4., 9., 16.}; + ws6->mutableX(i) = {0.4, 0.9, 1.1}; + } m_testee.setProperty("InputWorkspaces", std::vector<std::string>{"ws1", "ws6"}); @@ -146,55 +164,17 @@ public: TS_ASSERT(!out->isHistogramData()); TS_ASSERT_EQUALS(out->getAxis(0)->unit()->unitID(), "TOF"); - auto spectrum0 = out->y(0).rawData(); - auto error0 = out->e(0).rawData(); - auto xaxis0 = out->x(0).rawData(); - - TS_ASSERT_EQUALS(spectrum0[0], 2.); - TS_ASSERT_EQUALS(spectrum0[1], 2.); - TS_ASSERT_EQUALS(spectrum0[2], 2.); - TS_ASSERT_EQUALS(spectrum0[3], 2.); - TS_ASSERT_EQUALS(spectrum0[4], 2.); - TS_ASSERT_EQUALS(spectrum0[5], 2.); - - TS_ASSERT_EQUALS(error0[0], 3.); - TS_ASSERT_EQUALS(error0[1], 3.); - TS_ASSERT_EQUALS(error0[2], 3.); - TS_ASSERT_EQUALS(error0[3], 3.); - TS_ASSERT_EQUALS(error0[4], 3.); - TS_ASSERT_EQUALS(error0[5], 3.); - - TS_ASSERT_EQUALS(xaxis0[0], 1.); - TS_ASSERT_EQUALS(xaxis0[1], 2.); - TS_ASSERT_EQUALS(xaxis0[2], 3.); - TS_ASSERT_EQUALS(xaxis0[3], 1.); - TS_ASSERT_EQUALS(xaxis0[4], 2.); - TS_ASSERT_EQUALS(xaxis0[5], 3.); - - auto spectrum3 = out->y(3).rawData(); - auto error3 = out->e(3).rawData(); - auto xaxis3 = out->x(3).rawData(); - - TS_ASSERT_EQUALS(spectrum3[0], 2.); - TS_ASSERT_EQUALS(spectrum3[1], 2.); - TS_ASSERT_EQUALS(spectrum3[2], 2.); - TS_ASSERT_EQUALS(spectrum3[3], 4.); - TS_ASSERT_EQUALS(spectrum3[4], 9.); - TS_ASSERT_EQUALS(spectrum3[5], 16.); - - TS_ASSERT_EQUALS(error3[0], 3.); - TS_ASSERT_EQUALS(error3[1], 3.); - TS_ASSERT_EQUALS(error3[2], 3.); - TS_ASSERT_EQUALS(error3[3], 2.); - TS_ASSERT_EQUALS(error3[4], 3.); - TS_ASSERT_EQUALS(error3[5], 4.); - - TS_ASSERT_EQUALS(xaxis3[0], 1.); - TS_ASSERT_EQUALS(xaxis3[1], 2.); - TS_ASSERT_EQUALS(xaxis3[2], 3.); - TS_ASSERT_EQUALS(xaxis3[3], 0.4); - TS_ASSERT_EQUALS(xaxis3[4], 0.9); - TS_ASSERT_EQUALS(xaxis3[5], 1.1); + std::vector<double> x_vec{1., 2., 3., .4, .9, 1.1}; + std::vector<double> y_vec{2., 2., 2., 4., 9., 16.}; + std::vector<double> e_vec{3., 3., 3., 3., 3., 3.}; + std::vector<double> dx_vec{2., 2., 2., 2., 2., 2.}; + // Check all 5 spectra + for (auto i = 0; i < 5; i++) { + TS_ASSERT_EQUALS(out->y(i).rawData(), y_vec); + TS_ASSERT_EQUALS(out->e(i).rawData(), e_vec); + TS_ASSERT_EQUALS(out->x(i).rawData(), x_vec); + TS_ASSERT_EQUALS(out->dx(i).rawData(), dx_vec); + } } void testFailWithNumLog() { @@ -245,16 +225,12 @@ public: TS_ASSERT_EQUALS(out->getNumberHistograms(), 5); TS_ASSERT_EQUALS(out->getAxis(0)->unit()->unitID(), "Energy"); - std::vector<double> xaxis = out->x(0).rawData(); - std::vector<double> spectrum = out->y(0).rawData(); - std::vector<double> error = out->e(0).rawData(); - - TS_ASSERT_EQUALS(xaxis[0], 0.7); - TS_ASSERT_EQUALS(xaxis[1], 1.1); - TS_ASSERT_EQUALS(spectrum[0], 2.); - TS_ASSERT_EQUALS(spectrum[1], 5.); - TS_ASSERT_EQUALS(error[0], 3.); - TS_ASSERT_EQUALS(error[1], 4.); + TS_ASSERT_EQUALS(out->x(0)[0], 0.7); + TS_ASSERT_EQUALS(out->x(0)[1], 1.1); + TS_ASSERT_EQUALS(out->y(0)[0], 2.); + TS_ASSERT_EQUALS(out->y(0)[1], 5.); + TS_ASSERT_EQUALS(out->e(0)[0], 3.); + TS_ASSERT_EQUALS(out->e(0)[1], 4.); } void testFailWithStringLog() { @@ -315,27 +291,13 @@ public: TS_ASSERT_EQUALS(out->blocksize(), 5); TS_ASSERT_EQUALS(out->getNumberHistograms(), 5); - std::vector<double> spectrum = out->y(0).rawData(); - std::vector<double> xaxis = out->x(0).rawData(); - std::vector<double> error = out->e(0).rawData(); - - TS_ASSERT_EQUALS(spectrum[0], 2.); - TS_ASSERT_EQUALS(spectrum[1], 2.); - TS_ASSERT_EQUALS(spectrum[2], 2.); - TS_ASSERT_EQUALS(spectrum[3], 5.); - TS_ASSERT_EQUALS(spectrum[4], 5.); - - TS_ASSERT_EQUALS(error[0], 3.); - TS_ASSERT_EQUALS(error[1], 3.); - TS_ASSERT_EQUALS(error[2], 3.); - TS_ASSERT_EQUALS(error[3], 4.); - TS_ASSERT_EQUALS(error[4], 4.); - - TS_ASSERT_EQUALS(xaxis[0], 5.7); - TS_ASSERT_EQUALS(xaxis[1], 6.1); - TS_ASSERT_EQUALS(xaxis[2], 6.7); - TS_ASSERT_EQUALS(xaxis[3], 8.3); - TS_ASSERT_EQUALS(xaxis[4], 9.5); + std::vector<double> y_vec{2., 2., 2., 5., 5.}; + std::vector<double> x_vec{5.7, 6.1, 6.7, 8.3, 9.5}; + std::vector<double> e_vec{3., 3., 3., 4., 4.}; + TS_ASSERT_EQUALS(out->y(0).rawData(), y_vec); + TS_ASSERT_EQUALS(out->x(0).rawData(), x_vec); + TS_ASSERT_EQUALS(out->e(0).rawData(), e_vec); + TS_ASSERT_EQUALS(out->dx(0).rawData(), y_vec) } void testFailWithNumSeriesLog() { @@ -402,7 +364,8 @@ public: void setUp() override { m_ws.reserve(100); for (size_t i = 0; i < 100; ++i) { - MatrixWorkspace_sptr ws = create2DWorkspace123(10000, 100); + MatrixWorkspace_sptr ws = + create2DWorkspace123(2000, 100, false, std::set<int64_t>(), true); std::string name = "ws" + std::to_string(i); storeWS(name, ws); m_ws.push_back(name); diff --git a/Framework/Algorithms/test/ConvertToHistogramTest.h b/Framework/Algorithms/test/ConvertToHistogramTest.h index 0af9416c715ef295b7019e352fe57a6c4103b763..5ac8871d696e8cf6e224b75d33658a5569aeb123 100644 --- a/Framework/Algorithms/test/ConvertToHistogramTest.h +++ b/Framework/Algorithms/test/ConvertToHistogramTest.h @@ -13,12 +13,18 @@ using Mantid::API::MatrixWorkspace_sptr; using Mantid::Algorithms::ConvertToHistogram; using Mantid::DataObjects::Workspace2D_sptr; using Mantid::MantidVecPtr; +using Mantid::HistogramData::HistogramDx; using Mantid::HistogramData::LinearGenerator; using Mantid::HistogramData::Points; +using Mantid::Kernel::make_cow; class ConvertToHistogramTest : public CxxTest::TestSuite { public: + void tearDown() override { + Mantid::API::AnalysisDataService::Instance().clear(); + } + void test_That_The_Algorithm_Has_Two_Properties() { ConvertToHistogram alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -38,7 +44,6 @@ public: // Check that the algorithm just pointed the output data at the input TS_ASSERT_EQUALS(&(*testWS), &(*outputWS)); - Mantid::API::AnalysisDataService::Instance().remove(outputWS->getName()); } void test_A_Point_Data_InputWorkspace_Is_Converted_To_A_Histogram() { @@ -63,43 +68,40 @@ public: TS_ASSERT_EQUALS(outputWS->isHistogramData(), true); const int numBoundaries = numYPoints + 1; - // This makes the new X values more readable rather than using a dynamic - // array - // so I'll live with the hard coding const double expectedX[11] = {-0.5, 0.5, 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5}; for (int j = 0; j < numBoundaries; ++j) { TS_ASSERT_EQUALS(outputWS->readX(0)[j], expectedX[j]); } + } - // for( int i = 0; i < numSpectra; ++i ) - // { - // const Mantid::MantidVec & yValues = outputWS->readY(i); - // const Mantid::MantidVec & xValues = outputWS->readX(i); - // const Mantid::MantidVec & eValues = outputWS->readE(i); - - // TS_ASSERT_EQUALS(xValues.size(), numBins); - // // The y and e values sizes be unchanged - // TS_ASSERT_EQUALS(yValues.size(), numYPoints); - // TS_ASSERT_EQUALS(eValues.size(), numYPoints); - - // for( int j = 0; j < numYPoints; ++j ) - // { - // // Now the data. Y and E unchanged - // TS_ASSERT_EQUALS(yValues[j], 2.0); - // TS_ASSERT_EQUALS(eValues[j], M_SQRT2); - - // // X data originally was 0->10 in steps of 1. Now it should be the - // centre of each bin which is - // // 1.0 away from the last centre - // const double expectedX = 0.5 + j*1.0; - // TS_ASSERT_EQUALS(xValues[j], expectedX); - // } - // // And the final X points - // TS_ASSERT_EQUALS(xValues.back(), 100.); - // } - - Mantid::API::AnalysisDataService::Instance().remove(outputWS->getName()); + void test_Dx_Data_Is_Handled_Correctly() { + // Creates a workspace with 10 points + constexpr int numYPoints{10}; + constexpr int numSpectra{2}; + Workspace2D_sptr testWS = WorkspaceCreationHelper::create2DWorkspace123( + numSpectra, numYPoints, false); + double xErrors[numYPoints] = {0.1, 0.2, 0.3, 0.4, 0.5, + 0.6, 0.7, 0.8, 0.9, 1.0}; + auto dxs = make_cow<HistogramDx>(xErrors, xErrors + numYPoints); + // Reset the X data to something reasonable, set Dx. + Points x(numYPoints, LinearGenerator(0.0, 1.0)); + for (int i = 0; i < numSpectra; ++i) { + testWS->setPoints(i, x); + testWS->setSharedDx(i, dxs); + } + TS_ASSERT(!testWS->isHistogramData()) + MatrixWorkspace_sptr outputWS = runAlgorithm(testWS); + TS_ASSERT(outputWS); + TS_ASSERT(outputWS->isHistogramData()) + for (size_t i = 0; i < outputWS->getNumberHistograms(); ++i) { + TS_ASSERT(outputWS->hasDx(i)) + const auto &dx = outputWS->dx(i); + TS_ASSERT_EQUALS(dx.size(), numYPoints) + for (size_t j = 0; j < dx.size(); ++j) { + TS_ASSERT_EQUALS(dx[j], xErrors[j]) + } + } } private: diff --git a/Framework/Algorithms/test/ConvertToPointDataTest.h b/Framework/Algorithms/test/ConvertToPointDataTest.h index 287621e1ecb944169405ce0425df9be9f515d458..33a2a42f94137f5a76665ef3f902fb2bde5ab1cf 100644 --- a/Framework/Algorithms/test/ConvertToPointDataTest.h +++ b/Framework/Algorithms/test/ConvertToPointDataTest.h @@ -17,6 +17,10 @@ using Mantid::DataObjects::Workspace2D_sptr; class ConvertToPointDataTest : public CxxTest::TestSuite { public: + void tearDown() override { + Mantid::API::AnalysisDataService::Instance().clear(); + } + void test_That_The_Algorithm_Has_Two_Properties() { ConvertToPointData alg; TS_ASSERT_THROWS_NOTHING(alg.initialize()); @@ -35,7 +39,6 @@ public: // Check that the algorithm just pointed the output data at the input TS_ASSERT_EQUALS(&(*testWS), &(*outputWS)); - Mantid::API::AnalysisDataService::Instance().remove(outputWS->getName()); } void test_A_Uniformly_Binned_Histogram_Is_Transformed_Correctly() { @@ -94,8 +97,6 @@ public: TS_ASSERT_EQUALS((*(outputWS->getAxis(1)))(0), 0); TS_ASSERT_EQUALS((*(outputWS->getAxis(1)))(1), 2); TS_ASSERT_EQUALS((*(outputWS->getAxis(1)))(2), 4); - - Mantid::API::AnalysisDataService::Instance().remove(outputWS->getName()); } void test_A_Non_Uniformly_Binned_Histogram_Is_Transformed_Correctly() { @@ -103,8 +104,9 @@ public: double xBoundaries[11] = {0.0, 1.0, 3.0, 5.0, 6.0, 7.0, 10.0, 13.0, 16.0, 17.0, 17.5}; const int numSpectra(2); - Workspace2D_sptr testWS = WorkspaceCreationHelper::create2DWorkspaceBinned( - numSpectra, 11, xBoundaries); + Workspace2D_sptr testWS = + WorkspaceCreationHelper::create2DWorkspaceNonUniformlyBinned( + numSpectra, 11, xBoundaries); const size_t numBins = testWS->blocksize(); TS_ASSERT_EQUALS(testWS->isHistogramData(), true); @@ -139,6 +141,30 @@ public: } } + void test_Dx_Data_Is_Handled_Correctly() { + constexpr size_t numBins{11}; + double xBoundaries[numBins] = {0.0, 1.0, 3.0, 5.0, 6.0, 7.0, + 10.0, 13.0, 16.0, 17.0, 17.5}; + constexpr int numSpectra{2}; + Workspace2D_sptr testWS = + WorkspaceCreationHelper::create2DWorkspaceNonUniformlyBinned( + numSpectra, numBins, xBoundaries, true); + TS_ASSERT(testWS->isHistogramData()) + double xErrors[numBins - 1] = {0.1, 0.2, 0.3, 0.4, 0.5, + 0.6, 0.7, 0.8, 0.9, 1.0}; + MatrixWorkspace_sptr outputWS = runAlgorithm(testWS); + TS_ASSERT(outputWS) + TS_ASSERT(!outputWS->isHistogramData()) + for (size_t i = 0; i < outputWS->getNumberHistograms(); ++i) { + TS_ASSERT(outputWS->hasDx(i)) + const auto &dx = outputWS->dx(i); + TS_ASSERT_EQUALS(dx.size(), numBins - 1) + for (size_t j = 0; j < dx.size(); ++j) { + TS_ASSERT_DELTA(dx[j], xErrors[j], 1E-16); + } + } + } + private: MatrixWorkspace_sptr runAlgorithm(Workspace2D_sptr inputWS) { IAlgorithm_sptr alg(new ConvertToPointData()); diff --git a/Framework/Algorithms/test/ConvertUnitsTest.h b/Framework/Algorithms/test/ConvertUnitsTest.h index 5340a181e069a70531faf64483ab83ae65a1f31b..67db2df5870fcdea567328f07c94caf32a162c3e 100644 --- a/Framework/Algorithms/test/ConvertUnitsTest.h +++ b/Framework/Algorithms/test/ConvertUnitsTest.h @@ -714,7 +714,7 @@ public: WorkspaceCreationHelper::createEventWorkspaceWithFullInstrument(1, 10, false); ws->getAxis(0)->setUnit("TOF"); - ws->sortAll(sortType, NULL); + ws->sortAll(sortType, nullptr); if (sortType == TOF_SORT) { // Only threadsafe if all the event lists are sorted diff --git a/Framework/Algorithms/test/CopyInstrumentParametersTest.h b/Framework/Algorithms/test/CopyInstrumentParametersTest.h index 6109c023b2a07f06eedd00f32a98864ad31746be..4a5b449f498d632b0680169d54022ead2d385197 100644 --- a/Framework/Algorithms/test/CopyInstrumentParametersTest.h +++ b/Framework/Algorithms/test/CopyInstrumentParametersTest.h @@ -3,32 +3,25 @@ #include <cxxtest/TestSuite.h> -#include "MantidDataHandling/LoadInstrument.h" -#include "MantidAPI/IAlgorithm.h" #include "MantidAlgorithms/CopyInstrumentParameters.h" -#include "MantidAPI/Workspace.h" -#include "MantidDataObjects/Workspace2D.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/IAlgorithm.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" #include "MantidAPI/WorkspaceFactory.h" -#include "WorkspaceCreationHelperTest.h" -#include "MantidAPI/AnalysisDataService.h" -#include "MantidAPI/ITableWorkspace.h" -#include "MantidAPI/TableRow.h" #include "MantidKernel/V3D.h" #include "MantidGeometry/Instrument.h" #include "MantidGeometry/Instrument/Component.h" -#include "MantidDataHandling/LoadEmptyInstrument.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cmath> #include <stdexcept> using namespace Mantid::Algorithms; using namespace Mantid::API; -using namespace Mantid::Kernel; -using namespace Mantid::DataObjects; -using Mantid::Geometry::IDetector_const_sptr; -using Mantid::Geometry::IComponent_const_sptr; +using Mantid::Geometry::Instrument_const_sptr; +using Mantid::Geometry::ParameterMap; +using Mantid::Kernel::V3D; class CopyInstrumentParametersTest : public CxxTest::TestSuite { public: @@ -62,10 +55,10 @@ public: TS_ASSERT_THROWS_NOTHING( copyInstParam.setPropertyValue("OutputWorkspace", wsName2)); // Get instrument of input workspace and move some detectors - Geometry::ParameterMap *pmap; + ParameterMap *pmap; pmap = &(ws1->instrumentParameters()); auto &detectorInfoWs1 = ws1->mutableDetectorInfo(); - Geometry::Instrument_const_sptr instrument = ws1->getInstrument(); + Instrument_const_sptr instrument = ws1->getInstrument(); detectorInfoWs1.setPosition(0, V3D(6.0, 0.0, 0.7)); detectorInfoWs1.setPosition(1, V3D(6.0, 0.1, 0.7)); @@ -119,8 +112,8 @@ public: AnalysisDataServiceImpl &dataStore = AnalysisDataService::Instance(); dataStore.add(wsName1, ws1); - Geometry::Instrument_const_sptr instrument = ws1->getInstrument(); - Geometry::ParameterMap *pmap; + Instrument_const_sptr instrument = ws1->getInstrument(); + ParameterMap *pmap; pmap = &(ws1->instrumentParameters()); // add auxiliary instrument parameters pmap->addDouble(instrument.get(), "Ei", 100); @@ -218,8 +211,8 @@ public: AnalysisDataServiceImpl &dataStore = AnalysisDataService::Instance(); dataStore.add(m_SourceWSName, ws1); - Geometry::Instrument_const_sptr instrument = ws1->getInstrument(); - Geometry::ParameterMap *pmap; + Instrument_const_sptr instrument = ws1->getInstrument(); + ParameterMap *pmap; pmap = &(ws1->instrumentParameters()); for (size_t i = 0; i < n_Parameters; i++) { // add auxiliary instrument parameters @@ -230,7 +223,8 @@ public: // calibrate detectors; auto &detectorInfo = ws1->mutableDetectorInfo(); for (size_t i = 0; i < n_detectors; i++) { - auto detIndex = detectorInfo.indexOf(static_cast<Mantid::detid_t>(i + 1)); + size_t detIndex = + detectorInfo.indexOf(static_cast<Mantid::detid_t>(i + 1)); detectorInfo.setPosition( detIndex, V3D(sin(M_PI * double(i)), cos(M_PI * double(i / 500)), 7)); } @@ -270,7 +264,7 @@ public: AnalysisDataServiceImpl &dataStore = AnalysisDataService::Instance(); MatrixWorkspace_sptr ws2 = - dataStore.retrieveWS<API::MatrixWorkspace>(m_TargetWSName); + dataStore.retrieveWS<MatrixWorkspace>(m_TargetWSName); auto instr2 = ws2->getInstrument(); auto param_names = instr2->getParameterNames(); diff --git a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h index 6647ebd9c676eb173ba35b53a2301bff45fb6119..da7c08c0a7501bc6db2d47bf6631e26476e10720 100644 --- a/Framework/Algorithms/test/CorelliCrossCorrelateTest.h +++ b/Framework/Algorithms/test/CorelliCrossCorrelateTest.h @@ -62,7 +62,7 @@ public: ws->getAxis(0)->setUnit("TOF"); - ws->sortAll(PULSETIME_SORT, NULL); + ws->sortAll(PULSETIME_SORT, nullptr); // Add some chopper TDCs to the workspace. double period = 1 / 293.383; diff --git a/Framework/Algorithms/test/CreateTransmissionWorkspaceTest.h b/Framework/Algorithms/test/CreateTransmissionWorkspaceTest.h index 9f715efd114ee6cd38c1f9eaa01e34482070dcbd..8b524bcdf6a3a88e1e33b809991dfdbe62553238 100644 --- a/Framework/Algorithms/test/CreateTransmissionWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateTransmissionWorkspaceTest.h @@ -10,7 +10,6 @@ #include <cxxtest/TestSuite.h> #include <algorithm> -#include "MantidAlgorithms/ReflectometryReductionOne.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/Axis.h" #include "MantidAPI/FrameworkManager.h" @@ -22,7 +21,6 @@ using namespace Mantid; using namespace Mantid::Kernel; using namespace Mantid::API; -using namespace Mantid::Algorithms; using namespace WorkspaceCreationHelper; class CreateTransmissionWorkspaceTest : public CxxTest::TestSuite { diff --git a/Framework/Algorithms/test/CreateWorkspaceTest.h b/Framework/Algorithms/test/CreateWorkspaceTest.h index 86bdb52c4548a7e12ecf297860b591df4601dcb3..823ba7ba664060bf0ab132f115c95343ef1e4fad 100644 --- a/Framework/Algorithms/test/CreateWorkspaceTest.h +++ b/Framework/Algorithms/test/CreateWorkspaceTest.h @@ -23,6 +23,7 @@ void run_create(const Parallel::Communicator &comm, alg->setProperty<std::vector<double>>("DataX", dataEYX); alg->setProperty<std::vector<double>>("DataY", dataEYX); alg->setProperty<std::vector<double>>("DataE", dataEYX); + alg->setProperty<std::vector<double>>("Dx", dataEYX); alg->setProperty("ParallelStorageMode", storageMode); alg->execute(); MatrixWorkspace_const_sptr ws = alg->getProperty("OutputWorkspace"); @@ -73,6 +74,8 @@ public: alg.setProperty<std::vector<double>>("DataY", dataEYX)); TS_ASSERT_THROWS_NOTHING( alg.setProperty<std::vector<double>>("DataE", dataEYX)); + TS_ASSERT_THROWS_NOTHING( + alg.setProperty<std::vector<double>>("Dx", dataEYX)); TS_ASSERT_THROWS_NOTHING(alg.setPropertyValue("UnitX", "Wavelength")); TS_ASSERT_THROWS_NOTHING( alg.setPropertyValue("VerticalAxisUnit", "MomentumTransfer")); @@ -95,17 +98,14 @@ public: // No parent workspace -> no instrument -> no detectors -> no mapping. TS_ASSERT_EQUALS(ws->getSpectrum(0).getDetectorIDs().size(), 0); - TS_ASSERT_EQUALS(ws->x(0)[0], 0); - TS_ASSERT_EQUALS(ws->x(0)[1], 1.234); - TS_ASSERT_EQUALS(ws->x(0)[2], 2.468); - TS_ASSERT_EQUALS(ws->y(0)[0], 0); - TS_ASSERT_EQUALS(ws->y(0)[1], 1.234); - TS_ASSERT_EQUALS(ws->y(0)[2], 2.468); - TS_ASSERT_EQUALS(ws->e(0)[0], 0); - TS_ASSERT_EQUALS(ws->e(0)[1], 1.234); - TS_ASSERT_EQUALS(ws->e(0)[2], 2.468); + for (size_t i = 0; i < dataEYX.size(); ++i) { + TS_ASSERT_EQUALS(ws->x(0)[i], dataEYX[i]); + } + for (size_t i = 0; i < dataEYX.size(); ++i) { + TS_ASSERT_EQUALS(ws->y(0)[i], dataEYX[i]); + TS_ASSERT_EQUALS(ws->e(0)[i], dataEYX[i]); + } TS_ASSERT_EQUALS(ws->getAxis(0)->unit()->caption(), "Wavelength"); - TS_ASSERT_EQUALS(ws->getAxis(1)->unit()->unitID(), "MomentumTransfer"); TS_ASSERT_EQUALS(ws->getAxis(1)->unit()->caption(), "q"); @@ -122,6 +122,54 @@ public: "test_CreateWorkspace")); } + void testCreateBinEdges() { + Mantid::Algorithms::CreateWorkspace createBinEdges; + TS_ASSERT_THROWS_NOTHING(createBinEdges.initialize()); + + std::vector<double> dataX{5.5, 6.8, 9.1, 12.3}; + std::vector<double> dataEYDx{0.0, 1.234, 2.468}; + + TS_ASSERT_THROWS_NOTHING(createBinEdges.setProperty<int>("NSpec", 1)); + TS_ASSERT_THROWS_NOTHING( + createBinEdges.setProperty<std::vector<double>>("DataX", dataX)); + TS_ASSERT_THROWS_NOTHING( + createBinEdges.setProperty<std::vector<double>>("DataY", dataEYDx)); + TS_ASSERT_THROWS_NOTHING( + createBinEdges.setProperty<std::vector<double>>("DataE", dataEYDx)); + TS_ASSERT_THROWS_NOTHING( + createBinEdges.setProperty<std::vector<double>>("Dx", dataEYDx)); + TS_ASSERT_THROWS_NOTHING(createBinEdges.setPropertyValue( + "OutputWorkspace", "test_CreateWorkspace")); + TS_ASSERT_THROWS_NOTHING(createBinEdges.execute()); + + TS_ASSERT(createBinEdges.isExecuted()); + Mantid::API::MatrixWorkspace_const_sptr ws; + + TS_ASSERT_THROWS_NOTHING( + ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( + Mantid::API::AnalysisDataService::Instance().retrieve( + "test_CreateWorkspace"))); + + TS_ASSERT(ws->isHistogramData()); + TS_ASSERT_EQUALS(ws->getNumberHistograms(), 1); + // No parent workspace -> no instrument -> no detectors -> no mapping. + TS_ASSERT_EQUALS(ws->getSpectrum(0).getDetectorIDs().size(), 0); + + for (size_t i = 0; i < dataX.size(); ++i) { + TS_ASSERT_EQUALS(ws->x(0)[i], dataX[i]); + } + for (size_t i = 0; i < dataEYDx.size(); ++i) { + TS_ASSERT_EQUALS(ws->y(0)[i], dataEYDx[i]); + TS_ASSERT_EQUALS(ws->e(0)[i], dataEYDx[i]); + TS_ASSERT_EQUALS(ws->dx(0)[i], dataEYDx[i]); + } + + // Remove the created workspace + TS_ASSERT_THROWS_NOTHING( + Mantid::API::AnalysisDataService::Instance().remove( + "test_CreateWorkspace")); + } + void testCreateTextAxis() { std::vector<std::string> textAxis{"I've Got", "A Lovely", "Bunch Of", "Coconuts"}; @@ -157,11 +205,12 @@ public: alg.setProperty<int>("NSpec", 4); std::vector<double> values{1.0, 2.0, 3.0, 4.0}; + std::vector<double> xVals{1.1, 2.2}; - alg.setProperty<std::vector<double>>("DataX", - std::vector<double>{1.1, 2.2}); + alg.setProperty<std::vector<double>>("DataX", xVals); alg.setProperty<std::vector<double>>("DataY", values); alg.setProperty<std::vector<double>>("DataE", values); + alg.setProperty<std::vector<double>>("Dx", xVals); TS_ASSERT_THROWS(alg.execute(), std::invalid_argument); } @@ -302,6 +351,7 @@ public: creator.setProperty("DataX", *vec); creator.setProperty("DataY", *vec); creator.setProperty("DataE", *vec); + creator.setProperty("Dx", *vec); creator.setProperty("NSpec", 10000); TS_ASSERT(creator.execute()); } diff --git a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h index 419b32dd424a8296ab76140502f35116300e2a48..1203cd31423cc81381f875cad06a8bb3fe585d3d 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyCorTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyCorTest.h @@ -113,8 +113,8 @@ private: using namespace Mantid::DataObjects; std::string xmlShape = "<cylinder id=\"shape\"> "; - xmlShape += "<centre-of-bottom-base x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"1.0\" z=\"0\" /> "; + xmlShape += R"(<centre-of-bottom-base x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="1.0" z="0" /> )"; xmlShape += "<radius val=\"0.0127\" /> "; xmlShape += "<height val=\"1\" /> "; xmlShape += "</cylinder>"; @@ -128,13 +128,13 @@ private: const int ndets(2); std::vector<Detector *> detectors; for (int i = 0; i < ndets; ++i) { - Detector *detector = new Detector("det", i + 1, shape, NULL); + Detector *detector = new Detector("det", i + 1, shape, nullptr); detector->setPos(i * 0.2, i * 0.2, 5); instrument->add(detector); instrument->markAsDetector(detector); detectors.push_back(detector); } - ObjComponent *sample = new ObjComponent("sample", shape, NULL); + ObjComponent *sample = new ObjComponent("sample", shape, nullptr); sample->setPos(0, 0, 0); instrument->markAsSamplePos(sample); diff --git a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h index f91e385f02b7b81454bbfdcb26d5750c8f700674..cfeac3a09db0fcac766ec7fb03ed96b2c29d6b56 100644 --- a/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h +++ b/Framework/Algorithms/test/DetectorEfficiencyVariationTest.h @@ -130,8 +130,8 @@ public: inputB->setBinEdges(j, x); std::vector<double> forInputA, forInputB; // the spectravalues will be multiples of the random numbers above - for (int l = 0; l < ySize; ++l) { - forInputA.push_back(yArray[l]); + for (double y : yArray) { + forInputA.push_back(y); // there is going to be a small difference between the workspaces that // will vary with histogram number forInputB.push_back(forInputA.back() * diff --git a/Framework/Algorithms/test/DiffractionFocussing2Test.h b/Framework/Algorithms/test/DiffractionFocussing2Test.h index c0a0e67a77556bb6bd9b94a5cf500e5d1d4dd43c..c22f2022a26acc70a81acc4121ba86ef0b2c3690 100644 --- a/Framework/Algorithms/test/DiffractionFocussing2Test.h +++ b/Framework/Algorithms/test/DiffractionFocussing2Test.h @@ -270,7 +270,7 @@ public: alg->execute(); ws = AnalysisDataService::Instance().retrieveWS<EventWorkspace>( "SNAP_empty"); - ws->sortAll(TOF_SORT, NULL); + ws->sortAll(TOF_SORT, nullptr); // Fill a whole bunch of events PARALLEL_FOR_NO_WSP_CHECK() diff --git a/Framework/Algorithms/test/ExtractMaskTest.h b/Framework/Algorithms/test/ExtractMaskTest.h index e9803cf60e6c508e7227aaed47f558044a704f42..94d2c8503d51653c5e4398497cafaaeae39d1004 100644 --- a/Framework/Algorithms/test/ExtractMaskTest.h +++ b/Framework/Algorithms/test/ExtractMaskTest.h @@ -6,6 +6,7 @@ #include "MantidAlgorithms/ExtractMask.h" #include "MantidDataObjects/MaskWorkspace.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" +#include "MantidAPI/SpectrumInfo.h" using namespace Mantid::API; using namespace Mantid::DataObjects; @@ -59,6 +60,67 @@ public: AnalysisDataService::Instance().remove(outputWS->getName()); } + void test_That_Masked_Detector_List_Populated_When_Passed_A_Mask_Workspace() { + // Create a simple test workspace + const int nvectors(50), nbins(10); + Workspace2D_sptr inputWS = + WorkspaceCreationHelper::create2DWorkspace(nvectors, nbins); + // Mask every 10th spectra + std::set<int64_t> maskedIndices; + for (int i = 0; i < 50; i += 10) { + maskedIndices.insert(i); + } + // A few randoms + maskedIndices.insert(5); + maskedIndices.insert(23); + maskedIndices.insert(37); + inputWS = WorkspaceCreationHelper::maskSpectra(inputWS, maskedIndices); + const std::string inputName("inputWSMask"); + AnalysisDataService::Instance().add(inputName, inputWS); + MaskWorkspace_sptr inputWSMask = runExtractMask(inputName); + std::vector<Mantid::detid_t> expectedDetectorList = {1, 6, 11, 21, + 24, 31, 38, 41}; + + std::vector<Mantid::detid_t> detectorList; + + TS_ASSERT_THROWS_NOTHING( + detectorList = runExtractMaskReturnList(inputWSMask->getName())); + TS_ASSERT_EQUALS(detectorList, expectedDetectorList) + + AnalysisDataService::Instance().remove(inputName); + AnalysisDataService::Instance().remove(inputWSMask->getName()); + } + + void test_That_Masked_Detector_List_Populated_When_Passed_A_Workspace() { + // Create a simple test workspace + const int nvectors(50), nbins(10); + Workspace2D_sptr inputWS = + WorkspaceCreationHelper::create2DWorkspace(nvectors, nbins); + // Mask every 10th spectra + std::set<int64_t> maskedIndices; + for (int i = 0; i < 50; i += 10) { + maskedIndices.insert(i); + } + // A few randoms + maskedIndices.insert(5); + maskedIndices.insert(23); + maskedIndices.insert(37); + inputWS = WorkspaceCreationHelper::maskSpectra(inputWS, maskedIndices); + const std::string inputName("inputWS"); + AnalysisDataService::Instance().add(inputName, inputWS); + + std::vector<Mantid::detid_t> expectedDetectorList = {1, 6, 11, 21, + 24, 31, 38, 41}; + + std::vector<Mantid::detid_t> detectorList; + + TS_ASSERT_THROWS_NOTHING(detectorList = + runExtractMaskReturnList(inputName)); + TS_ASSERT_EQUALS(detectorList, expectedDetectorList) + + AnalysisDataService::Instance().remove(inputName); + } + private: // The input workspace should be in the analysis data service MaskWorkspace_sptr runExtractMask(const std::string &inputName) { @@ -82,6 +144,21 @@ private: } } + std::vector<Mantid::detid_t> + runExtractMaskReturnList(const std::string &inputName) { + ExtractMask maskExtractor; + maskExtractor.initialize(); + maskExtractor.setPropertyValue("InputWorkspace", inputName); + const std::string outputName("masking"); + maskExtractor.setPropertyValue("OutputWorkspace", outputName); + maskExtractor.setRethrows(true); + maskExtractor.execute(); + std::vector<Mantid::detid_t> detectorList = + maskExtractor.getProperty("DetectorList"); + AnalysisDataService::Instance().remove(outputName); + return detectorList; + } + void doTest(MatrixWorkspace_const_sptr inputWS, MaskWorkspace_const_sptr outputWS) { TS_ASSERT_EQUALS(outputWS->blocksize(), 1); diff --git a/Framework/Algorithms/test/FilterEventsTest.h b/Framework/Algorithms/test/FilterEventsTest.h index 7cbc4ae3eccc68e16f5301496607a942a3149200..10c83e09c25e84558615562f78ad2b7547957cb3 100644 --- a/Framework/Algorithms/test/FilterEventsTest.h +++ b/Framework/Algorithms/test/FilterEventsTest.h @@ -254,8 +254,8 @@ public: AnalysisDataService::Instance().remove("Splitter02"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -350,9 +350,9 @@ public: AnalysisDataService::Instance().remove("Splitter02"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - std::cout << "Delete output workspace name: " << outputwsnames[i] << "\n"; - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + std::cout << "Delete output workspace name: " << outputwsname << "\n"; + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -435,8 +435,8 @@ public: std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -493,8 +493,8 @@ public: // Delete all the workspaces generated here AnalysisDataService::Instance().remove("MockDirectEventWS"); AnalysisDataService::Instance().remove("SplitterTableX"); - for (size_t i = 0; i < vecwsname.size(); ++i) { - AnalysisDataService::Instance().remove(vecwsname[i]); + for (const auto &workspaceName : vecwsname) { + AnalysisDataService::Instance().remove(workspaceName); } return; @@ -544,8 +544,8 @@ public: AnalysisDataService::Instance().remove("SplitterTableX"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -608,8 +608,8 @@ public: AnalysisDataService::Instance().remove("MockIndirectEventWS"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -781,10 +781,10 @@ public: // Test the sample logs std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { + for (const auto &outputwsname : outputwsnames) { EventWorkspace_sptr filtered_ws = boost::dynamic_pointer_cast<DataObjects::EventWorkspace>( - AnalysisDataService::Instance().retrieve(outputwsnames[i])); + AnalysisDataService::Instance().retrieve(outputwsname)); TS_ASSERT(filtered_ws->run().hasProperty("LogA")); TS_ASSERT(filtered_ws->run().hasProperty("LogB")); @@ -805,8 +805,8 @@ public: // clean up all the workspaces generated AnalysisDataService::Instance().remove("Test10"); AnalysisDataService::Instance().remove("Splitter10"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -977,8 +977,8 @@ public: AnalysisDataService::Instance().remove("TableSplitter1"); std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -1033,10 +1033,10 @@ public: std::vector<std::string> outputwsnames = filter.getProperty("OutputWorkspaceNames"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { + for (const auto &outputwsname : outputwsnames) { EventWorkspace_sptr childworkspace = boost::dynamic_pointer_cast<EventWorkspace>( - AnalysisDataService::Instance().retrieve(outputwsnames[i])); + AnalysisDataService::Instance().retrieve(outputwsname)); TS_ASSERT(childworkspace); // there is 1 sample logs that is excluded from propagating to the child // workspaces. LogB is not TSP, so it won't be excluded even if it is @@ -1051,8 +1051,8 @@ public: // clean workspaces AnalysisDataService::Instance().remove("Test12"); AnalysisDataService::Instance().remove("TableSplitter2"); - for (size_t i = 0; i < outputwsnames.size(); ++i) { - AnalysisDataService::Instance().remove(outputwsnames[i]); + for (const auto &outputwsname : outputwsnames) { + AnalysisDataService::Instance().remove(outputwsname); } return; @@ -1587,8 +1587,7 @@ public: // 2. Add rows const auto &detectorInfo = inpws->detectorInfo(); const auto detids = detectorInfo.detectorIDs(); - for (size_t i = 0; i < detids.size(); ++i) { - int detid = detids[i]; + for (int detid : detids) { double factor = 0.75; TableRow newrow = corrtable->appendRow(); newrow << detid << factor; diff --git a/Framework/Algorithms/test/GenerateIPythonNotebookTest.h b/Framework/Algorithms/test/GenerateIPythonNotebookTest.h index 161da6b66676e8cdb6a629117882ae84222db436..cbd4cdfeb4ba454945b84f300eaac91d6cfb499c 100644 --- a/Framework/Algorithms/test/GenerateIPythonNotebookTest.h +++ b/Framework/Algorithms/test/GenerateIPythonNotebookTest.h @@ -65,7 +65,7 @@ public: create_test_workspace(workspaceName); std::string result[] = { - "{", " \"metadata\" : {", " \"name\" : \"Mantid Notebook\"", + "{", " \"metadata\" : {", R"( "name" : "Mantid Notebook")", " },", " \"nbformat\" : 3,", " \"nbformat_minor\" : 0,", " \"worksheets\" : [", " {"}; @@ -156,7 +156,7 @@ public: history.addHistory(boost::make_shared<AlgorithmHistory>( API::AlgorithmHistory(pAlg.get()))); - pAlg.reset(NULL); + pAlg.reset(nullptr); } }; diff --git a/Framework/Algorithms/test/GeneratePythonScriptTest.h b/Framework/Algorithms/test/GeneratePythonScriptTest.h index 67ac94d0a325c0b133ba0c14d194724bd09ecf18..f88f2d1cfd42fed80f4a34f3767308c5c6f0f29d 100644 --- a/Framework/Algorithms/test/GeneratePythonScriptTest.h +++ b/Framework/Algorithms/test/GeneratePythonScriptTest.h @@ -159,7 +159,7 @@ public: history.addHistory(boost::make_shared<AlgorithmHistory>( API::AlgorithmHistory(pAlg.get()))); - pAlg.reset(NULL); + pAlg.reset(nullptr); } }; diff --git a/Framework/Algorithms/test/GroupWorkspacesTest.h b/Framework/Algorithms/test/GroupWorkspacesTest.h index 0b9fa7e31c0bb1bba51c9b562e415d4be0c32ae7..bc183339d67f933d2927f0be610fe640d5c4932d 100644 --- a/Framework/Algorithms/test/GroupWorkspacesTest.h +++ b/Framework/Algorithms/test/GroupWorkspacesTest.h @@ -196,8 +196,8 @@ public: private: void addTestMatrixWorkspacesToADS(const std::vector<std::string> &inputs) { - for (auto it = inputs.begin(); it != inputs.end(); ++it) { - addTestMatrixWorkspaceToADS(*it); + for (const auto &input : inputs) { + addTestMatrixWorkspaceToADS(input); } } @@ -258,9 +258,9 @@ private: const std::vector<std::string> &members) { auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = members.begin(); it != members.end(); ++it) { - if (ads.doesExist(*it)) - ads.remove(*it); + for (const auto &member : members) { + if (ads.doesExist(member)) + ads.remove(member); } if (ads.doesExist(groupName)) ads.remove(groupName); diff --git a/Framework/Algorithms/test/LorentzCorrectionTest.h b/Framework/Algorithms/test/LorentzCorrectionTest.h index 0190630e7c05d0fe7a15421d4a327132ad0fe7af..99cdf9c705039ad5dddcaccbdf7bc53e17d2c979 100644 --- a/Framework/Algorithms/test/LorentzCorrectionTest.h +++ b/Framework/Algorithms/test/LorentzCorrectionTest.h @@ -126,7 +126,7 @@ public: alg.setPropertyValue("OutputWorkspace", "temp"); alg.execute(); MatrixWorkspace_sptr out_ws = alg.getProperty("OutputWorkspace"); - TS_ASSERT(out_ws != NULL); + TS_ASSERT(out_ws != nullptr); const std::string unitID = out_ws->getAxis(0)->unit()->unitID(); TS_ASSERT_EQUALS(unitID, "Wavelength"); diff --git a/Framework/Algorithms/test/MaskBinsFromTableTest.h b/Framework/Algorithms/test/MaskBinsFromTableTest.h index 4bf775b5486cac562a74b0afba2b242adb15c7ee..210d8061e634876534f5172d16e54010148feb00 100644 --- a/Framework/Algorithms/test/MaskBinsFromTableTest.h +++ b/Framework/Algorithms/test/MaskBinsFromTableTest.h @@ -183,8 +183,8 @@ public: speclist.push_back(6); speclist.push_back(7); speclist.push_back(8); - for (size_t iws = 0; iws < speclist.size(); ++iws) { - auto &yvec = WS->y(speclist[iws]); + for (int spectrum : speclist) { + auto &yvec = WS->y(spectrum); for (size_t bin = 0; bin < yvec.size(); ++bin) { if (bin >= 4 && bin < 7) { TS_ASSERT_EQUALS(yvec[bin], 0.0); diff --git a/Framework/Algorithms/test/MedianDetectorTestTest.h b/Framework/Algorithms/test/MedianDetectorTestTest.h index cfccc53ddd12d811965a103858a8b10aa712c32b..81be253a63a2a3a69deb98cf98b539caa60e7436 100644 --- a/Framework/Algorithms/test/MedianDetectorTestTest.h +++ b/Framework/Algorithms/test/MedianDetectorTestTest.h @@ -180,8 +180,8 @@ public: 1, 0, 15, 4, 0, 0.001, 2e-10, 0, 8, 0, 1e-4, 1, 7, 11}; m_YSum = 0; - for (int i = 0; i < specLength - 1; i++) { - m_YSum += yArray[i]; + for (double i : yArray) { + m_YSum += i; } // most error values will be small so that they wont affect the tests diff --git a/Framework/Algorithms/test/MergeRunsTest.h b/Framework/Algorithms/test/MergeRunsTest.h index 24f962ba1f78cea7ae95093099842a213459671d..a895e35e8d63a90189ea519d0595e90f03181e12 100644 --- a/Framework/Algorithms/test/MergeRunsTest.h +++ b/Framework/Algorithms/test/MergeRunsTest.h @@ -3,25 +3,21 @@ #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> -#include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <stdarg.h> #include "MantidAPI/AnalysisDataService.h" #include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidAPI/SpectrumInfo.h" -#include "MantidAPI/WorkspaceGroup.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/WorkspaceGroup.h" #include "MantidAlgorithms/GroupWorkspaces.h" #include "MantidAlgorithms/MergeRuns.h" -#include "MantidAlgorithms/GroupWorkspaces.h" #include "MantidAlgorithms/Rebin.h" #include "MantidGeometry/Instrument.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidKernel/TimeSeriesProperty.h" #include <boost/make_shared.hpp> #include <boost/shared_ptr.hpp> -#include <boost/make_shared.hpp> #include <MantidAlgorithms/RunCombinationHelpers/RunCombinationHelper.h> #include <MantidAlgorithms/RunCombinationHelpers/SampleLogsBehaviour.h> #include "MantidTypes/SpectrumDefinition.h" @@ -281,7 +277,7 @@ private: TS_ASSERT_THROWS_NOTHING(alg.execute()); MatrixWorkspace_sptr wsOut = Mantid::API::AnalysisDataService::Instance() .retrieveWS<MatrixWorkspace>("out"); - TS_ASSERT(wsOut != NULL); + TS_ASSERT(wsOut != nullptr); for (size_t j = 0; j < wsOut->getNumberHistograms(); ++j) { using Mantid::MantidVec; auto &xValues = wsOut->x(j); @@ -305,17 +301,17 @@ public: MergeRunsTest() { AnalysisDataService::Instance().add( - "in1", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1)); + "in1", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1.)); AnalysisDataService::Instance().add( - "in2", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1)); + "in2", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1.)); AnalysisDataService::Instance().add( - "in3", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1)); + "in3", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 10, 1.)); AnalysisDataService::Instance().add( - "in4", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 5, 20)); + "in4", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 5, 20.)); AnalysisDataService::Instance().add( - "in5", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 5, 3.5, 2)); + "in5", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 5, 3.5, 2.)); AnalysisDataService::Instance().add( - "in6", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 3, 2, 2)); + "in6", WorkspaceCreationHelper::create2DWorkspaceBinned(3, 3, 2., 2.)); } void checkOutput(std::string wsname) { @@ -930,13 +926,13 @@ public: WorkspaceGroup_sptr wsgroup = Mantid::API::AnalysisDataService::Instance().retrieveWS<WorkspaceGroup>( "outer"); - TS_ASSERT(wsgroup != NULL); + TS_ASSERT(wsgroup != nullptr); TS_ASSERT_EQUALS(input->size(), wsgroup->size()); // Loop through each workspace in the group for (size_t i = 0; i < wsgroup->size(); ++i) { MatrixWorkspace_sptr ws = boost::dynamic_pointer_cast<MatrixWorkspace>(wsgroup->getItem(i)); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); TS_ASSERT_EQUALS(expectedNumHistograms, ws->getNumberHistograms()); // Loop through each histogram in each workspace for (size_t j = 0; j < ws->getNumberHistograms(); ++j) { diff --git a/Framework/Algorithms/test/NormaliseByDetectorTest.h b/Framework/Algorithms/test/NormaliseByDetectorTest.h index a66f14d5b4a18204ea4f7b7cab353e68f1725c9c..63aa2b3f5a85ddd8827a06e5a08217caeeb3dd2b 100644 --- a/Framework/Algorithms/test/NormaliseByDetectorTest.h +++ b/Framework/Algorithms/test/NormaliseByDetectorTest.h @@ -51,7 +51,7 @@ do_test_doesnt_throw_on_execution(MatrixWorkspace_sptr inputWS, TS_ASSERT_THROWS_NOTHING(alg.execute()); MatrixWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("out"); - TS_ASSERT(outWS != NULL); + TS_ASSERT(outWS != nullptr); return outWS; } @@ -225,7 +225,7 @@ private: create_workspace_with_incomplete_detector_level_only_fit_functions( MatrixWorkspace_sptr original = boost::shared_ptr<MatrixWorkspace>()) { MatrixWorkspace_sptr ws = original; - if (original == NULL) { + if (original == nullptr) { // Create a default workspace with no-fitting functions. ws = create_workspace_with_no_fitting_functions(); } @@ -649,7 +649,7 @@ public: private: /// Helper method to run common sanity checks. void do_basic_checks(MatrixWorkspace_sptr normalisedWS) { - TS_ASSERT(normalisedWS != NULL); + TS_ASSERT(normalisedWS != nullptr); TS_ASSERT(ws->getNumberHistograms() == normalisedWS->getNumberHistograms()); TS_ASSERT(ws->x(0).size() == normalisedWS->x(0).size()); TS_ASSERT(ws->y(0).size() == normalisedWS->y(0).size()); diff --git a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h index 95d3c0843918c79bfa2b9af915b4fa2bdaa977e0..4da29ea57d10eef0a8d385d97c70a43b61823984 100644 --- a/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h +++ b/Framework/Algorithms/test/PDDetermineCharacterizationsTest.h @@ -213,8 +213,8 @@ public: const std::vector<Property *> &expectedProps = expected->getProperties(); - for (std::size_t i = 0; i < expectedProps.size(); ++i) { - const std::string name = expectedProps[i]->name(); + for (auto expectedProp : expectedProps) { + const std::string name = expectedProp->name(); TS_ASSERT_EQUALS(expected->getPropertyValue(name), observed->getPropertyValue(name)); } diff --git a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h index aaf90573ec8e58296e897cc1a1eccf8ccf20ee14..481148a9648f1aa808b7bb9efa99b95745d65dd0 100644 --- a/Framework/Algorithms/test/RebinByTimeAtSampleTest.h +++ b/Framework/Algorithms/test/RebinByTimeAtSampleTest.h @@ -31,8 +31,7 @@ createSinglePulseEventWorkspace(const V3D &sourcePosition, // Make fake events for (size_t pix = 0; pix < numberspectra; pix++) { - for (size_t i = 0; i < allSpectraTOF.size(); i++) { - const double tof = allSpectraTOF[i]; + for (double tof : allSpectraTOF) { uint64_t pulseTime(0); // Pulse time is always zero. Same pulse. retVal->getSpectrum(pix) += TofEvent(tof, pulseTime); } diff --git a/Framework/Algorithms/test/RebinByTimeBaseTest.h b/Framework/Algorithms/test/RebinByTimeBaseTest.h index c9b8d5f17bede6330ef6ccd952d3aa4421dd7b19..1f3f4ab0f1fd93c9a9654f592d14e13373e83f43 100644 --- a/Framework/Algorithms/test/RebinByTimeBaseTest.h +++ b/Framework/Algorithms/test/RebinByTimeBaseTest.h @@ -526,7 +526,7 @@ public: // Simple tests. Functionality tests cover this much better. MatrixWorkspace_sptr outWS = AnalysisDataService::Instance().retrieveWS<Workspace2D>("outWS"); - TS_ASSERT(outWS != NULL); + TS_ASSERT(outWS != nullptr); } }; diff --git a/Framework/Algorithms/test/RebinTest.h b/Framework/Algorithms/test/RebinTest.h index 00ea719f4815fea3275828127e1670443f765c05..17cb8232c6161526c2efd9f1c478b468f8b66551 100644 --- a/Framework/Algorithms/test/RebinTest.h +++ b/Framework/Algorithms/test/RebinTest.h @@ -424,9 +424,8 @@ public: // turn the mask list into an array like the Y values MantidVec weights(outY.size(), 0); - for (MatrixWorkspace::MaskList::const_iterator it = mask.begin(); - it != mask.end(); ++it) { - weights[it->first] = it->second; + for (auto it : mask) { + weights[it.first] = it.second; } // the degree of masking must be the same as the reduction in the y-value, @@ -484,9 +483,8 @@ public: // turn the mask list into an array like the Y values MantidVec weights(outY.size(), 0); - for (MatrixWorkspace::MaskList::const_iterator it = mask.begin(); - it != mask.end(); ++it) { - weights[it->first] = it->second; + for (auto it : mask) { + weights[it.first] = it.second; } // the degree of masking must be the same as the reduction in the y-value, diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h index 7faa8beb0c14086329b187589b22f22070a5227f..328fd8d98ea89de92988c67e1981416f07747db4 100644 --- a/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h +++ b/Framework/Algorithms/test/ReflectometryReductionOneAuto2Test.h @@ -244,7 +244,7 @@ public: alg.setProperty("OutputWorkspace", "IvsQ"); alg.setProperty("OutputWorkspaceBinned", "IvsQ_binned"); alg.setProperty("OutputWorkspaceWavelength", "IvsLam"); - alg.setProperty("ProcessingInstructions", "3:4"); + alg.setProperty("ProcessingInstructions", "3"); alg.execute(); MatrixWorkspace_sptr out = alg.getProperty("OutputWorkspace"); @@ -270,26 +270,17 @@ public: TS_ASSERT_EQUALS(instIn->getComponentByName("linear-detector")->getPos(), instOut->getComponentByName("linear-detector")->getPos()); - // Only 'point-detector' and 'point-detector2' should have been moved - // vertically (along Y) + // Only 'point-detector' should have been moved vertically (along Y) auto point1In = instIn->getComponentByName("point-detector")->getPos(); - auto point2In = instIn->getComponentByName("point-detector2")->getPos(); auto point1Out = instOut->getComponentByName("point-detector")->getPos(); - auto point2Out = instOut->getComponentByName("point-detector2")->getPos(); TS_ASSERT_EQUALS(point1In.X(), point1Out.X()); TS_ASSERT_EQUALS(point1In.Z(), point1Out.Z()); - TS_ASSERT_EQUALS(point2In.X(), point2Out.X()); - TS_ASSERT_EQUALS(point2In.Z(), point2Out.Z()); TS_ASSERT_DIFFERS(point1In.Y(), point1Out.Y()); - TS_ASSERT_DIFFERS(point2In.Y(), point2Out.Y()); TS_ASSERT_DELTA(point1Out.Y() / (point1Out.Z() - instOut->getSample()->getPos().Z()), std::tan(theta * 2 * M_PI / 180), 1e-4); - TS_ASSERT_DELTA(point2Out.Y() / - (point2Out.Z() - instOut->getSample()->getPos().Z()), - std::tan(theta * 2 * M_PI / 180), 1e-4); } void test_correct_detector_position_rotation_POLREF() { @@ -399,7 +390,7 @@ public: alg.setProperty("OutputWorkspace", "IvsQ"); alg.setProperty("OutputWorkspaceBinned", "IvsQ_binned"); alg.setProperty("OutputWorkspaceWavelength", "IvsLam"); - alg.setProperty("ProcessingInstructions", "3:4"); + alg.setProperty("ProcessingInstructions", "3"); alg.execute(); MatrixWorkspace_sptr corrected = alg.getProperty("OutputWorkspace"); @@ -417,26 +408,18 @@ public: TS_ASSERT_EQUALS(instIn->getComponentByName("linear-detector")->getPos(), instOut->getComponentByName("linear-detector")->getPos()); - // Only 'point-detector' and 'point-detector2' should have been moved + // Only 'point-detector' should have been moved // vertically (along Y) auto point1In = instIn->getComponentByName("point-detector")->getPos(); - auto point2In = instIn->getComponentByName("point-detector2")->getPos(); auto point1Out = instOut->getComponentByName("point-detector")->getPos(); - auto point2Out = instOut->getComponentByName("point-detector2")->getPos(); TS_ASSERT_EQUALS(point1In.X(), point1Out.X()); TS_ASSERT_EQUALS(point1In.Z(), point1Out.Z()); - TS_ASSERT_EQUALS(point2In.X(), point2Out.X()); - TS_ASSERT_EQUALS(point2In.Z(), point2Out.Z()); TS_ASSERT_DIFFERS(point1In.Y(), point1Out.Y()); - TS_ASSERT_DIFFERS(point2In.Y(), point2Out.Y()); TS_ASSERT_DELTA(point1Out.Y() / (point1Out.Z() - instOut->getSample()->getPos().Z()), std::tan(theta * 2 * M_PI / 180), 1e-4); - TS_ASSERT_DELTA(point2Out.Y() / - (point2Out.Z() - instOut->getSample()->getPos().Z()), - std::tan(theta * 2 * M_PI / 180), 1e-4); } void test_override_ThetaIn_without_correcting_detectors() { @@ -452,7 +435,7 @@ public: alg.setProperty("OutputWorkspace", "IvsQ"); alg.setProperty("OutputWorkspaceBinned", "IvsQ_binned"); alg.setProperty("OutputWorkspaceWavelength", "IvsLam"); - alg.setProperty("ProcessingInstructions", "3:4"); + alg.setProperty("ProcessingInstructions", "3"); alg.execute(); MatrixWorkspace_sptr corrected = alg.getProperty("OutputWorkspace"); @@ -463,12 +446,9 @@ public: // the detectors should not have been moved auto point1In = instIn->getComponentByName("point-detector")->getPos(); - auto point2In = instIn->getComponentByName("point-detector2")->getPos(); auto point1Out = instOut->getComponentByName("point-detector")->getPos(); - auto point2Out = instOut->getComponentByName("point-detector2")->getPos(); TS_ASSERT_EQUALS(point1In, point1Out); - TS_ASSERT_EQUALS(point2In, point2Out); } void test_sum_transmission_workspaces() { diff --git a/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h b/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h deleted file mode 100644 index 4a452f1ee0f0a5e51badcca4bbe05ddb422701a9..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/test/ReflectometryReductionOneAutoTest.h +++ /dev/null @@ -1,798 +0,0 @@ -#ifndef MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTOTEST_H_ -#define MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTOTEST_H_ - -#include <cxxtest/TestSuite.h> - -#include "MantidAPI/AlgorithmManager.h" -#include "MantidAPI/Axis.h" -#include "MantidAPI/FrameworkManager.h" -#include "MantidAPI/WorkspaceGroup.h" -#include "MantidAPI/WorkspaceHistory.h" -#include "MantidAlgorithms/ReflectometryReductionOneAuto.h" -#include "MantidGeometry/Instrument.h" -#include "MantidGeometry/Instrument/ReferenceFrame.h" -#include "MantidKernel/Unit.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" - -using Mantid::Algorithms::ReflectometryReductionOneAuto; -using namespace Mantid::API; -using namespace Mantid::DataObjects; -using namespace Mantid::Geometry; -using namespace Mantid::Kernel; -using Mantid::MantidVec; -using Mantid::MantidVecPtr; -using Mantid::HistogramData::BinEdges; - -namespace { -class PropertyFinder { -private: - const std::string m_propertyName; - -public: - PropertyFinder(const std::string &propertyName) - : m_propertyName(propertyName) {} - bool operator()(const PropertyHistories::value_type &candidate) const { - return candidate->name() == m_propertyName; - } -}; - -template <typename T> -T findPropertyValue(PropertyHistories &histories, - const std::string &propertyName) { - PropertyFinder finder(propertyName); - auto it = std::find_if(histories.begin(), histories.end(), finder); - return boost::lexical_cast<T>((*it)->value()); -} -} - -class ReflectometryReductionOneAutoTest : public CxxTest::TestSuite { -public: - // This pair of boilerplate methods prevent the suite being created statically - // This means the constructor isn't called when running other tests - static ReflectometryReductionOneAutoTest *createSuite() { - return new ReflectometryReductionOneAutoTest(); - } - static void destroySuite(ReflectometryReductionOneAutoTest *suite) { - delete suite; - } - - MatrixWorkspace_sptr m_TOF; - MatrixWorkspace_sptr m_NotTOF; - MatrixWorkspace_sptr m_dataWorkspace; - MatrixWorkspace_sptr m_transWorkspace1; - MatrixWorkspace_sptr m_transWorkspace2; - WorkspaceGroup_sptr m_multiDetectorWorkspace; - const std::string outWSQName; - const std::string outWSLamName; - const std::string inWSName; - const std::string transWSName; - - ReflectometryReductionOneAutoTest() - : outWSQName("ReflectometryReductionOneAutoTest_OutputWS_Q"), - outWSLamName("ReflectometryReductionOneAutoTest_OutputWS_Lam"), - inWSName("ReflectometryReductionOneAutoTest_InputWS"), - transWSName("ReflectometryReductionOneAutoTest_TransWS") { - MantidVec xData = {0, 0, 0, 0}; - MantidVec yData = {0, 0, 0}; - - auto createWorkspace = - AlgorithmManager::Instance().create("CreateWorkspace"); - createWorkspace->initialize(); - createWorkspace->setProperty("UnitX", "1/q"); - createWorkspace->setProperty("DataX", xData); - createWorkspace->setProperty("DataY", yData); - createWorkspace->setProperty("NSpec", 1); - createWorkspace->setPropertyValue("OutputWorkspace", "NotTOF"); - createWorkspace->execute(); - m_NotTOF = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("NotTOF"); - - createWorkspace->setProperty("UnitX", "TOF"); - createWorkspace->setProperty("DataX", xData); - createWorkspace->setProperty("DataY", yData); - createWorkspace->setProperty("NSpec", 1); - createWorkspace->setPropertyValue("OutputWorkspace", "TOF"); - createWorkspace->execute(); - m_TOF = AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("TOF"); - - IAlgorithm_sptr lAlg = AlgorithmManager::Instance().create("Load"); - lAlg->setChild(true); - lAlg->initialize(); - lAlg->setProperty("Filename", "INTER00013460.nxs"); - lAlg->setPropertyValue("OutputWorkspace", "demo_ws"); - lAlg->execute(); - Workspace_sptr temp = lAlg->getProperty("OutputWorkspace"); - m_dataWorkspace = boost::dynamic_pointer_cast<MatrixWorkspace>(temp); - // m_dataWorkspace = - // AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("data_ws"); - - lAlg->setProperty("Filename", "INTER00013463.nxs"); - lAlg->setPropertyValue("OutputWorkspace", "trans_ws_1"); - lAlg->execute(); - temp = lAlg->getProperty("OutputWorkspace"); - m_transWorkspace1 = boost::dynamic_pointer_cast<MatrixWorkspace>(temp); - // m_transWorkspace1 = - // AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("trans_ws_1"); - - lAlg->setProperty("Filename", "INTER00013464.nxs"); - lAlg->setPropertyValue("OutputWorkspace", "trans_ws_2"); - lAlg->execute(); - temp = lAlg->getProperty("OutputWorkspace"); - m_transWorkspace2 = boost::dynamic_pointer_cast<MatrixWorkspace>(temp); - // m_transWorkspace2 = - // AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("trans_ws_2"); - - lAlg->setPropertyValue("Filename", "POLREF00004699.nxs"); - lAlg->setPropertyValue("OutputWorkspace", "multidetector_ws_1"); - lAlg->execute(); - temp = lAlg->getProperty("OutputWorkspace"); - m_multiDetectorWorkspace = - boost::dynamic_pointer_cast<WorkspaceGroup>(temp); - AnalysisDataService::Instance().addOrReplace("multidetector_group", - m_multiDetectorWorkspace); - } - ~ReflectometryReductionOneAutoTest() override { - AnalysisDataService::Instance().remove("TOF"); - AnalysisDataService::Instance().remove("NotTOF"); - AnalysisDataService::Instance().remove("multidetector_group"); - AnalysisDataService::Instance().remove("multidetector_group_1"); - AnalysisDataService::Instance().remove("multidetector_group_2"); - } - - IAlgorithm_sptr construct_standard_algorithm() { - auto alg = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - alg->initialize(); - alg->setProperty("InputWorkspace", m_TOF); - alg->setProperty("WavelengthMin", 0.0); - alg->setProperty("WavelengthMax", 1.0); - alg->setProperty("I0MonitorIndex", 0); - alg->setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg->setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg->setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg->setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg->setProperty("MomentumTransferStep", 0.1); - alg->setPropertyValue("ProcessingInstructions", "0"); - alg->setPropertyValue("OutputWorkspace", outWSQName); - alg->setPropertyValue("OutputWorkspaceWavelength", outWSLamName); - alg->setRethrows(true); - return alg; - } - - void test_Init() { - ReflectometryReductionOneAuto alg; - TS_ASSERT_THROWS_NOTHING(alg.initialize()); - TS_ASSERT(alg.isInitialized()); - } - - void test_check_input_workpace_not_tof_or_wavelength_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("InputWorkspace", m_NotTOF); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_check_first_transmission_workspace_not_tof_or_wavelength_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("FirstTransmissionRun", m_NotTOF); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_check_second_transmission_workspace_not_tof_throws() { - auto alg = construct_standard_algorithm(); - TS_ASSERT_THROWS(alg->setProperty("SecondTransmissionRun", m_NotTOF), - std::invalid_argument); - } - - void test_proivde_second_transmission_run_without_first_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("SecondTransmissionRun", m_TOF); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_end_overlap_must_be_greater_than_start_overlap_or_throw() { - auto alg = construct_standard_algorithm(); - alg->setProperty("FirstTransmissionRun", m_TOF); - alg->setProperty("SecondTransmissionRun", m_TOF); - MantidVec params = {0.0, 0.1, 1.0}; - alg->setProperty("Params", params); - alg->setProperty("StartOverlap", 0.6); - alg->setProperty("EndOverlap", 0.4); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_must_provide_wavelengths() { - auto algWithMax = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - algWithMax->initialize(); - algWithMax->setProperty("InputWorkspace", m_TOF); - algWithMax->setProperty("FirstTransmissionRun", m_TOF); - algWithMax->setProperty("SecondTransmissionRun", m_TOF); - algWithMax->setProperty("ProcessingInstructions", "3:4"); - algWithMax->setProperty("MomentumTransferStep", 0.1); - algWithMax->setProperty("WavelengthMax", 1.0); - algWithMax->setPropertyValue("OutputWorkspace", "out_ws_Q"); - algWithMax->setPropertyValue("OutputWorkspaceWavelength", "out_ws_Lam"); - algWithMax->setRethrows(true); - TS_ASSERT_THROWS(algWithMax->execute(), std::runtime_error); - - auto algWithMin = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - algWithMin->initialize(); - algWithMin->setProperty("InputWorkspace", m_TOF); - algWithMin->setProperty("FirstTransmissionRun", m_TOF); - algWithMin->setProperty("SecondTransmissionRun", m_TOF); - algWithMin->setProperty("ProcessingInstructions", "3:4"); - algWithMin->setProperty("MomentumTransferStep", 0.1); - algWithMin->setProperty("WavelengthMin", 1.0); - algWithMin->setPropertyValue("OutputWorkspace", "out_ws_Q"); - algWithMin->setPropertyValue("OutputWorkspaceWavelength", "out_ws_Lam"); - algWithMin->setRethrows(true); - TS_ASSERT_THROWS(algWithMin->execute(), std::runtime_error); - } - - void test_wavelength_min_greater_wavelength_max_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("WavelengthMin", 1.0); - alg->setProperty("WavelengthMax", 0.0); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void - test_monitor_background_wavelength_min_greater_monitor_background_wavelength_max_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("MonitorBackgroundWavelengthMin", 1.0); - alg->setProperty("MonitorBackgroundWavelengthMax", 0.0); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void - test_monitor_integration_wavelength_min_greater_monitor_integration_wavelength_max_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("MonitorIntegrationWavelengthMin", 1.0); - alg->setProperty("MonitorIntegrationWavelengthMax", 0.0); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_monitor_index_positive() { - auto alg = construct_standard_algorithm(); - auto tempInst = m_TOF->getInstrument(); - m_TOF->setInstrument(m_dataWorkspace->getInstrument()); - alg->setProperty("InputWorkspace", m_TOF); - TS_ASSERT_THROWS(alg->execute(), std::runtime_error); - m_TOF->setInstrument(tempInst); - } - void - test_cannot_set_direct_beam_region_of_interest_without_multidetector_run() { - auto alg = construct_standard_algorithm(); - alg->setProperty("AnalysisMode", "PointDetectorAnalysis"); - std::vector<int> RegionOfDirectBeam = {1, 2}; - alg->setProperty("RegionOfDirectBeam", RegionOfDirectBeam); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_region_of_direct_beam_indexes_cannot_be_negative_or_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("AnalysisMode", "MultiDetectorAnalysis"); - std::vector<int> RegionOfDirectBeam = {0, -1}; - alg->setProperty("RegionOfDirectBeam", RegionOfDirectBeam); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void - test_region_of_direct_beam_indexes_must_be_provided_as_min_max_order_or_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("AnalysisMode", "MultiDetectorAnalysis"); - std::vector<int> RegionOfDirectBeam = {1, 0}; - alg->setProperty("RegionOfDirectBeam", RegionOfDirectBeam); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - - void test_bad_detector_component_name_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("DetectorComponentName", "made-up"); - TS_ASSERT_THROWS(alg->execute(), std::runtime_error); - } - - void test_bad_sample_component_name_throws() { - auto alg = construct_standard_algorithm(); - alg->setProperty("SampleComponentName", "made-up"); - TS_ASSERT_THROWS(alg->execute(), std::runtime_error); - } - void test_exec() { - IAlgorithm_sptr alg = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - alg->setRethrows(true); - TS_ASSERT_THROWS_NOTHING(alg->initialize()); - TS_ASSERT_THROWS_NOTHING( - alg->setProperty("InputWorkspace", m_dataWorkspace)); - TS_ASSERT_THROWS_NOTHING( - alg->setProperty("AnalysisMode", "PointDetectorAnalysis")); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspace", outWSQName)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspaceWavelength", outWSLamName)); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("MomentumTransferStep", 0.1)); - alg->execute(); - TS_ASSERT(alg->isExecuted()); - - MatrixWorkspace_sptr outWS = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(outWSQName); - - auto inst = m_dataWorkspace->getInstrument(); - auto workspaceHistory = outWS->getHistory(); - AlgorithmHistory_const_sptr workerAlgHistory = - workspaceHistory.getAlgorithmHistory(0)->getChildAlgorithmHistory(0); - auto vecPropertyHistories = workerAlgHistory->getProperties(); - - const double wavelengthMin = - findPropertyValue<double>(vecPropertyHistories, "WavelengthMin"); - const double wavelengthMax = - findPropertyValue<double>(vecPropertyHistories, "WavelengthMax"); - const double monitorBackgroundWavelengthMin = findPropertyValue<double>( - vecPropertyHistories, "MonitorBackgroundWavelengthMin"); - const double monitorBackgroundWavelengthMax = findPropertyValue<double>( - vecPropertyHistories, "MonitorBackgroundWavelengthMax"); - const double monitorIntegrationWavelengthMin = findPropertyValue<double>( - vecPropertyHistories, "MonitorIntegrationWavelengthMin"); - const double monitorIntegrationWavelengthMax = findPropertyValue<double>( - vecPropertyHistories, "MonitorIntegrationWavelengthMax"); - const int i0MonitorIndex = - findPropertyValue<int>(vecPropertyHistories, "I0MonitorIndex"); - std::string processingInstructions = findPropertyValue<std::string>( - vecPropertyHistories, "ProcessingInstructions"); - std::vector<std::string> pointDetectorStartStop; - boost::split(pointDetectorStartStop, processingInstructions, - boost::is_any_of(":")); - - TS_ASSERT_EQUALS(inst->getNumberParameter("LambdaMin")[0], wavelengthMin); - TS_ASSERT_EQUALS(inst->getNumberParameter("LambdaMax")[0], wavelengthMax); - TS_ASSERT_EQUALS(inst->getNumberParameter("MonitorBackgroundMin")[0], - monitorBackgroundWavelengthMin); - TS_ASSERT_EQUALS(inst->getNumberParameter("MonitorBackgroundMax")[0], - monitorBackgroundWavelengthMax); - TS_ASSERT_EQUALS(inst->getNumberParameter("MonitorIntegralMin")[0], - monitorIntegrationWavelengthMin); - TS_ASSERT_EQUALS(inst->getNumberParameter("MonitorIntegralMax")[0], - monitorIntegrationWavelengthMax); - TS_ASSERT_EQUALS(inst->getNumberParameter("I0MonitorIndex")[0], - i0MonitorIndex); - TS_ASSERT_EQUALS(inst->getNumberParameter("PointDetectorStart")[0], - boost::lexical_cast<double>(pointDetectorStartStop[0])); - TS_ASSERT_EQUALS(pointDetectorStartStop.size(), 1); - - // Remove workspace from the data service. - AnalysisDataService::Instance().remove(outWSQName); - AnalysisDataService::Instance().remove(outWSLamName); - } - - void test_missing_instrument_parameters_throws() { - auto tinyWS = - WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrument(); - auto inst = tinyWS->getInstrument(); - - inst->getParameterMap()->addDouble(inst.get(), "I0MonitorIndex", 1.0); - - tinyWS->mutableRun().addLogData( - new PropertyWithValue<double>("Theta", 0.12345)); - tinyWS->mutableRun().addLogData( - new PropertyWithValue<std::string>("run_number", "12345")); - - IAlgorithm_sptr alg = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - alg->setRethrows(true); - TS_ASSERT_THROWS_NOTHING(alg->initialize()); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("InputWorkspace", tinyWS)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspace", outWSQName)); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("MomentumTransferStep", 0.1)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspaceWavelength", outWSLamName)); - TS_ASSERT_THROWS_ANYTHING(alg->execute()); - - // Remove workspace from the data service. - AnalysisDataService::Instance().remove(outWSQName); - AnalysisDataService::Instance().remove(outWSLamName); - } - - void test_normalize_by_detmon() { - // Prepare workspace - //----------------- - // Single bin from 1->2 - BinEdges x{1, 2}; - - // 2 spectra, 2 x values, 1 y value per spectra - auto tinyWS = createWorkspace<Workspace2D>(2, 2, 1); - tinyWS->setBinEdges(0, x); - tinyWS->setBinEdges(1, x); - tinyWS->setCounts(0, 1, 10.0); - tinyWS->setCountStandardDeviations(0, 1, 0.0); - tinyWS->setCounts(1, 1, 5.0); - tinyWS->setCountStandardDeviations(1, 1, 0.0); - - tinyWS->setTitle("Test histogram"); - tinyWS->getAxis(0)->setUnit("Wavelength"); - tinyWS->setYUnit("Counts"); - - // Prepare instrument - //------------------ - Instrument_sptr instrument = boost::make_shared<Instrument>(); - instrument->setReferenceFrame( - boost::make_shared<ReferenceFrame>(Y, X, Left, "0,0,0")); - - ObjComponent *source = new ObjComponent("source"); - source->setPos(V3D(0, 0, 0)); - instrument->add(source); - instrument->markAsSource(source); - - ObjComponent *sample = new ObjComponent("some-surface-holder"); - source->setPos(V3D(15, 0, 0)); - instrument->add(sample); - instrument->markAsSamplePos(sample); - - Detector *det = new Detector("point-detector", 1, nullptr); - det->setPos(20, (20 - sample->getPos().X()), 0); - instrument->add(det); - instrument->markAsDetector(det); - - Detector *monitor = new Detector("Monitor", 2, nullptr); - monitor->setPos(14, 0, 0); - instrument->add(monitor); - instrument->markAsMonitor(monitor); - - // Add instrument to workspace - tinyWS->setInstrument(instrument); - tinyWS->getSpectrum(0).addDetectorID(det->getID()); - tinyWS->getSpectrum(1).addDetectorID(monitor->getID()); - - // Now we can parameterize the instrument - auto tinyInst = tinyWS->getInstrument(); - ParameterMap_sptr params = tinyInst->getParameterMap(); - params->addDouble(tinyInst.get(), "PointDetectorStart", 0.0); - params->addDouble(tinyInst.get(), "PointDetectorStop", 0.0); - params->addDouble(tinyInst.get(), "I0MonitorIndex", 1.0); - params->addDouble(tinyInst.get(), "LambdaMin", 0.0); - params->addDouble(tinyInst.get(), "LambdaMax", 10.0); - params->addDouble(tinyInst.get(), "MonitorBackgroundMin", 0.0); - params->addDouble(tinyInst.get(), "MonitorBackgroundMax", 0.0); - params->addDouble(tinyInst.get(), "MonitorIntegralMin", 0.0); - params->addDouble(tinyInst.get(), "MonitorIntegralMax", 10.0); - - tinyWS->mutableRun().addLogData( - new PropertyWithValue<double>("Theta", 0.1)); - - // Run the required algorithms - //--------------------------- - - // Convert units - IAlgorithm_sptr conv = AlgorithmManager::Instance().create("ConvertUnits"); - conv->initialize(); - conv->setProperty("InputWorkspace", tinyWS); - conv->setProperty("OutputWorkspace", inWSName); - conv->setProperty("Target", "TOF"); - conv->execute(); - TS_ASSERT(conv->isExecuted()); - - // Reduce - IAlgorithm_sptr alg = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - alg->setRethrows(true); - TS_ASSERT_THROWS_NOTHING(alg->initialize()); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("InputWorkspace", inWSName)); - TS_ASSERT_THROWS_NOTHING( - alg->setProperty("NormalizeByIntegratedMonitors", false)); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("MomentumTransferStep", 0.1)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspace", outWSQName)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspaceWavelength", outWSLamName)); - alg->execute(); - TS_ASSERT(alg->isExecuted()); - - // Get results - MatrixWorkspace_sptr outWSLam = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( - outWSLamName); - - // Check results (10 / 5 = 2) - TS_ASSERT_DELTA(outWSLam->readY(0)[0], 2, 1e-5); - TS_ASSERT_DELTA(outWSLam->readX(0)[0], 1, 1e-5); - TS_ASSERT_DELTA(outWSLam->readX(0)[1], 2, 1e-5); - - // Remove workspace from the data service. - AnalysisDataService::Instance().remove(inWSName); - AnalysisDataService::Instance().remove(outWSQName); - AnalysisDataService::Instance().remove(outWSLamName); - } - - void test_i0_monitor_index_not_required() { - // Prepare instrument - //------------------ - // hold the current instrument assigned to m_dataWorkspace - auto m_dataWorkspaceInstHolder = m_dataWorkspace->getInstrument(); - Instrument_sptr instrument = boost::make_shared<Instrument>(); - instrument->setReferenceFrame( - boost::make_shared<ReferenceFrame>(Y, X, Left, "0,0,0")); - - ObjComponent *source = new ObjComponent("source"); - source->setPos(V3D(0, 0, 0)); - instrument->add(source); - instrument->markAsSource(source); - - ObjComponent *sample = new ObjComponent("some-surface-holder"); - source->setPos(V3D(15, 0, 0)); - instrument->add(sample); - instrument->markAsSamplePos(sample); - - Detector *det = new Detector("point-detector", 1, nullptr); - det->setPos(20, (20 - sample->getPos().X()), 0); - instrument->add(det); - instrument->markAsDetector(det); - - Detector *monitor = new Detector("Monitor", 2, nullptr); - monitor->setPos(14, 0, 0); - instrument->add(monitor); - instrument->markAsMonitor(monitor); - - // Add new instrument to workspace - m_dataWorkspace->setInstrument(instrument); - - // Now we can parameterize the instrument - // without setting the I0MonitorIndex - auto tinyInst = m_dataWorkspace->getInstrument(); - ParameterMap_sptr params = tinyInst->getParameterMap(); - params->addDouble(tinyInst.get(), "PointDetectorStart", 0.0); - params->addDouble(tinyInst.get(), "PointDetectorStop", 0.0); - params->addDouble(tinyInst.get(), "LambdaMin", 0.0); - params->addDouble(tinyInst.get(), "LambdaMax", 10.0); - params->addDouble(tinyInst.get(), "MonitorBackgroundMin", 0.0); - params->addDouble(tinyInst.get(), "MonitorBackgroundMax", 0.0); - params->addDouble(tinyInst.get(), "MonitorIntegralMin", 0.0); - params->addDouble(tinyInst.get(), "MonitorIntegralMax", 10.0); - - // Reduce - IAlgorithm_sptr alg = - AlgorithmManager::Instance().create("ReflectometryReductionOneAuto", 1); - alg->setRethrows(true); - alg->setChild(true); - TS_ASSERT_THROWS_NOTHING(alg->initialize()); - TS_ASSERT_THROWS_NOTHING( - alg->setProperty("InputWorkspace", m_dataWorkspace)); - TS_ASSERT_THROWS_NOTHING( - alg->setProperty("I0MonitorIndex", Mantid::EMPTY_INT())); - TS_ASSERT_THROWS_NOTHING(alg->setProperty("MomentumTransferStep", 0.1)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspace", outWSQName)); - TS_ASSERT_THROWS_NOTHING( - alg->setPropertyValue("OutputWorkspaceWavelength", outWSLamName)); - // we have intentionally not set - TS_ASSERT_THROWS_NOTHING(alg->execute()); - - // Remove workspace from the data service. - AnalysisDataService::Instance().remove(inWSName); - AnalysisDataService::Instance().remove(outWSQName); - AnalysisDataService::Instance().remove(outWSLamName); - - // reset the instrument associated with m_dataWorkspace - m_dataWorkspace->setInstrument(m_dataWorkspaceInstHolder); - } - void test_point_detector_run_with_single_transmission_workspace() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(true); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "3,4"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setProperty("InputWorkspace", m_dataWorkspace); - alg.setProperty("FirstTransmissionRun", m_transWorkspace1); - alg.setProperty("ThetaIn", 0.2); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - - TS_ASSERT_THROWS_NOTHING(alg.execute()); - - double thetaOut = alg.getProperty("ThetaOut"); - TSM_ASSERT_EQUALS("Theta in and out should be the same", thetaOut, 0.2); - - MatrixWorkspace_sptr IvsLam = alg.getProperty("OutputWorkspaceWavelength"); - TSM_ASSERT("OutputWorkspaceWavelength should be a valid matrix workspace", - IvsLam); - - MatrixWorkspace_sptr IvsQ = alg.getProperty("OutputWorkspace"); - TSM_ASSERT("OutputWorkspace should be a valid matrix workspace", IvsQ); - - TSM_ASSERT_EQUALS("OutputWorkspaceWavelength should have two histograms", - IvsLam->getNumberHistograms(), 2); - } - - void test_point_detector_run_with_two_transmission_workspaces() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(true); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "3, 4"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setProperty("InputWorkspace", m_dataWorkspace); - alg.setProperty("FirstTransmissionRun", m_transWorkspace1); - alg.setProperty("SecondTransmissionRun", m_transWorkspace2); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - - TS_ASSERT_THROWS_NOTHING(alg.execute()); - } - - void test_spectrum_map_mismatch_throws_when_strict() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(true); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "3"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - - alg.setProperty("InputWorkspace", m_dataWorkspace); - alg.execute(); - - MatrixWorkspace_sptr trans = alg.getProperty("OutputWorkspaceWavelength"); - alg.setProperty("FirstTransmissionRun", trans); - alg.setProperty("ProcessingInstructions", "4"); - TS_ASSERT_THROWS_ANYTHING(alg.execute()); - } - - void test_spectrum_map_mismatch_doesnt_throw_when_not_strict() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(true); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "3"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - - alg.setProperty("InputWorkspace", m_dataWorkspace); - alg.execute(); - - MatrixWorkspace_sptr trans = alg.getProperty("OutputWorkspaceWavelength"); - alg.setProperty("FirstTransmissionRun", trans); - alg.setProperty("ProcessingInstructions", "4"); - alg.setProperty("StrictSpectrumChecking", "0"); - TS_ASSERT_THROWS_NOTHING(alg.execute()); - } - - void test_multidetector_run() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(false); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "10"); - alg.setProperty("AnalysisMode", "MultiDetectorAnalysis"); - alg.setProperty("CorrectDetectorPositions", "0"); - alg.setProperty("DetectorComponentName", "lineardetector"); - alg.setProperty("RegionOfDirectBeam", "20, 30"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setProperty("ThetaIn", 0.1); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - alg.setPropertyValue("InputWorkspace", "multidetector_group"); - - TS_ASSERT_THROWS_NOTHING(alg.execute()); - - MatrixWorkspace_sptr IvsLam_1 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsLam_1"); - TSM_ASSERT("OutputWorkspaceWavelength should be a matrix workspace", - IvsLam_1); - TS_ASSERT_EQUALS("Wavelength", IvsLam_1->getAxis(0)->unit()->unitID()); - MatrixWorkspace_sptr IvsLam_2 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsLam_2"); - TSM_ASSERT("OutputWorkspaceWavelength should be a matrix workspace", - IvsLam_2); - TS_ASSERT_EQUALS("Wavelength", IvsLam_2->getAxis(0)->unit()->unitID()); - - MatrixWorkspace_sptr IvsQ_1 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsQ_1"); - TSM_ASSERT("OutputWorkspace should be a matrix workspace", IvsQ_1); - TS_ASSERT_EQUALS("MomentumTransfer", IvsQ_1->getAxis(0)->unit()->unitID()); - MatrixWorkspace_sptr IvsQ_2 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsQ_2"); - TSM_ASSERT("OutputWorkspace should be a matrix workspace", IvsQ_2); - TS_ASSERT_EQUALS("MomentumTransfer", IvsQ_2->getAxis(0)->unit()->unitID()); - - MatrixWorkspace_sptr tempWS = boost::dynamic_pointer_cast<MatrixWorkspace>( - m_multiDetectorWorkspace->getItem(0)); - auto instrBefore = tempWS->getInstrument(); - auto detectorBefore = instrBefore->getComponentByName("lineardetector"); - auto instrAfter = IvsLam_1->getInstrument(); - auto detectorAfter = instrAfter->getComponentByName("lineardetector"); - TS_ASSERT_DELTA(detectorBefore->getPos().Z(), detectorAfter->getPos().Z(), - 0.0001) - - AnalysisDataService::Instance().remove("IvsLam"); - AnalysisDataService::Instance().remove("IvsLam_1"); - AnalysisDataService::Instance().remove("IvsLam_2"); - AnalysisDataService::Instance().remove("IvsQ"); - AnalysisDataService::Instance().remove("IvsQ_1"); - AnalysisDataService::Instance().remove("IvsQ_2"); - } - - void test_multidetector_run_correct_positions() { - ReflectometryReductionOneAuto alg; - alg.initialize(); - alg.setChild(false); - alg.setProperty("WavelengthMin", 1.0); - alg.setProperty("WavelengthMax", 2.0); - alg.setProperty("I0MonitorIndex", 0); - alg.setProperty("ProcessingInstructions", "73"); - alg.setProperty("AnalysisMode", "MultiDetectorAnalysis"); - alg.setProperty("CorrectDetectorPositions", "1"); - alg.setProperty("DetectorComponentName", "lineardetector"); - alg.setProperty("RegionOfDirectBeam", "28, 29"); - alg.setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg.setProperty("MonitorBackgroundWavelengthMax", 1.0); - alg.setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg.setProperty("MonitorIntegrationWavelengthMax", 1.0); - alg.setProperty("ThetaIn", 0.49); - alg.setPropertyValue("OutputWorkspace", "IvsQ"); - alg.setPropertyValue("OutputWorkspaceWavelength", "IvsLam"); - alg.setPropertyValue("InputWorkspace", "multidetector_group"); - - TS_ASSERT_THROWS_NOTHING(alg.execute()); - - MatrixWorkspace_sptr IvsLam_1 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsLam_1"); - TSM_ASSERT("OutputWorkspaceWavelength should be a matrix workspace", - IvsLam_1); - TS_ASSERT_EQUALS("Wavelength", IvsLam_1->getAxis(0)->unit()->unitID()); - MatrixWorkspace_sptr IvsLam_2 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsLam_2"); - TSM_ASSERT("OutputWorkspaceWavelength should be a matrix workspace", - IvsLam_2); - TS_ASSERT_EQUALS("Wavelength", IvsLam_2->getAxis(0)->unit()->unitID()); - - MatrixWorkspace_sptr IvsQ_1 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsQ_1"); - TSM_ASSERT("OutputWorkspace should be a matrix workspace", IvsQ_1); - TS_ASSERT_EQUALS("MomentumTransfer", IvsQ_1->getAxis(0)->unit()->unitID()); - MatrixWorkspace_sptr IvsQ_2 = - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>("IvsQ_2"); - TSM_ASSERT("OutputWorkspace should be a matrix workspace", IvsQ_2); - TS_ASSERT_EQUALS("MomentumTransfer", IvsQ_2->getAxis(0)->unit()->unitID()); - - auto instr = IvsLam_1->getInstrument(); - auto detectorPos = instr->getComponentByName("lineardetector"); - TS_ASSERT_DELTA(-0.05714, detectorPos->getPos().Z(), 0.0001) - - AnalysisDataService::Instance().remove("IvsLam"); - AnalysisDataService::Instance().remove("IvsLam_1"); - AnalysisDataService::Instance().remove("IvsLam_2"); - AnalysisDataService::Instance().remove("IvsQ"); - AnalysisDataService::Instance().remove("IvsQ_1"); - AnalysisDataService::Instance().remove("IvsQ_2"); - } -}; - -#endif /* MANTID_ALGORITHMS_REFLECTOMETRYREDUCTIONONEAUTOTEST_H_ */ diff --git a/Framework/Algorithms/test/ReflectometryReductionOneTest.h b/Framework/Algorithms/test/ReflectometryReductionOneTest.h deleted file mode 100644 index a8072ac9bd1df85b01ffa14a0eee9bb67922cccd..0000000000000000000000000000000000000000 --- a/Framework/Algorithms/test/ReflectometryReductionOneTest.h +++ /dev/null @@ -1,395 +0,0 @@ -#ifndef ALGORITHMS_TEST_REFLECTOMETRYREDUCTIONONETEST_H_ -#define ALGORITHMS_TEST_REFLECTOMETRYREDUCTIONONETEST_H_ - -#include <cxxtest/TestSuite.h> -#include <algorithm> -#include "MantidAlgorithms/ReflectometryReductionOne.h" -#include "MantidAPI/AlgorithmManager.h" -#include "MantidAPI/Axis.h" -#include "MantidAPI/FrameworkManager.h" -#include "MantidAPI/MatrixWorkspace.h" -#include "MantidTestHelpers/WorkspaceCreationHelper.h" -#include "MantidGeometry/Instrument/ReferenceFrame.h" -#include "MantidGeometry/Instrument.h" -#include "MantidKernel/Unit.h" - -using namespace Mantid; -using namespace Mantid::Kernel; -using namespace Mantid::API; -using namespace Mantid::Algorithms; -using namespace Mantid::Geometry; -using namespace WorkspaceCreationHelper; - -class ReflectometryReductionOneTest : public CxxTest::TestSuite { -private: - MatrixWorkspace_sptr m_tinyReflWS; - -public: - // This pair of boilerplate methods prevent the suite being created statically - // This means the constructor isn't called when running other tests - static ReflectometryReductionOneTest *createSuite() { - return new ReflectometryReductionOneTest(); - } - static void destroySuite(ReflectometryReductionOneTest *suite) { - delete suite; - } - - ReflectometryReductionOneTest() { - FrameworkManager::Instance(); - m_tinyReflWS = create2DWorkspaceWithReflectometryInstrument(); - } - - void test_tolam() { - MatrixWorkspace_sptr toConvert = m_tinyReflWS; - std::vector<int> detectorIndexRange; - size_t workspaceIndexToKeep1 = 1; - const int monitorIndex = 0; - - specnum_t specId1 = - toConvert->getSpectrum(workspaceIndexToKeep1).getSpectrumNo(); - specnum_t monitorSpecId = - toConvert->getSpectrum(monitorIndex).getSpectrumNo(); - - // Define one spectra to keep - detectorIndexRange.push_back(static_cast<int>(workspaceIndexToKeep1)); - std::stringstream buffer; - buffer << workspaceIndexToKeep1; - const std::string detectorIndexRangesStr = buffer.str(); - - // Define a wavelength range for the detector workspace - const double wavelengthMin = 1.0; - const double wavelengthMax = 15; - const double backgroundWavelengthMin = 17; - const double backgroundWavelengthMax = 20; - - ReflectometryReductionOne alg; - - // Run the conversion. - ReflectometryWorkflowBase::DetectorMonitorWorkspacePair inLam = - alg.toLam(toConvert, detectorIndexRangesStr, monitorIndex, - boost::tuple<double, double>(wavelengthMin, wavelengthMax), - boost::tuple<double, double>(backgroundWavelengthMin, - backgroundWavelengthMax)); - - // Unpack the results - MatrixWorkspace_sptr detectorWS = inLam.get<0>(); - MatrixWorkspace_sptr monitorWS = inLam.get<1>(); - - /* ---------- Checks for the detector workspace ------------------*/ - - // Check units. - TS_ASSERT_EQUALS("Wavelength", detectorWS->getAxis(0)->unit()->unitID()); - - // Check the number of spectrum kept. - TS_ASSERT_EQUALS(1, detectorWS->getNumberHistograms()); - - auto map = detectorWS->getSpectrumToWorkspaceIndexMap(); - // Check the spectrum Nos retained. - TS_ASSERT_EQUALS(map[specId1], 0); - - // Check the cropped x range - auto copyX = detectorWS->x(0); - std::sort(copyX.begin(), copyX.end()); - TS_ASSERT(copyX.front() >= wavelengthMin); - TS_ASSERT(copyX.back() <= wavelengthMax); - - /* ------------- Checks for the monitor workspace --------------------*/ - // Check units. - TS_ASSERT_EQUALS("Wavelength", monitorWS->getAxis(0)->unit()->unitID()); - - // Check the number of spectrum kept. This should only ever be 1. - TS_ASSERT_EQUALS(1, monitorWS->getNumberHistograms()); - - map = monitorWS->getSpectrumToWorkspaceIndexMap(); - // Check the spectrum Nos retained. - TS_ASSERT_EQUALS(map[monitorSpecId], 0); - } - - IAlgorithm_sptr construct_standard_algorithm() { - auto alg = - AlgorithmManager::Instance().create("ReflectometryReductionOne", 1); - alg->setRethrows(true); - alg->setChild(true); - alg->initialize(); - alg->setProperty("InputWorkspace", m_tinyReflWS); - alg->setProperty("WavelengthMin", 1.0); - alg->setProperty("WavelengthMax", 2.0); - alg->setProperty("I0MonitorIndex", 1); - alg->setProperty("MonitorBackgroundWavelengthMin", 1.0); - alg->setProperty("MonitorBackgroundWavelengthMax", 2.0); - alg->setProperty("MonitorIntegrationWavelengthMin", 1.2); - alg->setProperty("MonitorIntegrationWavelengthMax", 1.5); - alg->setProperty("MomentumTransferStep", 0.1); - alg->setPropertyValue("ProcessingInstructions", "0"); - alg->setPropertyValue("OutputWorkspace", "x"); - alg->setPropertyValue("OutputWorkspaceWavelength", "y"); - alg->setRethrows(true); - return alg; - } - - void test_execute() { - auto alg = construct_standard_algorithm(); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr workspaceInQ = alg->getProperty("OutputWorkspace"); - MatrixWorkspace_sptr workspaceInLam = - alg->getProperty("OutputWorkspaceWavelength"); - const double theta = alg->getProperty("ThetaOut"); - UNUSED_ARG(theta) - UNUSED_ARG(workspaceInQ) - UNUSED_ARG(workspaceInLam) - } - - void test_calculate_theta() { - - auto alg = construct_standard_algorithm(); - - alg->execute(); - // Should not throw - - const double outTwoTheta = alg->getProperty("ThetaOut"); - TS_ASSERT_DELTA(45.0, outTwoTheta, 0.00001); - } - - void test_source_rotation_after_second_reduction() { - // set up the axis for the instrument - Instrument_sptr instrument = boost::make_shared<Instrument>(); - instrument->setReferenceFrame(boost::make_shared<ReferenceFrame>( - Y /*up*/, Z /*along*/, Right, "0,0,0")); - - // add a source - ObjComponent *source = new ObjComponent("source"); - source->setPos(V3D(0, 0, -1)); - instrument->add(source); - instrument->markAsSource(source); - - // add a sample - ObjComponent *sample = new ObjComponent("some-surface-holder"); - sample->setPos(V3D(0, 0, 0)); - instrument->add(sample); - instrument->markAsSamplePos(sample); - - // add a detector - Detector *det = new Detector("point-detector", 1, nullptr); - det->setPos(V3D(0, 1, 1)); - instrument->add(det); - instrument->markAsDetector(det); - - // set the instrument to this workspace - m_tinyReflWS->setInstrument(instrument); - // set this detector ready for processing instructions - m_tinyReflWS->getSpectrum(0).setDetectorID(det->getID()); - - auto alg = - AlgorithmManager::Instance().create("ReflectometryReductionOne", 1); - alg->setRethrows(true); - alg->setChild(true); - alg->initialize(); - alg->setProperty("InputWorkspace", m_tinyReflWS); - alg->setProperty("WavelengthMin", 1.0); - alg->setProperty("WavelengthMax", 15.0); - alg->setProperty("I0MonitorIndex", 0); - alg->setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg->setProperty("MonitorBackgroundWavelengthMax", 0.0); - alg->setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg->setProperty("MonitorIntegrationWavelengthMax", 0.0); - alg->setProperty("MomentumTransferStep", 0.1); - alg->setProperty("NormalizeByIntegratedMonitors", false); - alg->setProperty("CorrectDetectorPositions", true); - alg->setProperty("CorrectionAlgorithm", "None"); - alg->setPropertyValue("ProcessingInstructions", "1"); - alg->setPropertyValue("OutputWorkspace", "x"); - alg->setPropertyValue("OutputWorkspaceWavelength", "y"); - alg->setRethrows(true); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr outLam = alg->getProperty("OutputWorkspaceWavelength"); - MatrixWorkspace_sptr outQ = alg->getProperty("OutputWorkspace"); - - TS_ASSERT_EQUALS(m_tinyReflWS->getInstrument()->getSource()->getPos(), - outLam->getInstrument()->getSource()->getPos()); - TS_ASSERT_EQUALS(outLam->getInstrument()->getSource()->getPos(), - outQ->getInstrument()->getSource()->getPos()); - } - void test_post_processing_scale_step() { - auto alg = construct_standard_algorithm(); - auto inWS = - WorkspaceCreationHelper::create2DWorkspaceWithReflectometryInstrument( - 2.0); - inWS->getAxis(0)->setUnit("Wavelength"); - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("ScaleFactor", 1.0); - alg->setProperty("ThetaIn", 1.5); - alg->setProperty("OutputWorkspace", "Test"); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr nonScaledWS = alg->getProperty("OutputWorkspace"); - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("ScaleFactor", 0.5); - alg->setProperty("OutputWorkspace", "scaledTest"); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr scaledWS = alg->getProperty("OutputWorkspace"); - // compare y data instead of workspaces. - auto &scaledYData = scaledWS->y(0); - auto &nonScaledYData = nonScaledWS->y(0); - TS_ASSERT_EQUALS(scaledYData.front(), 2 * nonScaledYData.front()); - TS_ASSERT_EQUALS(scaledYData[scaledYData.size() / 2], - 2 * nonScaledYData[nonScaledYData.size() / 2]); - TS_ASSERT_EQUALS(scaledYData.back(), 2 * nonScaledYData.back()); - // Remove workspace from the data service. - AnalysisDataService::Instance().remove("Test"); - AnalysisDataService::Instance().remove("scaledTest"); - } - void test_post_processing_rebin_step_with_params_not_provided() { - auto alg = construct_standard_algorithm(); - auto inWS = create2DWorkspace154(1, 10, true); - // this instrument does not have a "slit-gap" property - // defined in the IPF, so NRCalculateSlitResolution should throw. - inWS->setInstrument(m_tinyReflWS->getInstrument()); - inWS->getAxis(0)->setUnit("Wavelength"); - // Setup bad bin edges, Rebin will throw (not NRCalculateSlitResolution?) - inWS->mutableX(0) = inWS->x(0)[0]; - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("OutputWorkspace", "rebinnedWS"); - TS_ASSERT_THROWS(alg->execute(), std::invalid_argument); - } - void test_post_processing_rebin_step_with_partial_params_provided() { - auto alg = construct_standard_algorithm(); - auto inWS = create2DWorkspace154(1, 10, true); - inWS->setInstrument(m_tinyReflWS->getInstrument()); - inWS->getAxis(0)->setUnit("Wavelength"); - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("MomentumTransferMaximum", 15.0); - alg->setProperty("OutputWorkspace", "rebinnedWS"); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr rebinnedIvsQWS = alg->getProperty("OutputWorkspace"); - auto &xData = rebinnedIvsQWS->x(0); - // based off the equation for logarithmic binning X(i+1)=X(i)(1+|dX|) - double binWidthFromLogarithmicEquation = fabs((xData[1] / xData[0]) - 1); - TSM_ASSERT_DELTA("DQQ should be the same as abs(x[1]/x[0] - 1)", - binWidthFromLogarithmicEquation, 0.1, 1e-06); - TSM_ASSERT_DELTA("Qmax should be the same as last Params entry (5.0)", - xData.back(), 15.0, 1e-06); - } - void test_post_processing_rebin_step_with_logarithmic_rebinning() { - auto alg = construct_standard_algorithm(); - auto inWS = create2DWorkspace154(1, 10, true); - inWS->setInstrument(m_tinyReflWS->getInstrument()); - inWS->getAxis(0)->setUnit("Wavelength"); - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("MomentumTransferMinimum", 1.0); - alg->setProperty("MomentumTransferStep", 0.2); - alg->setProperty("MomentumTransferMaximum", 5.0); - alg->setProperty("OutputWorkspace", "rebinnedWS"); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr rebinnedIvsQWS = alg->getProperty("OutputWorkspace"); - auto &xData = rebinnedIvsQWS->x(0); - TSM_ASSERT_EQUALS("QMin should be the same as first Param entry (1.0)", - xData[0], 1.0); - // based off the equation for logarithmic binning X(i+1)=X(i)(1+|dX|) - double binWidthFromLogarithmicEquation = fabs((xData[1] / xData[0]) - 1); - TSM_ASSERT_DELTA("DQQ should be the same as abs(x[1]/x[0] - 1)", - binWidthFromLogarithmicEquation, 0.2, 1e-06); - TSM_ASSERT_EQUALS("QMax should be the same as last Param entry", - xData.back(), 5.0); - } - void test_post_processing_rebin_step_with_linear_rebinning() { - auto alg = construct_standard_algorithm(); - auto inWS = create2DWorkspace154(1, 10, true); - inWS->setInstrument(m_tinyReflWS->getInstrument()); - inWS->getAxis(0)->setUnit("Wavelength"); - alg->setProperty("InputWorkspace", inWS); - alg->setProperty("MomentumTransferMinimum", 1.577); - alg->setProperty("MomentumTransferStep", -0.2); - alg->setProperty("MomentumTransferMaximum", 5.233); - alg->setProperty("OutputWorkspace", "rebinnedWS"); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - MatrixWorkspace_sptr rebinnedIvsQWS = alg->getProperty("OutputWorkspace"); - auto &xData = rebinnedIvsQWS->x(0); - TSM_ASSERT_DELTA("QMin should be the same as the first Param entry (1.577)", - xData[0], 1.577, 1e-06); - TSM_ASSERT_DELTA("DQQ should the same as 0.2", xData[1] - xData[0], 0.2, - 1e-06); - TSM_ASSERT_DELTA("QMax should be the same as the last Param entry (5.233)", - xData.back(), 5.233, 1e-06); - } - void test_Qrange() { - // set up the axis for the instrument - Instrument_sptr instrument = boost::make_shared<Instrument>(); - instrument->setReferenceFrame(boost::make_shared<ReferenceFrame>( - Y /*up*/, Z /*along*/, Right, "0,0,0")); - - // add a source - ObjComponent *source = new ObjComponent("source"); - source->setPos(V3D(0, 0, -1)); - instrument->add(source); - instrument->markAsSource(source); - - // add a sample - ObjComponent *sample = new ObjComponent("some-surface-holder"); - sample->setPos(V3D(0, 0, 0)); - instrument->add(sample); - instrument->markAsSamplePos(sample); - - // add a detector - Detector *det = new Detector("point-detector", 1, nullptr); - det->setPos(V3D(0, 1, 1)); - instrument->add(det); - instrument->markAsDetector(det); - - // set the instrument to this workspace - m_tinyReflWS->setInstrument(instrument); - // set this detector ready for processing instructions - m_tinyReflWS->getSpectrum(0).setDetectorID(det->getID()); - - auto alg = - AlgorithmManager::Instance().create("ReflectometryReductionOne", 1); - alg->setRethrows(true); - alg->setChild(true); - alg->initialize(); - alg->setProperty("InputWorkspace", m_tinyReflWS); - alg->setProperty("WavelengthMin", 1.0); - alg->setProperty("WavelengthMax", 15.0); - alg->setProperty("I0MonitorIndex", 0); - alg->setProperty("MonitorBackgroundWavelengthMin", 0.0); - alg->setProperty("MonitorBackgroundWavelengthMax", 0.0); - alg->setProperty("MonitorIntegrationWavelengthMin", 0.0); - alg->setProperty("MonitorIntegrationWavelengthMax", 0.0); - alg->setProperty("MomentumTransferStep", 0.1); - alg->setProperty("NormalizeByIntegratedMonitors", false); - alg->setProperty("CorrectDetectorPositions", true); - alg->setProperty("CorrectionAlgorithm", "None"); - alg->setPropertyValue("ProcessingInstructions", "1"); - alg->setPropertyValue("OutputWorkspace", "x"); - alg->setPropertyValue("OutputWorkspaceWavelength", "y"); - alg->setRethrows(true); - TS_ASSERT_THROWS_NOTHING(alg->execute()); - - // retrieve the IvsLam workspace - MatrixWorkspace_sptr inLam = alg->getProperty("OutputWorkspaceWavelength"); - // retrieve the IvsQ workspace - MatrixWorkspace_sptr inQ = alg->getProperty("OutputWorkspace"); - // retrieve our Theta - double outTheta = alg->getProperty("ThetaOut"); - - TS_ASSERT_DELTA(45.0, outTheta, 0.00001); - TS_ASSERT_EQUALS(source->getPos(), - inQ->getInstrument()->getSource()->getPos()); - // convert from degrees to radians for sin() function - double outThetaInRadians = outTheta * M_PI / 180; - - double lamMin = inLam->x(0).front(); - double lamMax = inLam->x(0).back(); - - // Derive our QMin and QMax from the equation - double qMinFromEQ = (4 * M_PI * sin(outThetaInRadians)) / lamMax; - double qMaxFromEQ = (4 * M_PI * sin(outThetaInRadians)) / lamMin; - - // Get our QMin and QMax from the workspace - auto qMinFromWS = inQ->x(0).front(); - auto qMaxFromWS = inQ->x(0).back(); - - // Compare the two values (they should be identical) - TS_ASSERT_DELTA(qMinFromEQ, qMinFromWS, 0.00001); - TS_ASSERT_DELTA(qMaxFromEQ, qMaxFromWS, 0.00001); - } -}; - -#endif /* ALGORITHMS_TEST_REFLECTOMETRYREDUCTIONONETEST_H_ */ diff --git a/Framework/Algorithms/test/RemoveBackgroundTest.h b/Framework/Algorithms/test/RemoveBackgroundTest.h index c01c9209a077cc5256ef2ef3c76c8841d49e1f65..8139f055e6f27be7cd8e90c4ce43321777b1e007 100644 --- a/Framework/Algorithms/test/RemoveBackgroundTest.h +++ b/Framework/Algorithms/test/RemoveBackgroundTest.h @@ -195,8 +195,8 @@ public: auto clone = cloneSourceWS(); // set negative values to signal auto &Y = clone->dataY(0); - for (size_t i = 0; i < Y.size(); i++) { - Y[i] = -1000; + for (double &i : Y) { + i = -1000; } // Create zero background workspace // Create the workspace diff --git a/Framework/Algorithms/test/RunCombinationHelperTest.h b/Framework/Algorithms/test/RunCombinationHelperTest.h index 3545278c02b8566f13f1ef4bde72be731ae3138d..154f72f6e45db91f3c45b0b4f9cf854e5b245218 100644 --- a/Framework/Algorithms/test/RunCombinationHelperTest.h +++ b/Framework/Algorithms/test/RunCombinationHelperTest.h @@ -9,15 +9,18 @@ #include "MantidAPI/Axis.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidHistogramData/HistogramDx.h" #include "MantidAlgorithms/CreateSampleWorkspace.h" #include "MantidAlgorithms/GroupWorkspaces.h" #include "MantidKernel/UnitFactory.h" +#include "MantidKernel/make_cow.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" using Mantid::Algorithms::RunCombinationHelper; using Mantid::Algorithms::GroupWorkspaces; using Mantid::Algorithms::CreateSampleWorkspace; using namespace Mantid::API; +using namespace Mantid::HistogramData; using namespace Mantid::Kernel; using namespace WorkspaceCreationHelper; @@ -122,6 +125,16 @@ public: "different X units; different spectrum axis units; "); } + void testIncompatibleDx() { + // create a workspace where spectrum 1 has Dx + MatrixWorkspace_sptr ws2 = m_reference->clone(); + auto dx = + Mantid::Kernel::make_cow<Mantid::HistogramData::HistogramDx>(3, 0.2); + ws2->setSharedDx(1, dx); + TS_ASSERT_EQUALS(m_testee.checkCompatibility(ws2), + "spectra must have either Dx values or not; "); + } + void test_scanning_workspaces_throw_no_error() { const auto scanWS1 = createSampleScanningWorkspace(2); const auto scanWS2 = createSampleScanningWorkspace(2); diff --git a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h index 989a5db08afb529893d4136852ba96c7d3a1f44d..f4b89655dea41c2ac3ab7715133004950c8d25fa 100644 --- a/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h +++ b/Framework/Algorithms/test/SANSCollimationLengthEstimatorTest.h @@ -51,7 +51,7 @@ createTestInstrument(const Mantid::detid_t id, Detector *det0(nullptr); if (!detShapeXML.empty()) { auto shape = ShapeFactory().createShape(detShapeXML); - det0 = new Detector("det0", id, shape, NULL); + det0 = new Detector("det0", id, shape, nullptr); } else { det0 = new Detector("det0", id, nullptr); } diff --git a/Framework/Algorithms/test/SassenaFFTTest.h b/Framework/Algorithms/test/SassenaFFTTest.h index 4c15d0aa2fc5219da2356e5a9f2e1f2b96e7434c..a5736da301499ef73005aad7a142507008b6b799 100644 --- a/Framework/Algorithms/test/SassenaFFTTest.h +++ b/Framework/Algorithms/test/SassenaFFTTest.h @@ -144,10 +144,10 @@ private: double sum = 0.0; double average = 0.0; MantidVec::iterator itx = xv.begin(); - for (MantidVec::iterator it = yv.begin(); it != yv.end(); ++it) { + for (double &y : yv) { factor = exp(exponentFactor * (*itx)); - sum += (*it) * factor; - average += (*it) * (*itx) * factor; + sum += y * factor; + average += y * (*itx) * factor; ++itx; } average /= sum; @@ -186,9 +186,9 @@ private: xv = ws->readX(i); MantidVec::iterator itx = xv.begin(); double sum = 0.0; - for (MantidVec::iterator it = yv.begin(); it != yv.end(); ++it) { + for (double &y : yv) { factor = exp(exponentFactor * (*itx)); - sum += (*it) * factor; + sum += y * factor; ++itx; } sum *= dx / static_cast<double>(nbins); diff --git a/Framework/Algorithms/test/SofQWCutTest.h b/Framework/Algorithms/test/SofQWCutTest.h index ea13b7476613cec13ef681ba983fd72af91300f7..60f86cc05a0ceaa4101f5f2029446d09eac94a50 100644 --- a/Framework/Algorithms/test/SofQWCutTest.h +++ b/Framework/Algorithms/test/SofQWCutTest.h @@ -12,6 +12,7 @@ #include "MantidAPI/WorkspaceGroup.h" #include "MantidKernel/Unit.h" #include "MantidDataHandling/LoadNexusProcessed.h" +#include "MantidDataHandling/CreateSimulationWorkspace.h" #include <boost/make_shared.hpp> @@ -221,6 +222,47 @@ public: TS_ASSERT_DELTA(ws_e->readY(0)[119], 0.045373095, delta); TS_ASSERT_DELTA(ws_e->readE(0)[119], 0.005462714, delta); } + + void test_sofqw3_zerobinwidth() { + // This test sets up a workspace which can yield a bin with zero width + // to check the code FractionalRebinning code handles this correctly + const double delta(1e-08); + Mantid::DataHandling::CreateSimulationWorkspace create_ws; + create_ws.initialize(); + create_ws.setChild(true); + create_ws.setPropertyValue("Instrument", "MARI"); + create_ws.setPropertyValue("BinParams", "-5,0.5,24"); + create_ws.setPropertyValue("OutputWorkspace", "__unused"); + create_ws.execute(); + + MatrixWorkspace_sptr createdWS = create_ws.getProperty("OutputWorkspace"); + auto inWS = boost::dynamic_pointer_cast<MatrixWorkspace>(createdWS); + // Sets one spectrum to zero so final value is not unity. + inWS->setCounts(300, std::vector<double>(58, 0.)); + + Mantid::Algorithms::SofQWNormalisedPolygon sqw; + sqw.initialize(); + sqw.setChild(true); + TS_ASSERT_THROWS_NOTHING(sqw.setProperty("InputWorkspace", inWS)); + TS_ASSERT_THROWS_NOTHING( + sqw.setPropertyValue("OutputWorkspace", "__unused")); + TS_ASSERT_THROWS_NOTHING(sqw.setPropertyValue("QAxisBinning", "0,10,10")); + TS_ASSERT_THROWS_NOTHING(sqw.setPropertyValue("EMode", "Direct")); + TS_ASSERT_THROWS_NOTHING(sqw.setPropertyValue("EFixed", "25")); + TS_ASSERT_THROWS_NOTHING( + sqw.setPropertyValue("EAxisBinning", "-1.5,3,1.5")); + TS_ASSERT_THROWS_NOTHING(sqw.execute()); + TS_ASSERT(sqw.isExecuted()); + + MatrixWorkspace_sptr ws = sqw.getProperty("OutputWorkspace"); + TS_ASSERT_EQUALS(ws->getAxis(0)->length(), 2); + TS_ASSERT_EQUALS(ws->getAxis(0)->unit()->unitID(), "DeltaE"); + TS_ASSERT_EQUALS((*(ws->getAxis(0)))(0), -1.5); + TS_ASSERT_EQUALS((*(ws->getAxis(0)))(1), 1.5); + TS_ASSERT_EQUALS(ws->getAxis(1)->length(), 2); + TS_ASSERT_EQUALS(ws->getAxis(1)->unit()->unitID(), "MomentumTransfer"); + TS_ASSERT_DELTA(ws->readY(0)[0], 0.998910675, delta); + } }; #endif /*SOFQWCUTTEST_H_*/ diff --git a/Framework/Algorithms/test/SpecularReflectionPositionCorrect2Test.h b/Framework/Algorithms/test/SpecularReflectionPositionCorrect2Test.h index e9e8e0b82c0253f9e8b28d9462af3f47dda102d0..abb29b7f35ecbbca701ef90a2a971e68f9ec95be 100644 --- a/Framework/Algorithms/test/SpecularReflectionPositionCorrect2Test.h +++ b/Framework/Algorithms/test/SpecularReflectionPositionCorrect2Test.h @@ -164,7 +164,7 @@ public: auto detIn = instrIn->getComponentByName("point-detector")->getPos(); auto detOut = instrOut->getComponentByName("point-detector")->getPos(); TS_ASSERT_EQUALS(detIn.X(), detOut.X()); - TS_ASSERT_DELTA(detOut.Z(), 19.69921, 1e-5); + TS_ASSERT_DELTA(detOut.Z(), 2.66221, 1e-5); TS_ASSERT_DELTA(detOut.Y(), 0.06506, 1e-5); } @@ -205,7 +205,7 @@ public: auto detIn = instrIn->getComponentByName("linear-detector")->getPos(); auto detOut = instrOut->getComponentByName("linear-detector")->getPos(); TS_ASSERT_EQUALS(detIn.X(), detOut.X()); - TS_ASSERT_DELTA(detOut.Z(), 20.19906, 1e-5); + TS_ASSERT_DELTA(detOut.Z(), 3.162055, 1e-5); TS_ASSERT_DELTA(detOut.Y(), 0.07728, 1e-5); } }; diff --git a/Framework/Algorithms/test/Stitch1DTest.h b/Framework/Algorithms/test/Stitch1DTest.h index 1e787942a341012e425e0aa877de71edbe192e95..fab1d86938b60529bf8f2eecc7e7f8c50685acf9 100644 --- a/Framework/Algorithms/test/Stitch1DTest.h +++ b/Framework/Algorithms/test/Stitch1DTest.h @@ -384,8 +384,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -416,8 +415,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -449,8 +447,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. @@ -482,8 +479,7 @@ public: } // Check that the output E-Values are correct. Output Error values should // all be zero - for (auto itr = stitched_e.begin(); itr != stitched_e.end(); ++itr) { - double temp = *itr; + for (double temp : stitched_e) { TS_ASSERT_EQUALS(temp, 0); } // Check that the output X-Values are correct. diff --git a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h index 980b8035bf049eb687f0ab7d8ae3ed3f94b73fc0..7d7ddbd661f76f61a94df2939604bc62e9b08518 100644 --- a/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h +++ b/Framework/Algorithms/test/TOFSANSResolutionByPixelTest.h @@ -62,7 +62,7 @@ createTestInstrument(const Mantid::detid_t id, Detector *det0(nullptr); if (!detShapeXML.empty()) { auto shape = ShapeFactory().createShape(detShapeXML); - det0 = new Detector("det0", id, shape, NULL); + det0 = new Detector("det0", id, shape, nullptr); } else { det0 = new Detector("det0", id, nullptr); } diff --git a/Framework/Algorithms/test/UnGroupWorkspaceTest.h b/Framework/Algorithms/test/UnGroupWorkspaceTest.h index 70a5ea9404c01f1d1bb99a5e6f909149074df88e..62e6379b4d41eda4f2fa52b3b87c464f8824728e 100644 --- a/Framework/Algorithms/test/UnGroupWorkspaceTest.h +++ b/Framework/Algorithms/test/UnGroupWorkspaceTest.h @@ -102,8 +102,8 @@ private: auto newGroup = boost::make_shared<Mantid::API::WorkspaceGroup>(); auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = inputs.begin(); it != inputs.end(); ++it) { - auto ws = addTestMatrixWorkspaceToADS(*it); + for (const auto &input : inputs) { + auto ws = addTestMatrixWorkspaceToADS(input); newGroup->addWorkspace(ws); } ads.add(name, newGroup); @@ -120,9 +120,9 @@ private: void removeFromADS(const std::vector<std::string> &members) { auto &ads = Mantid::API::AnalysisDataService::Instance(); - for (auto it = members.begin(); it != members.end(); ++it) { - if (ads.doesExist(*it)) - ads.remove(*it); + for (const auto &member : members) { + if (ads.doesExist(member)) + ads.remove(member); } } }; diff --git a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h index f56173e6a3f265fb1237bd961ed00aa21cbe32b5..e788871524e4bfade6d5977e735470f3d60f3c72 100644 --- a/Framework/Algorithms/test/WorkspaceCreationHelperTest.h +++ b/Framework/Algorithms/test/WorkspaceCreationHelperTest.h @@ -1,14 +1,9 @@ #ifndef MANTID_ALGORITHMS_WORKSPACECREATIONHELPERTEST_H_ #define MANTID_ALGORITHMS_WORKSPACECREATIONHELPERTEST_H_ -#include "MantidKernel/System.h" -#include "MantidKernel/Timer.h" #include "MantidTestHelpers/WorkspaceCreationHelper.h" #include <cxxtest/TestSuite.h> -#include "MantidAPI/SpectraDetectorTypes.h" -using namespace Mantid; -using namespace Mantid::API; using namespace Mantid::DataObjects; /** Test class for the helpers in MantidTestHelpers/WorkspaceCreationHelper.h */ @@ -36,6 +31,19 @@ public: TS_ASSERT(ws->getSpectrum(0).hasDetectorID(100)); TS_ASSERT(ws->getSpectrum(1).hasDetectorID(101)); } + + void test_create2DWorkspaceWithValues() { + Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace123( + 1, 2, false, std::set<int64_t>(), true); + TS_ASSERT(ws); + TS_ASSERT_EQUALS(ws->getNumberHistograms(), 1); + TS_ASSERT_EQUALS(ws->size(), 2); + TS_ASSERT(ws->hasDx(0)); + TS_ASSERT_EQUALS(ws->dx(0).rawData()[0], 2.); + Workspace2D_sptr ws2 = WorkspaceCreationHelper::create2DWorkspace123( + 1, 2, false, std::set<int64_t>(), false); + TS_ASSERT(!ws2->hasDx(0)); + } }; #endif /* MANTID_ALGORITHMS_WORKSPACECREATIONHELPERTEST_H_ */ diff --git a/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h b/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h index edc8082ed89b61c42102e1cca799997351da7dff..a8883732d2d26155b18d85df9c08f5eb57da20b8 100644 --- a/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h +++ b/Framework/Beamline/inc/MantidBeamline/ComponentInfo.h @@ -52,6 +52,7 @@ private: boost::shared_ptr<const std::vector<std::pair<size_t, size_t>>> m_componentRanges; boost::shared_ptr<const std::vector<size_t>> m_parentIndices; + boost::shared_ptr<std::vector<std::vector<size_t>>> m_children; Mantid::Kernel::cow_ptr<std::vector<Eigen::Vector3d>> m_positions; Mantid::Kernel::cow_ptr<std::vector< Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> @@ -98,6 +99,7 @@ public: boost::shared_ptr<const std::vector<std::pair<size_t, size_t>>> componentRanges, boost::shared_ptr<const std::vector<size_t>> parentIndices, + boost::shared_ptr<std::vector<std::vector<size_t>>> children, boost::shared_ptr<std::vector<Eigen::Vector3d>> positions, boost::shared_ptr<std::vector< Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> @@ -112,7 +114,9 @@ public: std::unique_ptr<ComponentInfo> cloneWithoutDetectorInfo() const; std::vector<size_t> detectorsInSubtree(const size_t componentIndex) const; std::vector<size_t> componentsInSubtree(const size_t componentIndex) const; + const std::vector<size_t> &children(const size_t componentIndex) const; size_t size() const; + size_t numberOfDetectorsInSubtree(const size_t componentIndex) const; bool isDetector(const size_t componentIndex) const { return componentIndex < m_assemblySortedDetectorIndices->size(); } diff --git a/Framework/Beamline/inc/MantidBeamline/ComponentType.h b/Framework/Beamline/inc/MantidBeamline/ComponentType.h index 9548fac56244a43b907f5b23df7afe5c59c72efc..c5e33293a06915eef466511ce25289f9311aa010 100644 --- a/Framework/Beamline/inc/MantidBeamline/ComponentType.h +++ b/Framework/Beamline/inc/MantidBeamline/ComponentType.h @@ -6,6 +6,7 @@ namespace Mantid { namespace Beamline { enum class ComponentType { Generic, + Infinite, Rectangular, Structured, Unstructured, diff --git a/Framework/Beamline/src/ComponentInfo.cpp b/Framework/Beamline/src/ComponentInfo.cpp index 2e53c46e4701f61f27dc7d83f3181585efc2d2f0..6baef33046eb9e3973cd0eee83ee5f21f78b384c 100644 --- a/Framework/Beamline/src/ComponentInfo.cpp +++ b/Framework/Beamline/src/ComponentInfo.cpp @@ -38,6 +38,7 @@ ComponentInfo::ComponentInfo( boost::shared_ptr<const std::vector<std::pair<size_t, size_t>>> componentRanges, boost::shared_ptr<const std::vector<size_t>> parentIndices, + boost::shared_ptr<std::vector<std::vector<size_t>>> children, boost::shared_ptr<std::vector<Eigen::Vector3d>> positions, boost::shared_ptr<std::vector<Eigen::Quaterniond, Eigen::aligned_allocator<Eigen::Quaterniond>>> @@ -52,7 +53,8 @@ ComponentInfo::ComponentInfo( m_detectorRanges(std::move(detectorRanges)), m_componentRanges(std::move(componentRanges)), m_parentIndices(std::move(parentIndices)), - m_positions(std::move(positions)), m_rotations(std::move(rotations)), + m_children(std::move(children)), m_positions(std::move(positions)), + m_rotations(std::move(rotations)), m_scaleFactors(std::move(scaleFactors)), m_componentType(std::move(componentType)), m_names(std::move(names)), m_size(m_assemblySortedDetectorIndices->size() + @@ -92,6 +94,19 @@ ComponentInfo::ComponentInfo( throw std::invalid_argument("ComponentInfo should be provided same number " "of names as number of components"); } + + // Calculate total size of all assemblies + auto assemTotalSize = std::accumulate( + m_children->begin(), m_children->end(), static_cast<size_t>(1), + [](size_t size, const std::vector<size_t> &assem) { + return size += assem.size(); + }); + + if (assemTotalSize != m_size) { + throw std::invalid_argument("ComponentInfo should be provided an " + "instrument tree which contains same number " + "components"); + } } std::unique_ptr<ComponentInfo> ComponentInfo::cloneWithoutDetectorInfo() const { @@ -140,8 +155,24 @@ ComponentInfo::componentsInSubtree(const size_t componentIndex) const { return indices; } +const std::vector<size_t> & +ComponentInfo::children(const size_t componentIndex) const { + static const std::vector<size_t> emptyVec; + + if (!isDetector(componentIndex)) + return (*m_children)[compOffsetIndex(componentIndex)]; + + return emptyVec; +} + size_t ComponentInfo::size() const { return m_size; } +size_t +ComponentInfo::numberOfDetectorsInSubtree(const size_t componentIndex) const { + auto range = detectorRangeInSubtree(componentIndex); + return std::distance(range.begin(), range.end()); +} + Eigen::Vector3d ComponentInfo::position(const size_t componentIndex) const { checkNoTimeDependence(); if (isDetector(componentIndex)) { @@ -301,7 +332,8 @@ void ComponentInfo::setPosition(const size_t componentIndex, if (isDetector(componentIndex)) return m_detectorInfo->setPosition(componentIndex, newPosition); - // Optimization: Not using detectorsInSubtree and componentsInSubtree to avoid + // Optimization: Not using detectorsInSubtree and componentsInSubtree to + // avoid // memory allocations. // Optimization: Split loop over detectors and other components. const auto detectorRange = detectorRangeInSubtree(componentIndex); diff --git a/Framework/Beamline/test/ComponentInfoTest.h b/Framework/Beamline/test/ComponentInfoTest.h index 4af0a9d5fdbcce57e4d88c88190e1f9d48b204c9..dcd6c92dc07b0e2f27a43dd5ac5511390072ce08 100644 --- a/Framework/Beamline/test/ComponentInfoTest.h +++ b/Framework/Beamline/test/ComponentInfoTest.h @@ -66,6 +66,11 @@ makeFlatTree(PosVec detPositions, RotVec detRotations) { auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>(1, ComponentType::Generic); + std::vector<size_t> branch(detPositions.size()); + std::iota(branch.begin(), branch.end(), 0); + auto children = + boost::make_shared<std::vector<std::vector<size_t>>>(1, branch); + auto componentInfo = boost::make_shared<ComponentInfo>( bankSortedDetectorIndices, boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( @@ -73,8 +78,8 @@ makeFlatTree(PosVec detPositions, RotVec detRotations) { bankSortedComponentIndices, boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( componentRanges), - parentIndices, positions, rotations, scaleFactors, isRectangularBank, - names, -1, -1); + parentIndices, children, positions, rotations, scaleFactors, + isRectangularBank, names, -1, -1); componentInfo->setDetectorInfo(detectorInfo.get()); @@ -141,6 +146,8 @@ makeTreeExampleAndReturnGeometricArguments() { // Rectangular bank flag auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>(2, ComponentType::Generic); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>( + 2, std::vector<size_t>(2)); auto compInfo = boost::make_shared<ComponentInfo>( bankSortedDetectorIndices, @@ -149,7 +156,7 @@ makeTreeExampleAndReturnGeometricArguments() { bankSortedComponentIndices, boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( componentRanges), - parentIndices, compPositions, compRotations, scaleFactors, + parentIndices, children, compPositions, compRotations, scaleFactors, isRectangularBank, names, -1, -1); compInfo->setDetectorInfo(detectorInfo.get()); @@ -208,6 +215,9 @@ makeTreeExample() { auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>(2, ComponentType::Generic); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>( + 2, std::vector<size_t>(2)); + auto componentInfo = boost::make_shared<ComponentInfo>( bankSortedDetectorIndices, boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( @@ -215,8 +225,8 @@ makeTreeExample() { bankSortedComponentIndices, boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( componentRanges), - parentIndices, positions, rotations, scaleFactors, isRectangularBank, - names, -1, -1); + parentIndices, children, positions, rotations, scaleFactors, + isRectangularBank, names, -1, -1); componentInfo->setDetectorInfo(detectorInfo.get()); @@ -273,23 +283,28 @@ public: boost::make_shared<const std::vector<size_t>>( std::vector<size_t>{0, 1, 2}); auto bankSortedComponentIndices = - boost::make_shared<const std::vector<size_t>>(std::vector<size_t>{}); - auto parentIndices = boost::make_shared<const std::vector<size_t>>( - std::vector<size_t>{9, 9, 9}); // These indices are invalid, but that's - // ok as not being tested here + boost::make_shared<const std::vector<size_t>>(std::vector<size_t>(1)); + auto parentIndices = + boost::make_shared<const std::vector<size_t>>(std::vector<size_t>{ + 9, 9, 9, 9}); // These indices are invalid, but that's + // ok as not being tested here auto detectorRanges = - boost::make_shared<const std::vector<std::pair<size_t, size_t>>>(); + boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( + 1, std::pair<size_t, size_t>{0, 2}); auto componentRanges = boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( std::vector<std::pair<size_t, size_t>>{}); - auto positions = boost::make_shared<PosVec>(); - auto rotations = boost::make_shared<RotVec>(); - auto scaleFactors = boost::make_shared<PosVec>(3); - auto names = boost::make_shared<StrVec>(3); - auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>(); + auto positions = boost::make_shared<PosVec>(1); + auto rotations = boost::make_shared<RotVec>(1); + auto scaleFactors = boost::make_shared<PosVec>(4); + auto names = boost::make_shared<StrVec>(4); + auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>(1); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>( + 1, std::vector<size_t>(3)); + ComponentInfo componentInfo(bankSortedDetectorIndices, detectorRanges, bankSortedComponentIndices, componentRanges, - parentIndices, positions, rotations, + parentIndices, children, positions, rotations, scaleFactors, isRectangularBank, names, -1, -1); DetectorInfo detectorInfo; // Detector info size 0 @@ -325,11 +340,14 @@ public: auto names = boost::make_shared<StrVec>(); auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>( 2, ComponentType::Generic); + auto children = boost::make_shared< + std::vector<std::vector<size_t>>>(); // invalid but not being tested + TS_ASSERT_THROWS(ComponentInfo(detectorsInSubtree, detectorRanges, bankSortedComponentIndices, componentRanges, - parentIndices, positions, rotations, - scaleFactors, isRectangularBank, names, -1, - -1), + parentIndices, children, positions, + rotations, scaleFactors, isRectangularBank, + names, -1, -1), std::invalid_argument &); } @@ -365,16 +383,62 @@ public: std::vector<std::pair<size_t, size_t>>{{0, 0}}); auto isRectangularBank = boost::make_shared<std::vector<ComponentType>>( 2, ComponentType::Generic); + auto children = boost::make_shared< + std::vector<std::vector<size_t>>>(); // invalid but not being tested + + TS_ASSERT_THROWS(ComponentInfo(detectorsInSubtree, detectorRanges, + componentsInSubtree, componentRanges, + parentIndices, children, positions, + rotations, scaleFactors, isRectangularBank, + names, -1, -1), + std::invalid_argument &); + } + + void test_throw_if_instrument_tree_not_same_size_as_number_of_components() { + /* + * Positions are rotations are only currently stored for non-detector + * components + * We should have as many detectorRanges as we have non-detector components + * too. + * All vectors should be the same size. + */ + auto detectorsInSubtree = + boost::make_shared<const std::vector<size_t>>(); // No detector indices + // in this example! + + auto componentsInSubtree = + boost::make_shared<const std::vector<size_t>>(std::vector<size_t>{0}); + + auto detectorRanges = + boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( + 1, std::pair<size_t, size_t>(0, 0)); + + auto parentIndices = boost::make_shared<const std::vector<size_t>>( + std::vector<size_t>{9, 9, 9}); // These indices are invalid, but that's + // ok as not being tested here + auto positions = boost::make_shared<PosVec>(1); + auto rotations = boost::make_shared<RotVec>(1); + + auto scaleFactors = boost::make_shared<PosVec>(1); + auto names = boost::make_shared<StrVec>(1); + // Only one component. So single empty component range. + auto componentRanges = + boost::make_shared<const std::vector<std::pair<size_t, size_t>>>( + std::vector<std::pair<size_t, size_t>>{{0, 0}}); + auto componentTypes = + boost::make_shared<std::vector<Mantid::Beamline::ComponentType>>( + 1, Mantid::Beamline::ComponentType::Generic); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>( + 1, std::vector<size_t>{1, 2}); // invalid TS_ASSERT_THROWS( ComponentInfo(detectorsInSubtree, detectorRanges, componentsInSubtree, - componentRanges, parentIndices, positions, rotations, - scaleFactors, isRectangularBank, names, -1, -1), + componentRanges, parentIndices, children, positions, + rotations, scaleFactors, componentTypes, names, -1, -1), std::invalid_argument &); } void test_read_positions_rotations() { - auto allOutputs = makeTreeExampleAndReturnGeometricArguments(); // Resulting ComponentInfo diff --git a/Framework/Crystal/inc/MantidCrystal/AddPeakHKL.h b/Framework/Crystal/inc/MantidCrystal/AddPeakHKL.h index 49e3de7345dd88a50c55b0f0118d229fe3e516f9..4eaf865ad8c7c85b40b32ae3daeb29bec5c4e03c 100644 --- a/Framework/Crystal/inc/MantidCrystal/AddPeakHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/AddPeakHKL.h @@ -34,6 +34,9 @@ class DLLExport AddPeakHKL : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AddPeak"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h index b207795b4efa92701f104e1c5972d48761fee52f..684e31e4aeea43eb8b0650129c33b79558f3398e 100644 --- a/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h +++ b/Framework/Crystal/inc/MantidCrystal/AnvredCorrection.h @@ -87,6 +87,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LorentzCorrection"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Corrections;CorrectionFunctions\\AbsorptionCorrections"; diff --git a/Framework/Crystal/inc/MantidCrystal/CalculatePeaksHKL.h b/Framework/Crystal/inc/MantidCrystal/CalculatePeaksHKL.h index b66b64d5f46dc0a7a0722a4a63b1c02fa03551da..41136356c25729cf41e7f7f7b720e9cbf856e60c 100644 --- a/Framework/Crystal/inc/MantidCrystal/CalculatePeaksHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/CalculatePeaksHKL.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AddPeak"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/CalculateUMatrix.h b/Framework/Crystal/inc/MantidCrystal/CalculateUMatrix.h index be18c24679b1826d18651fe6a772becd2fe5bb16..a95255657f998ac0461baa92987b7e090cd0c9ad 100644 --- a/Framework/Crystal/inc/MantidCrystal/CalculateUMatrix.h +++ b/Framework/Crystal/inc/MantidCrystal/CalculateUMatrix.h @@ -46,6 +46,7 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { return {"SetUB"}; } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\UBMatrix"; } diff --git a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h index f5e0c4fdfaaca15b3c2636ac752e6593f164d9fe..73fc45672012e8b8afd405afd20deafded93a4ba 100644 --- a/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/CentroidPeaks.h @@ -27,6 +27,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CentroidPeaksMD", "PeakIntegration"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Crystal/inc/MantidCrystal/ClearUB.h b/Framework/Crystal/inc/MantidCrystal/ClearUB.h index 9785a49ec2156d922b21652ab0079ac9b84607bf..04c6c405e88100f9e988542fa5a85a0b5e25a823 100644 --- a/Framework/Crystal/inc/MantidCrystal/ClearUB.h +++ b/Framework/Crystal/inc/MantidCrystal/ClearUB.h @@ -45,6 +45,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "HasUB"}; + } const std::string category() const override; protected: diff --git a/Framework/Crystal/inc/MantidCrystal/CombinePeaksWorkspaces.h b/Framework/Crystal/inc/MantidCrystal/CombinePeaksWorkspaces.h index b72fb786fdaa70fc009d2b13e0e1fe47a717dae4..150268c2eff02e50bb2121ca6760bd1de0b59a77 100644 --- a/Framework/Crystal/inc/MantidCrystal/CombinePeaksWorkspaces.h +++ b/Framework/Crystal/inc/MantidCrystal/CombinePeaksWorkspaces.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreatePeaksWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/CountReflections.h b/Framework/Crystal/inc/MantidCrystal/CountReflections.h index bf1a72a7f0a77e00faf7172980ead02471873238..b06c2af7705e0951ff1c7e818c88bb251b910be9 100644 --- a/Framework/Crystal/inc/MantidCrystal/CountReflections.h +++ b/Framework/Crystal/inc/MantidCrystal/CountReflections.h @@ -41,6 +41,9 @@ class DLLExport CountReflections : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PredictPeaks", "SortHKL"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/Crystal/inc/MantidCrystal/DiffPeaksWorkspaces.h b/Framework/Crystal/inc/MantidCrystal/DiffPeaksWorkspaces.h index ac57e4c18d49f49682267db52aad413831508d12..f725a968f4416452868ff3499e93006c1abc7ba1 100644 --- a/Framework/Crystal/inc/MantidCrystal/DiffPeaksWorkspaces.h +++ b/Framework/Crystal/inc/MantidCrystal/DiffPeaksWorkspaces.h @@ -41,6 +41,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreatePeaksWorkspace", "CombinePeaksWorkspaces"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/FilterPeaks.h b/Framework/Crystal/inc/MantidCrystal/FilterPeaks.h index ca4816edd601a0ced44f11abd08020f1c552fb83..579d3225477883c9140ba5ee17dbddc53e56e2b9 100644 --- a/Framework/Crystal/inc/MantidCrystal/FilterPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FilterPeaks.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreatePeaksWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/FindClusterFaces.h b/Framework/Crystal/inc/MantidCrystal/FindClusterFaces.h index 6951b5625dc84de7e3a94ac77534de11cda9840a..5431772a914a403833ab3c3644378872de5406a8 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindClusterFaces.h +++ b/Framework/Crystal/inc/MantidCrystal/FindClusterFaces.h @@ -40,6 +40,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksUsingClusters"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h index f3f4a60123a27239582557130bf737f958bc151b..6c9e8db9866753046087c94649ea3994d6d85b2b 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FindSXPeaks.h @@ -64,6 +64,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"IndexSXPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Peaks;Optimization\\PeakFinding"; diff --git a/Framework/Crystal/inc/MantidCrystal/FindSXPeaksHelper.h b/Framework/Crystal/inc/MantidCrystal/FindSXPeaksHelper.h index 83c03c8fc5f103a00c2cc49e1f142e3e52301e0f..e021920f5c8ee9f3d7f1af280ce54bbc7c6a566f 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindSXPeaksHelper.h +++ b/Framework/Crystal/inc/MantidCrystal/FindSXPeaksHelper.h @@ -122,6 +122,7 @@ private: * ------------------------------------------------------------------------------------------ */ struct DLLExport BackgroundStrategy { + virtual ~BackgroundStrategy() = default; virtual bool isBelowBackground(const double intensity, const HistogramData::HistogramY &y) const = 0; }; @@ -155,6 +156,7 @@ public: const double minValue = EMPTY_DBL(), const double maxValue = EMPTY_DBL(), const XAxisUnit units = XAxisUnit::TOF); + virtual ~PeakFindingStrategy() = default; PeakList findSXPeaks(const HistogramData::HistogramX &x, const HistogramData::HistogramY &y, const int workspaceIndex) const; @@ -219,6 +221,7 @@ private: */ class DLLExport CompareStrategy { public: + virtual ~CompareStrategy() = default; virtual bool compare(const SXPeak &lhs, const SXPeak &rhs) const = 0; }; @@ -253,6 +256,7 @@ private: class DLLExport ReducePeakListStrategy { public: ReducePeakListStrategy(const CompareStrategy *compareStrategy); + virtual ~ReducePeakListStrategy() = default; virtual std::vector<SXPeak> reduce(const std::vector<SXPeak> &peaks, Mantid::Kernel::ProgressBase &progress) const = 0; diff --git a/Framework/Crystal/inc/MantidCrystal/FindUBUsingFFT.h b/Framework/Crystal/inc/MantidCrystal/FindUBUsingFFT.h index 91351b5cbcf2c825567fbad5da3f1c995c7ce9f0..1850af09c1423d0161983d691665b622088303f5 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindUBUsingFFT.h +++ b/Framework/Crystal/inc/MantidCrystal/FindUBUsingFFT.h @@ -40,6 +40,10 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "FindUBUsingIndexedPeaks", "FindUBUsingLatticeParameters", + "FindUBUsingMinMaxD"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h b/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h index a50d04231a88d7a782ff27abc6c6431f40807894..4d7456eefd8b7305edc0ea3130c58b294ab0d351 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/FindUBUsingIndexedPeaks.h @@ -41,6 +41,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "FindUBUsingFFT", "FindUBUsingLatticeParameters", + "FindUBUsingMinMaxD"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\UBMatrix"; } diff --git a/Framework/Crystal/inc/MantidCrystal/FindUBUsingLatticeParameters.h b/Framework/Crystal/inc/MantidCrystal/FindUBUsingLatticeParameters.h index dc8eebab33015d1b5cf2c85e76db846ea74efa4d..1cb69eba444ea677381a57097432dbd9821f542b 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindUBUsingLatticeParameters.h +++ b/Framework/Crystal/inc/MantidCrystal/FindUBUsingLatticeParameters.h @@ -43,6 +43,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingMinMaxD"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\UBMatrix"; } diff --git a/Framework/Crystal/inc/MantidCrystal/FindUBUsingMinMaxD.h b/Framework/Crystal/inc/MantidCrystal/FindUBUsingMinMaxD.h index 49ae0c5435529232c555d89283262fb16d9d649a..d62b5093268266408642bb66a605329808c7e4fc 100644 --- a/Framework/Crystal/inc/MantidCrystal/FindUBUsingMinMaxD.h +++ b/Framework/Crystal/inc/MantidCrystal/FindUBUsingMinMaxD.h @@ -45,6 +45,10 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Crystal/inc/MantidCrystal/GoniometerAnglesFromPhiRotation.h b/Framework/Crystal/inc/MantidCrystal/GoniometerAnglesFromPhiRotation.h index a15567c4e641725a25ff012b8315faa48f097e16..5365e4828283f74b50bb350dd2de1831efec0f87 100644 --- a/Framework/Crystal/inc/MantidCrystal/GoniometerAnglesFromPhiRotation.h +++ b/Framework/Crystal/inc/MantidCrystal/GoniometerAnglesFromPhiRotation.h @@ -56,6 +56,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SetGoniometer"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Goniometer"; } diff --git a/Framework/Crystal/inc/MantidCrystal/HasUB.h b/Framework/Crystal/inc/MantidCrystal/HasUB.h index 0b4ae3cb02b6af0a127ecff759059858f0ff39de..4937aebd190231c2b379671e34f61e5e6a9edf26 100644 --- a/Framework/Crystal/inc/MantidCrystal/HasUB.h +++ b/Framework/Crystal/inc/MantidCrystal/HasUB.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SetUB", "ClearUB"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/IndexPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexPeaks.h index b205ac8cbfe818e7bab25ea71de957cfc1e128ca..792114abb63ca28ec0edb4fc808a5d76824870b4 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexPeaks.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"IndexSXPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h index bb7a92f68c9de6772634f8ec7a904cd75f01817a..df864e4f7a2ab452d37e2d6a611cae285ce2d126 100644 --- a/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/IndexSXPeaks.h @@ -163,6 +163,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"IndexPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h index 837aeff6fe7a15b0ad06380ed28bddc03c429f59..da247e5f06cb6f13e423d84c4c76fafc4ac46c19 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeakTimeSlices.h @@ -245,6 +245,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"PeakIntegration"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Integration"; } diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeaksHybrid.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeaksHybrid.h index cfce138cd8a98be533b099ae2e3616c09e0a7cc7..0330ce088f6dc2e0069c3c118c93fa127869a26b 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeaksHybrid.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeaksHybrid.h @@ -34,6 +34,10 @@ class DLLExport IntegratePeaksHybrid : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksUsingClusters", "IntegratePeaksMDHKL", + "IntegratePeaksMD", "IntegratePeaksCWSD"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/IntegratePeaksUsingClusters.h b/Framework/Crystal/inc/MantidCrystal/IntegratePeaksUsingClusters.h index 1b6615135f267b9c744c15dad89786b6543eb52c..85bdca7257a72d4d6ec28bf36f51a7d6361ad09a 100644 --- a/Framework/Crystal/inc/MantidCrystal/IntegratePeaksUsingClusters.h +++ b/Framework/Crystal/inc/MantidCrystal/IntegratePeaksUsingClusters.h @@ -40,6 +40,10 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksHybrid", "IntegratePeaksMDHKL", "IntegratePeaksMD", + "IntegratePeaksCWSD"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/LoadHKL.h b/Framework/Crystal/inc/MantidCrystal/LoadHKL.h index 92842034004dca194e4c06c976e20493686e3b82..80582648ed920362afa2a26fa33344d2994f1d8c 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadHKL.h @@ -27,6 +27,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveHKL"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Text"; diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h index 7352a0a069f701b56e59051f7d8a4c1e5f54ea3f..3292dc08c389206083c119161e7e2153219f06f3 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawPeaks.h @@ -29,6 +29,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveIsawPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawSpectrum.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawSpectrum.h index 09c220e8fc72bce4ae230a69af1b042a76855d09..5e6289b756e1b3bb686da7a334a5e14ab6828612 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawSpectrum.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawSpectrum.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveIsawPeaks", "SaveIsawUB"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Text"; diff --git a/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h b/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h index 6b0835fca4ccc7a421b7ced9e3e780af29c34e3d..00c86fc298c2fc416e9669da1f781b84a8cb46fb 100644 --- a/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h +++ b/Framework/Crystal/inc/MantidCrystal/LoadIsawUB.h @@ -26,6 +26,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveIsawUB"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Isaw"; diff --git a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h index 018fb73a50b6a332dd6179f8c9888bc9f1ce8cf7..afe832b53da3afa8d9b367d92c14f4b9f6977e91 100644 --- a/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/MaskPeaksWorkspace.h @@ -45,6 +45,9 @@ public: const std::string name() const override { return "MaskPeaksWorkspace"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CreatePeaksWorkspace"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Crystal/inc/MantidCrystal/OptimizeLatticeForCellType.h b/Framework/Crystal/inc/MantidCrystal/OptimizeLatticeForCellType.h index 5f11c2f9dc6e0f57dbd7c6f65946f2b10a6aea12..6a96a5e364c242899d59091d15668f6da18beb21 100644 --- a/Framework/Crystal/inc/MantidCrystal/OptimizeLatticeForCellType.h +++ b/Framework/Crystal/inc/MantidCrystal/OptimizeLatticeForCellType.h @@ -55,6 +55,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Cell"; } diff --git a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h index 548d9238aa017be2efaa11fb2fa4336c9dfe09b6..5801c136b27791850257a9f9289379655f9d5d35 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakIntegration.h @@ -43,6 +43,9 @@ public: const std::string name() const override { return "PeakIntegration"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeakTimeSlices", "CentroidPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Crystal\\Integration"; } /// Summary of algorithms purpose diff --git a/Framework/Crystal/inc/MantidCrystal/PeakIntensityVsRadius.h b/Framework/Crystal/inc/MantidCrystal/PeakIntensityVsRadius.h index 22526c5a707cd4ccca7d2249c5d9d26c25370ed3..5991e2db6c612649dfd5fa2011de054b951597b6 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakIntensityVsRadius.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakIntensityVsRadius.h @@ -41,6 +41,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PeakIntegration"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/PeakStatisticsTools.h b/Framework/Crystal/inc/MantidCrystal/PeakStatisticsTools.h index 29e46581d4ca976a058354f0bdb0f5446da117a1..f3c426200421b82633ab26691e119263333dc673 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeakStatisticsTools.h +++ b/Framework/Crystal/inc/MantidCrystal/PeakStatisticsTools.h @@ -34,10 +34,12 @@ public: const std::vector<DataObjects::Peak> &getPeaks() const { return m_peaks; } size_t count() const { return m_peaks.size(); } + std::vector<double> getWavelengths() const; std::vector<double> getIntensities() const; std::vector<double> getSigmas() const; - UniqueReflection removeOutliers(double sigmaCritical = 3.0) const; + UniqueReflection removeOutliers(double sigmaCritical = 3.0, + bool weightedZ = false) const; void setPeaksIntensityAndSigma(double intensity, double sigma); private: @@ -109,7 +111,21 @@ public: m_redundancy(0.0), m_rMerge(0.0), m_rPim(0.0), m_meanIOverSigma(0.0), m_dspacingMin(0.0), m_dspacingMax(0.0), m_chiSquared(0.0), m_peaks() { m_peaks.reserve(reflections.getObservedReflectionCount()); - calculatePeaksStatistics(reflections.getReflections()); + std::string equivalentIntensities = "Mean"; + double sigmaCritical = 3.0; + bool weightedZ = false; + calculatePeaksStatistics(reflections.getReflections(), + equivalentIntensities, sigmaCritical, weightedZ); + } + explicit PeaksStatistics(const UniqueReflectionCollection &reflections, + std::string &equivalentIntensities, + double &sigmaCritical, bool &weightedZ) + : m_measuredReflections(0), m_uniqueReflections(0), m_completeness(0.0), + m_redundancy(0.0), m_rMerge(0.0), m_rPim(0.0), m_meanIOverSigma(0.0), + m_dspacingMin(0.0), m_dspacingMax(0.0), m_chiSquared(0.0), m_peaks() { + m_peaks.reserve(reflections.getObservedReflectionCount()); + calculatePeaksStatistics(reflections.getReflections(), + equivalentIntensities, sigmaCritical, weightedZ); } /// Total number of observed reflections - no symmetry is taken into @@ -152,7 +168,9 @@ public: private: void calculatePeaksStatistics( - const std::map<Kernel::V3D, UniqueReflection> &uniqueReflections); + const std::map<Kernel::V3D, UniqueReflection> &uniqueReflections, + std::string &equivalentIntensities, double &sigmaCritical, + bool &weightedZ); double getIOverSigmaSum(const std::vector<double> &sigmas, const std::vector<double> &intensities) const; diff --git a/Framework/Crystal/inc/MantidCrystal/PeaksInRegion.h b/Framework/Crystal/inc/MantidCrystal/PeaksInRegion.h index 7d703d788f64e65335d8b8ff29658c1a99e27012..59bc599256f06894bc8bd84053f93c12d23695f6 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeaksInRegion.h +++ b/Framework/Crystal/inc/MantidCrystal/PeaksInRegion.h @@ -39,6 +39,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PeaksOnSurface"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/PeaksOnSurface.h b/Framework/Crystal/inc/MantidCrystal/PeaksOnSurface.h index ecd75678effa12dae5d9f01cdf7f35684639dd26..a156efcb55de0a398d6daf997f7d9209961359cc 100644 --- a/Framework/Crystal/inc/MantidCrystal/PeaksOnSurface.h +++ b/Framework/Crystal/inc/MantidCrystal/PeaksOnSurface.h @@ -41,6 +41,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PeaksInRegion"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/PredictFractionalPeaks.h b/Framework/Crystal/inc/MantidCrystal/PredictFractionalPeaks.h index 3a2c319f1a456c6232e94af0b0ded1eac4c666e4..03142b147140a65b0e984bb70b481d1290d00fb3 100644 --- a/Framework/Crystal/inc/MantidCrystal/PredictFractionalPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/PredictFractionalPeaks.h @@ -47,6 +47,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"PredictPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks"; } diff --git a/Framework/Crystal/inc/MantidCrystal/PredictPeaks.h b/Framework/Crystal/inc/MantidCrystal/PredictPeaks.h index 922a6ad9ab78a4b6f2b7365920979482134d4df2..a4a61759f7d1a7bc1ecc6ad208f1f40fbcaa69d6 100644 --- a/Framework/Crystal/inc/MantidCrystal/PredictPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/PredictPeaks.h @@ -39,6 +39,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"CountReflections", "PredictFractionalPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks"; } @@ -64,7 +67,8 @@ private: void calculateQAndAddToOutput(const Kernel::V3D &hkl, const Kernel::DblMatrix &orientedUB, - const Kernel::DblMatrix &goniometerMatrix); + const Kernel::DblMatrix &goniometerMatrix, + int &seqNum); private: /// Get the predicted detector direction from Q diff --git a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h index b95ca3f7276d8abd1aef5e6038d497af6ef23b9c..541fa748f8e2378da555ff82b2a1db0814e01257 100644 --- a/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h +++ b/Framework/Crystal/inc/MantidCrystal/SCDCalibratePanels.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalculateUMatrix"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override; diff --git a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h index 392e2d0484dffa483605bc876031fca669346d42..f258a559c17b5ab13e7578beca928231fbafd803 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveHKL.h @@ -25,6 +25,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadHKL"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Text"; diff --git a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h index df8d19a4f3fc626e9da5ea978e1880b8f39a7575..094005a25e2bc59e103bc3ab25753cac72483be7 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveIsawPeaks.h @@ -30,6 +30,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadIsawPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Isaw"; diff --git a/Framework/Crystal/inc/MantidCrystal/SaveIsawUB.h b/Framework/Crystal/inc/MantidCrystal/SaveIsawUB.h index f80f316859d5184dd085e3842d215d1269c3afc7..a1beabf73d0341828b7ec51d785e71ff192f7065 100644 --- a/Framework/Crystal/inc/MantidCrystal/SaveIsawUB.h +++ b/Framework/Crystal/inc/MantidCrystal/SaveIsawUB.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadIsawUB"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\DataHandling;DataHandling\\Isaw"; diff --git a/Framework/Crystal/inc/MantidCrystal/SelectCellOfType.h b/Framework/Crystal/inc/MantidCrystal/SelectCellOfType.h index fbe9134f074dc20c1c8e63b8062f6a0787db0101..1e448ee097ba8dc5b392c62be72b69a601b4e1ed 100644 --- a/Framework/Crystal/inc/MantidCrystal/SelectCellOfType.h +++ b/Framework/Crystal/inc/MantidCrystal/SelectCellOfType.h @@ -43,6 +43,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Cell"; } diff --git a/Framework/Crystal/inc/MantidCrystal/SelectCellWithForm.h b/Framework/Crystal/inc/MantidCrystal/SelectCellWithForm.h index a6b4a6f01d64fa8dce9a783fa0975f9bab4824bd..2254043d5c438c0af70b766746679fe1fb43fea1 100644 --- a/Framework/Crystal/inc/MantidCrystal/SelectCellWithForm.h +++ b/Framework/Crystal/inc/MantidCrystal/SelectCellWithForm.h @@ -44,6 +44,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Cell"; } diff --git a/Framework/Crystal/inc/MantidCrystal/SetGoniometer.h b/Framework/Crystal/inc/MantidCrystal/SetGoniometer.h index 817b2e7af432d785b06afd26fca9e9c85ff8776d..c48931dc6b830eec7e4c6dd6ec0b8159b3d02f92 100644 --- a/Framework/Crystal/inc/MantidCrystal/SetGoniometer.h +++ b/Framework/Crystal/inc/MantidCrystal/SetGoniometer.h @@ -25,6 +25,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"GoniometerAnglesFromPhiRotation"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Goniometer"; } diff --git a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h index 6104fcc75d2fe9e79cfef375cb3b0d228fdcfe46..5a271da941ca64e8203f4bf0c49705659ad826b2 100644 --- a/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h +++ b/Framework/Crystal/inc/MantidCrystal/SetSpecialCoordinates.h @@ -48,6 +48,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD", "ConvertToDiffractionMDWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/SetUB.h b/Framework/Crystal/inc/MantidCrystal/SetUB.h index 481137668a9b8be23f4622fd26682e947ae114a9..6c105fe4681d0c678ee762d0c29d9f67043eb398 100644 --- a/Framework/Crystal/inc/MantidCrystal/SetUB.h +++ b/Framework/Crystal/inc/MantidCrystal/SetUB.h @@ -46,6 +46,10 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters", "FindUBUsingMinMaxD"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/ShowPeakHKLOffsets.h b/Framework/Crystal/inc/MantidCrystal/ShowPeakHKLOffsets.h index 1787aa59cfc6edc4e05856ce0fdc0c609d2164f4..368de1c811cbedc6773c2422d965efc71968d79d 100644 --- a/Framework/Crystal/inc/MantidCrystal/ShowPeakHKLOffsets.h +++ b/Framework/Crystal/inc/MantidCrystal/ShowPeakHKLOffsets.h @@ -53,6 +53,9 @@ public: } int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"StatisticsOfPeaksWorkspace"}; + } const std::string category() const override { return "Crystal\\Peaks"; }; diff --git a/Framework/Crystal/inc/MantidCrystal/ShowPossibleCells.h b/Framework/Crystal/inc/MantidCrystal/ShowPossibleCells.h index d890f6cac205f038cedf09525b5b0bfe09e656bf..977cbaa4e2cfd5bf1b7c55f9cf4f055c74544eed 100644 --- a/Framework/Crystal/inc/MantidCrystal/ShowPossibleCells.h +++ b/Framework/Crystal/inc/MantidCrystal/ShowPossibleCells.h @@ -43,6 +43,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"FindUBUsingFFT", "FindUBUsingIndexedPeaks", + "FindUBUsingLatticeParameters"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Cell"; } diff --git a/Framework/Crystal/inc/MantidCrystal/SortHKL.h b/Framework/Crystal/inc/MantidCrystal/SortHKL.h index f2a72e51f2a684dfc686d3f140d3be196c3d979d..ba95a470fd5087c970d6b1fd7a367a13256566a2 100644 --- a/Framework/Crystal/inc/MantidCrystal/SortHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/SortHKL.h @@ -41,9 +41,12 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"TransformHKL"}; + } /// Algorithm's category for identification const std::string category() const override { - return "Crystal\\Peaks;DataHandling\\Text;Utility\\Sorting"; + return R"(Crystal\Peaks;DataHandling\Text;Utility\Sorting)"; } private: diff --git a/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h index 27f8e9d5f13e927c20d46ed38eae6b6437a4bdd3..78034d3109244f23511beed431183d1406ff1d62 100644 --- a/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/SortPeaksWorkspace.h @@ -41,6 +41,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreatePeaksWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h index dae2543c1f6df4ba180ae4d6770335ddd4141295..baa26ff154923aa21399e60752e117ecd2b70a91 100644 --- a/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h +++ b/Framework/Crystal/inc/MantidCrystal/StatisticsOfPeaksWorkspace.h @@ -28,6 +28,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ShowPeakHKLOffsets"}; + } /// Algorithm's category for identification const std::string category() const override { return "Crystal\\Peaks;DataHandling\\Text"; diff --git a/Framework/Crystal/inc/MantidCrystal/TransformHKL.h b/Framework/Crystal/inc/MantidCrystal/TransformHKL.h index 5b8dd122cff92012d4c1e5690c29e5b86cc897fb..2c174d2fe1f7736e24e0412df11c37b48cdb31c4 100644 --- a/Framework/Crystal/inc/MantidCrystal/TransformHKL.h +++ b/Framework/Crystal/inc/MantidCrystal/TransformHKL.h @@ -41,6 +41,9 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SortHKL"}; + } /// Algorithm's category for identification const std::string category() const override; diff --git a/Framework/Crystal/src/ConnectedComponentLabeling.cpp b/Framework/Crystal/src/ConnectedComponentLabeling.cpp index 327fb52ffb01e74580a7a8857b947e6993af706b..e4117ccdf0362383b6b52abe100be4ee1e2ea7be 100644 --- a/Framework/Crystal/src/ConnectedComponentLabeling.cpp +++ b/Framework/Crystal/src/ConnectedComponentLabeling.cpp @@ -288,9 +288,7 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( const int nThreadsToUse = getNThreads(); if (nThreadsToUse > 1) { - std::vector<API::IMDIterator *> iterators = - ws->createIterators(nThreadsToUse); - + auto iterators = ws->createIterators(nThreadsToUse); const size_t maxClustersPossible = calculateMaxClusters(ws.get(), nThreadsToUse); @@ -303,7 +301,7 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( g_log.debug("Parallel solve local CCL"); // PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < nThreadsToUse; ++i) { - API::IMDIterator *iterator = iterators[i]; + API::IMDIterator *iterator = iterators[i].get(); boost::scoped_ptr<BackgroundStrategy> strategy( baseStrategy->clone()); // local strategy VecEdgeIndexPair &edgeVec = parallelEdgeVec[i]; // local edge indexes @@ -364,12 +362,12 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( clusterMap = clusterRegister.clusters(neighbourElements); } else { - API::IMDIterator *iterator = ws->createIterator(nullptr); + auto iterator = ws->createIterator(nullptr); VecEdgeIndexPair edgeIndexPair; // This should never get filled in a single // threaded situation. size_t endLabelId = doConnectedComponentLabeling( - iterator, baseStrategy, neighbourElements, progress, maxNeighbours, - m_startId, edgeIndexPair); + iterator.get(), baseStrategy, neighbourElements, progress, + maxNeighbours, m_startId, edgeIndexPair); // Create clusters from labels. for (size_t labelId = m_startId; labelId != endLabelId; ++labelId) { @@ -383,7 +381,7 @@ ClusterMap ConnectedComponentLabeling::calculateDisjointTree( iterator->jumpTo(0); // Reset do { const size_t currentIndex = iterator->getLinearIndex(); - if (!baseStrategy->isBackground(iterator)) { + if (!baseStrategy->isBackground(iterator.get())) { const int labelAtIndex = neighbourElements[currentIndex].getRoot(); clusterMap[labelAtIndex]->addIndex(currentIndex); } diff --git a/Framework/Crystal/src/FindClusterFaces.cpp b/Framework/Crystal/src/FindClusterFaces.cpp index c5bad728f4d7260da22687658aeec9cbdb7be2c2..0cfe98c93e987aae2285d0edbaebcb7bd71f3d8d 100644 --- a/Framework/Crystal/src/FindClusterFaces.cpp +++ b/Framework/Crystal/src/FindClusterFaces.cpp @@ -331,7 +331,7 @@ void FindClusterFaces::exec() { for (int it = 0; it < nIterators; ++it) { PARALLEL_START_INTERUPT_REGION ClusterFaces &localClusterFaces = clusterFaces[it]; - auto mdIterator = mdIterators[it]; + auto mdIterator = mdIterators[it].get(); if (usingFiltering) { executeFiltered(mdIterator, localClusterFaces, progress, clusterImage, diff --git a/Framework/Crystal/src/LoadHKL.cpp b/Framework/Crystal/src/LoadHKL.cpp index a629fc879488406df9ab26d2cf5686d775a61e20..666562eac9ae71b0910296b9a72c2b5160f4aaf0 100644 --- a/Framework/Crystal/src/LoadHKL.cpp +++ b/Framework/Crystal/src/LoadHKL.cpp @@ -85,16 +85,19 @@ void LoadHKL::exec() { double wl = std::stod(line.substr(32, 8)); double tbar, trans, scattering; int run, bank; + int seqNum; if (cosines) { tbar = std::stod(line.substr(40, 8)); // tbar run = std::stoi(line.substr(102, 6)); trans = std::stod(line.substr(114, 7)); // transmission + seqNum = std::stoi(line.substr(109, 7)); bank = std::stoi(line.substr(121, 4)); scattering = std::stod(line.substr(125, 9)); } else { tbar = std::stod(line.substr(40, 7)); // tbar run = std::stoi(line.substr(47, 7)); trans = std::stod(line.substr(61, 7)); // transmission + seqNum = std::stoi(line.substr(54, 7)); bank = std::stoi(line.substr(68, 4)); scattering = std::stod(line.substr(72, 9)); } @@ -115,6 +118,7 @@ void LoadHKL::exec() { peak.setIntensity(Inti); peak.setSigmaIntensity(SigI); peak.setRunNumber(run); + peak.setPeakNumber(seqNum); std::ostringstream oss; oss << "bank" << bank; std::string bankName = oss.str(); diff --git a/Framework/Crystal/src/LoadIsawPeaks.cpp b/Framework/Crystal/src/LoadIsawPeaks.cpp index 194e3125fea904e5bdc1a8a6faadb9ac5dd4736e..db2f3a2998b0b6dbc353954c1c70101da9664465 100644 --- a/Framework/Crystal/src/LoadIsawPeaks.cpp +++ b/Framework/Crystal/src/LoadIsawPeaks.cpp @@ -213,8 +213,8 @@ std::string LoadIsawPeaks::readHeader(PeaksWorkspace_sptr outWS, boost::erase_all(bankName, bankPart); int bank = 0; Strings::convert(bankName, bank); - for (size_t j = 0; j < det.size(); j++) { - if (bank == det[j]) { + for (int j : det) { + if (bank == j) { bank = 0; continue; } @@ -268,8 +268,6 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, double Inti; double SigI; - seqNum = -1; - std::string s = lastStr; if (s.length() < 1 && in.good()) // blank line @@ -334,6 +332,7 @@ DataObjects::Peak LoadIsawPeaks::readPeak(PeaksWorkspace_sptr outWS, peak.setIntensity(Inti); peak.setSigmaIntensity(SigI); peak.setBinCount(IPK); + peak.setPeakNumber(seqNum); // Return the peak return peak; } @@ -488,7 +487,7 @@ void LoadIsawPeaks::appendFile(PeaksWorkspace_sptr outWS, oss << bankString << bankNum; std::string bankName = oss.str(); - int seqNum = -1; + int seqNum; try { // Read the peak diff --git a/Framework/Crystal/src/PeakStatisticsTools.cpp b/Framework/Crystal/src/PeakStatisticsTools.cpp index bf1d288c6a2f3b0afad7143c076fca9a575d3913..be199079e7e902278585080dd166f15aa84e3699 100644 --- a/Framework/Crystal/src/PeakStatisticsTools.cpp +++ b/Framework/Crystal/src/PeakStatisticsTools.cpp @@ -16,6 +16,19 @@ using namespace Mantid::DataObjects; using namespace Mantid::Geometry; using namespace Mantid::Kernel; +/// Returns a vector with the wavelengths of the Peaks stored in this +/// reflection. +std::vector<double> UniqueReflection::getWavelengths() const { + std::vector<double> wavelengths; + wavelengths.reserve(m_peaks.size()); + + std::transform( + m_peaks.begin(), m_peaks.end(), std::back_inserter(wavelengths), + [](const DataObjects::Peak &peak) { return peak.getWavelength(); }); + + return wavelengths; +} + /// Returns a vector with the intensities of the Peaks stored in this /// reflection. std::vector<double> UniqueReflection::getIntensities() const { @@ -44,7 +57,8 @@ std::vector<double> UniqueReflection::getSigmas() const { /// Removes peaks whose intensity deviates more than sigmaCritical from the /// intensities' mean. -UniqueReflection UniqueReflection::removeOutliers(double sigmaCritical) const { +UniqueReflection UniqueReflection::removeOutliers(double sigmaCritical, + bool weightedZ) const { if (sigmaCritical <= 0.0) { throw std::invalid_argument( "Critical sigma value has to be greater than 0."); @@ -54,7 +68,13 @@ UniqueReflection UniqueReflection::removeOutliers(double sigmaCritical) const { if (m_peaks.size() > 2) { auto intensities = getIntensities(); - auto zScores = Kernel::getZscore(intensities); + std::vector<double> zScores; + if (!weightedZ) { + zScores = Kernel::getZscore(intensities); + } else { + auto sigmas = getSigmas(); + zScores = Kernel::getWeightedZscore(intensities, sigmas); + } for (size_t i = 0; i < zScores.size(); ++i) { if (zScores[i] <= sigmaCritical) { @@ -196,9 +216,15 @@ UniqueReflectionCollection::getReflections() const { * group of equivalent reflections. * * @param uniqueReflections :: Map of unique reflections and peaks. + * @param equivalentIntensities :: Mean or median for statistics of equivalent + *peaks. + * @param sigmaCritical :: Number of standard deviations for outliers. + * @param weightedZ :: True for weighted Zscore */ void PeaksStatistics::calculatePeaksStatistics( - const std::map<V3D, UniqueReflection> &uniqueReflections) { + const std::map<V3D, UniqueReflection> &uniqueReflections, + std::string &equivalentIntensities, double &sigmaCritical, + bool &weightedZ) { double rMergeNumerator = 0.0; double rPimNumerator = 0.0; double intensitySumRValues = 0.0; @@ -212,7 +238,8 @@ void PeaksStatistics::calculatePeaksStatistics( ++m_uniqueReflections; // Possibly remove outliers. - auto outliersRemoved = unique.second.removeOutliers(); + auto outliersRemoved = + unique.second.removeOutliers(sigmaCritical, weightedZ); // I/sigma is calculated for all reflections, even if there is only one // observation. @@ -225,9 +252,12 @@ void PeaksStatistics::calculatePeaksStatistics( if (outliersRemoved.count() > 1) { // Get mean, standard deviation for intensities auto intensityStatistics = Kernel::getStatistics( - intensities, StatOptions::Mean | StatOptions::UncorrectedStdDev); + intensities, StatOptions::Mean | StatOptions::UncorrectedStdDev | + StatOptions::Median); double meanIntensity = intensityStatistics.mean; + if (equivalentIntensities == "Median") + meanIntensity = intensityStatistics.median; /* This was in the original algorithm, not entirely sure where it is * used. It's basically the sum of all relative standard deviations. diff --git a/Framework/Crystal/src/PredictPeaks.cpp b/Framework/Crystal/src/PredictPeaks.cpp index 5dec60e24ced90c773d60e183c74ae2ea16c235c..26a76731256ca2ff7affdfaf5b4f9872ad77e647 100644 --- a/Framework/Crystal/src/PredictPeaks.cpp +++ b/Framework/Crystal/src/PredictPeaks.cpp @@ -274,6 +274,7 @@ void PredictPeaks::exec() { HKLFilterWavelength lambdaFilter(orientedUB, lambdaMin, lambdaMax); size_t allowedPeakCount = 0; + int seqNum = 1; bool useExtendedDetectorSpace = getProperty("PredictPeaksOutsideDetectors"); if (useExtendedDetectorSpace && @@ -284,8 +285,9 @@ void PredictPeaks::exec() { for (auto &possibleHKL : possibleHKLs) { if (lambdaFilter.isAllowed(possibleHKL)) { + calculateQAndAddToOutput(possibleHKL, orientedUB, goniometerMatrix, + seqNum); ++allowedPeakCount; - calculateQAndAddToOutput(possibleHKL, orientedUB, goniometerMatrix); } prog.report(); } @@ -471,10 +473,12 @@ void PredictPeaks::setStructureFactorCalculatorFromSample( * @param hkl * @param orientedUB * @param goniometerMatrix + * @param seqNum */ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl, const DblMatrix &orientedUB, - const DblMatrix &goniometerMatrix) { + const DblMatrix &goniometerMatrix, + int &seqNum) { // The q-vector direction of the peak is = goniometer * ub * hkl_vector // This is in inelastic convention: momentum transfer of the LATTICE! // Also, q does have a 2pi factor = it is equal to 2pi/wavelength. @@ -535,6 +539,8 @@ void PredictPeaks::calculateQAndAddToOutput(const V3D &hkl, // Save the run number found before. peak->setRunNumber(m_runNumber); peak->setHKL(hkl * m_qConventionFactor); + peak->setPeakNumber(seqNum); + seqNum++; if (m_sfCalculator) { peak->setIntensity(m_sfCalculator->getFSquared(hkl)); diff --git a/Framework/Crystal/src/SCDCalibratePanels.cpp b/Framework/Crystal/src/SCDCalibratePanels.cpp index 7ec8c15ed7bb0b02ff291f07d4975c043887fa60..be3bd66cf023288475cbe10d1eeb676070260bdb 100644 --- a/Framework/Crystal/src/SCDCalibratePanels.cpp +++ b/Framework/Crystal/src/SCDCalibratePanels.cpp @@ -102,9 +102,9 @@ void SCDCalibratePanels::exec() { std::vector<std::string> parameter_workspaces( MyBankNames.size() + MyPanels.size(), "params_"); int i = 0; - for (auto iBank = MyPanels.begin(); iBank != MyPanels.end(); ++iBank) { - fit_workspaces[i] += *iBank; - parameter_workspaces[i] += *iBank; + for (auto &MyPanel : MyPanels) { + fit_workspaces[i] += MyPanel; + parameter_workspaces[i] += MyPanel; i++; } if (snapPanels) { @@ -122,9 +122,9 @@ void SCDCalibratePanels::exec() { << " degrees\n"; } - for (auto iBank = MyBankNames.begin(); iBank != MyBankNames.end(); ++iBank) { - fit_workspaces[i] += *iBank; - parameter_workspaces[i] += *iBank; + for (auto &MyBankName : MyBankNames) { + fit_workspaces[i] += MyBankName; + parameter_workspaces[i] += MyBankName; i++; } if (bankPanels) { @@ -601,9 +601,9 @@ void SCDCalibratePanels::saveXmlFile( else scaley = 1.; - oss3 << " <parameter name =\"scalex\"><value val=\"" << scalex + oss3 << R"( <parameter name ="scalex"><value val=")" << scalex << "\" /> </parameter>\n"; - oss3 << " <parameter name =\"scaley\"><value val=\"" << scaley + oss3 << R"( <parameter name ="scaley"><value val=")" << scaley << "\" /> </parameter>\n"; oss3 << "</component-link>\n"; } // for each bank in the group diff --git a/Framework/Crystal/src/SaveHKL.cpp b/Framework/Crystal/src/SaveHKL.cpp index 42043c5f354587a8bb1855ac6d2010c5273ebd4d..c91416f25c3d8350fc7248107e70a39ab9369cfa 100644 --- a/Framework/Crystal/src/SaveHKL.cpp +++ b/Framework/Crystal/src/SaveHKL.cpp @@ -345,6 +345,7 @@ void SaveHKL::exec() { continue; } int run = p.getRunNumber(); + int seqNum = p.getPeakNumber(); int bank = 0; std::string bankName = p.getBankName(); int nCols, nRows; @@ -546,7 +547,7 @@ void SaveHKL::exec() { out << std::setw(6) << run; - out << std::setw(6) << wi + 1; + out << std::setw(6) << seqNum; out << std::setw(7) << std::fixed << std::setprecision(4) << transmission; diff --git a/Framework/Crystal/src/SaveIsawPeaks.cpp b/Framework/Crystal/src/SaveIsawPeaks.cpp index a50badfca018b97d35a92f4b33026209d02d0962..6cda29d7aa21a8864823d758f1ae21d75852a6cd 100644 --- a/Framework/Crystal/src/SaveIsawPeaks.cpp +++ b/Framework/Crystal/src/SaveIsawPeaks.cpp @@ -259,13 +259,14 @@ void SaveIsawPeaks::exec() { qSign = 1.0; // ============================== Save all Peaks // ========================================= - // Sequence number - int seqNum = 1; // Go in order of run numbers + int maxPeakNumb = 0; + int appendPeakNumb = 0; runMap_t::iterator runMap_it; for (runMap_it = runMap.begin(); runMap_it != runMap.end(); ++runMap_it) { // Start of a new run + appendPeakNumb += maxPeakNumb; int run = runMap_it->first; bankMap_t &bankMap = runMap_it->second; @@ -310,7 +311,8 @@ void SaveIsawPeaks::exec() { Peak &p = peaks[wi]; // Sequence (run) number - out << "3" << std::setw(7) << seqNum; + maxPeakNumb = std::max(maxPeakNumb, p.getPeakNumber()); + out << "3" << std::setw(7) << p.getPeakNumber() + appendPeakNumb; // HKL's are flipped by -1 because of the internal Q convention // unless Crystallography convention @@ -383,8 +385,6 @@ void SaveIsawPeaks::exec() { } } } - // Count the sequence - seqNum++; } } } diff --git a/Framework/Crystal/src/SortHKL.cpp b/Framework/Crystal/src/SortHKL.cpp index 976b92085587fa9522e0648ba9c54735d51e4619..f77708bfa28d97c98529f2a370bf8b6b7e43a1f8 100644 --- a/Framework/Crystal/src/SortHKL.cpp +++ b/Framework/Crystal/src/SortHKL.cpp @@ -1,16 +1,16 @@ #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/FileProperty.h" #include "MantidAPI/Sample.h" - +#include "MantidDataObjects/Workspace2D.h" #include "MantidCrystal/SortHKL.h" - +#include "MantidAPI/WorkspaceFactory.h" #include "MantidDataObjects/Peak.h" #include "MantidDataObjects/PeaksWorkspace.h" - +#include "MantidAPI/TextAxis.h" #include "MantidGeometry/Instrument/RectangularDetector.h" #include "MantidGeometry/Crystal/PointGroupFactory.h" #include "MantidGeometry/Crystal/OrientedLattice.h" - +#include "MantidKernel/UnitFactory.h" #include "MantidKernel/ListValidator.h" #include "MantidKernel/Utils.h" @@ -84,6 +84,22 @@ void SortHKL::init() { declareProperty("Append", false, "Append to output table workspace if true.\n" "If false, new output table workspace (default)."); + std::vector<std::string> equivTypes{"Mean", "Median"}; + declareProperty("EquivalentIntensities", equivTypes[0], + boost::make_shared<StringListValidator>(equivTypes), + "Replace intensities by mean(default), " + "or median."); + declareProperty(Kernel::make_unique<PropertyWithValue<double>>( + "SigmaCritical", 3.0, Direction::Input), + "Removes peaks whose intensity deviates more than " + "SigmaCritical from the mean (or median)."); + declareProperty( + make_unique<WorkspaceProperty<MatrixWorkspace>>( + "EquivalentsWorkspace", "EquivalentIntensities", Direction::Output), + "Output Equivalent Intensities"); + declareProperty("WeightedZScore", false, + "Use weighted ZScore if true.\n" + "If false, standard ZScore (default)."); } void SortHKL::exec() { @@ -101,8 +117,112 @@ void SortHKL::exec() { UniqueReflectionCollection uniqueReflections = getUniqueReflections(peaks, cell); + std::string equivalentIntensities = getPropertyValue("EquivalentIntensities"); + double sigmaCritical = getProperty("SigmaCritical"); + bool weightedZ = getProperty("WeightedZScore"); + + MatrixWorkspace_sptr UniqWksp = + Mantid::API::WorkspaceFactory::Instance().create( + "Workspace2D", uniqueReflections.getReflections().size(), 20, 20); + int counter = 0; + size_t maxPeaks = 0; + auto taxis = new TextAxis(uniqueReflections.getReflections().size()); + UniqWksp->getAxis(0)->unit() = UnitFactory::Instance().create("Wavelength"); + for (const auto &unique : uniqueReflections.getReflections()) { + /* Since all possible unique reflections are explored + * there may be 0 observations for some of them. + * In that case, nothing can be done.*/ + + if (unique.second.count() > 2) { + taxis->setLabel(counter, " " + unique.second.getHKL().toString()); + auto &UniqX = UniqWksp->mutableX(counter); + auto &UniqY = UniqWksp->mutableY(counter); + auto &UniqE = UniqWksp->mutableE(counter); + counter++; + auto wavelengths = unique.second.getWavelengths(); + auto intensities = unique.second.getIntensities(); + g_log.debug() << "HKL " << unique.second.getHKL() << "\n"; + g_log.debug() << "Intensities "; + for (const auto &e : intensities) + g_log.debug() << e << " "; + g_log.debug() << "\n"; + std::vector<double> zScores; + if (!weightedZ) { + zScores = Kernel::getZscore(intensities); + } else { + auto sigmas = unique.second.getSigmas(); + zScores = Kernel::getWeightedZscore(intensities, sigmas); + } + + if (zScores.size() > maxPeaks) + maxPeaks = zScores.size(); + // Possibly remove outliers. + auto outliersRemoved = + unique.second.removeOutliers(sigmaCritical, weightedZ); + + auto intensityStatistics = + Kernel::getStatistics(outliersRemoved.getIntensities(), + StatOptions::Mean | StatOptions::Median); + + g_log.debug() << "Mean = " << intensityStatistics.mean + << " Median = " << intensityStatistics.median << "\n"; + // sort wavelengths & intensities + for (size_t i = 0; i < wavelengths.size(); i++) { + size_t i0 = i; + for (size_t j = i + 1; j < wavelengths.size(); j++) { + if (wavelengths[j] < wavelengths[i0]) // Change was here! + { + i0 = j; + } + } + double temp = wavelengths[i0]; + wavelengths[i0] = wavelengths[i]; + wavelengths[i] = temp; + temp = intensities[i0]; + intensities[i0] = intensities[i]; + intensities[i] = temp; + } + g_log.debug() << "Zscores "; + for (size_t i = 0; i < std::min(zScores.size(), static_cast<size_t>(20)); + ++i) { + UniqX[i] = wavelengths[i]; + UniqY[i] = intensities[i]; + if (zScores[i] > sigmaCritical) + UniqE[i] = intensities[i]; + else if (equivalentIntensities == "Mean") + UniqE[i] = intensityStatistics.mean - intensities[i]; + else + UniqE[i] = intensityStatistics.median - intensities[i]; + g_log.debug() << zScores[i] << " "; + } + for (size_t i = zScores.size(); i < 20; ++i) { + UniqX[i] = wavelengths[zScores.size() - 1]; + UniqY[i] = intensities[zScores.size() - 1]; + UniqE[i] = 0.0; + } + g_log.debug() << "\n"; + } + } + + if (counter > 0) { + MatrixWorkspace_sptr UniqWksp2 = + Mantid::API::WorkspaceFactory::Instance().create("Workspace2D", counter, + maxPeaks, maxPeaks); + for (int64_t i = 0; i < counter; ++i) { + auto &outSpec = UniqWksp2->getSpectrum(i); + const auto &inSpec = UniqWksp->getSpectrum(i); + outSpec.setHistogram(inSpec.histogram()); + // Copy the spectrum number/detector IDs + outSpec.copyInfoFrom(inSpec); + } + UniqWksp2->replaceAxis(1, taxis); + setProperty("EquivalentsWorkspace", UniqWksp2); + } else { + setProperty("EquivalentsWorkspace", UniqWksp); + } - PeaksStatistics peaksStatistics(uniqueReflections); + PeaksStatistics peaksStatistics(uniqueReflections, equivalentIntensities, + sigmaCritical, weightedZ); // Store the statistics for output. const std::string tableName = getProperty("StatisticsTable"); diff --git a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp index fc67fa1e3ebd99c3dbc9cd587475fb186ac66718..3a1351badd3ea597548405cdf5962fbb44023989 100644 --- a/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp +++ b/Framework/Crystal/src/StatisticsOfPeaksWorkspace.cpp @@ -6,6 +6,7 @@ #include "MantidKernel/BoundedValidator.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/ListValidator.h" +#include "MantidDataObjects/Workspace2D.h" #include <fstream> @@ -75,6 +76,22 @@ void StatisticsOfPeaksWorkspace::init() { boost::make_shared<StringListValidator>(sortTypes), "Sort the peaks by resolution shell in d-Spacing(default), " "bank, run number, or only overall statistics."); + std::vector<std::string> equivTypes{"Mean", "Median"}; + declareProperty("EquivalentIntensities", equivTypes[0], + boost::make_shared<StringListValidator>(equivTypes), + "Replace intensities by mean(default), " + "or median."); + declareProperty(Kernel::make_unique<PropertyWithValue<double>>( + "SigmaCritical", 3.0, Direction::Input), + "Removes peaks whose intensity deviates more than " + "SigmaCritical from the mean (or median)."); + declareProperty( + make_unique<WorkspaceProperty<MatrixWorkspace>>( + "EquivalentsWorkspace", "EquivalentIntensities", Direction::Output), + "Output Equivalent Intensities"); + declareProperty("WeightedZScore", false, + "Use weighted ZScore if true.\n" + "If false, standard ZScore (default)."); } //---------------------------------------------------------------------------------------------- @@ -177,6 +194,9 @@ void StatisticsOfPeaksWorkspace::doSortHKL(Mantid::API::Workspace_sptr ws, std::string latticeCentering = getPropertyValue("LatticeCentering"); std::string wkspName = getPropertyValue("OutputWorkspace"); std::string tableName = getPropertyValue("StatisticsTable"); + std::string equivalentIntensities = getPropertyValue("EquivalentIntensities"); + double sigmaCritical = getProperty("SigmaCritical"); + bool weightedZ = getProperty("WeightedZScore"); API::IAlgorithm_sptr statsAlg = createChildAlgorithm("SortHKL"); statsAlg->setProperty("InputWorkspace", ws); statsAlg->setPropertyValue("OutputWorkspace", wkspName); @@ -186,12 +206,17 @@ void StatisticsOfPeaksWorkspace::doSortHKL(Mantid::API::Workspace_sptr ws, statsAlg->setProperty("RowName", runName); if (runName != "Overall") statsAlg->setProperty("Append", true); + statsAlg->setPropertyValue("EquivalentIntensities", equivalentIntensities); + statsAlg->setProperty("SigmaCritical", sigmaCritical); + statsAlg->setProperty("WeightedZScore", weightedZ); statsAlg->executeAsChildAlg(); PeaksWorkspace_sptr statsWksp = statsAlg->getProperty("OutputWorkspace"); ITableWorkspace_sptr tablews = statsAlg->getProperty("StatisticsTable"); + MatrixWorkspace_sptr equivws = statsAlg->getProperty("EquivalentsWorkspace"); if (runName == "Overall") setProperty("OutputWorkspace", statsWksp); setProperty("StatisticsTable", tablews); + setProperty("EquivalentsWorkspace", equivws); } } // namespace Mantid diff --git a/Framework/Crystal/test/ConnectedComponentLabelingTest.h b/Framework/Crystal/test/ConnectedComponentLabelingTest.h index 81beb4d05b422152c0ce2ca58e0470a39968e9da..dc161cfcc893e95b8d09b96e1b004768e78437de 100644 --- a/Framework/Crystal/test/ConnectedComponentLabelingTest.h +++ b/Framework/Crystal/test/ConnectedComponentLabelingTest.h @@ -410,9 +410,8 @@ public: clusterThreeIndexes.end()); // Add elevated signal to the workspace at cluster indexes. - for (auto it = allClusterIndexes.begin(); it != allClusterIndexes.end(); - ++it) { - inWS->setSignalAt(*it, raisedSignal); + for (auto &clusterIndex : allClusterIndexes) { + inWS->setSignalAt(clusterIndex, raisedSignal); } // ---------- Run the cluster finding diff --git a/Framework/Crystal/test/HardThresholdBackgroundTest.h b/Framework/Crystal/test/HardThresholdBackgroundTest.h index 3ba3c728bd0c74cd58939eb77955516fa65ae8cf..5d9566fcb27db74f4636fe95d8df25489e2f0c12 100644 --- a/Framework/Crystal/test/HardThresholdBackgroundTest.h +++ b/Framework/Crystal/test/HardThresholdBackgroundTest.h @@ -23,11 +23,11 @@ public: void test_isBackground() { const double threshold = 1; MDHistoWorkspace_sptr ws = makeFakeMDHistoWorkspace(threshold, 1, 1); - auto iterator = ws->createIterator(NULL); + auto iterator = ws->createIterator(nullptr); HardThresholdBackground strategy(threshold, Mantid::API::NoNormalization); - TS_ASSERT(strategy.isBackground(iterator)); + TS_ASSERT(strategy.isBackground(iterator.get())); } }; diff --git a/Framework/Crystal/test/PeakBackgroundTest.h b/Framework/Crystal/test/PeakBackgroundTest.h index 7b21d7d9da006754ba5a01247d98886c4a2e125a..4605bc1606738d9a813cc12304c531a78893c931 100644 --- a/Framework/Crystal/test/PeakBackgroundTest.h +++ b/Framework/Crystal/test/PeakBackgroundTest.h @@ -48,10 +48,12 @@ public: MOCK_CONST_METHOD0(getNormalizedSignalWithMask, signal_t()); MOCK_CONST_METHOD0(getSignal, signal_t()); MOCK_CONST_METHOD0(getError, signal_t()); - MOCK_CONST_METHOD1(getVertexesArray, coord_t *(size_t &numVertices)); + MOCK_CONST_METHOD1(getVertexesArray, + std::unique_ptr<coord_t[]>(size_t &numVertices)); MOCK_CONST_METHOD3(getVertexesArray, - coord_t *(size_t &numVertices, const size_t outDimensions, - const bool *maskDim)); + std::unique_ptr<coord_t[]>(size_t &numVertices, + const size_t outDimensions, + const bool *maskDim)); MOCK_CONST_METHOD0(getCenter, Mantid::Kernel::VMD()); MOCK_CONST_METHOD0(getNumEvents, size_t()); MOCK_CONST_METHOD1(getInnerRunIndex, uint16_t(size_t index)); diff --git a/Framework/Crystal/test/PeakStatisticsToolsTest.h b/Framework/Crystal/test/PeakStatisticsToolsTest.h index 779df462ee03d7bdd77fc92a82f02198f912161c..7f84cfa02c7354b2ac0ac0f503c05bac6a28dfb4 100644 --- a/Framework/Crystal/test/PeakStatisticsToolsTest.h +++ b/Framework/Crystal/test/PeakStatisticsToolsTest.h @@ -178,6 +178,30 @@ public: TS_ASSERT_EQUALS(cleanIntensities[1], 31.0); } + void test_UniqueReflectionRemoveOutliersWeighted() { + UniqueReflection reflection = + getReflectionWithPeaks({30.0, 34.0, 32.0, 31.0}, {4.5, 6.5, 10.0, 2.3}); + + // standard deviation is 1.70782512765993 + auto cleanReflection = reflection.removeOutliers(3.0, true); + TSM_ASSERT_EQUALS( + "UniqueReflection removed outlier although it should not.", + cleanReflection.count(), 3); + + cleanReflection = reflection.removeOutliers(2.0, true); + TSM_ASSERT_EQUALS( + "UniqueReflection removed outlier although it should not.", + cleanReflection.count(), 2); + + cleanReflection = reflection.removeOutliers(1.0, true); + TSM_ASSERT_EQUALS( + "UniqueReflection did not remove outliers although it should have.", + cleanReflection.count(), 1); + + std::vector<double> cleanIntensities = cleanReflection.getIntensities(); + TS_ASSERT_EQUALS(cleanIntensities[0], 32.0); + } + void test_UniqueReflectionSetIntensityAndSigma() { UniqueReflection reflection = getReflectionWithPeaks({30.0, 34.0, 32.0, 31.0}, {4.5, 6.5, 10.0, 2.3}); diff --git a/Framework/Crystal/test/PredictPeaksTest.h b/Framework/Crystal/test/PredictPeaksTest.h index ef297ab7108c36d69cc87f019564c751fb405c85..6778889cdc04a831cfb6977e6951db641086f479 100644 --- a/Framework/Crystal/test/PredictPeaksTest.h +++ b/Framework/Crystal/test/PredictPeaksTest.h @@ -37,9 +37,9 @@ public: PeaksWorkspace_sptr hklPW; if (hkls.size() > 0) { hklPW = PeaksWorkspace_sptr(new PeaksWorkspace()); - for (size_t i = 0; i < hkls.size(); i++) { + for (const auto &hkl : hkls) { Peak p(inst, detid, 1.0); - p.setHKL(hkls[i]); + p.setHKL(hkl); hklPW->addPeak(p); } } diff --git a/Framework/Crystal/test/SCDCalibratePanelsTest.h b/Framework/Crystal/test/SCDCalibratePanelsTest.h index 68b8026d4f6d0a59a632744f00e868dd3b0e4478..3113192c978c7ba6de20ae2428dbcb9e1a8acd58 100644 --- a/Framework/Crystal/test/SCDCalibratePanelsTest.h +++ b/Framework/Crystal/test/SCDCalibratePanelsTest.h @@ -17,7 +17,6 @@ using namespace Mantid::DataObjects; using namespace std; using namespace Mantid::Geometry; using namespace Mantid::Kernel; -using namespace Mantid::Geometry; using namespace Mantid::Crystal; class SCDCalibratePanelsTest : public CxxTest::TestSuite { diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateChiSquared.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateChiSquared.h index 3a4279938f528d0401123112fefbafe1681eaa97..ae69f85c4249a9b65d8ec2b97b4276442896f805 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateChiSquared.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateChiSquared.h @@ -39,6 +39,9 @@ class DLLExport CalculateChiSquared : public IFittingAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalculateCostFunction", "Fit"}; + } const std::string summary() const override; private: diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateCostFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateCostFunction.h index d66640fd091f0a6c0f0f085ab1f2034cc6d6a28f..958ac2940660bc04f6ff1f432b03613b7a00f993 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateCostFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/CalculateCostFunction.h @@ -42,6 +42,9 @@ class DLLExport CalculateCostFunction : public IFittingAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CalculateChiSquared", "Fit"}; + } const std::string summary() const override; private: diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimateFitParameters.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimateFitParameters.h index 4e7bffa93e4ed0032f30e4c0d36bdd655f2e5216..8366d8e8ccc980a57d687e9133e5a29032a8256b 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimateFitParameters.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimateFitParameters.h @@ -37,6 +37,9 @@ class DLLExport EstimateFitParameters : public IFittingAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Fit", "EstimatePeakErrors"}; + } const std::string summary() const override; private: diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimatePeakErrors.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimatePeakErrors.h index 9337aba270672b8e5d0be8a9fda44a8fbed9d98b..d7f2c396550fd832ea2436dbadb12d93eb352740 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimatePeakErrors.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EstimatePeakErrors.h @@ -38,6 +38,9 @@ public: const std::string summary() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Fit", "EstimateFitParameters"}; + } const std::string category() const override; private: diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EvaluateFunction.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EvaluateFunction.h index 915b3285faaf16451e5783672913d91faeb03785..aef157d8558dc8aa58313d180de2c67f7c4e0396 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EvaluateFunction.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/EvaluateFunction.h @@ -38,6 +38,7 @@ class DLLExport EvaluateFunction : public IFittingAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } const std::string summary() const override; private: diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/Fit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/Fit.h index a60b8da6de0437f337d657e4fc2cd0f64eb0ca29..028f6d76fee69f5393548e6712dbcea39a46e18d 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/Fit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/Fit.h @@ -103,6 +103,10 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"FitGaussian", "UserFunction1D", "PlotPeakByLogValue", + "SplineBackground", "EvaluateFunction"}; + } private: void initConcrete() override; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h index c602e18e0f11555dcbe956a1476ff8c7f1b93d42..8b99f2e5e91e722a798461dc074369f8f42cb301 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/FitPowderDiffPeaks.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LeBailFit"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Fitting"; } diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h index 05466c164ed240319e96168d10217fddabe5bfca..9c73166259e6736e64d6fd46b153faf92bc077c8 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/LeBailFit.h @@ -91,6 +91,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CreateLeBailFitInput", "FitPowderDiffPeaks"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Fitting"; } diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/NormaliseByPeakArea.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/NormaliseByPeakArea.h index 36c402f6e090a7a6353c9ace571b51aebcadbe48..d7ca221d8675bd9d3d39bb27c668d9ce605634c3 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/NormaliseByPeakArea.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/NormaliseByPeakArea.h @@ -49,6 +49,10 @@ public: "input mass value."; } + const std::vector<std::string> seeAlso() const override { + return {"MonitorEfficiencyCorUser", "Divide"}; + } + int version() const override; const std::string category() const override; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PawleyFit.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PawleyFit.h index deaad15eca404f903d653e9e535509651f616a28..9e25bff6a6681079f8790a497d56e127c6e60e93 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PawleyFit.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PawleyFit.h @@ -69,6 +69,9 @@ public: PawleyFit(); const std::string name() const override { return "PawleyFit"; } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"PoldiPeakSearch"}; + } const std::string summary() const override; const std::string category() const override { return "Diffraction\\Fitting"; } diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h index 659bad57095bce63b4d4965f53521c10bb476bb4..d7425fe118c2dabac5d2896d68e4af328a658c53 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/PlotPeakByLogValue.h @@ -88,6 +88,7 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Optimization"; } diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h index 1c02e46c59ebe5feaaf442c8fc04706ba23ea543..8e06e79bb4b2a1e39b6260b09f37cc874fa7181d 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/RefinePowderInstrumentParameters3.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 3; } + const std::vector<std::string> seeAlso() const override { + return {"RefinePowderDiffProfileSeq"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\Fitting"; } diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h index c154c4c35aad3f442946f3028571ef836935538c..cb77bfa19f4e59a0c1e8c4121e10ecfb449dcfb1 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineBackground.h @@ -47,6 +47,9 @@ public: const std::string name() const override { return "SplineBackground"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Fit", "SplineInterpolation", "SplineSmoothing"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Optimization;CorrectionFunctions\\BackgroundCorrections"; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h index 0d4af58d67a244ad85aff9c680b2435bd2b69027..363fb385aa413e0510c52090c63b1070e2c5826a 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineInterpolation.h @@ -49,6 +49,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Fit", "SplineBackground", "SplineSmoothing"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h index 51ed2dce5c909e38a8ad6b8c417f4e456a3a9125..1a59ab2510e329ed07156852800eb4bc4e22d321 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/SplineSmoothing.h @@ -45,6 +45,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Fit", "SplineInterpolation", "SplineBackground"}; + } const std::string category() const override; /// Summary of algorithms purpose const std::string summary() const override { diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateGammaBackground.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateGammaBackground.h index 108ccccdbd7751a2362c65f87786716422bd4c9a..08972a6f98b7928c72494861b87b2cd573129b7c 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateGammaBackground.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateGammaBackground.h @@ -57,6 +57,9 @@ public: return "Calculates the background due to gamma rays produced when neutrons " "are absorbed by shielding."; } + const std::vector<std::string> seeAlso() const override { + return {"VesuvioCorrections"}; + } int version() const override; const std::string category() const override; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateMS.h b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateMS.h index d3e19adf0d6f131582ed1ab189b83cac1e1ab244..7adc0d45e76cd6386f28b313b4e5bb6e80f4eb77 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateMS.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Algorithms/VesuvioCalculateMS.h @@ -95,6 +95,11 @@ public: "on a flat plate sample for VESUVIO"; } + const std::vector<std::string> seeAlso() const override { + return {"MayersSampleCorrection", "MonteCarloAbsorption", + "MultipleScatteringCylinderAbsorption"}; + } + private: void init() override; void exec() override; diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/UserFunction1D.h b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/UserFunction1D.h index 5274b319fc81ab123ad40c7acae73363e49f8180..e6478b9b33523bdb70aef1bdf636a43caf16a718 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/Functions/UserFunction1D.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/Functions/UserFunction1D.h @@ -88,6 +88,7 @@ public: const std::string summary() const override { return "Fits a histogram from a workspace to a user defined function."; } + const std::vector<std::string> seeAlso() const override { return {"Fit"}; } protected: /// overwrite base class methods diff --git a/Framework/CurveFitting/inc/MantidCurveFitting/RalNlls/Workspaces.h b/Framework/CurveFitting/inc/MantidCurveFitting/RalNlls/Workspaces.h index 5d13fc72a88c4ed89b04c8478ef1a30a05cf1841..a65b4c926944a839a9e45783c76d994423559416 100644 --- a/Framework/CurveFitting/inc/MantidCurveFitting/RalNlls/Workspaces.h +++ b/Framework/CurveFitting/inc/MantidCurveFitting/RalNlls/Workspaces.h @@ -183,14 +183,14 @@ struct nlls_inform { /// the value of the objective function at the best estimate of the solution /// determined by NLLS_solve - double obj = HUGE; + double obj = std::numeric_limits<float>::max(); /// the norm of the gradient of the objective function at the best estimate /// of the solution determined by NLLS_solve - double norm_g = HUGE; + double norm_g = std::numeric_limits<float>::max(); /// the norm of the gradient, scaled by the norm of the residual - double scaled_g = HUGE; + double scaled_g = std::numeric_limits<float>::max(); }; // END TYPE nlls_inform diff --git a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp index 2485a0cc1882e1119827512e8f49dd2109663eb1..aa33da349282e1aaf83b77ca02b7b04c73030673 100644 --- a/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp +++ b/Framework/CurveFitting/src/Algorithms/EstimateFitParameters.cpp @@ -322,9 +322,8 @@ void EstimateFitParameters::initConcrete() { declareProperty("NSamples", 100, "Number of samples."); declareProperty("Constraints", "", "Additional constraints on tied parameters."); - declareProperty( - "Type", "Monte Carlo", - "Type of the algorithm: \"Monte Carlo\" or \"Cross Entropy\""); + declareProperty("Type", "Monte Carlo", + R"(Type of the algorithm: "Monte Carlo" or "Cross Entropy")"); declareProperty("NOutputs", 10, "Number of parameter sets to output to " "OutputWorkspace. Unused if OutputWorkspace " "isn't set. (Monte Carlo only)"); @@ -430,8 +429,8 @@ void EstimateFitParameters::execConcrete() { if (m_function->isActive(i)) { TableRow row = table->appendRow(); row << m_function->parameterName(i); - for (size_t j = 0; j < output.size(); ++j) { - row << output[j][ia]; + for (auto &j : output) { + row << j[ia]; } ++ia; } diff --git a/Framework/CurveFitting/src/FuncMinimizers/FABADAMinimizer.cpp b/Framework/CurveFitting/src/FuncMinimizers/FABADAMinimizer.cpp index 98ecd9628f8812cfd0bac078b667474144a0a51f..fa2ce0ddb6a3ba13c5b128dc03133e80abf3c6ac 100644 --- a/Framework/CurveFitting/src/FuncMinimizers/FABADAMinimizer.cpp +++ b/Framework/CurveFitting/src/FuncMinimizers/FABADAMinimizer.cpp @@ -959,12 +959,12 @@ void FABADAMinimizer::calculateConvChainAndBestParameters( auto posBestPar = std::find(reducedChain[j].begin(), reducedChain[j].end(), bestParameters[j]); double varLeft = 0, varRight = 0; - for (auto k = reducedChain[j].begin(); k < reducedChain[j].end(); k++) { + for (auto k = reducedChain[j].begin(); k < reducedChain[j].end(); + k += 2) { if (k < posBestPar) varLeft += (*k - bestParameters[j]) * (*k - bestParameters[j]); else if (k > posBestPar) varRight += (*k - bestParameters[j]) * (*k - bestParameters[j]); - ++k; } if (posBestPar != reducedChain[j].begin()) varLeft /= double(posBestPar - reducedChain[j].begin()); diff --git a/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp b/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp index 2b4c732e7120eec05e4b92c7c63ccbf038b4e4d0..e2d26ec89472206ddd97fa46046a4e075146308c 100644 --- a/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp +++ b/Framework/CurveFitting/src/FuncMinimizers/TrustRegionMinimizer.cpp @@ -1274,10 +1274,10 @@ void solveSubproblem(int n, double radius, double f, inform.obj *= pow(scale_c, 2) / scale_h; inform.multiplier *= scale_h; inform.pole *= scale_h; - for (size_t i = 0; i < inform.history.size(); - ++i) { // do i = 1, inform.len_history - inform.history[i].lambda *= scale_h; - inform.history[i].x_norm *= scale_c / scale_h; + for (auto &history_item : + inform.history) { // do i = 1, inform.len_history + history_item.lambda *= scale_h; + history_item.x_norm *= scale_c / scale_h; } } diff --git a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp index f1af30eea7407b205972ccd4e73adc63fcabba0a..70aed84ab03885f642a0083babf89c4df6f4ccee 100644 --- a/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp +++ b/Framework/CurveFitting/src/Functions/CrystalFieldMultiSpectrum.cpp @@ -192,10 +192,20 @@ void CrystalFieldMultiSpectrum::setAttribute(const std::string &name, } } else if (boost::regex_match(name, match, FWHMX_ATTR_REGEX)) { auto iSpec = std::stoul(match[1]); - m_fwhmX[iSpec].clear(); + if (m_fwhmX.size() > iSpec) { + m_fwhmX[iSpec].clear(); + } else { + throw std::invalid_argument( + "Temperatures must be defined before resolution model"); + } } else if (boost::regex_match(name, match, FWHMY_ATTR_REGEX)) { auto iSpec = std::stoul(match[1]); - m_fwhmY[iSpec].clear(); + if (m_fwhmY.size() > iSpec) { + m_fwhmY[iSpec].clear(); + } else { + throw std::invalid_argument( + "Temperatures must be defined before resolution model"); + } } FunctionGenerator::setAttribute(name, attr); } diff --git a/Framework/CurveFitting/test/Algorithms/ConvertToYSpaceTest.h b/Framework/CurveFitting/test/Algorithms/ConvertToYSpaceTest.h index 17ed511e6d0cdc6beec65bc1bb6f69b44c806366..4c85a58beb16632a0d07a95690226f92b63e5234 100644 --- a/Framework/CurveFitting/test/Algorithms/ConvertToYSpaceTest.h +++ b/Framework/CurveFitting/test/Algorithms/ConvertToYSpaceTest.h @@ -57,13 +57,13 @@ public: // Get the y-Space output workspace MatrixWorkspace_sptr ySpOutputWs = alg->getProperty("OutputWorkspace"); - TS_ASSERT(ySpOutputWs != 0) + TS_ASSERT(ySpOutputWs != nullptr) TS_ASSERT_EQUALS(testWS->getNumberHistograms(), ySpOutputWs->getNumberHistograms()); // Get the q-Space output workspace MatrixWorkspace_sptr qSpOutputWs = alg->getProperty("QWorkspace"); - TS_ASSERT(qSpOutputWs != 0) + TS_ASSERT(qSpOutputWs != nullptr) TS_ASSERT_EQUALS(testWS->getNumberHistograms(), qSpOutputWs->getNumberHistograms()); diff --git a/Framework/CurveFitting/test/Algorithms/EvaluateFunctionTest.h b/Framework/CurveFitting/test/Algorithms/EvaluateFunctionTest.h index d675c5f0de7097dabcdada4d5d618168c7ca7088..9748b7ac8894a4d329eeda6f60db93575c957564 100644 --- a/Framework/CurveFitting/test/Algorithms/EvaluateFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/EvaluateFunctionTest.h @@ -149,7 +149,6 @@ public: TS_ASSERT_DELTA((signal - value) / value, 0.0, 1e-6); } } while (iter->next()); - delete iter; } void test_set_workspace_twice() { diff --git a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h index 0f761eab369d4154d0fe8165e083494d816c32ce..6f560ebd21cb8f079dc833cd9ad27cc63cf1c334 100644 --- a/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h +++ b/Framework/CurveFitting/test/Algorithms/LeBailFunctionTest.h @@ -515,10 +515,10 @@ public: 1.950190, 1.613562, 1.335208, 1.104734, 0.914043, 0.756362, 0.000000}; - for (size_t i = 0; i < vecY.size(); ++i) { + for (double y : vecY) { double e = 1.0; - if (vecY[i] > 1.0) - e = sqrt(vecY[i]); + if (y > 1.0) + e = sqrt(y); vecE.push_back(e); } @@ -687,8 +687,8 @@ public: vecy.push_back(0.03096179); vece.push_back(0.00105191); - for (size_t i = 0; i < vecy.size(); ++i) - vecy[i] -= 0.02295189; + for (double &i : vecy) + i -= 0.02295189; return; } diff --git a/Framework/CurveFitting/test/Algorithms/NormaliseByPeakAreaTest.h b/Framework/CurveFitting/test/Algorithms/NormaliseByPeakAreaTest.h index ef0f8b8aa540ed75bf1aff9f63b2391b50b97c86..549553b7dfdbd735e7b0e1a0ef43052dc7e7d773 100644 --- a/Framework/CurveFitting/test/Algorithms/NormaliseByPeakAreaTest.h +++ b/Framework/CurveFitting/test/Algorithms/NormaliseByPeakAreaTest.h @@ -60,10 +60,10 @@ public: MatrixWorkspace_sptr fittedWS = alg->getProperty("FittedWorkspace"); MatrixWorkspace_sptr symmetrisedWS = alg->getProperty("SymmetrisedWorkspace"); - TS_ASSERT(outputWS != 0); - TS_ASSERT(yspaceWS != 0); - TS_ASSERT(fittedWS != 0); - TS_ASSERT(symmetrisedWS != 0); + TS_ASSERT(outputWS != nullptr); + TS_ASSERT(yspaceWS != nullptr); + TS_ASSERT(fittedWS != nullptr); + TS_ASSERT(symmetrisedWS != nullptr); // Dimensions TS_ASSERT_EQUALS(testWS->getNumberHistograms(), @@ -171,10 +171,10 @@ public: MatrixWorkspace_sptr fittedWS = alg->getProperty("FittedWorkspace"); MatrixWorkspace_sptr symmetrisedWS = alg->getProperty("SymmetrisedWorkspace"); - TS_ASSERT(outputWS != 0); - TS_ASSERT(yspaceWS != 0); - TS_ASSERT(fittedWS != 0); - TS_ASSERT(symmetrisedWS != 0); + TS_ASSERT(outputWS != nullptr); + TS_ASSERT(yspaceWS != nullptr); + TS_ASSERT(fittedWS != nullptr); + TS_ASSERT(symmetrisedWS != nullptr); // Dimensions TS_ASSERT_EQUALS(testWS->getNumberHistograms(), diff --git a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h index 557a80dc32eaa0d02ed83932c242a531051e7f99..887b222e9af4f88ce50deb2ebc3212eca54c1a6a 100644 --- a/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h +++ b/Framework/CurveFitting/test/Algorithms/PlotPeakByLogValueTest.h @@ -496,10 +496,10 @@ public: TS_ASSERT(fits->getNames().size() == 2); auto wsNames = fits->getNames(); - for (size_t i = 0; i < wsNames.size(); ++i) { + for (const auto &wsName : wsNames) { auto fit = AnalysisDataService::Instance().retrieveWS<const MatrixWorkspace>( - wsNames[i]); + wsName); TS_ASSERT(fit); TS_ASSERT(fit->getNumberHistograms() == 5); } diff --git a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h index 233c1a20055e57a6afc44f54949e3f49375657cd..ba013ee91cb938a06b6db4edea8d7a321caa516a 100644 --- a/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h +++ b/Framework/CurveFitting/test/Algorithms/RefinePowderInstrumentParametersTest.h @@ -308,9 +308,9 @@ public: hkl << hkls[ipk][i]; cout << hkls[ipk][i] << ", "; } - for (size_t ipm = 0; ipm < peakparams[ipk].size(); ++ipm) { - hkl << peakparams[ipk][ipm]; - cout << peakparams[ipk][ipm]; + for (double ipm : peakparams[ipk]) { + hkl << ipm; + cout << ipm; } cout << '\n'; } @@ -416,10 +416,10 @@ public: // 2. Add peak parameters' name and values map<string, vector<double>>::iterator finditer; - for (size_t ipn = 0; ipn < paramnames.size(); ++ipn) { + for (const auto ¶mname : paramnames) { API::TableRow newrow = geomws->appendRow(); - std::string parname = paramnames[ipn]; - double parvalue = parameters[paramnames[ipn]]; + std::string parname = paramname; + double parvalue = parameters[paramname]; newrow << parname << parvalue; double parmin = -DBL_MAX; double parmax = DBL_MAX; diff --git a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h index ddc0df117f8a5b8fc41d29290b381be2a33c472f..a2b7cbb592881faabd324718088075ff10c4b52e 100644 --- a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h +++ b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateGammaBackgroundTest.h @@ -31,8 +31,8 @@ public: MatrixWorkspace_sptr backgroundWS = alg->getProperty("BackgroundWorkspace"); MatrixWorkspace_sptr correctedWS = alg->getProperty("CorrectedWorkspace"); - TS_ASSERT(backgroundWS != 0); - TS_ASSERT(correctedWS != 0); + TS_ASSERT(backgroundWS != nullptr); + TS_ASSERT(correctedWS != nullptr); TS_ASSERT(backgroundWS != correctedWS); // Test some values in the range @@ -81,8 +81,8 @@ public: MatrixWorkspace_sptr backgroundWS = alg->getProperty("BackgroundWorkspace"); MatrixWorkspace_sptr correctedWS = alg->getProperty("CorrectedWorkspace"); - TS_ASSERT(backgroundWS != 0); - TS_ASSERT(correctedWS != 0); + TS_ASSERT(backgroundWS != nullptr); + TS_ASSERT(correctedWS != nullptr); TS_ASSERT(backgroundWS != correctedWS); // Test some values in the range @@ -125,8 +125,8 @@ public: MatrixWorkspace_sptr backgroundWS = alg->getProperty("BackgroundWorkspace"); MatrixWorkspace_sptr correctedWS = alg->getProperty("CorrectedWorkspace"); - TS_ASSERT(backgroundWS != 0); - TS_ASSERT(correctedWS != 0); + TS_ASSERT(backgroundWS != nullptr); + TS_ASSERT(correctedWS != nullptr); TS_ASSERT(backgroundWS != correctedWS); TS_ASSERT_EQUALS(1, backgroundWS->getNumberHistograms()); diff --git a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h index 5e4bb0d4777fe098e2885eaf528a6fd5e74bd0cd..128c57e8c7009ab8d4344ebfbb4af62b0512acb9 100644 --- a/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h +++ b/Framework/CurveFitting/test/Algorithms/VesuvioCalculateMSTest.h @@ -78,7 +78,8 @@ createTestWorkspace(const bool detShape = true, if (groupedDets) { // Add another detector in the same position as the first auto shape = ShapeFactory().createShape(shapeXML); - Mantid::Geometry::Detector *det2 = new Detector("det1", 2, shape, NULL); + Mantid::Geometry::Detector *det2 = + new Detector("det1", 2, shape, nullptr); // Setting detectors should normally go via DetectorInfo, but here we need // to set a position as we are adding a new detector. In general getPos // should not be called as this tries to set the position of the base diff --git a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h index 2333150394447c5346ed148ef300cc60dbb46fc1..db19d23152d705a99b3a5764574534ddf7f72acf 100644 --- a/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h +++ b/Framework/CurveFitting/test/Functions/ChebfunBaseTest.h @@ -115,8 +115,7 @@ private: ChebfunBase base(n, start, end); auto p = base.fit(fun); auto x = base.linspace(2 * n); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { TS_ASSERT_DELTA(base.eval(xi, p), fun(xi), 1e-4); } } @@ -148,8 +147,7 @@ private: std::vector<double> p, a; auto base = ChebfunBase::bestFit(start, end, fun, p, a); auto x = base->linspace(2 * base->size()); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { TS_ASSERT_DELTA(base->eval(xi, p), fun(xi), 1e-14); } TS_ASSERT_EQUALS(base->size(), expected_n); @@ -169,8 +167,7 @@ private: base->derivative(a, da); dp = base->calcP(da); auto x = base->linspace(2 * base->size()); - for (size_t i = 0; i < x.size(); ++i) { - double xi = x[i]; + for (double xi : x) { // std::cerr << xi << ' ' << base->eval(xi,dp) - Cos(xi) << '\n'; TS_ASSERT_DELTA(base->eval(xi, dp), deriv(xi), 1e-13); } @@ -182,8 +179,8 @@ private: auto base = ChebfunBase::bestFit(start, end, fun, p, a); auto roots = base->roots(a); TS_ASSERT_EQUALS(n_roots, roots.size()); - for (size_t i = 0; i < roots.size(); ++i) { - TS_ASSERT_DELTA(base->eval(roots[i], p), 0.0, tol); + for (double root : roots) { + TS_ASSERT_DELTA(base->eval(root, p), 0.0, tol); } } }; diff --git a/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h b/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h index 2022b396ac9af193744371e2a305f6ad92631a3b..8ddde99e992a53fdaf8eacb804b415a75867f79b 100644 --- a/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h +++ b/Framework/CurveFitting/test/Functions/ComptonProfileTestHelpers.h @@ -154,7 +154,7 @@ createTestInstrumentWithNoFoilChanger(const Mantid::detid_t id, Detector *det0(nullptr); if (!detShapeXML.empty()) { auto shape = ShapeFactory().createShape(detShapeXML); - det0 = new Detector("det0", id, shape, NULL); + det0 = new Detector("det0", id, shape, nullptr); } else { det0 = new Detector("det0", id, nullptr); } diff --git a/Framework/CurveFitting/test/Functions/CrystalFieldMultiSpectrumTest.h b/Framework/CurveFitting/test/Functions/CrystalFieldMultiSpectrumTest.h index 4656d63c7a60cc0013af393e219cae68645a27ad..dc26a88b3b2da18775d65c4ed7968d9d1fbc9762 100644 --- a/Framework/CurveFitting/test/Functions/CrystalFieldMultiSpectrumTest.h +++ b/Framework/CurveFitting/test/Functions/CrystalFieldMultiSpectrumTest.h @@ -406,6 +406,16 @@ public: } } + void test_multispectrum_malformed_resmod() { + std::string fun = + "name=CrystalFieldMultiSpectrum,Ion=Ce,FWHMX0=(1,2),FWHMY0=(2,3)," + "FWHMX1=(0,1),FWHMY2=(5,6),Temperatures=(44,50),B20=0.37737"; + auto alg = AlgorithmFactory::Instance().create("EvaluateFunction", -1); + alg->initialize(); + TS_ASSERT_THROWS(alg->setPropertyValue("Function", fun), + std::invalid_argument); + } + void test_underdefinded() { CrystalFieldMultiSpectrum fun; fun.setParameter("B20", 0.37737); diff --git a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h index acd2ddcd4f044a5c4198e43c6ddb1cb46d45ec57..13ca05b896b37eb05b2c99fb5147e5ac5c897dbe 100644 --- a/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h +++ b/Framework/CurveFitting/test/Functions/ProcessBackgroundTest.h @@ -446,8 +446,8 @@ public: MersenneTwister mt(1234, 0.0, 1000000.0); std::vector<double> bkgdpts(10000); - for (auto it = bkgdpts.begin(); it != bkgdpts.end(); it++) { - *it = mt.nextValue(); + for (double &bkgdpt : bkgdpts) { + bkgdpt = mt.nextValue(); } sbg.initialize(); diff --git a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h index f3b4482f107ca3b44b94b2c821a6c9844d008bf4..f2ee2336d6824554d303cb6617232b124090574b 100644 --- a/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h +++ b/Framework/CurveFitting/test/Functions/SimpleChebfunTest.h @@ -159,9 +159,9 @@ private: } } auto &xp = cheb.xPoints(); - for (size_t i = 0; i < xp.size(); ++i) { + for (double i : xp) { // std::cerr << xp[i] << ' ' << cheb(xp[i]) - fun(xp[i]) << '\n'; - TS_ASSERT_DELTA(cheb(xp[i]), fun(xp[i]), accur2); + TS_ASSERT_DELTA(cheb(i), fun(i), accur2); } } }; diff --git a/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h b/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h index 2d19fed534771de58497e0ec4c005f3cb98b2f23..843542f9221c9389d16259e0375149175c60d847 100644 --- a/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h +++ b/Framework/CurveFitting/test/IPeakFunctionCentreParameterNameTest.h @@ -33,10 +33,9 @@ public: /* Test that all functions give the expected result. */ void testAllFunctions() { - for (auto it = m_expectedResults.begin(); it != m_expectedResults.end(); - ++it) { - const std::string &peakFunctionName = it->first; - const std::string ¢reParameterName = it->second; + for (auto &expectedResult : m_expectedResults) { + const std::string &peakFunctionName = expectedResult.first; + const std::string ¢reParameterName = expectedResult.second; IPeakFunction_sptr fn = boost::dynamic_pointer_cast<IPeakFunction>( FunctionFactory::Instance().createFunction(peakFunctionName)); diff --git a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h index cec758e09c5698897de8fdabc99b512465e886de..7babcbecbfa1a105b2e69811c80ae3f2c6f35f03 100644 --- a/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h +++ b/Framework/CurveFitting/test/IPeakFunctionIntensityTest.h @@ -91,12 +91,11 @@ private: std::vector<std::string> registeredFunctions = FunctionFactory::Instance().getFunctionNames<IPeakFunction>(); - for (auto it = registeredFunctions.begin(); it != registeredFunctions.end(); - ++it) { - if (blackList.count(*it) == 0) { + for (auto ®isteredFunction : registeredFunctions) { + if (blackList.count(registeredFunction) == 0) { IPeakFunction_sptr peakFunction = boost::dynamic_pointer_cast<IPeakFunction>( - FunctionFactory::Instance().createFunction(*it)); + FunctionFactory::Instance().createFunction(registeredFunction)); if (peakFunction) { peakFunctions.push_back(peakFunction); @@ -110,16 +109,16 @@ private: void initializePeakFunctions(const std::vector<IPeakFunction_sptr> &peaks, const ParameterSet ¶meters) const { - for (auto it = peaks.begin(); it != peaks.end(); ++it) { - (*it)->setCentre(parameters.center); + for (const auto &peak : peaks) { + peak->setCentre(parameters.center); // for Ikeda-Carpenter it's not allowed to set Fwhm try { - (*it)->setFwhm(parameters.fwhm); + peak->setFwhm(parameters.fwhm); } catch (std::invalid_argument) { } - (*it)->setHeight(parameters.height); + peak->setHeight(parameters.height); } } @@ -137,8 +136,8 @@ private: getIntensities(const std::vector<IPeakFunction_sptr> &peaks) const { std::vector<double> intensities; - for (auto it = peaks.begin(); it != peaks.end(); ++it) { - intensities.push_back((*it)->intensity()); + for (const auto &peak : peaks) { + intensities.push_back(peak->intensity()); } return intensities; diff --git a/Framework/DataHandling/inc/MantidDataHandling/CompressEvents.h b/Framework/DataHandling/inc/MantidDataHandling/CompressEvents.h index c3c49b795f8dd110d21e8837f6ac9e250dbc43b1..e787d32ae909a7e87ba5fcd27eadcce54fc3bbda 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/CompressEvents.h +++ b/Framework/DataHandling/inc/MantidDataHandling/CompressEvents.h @@ -53,6 +53,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadEventNexus", "LoadEventAndCompress"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Events"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/CreateSampleShape.h b/Framework/DataHandling/inc/MantidDataHandling/CreateSampleShape.h index 24ef28c000c7270ec4219a341768823e60e37abc..6151c5b35b1c4f6ab56e17cd1c28e76383e9c8df 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/CreateSampleShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/CreateSampleShape.h @@ -49,6 +49,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection", "SetSampleMaterial", "CopySample"}; + } /// Algorithm's category for identification const std::string category() const override { return "Sample;"; } /// Algorithm's aliases diff --git a/Framework/DataHandling/inc/MantidDataHandling/DefineGaugeVolume.h b/Framework/DataHandling/inc/MantidDataHandling/DefineGaugeVolume.h index bdddc787c77c81b47076500ee3ddf83e242dbfa5..6d5d06d7600f8dd8ba436477471b7f424c540af5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DefineGaugeVolume.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DefineGaugeVolume.h @@ -50,6 +50,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "Sample"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/DeleteTableRows.h b/Framework/DataHandling/inc/MantidDataHandling/DeleteTableRows.h index 93ac211c015f4d419989a75264cf351e7176a38c..524f0a5fd0623ba1900bdaa42ecd62d0a90e8b73 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DeleteTableRows.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DeleteTableRows.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CreateEmptyTableWorkspace"}; + } /// Category const std::string category() const override { return "Utility\\Workspaces"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/DownloadFile.h b/Framework/DataHandling/inc/MantidDataHandling/DownloadFile.h index dcf95a8715e1b997a5d7ef32d293aeacff53e80d..900a363266946a29cb7ce5ae2765f55c90872134 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DownloadFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DownloadFile.h @@ -43,6 +43,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Load", "CatalogDownloadDataFiles"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h index 08183f6e02ce7e9815871ea5f39cf505eb21194a..69e035ef999ced8ce603ab4aae6bde052e362f84 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/DownloadInstrument.h @@ -40,6 +40,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrument", "UpdateScriptRepository"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/ExtractMonitorWorkspace.h b/Framework/DataHandling/inc/MantidDataHandling/ExtractMonitorWorkspace.h index 96a62132aa9d77e688297a25d7d940a5d89af802..3e57037660bfb53a8ac65a6ab59e69f18d27b369 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/ExtractMonitorWorkspace.h +++ b/Framework/DataHandling/inc/MantidDataHandling/ExtractMonitorWorkspace.h @@ -36,6 +36,9 @@ class DLLExport ExtractMonitorWorkspace : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ExtractMonitors"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h index 492bbdf0e1fd0cb7062898be783246fd38bb683d..245ce4500cf6ee3bc7b548da6561a64928b41185 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/FindDetectorsInShape.h @@ -64,6 +64,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectorsInShape"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Utility\\Instrument"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h index 9424a2ce8ea3986592b23f30e819395604ecf854..0a3bbc012da53dcb4a3e5aff8eec4461a95f4b57 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/GroupDetectors2.h @@ -120,6 +120,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; }; + const std::vector<std::string> seeAlso() const override { + return {"SpatialGrouping"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Grouping"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/Load.h b/Framework/DataHandling/inc/MantidDataHandling/Load.h index 7ba6bf16ee67e57967eb0656fd95e6d29e2fe76e..3645c6b4066b2589ee5bc75b37dff89b20c4ec9f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/Load.h +++ b/Framework/DataHandling/inc/MantidDataHandling/Load.h @@ -47,6 +47,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus", "LoadRaw", "LoadBBY"}; + } + /// Category const std::string category() const override { return "DataHandling"; } /// Aliases diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadAscii2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadAscii2.h index db7c394e41301412bb1f427fdc0142cba2925968..961566c7770ab18dd1ae61bf845f5e2ec6757b64 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadAscii2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadAscii2.h @@ -60,6 +60,9 @@ public: /// The version number int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } /// The category const std::string category() const override { return "DataHandling\\Text"; } /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadBBY.h b/Framework/DataHandling/inc/MantidDataHandling/LoadBBY.h index 1540b860759873d4f5545bf59e60c3ca2206040a..8cbf569c98753fb78ded5af4ad1c72dc9501a8f1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadBBY.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadBBY.h @@ -91,6 +91,9 @@ class DLLExport LoadBBY : public API::IFileLoader<Kernel::FileDescriptor> { public: // description int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Load", "LoadQKK"}; + } const std::string name() const override { return "LoadBBY"; } const std::string category() const override { return "DataHandling\\ANSTO"; } const std::string summary() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h index c303d3859e2a3a8927d848979bafea799edfeb85..baf78431397f29ea2cb9b3ba8ca79ef4deb3fb49 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCalFile.h @@ -31,9 +31,15 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ReadGroupsFromFile", "CreateDummyCalFile", + "CreateCalFileByNames", "AlignDetectors", + "DiffractionFocussing", "SaveCalFile", + "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { - return "DataHandling\\Text;Diffraction\\DataHandling\\CalFiles"; + return R"(DataHandling\Text;Diffraction\DataHandling\CalFiles)"; } static void getInstrument3WaysInit(Mantid::API::Algorithm *alg); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D2.h index fa4a5ec2325ae7d9cca893e0a47a9e0134301ce3..33e161e4fa240fd73a9ea42dd9b388a40f8c827c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadCanSAS1D2.h @@ -72,6 +72,9 @@ class DLLExport LoadCanSAS1D2 : public LoadCanSAS1D { public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"SaveCanSAS1D"}; + } protected: /// Overwrites Algorithm method. Extend to create the LoadTransmission flag. diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h index ca1fb205d813b749cbf6c3520ac1276a90c71dd0..d0e153132618973a26fbc35db60bd16c3718b535 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDaveGrp.h @@ -58,6 +58,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveDaveGrp"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Text;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorInfo.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorInfo.h index 6e07009f37938dbf6f2181547a7fef4891eb4593..c628cae276c815a2111d178f50cb49a695825e6a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorInfo.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorInfo.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadRaw", "LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Raw"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h index 0e4c1fc1b845fa0bb058fca1869980e845bcbd0d..5dbe7b6e3c4635cd618f04f7ed9f97266743e08a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDetectorsGroupingFile.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveDetectorsGrouping", "GroupDetectors"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Grouping;Transforms\\Grouping"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/LoadDiffCal.h index a2a205d2264f62eeaaae42819d1e47fbbc348e32..a4c87a37ce54fb96327a2a7bbf2d923fbd872d84 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadDiffCal.h @@ -40,6 +40,9 @@ class DLLExport LoadDiffCal : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SaveDiffCal"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEmptyInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEmptyInstrument.h index 2165b49239b0e21bf223704cdc6e2edc189d93c4..18caec619c9511396379b3e77f1f492903773715 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEmptyInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEmptyInstrument.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrument"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h index 9d167858e4183d7a8c596de394ef7096218e331e..fe1e4f16d4f26e1d410c4d8351a1bed67f36189c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventNexus.h @@ -79,6 +79,9 @@ public: /// Version int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadISISNexus", "LoadEventAndCompress"}; + } /// Category const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h index 21e12011e364e0861cae0d04875e5b94d417d3ef..ed3863be5deaf6bb51765386b1bee41cfa806899 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadEventPreNexus2.h @@ -98,6 +98,9 @@ public: const std::string name() const override { return "LoadEventPreNexus"; } /// Algorithm's version int version() const override { return (2); } + const std::vector<std::string> seeAlso() const override { + return {"LoadPreNexus", "FilterEventsByLogValuePreNexus"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\PreNexus"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h index a699607c6ea99f3b5b3069327d678875af3228a0..a7f8ccbde2ff7ac74e69724fe8657ebb4cec1bd4 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFITS.h @@ -61,6 +61,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"Load", "SaveFITS"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h index 8111a311ed1e1d768fc85bd0a3e8773b9daca656..0c425dac2b6ea0c18bd1c944091368df19c3d7bd 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadFullprofResolution.h @@ -46,6 +46,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadFullprofFile"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h index e612508080100a2bb92bb93fd1a929418cfb6905..5cc76649a76dfe9af9401a8524da122144fe1b87 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSASInstrumentFile.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveGSASInstrumentFile", "LoadGSS", "FixGSASInstrumentFile"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h index 8512e0db3979701c7bd9159d3c14f0c7218239b3..b19318ba0f9c0cd59cd5243bdadccdb09cb6fad1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadGSS.h @@ -51,6 +51,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadAscii", "SaveGSS", "LoadMultipleGSS"}; + } /// Algorithm's category for identification const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h index 0d7413970515722ca6b1feafabea924355b8a2e0..cf96c27b81f0b783e70a1c499613b9fddd3ce387 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLDiffraction.h @@ -41,6 +41,9 @@ class MANTID_DATAHANDLING_DLL LoadILLDiffraction public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } const std::string category() const override; const std::string summary() const override; int confidence(Kernel::NexusDescriptor &descriptor) const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h index ab552a992cfc4fa8c3796a33d27141aa011305a3..cab355c3535d246857e454dc632f42984b262018 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLIndirect2.h @@ -41,6 +41,9 @@ public: /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } const std::string name() const override; /// Summary of algorithms purpose diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLReflectometry.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLReflectometry.h index 000b92adafa4bcb47d0ddc34bf6d0b9ddd95533c..eab4a74e9e8410b5c133e1414a8955f8df97668d 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLReflectometry.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLReflectometry.h @@ -40,6 +40,9 @@ public: const std::string name() const override { return "LoadILLReflectometry"; } /// Algorithm's version for identification. @see Algorithm::version int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for search and find. @see Algorithm::category const std::string category() const override { return "DataHandling\\Nexus;ILL\\Reflectometry"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLSANS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLSANS.h index cdb68d71b77982d26b91a02fc73b405d92b75d30..1a4f331bd3525209b88f2acff1e6586a821e4f7c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLSANS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLSANS.h @@ -68,6 +68,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } const std::string category() const override; /// Returns a confidence value that this algorithm can load a file int confidence(Kernel::NexusDescriptor &descriptor) const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF2.h index 79ce533b7231260f66c865d192ca6fd5b32e77b8..700a7a9646ae154e22cf66a1c9c5d120dd613b92 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadILLTOF2.h @@ -45,6 +45,9 @@ public: /// Algorithm's version int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus;ILL\\Direct"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h index 2954b9871a857df3bbdb390ee345ad5fa9332fcc..85144c3c08a6ef6e04c4cd095642fd9377f5a090 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadISISNexus2.h @@ -80,6 +80,9 @@ public: const std::string name() const override { return "LoadISISNexus"; } /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadEventNexus", "SaveISISNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } /// Summary of algorithms purpose diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h index 8649493fe51a914fa262794968c3530701d4b4d2..a0ffc22adc4ca40469c656eece9de2198db1cc6f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrument.h @@ -84,6 +84,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrumentFromNexus", "LoadInstrumentFromRaw", + "ExportGeometry", "Load"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromNexus.h index 5ae9d79ccadf75b74bd8060b018f98020f8f2622..b00f4d6a1480749ac93b2dbc49632166a6a021bc 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromNexus.h @@ -84,6 +84,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrument", "Load"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromRaw.h b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromRaw.h index 6185daee8cf7828a3f7135364c29ada2b7483c78..6b5e3d9a8263f1aba05251f61c592aeaa3e0093a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromRaw.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadInstrumentFromRaw.h @@ -84,6 +84,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrument"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h index 321ed71e5270634e29687c535889d46c877b2ff8..10a9d244e5975c899f525b21074a2fc0ffbb163c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadIsawDetCal.h @@ -56,6 +56,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveIsawDetCal"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Isaw"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h index 94b541b5c6390ada8e30be62047a8c2225f520cc..075cee128ed15424b081c8b72cdac68e010f5caa 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadLog.h @@ -85,6 +85,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"AddSampleLog", "LoadNexusLogs"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMask.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMask.h index 3ea1b44215762d6fbcd497382dc2cc7d7233c6a7..593063b1954eaa71f1b81900500c04f888cda7e2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMask.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMask.h @@ -59,6 +59,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ExportSpectraMask", "LoadMask"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Masking;Transforms\\Masking"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMcStas.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMcStas.h index 332df5a22b0016cd35764f93e8791941d58bb1a6..f0511bb6db436d3ae8bc3eeeaeaea62bdc9f6144 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMcStas.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMcStas.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadMcStasNexus", "LoadNexus"}; + } const std::string category() const override; /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMcStasNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMcStasNexus.h index 7097dddffa08dea6a2d0f7fb328e5bfff12bb0f6..5a7d147d6bd0339eacc366521c6be27740264a15 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMcStasNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMcStasNexus.h @@ -40,6 +40,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadMcStas"}; + } const std::string category() const override; /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonLog.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonLog.h index 7f10f57d91103d3b7cef5bb544b60c3618e71f8a..4d638a49e277e0216f65934592fbcd3535d0166a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonLog.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonLog.h @@ -66,6 +66,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadLog", "LoadLogPropertyTable"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Logs;Muon\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h index 38f9560f2e97e494d09f6fbb2369e92bb94b90c9..45189d42715cf5efa9e477252b62e1b6fbbacb94 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadMuonNexus2.h @@ -75,6 +75,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus;Muon\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNXSPE.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNXSPE.h index 0b8fcb6276e877a2552bdc223578e0a28eb1cb59..ad95de64fc8f445d08faeca8ab9a77963db30a4e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNXSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNXSPE.h @@ -52,9 +52,12 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveNXSPE", "LoadSPE"}; + } /// Algorithm's category for identification const std::string category() const override { - return "DataHandling\\Nexus;DataHandling\\SPE;Inelastic\\DataHandling"; + return R"(DataHandling\Nexus;DataHandling\SPE;Inelastic\DataHandling)"; } /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNXcanSAS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNXcanSAS.h index 5b0614563bb51beb4280d990e992d54b1f9dc006..f17a4f2c6fa2b4187768784466259a6f0e883eb3 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNXcanSAS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNXcanSAS.h @@ -50,6 +50,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadCanSAS1D", "SaveNXcanSAS"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexus.h index 0f99dc22017cfd36737ac6dc07b31145e45227e6..5f377952ec8f2e9284a76fab50b593dfbe4edf8c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexus.h @@ -70,6 +70,12 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadMcStasNexus", "LoadNexusMonitors", "LoadNexusProcessed", + "LoadTOFRawNexus", "LoadILLDiffraction", "LoadILLTOF", + "LoadILLIndirect", "LoadILLReflectometry", "LoadILLSANS", + "LoadMuonNexus", "LoadFlexiNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h index e0bc283b8eeb8e9ca3b70dfb54ea150b67ddf51a..c23d54cc16ef22b4c9a502ec93a816aa951f645a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusLogs.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadLog", "MergeLogs"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Logs;DataHandling\\Nexus"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h index 3ca91b39b598aab2ce94b87c5e9ba46bf3e0ce36..7a98ee10fe4c5aed02c3c3496a998bd21dd65fce 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusMonitors2.h @@ -61,6 +61,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h index 7aaec5cdb2335cafa4a4ce82076fb726acf79009..5f44961674654668ca5975027ebb7cdcc042b3fc 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadNexusProcessed.h @@ -76,6 +76,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h index 535770755f2b6853a9cfb4ae7123a86dab8c79c6..d74c01e2b0fe4f94a057557bb5b28e6ce6d3c7d9 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPDFgetNFile.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadAscii"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadParameterFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadParameterFile.h index 698e991deebf19e04ec739982eb0d4ec4e96d6b0..6843aa500b2a295c2993b60b1594f0b0f33d51c2 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadParameterFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadParameterFile.h @@ -76,6 +76,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveParameterFile"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexus.h index 713214413fa716dcc7f412fb409f67d1997ff514..c2ccb22f0e6a9b86c21a310e84f8d3641bca881b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexus.h @@ -44,6 +44,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadEventPreNexus", "LoadPreNexusMonitors", "LoadNexus"}; + } const std::string category() const override; void parseRuninfo(const std::string &runinfo, std::string &dataDir, std::vector<std::string> &eventFilenames); diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h index 664ac56cff3be2472402dcbe9c3e5793661de1c9..25c416c670175c613aaae96a96772e8d65428275 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadPreNexusMonitors.h @@ -47,6 +47,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadEventPreNexus", "LoadPreNexus"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\PreNexus"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadQKK.h b/Framework/DataHandling/inc/MantidDataHandling/LoadQKK.h index bc9889a5668d153656425983fee74ec5262fbbd7..406beb41fcb89d548f37dffa809a3b789ed97e11 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadQKK.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadQKK.h @@ -48,6 +48,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadBBY"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h index 1c2e33f2bf92d61f34da5d077ec2ed93d19d482c..7e174ea284f909bb4cef8961fb49360dd4b1e11c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRKH.h @@ -57,6 +57,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveRKH"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Text;SANS\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h index d72df2b5c523b9239b1b8818ae396582b764ec5d..f2908a5e83b3faa11a62a7f635260e9c3ac45f76 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRaw3.h @@ -58,6 +58,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 3; } + const std::vector<std::string> seeAlso() const override { + return {"LoadVesuvio", "RawFileInfo", "LoadSampleDetailsFromRaw", + "LoadRawBin0", "LoadRawSpectrum0"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Raw"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRawBin0.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRawBin0.h index 9fcc52621f67a5b211af7340070d3fe17fcc5a3d..ec86f240489320bb05d9bab9db2b9eeba6c4e645 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRawBin0.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRawBin0.h @@ -78,6 +78,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadRawSpectrum0", "LoadRaw"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diagnostics\\Raw;DataHandling\\Raw"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadRawSpectrum0.h b/Framework/DataHandling/inc/MantidDataHandling/LoadRawSpectrum0.h index 1be9e313735c4e962436d59405a1103c59c1312f..fdabf955b69ab61e1e33aece0ce9e209593c609b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadRawSpectrum0.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadRawSpectrum0.h @@ -70,6 +70,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadRawBin0", "LoadRaw"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Diagnostics\\Raw;DataHandling\\Raw"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSESANS.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSESANS.h index d2af4e82ce47dfe61346213832bf64cdacb97e80..300403b5dc899e7e109d94061d88f3d220d52791 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSESANS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSESANS.h @@ -51,6 +51,9 @@ public: const std::string name() const override; const std::string summary() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SaveSESANS"}; + } const std::string category() const override; int confidence(Kernel::FileDescriptor &descriptor) const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSINQFocus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSINQFocus.h index 14e8c75257992ecbb7a2b268b8e4b5488b8d8cb0..7bed907b11760ab42e1d21cfc07d79a015a18c52 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSINQFocus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSINQFocus.h @@ -55,6 +55,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadSINQ", "LoadSINQFile"}; + } const std::string category() const override; /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSNSspec.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSNSspec.h index 6ded9e3c0817d78b2294553cfd2dfa97dc7ea79a..68aa0af8ac915c1d56a746a8f257b3298cd55288 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSNSspec.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSNSspec.h @@ -58,6 +58,9 @@ public: } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadSpec"}; + } const std::string category() const override { return "DataHandling\\Text"; } /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h index 4b7893dcd77e74cbfdb6f645ccf357b260fdd31f..29d269c26ff2cf66ebbbab94a4de5781fda6fdf0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSPE.h @@ -52,6 +52,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveSPE"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\SPE;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleDetailsFromRaw.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleDetailsFromRaw.h index 99c75422620c4d3108b2d8ffd1a39120b58aa3f4..c898cb038b81404c39f6a8bc4f55934b4c4130e6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSampleDetailsFromRaw.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSampleDetailsFromRaw.h @@ -54,6 +54,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadRaw"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Raw;Sample"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpec.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpec.h index 4fcfdabb54d1379ba803a6d6aaf0fb22c9e1ee97..5eb20bb45b7045640719ea44be3546c5fe265bcf 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpec.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpec.h @@ -57,6 +57,9 @@ public: } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadSNSspec"}; + } const std::string category() const override { return "DataHandling\\Text"; } private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h index 2553c519928802e99de39afe6da5cd38264e9e03..4552c15f71bce422347be74c388fe6a3077c8287 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpice2D.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadSpiceAscii", "LoadSpiceXML2DDet"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Text;SANS\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h index ef02ed6e6c62a6ab30ed878c0bd62c2c137f9099..017f844650daa455d2658db9acba8849ade1274a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceAscii.h @@ -37,6 +37,9 @@ class DLLExport LoadSpiceAscii : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadSpice2D", "LoadSpiceXML2DDet"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h index 8edc6f39906df380ac4b2646c247b5a8d88ccf29..3129bdbfc31b0e157e7f8db9e3d35a55a5dcffa1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadSpiceXML2DDet.h @@ -69,6 +69,9 @@ public: /// Algorithm version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadSpice2D"}; + } /// Category const std::string category() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h index 7ada633b4f14b74311a77100ea6ccf7dc7293d6d..5f202b0a1168ce50f21c4214448dc5375470d38e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTBL.h @@ -48,6 +48,9 @@ public: /// The version number int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveTBL"}; + } /// The category const std::string category() const override { return "DataHandling\\Text"; } /// Returns a confidence value that this algorithm can load a file diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h index 83db10f28576f6fc2006c9b16f1c81a08ae6ec29..1c104389e45289451ba637865035305921f446b6 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadTOFRawNexus.h @@ -56,6 +56,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/LoadVulcanCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/LoadVulcanCalFile.h index 18fe35888b762253db6b58a318d01a4c3e345fa4..9614a977eac8644e3dca33cee932bff7f8cdab51 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/LoadVulcanCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/LoadVulcanCalFile.h @@ -36,6 +36,12 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ReadGroupsFromFile", "CreateDummyCalFile", + "CreateCalFileByNames", "AlignDetectors", + "DiffractionFocussing", "LoadCalFile", + "SaveCalFile", "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Text;Diffraction\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h index eeb72c9fea0682d8bc75a9dd9b57c3ff71e00040..fd2d0d03475487e154552318140c6de536676c29 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectors.h @@ -65,6 +65,10 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectorsInShape", "MaskDetectorsIf", "MaskInstrument", + "MaskSpectra", "MaskBTP", "MaskAngle", "InvertMask"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Masking"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h index 533fe235fe9d68dac7f0d8e2b51465b4280a3f23..ea22b9e1b00c65a974af54fc1685993f3e115843 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskDetectorsInShape.h @@ -58,6 +58,9 @@ public: const std::string name() const override { return "MaskDetectorsInShape"; }; /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors", "FindDetectorsInShape"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "Transforms\\Masking"; } /// Summary of algorithms purpose diff --git a/Framework/DataHandling/inc/MantidDataHandling/MaskSpectra.h b/Framework/DataHandling/inc/MantidDataHandling/MaskSpectra.h index ee0a2df9cfaa26dbb0ca3d14d1984039e55d7ec0..9c842bfe1abe8fd2016932d61b79d538f5ed9854 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MaskSpectra.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MaskSpectra.h @@ -39,6 +39,9 @@ class MANTID_DATAHANDLING_DLL MaskSpectra : public API::DistributedAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MergeLogs.h b/Framework/DataHandling/inc/MantidDataHandling/MergeLogs.h index 7489b04a7e8a359b7dde29baf04ec701e5cbff51..14b20e692d7b1da98ca056f060ddc47d6f6e9e1b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MergeLogs.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MergeLogs.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"AddTimeSeriesLog"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/ModifyDetectorDotDatFile.h b/Framework/DataHandling/inc/MantidDataHandling/ModifyDetectorDotDatFile.h index 7c0c85e460755b12583eaa5e0d1a9d81bb113c92..4783666f48c6e756bdd686ca264fa3c2f59c3580 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/ModifyDetectorDotDatFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/ModifyDetectorDotDatFile.h @@ -48,6 +48,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ResizeRectangularDetector"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/MoveInstrumentComponent.h b/Framework/DataHandling/inc/MantidDataHandling/MoveInstrumentComponent.h index d556d560520c091c50c0d4c94884229628dc55c8..3839dc8a3c53bc6cb558c968b6b2485b724fad49 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/MoveInstrumentComponent.h +++ b/Framework/DataHandling/inc/MantidDataHandling/MoveInstrumentComponent.h @@ -71,6 +71,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RotateInstrumentComponent", "SetInstrumentParameter"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/PatchBBY.h b/Framework/DataHandling/inc/MantidDataHandling/PatchBBY.h index c2001589b996989261629567a93c2c78591dfe10..dc12118760c15df3145ea3020382394d645366a9 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/PatchBBY.h +++ b/Framework/DataHandling/inc/MantidDataHandling/PatchBBY.h @@ -47,6 +47,9 @@ class DLLExport PatchBBY : public API::Algorithm { public: // description int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadBBY"}; + } const std::string name() const override { return "PatchBBY"; } const std::string category() const override { return "DataHandling\\ANSTO"; } const std::string summary() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/RawFileInfo.h b/Framework/DataHandling/inc/MantidDataHandling/RawFileInfo.h index f2be39a103ef8724dff12ce4d67b54a4202eff85..e73bd721436f460f80f8e6eb6173693baa9af9ba 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/RawFileInfo.h +++ b/Framework/DataHandling/inc/MantidDataHandling/RawFileInfo.h @@ -71,6 +71,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadRaw"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Raw"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/RemoveLogs.h b/Framework/DataHandling/inc/MantidDataHandling/RemoveLogs.h index 2e2354bd5df10bbc6e3c6af6dcc83020acab956b..976bccc342fc9ae06a87b549890a1f1ce167777f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/RemoveLogs.h +++ b/Framework/DataHandling/inc/MantidDataHandling/RemoveLogs.h @@ -86,6 +86,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RenameLog", "DeleteLog"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/RenameLog.h b/Framework/DataHandling/inc/MantidDataHandling/RenameLog.h index 936ff1012d7a72e11796852f6174f5c7b8fffe15..eeea4eb47e4825c41150739ae8f7114f102ae672 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/RenameLog.h +++ b/Framework/DataHandling/inc/MantidDataHandling/RenameLog.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RemoveLogs", "DeleteLog"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Logs"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/RotateInstrumentComponent.h b/Framework/DataHandling/inc/MantidDataHandling/RotateInstrumentComponent.h index 1b6cb651bd9c7a8c486e18c90a64ec5e30e4f6fc..0bab2f84414356adece559698411e7c3aea38c02 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/RotateInstrumentComponent.h +++ b/Framework/DataHandling/inc/MantidDataHandling/RotateInstrumentComponent.h @@ -70,6 +70,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MoveInstrumentComponent", "SetInstrumentParameter"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Instrument"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h b/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h index 40938148a8f64471ae7cd97ad7f44cb076d4cfda..2eebef20dc0aed8fe8c736521a75252238d44e96 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h +++ b/Framework/DataHandling/inc/MantidDataHandling/RotateSource.h @@ -36,6 +36,9 @@ class DLLExport RotateSource : public API::Algorithm { public: const std::string name() const override { return "RotateSource"; }; int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"RotateInstrumentComponent"}; + } const std::string category() const override { return "DataHandling\\Instrument"; }; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveANSTOAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveANSTOAscii.h index 5cd322be4f189b2b2f01a79de3c335f98e4e34de..c716e3f12edd381f0636f83cdb67fa879062b152 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveANSTOAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveANSTOAscii.h @@ -48,6 +48,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } private: /// Return the file extension this algorthm should output. diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h index a78c28d12aaca75edd01d211900fbdc0e949b0a1..899e9eb803b5a25e58d3ae3a4a1a2cafc37e4575 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveAscii2.h @@ -50,6 +50,12 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadAscii", "SaveANSTOAscii", "SaveCSV", "SaveDiffFittingAscii", + "SaveILLCosmosAscii", "SaveReflCustomAscii", + "SaveReflThreeColumnAscii", "SaveOpenGenieAscii", "SaveGSS", + "SaveFocusedXYE"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Text"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h index 2e60283a4f5bef14b06484df560475cb96744a48..5fad0d6a2a7b08bdc82c32baee56a4d0551b0576 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCSV.h @@ -93,6 +93,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Text"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h index 1d99257bd0a93271b922ddc87ed442805dffc037..6e801b78f2fb3810ab605732e76dc44365bf8ce5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCalFile.h @@ -29,9 +29,15 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"ReadGroupsFromFile", "CreateDummyCalFile", + "CreateCalFileByNames", "AlignDetectors", + "DiffractionFocussing", "LoadCalFile", + "MergeCalFiles"}; + } /// Algorithm's category for identification const std::string category() const override { - return "DataHandling\\Text;Diffraction\\DataHandling\\CalFiles"; + return R"(DataHandling\Text;Diffraction\DataHandling\CalFiles)"; } void saveCalFile(const std::string &calFileName, diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveCanSAS1D2.h b/Framework/DataHandling/inc/MantidDataHandling/SaveCanSAS1D2.h index 8763bb1052a46f89ebf08ed4a51a923b121406a1..de4678a9dcc5258409fe1265203b859f32168b31 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveCanSAS1D2.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveCanSAS1D2.h @@ -79,6 +79,9 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class DLLExport SaveCanSAS1D2 : public SaveCanSAS1D { public: int version() const override { return 2; } + const std::vector<std::string> seeAlso() const override { + return {"LoadCanSAS1D"}; + } protected: /// Extends the SaveCanSAS1D init method diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDaveGrp.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDaveGrp.h index c7f5b5cae24d6736857e71a28e98e0e31c28aab0..82380bf83671d5b937a8b5990dcc807150d5bfae 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDaveGrp.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDaveGrp.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadDaveGrp"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Text;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h index 52796fc12a701402fd9ba5efcbb6bc2a39288ab4..fecebb64053f9fd31dfa94601ae78dd4d3a94ed1 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDetectorsGrouping.h @@ -44,6 +44,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadDetectorsGroupingFile", "GroupDetectors"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Grouping;Transforms\\Grouping"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h index 74c30be7a4a77faaa9f004991df6070d06b403a6..d1ae5a69a2d4a09dec2c9e9ead15404a8de01fb0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffCal.h @@ -40,6 +40,9 @@ class DLLExport SaveDiffCal : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadDiffCal"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h index 4b0c21dd82f6ea938e9d3bb761ddc50b5ee76f1a..5b619ca6f592beb1272139a6d7b08a31e6c10d4c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveDiffFittingAscii.h @@ -28,6 +28,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"EnggFitPeaks", "SaveAscii"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Text"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h index ea59057a006e18e0981123edeeebf203d031115c..dff9928d773ec0decab9697eef164f273f1fc018 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFITS.h @@ -37,6 +37,9 @@ public: const std::string name() const override final; int version() const override final; + const std::vector<std::string> seeAlso() const override { + return {"LoadFITS", "SaveNXTomo"}; + } const std::string category() const override final; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFocusedXYE.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFocusedXYE.h index 7da884dc5cc1a1ccb0a96fc34134e3610d61e89f..7d71c4471738acabb41b8c8dc1b0b9902387490a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFocusedXYE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFocusedXYE.h @@ -69,6 +69,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveFullprofResolution", "SaveAscii"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Text"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h index 5b1fce6e8b82d2f9aa7d95bd8b2d1824ca2553bd..30dbb51d582aab4eec6e69803fc9e0b7aac11c5c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveFullprofResolution.h @@ -44,6 +44,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveFocusedXYE"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Text"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h index e4ec6e647f5948d6b4be7fbc8969c60cae1bc667..6ce5acae91daaee3798ca514d25ece15c50da1e5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveGSASInstrumentFile.h @@ -50,6 +50,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadGSASInstrumentFile", "SaveGSS"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveGSS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveGSS.h index bc4c870cf2590f143b5a3239e346005ea5050cbf..6c1124c070ba7418e3dde5c0b822e091085830b7 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveGSS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveGSS.h @@ -80,6 +80,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadGSS", "SaveVulcanGSS", "SaveGSASInstrumentFile", "SaveAscii"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Text"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveILLCosmosAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveILLCosmosAscii.h index a21a7709ed4efd93a87a099d005f4ee57ec4ea40..598759ad8f13f305d4aa66f4613ab10f8defda91 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveILLCosmosAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveILLCosmosAscii.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } private: /// Return the file extension this algorthm should output. diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveISISNexus.h b/Framework/DataHandling/inc/MantidDataHandling/SaveISISNexus.h index 4c070da9edc4d139633ecc9e8cd16f6220f3f9a9..963c5e9644756c046e50df2721bebc37477ff85e 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveISISNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveISISNexus.h @@ -58,6 +58,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveNexusProcessed", "SaveNexus", "LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h index 68970bb983a9e8899d05c88884c8a895e8ff0eee..8aab2423c5cdb5e7fa9a9bf5f181d18be52600a9 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveIsawDetCal.h @@ -45,6 +45,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadIsawDetCal"}; + } /// Algorithm's category for identification const std::string category() const override { return "Diffraction\\DataHandling;DataHandling\\Isaw"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h b/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h index d3c06e9be4088c7814bf85ce1544c62c265e98f5..e7ddb70ce273a32e1e6751cdbcf8f075b6b6821c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveMask.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveMask", "LoadMask"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Masking;Transforms\\Masking"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXSPE.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXSPE.h index 4725bcbaa39836e4205131d74e7e6b6bcef9718b..4e9a4116f28af932d759e6ce80d81cd41660df09 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXSPE.h @@ -45,9 +45,12 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadNXSPE", "SaveSPE"}; + } /// Algorithm's category for identification const std::string category() const override { - return "DataHandling\\Nexus;DataHandling\\SPE;Inelastic\\DataHandling"; + return R"(DataHandling\Nexus;DataHandling\SPE;Inelastic\DataHandling)"; } private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h index 1884a315586647b76bf9a59380176baa9c75eb6e..562a6d86b08b0794b9d27820316aecf4b5fb0752 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXTomo.h @@ -60,6 +60,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveNexusProcessed"}; + } /// Algorithm's category for identification const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h index 8c9541ef206a4145f8d8a8111c87c5f5bc707d82..62bbbbe7ce345215e67ee5da81baaebdd06b8eb0 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNXcanSAS.h @@ -45,6 +45,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveCanSAS1D", "LoadNXcanSAS"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNexus.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNexus.h index 98d7c344d6f8156a6fadf1a8edcd624bf32c386c..12b09027ad3b96c4c6b9ca5c427f3bcaa059791f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNexus.h @@ -55,6 +55,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveISISNexus", "SaveNexusPD", "SaveNexusProcessed", "LoadNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h index 5c3a7f73062e1312319b6dd704927f9055b82fc1..c3e23960fae3b997cb621a41d7d254d344667408 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveNexusProcessed.h @@ -62,6 +62,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveISISNexus", "SaveNexus", "LoadNexusProcessed"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveOpenGenieAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveOpenGenieAscii.h index 7b50c4f01410339e4db9221c765a0549755e1a53..de5947fd4a8350acd682f102b315a57a2efdd424 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveOpenGenieAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveOpenGenieAscii.h @@ -26,6 +26,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } /// Algorithm's category for identification const std::string category() const override { diff --git a/Framework/DataHandling/inc/MantidDataHandling/SavePAR.h b/Framework/DataHandling/inc/MantidDataHandling/SavePAR.h index 47569287cac9bff72e5914dbb3df21b995a0d39a..b223398d7dd900095de04fa4fe430ec5a8b6bf58 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SavePAR.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SavePAR.h @@ -68,6 +68,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveSPE"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\SPE;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h index 43f0ee8259d4a78e9003c8cb2ded4a4db1f0be68..ef1455272ccd9b5811039fe395a8e6685e65b702 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SavePDFGui.h @@ -34,6 +34,9 @@ class DLLExport SavePDFGui : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SaveAscii"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SavePHX.h b/Framework/DataHandling/inc/MantidDataHandling/SavePHX.h index 85a87d9784d41c136f8c67fb91c21bb06b78d0a8..4244b99431ee1084b3c9189900d6f22c16649992 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SavePHX.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SavePHX.h @@ -53,6 +53,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SaveSPE"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\SPE;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveParameterFile.h b/Framework/DataHandling/inc/MantidDataHandling/SaveParameterFile.h index 780ed0bb1e89369ffab0bc94aabbb96e2b9004f0..4f2fe27a23687878136ef64261878d2b6d376544 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveParameterFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveParameterFile.h @@ -44,6 +44,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadParameterFile"}; + } const std::string category() const override; private: diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveRKH.h b/Framework/DataHandling/inc/MantidDataHandling/SaveRKH.h index 846b94d51bd6016993df4691fa36b3be518be6c0..0dbf4c0197ec6a11e94f9a476564698af23a5ea4 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveRKH.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveRKH.h @@ -54,6 +54,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadRKH"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Text"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveReflCustomAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveReflCustomAscii.h index ddaa6abdaa7645bcb077efd3a4bd06e0b2274479..b4e5d8379127d8ade88dc072c923f8468435178b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveReflCustomAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveReflCustomAscii.h @@ -48,6 +48,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveReflThreeColumnAscii", "SaveAscii"}; + } /// void data(std::ofstream &file, const std::vector<double> &XData, diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveReflThreeColumnAscii.h b/Framework/DataHandling/inc/MantidDataHandling/SaveReflThreeColumnAscii.h index daa9664c0ee25ff93bf162639907294fa875a909..6bf26dd38800233feba2f3b36066858933b60b69 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveReflThreeColumnAscii.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveReflThreeColumnAscii.h @@ -50,6 +50,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SaveReflCustomAscii", "SaveAscii"}; + } /// Algorithm's version for data output overriding a virtual method void data(std::ofstream &file, const std::vector<double> &XData, bool exportDeltaQ = false) override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveSESANS.h b/Framework/DataHandling/inc/MantidDataHandling/SaveSESANS.h index 185f10b0cbf4ab9b92e1f3756688d0d1b64a7706..13e4b95071dedfbb69784c162fc50de77e3d7de5 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveSESANS.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveSESANS.h @@ -54,6 +54,9 @@ public: const std::string name() const override; const std::string summary() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadSESANS"}; + } const std::string category() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h index 1a1dc408346a18a5dc6ca115d98b2e648908dc59..c09ae5d284589e8d83e2fe0402535fd0a95c69d8 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveSPE.h @@ -57,6 +57,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadSPE", "SavePAR", "SavePHX"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\SPE;Inelastic\\DataHandling"; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h index 5f82e9098f8f1ebfa6cf394bd810efc6b2eea2d1..b80c6798d0a973d622ac49a9b397625a18e9bade 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveTBL.h @@ -49,6 +49,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"LoadTBL"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Text"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h index dc53024f17560f2a559f13761161a489cbe5ebe9..aeed901d4ad9864382e46d6661b4df9e9784d0b7 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SaveToSNSHistogramNexus.h @@ -60,6 +60,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SaveNexus"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/DataHandling/inc/MantidDataHandling/SetBeam.h b/Framework/DataHandling/inc/MantidDataHandling/SetBeam.h index c947ebbd142c185918db29cd99db11f18095f359..56a10b059668dc34731f29f4a698f5663256f529 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SetBeam.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SetBeam.h @@ -34,6 +34,9 @@ class MANTID_DATAHANDLING_DLL SetBeam final : public API::Algorithm { public: const std::string name() const override final; int version() const override final; + const std::vector<std::string> seeAlso() const override { + return {"SetSample"}; + } const std::string category() const override final; const std::string summary() const override final; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SetSample.h b/Framework/DataHandling/inc/MantidDataHandling/SetSample.h index 6769bd955b1d072b382907e536ddbc38b0c71856..b5a855904ddd1903e67aff6a5caae6adbe9c820f 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SetSample.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SetSample.h @@ -40,6 +40,9 @@ class MANTID_DATAHANDLING_DLL SetSample final : public API::Algorithm { public: const std::string name() const override final; int version() const override final; + const std::vector<std::string> seeAlso() const override { + return {"SetSampleMaterial", "CopySample", "SetBeam"}; + } const std::string category() const override final; const std::string summary() const override final; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SetSampleMaterial.h b/Framework/DataHandling/inc/MantidDataHandling/SetSampleMaterial.h index a4e0461fdbeb365bb0973f075337011b1297afab..573251000e4f64cc7ade9521dcc5f4cfd39dd66b 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SetSampleMaterial.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SetSampleMaterial.h @@ -47,6 +47,10 @@ public: /// Algorithm's version int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AbsorptionCorrection", "CreateSampleShape", + "CalculateSampleTransmission"}; + } /// Algorithm's category for identification const std::string category() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/SortTableWorkspace.h b/Framework/DataHandling/inc/MantidDataHandling/SortTableWorkspace.h index 22ac676da171c5e81cc96f8df3e754ef244e93ec..a165dce8bf6f2a09604674b35ac6b9bc5f21596c 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/SortTableWorkspace.h +++ b/Framework/DataHandling/inc/MantidDataHandling/SortTableWorkspace.h @@ -34,6 +34,9 @@ class DLLExport SortTableWorkspace : public API::ParallelAlgorithm { public: const std::string name() const override { return "SortTableWorkspace"; } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateEmptyTableWorkspace"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h b/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h index c19f353f5dfac291481bc5bd48e7be90c4823269..13b140d56608c1adafa40fa125e4863b9e35268a 100644 --- a/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h +++ b/Framework/DataHandling/inc/MantidDataHandling/UpdateInstrumentFromFile.h @@ -69,6 +69,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadInstrument"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/DataHandling/src/GenerateGroupingPowder.cpp b/Framework/DataHandling/src/GenerateGroupingPowder.cpp index 1f421d452bf10e18597a4afb6b07ea90d7c74c6c..b5a0f7b0b655e2a1b80ecacf50acd557b893db72 100644 --- a/Framework/DataHandling/src/GenerateGroupingPowder.cpp +++ b/Framework/DataHandling/src/GenerateGroupingPowder.cpp @@ -37,7 +37,7 @@ int GenerateGroupingPowder::version() const { return 1; } /// Algorithm's category for identification. @see Algorithm::category const std::string GenerateGroupingPowder::category() const { - return "DataHandling\\Grouping;Transforms\\Grouping;Diffraction\\Utility"; + return R"(DataHandling\Grouping;Transforms\Grouping;Diffraction\Utility)"; } /** Initialize the algorithm's properties. diff --git a/Framework/DataHandling/src/GroupDetectors2.cpp b/Framework/DataHandling/src/GroupDetectors2.cpp index ffde59f3348e12a00a36edacdf58ceabf5d47814..d4fa1c0b7f88e228a0100041371dd701a2af5cef 100644 --- a/Framework/DataHandling/src/GroupDetectors2.cpp +++ b/Framework/DataHandling/src/GroupDetectors2.cpp @@ -1337,7 +1337,7 @@ std::map<std::string, std::string> GroupDetectors2::validateInputs() { const std::string pattern = getPropertyValue("GroupingPattern"); boost::regex re( - "^\\s*[0-9]+\\s*$|^(\\s*,*[0-9]+(\\s*(,|:|\\+|\\-)\\s*)*[0-9]*)*$"); + R"(^\s*[0-9]+\s*$|^(\s*,*[0-9]+(\s*(,|:|\+|\-)\s*)*[0-9]*)*$)"); try { if (!pattern.empty() && !boost::regex_match(pattern, re)) { diff --git a/Framework/DataHandling/src/LoadISISNexus2.cpp b/Framework/DataHandling/src/LoadISISNexus2.cpp index 9f3a54baf0b857cd1f84b789cc2f9cfc01f5e0eb..8aabbd7aa3d6a7db48befe92a26cd1b47ad1ebb4 100644 --- a/Framework/DataHandling/src/LoadISISNexus2.cpp +++ b/Framework/DataHandling/src/LoadISISNexus2.cpp @@ -1090,8 +1090,8 @@ void LoadISISNexus2::parseISODateTime(const std::string &datetime_iso, time = Poco::DateTimeFormatter::format(datetime_output, "%H:%M:%S", timezone_diff); } catch (Poco::SyntaxException &) { - date = "\?\?-\?\?-\?\?\?\?"; - time = "\?\?:\?\?:\?\?"; + date = R"(??-??-????)"; + time = R"(??:??:??)"; g_log.warning() << "Cannot parse end time from entry in Nexus file.\n"; } } diff --git a/Framework/DataHandling/src/LoadMask.cpp b/Framework/DataHandling/src/LoadMask.cpp index ebf95f91f864cee6eb6179d1bb459b8540402b7b..10661889d027f597427d6020d5c0f2dfc6afa5a4 100644 --- a/Framework/DataHandling/src/LoadMask.cpp +++ b/Framework/DataHandling/src/LoadMask.cpp @@ -531,9 +531,7 @@ void LoadMask::processMaskOnWorkspaceIndex(bool mask, // 3. Set mask auto spec0 = maskedSpecID[0]; auto prev_masks = spec0; - for (size_t i = 0; i < maskedSpecID.size(); i++) { - - auto spec2mask = maskedSpecID[i]; + for (int spec2mask : maskedSpecID) { s2iter = s2imap.find(spec2mask); if (s2iter == s2imap.end()) { @@ -703,19 +701,18 @@ void LoadMask::convertSpMasksToDetIDs(const API::MatrixWorkspace &sourceWS, sourceWS.getDetectorIDToWorkspaceIndexMap(false); std::multimap<size_t, Mantid::detid_t> spectr2index_map; - for (auto it = sourceDetMap.begin(); it != sourceDetMap.end(); it++) { + for (auto &it : sourceDetMap) { spectr2index_map.insert( - std::pair<size_t, Mantid::detid_t>(it->second, it->first)); + std::pair<size_t, Mantid::detid_t>(it.second, it.first)); } spec2index_map new_map; - for (size_t i = 0; i < maskedSpecID.size(); i++) { + for (int i : maskedSpecID) { // find spectra number from spectra ID for the source workspace - const auto itSpec = s2imap.find(maskedSpecID[i]); + const auto itSpec = s2imap.find(i); if (itSpec == s2imap.end()) { - throw std::runtime_error( - "Can not find spectra with ID: " + - boost::lexical_cast<std::string>(maskedSpecID[i]) + - " in the workspace" + sourceWS.getName()); + throw std::runtime_error("Can not find spectra with ID: " + + boost::lexical_cast<std::string>(i) + + " in the workspace" + sourceWS.getName()); } size_t specN = itSpec->second; diff --git a/Framework/DataHandling/src/LoadNexusProcessed.cpp b/Framework/DataHandling/src/LoadNexusProcessed.cpp index 233a1faf072d1e6a1125aa810fe1f566f9beb803..a8c1164f786fe10729801171bcbbb256a605b3e1 100644 --- a/Framework/DataHandling/src/LoadNexusProcessed.cpp +++ b/Framework/DataHandling/src/LoadNexusProcessed.cpp @@ -1155,6 +1155,14 @@ API::Workspace_sptr LoadNexusProcessed::loadPeaksEntry(NXEntry &entry) { if (ival != -1) peakWS->getPeak(r).setRunNumber(ival); } + } else if (str == "column_17") { + NXInt nxInt = nx_tw.openNXInt(str); + nxInt.load(); + + for (int r = 0; r < numberPeaks; r++) { + int ival = nxInt[r]; + peakWS->getPeak(r).setPeakNumber(ival); + } } else if (str == "column_15") { NXDouble nxDouble = nx_tw.openNXDouble(str); nxDouble.load(); diff --git a/Framework/DataHandling/src/LoadRKH.cpp b/Framework/DataHandling/src/LoadRKH.cpp index 870343459d7e0438484e9418e371ae8151247673..8a235dfba8bfb4fc4dbe8ac595fcf4d221752de5 100644 --- a/Framework/DataHandling/src/LoadRKH.cpp +++ b/Framework/DataHandling/src/LoadRKH.cpp @@ -34,7 +34,7 @@ bool isUnit(const Mantid::Kernel::StringTokenizer &codes) { // 5. Close bracket std::string input = std::accumulate(codes.begin(), codes.end(), std::string("")); - std::string reg("^[06][\\w]+\\([/ \\w\\^-]+\\)$"); + std::string reg(R"(^[06][\w]+\([/ \w\^-]+\)$)"); boost::regex baseRegex(reg); return boost::regex_match(input, baseRegex); } diff --git a/Framework/DataHandling/src/LoadSESANS.cpp b/Framework/DataHandling/src/LoadSESANS.cpp index 05a9716452739d44c41e62d4d6739ae70bb59bc2..3c1927e527546c752fdca5e9de3502f23e9e345f 100644 --- a/Framework/DataHandling/src/LoadSESANS.cpp +++ b/Framework/DataHandling/src/LoadSESANS.cpp @@ -103,7 +103,7 @@ int LoadSESANS::confidence(Kernel::FileDescriptor &descriptor) const { bool ffvFound = boost::starts_with(line, "FileFormatVersion"); // Next few lines should be key-value pairs - boost::regex kvPair("[\\w_]+\\s+[\\w\\d\\.\\-]+(\\s+[\\w\\d\\.\\-\\$]+)*"); + boost::regex kvPair(R"([\w_]+\s+[\w\d\.\-]+(\s+[\w\d\.\-\$]+)*)"); int kvPairsFound = 0; for (int i = 0; i < 3 && !line.empty(); i++) { @@ -246,7 +246,7 @@ ColumnMap LoadSESANS::consumeData(std::ifstream &infile, std::string &line, header + "\"", lineNum); - std::string numberRegex = "(-?\\d+(\\.\\d+)?([Ee][-\\+]?\\d+)?)"; + std::string numberRegex = R"((-?\d+(\.\d+)?([Ee][-\+]?\d+)?))"; // static_cast is safe as realistically our file is never going to have enough // columns to overflow std::string rawRegex = "^\\s*" + diff --git a/Framework/DataHandling/src/LoadSpice2D.cpp b/Framework/DataHandling/src/LoadSpice2D.cpp index d109f4cdc8b8600b8e85953f71b0e5f9523cd081..56fd40b1e19a4d9f5b768605f777ab3ef61b1329 100644 --- a/Framework/DataHandling/src/LoadSpice2D.cpp +++ b/Framework/DataHandling/src/LoadSpice2D.cpp @@ -218,7 +218,7 @@ LoadSpice2D::parseDetectorDimensions(const std::string &dims_str) { std::pair<int, int> dims = std::make_pair(0, 0); - boost::regex b_re_sig("INT\\d+\\[(\\d+),(\\d+)\\]"); + boost::regex b_re_sig(R"(INT\d+\[(\d+),(\d+)\])"); if (boost::regex_match(dims_str, b_re_sig)) { boost::match_results<std::string::const_iterator> match; boost::regex_search(dims_str, match, b_re_sig); diff --git a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp index 725bcfd9be168382a783febaeccb9c2f74ebc393..31deaced9856b67e04ad103f9c55d7b65c427df3 100644 --- a/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp +++ b/Framework/DataHandling/src/LoadSpiceXML2DDet.cpp @@ -669,20 +669,17 @@ MatrixWorkspace_sptr LoadSpiceXML2DDet::createMatrixWorkspaceVersion2( } // END-FOR (xml nodes) // Add the property to output workspace - for (std::map<std::string, std::string>::iterator miter = str_log_map.begin(); - miter != str_log_map.end(); ++miter) { + for (auto &log_entry : str_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<std::string>(miter->first, miter->second)); + new PropertyWithValue<std::string>(log_entry.first, log_entry.second)); } - for (std::map<std::string, int>::iterator miter = int_log_map.begin(); - miter != int_log_map.end(); ++miter) { + for (auto &log_entry : int_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<int>(miter->first, miter->second)); + new PropertyWithValue<int>(log_entry.first, log_entry.second)); } - for (std::map<std::string, double>::iterator miter = dbl_log_map.begin(); - miter != dbl_log_map.end(); ++miter) { + for (auto &log_entry : dbl_log_map) { outws->mutableRun().addProperty( - new PropertyWithValue<double>(miter->first, miter->second)); + new PropertyWithValue<double>(log_entry.first, log_entry.second)); } // Raise exception if no detector node is found @@ -713,10 +710,10 @@ LoadSpiceXML2DDet::parseDetectorNode(const std::string &detvaluestr, // file records data in column major) size_t num_empty_line = 0; size_t num_weird_line = 0; - for (size_t iline = 0; iline < vecLines.size(); ++iline) { - if (vecLines[iline].empty()) + for (auto &vecLine : vecLines) { + if (vecLine.empty()) ++num_empty_line; - else if (vecLines[iline].size() < 100) + else if (vecLine.size() < 100) ++num_weird_line; } size_t num_pixel_x = vecLines.size() - num_empty_line - num_weird_line; diff --git a/Framework/DataHandling/src/ParallelEventLoader.cpp b/Framework/DataHandling/src/ParallelEventLoader.cpp index 90a7522fa793413a633f828dfe2691d64958d9ef..d8c240ba4892d2967bbfcc3aff417746eb93cb06 100644 --- a/Framework/DataHandling/src/ParallelEventLoader.cpp +++ b/Framework/DataHandling/src/ParallelEventLoader.cpp @@ -59,11 +59,11 @@ std::vector<int32_t> bankOffsetsSpectrumNumbers( const auto &specNums = ws.indexInfo().spectrumNumbers(); int32_t spectrumIndex{0}; // *global* index std::vector<int32_t> bankOffsets(bankNames.size(), 0); - for (size_t i = 0; i < specNums.size(); ++i) { + for (auto i : specNums) { // In contrast to the case of event ID = detector ID we know that any // spectrum number has a corresponding event ID, i.e., we do not need // special handling for monitors. - specnum_t specNum = static_cast<specnum_t>(specNums[i]); + specnum_t specNum = static_cast<specnum_t>(i); // See comment in bankOffsets regarding this offset computation. if (idToBank.count(specNum) == 1) { size_t bank = idToBank.at(specNum); diff --git a/Framework/DataHandling/src/SaveAscii2.cpp b/Framework/DataHandling/src/SaveAscii2.cpp index f254010925e0d3f6c72a0db8568b5f570ed27b5c..b8199fa5104ff46dca1ed7e160e0b218275be257 100644 --- a/Framework/DataHandling/src/SaveAscii2.cpp +++ b/Framework/DataHandling/src/SaveAscii2.cpp @@ -268,8 +268,8 @@ void SaveAscii2::exec() { } } else { Progress progress(this, 0.0, 1.0, idx.size()); - for (auto i = idx.begin(); i != idx.end(); ++i) { - writeSpectrum(*i, file); + for (int i : idx) { + writeSpectrum(i, file); progress.report(); } } diff --git a/Framework/DataHandling/src/SaveFocusedXYE.cpp b/Framework/DataHandling/src/SaveFocusedXYE.cpp index cd63e3462396de38db1139e1b49ce61caa6cfc5a..2483b0f9725ca409dd2eb221d344f1bc1321e71b 100644 --- a/Framework/DataHandling/src/SaveFocusedXYE.cpp +++ b/Framework/DataHandling/src/SaveFocusedXYE.cpp @@ -236,7 +236,8 @@ void SaveFocusedXYE::writeHeaders( void SaveFocusedXYE::writeXYEHeaders( std::ostream &os, Mantid::API::MatrixWorkspace_const_sptr &workspace) const { - os << "XYDATA\n"; + if (m_headerType != TOPAS) + os << "XYDATA\n"; os << m_comment << " File generated by Mantid, " << "Instrument " << workspace->getInstrument()->getName() << '\n'; os << m_comment diff --git a/Framework/DataHandling/src/SaveGSS.cpp b/Framework/DataHandling/src/SaveGSS.cpp index d9873b66173b423484db55bc7200f53b19edc84e..dd1410209b8a4d931b552b8c9dedadc12d5bf03b 100644 --- a/Framework/DataHandling/src/SaveGSS.cpp +++ b/Framework/DataHandling/src/SaveGSS.cpp @@ -442,9 +442,8 @@ void SaveGSS::generateInstrumentHeader(std::stringstream &out, // write user header first if (m_user_specified_gsas_header.size() > 0) { - for (auto iter = m_user_specified_gsas_header.begin(); - iter != m_user_specified_gsas_header.end(); ++iter) { - out << *iter << "\n"; + for (const auto &iter : m_user_specified_gsas_header) { + out << iter << "\n"; } } diff --git a/Framework/DataHandling/src/SetSample.cpp b/Framework/DataHandling/src/SetSample.cpp index ac802e9549bee96e5d6e400d2a6aedaebf340527..1516b5b66dd604586644c00e1c08a8139b411ec3 100644 --- a/Framework/DataHandling/src/SetSample.cpp +++ b/Framework/DataHandling/src/SetSample.cpp @@ -111,11 +111,11 @@ V3D cylBaseCentre(const std::vector<double> &cylCentre, double height, std::string axisXML(unsigned axisIdx) { switch (axisIdx) { case 0: - return "<axis x=\"1\" y=\"0\" z=\"0\" />"; + return R"(<axis x="1" y="0" z="0" />)"; case 1: - return "<axis x=\"0\" y=\"1\" z=\"0\" />"; + return R"(<axis x="0" y="1" z="0" />)"; case 2: - return "<axis x=\"0\" y=\"0\" z=\"1\" />"; + return R"(<axis x="0" y="0" z="1" />)"; default: return ""; } diff --git a/Framework/DataHandling/test/FindDetectorsInShapeTest.h b/Framework/DataHandling/test/FindDetectorsInShapeTest.h index e8918c444a31b6449c5ef0624586a2379ae6f508..9334ce32b75d1488a36e4a688b5a657e4a6ba105 100644 --- a/Framework/DataHandling/test/FindDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/FindDetectorsInShapeTest.h @@ -22,13 +22,13 @@ public: void testCuboidMiss() { std::string xmlShape = "<cuboid id=\"shape\"> "; - xmlShape += "<left-front-bottom-point x=\"0.005\" y=\"-0.1\" z=\"0.0\" /> "; + xmlShape += R"(<left-front-bottom-point x="0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<left-front-top-point x=\"0.005\" y=\"-0.1\" z=\"0.0001\" /> "; + R"(<left-front-top-point x="0.005" y="-0.1" z="0.0001" /> )"; xmlShape += - "<left-back-bottom-point x=\"-0.005\" y=\"-0.1\" z=\"0.0\" /> "; + R"(<left-back-bottom-point x="-0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<right-front-bottom-point x=\"0.005\" y=\"0.1\" z=\"0.0\" /> "; + R"(<right-front-bottom-point x="0.005" y="0.1" z="0.0" /> )"; xmlShape += "</cuboid> "; xmlShape += "<algebra val=\"shape\" /> "; @@ -55,7 +55,7 @@ public: void testSphereMiss() { // algebra line is essential std::string xmlShape = "<sphere id=\"shape\"> "; - xmlShape += "<centre x=\"4.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="4.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -66,7 +66,7 @@ public: void testSphereHit() { // algebra line is essential std::string xmlShape = "<sphere id=\"shape\"> "; - xmlShape += "<centre x=\"0.67\" y=\"0.33\" z=\"1.32\" /> "; + xmlShape += R"(<centre x="0.67" y="0.33" z="1.32" /> )"; xmlShape += "<radius val=\"0.05\" /> "; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -77,8 +77,8 @@ public: void testCylinderHit() { // algebra line is essential std::string xmlShape = "<cylinder id=\"shape\"> "; - xmlShape += "<centre-of-bottom-base x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre-of-bottom-base x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "<height val=\"3\" /> "; xmlShape += "</cylinder>"; @@ -90,8 +90,8 @@ public: void testInfiniteCylinderHit() { // algebra line is essential std::string xmlShape = "<infinite-cylinder id=\"shape\"> "; - xmlShape += "<centre x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "</infinite-cylinder>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -102,8 +102,8 @@ public: void testConeHitNoMonitors() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"-1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="-1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height val=\"4\" /> "; xmlShape += "</cone>"; diff --git a/Framework/DataHandling/test/FindDetectorsParTest.h b/Framework/DataHandling/test/FindDetectorsParTest.h index a55f1b77af5f5109c689be4c7cd7aa3d5d59943a..5d9785001adf4d766333e00ddf5ef9307c461f33 100644 --- a/Framework/DataHandling/test/FindDetectorsParTest.h +++ b/Framework/DataHandling/test/FindDetectorsParTest.h @@ -490,8 +490,8 @@ private: cont[2] = " 2. 3. -4. 5. 6. 2"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto &i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -503,8 +503,8 @@ private: cont[3] = "3. 4. -5. 6. 7. 3"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto &i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -516,8 +516,8 @@ private: cont[3] = "10 0 5.000 6.000 7.000 8.0000 3"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto &i : cont) { + testFile << i << '\n'; } testFile.close(); } @@ -527,8 +527,8 @@ private: cont[1] = "10 0 5.000 6.000 7.000 8.0000 1"; std::ofstream testFile(fileName); - for (size_t i = 0; i < cont.size(); i++) { - testFile << cont[i] << '\n'; + for (const auto &i : cont) { + testFile << i << '\n'; } testFile.close(); } diff --git a/Framework/DataHandling/test/LoadCalFileTest.h b/Framework/DataHandling/test/LoadCalFileTest.h index 2dfcf9897d6eb4cf136a78e634809b34f783e17b..d4724f78271a73fff6c2ea9cddd998c628b22d1d 100644 --- a/Framework/DataHandling/test/LoadCalFileTest.h +++ b/Framework/DataHandling/test/LoadCalFileTest.h @@ -125,8 +125,8 @@ public: } void tearDown() override { - for (size_t i = 0; i < loadAlgPtrArray.size(); i++) { - delete loadAlgPtrArray[i]; + for (auto &i : loadAlgPtrArray) { + delete i; } loadAlgPtrArray.clear(); diff --git a/Framework/DataHandling/test/LoadDetectorInfoTest.h b/Framework/DataHandling/test/LoadDetectorInfoTest.h index d7fe7bcb642188a80233601fb25a3e8ef1240292..dbdf54376538e206908a62fef20a2471aa7c43db 100644 --- a/Framework/DataHandling/test/LoadDetectorInfoTest.h +++ b/Framework/DataHandling/test/LoadDetectorInfoTest.h @@ -69,13 +69,14 @@ void writeSmallDatFile(const std::string &filename) { " w_y w_z f_x f_y f_z a_x " " a_y a_z det_1 det_2 det_3 " "det4\n"; - for (int i = 0; i < SmallTestDatFile::NDETECTS; ++i) { - file << i << "\t" << delta[i] << "\t" << det_l2[i] << "\t" << code[i] - << "\t" << det_theta[i] << "\t" << det_phi[i] << "\t" << NOTUSED - << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED << "\t" + for (int detector = 0; detector < SmallTestDatFile::NDETECTS; ++detector) { + file << detector << "\t" << delta[detector] << "\t" << det_l2[detector] + << "\t" << code[detector] << "\t" << det_theta[detector] << "\t" + << det_phi[detector] << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED - << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << pressure[i] << "\t" - << wallThick[i] << "\t" << NOTUSED << '\n'; + << "\t" << NOTUSED << "\t" << NOTUSED << "\t" << NOTUSED << "\t" + << NOTUSED << "\t" << pressure[detector] << "\t" << wallThick[detector] + << "\t" << NOTUSED << '\n'; } file.close(); } @@ -301,8 +302,8 @@ public: // read the parameters from some random detectors, they're parameters are // all set to the same thing - for (int i = 0; i < NUMRANDOM; ++i) { - const size_t detIndex = detInfo.indexOf(DETECTS[i]); + for (int detector : DETECTS) { + const size_t detIndex = detInfo.indexOf(detector); const auto &det = detInfo.detector(detIndex); Parameter_sptr par = pmap.getRecursive(&det, "TubePressure"); diff --git a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h index 0520c1e4b6013ddf6d296a82fe9d3a47f9a15644..b69047bccc78c54b60df834933b8105457e747f4 100644 --- a/Framework/DataHandling/test/LoadEmptyInstrumentTest.h +++ b/Framework/DataHandling/test/LoadEmptyInstrumentTest.h @@ -180,7 +180,7 @@ public: TS_ASSERT_DELTA(param->value<double>(), 32.0, 0.0001); param = paramMap.get(&det, "boevs"); - TS_ASSERT(param == NULL); + TS_ASSERT(param == nullptr); param = paramMap.getRecursive(&det, "boevs", "double"); TS_ASSERT_DELTA(param->value<double>(), 8.0, 0.0001); @@ -780,7 +780,7 @@ public: // And finally demonstrate that the get() method does not perform recursive // look-up param = paramMap.get(&det1, "tube_pressure2"); - TS_ASSERT(param == NULL); + TS_ASSERT(param == nullptr); AnalysisDataService::Instance().remove(wsName); } diff --git a/Framework/DataHandling/test/LoadEventNexusTest.h b/Framework/DataHandling/test/LoadEventNexusTest.h index 5dc3e8407b32d71270e186b3b8d67b879c523b54..c49541b5900776cee35717aad404ea4a01f5126f 100644 --- a/Framework/DataHandling/test/LoadEventNexusTest.h +++ b/Framework/DataHandling/test/LoadEventNexusTest.h @@ -295,9 +295,9 @@ public: double max = events.begin()->tof(); double min = events.begin()->tof(); - for (size_t j = 0; j < events.size(); ++j) { - max = events[j].tof() > max ? events[j].tof() : max; - min = events[j].tof() < min ? events[j].tof() : min; + for (auto &event : events) { + max = event.tof() > max ? event.tof() : max; + min = event.tof() < min ? event.tof() : min; } TSM_ASSERT("The max TOF in the workspace should be equal to or less than " "the filtered cut-off", diff --git a/Framework/DataHandling/test/LoadEventPreNexus2Test.h b/Framework/DataHandling/test/LoadEventPreNexus2Test.h index 35bb8cd208d371b6cac8cf526e5f1f8d78e5d6bf..9203e17325b48d9651498fefb8016e2e3a95435e 100644 --- a/Framework/DataHandling/test/LoadEventPreNexus2Test.h +++ b/Framework/DataHandling/test/LoadEventPreNexus2Test.h @@ -135,8 +135,8 @@ public: Types::Core::DateAndTime start = it->first; std::vector<TofEvent> events1 = ew->getSpectrum(1000).getEvents(); - for (size_t i = 0; i < events1.size(); i++) { - std::cout << (events1[i].pulseTime() - start) << " sec \n"; + for (auto &event : events1) { + std::cout << (event.pulseTime() - start) << " sec \n"; } } diff --git a/Framework/DataHandling/test/LoadISISNexusTest.h b/Framework/DataHandling/test/LoadISISNexusTest.h index bd8897282c52686f7f13acf630f4d7e5ca8d20bf..d5a63f9f7abf83d67123591d00d7667b74d9e333 100644 --- a/Framework/DataHandling/test/LoadISISNexusTest.h +++ b/Framework/DataHandling/test/LoadISISNexusTest.h @@ -483,8 +483,8 @@ public: boost::dynamic_pointer_cast<MatrixWorkspace>(grpWs->getItem(0)); MatrixWorkspace_sptr ws2 = boost::dynamic_pointer_cast<MatrixWorkspace>(grpWs->getItem(1)); - TS_ASSERT(ws1 != NULL); - TS_ASSERT(ws2 != NULL); + TS_ASSERT(ws1 != nullptr); + TS_ASSERT(ws2 != nullptr); // Check that workspace 1 has the correct period data, and no other period // log data checkPeriodLogData(ws1, 1); diff --git a/Framework/DataHandling/test/LoadInstrumentTest.h b/Framework/DataHandling/test/LoadInstrumentTest.h index 5e5c37231351524e22468611614c418f1af33f8c..d8a6a87974f32d47e3abc5aa1e080d6d60112fae 100644 --- a/Framework/DataHandling/test/LoadInstrumentTest.h +++ b/Framework/DataHandling/test/LoadInstrumentTest.h @@ -636,7 +636,7 @@ private: // IDFs_for_UNIT_TESTING/HRPD_Parameters_Test4.xml Parameter_sptr param = paramMap.getRecursive(&(*comp), par, "fitting"); TS_ASSERT(param); - if (param != 0) { + if (param != nullptr) { const FitParameter &fitParam4 = param->value<FitParameter>(); TS_ASSERT(fitParam4.getTie().compare("") == 0); TS_ASSERT(fitParam4.getFunction().compare("BackToBackExponential") == 0); diff --git a/Framework/DataHandling/test/LoadMaskTest.h b/Framework/DataHandling/test/LoadMaskTest.h index dc3f1db1fcf1b6cf89d2d6c02c941b771a2f7e98..9e10583d305e0f1055004f6d2ff1b81145574182 100644 --- a/Framework/DataHandling/test/LoadMaskTest.h +++ b/Framework/DataHandling/test/LoadMaskTest.h @@ -532,8 +532,8 @@ public: ss << "</detids>\n"; } - for (size_t i = 0; i < banks.size(); i++) { - ss << "<component>bank" << banks[i] << "</component>\n"; + for (int bank : banks) { + ss << "<component>bank" << bank << "</component>\n"; } // 4. End of file @@ -552,8 +552,8 @@ public: std::stringstream ss; // 1. Single spectra - for (size_t i = 0; i < singlespectra.size(); i++) { - ss << singlespectra[i] << " "; + for (int i : singlespectra) { + ss << i << " "; } ss << '\n'; diff --git a/Framework/DataHandling/test/LoadNexusMonitorsTest.h b/Framework/DataHandling/test/LoadNexusMonitorsTest.h index 7051fab7658ad221c483f1574a17bbd09a438fb7..b1a87e19a1eb3d00f84184491b0b949dea58fc0c 100644 --- a/Framework/DataHandling/test/LoadNexusMonitorsTest.h +++ b/Framework/DataHandling/test/LoadNexusMonitorsTest.h @@ -167,8 +167,8 @@ public: // Count output workspaces int ws_count = 0; auto props = ld1.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) - if ((*iter)->type() == "Workspace") + for (auto &prop : props) + if (prop->type() == "Workspace") ws_count++; // Version 1 has an issue that produces additional output workspaces for @@ -191,8 +191,8 @@ public: // Count output workspaces ws_count = 0; props = ld2.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) - if ((*iter)->type() == "Workspace") + for (auto &prop : props) + if (prop->type() == "Workspace") ws_count++; // Version 2 always produces one OutputWorkspace, which may be a group diff --git a/Framework/DataHandling/test/LoadNexusProcessedTest.h b/Framework/DataHandling/test/LoadNexusProcessedTest.h index b28faff22c4c5b38d87c0c85244439fbc7cd0e4f..82ee05ae66f2ae5fbe81d2f789c4b89c474e0aab 100644 --- a/Framework/DataHandling/test/LoadNexusProcessedTest.h +++ b/Framework/DataHandling/test/LoadNexusProcessedTest.h @@ -280,8 +280,8 @@ public: TS_ASSERT_EQUALS(ws->getSpectrum(4).getNumberEvents(), 100); // Do the comparison algo to check that they really are the same - origWS->sortAll(TOF_SORT, NULL); - ws->sortAll(TOF_SORT, NULL); + origWS->sortAll(TOF_SORT, nullptr); + ws->sortAll(TOF_SORT, nullptr); IAlgorithm_sptr alg2 = AlgorithmManager::Instance().createUnmanaged("CompareWorkspaces"); @@ -724,7 +724,7 @@ public: "IDFs_for_UNIT_TESTING/MINITOPAZ_Definition.xml"); InstrumentDefinitionParser parser(filename, "MINITOPAZ", Strings::loadFile(filename)); - auto instrument = parser.parseXML(NULL); + auto instrument = parser.parseXML(nullptr); peaksTestWS->populateInstrumentParameters(); peaksTestWS->setInstrument(instrument); @@ -769,7 +769,7 @@ public: "IDFs_for_UNIT_TESTING/MINITOPAZ_Definition.xml"); InstrumentDefinitionParser parser(filename, "MINITOPAZ", Strings::loadFile(filename)); - auto instrument = parser.parseXML(NULL); + auto instrument = parser.parseXML(nullptr); peaksTestWS->populateInstrumentParameters(); peaksTestWS->setInstrument(instrument); diff --git a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h index 1f8f61470db0cc871a9f511f1d9233c69666537e..8184605518f67230b83a6e81a990049ed2086ede 100644 --- a/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h +++ b/Framework/DataHandling/test/LoadRawSaveNxsLoadNxsTest.h @@ -150,8 +150,8 @@ public: // std::cerr << "Count = " << i.use_count(); boost::shared_ptr<const IComponent> source = i->getSource(); - TS_ASSERT(source != NULL); - if (source != NULL) { + TS_ASSERT(source != nullptr); + if (source != nullptr) { TS_ASSERT_EQUALS(source->getName(), "source"); TS_ASSERT_DELTA(detectorInfo.sourcePosition().Y(), 0.0, 0.01); diff --git a/Framework/DataHandling/test/LoadTest.h b/Framework/DataHandling/test/LoadTest.h index 55305d0dbeb8965e9edfa3689682b8a79964d1b3..8ffc38e739f04daa02a1957a8e31871403cd7d4d 100644 --- a/Framework/DataHandling/test/LoadTest.h +++ b/Framework/DataHandling/test/LoadTest.h @@ -112,16 +112,16 @@ public: const char *loadraw_props[NUMPROPS] = { "SpectrumMin", "SpectrumMax", "SpectrumList", "Cache", "LoadLogFiles"}; // Basic load has no additional loader properties - for (size_t i = 0; i < NUMPROPS; ++i) { - TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), false); + for (auto &loadraw_prop : loadraw_props) { + TS_ASSERT_EQUALS(loader.existsProperty(loadraw_prop), false); } // After setting the file property, the algorithm should have aquired the // appropriate properties TS_ASSERT_THROWS_NOTHING( loader.setPropertyValue("Filename", "IRS38633.raw")); // Now - for (size_t i = 0; i < NUMPROPS; ++i) { - TS_ASSERT_EQUALS(loader.existsProperty(loadraw_props[i]), true); + for (auto &loadraw_prop : loadraw_props) { + TS_ASSERT_EQUALS(loader.existsProperty(loadraw_prop), true); } // Did it find the right loader diff --git a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h index 91b4f68969c14b4843eac69e56828ca5a79bbd3b..8e7b8951df5cc96a61a3836ae25ed27dc0781b20 100644 --- a/Framework/DataHandling/test/MaskDetectorsInShapeTest.h +++ b/Framework/DataHandling/test/MaskDetectorsInShapeTest.h @@ -28,13 +28,13 @@ public: void testCuboidMiss() { std::string xmlShape = "<cuboid id=\"shape\"> "; - xmlShape += "<left-front-bottom-point x=\"0.005\" y=\"-0.1\" z=\"0.0\" /> "; + xmlShape += R"(<left-front-bottom-point x="0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<left-front-top-point x=\"0.005\" y=\"-0.1\" z=\"0.0001\" /> "; + R"(<left-front-top-point x="0.005" y="-0.1" z="0.0001" /> )"; xmlShape += - "<left-back-bottom-point x=\"-0.005\" y=\"-0.1\" z=\"0.0\" /> "; + R"(<left-back-bottom-point x="-0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<right-front-bottom-point x=\"0.005\" y=\"0.1\" z=\"0.0\" /> "; + R"(<right-front-bottom-point x="0.005" y="0.1" z="0.0" /> )"; xmlShape += "</cuboid> "; xmlShape += "<algebra val=\"shape\" /> "; @@ -44,8 +44,8 @@ public: void testConeHitNoMonitors() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"-1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="-1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height val=\"4\" /> "; xmlShape += "</cone>"; diff --git a/Framework/DataHandling/test/MaskDetectorsTest.h b/Framework/DataHandling/test/MaskDetectorsTest.h index a23e6800cf403ec0dc631646f78a6790c550042e..caee36084d2b7066b68d67be6dd327de4fbb36d0 100644 --- a/Framework/DataHandling/test/MaskDetectorsTest.h +++ b/Framework/DataHandling/test/MaskDetectorsTest.h @@ -668,7 +668,7 @@ public: // Make workspace to act as mask const auto numMaskWSSpec = inputWS->getInstrument()->getNumberDetectors(); auto maskWs = WorkspaceCreationHelper::create2DWorkspaceBinned( - static_cast<int>(numMaskWSSpec), 1, 0, 0); + static_cast<int>(numMaskWSSpec), 1, 0., 0.); maskWs->setInstrument(inputWS->getInstrument()); for (size_t i = 0; i < maskWs->getNumberHistograms(); ++i) { maskWs->mutableY(i)[0] = 1.0; @@ -736,7 +736,7 @@ public: // Make workspace to act as mask const auto numMaskWSSpec = inputWS->getInstrument()->getNumberDetectors(); auto maskWs = WorkspaceCreationHelper::create2DWorkspaceBinned( - static_cast<int>(numMaskWSSpec), 1, 0, 0); + static_cast<int>(numMaskWSSpec), 1, 0., 0.); maskWs->setInstrument(inputWS->getInstrument()); for (size_t i = 0; i < maskWs->getNumberHistograms(); ++i) { maskWs->mutableY(i)[0] = 1.0; diff --git a/Framework/DataHandling/test/SaveAscii2Test.h b/Framework/DataHandling/test/SaveAscii2Test.h index c3b86dacfdcae0ec544d1986597514b49bbdb5f2..26ef97cb2da2a6be07adbe308058cf9807dc7a8e 100644 --- a/Framework/DataHandling/test/SaveAscii2Test.h +++ b/Framework/DataHandling/test/SaveAscii2Test.h @@ -68,8 +68,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 2); @@ -78,8 +78,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 8.66667); @@ -165,8 +165,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 2); @@ -175,8 +175,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 8.66667); @@ -589,8 +589,8 @@ public: std::getline(in, binlines); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 0); TS_ASSERT_EQUALS(bins[1], 4); @@ -599,8 +599,8 @@ public: std::getline(in, binlines); bins.clear(); boost::split(binstr, binlines, boost::is_any_of(",")); - for (size_t i = 0; i < binstr.size(); i++) { - bins.push_back(boost::lexical_cast<double>(binstr.at(i))); + for (const auto &i : binstr) { + bins.push_back(boost::lexical_cast<double>(i)); } TS_ASSERT_EQUALS(bins[0], 1.66667); TS_ASSERT_EQUALS(bins[1], 17.3333); diff --git a/Framework/DataHandling/test/SaveFocusedXYETest.h b/Framework/DataHandling/test/SaveFocusedXYETest.h index 89b3e53dc0ea0e41f15d82084f75ccc7534c2f94..0598964d8241375ee226f30b34dd7ca1ef61cb61 100644 --- a/Framework/DataHandling/test/SaveFocusedXYETest.h +++ b/Framework/DataHandling/test/SaveFocusedXYETest.h @@ -68,7 +68,7 @@ public: "# Data for spectra :0", "TEMP 1 ", "# Time-of-flight Y E"}; size_t lineNumber = 1; - while (lineNumber <= MAX_HEADER_LENGTH) { + while (lineNumber <= expectedHeader.size()) { getline(filestrm, line); TS_ASSERT_EQUALS(line, expectedHeader[lineNumber - 1]); lineNumber++; @@ -114,7 +114,7 @@ public: while (getline(filestrm, line)) { lineNumber++; std::istringstream is(line); - if (lineNumber <= MAX_HEADER_LENGTH) { + if (lineNumber <= expectedHeader.size()) { TS_ASSERT_EQUALS(is.str(), expectedHeader[lineNumber - 1]); continue; } @@ -145,6 +145,79 @@ public: focusfile.remove(); AnalysisDataService::Instance().remove(resultWS); } + + void testHistogramTOPAS() { + using namespace Mantid::API; + using namespace Mantid::DataObjects; + Workspace2D_sptr workspace = + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 3, 1.0, 1.0); + workspace->getAxis(0)->unit() = + Mantid::Kernel::UnitFactory::Instance().create("TOF"); + + TS_ASSERT_DIFFERS(workspace, boost::shared_ptr<Workspace2D>()); + std::string resultWS("result"); + AnalysisDataService::Instance().add(resultWS, workspace); + + Mantid::DataHandling::SaveFocusedXYE saveXYE; + TS_ASSERT_THROWS_NOTHING(saveXYE.initialize()); + TS_ASSERT_EQUALS(saveXYE.isInitialized(), true); + + saveXYE.setPropertyValue("InputWorkspace", resultWS); + std::string filename("focussed.test"); + saveXYE.setPropertyValue("Filename", filename); + filename = saveXYE.getPropertyValue("Filename"); // absolute path + saveXYE.setProperty("SplitFiles", false); + saveXYE.setProperty("Format", "TOPAS"); + + TS_ASSERT_THROWS_NOTHING(saveXYE.execute()); + + Poco::File focusfile(filename); + TS_ASSERT_EQUALS(focusfile.exists(), true); + + std::ifstream filestrm(filename.c_str()); + std::string line; + const std::vector<std::string> expectedHeader{ + "' File generated by Mantid, Instrument ", + "' The X-axis unit is: Time-of-flight, The Y-axis unit is: ", + "' Data for spectra :0", "' Spectrum 1 ", + "' Time-of-flight Y E"}; + int bin_no(1); + size_t lineNumber = 0; + while (getline(filestrm, line)) { + lineNumber++; + std::istringstream is(line); + if (lineNumber <= expectedHeader.size()) { + TS_ASSERT_EQUALS(is.str(), expectedHeader[lineNumber - 1]); + continue; + } + double x(0.0), y(0.0), e(0.); + is >> x >> y >> e; + switch (bin_no) { + case 1: + TS_ASSERT_DELTA(x, 1.5, m_tol); + TS_ASSERT_DELTA(y, 2.0, m_tol); + TS_ASSERT_DELTA(e, M_SQRT2, m_tol); + break; + case 2: + TS_ASSERT_DELTA(x, 2.5, m_tol); + TS_ASSERT_DELTA(y, 2.0, m_tol); + TS_ASSERT_DELTA(e, M_SQRT2, m_tol); + break; + case 3: + TS_ASSERT_DELTA(x, 3.5, m_tol); + TS_ASSERT_DELTA(y, 2.0, m_tol); + TS_ASSERT_DELTA(e, M_SQRT2, m_tol); + break; + default: + TS_ASSERT(false); + } + ++bin_no; + } + filestrm.close(); + focusfile.remove(); + AnalysisDataService::Instance().remove(resultWS); + } + void testSaveFocusedXYEWorkspaceGroups() { using namespace Mantid::API; using namespace Mantid::DataObjects; diff --git a/Framework/DataHandling/test/SavePHXTest.h b/Framework/DataHandling/test/SavePHXTest.h index 1bb461aabe3a8507ac48b16e7526a454bdac27fe..e64993177daf4c788af676c2ce12297c76de5f31 100644 --- a/Framework/DataHandling/test/SavePHXTest.h +++ b/Framework/DataHandling/test/SavePHXTest.h @@ -139,8 +139,8 @@ public: sample_value[0] = (float)spTW->rowCount(); } else { size_t ii = 0; - for (size_t i = 0; i < column_name.size(); i++) { - sample_value[ii] = (spTW->cell_cast<float>(ic - 1, column_name[i])); + for (const auto &i : column_name) { + sample_value[ii] = (spTW->cell_cast<float>(ic - 1, i)); ii++; if (ii == 1) ii = 2; // scip second column in the file, which contains 0; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.h b/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.h index 2617c286f005453e294a3dc2a58d4a9506ad925f..37c91d33fba227ca282c5675c789e692e3e3a069 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.h @@ -158,9 +158,11 @@ public: // ------------------------------------------- std::vector<Mantid::Kernel::VMD> getVertexes() const override; - coord_t *getVertexesArray(size_t &numVertices) const override; - coord_t *getVertexesArray(size_t &numVertices, const size_t outDimensions, - const bool *maskDim) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const override; void transformDimensions(std::vector<double> &scaling, std::vector<double> &offset) override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.tcc b/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.tcc index 99c8f9aab90bacfe24b8c71410afc1224a9a89e7..fdd9f3d261ef679450fa86abff786138a750bdae 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.tcc +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxBase.tcc @@ -1,12 +1,11 @@ #include "MantidDataObjects/MDBoxBase.h" #include "MantidDataObjects/MDEvent.h" +#include "MantidKernel/make_unique.h" #include "MantidKernel/System.h" #include "MantidKernel/VMD.h" #include <boost/make_shared.hpp> #include <limits> -//using NeXus::File; - namespace Mantid { namespace DataObjects { @@ -135,13 +134,13 @@ TMDE(std::vector<Mantid::Kernel::VMD> MDBoxBase)::getVertexes() const { * @param[out] numVertices :: returns the number of vertices in the array. * @return the bare array. This should be deleted by the caller! * */ -TMDE(coord_t *MDBoxBase)::getVertexesArray(size_t &numVertices) const { +TMDE(std::unique_ptr<coord_t[]> MDBoxBase)::getVertexesArray(size_t &numVertices) const { // How many vertices does one box have? 2^nd, or bitwise shift left 1 by nd // bits numVertices = 1 << nd; // Allocate the array of the right size - auto out = new coord_t[nd * numVertices]; + auto out = Kernel::make_unique<coord_t[]>(nd * numVertices); // For each vertex, increase an integeer for (size_t i = 0; i < numVertices; ++i) { @@ -184,7 +183,7 @@ TMDE(coord_t *MDBoxBase)::getVertexesArray(size_t &numVertices) const { *caller! * @throw if outDimensions == 0 * */ -TMDE(coord_t *MDBoxBase)::getVertexesArray(size_t &numVertices, +TMDE(std::unique_ptr<coord_t[]> MDBoxBase)::getVertexesArray(size_t &numVertices, const size_t outDimensions, const bool *maskDim) const { if (outDimensions == 0) @@ -195,7 +194,7 @@ TMDE(coord_t *MDBoxBase)::getVertexesArray(size_t &numVertices, numVertices = (size_t)1 << outDimensions; // Allocate the array of the right size - auto out = new coord_t[outDimensions * numVertices]; + auto out = Kernel::make_unique<coord_t[]>(outDimensions * numVertices); // For each vertex, increase an integeer for (size_t i = 0; i < numVertices; ++i) { diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.h b/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.h index a76277444340ca730c60f6349cf37286794f418f..29e4b02904390d216215a057bddfc43f38cb6636 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.h @@ -54,10 +54,12 @@ public: signal_t getError() const override; - coord_t *getVertexesArray(size_t &numVertices, const size_t outDimensions, - const bool *maskDim) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const override; - coord_t *getVertexesArray(size_t &numVertices) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const override; Mantid::Kernel::VMD getCenter() const override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.tcc b/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.tcc index d5df20e7669093ba2fdf4b1a20c52b8862f33028..c15a92b207aacc62ef9a9fa2e76131501272dc43 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.tcc +++ b/Framework/DataObjects/inc/MantidDataObjects/MDBoxIterator.tcc @@ -258,11 +258,11 @@ TMDE(signal_t MDBoxIterator)::getSignal() const { TMDE(signal_t MDBoxIterator)::getError() const { return m_current->getError(); } /// Return a list of vertexes defining the volume pointed to -TMDE(coord_t *MDBoxIterator)::getVertexesArray(size_t &numVertices) const { +TMDE(std::unique_ptr<coord_t[]> MDBoxIterator)::getVertexesArray(size_t &numVertices) const { return m_current->getVertexesArray(numVertices); } -TMDE(coord_t *MDBoxIterator)::getVertexesArray(size_t &numVertices, +TMDE(std::unique_ptr<coord_t[]> MDBoxIterator)::getVertexesArray(size_t &numVertices, const size_t outDimensions, const bool *maskDim) const { return m_current->getVertexesArray(numVertices, outDimensions, maskDim); diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.h index d111f289f1d299322263c4c481b17128eb235392..e29bdc73fd90c6f56d1c25699256203692ef1f96 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.h @@ -73,7 +73,7 @@ public: uint64_t getNEvents() const override { return getNPoints(); } /// Creates a new iterator pointing to the first cell (box) in the workspace - std::vector<Mantid::API::IMDIterator *> createIterators( + std::vector<std::unique_ptr<Mantid::API::IMDIterator>> createIterators( size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.tcc b/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.tcc index e1e125b7e903a1994aa7a9291dcdefc995bac156..a67a2f30a5994f0942083ef6c2ae06d45b8f4804 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.tcc +++ b/Framework/DataObjects/inc/MantidDataObjects/MDEventWorkspace.tcc @@ -239,7 +239,7 @@ TMDE(std::vector<coord_t> MDEventWorkspace)::estimateResolution() const { * @param suggestedNumCores :: split iterator over this many cores. * @param function :: Optional MDImplicitFunction limiting the iterator */ -TMDE(std::vector<Mantid::API::IMDIterator *> MDEventWorkspace)::createIterators( +TMDE(std::vector<std::unique_ptr<Mantid::API::IMDIterator>> MDEventWorkspace)::createIterators( size_t suggestedNumCores, Mantid::Geometry::MDImplicitFunction *function) const { // Get all the boxes in this workspaces @@ -261,13 +261,13 @@ TMDE(std::vector<Mantid::API::IMDIterator *> MDEventWorkspace)::createIterators( numCores = 1; // Create one iterator per core, splitting evenly amongst spectra - std::vector<API::IMDIterator *> out; + std::vector<std::unique_ptr<API::IMDIterator>> out; for (size_t i = 0; i < numCores; i++) { size_t begin = (i * numElements) / numCores; size_t end = ((i + 1) * numElements) / numCores; if (end > numElements) end = numElements; - out.push_back(new MDBoxIterator<MDE, nd>(boxes, begin, end)); + out.push_back(Kernel::make_unique<MDBoxIterator<MDE, nd>>(boxes, begin, end)); } return out; } diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h index 2b4fcd178c1f41f3d3b1d5156f7ffa3867b5c35f..ae75cdc5c36ca47c59dc25a77dd320d60e2eb16b 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspace.h @@ -78,7 +78,7 @@ public: uint64_t getNPoints() const override { return m_length; } /// get number of contributed events uint64_t getNEvents() const override; - std::vector<Mantid::API::IMDIterator *> createIterators( + std::vector<std::unique_ptr<Mantid::API::IMDIterator>> createIterators( size_t suggestedNumCores = 1, Mantid::Geometry::MDImplicitFunction *function = nullptr) const override; @@ -174,7 +174,8 @@ public: void applyImplicitFunction(Mantid::Geometry::MDImplicitFunction *function, signal_t signal, signal_t errorSquared); - coord_t *getVertexesArray(size_t linearIndex, size_t &numVertices) const; + std::unique_ptr<coord_t[]> getVertexesArray(size_t linearIndex, + size_t &numVertices) const; Kernel::VMD getCenter(size_t linearIndex) const override; @@ -426,7 +427,7 @@ private: } MDHistoWorkspace *doCloneEmpty() const override { - return new MDHistoWorkspace(0); + return new MDHistoWorkspace(nullptr); } void makeSingleBinWithNaN(std::vector<coord_t> &x, std::vector<signal_t> &y, diff --git a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h index 622a532b6230fd0710c0e51be0c55aaba40150b3..ea83dda0416fb7edc3038a740e1507965ab30c79 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h +++ b/Framework/DataObjects/inc/MantidDataObjects/MDHistoWorkspaceIterator.h @@ -95,10 +95,12 @@ public: signal_t getError() const override; - coord_t *getVertexesArray(size_t &numVertices) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices) const override; - coord_t *getVertexesArray(size_t &numVertices, const size_t outDimensions, - const bool *maskDim) const override; + std::unique_ptr<coord_t[]> + getVertexesArray(size_t &numVertices, const size_t outDimensions, + const bool *maskDim) const override; Mantid::Kernel::VMD getCenter() const override; diff --git a/Framework/DataObjects/inc/MantidDataObjects/Peak.h b/Framework/DataObjects/inc/MantidDataObjects/Peak.h index 82b728b8712148070993bc0af967029daef132f2..40ae08376c44336c13162fea741a17cc8f418ab4 100644 --- a/Framework/DataObjects/inc/MantidDataObjects/Peak.h +++ b/Framework/DataObjects/inc/MantidDataObjects/Peak.h @@ -121,6 +121,7 @@ public: void setWavelength(double wavelength) override; double getWavelength() const override; double getScattering() const override; + double getAzimuthal() const override; double getDSpacing() const override; double getTOF() const override; @@ -149,6 +150,8 @@ public: int getCol() const override; void setRow(int m_row); void setCol(int m_col); + void setPeakNumber(int m_peakNumber) override; + int getPeakNumber() const override; virtual Mantid::Kernel::V3D getDetPos() const override; double getL1() const override; @@ -242,6 +245,9 @@ private: double m_orig_K; double m_orig_L; + // keep peak number + int m_peakNumber; + /// List of contributing detectors IDs std::set<int> m_detIDs; diff --git a/Framework/DataObjects/src/FractionalRebinning.cpp b/Framework/DataObjects/src/FractionalRebinning.cpp index ff317cc6cce6395dd66c2e835c69e0ea3bd6092b..6e9ee3b1a49dbdad84d1246ae4a98979182efdbc 100644 --- a/Framework/DataObjects/src/FractionalRebinning.cpp +++ b/Framework/DataObjects/src/FractionalRebinning.cpp @@ -152,9 +152,9 @@ double polyArea(T &v1, T &v2, Ts &&... vertices) { * @param yAxis The output data vertical axis * @param inputQ The input quadrilateral * @param y_start The starting y-axis index - * @param y_end The starting y-axis index + * @param y_end The ending y-axis index * @param x_start The starting x-axis index - * @param x_end The starting x-axis index + * @param x_end The ending x-axis index * @param areaInfo Output vector of indices and areas of overlapping bins */ void calcTrapezoidYIntersections( @@ -202,8 +202,8 @@ void calcTrapezoidYIntersections( // Step 1 - construct the left/right bin lims on the lines of the y-grid. const double NaN = std::numeric_limits<double>::quiet_NaN(); const double DBL_EPS = std::numeric_limits<double>::epsilon(); - std::vector<double> leftLim(nx * (ny + 1), NaN); - std::vector<double> rightLim(nx * (ny + 1), NaN); + std::vector<double> leftLim((nx + 1) * (ny + 1), NaN); + std::vector<double> rightLim((nx + 1) * (ny + 1), NaN); auto x0_it = xAxis.begin() + x_start; auto x1_it = xAxis.begin() + x_end + 1; auto y0_it = yAxis.begin() + y_start; @@ -239,7 +239,7 @@ void calcTrapezoidYIntersections( auto right_it = std::upper_bound(x0_it, x1_it, right_val); if (right_it != x1_it) { rightLim[right_it - x0_it - 1 + yjx] = right_val; - } else if (yAxis[yj + y_start] < ur_y) { + } else if (yAxis[yj + y_start] < ur_y && nx > 0) { right_it = x1_it - 1; rightLim[nx - 1 + yjx] = lr_x; } @@ -277,12 +277,15 @@ void calcTrapezoidYIntersections( left_it--; if (right_it == x1_it) right_it--; - size_t li = left_it - x0_it - 1; + size_t li = (left_it > x0_it) ? (left_it - x0_it - 1) : 0; + size_t ri = (right_it > x0_it) ? (right_it - x0_it - 1) : 0; leftLim[li + yjx] = (mTop >= 0) ? val : ll_x; - rightLim[right_it - x0_it - 1 + yjx] = (mTop >= 0) ? lr_x : val; - for (auto x_it = left_it; x_it != right_it; x_it++) { - leftLim[li + 1 + yjx] = *x_it; - rightLim[li++ + yjx] = *x_it; + rightLim[ri + yjx] = (mTop >= 0) ? lr_x : val; + if (left_it < right_it && right_it != x1_it) { + for (auto x_it = left_it; x_it != right_it; x_it++) { + leftLim[li + 1 + yjx] = *x_it; + rightLim[li++ + yjx] = *x_it; + } } } } diff --git a/Framework/DataObjects/src/MDHistoWorkspace.cpp b/Framework/DataObjects/src/MDHistoWorkspace.cpp index 0ee1c53816899dad502f6af9bcbc9939187ca45f..d93a75a35536329e5dcba2abe0abe0dcf270616d 100644 --- a/Framework/DataObjects/src/MDHistoWorkspace.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspace.cpp @@ -1,21 +1,22 @@ +#include "MantidDataObjects/MDHistoWorkspace.h" +#include "MantidAPI/IMDIterator.h" +#include "MantidAPI/IMDWorkspace.h" +#include "MantidDataObjects/MDFramesToSpecialCoordinateSystem.h" +#include "MantidDataObjects/MDHistoWorkspaceIterator.h" #include "MantidGeometry/MDGeometry/IMDDimension.h" +#include "MantidGeometry/MDGeometry/MDDimensionExtents.h" #include "MantidGeometry/MDGeometry/MDGeometryXMLBuilder.h" +#include "MantidGeometry/MDGeometry/MDHistoDimension.h" #include "MantidKernel/System.h" #include "MantidKernel/Utils.h" #include "MantidKernel/VMD.h" #include "MantidKernel/WarningSuppressions.h" -#include "MantidDataObjects/MDHistoWorkspace.h" -#include "MantidDataObjects/MDHistoWorkspaceIterator.h" -#include "MantidDataObjects/MDFramesToSpecialCoordinateSystem.h" -#include "MantidGeometry/MDGeometry/MDHistoDimension.h" -#include "MantidGeometry/MDGeometry/MDDimensionExtents.h" -#include <map> -#include "MantidAPI/IMDWorkspace.h" -#include "MantidAPI/IMDIterator.h" -#include <boost/scoped_array.hpp> +#include "MantidKernel/make_unique.h" #include <boost/make_shared.hpp> #include <boost/optional.hpp> +#include <boost/scoped_array.hpp> #include <cmath> +#include <map> using namespace Mantid::Kernel; using namespace Mantid::Geometry; @@ -303,8 +304,9 @@ void MDHistoWorkspace::applyImplicitFunction( * @param[out] numVertices :: returns the number of vertices in the array. * @return the bare array. This should be deleted by the caller! * */ -coord_t *MDHistoWorkspace::getVertexesArray(size_t linearIndex, - size_t &numVertices) const { +std::unique_ptr<coord_t[]> +MDHistoWorkspace::getVertexesArray(size_t linearIndex, + size_t &numVertices) const { // How many vertices does one box have? 2^nd, or bitwise shift left 1 by nd // bits numVertices = static_cast<size_t>(1) @@ -319,7 +321,7 @@ coord_t *MDHistoWorkspace::getVertexesArray(size_t linearIndex, numDimensions, linearIndex, m_indexMaker, m_indexMax, dimIndexes); // The output vertexes coordinates - auto out = new coord_t[numDimensions * numVertices]; + auto out = Kernel::make_unique<coord_t[]>(numDimensions * numVertices); for (size_t i = 0; i < numVertices; ++i) { size_t outIndex = i * numDimensions; // Offset the 0th box by the position of this linear index, in each @@ -421,7 +423,8 @@ size_t MDHistoWorkspace::getLinearIndexAtCoord(const coord_t *coords) const { *call. * @return MDHistoWorkspaceIterator vector */ -std::vector<Mantid::API::IMDIterator *> MDHistoWorkspace::createIterators( +std::vector<std::unique_ptr<Mantid::API::IMDIterator>> +MDHistoWorkspace::createIterators( size_t suggestedNumCores, Mantid::Geometry::MDImplicitFunction *function) const { size_t numCores = suggestedNumCores; @@ -434,7 +437,7 @@ std::vector<Mantid::API::IMDIterator *> MDHistoWorkspace::createIterators( numCores = 1; // Create one iterator per core, splitting evenly amongst spectra - std::vector<IMDIterator *> out; + std::vector<std::unique_ptr<IMDIterator>> out; for (size_t i = 0; i < numCores; i++) { size_t begin = (i * numElements) / numCores; size_t end = ((i + 1) * numElements) / numCores; @@ -446,8 +449,8 @@ std::vector<Mantid::API::IMDIterator *> MDHistoWorkspace::createIterators( if (function) clonedFunction = new Mantid::Geometry::MDImplicitFunction(*function); - out.push_back( - new MDHistoWorkspaceIterator(this, clonedFunction, begin, end)); + out.push_back(Kernel::make_unique<MDHistoWorkspaceIterator>( + this, clonedFunction, begin, end)); } return out; } diff --git a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp index 03277600b8d0619d9ed03d099bf8930f339f51a0..ffc3b2e39ef24328476f619e0d4a7b0470072975 100644 --- a/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp +++ b/Framework/DataObjects/src/MDHistoWorkspaceIterator.cpp @@ -384,14 +384,16 @@ signal_t MDHistoWorkspaceIterator::getError() const { } //---------------------------------------------------------------------------------------------- /// Return a list of vertexes defining the volume pointed to -coord_t *MDHistoWorkspaceIterator::getVertexesArray(size_t &numVertices) const { +std::unique_ptr<coord_t[]> +MDHistoWorkspaceIterator::getVertexesArray(size_t &numVertices) const { // The MDHistoWorkspace takes care of this return m_ws->getVertexesArray(m_pos, numVertices); } -coord_t *MDHistoWorkspaceIterator::getVertexesArray(size_t &numVertices, - const size_t outDimensions, - const bool *maskDim) const { +std::unique_ptr<coord_t[]> +MDHistoWorkspaceIterator::getVertexesArray(size_t &numVertices, + const size_t outDimensions, + const bool *maskDim) const { // Do the same thing as is done in the MDBoxBase UNUSED_ARG(numVertices); UNUSED_ARG(outDimensions); diff --git a/Framework/DataObjects/src/Peak.cpp b/Framework/DataObjects/src/Peak.cpp index c99817f9474018bccf908368be0cb7c016f3abcb..a0fbcb21920c6f1b70cd9d041558fe0b3b9a7af9 100644 --- a/Framework/DataObjects/src/Peak.cpp +++ b/Framework/DataObjects/src/Peak.cpp @@ -29,7 +29,7 @@ Peak::Peak() m_finalEnergy(0.), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0), - m_peakShape(boost::make_shared<NoShape>()) { + m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); } @@ -49,7 +49,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), - m_orig_H(0), m_orig_K(0), m_orig_L(0), + m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -76,7 +76,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer), m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), - m_orig_H(0), m_orig_K(0), m_orig_L(0), + m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -99,7 +99,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, : m_H(0), m_K(0), m_L(0), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), - m_orig_H(0), m_orig_K(0), m_orig_L(0), + m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -121,7 +121,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, : m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), - m_orig_H(0), m_orig_K(0), m_orig_L(0), + m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); @@ -145,7 +145,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, int m_detectorID, : m_H(HKL[0]), m_K(HKL[1]), m_L(HKL[2]), m_intensity(0), m_sigmaIntensity(0), m_binCount(0), m_GoniometerMatrix(goniometer), m_InverseGoniometerMatrix(goniometer), m_runNumber(0), m_monitorCount(0), - m_orig_H(0), m_orig_K(0), m_orig_L(0), + m_orig_H(0), m_orig_K(0), m_orig_L(0), m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -169,7 +169,7 @@ Peak::Peak(const Geometry::Instrument_const_sptr &m_inst, double scattering, m_binCount(0), m_GoniometerMatrix(3, 3, true), m_InverseGoniometerMatrix(3, 3, true), m_runNumber(0), m_monitorCount(0), m_row(-1), m_col(-1), m_orig_H(0), m_orig_K(0), m_orig_L(0), - m_peakShape(boost::make_shared<NoShape>()) { + m_peakNumber(0), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); this->setInstrument(m_inst); this->setWavelength(m_Wavelength); @@ -197,8 +197,9 @@ Peak::Peak(const Peak &other) m_row(other.m_row), m_col(other.m_col), sourcePos(other.sourcePos), samplePos(other.samplePos), detPos(other.detPos), m_orig_H(other.m_orig_H), m_orig_K(other.m_orig_K), - m_orig_L(other.m_orig_L), m_detIDs(other.m_detIDs), - m_peakShape(other.m_peakShape->clone()), convention(other.convention) {} + m_orig_L(other.m_orig_L), m_peakNumber(other.m_peakNumber), + m_detIDs(other.m_detIDs), m_peakShape(other.m_peakShape->clone()), + convention(other.convention) {} //---------------------------------------------------------------------------------------------- /** Constructor making a Peak from IPeak interface @@ -218,6 +219,7 @@ Peak::Peak(const Geometry::IPeak &ipeak) m_runNumber(ipeak.getRunNumber()), m_monitorCount(ipeak.getMonitorCount()), m_row(ipeak.getRow()), m_col(ipeak.getCol()), m_orig_H(0.), m_orig_K(0.), m_orig_L(0.), + m_peakNumber(ipeak.getPeakNumber()), m_peakShape(boost::make_shared<NoShape>()) { convention = Kernel::ConfigService::Instance().getString("Q.convention"); if (fabs(m_InverseGoniometerMatrix.Invert()) < 1e-8) @@ -422,6 +424,15 @@ double Peak::getScattering() const { return detDir.angle(beamDir); } +// ------------------------------------------------------------------------------------- +/** Calculate the azimuthal angle of the peak */ +double Peak::getAzimuthal() const { + // The detector is at 2 theta scattering angle + V3D detDir = detPos - samplePos; + + return atan2(detDir.Y(), detDir.X()); +} + // ------------------------------------------------------------------------------------- /** Calculate the d-spacing of the peak, in 1/Angstroms */ double Peak::getDSpacing() const { @@ -878,6 +889,11 @@ int Peak::getRow() const { return m_row; } * Returns -1 if it could not find it. */ int Peak::getCol() const { return m_col; } +// ------------------------------------------------------------------------------------- +/**Returns the unique peak number + * Returns -1 if it could not find it. */ +int Peak::getPeakNumber() const { return m_peakNumber; } + // ------------------------------------------------------------------------------------- /** For RectangularDetectors only, sets the row (y) of the pixel of the * detector. @@ -890,6 +906,13 @@ void Peak::setRow(int m_row) { this->m_row = m_row; } * @param m_col :: col value */ void Peak::setCol(int m_col) { this->m_col = m_col; } +// ------------------------------------------------------------------------------------- +/** Sets the unique peak number + * @param m_peakNumber :: unique peak number value */ +void Peak::setPeakNumber(int m_peakNumber) { + this->m_peakNumber = m_peakNumber; +} + // ------------------------------------------------------------------------------------- /** Return the detector position vector */ Mantid::Kernel::V3D Peak::getDetPos() const { return detPos; } @@ -941,6 +964,8 @@ double Peak::getValueByColName(const std::string &name_in) const { return this->getRow(); else if (name == "col") return this->getCol(); + else if (name == "peaknumber") + return double(this->getPeakNumber()); else throw std::runtime_error( "Peak::getValueByColName() unknown column or column is not a number: " + diff --git a/Framework/DataObjects/src/PeakColumn.cpp b/Framework/DataObjects/src/PeakColumn.cpp index 57a6634f4b223d96b97b4c53539eb4fbaa38db1d..891e199908ab275e30a2c6c570e9b6ddc761bbf9 100644 --- a/Framework/DataObjects/src/PeakColumn.cpp +++ b/Framework/DataObjects/src/PeakColumn.cpp @@ -31,7 +31,7 @@ const std::string typeFromName(const std::string &name) { // We should enter the critical section if the map has not been fully filled. // Be sure to keep the value tested against in sync with the number of inserts // below - if (TYPE_INDEX.size() != 17) { + if (TYPE_INDEX.size() != 18) { PARALLEL_CRITICAL(fill_column_index_map) { if (TYPE_INDEX.empty()) // check again inside the critical block { @@ -53,6 +53,7 @@ const std::string typeFromName(const std::string &name) { TYPE_INDEX.emplace("Col", "double"); TYPE_INDEX.emplace("QLab", "V3D"); TYPE_INDEX.emplace("QSample", "V3D"); + TYPE_INDEX.emplace("PeakNumber", "int"); // If adding an entry, be sure to increment the size comparizon in the // first line } @@ -152,6 +153,8 @@ void PeakColumn::print(size_t index, std::ostream &s) const { s << std::fixed << std::setprecision(m_hklPrec) << peak.getK(); } else if (m_name == "l") { s << std::fixed << std::setprecision(m_hklPrec) << peak.getL(); + } else if (m_name == "PeakNumber") { + s << peak.getPeakNumber(); } else s << peak.getValueByColName(m_name); s.flags(fflags); @@ -291,6 +294,9 @@ const void *PeakColumn::void_pointer(size_t index) const { } else if (m_name == "RunNumber") { value = peak.getRunNumber(); return boost::get<int>(&value); + } else if (m_name == "PeakNumber") { + value = peak.getPeakNumber(); + return boost::get<int>(&value); } else if (m_name == "DetID") { value = peak.getDetectorID(); return boost::get<int>(&value); diff --git a/Framework/DataObjects/src/PeaksWorkspace.cpp b/Framework/DataObjects/src/PeaksWorkspace.cpp index eab92ec1da6acffa556b7c14a23d8dce15c316f5..7cbe6aea457b9b5fb8b05259675843ad0cf027dd 100644 --- a/Framework/DataObjects/src/PeaksWorkspace.cpp +++ b/Framework/DataObjects/src/PeaksWorkspace.cpp @@ -162,8 +162,8 @@ void PeaksWorkspace::removePeaks(std::vector<int> badPeaks) { std::remove_if(peaks.begin(), peaks.end(), [&ip, badPeaks](Peak &pk) { (void)pk; ip++; - for (auto ibp = badPeaks.begin(); ibp != badPeaks.end(); ++ibp) { - if (*ibp == ip) + for (int badPeak : badPeaks) { + if (badPeak == ip) return true; } return false; @@ -630,6 +630,7 @@ void PeaksWorkspace::initColumns() { addPeakColumn("Col"); addPeakColumn("QLab"); addPeakColumn("QSample"); + addPeakColumn("PeakNumber"); } //--------------------------------------------------------------------------------------------- @@ -694,6 +695,7 @@ void PeaksWorkspace::saveNexus(::NeXus::File *file) const { std::vector<double> dSpacing(np); std::vector<double> TOF(np); std::vector<int> runNumber(np); + std::vector<int> peakNumber(np); std::vector<double> goniometerMatrix(9 * np); std::vector<std::string> shapes(np); @@ -715,6 +717,7 @@ void PeaksWorkspace::saveNexus(::NeXus::File *file) const { dSpacing[i] = p.getDSpacing(); TOF[i] = p.getTOF(); runNumber[i] = p.getRunNumber(); + peakNumber[i] = p.getPeakNumber(); { Matrix<double> gm = p.getGoniometerMatrix(); goniometerMatrix[9 * i] = gm[0][0]; @@ -861,6 +864,14 @@ void PeaksWorkspace::saveNexus(::NeXus::File *file) const { file->putAttr("units", "Not known"); // Units may need changing when known file->closeData(); + // Peak Number column + file->writeData("column_17", peakNumber); + file->openData("column_17"); + file->putAttr("name", "Peak Number"); + file->putAttr("interpret_as", specifyInteger); + file->putAttr("units", "Not known"); // Units may need changing when known + file->closeData(); + // Goniometer Matrix Column std::vector<int> array_dims; array_dims.push_back(static_cast<int>(peaks.size())); diff --git a/Framework/DataObjects/src/Workspace2D.cpp b/Framework/DataObjects/src/Workspace2D.cpp index 169ce00da4cd24479f3eaa77e855efe94c98bf03..883abc4fd8576a061122cd9bcdf3b1ad3458c8de 100644 --- a/Framework/DataObjects/src/Workspace2D.cpp +++ b/Framework/DataObjects/src/Workspace2D.cpp @@ -107,8 +107,8 @@ void Workspace2D::init(const HistogramData::Histogram &histogram) { Histogram1D spec(initializedHistogram.xMode(), initializedHistogram.yMode()); spec.setHistogram(initializedHistogram); - for (size_t i = 0; i < data.size(); i++) { - data[i] = new Histogram1D(spec); + for (auto &i : data) { + i = new Histogram1D(spec); } // Add axes that reference the data diff --git a/Framework/DataObjects/test/EventListTest.h b/Framework/DataObjects/test/EventListTest.h index 7d1e65d52deba0bf4d57033a8e12843e985d06f5..30b5161f1118f42bbd28559f0c09a25a130fe075 100644 --- a/Framework/DataObjects/test/EventListTest.h +++ b/Framework/DataObjects/test/EventListTest.h @@ -1434,7 +1434,7 @@ public: void test_convertUnitsViaTof_failures() { DummyUnit1 fromUnit; DummyUnit2 toUnit; - TS_ASSERT_THROWS_ANYTHING(el.convertUnitsViaTof(NULL, NULL)); + TS_ASSERT_THROWS_ANYTHING(el.convertUnitsViaTof(nullptr, nullptr)); // Not initalized TS_ASSERT_THROWS_ANYTHING(el.convertUnitsViaTof(&fromUnit, &toUnit)); } @@ -1826,9 +1826,8 @@ public: } // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto &output : outputs) { + delete output.second; } return; @@ -1874,9 +1873,8 @@ public: } // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto &output : outputs) { + delete output.second; } return; @@ -2312,9 +2310,8 @@ public: TS_ASSERT_EQUALS(e7->getNumberEvents(), 1); // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto &output : outputs) { + delete output.second; } return; @@ -2385,9 +2382,8 @@ public: // TS_ASSERT_EQUALS(e7->getNumberEvents(), 1); // Clean the pointers - for (std::map<int, EventList *>::iterator im = outputs.begin(); - im != outputs.end(); ++im) { - delete im->second; + for (auto &output : outputs) { + delete output.second; } return; diff --git a/Framework/DataObjects/test/EventWorkspaceTest.h b/Framework/DataObjects/test/EventWorkspaceTest.h index ff9c4f94fed807a2ae8ed22aa38b431051783bf2..b873a8cbae6d99bf0a0413200db9b725ae144051 100644 --- a/Framework/DataObjects/test/EventWorkspaceTest.h +++ b/Framework/DataObjects/test/EventWorkspaceTest.h @@ -691,10 +691,10 @@ public: EventWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<EventWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<EventWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -702,9 +702,9 @@ public: EventWorkspace_const_sptr wsCastConst; EventWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (EventWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (EventWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } @@ -722,10 +722,10 @@ public: IEventWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<IEventWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<IEventWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -733,9 +733,9 @@ public: IEventWorkspace_const_sptr wsCastConst; IEventWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (IEventWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (IEventWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } diff --git a/Framework/DataObjects/test/FakeMDTest.h b/Framework/DataObjects/test/FakeMDTest.h index aa8ce321bca46edbc2ff09defc670717983c2ec0..e7c5b133b2228d5a0a576224e406785a03dd74ae 100644 --- a/Framework/DataObjects/test/FakeMDTest.h +++ b/Framework/DataObjects/test/FakeMDTest.h @@ -150,8 +150,6 @@ public: it->next(); ++counter; } - - delete it; } }; diff --git a/Framework/DataObjects/test/GroupingWorkspaceTest.h b/Framework/DataObjects/test/GroupingWorkspaceTest.h index a2c232cbcf140400301b01a5c558ef81cee8104b..04f7fb02a072eb847871a8ccb539dc5d44789285 100644 --- a/Framework/DataObjects/test/GroupingWorkspaceTest.h +++ b/Framework/DataObjects/test/GroupingWorkspaceTest.h @@ -109,10 +109,10 @@ public: GroupingWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<GroupingWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<GroupingWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -120,9 +120,9 @@ public: GroupingWorkspace_const_sptr wsCastConst; GroupingWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (GroupingWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (GroupingWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/MDBoxBaseTest.h b/Framework/DataObjects/test/MDBoxBaseTest.h index 046b09bca0a43ba1b59f88dfd46ce21bc28eee24..8af6937d8c1c44ea82c15774b33f4d574a83f8fb 100644 --- a/Framework/DataObjects/test/MDBoxBaseTest.h +++ b/Framework/DataObjects/test/MDBoxBaseTest.h @@ -326,7 +326,7 @@ public: b.setExtents(0, -10.0, 10.0); b.setExtents(1, -4.0, 6.0); size_t numVertexes = 0; - coord_t *v = b.getVertexesArray(numVertexes); + auto v = b.getVertexesArray(numVertexes); TS_ASSERT_EQUALS(numVertexes, 4); TS_ASSERT_EQUALS(v[0], -10.0); TS_ASSERT_EQUALS(v[0 + 1], -4.0); @@ -336,7 +336,6 @@ public: TS_ASSERT_EQUALS(v[4 + 1], 6.0); TS_ASSERT_EQUALS(v[6], 10.0); TS_ASSERT_EQUALS(v[6 + 1], 6.0); - delete[] v; } /** Get vertexes as a bare array, @@ -346,21 +345,18 @@ public: b.setExtents(0, -10.0, 10.0); b.setExtents(1, -4.0, 6.0); size_t numVertexes = 0; - coord_t *v; bool maskDim[2] = {true, false}; - v = b.getVertexesArray(numVertexes, 1, maskDim); + auto v = b.getVertexesArray(numVertexes, 1, maskDim); TS_ASSERT_EQUALS(numVertexes, 2); TS_ASSERT_EQUALS(v[0], -10.0); TS_ASSERT_EQUALS(v[1], 10.0); - delete[] v; bool maskDim2[2] = {false, true}; v = b.getVertexesArray(numVertexes, 1, maskDim2); TS_ASSERT_EQUALS(numVertexes, 2); TS_ASSERT_EQUALS(v[0], -4.0); TS_ASSERT_EQUALS(v[1], 6.0); - delete[] v; } /** Get vertexes as a bare array, @@ -371,11 +367,10 @@ public: b.setExtents(1, -4.0, 6.0); b.setExtents(2, -2.0, 8.0); size_t numVertexes = 0; - coord_t *v; // 3D projected down to 2D in X/Y bool maskDim[3] = {true, true, false}; - v = b.getVertexesArray(numVertexes, 2, maskDim); + auto v = b.getVertexesArray(numVertexes, 2, maskDim); TS_ASSERT_EQUALS(numVertexes, 4); TS_ASSERT_EQUALS(v[0], -10.0); TS_ASSERT_EQUALS(v[0 + 1], -4.0); @@ -385,7 +380,6 @@ public: TS_ASSERT_EQUALS(v[4 + 1], 6.0); TS_ASSERT_EQUALS(v[6], 10.0); TS_ASSERT_EQUALS(v[6 + 1], 6.0); - delete[] v; // Can't give 0 dimensions. TS_ASSERT_THROWS_ANYTHING(v = b.getVertexesArray(numVertexes, 0, maskDim)); @@ -396,7 +390,6 @@ public: TS_ASSERT_EQUALS(numVertexes, 2); TS_ASSERT_EQUALS(v[0], -4.0); TS_ASSERT_EQUALS(v[1], 6.0); - delete[] v; // 3D projected down to 2D in Y/Z bool maskDim3[3] = {false, true, true}; @@ -410,7 +403,6 @@ public: TS_ASSERT_EQUALS(v[4 + 1], 8.0); TS_ASSERT_EQUALS(v[6], 6.0); TS_ASSERT_EQUALS(v[6 + 1], 8.0); - delete[] v; } void xtest_sortBoxesByFilePos() { @@ -456,8 +448,7 @@ public: b.setExtents(2, -7.0, 7.0); for (size_t i = 0; i < 1000000; i++) { size_t numVertexes; - coord_t *v = b.getVertexesArray(numVertexes); - delete[] v; + auto v = b.getVertexesArray(numVertexes); } } @@ -469,8 +460,7 @@ public: bool maskDim[3] = {true, true, false}; for (size_t i = 0; i < 1000000; i++) { size_t numVertexes; - coord_t *v = b.getVertexesArray(numVertexes, 2, maskDim); - delete[] v; + auto v = b.getVertexesArray(numVertexes, 2, maskDim); } } @@ -482,8 +472,7 @@ public: b.setExtents(3, -6.0, 6.0); for (size_t i = 0; i < 1000000; i++) { size_t numVertexes; - coord_t *v = b.getVertexesArray(numVertexes); - delete[] v; + auto v = b.getVertexesArray(numVertexes); } } void test_getVertexesArray_4D_projected_to_3D() { @@ -495,8 +484,7 @@ public: b.setExtents(3, -6.0, 6.0); for (size_t i = 0; i < 1000000; i++) { size_t numVertexes; - coord_t *v = b.getVertexesArray(numVertexes, 3, maskDim); - delete[] v; + auto v = b.getVertexesArray(numVertexes, 3, maskDim); } } }; diff --git a/Framework/DataObjects/test/MDBoxFlatTreeTest.h b/Framework/DataObjects/test/MDBoxFlatTreeTest.h index 3b3cfc2c991e4cb323bc2f8e04249bee292a497c..3fcd866ec461a6c02cc4ca9d300e3393dc031ec2 100644 --- a/Framework/DataObjects/test/MDBoxFlatTreeTest.h +++ b/Framework/DataObjects/test/MDBoxFlatTreeTest.h @@ -93,8 +93,8 @@ public: if (!Boxes[i]->isBox()) gridIndices.push_back(i); } - for (size_t i = 0; i < gridIndices.size(); ++i) { - delete Boxes[gridIndices[i]]; + for (auto gridIndex : gridIndices) { + delete Boxes[gridIndex]; } // Clean up file diff --git a/Framework/DataObjects/test/MDBoxIteratorTest.h b/Framework/DataObjects/test/MDBoxIteratorTest.h index 1ee036378ca7192c86e4a356cfe3602733442a00..93fc5a6f58966a92d18a7796658c7388fcb74db9 100644 --- a/Framework/DataObjects/test/MDBoxIteratorTest.h +++ b/Framework/DataObjects/test/MDBoxIteratorTest.h @@ -83,7 +83,7 @@ public: //-------------------------------------------------------------------------------------- void test_ctor_with_null_box_fails() { using boxit_t = MDBoxIterator<MDLeanEvent<1>, 1>; - TS_ASSERT_THROWS_ANYTHING(new boxit_t(NULL, 10, false);); + TS_ASSERT_THROWS_ANYTHING(new boxit_t(nullptr, 10, false);); } //-------------------------------------------------------------------------------------- diff --git a/Framework/DataObjects/test/MDBoxSaveableTest.h b/Framework/DataObjects/test/MDBoxSaveableTest.h index 12c374388df199b5d74224a47e64d7dc963e4d71..fdf5fb46e9bf0a5be5113c9c6275fb618c7f803c 100644 --- a/Framework/DataObjects/test/MDBoxSaveableTest.h +++ b/Framework/DataObjects/test/MDBoxSaveableTest.h @@ -254,7 +254,7 @@ public: MDBox<MDLeanEvent<3>, 3> *b = dynamic_cast<MDBox<MDLeanEvent<3>, 3> *>(gb->getChild(22)); TSM_ASSERT_EQUALS("Child has 8 events", b->getNPoints(), 8); - TSM_ASSERT("The child is also saveabele", b->getISaveable() != NULL); + TSM_ASSERT("The child is also saveabele", b->getISaveable() != nullptr); if (!b->getISaveable()) return; @@ -753,7 +753,7 @@ public: bin.m_max[d] = 4.0; bin.m_signal = 0; } - c.centerpointBin(bin, NULL); + c.centerpointBin(bin, nullptr); TS_ASSERT_DELTA(bin.m_signal, 8.0, 1e-4); TS_ASSERT_DELTA(bin.m_errorSquared, 8.0, 1e-4); } @@ -840,14 +840,13 @@ public: size_t numOnDisk = 0; uint64_t eventsOnDisk = 0; uint64_t maxFilePos = 0; - for (size_t i = 0; i < boxes.size(); i++) { - API::IMDNode *box = boxes[i]; + for (auto box : boxes) { TS_ASSERT_EQUALS(box->getNPoints(), num_repeat); auto mdbox = dynamic_cast<MDBox<MDE, 2> *>(box); TS_ASSERT(mdbox); auto pIO = mdbox->getISaveable(); - TS_ASSERT(pIO != NULL); + TS_ASSERT(pIO != nullptr); if (!pIO) continue; diff --git a/Framework/DataObjects/test/MDBoxTest.h b/Framework/DataObjects/test/MDBoxTest.h index 0f64cf5f143a114f949186afb4f85db5e7d24f3b..ab9b56a8a17f71ba2fa5b3924f94f585e2bf6f0f 100644 --- a/Framework/DataObjects/test/MDBoxTest.h +++ b/Framework/DataObjects/test/MDBoxTest.h @@ -407,7 +407,7 @@ public: // First, a bin object that holds everything MDBin<MDLeanEvent<2>, 2> bin; // Perform the centerpoint binning - box.centerpointBin(bin, NULL); + box.centerpointBin(bin, nullptr); // 100 events = 100 weight. TS_ASSERT_DELTA(bin.m_signal, 100.0, 1e-4); TS_ASSERT_DELTA(bin.m_errorSquared, 150.0, 1e-4); @@ -419,7 +419,7 @@ public: bin.m_max[0] = 6.0; bin.m_min[1] = 1.0; bin.m_max[1] = 3.0; - box.centerpointBin(bin, NULL); + box.centerpointBin(bin, nullptr); TS_ASSERT_DELTA(bin.m_signal, 4.0, 1e-4); TS_ASSERT_DELTA(bin.m_errorSquared, 6.0, 1e-4); } @@ -585,8 +585,8 @@ public: coord_t centroid[2] = {0, 0}; signal_t signal = 0.0; b.centroidSphere(sphere, 400., centroid, signal); - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float &d : centroid) + d /= static_cast<coord_t>(signal); // This should be the weighted centroid TS_ASSERT_DELTA(signal, 6.000, 0.001); @@ -595,11 +595,11 @@ public: // --- Reset and reduce the radius ------ signal = 0; - for (size_t d = 0; d < 2; d++) - centroid[d] = 0.0; + for (float &d : centroid) + d = 0.0; b.centroidSphere(sphere, 16., centroid, signal); - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float &d : centroid) + d /= static_cast<coord_t>(signal); // Only one event was contained TS_ASSERT_DELTA(signal, 2.000, 0.001); TS_ASSERT_DELTA(centroid[0], 2.000, 0.001); diff --git a/Framework/DataObjects/test/MDEventWorkspaceTest.h b/Framework/DataObjects/test/MDEventWorkspaceTest.h index 72e27f6bb92a454bb14ebb62ff8038403fac0bde..f1e0a555200a0039340d8858eb6589ee24d7e191 100644 --- a/Framework/DataObjects/test/MDEventWorkspaceTest.h +++ b/Framework/DataObjects/test/MDEventWorkspaceTest.h @@ -42,7 +42,7 @@ private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { - Mantid::API::IMDIterator *it = ws->createIterator(NULL); + auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; for (; counter < it->getDataSize(); ++counter) { @@ -51,7 +51,6 @@ private: } it->next(1); // Doesn't perform skipping on masked, bins, but next() does. } - delete it; return numberMasked; } @@ -123,7 +122,7 @@ public: /*Test that the boxes were deep copied and that their BoxController pointers * have been updated too.*/ - std::vector<API::IMDNode *> originalBoxes(0, NULL); + std::vector<API::IMDNode *> originalBoxes(0, nullptr); ew3.getBox()->getBoxes(originalBoxes, 10000, false); std::vector<API::IMDNode *> copiedBoxes; @@ -238,42 +237,34 @@ public: //------------------------------------------------------------------------------------- /** Create an IMDIterator */ void test_createIterator() { - MDEventWorkspace3 *ew = new MDEventWorkspace3(); + auto ew = boost::make_shared<MDEventWorkspace3>(); BoxController_sptr bc = ew->getBoxController(); bc->setSplitInto(4); ew->splitBox(); - IMDIterator *it = ew->createIterator(); + auto it = ew->createIterator(); TS_ASSERT(it); TS_ASSERT_EQUALS(it->getDataSize(), 4 * 4 * 4); TS_ASSERT(it->next()); - delete it; - auto *mdfunction = new MDImplicitFunction(); - it = ew->createIterator(mdfunction); + MDImplicitFunction mdfunction; + it = ew->createIterator(&mdfunction); TS_ASSERT(it); TS_ASSERT_EQUALS(it->getDataSize(), 4 * 4 * 4); TS_ASSERT(it->next()); - delete mdfunction; - delete it; - delete ew; } //------------------------------------------------------------------------------------- /** Create several IMDIterators to run them in parallel */ void test_createIterators() { - MDEventWorkspace3 *ew = new MDEventWorkspace3(); + auto ew = boost::make_shared<MDEventWorkspace3>(); BoxController_sptr bc = ew->getBoxController(); bc->setSplitInto(4); ew->splitBox(); - std::vector<IMDIterator *> iterators = ew->createIterators(3); + auto iterators = ew->createIterators(3); TS_ASSERT_EQUALS(iterators.size(), 3); TS_ASSERT_EQUALS(iterators[0]->getDataSize(), 21); TS_ASSERT_EQUALS(iterators[1]->getDataSize(), 21); TS_ASSERT_EQUALS(iterators[2]->getDataSize(), 22); - - for (size_t i = 0; i < 3; ++i) - delete iterators[i]; - delete ew; } //------------------------------------------------------------------------------------- @@ -379,7 +370,7 @@ public: for (size_t i = 0; i < 50; i++) { ew->addEvent(ev); } - ew->splitAllIfNeeded(NULL); + ew->splitAllIfNeeded(nullptr); ew->refreshCache(); // Create dimension-aligned line through the workspace @@ -792,10 +783,10 @@ public: IMDEventWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<IMDEventWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<IMDEventWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -803,9 +794,9 @@ public: IMDEventWorkspace_const_sptr wsCastConst; IMDEventWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (IMDEventWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (IMDEventWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; @@ -855,7 +846,7 @@ public: std::cout << "Starting Workspace splitting performance test, single " "threaded with " << nBoxes << " events \n"; Kernel::Timer clock; - m_ws->splitAllIfNeeded(NULL); + m_ws->splitAllIfNeeded(nullptr); std::cout << "Finished Workspace splitting performance test, single threaded in " << clock.elapsed() << " sec\n"; diff --git a/Framework/DataObjects/test/MDGridBoxTest.h b/Framework/DataObjects/test/MDGridBoxTest.h index 0ae4ef00585b969ee93c53c9db40380f693f33f3..ff4538f21b275b5f5805b9c7acefc8616a46855a 100644 --- a/Framework/DataObjects/test/MDGridBoxTest.h +++ b/Framework/DataObjects/test/MDGridBoxTest.h @@ -261,10 +261,10 @@ public: new MDGridBox<MDLeanEvent<1>, 1>(*box, newBoxController); auto boxes = box1->getBoxes(); - for (size_t i = 0; i < boxes.size(); ++i) { + for (auto &box : boxes) { TSM_ASSERT_EQUALS( "All child boxes should have the same box controller as the parent.", - newBoxController, boxes[i]->getBoxController()); + newBoxController, box->getBoxController()); } delete newBoxController; delete box1; @@ -295,11 +295,10 @@ public: TS_ASSERT_EQUALS(g->getChild(i - 2)->getParent(), g); } // MDGridBox will delete the children that it pulled in but the rest need to - // be - // taken care of manually + // be taken care of manually size_t indices[5] = {0, 1, 12, 13, 14}; - for (size_t i = 0; i < 5; ++i) - delete boxes[indices[i]]; + for (auto index : indices) + delete boxes[index]; delete g; delete bcc; } @@ -329,9 +328,9 @@ public: // Check the boxes std::vector<MDBoxBase<MDLeanEvent<3>, 3> *> boxes = g->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 10 * 5 * 2); - for (size_t i = 0; i < boxes.size(); i++) { + for (auto &boxBase : boxes) { MDBox<MDLeanEvent<3>, 3> *box = - dynamic_cast<MDBox<MDLeanEvent<3>, 3> *>(boxes[i]); + dynamic_cast<MDBox<MDLeanEvent<3>, 3> *>(boxBase); TS_ASSERT(box); } MDBox<MDLeanEvent<3>, 3> *box; @@ -445,7 +444,7 @@ public: } // You must refresh the cache after adding individual events. - superbox->refreshCache(NULL); + superbox->refreshCache(nullptr); // superbox->refreshCentroid(NULL); TS_ASSERT_EQUALS(superbox->getNPoints(), 3); @@ -473,7 +472,7 @@ public: } TS_ASSERT_EQUALS(superbox->getNPoints(), 3); - superbox->refreshCache(NULL); + superbox->refreshCache(nullptr); TS_ASSERT_EQUALS(superbox->getNPoints(), 6); // Retrieve the 0th grid box @@ -602,8 +601,8 @@ public: parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 54); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 1.51); } // --- Now leaf-only --- @@ -611,8 +610,8 @@ public: parent->getBoxes(boxes, 3, true, function); TS_ASSERT_EQUALS(boxes.size(), 40); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 1.51); } // Limit by another plane @@ -622,18 +621,18 @@ public: boxes.clear(); parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 33); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 2.99); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 1.51); + TS_ASSERT(box->getExtents(0).getMin() <= 2.99); } // Same, leaf only boxes.clear(); parent->getBoxes(boxes, 3, true, function); TS_ASSERT_EQUALS(boxes.size(), 24); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 1.51); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 2.99); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 1.51); + TS_ASSERT(box->getExtents(0).getMin() <= 2.99); } // ----- Infinitely thin plane for an implicit function ------------ @@ -675,11 +674,11 @@ public: parent->getBoxes(boxes, 3, false, function); TS_ASSERT_EQUALS(boxes.size(), 46); // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 3.00); - TS_ASSERT(boxes[i]->getExtents(1).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(1).getMin() <= 3.00); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 2.00); + TS_ASSERT(box->getExtents(0).getMin() <= 3.00); + TS_ASSERT(box->getExtents(1).getMax() >= 2.00); + TS_ASSERT(box->getExtents(1).getMin() <= 3.00); } // -- Leaf only --- @@ -690,11 +689,11 @@ public: 16 + 4 * 4 + 4); // 16 in the center one + 4x4 at the 4 edges + 4 at the corners // The boxes extents make sense - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT(boxes[i]->getExtents(0).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(0).getMin() <= 3.00); - TS_ASSERT(boxes[i]->getExtents(1).getMax() >= 2.00); - TS_ASSERT(boxes[i]->getExtents(1).getMin() <= 3.00); + for (auto &box : boxes) { + TS_ASSERT(box->getExtents(0).getMax() >= 2.00); + TS_ASSERT(box->getExtents(0).getMin() <= 3.00); + TS_ASSERT(box->getExtents(1).getMax() >= 2.00); + TS_ASSERT(box->getExtents(1).getMin() <= 3.00); } // clean up behind @@ -801,7 +800,7 @@ public: } } // You must refresh the cache after adding individual events. - box->refreshCache(NULL); + box->refreshCache(nullptr); } } @@ -824,7 +823,7 @@ public: size_t numbad = 0; TS_ASSERT_THROWS_NOTHING(numbad = b->addEvents(events);); // Get the right totals again - b->refreshCache(NULL); + b->refreshCache(nullptr); TS_ASSERT_EQUALS(numbad, 0); TS_ASSERT_EQUALS(b->getNPoints(), 100); TS_ASSERT_EQUALS(b->getSignal(), 100 * 2.0); @@ -835,12 +834,12 @@ public: // Get all the boxes contained std::vector<MDBoxBase<MDLeanEvent<2>, 2> *> boxes = b->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 100); - for (size_t i = 0; i < boxes.size(); i++) { - TS_ASSERT_EQUALS(boxes[i]->getNPoints(), 1); - TS_ASSERT_EQUALS(boxes[i]->getSignal(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getErrorSquared(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getSignalNormalized(), 2.0); - TS_ASSERT_EQUALS(boxes[i]->getErrorSquaredNormalized(), 2.0); + for (auto &box : boxes) { + TS_ASSERT_EQUALS(box->getNPoints(), 1); + TS_ASSERT_EQUALS(box->getSignal(), 2.0); + TS_ASSERT_EQUALS(box->getErrorSquared(), 2.0); + TS_ASSERT_EQUALS(box->getSignalNormalized(), 2.0); + TS_ASSERT_EQUALS(box->getErrorSquaredNormalized(), 2.0); } // Now try to add bad events (outside bounds) @@ -851,7 +850,7 @@ public: events.push_back(MDLeanEvent<2>(2.0, 2.0, centers)); } // Get the right totals again - b->refreshCache(NULL); + b->refreshCache(nullptr); // All 4 points get rejected TS_ASSERT_THROWS_NOTHING(numbad = b->addEvents(events);); TS_ASSERT_EQUALS(numbad, 4); @@ -886,7 +885,7 @@ public: TS_ASSERT_THROWS_NOTHING(numbad = b->addEvents(events)); TS_ASSERT_EQUALS(numbad, 3); - b->refreshCache(NULL); + b->refreshCache(nullptr); TS_ASSERT_EQUALS(b->getNPoints(), 1); TS_ASSERT_EQUALS(b->getSignal(), 2.0); TS_ASSERT_EQUALS(b->getErrorSquared(), 2.0); @@ -1006,7 +1005,7 @@ public: TS_ASSERT_THROWS_NOTHING(b0->addEvents(events);); // Split into sub-grid boxes - TS_ASSERT_THROWS_NOTHING(b0->splitAllIfNeeded(NULL);) + TS_ASSERT_THROWS_NOTHING(b0->splitAllIfNeeded(nullptr);) // Dig recursively into the gridded box hierarchies std::vector<ibox_t *> boxes; @@ -1083,8 +1082,7 @@ public: // many events std::vector<ibox_t *> boxes = b->getBoxes(); TS_ASSERT_EQUALS(boxes.size(), 100); - for (size_t i = 0; i < boxes.size(); i++) { - ibox_t *box = boxes[i]; + for (auto box : boxes) { TS_ASSERT_EQUALS(box->getNPoints(), num_repeat); TS_ASSERT(dynamic_cast<gbox_t *>(box)); @@ -1128,7 +1126,7 @@ public: MDBin<MDLeanEvent<2>, 2> bin; bin = makeMDBin2(minX, maxX, minY, maxY); - b->centerpointBin(bin, NULL); + b->centerpointBin(bin, nullptr); TSM_ASSERT_DELTA(message, bin.m_signal, expectedSignal, 1e-5); } @@ -1405,8 +1403,8 @@ public: signal); // Normalized if (signal != 0.0) { - for (size_t d = 0; d < 2; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float &d : centroid) + d /= static_cast<coord_t>(signal); } TSM_ASSERT_DELTA(message, signal, 1.0 * numExpected, 1e-5); @@ -1630,8 +1628,8 @@ public: rng, u); for (size_t i = 0; i < num; ++i) { double centers[3]; - for (size_t d = 0; d < 3; d++) - centers[d] = gen(); + for (double ¢er : centers) + center = gen(); // Create and add the event. events.push_back(MDLeanEvent<3>(1.0, 1.0, centers)); } @@ -1730,12 +1728,12 @@ public: coord_t centroid[3]; for (size_t i = 0; i < 100; i++) { signal = 0; - for (size_t d = 0; d < 3; d++) - centroid[d] = 0.0; + for (float &d : centroid) + d = 0.0; box3b->centroidSphere(sphere, radius * radius, centroid, signal); if (signal != 0.0) { - for (size_t d = 0; d < 3; d++) - centroid[d] /= static_cast<coord_t>(signal); + for (float &d : centroid) + d /= static_cast<coord_t>(signal); } } diff --git a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h index cc63960592dff086b9a55237727bea56a76398b3..6c89feb705d6c7580ea28fc18d145451c2910473 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceIteratorTest.h @@ -79,9 +79,8 @@ public: TS_ASSERT_DELTA(it->getNormalizedSignal(), double(i) / 1.0, 1e-5); TS_ASSERT_DELTA(it->getNormalizedError(), 1.0, 1e-5); size_t numVertices; - coord_t *vertexes = it->getVertexesArray(numVertices); + auto vertexes = it->getVertexesArray(numVertices); TS_ASSERT(vertexes); - delete[] vertexes; TS_ASSERT_EQUALS(it->getNumEvents(), 1); TS_ASSERT_EQUALS(it->getInnerDetectorID(0), 0); TS_ASSERT_EQUALS(it->getInnerRunIndex(0), 0); @@ -126,8 +125,7 @@ public: Mantid::DataObjects::MDHistoWorkspace_sptr ws_sptr(ws); - MDHistoWorkspaceIterator *histoIt = - new MDHistoWorkspaceIterator(ws, function); + auto histoIt = Kernel::make_unique<MDHistoWorkspaceIterator>(ws, function); TSM_ASSERT_EQUALS("The first index hit should be 5 since that is the first " "unmasked and inside function", @@ -136,8 +134,6 @@ public: TSM_ASSERT_EQUALS("The next index hit should be 7 since that is the next " "unmasked and inside function", 7, histoIt->getLinearIndex()); - - delete histoIt; } void test_getNormalizedSignal_with_mask() { @@ -167,8 +163,8 @@ public: Mantid::DataObjects::MDHistoWorkspace_sptr ws_sptr(ws); - MDHistoWorkspaceIterator *histoIt = - dynamic_cast<MDHistoWorkspaceIterator *>(ws->createIterator()); + auto it = ws->createIterator(); + auto histoIt = dynamic_cast<MDHistoWorkspaceIterator *>(it.get()); TSM_ASSERT_EQUALS("Should get the signal value here as data at the iterator" " are unmasked", @@ -180,8 +176,6 @@ public: TSM_ASSERT_EQUALS("Should get the signal value here as data at the iterator" " are unmasked", 3.0, histoIt->getNormalizedSignal()); - - delete histoIt; } void test_iterator_1D() { do_test_iterator(1, 10); } @@ -202,7 +196,7 @@ public: MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2, 10); for (size_t i = 0; i < 100; i++) ws->setSignalAt(i, double(i)); - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws, function); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws, function); TSM_ASSERT("This iterator is valid at the start.", it->valid()); TS_ASSERT_EQUALS(it->getNormalizedSignal(), 0.); @@ -225,8 +219,6 @@ public: it->next(); TS_ASSERT_EQUALS(it->getNormalizedSignal(), 30.); TS_ASSERT(!it->next()); - - delete it; } void test_iterator_2D_implicitFunction_thatExcludesTheStart() { @@ -239,7 +231,7 @@ public: MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2, 10); for (size_t i = 0; i < 100; i++) ws->setSignalAt(i, double(i)); - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws, function); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws, function); TSM_ASSERT("This iterator is valid at the start.", it->valid()); TS_ASSERT_EQUALS(it->getNormalizedSignal(), 4.); @@ -257,8 +249,6 @@ public: TS_ASSERT_EQUALS(it->getNormalizedSignal(), 13.); it->next(); // And so forth.... - - delete it; } void test_iterator_2D_implicitFunction_thatExcludesEverything() { @@ -270,11 +260,9 @@ public: MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2, 10); for (size_t i = 0; i < 100; i++) ws->setSignalAt(i, double(i)); - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws, function); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws, function); TSM_ASSERT("This iterator is not valid at the start.", !it->valid()); - - delete it; } /** Create several parallel iterators */ @@ -286,38 +274,35 @@ public: ws->setSignalAt(i, double(i)); // Make 3 iterators - std::vector<IMDIterator *> iterators = ws->createIterators(3); + auto iterators = ws->createIterators(3); TS_ASSERT_EQUALS(iterators.size(), 3); IMDIterator *it; - it = iterators[0]; + it = iterators[0].get(); TS_ASSERT_DELTA(it->getSignal(), 0.0, 1e-5); TS_ASSERT_EQUALS(it->getDataSize(), 33); TS_ASSERT_DELTA(it->getInnerPosition(0, 0), 0.5, 1e-5); TS_ASSERT_DELTA(it->getInnerPosition(0, 1), 0.5, 1e-5); - it = iterators[1]; + it = iterators[1].get(); TS_ASSERT_DELTA(it->getSignal(), 33.0, 1e-5); TS_ASSERT_EQUALS(it->getDataSize(), 33); TS_ASSERT_DELTA(it->getInnerPosition(0, 0), 3.5, 1e-5); TS_ASSERT_DELTA(it->getInnerPosition(0, 1), 3.5, 1e-5); - it = iterators[2]; + it = iterators[2].get(); TS_ASSERT_DELTA(it->getSignal(), 66.0, 1e-5); TS_ASSERT_EQUALS(it->getDataSize(), 34); TS_ASSERT_DELTA(it->getInnerPosition(0, 0), 6.5, 1e-5); TS_ASSERT_DELTA(it->getInnerPosition(0, 1), 6.5, 1e-5); - - for (size_t i = 0; i < 3; ++i) - delete iterators[i]; } void test_predictable_steps() { MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace(1.0, 2, 10); - MDHistoWorkspaceIterator *histoIt = - dynamic_cast<MDHistoWorkspaceIterator *>(ws->createIterator()); + auto it = ws->createIterator(); + auto histoIt = dynamic_cast<MDHistoWorkspaceIterator *>(it.get()); size_t expected = 0; for (size_t i = 0; i < histoIt->getDataSize(); ++i) { size_t current = histoIt->getLinearIndex(); @@ -326,7 +311,6 @@ public: expected = current + 1; histoIt->next(); } - delete histoIt; } void test_skip_masked_detectors() { @@ -345,8 +329,8 @@ public: Mantid::DataObjects::MDHistoWorkspace_sptr ws_sptr(ws); - MDHistoWorkspaceIterator *histoIt = - dynamic_cast<MDHistoWorkspaceIterator *>(ws_sptr->createIterator()); + auto it = ws_sptr->createIterator(); + auto histoIt = dynamic_cast<MDHistoWorkspaceIterator *>(it.get()); histoIt->next(); TSM_ASSERT_EQUALS( "The first index hit should be 2 since that is the first unmasked one", @@ -355,8 +339,6 @@ public: TSM_ASSERT_EQUALS( "The next index hit should be 5 since that is the next unmasked one", 5, histoIt->getLinearIndex()); - - delete histoIt; } // template<typename ContainerType, typename ElementType> @@ -374,7 +356,7 @@ public: size_t begin = 1; size_t end = 5; - MDHistoWorkspaceIterator iterator(ws.get(), NULL, begin, end); + MDHistoWorkspaceIterator iterator(ws.get(), nullptr, begin, end); TS_ASSERT(iterator.isWithinBounds(begin)); TS_ASSERT(iterator.isWithinBounds(end - 1)); @@ -393,7 +375,7 @@ public: */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At first position /* @@ -401,7 +383,8 @@ public: ^ | */ - std::vector<size_t> neighbourIndexes = findNeighbourMemberFunction(it); + std::vector<size_t> neighbourIndexes = + findNeighbourMemberFunction(it.get()); TS_ASSERT_EQUALS(1, neighbourIndexes.size()); // should be on edge TSM_ASSERT("Neighbour at index 0 is 1", @@ -414,7 +397,7 @@ public: | */ it->next(); - neighbourIndexes = findNeighbourMemberFunction(it); + neighbourIndexes = findNeighbourMemberFunction(it.get()); TS_ASSERT_EQUALS(2, neighbourIndexes.size()); // should be on edge TSM_ASSERT("Neighbours at index 1 includes 0", @@ -429,11 +412,9 @@ public: | */ it->jumpTo(9); - neighbourIndexes = findNeighbourMemberFunction(it); + neighbourIndexes = findNeighbourMemberFunction(it.get()); TSM_ASSERT("Neighbour at index 9 is 8", doesContainIndex(neighbourIndexes, 8)); - - delete it; } void test_neighbours_1d_face_touching() { @@ -462,7 +443,7 @@ public: 8 - 9 -10 -11 12-13 -14 -15 */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At initial position /* @@ -532,8 +513,6 @@ public: doesContainIndex(neighbourIndexes, 11)); TSM_ASSERT("Neighbour at index 15 is 14", doesContainIndex(neighbourIndexes, 14)); - - delete it; } void test_neighbours_2d_vertex_touching() { @@ -548,7 +527,7 @@ public: 8 - 9 -10 -11 12-13 -14 -15 */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At initial position /* @@ -633,8 +612,6 @@ public: doesContainIndex(neighbourIndexes, 11)); TSM_ASSERT("Neighbour at index 15 is 14", doesContainIndex(neighbourIndexes, 14)); - - delete it; } void test_neighbours_3d_face_touching() { @@ -665,7 +642,7 @@ public: [60 61 62 63]]] */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // Start at Index = 0 std::vector<size_t> neighbourIndexes = @@ -681,9 +658,8 @@ public: neighbourIndexes = it->findNeighbourIndexesFaceTouching(); TS_ASSERT_EQUALS(4, neighbourIndexes.size()); std::vector<size_t> expected_neighbours = {0, 2, 5, 17}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 21 @@ -694,9 +670,8 @@ public: // Is completely enclosed expected_neighbours = {17, 20, 22, 25, 5, 37}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 63. The last index. @@ -706,12 +681,9 @@ public: // Is on edge expected_neighbours = {47, 59, 62}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } - - delete it; } void test_neighbours_3d_vertex_touching() { @@ -742,7 +714,7 @@ public: [60 61 62 63]]] */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // Start at Index = 0 std::vector<size_t> neighbourIndexes = it->findNeighbourIndexes(); @@ -762,9 +734,8 @@ public: TS_ASSERT_EQUALS(11, neighbourIndexes.size()); std::vector<size_t> expected_neighbours = {0, 2, 4, 5, 6, 16, 17, 18, 20, 21, 22, 22}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 21 @@ -776,9 +747,8 @@ public: expected_neighbours = {0, 1, 2, 4, 5, 6, 8, 9, 10, 16, 17, 18, 22, 20, 24, 25, 26, 32, 33, 34, 37, 38, 36, 41, 40, 42}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } // Move to index 63. The last index. @@ -788,12 +758,9 @@ public: // Is on edge expected_neighbours = {42, 43, 46, 47, 58, 59, 62}; - for (auto i = expected_neighbours.begin(); i != expected_neighbours.end(); - ++i) { - TS_ASSERT(doesContainIndex(neighbourIndexes, *i)); + for (auto &expected_neighbour : expected_neighbours) { + TS_ASSERT(doesContainIndex(neighbourIndexes, expected_neighbour)); } - - delete it; } void test_neighbours_1d_with_width() { @@ -811,7 +778,7 @@ public: */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At first position /* @@ -859,8 +826,6 @@ public: doesContainIndex(neighbourIndexes, 8)); TSM_ASSERT("Neighbours at index 9 includes 7", doesContainIndex(neighbourIndexes, 7)); - - delete it; } void test_neighbours_2d_vertex_touching_by_width() { @@ -876,7 +841,7 @@ public: 8 - 9 -10 -11 12-13 -14 -15 */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At initial position /* @@ -953,8 +918,6 @@ public: doesContainIndex(neighbourIndexes, 13)); TSM_ASSERT("Neighbour at index is 14", doesContainIndex(neighbourIndexes, 14)); - - delete it; } void test_neighbours_2d_vertex_touching_by_width_vector() { @@ -973,7 +936,7 @@ public: 8 - 9 -10 -11 12-13 -14 -15 */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At initial position /* @@ -1038,8 +1001,6 @@ public: doesContainIndex(neighbourIndexes, 13)); TSM_ASSERT("Neighbour at index is 14", doesContainIndex(neighbourIndexes, 14)); - - delete it; } void test_neighbours_3d_vertex_touching_width() { @@ -1071,7 +1032,7 @@ public: [60 61 62 63]]] */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // Start at Index = 0 std::vector<size_t> neighbourIndexes = @@ -1095,8 +1056,6 @@ public: TS_ASSERT(doesContainIndex(neighbourIndexes, 24)); TS_ASSERT(doesContainIndex(neighbourIndexes, 25)); TS_ASSERT(doesContainIndex(neighbourIndexes, 26)); - - delete it; } void test_cache() { @@ -1110,7 +1069,7 @@ public: */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); TSM_ASSERT_EQUALS("Empty cache expected", 0, it->permutationCacheSize()); it->findNeighbourIndexesByWidth(3); TSM_ASSERT_EQUALS("One cache item expected", 1, it->permutationCacheSize()); @@ -1121,15 +1080,13 @@ public: it->findNeighbourIndexesByWidth(5); TSM_ASSERT_EQUALS("Two cache entries expected", 2, it->permutationCacheSize()); - - delete it; } void test_getBoxExtents_1d() { const size_t nd = 1; MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace( 1.0 /*signal*/, nd, 3 /*3 bins*/); // Dimension length defaults to 10 - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At zeroth position VecMDExtents extents = it->getBoxExtents(); @@ -1149,15 +1106,13 @@ public: extents = it->getBoxExtents(); TS_ASSERT_DELTA(extents[0].get<0>(), 10.0 * 2.0 / 3.0, 1e-4); TS_ASSERT_DELTA(extents[0].get<1>(), 10.0 * 3.0 / 3.0, 1e-4); - - delete it; } void test_getBoxExtents_3d() { MDHistoWorkspace_sptr ws = MDEventsTestHelper::makeFakeMDHistoWorkspace( 1.0 /*signal*/, 3 /*nd*/, 4 /*nbins per dim*/, 6 /*max*/, 1.0 /*error sq*/); - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At zeroth position VecMDExtents extents = it->getBoxExtents(); @@ -1181,8 +1136,6 @@ public: TS_ASSERT_DELTA(extents[1].get<1>(), 4.0 / 4 * 6.0, 1e-4); TS_ASSERT_DELTA(extents[2].get<0>(), 3.0 / 4 * 6.0, 1e-4); TS_ASSERT_DELTA(extents[2].get<1>(), 4.0 / 4 * 6.0, 1e-4); - - delete it; } void test_jump_to_nearest_1d() { @@ -1210,8 +1163,8 @@ public: */ - MDHistoWorkspaceIterator *itIn = new MDHistoWorkspaceIterator(wsIn); - MDHistoWorkspaceIterator *itOut = new MDHistoWorkspaceIterator(wsOut); + auto itIn = Kernel::make_unique<MDHistoWorkspaceIterator>(wsIn); + auto itOut = Kernel::make_unique<MDHistoWorkspaceIterator>(wsOut); // First position TS_ASSERT_EQUALS(itIn->getLinearIndex(), 0); @@ -1239,9 +1192,6 @@ public: diff = itOut->jumpToNearest(itIn->getCenter()); TS_ASSERT_EQUALS(itOut->getLinearIndex(), 3); // 10.5 closer to 12 than 8 TS_ASSERT_DELTA(1.5, diff, 1e-4); - - delete itIn; - delete itOut; } void test_neighbours_1d_with_width_including_out_of_bounds() { @@ -1259,7 +1209,7 @@ public: */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At first position /* @@ -1348,8 +1298,6 @@ public: doesContainIndex(neighbourIndexes, 10)); // Invalid TSM_ASSERT("Neighbours include 3", doesContainIndex(neighbourIndexes, 11)); // Invalid - - delete it; } void test_neighbours_2d_vertex_touching_by_width_including_out_of_bounds() { @@ -1366,7 +1314,7 @@ public: 8 - 9 -10 -11 12-13 -14 -15 */ - MDHistoWorkspaceIterator *it = new MDHistoWorkspaceIterator(ws); + auto it = Kernel::make_unique<MDHistoWorkspaceIterator>(ws); // At initial position /* @@ -1451,8 +1399,6 @@ public: doesContainIndex(neighbourIndexes, 19)); // Invalid TSM_ASSERT("Neighbour at index is 23", doesContainIndex(neighbourIndexes, 23)); // Invalid - - delete it; } }; @@ -1479,37 +1425,34 @@ public: /** ~Two million iterations */ void test_iterator_3D_signalAndErrorOnly() { - MDHistoWorkspaceIterator *it = - new MDHistoWorkspaceIterator(ws, new SkipNothing); + auto it = + Kernel::make_unique<MDHistoWorkspaceIterator>(ws, new SkipNothing); do { signal_t sig = it->getNormalizedSignal(); signal_t err = it->getNormalizedError(); UNUSED_ARG(sig); UNUSED_ARG(err); } while (it->next()); - delete it; } /** ~Two million iterations */ void test_iterator_3D_withGetVertexes() { - MDHistoWorkspaceIterator *it = - new MDHistoWorkspaceIterator(ws, new SkipNothing); + auto it = + Kernel::make_unique<MDHistoWorkspaceIterator>(ws, new SkipNothing); size_t numVertices; do { signal_t sig = it->getNormalizedSignal(); signal_t err = it->getNormalizedError(); - coord_t *vertexes = it->getVertexesArray(numVertices); - delete[] vertexes; + auto vertexes = it->getVertexesArray(numVertices); UNUSED_ARG(sig); UNUSED_ARG(err); } while (it->next()); - delete it; } /** ~Two million iterations */ void test_iterator_3D_withGetCenter() { - MDHistoWorkspaceIterator *it = - new MDHistoWorkspaceIterator(ws, new SkipNothing); + auto it = + Kernel::make_unique<MDHistoWorkspaceIterator>(ws, new SkipNothing); do { signal_t sig = it->getNormalizedSignal(); signal_t err = it->getNormalizedError(); @@ -1517,13 +1460,12 @@ public: UNUSED_ARG(sig); UNUSED_ARG(err); } while (it->next()); - delete it; } /** Use jumpTo() */ void test_iterator_3D_withGetCenter_usingJumpTo() { - MDHistoWorkspaceIterator *it = - new MDHistoWorkspaceIterator(ws, new SkipNothing); + auto it = + Kernel::make_unique<MDHistoWorkspaceIterator>(ws, new SkipNothing); int max = int(it->getDataSize()); for (int i = 0; i < max; i++) { it->jumpTo(size_t(i)); @@ -1533,7 +1475,6 @@ public: UNUSED_ARG(sig); UNUSED_ARG(err); } - delete it; } void test_masked_get_vertexes_call_throws() { diff --git a/Framework/DataObjects/test/MDHistoWorkspaceTest.h b/Framework/DataObjects/test/MDHistoWorkspaceTest.h index b1870ca4b3fd16c8a188d7e47e3968cb0137c4c1..d0de735e34c10ac5d4cf6f248517ab2b1f30577a 100644 --- a/Framework/DataObjects/test/MDHistoWorkspaceTest.h +++ b/Framework/DataObjects/test/MDHistoWorkspaceTest.h @@ -33,7 +33,7 @@ private: /// Helper function to return the number of masked bins in a workspace. TODO: /// move helper into test helpers size_t getNumberMasked(Mantid::API::IMDWorkspace_sptr ws) { - Mantid::API::IMDIterator *it = ws->createIterator(NULL); + auto it = ws->createIterator(nullptr); size_t numberMasked = 0; size_t counter = 0; for (; counter < it->getDataSize(); ++counter) { @@ -42,7 +42,6 @@ private: } it->next(1); } - delete it; return numberMasked; } @@ -287,16 +286,14 @@ public: new MDHistoDimension("X", "x", frame, -10, 10, 5)); MDHistoWorkspace ws(dimX); size_t numVertices; - coord_t *v1 = ws.getVertexesArray(0, numVertices); + auto v1 = ws.getVertexesArray(0, numVertices); TS_ASSERT_EQUALS(numVertices, 2); TS_ASSERT_DELTA(v1[0], -10.0, 1e-5); TS_ASSERT_DELTA(v1[1], -6.0, 1e-5); - delete[] v1; - coord_t *v2 = ws.getVertexesArray(4, numVertices); + auto v2 = ws.getVertexesArray(4, numVertices); TS_ASSERT_DELTA(v2[0], 6.0, 1e-5); TS_ASSERT_DELTA(v2[1], 10.0, 1e-5); - delete[] v2; } //--------------------------------------------------------------------------------------------------- @@ -309,7 +306,7 @@ public: MDHistoWorkspace ws(dimX, dimY); size_t numVertices, i; - boost::scoped_array<coord_t> v1(ws.getVertexesArray(0, numVertices)); + auto v1 = ws.getVertexesArray(0, numVertices); TS_ASSERT_EQUALS(numVertices, 4); i = 0 * 2; TS_ASSERT_DELTA(v1[i + 0], -10.0, 1e-5); @@ -318,7 +315,7 @@ public: TS_ASSERT_DELTA(v1[i + 0], -6.0, 1e-5); TS_ASSERT_DELTA(v1[i + 1], -6.0, 1e-5); // The opposite corner - boost::scoped_array<coord_t> v2(ws.getVertexesArray(24, numVertices)); + auto v2 = ws.getVertexesArray(24, numVertices); i = 0 * 2; TS_ASSERT_DELTA(v2[i + 0], 6.0, 1e-5); TS_ASSERT_DELTA(v2[i + 1], 6.0, 1e-5); @@ -339,7 +336,7 @@ public: MDHistoWorkspace ws(dimX, dimY, dimZ); size_t numVertices, i; - boost::scoped_array<coord_t> v(ws.getVertexesArray(0, numVertices)); + auto v = ws.getVertexesArray(0, numVertices); TS_ASSERT_EQUALS(numVertices, 8); i = 0; TS_ASSERT_DELTA(v[i + 0], -10.0, 1e-5); @@ -413,17 +410,15 @@ public: MDHistoDimension_sptr dimZ( new MDHistoDimension("Z", "z", frame, -8, 10, 10)); MDHistoWorkspace ws(dimX, dimY, dimZ); - IMDIterator *it = ws.createIterator(); + auto it = ws.createIterator(); TS_ASSERT(it); MDHistoWorkspaceIterator *hwit = - dynamic_cast<MDHistoWorkspaceIterator *>(it); + dynamic_cast<MDHistoWorkspaceIterator *>(it.get()); TS_ASSERT(hwit); TS_ASSERT(it->next()); - delete it; boost::scoped_ptr<MDImplicitFunction> mdfunction(new MDImplicitFunction); it = ws.createIterator(mdfunction.get()); TS_ASSERT(it); - delete it; } //--------------------------------------------------------------------------------------------------- @@ -1263,10 +1258,10 @@ public: IMDHistoWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<IMDHistoWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<IMDHistoWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -1274,9 +1269,9 @@ public: IMDHistoWorkspace_const_sptr wsCastConst; IMDHistoWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (IMDHistoWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (IMDHistoWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/MaskWorkspaceTest.h b/Framework/DataObjects/test/MaskWorkspaceTest.h index f32094b5c2b86c788c5b69c6f1480f1f26bee012..275406bef2054746a929cc0c0cc9062e5e620fdc 100644 --- a/Framework/DataObjects/test/MaskWorkspaceTest.h +++ b/Framework/DataObjects/test/MaskWorkspaceTest.h @@ -129,10 +129,10 @@ public: MaskWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<MaskWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<MaskWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -140,9 +140,9 @@ public: MaskWorkspace_const_sptr wsCastConst; MaskWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (MaskWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (MaskWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/OffsetsWorkspaceTest.h b/Framework/DataObjects/test/OffsetsWorkspaceTest.h index c910bbb631d9c58555d04060070ee9ee96549e0f..4bc9a8f60f160e2611e219e909c475465db7cdd0 100644 --- a/Framework/DataObjects/test/OffsetsWorkspaceTest.h +++ b/Framework/DataObjects/test/OffsetsWorkspaceTest.h @@ -38,10 +38,10 @@ public: OffsetsWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<OffsetsWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<OffsetsWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -49,9 +49,9 @@ public: OffsetsWorkspace_const_sptr wsCastConst; OffsetsWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (OffsetsWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (OffsetsWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/PeakTest.h b/Framework/DataObjects/test/PeakTest.h index 9c3404718fc0c726ece72a950c40fd00ab2b4a3c..82ded86e3f99edbae856bffc7c907804babcea2c 100644 --- a/Framework/DataObjects/test/PeakTest.h +++ b/Framework/DataObjects/test/PeakTest.h @@ -601,8 +601,7 @@ private: void check_Contributing_Detectors(const Peak &peak, const std::vector<int> &expected) { auto peakIDs = peak.getContributingDetIDs(); - for (auto it = expected.begin(); it != expected.end(); ++it) { - const int id = *it; + for (int id : expected) { TSM_ASSERT_EQUALS("Expected " + boost::lexical_cast<std::string>(id) + " in contribution list", 1, peakIDs.count(id)) diff --git a/Framework/DataObjects/test/PeaksWorkspaceTest.h b/Framework/DataObjects/test/PeaksWorkspaceTest.h index d0299473b002cdf4d5716037d6723c859c497515..929e62a01741eed1318c6fd29cd0632c98755585 100644 --- a/Framework/DataObjects/test/PeaksWorkspaceTest.h +++ b/Framework/DataObjects/test/PeaksWorkspaceTest.h @@ -56,7 +56,7 @@ public: /** Check that the PeaksWorkspace build by buildPW() is correct */ void checkPW(const PeaksWorkspace &pw) { - TS_ASSERT_EQUALS(pw.columnCount(), 17); + TS_ASSERT_EQUALS(pw.columnCount(), 18); TS_ASSERT_EQUALS(pw.rowCount(), 1); TS_ASSERT_EQUALS(pw.getNumberPeaks(), 1); if (pw.getNumberPeaks() != 1) @@ -481,10 +481,10 @@ public: PeaksWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<PeaksWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<PeaksWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -492,9 +492,9 @@ public: PeaksWorkspace_const_sptr wsCastConst; PeaksWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (PeaksWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (PeaksWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } @@ -513,10 +513,10 @@ public: IPeaksWorkspace_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<IPeaksWorkspace_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<IPeaksWorkspace_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -524,9 +524,9 @@ public: IPeaksWorkspace_const_sptr wsCastConst; IPeaksWorkspace_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (IPeaksWorkspace_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (IPeaksWorkspace_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } diff --git a/Framework/DataObjects/test/SpecialWorkspace2DTest.h b/Framework/DataObjects/test/SpecialWorkspace2DTest.h index 88d2f1608a15dac281f9888c1409ba1b9d225d1f..40825c572ffe4fa33c9ba0c157012e142cc36c36 100644 --- a/Framework/DataObjects/test/SpecialWorkspace2DTest.h +++ b/Framework/DataObjects/test/SpecialWorkspace2DTest.h @@ -231,10 +231,10 @@ public: SpecialWorkspace2D_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<SpecialWorkspace2D_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<SpecialWorkspace2D_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -242,9 +242,9 @@ public: SpecialWorkspace2D_const_sptr wsCastConst; SpecialWorkspace2D_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (SpecialWorkspace2D_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (SpecialWorkspace2D_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/Workspace2DTest.h b/Framework/DataObjects/test/Workspace2DTest.h index 9d3e6ccd6e0db5a7058ccf76f33a8a6210d29348..2f6958be4b372cdc19d8a68f20db20de81353068 100644 --- a/Framework/DataObjects/test/Workspace2DTest.h +++ b/Framework/DataObjects/test/Workspace2DTest.h @@ -250,10 +250,10 @@ public: Workspace2D_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<Workspace2D_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsNonConst = manager.getValue<Workspace2D_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -261,9 +261,9 @@ public: Workspace2D_const_sptr wsCastConst; Workspace2D_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (Workspace2D_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (Workspace2D_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/DataObjects/test/WorkspaceSingleValueTest.h b/Framework/DataObjects/test/WorkspaceSingleValueTest.h index facddcc1d3fab004581f258269ebbcd8c2f704e9..015d1a21d20378f6fae393ba12bef57190ed601c 100644 --- a/Framework/DataObjects/test/WorkspaceSingleValueTest.h +++ b/Framework/DataObjects/test/WorkspaceSingleValueTest.h @@ -78,10 +78,10 @@ public: WorkspaceSingleValue_sptr wsNonConst; TS_ASSERT_THROWS_NOTHING( wsConst = manager.getValue<WorkspaceSingleValue_const_sptr>(wsName)); - TS_ASSERT(wsConst != NULL); + TS_ASSERT(wsConst != nullptr); TS_ASSERT_THROWS_NOTHING( wsNonConst = manager.getValue<WorkspaceSingleValue_sptr>(wsName)); - TS_ASSERT(wsNonConst != NULL); + TS_ASSERT(wsNonConst != nullptr); TS_ASSERT_EQUALS(wsConst, wsNonConst); // Check TypedValue can be cast to const_sptr or to sptr @@ -90,9 +90,9 @@ public: WorkspaceSingleValue_sptr wsCastNonConst; TS_ASSERT_THROWS_NOTHING(wsCastConst = (WorkspaceSingleValue_const_sptr)val); - TS_ASSERT(wsCastConst != NULL); + TS_ASSERT(wsCastConst != nullptr); TS_ASSERT_THROWS_NOTHING(wsCastNonConst = (WorkspaceSingleValue_sptr)val); - TS_ASSERT(wsCastNonConst != NULL); + TS_ASSERT(wsCastNonConst != nullptr); TS_ASSERT_EQUALS(wsCastConst, wsCastNonConst); } }; diff --git a/Framework/Geometry/CMakeLists.txt b/Framework/Geometry/CMakeLists.txt index b66dbe21896a5352ff8f1a3f57e3951982d92468..98e664cba7c3395e7f0e8545eb5b8242ea653613 100644 --- a/Framework/Geometry/CMakeLists.txt +++ b/Framework/Geometry/CMakeLists.txt @@ -109,16 +109,12 @@ set ( SRC_FILES src/Objects/Rules.cpp src/Objects/ShapeFactory.cpp src/Objects/Track.cpp - src/Rendering/BitmapGeometryHandler.cpp - src/Rendering/CacheGeometryGenerator.cpp - src/Rendering/CacheGeometryHandler.cpp - src/Rendering/CacheGeometryRenderer.cpp src/Rendering/GeometryHandler.cpp - src/Rendering/GluGeometryHandler.cpp - src/Rendering/GluGeometryRenderer.cpp - src/Rendering/StructuredGeometryHandler.cpp + src/Rendering/RenderingHelpers.cpp + src/Rendering/ShapeInfo.cpp src/Rendering/vtkGeometryCacheReader.cpp src/Rendering/vtkGeometryCacheWriter.cpp + src/Rendering/GeometryTriangulator.cpp src/Surfaces/Cone.cpp src/Surfaces/Cylinder.cpp src/Surfaces/General.cpp @@ -132,16 +128,8 @@ set ( SRC_FILES src/Surfaces/Torus.cpp ) -set ( OPENCASCADE_SRC - src/Rendering/OCGeometryGenerator.cpp - src/Rendering/OCGeometryHandler.cpp - src/Rendering/OCGeometryRenderer.cpp -) - set ( SRC_UNITY_IGNORE_FILES src/Instrument/CompAssembly.cpp src/Instrument/ObjCompAssembly.cpp - src/Rendering/OCGeometryHandler.cpp - src/Rendering/OCGeometryRenderer.cpp ) set ( INC_FILES @@ -270,24 +258,17 @@ set ( INC_FILES inc/MantidGeometry/Objects/CSGObject.h inc/MantidGeometry/Objects/IObject.h inc/MantidGeometry/Objects/InstrumentRayTracer.h - inc/MantidGeometry/Objects/MeshObject.h + inc/MantidGeometry/Objects/MeshObject.h inc/MantidGeometry/Objects/Rules.h inc/MantidGeometry/Objects/ShapeFactory.h inc/MantidGeometry/Objects/Track.h - inc/MantidGeometry/Rendering/BitmapGeometryHandler.h - inc/MantidGeometry/Rendering/CacheGeometryGenerator.h - inc/MantidGeometry/Rendering/CacheGeometryHandler.h - inc/MantidGeometry/Rendering/CacheGeometryRenderer.h inc/MantidGeometry/Rendering/GeometryHandler.h - inc/MantidGeometry/Rendering/GluGeometryHandler.h - inc/MantidGeometry/Rendering/GluGeometryRenderer.h - inc/MantidGeometry/Rendering/OCGeometryGenerator.h - inc/MantidGeometry/Rendering/OCGeometryHandler.h - inc/MantidGeometry/Rendering/OCGeometryRenderer.h + inc/MantidGeometry/Rendering/RenderingHelpers.h + inc/MantidGeometry/Rendering/ShapeInfo.h inc/MantidGeometry/Rendering/OpenGL_Headers.h - inc/MantidGeometry/Rendering/StructuredGeometryHandler.h inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h inc/MantidGeometry/Rendering/vtkGeometryCacheWriter.h + inc/MantidGeometry/Rendering/GeometryTriangulator.h inc/MantidGeometry/Surfaces/BaseVisit.h inc/MantidGeometry/Surfaces/Cone.h inc/MantidGeometry/Surfaces/Cylinder.h @@ -410,6 +391,7 @@ set ( TEST_FILES SampleEnvironmentTest.h ScalarUtilsTest.h ShapeFactoryTest.h + ShapeInfoTest.h SpaceGroupFactoryTest.h SpaceGroupTest.h SphereTest.h @@ -446,11 +428,6 @@ if(UNITY_BUILD) enable_unity_build(Geometry SRC_FILES SRC_UNITY_IGNORE_FILES 10) endif(UNITY_BUILD) -# ===================== Open Cascade =================== -if (ENABLE_OPENCASCADE) - LIST (APPEND SRC_FILES ${OPENCASCADE_SRC} ) -endif () - # A few defines needed for OpenCascade on the Mac if ( APPLE ) add_definitions ( -DHAVE_IOSTREAM -DHAVE_LIMITS -DHAVE_IOMANIP ) diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/HKLGenerator.h b/Framework/Geometry/inc/MantidGeometry/Crystal/HKLGenerator.h index b20d11ccf2f0c219d02657d251d62098597c517a..b3467fdf70924cd0e3b8d1dd283e136899470d3a 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/HKLGenerator.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/HKLGenerator.h @@ -143,7 +143,7 @@ public: int m_h, m_k, m_l; Kernel::V3D m_hkl; - int m_hMin, m_hMax; + int m_hMax; int m_kMin, m_kMax; int m_lMin, m_lMax; }; diff --git a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h index 2b8afe9447217ebfe73566259813e6b489bb4d1e..f900b5b7cb4b6a464706f3d1e156703e710b9ea1 100644 --- a/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h +++ b/Framework/Geometry/inc/MantidGeometry/Crystal/IPeak.h @@ -60,6 +60,7 @@ public: virtual void setWavelength(double wavelength) = 0; virtual double getWavelength() const = 0; virtual double getScattering() const = 0; + virtual double getAzimuthal() const = 0; virtual double getDSpacing() const = 0; virtual double getTOF() const = 0; @@ -78,6 +79,9 @@ public: virtual double getBinCount() const = 0; virtual void setBinCount(double m_BinCount) = 0; + virtual int getPeakNumber() const = 0; + virtual void setPeakNumber(int m_PeakNumber) = 0; + virtual Mantid::Kernel::Matrix<double> getGoniometerMatrix() const = 0; virtual void setGoniometerMatrix( const Mantid::Kernel::Matrix<double> &m_GoniometerMatrix) = 0; diff --git a/Framework/Geometry/inc/MantidGeometry/IObjComponent.h b/Framework/Geometry/inc/MantidGeometry/IObjComponent.h index d5a239686bdc0cbcaf9a58d16f1a5f486de94a48..2553ed3915c90b2c233b733e2107f1cf0c476dcb 100644 --- a/Framework/Geometry/inc/MantidGeometry/IObjComponent.h +++ b/Framework/Geometry/inc/MantidGeometry/IObjComponent.h @@ -59,6 +59,10 @@ public: IObjComponent(GeometryHandler *the_handler); + IObjComponent(const IObjComponent &); + + IObjComponent &operator=(const IObjComponent &rhs); + // Looking to get rid of the first of these constructors in due course (and // probably add others) ~IObjComponent() override; @@ -104,11 +108,6 @@ public: GeometryHandler *Handle() const { return handle; } protected: - /// Protected copy constructor - IObjComponent(const IObjComponent &); - /// Assignment operator - IObjComponent &operator=(const IObjComponent &); - /// Reset the current geometry handler void setGeometryHandler(GeometryHandler *h); diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h index 81ea8c9367e23638109d10c851fac1c57376f4e2..0018c011783ca1f2f9fc0934744e788e82f84cc9 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentInfo.h @@ -87,6 +87,15 @@ private: const std::map<size_t, size_t> &detectorExclusions) const; public: + struct QuadrilateralComponent { + size_t topLeft; + size_t bottomLeft; + size_t bottomRight; + size_t topRight; + size_t nX; + size_t nY; + }; + ComponentInfo( std::unique_ptr<Beamline::ComponentInfo> componentInfo, boost::shared_ptr<const std::vector<Mantid::Geometry::IComponent *>> @@ -101,7 +110,10 @@ public: std::unique_ptr<ComponentInfo> cloneWithoutDetectorInfo() const; std::vector<size_t> detectorsInSubtree(size_t componentIndex) const; std::vector<size_t> componentsInSubtree(size_t componentIndex) const; + const std::vector<size_t> &children(size_t componentIndex) const; size_t size() const; + QuadrilateralComponent + quadrilateralComponent(const size_t componentIndex) const; size_t indexOf(Geometry::IComponent *id) const; size_t indexOfAny(const std::string &name) const; bool isDetector(const size_t componentIndex) const; @@ -131,13 +143,15 @@ public: const std::string &name(const size_t componentIndex) const; void setScaleFactor(const size_t componentIndex, const Kernel::V3D &scaleFactor); - size_t root(); + size_t root() const; const IComponent *componentID(const size_t componentIndex) const { return m_componentIds->operator[](componentIndex); } bool hasValidShape(const size_t componentIndex) const; + const Geometry::IObject &shape(const size_t componentIndex) const; + double solidAngle(const size_t componentIndex, const Kernel::V3D &observer) const; BoundingBox boundingBox(const size_t componentIndex, diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h index 1ee03f9ba9eb327e1264fc3234da2d7b6e63756b..548dbc62cbbbf5b378c444c7eff232990cda9f16 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ComponentVisitor.h @@ -43,8 +43,13 @@ public: virtual size_t registerComponentAssembly(const ICompAssembly &assembly) = 0; virtual size_t registerGenericComponent(const IComponent &component) = 0; virtual size_t + registerInfiniteComponent(const Mantid::Geometry::IComponent &component) = 0; + virtual size_t registerGenericObjComponent(const IObjComponent &objComponent) = 0; + virtual size_t + registerInfiniteObjComponent(const IObjComponent &component) = 0; virtual size_t registerDetector(const IDetector &detector) = 0; + virtual size_t registerRectangularBank(const ICompAssembly &bank) = 0; virtual size_t registerStructuredBank(const ICompAssembly &bank) = 0; virtual size_t registerObjComponentAssembly(const ObjCompAssembly &obj) = 0; virtual ~ComponentVisitor() {} diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h b/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h index e3a2e8b85c6967426dad5a0c3019ea5733c094d5..8717345260c04507e5aea76d936418ef0fdc99b0 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/Container.h @@ -103,8 +103,9 @@ public: return m_shape->generatePointInObject(rng, activeRegion, i); } - void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) const override { + void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, + double &myheight) const override { m_shape->GetObjectGeom(type, vectors, myradius, myheight); } boost::shared_ptr<GeometryHandler> getGeometryHandler() const override { diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h index ac77820aad5f68c8ae5d649ee6e933cd29df1eb6..ee23596428cf874d6a6de8119b37471117a8db14 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/InstrumentVisitor.h @@ -78,6 +78,9 @@ private: /// Index of the parent component boost::shared_ptr<std::vector<size_t>> m_parentComponentIndices; + /// Stores instrument tree structure by storing children of all Components + boost::shared_ptr<std::vector<std::vector<size_t>>> m_children; + /// Only Assemblies and other NON-detectors yield detector ranges boost::shared_ptr<std::vector<std::pair<size_t, size_t>>> m_detectorRanges; @@ -165,9 +168,18 @@ public: virtual size_t registerGenericComponent( const Mantid::Geometry::IComponent &component) override; + virtual size_t registerInfiniteComponent( + const Mantid::Geometry::IComponent &component) override; + virtual size_t registerGenericObjComponent( const Mantid::Geometry::IObjComponent &objComponent) override; + virtual size_t + registerRectangularBank(const Mantid::Geometry::ICompAssembly &bank) override; + + virtual size_t + registerInfiniteObjComponent(const IObjComponent &objComponent) override; + virtual size_t registerStructuredBank(const Mantid::Geometry::ICompAssembly &bank) override; diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/ReferenceFrame.h b/Framework/Geometry/inc/MantidGeometry/Instrument/ReferenceFrame.h index aa40ca05e075bea32da9a2ffc09d5d2737cb110d..444e77c69a339476d721c0ba65f072c7d0ab57d8 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/ReferenceFrame.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/ReferenceFrame.h @@ -79,8 +79,6 @@ public: bool isVectorPointingAlongBeam(const Mantid::Kernel::V3D &v) const; private: - /// Common setup - void init(); /// Disabled assignment ReferenceFrame &operator=(const ReferenceFrame &); /// Pointing up axis diff --git a/Framework/Geometry/inc/MantidGeometry/Instrument/StructuredDetector.h b/Framework/Geometry/inc/MantidGeometry/Instrument/StructuredDetector.h index fdfb8b637d1522bc0615bdcb29366612d0760dda..7939e9e0707d29c5b10b9c014ce0a99df1502fa2 100644 --- a/Framework/Geometry/inc/MantidGeometry/Instrument/StructuredDetector.h +++ b/Framework/Geometry/inc/MantidGeometry/Instrument/StructuredDetector.h @@ -64,8 +64,8 @@ public: StructuredDetector(const StructuredDetector *base, const ParameterMap *map); /// Create all the detector pixels of this rectangular detector. - void initialize(size_t xPixels, size_t yPixels, const std::vector<double> &x, - const std::vector<double> &y, bool isZBeam, detid_t idStart, + void initialize(size_t xPixels, size_t yPixels, std::vector<double> &&x, + std::vector<double> &&y, bool isZBeam, detid_t idStart, bool idFillByFirstY, int idStepByRow, int idStep = 1); //! Make a clone of the present component diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h index f7ee2fe939e0a5205d66827c68cdd9176c10c18b..26b173e33cccbce0548c01dfa1f5fae595633d23 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/CSGObject.h @@ -5,6 +5,7 @@ // Includes //---------------------------------------------------------------------- #include "MantidGeometry/DllConfig.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidGeometry/Objects/IObject.h" #include "BoundingBox.h" @@ -22,7 +23,6 @@ class V3D; } namespace Geometry { -class CacheGeometryHandler; class CompGrp; class GeometryHandler; class Rule; @@ -83,6 +83,11 @@ public: return obj; } + bool isFiniteGeometry() const override { return m_isFiniteGeometry; } + void setFiniteGeometryFlag(bool isFinite) override { + m_isFiniteGeometry = isFinite; + } + /// Return the top rule const Rule *topRule() const { return TopRule.get(); } void setID(const std::string &id) { m_id = id; } @@ -191,8 +196,9 @@ public: void setVtkGeometryCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>); /// set vtkGeometryCache reader void setVtkGeometryCacheReader(boost::shared_ptr<vtkGeometryCacheReader>); - void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) const override; + void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, + double &myheight) const override; /// Getter for the shape xml std::string getShapeXML() const; @@ -252,7 +258,8 @@ private: int ObjNum; /// Geometry Handle for rendering boost::shared_ptr<GeometryHandler> m_handler; - friend class CacheGeometryHandler; + friend class GeometryHandler; + friend class GeometryRenderer; /// Is geometry caching enabled? bool bGeometryCaching; /// a pointer to a class for reading from the geometry cache @@ -260,17 +267,19 @@ private: /// a pointer to a class for writing to the geometry cache boost::shared_ptr<vtkGeometryCacheWriter> vtkCacheWriter; void updateGeometryHandler(); + size_t numberOfTriangles() const; + size_t numberOfVertices() const; /// for solid angle from triangulation - int NumberOfTriangles() const; - int NumberOfPoints() const; - int *getTriangleFaces() const; - double *getTriangleVertices() const; + const std::vector<uint32_t> &getTriangleFaces() const; + const std::vector<double> &getTriangleVertices() const; /// original shape xml used to generate this object. std::string m_shapeXML; /// Optional string identifier std::string m_id; /// material composition std::unique_ptr<Kernel::Material> m_material; + /// Whether or not the object geometry is finite + bool m_isFiniteGeometry = true; protected: std::vector<const Surface *> m_SurList; ///< Full surfaces (make a map diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h index 11e92711d7068c80aa02a3c5f147dae079fb3c13..92f4c32efe2674b687310c71d12767c9e14ab04b 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/IObject.h @@ -2,9 +2,10 @@ #define MANTID_GEOMETRY_IOBJECT_H_ #include "MantidGeometry/DllConfig.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include <boost/shared_ptr.hpp> -#include <vector> #include <map> +#include <vector> namespace Mantid { @@ -54,10 +55,13 @@ class vtkGeometryCacheWriter; */ class MANTID_GEOMETRY_DLL IObject { public: + virtual ~IObject() = default; virtual bool isValid(const Kernel::V3D &) const = 0; virtual bool isOnSide(const Kernel::V3D &) const = 0; virtual int calcValidType(const Kernel::V3D &Pt, const Kernel::V3D &uVec) const = 0; + virtual bool isFiniteGeometry() const { return true; } + virtual void setFiniteGeometryFlag(bool) {} virtual bool hasValidShape() const = 0; virtual IObject *clone() const = 0; virtual IObject * @@ -89,9 +93,9 @@ public: const BoundingBox &activeRegion, const size_t) const = 0; - virtual void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, + virtual void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, double &myheight) const = 0; - // Rendering virtual void draw() const = 0; virtual void initDraw() const = 0; diff --git a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h index ac3cbb67fe3a5387f32bf7573ee8aebeecd8cd1e..d1b0478870289fc0746484d742a508593dea45cd 100644 --- a/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h +++ b/Framework/Geometry/inc/MantidGeometry/Objects/MeshObject.h @@ -7,6 +7,7 @@ #include "MantidGeometry/DllConfig.h" #include "MantidGeometry/Objects/IObject.h" #include "MantidKernel/Material.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "BoundingBox.h" #include <map> #include <memory> @@ -21,7 +22,6 @@ class V3D; } namespace Geometry { -class CacheGeometryHandler; class CompGrp; class GeometryHandler; class Track; @@ -139,14 +139,15 @@ public: /// Set Geometry Handler void setGeometryHandler(boost::shared_ptr<GeometryHandler> h); - void GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) const override; + void GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, + double &myheight) const override; /// Read access to mesh object for rendering - int numberOfVertices() const; - double *getVertices() const; - int numberOfTriangles() const; - int *getTriangles() const; + size_t numberOfVertices() const; + std::vector<double> getVertices() const; + size_t numberOfTriangles() const; + std::vector<uint32_t> getTriangles() const; void updateGeometryHandler(); diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/BitmapGeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/BitmapGeometryHandler.h deleted file mode 100644 index a984a0bd4d2f396be10542386b170defcd223f78..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/BitmapGeometryHandler.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef BITMAPGEOMETRYHANDLER_H -#define BITMAPGEOMETRYHANDLER_H - -#ifndef Q_MOC_RUN -#include <boost/weak_ptr.hpp> -#endif -#include "MantidGeometry/DllConfig.h" -#include "MantidKernel/Logger.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -namespace Mantid { - -namespace Geometry { -/** -\class BitmapGeometryHandler -\brief Handler for geometry objects that are rendered as bitmaps (e.g. -RectangularDetector), rather than primitives. -\author Janik Zikovsky -\date October 2010 -\version 1.0 - -This class supports drawing RectangularDetector - as a bitmap plotted by openGL -rather -than a million individual pixels rendered as cubes. -A texture will have been created by the RectangularDetectorActor (in MantidPlot) -and this is what will be mapped. - -Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class ObjComponent; -class CSGObject; -class MANTID_GEOMETRY_DLL BitmapGeometryHandler : public GeometryHandler { -private: - static Kernel::Logger &PLog; ///< The official logger - - boost::shared_ptr<GeometryHandler> clone() const override; - - /// The RectangularDetector object being plotted. - RectangularDetector *m_rectDet; - -public: - BitmapGeometryHandler(RectangularDetector *comp); - BitmapGeometryHandler(); - // - // BitmapGeometryHandler(IObjComponent *comp); ///< - // Constructor - // BitmapGeometryHandler(boost::shared_ptr<Object> obj); - // ///<Constructor - // BitmapGeometryHandler(Object *obj); ///<Constructor - BitmapGeometryHandler *createInstance( - IObjComponent *) override; ///< Create an instance of concrete geometry - /// handler for ObjComponent - BitmapGeometryHandler *createInstance(boost::shared_ptr<CSGObject>) - override; ///< Create an instance of concrete geometry handler for Object - GeometryHandler *createInstance(CSGObject *) - override; ///< Create an instance of concrete geometry handler for Object - void Triangulate() override; ///< Triangulate the Object - void Render() override; ///< Render Object or ObjComponent - void Initialize() - override; ///< Prepare/Initialize Object/ObjComponent to be rendered - /// Returns true if the shape can be triangulated - bool canTriangulate() override { return false; } - /// get the number of triangles - int NumberOfTriangles() override { return 0; } - /// get the number of points or vertices - int NumberOfPoints() override { return 0; } - /// Extract the vertices of the triangles - double *getTriangleVertices() override { return nullptr; } - /// Extract the Faces of the triangles - int *getTriangleFaces() override { return nullptr; } - /// Sets the geometry cache using the triangulation information provided - void setGeometryCache(int noPts, int noFaces, double *pts, - int *faces) override { - (void)noPts; - (void)noFaces; - (void)pts; - (void)faces; // Avoid compiler warning - }; - /// return the actual type and points of one of the "standard" objects, - /// cuboid/cone/cyl/sphere - void GetObjectGeom(int &mytype, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) override { - (void)mytype; - (void)vectors; - (void)myradius; - (void)myheight; // Avoid compiler warning - }; -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryGenerator.h b/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryGenerator.h deleted file mode 100644 index dcdfb1627eb3791e82990f8930c26d2b80dede1a..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryGenerator.h +++ /dev/null @@ -1,75 +0,0 @@ -#ifndef CACHE_GEOMETRYGENERATOR_H -#define CACHE_GEOMETRYGENERATOR_H - -#include "MantidGeometry/DllConfig.h" - -namespace Mantid { - -namespace Geometry { - -/** - \class CacheGeometryGenerator - \brief Generates geometry using other geometry handlers or keeps the cache of - the triangles - \author Mr. Srikanth Nagella - \date Jan 2009 - \version 1.0 - - This class is an cache for the geometry triangles and if needed generates the - triangles using - other GeometryHandlers. - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class CSGObject; -class MeshObject; - -class MANTID_GEOMETRY_DLL CacheGeometryGenerator { -private: - CSGObject *csgObj; ///< Input CSGObject - MeshObject *meshObj; ///< Input MeshObject - int mNoOfVertices; ///< number of vertices - int mNoOfTriangles; ///< number of triangles - double *mPoints; ///<double array or points - int *mFaces; ///< Integer array of faces -public: - CacheGeometryGenerator(CSGObject *obj); - CacheGeometryGenerator(MeshObject *obj); - ~CacheGeometryGenerator(); - /// Generate the trangles - void Generate(); - /// get the number of triangles - int getNumberOfTriangles(); - /// get the number of points - int getNumberOfPoints(); - /// get the triangle vertices - double *getTriangleVertices(); - /// get the triangle faces - int *getTriangleFaces(); - /// Sets the geometry cache using the triangulation information provided - void setGeometryCache(int noPts, int noFaces, double *pts, int *faces); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryHandler.h deleted file mode 100644 index 0dcf4a3d9f9eddbf739845620204a27dbde24b5c..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryHandler.h +++ /dev/null @@ -1,89 +0,0 @@ -#ifndef CACHE_GEOMETRYHANDLER_H -#define CACHE_GEOMETRYHANDLER_H - -#include "MantidGeometry/DllConfig.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" - -namespace Mantid { -namespace Kernel { -class V3D; -} - -namespace Geometry { -class GeometryHandler; -class CacheGeometryRenderer; -class CacheGeometryGenerator; -class IObjComponent; -class CSGObject; -class MeshObject; - -/** - \class CacheGeometryHandler - \brief Place holder for geometry triangulation and rendering with caching - triangles. - \author Srikanth Nagella - \date Jan 2009 - \version 1.0 - - This is an implementation class for handling geometry from cache, if the - cache doesn't exist then the - triangulation is done using another triangulation handler and store in cache. - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL CacheGeometryHandler : public GeometryHandler { -private: - CacheGeometryRenderer *Renderer; ///< Geometry renderer variable used for - /// rendering Object/ObjComponent - CacheGeometryGenerator * - Triangulator; ///< Geometry generator to triangulate Object - void updateGeometryHandler(); - -public: - CacheGeometryHandler(IObjComponent *comp); ///< Constructor - CacheGeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor - CacheGeometryHandler(CSGObject *obj); ///< Constructor - CacheGeometryHandler(boost::shared_ptr<MeshObject> obj); ///< Constructor - CacheGeometryHandler(MeshObject *obj); ///< Constructor - boost::shared_ptr<GeometryHandler> clone() const override; - ~CacheGeometryHandler() override; ///< Destructor - GeometryHandler *createInstance(IObjComponent *comp) override; - GeometryHandler *createInstance(boost::shared_ptr<CSGObject> obj) override; - GeometryHandler *createInstance(CSGObject *obj) override; - - void Triangulate() override; - void Render() override; - void Initialize() override; - bool canTriangulate() override { return true; } - int NumberOfTriangles() override; - int NumberOfPoints() override; - double *getTriangleVertices() override; - int *getTriangleFaces() override; - /// Sets the geometry cache using the triangulation information provided - void setGeometryCache(int noPts, int noFaces, double *pts, - int *faces) override; -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryRenderer.h b/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryRenderer.h deleted file mode 100644 index 708cb3b70b21657ed4746fb4528abdc847f47a15..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/CacheGeometryRenderer.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef CACHE_GEOMETRYRENDERER_H -#define CACHE_GEOMETRYRENDERER_H - -#include "MantidGeometry/DllConfig.h" - -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class IObjComponent; -/** - \class CacheGeometryRenderer - \brief rendering geometry using opengl from the geometry cache. - \author Srikanth Nagella - \date Jan 2009 - \version 1.0 - - This is an concrete class for rendering cached geometry using opengl. - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL CacheGeometryRenderer { -public: - /// Render using an object component - void Render(IObjComponent *ObjComp) const; - /// Render using triangulation information - void Render(int noPts, int noFaces, double *points, int *faces) const; - /// Initialize using triangulation information - void Initialize(int noPts, int noFaces, double *points, int *faces) const; - /// Initialize using an object component - void Initialize(IObjComponent *ObjComp); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h index 055ce4ca74f4614b2e8f9042a1a3e165231344a7..434c3100f1cf49f8a8aa82879997be006e7ffdca 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryHandler.h @@ -2,118 +2,102 @@ #define GEOMETRYHANDLER_H #include "MantidGeometry/DllConfig.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidKernel/Logger.h" #include "MantidKernel/V3D.h" #include <boost/shared_ptr.hpp> +#include <boost/optional.hpp> +#include <memory> #include <vector> namespace Mantid { namespace Geometry { class IObjComponent; -class ObjComponent; class CSGObject; + class MeshObject; +namespace detail { +class Renderer; +class GeometryTriangulator; +} /** - \class GeometryHandler - \brief Place holder for geometry triangulation and rendering. - \author Srikanth Nagella - \date July 2008 - \version 1.0 +\class GeometryHandler +\brief Handles rendering of all object Geometry. +\author Lamar Moore +\date December 2017 - This is an abstract class for handling geometry primitives. +Handles the rendering of all geometry types in Mantid. - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source +Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source - This file is part of Mantid. +This file is part of Mantid. - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. - File change history is stored at: <https://github.com/mantidproject/mantid> +File change history is stored at: <https://github.com/mantidproject/mantid> */ class MANTID_GEOMETRY_DLL GeometryHandler { private: static Kernel::Logger &PLog; ///< The official logger protected: - IObjComponent *ObjComp; ///< ObjComponent that uses this geometry handler - CSGObject *csgObj; ///< CSG Object that uses this geometry handler - MeshObject *meshObj; ///< Mesh Object that uses this geometry handler - bool boolTriangulated; ///< state of the geometry triangulation - bool - boolIsInitialized; ///< state of the geometry initialization for rendering + std::shared_ptr<detail::ShapeInfo> m_shapeInfo; + std::unique_ptr<detail::GeometryTriangulator> m_triangulator; + MeshObject *m_meshObj = + nullptr; ///< Mesh Object that uses this geometry handler + IObjComponent *m_objComp = + nullptr; ///< ObjComponent that uses this geometry handler + CSGObject *m_csgObj = nullptr; ///< Object that uses this geometry handler public: GeometryHandler(IObjComponent *comp); ///< Constructor - GeometryHandler(boost::shared_ptr<CSGObject> obj); ///<Constructor - GeometryHandler(CSGObject *obj); ///<Constructor + GeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor + GeometryHandler(CSGObject *obj); ///< Constructor GeometryHandler(boost::shared_ptr<MeshObject> obj); ///<Constructor - GeometryHandler(MeshObject *obj); ///<Constructor - virtual boost::shared_ptr<GeometryHandler> - clone() const = 0; ///< Virtual copy constructor - virtual ~GeometryHandler(); - virtual GeometryHandler *createInstance(IObjComponent *) = 0; ///< Create an - /// instance of - /// concrete - /// geometry - /// handler for - /// ObjComponent - virtual GeometryHandler *createInstance( - boost::shared_ptr<CSGObject>) = 0; ///< Create an instance of - /// concrete geometry - /// handler for Object - virtual GeometryHandler * - createInstance(CSGObject *) = 0; ///< Create an instance - /// of concrete geometry - /// handler for Object - virtual void Triangulate() = 0; ///< Triangulate the Object - virtual void Render() = 0; ///< Render Object or ObjComponent - virtual void - Initialize() = 0; ///< Prepare/Initialize Object/ObjComponent to be rendered - /// Returns true if the shape can be triangulated - virtual bool canTriangulate() { return false; } + GeometryHandler(MeshObject *obj); + GeometryHandler(const GeometryHandler &handler); + boost::shared_ptr<GeometryHandler> clone() const; + ~GeometryHandler(); + void render() const; ///< Render Object or ObjComponent + void + initialize() const; ///< Prepare/Initialize Object/ObjComponent to be rendered + bool canTriangulate() const { return !(m_triangulator == nullptr); } /// get the number of triangles - virtual int NumberOfTriangles() { return 0; } + size_t numberOfTriangles() const; /// get the number of points or vertices - virtual int NumberOfPoints() { return 0; } + size_t numberOfPoints() const; + + bool hasShapeInfo() const { return !(m_shapeInfo == nullptr); } + const detail::ShapeInfo &shapeInfo() const { return *m_shapeInfo; } /// Extract the vertices of the triangles - virtual double *getTriangleVertices() { return nullptr; } + const std::vector<double> &getTriangleVertices() const; /// Extract the Faces of the triangles - virtual int *getTriangleFaces() { return nullptr; } + const std::vector<uint32_t> &getTriangleFaces() const; /// Sets the geometry cache using the triangulation information provided - virtual void setGeometryCache(int noPts, int noFaces, double *pts, - int *faces) { - UNUSED_ARG(noPts); - UNUSED_ARG(noFaces); - UNUSED_ARG(pts); - UNUSED_ARG(faces); - }; + void setGeometryCache(size_t nPts, size_t nFaces, std::vector<double> &&pts, + std::vector<uint32_t> &&faces); /// return the actual type and points of one of the "standard" objects, /// cuboid/cone/cyl/sphere - virtual void GetObjectGeom(int &mytype, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) { - UNUSED_ARG(vectors); - UNUSED_ARG(myradius); - UNUSED_ARG(myheight); - // Flag that this is unknown at this point - mytype = -1; - }; + void GetObjectGeom(detail::ShapeInfo::GeometryShape &mytype, + std::vector<Kernel::V3D> &vectors, double &myradius, + double &myheight) const; + void setShapeInfo(detail::ShapeInfo &&shapeInfo); }; } // NAMESPACE Geometry - } // NAMESPACE Mantid #endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryTriangulator.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryTriangulator.h new file mode 100644 index 0000000000000000000000000000000000000000..e7a6b86a5fc1a74d84d53e9701f90986e96e4c42 --- /dev/null +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/GeometryTriangulator.h @@ -0,0 +1,94 @@ +#ifndef MANTID_GEOMETRY_SURFACETRIANGULATOR_H_ +#define MANTID_GEOMETRY_SURFACETRIANGULATOR_H_ + +#include "MantidGeometry/DllConfig.h" +#include <memory> +#include <vector> + +class TopoDS_Shape; + +namespace Mantid { +namespace Geometry { +class CSGObject; +class MeshObject; + +namespace detail { +/** GeometryTriangulator : Triangulates object surfaces. May or may not use + opencascade. + + Copyright © 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge + National Laboratory & European Spallation Source + + This file is part of Mantid. + + Mantid is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + + Mantid is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see <http://www.gnu.org/licenses/>. + + File change history is stored at: <https://github.com/mantidproject/mantid> + Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +class MANTID_GEOMETRY_DLL GeometryTriangulator { +private: + bool m_isTriangulated; + size_t m_nFaces; + size_t m_nPoints; + std::vector<double> m_points; ///< double array or points + std::vector<uint32_t> m_faces; ///< Integer array of faces + const CSGObject *m_csgObj = nullptr; ///< Input Object + const MeshObject *m_meshObj = nullptr; + void checkTriangulated(); + +public: + GeometryTriangulator(const CSGObject *obj = nullptr); + GeometryTriangulator(const MeshObject *obj); + GeometryTriangulator(const GeometryTriangulator &) = delete; + GeometryTriangulator &operator=(const GeometryTriangulator &) = delete; + ~GeometryTriangulator(); + void triangulate(); + void generateMesh(); + void setGeometryCache(size_t nPoints, size_t nFaces, + std::vector<double> &&points, + std::vector<uint32_t> &&faces); + /// Return the number of triangle faces + size_t numTriangleFaces(); + /// Return the number of triangle vertices + size_t numTriangleVertices(); + /// get a pointer to the 3x(NumberOfPoints) coordinates (x1,y1,z1,x2..) of + /// mesh + const std::vector<double> &getTriangleVertices(); + /// get a pointer to the 3x(NumberOFaces) integers describing points forming + /// faces (p1,p2,p3)(p4,p5,p6). + const std::vector<uint32_t> &getTriangleFaces(); +#ifdef ENABLE_OPENCASCADE +private: + std::unique_ptr<TopoDS_Shape> + m_objSurface; ///< Storage for the output surface + /// Analyze the object + /// OpenCascade analysis of object surface + void OCAnalyzeObject(); + size_t numPoints() const; + size_t numFaces() const; + void setupPoints(); + void setupFaces(); + +public: + /// Return OpenCascade surface. + bool hasOCSurface() const; + const TopoDS_Shape &getOCSurface(); +#endif +}; +} // namespace detail +} // namespace Geometry +} // namespace Mantid + +#endif /* MANTID_GEOMETRY_SURFACETRIANGULATOR_H_ */ \ No newline at end of file diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryHandler.h deleted file mode 100644 index d8497b6cc5d33ea3fa6262df824960e98b49d1f3..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryHandler.h +++ /dev/null @@ -1,110 +0,0 @@ -#ifndef GLU_GEOMETRYHANDLER_H -#define GLU_GEOMETRYHANDLER_H - -#include "MantidGeometry/DllConfig.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" - -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class GeometryHandler; -class GluGeometryRenderer; -class IObjComponent; -class CSGObject; -/** - \class GluGeometryHandler - \brief Place holder for geometry triangulation and rendering with special - cases of cube, sphere, cone and cylinder. - \author Srikanth Nagella - \date December 2008 - \version 1.0 - - This is an implementation class for handling geometry without triangulating - and using opengl glu methods. - This class can render cube, sphere, cone and cylinder. - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL GluGeometryHandler : public GeometryHandler { -public: - /// the type of the geometry eg CUBOID,CYLINDER,CONE,SPHERE - enum class GeometryType { - NOSHAPE = 0, - CUBOID, ///< CUBOID - HEXAHEDRON, ///< HEXAHEDRON - SPHERE, ///< SPHERE - CYLINDER, ///< CYLINDER - CONE, ///< CONE - SEGMENTED_CYLINDER ///< Cylinder with 1 or more segments (along the axis). - /// Sizes of segments are important. - }; - -private: - static Kernel::Logger &PLog; ///< The official logger - std::unique_ptr<GluGeometryRenderer> Renderer; ///< Geometry renderer variable - /// used for rendering - /// Object/ObjComponent - std::vector<Kernel::V3D> m_points; - double radius; ///<Radius for the sphere, cone and cylinder - double height; ///<height for cone and cylinder; - GeometryType - type; ///< the type of the geometry eg CUBOID,CYLINDER,CONE,SPHERE -public: - GluGeometryHandler(const GluGeometryHandler &other); - GluGeometryHandler(IObjComponent *comp); ///< Constructor - GluGeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor - GluGeometryHandler(CSGObject *obj); ///< Constructor - boost::shared_ptr<GeometryHandler> clone() const override; - ~GluGeometryHandler() override; ///< Destructor - GeometryHandler *createInstance(IObjComponent *comp) override; - GeometryHandler *createInstance(boost::shared_ptr<CSGObject> obj) override; - GeometryHandler *createInstance(CSGObject *) override; - /// sets the geometry handler for a cuboid - void setCuboid(const Kernel::V3D &, const Kernel::V3D &, const Kernel::V3D &, - const Kernel::V3D &); - /// sets the geometry handler for a hexahedron - void setHexahedron(const Kernel::V3D &, const Kernel::V3D &, - const Kernel::V3D &, const Kernel::V3D &, - const Kernel::V3D &, const Kernel::V3D &, - const Kernel::V3D &, const Kernel::V3D &); - /// sets the geometry handler for a cone - void setSphere(const Kernel::V3D &, double); - /// sets the geometry handler for a cylinder - void setCylinder(const Kernel::V3D &, const Kernel::V3D &, double, double); - /// sets the geometry handler for a cone - void setCone(const Kernel::V3D &, const Kernel::V3D &, double, double); - /// sets the geometry handler for a segmented cylinder - void setSegmentedCylinder(const Kernel::V3D &, const Kernel::V3D &, double, - double); - void Triangulate() override; - void Render() override; - void Initialize() override; - void GetObjectGeom(int &mytype, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) override; -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryRenderer.h b/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryRenderer.h deleted file mode 100644 index 0b0f4b7e2207c34526eece1f2165649e0974e318..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/GluGeometryRenderer.h +++ /dev/null @@ -1,91 +0,0 @@ -#ifndef GLU_GEOMETRYRENDERER_H -#define GLU_GEOMETRYRENDERER_H - -#include "MantidGeometry/DllConfig.h" - -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class IObjComponent; -/** - \class GluGeometryRenderer - \brief rendering geometry using opengl utility library glu. - \author Srikanth Nagella - \date July 2008 - \version 1.0 - - This is an concrete class for rendering geometry using opengl. - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL GluGeometryRenderer { -public: - /// Renders an object component - void Render(IObjComponent *ObjComp) const; - /// Renders a Sphere from the input values - void RenderSphere(const Kernel::V3D ¢er, double radius); - /// Renders a Cuboid from the input values - void RenderCube(const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4); - /// Renders a Hexahedron from the input values - void RenderHexahedron(const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4, - const Kernel::V3D &Point5, const Kernel::V3D &Point6, - const Kernel::V3D &Point7, const Kernel::V3D &Point8); - /// Renders a Cone from the input values - void RenderCone(const Kernel::V3D ¢er, const Kernel::V3D &axis, - double radius, double height); - /// Renders a Cylinder from the input values - void RenderCylinder(const Kernel::V3D ¢er, const Kernel::V3D &axis, - double radius, double height); - /// Renders a Segmented Cylinder from the input values - void RenderSegmentedCylinder(const Kernel::V3D ¢er, - const Kernel::V3D &axis, double radius, - double height); - /// Creates a sphere from the input values - void CreateSphere(const Kernel::V3D ¢er, double radius); - /// Creates a cuboid from the input values - void CreateCube(const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4); - /// Creates a Hexahedron from the input values - void CreateHexahedron(const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4, - const Kernel::V3D &Point5, const Kernel::V3D &Point6, - const Kernel::V3D &Point7, const Kernel::V3D &Point8); - /// Creates a Cone from the input values - void CreateCone(const Kernel::V3D ¢er, const Kernel::V3D &axis, - double radius, double height); - /// Creates a cylinder from the input values - void CreateCylinder(const Kernel::V3D ¢er, const Kernel::V3D &axis, - double radius, double height); - /// Creates a segmented cylinder from the input values - void CreateSegmentedCylinder(const Kernel::V3D ¢er, - const Kernel::V3D &axis, double radius, - double height); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/MeshGeometryGenerator.h b/Framework/Geometry/inc/MantidGeometry/Rendering/MeshGeometryGenerator.h deleted file mode 100644 index 18020711526b6d6ac5bde9c1a52d4fb03581413a..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/MeshGeometryGenerator.h +++ /dev/null @@ -1,63 +0,0 @@ -#ifndef MESH_GEOMETRYGENERATOR_H -#define MESH_GEOMETRYGENERATOR_H - -#include "MantidGeometry/DllConfig.h" - -namespace Mantid { - -namespace Geometry { - -/** - This class delivers the triangles of a MeshObject for rendering via - the CacheGeometryRenderer. - - Copyright © 2018 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MeshObject; -class MANTID_GEOMETRY_DLL MeshGeometryGenerator { -private: - MeshObject *Obj; ///< Input Object - int mNoOfVertices; ///< number of vertices - int mNoOfTriangles; ///< number of triangles - double *mPoints; ///<double array or points - int *mFaces; ///< Integer array of faces -public: - MeshGeometryGenerator(MeshObject *obj); - ~MeshGeometryGenerator(); - /// Generate the trangles - void Generate(); - /// get the number of triangles - int getNumberOfTriangles(); - /// get the number of points - int getNumberOfPoints(); - /// get the triangle vertices - double *getTriangleVertices(); - /// get the triangle faces - int *getTriangleFaces(); - /// Sets the geometry cache using the triangulation information provided - void setGeometryCache(int noPts, int noFaces, double *pts, int *faces); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif MESH_GEOMETRYGENERATOR_H diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryGenerator.h b/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryGenerator.h deleted file mode 100644 index 7433fcc7d2da07f0fa89f49c2b6cbbbb30675f7f..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryGenerator.h +++ /dev/null @@ -1,83 +0,0 @@ -#ifndef OC_GEOMETRYGENERATOR_H -#define OC_GEOMETRYGENERATOR_H - -#include "MantidGeometry/DllConfig.h" - -class TopoDS_Shape; - -namespace Mantid { -namespace Geometry { -class CSGObject; -class Intersection; -class Union; -class SurfPoint; -class CompGrp; -class CompObj; -class BoolValue; -class Rule; -class Surface; -class Cylinder; -class Sphere; -class Cone; -class Plane; -class Torus; - -/** - \class OCGeometryGenerator - \brief Generates OpenCascade geometry from the ObjComponent - \author Mr. Srikanth Nagella - \date 4.08.2008 - \version 1.0 - - This class is an OpenCascade geometry generation that takes in input as - ObjComponent. - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL OCGeometryGenerator { -private: - const CSGObject *Obj; ///< Input Object - TopoDS_Shape *ObjSurface; ///< Storage for the output surface - /// Analyze the object - void AnalyzeObject(); - -public: - OCGeometryGenerator(const CSGObject *obj); - ~OCGeometryGenerator(); - void Generate(); - TopoDS_Shape *getObjectSurface(); - /// return number of triangles in mesh (0 for special shapes) - int getNumberOfTriangles(); - /// return number of points used in mesh (o for special shapes) - int getNumberOfPoints(); - /// get a pointer to the 3x(NumberOfPoints) coordinates (x1,y1,z1,x2..) of - /// mesh - double *getTriangleVertices(); - /// get a pointer to the 3x(NumberOFaces) integers describing points forming - /// faces (p1,p2,p3)(p4,p5,p6). - int *getTriangleFaces(); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryHandler.h deleted file mode 100644 index b6482ce7e57434e6165312444cb39f9e99be8f4b..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryHandler.h +++ /dev/null @@ -1,86 +0,0 @@ -#ifndef OC_GEOMETRYHANDLER_H -#define OC_GEOMETRYHANDLER_H - -#include "MantidGeometry/DllConfig.h" - -namespace Mantid { - -namespace Geometry { -class GeometryHandler; -class OCGeometryRenderer; -class OCGeometryGenerator; -class IObjComponent; -class CSGObject; -/** - \class OCGeometryHandler - \brief Place holder for OpenCascade library geometry triangulation and - rendering. - \author Srikanth Nagella - \date July 2008 - \version 1.0 - - This is an implementation class for handling geometry using - OpenCascade(www.opencascade.org). - Unlike the GluGeometryHandler, it can handle more complex shapes. - It uses OpenCascade to generate a mesh defining the surface of an Object - (shape). - This shape is saved along with the instrument definition as a .vtp file (for - speed-ups). - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL OCGeometryHandler : public GeometryHandler { -private: - static Kernel::Logger &PLog; ///< The official logger - OCGeometryRenderer *Renderer; ///< Geometry renderer variable used for - /// rendering Object/ObjComponent - OCGeometryGenerator * - Triangulator; ///< Geometry generator to triangulate Object -public: - OCGeometryHandler(IObjComponent *comp); ///< Constructor - OCGeometryHandler(boost::shared_ptr<CSGObject> obj); ///< Constructor - OCGeometryHandler(CSGObject *obj); ///< Constructor - boost::shared_ptr<GeometryHandler> - clone() const override; ///< Virtual copy constructor - ~OCGeometryHandler() override; ///< Destructor - GeometryHandler *createInstance(IObjComponent *comp) override; - GeometryHandler *createInstance(boost::shared_ptr<CSGObject> obj) override; - GeometryHandler *createInstance(CSGObject *) override; - void Triangulate() override; - void Render() override; - void Initialize() override; - /// Returns true if the shape can be triangulated - bool canTriangulate() override { return true; } - /// get the number of Triangles - int NumberOfTriangles() override; - /// get the number of points or vertices - int NumberOfPoints() override; - /// Extract the vertices of the triangles - double *getTriangleVertices() override; - /// Extract the Faces of the triangles - int *getTriangleFaces() override; -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryRenderer.h b/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryRenderer.h deleted file mode 100644 index a9ab4715e1a4b623ad54ab3be5ce31b228a7d4a3..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/OCGeometryRenderer.h +++ /dev/null @@ -1,57 +0,0 @@ -#ifndef OC_GEOMETRYRENDERER_H -#define OC_GEOMETRYRENDERER_H - -#include "MantidGeometry/DllConfig.h" -#include "MantidKernel/Logger.h" -class TopoDS_Shape; -namespace Mantid { - -namespace Geometry { -class IObjComponent; -/** - \class OCGeometryRenderer - \brief rendering geometry primitives of OpenCascade - \author Srikanth Nagella - \date July 2008 - \version 1.0 - - This is an concrete class for rendering GtsSurface using opengl. - - Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class MANTID_GEOMETRY_DLL OCGeometryRenderer { -private: - static Kernel::Logger &PLog; ///< The official logger - void RenderTopoDS(TopoDS_Shape *ObjSurf); - -public: - void Render(TopoDS_Shape *ObjSurf); - void Render(IObjComponent *ObjComp); - void Initialize(TopoDS_Shape *ObjSurf); - void Initialize(IObjComponent *ObjComp); - void WriteVTK(TopoDS_Shape *out); -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/RenderingHelpers.h b/Framework/Geometry/inc/MantidGeometry/Rendering/RenderingHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..1d266bf6730c5e2350c222d6ce2af51b559c1c0f --- /dev/null +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/RenderingHelpers.h @@ -0,0 +1,40 @@ +#ifndef MANTID_GEOMETRY_RENDERER_H_ +#define MANTID_GEOMETRY_RENDERER_H_ + +#include "MantidGeometry/DllConfig.h" +#include "MantidGeometry/Rendering/OpenGL_Headers.h" +#include <vector> + +class TopoDS_Shape; + +namespace Mantid { +namespace Kernel { +class V3D; +} +namespace Geometry { +class RectangularDetector; +class StructuredDetector; +class IObjComponent; + +namespace detail { +class GeometryTriangulator; +class ShapeInfo; +} // namespace detail + +namespace RenderingHelpers { +/// Render IObjComponent +MANTID_GEOMETRY_DLL void renderIObjComponent(const IObjComponent &objComp); +/// Render Traingulated Surface +MANTID_GEOMETRY_DLL void +renderTriangulated(detail::GeometryTriangulator &triangulator); +/// Renders a sphere, cuboid, hexahedron, cone or cylinder +MANTID_GEOMETRY_DLL void renderShape(const detail::ShapeInfo &shapeInfo); +/// Renders a Bitmap (used for rendering RectangularDetector) +MANTID_GEOMETRY_DLL void renderBitmap(const RectangularDetector &rectDet); +/// Renders structured geometry (used for rendering StructuredDetector) +MANTID_GEOMETRY_DLL void renderStructured(const StructuredDetector &structDet); +} // namespace RenderingHelpers +} // namespace Geometry +} // namespace Mantid + +#endif /* MANTID_GEOMETRY_RENDERER_H_ */ \ No newline at end of file diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/ShapeInfo.h b/Framework/Geometry/inc/MantidGeometry/Rendering/ShapeInfo.h new file mode 100644 index 0000000000000000000000000000000000000000..a4d0ea6e32214baf01e6a5d28ddd2a38bf56ab1d --- /dev/null +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/ShapeInfo.h @@ -0,0 +1,94 @@ +#ifndef MANTID_GEOMETRY_SHAPEINFO_H_ +#define MANTID_GEOMETRY_SHAPEINFO_H_ + +#include "MantidGeometry/DllConfig.h" +#include <vector> + +namespace Mantid { +namespace Kernel { +class V3D; +} +namespace Geometry { +class RectangularDetector; +class StructuredDetector; +class IObjComponent; + +/** ShapeInfo : Stores shape types and information relevant to drawing the +shape. For cylinders, spheres and cones, height and radius are stored. Points +are stored in the winding order shown in the IDF here +http://docs.mantidproject.org/nightly/concepts/HowToDefineGeometricShape.html. + +Copyright © 2017 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge +National Laboratory & European Spallation Source + +This file is part of Mantid. + +Mantid is free software; you can redistribute it and/or modify +it under the terms of the GNU General Public License as published by +the Free Software Foundation; either version 3 of the License, or +(at your option) any later version. + +Mantid is distributed in the hope that it will be useful, +but WITHOUT ANY WARRANTY; without even the implied warranty of +MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +GNU General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see <http://www.gnu.org/licenses/>. + +File change history is stored at: <https://github.com/mantidproject/mantid> +Code Documentation is available at: <http://doxygen.mantidproject.org> +*/ +namespace detail { +class MANTID_GEOMETRY_DLL ShapeInfo { +public: + enum class GeometryShape { + NOSHAPE = 0, + CUBOID, ///< CUBOID + HEXAHEDRON, ///< HEXAHEDRON + SPHERE, ///< SPHERE + CYLINDER, ///< CYLINDER + CONE, ///< CONE + }; + +private: + std::vector<Kernel::V3D> m_points; + double m_radius; ///< Radius for the sphere, cone and cylinder + double m_height; ///< height for cone and cylinder; + GeometryShape m_shape; + +public: + ShapeInfo(); + ShapeInfo(const ShapeInfo &) = default; + const std::vector<Kernel::V3D> &points() const; + double radius() const; + double height() const; + GeometryShape shape() const; + + void getObjectGeometry(GeometryShape &myshape, + std::vector<Kernel::V3D> &points, double &myradius, + double &myheight) const; + /// sets the geometry handler for a cuboid + void setCuboid(const Kernel::V3D &, const Kernel::V3D &, const Kernel::V3D &, + const Kernel::V3D &); + /// sets the geometry handler for a hexahedron + void setHexahedron(const Kernel::V3D &, const Kernel::V3D &, + const Kernel::V3D &, const Kernel::V3D &, + const Kernel::V3D &, const Kernel::V3D &, + const Kernel::V3D &, const Kernel::V3D &); + /// sets the geometry handler for a sphere + void setSphere(const Kernel::V3D ¢er, double radius); + /// sets the geometry handler for a cylinder + void setCylinder(const Kernel::V3D ¢er, const Kernel::V3D &axis, + double radius, double height); + /// sets the geometry handler for a cone + void setCone(const Kernel::V3D ¢er, const Kernel::V3D &axis, + double radius, double height); + + bool operator==(const ShapeInfo &other); +}; +} // namespace detail +} // namespace Geometry +} // namespace Mantid + +#endif /* MANTID_GEOMETRY_SHAPEINFO_H_ */ \ No newline at end of file diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/StructuredGeometryHandler.h b/Framework/Geometry/inc/MantidGeometry/Rendering/StructuredGeometryHandler.h deleted file mode 100644 index 2985f21c5d5dcc74a2dcba74a9bfd9141b324b10..0000000000000000000000000000000000000000 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/StructuredGeometryHandler.h +++ /dev/null @@ -1,103 +0,0 @@ -#ifndef STRUCTUREDGEOMETRYHANDLER_H -#define STRUCTUREDGEOMETRYHANDLER_H - -#ifndef Q_MOC_RUN -#include <boost/weak_ptr.hpp> -#endif -#include "MantidGeometry/DllConfig.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidKernel/Logger.h" - -namespace Mantid { -namespace Geometry { -/** -\class StructuredGeometryHandler -\brief Handler for StructuredDetector geometry objects -\author Lamar Moore -\date March 2016 -\version 1.0 - -This class supports drawing StructuredDetector. - -Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class ObjComponent; -class CSGObject; -class MANTID_GEOMETRY_DLL StructuredGeometryHandler : public GeometryHandler { -private: - static Kernel::Logger &PLog; ///< The official logger - - boost::shared_ptr<GeometryHandler> clone() const override; - - /// The StructuredDetector object being drawn. - StructuredDetector *m_Det; - -public: - StructuredGeometryHandler(StructuredDetector *comp); - StructuredGeometryHandler(); - - StructuredGeometryHandler *createInstance( - IObjComponent *) override; ///< Create an instance of concrete geometry - /// handler for ObjComponent - StructuredGeometryHandler *createInstance(boost::shared_ptr<CSGObject>) - override; ///< Create an instance of concrete geometry handler for Object - GeometryHandler *createInstance(CSGObject *) - override; ///< Create an instance of concrete geometry handler for Object - void Triangulate() override; ///< Triangulate the Object - void Render() override; ///< Render Object or ObjComponent - void Initialize() - override; ///< Prepare/Initialize Object/ObjComponent to be rendered - /// Returns true if the shape can be triangulated - bool canTriangulate() override { return false; } - /// get the number of triangles - int NumberOfTriangles() override { return 0; } - /// get the number of points or vertices - int NumberOfPoints() override { return 0; } - /// Extract the vertices of the triangles - double *getTriangleVertices() override { return nullptr; } - /// Extract the Faces of the triangles - int *getTriangleFaces() override { return nullptr; } - /// Sets the geometry cache using the triangulation information provided - void setGeometryCache(int noPts, int noFaces, double *pts, - int *faces) override { - (void)noPts; - (void)noFaces; - (void)pts; - (void)faces; // Avoid compiler warning - }; - /// return the actual type and points of one of the "standard" objects, - /// cuboid/cone/cyl/sphere - void GetObjectGeom(int &mytype, std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) override { - (void)mytype; - (void)vectors; - (void)myradius; - (void)myheight; // Avoid compiler warning - }; -}; - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid - -#endif // STRUCTUREDGEOMETRYHANDLER_H \ No newline at end of file diff --git a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h index bd264ce85ac611f52532896802cbbbc4f7d2d12d..0c3a58e15cf9d6f1d93be3871744b90a19711413 100644 --- a/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h +++ b/Framework/Geometry/inc/MantidGeometry/Rendering/vtkGeometryCacheReader.h @@ -53,8 +53,10 @@ private: // Private Methods void Init(); Poco::XML::Element *getElementByObjectName(std::string name); - void readPoints(Poco::XML::Element *pEle, int *noOfPoints, double **points); - void readTriangles(Poco::XML::Element *pEle, int *noOfTriangles, int **faces); + void readPoints(Poco::XML::Element *pEle, int noOfPoints, + std::vector<double> &points); + void readTriangles(Poco::XML::Element *pEle, int noOfTriangles, + std::vector<uint32_t> &faces); public: vtkGeometryCacheReader(std::string filename); diff --git a/Framework/Geometry/src/Crystal/HKLGenerator.cpp b/Framework/Geometry/src/Crystal/HKLGenerator.cpp index 9d56c3a2f5dd5fcc96326c4b51852362a6558c03..0979b69dff53f69745f4d2e8b991c44f9d89e1da 100644 --- a/Framework/Geometry/src/Crystal/HKLGenerator.cpp +++ b/Framework/Geometry/src/Crystal/HKLGenerator.cpp @@ -62,20 +62,20 @@ V3D HKLGenerator::getEndHKL() const { /// Default constructor, requirement from boost::iterator_facade HKLGenerator::const_iterator::const_iterator() - : m_h(0), m_k(0), m_l(0), m_hkl(V3D(0, 0, 0)), m_hMin(0), m_hMax(0), - m_kMin(0), m_kMax(0), m_lMin(0), m_lMax(0) {} + : m_h(0), m_k(0), m_l(0), m_hkl(V3D(0, 0, 0)), m_hMax(0), m_kMin(0), + m_kMax(0), m_lMin(0), m_lMax(0) {} /// Return an iterator with min = max = current. HKLGenerator::const_iterator::const_iterator(const V3D ¤t) : m_h(static_cast<int>(current.X())), m_k(static_cast<int>(current.Y())), - m_l(static_cast<int>(current.Z())), m_hkl(current), m_hMin(m_h), - m_hMax(m_h), m_kMin(m_k), m_kMax(m_k), m_lMin(m_l), m_lMax(m_l) {} + m_l(static_cast<int>(current.Z())), m_hkl(current), m_hMax(m_h), + m_kMin(m_k), m_kMax(m_k), m_lMin(m_l), m_lMax(m_l) {} /// Return an iterator that can move from min to max, with current = min HKLGenerator::const_iterator::const_iterator(const V3D &hklMin, const V3D &hklMax) : m_h(static_cast<int>(hklMin.X())), m_k(static_cast<int>(hklMin.Y())), - m_l(static_cast<int>(hklMin.Z())), m_hkl(hklMin), m_hMin(m_h), + m_l(static_cast<int>(hklMin.Z())), m_hkl(hklMin), m_hMax(static_cast<int>(hklMax.X())), m_kMin(m_k), m_kMax(static_cast<int>(hklMax.Y())), m_lMin(m_l), m_lMax(static_cast<int>(hklMax.Z())) {} diff --git a/Framework/Geometry/src/IObjComponent.cpp b/Framework/Geometry/src/IObjComponent.cpp index a922c367caf7c5d45b5b1d490808e3de6b26e386..8ea7b46480f7e62f58e1c99604d75ca231cbd77c 100644 --- a/Framework/Geometry/src/IObjComponent.cpp +++ b/Framework/Geometry/src/IObjComponent.cpp @@ -3,12 +3,12 @@ //---------------------------------------------------------------------- #include "MantidGeometry/IObjComponent.h" #include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Rendering/CacheGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" namespace Mantid { namespace Geometry { -IObjComponent::IObjComponent() { handle = new CacheGeometryHandler(this); } +IObjComponent::IObjComponent() { handle = new GeometryHandler(this); } /** Constructor, specifying the GeometryHandler (renderer engine) * for this IObjComponent. @@ -37,12 +37,10 @@ void IObjComponent::setGeometryHandler(GeometryHandler *h) { /** * Copy constructor - * @param origin :: The object to initialize this with */ -IObjComponent::IObjComponent(const IObjComponent &origin) { - // Handler contains a pointer to 'this' therefore needs regenerating - // with new object - handle = origin.handle->createInstance(this); +IObjComponent::IObjComponent(const IObjComponent &) { + // Copy constructor just creates new handle. Copies nothing. + handle = new GeometryHandler(this); } /** @@ -52,10 +50,10 @@ IObjComponent::IObjComponent(const IObjComponent &origin) { */ IObjComponent &IObjComponent::operator=(const IObjComponent &rhs) { if (&rhs != this) { - handle = rhs.handle->createInstance(this); + // Assignment operator copies nothing. Just creates new handle. + handle = new GeometryHandler(this); } return *this; } - } // namespace Geometry } // namespace Mantid diff --git a/Framework/Geometry/src/Instrument/ComponentInfo.cpp b/Framework/Geometry/src/Instrument/ComponentInfo.cpp index e5692787af4641436aa1a79be11881a92b5122d6..b8ec01fc27f03d346882023a7b834ec5b5a98c52 100644 --- a/Framework/Geometry/src/Instrument/ComponentInfo.cpp +++ b/Framework/Geometry/src/Instrument/ComponentInfo.cpp @@ -107,8 +107,46 @@ ComponentInfo::componentsInSubtree(size_t componentIndex) const { return m_componentInfo->componentsInSubtree(componentIndex); } +const std::vector<size_t> & +ComponentInfo::children(size_t componentIndex) const { + return m_componentInfo->children(componentIndex); +} + size_t ComponentInfo::size() const { return m_componentInfo->size(); } +ComponentInfo::QuadrilateralComponent +ComponentInfo::quadrilateralComponent(const size_t componentIndex) const { + auto type = componentType(componentIndex); + if (!(type == Beamline::ComponentType::Structured || + type == Beamline::ComponentType::Rectangular)) + throw std::runtime_error("ComponentType is not Structured or Rectangular " + "in ComponentInfo::quadrilateralComponent."); + + QuadrilateralComponent corners; + const auto &innerRangeComp = m_componentInfo->children(componentIndex); + // nSubComponents, subtract off self hence -1. nSubComponents = number of + // horizontal columns. + corners.nX = innerRangeComp.size(); + auto innerRangeDet = m_componentInfo->detectorRangeInSubtree(componentIndex); + auto nSubDetectors = + std::distance(innerRangeDet.begin(), innerRangeDet.end()); + corners.nY = nSubDetectors / corners.nX; + auto firstComp = innerRangeComp.front(); + // The ranges contain the parent component as the last index + // therefore end() - 2 + auto lastComp = innerRangeComp.back(); + corners.bottomLeft = + *(m_componentInfo->detectorRangeInSubtree(firstComp).begin()); + corners.topRight = + *(m_componentInfo->detectorRangeInSubtree(lastComp).end() - 1); + corners.topLeft = + *(m_componentInfo->detectorRangeInSubtree(firstComp).end() - 1); + corners.bottomRight = + *m_componentInfo->detectorRangeInSubtree(lastComp).begin(); + + return corners; +} + size_t ComponentInfo::indexOf(Geometry::IComponent *id) const { return m_compIDToIndex->at(id); } @@ -193,7 +231,7 @@ size_t ComponentInfo::sample() const { return m_componentInfo->sample(); } double ComponentInfo::l1() const { return m_componentInfo->l1(); } -size_t ComponentInfo::root() { return m_componentInfo->root(); } +size_t ComponentInfo::root() const { return m_componentInfo->root(); } void ComponentInfo::setPosition(const size_t componentIndex, const Kernel::V3D &newPosition) { @@ -268,27 +306,18 @@ void ComponentInfo::growBoundingBoxAsRectuangularBank( Geometry::BoundingBox &mutableBB, std::map<size_t, size_t> &mutableDetExclusions, IteratorT &mutableIterator) const { - const auto innerRangeComp = m_componentInfo->componentRangeInSubtree(index); - const auto innerRangeDet = m_componentInfo->detectorRangeInSubtree(index); - // subtract 1 because component ranges includes self - auto nSubComponents = innerRangeComp.end() - innerRangeComp.begin() - 1; - auto nSubDetectors = - std::distance(innerRangeDet.begin(), innerRangeDet.end()); - auto nY = nSubDetectors / nSubComponents; - size_t bottomLeft = *innerRangeDet.begin(); - size_t topRight = bottomLeft + nSubDetectors - 1; - size_t topLeft = bottomLeft + (nY - 1); - size_t bottomRight = topRight - (nY - 1); - mutableBB.grow(componentBoundingBox(bottomLeft, reference)); - mutableBB.grow(componentBoundingBox(topRight, reference)); - mutableBB.grow(componentBoundingBox(topLeft, reference)); - mutableBB.grow(componentBoundingBox(bottomRight, reference)); + auto panel = quadrilateralComponent(index); + mutableBB.grow(componentBoundingBox(panel.bottomLeft, reference)); + mutableBB.grow(componentBoundingBox(panel.topRight, reference)); + mutableBB.grow(componentBoundingBox(panel.topLeft, reference)); + mutableBB.grow(componentBoundingBox(panel.bottomRight, reference)); // Get bounding box for rectangular bank. // Record detector ranges to skip - mutableDetExclusions.insert(std::make_pair(bottomLeft, topRight)); + mutableDetExclusions.insert(std::make_pair(panel.bottomLeft, panel.topRight)); // Skip all sub components. + const auto innerRangeComp = m_componentInfo->componentRangeInSubtree(index); mutableIterator = innerRangeComp.rend(); } @@ -370,7 +399,8 @@ BoundingBox ComponentInfo::componentBoundingBox(const size_t index, const BoundingBox *reference) const { // Check that we have a valid shape here - if (!hasValidShape(index)) { + if (!hasValidShape(index) || + componentType(index) == Beamline::ComponentType::Infinite) { return BoundingBox(); // Return null bounding box } const auto &s = this->shape(index); @@ -423,7 +453,8 @@ ComponentInfo::componentBoundingBox(const size_t index, */ BoundingBox ComponentInfo::boundingBox(const size_t componentIndex, const BoundingBox *reference) const { - if (isDetector(componentIndex)) { + if (isDetector(componentIndex) || + componentType(componentIndex) == Beamline::ComponentType::Infinite) { return componentBoundingBox(componentIndex, reference); } BoundingBox absoluteBB; @@ -435,7 +466,8 @@ BoundingBox ComponentInfo::boundingBox(const size_t componentIndex, const auto compFlag = componentType(index); if (hasSource() && index == source()) { ++compIterator; - } else if (compFlag == Beamline::ComponentType::Rectangular) { + } else if (compFlag == Beamline::ComponentType::Rectangular || + compFlag == Beamline::ComponentType::Structured) { growBoundingBoxAsRectuangularBank(index, reference, absoluteBB, detExclusions, compIterator); } else if (compFlag == Beamline::ComponentType::OutlineComposite) { diff --git a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp index 88776862dc21d3fe9f78c77b8178981638c7ecb1..41e50b977925a30e0e742769615aaf8b4f84a5ca 100644 --- a/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentDefinitionParser.cpp @@ -1587,8 +1587,8 @@ void InstrumentDefinitionParser::createStructuredDetector( bool isZBeam = m_instrument->getReferenceFrame()->isVectorPointingAlongBeam(zVector); // Now, initialize all the pixels in the bank - bank->initialize(xpixels, ypixels, xValues, yValues, isZBeam, idstart, - idfillbyfirst_y, idstepbyrow, idstep); + bank->initialize(xpixels, ypixels, std::move(xValues), std::move(yValues), + isZBeam, idstart, idfillbyfirst_y, idstepbyrow, idstep); // Loop through all detectors in the newly created bank and mark those in // the instrument. diff --git a/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp b/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp index daa04a82684604f0229a009008b981d04803c9ff..719d9883b116ce6045efb159cedb1ed541667ab6 100644 --- a/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp +++ b/Framework/Geometry/src/Instrument/InstrumentVisitor.cpp @@ -71,6 +71,7 @@ InstrumentVisitor::InstrumentVisitor( boost::make_shared<std::vector<size_t>>()), m_parentComponentIndices(boost::make_shared<std::vector<size_t>>( m_orderedDetectorIds->size(), 0)), + m_children(boost::make_shared<std::vector<std::vector<size_t>>>()), m_detectorRanges( boost::make_shared<std::vector<std::pair<size_t, size_t>>>()), m_componentRanges( @@ -178,6 +179,7 @@ InstrumentVisitor::registerComponentAssembly(const ICompAssembly &assembly) { for (const auto &child : children) { (*m_parentComponentIndices)[child] = componentIndex; } + m_children->emplace_back(std::move(children)); return componentIndex; } @@ -205,6 +207,37 @@ InstrumentVisitor::registerGenericComponent(const IComponent &component) { // Unless this is the root component this parent is not correct and will be // updated later in the register call of the parent. m_parentComponentIndices->push_back(componentIndex); + // Generic components are not assemblies and do not therefore have children. + m_children->emplace_back(std::vector<size_t>()); + return componentIndex; +} + +/** +* @brief InstrumentVisitor::registerInfiniteComponent +* @param component : IComponent being visited +* @return Component index of this component +*/ +size_t InstrumentVisitor::registerInfiniteComponent( + const Mantid::Geometry::IComponent &component) { + /* + * For a generic leaf component we extend the component ids list, but + * the detector indexes entries will of course be empty + */ + m_detectorRanges->emplace_back( + std::make_pair(0, 0)); // Represents an empty range + // Record the ID -> index mapping + const size_t componentIndex = commonRegistration(component); + m_componentType->push_back(Beamline::ComponentType::Infinite); + + const size_t componentStart = m_assemblySortedComponentIndices->size(); + m_componentRanges->emplace_back( + std::make_pair(componentStart, componentStart + 1)); + m_assemblySortedComponentIndices->push_back(componentIndex); + // Unless this is the root component this parent is not correct and will be + // updated later in the register call of the parent. + m_parentComponentIndices->push_back(componentIndex); + // Generic components are not assemblies and do not therefore have children. + m_children->emplace_back(std::vector<size_t>()); return componentIndex; } @@ -220,15 +253,39 @@ size_t InstrumentVisitor::registerGenericObjComponent( return index; } +/** +* Register a structured bank +* @param bank : Rectangular Detector +* @return index assigned +*/ +size_t InstrumentVisitor::registerRectangularBank(const ICompAssembly &bank) { + auto index = registerComponentAssembly(bank); + size_t rangesIndex = index - m_orderedDetectorIds->size(); + (*m_componentType)[rangesIndex] = Beamline::ComponentType::Rectangular; + return index; +} + +/** +* @brief InstrumentVisitor::registerInfiniteObjComponent +* @param objComponent : IObjComponent being visited +* @return Component index of this component +*/ +size_t InstrumentVisitor::registerInfiniteObjComponent( + const IObjComponent &objComponent) { + auto index = registerInfiniteComponent(objComponent); + (*m_shapes)[index] = objComponent.shape(); + return index; +} + /** * Register a structured bank - * @param bank : Rectangular Detector + * @param bank : Structured Detector * @return index assigned */ size_t InstrumentVisitor::registerStructuredBank(const ICompAssembly &bank) { auto index = registerComponentAssembly(bank); size_t rangesIndex = index - m_orderedDetectorIds->size(); - (*m_componentType)[rangesIndex] = Beamline::ComponentType::Rectangular; + (*m_componentType)[rangesIndex] = Beamline::ComponentType::Structured; return index; } @@ -335,8 +392,8 @@ InstrumentVisitor::componentInfo() const { return Kernel::make_unique<Mantid::Beamline::ComponentInfo>( m_assemblySortedDetectorIndices, m_detectorRanges, m_assemblySortedComponentIndices, m_componentRanges, - m_parentComponentIndices, m_positions, m_rotations, m_scaleFactors, - m_componentType, m_names, m_sourceIndex, m_sampleIndex); + m_parentComponentIndices, m_children, m_positions, m_rotations, + m_scaleFactors, m_componentType, m_names, m_sourceIndex, m_sampleIndex); } std::unique_ptr<Beamline::DetectorInfo> diff --git a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp index c53c6a4713ff87bbc8d04c055c1f4c4625f62dad..3f4deaf8030b92ec3672c975aa4162e48dd91a84 100644 --- a/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp +++ b/Framework/Geometry/src/Instrument/ObjCompAssembly.cpp @@ -380,7 +380,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // Get information about the shape and size of a detector std::string type; - int otype; + detail::ShapeInfo::GeometryShape otype; std::vector<Kernel::V3D> vectors; double radius, height; boost::shared_ptr<const IObject> obj = group.front()->shape(); @@ -389,9 +389,9 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { "Found ObjComponent without shape"); } obj->GetObjectGeom(otype, vectors, radius, height); - if (otype == 1) { + if (otype == detail::ShapeInfo::GeometryShape::CUBOID) { type = "box"; - } else if (otype == 4) { + } else if (otype == detail::ShapeInfo::GeometryShape::CYLINDER) { type = "cylinder"; } else { throw std::runtime_error( @@ -583,7 +583,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { // inverse the vz axis vz = vz * (-1); } - obj_str << "<segmented-cylinder id=\"stick\">"; + obj_str << "<cylinder id=\"stick\">"; obj_str << "<centre-of-bottom-base "; obj_str << "x=\"" << Cmass.X(); obj_str << "\" y=\"" << Cmass.Y(); @@ -593,7 +593,7 @@ boost::shared_ptr<IObject> ObjCompAssembly::createOutline() { << vz.Z() << "\" /> "; obj_str << "<radius val=\"" << radius << "\" />"; obj_str << "<height val=\"" << hz << "\" />"; - obj_str << "</segmented-cylinder>"; + obj_str << "</cylinder>"; } if (!obj_str.str().empty()) { diff --git a/Framework/Geometry/src/Instrument/ObjComponent.cpp b/Framework/Geometry/src/Instrument/ObjComponent.cpp index f648681ec0870676d4ff272868717e86762615e8..5dcd1e54cf1ade6a8072cc65c8daedcae2fe276e 100644 --- a/Framework/Geometry/src/Instrument/ObjComponent.cpp +++ b/Framework/Geometry/src/Instrument/ObjComponent.cpp @@ -1,12 +1,13 @@ #include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidGeometry/Instrument/ComponentVisitor.h" #include "MantidGeometry/Instrument/ComponentInfo.h" -#include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Instrument/ComponentVisitor.h" #include "MantidGeometry/Objects/BoundingBox.h" +#include "MantidGeometry/Objects/CSGObject.h" +#include "MantidGeometry/Objects/IObject.h" #include "MantidGeometry/Objects/Track.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" #include <cfloat> namespace Mantid { @@ -313,7 +314,7 @@ void ObjComponent::draw() const { if (Handle() == nullptr) return; // Render the ObjComponent and then render the object - Handle()->Render(); + Handle()->render(); } /** @@ -334,7 +335,7 @@ void ObjComponent::initDraw() const { // Render the ObjComponent and then render the object if (shape() != nullptr) shape()->initDraw(); - Handle()->Initialize(); + Handle()->initialize(); } /** @@ -342,8 +343,10 @@ void ObjComponent::initDraw() const { */ size_t ObjComponent::registerContents(class ComponentVisitor &componentVisitor) const { - - return componentVisitor.registerGenericObjComponent(*this); + if (this->shape() != nullptr && this->shape()->isFiniteGeometry()) + return componentVisitor.registerGenericObjComponent(*this); + else + return componentVisitor.registerInfiniteObjComponent(*this); } } // namespace Geometry diff --git a/Framework/Geometry/src/Instrument/RectangularDetector.cpp b/Framework/Geometry/src/Instrument/RectangularDetector.cpp index 29744ae693e6a62718a193817c225a3a0d248449..95793784ae30a41dea15a699f0fdbfeb99ecd77a 100644 --- a/Framework/Geometry/src/Instrument/RectangularDetector.cpp +++ b/Framework/Geometry/src/Instrument/RectangularDetector.cpp @@ -5,15 +5,17 @@ #include "MantidKernel/Matrix.h" #include "MantidGeometry/Objects/BoundingBox.h" #include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Objects/CSGObject.h" #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidGeometry/Objects/Track.h" -#include "MantidGeometry/Rendering/BitmapGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" #include <algorithm> #include <ostream> #include <stdexcept> #include <boost/regex.hpp> +#include <boost/make_shared.hpp> #include "MantidGeometry/Instrument/RectangularDetectorPixel.h" namespace { @@ -45,7 +47,7 @@ RectangularDetector::RectangularDetector() m_minDetId(0), m_maxDetId(0) { init(); - setGeometryHandler(new BitmapGeometryHandler(this)); + setGeometryHandler(new GeometryHandler(this)); } /** Constructor for a parametrized RectangularDetector @@ -57,7 +59,7 @@ RectangularDetector::RectangularDetector(const RectangularDetector *base, : CompAssembly(base, map), IObjComponent(nullptr), m_rectBase(base), m_minDetId(0), m_maxDetId(0) { init(); - setGeometryHandler(new BitmapGeometryHandler(this)); + setGeometryHandler(new GeometryHandler(this)); } /** Valued constructor @@ -75,7 +77,7 @@ RectangularDetector::RectangularDetector(const std::string &n, m_minDetId(0), m_maxDetId(0) { init(); this->setName(n); - setGeometryHandler(new BitmapGeometryHandler(this)); + setGeometryHandler(new GeometryHandler(this)); } bool RectangularDetector::compareName(const std::string &proposedMatch) { @@ -673,7 +675,7 @@ void RectangularDetector::draw() const { if (Handle() == nullptr) return; // Render the ObjComponent and then render the object - Handle()->Render(); + Handle()->render(); } /** @@ -696,7 +698,7 @@ void RectangularDetector::initDraw() const { return; // Render the ObjComponent and then render the object // if(shape!=NULL) shape->initDraw(); - Handle()->Initialize(); + Handle()->initialize(); } //------------------------------------------------------------------------------------------------- @@ -732,7 +734,7 @@ const Kernel::Material RectangularDetector::material() const { size_t RectangularDetector::registerContents( ComponentVisitor &componentVisitor) const { - return componentVisitor.registerStructuredBank(*this); + return componentVisitor.registerRectangularBank(*this); } //------------------------------------------------------------------------------------------------- diff --git a/Framework/Geometry/src/Instrument/ReferenceFrame.cpp b/Framework/Geometry/src/Instrument/ReferenceFrame.cpp index a9c128f1280601372253ffe9e4decc9e832c639f..520aafe8cd568d4dcf3573a82f8472a5f67cb6f7 100644 --- a/Framework/Geometry/src/Instrument/ReferenceFrame.cpp +++ b/Framework/Geometry/src/Instrument/ReferenceFrame.cpp @@ -6,65 +6,15 @@ using namespace Mantid::Kernel; namespace Mantid { namespace Geometry { -//---------------------------------------------------------------------------------------------- -/** Constructor -@param up : pointing up axis -@param alongBeam : axis pointing along the beam -@param handedness : Handedness -@param origin : origin -*/ -ReferenceFrame::ReferenceFrame(PointingAlong up, PointingAlong alongBeam, - Handedness handedness, std::string origin) - : m_up(up), m_alongBeam(alongBeam), m_thetaSign(up), - m_handedness(handedness), m_origin(origin) { - if (up == alongBeam) { - throw std::invalid_argument( - "Cannot have up direction the same as the beam direction"); - } - init(); -} - -//---------------------------------------------------------------------------------------------- -/** Constructor -@param up : pointing up axis -@param alongBeam : axis pointing along the beam -@param thetaSign : axis defining the sign of 2theta -@param handedness : Handedness -@param origin : origin -*/ -ReferenceFrame::ReferenceFrame(PointingAlong up, PointingAlong alongBeam, - PointingAlong thetaSign, Handedness handedness, - std::string origin) - : m_up(up), m_alongBeam(alongBeam), m_thetaSign(thetaSign), - m_handedness(handedness), m_origin(origin) { - if (up == alongBeam) { - throw std::invalid_argument( - "Cannot have up direction the same as the beam direction"); - } - if (thetaSign == alongBeam) { - throw std::invalid_argument( - "Scattering angle sign axis cannot be the same as the beam direction"); - } - init(); -} - -//---------------------------------------------------------------------------------------------- -/** Constructor -Default constructor -*/ -ReferenceFrame::ReferenceFrame() - : m_up(Y), m_alongBeam(Z), m_handedness(Right), m_origin("source") { - init(); -} - +namespace { /** -Non-member helper method to convert x y z enumeration directions into proper -3D vectors. -@param direction : direction marker -@return 3D vector + * Non-member helper method to convert x y z enumeration directions into proper + * 3D vectors. + * @param direction : direction marker + * @return 3D vector */ V3D directionToVector(const PointingAlong &direction) { - Mantid::Kernel::V3D result; + V3D result; if (direction == X) { result = V3D(1, 0, 0); } else if (direction == Y) { @@ -91,9 +41,44 @@ std::string directionToString(const PointingAlong &direction) { } return result; } +} + +/** + * Default constructor. up=Y, beam=Z, thetaSign=Y + */ +ReferenceFrame::ReferenceFrame() : ReferenceFrame(Y, Z, Y, Right, "source") {} -/// Perform common initalisation steps. -void ReferenceFrame::init() { +/** Constructor specifying thetaSign=up + * @param up :pointing up axis + * @param alongBeam : axis pointing along the beam + * @param handedness : Handedness + * @param origin : origin +*/ +ReferenceFrame::ReferenceFrame(PointingAlong up, PointingAlong alongBeam, + Handedness handedness, std::string origin) + : ReferenceFrame(up, alongBeam, up, handedness, std::move(origin)) {} + +/** + * Constructor specifying all attributes + * @param up : pointing up axis + * @param alongBeam : axis pointing along the beam + * @param thetaSign : axis defining the sign of 2theta + * @param handedness : Handedness + * @param origin : origin +*/ +ReferenceFrame::ReferenceFrame(PointingAlong up, PointingAlong alongBeam, + PointingAlong thetaSign, Handedness handedness, + std::string origin) + : m_up(up), m_alongBeam(alongBeam), m_thetaSign(thetaSign), + m_handedness(handedness), m_origin(std::move(origin)) { + if (up == alongBeam) { + throw std::invalid_argument( + "Cannot have up direction the same as the beam direction"); + } + if (thetaSign == alongBeam) { + throw std::invalid_argument( + "Scattering angle sign axis cannot be the same as the beam direction"); + } m_vecPointingUp = directionToVector(m_up); m_vecPointingAlongBeam = directionToVector(m_alongBeam); m_vecThetaSign = directionToVector(m_thetaSign); diff --git a/Framework/Geometry/src/Instrument/StructuredDetector.cpp b/Framework/Geometry/src/Instrument/StructuredDetector.cpp index ecf96fc36e343086ef31a3f56d01ada46ea13800..40ba6ba2edc487ecfa1cc7e153e17d51035404ac 100644 --- a/Framework/Geometry/src/Instrument/StructuredDetector.cpp +++ b/Framework/Geometry/src/Instrument/StructuredDetector.cpp @@ -5,8 +5,7 @@ #include "MantidGeometry/Objects/BoundingBox.h" #include "MantidGeometry/Objects/CSGObject.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidGeometry/Rendering/GluGeometryHandler.h" -#include "MantidGeometry/Rendering/StructuredGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidKernel/Exception.h" #include "MantidKernel/Material.h" #include "MantidKernel/Matrix.h" @@ -71,7 +70,7 @@ void StructuredDetector::init() { m_idStepByRow = 0; m_idStep = 0; - setGeometryHandler(new StructuredGeometryHandler(this)); + setGeometryHandler(new GeometryHandler(this)); } /** Clone method @@ -290,8 +289,8 @@ std::vector<double> const &StructuredDetector::getYValues() const { * */ void StructuredDetector::initialize(size_t xPixels, size_t yPixels, - const std::vector<double> &x, - const std::vector<double> &y, bool isZBeam, + std::vector<double> &&x, + std::vector<double> &&y, bool isZBeam, detid_t idStart, bool idFillByFirstY, int idStepByRow, int idStep) { if (m_map) @@ -329,8 +328,8 @@ void StructuredDetector::initialize(size_t xPixels, size_t yPixels, "z-axis aligned beams."); // Store vertices - m_xvalues = x; - m_yvalues = y; + m_xvalues = std::move(x); + m_yvalues = std::move(y); createDetectors(); } @@ -552,7 +551,7 @@ void StructuredDetector::draw() const { if (Handle() == nullptr) return; // Render the ObjComponent and then render the object - Handle()->Render(); + Handle()->render(); } /** @@ -568,7 +567,7 @@ void StructuredDetector::initDraw() const { if (Handle() == nullptr) return; - Handle()->Initialize(); + Handle()->initialize(); } /// Returns the shape of the Object diff --git a/Framework/Geometry/src/Math/BnId.cpp b/Framework/Geometry/src/Math/BnId.cpp index 84088af001457c25bc1c922dd3fadc196f625473..5c5ae0742ea7a5214d53876fb063c0cee9b0ebc0 100644 --- a/Framework/Geometry/src/Math/BnId.cpp +++ b/Framework/Geometry/src/Math/BnId.cpp @@ -110,8 +110,6 @@ int BnId::operator<(const BnId &A) const { if (A.size != size) return size < A.size; - std::pair<int, int> cntA(0, 0); // count for A - std::pair<int, int> cntT(0, 0); // count for this if (Znum != A.Znum) return (Znum < A.Znum) ? 1 : 0; @@ -281,9 +279,7 @@ std::pair<int, BnId> BnId::makeCombination(const BnId &A) const if (Tnum == A.Tnum) return std::pair<int, BnId>(0, BnId()); - int flag(0); // numb of diff - std::pair<int, int> Tcnt(0, 0); // this counter - std::pair<int, int> Acnt(0, 0); // A counter + int flag(0); // numb of diff auto avc = A.Tval.cbegin(); std::vector<int>::const_iterator chpt; // change point for (auto tvc = Tval.cbegin(); tvc != Tval.cend(); ++tvc, ++avc) { diff --git a/Framework/Geometry/src/Objects/CSGObject.cpp b/Framework/Geometry/src/Objects/CSGObject.cpp index 0d512c6a9402b8b6f6f25646b2df2e71b04aeaee..ee88d0106064d96fac71ad90b213d7540984b1e5 100644 --- a/Framework/Geometry/src/Objects/CSGObject.cpp +++ b/Framework/Geometry/src/Objects/CSGObject.cpp @@ -2,9 +2,8 @@ #include "MantidGeometry/Objects/Rules.h" #include "MantidGeometry/Objects/Track.h" -#include "MantidGeometry/Rendering/CacheGeometryHandler.h" #include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Rendering/GluGeometryHandler.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" #include "MantidGeometry/Rendering/vtkGeometryCacheWriter.h" #include "MantidGeometry/Surfaces/Cone.h" @@ -60,7 +59,7 @@ CSGObject::CSGObject(const std::string &shapeXML) vtkCacheWriter(boost::shared_ptr<vtkGeometryCacheWriter>()), m_shapeXML(shapeXML), m_id(), m_material() // empty by default { - m_handler = boost::make_shared<CacheGeometryHandler>(this); + m_handler = boost::make_shared<GeometryHandler>(this); } /** @@ -810,7 +809,7 @@ int CSGObject::calcValidType(const Kernel::V3D &point, * shape. */ double CSGObject::solidAngle(const Kernel::V3D &observer) const { - if (this->NumberOfTriangles() > 30000) + if (this->numberOfTriangles() > 30000) return rayTraceSolidAngle(observer); return triangleSolidAngle(observer); } @@ -1008,28 +1007,25 @@ double CSGObject::triangleSolidAngle(const V3D &observer) const { // If the object is a simple shape use the special methods double height(0.0), radius(0.0); - int type(0); + detail::ShapeInfo::GeometryShape type; std::vector<Mantid::Kernel::V3D> geometry_vectors; // Maximum of 4 vectors depending on the type geometry_vectors.reserve(4); this->GetObjectGeom(type, geometry_vectors, radius, height); - int nTri = this->NumberOfTriangles(); + auto nTri = this->numberOfTriangles(); // Cylinders are by far the most frequently used - GluGeometryHandler::GeometryType gluType = - static_cast<GluGeometryHandler::GeometryType>(type); - - switch (gluType) { - case GluGeometryHandler::GeometryType::CUBOID: + switch (type) { + case detail::ShapeInfo::GeometryShape::CUBOID: return CuboidSolidAngle(observer, geometry_vectors); break; - case GluGeometryHandler::GeometryType::SPHERE: + case detail::ShapeInfo::GeometryShape::SPHERE: return SphereSolidAngle(observer, geometry_vectors, radius); break; - case GluGeometryHandler::GeometryType::CYLINDER: + case detail::ShapeInfo::GeometryShape::CYLINDER: return CylinderSolidAngle(observer, geometry_vectors[0], geometry_vectors[1], radius, height); break; - case GluGeometryHandler::GeometryType::CONE: + case detail::ShapeInfo::GeometryShape::CONE: return ConeSolidAngle(observer, geometry_vectors[0], geometry_vectors[1], radius, height); break; @@ -1038,10 +1034,10 @@ double CSGObject::triangleSolidAngle(const V3D &observer) const { { return rayTraceSolidAngle(observer); } else { // Compute a generic shape that has been triangulated - double *vertices = this->getTriangleVertices(); - int *faces = this->getTriangleFaces(); + const auto &vertices = this->getTriangleVertices(); + const auto &faces = this->getTriangleFaces(); double sangle(0.0), sneg(0.0); - for (int i = 0; i < nTri; i++) { + for (size_t i = 0; i < nTri; i++) { int p1 = faces[i * 3], p2 = faces[i * 3 + 1], p3 = faces[i * 3 + 2]; V3D vp1 = V3D(vertices[3 * p1], vertices[3 * p1 + 1], vertices[3 * p1 + 2]); @@ -1090,7 +1086,7 @@ double CSGObject::triangleSolidAngle(const V3D &observer, } } - int nTri = this->NumberOfTriangles(); + auto nTri = this->numberOfTriangles(); // // If triangulation is not available fall back to ray tracing method, unless // object is a standard shape, currently Cuboid or Sphere. Should add Cylinder @@ -1098,19 +1094,16 @@ double CSGObject::triangleSolidAngle(const V3D &observer, // if (nTri == 0) { double height = 0.0, radius(0.0); - int type; + detail::ShapeInfo::GeometryShape type; std::vector<Kernel::V3D> vectors; this->GetObjectGeom(type, vectors, radius, height); - GluGeometryHandler::GeometryType gluType = - static_cast<GluGeometryHandler::GeometryType>(type); - - switch (gluType) { - case GluGeometryHandler::GeometryType::CUBOID: + switch (type) { + case detail::ShapeInfo::GeometryShape::CUBOID: for (auto &vector : vectors) vector *= scaleFactor; return CuboidSolidAngle(observer, vectors); break; - case GluGeometryHandler::GeometryType::SPHERE: + case detail::ShapeInfo::GeometryShape::SPHERE: return SphereSolidAngle(observer, vectors, radius); break; default: @@ -1122,10 +1115,10 @@ double CSGObject::triangleSolidAngle(const V3D &observer, // return rayTraceSolidAngle(observer); // so is this } - double *vertices = this->getTriangleVertices(); - int *faces = this->getTriangleFaces(); + const auto &vertices = this->getTriangleVertices(); + const auto &faces = this->getTriangleFaces(); double sangle(0.0), sneg(0.0); - for (int i = 0; i < nTri; i++) { + for (size_t i = 0; i < nTri; i++) { int p1 = faces[i * 3], p2 = faces[i * 3 + 1], p3 = faces[i * 3 + 2]; // would be more efficient to pre-multiply the vertices (copy of) by these // factors beforehand @@ -1491,15 +1484,13 @@ double CSGObject::ConeSolidAngle(const V3D &observer, * @return The volume. */ double CSGObject::volume() const { - int type; + detail::ShapeInfo::GeometryShape type; double height; double radius; std::vector<Kernel::V3D> vectors; this->GetObjectGeom(type, vectors, radius, height); - GluGeometryHandler::GeometryType gluType = - static_cast<GluGeometryHandler::GeometryType>(type); - switch (gluType) { - case GluGeometryHandler::GeometryType::CUBOID: { + switch (type) { + case detail::ShapeInfo::GeometryShape::CUBOID: { // Here, the volume is calculated by the triangular method. // We use one of the vertices (vectors[0]) as the reference // point. @@ -1529,9 +1520,9 @@ double CSGObject::volume() const { volume += brt.scalar_prod(brb.cross_prod(blb)); return volume / 6; } - case GluGeometryHandler::GeometryType::SPHERE: + case detail::ShapeInfo::GeometryShape::SPHERE: return 4.0 / 3.0 * M_PI * radius * radius * radius; - case GluGeometryHandler::GeometryType::CYLINDER: + case detail::ShapeInfo::GeometryShape::CYLINDER: return M_PI * radius * radius * height; default: // Fall back to Monte Carlo method. @@ -1717,10 +1708,10 @@ void CSGObject::calcBoundingBoxByRule() { */ void CSGObject::calcBoundingBoxByVertices() { // Grab vertex information - auto vertCount = this->NumberOfPoints(); - auto vertArray = this->getTriangleVertices(); + auto vertCount = this->numberOfVertices(); - if (vertCount && vertArray) { + if (vertCount > 0) { + const auto &vertArray = this->getTriangleVertices(); // Unreasonable extents to be overwritten by loop constexpr double huge = 1e10; double minX, maxX, minY, maxY, minZ, maxZ; @@ -1728,7 +1719,7 @@ void CSGObject::calcBoundingBoxByVertices() { maxX = maxY = maxZ = -huge; // Loop over all vertices and determine minima and maxima on each axis - for (int i = 0; i < vertCount; ++i) { + for (size_t i = 0; i < vertCount; ++i) { auto vx = vertArray[3 * i + 0]; auto vy = vertArray[3 * i + 1]; auto vz = vertArray[3 * i + 2]; @@ -1761,19 +1752,16 @@ void CSGObject::calcBoundingBoxByGeometry() { double minX, maxX, minY, maxY, minZ, maxZ; // Shape geometry data - int type(0); + detail::ShapeInfo::GeometryShape type; std::vector<Kernel::V3D> vectors; double radius; double height; - // Will only work for shapes handled by GluGeometryHandler + // Will only work for shapes with ShapeInfo m_handler->GetObjectGeom(type, vectors, radius, height); - GluGeometryHandler::GeometryType gluType = - static_cast<GluGeometryHandler::GeometryType>(type); - // Type of shape is given as a simple integer - switch (gluType) { - case GluGeometryHandler::GeometryType::CUBOID: { + switch (type) { + case detail::ShapeInfo::GeometryShape::CUBOID: { // Points as defined in IDF XML auto &lfb = vectors[0]; // Left-Front-Bottom auto &lft = vectors[1]; // Left-Front-Top @@ -1806,7 +1794,7 @@ void CSGObject::calcBoundingBoxByGeometry() { maxZ = std::max(maxZ, vector.Z()); } } break; - case GluGeometryHandler::GeometryType::HEXAHEDRON: { + case detail::ShapeInfo::GeometryShape::HEXAHEDRON: { // These will be replaced by more realistic values in the loop below minX = minY = minZ = std::numeric_limits<decltype(minZ)>::max(); maxX = maxY = maxZ = -std::numeric_limits<decltype(maxZ)>::max(); @@ -1821,8 +1809,7 @@ void CSGObject::calcBoundingBoxByGeometry() { maxZ = std::max(maxZ, vector.Z()); } } break; - case GluGeometryHandler::GeometryType::CYLINDER: - case GluGeometryHandler::GeometryType::SEGMENTED_CYLINDER: { + case detail::ShapeInfo::GeometryShape::CYLINDER: { // Center-point of base and normalized axis based on IDF XML auto &base = vectors[0]; auto &axis = vectors[1]; @@ -1845,7 +1832,7 @@ void CSGObject::calcBoundingBoxByGeometry() { maxZ = std::max(base.Z(), top.Z()) + rz; } break; - case GluGeometryHandler::GeometryType::CONE: { + case detail::ShapeInfo::GeometryShape::CONE: { auto &tip = vectors[0]; // Tip-point of cone auto &axis = vectors[1]; // Normalized axis auto base = tip + (axis * height); // Center of base @@ -2072,7 +2059,7 @@ void CSGObject::draw() const { if (m_handler == nullptr) return; // Render the Object - m_handler->Render(); + m_handler->render(); } /** @@ -2084,7 +2071,7 @@ void CSGObject::initDraw() const { if (m_handler == nullptr) return; // Render the Object - m_handler->Initialize(); + m_handler->initialize(); } /** * set vtkGeometryCache writer @@ -2105,8 +2092,8 @@ void CSGObject::setVtkGeometryCacheReader( } /** -* Returns the geometry handler -*/ + * Returns the geometry handler + */ boost::shared_ptr<GeometryHandler> CSGObject::getGeometryHandler() const { // Check if the geometry handler is upto dated with the cache, if not then // cache it now. @@ -2137,49 +2124,43 @@ void CSGObject::updateGeometryHandler() { // Initialize Draw Object -/** -* get number of triangles -* @return the number of triangles -*/ -int CSGObject::NumberOfTriangles() const { +size_t CSGObject::numberOfTriangles() const { if (m_handler == nullptr) return 0; - return m_handler->NumberOfTriangles(); + return m_handler->numberOfTriangles(); } - -/** -* get number of points -*/ -int CSGObject::NumberOfPoints() const { +size_t CSGObject::numberOfVertices() const { if (m_handler == nullptr) return 0; - return m_handler->NumberOfPoints(); + return m_handler->numberOfPoints(); } - /** * get vertices */ -double *CSGObject::getTriangleVertices() const { +const std::vector<double> &CSGObject::getTriangleVertices() const { + static const std::vector<double> empty; if (m_handler == nullptr) - return nullptr; + return empty; return m_handler->getTriangleVertices(); } /** -* get faces -*/ -int *CSGObject::getTriangleFaces() const { + * get faces + */ +const std::vector<uint32_t> &CSGObject::getTriangleFaces() const { + static const std::vector<uint32_t> empty; if (m_handler == nullptr) - return nullptr; + return empty; return m_handler->getTriangleFaces(); } /** * get info on standard shapes */ -void CSGObject::GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, +void CSGObject::GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, double &myheight) const { - type = 0; + type = detail::ShapeInfo::GeometryShape::NOSHAPE; if (m_handler == nullptr) return; m_handler->GetObjectGeom(type, vectors, myradius, myheight); diff --git a/Framework/Geometry/src/Objects/MeshObject.cpp b/Framework/Geometry/src/Objects/MeshObject.cpp index fa4981b8796175f70e6d1a73af30c18431212a2e..5ac26e51f9a63c0030dccb25d4065d904534f505 100644 --- a/Framework/Geometry/src/Objects/MeshObject.cpp +++ b/Framework/Geometry/src/Objects/MeshObject.cpp @@ -1,7 +1,5 @@ #include "MantidGeometry/Objects/MeshObject.h" - #include "MantidGeometry/Objects/Track.h" -#include "MantidGeometry/Rendering/CacheGeometryHandler.h" #include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Rendering/vtkGeometryCacheReader.h" #include "MantidGeometry/Rendering/vtkGeometryCacheWriter.h" @@ -45,7 +43,7 @@ void MeshObject::initialize() { "Too many vertices (" + std::to_string(m_vertices.size()) + "). MeshObject cannot have more than 65535 vertices."); } - m_handler = boost::make_shared<CacheGeometryHandler>(this); + m_handler = boost::make_shared<GeometryHandler>(this); } /** @@ -567,7 +565,7 @@ void MeshObject::draw() const { if (m_handler == nullptr) return; // Render the Object - m_handler->Render(); + m_handler->render(); } /** @@ -579,7 +577,7 @@ void MeshObject::initDraw() const { if (m_handler == nullptr) return; // Render the Object - m_handler->Initialize(); + m_handler->initialize(); } /** @@ -601,18 +599,16 @@ void MeshObject::updateGeometryHandler() { /** * Output functions for rendering, may also be used internally */ -int MeshObject::numberOfTriangles() const { - return static_cast<int>(m_triangles.size() / 3); -} +size_t MeshObject::numberOfTriangles() const { return m_triangles.size() / 3; } /** * get faces */ -int *MeshObject::getTriangles() const { - int *faces = nullptr; +std::vector<uint32_t> MeshObject::getTriangles() const { + std::vector<uint32_t> faces; size_t nFaceCorners = m_triangles.size(); if (nFaceCorners > 0) { - faces = new int[static_cast<std::size_t>(nFaceCorners)]; + faces.resize(static_cast<std::size_t>(nFaceCorners)); for (size_t i = 0; i < nFaceCorners; ++i) { faces[i] = static_cast<int>(m_triangles[i]); } @@ -623,18 +619,18 @@ int *MeshObject::getTriangles() const { /** * get number of points */ -int MeshObject::numberOfVertices() const { +size_t MeshObject::numberOfVertices() const { return static_cast<int>(m_vertices.size()); } /** * get vertices */ -double *MeshObject::getVertices() const { - double *points = nullptr; +std::vector<double> MeshObject::getVertices() const { + std::vector<double> points; size_t nPoints = m_vertices.size(); if (nPoints > 0) { - points = new double[static_cast<std::size_t>(nPoints) * 3]; + points.resize(static_cast<std::size_t>(nPoints) * 3); for (size_t i = 0; i < nPoints; ++i) { V3D pnt = m_vertices[i]; points[i * 3 + 0] = pnt.X(); @@ -648,12 +644,13 @@ double *MeshObject::getVertices() const { /** * get info on standard shapes (none for Mesh Object) */ -void MeshObject::GetObjectGeom(int &type, std::vector<Kernel::V3D> &vectors, +void MeshObject::GetObjectGeom(detail::ShapeInfo::GeometryShape &type, + std::vector<Kernel::V3D> &vectors, double &myradius, double &myheight) const { // In practice, this outputs type = -1, // to indicate not a "standard" object (cuboid/cone/cyl/sphere). // Retained for possible future use. - type = 0; + type = detail::ShapeInfo::GeometryShape::NOSHAPE; if (m_handler == nullptr) return; m_handler->GetObjectGeom(type, vectors, myradius, myheight); diff --git a/Framework/Geometry/src/Objects/ShapeFactory.cpp b/Framework/Geometry/src/Objects/ShapeFactory.cpp index 75a8b08636b225d8eb6ce61613a9472713617760..825101d50a73be299e15d451781fabc6d247b2e7 100644 --- a/Framework/Geometry/src/Objects/ShapeFactory.cpp +++ b/Framework/Geometry/src/Objects/ShapeFactory.cpp @@ -5,7 +5,8 @@ #include "MantidGeometry/Instrument/Container.h" #include "MantidGeometry/Objects/CSGObject.h" #include "MantidGeometry/Objects/ShapeFactory.h" -#include "MantidGeometry/Rendering/GluGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidGeometry/Surfaces/Cone.h" #include "MantidGeometry/Surfaces/Cylinder.h" #include "MantidGeometry/Surfaces/Plane.h" @@ -151,20 +152,17 @@ ShapeFactory::createShape(Poco::XML::Element *pElem) { numPrimitives++; } else if (primitiveName == "infinite-plane") { idMatching[idFromUser] = parseInfinitePlane(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "infinite-cylinder") { idMatching[idFromUser] = parseInfiniteCylinder(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "cylinder") { lastElement = pE; idMatching[idFromUser] = parseCylinder(pE, primitives, l_id); numPrimitives++; - } else if (primitiveName == "segmented-cylinder") { - lastElement = pE; - idMatching[idFromUser] = - parseSegmentedCylinder(pE, primitives, l_id); - numPrimitives++; } else if (primitiveName == "hollow-cylinder") { idMatching[idFromUser] = parseHollowCylinder(pE, primitives, l_id); numPrimitives++; @@ -174,6 +172,7 @@ ShapeFactory::createShape(Poco::XML::Element *pElem) { numPrimitives++; } else if (primitiveName == "infinite-cone") { idMatching[idFromUser] = parseInfiniteCone(pE, primitives, l_id); + retVal->setFiniteGeometryFlag(false); numPrimitives++; } else if (primitiveName == "cone") { lastElement = pE; @@ -1406,12 +1405,14 @@ ShapeFactory::createHexahedralShape(double xlb, double xlf, double xrf, shape->setObject(21, algebra); shape->populate(prim); - auto handler = boost::make_shared<GluGeometryHandler>(shape); - + auto handler = boost::make_shared<GeometryHandler>(shape); + detail::ShapeInfo shapeInfo; shape->setGeometryHandler(handler); - handler->setHexahedron(hex.lbb, hex.lfb, hex.rfb, hex.rbb, hex.lbt, hex.lft, - hex.rft, hex.rbt); + shapeInfo.setHexahedron(hex.lbb, hex.lfb, hex.rfb, hex.rbb, hex.lbt, hex.lft, + hex.rft, hex.rbt); + + handler->setShapeInfo(std::move(shapeInfo)); shape->defineBoundingBox(std::max(xrb, xrf), yrf, ZDEPTH, std::min(xlf, xlb), ylb, 0); @@ -1423,24 +1424,24 @@ ShapeFactory::createHexahedralShape(double xlb, double xlf, double xrf, void ShapeFactory::createGeometryHandler(Poco::XML::Element *pElem, boost::shared_ptr<CSGObject> Obj) { - auto geomHandler = boost::make_shared<GluGeometryHandler>(Obj); + auto geomHandler = boost::make_shared<GeometryHandler>(Obj); + detail::ShapeInfo shapeInfo; Obj->setGeometryHandler(geomHandler); if (pElem->tagName() == "cuboid") { auto corners = parseCuboid(pElem); - geomHandler->setCuboid(corners.lfb, corners.lft, corners.lbb, corners.rfb); + shapeInfo.setCuboid(corners.lfb, corners.lft, corners.lbb, corners.rfb); } else if (pElem->tagName() == "hexahedron") { auto corners = parseHexahedron(pElem); - geomHandler->setHexahedron(corners.lbb, corners.lfb, corners.rfb, - corners.rbb, corners.lbt, corners.lft, - corners.rft, corners.rbt); + shapeInfo.setHexahedron(corners.lbb, corners.lfb, corners.rfb, corners.rbb, + corners.lbt, corners.lft, corners.rft, corners.rbt); } else if (pElem->tagName() == "sphere") { Element *pElemCentre = getOptionalShapeElement(pElem, "centre"); Element *pElemRadius = getShapeElement(pElem, "radius"); V3D centre; if (pElemCentre) centre = parsePosition(pElemCentre); - geomHandler->setSphere(centre, std::stod(pElemRadius->getAttribute("val"))); + shapeInfo.setSphere(centre, std::stod(pElemRadius->getAttribute("val"))); } else if (pElem->tagName() == "cylinder") { Element *pElemCentre = getShapeElement(pElem, "centre-of-bottom-base"); Element *pElemAxis = getShapeElement(pElem, "axis"); @@ -1448,20 +1449,9 @@ void ShapeFactory::createGeometryHandler(Poco::XML::Element *pElem, Element *pElemHeight = getShapeElement(pElem, "height"); V3D normVec = parsePosition(pElemAxis); normVec.normalize(); - geomHandler->setCylinder(parsePosition(pElemCentre), normVec, - std::stod(pElemRadius->getAttribute("val")), - std::stod(pElemHeight->getAttribute("val"))); - } else if (pElem->tagName() == "segmented-cylinder") { - Element *pElemCentre = getShapeElement(pElem, "centre-of-bottom-base"); - Element *pElemAxis = getShapeElement(pElem, "axis"); - Element *pElemRadius = getShapeElement(pElem, "radius"); - Element *pElemHeight = getShapeElement(pElem, "height"); - V3D normVec = parsePosition(pElemAxis); - normVec.normalize(); - geomHandler->setSegmentedCylinder( - parsePosition(pElemCentre), normVec, - std::stod(pElemRadius->getAttribute("val")), - std::stod(pElemHeight->getAttribute("val"))); + shapeInfo.setCylinder(parsePosition(pElemCentre), normVec, + std::stod(pElemRadius->getAttribute("val")), + std::stod(pElemHeight->getAttribute("val"))); } else if (pElem->tagName() == "cone") { Element *pElemTipPoint = getShapeElement(pElem, "tip-point"); Element *pElemAxis = getShapeElement(pElem, "axis"); @@ -1473,8 +1463,10 @@ void ShapeFactory::createGeometryHandler(Poco::XML::Element *pElem, double height = std::stod(pElemHeight->getAttribute("val")); double radius = height * tan(M_PI * std::stod(pElemAngle->getAttribute("val")) / 180.0); - geomHandler->setCone(parsePosition(pElemTipPoint), normVec, radius, height); + shapeInfo.setCone(parsePosition(pElemTipPoint), normVec, radius, height); } + + geomHandler->setShapeInfo(std::move(shapeInfo)); } } // namespace Geometry diff --git a/Framework/Geometry/src/Rendering/BitmapGeometryHandler.cpp b/Framework/Geometry/src/Rendering/BitmapGeometryHandler.cpp deleted file mode 100644 index abf8021c0a6c17fe48166435b595d23afeb12e0e..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/BitmapGeometryHandler.cpp +++ /dev/null @@ -1,136 +0,0 @@ -#include "MantidGeometry/Rendering/BitmapGeometryHandler.h" -#include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include <climits> -#include <iostream> - -#include <boost/make_shared.hpp> - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; - -/** - * @return A shared_ptr to a new copy of this object - */ -boost::shared_ptr<GeometryHandler> BitmapGeometryHandler::clone() const { - return boost::make_shared<BitmapGeometryHandler>(*this); -} - -/// Parameter constructor -BitmapGeometryHandler::BitmapGeometryHandler(RectangularDetector *comp) - : GeometryHandler(dynamic_cast<IObjComponent *>(comp)) { - // Save the rectangular detector link for later. - m_rectDet = comp; -} - -BitmapGeometryHandler::BitmapGeometryHandler() - : GeometryHandler(static_cast<CSGObject *>(nullptr)), m_rectDet(nullptr) {} - -///< Create an instance of concrete geometry handler for ObjComponent -BitmapGeometryHandler * -BitmapGeometryHandler::createInstance(IObjComponent *comp) { - (void)comp; - return new BitmapGeometryHandler(); -} - -///< Create an instance of concrete geometry handler for Object -BitmapGeometryHandler * -BitmapGeometryHandler::createInstance(boost::shared_ptr<CSGObject> obj) { - (void)obj; - return new BitmapGeometryHandler(); -} - -///< Create an instance of concrete geometry handler for Object -GeometryHandler *BitmapGeometryHandler::createInstance(CSGObject *obj) { - (void)obj; - return new BitmapGeometryHandler(); -} - -//---------------------------------------------------------------------------------------------- -/** Triangulate the Object - this function will not be used. - * - */ -void BitmapGeometryHandler::Triangulate() { - // std::cout << "BitmapGeometryHandler::Triangulate() called\n"; -} - -//---------------------------------------------------------------------------------------------- -///< Render Object or ObjComponent -void BitmapGeometryHandler::Render() { - // std::cout << "BitmapGeometryHandler::Render() called\n"; - V3D pos; - - // Wait for no error - while (glGetError() != GL_NO_ERROR) - ; - - // Because texture colours are combined with the geometry colour - // make sure the current colour is white - glColor3f(1.0f, 1.0f, 1.0f); - - // Nearest-neighbor scaling - GLint texParam = GL_NEAREST; - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParam); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParam); - - glEnable(GL_TEXTURE_2D); // enable texture mapping - - int texx, texy; - m_rectDet->getTextureSize(texx, texy); - double tex_frac_x = (1.0 * m_rectDet->xpixels()) / (texx); - double tex_frac_y = (1.0 * m_rectDet->ypixels()) / (texy); - - // Point to the ID of the texture that was created before - in - // RectangularDetectorActor. - // int texture_id = m_rectDet->getTextureID(); - // glBindTexture (GL_TEXTURE_2D, texture_id); - // if (glGetError()>0) std::cout << "OpenGL error in glBindTexture \n"; - - glBegin(GL_QUADS); - - glTexCoord2f(0.0, 0.0); - pos = m_rectDet->getRelativePosAtXY(0, 0); - pos += V3D(m_rectDet->xstep() * (-0.5), m_rectDet->ystep() * (-0.5), - 0.0); // Adjust to account for the size of a pixel - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - - glTexCoord2f(static_cast<GLfloat>(tex_frac_x), 0.0); - pos = m_rectDet->getRelativePosAtXY(m_rectDet->xpixels() - 1, 0); - pos += V3D(m_rectDet->xstep() * (+0.5), m_rectDet->ystep() * (-0.5), - 0.0); // Adjust to account for the size of a pixel - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - - glTexCoord2f(static_cast<GLfloat>(tex_frac_x), - static_cast<GLfloat>(tex_frac_y)); - pos = m_rectDet->getRelativePosAtXY(m_rectDet->xpixels() - 1, - m_rectDet->ypixels() - 1); - pos += V3D(m_rectDet->xstep() * (+0.5), m_rectDet->ystep() * (+0.5), - 0.0); // Adjust to account for the size of a pixel - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - - glTexCoord2f(0.0, static_cast<GLfloat>(tex_frac_y)); - pos = m_rectDet->getRelativePosAtXY(0, m_rectDet->ypixels() - 1); - pos += V3D(m_rectDet->xstep() * (-0.5), m_rectDet->ystep() * (+0.5), - 0.0); // Adjust to account for the size of a pixel - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - - glEnd(); - if (glGetError() > 0) - std::cout << "OpenGL error in BitmapGeometryHandler::Render \n"; - - glDisable( - GL_TEXTURE_2D); // stop texture mapping - not sure if this is necessary. -} - -//---------------------------------------------------------------------------------------------- -///< Prepare/Initialize Object/ObjComponent to be rendered -void BitmapGeometryHandler::Initialize() { - // std::cout << "BitmapGeometryHandler::Initialize() called\n"; -} -} -} diff --git a/Framework/Geometry/src/Rendering/CacheGeometryGenerator.cpp b/Framework/Geometry/src/Rendering/CacheGeometryGenerator.cpp deleted file mode 100644 index efb52d5bb35b62ed15b7d61849f8eaa93b63ef83..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/CacheGeometryGenerator.cpp +++ /dev/null @@ -1,104 +0,0 @@ -#include <vector> -#include <cmath> -#include "MantidKernel/Matrix.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Objects/MeshObject.h" -#include "MantidGeometry/Rendering/CacheGeometryGenerator.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" - -#ifdef ENABLE_OPENCASCADE -#include "MantidGeometry/Rendering/OCGeometryHandler.h" -#endif - -namespace Mantid { - -namespace Geometry { -/** - * Constructor - * @param obj :: input CSG object - */ -CacheGeometryGenerator::CacheGeometryGenerator(CSGObject *obj) : csgObj(obj) { - mNoOfVertices = 0; - mNoOfTriangles = 0; - mFaces = nullptr; - mPoints = nullptr; - meshObj = nullptr; -} - -/** -* Constructor -* @param obj :: input CSG object -*/ -CacheGeometryGenerator::CacheGeometryGenerator(MeshObject *obj) : meshObj(obj) { - mNoOfVertices = 0; - mNoOfTriangles = 0; - mFaces = nullptr; - mPoints = nullptr; - csgObj = nullptr; -} - -/** - * Generate geometry, if there is no cache then it uses OpenCascade to generate - * surface triangles. - */ -void CacheGeometryGenerator::Generate() { - if (mNoOfVertices <= 0) { - if (csgObj != nullptr) { -// There are no triangles defined to use OpenCascade handler to get them -#ifdef ENABLE_OPENCASCADE - OCGeometryHandler h(csgObj); - mNoOfVertices = h.NumberOfPoints(); - mNoOfTriangles = h.NumberOfTriangles(); - mPoints = h.getTriangleVertices(); - mFaces = h.getTriangleFaces(); -#endif - } else if (meshObj != nullptr) { - // Get triangles from MeshObject - mNoOfVertices = meshObj->numberOfVertices(); - mNoOfTriangles = meshObj->numberOfTriangles(); - mPoints = meshObj->getVertices(); - mFaces = meshObj->getTriangles(); - } - } -} - -/** - * Destroy the surface generated for the object - */ -CacheGeometryGenerator::~CacheGeometryGenerator() { - if (mFaces != nullptr) - delete[] mFaces; - if (mPoints != nullptr) - delete[] mPoints; -} - -int CacheGeometryGenerator::getNumberOfTriangles() { return mNoOfTriangles; } - -int CacheGeometryGenerator::getNumberOfPoints() { return mNoOfVertices; } - -double *CacheGeometryGenerator::getTriangleVertices() { return mPoints; } - -int *CacheGeometryGenerator::getTriangleFaces() { return mFaces; } - -/** - Sets the geometry cache using the triangulation information provided - @param noPts :: the number of points - @param noFaces :: the number of faces - @param pts :: a double array of the points - @param faces :: an int array of the faces -*/ -void CacheGeometryGenerator::setGeometryCache(int noPts, int noFaces, - double *pts, int *faces) { - if (mPoints != nullptr) - delete[] mPoints; - if (mFaces != nullptr) - delete[] mFaces; - mNoOfVertices = noPts; - mNoOfTriangles = noFaces; - mPoints = pts; - mFaces = faces; -} - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid diff --git a/Framework/Geometry/src/Rendering/CacheGeometryHandler.cpp b/Framework/Geometry/src/Rendering/CacheGeometryHandler.cpp deleted file mode 100644 index 88743826dd878985af79428f3df72132b18e97c7..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/CacheGeometryHandler.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Objects/MeshObject.h" -#include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Rendering/CacheGeometryHandler.h" -#include "MantidGeometry/Rendering/CacheGeometryRenderer.h" -#include "MantidGeometry/Rendering/CacheGeometryGenerator.h" -#include "MantidKernel/MultiThreaded.h" - -#include <boost/make_shared.hpp> - -namespace Mantid { -namespace Geometry { - -CacheGeometryHandler::CacheGeometryHandler(IObjComponent *comp) - : GeometryHandler(comp) { - Triangulator = nullptr; - Renderer = new CacheGeometryRenderer(); -} - -CacheGeometryHandler::CacheGeometryHandler(boost::shared_ptr<CSGObject> obj) - : GeometryHandler(obj) { - Triangulator = new CacheGeometryGenerator(obj.get()); - Renderer = new CacheGeometryRenderer(); -} - -CacheGeometryHandler::CacheGeometryHandler(CSGObject *obj) - : GeometryHandler(obj) { - Triangulator = new CacheGeometryGenerator(obj); - Renderer = new CacheGeometryRenderer(); -} - -CacheGeometryHandler::CacheGeometryHandler(boost::shared_ptr<MeshObject> obj) - : GeometryHandler(obj) { - Triangulator = new CacheGeometryGenerator(obj.get()); - Renderer = new CacheGeometryRenderer(); -} - -CacheGeometryHandler::CacheGeometryHandler(MeshObject *obj) - : GeometryHandler(obj) { - Triangulator = new CacheGeometryGenerator(obj); - Renderer = new CacheGeometryRenderer(); -} - -boost::shared_ptr<GeometryHandler> CacheGeometryHandler::clone() const { - auto clone = boost::make_shared<CacheGeometryHandler>(*this); - clone->Renderer = new CacheGeometryRenderer(*(this->Renderer)); - if (this->Triangulator) - if (meshObj != nullptr) { - clone->Triangulator = new CacheGeometryGenerator(this->meshObj); - } else { - clone->Triangulator = new CacheGeometryGenerator(this->csgObj); - } - else - clone->Triangulator = nullptr; - return clone; -} - -CacheGeometryHandler::~CacheGeometryHandler() { - if (Triangulator != nullptr) - delete Triangulator; - if (Renderer != nullptr) - delete Renderer; -} - -GeometryHandler *CacheGeometryHandler::createInstance(IObjComponent *comp) { - return new CacheGeometryHandler(comp); -} - -GeometryHandler * -CacheGeometryHandler::createInstance(boost::shared_ptr<CSGObject> obj) { - return new CacheGeometryHandler(obj); -} - -GeometryHandler *CacheGeometryHandler::createInstance(CSGObject *obj) { - return new CacheGeometryHandler(obj); -} - -void CacheGeometryHandler::Triangulate() { - // Check whether Object is triangulated otherwise triangulate - PARALLEL_CRITICAL(Triangulate) - if ((csgObj != nullptr || meshObj != nullptr) && !boolTriangulated) { - Triangulator->Generate(); - boolTriangulated = true; - } -} - -void CacheGeometryHandler::Render() { - if (csgObj != nullptr || meshObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - Renderer->Render( - Triangulator->getNumberOfPoints(), Triangulator->getNumberOfTriangles(), - Triangulator->getTriangleVertices(), Triangulator->getTriangleFaces()); - } else if (ObjComp != nullptr) { - Renderer->Render(ObjComp); - } -} - -void CacheGeometryHandler::Initialize() { - if (csgObj != nullptr || meshObj != nullptr) { - updateGeometryHandler(); - if (!boolTriangulated) - Triangulate(); - Renderer->Initialize( - Triangulator->getNumberOfPoints(), Triangulator->getNumberOfTriangles(), - Triangulator->getTriangleVertices(), Triangulator->getTriangleFaces()); - } else if (ObjComp != nullptr) { - Renderer->Initialize(ObjComp); - } -} - -int CacheGeometryHandler::NumberOfTriangles() { - if (csgObj != nullptr || meshObj != nullptr) { - updateGeometryHandler(); - if (!boolTriangulated) - Triangulate(); - return Triangulator->getNumberOfTriangles(); - } else { - return 0; - } -} - -int CacheGeometryHandler::NumberOfPoints() { - if (csgObj != nullptr || meshObj != nullptr) { - updateGeometryHandler(); - if (!boolTriangulated) - Triangulate(); - return Triangulator->getNumberOfPoints(); - } else { - return 0; - } -} - -double *CacheGeometryHandler::getTriangleVertices() { - if (csgObj != nullptr || meshObj != nullptr) { - updateGeometryHandler(); - if (!boolTriangulated) - Triangulate(); - return Triangulator->getTriangleVertices(); - } else { - return nullptr; - } -} - -int *CacheGeometryHandler::getTriangleFaces() { - if (csgObj != nullptr || meshObj != nullptr) { - updateGeometryHandler(); - if (!boolTriangulated) - Triangulate(); - return Triangulator->getTriangleFaces(); - } else { - return nullptr; - } -} - -void CacheGeometryHandler::updateGeometryHandler() { - if (meshObj != nullptr) { - meshObj->updateGeometryHandler(); - } else { - csgObj->updateGeometryHandler(); - } -} - -/** -Sets the geometry cache using the triangulation information provided -@param noPts :: the number of points -@param noFaces :: the number of faces -@param pts :: a double array of the points -@param faces :: an int array of the faces -*/ -void CacheGeometryHandler::setGeometryCache(int noPts, int noFaces, double *pts, - int *faces) { - Triangulator->setGeometryCache(noPts, noFaces, pts, faces); - boolTriangulated = true; -} -} -} diff --git a/Framework/Geometry/src/Rendering/CacheGeometryRenderer.cpp b/Framework/Geometry/src/Rendering/CacheGeometryRenderer.cpp deleted file mode 100644 index a34f7e042fb5242dbdcff5b1172e58de57fdbd79..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/CacheGeometryRenderer.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "MantidGeometry/Rendering/CacheGeometryRenderer.h" -#include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidKernel/Quat.h" -#include <climits> - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; -using Kernel::Quat; - -/** - * Render ObjComponent - * @param ObjComp :: input to render - */ -void CacheGeometryRenderer::Render(IObjComponent *ObjComp) const { - glPushMatrix(); - V3D pos = ObjComp->getPos(); - Quat rot = ObjComp->getRotation(); - double rotGL[16]; - rot.GLMatrix(&rotGL[0]); - glTranslated(pos[0], pos[1], pos[2]); - glMultMatrixd(rotGL); - V3D scaleFactor = ObjComp->getScaleFactor(); - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - ObjComp->drawObject(); - glPopMatrix(); -} - -void CacheGeometryRenderer::Render(int noPts, int noFaces, double *points, - int *faces) const { - (void)noPts; - (void)noFaces; - (void)points; - (void)faces; // Avoid compiler warning - Initialize(noPts, noFaces, points, faces); -} - -void CacheGeometryRenderer::Initialize(int noPts, int noFaces, double *points, - int *faces) const { - (void)noPts; // Avoid compiler warning - glBegin(GL_TRIANGLES); - V3D normal; - for (int i = 0; i < noFaces; i++) { - int index1 = faces[i * 3] * 3; - int index2 = faces[i * 3 + 1] * 3; - int index3 = faces[i * 3 + 2] * 3; - // Calculate normal and normalize - V3D v1(points[index1], points[index1 + 1], points[index1 + 2]); - V3D v2(points[index2], points[index2 + 1], points[index2 + 2]); - V3D v3(points[index3], points[index3 + 1], points[index3 + 2]); - normal = (v1 - v2).cross_prod(v2 - v3); - normal.normalize(); - glNormal3d(normal[0], normal[1], normal[2]); - glVertex3dv(points + index1); - glVertex3dv(points + index2); - glVertex3dv(points + index3); - } - glEnd(); -} - -void CacheGeometryRenderer::Initialize(IObjComponent *ObjComp) { - glPushMatrix(); - V3D pos = ObjComp->getPos(); - Quat rot = ObjComp->getRotation(); - double rotGL[16]; - rot.GLMatrix(&rotGL[0]); - glTranslated(pos[0], pos[1], pos[2]); - glMultMatrixd(rotGL); - V3D scaleFactor = ObjComp->getScaleFactor(); - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - ObjComp->drawObject(); - glPopMatrix(); -} -} -} diff --git a/Framework/Geometry/src/Rendering/GeometryHandler.cpp b/Framework/Geometry/src/Rendering/GeometryHandler.cpp index fb32675b9e53b54d1ccc49453a83d9e14b1a4946..51a3f459eae4b7f0c1c66c4d9a46bbe68609c2db 100644 --- a/Framework/Geometry/src/Rendering/GeometryHandler.cpp +++ b/Framework/Geometry/src/Rendering/GeometryHandler.cpp @@ -1,68 +1,109 @@ #include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Instrument/RectangularDetector.h" +#include "MantidGeometry/Objects/CSGObject.h" +#include "MantidGeometry/Objects/MeshObject.h" +#include "MantidGeometry/Rendering/GeometryTriangulator.h" +#include "MantidGeometry/Rendering/RenderingHelpers.h" +#include <boost/make_shared.hpp> namespace Mantid { namespace Geometry { +GeometryHandler::GeometryHandler(IObjComponent *comp) : m_objComp(comp) {} -/** Constructor - * @param[in] comp - * This geometry handler will be ObjComponent's geometry handler - */ -GeometryHandler::GeometryHandler(IObjComponent *comp) : csgObj() { - ObjComp = comp; - meshObj = nullptr; - boolTriangulated = true; - boolIsInitialized = false; +GeometryHandler::GeometryHandler(boost::shared_ptr<CSGObject> obj) + : m_triangulator(new detail::GeometryTriangulator(obj.get())), + m_csgObj(obj.get()) {} + +GeometryHandler::GeometryHandler(CSGObject *obj) + : m_triangulator(new detail::GeometryTriangulator(obj)), m_csgObj(obj) {} + +GeometryHandler::GeometryHandler(boost::shared_ptr<MeshObject> obj) + : m_triangulator(new detail::GeometryTriangulator(obj.get())), + m_meshObj(obj.get()) {} + +GeometryHandler::GeometryHandler(MeshObject *obj) + : m_triangulator(new detail::GeometryTriangulator(obj)), m_meshObj(obj) {} + +GeometryHandler::GeometryHandler(const GeometryHandler &handler) { + if (handler.m_csgObj) { + m_csgObj = handler.m_csgObj; + if (handler.m_triangulator) + m_triangulator.reset(new detail::GeometryTriangulator(m_csgObj)); + } + if (handler.m_objComp) + m_objComp = handler.m_objComp; + if (handler.m_shapeInfo) + m_shapeInfo = handler.m_shapeInfo; } -/** Constructor - * @param[in] obj - * This geometry handler will be Object's geometry handler - */ -GeometryHandler::GeometryHandler(boost::shared_ptr<CSGObject> obj) - : csgObj(obj.get()) { - ObjComp = nullptr; - meshObj = nullptr; - boolTriangulated = false; - boolIsInitialized = false; +/// Destructor +GeometryHandler::~GeometryHandler() {} + +boost::shared_ptr<GeometryHandler> GeometryHandler::clone() const { + return boost::make_shared<GeometryHandler>(*this); } -/** Constructor - * @param[in] obj - * This geometry handler will be Object's geometry handler - */ -GeometryHandler::GeometryHandler(CSGObject *obj) : csgObj(obj) { - ObjComp = nullptr; - meshObj = nullptr; - boolTriangulated = false; - boolIsInitialized = false; +void GeometryHandler::render() const { + if (m_shapeInfo) + RenderingHelpers::renderShape(*m_shapeInfo); + else if (m_objComp != nullptr) + RenderingHelpers::renderIObjComponent(*m_objComp); + else if (canTriangulate()) + RenderingHelpers::renderTriangulated(*m_triangulator); } -/** Constructor -* @param[in] obj -* This geometry handler will be Object's geometry handler -*/ -GeometryHandler::GeometryHandler(boost::shared_ptr<MeshObject> obj) : csgObj() { - ObjComp = nullptr; - meshObj = obj.get(); - boolTriangulated = false; - boolIsInitialized = false; +void GeometryHandler::initialize() const { + if (m_csgObj != nullptr) + m_csgObj->updateGeometryHandler(); + render(); } -/** Constructor -* @param[in] obj -* This geometry handler will be Object's geometry handler -*/ -GeometryHandler::GeometryHandler(MeshObject *obj) : csgObj() { - ObjComp = nullptr; - meshObj = obj; - boolTriangulated = false; - boolIsInitialized = false; +size_t GeometryHandler::numberOfTriangles() const { + if (canTriangulate()) + return m_triangulator->numTriangleFaces(); + return 0; } -/// Destructor -GeometryHandler::~GeometryHandler() { - ObjComp = nullptr; - meshObj = nullptr; +size_t GeometryHandler::numberOfPoints() const { + if (canTriangulate()) + return m_triangulator->numTriangleVertices(); + return 0; } + +const std::vector<double> &GeometryHandler::getTriangleVertices() const { + static std::vector<double> empty; + if (canTriangulate()) + return m_triangulator->getTriangleVertices(); + return empty; +} + +const std::vector<uint32_t> &GeometryHandler::getTriangleFaces() const { + static std::vector<uint32_t> empty; + if (canTriangulate()) + return m_triangulator->getTriangleFaces(); + return empty; +} + +void GeometryHandler::setGeometryCache(size_t nPts, size_t nFaces, + std::vector<double> &&pts, + std::vector<uint32_t> &&faces) { + if (canTriangulate()) { + m_triangulator->setGeometryCache(nPts, nFaces, std::move(pts), + std::move(faces)); + } +} + +void GeometryHandler::GetObjectGeom(detail::ShapeInfo::GeometryShape &mytype, + std::vector<Kernel::V3D> &vectors, + double &myradius, double &myheight) const { + mytype = detail::ShapeInfo::GeometryShape::NOSHAPE; + if (m_shapeInfo) + m_shapeInfo->getObjectGeometry(mytype, vectors, myradius, myheight); } + +void GeometryHandler::setShapeInfo(detail::ShapeInfo &&shapeInfo) { + m_triangulator.reset(nullptr); + m_shapeInfo.reset(new detail::ShapeInfo(std::move(shapeInfo))); } +} // namespace Geometry +} // namespace Mantid diff --git a/Framework/Geometry/src/Rendering/GeometryTriangulator.cpp b/Framework/Geometry/src/Rendering/GeometryTriangulator.cpp new file mode 100644 index 0000000000000000000000000000000000000000..ec15829f2b8bf75a7cd2667fa788822722b991cc --- /dev/null +++ b/Framework/Geometry/src/Rendering/GeometryTriangulator.cpp @@ -0,0 +1,250 @@ +#include "MantidGeometry/Rendering/GeometryTriangulator.h" +#include "MantidGeometry/Objects/CSGObject.h" +#include "MantidGeometry/Objects/MeshObject.h" +#include "MantidGeometry/Objects/Rules.h" +#include "MantidKernel/Logger.h" +#include "MantidKernel/WarningSuppressions.h" +#include <climits> + +#ifdef ENABLE_OPENCASCADE +// Squash a warning coming out of an OpenCascade header +#ifdef __INTEL_COMPILER +#pragma warning disable 191 +#endif +// Opencascade defines _USE_MATH_DEFINES without checking whether it is already +// used. +// Undefine it here before we include the headers to avoid a warning. Older +// versions +// also define M_SQRT1_2 so do the same if it is already defined +#ifdef _MSC_VER +#undef _USE_MATH_DEFINES +#ifdef M_SQRT1_2 +#undef M_SQRT1_2 +#endif +#endif + +GCC_DIAG_OFF(conversion) +// clang-format off +GCC_DIAG_OFF(cast-qual) +// clang-format on +#include <gp_Trsf.hxx> +#include <gp_Pnt.hxx> +#include <gp_Pln.hxx> +#include <StdFail_NotDone.hxx> +#include <TopoDS.hxx> +#include <TopoDS_Shape.hxx> +#include <TopoDS_Face.hxx> +#include <TopExp_Explorer.hxx> +#include <BRepMesh_IncrementalMesh.hxx> +#include <BRepBuilderAPI_Transform.hxx> +#include <BRep_Tool.hxx> +#include <Poly_Triangulation.hxx> +GCC_DIAG_ON(conversion) +// clang-format off +GCC_DIAG_ON(cast-qual) +// clang-format on + +#ifdef __INTEL_COMPILER +#pragma warning enable 191 +#endif + +#endif // ENABLE_OPENCASCADE + +namespace Mantid { +namespace Geometry { +namespace detail { +namespace { +/// static logger +Kernel::Logger g_log("GeometryTriangulator"); +} // namespace + +GeometryTriangulator::GeometryTriangulator(const CSGObject *obj) + : m_isTriangulated(false), m_nFaces(0), m_nPoints(0), m_csgObj(obj) { +#ifdef ENABLE_OPENCASCADE + m_objSurface = nullptr; +#endif +} + +GeometryTriangulator::GeometryTriangulator(const MeshObject *obj) + : m_isTriangulated(false), m_meshObj(obj) {} + +GeometryTriangulator::~GeometryTriangulator() {} + +void GeometryTriangulator::triangulate() { +#ifdef ENABLE_OPENCASCADE + if (m_objSurface == nullptr) + OCAnalyzeObject(); +#endif + if (m_meshObj) { + generateMesh(); + m_nPoints = m_meshObj->numberOfVertices(); + m_nFaces = m_meshObj->numberOfTriangles(); + m_points = m_meshObj->getVertices(); + m_faces = m_meshObj->getTriangles(); + } + m_isTriangulated = true; +} + +void GeometryTriangulator::generateMesh() { + /* Placeholder function to replace MeshGeometryGenerator::Generate()*/ +} + +#ifdef ENABLE_OPENCASCADE +bool GeometryTriangulator::hasOCSurface() const { + return m_objSurface != nullptr; +} +/// Return OpenCascade surface. +const TopoDS_Shape &GeometryTriangulator::getOCSurface() { + checkTriangulated(); + return *m_objSurface; +} +#endif + +void GeometryTriangulator::checkTriangulated() { + if (m_csgObj != nullptr || m_meshObj != nullptr) { + if (!m_isTriangulated) { + triangulate(); + } + } +} +size_t GeometryTriangulator::numTriangleFaces() { + checkTriangulated(); + return m_nFaces; +} + +size_t GeometryTriangulator::numTriangleVertices() { + checkTriangulated(); + return m_nPoints; +} + +/// get a pointer to the 3x(NumberOfPoints) coordinates (x1,y1,z1,x2..) of +/// mesh +const std::vector<double> &GeometryTriangulator::getTriangleVertices() { + checkTriangulated(); + return m_points; +} +/// get a pointer to the 3x(NumberOFaces) integers describing points forming +/// faces (p1,p2,p3)(p4,p5,p6). +const std::vector<uint32_t> &GeometryTriangulator::getTriangleFaces() { + checkTriangulated(); + return m_faces; +} + +#ifdef ENABLE_OPENCASCADE +void GeometryTriangulator::OCAnalyzeObject() { + if (m_csgObj != nullptr) // If object exists + { + // Get the top rule tree in Obj + const Rule *top = m_csgObj->topRule(); + if (top == nullptr) { + m_objSurface.reset(new TopoDS_Shape()); + return; + } else { + // Traverse through Rule + TopoDS_Shape Result = const_cast<Rule *>(top)->analyze(); + try { + m_objSurface.reset(new TopoDS_Shape(Result)); + BRepMesh_IncrementalMesh(Result, 0.001); + } catch (StdFail_NotDone &) { + g_log.error("Cannot build the geometry. Check the geometry definition"); + } + } + } + + setupPoints(); + setupFaces(); +} + +size_t GeometryTriangulator::numPoints() const { + size_t countVert = 0; + if (m_objSurface != nullptr) { + TopExp_Explorer Ex; + for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { + TopoDS_Face F = TopoDS::Face(Ex.Current()); + TopLoc_Location L; + Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); + countVert += static_cast<size_t>(facing->NbNodes()); + } + } + return countVert; +} + +size_t GeometryTriangulator::numFaces() const { + size_t countFace = 0; + if (m_objSurface != nullptr) { + TopExp_Explorer Ex; + for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { + TopoDS_Face F = TopoDS::Face(Ex.Current()); + TopLoc_Location L; + Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); + countFace += static_cast<size_t>(facing->NbTriangles()); + } + } + return countFace; +} + +void GeometryTriangulator::setupPoints() { + m_nPoints = numPoints(); + if (m_nPoints > 0) { + size_t index = 0; + m_points.resize(m_nPoints * 3); + TopExp_Explorer Ex; + for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { + TopoDS_Face F = TopoDS::Face(Ex.Current()); + TopLoc_Location L; + Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); + TColgp_Array1OfPnt tab(1, (facing->NbNodes())); + tab = facing->Nodes(); + for (Standard_Integer i = 1; i <= (facing->NbNodes()); i++) { + gp_Pnt pnt = tab.Value(i); + m_points[index * 3 + 0] = pnt.X(); + m_points[index * 3 + 1] = pnt.Y(); + m_points[index * 3 + 2] = pnt.Z(); + index++; + } + } + } +} + +void GeometryTriangulator::setupFaces() { + m_nFaces = numFaces(); + if (m_nFaces > 0) { + m_faces.resize(m_nFaces * 3); + TopExp_Explorer Ex; + int maxindex = 0; + size_t index = 0; + for (Ex.Init(*m_objSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { + TopoDS_Face F = TopoDS::Face(Ex.Current()); + TopLoc_Location L; + Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); + TColgp_Array1OfPnt tab(1, (facing->NbNodes())); + tab = facing->Nodes(); + Poly_Array1OfTriangle tri(1, facing->NbTriangles()); + tri = facing->Triangles(); + for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) { + Poly_Triangle trian = tri.Value(i); + Standard_Integer index1, index2, index3; + trian.Get(index1, index2, index3); + m_faces[index * 3 + 0] = static_cast<uint32_t>(maxindex + index1 - 1); + m_faces[index * 3 + 1] = static_cast<uint32_t>(maxindex + index2 - 1); + m_faces[index * 3 + 2] = static_cast<uint32_t>(maxindex + index3 - 1); + index++; + } + maxindex += facing->NbNodes(); + } + } +} +#endif + +void GeometryTriangulator::setGeometryCache(size_t nPoints, size_t nFaces, + std::vector<double> &&points, + std::vector<uint32_t> &&faces) { + m_nPoints = nPoints; + m_nFaces = nFaces; + m_points = std::move(points); + m_faces = std::move(faces); + m_isTriangulated = true; +} +} // namespace detail +} // namespace Geometry +} // namespace Mantid diff --git a/Framework/Geometry/src/Rendering/GluGeometryHandler.cpp b/Framework/Geometry/src/Rendering/GluGeometryHandler.cpp deleted file mode 100644 index 15ad30496a93c7d7fb3b4f572a40b5aa115941ea..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/GluGeometryHandler.cpp +++ /dev/null @@ -1,163 +0,0 @@ -#include "MantidGeometry/Rendering/GluGeometryHandler.h" -#include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Rendering/GluGeometryRenderer.h" -#include "MantidKernel/make_unique.h" - -#include <boost/make_shared.hpp> - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; - -GluGeometryHandler::GluGeometryHandler(IObjComponent *comp) - : GeometryHandler(comp), - Renderer(Kernel::make_unique<GluGeometryRenderer>()), radius(0.0), - height(0.0), type(GeometryType::NOSHAPE) {} - -GluGeometryHandler::GluGeometryHandler(boost::shared_ptr<CSGObject> obj) - : GeometryHandler(std::move(obj)), - Renderer(Kernel::make_unique<GluGeometryRenderer>()), radius(0.0), - height(0.0), type(GeometryType::NOSHAPE) {} - -GluGeometryHandler::GluGeometryHandler(CSGObject *obj) - : GeometryHandler(obj), - Renderer(Kernel::make_unique<GluGeometryRenderer>()), radius(0.0), - height(0.0), type(GeometryType::NOSHAPE) {} - -GluGeometryHandler::GluGeometryHandler(const GluGeometryHandler &other) - : GeometryHandler(other), m_points(other.m_points), radius(other.radius), - height(other.height), type(other.type) { - this->Renderer = Kernel::make_unique<GluGeometryRenderer>(); -} - -boost::shared_ptr<GeometryHandler> GluGeometryHandler::clone() const { - return boost::make_shared<GluGeometryHandler>(*this); -} - -GluGeometryHandler::~GluGeometryHandler() = default; - -GeometryHandler *GluGeometryHandler::createInstance(IObjComponent *comp) { - return new GluGeometryHandler(comp); -} - -GeometryHandler * -GluGeometryHandler::createInstance(boost::shared_ptr<CSGObject> obj) { - return new GluGeometryHandler(obj); -} - -GeometryHandler *GluGeometryHandler::createInstance(CSGObject *obj) { - return new GluGeometryHandler(obj); -} - -void GluGeometryHandler::Triangulate() { - // Check whether Object is triangulated otherwise triangulate - // Doesn't have to do anything because we are not going to triangulate - // anything -} - -void GluGeometryHandler::Render() { - if (csgObj != nullptr) { - switch (type) { - case GeometryType::CUBOID: - Renderer->RenderCube(m_points[0], m_points[1], m_points[2], m_points[3]); - break; - case GeometryType::HEXAHEDRON: - Renderer->RenderHexahedron(m_points[0], m_points[1], m_points[2], - m_points[3], m_points[4], m_points[5], - m_points[6], m_points[7]); - break; - case GeometryType::SPHERE: - Renderer->RenderSphere(m_points[0], radius); - break; - case GeometryType::CYLINDER: - Renderer->RenderCylinder(m_points[0], m_points[1], radius, height); - break; - case GeometryType::CONE: - Renderer->RenderCone(m_points[0], m_points[1], radius, height); - break; - case GeometryType::SEGMENTED_CYLINDER: - Renderer->RenderSegmentedCylinder(m_points[0], m_points[1], radius, - height); - break; - case GeometryType::NOSHAPE: - break; - } - } else if (ObjComp != nullptr) { - Renderer->Render(ObjComp); - } -} - -void GluGeometryHandler::GetObjectGeom(int &mytype, - std::vector<Kernel::V3D> &vectors, - double &myradius, double &myheight) { - mytype = 0; - if (csgObj != nullptr) { - mytype = static_cast<int>(type); - vectors = m_points; - switch (type) { - case GeometryType::CUBOID: - break; - case GeometryType::HEXAHEDRON: - break; - case GeometryType::SPHERE: - myradius = radius; - break; - default: - myradius = radius; - myheight = height; - break; - } - } -} - -void GluGeometryHandler::Initialize() { - if (csgObj != nullptr) { - // There is no initialization or probably call render - Render(); - } -} - -void GluGeometryHandler::setCuboid(const V3D &p1, const V3D &p2, const V3D &p3, - const V3D &p4) { - type = GeometryType::CUBOID; - m_points.assign({p1, p2, p3, p4}); -} - -void GluGeometryHandler::setHexahedron(const V3D &p1, const V3D &p2, - const V3D &p3, const V3D &p4, - const V3D &p5, const V3D &p6, - const V3D &p7, const V3D &p8) { - type = GeometryType::HEXAHEDRON; - m_points.assign({p1, p2, p3, p4, p5, p6, p7, p8}); -} - -void GluGeometryHandler::setSphere(const V3D &c, double r) { - type = GeometryType::SPHERE; - m_points.assign({c}); - radius = r; -} -void GluGeometryHandler::setCylinder(const V3D &c, const V3D &a, double r, - double h) { - type = GeometryType::CYLINDER; - m_points.assign({c, a}); - radius = r; - height = h; -} -void GluGeometryHandler::setCone(const V3D &c, const V3D &a, double r, - double h) { - type = GeometryType::CONE; - m_points.assign({c, a}); - radius = r; - height = h; -} -void GluGeometryHandler::setSegmentedCylinder(const V3D &c, const V3D &a, - double r, double h) { - type = GeometryType::SEGMENTED_CYLINDER; - m_points.assign({c, a}); - radius = r; - height = h; -} -} -} diff --git a/Framework/Geometry/src/Rendering/GluGeometryRenderer.cpp b/Framework/Geometry/src/Rendering/GluGeometryRenderer.cpp deleted file mode 100644 index fca52b37921125bb7b8efb42f7a80a6d10a5720e..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/GluGeometryRenderer.cpp +++ /dev/null @@ -1,298 +0,0 @@ -#include "MantidGeometry/Rendering/GluGeometryRenderer.h" -#include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include "MantidGeometry/Instrument/ObjComponent.h" -#include "MantidKernel/Quat.h" -#include "MantidGeometry/Surfaces/Cylinder.h" -#include "MantidGeometry/Surfaces/Cone.h" -#include "MantidGeometry/Surfaces/Sphere.h" -#include <climits> - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; -using Kernel::Quat; - -void GluGeometryRenderer::RenderSphere(const V3D ¢er, double radius) { - while (glGetError() != GL_NO_ERROR) - ; - CreateSphere(center, radius); -} - -void GluGeometryRenderer::RenderCube(const V3D &Point1, const V3D &Point2, - const V3D &Point3, const V3D &Point4) { - while (glGetError() != GL_NO_ERROR) - ; - CreateCube(Point1, Point2, Point3, Point4); -} - -void GluGeometryRenderer::RenderHexahedron( - const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4, - const Kernel::V3D &Point5, const Kernel::V3D &Point6, - const Kernel::V3D &Point7, const Kernel::V3D &Point8) { - - while (glGetError() != GL_NO_ERROR) - ; - CreateHexahedron(Point1, Point2, Point3, Point4, Point5, Point6, Point7, - Point8); -} - -void GluGeometryRenderer::RenderCone(const V3D ¢er, const V3D &axis, - double radius, double height) { - while (glGetError() != GL_NO_ERROR) - ; - CreateCone(center, axis, radius, height); -} - -void GluGeometryRenderer::RenderCylinder(const V3D ¢er, const V3D &axis, - double radius, double height) { - while (glGetError() != GL_NO_ERROR) - ; - CreateCylinder(center, axis, radius, height); -} - -void GluGeometryRenderer::RenderSegmentedCylinder(const V3D ¢er, - const V3D &axis, - double radius, - double height) { - while (glGetError() != GL_NO_ERROR) - ; - CreateSegmentedCylinder(center, axis, radius, height); -} - -/** - * Render ObjComponent - * @param ObjComp :: input to render - */ -void GluGeometryRenderer::Render(IObjComponent *ObjComp) const { - glPushMatrix(); - V3D pos = ObjComp->getPos(); - Quat rot = ObjComp->getRotation(); - double rotGL[16]; - rot.GLMatrix(&rotGL[0]); - glTranslated(pos[0], pos[1], pos[2]); - glMultMatrixd(rotGL); - ObjComp->drawObject(); - glPopMatrix(); -} - -/** - * Creates a GLU Sphere - * @param center :: center of the sphere - * @param radius :: radius of the sphere - */ -void GluGeometryRenderer::CreateSphere(const V3D ¢er, double radius) { - // create glu sphere - GLUquadricObj *qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_FILL); - gluQuadricNormals(qobj, GL_SMOOTH); - glPushMatrix(); - glTranslated(center[0], center[1], center[2]); - gluSphere(qobj, radius, Geometry::Sphere::g_nslices, - Geometry::Sphere::g_nstacks); - glPopMatrix(); - gluDeleteQuadric(qobj); -} - -/** - * Creates a Cube - * @param Point1 :: first point of the cube - * @param Point2 :: second point of the cube - * @param Point3 :: thrid point of the cube - * @param Point4 :: fourth point of the cube - */ -void GluGeometryRenderer::CreateCube(const V3D &Point1, const V3D &Point2, - const V3D &Point3, const V3D &Point4) { - V3D vec0 = Point1; - V3D vec1 = Point2 - Point1; - V3D vec2 = Point3 - Point1; - V3D vec3 = Point4 - Point1; - V3D vertex[8]; - vertex[0] = vec0; - vertex[1] = vec0 + vec3; - vertex[2] = vec0 + vec3 + vec1; - vertex[3] = vec0 + vec1; - vertex[4] = vec0 + vec2; - vertex[5] = vec0 + vec2 + vec3; - vertex[6] = vec0 + vec2 + vec3 + vec1; - vertex[7] = vec0 + vec1 + vec2; - // int - // faceindex[6][4]={{0,1,2,3},{0,3,7,4},{3,2,6,7},{2,1,5,6},{0,4,5,1},{4,7,6,5}}; - // int - // faceindex[6][4]={{0,3,2,1},{0,4,7,3},{3,7,6,2},{2,6,5,1},{0,1,5,4},{4,5,6,7}}; - int faceindex[6][4] = { - {0, 1, 2, 3}, // top - {0, 3, 7, 4}, // left - {3, 2, 6, 7}, // back - {2, 1, 5, 6}, // right - {0, 4, 5, 1}, // front - {4, 7, 6, 5}, // bottom - }; - V3D normal; - // first face - glBegin(GL_QUADS); - for (auto &row : faceindex) { - normal = (vertex[row[0]] - vertex[row[1]]) - .cross_prod((vertex[row[0]] - vertex[row[2]])); - normal.normalize(); - glNormal3d(normal[0], normal[1], normal[2]); - for (const int ij : row) { - if (ij == 0) - glTexCoord2i(0, 0); - if (ij == 1) - glTexCoord2i(1, 0); - if (ij == 2) - glTexCoord2i(1, 1); - if (ij == 3) - glTexCoord2i(0, 1); - if (ij == 4) - glTexCoord2i(0, 0); - if (ij == 5) - glTexCoord2i(1, 0); - if (ij == 6) - glTexCoord2i(1, 1); - if (ij == 7) - glTexCoord2i(0, 1); - glVertex3d(vertex[ij][0], vertex[ij][1], vertex[ij][2]); - } - } - glEnd(); -} - -/** -* Creates a Hexahedron -* @param Point1 :: first point of the hexahedron -* @param Point2 :: second point of the hexahedron -* @param Point3 :: third point of the hexahedron -* @param Point4 :: fourth point of the hexahedron -* @param Point5 :: fifth point of the hexahedron -* @param Point6 :: sixth point of the hexahedron -* @param Point7 :: seventh point of the hexahedron -* @param Point8 :: eigth point of the hexahedron -*/ -void GluGeometryRenderer::CreateHexahedron( - const Kernel::V3D &Point1, const Kernel::V3D &Point2, - const Kernel::V3D &Point3, const Kernel::V3D &Point4, - const Kernel::V3D &Point5, const Kernel::V3D &Point6, - const Kernel::V3D &Point7, const Kernel::V3D &Point8) { - - glBegin(GL_QUADS); - - // bottom - glVertex3d(Point1.X(), Point1.Y(), Point1.Z()); - glVertex3d(Point2.X(), Point2.Y(), Point2.Z()); - glVertex3d(Point3.X(), Point3.Y(), Point3.Z()); - glVertex3d(Point4.X(), Point4.Y(), Point4.Z()); - - // front - glVertex3d(Point2.X(), Point2.Y(), Point2.Z()); - glVertex3d(Point6.X(), Point6.Y(), Point6.Z()); - glVertex3d(Point7.X(), Point7.Y(), Point7.Z()); - glVertex3d(Point3.X(), Point3.Y(), Point3.Z()); - - // right - glVertex3d(Point3.X(), Point3.Y(), Point3.Z()); - glVertex3d(Point7.X(), Point7.Y(), Point7.Z()); - glVertex3d(Point8.X(), Point8.Y(), Point8.Z()); - glVertex3d(Point4.X(), Point4.Y(), Point4.Z()); - - // back - glVertex3d(Point4.X(), Point4.Y(), Point4.Z()); - glVertex3d(Point8.X(), Point8.Y(), Point8.Z()); - glVertex3d(Point5.X(), Point5.Y(), Point5.Z()); - glVertex3d(Point1.X(), Point1.Y(), Point1.Z()); - - // left - glVertex3d(Point1.X(), Point1.Y(), Point1.Z()); - glVertex3d(Point5.X(), Point5.Y(), Point5.Z()); - glVertex3d(Point6.X(), Point6.Y(), Point6.Z()); - glVertex3d(Point2.X(), Point2.Y(), Point2.Z()); - - // top - glVertex3d(Point5.X(), Point5.Y(), Point5.Z()); - glVertex3d(Point6.X(), Point6.Y(), Point6.Z()); - glVertex3d(Point7.X(), Point7.Y(), Point7.Z()); - glVertex3d(Point8.X(), Point8.Y(), Point8.Z()); - - glEnd(); -} - -/** - * Creates a Cone - * @param center :: center of the cone - * @param axis :: axis of the cone - * @param radius :: radius of the cone - * @param height :: height of the cone - */ -void GluGeometryRenderer::CreateCone(const V3D ¢er, const V3D &axis, - double radius, double height) { - glPushMatrix(); - GLUquadricObj *qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_FILL); - gluQuadricNormals(qobj, GL_SMOOTH); - glTranslated(center[0], center[1], center[2]); - GLdouble mat[16]; - V3D unit(0, 0, 1); - Quat rot(unit, axis); - rot.GLMatrix(&mat[0]); - glMultMatrixd(mat); - gluCylinder(qobj, 0, radius, height, Geometry::Cone::g_nslices, - Geometry::Cone::g_nstacks); - glTranslated(0.0, 0.0, height); - gluDisk(qobj, 0, radius, Geometry::Cone::g_nslices, 1); - glPopMatrix(); -} - -/** - * Create a Cylinder - * @param center :: center of the cylinder - * @param axis :: axis of the cylinder - * @param radius :: radius of the cylinder - * @param height :: height of the cylinder - */ -void GluGeometryRenderer::CreateCylinder(const V3D ¢er, const V3D &axis, - double radius, double height) { - GLUquadricObj *qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_FILL); - gluQuadricNormals(qobj, GL_SMOOTH); - gluQuadricTexture(qobj, true); - glPushMatrix(); - glTranslated(center[0], center[1], center[2]); - GLdouble mat[16]; - V3D unit(0, 0, 1); - Quat rot(unit, axis); - rot.GLMatrix(&mat[0]); - glMultMatrixd(mat); - gluCylinder(qobj, radius, radius, height, Cylinder::g_nslices, - Cylinder::g_nstacks); - gluQuadricTexture(qobj, false); - gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); - glTranslated(0.0, 0.0, height); - gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); - glPopMatrix(); -} - -void GluGeometryRenderer::CreateSegmentedCylinder(const V3D ¢er, - const V3D &axis, - double radius, - double height) { - GLUquadricObj *qobj = gluNewQuadric(); - gluQuadricDrawStyle(qobj, GLU_FILL); - gluQuadricNormals(qobj, GL_SMOOTH); - gluQuadricTexture(qobj, true); - glPushMatrix(); - glTranslated(center[0], center[1], center[2]); - GLdouble mat[16]; - V3D unit(0, 0, 1); - Quat rot(unit, axis); - rot.GLMatrix(&mat[0]); - glMultMatrixd(mat); - gluCylinder(qobj, radius, radius, height, Cylinder::g_nslices, 1); - gluQuadricTexture(qobj, false); - gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); - glTranslated(0.0, 0.0, height); - gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); - glPopMatrix(); -} -} -} diff --git a/Framework/Geometry/src/Rendering/MeshGeometryGenerator.cpp b/Framework/Geometry/src/Rendering/MeshGeometryGenerator.cpp deleted file mode 100644 index e7706d37ac1c4824290cc708e35c440f1a834b57..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/MeshGeometryGenerator.cpp +++ /dev/null @@ -1,73 +0,0 @@ -#include <vector> -#include <cmath> -#include "MantidKernel/Matrix.h" -#include "MantidGeometry/Objects/MeshObject.h" -#include "MantidGeometry/Rendering/MeshGeometryGenerator.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" - -#ifdef ENABLE_OPENCASCADE -#include "MantidGeometry/Rendering/OCGeometryHandler.h" -#endif - -namespace Mantid { - -namespace Geometry { -/** - * Constructor - * @param obj :: input object - */ -MeshGeometryGenerator::MeshGeometryGenerator(MeshObject *obj) : Obj(obj) { - mNoOfVertices = 0; - mNoOfTriangles = 0; - mFaces = nullptr; - mPoints = nullptr; -} - -/** - * Generate geometry, get triangles from object if not in cache. - */ -void MeshGeometryGenerator::Generate() { - if (mNoOfVertices <= 0) { // Get triangles from object - } -} - -/** - * Destroy the surface generated for the object - */ -MeshGeometryGenerator::~MeshGeometryGenerator() { - if (mFaces != nullptr) - delete[] mFaces; - if (mPoints != nullptr) - delete[] mPoints; -} - -int MeshGeometryGenerator::getNumberOfTriangles() { return mNoOfTriangles; } - -int MeshGeometryGenerator::getNumberOfPoints() { return mNoOfVertices; } - -double *MeshGeometryGenerator::getTriangleVertices() { return mPoints; } - -int *MeshGeometryGenerator::getTriangleFaces() { return mFaces; } - -/** - Sets the geometry cache using the triangulation information provided - @param noPts :: the number of points - @param noFaces :: the number of faces - @param pts :: a double array of the points - @param faces :: an int array of the faces -*/ -void MeshGeometryGenerator::setGeometryCache(int noPts, int noFaces, - double *pts, int *faces) { - if (mPoints != nullptr) - delete[] mPoints; - if (mFaces != nullptr) - delete[] mFaces; - mNoOfVertices = noPts; - mNoOfTriangles = noFaces; - mPoints = pts; - mFaces = faces; -} - -} // NAMESPACE Geometry - -} // NAMESPACE Mantid diff --git a/Framework/Geometry/src/Rendering/OCGeometryGenerator.cpp b/Framework/Geometry/src/Rendering/OCGeometryGenerator.cpp deleted file mode 100644 index 49b701333b624aabd93a73142688d6f8c5d3e3b2..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/OCGeometryGenerator.cpp +++ /dev/null @@ -1,215 +0,0 @@ -#include "MantidGeometry/Rendering/OCGeometryGenerator.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Surfaces/Quadratic.h" -#include "MantidGeometry/Surfaces/Sphere.h" -#include "MantidGeometry/Surfaces/Cylinder.h" -#include "MantidGeometry/Surfaces/Cone.h" -#include "MantidGeometry/Surfaces/Plane.h" -#include "MantidGeometry/Surfaces/Torus.h" -#include "MantidGeometry/Objects/Rules.h" -#include "MantidKernel/Logger.h" -#include "MantidKernel/Matrix.h" -#include "MantidKernel/Quat.h" -#include "MantidKernel/V3D.h" -#include "MantidKernel/WarningSuppressions.h" - -#include <climits> // Needed for g++4.4 on Mac with OpenCASCADE 6.3.0 -#include <cmath> -#include <vector> - -// Squash a warning coming out of an OpenCascade header -#ifdef __INTEL_COMPILER -#pragma warning disable 191 -#endif -// Opencascade defines _USE_MATH_DEFINES without checking whether it is already -// used. -// Undefine it here before we include the headers to avoid a warning. Older -// versions -// also define M_SQRT1_2 so do the same if it is already defined -#ifdef _MSC_VER -#undef _USE_MATH_DEFINES -#ifdef M_SQRT1_2 -#undef M_SQRT1_2 -#endif -#endif - -GCC_DIAG_OFF(conversion) -// clang-format off -GCC_DIAG_OFF(cast-qual) -// clang-format on -#include <gp_Trsf.hxx> -#include <gp_Vec.hxx> -#include <gp_Dir.hxx> -#include <gp_Pnt.hxx> -#include <gp_Pln.hxx> -#include <StdFail_NotDone.hxx> -#include <TopoDS.hxx> -#include <TopoDS_Shape.hxx> -#include <TopoDS_Solid.hxx> -#include <TopoDS_Face.hxx> -#include <TopExp_Explorer.hxx> -#include <BRepMesh_IncrementalMesh.hxx> -#include <BRepAlgoAPI_Fuse.hxx> -#include <BRepAlgoAPI_Common.hxx> -#include <BRepAlgoAPI_Cut.hxx> -#include <BRepPrimAPI_MakeBox.hxx> -#include <BRepBuilderAPI_Transform.hxx> -#include <BRep_Tool.hxx> -#include <Poly_Triangulation.hxx> -GCC_DIAG_ON(conversion) -// clang-format off -GCC_DIAG_ON(cast-qual) -// clang-format on - -#ifdef __INTEL_COMPILER -#pragma warning enable 191 -#endif - -namespace Mantid { - -namespace Geometry { -namespace { -/// static logger -Kernel::Logger g_log("OCGeometryGenerator"); -} - -/** -* Constructor -* @param obj :: input object -*/ -OCGeometryGenerator::OCGeometryGenerator(const CSGObject *obj) : Obj(obj) { - ObjSurface = nullptr; -} - -/** -* Generate geometry, it uses OpenCascade to generate surface triangles. -*/ -void OCGeometryGenerator::Generate() { - if (ObjSurface == nullptr) { - AnalyzeObject(); - } -} - -/** -* Destroy the surface generated for the object -*/ -OCGeometryGenerator::~OCGeometryGenerator() { - if (ObjSurface != nullptr) { - delete ObjSurface; - } -} - -/** -* Analyzes the rule tree in object and creates a Topology Shape -*/ -void OCGeometryGenerator::AnalyzeObject() { - if (Obj != nullptr) // If object exists - { - // Get the top rule tree in Obj - const Rule *top = Obj->topRule(); - if (top == nullptr) { - ObjSurface = new TopoDS_Shape(); - return; - } - // Traverse through Rule - TopoDS_Shape Result = const_cast<Rule *>(top)->analyze(); - try { - ObjSurface = new TopoDS_Shape(Result); - BRepMesh_IncrementalMesh(Result, 0.001); - } catch (StdFail_NotDone &) { - g_log.error("Cannot build the geometry. Check the geometry definition"); - } - } -} - -/** -* Returns the shape generated. -*/ -TopoDS_Shape *OCGeometryGenerator::getObjectSurface() { return ObjSurface; } - -int OCGeometryGenerator::getNumberOfTriangles() { - int countFace = 0; - if (ObjSurface != nullptr) { - TopExp_Explorer Ex; - for (Ex.Init(*ObjSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - countFace += facing->NbTriangles(); - } - } - return countFace; -} - -int OCGeometryGenerator::getNumberOfPoints() { - int countVert = 0; - if (ObjSurface != nullptr) { - TopExp_Explorer Ex; - for (Ex.Init(*ObjSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - countVert += facing->NbNodes(); - } - } - return countVert; -} - -double *OCGeometryGenerator::getTriangleVertices() { - double *points = nullptr; - int nPts = this->getNumberOfPoints(); - if (nPts > 0) { - points = new double[static_cast<std::size_t>(nPts) * 3]; - int index = 0; - TopExp_Explorer Ex; - for (Ex.Init(*ObjSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - TColgp_Array1OfPnt tab(1, (facing->NbNodes())); - tab = facing->Nodes(); - for (Standard_Integer i = 1; i <= (facing->NbNodes()); i++) { - gp_Pnt pnt = tab.Value(i); - points[index * 3 + 0] = pnt.X(); - points[index * 3 + 1] = pnt.Y(); - points[index * 3 + 2] = pnt.Z(); - index++; - } - } - } - return points; -} - -int *OCGeometryGenerator::getTriangleFaces() { - int *faces = nullptr; - int nFaces = this->getNumberOfTriangles(); // was Points - if (nFaces > 0) { - faces = new int[static_cast<std::size_t>(nFaces) * 3]; - TopExp_Explorer Ex; - int maxindex = 0; - int index = 0; - for (Ex.Init(*ObjSurface, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - TColgp_Array1OfPnt tab(1, (facing->NbNodes())); - tab = facing->Nodes(); - Poly_Array1OfTriangle tri(1, facing->NbTriangles()); - tri = facing->Triangles(); - for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) { - Poly_Triangle trian = tri.Value(i); - Standard_Integer index1, index2, index3; - trian.Get(index1, index2, index3); - faces[index * 3 + 0] = maxindex + index1 - 1; - faces[index * 3 + 1] = maxindex + index2 - 1; - faces[index * 3 + 2] = maxindex + index3 - 1; - index++; - } - maxindex += facing->NbNodes(); - } - } - return faces; -} -} // NAMESPACE Geometry - -} // NAMESPACE Mantid diff --git a/Framework/Geometry/src/Rendering/OCGeometryHandler.cpp b/Framework/Geometry/src/Rendering/OCGeometryHandler.cpp deleted file mode 100644 index 821d762c3d8d4884f59e5adafeb4c6e4b3a7f3ba..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/OCGeometryHandler.cpp +++ /dev/null @@ -1,125 +0,0 @@ -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/Rendering/GeometryHandler.h" -#include "MantidGeometry/Rendering/OCGeometryHandler.h" -#include "MantidGeometry/Rendering/OCGeometryGenerator.h" -#include "MantidGeometry/Rendering/OCGeometryRenderer.h" - -#include <boost/make_shared.hpp> - -namespace Mantid { -namespace Geometry { -OCGeometryHandler::OCGeometryHandler(IObjComponent *comp) - : GeometryHandler(comp) { - Triangulator = nullptr; - Renderer = new OCGeometryRenderer(); -} - -OCGeometryHandler::OCGeometryHandler(boost::shared_ptr<CSGObject> obj) - : GeometryHandler(obj) { - Triangulator = new OCGeometryGenerator(obj.get()); - Renderer = new OCGeometryRenderer(); -} - -OCGeometryHandler::OCGeometryHandler(CSGObject *obj) : GeometryHandler(obj) { - Triangulator = new OCGeometryGenerator(obj); - Renderer = new OCGeometryRenderer(); -} - -boost::shared_ptr<GeometryHandler> OCGeometryHandler::clone() const { - auto clone = boost::make_shared<OCGeometryHandler>(*this); - clone->Renderer = new OCGeometryRenderer(*(this->Renderer)); - if (this->Triangulator) - clone->Triangulator = new OCGeometryGenerator(this->csgObj); - return clone; -} - -OCGeometryHandler::~OCGeometryHandler() { - if (Triangulator != nullptr) - delete Triangulator; - if (Renderer != nullptr) - delete Renderer; -} - -GeometryHandler *OCGeometryHandler::createInstance(IObjComponent *comp) { - return new OCGeometryHandler(comp); -} - -GeometryHandler * -OCGeometryHandler::createInstance(boost::shared_ptr<CSGObject> obj) { - return new OCGeometryHandler(obj); -} - -GeometryHandler *OCGeometryHandler::createInstance(CSGObject *obj) { - return new OCGeometryHandler(obj); -} - -void OCGeometryHandler::Triangulate() { - // Check whether Object is triangulated otherwise triangulate - if (csgObj != nullptr && !boolTriangulated) { - Triangulator->Generate(); - boolTriangulated = true; - } -} - -void OCGeometryHandler::Render() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - Renderer->Render(Triangulator->getObjectSurface()); - } else if (ObjComp != nullptr) { - Renderer->Render(ObjComp); - } -} - -void OCGeometryHandler::Initialize() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - Renderer->Initialize(Triangulator->getObjectSurface()); - } else if (ObjComp != nullptr) { - Renderer->Initialize(ObjComp); - } -} - -int OCGeometryHandler::NumberOfTriangles() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - return Triangulator->getNumberOfTriangles(); - } else { - return 0; - } -} - -int OCGeometryHandler::NumberOfPoints() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - return Triangulator->getNumberOfPoints(); - } else { - return 0; - } -} - -double *OCGeometryHandler::getTriangleVertices() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - return Triangulator->getTriangleVertices(); - } else { - return nullptr; - } -} - -int *OCGeometryHandler::getTriangleFaces() { - if (csgObj != nullptr) { - if (!boolTriangulated) - Triangulate(); - return Triangulator->getTriangleFaces(); - } else { - return nullptr; - } -} -} -} diff --git a/Framework/Geometry/src/Rendering/OCGeometryRenderer.cpp b/Framework/Geometry/src/Rendering/OCGeometryRenderer.cpp deleted file mode 100644 index 1f899f84b1a74f95bd55a70d8ade7a13de4c81bc..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/OCGeometryRenderer.cpp +++ /dev/null @@ -1,196 +0,0 @@ -#include "MantidGeometry/Rendering/OCGeometryRenderer.h" -#include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidKernel/V3D.h" -#include "MantidKernel/Quat.h" -#include "MantidKernel/WarningSuppressions.h" -#include <climits> - -// Squash a warning coming out of an OpenCascade header -#ifdef __INTEL_COMPILER -#pragma warning disable 191 -#endif -// Opencascade defines _USE_MATH_DEFINES without checking whether it is already -// used. -// Undefine it here before we include the headers to avoid a warning -#ifdef _MSC_VER -#undef _USE_MATH_DEFINES -#ifdef M_SQRT1_2 -#undef M_SQRT1_2 -#endif -#endif - -GCC_DIAG_OFF(conversion) -// clang-format off -GCC_DIAG_OFF(cast-qual) -// clang-format on -#include <gp_Pnt.hxx> -#include <TopoDS.hxx> -#include <TopoDS_Shape.hxx> -#include <TopoDS_Face.hxx> -#include <BRep_Tool.hxx> -#include <TopExp_Explorer.hxx> -#include <Poly_Array1OfTriangle.hxx> -#include <TColgp_Array1OfPnt.hxx> -#include <Poly_Triangulation.hxx> -GCC_DIAG_ON(conversion) -// clang-format off -GCC_DIAG_ON(cast-qual) -// clang-format on - -#ifdef __INTEL_COMPILER -#pragma warning enable 191 -#endif - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; -using Kernel::Quat; - -/** - * Renders Object surface given as OpenCascade topology shape - * @param ObjSurf :: object's surface stored in topology shape - */ -void OCGeometryRenderer::Render(TopoDS_Shape *ObjSurf) { Initialize(ObjSurf); } - -/** - * Render ObjComponent - * @param ObjComp :: input to render - */ -void OCGeometryRenderer::Render(IObjComponent *ObjComp) { - if (ObjComp == nullptr) - return; - glPushMatrix(); - V3D pos = ObjComp->getPos(); - Quat rot = ObjComp->getRotation(); - double rotGL[16]; - rot.GLMatrix(&rotGL[0]); - glTranslated(pos[0], pos[1], pos[2]); - glMultMatrixd(rotGL); - V3D scaleFactor = ObjComp->getScaleFactor(); - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - ObjComp->drawObject(); - glPopMatrix(); -} - -/** - * Initialze the object surface for rendering - * @param ObjSurf :: input to create display list - */ -void OCGeometryRenderer::Initialize(TopoDS_Shape *ObjSurf) { - glBegin(GL_TRIANGLES); - // Here goes the traversing through TopoDS_Shape triangles - RenderTopoDS(ObjSurf); - glEnd(); -} - -/** - * Initializes creates a display for the input ObjComponent - * @param ObjComp :: input object component for creating display - */ -void OCGeometryRenderer::Initialize(IObjComponent *ObjComp) { - glPushMatrix(); - V3D pos = ObjComp->getPos(); - Quat rot = ObjComp->getRotation(); - double rotGL[16]; - rot.GLMatrix(&rotGL[0]); - glTranslated(pos[0], pos[1], pos[2]); - glMultMatrixd(rotGL); - V3D scaleFactor = ObjComp->getScaleFactor(); - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - ObjComp->drawObject(); - glPopMatrix(); -} - -/** - * Renders TopoDS Shape by traversing through the TopoDS_Shape - */ -void OCGeometryRenderer::RenderTopoDS(TopoDS_Shape *ObjSurf) { - if ((ObjSurf != nullptr) && !ObjSurf->IsNull()) { - TopExp_Explorer Ex; - for (Ex.Init(*ObjSurf, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - TColgp_Array1OfPnt tab(1, (facing->NbNodes())); - tab = facing->Nodes(); - Poly_Array1OfTriangle tri(1, facing->NbTriangles()); - tri = facing->Triangles(); - for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) { - Poly_Triangle trian = tri.Value(i); - Standard_Integer index1, index2, index3; - trian.Get(index1, index2, index3); - gp_Pnt point1 = tab.Value(index1); - gp_Pnt point2 = tab.Value(index2); - gp_Pnt point3 = tab.Value(index3); - gp_XYZ pt1 = tab.Value(index1).XYZ(); - gp_XYZ pt2 = tab.Value(index2).XYZ(); - gp_XYZ pt3 = tab.Value(index3).XYZ(); - - gp_XYZ v1 = pt2 - pt1; - gp_XYZ v2 = pt3 - pt2; - - gp_XYZ normal = v1 ^ v2; - normal.Normalize(); - glNormal3d(normal.X(), normal.Y(), normal.Z()); - glVertex3d(point1.X(), point1.Y(), point1.Z()); - glVertex3d(point2.X(), point2.Y(), point2.Z()); - glVertex3d(point3.X(), point3.Y(), point3.Z()); - } - } - } -} - -/** - * Writes out a vtk 2.0 file, currently hardcoded to c:\\outputcascade.vtk - */ -void OCGeometryRenderer::WriteVTK(TopoDS_Shape *out) { - FILE *fp = fopen("C:\\outputcascade.vtk", "w+"); - fprintf(fp, "# vtk DataFile Version 2.0 \nOpenCascade data\nASCII\n"); - fprintf(fp, "DATASET POLYDATA\n"); - // BRepMesh::Mesh(out,0.1); - TopExp_Explorer Ex; - int countVert = 0; - int countFace = 0; - for (Ex.Init(*out, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - countVert += facing->NbNodes(); - countFace += facing->NbTriangles(); - } - fprintf(fp, "POINTS %d float\n", countVert); - for (Ex.Init(*out, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - TColgp_Array1OfPnt tab(1, (facing->NbNodes())); - tab = facing->Nodes(); - for (Standard_Integer i = 1; i <= (facing->NbNodes()); i++) { - gp_Pnt pnt = tab.Value(i); - fprintf(fp, "%f %f %f\n", pnt.X(), pnt.Y(), pnt.Z()); - } - } - fprintf(fp, "POLYGONS %d %d\n", countFace, countFace * 4); - int maxindex = 0; - for (Ex.Init(*out, TopAbs_FACE); Ex.More(); Ex.Next()) { - TopoDS_Face F = TopoDS::Face(Ex.Current()); - TopLoc_Location L; - Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); - TColgp_Array1OfPnt tab(1, (facing->NbNodes())); - tab = facing->Nodes(); - Poly_Array1OfTriangle tri(1, facing->NbTriangles()); - tri = facing->Triangles(); - for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) { - Poly_Triangle trian = tri.Value(i); - Standard_Integer index1, index2, index3; - trian.Get(index1, index2, index3); - fprintf(fp, "3 %d %d %d\n", maxindex + index1 - 1, maxindex + index2 - 1, - maxindex + index3 - 1); - } - maxindex += facing->NbNodes(); - } - fclose(fp); -} -} -} diff --git a/Framework/Geometry/src/Rendering/RenderingHelpers.cpp b/Framework/Geometry/src/Rendering/RenderingHelpers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..af230c87276a01f61b3969d0b32097b240b5b1b5 --- /dev/null +++ b/Framework/Geometry/src/Rendering/RenderingHelpers.cpp @@ -0,0 +1,330 @@ +#include "MantidGeometry/Rendering/RenderingHelpers.h" +#include "MantidGeometry/IObjComponent.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Objects/ShapeFactory.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryTriangulator.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidGeometry/Surfaces/Cone.h" +#include "MantidGeometry/Surfaces/Cylinder.h" +#include "MantidGeometry/Surfaces/Sphere.h" +#include "MantidKernel/Quat.h" +#include "MantidKernel/WarningSuppressions.h" +#include <climits> + +#ifdef ENABLE_OPENCASCADE +// Squash a warning coming out of an OpenCascade header +#ifdef __INTEL_COMPILER +#pragma warning disable 191 +#endif +// Opencascade defines _USE_MATH_DEFINES without checking whether it is already +// used. +// Undefine it here before we include the headers to avoid a warning +#ifdef _MSC_VER +#undef _USE_MATH_DEFINES +#ifdef M_SQRT1_2 +#undef M_SQRT1_2 +#endif +#endif + +GCC_DIAG_OFF(conversion) +// clang-format off +GCC_DIAG_OFF(cast-qual) +// clang-format on +#include <gp_Pnt.hxx> +#include <TopoDS.hxx> +#include <TopoDS_Shape.hxx> +#include <TopoDS_Face.hxx> +#include <BRep_Tool.hxx> +#include <TopExp_Explorer.hxx> +#include <Poly_Array1OfTriangle.hxx> +#include <TColgp_Array1OfPnt.hxx> +#include <Poly_Triangulation.hxx> +GCC_DIAG_ON(conversion) +// clang-format off +GCC_DIAG_ON(cast-qual) +// clang-format on + +#ifdef __INTEL_COMPILER +#pragma warning enable 191 +#endif +#endif + +namespace Mantid { +namespace Geometry { +using Kernel::Quat; +using Kernel::V3D; + +namespace { +// Render IObjectComponent +void render(const IObjComponent &ObjComp) { + glPushMatrix(); + V3D pos = ObjComp.getPos(); + Quat rot = ObjComp.getRotation(); + double rotGL[16]; + rot.GLMatrix(&rotGL[0]); + glTranslated(pos[0], pos[1], pos[2]); + glMultMatrixd(rotGL); + V3D scaleFactor = ObjComp.getScaleFactor(); + glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); + ObjComp.drawObject(); + glPopMatrix(); +} + +// Render triangulated surface +void render(detail::GeometryTriangulator &triangulator) { + const auto &faces = triangulator.getTriangleFaces(); + const auto &points = triangulator.getTriangleVertices(); + glBegin(GL_TRIANGLES); + V3D normal; + for (size_t i = 0; i < triangulator.numTriangleFaces(); i++) { + auto index2 = static_cast<size_t>(faces[i * 3 + 1] * 3); + auto index3 = static_cast<size_t>(faces[i * 3 + 2] * 3); + auto index1 = static_cast<size_t>(faces[i * 3] * 3); + // Calculate normal and normalize + V3D v1(points[index1], points[index1 + 1], points[index1 + 2]); + V3D v2(points[index2], points[index2 + 1], points[index2 + 2]); + V3D v3(points[index3], points[index3 + 1], points[index3 + 2]); + normal = (v1 - v2).cross_prod(v2 - v3); + normal.normalize(); + glNormal3d(normal[0], normal[1], normal[2]); + glVertex3dv(&points[index1]); + glVertex3dv(&points[index2]); + glVertex3dv(&points[index3]); + } + glEnd(); +} + +#ifdef ENABLE_OPENCASCADE +// Render OpenCascade Shape +void render(const TopoDS_Shape &ObjSurf) { + glBegin(GL_TRIANGLES); + if (!ObjSurf.IsNull()) { + TopExp_Explorer Ex; + for (Ex.Init(ObjSurf, TopAbs_FACE); Ex.More(); Ex.Next()) { + TopoDS_Face F = TopoDS::Face(Ex.Current()); + TopLoc_Location L; + Handle(Poly_Triangulation) facing = BRep_Tool::Triangulation(F, L); + TColgp_Array1OfPnt tab(1, (facing->NbNodes())); + tab = facing->Nodes(); + Poly_Array1OfTriangle tri(1, facing->NbTriangles()); + tri = facing->Triangles(); + for (Standard_Integer i = 1; i <= (facing->NbTriangles()); i++) { + Poly_Triangle trian = tri.Value(i); + Standard_Integer index1, index2, index3; + trian.Get(index1, index2, index3); + gp_Pnt point1 = tab.Value(index1); + gp_Pnt point2 = tab.Value(index2); + gp_Pnt point3 = tab.Value(index3); + gp_XYZ pt1 = tab.Value(index1).XYZ(); + gp_XYZ pt2 = tab.Value(index2).XYZ(); + gp_XYZ pt3 = tab.Value(index3).XYZ(); + + gp_XYZ v1 = pt2 - pt1; + gp_XYZ v2 = pt3 - pt2; + + gp_XYZ normal = v1 ^ v2; + normal.Normalize(); + glNormal3d(normal.X(), normal.Y(), normal.Z()); + glVertex3d(point1.X(), point1.Y(), point1.Z()); + glVertex3d(point2.X(), point2.Y(), point2.Z()); + glVertex3d(point3.X(), point3.Y(), point3.Z()); + } + } + } + glEnd(); +} +#endif + +void renderSphere(const detail::ShapeInfo &shapeInfo) { + // create glu sphere + GLUquadricObj *qobj = gluNewQuadric(); + gluQuadricDrawStyle(qobj, GLU_FILL); + gluQuadricNormals(qobj, GL_SMOOTH); + glPushMatrix(); + auto center = shapeInfo.points()[0]; + glTranslated(center[0], center[1], center[2]); + gluSphere(qobj, shapeInfo.radius(), Sphere::g_nslices, Sphere::g_nstacks); + glPopMatrix(); + gluDeleteQuadric(qobj); +} + +void renderCuboid(const detail::ShapeInfo &shapeInfo) { + const auto &points = shapeInfo.points(); + V3D vec0 = points[0]; + V3D vec1 = points[1] - points[0]; + V3D vec2 = points[2] - points[0]; + V3D vec3 = points[3] - points[0]; + V3D vertex[8]; + vertex[0] = vec0; + vertex[1] = vec0 + vec3; + vertex[2] = vec0 + vec3 + vec1; + vertex[3] = vec0 + vec1; + vertex[4] = vec0 + vec2; + vertex[5] = vec0 + vec2 + vec3; + vertex[6] = vec0 + vec2 + vec3 + vec1; + vertex[7] = vec0 + vec1 + vec2; + + int faceindex[6][4] = { + {0, 1, 2, 3}, // top + {0, 3, 7, 4}, // left + {3, 2, 6, 7}, // back + {2, 1, 5, 6}, // right + {0, 4, 5, 1}, // front + {4, 7, 6, 5}, // bottom + }; + V3D normal; + // first face + glBegin(GL_QUADS); + for (auto &row : faceindex) { + normal = (vertex[row[0]] - vertex[row[1]]) + .cross_prod((vertex[row[0]] - vertex[row[2]])); + normal.normalize(); + glNormal3d(normal[0], normal[1], normal[2]); + for (const int ij : row) { + if (ij == 0) + glTexCoord2i(0, 0); + if (ij == 1) + glTexCoord2i(1, 0); + if (ij == 2) + glTexCoord2i(1, 1); + if (ij == 3) + glTexCoord2i(0, 1); + if (ij == 4) + glTexCoord2i(0, 0); + if (ij == 5) + glTexCoord2i(1, 0); + if (ij == 6) + glTexCoord2i(1, 1); + if (ij == 7) + glTexCoord2i(0, 1); + glVertex3d(vertex[ij][0], vertex[ij][1], vertex[ij][2]); + } + } + glEnd(); +} + +void renderHexahedron(const detail::ShapeInfo &shapeInfo) { + glBegin(GL_QUADS); + const auto &points = shapeInfo.points(); + // bottom + glVertex3d(points[0].X(), points[0].Y(), points[0].Z()); + glVertex3d(points[1].X(), points[1].Y(), points[1].Z()); + glVertex3d(points[2].X(), points[2].Y(), points[2].Z()); + glVertex3d(points[3].X(), points[3].Y(), points[3].Z()); + // front + glVertex3d(points[1].X(), points[1].Y(), points[1].Z()); + glVertex3d(points[5].X(), points[5].Y(), points[5].Z()); + glVertex3d(points[6].X(), points[6].Y(), points[6].Z()); + glVertex3d(points[2].X(), points[2].Y(), points[2].Z()); + // right + glVertex3d(points[2].X(), points[2].Y(), points[2].Z()); + glVertex3d(points[6].X(), points[6].Y(), points[6].Z()); + glVertex3d(points[7].X(), points[7].Y(), points[7].Z()); + glVertex3d(points[3].X(), points[3].Y(), points[3].Z()); + // back + glVertex3d(points[3].X(), points[3].Y(), points[3].Z()); + glVertex3d(points[7].X(), points[7].Y(), points[7].Z()); + glVertex3d(points[4].X(), points[4].Y(), points[4].Z()); + glVertex3d(points[0].X(), points[0].Y(), points[0].Z()); + // left + glVertex3d(points[0].X(), points[0].Y(), points[0].Z()); + glVertex3d(points[4].X(), points[4].Y(), points[4].Z()); + glVertex3d(points[5].X(), points[5].Y(), points[5].Z()); + glVertex3d(points[1].X(), points[1].Y(), points[1].Z()); + // top + glVertex3d(points[4].X(), points[4].Y(), points[4].Z()); + glVertex3d(points[5].X(), points[5].Y(), points[5].Z()); + glVertex3d(points[6].X(), points[6].Y(), points[6].Z()); + glVertex3d(points[7].X(), points[7].Y(), points[7].Z()); + + glEnd(); +} + +void renderCone(const detail::ShapeInfo &shapeInfo) { + glPushMatrix(); + GLUquadricObj *qobj = gluNewQuadric(); + gluQuadricDrawStyle(qobj, GLU_FILL); + gluQuadricNormals(qobj, GL_SMOOTH); + auto center = shapeInfo.points()[0]; + glTranslated(center[0], center[1], center[2]); + GLdouble mat[16]; + V3D unit(0, 0, 1); + auto axis = shapeInfo.points()[1]; + Quat rot(unit, axis); + rot.GLMatrix(&mat[0]); + glMultMatrixd(mat); + auto radius = shapeInfo.radius(); + auto height = shapeInfo.height(); + gluCylinder(qobj, 0, radius, height, Geometry::Cone::g_nslices, + Geometry::Cone::g_nstacks); + glTranslated(0.0, 0.0, height); + gluDisk(qobj, 0, radius, Geometry::Cone::g_nslices, 1); + glPopMatrix(); +} + +void renderCylinder(const detail::ShapeInfo &shapeInfo) { + GLUquadricObj *qobj = gluNewQuadric(); + gluQuadricDrawStyle(qobj, GLU_FILL); + gluQuadricNormals(qobj, GL_SMOOTH); + gluQuadricTexture(qobj, true); + glPushMatrix(); + auto center = shapeInfo.points()[0]; + glTranslated(center[0], center[1], center[2]); + GLdouble mat[16]; + V3D unit(0, 0, 1); + auto axis = shapeInfo.points()[1]; + Quat rot(unit, axis); + rot.GLMatrix(&mat[0]); + glMultMatrixd(mat); + auto radius = shapeInfo.radius(); + auto height = shapeInfo.height(); + gluCylinder(qobj, radius, radius, height, Cylinder::g_nslices, + Cylinder::g_nstacks); + gluQuadricTexture(qobj, false); + gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); + glTranslated(0.0, 0.0, height); + gluDisk(qobj, 0, radius, Cylinder::g_nslices, 1); + glPopMatrix(); +} +} // namespace + +namespace RenderingHelpers { +void renderIObjComponent(const IObjComponent &objComp) { render(objComp); } + +void renderTriangulated(detail::GeometryTriangulator &triangulator) { +#ifdef ENABLE_OPENCASCADE + if (triangulator.hasOCSurface() && !triangulator.getOCSurface().IsNull()) + render(triangulator.getOCSurface()); + else + render(triangulator); +#else + render(triangulator); +#endif +} + +void renderShape(const detail::ShapeInfo &shapeInfo) { + switch (shapeInfo.shape()) { + case detail::ShapeInfo::GeometryShape::CUBOID: + renderCuboid(shapeInfo); + break; + case detail::ShapeInfo::GeometryShape::SPHERE: + renderSphere(shapeInfo); + break; + case detail::ShapeInfo::GeometryShape::HEXAHEDRON: + renderHexahedron(shapeInfo); + break; + case detail::ShapeInfo::GeometryShape::CONE: + renderCone(shapeInfo); + break; + case detail::ShapeInfo::GeometryShape::CYLINDER: + renderCylinder(shapeInfo); + break; + default: + return; + } +} +} // namespace RenderingHelpers +} // namespace Geometry +} // namespace Mantid diff --git a/Framework/Geometry/src/Rendering/ShapeInfo.cpp b/Framework/Geometry/src/Rendering/ShapeInfo.cpp new file mode 100644 index 0000000000000000000000000000000000000000..1c6b7ba2c08ab6eda799a2fb790835f91d9fc3b3 --- /dev/null +++ b/Framework/Geometry/src/Rendering/ShapeInfo.cpp @@ -0,0 +1,74 @@ +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidKernel/V3D.h" + +namespace Mantid { +using Kernel::V3D; +namespace Geometry { +namespace detail { +ShapeInfo::ShapeInfo() + : m_points(), m_radius(0), m_height(0), + m_shape(ShapeInfo::GeometryShape::NOSHAPE) {} + +const std::vector<Kernel::V3D> &ShapeInfo::points() const { return m_points; } + +double ShapeInfo::radius() const { return m_radius; } + +double ShapeInfo::height() const { return m_height; } + +ShapeInfo::GeometryShape ShapeInfo::shape() const { return m_shape; } + +void ShapeInfo::getObjectGeometry(ShapeInfo::GeometryShape &myshape, + std::vector<Kernel::V3D> &points, + double &myradius, double &myheight) const { + myshape = m_shape; + points = m_points; + myradius = m_radius; + myheight = m_height; +} + +void ShapeInfo::setCuboid(const V3D &p1, const V3D &p2, const V3D &p3, + const V3D &p4) { + m_shape = GeometryShape::CUBOID; + m_points.assign({p1, p2, p3, p4}); + m_radius = 0; + m_height = 0; +} + +void ShapeInfo::setHexahedron(const V3D &p1, const V3D &p2, const V3D &p3, + const V3D &p4, const V3D &p5, const V3D &p6, + const V3D &p7, const V3D &p8) { + m_shape = GeometryShape::HEXAHEDRON; + m_points.assign({p1, p2, p3, p4, p5, p6, p7, p8}); + m_radius = 0; + m_height = 0; +} + +void ShapeInfo::setSphere(const V3D &c, double r) { + m_shape = GeometryShape::SPHERE; + m_points.assign({c}); + m_radius = r; + m_height = 0; +} + +void ShapeInfo::setCylinder(const V3D &c, const V3D &a, double r, double h) { + m_shape = GeometryShape::CYLINDER; + m_points.assign({c, a}); + m_radius = r; + m_height = h; +} + +void ShapeInfo::setCone(const V3D &c, const V3D &a, double r, double h) { + m_shape = GeometryShape::CONE; + m_points.assign({c, a}); + m_radius = r; + m_height = h; +} + +bool ShapeInfo::operator==(const ShapeInfo &other) { + return m_shape == other.m_shape && m_height == other.m_height && + m_radius == other.m_radius && m_points == other.m_points; +} + +} // namespace detail +} // namespace Geometry +} // namespace Mantid \ No newline at end of file diff --git a/Framework/Geometry/src/Rendering/StructuredGeometryHandler.cpp b/Framework/Geometry/src/Rendering/StructuredGeometryHandler.cpp deleted file mode 100644 index cb756fdfad08f6111bc8625c955574bc15fbdf51..0000000000000000000000000000000000000000 --- a/Framework/Geometry/src/Rendering/StructuredGeometryHandler.cpp +++ /dev/null @@ -1,116 +0,0 @@ -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidGeometry/Rendering/OpenGL_Headers.h" -#include "MantidGeometry/Rendering/StructuredGeometryHandler.h" -#include <climits> -#include <iostream> - -#include <boost/make_shared.hpp> - -namespace Mantid { -namespace Geometry { -using Kernel::V3D; - -/** - * @return A shared_ptr to a new copy of this object - */ -boost::shared_ptr<GeometryHandler> StructuredGeometryHandler::clone() const { - return boost::make_shared<StructuredGeometryHandler>(*this); -} - -/// Parameter constructor -StructuredGeometryHandler::StructuredGeometryHandler(StructuredDetector *comp) - : GeometryHandler(dynamic_cast<IObjComponent *>(comp)) { - // Save the structured detector link for later. - m_Det = comp; -} - -StructuredGeometryHandler::StructuredGeometryHandler() - : GeometryHandler(static_cast<CSGObject *>(nullptr)), m_Det(nullptr) {} - -///< Create an instance of concrete geometry handler for ObjComponent -StructuredGeometryHandler * -StructuredGeometryHandler::createInstance(IObjComponent *) { - return new StructuredGeometryHandler(); -} - -///< Create an instance of concrete geometry handler for Object -StructuredGeometryHandler * - StructuredGeometryHandler::createInstance(boost::shared_ptr<CSGObject>) { - return new StructuredGeometryHandler(); -} - -///< Create an instance of concrete geometry handler for Object -GeometryHandler *StructuredGeometryHandler::createInstance(CSGObject *) { - return new StructuredGeometryHandler(); -} - -//---------------------------------------------------------------------------------------------- -/** Triangulate the Object - this function will not be used. - * - */ -void StructuredGeometryHandler::Triangulate() { - // do nothing -} - -//---------------------------------------------------------------------------------------------- -///< Draw pixels according to StructuredDetector vertices -void StructuredGeometryHandler::Render() { - V3D pos; - - // Wait for no error - while (glGetError() != GL_NO_ERROR) - ; - - auto xVerts = m_Det->getXValues(); - auto yVerts = m_Det->getYValues(); - auto r = m_Det->getR(); - auto g = m_Det->getG(); - auto b = m_Det->getB(); - - if (xVerts.size() != yVerts.size()) - return; - - auto w = m_Det->xPixels() + 1; - auto h = m_Det->yPixels() + 1; - - glBegin(GL_QUADS); - - for (size_t iy = 0; iy < h - 1; iy++) { - for (size_t ix = 0; ix < w - 1; ix++) { - - glColor3ub((GLubyte)r[(iy * (w - 1)) + ix], - (GLubyte)g[(iy * (w - 1)) + ix], - (GLubyte)b[(iy * (w - 1)) + ix]); - - pos = V3D(xVerts[(iy * w) + ix + w], yVerts[(iy * w) + ix + w], 0.0); - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - pos = V3D(xVerts[(iy * w) + ix + w + 1], yVerts[(iy * w) + ix + w + 1], - 0.0); - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - pos = V3D(xVerts[(iy * w) + ix + 1], yVerts[(iy * w) + ix + 1], 0.0); - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - pos = V3D(xVerts[(iy * w) + ix], yVerts[(iy * w) + ix], 0.0); - glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), - static_cast<GLfloat>(pos.Z())); - } - } - - glEnd(); - - if (glGetError() > 0) - std::cout << "OpenGL error in StructuredGeometryHandler::Render \n"; - - glDisable( - GL_TEXTURE_2D); // stop texture mapping - not sure if this is necessary. -} - -//---------------------------------------------------------------------------------------------- -///< Prepare/Initialize Object/ObjComponent to be rendered -void StructuredGeometryHandler::Initialize() { - // do nothing -} -} -} diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp index 86ff9a92dc65d1131bf6d3971a719f25f68364d1..1b770483367e33edc7fba310da1e18134a62b487 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheReader.cpp @@ -68,8 +68,8 @@ void vtkGeometryCacheReader::readCacheForObject(IObject *obj) { } // Read the cache from the element int noOfTriangles = 0, noOfPoints = 0; - double *Points; - int *Faces; + std::vector<double> Points; + std::vector<uint32_t> Faces; std::stringstream buff; // Read number of points buff << pEle->getAttribute("NumberOfPoints"); @@ -82,15 +82,16 @@ void vtkGeometryCacheReader::readCacheForObject(IObject *obj) { // Read Points Element *pPts = pEle->getChildElement("Points")->getChildElement("DataArray"); - readPoints(pPts, &noOfPoints, &Points); + readPoints(pPts, noOfPoints, Points); // Read Triangles Element *pTris = pEle->getChildElement("Polys")->getChildElement("DataArray"); - readTriangles(pTris, &noOfTriangles, &Faces); + readTriangles(pTris, noOfTriangles, Faces); // First check whether Object can be written to the file boost::shared_ptr<GeometryHandler> handle = obj->getGeometryHandler(); - handle->setGeometryCache(noOfPoints, noOfTriangles, Points, Faces); + handle->setGeometryCache(noOfPoints, noOfTriangles, std::move(Points), + std::move(Faces)); } /** @@ -111,14 +112,15 @@ vtkGeometryCacheReader::getElementByObjectName(std::string name) { * Read the points from the element */ void vtkGeometryCacheReader::readPoints(Poco::XML::Element *pEle, - int *noOfPoints, double **points) { + int noOfPoints, + std::vector<double> &points) { if (pEle == nullptr) { - *noOfPoints = 0; + noOfPoints = 0; return; } // Allocate memory - *points = new double[(*noOfPoints) * 3]; - if (*points == nullptr) // Out of memory + points.resize(noOfPoints * 3); + if (points.size() != static_cast<size_t>(noOfPoints * 3)) // Out of memory { g_log.error("Cannot allocate memory for triangle cache of Object "); return; @@ -126,25 +128,26 @@ void vtkGeometryCacheReader::readPoints(Poco::XML::Element *pEle, if (pEle->getAttribute("format") == "ascii") { // Read from Ascii std::stringstream buf; buf << pEle->innerText(); - for (int i = 0; i < (*noOfPoints) * 3; i++) { - buf >> (*points)[i]; + for (double &point : points) { + buf >> point; } - } else { // Read from binary } + // Read from binary otherwise } /** * Read triangle face indexs */ void vtkGeometryCacheReader::readTriangles(Poco::XML::Element *pEle, - int *noOfTriangles, int **faces) { + int noOfTriangles, + std::vector<uint32_t> &faces) { if (pEle == nullptr) { - *noOfTriangles = 0; + noOfTriangles = 0; return; } // Allocate memory - *faces = new int[(*noOfTriangles) * 3]; - if (*faces == nullptr) // Out of memory + faces.resize(noOfTriangles * 3); + if (faces.size() != static_cast<size_t>(noOfTriangles * 3)) // Out of memory { g_log.error("Cannot allocate memory for triangle cache of Object "); return; @@ -152,11 +155,11 @@ void vtkGeometryCacheReader::readTriangles(Poco::XML::Element *pEle, if (pEle->getAttribute("format") == "ascii") { // Read from Ascii std::stringstream buf; buf << pEle->innerText(); - for (int i = 0; i < (*noOfTriangles) * 3; i++) { - buf >> (*faces)[i]; + for (unsigned int &face : faces) { + buf >> face; } - } else { // Read from binary } + // Read from binary otherwise } } } diff --git a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp index 8b23a7a86a41c6542f0be32efc49d34f92bcf806..93e1ef29884023f149b2e29b716f4e5cbff261ac 100644 --- a/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp +++ b/Framework/Geometry/src/Rendering/vtkGeometryCacheWriter.cpp @@ -85,9 +85,9 @@ void vtkGeometryCacheWriter::addObject(CSGObject *obj) { // get the name of the Object int name = obj->getName(); // get number of point - int noPts = handle->NumberOfPoints(); + auto noPts = handle->numberOfPoints(); // get number of triangles - int noTris = handle->NumberOfTriangles(); + auto noTris = handle->numberOfTriangles(); // Add Piece AutoPtr<Element> pPiece = mDoc->createElement("Piece"); // Add attribute name @@ -110,9 +110,9 @@ void vtkGeometryCacheWriter::addObject(CSGObject *obj) { pPtsDataArray->setAttribute("format", "ascii"); buf.str(""); // get the triangles info - double *points = handle->getTriangleVertices(); - int i; - for (i = 0; i < noPts * 3; i++) { + const auto &points = handle->getTriangleVertices(); + size_t i; + for (i = 0; i < points.size(); i++) { buf << points[i] << " "; } AutoPtr<Text> pPointText = mDoc->createTextNode(buf.str()); @@ -122,13 +122,13 @@ void vtkGeometryCacheWriter::addObject(CSGObject *obj) { AutoPtr<Element> pFaces = mDoc->createElement("Polys"); AutoPtr<Element> pTrisDataArray = mDoc->createElement("DataArray"); // add attribute - pTrisDataArray->setAttribute("type", "Int32"); + pTrisDataArray->setAttribute("type", "UInt32"); pTrisDataArray->setAttribute("Name", "connectivity"); pTrisDataArray->setAttribute("format", "ascii"); buf.str(""); - int *faces = handle->getTriangleFaces(); - for (i = 0; i < noTris * 3; i++) { + const auto &faces = handle->getTriangleFaces(); + for (i = 0; i < faces.size(); i++) { buf << faces[i] << " "; } AutoPtr<Text> pTrisDataText = mDoc->createTextNode(buf.str()); @@ -137,7 +137,7 @@ void vtkGeometryCacheWriter::addObject(CSGObject *obj) { // set the offsets AutoPtr<Element> pTrisOffsetDataArray = mDoc->createElement("DataArray"); // add attribute - pTrisOffsetDataArray->setAttribute("type", "Int32"); + pTrisOffsetDataArray->setAttribute("type", "UInt32"); pTrisOffsetDataArray->setAttribute("Name", "offsets"); pTrisOffsetDataArray->setAttribute("format", "ascii"); buf.str(""); @@ -164,6 +164,7 @@ void vtkGeometryCacheWriter::write() { writer.setOptions(XMLWriter::PRETTY_PRINT); std::ofstream file; try { + g_log.information("Writing Geometry Cache file to " + mFileName); file.open(mFileName.c_str(), std::ios::trunc); writer.writeNode(file, mDoc); file.close(); diff --git a/Framework/Geometry/test/CSGObjectTest.h b/Framework/Geometry/test/CSGObjectTest.h index 0557002c49cac56d3c88f0fe7fe849de3eabada1..0c9f7bb10e417971079e96b04819fca94ea61924 100644 --- a/Framework/Geometry/test/CSGObjectTest.h +++ b/Framework/Geometry/test/CSGObjectTest.h @@ -10,7 +10,9 @@ #include "MantidGeometry/Surfaces/SurfaceFactory.h" #include "MantidGeometry/Objects/Rules.h" #include "MantidGeometry/Objects/Track.h" -#include "MantidGeometry/Rendering/GluGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidKernel/make_unique.h" #include "MantidKernel/Material.h" @@ -35,6 +37,7 @@ using namespace Mantid; using namespace Geometry; using Mantid::Kernel::V3D; +using detail::ShapeInfo; namespace { // ----------------------------------------------------------------------------- @@ -83,23 +86,22 @@ public: auto original_ptr = ComponentCreationHelper::createSphere(1.0); auto &original = dynamic_cast<CSGObject &>(*original_ptr); original.setID("sp-1"); - int objType(-1); + ShapeInfo::GeometryShape objType; double radius(-1.0), height(-1.0); std::vector<V3D> pts; + auto handler = original.getGeometryHandler(); + TS_ASSERT(handler->hasShapeInfo()); original.GetObjectGeom(objType, pts, radius, height); - TS_ASSERT_EQUALS(3, objType); - TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>( - original.getGeometryHandler())); + TS_ASSERT_EQUALS(ShapeInfo::GeometryShape::SPHERE, objType); CSGObject copy(original); - // The copy should be a primitive object with a GluGeometryHandler - objType = -1; + // The copy should be a primitive object with a GeometryHandler copy.GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS("sp-1", copy.id()); - TS_ASSERT_EQUALS(3, objType); - TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>( - copy.getGeometryHandler())); + auto handlerCopy = copy.getGeometryHandler(); + TS_ASSERT(handlerCopy->hasShapeInfo()); + TS_ASSERT_EQUALS(handler->shapeInfo(), handlerCopy->shapeInfo()); TS_ASSERT_EQUALS(copy.getName(), original.getName()); // Check the string representation is the same TS_ASSERT_EQUALS(copy.str(), original.str()); @@ -110,24 +112,24 @@ public: auto original_ptr = ComponentCreationHelper::createSphere(1.0); auto &original = dynamic_cast<CSGObject &>(*original_ptr); original.setID("sp-1"); - int objType(-1); + ShapeInfo::GeometryShape objType; double radius(-1.0), height(-1.0); std::vector<V3D> pts; + auto handler = original.getGeometryHandler(); + TS_ASSERT(handler->hasShapeInfo()); original.GetObjectGeom(objType, pts, radius, height); - TS_ASSERT_EQUALS(3, objType); - TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>( - original.getGeometryHandler())); + TS_ASSERT_EQUALS(ShapeInfo::GeometryShape::SPHERE, objType); CSGObject lhs; // initialize lhs = original; // assign // The copy should be a primitive object with a GluGeometryHandler - objType = -1; lhs.GetObjectGeom(objType, pts, radius, height); TS_ASSERT_EQUALS("sp-1", lhs.id()); - TS_ASSERT_EQUALS(3, objType); - TS_ASSERT(boost::dynamic_pointer_cast<GluGeometryHandler>( - lhs.getGeometryHandler())); + TS_ASSERT_EQUALS(ShapeInfo::GeometryShape::SPHERE, objType); + auto handlerCopy = lhs.getGeometryHandler(); + TS_ASSERT(handlerCopy->hasShapeInfo()); + TS_ASSERT_EQUALS(handlerCopy->shapeInfo(), handler->shapeInfo()); } void testCreateUnitCube() { @@ -793,10 +795,11 @@ public: { boost::shared_ptr<CSGObject> geom_obj = createSmallCappedCylinder(); // Want to test triangulation so setup a geometry handler - boost::shared_ptr<GluGeometryHandler> h = - boost::shared_ptr<GluGeometryHandler>( - new GluGeometryHandler(geom_obj.get())); - h->setCylinder(V3D(-0.0015, 0.0, 0.0), V3D(1., 0.0, 0.0), 0.005, 0.003); + auto h = boost::make_shared<GeometryHandler>(geom_obj); + detail::ShapeInfo shapeInfo; + shapeInfo.setCylinder(V3D(-0.0015, 0.0, 0.0), V3D(1., 0.0, 0.0), 0.005, + 0.003); + h->setShapeInfo(std::move(shapeInfo)); geom_obj->setGeometryHandler(h); double satol(1e-8); // tolerance for solid angle @@ -1268,12 +1271,12 @@ private: SurfLine.push_back(SCompT(73, "s 0.6 0 0 0.4")); // Note that the testObject now manages the "new Plane" - for (auto vc = SurfLine.cbegin(); vc != SurfLine.cend(); ++vc) { - auto A = Geometry::SurfaceFactory::Instance()->processLine(vc->second); + for (const auto &vc : SurfLine) { + auto A = Geometry::SurfaceFactory::Instance()->processLine(vc.second); TSM_ASSERT("Expected a non-null surface from the factory", A); - A->setName(vc->first); - SMap.insert(STYPE::value_type(vc->first, - boost::shared_ptr<Surface>(A.release()))); + A->setName(vc.first); + SMap.insert( + STYPE::value_type(vc.first, boost::shared_ptr<Surface>(A.release()))); } return; @@ -1441,9 +1444,11 @@ private: // Explicitly setting the GluGeometryHanler hexahedron allows // for the correct bounding box calculation. - auto handler = boost::make_shared<GluGeometryHandler>(retVal); - handler->setHexahedron(hex.lbb, hex.lfb, hex.rfb, hex.rbb, hex.lbt, hex.lft, - hex.rft, hex.rbt); + auto handler = boost::make_shared<GeometryHandler>(retVal); + detail::ShapeInfo shapeInfo; + shapeInfo.setHexahedron(hex.lbb, hex.lfb, hex.rfb, hex.rbb, hex.lbt, + hex.lft, hex.rft, hex.rbt); + handler->setShapeInfo(std::move(shapeInfo)); retVal->setGeometryHandler(handler); retVal->setObject(68, ObjHex); diff --git a/Framework/Geometry/test/CenteringGroupTest.h b/Framework/Geometry/test/CenteringGroupTest.h index 16667f7f017bdb7a8e90f539a705be9201534279..8db17e52a86d6f3ccfb7cf88d8cc7fae5b96425b 100644 --- a/Framework/Geometry/test/CenteringGroupTest.h +++ b/Framework/Geometry/test/CenteringGroupTest.h @@ -65,10 +65,10 @@ private: TSM_ASSERT_EQUALS("Unexpected number of operations for " + symbol, ops.size(), expectedOperations.size()); - for (auto it = expectedOperations.begin(); it != expectedOperations.end(); - ++it) { - TSM_ASSERT("Operation " + (*it).identifier() + " not found in " + symbol, - symOpExistsInCollection(*it, ops)); + for (const auto &expectedOperation : expectedOperations) { + TSM_ASSERT("Operation " + expectedOperation.identifier() + + " not found in " + symbol, + symOpExistsInCollection(expectedOperation, ops)); } CenteringGroup_const_sptr centeringGroup = diff --git a/Framework/Geometry/test/ComponentInfoTest.h b/Framework/Geometry/test/ComponentInfoTest.h index f4282e4ef0fc0a1001fd6ed3fa0f80ed8a4ba124..1bb68e32000b35b7496f878fb80cf1d449d08576 100644 --- a/Framework/Geometry/test/ComponentInfoTest.h +++ b/Framework/Geometry/test/ComponentInfoTest.h @@ -107,12 +107,13 @@ std::unique_ptr<Beamline::ComponentInfo> makeSingleBeamlineComponentInfo( boost::make_shared<std::vector<Eigen::Vector3d>>(1, scaleFactor); auto names = boost::make_shared<std::vector<std::string>>(1); using Mantid::Beamline::ComponentType; - auto isStructuredBank = + auto componentType = boost::make_shared<std::vector<ComponentType>>(1, ComponentType::Generic); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>(1); return Kernel::make_unique<Beamline::ComponentInfo>( detectorIndices, detectorRanges, componentIndices, componentRanges, - parentIndices, positions, rotations, scaleFactors, isStructuredBank, - names, -1, -1); + parentIndices, children, positions, rotations, scaleFactors, + componentType, names, -1, -1); } } // namespace @@ -156,10 +157,12 @@ public: using Mantid::Beamline::ComponentType; auto isRectBank = boost::make_shared<std::vector<ComponentType>>( 2, ComponentType::Generic); + auto children = boost::make_shared<std::vector<std::vector<size_t>>>( + 1, std::vector<size_t>(1)); auto internalInfo = Kernel::make_unique<Beamline::ComponentInfo>( detectorIndices, detectorRanges, componentIndices, componentRanges, - parentIndices, positions, rotations, scaleFactors, isRectBank, names, - -1, -1); + parentIndices, children, positions, rotations, scaleFactors, isRectBank, + names, -1, -1); Mantid::Geometry::ObjComponent comp1("component1"); Mantid::Geometry::ObjComponent comp2("component2"); @@ -647,6 +650,47 @@ public: TS_ASSERT_EQUALS(infoScan1->position({0 /*detector index*/, 1}), detectorPos); } + + void test_throws_if_ComponentType_is_not_Quadrilateral() { + auto instrument = + ComponentCreationHelper::createTestInstrumentRectangular2(1, 4); + auto wrappers = InstrumentVisitor::makeWrappers(*instrument); + const auto &componentInfo = std::get<0>(wrappers); + + // find quadrilateral component + size_t structuredIndex = componentInfo->root() - 3; + // Does not throw for valid index + TS_ASSERT_THROWS_NOTHING( + componentInfo->quadrilateralComponent(structuredIndex)); + // Throws for other non quadrilateral component + TS_ASSERT_THROWS( + componentInfo->quadrilateralComponent(componentInfo->root() - 1), + std::runtime_error &); + // Throws for root + TS_ASSERT_THROWS( + componentInfo->quadrilateralComponent(componentInfo->root()), + std::runtime_error &); + // Throws for detector + TS_ASSERT_THROWS(componentInfo->quadrilateralComponent(0), + std::runtime_error &); + } + + void test_QuadrilateralComponent_for_single_rectangular_bank() { + auto instrument = + ComponentCreationHelper::createTestInstrumentRectangular2(1, 4); + auto wrappers = InstrumentVisitor::makeWrappers(*instrument); + const auto &componentInfo = std::get<0>(wrappers); + + // find quadrilateral component + size_t structuredIndex = componentInfo->root() - 3; + auto panel = componentInfo->quadrilateralComponent(structuredIndex); + TS_ASSERT_EQUALS(panel.nX, 4); + TS_ASSERT_EQUALS(panel.nY, 4); + TS_ASSERT_EQUALS(panel.bottomLeft, 0); + TS_ASSERT_EQUALS(panel.bottomRight, 12); + TS_ASSERT_EQUALS(panel.topLeft, 3); + TS_ASSERT_EQUALS(panel.topRight, 15); + } }; #endif /* MANTID_GEOMETRY_COMPONENTINFOTEST_H_ */ diff --git a/Framework/Geometry/test/CompositeBraggScattererTest.h b/Framework/Geometry/test/CompositeBraggScattererTest.h index cb65396fb3992bd3a025ad5fa056ad3f3e16fc7a..0ca949e61226c8a4b5f7ec3e58cffe7bf2e2b3a8 100644 --- a/Framework/Geometry/test/CompositeBraggScattererTest.h +++ b/Framework/Geometry/test/CompositeBraggScattererTest.h @@ -130,9 +130,9 @@ public: spaceGroup->getEquivalentPositions(V3D(0.2, 0.3, 0.4)); CompositeBraggScatterer_sptr coll = CompositeBraggScatterer::create(); - for (auto pos = positions.begin(); pos != positions.end(); ++pos) { + for (auto &position : positions) { std::ostringstream strm; - strm << (*pos); + strm << position; coll->addScatterer(getInitializedScatterer("Si", strm.str(), 0.01267)); } diff --git a/Framework/Geometry/test/CrystalStructureTest.h b/Framework/Geometry/test/CrystalStructureTest.h index 0675a65b79941716912b3905c9df6dc18bcb5665..ccd22be238186667360bad74b1d6dfec6af4e067 100644 --- a/Framework/Geometry/test/CrystalStructureTest.h +++ b/Framework/Geometry/test/CrystalStructureTest.h @@ -29,7 +29,7 @@ public: m_scatterers->addScatterer( BraggScattererFactory::Instance().createScatterer( "IsotropicAtomBraggScatterer", - "{\"Element\":\"Si\",\"Position\":\"0,0,0\"}")); + R"({"Element":"Si","Position":"0,0,0"})")); } void testConstructionSpaceGroup() { diff --git a/Framework/Geometry/test/GroupTransformationTest.h b/Framework/Geometry/test/GroupTransformationTest.h index e583286acb052eadbc62e08dbb1767e9090624d0..8d54c5029f02ff1f7f1f57e89315b74f0933b651 100644 --- a/Framework/Geometry/test/GroupTransformationTest.h +++ b/Framework/Geometry/test/GroupTransformationTest.h @@ -51,9 +51,9 @@ public: */ std::unordered_set<std::string> elements; std::vector<SymmetryOperation> ops = transformed.getSymmetryOperations(); - for (auto op = ops.begin(); op != ops.end(); ++op) { + for (auto &op : ops) { SymmetryElement_sptr el = - SymmetryElementFactory::Instance().createSymElement(*op); + SymmetryElementFactory::Instance().createSymElement(op); // Check for identity SymmetryElementIdentity_sptr identity = diff --git a/Framework/Geometry/test/IndexingUtilsTest.h b/Framework/Geometry/test/IndexingUtilsTest.h index 200bd61e8ec9d09bda9f2c7bc6f25e2f5adc4104..8c28ab07fc5b86e270cd4a97aa8dc897d0864745 100644 --- a/Framework/Geometry/test/IndexingUtilsTest.h +++ b/Framework/Geometry/test/IndexingUtilsTest.h @@ -29,8 +29,8 @@ public: {-0.90478, -0.50667, 0.51072}, {-0.50387, -0.58561, 0.43502}}; // Dec 2011: Change convention for Q = 2 pi / wavelength - for (size_t i = 0; i < q_vectors.size(); i++) - q_vectors[i] *= (2.0 * M_PI); + for (auto &q_vector : q_vectors) + q_vector *= (2.0 * M_PI); return q_vectors; } @@ -232,8 +232,8 @@ public: void test_Optimize_Direction() { std::vector<int> index_values; int correct_indices[] = {1, 4, 2, 0, 1, 3, 0, -1, 0, -1, -2, -3}; - for (size_t i = 0; i < 12; i++) { - index_values.push_back(correct_indices[i]); + for (int correct_index : correct_indices) { + index_values.push_back(correct_index); } std::vector<V3D> q_vectors = getNatroliteQs(); @@ -372,8 +372,8 @@ public: {2.66668320, 5.29605670, 7.9653444}}; std::vector<V3D> directions; - for (size_t i = 0; i < 5; i++) - directions.emplace_back(vectors[i][0], vectors[i][1], vectors[i][2]); + for (auto &vector : vectors) + directions.emplace_back(vector[0], vector[1], vector[2]); double required_tolerance = 0.12; size_t a_index = 0; @@ -410,8 +410,8 @@ public: {2.66668320, 5.29605670, 7.9653444}}; std::vector<V3D> directions; - for (size_t i = 0; i < 5; i++) - directions.emplace_back(vectors[i][0], vectors[i][1], vectors[i][2]); + for (auto &vector : vectors) + directions.emplace_back(vector[0], vector[1], vector[2]); std::vector<V3D> q_vectors = getNatroliteQs(); double required_tolerance = 0.12; @@ -756,8 +756,8 @@ public: TS_ASSERT_DELTA(direction_list[7].Z(), -0.211325, 1e-5); double dot_prod; - for (size_t i = 0; i < direction_list.size(); i++) { - dot_prod = axis.scalar_prod(direction_list[i]); + for (const auto &direction : direction_list) { + dot_prod = axis.scalar_prod(direction); TS_ASSERT_DELTA(dot_prod, 0, 1e-10); } } diff --git a/Framework/Geometry/test/InstrumentDefinitionParserTest.h b/Framework/Geometry/test/InstrumentDefinitionParserTest.h index 45a1802fc948a4760c9e874cc8c640f230380777..ea47421b1f6a457f5525f0afa44f86f278406007 100644 --- a/Framework/Geometry/test/InstrumentDefinitionParserTest.h +++ b/Framework/Geometry/test/InstrumentDefinitionParserTest.h @@ -891,7 +891,7 @@ public: void testLocationsNaming() { std::string locations = - "<locations n-elements=\" 5\" name-count-start=\" 10\" name=\"det\" />"; + R"(<locations n-elements=" 5" name-count-start=" 10" name="det" />)"; detid_t numDetectors = 5; Instrument_sptr instr = loadInstrLocations(locations, numDetectors); @@ -903,7 +903,7 @@ public: void testLocationsStaticValues() { std::string locations = - "<locations n-elements=\"5\" x=\" 1.0\" y=\" 2.0\" z=\" 3.0\" />"; + R"(<locations n-elements="5" x=" 1.0" y=" 2.0" z=" 3.0" />)"; detid_t numDetectors = 5; Instrument_sptr instr = loadInstrLocations(locations, numDetectors); @@ -986,13 +986,13 @@ public: void testLocationsInvalidNoElements() { std::string locations = - "<locations n-elements=\"0\" t=\"0.0\" t-end=\"180.0\" />"; + R"(<locations n-elements="0" t="0.0" t-end="180.0" />)"; detid_t numDetectors = 2; TS_ASSERT_THROWS(loadInstrLocations(locations, numDetectors, true), Exception::InstrumentDefinitionError); - locations = "<locations n-elements=\"-1\" t=\"0.0\" t-end=\"180.0\" />"; + locations = R"(<locations n-elements="-1" t="0.0" t-end="180.0" />)"; TS_ASSERT_THROWS(loadInstrLocations(locations, numDetectors, true), Exception::InstrumentDefinitionError); @@ -1000,28 +1000,28 @@ public: void testLocationsNotANumber() { std::string locations = - "<locations n-elements=\"2\" t=\"0.0\" t-end=\"180.x\" />"; + R"(<locations n-elements="2" t="0.0" t-end="180.x" />)"; detid_t numDetectors = 2; TS_ASSERT_THROWS_ANYTHING( loadInstrLocations(locations, numDetectors, true)); - locations = "<locations n-elements=\"2\" t=\"0.x\" t-end=\"180.0\" />"; + locations = R"(<locations n-elements="2" t="0.x" t-end="180.0" />)"; TS_ASSERT_THROWS_ANYTHING( loadInstrLocations(locations, numDetectors, true)); - locations = "<locations n-elements=\"x\" t=\"0.0\" t-end=\"180.0\" />"; + locations = R"(<locations n-elements="x" t="0.0" t-end="180.0" />)"; TS_ASSERT_THROWS_ANYTHING( loadInstrLocations(locations, numDetectors, true)); - locations = "<locations n-elements=\"2\" name-count-start=\"x\"/>"; + locations = R"(<locations n-elements="2" name-count-start="x"/>)"; TS_ASSERT_THROWS_ANYTHING( loadInstrLocations(locations, numDetectors, true)); } void testLocationsNoCorrespondingStartAttr() { - std::string locations = "<locations n-elements=\"2\" t-end=\"180.0\" />"; + std::string locations = R"(<locations n-elements="2" t-end="180.0" />)"; detid_t numDetectors = 2; TS_ASSERT_THROWS(loadInstrLocations(locations, numDetectors, true), diff --git a/Framework/Geometry/test/InstrumentVisitorTest.h b/Framework/Geometry/test/InstrumentVisitorTest.h index 3a656cf489f62bec3f39964b3140665e740971bc..dbd6ecf5eec65b0b8c3274f170ba363fae1c086d 100644 --- a/Framework/Geometry/test/InstrumentVisitorTest.h +++ b/Framework/Geometry/test/InstrumentVisitorTest.h @@ -244,8 +244,7 @@ public: void test_visitor_component_ranges_check() { // Create a very basic instrument to visit auto visitee = createMinimalInstrument(V3D(0, 0, 0) /*source pos*/, - V3D(10, 0, 0) /*sample pos*/ - , + V3D(10, 0, 0) /*sample pos*/, V3D(11, 0, 0) /*detector position*/); InstrumentVisitor visitor(makeParameterized(visitee)); @@ -441,6 +440,57 @@ public: TS_ASSERT_EQUALS(detScaling, compInfo->scaleFactor(0)); TS_ASSERT_EQUALS(instrScaling, compInfo->scaleFactor(compInfo->root())); } + + void test_instrumentTreeWithMinimalInstrument() { + /** This should produce the following instrument tree + * 3 + * / | \ + *0 1 2 + */ + auto instrument = + createMinimalInstrument(V3D(0, 0, 0), V3D(0, 0, 1), V3D(0, 0, 10)); + auto visitor = InstrumentVisitor(instrument); + + visitor.walkInstrument(); + + auto componentInfo = visitor.componentInfo(); + auto root = componentInfo->root(); + TS_ASSERT_EQUALS(componentInfo->children(0).size(), 0); + TS_ASSERT_EQUALS(componentInfo->children(1).size(), 0); + TS_ASSERT_EQUALS(componentInfo->children(2).size(), 0); + TS_ASSERT_EQUALS(componentInfo->children(root).size(), 3); + } + + void test_instrumentTreeWithComplexInstrument() { + /** This should produce the following instrument tree + * 16 + * / / \ \ + * 14 15 10 13 + * / \ / \ + * 8 9 11 12 + * / \ / \ / \ / \ + * 0 1 2 3 4 5 6 7 + */ + auto instrument = createTestInstrumentRectangular2(2, 2); + auto visitor = InstrumentVisitor(instrument); + + visitor.walkInstrument(); + + auto componentInfo = visitor.componentInfo(); + auto root = componentInfo->root(); + for (int i = 0; i < 8; i++) + TS_ASSERT_EQUALS(componentInfo->children(i).size(), 0); + + TS_ASSERT_EQUALS(componentInfo->children(root).size(), 4); + TS_ASSERT_EQUALS(componentInfo->children(8).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(9).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(11).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(12).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(10).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(13).size(), 2); + TS_ASSERT_EQUALS(componentInfo->children(14).size(), 0); + TS_ASSERT_EQUALS(componentInfo->children(15).size(), 0); + } }; class InstrumentVisitorTestPerformance : public CxxTest::TestSuite { diff --git a/Framework/Geometry/test/MDGeometryXMLParserTest.h b/Framework/Geometry/test/MDGeometryXMLParserTest.h index 00c7187b4343efbd03108803c51eb56fa5d5183d..4137571754c48e63ad505b1766240c72feaae504 100644 --- a/Framework/Geometry/test/MDGeometryXMLParserTest.h +++ b/Framework/Geometry/test/MDGeometryXMLParserTest.h @@ -12,7 +12,7 @@ public: const std::string &yDimensionIdMapping, const std::string &zDimensionIdMapping, const std::string &tDimensionIdMapping) { - return std::string("<?xml version=\"1.0\" encoding=\"utf-8\"?>") + + return std::string(R"(<?xml version="1.0" encoding="utf-8"?>)") + "<DimensionSet>" + "<Dimension ID=\"en\">" + "<Name>Energy</Name>" + "<UpperBounds>150</UpperBounds>" + "<LowerBounds>0</LowerBounds>" + "<NumberOfBins>1</NumberOfBins>" + "</Dimension>" + diff --git a/Framework/Geometry/test/MeshObjectTest.h b/Framework/Geometry/test/MeshObjectTest.h index 61f176997572f7c6950fd34de3c94f4b7197bb22..65b2c6ac1e6a99fc962a5183011c318caf581cc2 100644 --- a/Framework/Geometry/test/MeshObjectTest.h +++ b/Framework/Geometry/test/MeshObjectTest.h @@ -5,7 +5,7 @@ #include "MantidGeometry/Math/Algebra.h" #include "MantidGeometry/Objects/Track.h" -#include "MantidGeometry/Rendering/CacheGeometryHandler.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidKernel/make_unique.h" #include "MantidKernel/Material.h" diff --git a/Framework/Geometry/test/MockObjects.h b/Framework/Geometry/test/MockObjects.h index 3ac5a0a72781f02b582630ae263fce3d5ffc37f5..168b8db8a002d858eba0ece05e8270c6e9105826 100644 --- a/Framework/Geometry/test/MockObjects.h +++ b/Framework/Geometry/test/MockObjects.h @@ -66,7 +66,9 @@ public: MOCK_CONST_METHOD0(getDetector, Geometry::IDetector_const_sptr()); MOCK_CONST_METHOD0(getInstrument, Geometry::Instrument_const_sptr()); MOCK_CONST_METHOD0(getRunNumber, int()); + MOCK_CONST_METHOD0(getPeakNumber, int()); MOCK_METHOD1(setRunNumber, void(int m_RunNumber)); + MOCK_METHOD1(setPeakNumber, void(int m_PeakNumber)); MOCK_CONST_METHOD0(getMonitorCount, double()); MOCK_METHOD1(setMonitorCount, void(double m_MonitorCount)); MOCK_CONST_METHOD0(getH, double()); @@ -90,6 +92,7 @@ public: MOCK_METHOD1(setWavelength, void(double wavelength)); MOCK_CONST_METHOD0(getWavelength, double()); MOCK_CONST_METHOD0(getScattering, double()); + MOCK_CONST_METHOD0(getAzimuthal, double()); MOCK_CONST_METHOD0(getDSpacing, double()); MOCK_CONST_METHOD0(getTOF, double()); MOCK_CONST_METHOD0(getInitialEnergy, double()); diff --git a/Framework/Geometry/test/ObjCompAssemblyTest.h b/Framework/Geometry/test/ObjCompAssemblyTest.h index 4956b67a238a9c07931b3cb2d31e8c9826599f65..1c823495acf779fdadc2989c6e5bb601eda57139 100644 --- a/Framework/Geometry/test/ObjCompAssemblyTest.h +++ b/Framework/Geometry/test/ObjCompAssemblyTest.h @@ -337,8 +337,8 @@ public: std::stringstream obj_str; obj_str << "<cylinder id=\"stick\">"; obj_str << "<centre-of-bottom-base "; - obj_str << "x=\"0\" y=\"0\" z=\"0\" />"; - obj_str << "<axis x=\"0\" y=\"1\" z=\"0\" /> "; + obj_str << R"(x="0" y="0" z="0" />)"; + obj_str << R"(<axis x="0" y="1" z="0" /> )"; obj_str << "<radius val=\"0.1\" />"; obj_str << "<height val=\"0.2\" />"; obj_str << "</cylinder>"; @@ -359,25 +359,22 @@ public: boost::shared_ptr<IObject> shape = bank.createOutline(); TS_ASSERT(shape); - int otype; + detail::ShapeInfo::GeometryShape otype; std::vector<V3D> vectors; double radius, height; shape->GetObjectGeom(otype, vectors, radius, height); - TS_ASSERT_EQUALS(otype, 6); + TS_ASSERT_EQUALS(otype, detail::ShapeInfo::GeometryShape::CYLINDER); TS_ASSERT_EQUALS(radius, 0.1); TS_ASSERT_EQUALS(height, 0.6); } void test_fail_CreateOutline_for_wrong_component_type() { std::stringstream obj_str; - obj_str << "<segmented-cylinder id=\"stick\">"; - obj_str << "<centre-of-bottom-base "; - obj_str << "x=\"0\" y=\"0\" z=\"0\" />"; - obj_str << "<axis x=\"0\" y=\"1\" z=\"0\" /> "; + obj_str << "<sphere id=\"A\">"; + obj_str << "<centre x=\"4.1\" y=\"2.1\" z=\"8.1\" />"; obj_str << "<radius val=\"0.1\" />"; - obj_str << "<height val=\"0.2\" />"; - obj_str << "</segmented-cylinder>"; + obj_str << "</sphere>"; auto s = Mantid::Geometry::ShapeFactory().createShape(obj_str.str()); ObjCompAssembly bank("BankName"); diff --git a/Framework/Geometry/test/ParObjCompAssemblyTest.h b/Framework/Geometry/test/ParObjCompAssemblyTest.h index 7710e6233bbcea6b68ab1c83487f32ac45da4fcc..6584f674df8c574f8acada58f18f67ec5496da07 100644 --- a/Framework/Geometry/test/ParObjCompAssemblyTest.h +++ b/Framework/Geometry/test/ParObjCompAssemblyTest.h @@ -107,13 +107,12 @@ public: TS_ASSERT_EQUALS(pcomp.type(), "ObjCompAssembly"); } - void testCreateOutlineCylinder() { std::stringstream obj_str; obj_str << "<cylinder id=\"stick\">"; obj_str << "<centre-of-bottom-base "; - obj_str << "x=\"0\" y=\"0\" z=\"0\" />"; - obj_str << "<axis x=\"0\" y=\"1\" z=\"0\" /> "; + obj_str << R"(x="0" y="0" z="0" />)"; + obj_str << R"(<axis x="0" y="1" z="0" /> )"; obj_str << "<radius val=\"0.1\" />"; obj_str << "<height val=\"0.2\" />"; obj_str << "</cylinder>"; @@ -135,12 +134,12 @@ public: boost::shared_ptr<IObject> shape = bank.createOutline(); TS_ASSERT(shape); - int otype; + detail::ShapeInfo::GeometryShape otype; std::vector<V3D> vectors; double radius, height; shape->GetObjectGeom(otype, vectors, radius, height); - TS_ASSERT_EQUALS(otype, 6); + TS_ASSERT_EQUALS(otype, detail::ShapeInfo::GeometryShape::CYLINDER); TS_ASSERT_EQUALS(radius, 0.1); TS_ASSERT_EQUALS(height, 0.6); diff --git a/Framework/Geometry/test/ParameterMapTest.h b/Framework/Geometry/test/ParameterMapTest.h index bfa297487d907f86a2a9b9537ce297967cdc4084..cac00aafd7ec8ca66623aece35a6bea3c13fd7a1 100644 --- a/Framework/Geometry/test/ParameterMapTest.h +++ b/Framework/Geometry/test/ParameterMapTest.h @@ -513,7 +513,7 @@ public: Parameter_sptr fetchedValue = pmap.getByType(comp.get(), ParameterMap::pDouble()); TSM_ASSERT("Should not be able to find a double type parameter", - fetchedValue == NULL); + fetchedValue == nullptr); } void test_lookup_via_type() { @@ -551,7 +551,7 @@ public: // Find it via the component Parameter_sptr fetchedValue = pmap.getRecursiveByType(component.get(), ParameterMap::pBool()); - TS_ASSERT(fetchedValue != NULL); + TS_ASSERT(fetchedValue != nullptr); TS_ASSERT_EQUALS("A", fetchedValue->name()); TS_ASSERT_EQUALS(ParameterMap::pBool(), fetchedValue->type()); TS_ASSERT_EQUALS(true, fetchedValue->value<bool>()); @@ -568,7 +568,7 @@ public: // Find it via the child Parameter_sptr fetchedValue = pmap.getRecursiveByType(childComponent.get(), ParameterMap::pBool()); - TS_ASSERT(fetchedValue != NULL); + TS_ASSERT(fetchedValue != nullptr); TS_ASSERT_EQUALS("A", fetchedValue->name()); TS_ASSERT_EQUALS(ParameterMap::pBool(), fetchedValue->type()); TS_ASSERT_EQUALS(true, fetchedValue->value<bool>()); @@ -589,7 +589,7 @@ public: // Find it via the child Parameter_sptr fetchedValue = pmap.getRecursiveByType(childComponent.get(), ParameterMap::pBool()); - TS_ASSERT(fetchedValue != NULL); + TS_ASSERT(fetchedValue != nullptr); TSM_ASSERT_EQUALS( "Has not searched through parameters with the correct priority", "A", fetchedValue->name()); @@ -639,7 +639,7 @@ private: const ValueType &newValue) { ParameterMap pmap; const std::string name = "Parameter"; - pmap.add<ValueType>(type, m_testInstrument.get(), name, origValue, NULL); + pmap.add<ValueType>(type, m_testInstrument.get(), name, origValue, nullptr); ParameterMap copy(pmap); // invoke copy constructor diff --git a/Framework/Geometry/test/PointGroupTest.h b/Framework/Geometry/test/PointGroupTest.h index 5976f6c135122be341b9dcabf91d0cccbf041fb3..1165941734bb33303285c5758584e801ef92d734 100644 --- a/Framework/Geometry/test/PointGroupTest.h +++ b/Framework/Geometry/test/PointGroupTest.h @@ -289,11 +289,11 @@ public: std::vector<PointGroup_sptr> pointgroups = getAllPointGroups(); - for (size_t i = 0; i < pointgroups.size(); ++i) { - TSM_ASSERT_EQUALS(pointgroups[i]->getSymbol() + + for (auto &pointgroup : pointgroups) { + TSM_ASSERT_EQUALS(pointgroup->getSymbol() + ": Unexpected crystal system.", - pointgroups[i]->crystalSystem(), - crystalSystemsMap[pointgroups[i]->getSymbol()]); + pointgroup->crystalSystem(), + crystalSystemsMap[pointgroup->getSymbol()]); } } @@ -446,8 +446,8 @@ private: t.reset(); int h = 0; for (size_t i = 0; i < 1000; ++i) { - for (auto hkl = hkls.begin(); hkl != hkls.end(); ++hkl) { - bool eq = pointGroup->isEquivalent(base, *hkl); + for (auto &hkl : hkls) { + bool eq = pointGroup->isEquivalent(base, hkl); if (eq) { ++h; } diff --git a/Framework/Geometry/test/ReflectionConditionTest.h b/Framework/Geometry/test/ReflectionConditionTest.h index c8841ae0fee41586c4868b1a3a63d6d9acdd669d..c34005420456177dbab7700f19808b5b2ad2f4ba 100644 --- a/Framework/Geometry/test/ReflectionConditionTest.h +++ b/Framework/Geometry/test/ReflectionConditionTest.h @@ -58,11 +58,11 @@ public: centeringSymbols.insert("H"); std::vector<ReflectionCondition_sptr> refs = getAllReflectionConditions(); - for (auto it = refs.begin(); it != refs.end(); ++it) { - TSM_ASSERT_DIFFERS((*it)->getSymbol(), - centeringSymbols.find((*it)->getSymbol()), + for (auto &ref : refs) { + TSM_ASSERT_DIFFERS(ref->getSymbol(), + centeringSymbols.find(ref->getSymbol()), centeringSymbols.end()); - centeringSymbols.erase((*it)->getSymbol()); + centeringSymbols.erase(ref->getSymbol()); } // All centering symbols are present if the set is empty. diff --git a/Framework/Geometry/test/ShapeFactoryTest.h b/Framework/Geometry/test/ShapeFactoryTest.h index b6335b198e542f5363861a861a17ec73d67e64aa..3cef5552e50838db6c60fb216db279ac01a12516 100644 --- a/Framework/Geometry/test/ShapeFactoryTest.h +++ b/Framework/Geometry/test/ShapeFactoryTest.h @@ -23,13 +23,13 @@ class ShapeFactoryTest : public CxxTest::TestSuite { public: void testCuboid() { std::string xmlShape = "<cuboid id=\"shape\"> "; - xmlShape += "<left-front-bottom-point x=\"0.005\" y=\"-0.1\" z=\"0.0\" /> "; + xmlShape += R"(<left-front-bottom-point x="0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<left-front-top-point x=\"0.005\" y=\"-0.1\" z=\"0.0001\" /> "; + R"(<left-front-top-point x="0.005" y="-0.1" z="0.0001" /> )"; xmlShape += - "<left-back-bottom-point x=\"-0.005\" y=\"-0.1\" z=\"0.0\" /> "; + R"(<left-back-bottom-point x="-0.005" y="-0.1" z="0.0" /> )"; xmlShape += - "<right-front-bottom-point x=\"0.005\" y=\"0.1\" z=\"0.0\" /> "; + R"(<right-front-bottom-point x="0.005" y="0.1" z="0.0" /> )"; xmlShape += "</cuboid> "; xmlShape += "<algebra val=\"shape\" /> "; @@ -48,8 +48,8 @@ public: xmlShape += "<height val=\"0.2\" />"; xmlShape += "<width val=\"0.1\" />"; xmlShape += "<depth val=\"0.4\" />"; - xmlShape += "<centre x=\"1.0\" y=\"1.0\" z=\"1.0\" />"; - xmlShape += "<axis x=\"1\" y=\"0\" z=\"0\" />"; // Note non-default axis. + xmlShape += R"(<centre x="1.0" y="1.0" z="1.0" />)"; + xmlShape += R"(<axis x="1" y="0" z="0" />)"; // Note non-default axis. xmlShape += "</cuboid>"; xmlShape += "<algebra val=\"some-shape\" />"; @@ -80,7 +80,7 @@ public: xmlShape += "<height val=\"0.2\" />"; xmlShape += "<width val=\"0.1\" />"; xmlShape += "<depth val=\"0.4\" />"; - xmlShape += "<centre x=\"1.0\" y=\"1.0\" z=\"1.0\" />"; + xmlShape += R"(<centre x="1.0" y="1.0" z="1.0" />)"; xmlShape += "</cuboid>"; xmlShape += "<algebra val=\"some-shape\" />"; @@ -111,7 +111,7 @@ public: xmlShape += "<height val=\"0.2\" />"; xmlShape += "<width val=\"0.1\" />"; xmlShape += "<depth val=\"0.4\" />"; - xmlShape += "<axis x=\"0\" y=\"0\" z=\"1\" />"; + xmlShape += R"(<axis x="0" y="0" z="1" />)"; xmlShape += "</cuboid>"; xmlShape += "<algebra val=\"some-shape\" />"; @@ -139,10 +139,10 @@ public: void testRelayShapeXML() { // Create a cuboid. std::string xmlShape = "<cuboid id=\"shape\"> "; - xmlShape += "<left-front-bottom-point x=\"0.005\" y=\"-0.1\" z=\"0.0\"/> "; - xmlShape += "<left-front-top-point x=\"0.005\" y=\"-0.1\" z=\"0.0001\"/> "; - xmlShape += "<left-back-bottom-point x=\"-0.005\" y=\"-0.1\" z=\"0.0\"/> "; - xmlShape += "<right-front-bottom-point x=\"0.005\" y=\"0.1\" z=\"0.0\"/> "; + xmlShape += R"(<left-front-bottom-point x="0.005" y="-0.1" z="0.0"/> )"; + xmlShape += R"(<left-front-top-point x="0.005" y="-0.1" z="0.0001"/> )"; + xmlShape += R"(<left-back-bottom-point x="-0.005" y="-0.1" z="0.0"/> )"; + xmlShape += R"(<right-front-bottom-point x="0.005" y="0.1" z="0.0"/> )"; xmlShape += "</cuboid> "; xmlShape += "<algebra val=\"shape\"/> "; @@ -157,14 +157,14 @@ public: void testHexahedron() { std::string xmlShape = "<hexahedron id=\"shape\"> "; - xmlShape += "<left-back-bottom-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<left-front-bottom-point x=\"1.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<right-front-bottom-point x=\"1.0\" y=\"1.0\" z=\"0.0\" /> "; - xmlShape += "<right-back-bottom-point x=\"0.0\" y=\"1.0\" z=\"0.0\" /> "; - xmlShape += "<left-back-top-point x=\"0.0\" y=\"0.0\" z=\"2.0\" /> "; - xmlShape += "<left-front-top-point x=\"0.5\" y=\"0.0\" z=\"2.0\" /> "; - xmlShape += "<right-front-top-point x=\"0.5\" y=\"0.5\" z=\"2.0\" /> "; - xmlShape += "<right-back-top-point x=\"0.0\" y=\"0.5\" z=\"2.0\" /> "; + xmlShape += R"(<left-back-bottom-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<left-front-bottom-point x="1.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<right-front-bottom-point x="1.0" y="1.0" z="0.0" /> )"; + xmlShape += R"(<right-back-bottom-point x="0.0" y="1.0" z="0.0" /> )"; + xmlShape += R"(<left-back-top-point x="0.0" y="0.0" z="2.0" /> )"; + xmlShape += R"(<left-front-top-point x="0.5" y="0.0" z="2.0" /> )"; + xmlShape += R"(<right-front-top-point x="0.5" y="0.5" z="2.0" /> )"; + xmlShape += R"(<right-back-top-point x="0.0" y="0.5" z="2.0" /> )"; xmlShape += "</hexahedron> "; xmlShape += "<algebra val=\"shape\" /> "; @@ -180,21 +180,21 @@ public: void testHexahedron2() { std::string xmlShape = "<hexahedron id=\"shape\"> "; xmlShape += - "<left-front-bottom-point x=\"0.0\" y=\"-0.0031\" z=\"-0.037\" /> "; + R"(<left-front-bottom-point x="0.0" y="-0.0031" z="-0.037" /> )"; xmlShape += - "<right-front-bottom-point x=\"0.0\" y=\"0.0031\" z=\"-0.037\" /> "; + R"(<right-front-bottom-point x="0.0" y="0.0031" z="-0.037" /> )"; xmlShape += - "<left-front-top-point x=\"0.0\" y=\"-0.0104\" z=\"0.037\" /> "; + R"(<left-front-top-point x="0.0" y="-0.0104" z="0.037" /> )"; xmlShape += - "<right-front-top-point x=\"0.0\" y=\"0.0104\" z=\"0.037\" /> "; + R"(<right-front-top-point x="0.0" y="0.0104" z="0.037" /> )"; xmlShape += - "<left-back-bottom-point x=\"0.005\" y=\"-0.0031\" z=\"-0.037\" /> "; + R"(<left-back-bottom-point x="0.005" y="-0.0031" z="-0.037" /> )"; xmlShape += - "<right-back-bottom-point x=\"0.005\" y=\"0.0031\" z=\"-0.037\" /> "; + R"(<right-back-bottom-point x="0.005" y="0.0031" z="-0.037" /> )"; xmlShape += - "<left-back-top-point x=\"0.005\" y=\"-0.0104\" z=\"0.037\" /> "; + R"(<left-back-top-point x="0.005" y="-0.0104" z="0.037" /> )"; xmlShape += - "<right-back-top-point x=\"0.005\" y=\"0.0104\" z=\"0.037\" /> "; + R"(<right-back-top-point x="0.005" y="0.0104" z="0.037" /> )"; xmlShape += "</hexahedron> "; xmlShape += "<algebra val=\"shape\" /> "; @@ -209,9 +209,9 @@ public: void testTaperedGuideDefaults() { std::string xmlShape = "<tapered-guide id=\"shape\">"; - xmlShape += "<aperture-start height=\"2.0\" width=\"2.0\" />"; + xmlShape += R"(<aperture-start height="2.0" width="2.0" />)"; xmlShape += "<length val=\"2.0\" />"; - xmlShape += "<aperture-end height=\"4.0\" width=\"4.0\" />"; + xmlShape += R"(<aperture-end height="4.0" width="4.0" />)"; xmlShape += "</tapered-guide>"; xmlShape += "<algebra val=\"shape\"/>"; @@ -242,11 +242,11 @@ public: void testTaperedGuideDifferentAxisAndCentre() { std::string xmlShape = "<tapered-guide id=\"shape\">"; - xmlShape += "<aperture-start height=\"2.0\" width=\"2.0\" />"; + xmlShape += R"(<aperture-start height="2.0" width="2.0" />)"; xmlShape += "<length val=\"2.0\" />"; - xmlShape += "<aperture-end height=\"4.0\" width=\"4.0\" />"; - xmlShape += "<centre x=\"0.0\" y=\"0.0\" z=\"1.0\" />"; - xmlShape += "<axis x=\"1.0\" y=\"0.0\" z=\"0\" />"; + xmlShape += R"(<aperture-end height="4.0" width="4.0" />)"; + xmlShape += R"(<centre x="0.0" y="0.0" z="1.0" />)"; + xmlShape += R"(<axis x="1.0" y="0.0" z="0" />)"; xmlShape += "</tapered-guide>"; xmlShape += "<algebra val=\"shape\"/>"; @@ -278,7 +278,7 @@ public: void testSphere() { // algebra line is essential std::string xmlShape = "<sphere id=\"shape\"> "; - xmlShape += "<centre x=\"4.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="4.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -295,11 +295,11 @@ public: void testTwoSpheres() { // algebra line is essential std::string xmlShape = "<sphere id=\"shape1\"> "; - xmlShape += "<centre x=\"4.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="4.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; xmlShape += "<sphere id=\"shape2\"> "; - xmlShape += "<centre x=\"2.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="2.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"shape1 : shape2\" /> "; @@ -318,11 +318,11 @@ public: void testTwoSpheresNoAlgebraString() { // algebra line is essential std::string xmlShape = "<sphere id=\"shape1\"> "; - xmlShape += "<centre x=\"4.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="4.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; xmlShape += "<sphere id=\"shape2\"> "; - xmlShape += "<centre x=\"2.1\" y=\"2.1\" z=\"8.1\" /> "; + xmlShape += R"(<centre x="2.1" y="2.1" z="8.1" /> )"; xmlShape += "<radius val=\"3.2\" /> "; xmlShape += "</sphere>"; @@ -363,8 +363,8 @@ public: void testCylinder() { // algebra line is essential std::string xmlShape = "<cylinder id=\"shape\"> "; - xmlShape += "<centre-of-bottom-base x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre-of-bottom-base x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "<height val=\"3\" /> "; xmlShape += "</cylinder>"; @@ -382,8 +382,8 @@ public: void testCylinderNoAlgebraString() { // algebra line is essential std::string xmlShape = "<cylinder id=\"shape\"> "; - xmlShape += "<centre-of-bottom-base x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre-of-bottom-base x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "<height val=\"3\" /> "; xmlShape += "</cylinder>"; @@ -400,8 +400,8 @@ public: void testCylinderTwoAlgebraStrings() { // algebra line is essential std::string xmlShape = "<cylinder id=\"shape\"> "; - xmlShape += "<centre-of-bottom-base x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre-of-bottom-base x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "<height val=\"3\" /> "; xmlShape += "</cylinder>"; @@ -506,8 +506,8 @@ public: void testInfiniteCylinder() { // algebra line is essential std::string xmlShape = "<infinite-cylinder id=\"shape\"> "; - xmlShape += "<centre x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<centre x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<radius val=\"0.1\" /> "; xmlShape += "</infinite-cylinder>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -524,8 +524,8 @@ public: void testCone() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height val=\"4\" /> "; xmlShape += "</cone>"; @@ -543,8 +543,8 @@ public: void testConeUseDirectStringArgument() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height val=\"4\" /> "; xmlShape += "</cone>"; @@ -562,13 +562,13 @@ public: void testComplement() { std::string xmlShape = "<cylinder id=\"stick\"> "; - xmlShape += "<centre-of-bottom-base x=\"-0.5\" y=\"0.0\" z=\"0.0\" />"; - xmlShape += "<axis x=\"1.0\" y=\"0.0\" z=\"0.0\" />"; + xmlShape += R"(<centre-of-bottom-base x="-0.5" y="0.0" z="0.0" />)"; + xmlShape += R"(<axis x="1.0" y="0.0" z="0.0" />)"; xmlShape += "<radius val=\"0.05\" />"; xmlShape += "<height val=\"1.0\" />"; xmlShape += "</cylinder>"; xmlShape += "<sphere id=\"some-sphere\">"; - xmlShape += "<centre x=\"0.0\" y=\"0.0\" z=\"0.0\" />"; + xmlShape += R"(<centre x="0.0" y="0.0" z="0.0" />)"; xmlShape += "<radius val=\"0.5\" />"; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"some-sphere # stick\" />"; @@ -589,8 +589,8 @@ public: void testNoneExistingShape() { // algebra line is essential std::string xmlShape = "<c5one id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height val=\"4\" /> "; xmlShape += "</c5one>"; @@ -604,8 +604,8 @@ public: void testTypingErrorInSubElement() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<heeight val=\"4\" /> "; xmlShape += "</cone>"; @@ -619,8 +619,8 @@ public: void testTypingErrorInAttribute() { // algebra line is essential std::string xmlShape = "<cone id=\"shape\"> "; - xmlShape += "<tip-point x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; - xmlShape += "<axis x=\"0.0\" y=\"0.0\" z=\"1\" /> "; + xmlShape += R"(<tip-point x="0.0" y="0.0" z="0.0" /> )"; + xmlShape += R"(<axis x="0.0" y="0.0" z="1" /> )"; xmlShape += "<angle val=\"8.1\" /> "; xmlShape += "<height vaal=\"4\" /> "; xmlShape += "</cone>"; diff --git a/Framework/Geometry/test/ShapeInfoTest.h b/Framework/Geometry/test/ShapeInfoTest.h new file mode 100644 index 0000000000000000000000000000000000000000..573a8b5f8394143442be882c2cdbe7de7b8795be --- /dev/null +++ b/Framework/Geometry/test/ShapeInfoTest.h @@ -0,0 +1,138 @@ +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidKernel/V3D.h" +#include <cxxtest/TestSuite.h> + +using Mantid::Kernel::V3D; +using namespace Mantid::Geometry::detail; + +class ShapeInfoTest : public CxxTest::TestSuite { +private: + ShapeInfo m_shapeInfo; + +public: + void testConstructEmptyInitiazesEverythingZero() { + TS_ASSERT(m_shapeInfo.points().size() == 0); + TS_ASSERT(m_shapeInfo.height() == 0); + TS_ASSERT(m_shapeInfo.radius() == 0); + TS_ASSERT(m_shapeInfo.shape() == ShapeInfo::GeometryShape::NOSHAPE); + } + + void testSetSphere() { + V3D center(0, 0, 0); + double radius = 10; + m_shapeInfo.setSphere(center, radius); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), ShapeInfo::GeometryShape::SPHERE); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), radius); + TS_ASSERT_EQUALS(m_shapeInfo.height(), 0); + TS_ASSERT_EQUALS(m_shapeInfo.points().size(), 1); + TS_ASSERT_EQUALS(m_shapeInfo.points()[0], center); + } + + void testSetCuboid() { + V3D p1(0, 0, 0); + V3D p2(0, 0, 1); + V3D p3(0, 1, 0); + V3D p4(0, 1, 1); + + m_shapeInfo.setCuboid(p1, p2, p3, p4); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), ShapeInfo::GeometryShape::CUBOID); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), 0); + TS_ASSERT_EQUALS(m_shapeInfo.height(), 0); + TS_ASSERT_EQUALS(m_shapeInfo.points().size(), 4); + TS_ASSERT_EQUALS(m_shapeInfo.points(), (std::vector<V3D>{p1, p2, p3, p4})); + } + + void testSetHexahedron() { + V3D p1(0, 0, 0); + V3D p2(0, 0, 1); + V3D p3(0, 1, 0); + V3D p4(0, 1, 1); + V3D p5(1, 0, 0); + V3D p6(1, 0, 1); + V3D p7(1, 1, 0); + V3D p8(1, 1, 1); + + m_shapeInfo.setHexahedron(p1, p2, p3, p4, p5, p6, p7, p8); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), ShapeInfo::GeometryShape::HEXAHEDRON); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), 0); + TS_ASSERT_EQUALS(m_shapeInfo.height(), 0); + TS_ASSERT_EQUALS(m_shapeInfo.points().size(), 8); + TS_ASSERT_EQUALS(m_shapeInfo.points(), + (std::vector<V3D>{p1, p2, p3, p4, p5, p6, p7, p8})); + } + + void testSetCone() { + V3D center(0, 0, 0); + V3D axis(1, 0, 0); + double radius = 10; + double height = 5; + m_shapeInfo.setCone(center, axis, radius, height); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), ShapeInfo::GeometryShape::CONE); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), radius); + TS_ASSERT_EQUALS(m_shapeInfo.height(), height); + TS_ASSERT_EQUALS(m_shapeInfo.points().size(), 2); + TS_ASSERT_EQUALS(m_shapeInfo.points()[0], center); + TS_ASSERT_EQUALS(m_shapeInfo.points()[1], axis); + } + + void testSetCylinder() { + V3D center(0, 0, 0); + V3D axis(1, 0, 0); + double radius = 10; + double height = 5; + m_shapeInfo.setCylinder(center, axis, radius, height); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), ShapeInfo::GeometryShape::CYLINDER); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), radius); + TS_ASSERT_EQUALS(m_shapeInfo.height(), height); + TS_ASSERT_EQUALS(m_shapeInfo.points().size(), 2); + TS_ASSERT_EQUALS(m_shapeInfo.points()[0], center); + TS_ASSERT_EQUALS(m_shapeInfo.points()[1], axis); + } + + void testGetObjectGeometry() { + V3D center(0, 0, 0); + double radius = 10; + m_shapeInfo.setSphere(center, radius); + + ShapeInfo::GeometryShape tshape; + std::vector<V3D> tpoints; + double theight; + double tradius; + + m_shapeInfo.getObjectGeometry(tshape, tpoints, tradius, theight); + TS_ASSERT_EQUALS(tradius, radius); + TS_ASSERT(theight == 0); + TS_ASSERT(tpoints.size() == 1); + TS_ASSERT_EQUALS(tpoints[0], center); + TS_ASSERT_EQUALS(tshape, ShapeInfo::GeometryShape::SPHERE); + } + + void testCopyConstructor() { + V3D center(0, 2, 1); + double radius = 10; + m_shapeInfo.setSphere(center, radius); + + ShapeInfo shapeInfoCopy(m_shapeInfo); + + TS_ASSERT_EQUALS(m_shapeInfo.shape(), shapeInfoCopy.shape()); + TS_ASSERT_EQUALS(m_shapeInfo.radius(), shapeInfoCopy.radius()); + TS_ASSERT_EQUALS(m_shapeInfo.height(), shapeInfoCopy.height()); + TS_ASSERT_EQUALS(m_shapeInfo.points(), shapeInfoCopy.points()); + } + + void testEquality() { + V3D center(0, 2, 1); + double radius = 10; + m_shapeInfo.setSphere(center, radius); + ShapeInfo shapeInfo2, shapeInfo3; + shapeInfo2.setSphere(center, radius); + shapeInfo3.setCuboid(V3D(), V3D(), V3D(), V3D()); + TS_ASSERT_EQUALS(shapeInfo2, m_shapeInfo); + TS_ASSERT_DIFFERS(shapeInfo3, m_shapeInfo); + } +}; diff --git a/Framework/Geometry/test/SpaceGroupTest.h b/Framework/Geometry/test/SpaceGroupTest.h index 4aa4df38b140568802a7c4095c2ae6f55e64f5d9..363d32d0d38209cac1e440c30d9055b84c1a16b9 100644 --- a/Framework/Geometry/test/SpaceGroupTest.h +++ b/Framework/Geometry/test/SpaceGroupTest.h @@ -66,8 +66,8 @@ public: SpaceGroup spaceGroup(167, "R-3c", *(group * centering)); std::vector<V3D> byOperator = spaceGroup * V3D(0.3, 0.0, 0.25); - for (size_t i = 0; i < byOperator.size(); ++i) { - byOperator[i] = getWrappedVector(byOperator[i]); + for (auto &i : byOperator) { + i = getWrappedVector(i); } std::sort(byOperator.begin(), byOperator.end()); @@ -86,8 +86,8 @@ public: SpaceGroup spaceGroup = getSpaceGroupR3m(); std::vector<V3D> byOperator = spaceGroup * V3D(0.5, 0.0, 0.0); - for (size_t i = 0; i < byOperator.size(); ++i) { - byOperator[i] = getWrappedVector(byOperator[i]); + for (auto &i : byOperator) { + i = getWrappedVector(i); } std::sort(byOperator.begin(), byOperator.end()); diff --git a/Framework/Geometry/test/StructureFactorCalculatorSummationTest.h b/Framework/Geometry/test/StructureFactorCalculatorSummationTest.h index 80b53703646a26e7945a84974b2d04036b9f3918..6880e34e3dbd69b4ac7b60b16bbe8e75c463f2ec 100644 --- a/Framework/Geometry/test/StructureFactorCalculatorSummationTest.h +++ b/Framework/Geometry/test/StructureFactorCalculatorSummationTest.h @@ -63,7 +63,7 @@ private: CompositeBraggScatterer_sptr scatterers = CompositeBraggScatterer::create(); scatterers->addScatterer(BraggScattererFactory::Instance().createScatterer( "IsotropicAtomBraggScatterer", - "{\"Element\":\"Si\",\"Position\":\"0,0,0\",\"U\":\"0.05\"}")); + R"({"Element":"Si","Position":"0,0,0","U":"0.05"})")); CrystalStructure si( UnitCell(5.43, 5.43, 5.43), diff --git a/Framework/Geometry/test/StructuredDetectorTest.h b/Framework/Geometry/test/StructuredDetectorTest.h index 996d0903d2a8a78885ecf033d1945a2656199c81..e8d10f62026766ece13233ea9a09013eda0eb92f 100644 --- a/Framework/Geometry/test/StructuredDetectorTest.h +++ b/Framework/Geometry/test/StructuredDetectorTest.h @@ -125,7 +125,7 @@ public: std::vector<double> y{0, 0, 0, 1, 1, 1, 2, 2, 2}; // Initialize with these parameters - det->initialize(2, 2, x, y, true, 0, true, 2, 1); + det->initialize(2, 2, std::move(x), std::move(y), true, 0, true, 2, 1); do_test_on(det); @@ -145,10 +145,11 @@ public: std::vector<double> x{0, 1, 2, 0, 1, 2, 0, 1, 2}; std::vector<double> y{0, 0, 0, 1, 1, 1, 2, 2, 2}; - TSM_ASSERT_THROWS("StructuredDetectors created with beams not aligned " - "along the z-axis should fail.", - det->initialize(2, 2, x, y, false, 0, true, 2, 1), - std::invalid_argument); + TSM_ASSERT_THROWS( + "StructuredDetectors created with beams not aligned " + "along the z-axis should fail.", + det->initialize(2, 2, std::move(x), std::move(y), false, 0, true, 2, 1), + std::invalid_argument); delete det; } @@ -162,19 +163,27 @@ public: std::vector<double> x{0, 1, 2, 0, 1, 2}; std::vector<double> y{0, 0, 0, 1, 1, 1}; + auto x2 = x; + auto y2 = y; + // Initialize with these parameters - TS_ASSERT_THROWS(det->initialize(2, 2, x, y, true, 0, true, 2, 1), - std::invalid_argument); + TS_ASSERT_THROWS( + det->initialize(2, 2, std::move(x), std::move(y), true, 0, true, 2, 1), + std::invalid_argument); - x.resize(3); + x2.resize(3); + auto x3 = x2; + auto y3 = y2; - TS_ASSERT_THROWS(det->initialize(2, 2, x, y, true, 0, true, 2, 1), + TS_ASSERT_THROWS(det->initialize(2, 2, std::move(x2), std::move(y2), true, + 0, true, 2, 1), std::invalid_argument); - x.resize(0); - y.resize(0); + x3.resize(0); + y3.resize(0); - TS_ASSERT_THROWS(det->initialize(2, 2, x, y, true, 0, true, 2, 1), + TS_ASSERT_THROWS(det->initialize(2, 2, std::move(x3), std::move(y3), true, + 0, true, 2, 1), std::invalid_argument); delete det; diff --git a/Framework/Geometry/test/SymmetryOperationFactoryTest.h b/Framework/Geometry/test/SymmetryOperationFactoryTest.h index 7e425a0df075f45b5d01d453a7bb06c8d9d6e3a7..978514be0baf26e1fa2b51bdc70388fee5b5d357 100644 --- a/Framework/Geometry/test/SymmetryOperationFactoryTest.h +++ b/Framework/Geometry/test/SymmetryOperationFactoryTest.h @@ -125,8 +125,8 @@ public: // Clear factory std::vector<std::string> allSymbols = SymmetryOperationFactory::Instance().subscribedSymbols(); - for (auto it = allSymbols.begin(); it != allSymbols.end(); ++it) { - SymmetryOperationFactory::Instance().unsubscribeSymOp(*it); + for (auto &symbol : allSymbols) { + SymmetryOperationFactory::Instance().unsubscribeSymOp(symbol); } // Subscribe two symmetry operations @@ -146,8 +146,8 @@ public: SymmetryOperationFactory::Instance().unsubscribeSymOp("-x,-y,-z"); // Restore factory - for (auto it = allSymbols.begin(); it != allSymbols.end(); ++it) { - SymmetryOperationFactory::Instance().subscribeSymOp(*it); + for (auto &symbol : allSymbols) { + SymmetryOperationFactory::Instance().subscribeSymOp(symbol); } } }; diff --git a/Framework/HistogramData/inc/MantidHistogramData/Histogram.h b/Framework/HistogramData/inc/MantidHistogramData/Histogram.h index 0b3d1c4ccc5b9a5f2b223599ef9f0a0d947916a4..c1955f6deb725e2cd24ca24f58164aae01c1829f 100644 --- a/Framework/HistogramData/inc/MantidHistogramData/Histogram.h +++ b/Framework/HistogramData/inc/MantidHistogramData/Histogram.h @@ -239,7 +239,7 @@ Histogram::setUncertainties(const FrequencyStandardDeviations &e); @param y Optional Y data for the Histogram. Can be Counts or Frequencies. @param e Optional E data for the Histogram. Can be Variances or StandardDeviations for Counts or Frequencies. If not specified or null, the - standard deviations will be set as the suare root of the Y data. + standard deviations will be set as the square root of the Y data. */ template <class TX, class TY, class TE> Histogram::Histogram(const TX &x, const TY &y, const TE &e) { diff --git a/Framework/HistogramData/inc/MantidHistogramData/HistogramBuilder.h b/Framework/HistogramData/inc/MantidHistogramData/HistogramBuilder.h index f99d3a7b5860c4a64771631edff0321c23636c1b..7442ee4845fe9b05f8880b3a6ba387173f37fce2 100644 --- a/Framework/HistogramData/inc/MantidHistogramData/HistogramBuilder.h +++ b/Framework/HistogramData/inc/MantidHistogramData/HistogramBuilder.h @@ -50,6 +50,10 @@ public: template <typename... T> void setE(T &&... data) { m_e = Kernel::make_cow<HistogramE>(std::forward<T>(data)...); } + /// Sets Dx information. Can be a length or actual Dx data. + template <typename... T> void setDx(T &&... data) { + d_x = Kernel::make_cow<HistogramDx>(std::forward<T>(data)...); + } void setDistribution(bool isDistribution); Histogram build() const; @@ -59,6 +63,7 @@ private: Kernel::cow_ptr<HistogramX> m_x{nullptr}; Kernel::cow_ptr<HistogramY> m_y{nullptr}; Kernel::cow_ptr<HistogramE> m_e{nullptr}; + Kernel::cow_ptr<HistogramDx> d_x{nullptr}; }; } // namespace HistogramData diff --git a/Framework/HistogramData/src/HistogramBuilder.cpp b/Framework/HistogramData/src/HistogramBuilder.cpp index 44932841a90525b7cff29dd9a7823077e066c321..6f43a9f72df01ab63eed66be6551c279149e2254 100644 --- a/Framework/HistogramData/src/HistogramBuilder.cpp +++ b/Framework/HistogramData/src/HistogramBuilder.cpp @@ -34,6 +34,8 @@ Histogram HistogramBuilder::build() const { } if (m_e) histogram->setSharedE(m_e); + if (d_x) + histogram->setSharedDx(d_x); return *histogram; } diff --git a/Framework/HistogramData/test/HistogramBuilderTest.h b/Framework/HistogramData/test/HistogramBuilderTest.h index f70363696e17a4925bd508244602e1ab4804f984..861825d596b165f68c98afc043f398c17afccfed 100644 --- a/Framework/HistogramData/test/HistogramBuilderTest.h +++ b/Framework/HistogramData/test/HistogramBuilderTest.h @@ -39,6 +39,8 @@ public: TS_ASSERT_THROWS(builder.build(), std::logic_error); builder.setY(6); TS_ASSERT_THROWS(builder.build(), std::logic_error); + builder.setDx(3); + TS_ASSERT_THROWS(builder.build(), std::logic_error); } void test_build_from_size() { @@ -63,6 +65,31 @@ public: TS_ASSERT_EQUALS(hist.xMode(), Histogram::XMode::Points); TS_ASSERT_EQUALS(hist.yMode(), Histogram::YMode::Frequencies); } + + void test_build_Dx() { + HistogramBuilder builder; + builder.setX(5); + builder.setY(5); + builder.setDx(5); + const auto hist = builder.build(); + TS_ASSERT_EQUALS(hist.x().size(), 5); + TS_ASSERT_EQUALS(hist.y().size(), 5); + TS_ASSERT_EQUALS(hist.e().size(), 5); + TS_ASSERT_EQUALS(hist.dx().size(), 5); + } + + void test_build_Dx_with_bin_edges() { + HistogramBuilder builder; + builder.setX(5); + builder.setY(4); + builder.setDx(4); + const auto hist = builder.build(); + TS_ASSERT_EQUALS(hist.x().size(), 5); + TS_ASSERT_EQUALS(hist.y().size(), 4); + TS_ASSERT_EQUALS(hist.e().size(), 4); + TS_ASSERT_EQUALS(hist.dx().size(), 4); + TS_ASSERT_EQUALS(hist.xMode(), Histogram::XMode::BinEdges); + } }; #endif /* MANTID_HISTOGRAMDATA_HISTOGRAMBUILDERTEST_H_ */ diff --git a/Framework/ICat/inc/MantidICat/CatalogDownloadDataFiles.h b/Framework/ICat/inc/MantidICat/CatalogDownloadDataFiles.h index f26e863bc9cdc5298db0689297b89721e41c7f70..1515f9f8d703a81c848ce202146edbf541c281e9 100644 --- a/Framework/ICat/inc/MantidICat/CatalogDownloadDataFiles.h +++ b/Framework/ICat/inc/MantidICat/CatalogDownloadDataFiles.h @@ -60,6 +60,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"DownloadFile", "CatalogGetDataFiles", "CatalogLogin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogGetDataFiles.h b/Framework/ICat/inc/MantidICat/CatalogGetDataFiles.h index c84de8a944c62e77e508ceef05f0879d378eaeb1..e533b041b7425280e1f0bcf5ba6beb06c4d330fc 100644 --- a/Framework/ICat/inc/MantidICat/CatalogGetDataFiles.h +++ b/Framework/ICat/inc/MantidICat/CatalogGetDataFiles.h @@ -57,6 +57,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogDownloadDataFiles", "CatalogGetDataSets", "CatalogLogin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogGetDataSets.h b/Framework/ICat/inc/MantidICat/CatalogGetDataSets.h index db6a954318596e7138ac7e92fa79ccfe58c7b9e2..283a9629a47f826915fc9c0030291196f5f8a42b 100644 --- a/Framework/ICat/inc/MantidICat/CatalogGetDataSets.h +++ b/Framework/ICat/inc/MantidICat/CatalogGetDataSets.h @@ -57,6 +57,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogGetDataFiles", "CatalogDownloadDataFiles", "CatalogLogin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogKeepAlive.h b/Framework/ICat/inc/MantidICat/CatalogKeepAlive.h index 5e042ba5b5ae08a2e1b43e6b223119a3dc5dcfd7..2264f54c27e07c8cae5dc23337701604e09f2704 100644 --- a/Framework/ICat/inc/MantidICat/CatalogKeepAlive.h +++ b/Framework/ICat/inc/MantidICat/CatalogKeepAlive.h @@ -53,6 +53,9 @@ public: } /// Algorithm's version for identification. int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogLogin"}; + } /// Algorithm's category for identification. const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogListInstruments.h b/Framework/ICat/inc/MantidICat/CatalogListInstruments.h index 8a2e97ed3528e1a459a6e907fc7cad24ff0b1181..38829e19b2892f44cc1de6123b349855bfa29fed 100644 --- a/Framework/ICat/inc/MantidICat/CatalogListInstruments.h +++ b/Framework/ICat/inc/MantidICat/CatalogListInstruments.h @@ -48,6 +48,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogListInvestigationTypes"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogListInvestigationTypes.h b/Framework/ICat/inc/MantidICat/CatalogListInvestigationTypes.h index 52099cee6752106bc870c4c295691f53502f0ce2..277c03ac35f6cfa3675af15d8b5bc521fa32901e 100644 --- a/Framework/ICat/inc/MantidICat/CatalogListInvestigationTypes.h +++ b/Framework/ICat/inc/MantidICat/CatalogListInvestigationTypes.h @@ -50,6 +50,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogListInstruments"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogLogin.h b/Framework/ICat/inc/MantidICat/CatalogLogin.h index f18ab9298d44e6097c46b36f76b732a5c0178182..f40c9cd77775abfe2e58e2e55ea0313aa9d35af5 100644 --- a/Framework/ICat/inc/MantidICat/CatalogLogin.h +++ b/Framework/ICat/inc/MantidICat/CatalogLogin.h @@ -54,6 +54,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogLogout", "CatalogSearch", "CatalogPublish"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogLogout.h b/Framework/ICat/inc/MantidICat/CatalogLogout.h index c79808c0b3dbeae3b6c994328b14d7e41158469e..b8b48f74d794dc85a19a01075b50d352d2e5da25 100644 --- a/Framework/ICat/inc/MantidICat/CatalogLogout.h +++ b/Framework/ICat/inc/MantidICat/CatalogLogout.h @@ -51,6 +51,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogLogin"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogMyDataSearch.h b/Framework/ICat/inc/MantidICat/CatalogMyDataSearch.h index fb3c806dfe2c5193f61eb26430b73f50e66590f5..6ba41b4702f4aa941bb6aefc793893e7d6bcfe35 100644 --- a/Framework/ICat/inc/MantidICat/CatalogMyDataSearch.h +++ b/Framework/ICat/inc/MantidICat/CatalogMyDataSearch.h @@ -57,6 +57,9 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogSearch"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogPublish.h b/Framework/ICat/inc/MantidICat/CatalogPublish.h index b98865b41caaac3a6e0172c26a14797377cf21c1..6bf0e884522eccb91c09ce60cf1b89675a40fb15 100644 --- a/Framework/ICat/inc/MantidICat/CatalogPublish.h +++ b/Framework/ICat/inc/MantidICat/CatalogPublish.h @@ -59,6 +59,9 @@ public: } /// Algorithm's version for identification. int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogLogin"}; + } /// Algorithm's category for identification. const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/CatalogSearch.h b/Framework/ICat/inc/MantidICat/CatalogSearch.h index 9e235f557f24013037c11c718870749def9d41cf..d2e9b471c698132370662b4f6bfb4602c9f74a58 100644 --- a/Framework/ICat/inc/MantidICat/CatalogSearch.h +++ b/Framework/ICat/inc/MantidICat/CatalogSearch.h @@ -68,6 +68,10 @@ public: } /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CatalogMyDataSearch", "CatalogGetDataFiles", "CatalogLogin", + "CatalogPublish"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { return "DataHandling\\Catalog"; diff --git a/Framework/ICat/inc/MantidICat/ICat3/ICat3Helper.h b/Framework/ICat/inc/MantidICat/ICat3/ICat3Helper.h index ce57682420fb4596dbbd472734e303263a758aeb..475ab86fb845c4eb10c2f25f6db9cd67a9ac3647 100644 --- a/Framework/ICat/inc/MantidICat/ICat3/ICat3Helper.h +++ b/Framework/ICat/inc/MantidICat/ICat3/ICat3Helper.h @@ -134,7 +134,7 @@ private: */ template <class T> void savetoTableWorkspace(const T *input, Mantid::API::TableRow &t) { - if (input != 0) { + if (input != nullptr) { t << *input; } else { diff --git a/Framework/ICat/src/GSoap/stdsoap2.cpp b/Framework/ICat/src/GSoap/stdsoap2.cpp index 140a634526da605309dbb4f955297298c3f0af06..fc03059c4637bf0dacc9e982d79bc24d44fbf45f 100644 --- a/Framework/ICat/src/GSoap/stdsoap2.cpp +++ b/Framework/ICat/src/GSoap/stdsoap2.cpp @@ -16101,7 +16101,7 @@ int SOAP_FMAC2 soap_puthttphdr(struct soap *soap, int status, size_t count) { sizeof(soap->tmpbuf) - 80) { const char *t = strchr(s, ';'); sprintf(soap->tmpbuf, - "multipart/related; charset=utf-8; boundary=\"%s\"; type=\"", + R"(multipart/related; charset=utf-8; boundary="%s"; type=")", soap->mime.boundary); if (t) { strncat(soap->tmpbuf, s, t - s); diff --git a/Framework/Indexing/src/IndexInfo.cpp b/Framework/Indexing/src/IndexInfo.cpp index ab3a15e754db2d9e583d219e97e3d185f3573a40..db12c33e2f0ba9273e8a1607d046f09406b3435f 100644 --- a/Framework/Indexing/src/IndexInfo.cpp +++ b/Framework/Indexing/src/IndexInfo.cpp @@ -90,7 +90,8 @@ IndexInfo::~IndexInfo() = default; IndexInfo &IndexInfo::operator=(const IndexInfo &other) { auto copy(other); - return *this = std::move(copy); + *this = std::move(copy); + return *this; } IndexInfo &IndexInfo::operator=(IndexInfo &&) noexcept = default; diff --git a/Framework/Kernel/CMakeLists.txt b/Framework/Kernel/CMakeLists.txt index 81ebe6576c52af5ac8028d1b402bf573041a804e..04396eb710a7eb5fc3e7aea9c79c424a9d4cea7f 100644 --- a/Framework/Kernel/CMakeLists.txt +++ b/Framework/Kernel/CMakeLists.txt @@ -673,7 +673,7 @@ install ( TARGETS Kernel ${SYSTEM_PACKAGE_TARGET} DESTINATION ${LIB_DIR} ) # Create the properties file for the installer set ( MANTID_ROOT_BUILD ${MANTID_ROOT} ) -if ( APPLE ) +if ( APPLE AND ENABLE_MANTIDPLOT ) set ( MANTID_ROOT ../.. ) else () set ( MANTID_ROOT .. ) diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h index 3acb4f61207f414f96d5211800c26997a2ef9030..dee6e74546c51dc221d36eda8086b17318544248 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.h @@ -76,7 +76,7 @@ public: std::string setDataItem(const boost::shared_ptr<DataItem> data) override; PropertyWithValue &operator=(const PropertyWithValue &right); PropertyWithValue &operator+=(Property const *right) override; - virtual TYPE &operator=(const TYPE &value); + virtual PropertyWithValue &operator=(const TYPE &value); virtual const TYPE &operator()() const; virtual operator const TYPE &() const; std::string isValid() const override; diff --git a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc index a4902017dbb7104790d56d09cb1a6fcb93393f37..af580021274c2f9dc67441d495ea6158b94fe138 100644 --- a/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc +++ b/Framework/Kernel/inc/MantidKernel/PropertyWithValue.tcc @@ -259,7 +259,7 @@ operator+=(Property const *right) { * @return the reference to itself */ template <typename TYPE> -TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) { +PropertyWithValue<TYPE> &PropertyWithValue<TYPE>::operator=(const TYPE &value) { TYPE oldValue = m_value; if (std::is_same<TYPE, std::string>::value) { std::string valueCopy = toString(value); @@ -272,10 +272,10 @@ TYPE &PropertyWithValue<TYPE>::operator=(const TYPE &value) { } std::string problem = this->isValid(); if (problem.empty()) { - return m_value; + return *this; } else if (problem == "_alias") { m_value = getValueForAlias(value); - return m_value; + return *this; } else { m_value = oldValue; throw std::invalid_argument(problem); diff --git a/Framework/Kernel/inc/MantidKernel/Statistics.h b/Framework/Kernel/inc/MantidKernel/Statistics.h index 0d3cd0a6143d063e3059f095c107f62e20d978de..af8d46e77ee82dc3a290b345a3c6daffef93dbf9 100644 --- a/Framework/Kernel/inc/MantidKernel/Statistics.h +++ b/Framework/Kernel/inc/MantidKernel/Statistics.h @@ -93,6 +93,9 @@ Statistics getStatistics(const std::vector<TYPE> &data, /// Return the Z score values for a dataset template <typename TYPE> std::vector<double> getZscore(const std::vector<TYPE> &data); +template <typename TYPE> +std::vector<double> getWeightedZscore(const std::vector<TYPE> &data, + const std::vector<TYPE> &weights); /// Return the modified Z score values for a dataset template <typename TYPE> std::vector<double> getModifiedZscore(const std::vector<TYPE> &data, diff --git a/Framework/Kernel/src/ConfigService.cpp b/Framework/Kernel/src/ConfigService.cpp index ff37f5e09b0d833297014692bacc05b4df366716..16a6189f4383f869766cb4a85af77f4091e5493f 100644 --- a/Framework/Kernel/src/ConfigService.cpp +++ b/Framework/Kernel/src/ConfigService.cpp @@ -1774,8 +1774,9 @@ std::string ConfigServiceImpl::getFacilityFilename(const std::string &fName) { // look through all the possible files for (; instrDir != directoryNames.end(); ++instrDir) { - std::string filename = (*instrDir) + "Facilities.xml"; - + Poco::Path p(*instrDir); + p.append("Facilities.xml"); + std::string filename = p.toString(); Poco::File fileObj(filename); // stop when you find the first one if (fileObj.exists()) diff --git a/Framework/Kernel/src/MaterialXMLParser.cpp b/Framework/Kernel/src/MaterialXMLParser.cpp index f1411168f7cceb81b047ab567b6674b5563ab96f..f15080f4e8e3bf08b978ed642e7a4a8dd3ab7f6c 100644 --- a/Framework/Kernel/src/MaterialXMLParser.cpp +++ b/Framework/Kernel/src/MaterialXMLParser.cpp @@ -51,6 +51,7 @@ const char *ABSORB_ATT = "absorptionxsec"; // Base type to put in a hash struct BuilderHandle { + virtual ~BuilderHandle() = default; virtual void operator()(MaterialBuilder &builder, const std::string &value) const = 0; }; diff --git a/Framework/Kernel/src/Statistics.cpp b/Framework/Kernel/src/Statistics.cpp index a42617046cccd533d475d32bf260448588806edc..42bf89c2a82051612a9fadfc88910831dd9be4cf 100644 --- a/Framework/Kernel/src/Statistics.cpp +++ b/Framework/Kernel/src/Statistics.cpp @@ -102,7 +102,43 @@ std::vector<double> getZscore(const vector<TYPE> &data) { } for (auto it = data.cbegin(); it != data.cend(); ++it) { double tmp = static_cast<double>(*it); - Zscore.push_back(fabs((tmp - stats.mean) / stats.standard_deviation)); + Zscore.push_back(fabs((stats.mean - tmp) / stats.standard_deviation)); + } + return Zscore; +} +/** + * There are enough special cases in determining the Z score where it useful to + * put it in a single function. + */ +template <typename TYPE> +std::vector<double> getWeightedZscore(const vector<TYPE> &data, + const vector<TYPE> &weights) { + if (data.size() < 3) { + std::vector<double> Zscore(data.size(), 0.); + return Zscore; + } + std::vector<double> Zscore; + Statistics stats = getStatistics(data); + if (stats.standard_deviation == 0.) { + std::vector<double> Zscore(data.size(), 0.); + return Zscore; + } + double sumWeights = 0.0; + double sumWeightedData = 0.0; + double weightedVariance = 0.0; + for (size_t it = 0; it != data.size(); ++it) { + sumWeights += static_cast<double>(weights[it]); + sumWeightedData += static_cast<double>(weights[it] * data[it]); + } + double weightedMean = sumWeightedData / sumWeights; + for (size_t it = 0; it != data.size(); ++it) { + weightedVariance += + std::pow(static_cast<double>(data[it]) - weightedMean, 2) * + std::pow(static_cast<double>(weights[it]) / sumWeights, 2); + } + for (auto it = data.cbegin(); it != data.cend(); ++it) { + Zscore.push_back(fabs((static_cast<double>(*it) - weightedMean) / + std::sqrt(weightedVariance))); } return Zscore; } @@ -406,6 +442,8 @@ std::vector<double> getMomentsAboutMean(const std::vector<TYPE> &x, getStatistics<TYPE>(const vector<TYPE> &, const unsigned int); \ template MANTID_KERNEL_DLL std::vector<double> getZscore<TYPE>( \ const vector<TYPE> &); \ + template MANTID_KERNEL_DLL std::vector<double> getWeightedZscore<TYPE>( \ + const vector<TYPE> &, const vector<TYPE> &); \ template MANTID_KERNEL_DLL std::vector<double> getModifiedZscore<TYPE>( \ const vector<TYPE> &, const bool); \ template MANTID_KERNEL_DLL std::vector<double> getMomentsAboutOrigin<TYPE>( \ diff --git a/Framework/Kernel/test/ArrayPropertyTest.h b/Framework/Kernel/test/ArrayPropertyTest.h index 75408b0d46d6535385a074c232c3dc93cefbb565..f15f1f2ab2e40e36fcb639a7a502672ea30a2313 100644 --- a/Framework/Kernel/test/ArrayPropertyTest.h +++ b/Framework/Kernel/test/ArrayPropertyTest.h @@ -242,21 +242,24 @@ public: ArrayProperty<int> i("i"); TS_ASSERT(i.isDefault()) std::vector<int> ii(3, 4); - TS_ASSERT_EQUALS(i = ii, ii) + i = ii; + TS_ASSERT_EQUALS(i.operator()(), ii); TS_ASSERT_EQUALS(i.operator()()[1], 4) TS_ASSERT(!i.isDefault()) ArrayProperty<double> d("d"); TS_ASSERT(d.isDefault()) std::vector<double> dd(5, 9.99); - TS_ASSERT_EQUALS(d = dd, dd) + d = dd; + TS_ASSERT_EQUALS(d.operator()(), dd); TS_ASSERT_EQUALS(d.operator()()[3], 9.99) TS_ASSERT(!d.isDefault()) ArrayProperty<std::string> s("s"); TS_ASSERT(s.isDefault()) std::vector<std::string> ss(2, "zzz"); - TS_ASSERT_EQUALS(s = ss, ss) + s = ss; + TS_ASSERT_EQUALS(s.operator()(), ss) TS_ASSERT_EQUALS(s.operator()()[0], "zzz") TS_ASSERT(!s.isDefault()) } diff --git a/Framework/Kernel/test/CatalogInfoTest.h b/Framework/Kernel/test/CatalogInfoTest.h index 0eaa2692f5d9b50b48d5dacbac9a2c04f563f6e7..9f8e742c4b0c9c7e7bd8330115cefcdc35608ec9 100644 --- a/Framework/Kernel/test/CatalogInfoTest.h +++ b/Framework/Kernel/test/CatalogInfoTest.h @@ -86,7 +86,7 @@ public: std::string macPrefixPath = "/archive/NDXSANDALS/Instrument/data/cycle_05_3/ALF06716.LOG"; std::string winPrefixPath = - "\\NDXSANDALS\\Instrument\\data\\cycle_05_3\\ALF06716.LOG"; + R"(\NDXSANDALS\Instrument\data\cycle_05_3\ALF06716.LOG)"; std::string winDefaultPath = "\\\\isis\\inst$\\Instruments$" "\\NDXSANDALS\\Instrument\\data\\cycle_05_" "3\\ALF06716.LOG"; diff --git a/Framework/Kernel/test/ComputeResourceInfoTest.h b/Framework/Kernel/test/ComputeResourceInfoTest.h index 9e830ad03b034b33d79acf724314b40a4194dd0a..89f745063222fd0417991fc6ae2221a5eb6f6d25 100644 --- a/Framework/Kernel/test/ComputeResourceInfoTest.h +++ b/Framework/Kernel/test/ComputeResourceInfoTest.h @@ -211,7 +211,7 @@ private: "<facilities>" " <facility name=\"" + testFacilityName + - "\" FileExtensions=\".xyz\">" + simpleInstStr + + R"(" FileExtensions=".xyz">)" + simpleInstStr + crStr + " </facility>" "</facilities>"; diff --git a/Framework/Kernel/test/ConfigServiceTest.h b/Framework/Kernel/test/ConfigServiceTest.h index bd2f247a1d1eff08e9611e0b2da34383334f0d39..0485fd2b6c03ec15a2bdd0398d9e853e626002aa 100644 --- a/Framework/Kernel/test/ConfigServiceTest.h +++ b/Framework/Kernel/test/ConfigServiceTest.h @@ -352,9 +352,9 @@ public: ConfigService::Instance().getInstrumentDirectory()); // check all of the directory entries actually exist - for (auto it = directories.begin(); it != directories.end(); ++it) { - Poco::File directory(*it); - TSM_ASSERT(*it + " does not exist", directory.exists()); + for (auto &directoryPath : directories) { + Poco::File directory(directoryPath); + TSM_ASSERT(directoryPath + " does not exist", directory.exists()); } } diff --git a/Framework/Kernel/test/DiskBufferISaveableTest.h b/Framework/Kernel/test/DiskBufferISaveableTest.h index 873796a94bce45fc586a0c48295e8e89b71db072..da1a11e73979182cd4d9629178c7b673e2f43a9b 100644 --- a/Framework/Kernel/test/DiskBufferISaveableTest.h +++ b/Framework/Kernel/test/DiskBufferISaveableTest.h @@ -90,15 +90,14 @@ public: } void tearDown() override { - for (size_t i = 0; i < data.size(); i++) { - delete data[i]; - data[i] = NULL; + for (auto &item : data) { + delete item; } - for (size_t i = 0; i < bigData.size(); i++) { - delete bigData[i]; - bigData[i] = NULL; + for (auto &bigItem : bigData) { + delete bigItem; } + ISaveableTester::fakeFile = ""; } void testIsaveable() { @@ -435,9 +434,9 @@ public: void test_smallCache_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(3); - for (size_t i = 0; i < data.size(); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto &i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU.\n"; } @@ -445,13 +444,13 @@ public: void test_smallCache_no_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (size_t i = 0; i < data.size(); i++) { - data[i]->setBusy(true); // Items won't do any real saving + for (auto &i : data) { + i->setBusy(true); // Items won't do any real saving } - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto &i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU (no write cache).\n"; @@ -460,9 +459,9 @@ public: void test_largeCache_writeBuffer() { CPUTimer tim; DiskBuffer dbuf(1000); - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto &i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << tim << " to load " << num << " into MRU.\n"; } @@ -470,9 +469,9 @@ public: void test_largeCache_noWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (int i = 0; i < int(data.size()); i++) { - dbuf.toWrite(data[i]); - data[i]->setBusy(false); + for (auto &i : data) { + dbuf.toWrite(i); + i->setBusy(false); } std::cout << " Elapsed : " << tim << " to load " << num << " into MRU (no write buffer).\n"; diff --git a/Framework/Kernel/test/DiskBufferTest.h b/Framework/Kernel/test/DiskBufferTest.h index 426c375731d7603559e2448f15d25f68bc4d2de1..4911bcdaca6a9e6ba3b12ebbf41990182b86b741 100644 --- a/Framework/Kernel/test/DiskBufferTest.h +++ b/Framework/Kernel/test/DiskBufferTest.h @@ -115,9 +115,8 @@ public: } void tearDown() override { - for (size_t i = 0; i < data.size(); i++) { - delete data[i]; - data[i] = NULL; + for (auto &i : data) { + delete i; } } void xest_nothing() { @@ -171,8 +170,8 @@ public: ////-------------------------------------------------------------------------------- ///** Sorts by file position when writing to a file */ void test_writesOutInFileOrder() { - for (size_t i = 0; i < data.size(); i++) { - data[i]->setDataChanged(); + for (auto &i : data) { + i->setDataChanged(); } // Room for 2 objects of size 2 in the to-write cache DiskBuffer dbuf(2 * 2); @@ -796,9 +795,9 @@ public: void test_withFakeSeeking_withWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(10); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto &i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->load(dbuf); + i->load(dbuf); } std::cout << tim << " to load " << dataSeek.size() << " into MRU with fake seeking. \n"; @@ -809,9 +808,9 @@ public: void test_withFakeSeeking_noWriteBuffer() { CPUTimer tim; DiskBuffer dbuf(0); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto &i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->load(dbuf); + i->load(dbuf); } std::cout << tim << " to load " << dataSeek.size() << " into MRU with fake seeking. \n"; @@ -823,10 +822,10 @@ public: CPUTimer tim; DiskBuffer dbuf(20); dbuf.setFileLength(dataSeek.size()); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto &i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->grow(dbuf, true); - dbuf.toWrite(dataSeek[i]); + i->grow(dbuf, true); + dbuf.toWrite(i); } std::cout << "About to flush the cache to finish writes.\n"; dbuf.flushCache(); @@ -840,10 +839,10 @@ public: void test_withFakeSeeking_growingData_savingWithoutUsingMRU() { CPUTimer tim; DiskBuffer dbuf(dataSeek.size()); - for (int i = 0; i < int(dataSeek.size()); i++) { + for (auto &i : dataSeek) { // Pretend you just loaded the data - dataSeek[i]->grow(dbuf, false); - dataSeek[i]->save(); + i->grow(dbuf, false); + i->save(); } std::cout << tim << " to grow " << dataSeek.size() << " into MRU with fake seeking. \n"; diff --git a/Framework/Kernel/test/FileDescriptorTest.h b/Framework/Kernel/test/FileDescriptorTest.h index ec7856f06e13ccb66f81c6e839962836ab23f5be..a3957fa443394a222a4fb7cc9ff5cfa80d57afd6 100644 --- a/Framework/Kernel/test/FileDescriptorTest.h +++ b/Framework/Kernel/test/FileDescriptorTest.h @@ -23,14 +23,14 @@ public: auto &cfg = Mantid::Kernel::ConfigService::Instance(); cfg.reset(); const auto &dataPaths = cfg.getDataSearchDirs(); - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path nxsPath(*it, "CNCS_7860_event.nxs"); + for (const auto &dataPath : dataPaths) { + Poco::Path nxsPath(dataPath, "CNCS_7860_event.nxs"); if (Poco::File(nxsPath).exists()) m_testNexusPath = nxsPath.toString(); - Poco::Path nonNxsPath(*it, "CSP79590.raw"); + Poco::Path nonNxsPath(dataPath, "CSP79590.raw"); if (Poco::File(nonNxsPath).exists()) m_testNonNexusPath = nonNxsPath.toString(); - Poco::Path asciiPath(*it, "AsciiExample.txt"); + Poco::Path asciiPath(dataPath, "AsciiExample.txt"); if (Poco::File(asciiPath).exists()) m_testAsciiPath = asciiPath.toString(); diff --git a/Framework/Kernel/test/GlobTest.h b/Framework/Kernel/test/GlobTest.h index 1908edbff8e531f2dbdb37feb97f9184638593ce..92057289d2f9d4c1d705e1df05b3e285c0eca443 100644 --- a/Framework/Kernel/test/GlobTest.h +++ b/Framework/Kernel/test/GlobTest.h @@ -34,9 +34,8 @@ public: TS_ASSERT(files.size() > 0); size_t matches = 0; - for (std::set<std::string>::const_iterator f = files.begin(); - f != files.end(); ++f) { - Poco::Path path = *f; + for (const auto &file : files) { + Poco::Path path = file; std::string project = path[path.depth() - 1]; if (project == "API") ++matches; @@ -96,9 +95,8 @@ public: TS_ASSERT(files.size() > 0); size_t matches = 0; - for (std::set<std::string>::const_iterator f = files.begin(); - f != files.end(); ++f) { - Poco::Path path = *f; + for (const auto &file : files) { + Poco::Path path = file; std::string project = path[path.depth() - 1]; if (project == "API") ++matches; diff --git a/Framework/Kernel/test/InterpolationTest.h b/Framework/Kernel/test/InterpolationTest.h index a2ed45e607b1b291938b06922ee96589fb13052d..a54e36bb57ab8a4df5cb2d24e07ad604c0160a65 100644 --- a/Framework/Kernel/test/InterpolationTest.h +++ b/Framework/Kernel/test/InterpolationTest.h @@ -206,13 +206,13 @@ public: Interpolation interpolationOne; interpolationOne.addPoint(200, 2.0); - for (size_t i = 0; i < m_tableXValues.size(); ++i) { + for (double m_tableXValue : m_tableXValues) { // When there are zero values in the interpolation, it returns 0.0 - checkValue(interpolationZero, m_tableXValues[i], 0.0, + checkValue(interpolationZero, m_tableXValue, 0.0, "zero interpolation values"); // With one value, it returns this one value for any x. - checkValue(interpolationOne, m_tableXValues[i], 2.0, + checkValue(interpolationOne, m_tableXValue, 2.0, "one interpolation value"); } } diff --git a/Framework/Kernel/test/MaterialXMLParserTest.h b/Framework/Kernel/test/MaterialXMLParserTest.h index 4391ccfd806086a1a22eb03ab3fdf6e6a0082064..f9fc269958bc1266962c2f1ad2421c6796b078c3 100644 --- a/Framework/Kernel/test/MaterialXMLParserTest.h +++ b/Framework/Kernel/test/MaterialXMLParserTest.h @@ -30,7 +30,7 @@ public: // all of the attributes are handled. //---------------------------------------------------------------------------- void test_Formula_Attribute() { - auto mat = parseMaterial("<material id=\"vanadium\" formula=\"V\"/>"); + auto mat = parseMaterial(R"(<material id="vanadium" formula="V"/>)"); TS_ASSERT_EQUALS("vanadium", mat.name()); TS_ASSERT_DELTA(0.07223047, mat.numberDensity(), 1e-8); @@ -38,7 +38,7 @@ public: void test_AtomicNumber_Attribute() { auto mat = parseMaterial( - "<material id=\"n\" atomicnumber=\"28\" numberdensity=\"0.12\"/>"); + R"(<material id="n" atomicnumber="28" numberdensity="0.12"/>)"); TS_ASSERT_DELTA(mat.totalScatterXSection(), 18.5, 0.0001); TS_ASSERT_DELTA(mat.absorbXSection(), 4.49, 0.0001); diff --git a/Framework/Kernel/test/MutexTest.h b/Framework/Kernel/test/MutexTest.h index b823f9e03fcf7fcc7dbf9ddc4627497fbcbc202d..e85fac873ccaaf6142eb8cf688133ceac5479e01 100644 --- a/Framework/Kernel/test/MutexTest.h +++ b/Framework/Kernel/test/MutexTest.h @@ -24,8 +24,7 @@ void reader() { Poco::ScopedReadRWLock lock(_access); // std::cout << "Read launching\n"; // do work here, without anyone having exclusive access - for (size_t i = 0; i < shared_data.size(); i++) { - double val = shared_data[i]; + for (double val : shared_data) { UNUSED_ARG(val) } // std::cout << "Read finished\n"; @@ -38,8 +37,8 @@ void unconditional_writer() { // do work here, with exclusive access shared_data.resize(shared_data.size() + 1, 2.345); // Dumb thing to slow down the writer - for (size_t i = 0; i < shared_data.size(); i++) - shared_data[i] = 4.567; + for (double &i : shared_data) + i = 4.567; // std::cout << "Write finished\n"; } diff --git a/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h b/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h index 18de5157a0f25ecd6b41c184a9e22b59bec4ce13..197da2111b84e4930f841f7d0568a5d17bb03d41 100644 --- a/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h +++ b/Framework/Kernel/test/NDPseudoRandomNumberGeneratorTest.h @@ -38,8 +38,8 @@ public: const double start(2.1), end(3.4); NDGenerator_sptr ndRand = createTestGenerator(12345, start, end); std::vector<double> firstPoint = ndRand->nextPoint(); - for (size_t i = 0; i < firstPoint.size(); ++i) { - TS_ASSERT(firstPoint[i] >= start && firstPoint[i] <= end); + for (double i : firstPoint) { + TS_ASSERT(i >= start && i <= end); } } diff --git a/Framework/Kernel/test/NexusDescriptorTest.h b/Framework/Kernel/test/NexusDescriptorTest.h index bf8f89446372d47d4d21960b556bcafc3686766d..0238213b82af62473eaf3d3f791bd9088b895a69 100644 --- a/Framework/Kernel/test/NexusDescriptorTest.h +++ b/Framework/Kernel/test/NexusDescriptorTest.h @@ -28,16 +28,16 @@ public: NexusDescriptorTest() { using Mantid::Kernel::ConfigService; auto dataPaths = ConfigService::Instance().getDataSearchDirs(); - for (auto it = dataPaths.begin(); it != dataPaths.end(); ++it) { - Poco::Path hdf5Path(*it, "CNCS_7860_event.nxs"); + for (auto &dataPath : dataPaths) { + Poco::Path hdf5Path(dataPath, "CNCS_7860_event.nxs"); if (Poco::File(hdf5Path).exists()) m_testHDF5Path = hdf5Path.toString(); - Poco::Path hdf4Path(*it, "argus0026287.nxs"); + Poco::Path hdf4Path(dataPath, "argus0026287.nxs"); if (Poco::File(hdf4Path).exists()) m_testHDF4Path = hdf4Path.toString(); - Poco::Path nonhdf5Path(*it, "CSP79590.raw"); + Poco::Path nonhdf5Path(dataPath, "CSP79590.raw"); if (Poco::File(nonhdf5Path).exists()) m_testNonHDFPath = nonhdf5Path.toString(); diff --git a/Framework/Kernel/test/PropertyManagerTest.h b/Framework/Kernel/test/PropertyManagerTest.h index 926c339d284251f7a6f4096eb8f03c40e4cb876d..f23ad6e6fb32f0fb45129722b39af79c3c1778ff 100644 --- a/Framework/Kernel/test/PropertyManagerTest.h +++ b/Framework/Kernel/test/PropertyManagerTest.h @@ -90,12 +90,12 @@ public: TS_ASSERT_EQUALS(manager.propertyCount(), 3); const std::vector<Property *> &props = manager.getProperties(); - for (auto iter = props.begin(); iter != props.end(); ++iter) { - Property *prop = *iter; + for (auto iter : props) { + Property *prop = iter; std::string msg = "Property " + prop->name() + " has not been changed to a FilteredTimeSeries"; auto filteredProp = - dynamic_cast<FilteredTimeSeriesProperty<double> *>(*iter); + dynamic_cast<FilteredTimeSeriesProperty<double> *>(iter); TSM_ASSERT(msg, filteredProp); } @@ -248,7 +248,7 @@ public: mgr.declareProperty( Mantid::Kernel::make_unique<ArrayProperty<double>>("ArrayProp")); - std::string jsonString = "{\"ArrayProp\":\"10,12,23\"}"; + std::string jsonString = R"({"ArrayProp":"10,12,23"})"; TS_ASSERT_THROWS_NOTHING(mgr.setProperties(jsonString)); TS_ASSERT_EQUALS(mgr.getPropertyValue("ArrayProp"), "10,12,23"); } @@ -581,13 +581,13 @@ public: TS_ASSERT_EQUALS(d, 23.4); TS_ASSERT_EQUALS(i, 22); - mgr.setPropertiesWithString("{\"double\": 14.0, \"int\":33}"); + mgr.setPropertiesWithString(R"({"double": 14.0, "int":33})"); d = mgr.getProperty("double"); i = mgr.getProperty("int"); TS_ASSERT_EQUALS(d, 14.0); TS_ASSERT_EQUALS(i, 33); - mgr.setPropertiesWithString("{\"double\": 12.3 ,\"int\":11}", {"int"}); + mgr.setPropertiesWithString(R"({"double": 12.3 ,"int":11})", {"int"}); d = mgr.getProperty("double"); i = mgr.getProperty("int"); TS_ASSERT_EQUALS(d, 12.3); diff --git a/Framework/Kernel/test/PropertyWithValueTest.h b/Framework/Kernel/test/PropertyWithValueTest.h index 0dd1155b1402962a8a667179a01090b8e725fd11..6f3d65b5a803244f7a01eee9dd024ef9692453a3 100644 --- a/Framework/Kernel/test/PropertyWithValueTest.h +++ b/Framework/Kernel/test/PropertyWithValueTest.h @@ -690,9 +690,9 @@ public: auto values = property.allowedValues(); auto possibilities = OptionalBool::strToEmumMap(); TSM_ASSERT_EQUALS("3 states allowed", possibilities.size(), values.size()); - for (auto it = values.begin(); it != values.end(); ++it) { + for (auto &value : values) { TSM_ASSERT("value not a known state", - possibilities.find(*it) != possibilities.end()); + possibilities.find(value) != possibilities.end()); } } diff --git a/Framework/Kernel/test/SobolSequenceTest.h b/Framework/Kernel/test/SobolSequenceTest.h index 0a61b278d64888d561761ffea80a79341db9623c..3abe083aa37b85a76633d350505102bf5e311f80 100644 --- a/Framework/Kernel/test/SobolSequenceTest.h +++ b/Framework/Kernel/test/SobolSequenceTest.h @@ -87,10 +87,10 @@ private: {0.75, 0.25, 0.75, 0.25, 0.75}, {0.25, 0.75, 0.25, 0.75, 0.25}, }; - for (std::size_t i = 0; i < 3; ++i) { + for (auto &expectedValue : expectedValues) { const std::vector<double> randPoint = randGen.nextPoint(); for (std::size_t j = 0; j < 5; ++j) { - TS_ASSERT_DELTA(randPoint[j], expectedValues[i][j], 1e-12); + TS_ASSERT_DELTA(randPoint[j], expectedValue[j], 1e-12); } } } diff --git a/Framework/Kernel/test/ThreadSchedulerTest.h b/Framework/Kernel/test/ThreadSchedulerTest.h index 587bb4e5707eab9248a568b6f55f6493b4a613fa..60be77fbe9b3aa5bf2eac3cf20051a22c12335b9 100644 --- a/Framework/Kernel/test/ThreadSchedulerTest.h +++ b/Framework/Kernel/test/ThreadSchedulerTest.h @@ -87,8 +87,8 @@ public: // And ThreadScheduler does not delete popped tasks in this way TS_ASSERT_EQUALS(ThreadSchedulerTest_numDestructed, 0); - for (size_t i = 0; i < 4; i++) { - delete tasks[i]; + for (auto &task : tasks) { + delete task; } } diff --git a/Framework/Kernel/test/UsageServiceTest.h b/Framework/Kernel/test/UsageServiceTest.h index fbf3fbf4f1b4c26e44e461280e283e3996ae9488..022d88b7c38e1c3e6a1086a81e9747cd76df5300 100644 --- a/Framework/Kernel/test/UsageServiceTest.h +++ b/Framework/Kernel/test/UsageServiceTest.h @@ -101,11 +101,11 @@ public: } auto features = root["features"]; - for (Json::ArrayIndex i = 0; i < features.size(); i++) { - std::string name = features[i]["name"].asString(); - std::string type = features[i]["type"].asString(); - bool internal = features[i]["internal"].asBool(); - size_t count = features[i]["count"].asUInt(); + for (auto &feature : features) { + std::string name = feature["name"].asString(); + std::string type = feature["type"].asString(); + bool internal = feature["internal"].asBool(); + size_t count = feature["count"].asUInt(); bool correct = false; diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISEventDAE.h b/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISEventDAE.h index d776a84d8e57ff70249312c0a19fb0fd777abf43..2f648a9df8f0af3c299aa202f5ffbaae08b195ce 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISEventDAE.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISEventDAE.h @@ -55,6 +55,9 @@ public: const std::string category() const override { return "DataHandling\\DataAcquisition"; } + const std::vector<std::string> seeAlso() const override { + return {"FakeISISHistoDAE"}; + } /// Algorithm's summary const std::string summary() const override { diff --git a/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISHistoDAE.h b/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISHistoDAE.h index 35c4dff7a37d1421b4e80c36b8e028a83417e7da..87a7dab447a2c2c066a911ee8d8f3f127b0e6117 100644 --- a/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISHistoDAE.h +++ b/Framework/LiveData/inc/MantidLiveData/ISIS/FakeISISHistoDAE.h @@ -61,6 +61,9 @@ public: const std::string category() const override { return "DataHandling\\DataAcquisition"; } + const std::vector<std::string> seeAlso() const override { + return {"FakeISISEventDAE"}; + } /// Summary of algorithms purpose const std::string summary() const override { return "Simulates ISIS histogram DAE."; diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaBroker.h b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaBroker.h index 0b83329afb84bfc383025bc1df4b4ac6646e3359..6104a95cd4860d77c0d21165cca146242ce0d243 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaBroker.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/IKafkaBroker.h @@ -35,7 +35,7 @@ namespace LiveData { */ class DLLExport IKafkaBroker { public: - ~IKafkaBroker() = default; + virtual ~IKafkaBroker() = default; virtual std::unique_ptr<IKafkaStreamSubscriber> subscribe(std::vector<std::string> topics, diff --git a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h index ef4cd6231eaa2bc398f96f17a50bca35317ac0c4..e9410dced555084aef336391bd13fb4811574417 100644 --- a/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h +++ b/Framework/LiveData/inc/MantidLiveData/Kafka/KafkaEventListener.h @@ -1,5 +1,5 @@ -#ifndef MANTID_LIVEDATA_ISISKAFKAEVENTLISTENER_H_ -#define MANTID_LIVEDATA_ISISKAFKAEVENTLISTENER_H_ +#ifndef MANTID_LIVEDATA_KAFKAEVENTLISTENER_H_ +#define MANTID_LIVEDATA_KAFKAEVENTLISTENER_H_ //---------------------------------------------------------------------- // Includes //---------------------------------------------------------------------- @@ -10,6 +10,11 @@ //---------------------------------------------------------------------- namespace Mantid { + +namespace API { +class IAlgorithm; +} + namespace LiveData { class KafkaEventStreamDecoder; @@ -38,8 +43,7 @@ class KafkaEventStreamDecoder; */ class DLLExport KafkaEventListener : public API::LiveListener { public: - KafkaEventListener(); - /// Destructor. Should handle termination of any socket connections. + KafkaEventListener() = default; ~KafkaEventListener() override = default; //---------------------------------------------------------------------- @@ -61,6 +65,7 @@ public: void start( Types::Core::DateAndTime startTime = Types::Core::DateAndTime()) override; boost::shared_ptr<API::Workspace> extractData() override; + void setAlgorithm(const Mantid::API::IAlgorithm &callingAlgorithm) override; //---------------------------------------------------------------------- // State flags @@ -71,9 +76,10 @@ public: private: std::unique_ptr<KafkaEventStreamDecoder> m_decoder = nullptr; + std::string m_instrumentName; }; } // namespace LiveData } // namespace Mantid -#endif /*MANTID_LIVEDATA_ISISKAFKAEVENTLISTENER_H_*/ +#endif /*MANTID_LIVEDATA_KAFKAEVENTLISTENER_H_*/ diff --git a/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h b/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h index 7b76f388e850c9ed4f3db4d6de75eaecfbccef94..652b613e8a57e51aaf36b4f6119a002f249d1865 100644 --- a/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h +++ b/Framework/LiveData/inc/MantidLiveData/SNSLiveEventDataListener.h @@ -79,7 +79,7 @@ protected: bool rxPacket(const ADARA::VariableStringPkt &pkt) override; bool rxPacket(const ADARA::DeviceDescriptorPkt &pkt) override; bool rxPacket(const ADARA::AnnotationPkt &pkt) override; - // virtual bool rxPacket( const ADARA::RunInfoPkt &pkt); + bool rxPacket(const ADARA::RunInfoPkt &pkt) override; private: // Workspace initialization needs to happen in 2 steps. Part 1 must happen diff --git a/Framework/LiveData/src/Kafka/KafkaEventListener.cpp b/Framework/LiveData/src/Kafka/KafkaEventListener.cpp index 78fdb58efce7b9ddbeb08cb6469ab5001aa41dff..567a2a883801c81139820eb895db3351835116da 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventListener.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventListener.cpp @@ -1,7 +1,8 @@ #include "MantidLiveData/Kafka/KafkaEventListener.h" +#include "MantidAPI/IAlgorithm.h" #include "MantidAPI/LiveListenerFactory.h" -#include "MantidLiveData/Kafka/KafkaEventStreamDecoder.h" #include "MantidLiveData/Kafka/KafkaBroker.h" +#include "MantidLiveData/Kafka/KafkaEventStreamDecoder.h" #include "MantidLiveData/Kafka/KafkaTopicSubscriber.h" namespace { @@ -13,21 +14,32 @@ namespace LiveData { DECLARE_LISTENER(KafkaEventListener) -KafkaEventListener::KafkaEventListener() { - declareProperty("InstrumentName", ""); +void KafkaEventListener::setAlgorithm( + const Mantid::API::IAlgorithm &callingAlgorithm) { + this->updatePropertyValues(callingAlgorithm); + // Get the instrument name from StartLiveData so we can sub to correct topics + if (callingAlgorithm.existsProperty("Instrument")) { + m_instrumentName = callingAlgorithm.getPropertyValue("Instrument"); + } else { + g_log.error("KafkaEventListener requires Instrument property to be set in " + "calling algorithm"); + } } /// @copydoc ILiveListener::connect bool KafkaEventListener::connect(const Poco::Net::SocketAddress &address) { + if (m_instrumentName.empty()) { + g_log.error( + "KafkaEventListener::connect requires a non-empty instrument name"); + } auto broker = std::make_shared<KafkaBroker>(address.toString()); try { - std::string instrumentName = getProperty("InstrumentName"); - const std::string eventTopic(instrumentName + + const std::string eventTopic(m_instrumentName + KafkaTopicSubscriber::EVENT_TOPIC_SUFFIX), - runInfoTopic(instrumentName + KafkaTopicSubscriber::RUN_TOPIC_SUFFIX), - spDetInfoTopic(instrumentName + + runInfoTopic(m_instrumentName + KafkaTopicSubscriber::RUN_TOPIC_SUFFIX), + spDetInfoTopic(m_instrumentName + KafkaTopicSubscriber::DET_SPEC_TOPIC_SUFFIX), - sampleEnvTopic(instrumentName + + sampleEnvTopic(m_instrumentName + KafkaTopicSubscriber::SAMPLE_ENV_TOPIC_SUFFIX); m_decoder = Kernel::make_unique<KafkaEventStreamDecoder>( broker, eventTopic, runInfoTopic, spDetInfoTopic, sampleEnvTopic); diff --git a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp index 6c79894cfd31f88735817984939665aec85a2b50..1de3cca7717c31050de637311c035331d08e1dc4 100644 --- a/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp +++ b/Framework/LiveData/src/Kafka/KafkaEventStreamDecoder.cpp @@ -507,22 +507,21 @@ void KafkaEventStreamDecoder::eventDataFromMessage(const std::string &buffer) { const auto &detData = *(eventMsg->detector_id()); auto nEvents = tofData.size(); - if (eventMsg->facility_specific_data_type() != FacilityData_ISISData) { - throw std::runtime_error("KafkaEventStreamDecoder only knows how to " - "deal with ISIS facility specific data"); - } - auto ISISMsg = - static_cast<const ISISData *>(eventMsg->facility_specific_data()); - + DataObjects::EventWorkspace_sptr periodBuffer; std::lock_guard<std::mutex> lock(m_mutex); - auto &periodBuffer = - *m_localEvents[static_cast<size_t>(ISISMsg->period_number())]; - auto &mutableRunInfo = periodBuffer.mutableRun(); - mutableRunInfo.getTimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY) - ->addValue(pulseTime, ISISMsg->proton_charge()); + if (eventMsg->facility_specific_data_type() == FacilityData_ISISData) { + auto ISISMsg = + static_cast<const ISISData *>(eventMsg->facility_specific_data()); + periodBuffer = m_localEvents[static_cast<size_t>(ISISMsg->period_number())]; + auto &mutableRunInfo = periodBuffer->mutableRun(); + mutableRunInfo.getTimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY) + ->addValue(pulseTime, ISISMsg->proton_charge()); + } else { + periodBuffer = m_localEvents[0]; + } for (decltype(nEvents) i = 0; i < nEvents; ++i) { - auto &spectrum = - periodBuffer.getSpectrum(m_specToIdx[static_cast<int32_t>(detData[i])]); + auto &spectrum = periodBuffer->getSpectrum( + m_specToIdx[static_cast<int32_t>(detData[i])]); spectrum.addEventQuickly(TofEvent(static_cast<double>(tofData[i]) * 1e-3, // nanoseconds to microseconds pulseTime)); diff --git a/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h b/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h index 2c57e5aa153a33fa43a257f74a0a2bc8a5edc893..6ce57b8f32bbb833fa054492dd1d4c15b2f3f6a4 100644 --- a/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h +++ b/Framework/LiveData/src/Kafka/private/Schema/flatbuffers/flatbuffers.h @@ -757,11 +757,11 @@ FLATBUFFERS_FINAL_CLASS auto vt_use = GetSize(); // See if we already have generated a vtable with this exact same // layout before. If so, make it point to the old one, remove this one. - for (auto it = vtables_.begin(); it != vtables_.end(); ++it) { - auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(*it)); + for (unsigned int & vtable : vtables_) { + auto vt2 = reinterpret_cast<voffset_t *>(buf_.data_at(vtable)); auto vt2_size = *vt2; if (vt1_size != vt2_size || memcmp(vt2, vt1, vt1_size)) continue; - vt_use = *it; + vt_use = vtable; buf_.pop(GetSize() - vtableoffsetloc); break; } diff --git a/Framework/LiveData/src/SNSLiveEventDataListener.cpp b/Framework/LiveData/src/SNSLiveEventDataListener.cpp index fb5f61f9406cd4fc7406e62d2fea0aafff5e1f44..6053943d2a1c83a258b435ae49bdb3e3b9862fb1 100644 --- a/Framework/LiveData/src/SNSLiveEventDataListener.cpp +++ b/Framework/LiveData/src/SNSLiveEventDataListener.cpp @@ -50,6 +50,10 @@ const std::string PAUSE_PROPERTY("pause"); const std::string SCAN_PROPERTY("scan_index"); const std::string PROTON_CHARGE_PROPERTY("proton_charge"); +// These are names for some string properties (not time series) +const std::string RUN_TITLE_PROPERTY("run_title"); +const std::string EXPERIMENT_ID_PROPERTY("experiment_identifier"); + // Helper function to get a DateAndTime value from an ADARA packet header Mantid::Types::Core::DateAndTime timeFromPacket(const ADARA::PacketHeader &hdr) { @@ -1011,8 +1015,7 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::DeviceDescriptorPkt &pkt) { // Find the process_variables element // Note: for now, I'm ignoring the 'device_name' & 'enumeration' elements - // because I don't - // think I need them + // because I don't think I need them const Poco::XML::Node *node = deviceNode->firstChild(); while (node && node->nodeName() != "process_variables") { @@ -1193,6 +1196,97 @@ bool SNSLiveEventDataListener::rxPacket(const ADARA::AnnotationPkt &pkt) { return false; } +/// Parse a Run Information packet + +/// Overrides the default function defined in ADARA::Parser and processes +/// data from ADARA::RunInfoPkt packets. Specifically, it looks for the +/// proposal id and run title and stores those values in properties in the +/// workspace. +/// @param pkt The packet to be parsed +/// @return Returns false if there were no problems. Returns true if there +/// was an error and packet parsing should be interrupted +bool SNSLiveEventDataListener::rxPacket(const ADARA::RunInfoPkt &pkt) { + + // RunInfoPkts are mostly just blocks of XML. + Poco::XML::DOMParser parser; + Poco::AutoPtr<Poco::XML::Document> doc = parser.parseString(pkt.info()); + const Poco::XML::Node *runInfoNode = doc->firstChild(); + + // The root of the XML should be "runinfo". + while (runInfoNode && runInfoNode->nodeName() != "runinfo") { + runInfoNode = runInfoNode->nextSibling(); + } + + if (!runInfoNode) { + g_log.error("Run info packet did not contain a 'runinfo' element!! " + "This should never happen!"); + return false; + } + + // The two elements we're looking for (proposal_id and run_title) should + // be children of the runInfoNode. (Note that run_number is also in there, + // but we already get that from the RunStatusPkt.) + std::string proposalID; + std::string runTitle; + const Poco::XML::Node *node = runInfoNode->firstChild(); + while (node) { + // iterate through each individual variable... + if (node->nodeName() == "proposal_id") { + const Poco::XML::Node *textElement = node->firstChild(); + if (textElement) { + proposalID = textElement->nodeValue(); + } + } else if (node->nodeName() == "run_title") { + const Poco::XML::Node *textElement = node->firstChild(); + if (textElement) { + runTitle = textElement->nodeValue(); + } + } + + // If we've got everything we need, we can break out of the while loop + if (proposalID.length() && runTitle.length()) { + break; + } + + node = node->nextSibling(); + } + + if (proposalID.length()) { + Property *prop = + m_eventBuffer->mutableRun().getProperty(EXPERIMENT_ID_PROPERTY); + + // Sanity check: We're likely to get multiple RunInfo packets in a + // run, but the values shouldn't change mid-run... + std::string prevPropVal = prop->value(); + if (prevPropVal.length() && prevPropVal != proposalID) { + g_log.error("Proposal ID in the current run info packet has changed! " + "This shouldn't happen! (Keeping new ID value.)"); + } + prop->setValue(proposalID); + } else { + g_log.warning("Run info packet did not contain a proposal ID. " + "Property will be empty."); + } + + if (runTitle.length()) { + Property *prop = + m_eventBuffer->mutableRun().getProperty(RUN_TITLE_PROPERTY); + + // Sanity check + std::string prevPropVal = prop->value(); + if (prevPropVal.length() && prevPropVal != runTitle) { + g_log.error("The run title in the current run info packet has changed!" + " This shouldn't happen! (Keeping new title value.)"); + } + prop->setValue(runTitle); + } else { + g_log.warning("Run info packet did not contain a run title. " + "Property will be empty."); + } + + return false; +} + /// First part of the workspace initialization /// Performs various initialization steps that can (and, in some @@ -1213,6 +1307,12 @@ void SNSLiveEventDataListener::initWorkspacePart1() { prop = new TimeSeriesProperty<double>(PROTON_CHARGE_PROPERTY); prop->setUnits("picoCoulomb"); m_eventBuffer->mutableRun().addLogData(prop); + + // Same for a couple of other properties (that are not time series) + prop = new PropertyWithValue<std::string>(RUN_TITLE_PROPERTY, ""); + m_eventBuffer->mutableRun().addLogData(prop); + prop = new PropertyWithValue<std::string>(EXPERIMENT_ID_PROPERTY, ""); + m_eventBuffer->mutableRun().addLogData(prop); } /// Second part of the workspace initialization diff --git a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h index a7f1e0e423de383241c072f1f2f194e194019c7b..6a83ccdd50fcf8815e054f1efd6ba00631a2533f 100644 --- a/Framework/LiveData/test/KafkaEventStreamDecoderTest.h +++ b/Framework/LiveData/test/KafkaEventStreamDecoderTest.h @@ -54,7 +54,7 @@ public: //---------------------------------------------------------------------------- void test_Single_Period_Event_Stream() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; using Mantid::API::Workspace_sptr; using Mantid::DataObjects::EventWorkspace; using namespace Mantid::LiveData; @@ -92,7 +92,7 @@ public: void test_Multiple_Period_Event_Stream() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; using Mantid::API::Workspace_sptr; using Mantid::API::WorkspaceGroup; using Mantid::DataObjects::EventWorkspace; @@ -134,7 +134,7 @@ public: void test_End_Of_Run_Reported_After_Run_Stop_Reached() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; using Mantid::API::Workspace_sptr; using Mantid::DataObjects::EventWorkspace; using namespace Mantid::LiveData; @@ -173,7 +173,7 @@ public: void test_Get_All_Run_Events_When_Run_Stop_Message_Received_Before_Last_Event_Message() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; using Mantid::API::Workspace_sptr; using Mantid::DataObjects::EventWorkspace; using namespace Mantid::LiveData; @@ -211,7 +211,7 @@ public: void test_Sample_Log_From_Event_Stream() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; using Mantid::API::Workspace_sptr; using Mantid::DataObjects::EventWorkspace; using namespace Mantid::LiveData; @@ -244,7 +244,7 @@ public: void test_Empty_Event_Stream_Waits() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; auto mockBroker = std::make_shared<MockKafkaBroker>(); EXPECT_CALL(*mockBroker, subscribe_(_, _)) @@ -260,12 +260,44 @@ public: TS_ASSERT(!decoder->isCapturing()); } + void + test_No_Exception_When_Event_Message_Without_Facility_Data_Is_Processed() { + using namespace ::testing; + using namespace KafkaTesting; + using Mantid::API::Workspace_sptr; + using Mantid::DataObjects::EventWorkspace; + + auto mockBroker = std::make_shared<MockKafkaBroker>(); + EXPECT_CALL(*mockBroker, subscribe_(_, _)) + .Times(Exactly(3)) + .WillOnce(Return(new FakeEventSubscriber)) + .WillOnce(Return(new FakeRunInfoStreamSubscriber(1))) + .WillOnce(Return(new FakeISISSpDetStreamSubscriber)); + auto decoder = createTestDecoder(mockBroker); + startCapturing(*decoder, 2); + Workspace_sptr workspace; + TS_ASSERT_THROWS_NOTHING(workspace = decoder->extractData()); + TS_ASSERT_THROWS_NOTHING(decoder->stopCapture()); + TS_ASSERT(!decoder->isCapturing()); + + // Check we did process the event message and extract the events + TSM_ASSERT("Expected non-null workspace pointer from extractData()", + workspace); + auto eventWksp = boost::dynamic_pointer_cast<EventWorkspace>(workspace); + TSM_ASSERT( + "Expected an EventWorkspace from extractData(). Found something else", + eventWksp); + + TSM_ASSERT_EQUALS("Expected 3 events from the event message", 3, + eventWksp->getNumberEvents()); + } + //---------------------------------------------------------------------------- // Failure tests //---------------------------------------------------------------------------- void test_Error_In_Stream_Extraction_Throws_Error_On_ExtractData() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; auto mockBroker = std::make_shared<MockKafkaBroker>(); EXPECT_CALL(*mockBroker, subscribe_(_, _)) @@ -283,7 +315,7 @@ public: void test_Empty_SpDet_Stream_Throws_Error_On_ExtractData() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; auto mockBroker = std::make_shared<MockKafkaBroker>(); EXPECT_CALL(*mockBroker, subscribe_(_, _)) @@ -301,7 +333,7 @@ public: void test_Empty_RunInfo_Stream_Throws_Error_On_ExtractData() { using namespace ::testing; - using namespace ISISKafkaTesting; + using namespace KafkaTesting; auto mockBroker = std::make_shared<MockKafkaBroker>(); EXPECT_CALL(*mockBroker, subscribe_(_, _)) diff --git a/Framework/LiveData/test/KafkaTesting.h b/Framework/LiveData/test/KafkaTesting.h index b8a45780121c74151bbe6263c0e86a4bcf070f2c..01e1d6b342b66878188c23b973e0220b54a98af9 100644 --- a/Framework/LiveData/test/KafkaTesting.h +++ b/Framework/LiveData/test/KafkaTesting.h @@ -18,7 +18,7 @@ GCC_DIAG_ON(conversion) #include <ctime> -namespace ISISKafkaTesting { +namespace KafkaTesting { // ----------------------------------------------------------------------------- // Mock broker to inject fake subscribers @@ -122,7 +122,7 @@ public: } }; -void fakeReceiveAnEventMessage(std::string *buffer, int32_t nextPeriod) { +void fakeReceiveAnISISEventMessage(std::string *buffer, int32_t nextPeriod) { flatbuffers::FlatBufferBuilder builder; std::vector<uint32_t> spec = {5, 4, 3, 2, 1, 2}; std::vector<uint32_t> tof = {11000, 10000, 9000, 8000, 7000, 6000}; @@ -143,6 +143,22 @@ void fakeReceiveAnEventMessage(std::string *buffer, int32_t nextPeriod) { builder.GetSize()); } +void fakeReceiveAnEventMessage(std::string *buffer) { + flatbuffers::FlatBufferBuilder builder; + std::vector<uint32_t> spec = {5, 4, 3}; + std::vector<uint32_t> tof = {11000, 10000, 9000}; + uint64_t frameTime = 1; + + auto messageFlatbuf = CreateEventMessage( + builder, builder.CreateString("KafkaTesting"), 0, frameTime, + builder.CreateVector(tof), builder.CreateVector(spec)); + FinishEventMessageBuffer(builder, messageFlatbuf); + + // Copy to provided buffer + buffer->assign(reinterpret_cast<const char *>(builder.GetBufferPointer()), + builder.GetSize()); +} + void fakeReceiveASampleEnvMessage(std::string *buffer) { flatbuffers::FlatBufferBuilder builder; // Sample environment log @@ -206,7 +222,7 @@ public: std::string &topic) override { assert(message); - fakeReceiveAnEventMessage(message, m_nextPeriod); + fakeReceiveAnISISEventMessage(message, m_nextPeriod); m_nextPeriod = ((m_nextPeriod + 1) % m_nperiods); UNUSED_ARG(offset); @@ -236,6 +252,58 @@ private: int32_t m_nextPeriod; }; +// --------------------------------------------------------------------------------------- +// Fake non-institution-specific event stream to provide event and sample +// environment data +// --------------------------------------------------------------------------------------- +class FakeEventSubscriber : public Mantid::LiveData::IKafkaStreamSubscriber { +public: + void subscribe() override {} + void subscribe(int64_t offset) override { UNUSED_ARG(offset) } + void consumeMessage(std::string *message, int64_t &offset, int32_t &partition, + std::string &topic) override { + assert(message); + + switch (m_nextOffset) { + case 0: + fakeReceiveARunStartMessage(message, 1000, "2016-08-31T12:07:42", + "HRPDTEST", 1); + break; + case 2: + fakeReceiveARunStopMessage(message, m_stopTime); + break; + default: + fakeReceiveAnEventMessage(message); + } + m_nextOffset++; + + UNUSED_ARG(offset); + UNUSED_ARG(partition); + UNUSED_ARG(topic); + } + std::unordered_map<std::string, std::vector<int64_t>> + getOffsetsForTimestamp(int64_t timestamp) override { + UNUSED_ARG(timestamp); + return {std::pair<std::string, std::vector<int64_t>>(m_topicName, {1})}; + } + std::unordered_map<std::string, std::vector<int64_t>> + getCurrentOffsets() override { + std::unordered_map<std::string, std::vector<int64_t>> offsets; + return {std::pair<std::string, std::vector<int64_t>>(m_topicName, {1})}; + } + void seek(const std::string &topic, uint32_t partition, + int64_t offset) override { + UNUSED_ARG(topic); + UNUSED_ARG(partition); + UNUSED_ARG(offset); + } + +private: + std::string m_topicName = "topic_name"; + int m_nextOffset = 0; + std::string m_stopTime = "2016-08-31T12:07:52"; +}; + // ----------------------------------------------------------------------------- // Fake event stream to provide sample environment data // ----------------------------------------------------------------------------- @@ -354,7 +422,7 @@ public: m_nperiods); break; default: - fakeReceiveAnEventMessage(buffer, 0); + fakeReceiveAnISISEventMessage(buffer, 0); } topic = "topic_name"; offset = m_nextOffset; @@ -441,6 +509,6 @@ private: // These match the detector numbers in HRPDTEST_Definition.xml std::vector<int32_t> m_detid = {1001, 1002, 1100, 901000, 10100}; }; -} // namespace ISISKafkaTesting +} // namespace KafkaTesting #endif // MANTID_LIVEDATA_ISISKAFKAEVENTSTREAMDECODERTESTMOCKS_H_ diff --git a/Framework/LiveData/test/LoadLiveDataTest.h b/Framework/LiveData/test/LoadLiveDataTest.h index 028cf8db44bba55227d5662481c9cdbf6604a585..a8830030a22f405158b5e3cdb3fdb6c242017c38 100644 --- a/Framework/LiveData/test/LoadLiveDataTest.h +++ b/Framework/LiveData/test/LoadLiveDataTest.h @@ -180,8 +180,8 @@ public: TS_ASSERT_EQUALS(ws1->getNumberHistograms(), 2); double total; total = 0; - for (auto it = ws1->readY(0).begin(); it != ws1->readY(0).end(); it++) - total += *it; + for (double yValue : ws1->readY(0)) + total += yValue; TS_ASSERT_DELTA(total, 100.0, 1e-4); // Next one adds the histograms together @@ -191,8 +191,8 @@ public: // The new total signal is 200.0 total = 0; - for (auto it = ws1->readY(0).begin(); it != ws1->readY(0).end(); it++) - total += *it; + for (double yValue : ws1->readY(0)) + total += yValue; TS_ASSERT_DELTA(total, 200.0, 1e-4); TSM_ASSERT("Workspace being added stayed the same pointer", ws1 == ws2); diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h index 2763c719ce6ea44486061d2c69be1b738ce93904..cb6bddffcc849d1dc4b65ef57562ca53ac9de890 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AccumulateMD.h @@ -88,6 +88,9 @@ class DLLExport AccumulateMD : public API::DataProcessorAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MergeMD"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AndMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AndMD.h index 8158a03297139e96ff8331d34975869a799c104d..6a2ac1cef7a32b6ae3f2afc180b4b9f151a3d0f5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AndMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/AndMD.h @@ -38,6 +38,9 @@ class DLLExport AndMD : public BooleanBinaryOperationMD { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"XorMD", "OrMD", "NotMD"}; + } private: void execHistoHisto( diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BinMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BinMD.h index d97ebc5c22f8e5125ca171b68d8a2113e85bef9b..ff47996ac36e6c01a1f5a5d8123ac01f5601f775 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BinMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/BinMD.h @@ -44,6 +44,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SliceMDHisto", "ProjectMD", "CutMD", "SliceMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Slicing"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CalculateCoverageDGS.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CalculateCoverageDGS.h index 29e327cdfe630daa2610568364851292193cd36c..a00c63a3bb4e09b1ccdb9a14aea24ed90f1d8432 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CalculateCoverageDGS.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CalculateCoverageDGS.h @@ -37,6 +37,9 @@ public: CalculateCoverageDGS(); const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SetGoniometer", "SetUB"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CentroidPeaksMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CentroidPeaksMD2.h index a6239f7da84ac4c21c278bd908675c74144b3bdc..642109658fb8fad5dabb30db38377066b177d1db 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CentroidPeaksMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CentroidPeaksMD2.h @@ -28,6 +28,9 @@ public: /// Algorithm's version for identification int version() const override { return 2; }; + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksMD", "CentroidPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Peaks"; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CloneMDWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CloneMDWorkspace.h index b6de872d91f83fa2673fbb0c06160b52ef94f207..7e39035ac96be9edfd1a51538ddf5a5465ed34fe 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CloneMDWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CloneMDWorkspace.h @@ -49,7 +49,7 @@ public: int version() const override { return 1; }; /// Algorithm's category for identification const std::string category() const override { - return "MDAlgorithms\\Utility\\Workspaces;MDAlgorithms\\Creation"; + return R"(MDAlgorithms\Utility\Workspaces;MDAlgorithms\Creation)"; } private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h index eb229efb9da5f02237771569429c1f4ecba45630..4071a31b64841b920b5499ae19d4255c3151fcbf 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertMDHistoToMatrixWorkspace.h @@ -62,6 +62,10 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD", "CreateMDHistoWorkspace", + "ConvertTableToMatrixWorkspace", "MDHistoToWorkspace2D"}; + } /// Algorithm's category for identification const std::string category() const override { return "Utility\\Workspaces;MDAlgorithms\\Transforms"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h index b59283a4daab9cd06b5944492462487a9e52d1ed..b81698b736a1eb800f1d9bee4ec198d5fc42992d 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDetectorFaceMD.h @@ -48,6 +48,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h index 15374ecf3f11b4c0d637d055789a35cb90001b4e..55bf4e3230f8e7c7b0579bca86aae8dd7302eb03 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToDiffractionMDWorkspace3.h @@ -21,6 +21,9 @@ class DLLExport ConvertToDiffractionMDWorkspace3 public: /// Algorithm's version for identification int version() const override { return 3; } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD", "SetSpecialCoordinates"}; + } private: void init() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h index 8f7f443248d6b73ff04d2a9b9700807f5b641864..4b3c7bb5c556713e05fad7d6381720da3394e42e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMD.h @@ -64,6 +64,11 @@ public: /// Algorithm's version for identification int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToDiffractionMDWorkspace", "ConvertToMDMinMaxGlobal", + "ConvertToMDMinMaxLocal", "CreateMDWorkspace", + "SetSpecialCoordinates"}; + } private: std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h index 31d9867bcef75fa14e730a1ef298e6c143c90543..018e6ad2c27d13f2d7c3f75cafe13a4c91892566 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxGlobal.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h index 67f1f5a48e8ff0493c19503aeec80cc5068f30d7..7f27270b0dd367762d4042ca3d7410d680435ed5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToMDMinMaxLocal.h @@ -41,6 +41,9 @@ public: } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD"}; + } protected: // for testing void findMinMaxValues(MDWSDescription &WSDescription, diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToReflectometryQ.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToReflectometryQ.h index b4e4c9dd97a6ee0174a68590933a5c5536c7e8bb..164fe699b78d0da366a16d5b1de323717f5e2366 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToReflectometryQ.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ConvertToReflectometryQ.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertUnits"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h index a650274c89d82d29ed03c3071fe55d20841d02d8..45dd364aea1a515a8993e65414f83916124303d5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMD.h @@ -45,6 +45,9 @@ class MANTID_MDALGORITHMS_DLL CreateMD : public API::DataProcessorAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateMDWorkspace"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h index ec386117d678a907e9995699a385b00bb791f4b0..4908e723d2f6353302b332be2916691aae7884d5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDHistoWorkspace.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD", "CreateMDWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h index 5b9c8aaa67bb0a0ff90ecf0f9e72c6d6474f0d01..dc8041f778f80fa83079b4926b217b2664ad640a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CreateMDWorkspace.h @@ -36,6 +36,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"ConvertToMD", "CreateMDHistoWorkspace", "FakeMDEventData", + "CreateMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Creation"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h index 92aa260c570984e1db299322391c47ed3f00a00c..39adbc42dabc3151a37d8a0e647352a0256ffe79 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/CutMD.h @@ -42,6 +42,9 @@ class DLLExport CutMD : public API::DataProcessorAlgorithm { public: const std::string name() const override { return "CutMD"; } int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"SliceMDHisto", "ProjectMD", "SliceMD", "BinMD"}; + } const std::string summary() const override { return "Slices multidimensional workspaces using input projection " "information and binning limits."; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DivideMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DivideMD.h index 2c1450dac3bd7693fb33f5dee10d3853fb2ccf9b..d95be8e21932a3b215d6669576b48585fd7cf313 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DivideMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/DivideMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MinusMD", "MultiplyMD", "PlusMD", "PowerMD"}; + } private: /// Is the operation commutative? diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EqualToMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EqualToMD.h index 0facbbb05363791d3550f68922a71a7839b8cec1..c6ca87f2652a76f9322c9665a23791b8adbc90df 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EqualToMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EqualToMD.h @@ -37,6 +37,9 @@ class DLLExport EqualToMD : public BooleanBinaryOperationMD { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"GreaterThanMD", "LessThanMD", "NotMD"}; + } private: void initExtraProperties() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EvaluateMDFunction.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EvaluateMDFunction.h index 50bac7d0c1459c4a694b1e615a19f7534544c4e3..3dd3d240522462fdcd5dc941e3933948100483f4 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EvaluateMDFunction.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/EvaluateMDFunction.h @@ -38,6 +38,9 @@ public: const std::string name() const override { return "EvaluateMDFunction"; } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateMDWorkspace", "FakeMDEventData"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ExponentialMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ExponentialMD.h index 84fa2e1abb447c79b22daf788672a0587e6242df..ed0262ff09af95e769c29c608797801ad636da0e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ExponentialMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ExponentialMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PowerMD", "LogarithmMD"}; + } private: /// Check the inputs and throw if the algorithm cannot be run diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FakeMDEventData.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FakeMDEventData.h index acb6ae4924718c9cd735796e25817795f63df340..043e75aea385a69fcbea1edbea847f4ae31269e0 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FakeMDEventData.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FakeMDEventData.h @@ -44,6 +44,9 @@ public: } /// Algorithm's verion for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"CreateMDWorkspace", "EvaluateMDFunction"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Creation"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h index 6f21dbd40aee83410955893bab59f9f229fc814c..cd8ce88a8d6452b44a9431fb1adb64d383c42471 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/FindPeaksMD.h @@ -36,6 +36,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"FindPeaks"}; + } /// Algorithm's category for identification const std::string category() const override { return "Optimization\\PeakFinding;MDAlgorithms\\Peaks"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GreaterThanMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GreaterThanMD.h index 6df08bee89dd20485fa2860d159dd342dd8e09fc..89d2cbad0a02f9fe5013c52f1bb1c914296aae8f 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GreaterThanMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/GreaterThanMD.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LessThanMD", "EqualToMD"}; + } private: bool acceptScalar() const override { return true; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDEventWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDEventWorkspace.h index 1be7c21e36199a38a7d5b35e1d7b4cbed7bd4454..6d0b420318ad15968f8b77bbd6202163d2e0c2bc 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDEventWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDEventWorkspace.h @@ -45,6 +45,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ImportMDHistoWorkspace"}; + } const std::string category() const override; /// Flag used to indicate the dimension block in the file diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h index 61acba6d723bc9004de92c1fd1a08505a5ecc0c7..815c78243c8058daef0c71d8431050e3e8f1b528 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ImportMDHistoWorkspace.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ImportMDEventWorkspace"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h index 2a3c8dad79e6566e77c32e5a6cae2b105f549359..aa5f1fca90531229ada789ed93dd44ccd75c9ca2 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoids.h @@ -27,6 +27,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"IntegrateEllipsoidsTwoStep"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h index 050e00a795a65ace7ee040f77317c6f8097232ab..674f9a3ff44e0f2c6675549ce4b72698a59eed0a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateEllipsoidsTwoStep.h @@ -45,6 +45,9 @@ public: const std::string name() const override; /// Get the version of this algorithm int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"IntegrateEllipsoids"}; + } /// Get the category of this algorithm const std::string category() const override; /// Summary of algorithms purpose diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateFlux.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateFlux.h index 281667f1de9043327af3f7e6b9fb2848194e5da1..14d481f5ab2c33f8dd541c15cf337106bbf30ec2 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateFlux.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateFlux.h @@ -46,6 +46,9 @@ class DLLExport IntegrateFlux : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Integration"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h index 813e82138b3aaf36caff24de37310e4e446273ba..9901172d10103d0a94fce0cb02b28a17ae23f2ce 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegrateMDHistoWorkspace.h @@ -37,6 +37,9 @@ class DLLExport IntegrateMDHistoWorkspace : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SliceMDHisto"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h index 04360a2a6c4aaa783ce10adaf2cbb5446591945d..5127fef4c8bf538c50e9e643b0c039a7740aae7b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksCWSD.h @@ -33,6 +33,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksHybrid", "IntegratePeaksMDHKL", "IntegratePeaksMD", + "IntegratePeaksUsingClusters"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Peaks"; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h index eac3242ca28170a61551c24efa86840a8c90e9c6..8da44d60ff9fa98b1aa06d1e5e09e3c9edc229e3 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMD2.h @@ -32,6 +32,10 @@ public: /// Algorithm's version for identification int version() const override { return 2; }; + const std::vector<std::string> seeAlso() const override { + return {"CentroidPeaksMD", "IntegratePeaksHybrid", "IntegratePeaksMDHKL", + "IntegratePeaksUsingClusters", "IntegratePeaksCWSD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Peaks"; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h index b97d605f74cb6d492c9eaf12735852cff22e0199..a4cabeaf9e37432de291e368e67da632da62adc5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/IntegratePeaksMDHKL.h @@ -29,6 +29,10 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"IntegratePeaksHybrid", "IntegratePeaksUsingClusters", + "IntegratePeaksMD", "IntegratePeaksCWSD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Peaks"; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LessThanMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LessThanMD.h index 0eb6c2c5a8306a5c7d6618834cd5a8e6ff73d358..c478493573c9b175839eb8a5d2e46dc5d9aa106b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LessThanMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LessThanMD.h @@ -37,6 +37,9 @@ class DLLExport LessThanMD : public BooleanBinaryOperationMD { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"GreaterThanMD", "EqualToMD"}; + } private: bool acceptScalar() const override { return true; } diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h index 45a2f6ab84802c5a57be9caf711086a9693029f5..34be74d57520c9f445fd8f040a4f1242dc827914 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadMD.h @@ -51,6 +51,7 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { return {"SaveMD"}; } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\DataHandling"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h index c770267191d96ed67ae39e479aed64d98e58fb42..b4936899c25fd9bf811c1f3d33765ccbb3a81193 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LoadSQW2.h @@ -47,6 +47,9 @@ class DLLExport LoadSQW2 : public API::IFileLoader<Kernel::FileDescriptor> { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadNXSPE", "SaveNXSPE"}; + } const std::string category() const override; const std::string summary() const override; int confidence(Kernel::FileDescriptor &descriptor) const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LogarithmMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LogarithmMD.h index b018c748317c156c89f619ff6f4141636c1a9bd6..21ef39b0ec6a7f6757b225c6119cb80a78f34749 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LogarithmMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/LogarithmMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PowerMD", "ExponentialMD"}; + } private: void initExtraProperties() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormDirectSC.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormDirectSC.h index 9e05a140fe0fb07843902ccd82a731cacddc7f9d..8239e46772954ab534e42e4523f88c232dd0c18a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormDirectSC.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormDirectSC.h @@ -39,6 +39,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MDNormSCD", "MDNormSCDPreprocessIncoherent"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormSCD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormSCD.h index 5b18915c2920df28b5675b3151318e5ead64e9d8..749f6007e75b44aafb91075a0778ceb8165a9a11 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormSCD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MDNormSCD.h @@ -39,6 +39,9 @@ public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MDNormSCDPreprocessIncoherent", "MDNormDirectSC"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MaskMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MaskMD.h index e1e0b6a9990575bf5135fb5669612ef530a1daec..cd6106e261fa8a675a0549d47e5ac6ef8f6b0c4e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MaskMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MaskMD.h @@ -47,6 +47,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MaskDetectors"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMD.h index 8d8155f633557e4c73636f6e6b4c0942aa8462d2..39a0ac1b40109e2923b3b56a864d5c18352c844f 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMD.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MergeMDFiles", "AccumulateMD"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h index 04860beaa88cf087a6a010bd786ea9b431c44408..cac9e9687137d6888dccc241f36640f32a0af2c1 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MergeMDFiles.h @@ -54,6 +54,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MergeMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Creation"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MinusMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MinusMD.h index 6acb7cb6aeb7bb533654a6b520992ac9498cd304..d6d2baf9733c1bb9cd2ebb87cb2cdaef797141a5 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MinusMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MinusMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PlusMD", "MultiplyMD", "DivideMD", "PowerMD"}; + } private: /// Is the operation commutative? diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MultiplyMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MultiplyMD.h index 71655bf240945ab79d446b25d67303b9a45b4c71..5f69fcd6861f1c9e530516480b7f4164fcdddc37 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MultiplyMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/MultiplyMD.h @@ -43,6 +43,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MinusMD", "PlusMD", "DivideMD", "PowerMD"}; + } private: /// Is the operation commutative? diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NotMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NotMD.h index cffce98eaf441afdad3d93438e3d5ad117126092..c855fbcbcc7b9a2fc590851a9e3da6b6ce0fe014 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NotMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/NotMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AndMD", "OrMD", "XorMD"}; + } private: /// Check the inputs and throw if the algorithm cannot be run diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OrMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OrMD.h index 4990ac1658eb82c354639e71c0daffd85747be32..5cbf604ad4153e12855d9a2e1735e853893efd0a 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OrMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/OrMD.h @@ -37,6 +37,9 @@ class DLLExport OrMD : public BooleanBinaryOperationMD { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AndMD", "XorMD", "NotMD"}; + } private: void execHistoHisto( diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlusMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlusMD.h index edfd89a6db928b5768f2dc0b29c4d665404c4ded..5a34023e7c2b94bfa4667d0959f359c94e7b110e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlusMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PlusMD.h @@ -47,6 +47,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"MinusMD", "MultiplyMD", "DivideMD", "PowerMD"}; + } private: /// Is the operation commutative? diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PowerMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PowerMD.h index 1f9070f74c14542da6629dfaf52e62ef6b8061e9..f4d1e18e28658ea3083b36c8c2179871fffe22a2 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PowerMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/PowerMD.h @@ -42,6 +42,10 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"MinusMD", "MultiplyMD", "DivideMD", + "PlusMD", "LogarithmMD", "ExponentialMD"}; + } private: void initExtraProperties() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h index dd236708ec225878d26e2f4ad265ddc15de0c618..e4eb5ed095f23bb5c57a73f764adaaa059572e2d 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/FitResolutionConvolvedModel.h @@ -35,6 +35,9 @@ public: return "Fits a cuts/slices from an MDEventWorkspace using a resolution " "function convolved with a foreground model"; } + const std::vector<std::string> seeAlso() const override { + return {"SimulateResolutionConvolvedModel"}; + } int version() const override; const std::string category() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h index d869716128e4943b2e8f2682791041eea930d14a..e068f43de12174fbc94d4474079044fe959c8428 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/Quantification/SimulateResolutionConvolvedModel.h @@ -43,7 +43,9 @@ public: const std::string summary() const override { return "Runs a simulation of a model with a selected resolution function"; } - + const std::vector<std::string> seeAlso() const override { + return {"FitResolutionConvolvedModel"}; + } int version() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ReplicateMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ReplicateMD.h index cf3cb6ce70382f5607d333fcb2567eb5c728fa7a..3c8286f0b3590a12ecaedb29a4cbf4f8b670db2e 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ReplicateMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ReplicateMD.h @@ -45,6 +45,9 @@ class MANTID_MDALGORITHMS_DLL ReplicateMD : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"CreateMDWorkspace", "MergeMD"}; + } const std::string category() const override; const std::string summary() const override; /// Valdiate the algorithm inputs diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h index 0f64bd206d0dfb6cb997838cc250aa21f94e8e66..5f20735ef2ea148271bed84c3682acf0a23ab6ca 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveMD2.h @@ -43,6 +43,9 @@ public: /// Algorithm's version for identification int version() const override { return 2; }; + const std::vector<std::string> seeAlso() const override { + return {"LoadMD", "SaveZODS"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\DataHandling"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveZODS.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveZODS.h index 28aa71218493fcf7534852f01566b083f0ca9665..dc49617eb411f053536547f6a15deeadbe9995b1 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveZODS.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SaveZODS.h @@ -43,6 +43,7 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { return {"SaveMD"}; } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SliceMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SliceMD.h index 9b04faf63ee3940cd3c62b088799cdadcb54401e..4facc974e9e60ef0833c0adb414323b8e49de843 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SliceMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SliceMD.h @@ -57,6 +57,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"SliceMDHisto", "ProjectMD", "CutMD", "BinMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Slicing"; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h index 1b5c16d16e85ff34f21b0e44fe5c4dcedbf68623..4d42b9b57d19b0ce9ae99b58136871971d9f63f6 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/SmoothMD.h @@ -46,6 +46,9 @@ class DLLExport SmoothMD : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"ThresholdMD"}; + } const std::string category() const override; const std::string summary() const override; std::map<std::string, std::string> validateInputs() override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ThresholdMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ThresholdMD.h index 6461f45ade87a92144c4cc1afc92abb8737b1061..46923478f9ed38ac62a3267a7dbc9c8f346ddba0 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ThresholdMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/ThresholdMD.h @@ -39,6 +39,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"SmoothMD"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransformMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransformMD.h index c697d5e048d3bc29023ca8640e4268d393b7dd66..10479c11f61df25246bc64c86336a1b0e3875d5b 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransformMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransformMD.h @@ -42,6 +42,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"InvertMDDim"}; + } const std::string category() const override; private: diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransposeMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransposeMD.h index d1a9300c8ba6b18cf152d05d164b6f18cb906cc0..ac5308243e0deca4197beb923cff563946cc66c8 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransposeMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/TransposeMD.h @@ -35,6 +35,9 @@ class MANTID_MDALGORITHMS_DLL TransposeMD : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"Transpose3D", "Transpose"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WeightedMeanMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WeightedMeanMD.h index 6068aa04784d2045c30438aa695b8f4c94650e7d..5e200f69f9e437a097e0aa73199993e088627a48 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WeightedMeanMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/WeightedMeanMD.h @@ -44,6 +44,9 @@ public: /// Algorithm's version for identification int version() const override { return 1; }; + const std::vector<std::string> seeAlso() const override { + return {"WeightedMean"}; + } private: /// Is the operation commutative? diff --git a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/XorMD.h b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/XorMD.h index 0456fc93eb23e496f0e11b00680e70fa28f61b00..ab39c4cf020bf91824adcd45693a83dd6766f0d9 100644 --- a/Framework/MDAlgorithms/inc/MantidMDAlgorithms/XorMD.h +++ b/Framework/MDAlgorithms/inc/MantidMDAlgorithms/XorMD.h @@ -37,6 +37,9 @@ class DLLExport XorMD : public BooleanBinaryOperationMD { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"AndMD", "OrMD", "NotMD"}; + } private: void execHistoHisto( diff --git a/Framework/MDAlgorithms/src/BinMD.cpp b/Framework/MDAlgorithms/src/BinMD.cpp index 3346daac0c5044f79ba7a8d9e3128c46d9583457..e1c84d9b869c2a61297aa0ab6aa7f2ecb927fa99 100644 --- a/Framework/MDAlgorithms/src/BinMD.cpp +++ b/Framework/MDAlgorithms/src/BinMD.cpp @@ -103,7 +103,7 @@ inline void BinMD::binMDBox(MDBox<MDE, nd> *box, const size_t *const chunkMin, // There is a check that the number of events is enough for it to make sense // to do all this processing. size_t numVertexes = 0; - coord_t *vertexes = box->getVertexesArray(numVertexes); + auto vertexes = box->getVertexesArray(numVertexes); // All vertexes have to be within THE SAME BIN = have the same linear index. size_t lastLinearIndex = 0; @@ -111,7 +111,7 @@ inline void BinMD::binMDBox(MDBox<MDE, nd> *box, const size_t *const chunkMin, for (size_t i = 0; i < numVertexes; i++) { // Cache the center of the event (again for speed) - const coord_t *inCenter = vertexes + i * nd; + const coord_t *inCenter = vertexes.get() + i * nd; // Now transform to the output dimensions m_transform->apply(inCenter, outCenter); @@ -154,8 +154,6 @@ inline void BinMD::binMDBox(MDBox<MDE, nd> *box, const size_t *const chunkMin, break; } // (for each vertex) - delete[] vertexes; - if (!badOne) { // Yes, the entire box is within a single bin // std::cout << "Box at " << box->getExtentsStr() << " is within a diff --git a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp index 1b60b9fda5e59c0fb9dab11aec023d49381a0ca7..38e425b77bcac42146d33d31ad284debc62d87c2 100644 --- a/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWPDMDToSpectra.cpp @@ -449,7 +449,7 @@ void ConvertCWPDMDToSpectra::binMD(API::IMDEventWorkspace_const_sptr mdws, << sourcepos.Y() << ", " << sourcepos.Z() << "\n"; // Go through all events to find out their positions - IMDIterator *mditer = mdws->createIterator(); + auto mditer = mdws->createIterator(); bool scancell = true; size_t nextindex = 1; int currRunIndex = -1; diff --git a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp index f31c9245fc92fdbd23d90567bec3aff37da71f89..018851c2df615ebdbdb31540be58b52021f420c2 100644 --- a/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp +++ b/Framework/MDAlgorithms/src/ConvertCWSDMDtoHKL.cpp @@ -175,7 +175,7 @@ void ConvertCWSDMDtoHKL::exportEvents( vec_event_det.resize(numevents); // Go through to get value - IMDIterator *mditer = mdws->createIterator(); + auto mditer = mdws->createIterator(); size_t nextindex = 1; bool scancell = true; size_t currindex = 0; diff --git a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp index 7a23dca48eabeb2633cf9cfcd9a3547d07535fd0..fd7750cbc9bcfe412a9ddf920f626a4ae194d1e1 100644 --- a/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/CreateMDWorkspace.cpp @@ -41,7 +41,7 @@ std::vector<std::string> parseNames(const std::string &names_string) { // The second part matches anything that doesn't contain a comma // NB, the order of the two parts matters - regex expression("\\[([^\\[]*)\\]|[^,]+"); + regex expression(R"(\[([^\[]*)\]|[^,]+)"); boost::sregex_token_iterator iter(names_string.begin(), names_string.end(), expression, 0); diff --git a/Framework/MDAlgorithms/src/FindPeaksMD.cpp b/Framework/MDAlgorithms/src/FindPeaksMD.cpp index 309a9a590d712fa2416a3916a2758bfe38ffb8b0..9856bc510dc0f0a7615eec1aed5d915113910279 100644 --- a/Framework/MDAlgorithms/src/FindPeaksMD.cpp +++ b/Framework/MDAlgorithms/src/FindPeaksMD.cpp @@ -746,6 +746,10 @@ void FindPeaksMD::exec() { criteria.push_back(std::pair<std::string, bool>("bincount", false)); peakWS->sort(criteria); + for (auto i = 0; i != peakWS->getNumberPeaks(); ++i) { + Peak &p = peakWS->getPeak(i); + p.setPeakNumber(i + 1); + } // Save the output setProperty("OutputWorkspace", peakWS); } diff --git a/Framework/MDAlgorithms/src/FitMD.cpp b/Framework/MDAlgorithms/src/FitMD.cpp index e3fbd3f0e296be263b1a1b3c9e714bc69c700ca5..959a88dd53649df7a14d5e36c78862913f0a1c99 100644 --- a/Framework/MDAlgorithms/src/FitMD.cpp +++ b/Framework/MDAlgorithms/src/FitMD.cpp @@ -97,7 +97,6 @@ void FitMD::createDomain(boost::shared_ptr<API::FunctionDomain> &domain, setParameters(); auto iterator = m_IMDWorkspace->createIterator(); const size_t n = iterator->getDataSize(); - delete iterator; if (m_count == 0) { m_count = n; @@ -233,7 +232,6 @@ boost::shared_ptr<API::Workspace> FitMD::createEventOutputWorkspace( } ++resultValueIndex; } while (inputIter->next()); - delete inputIter; // This splits up all the boxes according to split thresholds and sizes. auto threadScheduler = new Kernel::ThreadSchedulerFIFO(); @@ -342,7 +340,6 @@ size_t FitMD::getDomainSize() const { throw std::runtime_error("FitMD: workspace wasn't defined"); auto iterator = m_IMDWorkspace->createIterator(); size_t n = iterator->getDataSize(); - delete iterator; if (m_count != 0) { if (m_startIndex + m_count > n) throw std::range_error("FitMD: index is out of range"); diff --git a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp index 0446997a822a54d0854e7a37efcd249b3c036dde..3299118922a09d1e6ec334564cff1ed86e108db4 100644 --- a/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp +++ b/Framework/MDAlgorithms/src/GetSpiceDataRawCountsFromMD.cpp @@ -378,7 +378,7 @@ void GetSpiceDataRawCountsFromMD::getDetCounts( vecY.clear(); // Go through all events to find out their positions - IMDIterator *mditer = mdws->createIterator(); + auto mditer = mdws->createIterator(); bool scancell = true; size_t nextindex = 1; @@ -429,8 +429,6 @@ void GetSpiceDataRawCountsFromMD::getDetCounts( scancell = false; } } // ENDOF(while) - - delete (mditer); } //---------------------------------------------------------------------------------------------- diff --git a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp index 7e516c8f36962a81fe8ce232650ef68b475080e3..301bd111b807cbb7b12dd62067a54bbcf7bbea74 100644 --- a/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp +++ b/Framework/MDAlgorithms/src/IntegrateMDHistoWorkspace.cpp @@ -359,9 +359,8 @@ void IntegrateMDHistoWorkspace::exec() { PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < int(outIterators.size()); ++i) { // NOLINT PARALLEL_START_INTERUPT_REGION - boost::scoped_ptr<MDHistoWorkspaceIterator> outIterator( - dynamic_cast<MDHistoWorkspaceIterator *>(outIterators[i])); - + auto outIterator = + dynamic_cast<MDHistoWorkspaceIterator *>(outIterators[i].get()); if (!outIterator) { throw std::logic_error( "Failed to cast iterator to MDHistoWorkspaceIterator"); @@ -386,8 +385,10 @@ void IntegrateMDHistoWorkspace::exec() { double sumNEvents = 0; // Create a thread-local input iterator. - boost::scoped_ptr<MDHistoWorkspaceIterator> inIterator( - dynamic_cast<MDHistoWorkspaceIterator *>(inWS->createIterator())); + + auto iterator = inWS->createIterator(); + auto inIterator = + dynamic_cast<MDHistoWorkspaceIterator *>(iterator.get()); if (!inIterator) { throw std::runtime_error( "Could not convert IMDIterator to a MDHistoWorkspaceIterator"); @@ -401,7 +402,7 @@ void IntegrateMDHistoWorkspace::exec() { rather than iterating over the full set of boxes of the input workspace. */ inIterator->jumpToNearest(outIteratorCenter); - performWeightedSum(inIterator.get(), box, sumSignal, sumSQErrors, + performWeightedSum(inIterator, box, sumSignal, sumSQErrors, sumNEvents); // Use the present position. neighbours // below exclude the current position. // Look at all of the neighbours of our position. We previously @@ -410,7 +411,7 @@ void IntegrateMDHistoWorkspace::exec() { inIterator->findNeighbourIndexesByWidth(widthVector); for (auto neighbourIndex : neighbourIndexes) { inIterator->jumpTo(neighbourIndex); // Go to that neighbour - performWeightedSum(inIterator.get(), box, sumSignal, sumSQErrors, + performWeightedSum(inIterator, box, sumSignal, sumSQErrors, sumNEvents); } diff --git a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp index 9dccb27505ce3f4606fd5d5c930f316f823469c1..2f71a584d41d85065b887f0136c74f9cfd4c6892 100644 --- a/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp +++ b/Framework/MDAlgorithms/src/IntegratePeaksCWSD.cpp @@ -210,7 +210,7 @@ void IntegratePeaksCWSD::simplePeakIntegration( throw std::runtime_error("MDEventWorkspace is not defined."); // Go through to get value - API::IMDIterator *mditer = m_inputWS->createIterator(); + auto mditer = m_inputWS->createIterator(); size_t nextindex = 1; bool scancell = true; // size_t currindex = 0; diff --git a/Framework/MDAlgorithms/src/MaskMD.cpp b/Framework/MDAlgorithms/src/MaskMD.cpp index 72970550e3724315c692e698fa3758290d8cffcd..0487f4e75d7712df2775dd2f905af8a208310ca0 100644 --- a/Framework/MDAlgorithms/src/MaskMD.cpp +++ b/Framework/MDAlgorithms/src/MaskMD.cpp @@ -28,7 +28,7 @@ std::vector<std::string> parseDimensionNames(const std::string &names_string) { // unless they contain square brackets (so that it only matches inner pairs) // The second part matches anything that doesn't contain a comma // NB, the order of the two parts matters - regex expression("\\[([^\\[]*)\\]|[^,]+"); + regex expression(R"(\[([^\[]*)\]|[^,]+)"); boost::sregex_token_iterator iter(names_string.begin(), names_string.end(), expression, 0); diff --git a/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp b/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp index 6bb75c91ab395830a86aaeca8d4439b0b81a4db7..1d4d421642d150d48cbfc6bf9832e2c4f48dda9a 100644 --- a/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp +++ b/Framework/MDAlgorithms/src/Quantification/Resolution/TobyFitResolutionModel.cpp @@ -521,7 +521,6 @@ void TobyFitResolutionModel::preprocess( } while (iterator->next()); g_log.debug() << "Done preprocessing loop:" << timer.elapsed() << " seconds\n"; - delete iterator; } /** diff --git a/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp b/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp index c4efecaad073a109ef52bc2805c45f2a8a3307e5..f757691d623114445676a51759b7aedc66911071 100644 --- a/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp +++ b/Framework/MDAlgorithms/src/Quantification/ResolutionConvolvedCrossSection.cpp @@ -101,7 +101,7 @@ void ResolutionConvolvedCrossSection::function( "Expected FunctionDomainMD in ResolutionConvolvedCrossSection"); } - std::vector<API::IMDIterator *> iterators = m_inputWS->createIterators( + auto iterators = m_inputWS->createIterators( API::FrameworkManager::Instance().getNumOMPThreads()); const int nthreads = static_cast<int>(iterators.size()); std::vector<size_t> resultOffsets(nthreads, 0); @@ -126,7 +126,7 @@ void ResolutionConvolvedCrossSection::function( bool exceptionThrown = false; // required for *_PARALLEL_* macros PARALLEL_FOR_NO_WSP_CHECK() for (int i = 0; i < nthreads; ++i) { - API::IMDIterator *boxIterator = iterators[i]; + auto &boxIterator = iterators[i]; const size_t resultsOffset = resultOffsets[i]; size_t boxIndex(0); @@ -141,10 +141,6 @@ void ResolutionConvolvedCrossSection::function( } while (boxIterator->next()); } CHECK_PARALLEL_EXCEPTIONS // Not standard macros. See top of file for reason - - for (auto boxIterator : iterators) { - delete boxIterator; - } } /** diff --git a/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp b/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp index 4b5f8a242bfe6f39a36f674524c422631b20ad3a..a008b064c2a8eda56ea21430c67aa680f6290b64 100644 --- a/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp +++ b/Framework/MDAlgorithms/src/QueryMDWorkspace.cpp @@ -211,7 +211,7 @@ void QueryMDWorkspace::exec() { output->getColumn(signalColumnName)->setPlotType(2); output->getColumn(errorColumnName)->setPlotType(5); - IMDIterator *it = input->createIterator(); + auto it = input->createIterator(); it->setNormalization(requestedNormalisation); bool bLimitRows = getProperty("LimitRows"); @@ -251,7 +251,6 @@ void QueryMDWorkspace::exec() { rowCounter++; } setProperty("OutputWorkspace", output); - delete it; // IMDEventWorkspace_sptr mdew; diff --git a/Framework/MDAlgorithms/src/ReplicateMD.cpp b/Framework/MDAlgorithms/src/ReplicateMD.cpp index 9966a1f2210600af0078ed386607611240c9c20a..70133087d62a33bd88dbe74feb2b7fc25950d9ae 100644 --- a/Framework/MDAlgorithms/src/ReplicateMD.cpp +++ b/Framework/MDAlgorithms/src/ReplicateMD.cpp @@ -339,9 +339,6 @@ void ReplicateMD::exec() { // Create the output workspace from the shape. MDHistoWorkspace_sptr outputWS(shapeWS->clone()); - auto outIt = std::unique_ptr<MDHistoWorkspaceIterator>( - dynamic_cast<MDHistoWorkspaceIterator *>(outputWS->createIterator())); - const int nThreads = Mantid::API::FrameworkManager::Instance() .getNumOMPThreads(); // NThreads to Request @@ -352,8 +349,7 @@ void ReplicateMD::exec() { for (int it = 0; it < int(iterators.size()); ++it) { // NOLINT PARALLEL_START_INTERUPT_REGION - auto outIt = std::unique_ptr<MDHistoWorkspaceIterator>( - dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it])); + auto outIt = dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it].get()); // Iterate over the output workspace do { diff --git a/Framework/MDAlgorithms/src/SmoothMD.cpp b/Framework/MDAlgorithms/src/SmoothMD.cpp index 34d380cd7b6ccd0d7d0a4cd336a615fcb0a8ef68..33c3258aded9747a45c0ac00546bfe026edbd6ad 100644 --- a/Framework/MDAlgorithms/src/SmoothMD.cpp +++ b/Framework/MDAlgorithms/src/SmoothMD.cpp @@ -192,8 +192,8 @@ SmoothMD::hatSmooth(IMDHistoWorkspace_const_sptr toSmooth, for (int it = 0; it < int(iterators.size()); ++it) { // NOLINT PARALLEL_START_INTERUPT_REGION - boost::scoped_ptr<MDHistoWorkspaceIterator> iterator( - dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it])); + auto iterator = + dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it].get()); if (!iterator) { throw std::logic_error( @@ -318,9 +318,8 @@ SmoothMD::gaussianSmooth(IMDHistoWorkspace_const_sptr toSmooth, for (int it = 0; it < int(iterators.size()); ++it) { // NOLINT PARALLEL_START_INTERUPT_REGION - boost::scoped_ptr<MDHistoWorkspaceIterator> iterator( - dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it])); - + auto iterator = + dynamic_cast<MDHistoWorkspaceIterator *>(iterators[it].get()); if (!iterator) { throw std::logic_error( "Failed to cast IMDIterator to MDHistoWorkspaceIterator"); diff --git a/Framework/MDAlgorithms/src/TransposeMD.cpp b/Framework/MDAlgorithms/src/TransposeMD.cpp index 81cebe92560b7f0a4e36d261734a3fe832ac01e3..6f5d7b219a14653b8aebf2a28cc426b9b36ad8d8 100644 --- a/Framework/MDAlgorithms/src/TransposeMD.cpp +++ b/Framework/MDAlgorithms/src/TransposeMD.cpp @@ -132,7 +132,7 @@ void TransposeMD::exec() { for (int it = 0; it < int(iterators.size()); ++it) { // NOLINT PARALLEL_START_INTERUPT_REGION - auto inIterator = std::unique_ptr<IMDIterator>(iterators[it]); + auto inIterator = iterators[it].get(); do { auto center = inIterator->getCenter(); const coord_t *incoords = center.getBareArray(); diff --git a/Framework/MDAlgorithms/src/WeightedMeanMD.cpp b/Framework/MDAlgorithms/src/WeightedMeanMD.cpp index 89f05670921a5a1070bcd2e8754b1cf358b5305c..8f301e9faa4dc5abf88b1b2e10b98eacae6af552 100644 --- a/Framework/MDAlgorithms/src/WeightedMeanMD.cpp +++ b/Framework/MDAlgorithms/src/WeightedMeanMD.cpp @@ -28,10 +28,10 @@ void WeightedMeanMD::execHistoHisto( Mantid::DataObjects::MDHistoWorkspace_sptr out, Mantid::DataObjects::MDHistoWorkspace_const_sptr operand) { using DataObjects::MDHistoWorkspaceIterator; - MDHistoWorkspaceIterator *lhs_it = - dynamic_cast<MDHistoWorkspaceIterator *>(out->createIterator()); - MDHistoWorkspaceIterator *rhs_it = - dynamic_cast<MDHistoWorkspaceIterator *>(operand->createIterator()); + auto lhs = out->createIterator(); + auto lhs_it = dynamic_cast<MDHistoWorkspaceIterator *>(lhs.get()); + auto rhs = operand->createIterator(); + auto rhs_it = dynamic_cast<MDHistoWorkspaceIterator *>(rhs.get()); if (!lhs_it || !rhs_it) { throw std::logic_error("Histo iterators have wrong type."); @@ -63,9 +63,6 @@ void WeightedMeanMD::execHistoHisto( out->setSignalAt(pos, signal); out->setErrorSquaredAt(pos, error_sq); } while (lhs_it->next() && rhs_it->next()); - - delete lhs_it; - delete rhs_it; } //---------------------------------------------------------------------------------------------- diff --git a/Framework/MDAlgorithms/test/BinMDTest.h b/Framework/MDAlgorithms/test/BinMDTest.h index 38d16b0b854d5c275797de94c6b9872e34d4acdf..980e8d0b7b4a9b5e64772d2a4d7352c46caafd9e 100644 --- a/Framework/MDAlgorithms/test/BinMDTest.h +++ b/Framework/MDAlgorithms/test/BinMDTest.h @@ -1111,7 +1111,7 @@ public: BinMDTestPerformance() { in_ws = MDEventsTestHelper::makeMDEW<3>(10, 0.0, 10.0, 0); in_ws->getBoxController()->setSplitThreshold(2000); - in_ws->splitAllIfNeeded(NULL); + in_ws->splitAllIfNeeded(nullptr); AnalysisDataService::Instance().addOrReplace("BinMDTest_ws", in_ws); FrameworkManager::Instance().exec("FakeMDEventData", 4, "InputWorkspace", "BinMDTest_ws", "UniformParams", diff --git a/Framework/MDAlgorithms/test/ConvertCWSDExpToMomentumTest.h b/Framework/MDAlgorithms/test/ConvertCWSDExpToMomentumTest.h index 9877a870eddfe7e61d0833a6d7fe69f9efaf572e..64ae9fa681f58d894ee93cfd3537deb93407c028 100644 --- a/Framework/MDAlgorithms/test/ConvertCWSDExpToMomentumTest.h +++ b/Framework/MDAlgorithms/test/ConvertCWSDExpToMomentumTest.h @@ -118,7 +118,7 @@ public: AnalysisDataService::Instance().retrieve("QSampleMDEvents")); TS_ASSERT(outws); - IMDIterator *mditer = outws->createIterator(); + auto mditer = outws->createIterator(); TS_ASSERT_EQUALS(mditer->getNumEvents(), 7400); size_t numexpinfo = outws->getNumExperimentInfo(); @@ -157,7 +157,7 @@ public: AnalysisDataService::Instance().retrieve("QSampleMDEvents")); TS_ASSERT(outws); - IMDIterator *mditer = outws->createIterator(); + auto mditer = outws->createIterator(); TS_ASSERT_EQUALS(mditer->getNumEvents(), 7400); size_t numexpinfo = outws->getNumExperimentInfo(); diff --git a/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h b/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h index d01934b1b6b2ab1458063f4f3c8399818292f018..8a762208e6c01fa650e82cf87f7c6ef44d17dfb7 100644 --- a/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h +++ b/Framework/MDAlgorithms/test/ConvertSpiceDataToRealSpaceTest.h @@ -143,7 +143,7 @@ public: size_t numevents = mdws->getNEvents(); TS_ASSERT_EQUALS(numevents, 44 * 61); - IMDIterator *mditer = mdws->createIterator(); + auto mditer = mdws->createIterator(); TS_ASSERT_EQUALS(mditer->getNumEvents(), 44 * 61); double y0 = mditer->getInnerSignal(0); @@ -333,7 +333,7 @@ public: size_t numevents = mdws->getNEvents(); TS_ASSERT_EQUALS(numevents, 44 * 61); - IMDIterator *mditer = mdws->createIterator(); + auto mditer = mdws->createIterator(); TS_ASSERT_EQUALS(mditer->getNumEvents(), 44 * 61); double y0 = mditer->getInnerSignal(0); diff --git a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h index 5f44b55e93d9b9bb4cd01fa0cca8884624f1492c..449ff78025603b89372dac9fc76002af02a12c22 100644 --- a/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h +++ b/Framework/MDAlgorithms/test/ConvertToReflectometryQTest.h @@ -153,7 +153,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); TS_ASSERT_EQUALS(2, ws->getExperimentInfo(0)->run().getLogData().size()); // Assert that dimensions should be a general frame const auto &frame0 = ws->getDimension(0)->getMDFrame(); @@ -170,7 +170,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); // Assert that dimensions should be a general frame const auto &frame0 = ws->getDimension(0)->getMDFrame(); TSM_ASSERT_EQUALS("Should be a general frame", "KiKf", frame0.name()); @@ -185,7 +185,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::IMDEventWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); // Assert that dimensions should be a general frame const auto &frame0 = ws->getDimension(0)->getMDFrame(); TSM_ASSERT_EQUALS("Should be a general frame", "P", frame0.name()); @@ -201,7 +201,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); TS_ASSERT_EQUALS(2, ws->run().getLogData().size()); } @@ -213,7 +213,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); TS_ASSERT_EQUALS(2, ws->run().getLogData().size()); } @@ -225,7 +225,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::IMDHistoWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); TS_ASSERT_EQUALS(2, ws->getExperimentInfo(0)->run().getLogData().size()); } @@ -236,7 +236,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); } void test_execute_pipf_2D() { @@ -246,7 +246,7 @@ public: auto ws = boost::dynamic_pointer_cast<Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( "OutputTransformedWorkspace")); - TS_ASSERT(ws != NULL); + TS_ASSERT(ws != nullptr); } void test_box_controller_defaults() { @@ -342,7 +342,7 @@ public: IMDWorkspace_sptr out = AnalysisDataService::Instance().retrieveWS<IMDWorkspace>( "OutputTransformedWorkspace"); - TS_ASSERT(out != NULL); + TS_ASSERT(out != nullptr); TS_ASSERT_EQUALS(out->getNumDims(), 2); } @@ -363,7 +363,7 @@ public: auto out = AnalysisDataService::Instance() .retrieveWS<Mantid::DataObjects::Workspace2D>( "OutputTransformedWorkspace"); - TS_ASSERT(out != NULL); + TS_ASSERT(out != nullptr); TS_ASSERT_EQUALS(out->getNumDims(), 2); } }; diff --git a/Framework/MDAlgorithms/test/DivideMDTest.h b/Framework/MDAlgorithms/test/DivideMDTest.h index 611b11c15421192bfe87cac895d7ccf8a322eb27..fdc2633896f0218d7866d4f7eac9e22473ebc362 100644 --- a/Framework/MDAlgorithms/test/DivideMDTest.h +++ b/Framework/MDAlgorithms/test/DivideMDTest.h @@ -64,7 +64,7 @@ public: TS_ASSERT(ws); if (!ws) return; - IMDIterator *it = ws->createIterator(NULL); + auto it = ws->createIterator(nullptr); do { TS_ASSERT_EQUALS(it->getNumEvents(), 1); TS_ASSERT_DELTA(it->getInnerSignal(0), expectedSignal, 1e-5); diff --git a/Framework/MDAlgorithms/test/FakeMDEventDataTest.h b/Framework/MDAlgorithms/test/FakeMDEventDataTest.h index fbb8c4be9ccf660d5174a60dc696d9fd0c684a80..9a90697ffccdf4a791f4870ca6249d3895ad219d 100644 --- a/Framework/MDAlgorithms/test/FakeMDEventDataTest.h +++ b/Framework/MDAlgorithms/test/FakeMDEventDataTest.h @@ -202,8 +202,6 @@ public: it->next(); ++counter; } - - delete it; } }; diff --git a/Framework/MDAlgorithms/test/FitMDTest.h b/Framework/MDAlgorithms/test/FitMDTest.h index d0f7421baa938e1583f4958a3d6cadc32519b6f9..19d2f93a23b801b6c1a67a0e2fe197b6100c44ae 100644 --- a/Framework/MDAlgorithms/test/FitMDTest.h +++ b/Framework/MDAlgorithms/test/FitMDTest.h @@ -36,9 +36,11 @@ public: signal_t getNormalizedError() const override; signal_t getSignal() const override { return 0; } signal_t getError() const override { return 0; } - coord_t *getVertexesArray(size_t &) const override { return nullptr; } - coord_t *getVertexesArray(size_t &, const size_t, - const bool *) const override { + std::unique_ptr<coord_t[]> getVertexesArray(size_t &) const override { + return nullptr; + } + std::unique_ptr<coord_t[]> getVertexesArray(size_t &, const size_t, + const bool *) const override { return nullptr; } Mantid::Kernel::VMD getCenter() const override; @@ -69,10 +71,15 @@ public: class IMDWorkspaceTester : public WorkspaceTester { public: - std::vector<IMDIterator *> + std::vector<std::unique_ptr<IMDIterator>> createIterators(size_t, Mantid::Geometry::MDImplicitFunction *) const override { - return std::vector<IMDIterator *>(1, new IMDWorkspaceTesterIterator(this)); + + std::vector<std::unique_ptr<IMDIterator>> ret; + auto ptr = std::unique_ptr<IMDIterator>{ + Kernel::make_unique<IMDWorkspaceTesterIterator>(this)}; + ret.push_back(std::move(ptr)); + return ret; } }; diff --git a/Framework/MDAlgorithms/test/ImportMDHistoWorkspaceTest.h b/Framework/MDAlgorithms/test/ImportMDHistoWorkspaceTest.h index 37c2318fa5352feee95277880e293b85f552eb71..17a8ae84fcd21b3770370b35e1e5391a094dbb56 100644 --- a/Framework/MDAlgorithms/test/ImportMDHistoWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/ImportMDHistoWorkspaceTest.h @@ -228,7 +228,7 @@ public: IMDHistoWorkspace_sptr outWs = boost::dynamic_pointer_cast<IMDHistoWorkspace>( ADS.retrieve("test_workspace")); - TS_ASSERT(outWs != NULL); + TS_ASSERT(outWs != nullptr); // Check the dimensionality TS_ASSERT_EQUALS(2, outWs->getNumDims()); @@ -290,7 +290,7 @@ public: IMDHistoWorkspace_sptr outWs = boost::dynamic_pointer_cast<IMDHistoWorkspace>( ADS.retrieve("test_workspace")); - TS_ASSERT(outWs != NULL); + TS_ASSERT(outWs != nullptr); // Check the dimensionality TS_ASSERT_EQUALS(3, outWs->getNumDims()); diff --git a/Framework/MDAlgorithms/test/LoadMDTest.h b/Framework/MDAlgorithms/test/LoadMDTest.h index 00394b574974ff619670d8d8400dbe6bac4ef852..3776ab48fa02a0a8c895d5013a7089d08b4563ff 100644 --- a/Framework/MDAlgorithms/test/LoadMDTest.h +++ b/Framework/MDAlgorithms/test/LoadMDTest.h @@ -253,8 +253,8 @@ public: typename std::vector<API::IMDNode *> boxes; ws->getBox()->getBoxes(boxes, 1000, false); - for (size_t i = 0; i < boxes.size(); i++) { - MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxes[i]); + for (auto &boxIt : boxes) { + MDBox<MDE, nd> *box = dynamic_cast<MDBox<MDE, nd> *>(boxIt); if (box) { TSM_ASSERT("Large box should not be in memory", box->getISaveable()->getDataMemorySize() == 0); @@ -307,7 +307,7 @@ public: ev.setCenter(d, 0.5); box->addEvent(ev); // CHANGE from AB: 20/01/2013: you have to split to identify changes! - box->splitAllIfNeeded(NULL); + box->splitAllIfNeeded(nullptr); // Modify a different box by accessing the events MDBox<MDLeanEvent<nd>, nd> *box8 = diff --git a/Framework/MDAlgorithms/test/MDTransfModQTest.h b/Framework/MDAlgorithms/test/MDTransfModQTest.h index 8d4abe7cf82e7fb93914711fd643705b8d906cbd..1178b956b156fa4a78c8e506c55acacce79551c2 100644 --- a/Framework/MDAlgorithms/test/MDTransfModQTest.h +++ b/Framework/MDAlgorithms/test/MDTransfModQTest.h @@ -108,8 +108,8 @@ public: // the detectors parameters MDTransf.calcYDepCoordinates(locCoord, i); - for (size_t k = 0; k < range.size(); k++) { - MDTransf.calcMatrixCoord(range[k], locCoord, signal, errorSq); + for (double k : range) { + MDTransf.calcMatrixCoord(k, locCoord, signal, errorSq); for (size_t j = 0; j < nDims; j++) { if (locCoord[j] < minCoord[j]) minCoord[j] = locCoord[j]; diff --git a/Framework/MDAlgorithms/test/MDTransfQ3DTest.h b/Framework/MDAlgorithms/test/MDTransfQ3DTest.h index cfe87617ea444c234a16e28025bdee3ea56d4565..81f46d2f193900426196cd693d57bf6db14b7fa1 100644 --- a/Framework/MDAlgorithms/test/MDTransfQ3DTest.h +++ b/Framework/MDAlgorithms/test/MDTransfQ3DTest.h @@ -116,8 +116,8 @@ public: // testing purposes here auto &TwoTheta = const_cast<std::vector<double> &>( WSDescr.m_PreprDetTable->getColVector<double>("TwoTheta")); - for (size_t i = 0; i < TwoTheta.size(); i++) { - TwoTheta[i] = 0; + for (double &i : TwoTheta) { + i = 0; } TSM_ASSERT_THROWS_NOTHING("should initialize properly: ", diff --git a/Framework/MDAlgorithms/test/MDWSTransfTest.h b/Framework/MDAlgorithms/test/MDWSTransfTest.h index ddf5e20a54a424ff579e466a57275dfdf1e7d397..3ca531923c5c42c14f7bba68098f056e900b6d44 100644 --- a/Framework/MDAlgorithms/test/MDWSTransfTest.h +++ b/Framework/MDAlgorithms/test/MDWSTransfTest.h @@ -78,7 +78,7 @@ public: WorkspaceCreationHelper::create2DWorkspaceBinned(10, 10); std::vector<double> minVal(4, -3), maxVal(4, 3); TargWSDescription.setMinMax(minVal, maxVal); - spws->mutableSample().setOrientedLattice(NULL); + spws->mutableSample().setOrientedLattice(nullptr); TargWSDescription.buildFromMatrixWS(spws, "Q3D", "Direct"); diff --git a/Framework/MDAlgorithms/test/MaskMDTest.h b/Framework/MDAlgorithms/test/MaskMDTest.h index 8cf01437735cad16782ad5bceb4a9676b6a786e7..9539790800664ee9e4d2a8791552107dc3b55cea 100644 --- a/Framework/MDAlgorithms/test/MaskMDTest.h +++ b/Framework/MDAlgorithms/test/MaskMDTest.h @@ -37,7 +37,7 @@ private: if (!ws) return; - IMDIterator *it = ws->createIterator(); + auto it = ws->createIterator(); size_t nMasked = 0; for (size_t i = 0; i < it->getDataSize(); ++i) { if (it->getIsMasked()) { diff --git a/Framework/MDAlgorithms/test/MergeMDFilesTest.h b/Framework/MDAlgorithms/test/MergeMDFilesTest.h index b62604f3fb8ccaa6f4a1884afd06fc64c33b2f69..f20739fa83960da1c54e4bbcac27280ab4332df2 100644 --- a/Framework/MDAlgorithms/test/MergeMDFilesTest.h +++ b/Framework/MDAlgorithms/test/MergeMDFilesTest.h @@ -102,11 +102,11 @@ public: } // Cleanup generated input files - for (size_t i = 0; i < inWorkspaces.size(); i++) { - if (inWorkspaces[i]->getBoxController()->isFileBacked()) { + for (auto &inWorkspace : inWorkspaces) { + if (inWorkspace->getBoxController()->isFileBacked()) { std::string fileName = - inWorkspaces[i]->getBoxController()->getFileIO()->getFileName(); - inWorkspaces[i]->clearFileBacked(false); + inWorkspace->getBoxController()->getFileIO()->getFileName(); + inWorkspace->clearFileBacked(false); Poco::File(fileName).remove(); } } diff --git a/Framework/MDAlgorithms/test/MinusMDTest.h b/Framework/MDAlgorithms/test/MinusMDTest.h index 82ae75c7b7cacc881f963df6da910ee8856d2fbc..8daa5000cbbef30c42a4d4e069318a092bddfc51 100644 --- a/Framework/MDAlgorithms/test/MinusMDTest.h +++ b/Framework/MDAlgorithms/test/MinusMDTest.h @@ -105,7 +105,7 @@ public: TS_ASSERT_EQUALS(ws->getNPoints(), 10000); } - IMDIterator *it = ws->createIterator(); + auto it = ws->createIterator(); if (mask_ws_num == 0) { while (it->next()) { // Signal of all boxes is zero since they got subtracted diff --git a/Framework/MDAlgorithms/test/MultiplyMDTest.h b/Framework/MDAlgorithms/test/MultiplyMDTest.h index 480a3576dff6bfa98ed06d8c863af1724f6d27bc..08725d35da0d6f94f19de65a18a4faade03cfd0d 100644 --- a/Framework/MDAlgorithms/test/MultiplyMDTest.h +++ b/Framework/MDAlgorithms/test/MultiplyMDTest.h @@ -63,7 +63,7 @@ public: TS_ASSERT(ws); if (!ws) return; - IMDIterator *it = ws->createIterator(NULL); + auto it = ws->createIterator(nullptr); do { TS_ASSERT_EQUALS(it->getNumEvents(), 1); TS_ASSERT_DELTA(it->getInnerSignal(0), expectedSignal, 1e-5); diff --git a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h index fc1b53032897206a8951c2aa05b782698ab024bc..b5e411b78e56a7510c4b3797bd4c1614f51e0fa2 100644 --- a/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h +++ b/Framework/MDAlgorithms/test/QueryMDWorkspaceTest.h @@ -154,7 +154,7 @@ public: ITableWorkspace_sptr table = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>("QueryWS"); - TSM_ASSERT("Workspace output is not an ITableWorkspace", table != NULL); + TSM_ASSERT("Workspace output is not an ITableWorkspace", table != nullptr); size_t expectedCount = 3 + in_ws->getNumDims(); // 3 fixed columns are Signal, Error, nEvents TSM_ASSERT_EQUALS("Four columns expected", expectedCount, @@ -176,7 +176,7 @@ public: ITableWorkspace_sptr table = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>("QueryWS"); - TSM_ASSERT("Workspace output is not an ITableWorkspace", table != NULL); + TSM_ASSERT("Workspace output is not an ITableWorkspace", table != nullptr); size_t expectedCount = 3 + in_ws->getNumDims(); // 3 fixed columns are Signal, Error, nEvents TSM_ASSERT_EQUALS("Five columns expected", expectedCount, @@ -199,7 +199,7 @@ public: ITableWorkspace_sptr table = AnalysisDataService::Instance().retrieveWS<ITableWorkspace>("QueryWS"); - TSM_ASSERT("Workspace output is not an ITableWorkspace", table != NULL); + TSM_ASSERT("Workspace output is not an ITableWorkspace", table != nullptr); size_t expectedCount = 3 + in_ws->getNumDims(); // 3 fixed columns are Signal, Error, nEvents TSM_ASSERT_EQUALS("Five columns expected", expectedCount, @@ -253,7 +253,7 @@ public: query.execute(); ITableWorkspace_sptr table = query.getProperty("OutputWorkspace"); - TSM_ASSERT("Workspace output is not an ITableWorkspace", table != NULL); + TSM_ASSERT("Workspace output is not an ITableWorkspace", table != nullptr); size_t expectedCount = 3 + 2; // 3 fixed columns are Signal, Error, nEvents and then data is 2D TSM_ASSERT_EQUALS("Six columns expected", expectedCount, @@ -292,7 +292,7 @@ public: query.execute(); ITableWorkspace_sptr table = query.getProperty("OutputWorkspace"); - TSM_ASSERT("Workspace output is not an ITableWorkspace", table != NULL); + TSM_ASSERT("Workspace output is not an ITableWorkspace", table != nullptr); size_t expectedCount = 3 + 2; // 3 fixed columns are Signal, Error, nEvents and then data is 2D TSM_ASSERT_EQUALS("Six columns expected", expectedCount, diff --git a/Framework/MDAlgorithms/test/ReplicateMDTest.h b/Framework/MDAlgorithms/test/ReplicateMDTest.h index 56b24e96f43f92295ab60e9f6ec816f8597b6f52..68a25f36780b881b47c7d48d55b81ec46aa82802 100644 --- a/Framework/MDAlgorithms/test/ReplicateMDTest.h +++ b/Framework/MDAlgorithms/test/ReplicateMDTest.h @@ -77,8 +77,8 @@ MDHistoWorkspace_sptr makeHistoWorkspace(const std::vector<int> &shape, // Generate the axis order 0, 1, 2 ... in reverse std::vector<int> axes(outWs->getNumDims()); Decreasing op(outWs->getNumDims()); - for (auto it = axes.begin(); it != axes.end(); ++it) { - *it = static_cast<int>(op()); + for (int &axis : axes) { + axis = static_cast<int>(op()); } IAlgorithm *transpose = diff --git a/Framework/MDAlgorithms/test/ResolutionConvolvedCrossSectionTest.h b/Framework/MDAlgorithms/test/ResolutionConvolvedCrossSectionTest.h index 03cd21691ed3599ff6b7a178e1e484469b214e8b..497cd15840db79a25a1d1116c639c4e455edac75 100644 --- a/Framework/MDAlgorithms/test/ResolutionConvolvedCrossSectionTest.h +++ b/Framework/MDAlgorithms/test/ResolutionConvolvedCrossSectionTest.h @@ -47,7 +47,7 @@ public: using namespace Mantid::MDAlgorithms; using namespace Mantid::API; Mantid::API::IMDWorkspace_sptr testWS = createTestMDWorkspace(); - Mantid::API::IMDIterator *box = testWS->createIterator(); + auto box = testWS->createIterator(); FunctionDomainMD mdDomain(testWS, 0, box->getDataSize()); FunctionValues output; @@ -55,7 +55,6 @@ public: crossSecResolution->setWorkspace(testWS); // TODO: Needs a better input workspace // TS_ASSERT_THROWS_NOTHING(crossSecResolution->function(mdDomain, output)); - delete box; delete crossSecResolution; } diff --git a/Framework/MDAlgorithms/test/SaveMD2Test.h b/Framework/MDAlgorithms/test/SaveMD2Test.h index 85c4b9e2704648910ab7cdb2ae05d6d314bba571..a91a48586cc6002685ba3488c253266bf56300dd 100644 --- a/Framework/MDAlgorithms/test/SaveMD2Test.h +++ b/Framework/MDAlgorithms/test/SaveMD2Test.h @@ -109,7 +109,7 @@ public: ev.setCenter(0, double(i) * 0.01 + 0.4); ws->addEvent(ev); } - ws->splitAllIfNeeded(NULL); + ws->splitAllIfNeeded(nullptr); ws->refreshCache(); // Manually set the flag that the algo would set ws->setFileNeedsUpdating(true); diff --git a/Framework/MDAlgorithms/test/SaveMDTest.h b/Framework/MDAlgorithms/test/SaveMDTest.h index a53feb583d2d2207db28d66eba17f118690075ff..aaad74bf8e361ed53febf02492341e57078d3679 100644 --- a/Framework/MDAlgorithms/test/SaveMDTest.h +++ b/Framework/MDAlgorithms/test/SaveMDTest.h @@ -114,7 +114,7 @@ public: ev.setCenter(0, double(i) * 0.01 + 0.4); ws->addEvent(ev); } - ws->splitAllIfNeeded(NULL); + ws->splitAllIfNeeded(nullptr); ws->refreshCache(); // Manually set the flag that the algo would set ws->setFileNeedsUpdating(true); diff --git a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h index 3e736c1d1ca7383cea549b941e39ec25313e29bc..0d558dbcf5f121b919345f2ceedfa9e5197ea267 100644 --- a/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h +++ b/Framework/MDAlgorithms/test/SlicingAlgorithmTest.h @@ -332,7 +332,8 @@ public: void test_aligned_ImplicitFunction() { SlicingAlgorithmImpl *alg = do_createAlignedTransform( "Axis0, 2.0,8.0, 6", "Axis1, 2.0,8.0, 3", "Axis2, 2.0,8.0, 3", ""); - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(3, 4, 5))); @@ -681,7 +682,8 @@ public: TS_ASSERT_EQUALS(VMD(3, in), VMD(3.0, 1.0, 2.6)); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2))); @@ -738,7 +740,8 @@ public: TS_ASSERT_EQUALS(VMD(3, in), VMD(3.0, -1.0, 2.6)); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(1.5, -1.5, 2))); @@ -756,8 +759,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2, 234))); @@ -777,8 +780,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 8); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 1.5, 1.5))); @@ -796,8 +799,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 8); TS_ASSERT(func->isPointContained(VMD(1.5, -1.5, 1.5, 1.5))); @@ -814,8 +817,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2, 234, 456))); @@ -835,8 +838,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2, 234))); @@ -854,8 +857,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2))); @@ -873,8 +876,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5))); @@ -932,7 +935,8 @@ public: TS_ASSERT_EQUALS(VMD(2, in), VMD(3., -11.)); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(-8.9, -18.9))); @@ -997,7 +1001,8 @@ public: TS_ASSERT_EQUALS(VMD(2, in), VMD(3., -11.)); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(-18.9, -98.9))); @@ -1026,8 +1031,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(2., 1.))); @@ -1048,8 +1053,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 4); TS_ASSERT(func->isPointContained(VMD(2., 1., 0.))); @@ -1072,8 +1077,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 8); TS_ASSERT(func->isPointContained(VMD(2., 1., 0., 0.))); @@ -1093,8 +1098,8 @@ public: // The implicit function MDImplicitFunction *func(nullptr); - TS_ASSERT_THROWS_NOTHING(func = - alg->getImplicitFunctionForChunk(NULL, NULL)); + TS_ASSERT_THROWS_NOTHING( + func = alg->getImplicitFunctionForChunk(nullptr, nullptr)); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 6); TS_ASSERT(func->isPointContained(VMD(2., 1., 0., 0.))); @@ -1112,7 +1117,8 @@ public: TS_ASSERT_EQUALS(alg->m_bases.size(), 1); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 2); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2, 345))); @@ -1127,7 +1133,8 @@ public: TS_ASSERT_EQUALS(alg->m_bases.size(), 1); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 2); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5, 2))); @@ -1142,7 +1149,8 @@ public: TS_ASSERT_EQUALS(alg->m_bases.size(), 1); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 2); TS_ASSERT(func->isPointContained(VMD(1.5, 1.5))); @@ -1159,7 +1167,8 @@ public: TS_ASSERT_EQUALS(alg->m_bases.size(), 1); // The implicit function - MDImplicitFunction *func = alg->getImplicitFunctionForChunk(NULL, NULL); + MDImplicitFunction *func = + alg->getImplicitFunctionForChunk(nullptr, nullptr); TS_ASSERT(func); TS_ASSERT_EQUALS(func->getNumPlanes(), 2); VMD point(1); diff --git a/Framework/MDAlgorithms/test/TobyFitYVectorTest.h b/Framework/MDAlgorithms/test/TobyFitYVectorTest.h index 249061f556a7b99ba826b27bca9261baa471232a..497046f3e9303c9447cb8ac37c03d744cf8efd5f 100644 --- a/Framework/MDAlgorithms/test/TobyFitYVectorTest.h +++ b/Framework/MDAlgorithms/test/TobyFitYVectorTest.h @@ -45,8 +45,8 @@ public: "DetectorArea", "DetectionTime"}; TobyFitYVector yVector; - for (unsigned int i = 0; i < 8; ++i) { - yVector.setAttribute(attrs[i], IFunction::Attribute(false)); + for (auto &attr : attrs) { + yVector.setAttribute(attr, IFunction::Attribute(false)); } std::vector<double> randNums(yVector.requiredRandomNums(), 0.5); diff --git a/Framework/MDAlgorithms/test/TransformMDTest.h b/Framework/MDAlgorithms/test/TransformMDTest.h index 6ecf6571f7be221ac908dbec2880af65d34b7e61..dfa6a35e8ad0910c10fab440ac859b2c663d44ce 100644 --- a/Framework/MDAlgorithms/test/TransformMDTest.h +++ b/Framework/MDAlgorithms/test/TransformMDTest.h @@ -64,8 +64,7 @@ public: } std::vector<API::IMDNode *> boxes; ws2->getBox()->getBoxes(boxes, 1000, true); - for (size_t i = 0; i < boxes.size(); i++) { - API::IMDNode *box = boxes[i]; + for (auto box : boxes) { TSM_ASSERT_LESS_THAN("Box extents was offset", 20.0, box->getExtents(0).getMin()); // More detailed tests are in MDBox, MDBoxBase and MDGridBox. diff --git a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h index 93ba7996521cfd4e00b81c502f17221264f46893..eacd4333e6e1c17ed6cb064d4b5d49e522ec2573 100644 --- a/Framework/MDAlgorithms/test/WeightedMeanMDTest.h +++ b/Framework/MDAlgorithms/test/WeightedMeanMDTest.h @@ -134,7 +134,7 @@ public: MDHistoWorkspace_sptr c = boost::dynamic_pointer_cast<MDHistoWorkspace>(ADS.retrieve(outName)); - TS_ASSERT(c != NULL); + TS_ASSERT(c != nullptr); // Since A and B are equivalent, the mean Signal in C should be the same as // both A and B. double expectedSignalResults[10] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; @@ -157,7 +157,7 @@ public: MDHistoWorkspace_sptr out; out = BinaryOperationMDTestHelper::doTest("WeightedMeanMD", "histo_A", "histo_B", "out"); - TS_ASSERT(out != NULL); + TS_ASSERT(out != nullptr); } /** diff --git a/Framework/Parallel/inc/MantidParallel/Status.h b/Framework/Parallel/inc/MantidParallel/Status.h index adbb5c852be0efdad89126aa8943569e548b364d..965a117cf8c7c473525decf0a28746ae03a45984 100644 --- a/Framework/Parallel/inc/MantidParallel/Status.h +++ b/Framework/Parallel/inc/MantidParallel/Status.h @@ -44,7 +44,8 @@ class ThreadingBackend; class MANTID_PARALLEL_DLL Status { public: #ifdef MPI_EXPERIMENTAL - Status(const boost::mpi::status &status) : m_status(status) {} + Status(const boost::mpi::status &status) + : m_status(status), m_threadingBackend{false} {} #endif template <typename T> boost::optional<int> count() const { @@ -56,12 +57,14 @@ public: } private: - Status(const size_t size) : m_size(size), m_threadingBackend(true) {} + Status(const size_t size) : m_size(size) {} #ifdef MPI_EXPERIMENTAL boost::mpi::status m_status; #endif const size_t m_size{0}; - const bool m_threadingBackend{false}; +#ifdef MPI_EXPERIMENTAL + bool m_threadingBackend{true}; +#endif // For accessing constructor based on size. friend class detail::ThreadingBackend; }; diff --git a/Framework/Parallel/test/EventParserTest.h b/Framework/Parallel/test/EventParserTest.h index 0dce40044bdbb7e1165d6dc4fc4fdc58fb0154d8..2de672e236ad0e241279aaadd0646c84e86630c5 100644 --- a/Framework/Parallel/test/EventParserTest.h +++ b/Framework/Parallel/test/EventParserTest.h @@ -97,7 +97,7 @@ private: static_cast<IndexType>(m_bank_offsets[bank] + absolutePixel)); std::transform(list.cbegin() + prev_end, list.cend(), std::back_inserter(m_event_time_offsets[bank]), - [this](const TofEvent &event) { + [](const TofEvent &event) { return static_cast<TimeOffsetType>(event.tof()); }); } diff --git a/Framework/PythonInterface/inc/MantidPythonInterface/api/PythonAlgorithm/AlgorithmAdapter.h b/Framework/PythonInterface/inc/MantidPythonInterface/api/PythonAlgorithm/AlgorithmAdapter.h index 6a52ea528c884fa84673b5318c9ec8254a4e92ec..eaa58ae1aeafc4c3fa7d1346bf8415d63240521e 100644 --- a/Framework/PythonInterface/inc/MantidPythonInterface/api/PythonAlgorithm/AlgorithmAdapter.h +++ b/Framework/PythonInterface/inc/MantidPythonInterface/api/PythonAlgorithm/AlgorithmAdapter.h @@ -68,6 +68,8 @@ public: const std::string summary() const override; /// Returns a category of the algorithm. const std::string category() const override; + /// Returns seeAlso related algorithms. + const std::vector<std::string> seeAlso() const override; /// Returns optional documentation URL of the algorithm const std::string helpURL() const override; /// Allow the isRunning method to be overridden diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp index 56fc63c961bfd99a53206dc05fb0d27642fb1259..c71b84d79039c99a1520dcde4fce3d7fc050ff4f 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IAlgorithm.cpp @@ -372,7 +372,11 @@ void export_ialgorithm() { .def("category", &IAlgorithm::category, arg("self"), "Returns the category containing the algorithm") .def("categories", &IAlgorithm::categories, arg("self"), + return_value_policy<VectorToNumpy>(), "Returns the list of categories this algorithm belongs to") + .def("seeAlso", &IAlgorithm::seeAlso, arg("self"), + return_value_policy<VectorToNumpy>(), + "Returns the list of similar algorithms") .def("summary", &IAlgorithm::summary, arg("self"), "Returns a summary message describing the algorithm") .def("helpURL", &IAlgorithm::helpURL, arg("self"), diff --git a/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp b/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp index 67183097ad13b31492d5299c15bb014490a51a09..10de2206815755e357cc04b60d91f8ed2253708e 100644 --- a/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp +++ b/Framework/PythonInterface/mantid/api/src/Exports/IPeak.cpp @@ -61,9 +61,16 @@ void export_IPeak() { "cache values related to it.") .def("getRunNumber", &IPeak::getRunNumber, arg("self"), "Return the run number this peak was measured at") + .def("getPeakNumber", &IPeak::getPeakNumber, arg("self"), + "Return the peak number for this peak") + .def("getBankName", &IPeak::getBankName, arg("self"), + "Return the bank name for this peak") .def("setRunNumber", &IPeak::setRunNumber, (arg("self"), arg("run_number")), "Set the run number that measured this peak") + .def("setPeakNumber", &IPeak::setPeakNumber, + (arg("self"), arg("peak_number")), + "Set the peak number for this peak") .def("getMonitorCount", &IPeak::getMonitorCount, arg("self"), "Get the monitor count set for this peak") .def("setMonitorCount", &IPeak::setMonitorCount, @@ -126,6 +133,8 @@ void export_IPeak() { "Return the incident wavelength") .def("getScattering", &IPeak::getScattering, arg("self"), "Calculate the scattering angle of the peak") + .def("getAzimuthal", &IPeak::getAzimuthal, arg("self"), + "Calculate the azimuthal angle of the peak") .def("getDSpacing", &IPeak::getDSpacing, arg("self"), "Calculate the d-spacing of the peak, in 1/Angstroms") .def("getTOF", &IPeak::getTOF, arg("self"), diff --git a/Framework/PythonInterface/mantid/api/src/PythonAlgorithm/AlgorithmAdapter.cpp b/Framework/PythonInterface/mantid/api/src/PythonAlgorithm/AlgorithmAdapter.cpp index 6d9358d85c22bde259d8e828fe598f2541187999..2c9db0825e8bc623df61a80774bfbf693e78f011 100644 --- a/Framework/PythonInterface/mantid/api/src/PythonAlgorithm/AlgorithmAdapter.cpp +++ b/Framework/PythonInterface/mantid/api/src/PythonAlgorithm/AlgorithmAdapter.cpp @@ -3,6 +3,7 @@ #include "MantidPythonInterface/kernel/Environment/WrapperHelpers.h" #include "MantidPythonInterface/kernel/Environment/CallMethod.h" #include "MantidPythonInterface/kernel/Environment/GlobalInterpreterLock.h" +#include "MantidPythonInterface/kernel/Converters/PySequenceToVector.h" #include "MantidAPI/DataProcessorAlgorithm.h" #include "MantidAPI/SerialAlgorithm.h" #include "MantidAPI/ParallelAlgorithm.h" @@ -92,6 +93,21 @@ const std::string AlgorithmAdapter<BaseAlgorithm>::category() const { return category; } +/** +* Returns seeAlso related algorithms. If not overridden +* it returns an empty vector of strings +*/ +template <typename BaseAlgorithm> +const std::vector<std::string> +AlgorithmAdapter<BaseAlgorithm>::seeAlso() const { + try { + auto seeAlsoPyList = callMethod<object>(getSelf(), "seeAlso"); + return Converters::PySequenceToVector<std::string>(seeAlsoPyList)(); + } catch (UndefinedAttributeError &) { + return {}; + } +} + /** * Returns the summary of the algorithm. If not overridden * it returns defaultSummary diff --git a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp index ec12497997cfb132b5b3c8251807f19f9a7ffeae..7987881b15b54e526ba5644ac0d220475da0777e 100644 --- a/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp +++ b/Framework/PythonInterface/mantid/dataobjects/src/Exports/Workspace2D.cpp @@ -72,8 +72,8 @@ public: const auto &spectrumDefinition = (*spectrumDefinitions)[i]; std::vector<size_t> detectorIndices; - for (size_t j = 0; j < spectrumDefinition.size(); ++j) { - size_t detectorIndex = spectrumDefinition[j].first; + for (const auto &j : spectrumDefinition) { + size_t detectorIndex = j.first; detectorIndices.emplace_back(std::move(detectorIndex)); } @@ -133,8 +133,7 @@ public: ws.setBinEdges(i, std::move(binEdgeData)); SpectrumDefinition specDef; - for (size_t j = 0; j < detectorIndices.size(); ++j) { - size_t detectorIndex = detectorIndices[j]; + for (auto detectorIndex : detectorIndices) { specDef.add(detectorIndex); } spectrumDefinitions.emplace_back(std::move(specDef)); diff --git a/Framework/PythonInterface/mantid/kernel/CMakeLists.txt b/Framework/PythonInterface/mantid/kernel/CMakeLists.txt index b7f0589931fca6b907c0ed4b3037ae394ee9a4fd..865b313bab49fc5fcfec36706a0b89ca094b019c 100644 --- a/Framework/PythonInterface/mantid/kernel/CMakeLists.txt +++ b/Framework/PythonInterface/mantid/kernel/CMakeLists.txt @@ -179,7 +179,7 @@ copy_files_to_dir ( ${MPISETUP_PY}.py ${CMAKE_CURRENT_BINARY_DIR} ${OUTPUT_DIR} PYTHON_INSTALL_FILES ) # Package version -if ( WIN32 OR APPLE ) +if ( WIN32 OR (APPLE AND ENABLE_MANTIDPLOT) ) # NeXus library is in the same place relative to the Python library get_filename_component ( NEXUSLIB_FILE ${NEXUSLIB} NAME ) set ( NEXUSLIB ../../${NEXUSLIB_FILE} ) diff --git a/Framework/PythonInterface/mantid/kernel/src/Converters/CloneToNumpy.cpp b/Framework/PythonInterface/mantid/kernel/src/Converters/CloneToNumpy.cpp index bf501e26a4bc419856aa96a90cc9b3b9c9969542..fb49c9d5934b2a8727b8d2addf5bf723083511d0 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Converters/CloneToNumpy.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Converters/CloneToNumpy.cpp @@ -22,6 +22,7 @@ extern template int NDArrayTypeIndex<unsigned long>::typenum; extern template int NDArrayTypeIndex<unsigned long long>::typenum; extern template int NDArrayTypeIndex<float>::typenum; extern template int NDArrayTypeIndex<double>::typenum; +extern template int NDArrayTypeIndex<Mantid::Types::Core::DateAndTime>::typenum; namespace Impl { /** diff --git a/Framework/PythonInterface/mantid/kernel/src/Converters/DateAndTime.cpp b/Framework/PythonInterface/mantid/kernel/src/Converters/DateAndTime.cpp index 17e46c70885598abac82d7128e2787accf168869..539d41c26a28fd1f1c791fb2a19bf2fa4eb9cfc3 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Converters/DateAndTime.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Converters/DateAndTime.cpp @@ -42,7 +42,14 @@ PyArray_Descr *descr_ns() { return func_PyArray_Descr("M8[ns]"); } // internal function that handles raw pointer boost::shared_ptr<Types::Core::DateAndTime> to_dateandtime(const PyObject *datetime) { +#if __clang__ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wcast-qual" +#endif if (!PyArray_IsScalar(datetime, Datetime)) { +#if __clang__ +#pragma clang diagnostic pop +#endif throw std::runtime_error("Expected datetime64"); } diff --git a/Framework/PythonInterface/mantid/kernel/src/Converters/NDArrayToVector.cpp b/Framework/PythonInterface/mantid/kernel/src/Converters/NDArrayToVector.cpp index 94668f5a1d3fd66fc43bc29e7028c12a7f9e7fd5..2045edd668b047f205790598a7a7c4fa25018775 100644 --- a/Framework/PythonInterface/mantid/kernel/src/Converters/NDArrayToVector.cpp +++ b/Framework/PythonInterface/mantid/kernel/src/Converters/NDArrayToVector.cpp @@ -27,6 +27,14 @@ extern template int NDArrayTypeIndex<unsigned long>::typenum; extern template int NDArrayTypeIndex<unsigned long long>::typenum; extern template int NDArrayTypeIndex<float>::typenum; extern template int NDArrayTypeIndex<double>::typenum; +extern template char NDArrayTypeIndex<bool>::typecode; +extern template char NDArrayTypeIndex<int>::typecode; +extern template char NDArrayTypeIndex<long>::typecode; +extern template char NDArrayTypeIndex<long long>::typecode; +extern template char NDArrayTypeIndex<unsigned int>::typecode; +extern template char NDArrayTypeIndex<unsigned long>::typecode; +extern template char NDArrayTypeIndex<unsigned long long>::typecode; +extern template char NDArrayTypeIndex<double>::typecode; } namespace { diff --git a/Framework/PythonInterface/mantid/simpleapi.py b/Framework/PythonInterface/mantid/simpleapi.py index 290fe3d92844c017dde699e8769ac18a1fb9949d..b573512873245c3fcaab9f0477585f68ae3ec009 100644 --- a/Framework/PythonInterface/mantid/simpleapi.py +++ b/Framework/PythonInterface/mantid/simpleapi.py @@ -266,6 +266,10 @@ def StartLiveData(*args, **kwargs): try: if value is None: value = kwargs.pop(name) + else: + # We don't need the value, but still need to remove from kwargs + # so that this property isn't set again later + kwargs.pop(name, None) algm.setProperty(name, value) except ValueError as ve: diff --git a/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py b/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py index 4faee2742fa410fcdd995eb10eb5940ccb9d4091..11b3ee7637f8cabc129c2b0feac6254c94db330c 100644 --- a/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/AlignAndFocusPowderFromFiles.py @@ -56,6 +56,9 @@ class AlignAndFocusPowderFromFiles(DistributedDataProcessorAlgorithm): def category(self): return "Diffraction\\Reduction" + def seeAlso(self): + return [ "AlignAndFocusPowder" ] + def name(self): return "AlignAndFocusPowderFromFiles" diff --git a/Framework/PythonInterface/plugins/algorithms/AlignComponents.py b/Framework/PythonInterface/plugins/algorithms/AlignComponents.py index fda95bd0c683a72d06d32aca40e3f46d5c580070..4232e5c6914054091a8a3dba7037f57bfddc9a5c 100644 --- a/Framework/PythonInterface/plugins/algorithms/AlignComponents.py +++ b/Framework/PythonInterface/plugins/algorithms/AlignComponents.py @@ -30,6 +30,9 @@ class AlignComponents(PythonAlgorithm): """ return "Diffraction" + def seeAlso(self): + return [ "GetDetOffsetsMultiPeaks","CalibrateRectangularDetectors" ] + def name(self): """ Mantid required diff --git a/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py b/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py index cef353b8e83a226a35b8056f338f0efb5524ae08..9498be25f5c0a8e17afdd4c94cc2d12a024f1171 100644 --- a/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py +++ b/Framework/PythonInterface/plugins/algorithms/ApplyDetectorScanEffCorr.py @@ -11,6 +11,9 @@ class ApplyDetectorScanEffCorr(PythonAlgorithm): def category(self): return 'ILL\\Diffraction;Diffraction\\Utility' + def seeAlso(self): + return [ "PowderDiffILLDetEffCorr","LoadILLDiffraction" ] + def name(self): return 'ApplyDetectorScanEffCorr' diff --git a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py index 23227fbd37c46a0f850591b206c2e9e709834253..1cc3cc472c2c59d86f4847500b0296b7db23e472 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISDiffraction.py @@ -103,6 +103,9 @@ class BASISDiffraction(DataProcessorAlgorithm): def summary(self): return "Multiple-file BASIS reduction for diffraction detectors." + def seeAlso(self): + return [ "AlignDetectors","DiffractionFocussing","SNSPowderReduction" ] + def PyInit(self): # Input validators array_length_three = FloatArrayLengthValidator(3) diff --git a/Framework/PythonInterface/plugins/algorithms/BASISReduction311.py b/Framework/PythonInterface/plugins/algorithms/BASISReduction311.py index 3b284a3b6a0b6933922cf7107fdeee5678730864..8a43ed1c89ea2e72b0ea4beba09e8480f8f98ec7 100644 --- a/Framework/PythonInterface/plugins/algorithms/BASISReduction311.py +++ b/Framework/PythonInterface/plugins/algorithms/BASISReduction311.py @@ -45,6 +45,9 @@ class BASISReduction311(PythonAlgorithm): def category(self): return "Inelastic\\Reduction" + def seeAlso(self): + return [ "BASISReduction" ] + def name(self): return "BASISReduction311" diff --git a/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py b/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py index 0c5d8382208ebce34de10cf649e0ee7b5a308b96..41caf00b74322d81bb0a8dee3754a61ae8c8825e 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py +++ b/Framework/PythonInterface/plugins/algorithms/CalculateSampleTransmission.py @@ -20,6 +20,9 @@ class CalculateSampleTransmission(PythonAlgorithm): def category(self): return 'Sample' + def seeAlso(self): + return [ "SetSampleMaterial" ] + def summary(self): return 'Calculates the scattering & transmission for a given sample material and size over a given wavelength range.' diff --git a/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py b/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py index 234a605e8d85102e77e50478bf1e97665a353692..564fec0e0b67f8a90f478403a6fcb3b8e77f0442 100644 --- a/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py +++ b/Framework/PythonInterface/plugins/algorithms/CalibrateRectangularDetectors.py @@ -52,6 +52,9 @@ class CalibrateRectangularDetectors(PythonAlgorithm): def category(self): return "Diffraction\\Calibration" + def seeAlso(self): + return [ "GetDetectorOffsets" ] + def name(self): return "CalibrateRectangularDetectors" diff --git a/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py b/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py index c474b0f71040ac4faf9d36f36e812a6f6c48097d..d9eca9bb05c256f34cf7dc4bf5736c461da14bd5 100644 --- a/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py +++ b/Framework/PythonInterface/plugins/algorithms/CheckForSampleLogs.py @@ -14,6 +14,9 @@ class CheckForSampleLogs(PythonAlgorithm): """ return "Utility\\Workspaces" + def seeAlso(self): + return [ "CompareSampleLogs","CopyLogs" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py b/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py index 6aaabfdf879bd1133bad7308efebbdfed34a3f9c..b6baac7f332d1dcaea763c6e17c7a8abf89ff96c 100644 --- a/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py +++ b/Framework/PythonInterface/plugins/algorithms/CleanFileCache.py @@ -17,6 +17,9 @@ class CleanFileCache(PythonAlgorithm): """ return "Workflow\\DataHandling" + def seeAlso(self): + return [ "ClearCache" ] + def name(self): """ """ diff --git a/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py b/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py index 2a7992709b78dc2850e2be9a4d6a5ac716f16dcf..e6a6bca8c7b5522145bb68acf24914f4966cd528 100644 --- a/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py +++ b/Framework/PythonInterface/plugins/algorithms/CompareSampleLogs.py @@ -25,6 +25,9 @@ class CompareSampleLogs(PythonAlgorithm): """ return "Utility\\Workspaces" + def seeAlso(self): + return [ "CompareWorkspaces","CheckForSampleLogs","CopySample" ] + def name(self): """ Returns name diff --git a/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py b/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py index cefc7c15e5474f13345d23d03763eeb6fe562476..869d8b5b149ee6ff472d6f685e75e39bf439faa1 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/ConjoinFiles.py @@ -11,6 +11,9 @@ class ConjoinFiles(PythonAlgorithm): def category(self): return "DataHandling\\Text" + def seeAlso(self): + return [ "ConjoinWorkspaces" ] + def name(self): return "ConjoinFiles" diff --git a/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py b/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py index cbc4405b21d0297a0b8cbfbf42a9b265b71ce47d..40240565811cb2e853128eb183d60d3107a16a36 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py +++ b/Framework/PythonInterface/plugins/algorithms/ConjoinSpectra.py @@ -17,6 +17,9 @@ class ConjoinSpectra(PythonAlgorithm): def category(self): return "Transforms\\Merging" + def seeAlso(self): + return [ "AppendSpectra","ConjoinWorkspaces" ] + def name(self): return "ConjoinSpectra" diff --git a/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py b/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py index 46ce04c74c2d931dcdf220ade2a49e05397d1b13..db4ac9fec84d3be62ca92f10c928c71f71231ae9 100644 --- a/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py +++ b/Framework/PythonInterface/plugins/algorithms/ConvertSnsRoiFileToMask.py @@ -31,6 +31,9 @@ class ConvertSnsRoiFileToMask(api.PythonAlgorithm): """ return "Inelastic\\Utility" + def seeAlso(self): + return [ "MaskDetectors" ] + def name(self): """ Name of the algorithm. diff --git a/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py b/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py index f00d6a438e4565c283a6e1ffe8ed4512f60d8786..6ff0279085ada7aabf4df8e2385b241e31ad7fd0 100644 --- a/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py +++ b/Framework/PythonInterface/plugins/algorithms/CorrectLogTimes.py @@ -17,6 +17,9 @@ class CorrectLogTimes(mantid.api.PythonAlgorithm): """ return "DataHandling\\Logs" + def seeAlso(self): + return [ "ChangeLogTime","CreateLogTimeCorrection","ChangePulsetime","ShiftLogTime" ] + def name(self): """ Mantid required """ diff --git a/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py b/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py index 8d1d0e831e269e098ceee84acd15b8cbcbbc9f8e..a4e2f8f1f10b4d14cbad8364bc105d821622635f 100644 --- a/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py +++ b/Framework/PythonInterface/plugins/algorithms/CorrectTOF.py @@ -21,6 +21,9 @@ class CorrectTOF (PythonAlgorithm): """ return "Workflow\\MLZ\\TOFTOF;Transforms\\Axes" + def seeAlso(self): + return [ "TOFTOFMergeRuns","TOFTOFCropWorkspace" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py b/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py index 026393dc796de4d5b908e6fdd99121d0216a0c34..39f42a823d35319152a14ee1976cedc32c0d61c2 100644 --- a/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/CreateEmptyTableWorkspace.py @@ -16,6 +16,9 @@ class CreateEmptyTableWorkspace(PythonAlgorithm): def category(self): return 'Utility\\Workspaces' + def seeAlso(self): + return [ "DeleteTableRows","SortTableWorkspace" ] + def PyInit(self): # Declare properties self.declareProperty(ITableWorkspaceProperty("OutputWorkspace", "", Direction.Output), diff --git a/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py b/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py index 579f1cc4802ac39a1904fa9fec880659bc66883d..6585d93e16388b07298c608c0e73c28faa2d9868 100644 --- a/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py +++ b/Framework/PythonInterface/plugins/algorithms/CreateLeBailFitInput.py @@ -18,6 +18,9 @@ class CreateLeBailFitInput(PythonAlgorithm): """ return "Diffraction\\Fitting;Utility\\Workspaces" + def seeAlso(self): + return [ "LeBailFit" ] + def name(self): """ """ diff --git a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py index 722feb44491177aadcee60bb316158ec6e38180d..c4898987d935dbfd031f8a3892d7a0f06be0d529 100644 --- a/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py +++ b/Framework/PythonInterface/plugins/algorithms/CropWorkspaceRagged.py @@ -11,6 +11,9 @@ class CropWorkspaceRagged(PythonAlgorithm): def category(self): return 'Transforms\\Splitting;Workflow' + def seeAlso(self): + return [ "CropWorkspace" ] + def name(self): return 'CropWorkspaceRagged' diff --git a/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py b/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py index 8851d3e351b7a7fe4f70adb7a00c8b9896ca89ea..234be4b2ea84fc21523f827ad89212a4f97ec4bc 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSComputeDetEffCorrCoefs.py @@ -29,6 +29,9 @@ class DNSComputeDetEffCorrCoefs(PythonAlgorithm): """ return 'Workflow\\MLZ\\DNS;CorrectionFunctions\\SpecialCorrections' + def seeAlso(self): + return [ "DNSFlippingRatioCorr" ] + def name(self): """ Returns name diff --git a/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py b/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py index 26e5b3b713262729936ce5baa2cf4558b4358e2f..d2c237c7e40d23d3386dd8faaa759e52e5be17ae 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSFlippingRatioCorr.py @@ -32,6 +32,9 @@ class DNSFlippingRatioCorr(PythonAlgorithm): """ return 'Workflow\\MLZ\\DNS;;CorrectionFunctions\\SpecialCorrections' + def seeAlso(self): + return [ "DNSComputeDetEffCorrCoefs" ] + def name(self): """ Returns name diff --git a/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py b/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py index 0a98575c21b3d74bb25f6e6a1668dda2c2c08eef..8110e19d9fe1c88dc2e3d88ef38c61a483d270a9 100644 --- a/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py +++ b/Framework/PythonInterface/plugins/algorithms/DNSMergeRuns.py @@ -30,6 +30,9 @@ class DNSMergeRuns(PythonAlgorithm): """ return 'Workflow\\MLZ\\DNS' + def seeAlso(self): + return [ "LoadDNSLegacy" ] + def name(self): """ Returns name diff --git a/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py b/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py index 2e8176f65d3fbaf646fbba78e675e5805c93741f..351f905d5cb4285c6752efc0be08516718fc9421 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggCalibrate.py @@ -10,6 +10,9 @@ class EnggCalibrate(PythonAlgorithm): def category(self): return "Diffraction\\Engineering" + def seeAlso(self): + return [ "EnggCalibrateFull" ] + def name(self): return "EnggCalibrate" diff --git a/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py b/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py index df8ed01c1260745c113ff6c63c2db27f0a5962d0..c3b5e48c07e649baefedeb5bb95e19e54cb41e63 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggCalibrateFull.py @@ -12,6 +12,9 @@ class EnggCalibrateFull(PythonAlgorithm): def category(self): return "Diffraction\\Engineering" + def seeAlso(self): + return [ "EnggCalibrate" ] + def name(self): return "EnggCalibrateFull" diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFitDIFCFromPeaks.py b/Framework/PythonInterface/plugins/algorithms/EnggFitDIFCFromPeaks.py index fab141ea1d2315f4f22fcfbb62b9860a5c2546a6..5526e2a7cff3942ce226d618bb90da2c7a559df0 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFitDIFCFromPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFitDIFCFromPeaks.py @@ -8,6 +8,9 @@ class EnggFitDIFCFromPeaks(PythonAlgorithm): def category(self): return "Diffraction\\Engineering;Diffraction\\Fitting" + def seeAlso(self): + return [ "EnggFitPeaks","GSASIIRefineFitPeaks","Fit" ] + def name(self): return "EnggFitPeaks" diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py b/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py index 2a58c7e58ab454a6067218bd84042ea1be3d45e2..a951a7275f84f4469850226928bd554f1f045a85 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFitPeaks.py @@ -19,6 +19,9 @@ class EnggFitPeaks(PythonAlgorithm): def category(self): return "Diffraction\\Engineering;Diffraction\\Fitting" + def seeAlso(self): + return [ "EnggFitDIFCFromPeaks","GSASIIRefineFitPeaks","Fit" ] + def name(self): return "EnggFitPeaks" diff --git a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py index 28ecf993a48d5403c04f3ac7fa2bba021ee4fa61..128ab3e76045932c76c146d95a794468ead0df59 100644 --- a/Framework/PythonInterface/plugins/algorithms/EnggFocus.py +++ b/Framework/PythonInterface/plugins/algorithms/EnggFocus.py @@ -11,6 +11,9 @@ class EnggFocus(PythonAlgorithm): def category(self): return "Diffraction\\Engineering" + def seeAlso(self): + return [ "AlignDetectors","DiffractionFocussing" ] + def name(self): return "EnggFocus" diff --git a/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py b/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py index 82f6ca11e41d3efaf03e9e8fbd230a16e6de559f..25167d7a36c7a7b9870b5e9d0c371c6b3d3f8e42 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportExperimentLog.py @@ -40,6 +40,9 @@ class ExportExperimentLog(PythonAlgorithm): """ return 'DataHandling\\Logs' + def seeAlso(self): + return [ "ExportSampleLogsToCSVFile" ] + def PyInit(self): """ Declaration of properties """ diff --git a/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py b/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py index dac0fb3c0d80e405883a551397ff464aec38629e..aca44bbbd2136b978354554146d6e686dff117ec 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportGeometry.py @@ -46,6 +46,9 @@ class ExportGeometry(PythonAlgorithm): def category(self): return "Utility\\Instrument" + def seeAlso(self): + return [ "LoadInstrument" ] + def name(self): return "ExportGeometry" diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py index be7dd8390cf2485a6eb3d434089d55f1311c5faf..dad5fffe9e8d1573bb7f673e2569204f00d35b1b 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSampleLogsToCSVFile.py @@ -41,6 +41,9 @@ class ExportSampleLogsToCSVFile(PythonAlgorithm): """ return "DataHandling\\Logs" + def seeAlso(self): + return [ "ExportExperimentLog" ] + def name(self): """ Algorithm name """ diff --git a/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py b/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py index 69310ca255d518d027b0690d75a58c8ccfc724d7..cc407f5afdd96aedea7c2857c183e09fc80135ba 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py +++ b/Framework/PythonInterface/plugins/algorithms/ExportSpectraMask.py @@ -165,6 +165,9 @@ class ExportSpectraMask(PythonAlgorithm): """ return "DataHandling\\Masking" + def seeAlso(self): + return [ "SaveMask","ExportSpectraMask" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py b/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py index 15f1a2fcf4363537084155b84c9d6230cefc5ae0..54e3154eb24bc8add89d2a3d77f4059d4b6c58ce 100644 --- a/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py +++ b/Framework/PythonInterface/plugins/algorithms/ExtractMonitors.py @@ -11,6 +11,9 @@ class ExtractMonitors(DataProcessorAlgorithm): def summary(self): return 'Separates the monitors and/or detectors into separate workspaces.' + def seeAlso(self): + return [ "ExtractMonitorWorkspace" ] + def PyInit(self): self.declareProperty(MatrixWorkspaceProperty('InputWorkspace', '', direction=Direction.Input), diff --git a/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py b/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py index 450554a5dd5f918555a3404dc72c2c4f08779e4c..5089d9fa7cc9a9cae933752dd4429b496f32814a 100644 --- a/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py +++ b/Framework/PythonInterface/plugins/algorithms/FilterLogByTime.py @@ -12,6 +12,9 @@ class FilterLogByTime(PythonAlgorithm): def category(self): return "Events\\EventFiltering" + def seeAlso(self): + return [ "FilterByTime","FilterByLogValue" ] + def name(self): return "FilterLogByTime" diff --git a/Framework/PythonInterface/plugins/algorithms/FitGaussian.py b/Framework/PythonInterface/plugins/algorithms/FitGaussian.py index 8777631a52d5228667de2928441f4a64f2f8f22c..fe11460f638beb294ae673481bcef879406234aa 100644 --- a/Framework/PythonInterface/plugins/algorithms/FitGaussian.py +++ b/Framework/PythonInterface/plugins/algorithms/FitGaussian.py @@ -11,6 +11,9 @@ class FitGaussian(PythonAlgorithm): def category(self): return "Optimization" + def seeAlso(self): + return [ "Fit" ] + def PyInit(self): # input self.declareProperty(MatrixWorkspaceProperty("Workspace", "", Direction.Input), diff --git a/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py b/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py index 93aa61dbf9ff9a7f7eeeaf643d1ca636e24c1f67..c9ccb2c5628adab6b76c19c77cdf2389b38f1480 100644 --- a/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py +++ b/Framework/PythonInterface/plugins/algorithms/GSASIIRefineFitPeaks.py @@ -45,6 +45,9 @@ class GSASIIRefineFitPeaks(PythonAlgorithm): def category(self): return "Diffraction\\Engineering;Diffraction\\Fitting" + def seeAlso(self): + return [ "LoadGSS","SaveGSS","Fit","EnggFitPeaks" ] + def name(self): return "GSASIIRefineFitPeaks" @@ -248,7 +251,7 @@ class GSASIIRefineFitPeaks(PythonAlgorithm): """ phase_paths = self.getPropertyValue(self.PROP_PATHS_TO_PHASE_FILES).split(",") refinements = self._create_refinement_params_dict(num_phases=len(phase_paths)) - prog = Progress(self, start=0, end=1, nreports=len(refinements) + 1) + prog = Progress(self, start=0, end=1, nreports=2) prog.report("Reading phase files") for phase_path in phase_paths: @@ -256,8 +259,8 @@ class GSASIIRefineFitPeaks(PythonAlgorithm): if do_pawley: self._set_pawley_phase_parameters(phase) + prog.report("Running {} refinement steps".format(len(refinements))) for i, refinement in enumerate(refinements): - prog.report("Step {} of refinement recipe".format(i + 1)) gsas_proj.do_refinements([refinement]) gsas_proj.save() diff --git a/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py b/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py index 6a712c3ec19cd2efaa681b04210a690018dd488f..d0eaa513924ae05d22a466f732f6dc3a304fc0cf 100644 --- a/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py +++ b/Framework/PythonInterface/plugins/algorithms/GenerateGroupingSNSInelastic.py @@ -16,6 +16,9 @@ class GenerateGroupingSNSInelastic(mantid.api.PythonAlgorithm): """ return "Inelastic\\Utility;Transforms\\Grouping" + def seeAlso(self): + return [ "GroupWorkspaces" ] + def name(self): """ Mantid required """ diff --git a/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py b/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py index 0ad786a631a52025ddddbd0bc220bacfde4061c2..7c84a9c231b2d62426e0e9ba0cc9cbd29017fe1e 100644 --- a/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py +++ b/Framework/PythonInterface/plugins/algorithms/GetEiT0atSNS.py @@ -10,6 +10,9 @@ class GetEiT0atSNS(mantid.api.PythonAlgorithm): """ return "Inelastic\\Ei" + def seeAlso(self): + return [ "GetEi" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py b/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py index 8e954c53f6964d3ba5314a08747be04859bdd391..f119bb777a707574bde68546b2eeef0c2f6e7683 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadAndMerge.py @@ -15,6 +15,9 @@ class LoadAndMerge(PythonAlgorithm): _prefix = '' _progress = None + def seeAlso(self): + return [ "Load","MergeRuns" ] + def name(self): return "LoadMergeRuns" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadEXED.py b/Framework/PythonInterface/plugins/algorithms/LoadEXED.py index cc32a7e6cbb70cbe01bbd0836c7924403dcb3b32..8821f9ce1f9ca65c30e912b7470616967ec956c3 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadEXED.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadEXED.py @@ -24,7 +24,7 @@ class LoadEXED(PythonAlgorithm): """ def category(self): - return "Inelastic;Diffraction;PythonAlgorithms" + return "Inelastic;Diffraction" def name(self): return "LoadEXED" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py b/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py index c48ad3107bee394f17529cd313de73a6086c7a1f..a8b82620cbca37ce2526781777e72b34f4fff1e3 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadEmptyVesuvio.py @@ -29,6 +29,10 @@ class LoadEmptyVesuvio(PythonAlgorithm): return 'DataHandling\\Raw' #---------------------------------------------------------------------------------------- + def seeAlso(self): + return [ "LoadVesuvio" ] + +#---------------------------------------------------------------------------------------- def PyInit(self): self.declareProperty(FileProperty(INST_PAR_PROP, "", action=FileAction.OptionalLoad, extensions=["dat"]), diff --git a/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py b/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py index 86d686206b6401f77efbe073b0119fc6fc73d644..d389ab8868345016f4c89e581dd4f8c487fb0de0 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadFullprofFile.py @@ -21,6 +21,9 @@ class LoadFullprofFile(PythonAlgorithm): """ return "Diffraction\\DataHandling" + def seeAlso(self): + return [ "LoadFullprofResolution" ] + def name(self): """ """ diff --git a/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py b/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py index 22d6f03a55eb33fe8b3b610fd6b1aa729df51a68..2b3cfd8b0dad701e5687e5c1232675c3b22c315c 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadLogPropertyTable.py @@ -18,6 +18,9 @@ class LoadLogPropertyTable(PythonAlgorithm): return "Creates a table of Run number against the log values for that run for a range of files.\ It can use a single log value or a list of log values." + def seeAlso(self): + return [ "LoadLog", "LoadMuonLog" ] + # same concept as built in "CreateLogPropertyTable" but loads its own workspaces and needn't hold all in memory at once # select log values to put in table (list) # special cases for: diff --git a/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py b/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py index a00fb3a26a6a22eabf8178fb3a131461220452c6..cba8e48b6cd5f3b65b77b33a3d9454cae32c26e1 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadMultipleGSS.py @@ -14,6 +14,9 @@ class LoadMultipleGSS(PythonAlgorithm): def category(self): return "DataHandling\\Text" + def seeAlso(self): + return [ "LoadGSS" ] + def name(self): return "LoadMultipleGSS" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py b/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py index 9166c9e8e4474aeab9e0c541a59c8625aaa32a3e..d452a23ab3aad343a377838f088de2546bab3b2a 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVesuvio.py @@ -107,6 +107,12 @@ class LoadVesuvio(LoadEmptyVesuvio): """ Defines the category the algorithm will be put in the algorithm browser """ return 'DataHandling\\Raw' + +#---------------------------------------------------------------------------------------- + + def seeAlso(self): + return [ "LoadEmptyVesuvio" ,"LoadRaw" ] + #---------------------------------------------------------------------------------------- def PyInit(self): diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py index 6b965402ea76ccca15964494abb4a29c8251b36d..371d7872146617b6f4b99153d9e79ead2b8f7335 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticBS.py @@ -16,6 +16,9 @@ class LoadVisionElasticBS(PythonAlgorithm): def category(self): return "DataHandling\\Nexus" + def seeAlso(self): + return [ "LoadVisionElasticEQ","LoadVisionInelastic" ] + def name(self): return "LoadVisionElasticBS" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py index 79b1af0f6ebcd60cf5141da6767fdf711b1a345a..8ce8b6db34ea8b101b84ed8e38430b7cec04ca1b 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionElasticEQ.py @@ -16,6 +16,9 @@ class LoadVisionElasticEQ(PythonAlgorithm): def category(self): return "DataHandling\\Nexus" + def seeAlso(self): + return [ "LoadVisionElasticBS","LoadVisionInelastic" ] + def name(self): return "LoadVisionElasticEQ" diff --git a/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py b/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py index fdec94a4f92a39fe258c4e5ff998cc43cf2f6fbc..8fe64569d0796e89a3db72a9d0a8af83a16372bf 100644 --- a/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py +++ b/Framework/PythonInterface/plugins/algorithms/LoadVisionInelastic.py @@ -16,6 +16,9 @@ class LoadVisionInelastic(PythonAlgorithm): def category(self): return "DataHandling\\Nexus" + def seeAlso(self): + return [ "LoadVisionElasticBS","LoadVisionElasticEQ" ] + def name(self): return "LoadVisionInelastic" diff --git a/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py b/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py index ef7bf24f40c7622be9f353368d36374c3a4a267e..3b0f9d86b24f3ce77acaa66c9409d3899d2627a1 100644 --- a/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py +++ b/Framework/PythonInterface/plugins/algorithms/MRFilterCrossSections.py @@ -186,7 +186,8 @@ class MRFilterCrossSections(PythonAlgorithm): api.AddSampleLog(Workspace=ws, LogName='cross_section_id', LogText=pol_state) - AnalysisDataService.remove(ws_raw_name) + if ws_event_data is None: + AnalysisDataService.remove(ws_raw_name) self.setProperty("CrossSectionWorkspaces", output_wsg) # If we don't have a splitter table, it might be because we don't have analyzer/polarizer @@ -196,7 +197,8 @@ class MRFilterCrossSections(PythonAlgorithm): self.setProperty("CrossSectionWorkspaces", api.GroupWorkspaces([ws_raw])) else: api.logger.error("No events remained after filtering") - AnalysisDataService.remove(ws_raw_name) + if ws_event_data is None: + AnalysisDataService.remove(ws_raw_name) def load_legacy_cross_Sections(self, file_path): """ diff --git a/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py b/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py index 596f1e40170905fffde3ea049e0eece8dc0132bc..91be6ae1c855a9b9c1d7ef5292fc746f4f5a6791 100644 --- a/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/MagnetismReflectometryReduction.py @@ -477,29 +477,42 @@ class MagnetismReflectometryReduction(PythonAlgorithm): """ sample_length = self.getProperty("SampleLength").value - #TODO: Read the slit distances relative to the sample from the logs once - # they are available with the new DAS. - slits =[[ws.getRun().getProperty("S1HWidth").getStatistics().mean, 2600.], - [ws.getRun().getProperty("S2HWidth").getStatistics().mean, 2019.], - [ws.getRun().getProperty("S3HWidth").getStatistics().mean, 714.]] - theta = ws.getRun().getProperty("two_theta").value/2.0 + # In newer data files, the slit distances are part of the logs + if ws.getRun().hasProperty("S1Distance"): + s1_dist = ws.getRun().getProperty("S1Distance").value + s2_dist = ws.getRun().getProperty("S2Distance").value + s3_dist = ws.getRun().getProperty("S3Distance").value + else: + s1_dist = -2600. + s2_dist = -2019. + s3_dist = -714. + slits =[[ws.getRun().getProperty("S1HWidth").getStatistics().mean, s1_dist], + [ws.getRun().getProperty("S2HWidth").getStatistics().mean, s2_dist], + [ws.getRun().getProperty("S3HWidth").getStatistics().mean, s3_dist]] + theta = ws.getRun().getProperty("two_theta").value/2.0 * np.pi / 180.0 res=[] - s_width=sample_length*math.sin(theta) + s_width=sample_length*np.sin(theta) for width, dist in slits: # Calculate the maximum opening angle dTheta if s_width > 0.: - d_theta = math.atan((s_width/2.*(1.+width/s_width))/dist)*2. + d_theta = np.arctan((s_width/2.*(1.+width/s_width))/dist)*2. else: - d_theta = math.atan(width/2./dist)*2. + d_theta = np.arctan(width/2./dist)*2. # The standard deviation for a uniform angle distribution is delta/sqrt(12) res.append(d_theta*0.28867513) - dq_over_q = min(res) / math.tan(theta) + # Wavelength uncertainty + lambda_min = ws.getRun().getProperty("lambda_min").value + lambda_max = ws.getRun().getProperty("lambda_max").value + dq_over_q = min(res) / np.tan(theta) data_x = ws.dataX(0) data_dx = ws.dataDx(0) + dwl = (lambda_max - lambda_min) / len(data_x) / np.sqrt(12.0) for i in range(len(data_x)): - data_dx[i] = data_x[i] * dq_over_q + dq_theta = data_x[i] * dq_over_q + dq_wl = data_x[i]**2 * dwl / (4.0*np.pi*np.sin(theta)) + data_dx[i] = np.sqrt(dq_theta**2 + dq_wl**2) return ws diff --git a/Framework/PythonInterface/plugins/algorithms/MaskAngle.py b/Framework/PythonInterface/plugins/algorithms/MaskAngle.py index 772db73daecb35af2814be1d49e0453e8bfce3ab..5c5805a536903e495f62f09b15502f6c6332cff2 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskAngle.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskAngle.py @@ -15,6 +15,9 @@ class MaskAngle(mantid.api.PythonAlgorithm): """ return "Transforms\\Masking" + def seeAlso(self): + return [ "MaskDetectors" ] + def name(self): """ Mantid require """ diff --git a/Framework/PythonInterface/plugins/algorithms/MaskBTP.py b/Framework/PythonInterface/plugins/algorithms/MaskBTP.py index 071924945e83957fa3a3cfe554590fd079bee597..e3bdc053705e7602745acecfb71714fe05a3dcef 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskBTP.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskBTP.py @@ -24,6 +24,9 @@ class MaskBTP(mantid.api.PythonAlgorithm): """ return "Transforms\\Masking;Inelastic\\Utility" + def seeAlso(self): + return [ "MaskDetectors","MaskInstrument" ] + def name(self): """ Mantid required """ diff --git a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py index 981b8b3d0a470fa1e074d75da1381f2fc734a916..ae736dae55d479c3cfb1a395a131d0099d1bda92 100644 --- a/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py +++ b/Framework/PythonInterface/plugins/algorithms/MaskWorkspaceToCalFile.py @@ -24,6 +24,10 @@ class MaskWorkspaceToCalFile(PythonAlgorithm): def category(self): return "DataHandling\\Text;Diffraction\\DataHandling;Diffraction\\Masking" + def seeAlso(self): + return [ "ReadGroupsFromFile","CreateDummyCalFile","CreateCalFileByNames", + "AlignDetectors","DiffractionFocussing","LoadCalFile","SaveCalFile","MergeCalFiles" ] + def name(self): return "MaskWorkspaceToCalFile" diff --git a/Framework/PythonInterface/plugins/algorithms/Mean.py b/Framework/PythonInterface/plugins/algorithms/Mean.py index 7b192ce4e894eabcfe54f96da93713d5491a0b0c..59d8b93a16e3789946e7158f5bcd7699c6e20f16 100644 --- a/Framework/PythonInterface/plugins/algorithms/Mean.py +++ b/Framework/PythonInterface/plugins/algorithms/Mean.py @@ -13,6 +13,9 @@ class Mean(PythonAlgorithm): def category(self): return "Arithmetic" + def seeAlso(self): + return [ "MostLikelyMean","WeightedMean","WeightedMeanOfWorkspace" ] + def name(self): return "Mean" diff --git a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py index 8c2b116f84f9e6f4cb2583603a41ad3191c259a4..ea0382a6d5898cbc16ccfa4255da245d5fd53259 100644 --- a/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py +++ b/Framework/PythonInterface/plugins/algorithms/MergeCalFiles.py @@ -9,6 +9,10 @@ class MergeCalFiles(PythonAlgorithm): def category(self): return "DataHandling\\Text;Diffraction\\DataHandling\\CalFiles" + def seeAlso(self): + return [ "ReadGroupsFromFile","CreateDummyCalFile","CreateCalFileByNames", + "AlignDetectors","DiffractionFocussing","LoadCalFile","SaveCalFile" ] + def name(self): return "MergeCalFiles" diff --git a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py index 2ede9effc741e6184b06ff5121d5dd75bef57738..28eafd02a7fd473f21be65ea9455ae291cc023e8 100644 --- a/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py +++ b/Framework/PythonInterface/plugins/algorithms/MuonMaxent.py @@ -35,6 +35,9 @@ class MuonMaxent(PythonAlgorithm): def category(self): return "Muon;Arithmetic\\FFT" + def seeAlso(self): + return [ "PhaseQuad","FFT" ] + def PyInit(self): self.declareProperty( WorkspaceProperty("InputWorkspace", diff --git a/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py b/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py index 71ee15fb52ca8821dc1d0c0afd1bb0be207dde87..136152bbcc960359627df6abdf66a212768a79d9 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py +++ b/Framework/PythonInterface/plugins/algorithms/PDToGUDRUN.py @@ -15,6 +15,9 @@ class PDToGUDRUN(DataProcessorAlgorithm): def category(self): return "Workflow\\Diffraction" + def seeAlso(self): + return [ "PDToPDFgetN" ] + def name(self): return "PDToGUDRUN" diff --git a/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py b/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py index b31a019a7a528ab7baa4324973b78aa31c378542..0e2e6709d0e88e4a3b64e60eb2044b19496127b2 100644 --- a/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py +++ b/Framework/PythonInterface/plugins/algorithms/PDToPDFgetN.py @@ -19,6 +19,9 @@ class PDToPDFgetN(DataProcessorAlgorithm): def category(self): return "Workflow\\Diffraction" + def seeAlso(self): + return [ "PDToGUDRUN" ] + def name(self): return "PDToPDFgetN" diff --git a/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py b/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py index 6d18bd5d01ac181955c3da5428e2481345996947..9f96154d37d3f80b01e452e3edde20a8d62d10c0 100644 --- a/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/PearlMCAbsorption.py @@ -14,6 +14,10 @@ class PearlMCAbsorption(PythonAlgorithm): def summary(self): return "Loads pre-calculated or measured absorption correction files for Pearl." + def seeAlso(self): + return [ "MonteCarloAbsorption", "MayersSampleCorrection", + "MultipleScatteringCylinderAbsorption", "VesuvioCalculateMS" ] + def PyInit(self): # Input file self.declareProperty(FileProperty("Filename","", FileAction.Load, ['.out','.dat']), doc="The name of the input file.") diff --git a/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py b/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py index da350d1d7d0469b64b7636868b36c55aad38135b..a1207669b60cec5d82fd06e4fa0790d912e69f89 100644 --- a/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py +++ b/Framework/PythonInterface/plugins/algorithms/PoldiCreatePeaksFromFile.py @@ -144,6 +144,9 @@ class PoldiCreatePeaksFromFile(PythonAlgorithm): def category(self): return "SINQ\\Poldi" + def seeAlso(self): + return [ "PoldiCreatePeaksFromCell" ] + def name(self): return "PoldiLoadCrystalData" diff --git a/Framework/PythonInterface/plugins/algorithms/RefLReduction.py b/Framework/PythonInterface/plugins/algorithms/RefLReduction.py deleted file mode 100644 index a6467a68d83d5d21e9fa6df7d7fa29fc54440c86..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/plugins/algorithms/RefLReduction.py +++ /dev/null @@ -1,390 +0,0 @@ -#pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) -from mantid.api import * -from mantid.simpleapi import * -from mantid.kernel import * - -# import sfCalculator -import sys -import os -sys.path.insert(0,os.path.dirname(__file__)) -import sfCalculator # noqa -sys.path.pop(0) - - -class RefLReduction(PythonAlgorithm): - - def category(self): - return "Reflectometry\\SNS" - - def name(self): - return "RefLReduction" - - def version(self): - return 1 - - def summary(self): - return "Liquids Reflectometer (REFL) reduction" - - def PyInit(self): - self.declareProperty(IntArrayProperty("RunNumbers"), "List of run numbers to process") - self.declareProperty("NormalizationRunNumber", 0, "Run number of the normalization run to use") - self.declareProperty(IntArrayProperty("SignalPeakPixelRange"), "Pixel range defining the data peak") - self.declareProperty("SubtractSignalBackground", True, - doc='If true, the background will be subtracted from the data peak') - self.declareProperty(IntArrayProperty("SignalBackgroundPixelRange", [123, 137], - IntArrayLengthValidator(2), direction=Direction.Input), - "Pixelrange defining the background. Default:(123,137)") - self.declareProperty("NormFlag", True, doc="If true, the data will be normalized") - self.declareProperty(IntArrayProperty("NormPeakPixelRange", [127,133], - IntArrayLengthValidator(2), direction=Direction.Input), - "Pixel range defining the normalization peak") - self.declareProperty("SubtractNormBackground", True, - doc="If true, the background will be subtracted from the normalization peak") - self.declareProperty(IntArrayProperty("NormBackgroundPixelRange", [127,137], - IntArrayLengthValidator(2), direction=Direction.Input), - "Pixel range defining the background for the normalization") - self.declareProperty("LowResDataAxisPixelRangeFlag", True, - doc="If true, the low resolution direction of the data will be cropped according "+ - "to the lowResDataAxisPixelRange property") - self.declareProperty(IntArrayProperty("LowResDataAxisPixelRange", [115,210], - IntArrayLengthValidator(2), direction=Direction.Input), - "Pixel range to use in the low resolution direction of the data") - self.declareProperty("LowResNormAxisPixelRangeFlag", True, - doc="If true, the low resolution direction of the normalization run will be cropped "+ - "according to the LowResNormAxisPixelRange property") - self.declareProperty(IntArrayProperty("LowResNormAxisPixelRange", [115,210], - IntArrayLengthValidator(2), direction=Direction.Input), - "Pixel range to use in the low resolution direction of the normalizaion run") - self.declareProperty(FloatArrayProperty("TOFRange", [9000., 23600.], - FloatArrayLengthValidator(2), direction=Direction.Input), - "TOF range to use") - self.declareProperty("TofRangeFlag", True, - doc="If true, the TOF will be cropped according to the TOF range property") - self.declareProperty("QMin", 0.05, doc="Mnimum Q-value") - self.declareProperty("QStep", 0.02, doc="Step size in Q. Enter a negative value to get a log scale") - self.declareProperty("AngleOffset", 0.0, doc="angle offset (degrees)") - self.declareProperty("AngleOffsetError", 0.0, doc="Angle offset error (degrees)") - self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "", Direction.Output), "Output workspace") -# self.declareProperty("", True, -# doc="Use Scaling Factor configuration file") - self.declareProperty("ScalingFactorFile", "", doc="Scaling factor configuration file") - self.declareProperty("SlitsWidthFlag", True, - doc="Looking for perfect match of slits width when using Scaling Factor file") - self.declareProperty("IncidentMediumSelected", "", doc="Incident medium used for those runs") - self.declareProperty("GeometryCorrectionFlag", False, doc="Use or not the geometry correction") - - #pylint: disable=too-many-locals, too-many-branches - def PyExec(self): - - print('-- > starting new Reflectometer Reduction ...') - - from reduction.instruments.reflectometer import wks_utility - - #remove all previous workspaces - list_mt = mtd.getObjectNames() - for _mt in list_mt: - if _mt.find('_scaled') != -1: - DeleteWorkspace(_mt) - if _mt.find('_reflectivity') != -1: - DeleteWorkspace(_mt) - - # retrieve settings from GUI - print('-> Retrieving settings from GUI') - - #print 'RunNumbers: ' + str(self.getProperty("RunNumbers").value) - #print 'NormalizationRunNumber: ' + str(self.getProperty("NormalizationRunNumber").value) - #print 'SignalPeakPixelRange: ' + str(self.getProperty("SignalPeakPixelRange").value) - #print 'SubtractSignalBackground: ' + str(self.getProperty("SubtractSignalBackground").value) - #print 'SignalBackgroundPixelRange: ' + str(self.getProperty("SignalBackgroundPixelRange").value) - #print "NormFlag: " + str(self.getProperty("NormFlag").value) - #print "NormPeakPixelRange: " + str(self.getProperty("NormPeakPixelRange").value) - #print "NormBackgroundPixelRange: " + str(self.getProperty("NormBackgroundPixelRange").value) - #print "SubtractNormBackground: " + str(self.getProperty("SubtractNormBackground").value) - #print "LowResDataAxisPixelRangeFlag: " + str(self.getProperty("LowResDataAxisPixelRangeFlag").value) - #print "LowResDataAxisPixelRange: " + str(self.getProperty("LowResDataAxisPixelRange").value) - #print "LowResNormAxisPixelRangeFlag: " + str(self.getProperty("LowResNormAxisPixelRangeFlag").value) - #print "LowResNormAxisPixelRange: " + str(self.getProperty("LowResNormAxisPixelRange").value) - #print "TOFRange: " + str(self.getProperty("TOFRange").value) - #print "IncidentMediumSelected: " + str(self.getProperty("incidentMediumSelected").value) - #print "GeometryCorrectionFlag: " + str(self.getProperty("GeometryCorrectionFlag").value) - #print "QMin: " + str(self.getProperty("QMin").value) - #print "QStep: " + str(self.getProperty("QStep").value) - #print "ScalingFactorFile: " + str(self.getProperty("ScalingFactorFile").value) - #print "SlitsWidthFlag: " + str(self.getProperty("SlitsWidthFlag").value) - #print "OutputWorkspace: " + str(self.getProperty("OutputWorkspace").value) - - # DATA - dataRunNumbers = self.getProperty("RunNumbers").value - dataPeakRange = self.getProperty("SignalPeakPixelRange").value - dataBackRange = self.getProperty("SignalBackgroundPixelRange").value - dataBackFlag = self.getProperty("SubtractSignalBackground").value - #Due to the frame effect, it's sometimes necessary to narrow the range - #over which we add all the pixels along the low resolution - #Parameter - dataLowResFlag = self.getProperty("LowResDataAxisPixelRangeFlag") - if dataLowResFlag: - dataLowResRange = self.getProperty("LowResDataAxisPixelRange").value - else: - dataLowResRange = [0,maxX-1] - - # NORM - normalizationRunNumber = self.getProperty("NormalizationRunNumber").value - # normFlag = self.getProperty("NormFlag") - normBackRange = self.getProperty("NormBackgroundPixelRange").value - normPeakRange = self.getProperty("NormPeakPixelRange").value - normBackFlag = self.getProperty("SubtractNormBackground").value - #Due to the frame effect, it's sometimes necessary to narrow the range - #over which we add all the pixels along the low resolution - #Parameter - normLowResFlag = self.getProperty("LowResNormAxisPixelRangeFlag") - if normLowResFlag: - normLowResRange = self.getProperty("LowResNormAxisPixelRange").value - else: - normLowResRange = [0,maxX-1] - - #GENERAL - TOFrangeFlag = self.getProperty("TofRangeFlag") - if TOFrangeFlag: - TOFrange = self.getProperty("TOFRange").value #microS - else: - TOFrange = [0, 200000] - # TOF binning parameters - binTOFrange = [0, 200000] - binTOFsteps = 40 - - # geometry correction - geometryCorrectionFlag = self.getProperty("GeometryCorrectionFlag").value - - qMin = self.getProperty("QMin").value - qStep = self.getProperty("QStep").value - if qStep > 0: #force logarithmic binning - qStep = -qStep - - # angle offset - angleOffsetDeg = self.getProperty("AngleOffset").value - - # sfCalculator settings - slitsValuePrecision = sfCalculator.PRECISION - sfFile = self.getProperty("ScalingFactorFile").value - - incidentMedium = self.getProperty("IncidentMediumSelected").value - slitsWidthFlag = self.getProperty("SlitsWidthFlag").value - # ==== done retrievin the settings ===== - - # ==== start reduction ==== - - # work with data - # load data - ws_event_data = wks_utility.loadNeXus(dataRunNumbers, 'data') - - is_nexus_detector_rotated_flag = wks_utility.isNexusTakeAfterRefDate(ws_event_data.getRun().getProperty('run_start').value) - print('-> is NeXus taken with new detector geometry: ' + str(is_nexus_detector_rotated_flag)) - - ## retrieve general informations - # calculate the central pixel (using weighted average) - print('-> retrieving general informations') - data_central_pixel = wks_utility.getCentralPixel(ws_event_data, - dataPeakRange, - is_nexus_detector_rotated_flag) - # get the distance moderator-detector and sample-detector - [dMD, dSD] = wks_utility.getDistances(ws_event_data) - # get theta - theta = wks_utility.getTheta(ws_event_data, angleOffsetDeg) - # get proton charge - pc = wks_utility.getProtonCharge(ws_event_data) - error_0 = 1. / pc - - # rebin data - ws_histo_data = wks_utility.rebinNeXus(ws_event_data, - [binTOFrange[0], binTOFsteps, binTOFrange[1]], - 'data') - - # get q range - q_range = wks_utility.getQrange(ws_histo_data, theta, dMD, qMin, qStep) - - # slit size - [first_slit_size, last_slit_size] = wks_utility.getSlitsSize(ws_histo_data) - - # keep only TOF range - ws_histo_data = wks_utility.cropTOF(ws_histo_data, - TOFrange[0], - TOFrange[1], - 'data') - - # normalize by current proton charge - ws_histo_data = wks_utility.normalizeNeXus(ws_histo_data, 'data') - - # integrate over low resolution range - [data_tof_axis, data_y_axis, data_y_error_axis] = wks_utility.integrateOverLowResRange(ws_histo_data, - dataLowResRange, - 'data', - is_nexus_detector_rotated_flag) - -# #DEBUG ONLY -# wks_utility.ouput_big_ascii_file( -#'/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/data_file_after_low_resolution_integration.txt', -# data_tof_axis, -# data_y_axis, -# data_y_error_axis) - - tof_axis = data_tof_axis[0:-1].copy() - tof_axis_full = data_tof_axis.copy() - - # data_tof_axis.shape -> (62,) - # data_y_axis.shape -> (256,61) - - #substract background - [data_y_axis, data_y_error_axis] = wks_utility.substractBackground(tof_axis , - data_y_axis, - data_y_error_axis, - dataPeakRange, - dataBackFlag, - dataBackRange, - error_0, - 'data') -# #DEBUG ONLY -# wks_utility.ouput_big_ascii_file('/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/data_file_back_sub_not_integrated.txt', -# data_tof_axis, -# data_y_axis, -# data_y_error_axis) - - # work with normalization - - # load normalization - ws_event_norm = wks_utility.loadNeXus(int(normalizationRunNumber), 'normalization') - - # get proton charge - pc = wks_utility.getProtonCharge(ws_event_norm) - error_0 = 1. / pc - - # rebin normalization - ws_histo_norm = wks_utility.rebinNeXus(ws_event_norm, - [binTOFrange[0], binTOFsteps, binTOFrange[1]], - 'normalization') - - # keep only TOF range - ws_histo_norm = wks_utility.cropTOF(ws_histo_norm, - TOFrange[0], - TOFrange[1], - 'normalization') - - # normalize by current proton charge - ws_histo_norm = wks_utility.normalizeNeXus(ws_histo_norm, 'normalization') - - # integrate over low resolution range - [norm_tof_axis, norm_y_axis, norm_y_error_axis] = wks_utility.integrateOverLowResRange(ws_histo_norm, - normLowResRange, - 'normalization', - is_nexus_detector_rotated_flag) - - # substract background - [norm_y_axis, norm_y_error_axis] = wks_utility.substractBackground(norm_tof_axis[0:-1], - norm_y_axis, - norm_y_error_axis, - normPeakRange, - normBackFlag, - normBackRange, - error_0, - 'normalization') - - [av_norm, av_norm_error] = wks_utility.fullSumWithError(norm_y_axis, - norm_y_error_axis) - -# ## DEBUGGING ONLY -# wks_utility.ouput_ascii_file('/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/norm_file_back_sub_not_integrated.txt', -# norm_tof_axis, -# av_norm, -# av_norm_error) - - [final_data_y_axis, final_data_y_error_axis] = wks_utility.divideDataByNormalization(data_y_axis, - data_y_error_axis, - av_norm, - av_norm_error) - -# #DEBUG ONLY -# wks_utility.ouput_big_ascii_file('/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/data_divided_by_norm_not_integrated.txt', -# data_tof_axis, -# final_data_y_axis, -# final_data_y_error_axis) - - # apply Scaling factor - [tof_axis_full, y_axis, y_error_axis, isSFfound] = wks_utility.applyScalingFactor(tof_axis_full, - final_data_y_axis, - final_data_y_error_axis, - incidentMedium, - sfFile, - slitsValuePrecision, - slitsWidthFlag) - -# #DEBUG ONLY -# wks_utility.ouput_big_ascii_file('/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/after_applying_scaling_factor.txt', -# data_tof_axis, -# y_axis, -# y_error_axis) - - if geometryCorrectionFlag: # convert To Q with correction - [q_axis, y_axis, y_error_axis] = wks_utility.convertToQ(tof_axis_full, - y_axis, - y_error_axis, - peak_range = dataPeakRange, - central_pixel = data_central_pixel, - source_to_detector_distance = dMD, - sample_to_detector_distance = dSD, - theta = theta, - first_slit_size = first_slit_size, - last_slit_size = last_slit_size) - - else: # convert to Q without correction - - [q_axis, y_axis, y_error_axis] = wks_utility.convertToQWithoutCorrection(tof_axis_full, - y_axis, - y_error_axis, - peak_range = dataPeakRange, - source_to_detector_distance = dMD, - sample_to_detector_distance = dSD, - theta = theta, - first_slit_size = first_slit_size, - last_slit_size = last_slit_size) - - -# wks_utility.ouput_big_Q_ascii_file('/mnt/hgfs/j35/Matlab/DebugMantid/Strange0ValuesToData/after_conversion_to_q.txt', -# q_axis, -# y_axis, -# y_error_axis) - - # create workspace - q_workspace = wks_utility.createQworkspace(q_axis, y_axis, y_error_axis) - - q_rebin = Rebin(InputWorkspace=q_workspace, - Params=q_range, - PreserveEvents=True) - - # keep only the q values that have non zero counts - nonzero_q_rebin_wks = wks_utility.cropAxisToOnlyNonzeroElements(q_rebin, - dataPeakRange) - # integrate spectra (normal mean) and remove first and last Q value - [final_x_axis, final_y_axis, final_error_axis] = wks_utility.integrateOverPeakRange(nonzero_q_rebin_wks, dataPeakRange) - - # cleanup data - [final_y_axis, final_y_error_axis] = wks_utility.cleanupData1D(final_y_axis, - final_error_axis) - - # create final workspace - import time - _time = int(time.time()) - name_output_ws = self.getPropertyValue("OutputWorkspace") - name_output_ws = name_output_ws + '_#' + str(_time) + 'ts' - wks_utility.createFinalWorkspace(final_x_axis, - final_y_axis, - final_y_error_axis, - name_output_ws, - ws_event_data) - AddSampleLog(Workspace=name_output_ws, - LogName='isSFfound', - LOgText=str(isSFfound)) - - self.setProperty('OutputWorkspace', mtd[name_output_ws]) - - -AlgorithmFactory.subscribe(RefLReduction) diff --git a/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py b/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py index ce93bb8f87e1ebc8395b44ef0da2ba04efc9d875..b666bdb7bd7400d209d5eab91ef914e856051df2 100644 --- a/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py +++ b/Framework/PythonInterface/plugins/algorithms/RefinePowderDiffProfileSeq.py @@ -40,6 +40,9 @@ class RefinePowderDiffProfileSeq(PythonAlgorithm): """ return "Diffraction\\Fitting" + def seeAlso(self): + return [ "RefinePowderInstrumentParameters" ] + def name(self): """ Algorithm name """ diff --git a/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py b/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py index 112e1b8d5e58449cce33f746c18a4c84f8209d7b..20bb725b0ae8811e04e4ac775df8ac12e6025ddb 100644 --- a/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py +++ b/Framework/PythonInterface/plugins/algorithms/RetrieveRunInfo.py @@ -191,6 +191,9 @@ class RetrieveRunInfo(PythonAlgorithm): return "Given a range of run numbers and an output workspace name, will compile a table of info for "+\ "each run of the instrument you have set as default." + def seeAlso(self): + return [ "CreateLogPropertyTable" ] + def PyInit(self): # Declare algorithm properties. self.declareProperty( diff --git a/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py b/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py index 12684213282bf75396df9f9e05e2731c63043280..325358d88c4fd9b1601bc378b1b18c46d27b223a 100644 --- a/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py +++ b/Framework/PythonInterface/plugins/algorithms/SANSSubtract.py @@ -17,6 +17,9 @@ class SANSSubtract(PythonAlgorithm): """ return "SANS" + def seeAlso(self): + return [ "SANSStitch","SANSFitShiftScale" ] + def name(self): """ Return name diff --git a/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py b/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py index a2b6d8291abdc9f05912da9a06ba9cc3eb698e93..ba71273be7b3923f10951c05e6fe1d7545ce07dc 100644 --- a/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/SNSPowderReduction.py @@ -138,6 +138,9 @@ class SNSPowderReduction(DistributedDataProcessorAlgorithm): def category(self): return "Diffraction\\Reduction" + def seeAlso(self): + return [ "DiffractionFocussing","AlignAndFocusPowder" ] + def name(self): return "SNSPowderReduction" diff --git a/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py b/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py index 9d5498c19852cba40952f6e4c5852e788ce98e84..72c096474a36380fc7fac8b3d788d7dd79b2d086 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveNexusPD.py @@ -27,6 +27,9 @@ class SaveNexusPD(mantid.api.PythonAlgorithm): def category(self): return "DataHandling\\Nexus" + def seeAlso(self): + return [ "SaveNexus" ] + def name(self): return "SaveNexusPD" diff --git a/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py b/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py index 6e4a62e6e0c60ec27fb9283e22c3ac24d39b22aa..4cca8b79ae2f6f1249022ffba01b3b0d016123d2 100644 --- a/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py +++ b/Framework/PythonInterface/plugins/algorithms/SavePlot1DAsJson.py @@ -15,6 +15,9 @@ class SavePlot1DAsJson(PythonAlgorithm): """ return "DataHandling\\Plots" + def seeAlso(self): + return [ "SavePlot1D","StringToPng" ] + def name(self): """ """ diff --git a/Framework/PythonInterface/plugins/algorithms/SaveReflections.py b/Framework/PythonInterface/plugins/algorithms/SaveReflections.py index 894549a9f1257577f7741d2aadd00313f310060f..ef5b38c0c31aa45106133041a7d97b830d984033 100644 --- a/Framework/PythonInterface/plugins/algorithms/SaveReflections.py +++ b/Framework/PythonInterface/plugins/algorithms/SaveReflections.py @@ -5,7 +5,7 @@ from mantid.simpleapi import SaveHKL # List of file format names supported by this algorithm SUPPORTED_FORMATS = ["Fullprof", "GSAS", "Jana", "SHELX"] -NUM_PEAKSWS_COLUMNS = 17 +NUM_PEAKSWS_COLUMNS = 18 def has_modulated_indexing(workspace): diff --git a/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py b/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py index 3b13cc9d5a56599fa1b82ab8dfb34822f228c54b..fbd980e03f80be57024b8a76d018fd246f655ceb 100644 --- a/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py +++ b/Framework/PythonInterface/plugins/algorithms/SortByQVectors.py @@ -15,6 +15,9 @@ class SortByQVectors(PythonAlgorithm): def category(self): return "Transforms\\Merging;Utility\\Sorting" + def seeAlso(self): + return [ "SortDetectors" ] + def name(self): return "SortByQVectors" diff --git a/Framework/PythonInterface/plugins/algorithms/SortDetectors.py b/Framework/PythonInterface/plugins/algorithms/SortDetectors.py index 1a48cb09a4c670cfdf47dca17118d4136a43518c..7951bead58b5b62fd4668a8042af3188ebad0469 100644 --- a/Framework/PythonInterface/plugins/algorithms/SortDetectors.py +++ b/Framework/PythonInterface/plugins/algorithms/SortDetectors.py @@ -16,6 +16,9 @@ class SortDetectors(PythonAlgorithm): """ return "Utility\\Sorting" + def seeAlso(self): + return [ "SortByQVectors","SortXAxis" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/SortXAxis.py b/Framework/PythonInterface/plugins/algorithms/SortXAxis.py index ee803cb59e1246ccd5785d922c4efe1626ebf173..41c8dd04224f554cc2d14ed84e24dd741edff6a2 100644 --- a/Framework/PythonInterface/plugins/algorithms/SortXAxis.py +++ b/Framework/PythonInterface/plugins/algorithms/SortXAxis.py @@ -1,8 +1,8 @@ #pylint: disable=no-init,invalid-name from __future__ import (absolute_import, division, print_function) -from mantid.api import * -from mantid.kernel import * +from mantid.api import AlgorithmFactory, MatrixWorkspaceProperty, PythonAlgorithm +from mantid.kernel import Direction, StringListValidator import numpy as np @@ -11,6 +11,9 @@ class SortXAxis(PythonAlgorithm): def category(self): return "Transforms\\Axes;Utility\\Sorting" + def seeAlso(self): + return [ "SortDetectors" ] + def name(self): return "SortXAxis" @@ -22,6 +25,11 @@ class SortXAxis(PythonAlgorithm): doc="Input workspace") self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", defaultValue="", direction=Direction.Output), doc="Sorted Output Workspace") + self.declareProperty("Ordering", + defaultValue="Ascending", + validator=StringListValidator(["Ascending", "Descending"]), + direction=Direction.Input, + doc="Ascending or descending sorting") def PyExec(self): input_ws = self.getProperty('InputWorkspace').value @@ -40,9 +48,14 @@ class SortXAxis(PythonAlgorithm): y_data = input_ws.readY(i) e_data = input_ws.readE(i) - indexes = x_data.argsort() + indexes = x_data.argsort() + + if self.getPropertyValue("Ordering") == "Descending": + self.log().information("Sort descending") + indexes = indexes[::-1] x_ordered = x_data[indexes] + if input_ws.isHistogramData(): max_index = np.argmax(indexes) indexes = np.delete(indexes, max_index) @@ -54,7 +67,12 @@ class SortXAxis(PythonAlgorithm): output_ws.setY(i, y_ordered) output_ws.setE(i, e_ordered) + if input_ws.hasDx(i): + dx = input_ws.readDx(i) + dx_ordered = dx[indexes] + output_ws.setDx(i, dx_ordered) + self.setProperty('OutputWorkspace', output_ws) -AlgorithmFactory.subscribe(SortXAxis()) +AlgorithmFactory.subscribe(SortXAxis) diff --git a/Framework/PythonInterface/plugins/algorithms/StringToPng.py b/Framework/PythonInterface/plugins/algorithms/StringToPng.py index 184ea6cab966f63590d37ebd0daa9571046189d0..0349445489ab5545005e46ee13e6edfb61147898 100644 --- a/Framework/PythonInterface/plugins/algorithms/StringToPng.py +++ b/Framework/PythonInterface/plugins/algorithms/StringToPng.py @@ -11,6 +11,9 @@ class StringToPng(mantid.api.PythonAlgorithm): """ return "DataHandling\\Plots" + def seeAlso(self): + return [ "SavePlot1D" ] + def name(self): """ Algorithm name """ diff --git a/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py b/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py index 51a7993a62ac2b6e96a49ab261bda90aa5deb8ab..538ee9d1433d8ffbb5f61969cccc1b188d3fe6ec 100644 --- a/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py +++ b/Framework/PythonInterface/plugins/algorithms/SuggestTibCNCS.py @@ -34,6 +34,9 @@ class SuggestTibCNCS(PythonAlgorithm): """ return "Inelastic\\Utility" + def seeAlso(self): + return [ "SuggestTibHYSPEC" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py b/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py index e4f653aa559436880c421886bbc7babbbea07e18..b2354db61311346be11d73d167b1c96aa06d5545 100644 --- a/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py +++ b/Framework/PythonInterface/plugins/algorithms/SuggestTibHYSPEC.py @@ -15,6 +15,9 @@ class SuggestTibHYSPEC(PythonAlgorithm): """ return "Inelastic\\Utility" + def seeAlso(self): + return [ "SuggestTibCNCS" ] + def name(self): """ Return name """ diff --git a/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py b/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py index 8c14b944c38ba689f8df1ca52d3f55c40c62cda3..64706916799f9e7d5a55b839a7fe131cd82a5cb2 100644 --- a/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py +++ b/Framework/PythonInterface/plugins/algorithms/TOFTOFCropWorkspace.py @@ -17,6 +17,9 @@ class TOFTOFCropWorkspace(PythonAlgorithm): """ return "Workflow\\MLZ\\TOFTOF;Transforms\\Splitting" + def seeAlso(self): + return [ "TOFTOFMergeRuns","CorrectTOF" ] + def name(self): """ Return summary """ diff --git a/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py b/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py index 56f24da68deb9a40b53b940bb08db0a98ff77a47..69c9e7dd8f50f9bbf749ffdcfd9be9c58c40eb59 100644 --- a/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py +++ b/Framework/PythonInterface/plugins/algorithms/TOFTOFMergeRuns.py @@ -27,6 +27,9 @@ class TOFTOFMergeRuns(PythonAlgorithm): """ return "Workflow\\MLZ\\TOFTOF;Transforms\\Splitting" + def seeAlso(self): + return [ "TOFTOFCropWorkspace","CorrectTOF" ] + def name(self): """ Return summary """ diff --git a/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py b/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py index b86164900b2c4e4ba2e45e24faa628887a44db58..e573c87116c61147467fdba24ca0e45cb61aa56d 100644 --- a/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py +++ b/Framework/PythonInterface/plugins/algorithms/USANSSimulation.py @@ -13,6 +13,9 @@ class USANSSimulation(PythonAlgorithm): def category(self): return "SANS" + def seeAlso(self): + return [ "USANSReduction" ] + def name(self): return "USANSSimulation" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py index d523aabcc4c379cef205751e5e1c556cda5f5018..b76c01067cb45042f94f1318a16df98d0e2af3db 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/AddSampleLogMultiple.py @@ -14,6 +14,9 @@ class AddSampleLogMultiple(PythonAlgorithm): def summary(self): return 'Add multiple sample logs to a workspace' + def seeAlso(self): + return ["AddSampleLog"] + def PyInit(self): self.declareProperty(WorkspaceProperty('Workspace', '', direction=Direction.InOut), doc='Workspace to add logs to') diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py index 00bb6453ebd3e5a73081e4bfc005c05f316f1039..2d82b71a8c4f40ba611ded775af20833f12a5cbb 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/CalculateMonteCarloAbsorption.py @@ -51,6 +51,9 @@ class CalculateMonteCarloAbsorption(DataProcessorAlgorithm): def category(self): return "Workflow\\Inelastic;CorrectionFunctions\\AbsorptionCorrections;Workflow\\MIDAS" + def seeAlso(self): + return [ "MonteCarloAbsorption","SimpleShapeMonteCarloAbsorption" ] + def summary(self): return "Calculates indirect absorption corrections for a given sample shape, using a MonteCarlo simulation." diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py index 16123503e88339c030506866320d3c042da87871..bb5a9eb1aae7007c647e90e83022c711caab0fd8 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ConvertMultipleRunsToSingleCrystalMD.py @@ -17,6 +17,9 @@ class ConvertMultipleRunsToSingleCrystalMD(DataProcessorAlgorithm): def category(self): return "MDAlgorithms\\Creation" + def seeAlso(self): + return [ "ConvertToDiffractionMDWorkspace","ConvertToMD" ] + def name(self): return "ConvertMultipleRunsToSingleCrystalMD" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py index 19fcf7cb2a8532acf807391a63fc395d1d49d058..bc330f9f2e2934a3c54eb8b6eacab91433845671 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLApplySelfShielding.py @@ -42,6 +42,9 @@ class DirectILLApplySelfShielding(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLReduction" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLApplySelfShielding' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py index afc256c831523210d099510a934a137e11623ba5..0bf3c901ec56af6732343898192026f66dec44ef 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLCollectData.py @@ -247,6 +247,9 @@ class DirectILLCollectData(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLReduction" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLCollectData' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py index bb2a888e8497d667b89560a79e02b7cd9b035513..15482c1bd95f5a552ba24b097df61bebdfe265b7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLDiagnostics.py @@ -309,6 +309,9 @@ class DirectILLDiagnostics(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLReduction" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLDiagnostics' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py index 0d719a89e78c75e37331c10c3f79a25aee067d17..a19138f37f62f3d555d5a90ec27c6b396fc00411 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLIntegrateVanadium.py @@ -22,6 +22,9 @@ class DirectILLIntegrateVanadium(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLReduction" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLIntegrateVanadium' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py index 3d4b7bee8fb559a0726f4569fd8310ef0b1a5b30..55bd25376e74a55ba6657e29e632f7ec7f3fd964 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLReduction.py @@ -169,6 +169,10 @@ class DirectILLReduction(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLApplySelfShielding","DirectILLCollectData", + "DirectILLDiagnostics","DirectILLIntegrateVanadium","DirectILLSelfShielding" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLReduction' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py index 5c1391a418ed55800d7d0b54b5dbc8b70ade9a9f..2609db7937b56b507f20e8690ff070b6279f710f 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/DirectILLSelfShielding.py @@ -21,6 +21,9 @@ class DirectILLSelfShielding(DataProcessorAlgorithm): """Return the algorithm's category.""" return common.CATEGORIES + def seeAlso(self): + return [ "DirectILLReduction" ] + def name(self): """Return the algorithm's name.""" return 'DirectILLSelfShielding' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py index a80ac5c10bc5b3a4ca56303a94210b6e5ba0141e..86d73568ee12c53b8eb443c00fee0bee0247f0ca 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ISISIndirectDiffractionReduction.py @@ -38,7 +38,10 @@ class ISISIndirectDiffractionReduction(DataProcessorAlgorithm): def summary(self): return 'Performs a diffraction reduction for a set of raw run files for an ISIS indirect spectrometer' - # ------------------------------------------------------------------------------ + def seeAlso(self): + return [ "AlignDetectors","DiffractionFocussing","SNSPowderReduction" ] + + # ------------------------------------------------------------------------------ def PyInit(self): self.declareProperty(StringArrayProperty(name='InputFiles'), diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py index 37f75eb8838867cb37ebabd3b0a894885536baf0..fd2a0953387817ec90a9a44a8f9d96a22356b519 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLEnergyTransfer.py @@ -53,6 +53,9 @@ class IndirectILLEnergyTransfer(PythonAlgorithm): def summary(self): return 'Performs initial energy transfer reduction for ILL indirect geometry data, instrument IN16B.' + def seeAlso(self): + return [ "IndirectILLReductionQENS","IndirectILLReductionFWS" ] + def name(self): return "IndirectILLEnergyTransfer" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py index 35dbafe567681ec70e6cea4fb8d227367cc68508..7ddec145b25dbc38a417e391dbf164c605063746 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionFWS.py @@ -39,6 +39,9 @@ class IndirectILLReductionFWS(PythonAlgorithm): return 'Performs fixed-window scan (FWS) multiple file reduction (both elastic and inelastic) ' \ 'for ILL indirect geometry data, instrument IN16B.' + def seeAlso(self): + return [ "IndirectILLReductionQENS","IndirectILLEnergyTransfer" ] + def name(self): return "IndirectILLReductionFWS" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py index c6120c518afb9635e3800e1c02540dc090790afd..85b1ab7b4ddb5498a991341eb50b0f4ad0b4fccd 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectILLReductionQENS.py @@ -36,6 +36,9 @@ class IndirectILLReductionQENS(PythonAlgorithm): return 'Performs quasi-elastic neutron scattering (QENS) multiple file reduction ' \ 'for ILL indirect geometry data, instrument IN16B.' + def seeAlso(self): + return [ "IndirectILLReductionFWS","IndirectILLEnergyTransfer" ] + def name(self): return "IndirectILLReductionQENS" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChanger.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChanger.py index aee47be349af9b5223b13881c71803f5bc438257..e7fbf7bd15271b38992b0ecad732e23e3f7b8513 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChanger.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/IndirectSampleChanger.py @@ -16,7 +16,7 @@ class IndirectSampleChanger(DataProcessorAlgorithm): _q1_workspaces = None def category(self): - return "Workflow\\MIDAS;PythonAlgorithms" + return "Workflow\\MIDAS" def summary(self): return "Create elastic window scans for sample changer" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py index 5a12480428170664ab101048da7e072fa0fedf3a..1d5cd7025e4ae2ab1437d05a621975a623d6d892 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/MDNormSCDPreprocessIncoherent.py @@ -19,6 +19,9 @@ class MDNormSCDPreprocessIncoherent(DataProcessorAlgorithm): def category(self): return "MDAlgorithms\\Normalisation" + def seeAlso(self): + return [ "MDNormSCD","MDNormDirectSC" ] + def name(self): return "MDNormSCDPreprocessIncoherent" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py index 3f49c6af191eb81326d8c3a2d494997dc4ad7db7..dd4614d029fa8574c7d777dc07432526afcf47f1 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/OSIRISDiffractionReduction.py @@ -480,6 +480,9 @@ class OSIRISDiffractionReduction(PythonAlgorithm): def category(self): return 'Diffraction\\Reduction' + def seeAlso(self): + return [ "ISISIndirectDiffractionReduction" ] + def summary(self): return "This Python algorithm performs the operations necessary for the reduction of diffraction data " + \ "from the Osiris instrument at ISIS " + \ diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetEffCorr.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetEffCorr.py index 6164d2ca6a612c960f72ee793f8c79c1ab96f51b..e6b7451ddc1307fcb2e243cd60e5a2382c809971 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetEffCorr.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetEffCorr.py @@ -76,6 +76,9 @@ class PowderDiffILLDetEffCorr(PythonAlgorithm): return "Performs detector efficiency correction calculation for scanning " \ "monochromatic powder diffraction instruments D20 and D2B at ILL." + def seeAlso(self): + return [ "ApplyDetectorScanEffCorr","PowderDiffILLReduction" ] + def name(self): return "PowderDiffILLDetEffCorr" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetScanReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetScanReduction.py index 331159d6493b9e118dc6908fdbe573a4072fede4..88e50537d399b7223691c349e19f2f8407ef1a39 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetScanReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLDetScanReduction.py @@ -16,6 +16,9 @@ class PowderDiffILLDetScanReduction(DataProcessorAlgorithm): def summary(self): return 'Performs powder diffraction data reduction for D2B and D20 (when doing a detector scan).' + def seeAlso(self): + return [ "PowderDiffILLReduction" ] + def name(self): return "PowderDiffILLDetScanReduction" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLReduction.py index 699ec5e52f0c6cd2c164cb352d00083c32a5cd1b..4930d7631249e3a7c27147832869bb88562a8efd 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/PowderDiffILLReduction.py @@ -36,6 +36,9 @@ class PowderDiffILLReduction(PythonAlgorithm): def summary(self): return 'Performs powder diffraction data reduction for ILL instrument D20.' + def seeAlso(self): + return [ "PowderDiffILLDetScanReduction","PowderDiffILLDetEffCorr" ] + def name(self): return "PowderDiffILLReduction" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/REFLReprocess.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/REFLReprocess.py deleted file mode 100644 index 3c0a7cca5f14647453cd1df661dc500b55b66ad0..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/REFLReprocess.py +++ /dev/null @@ -1,229 +0,0 @@ -#pylint: disable=no-init,invalid-name -from __future__ import (absolute_import, division, print_function) - -from mantid.api import * -from mantid.kernel import * -from mantid.simpleapi import * -import os -import math -import sys - -#pylint: disable=too-few-public-methods - - -class REFLOptions(object): - def __init__(self): - from reduction_gui.reduction.reflectometer.refl_data_script import DataSets as REFLDataSets - from reduction_gui.reduction.reflectometer.refl_data_series import DataSeries - self._state = DataSeries(data_class=REFLDataSets) - - def get_state(self): - return self._state - - -class REFLReprocess(PythonAlgorithm): - """ - Normalise detector counts by accelerator current and beam spectrum. - """ - - def category(self): - return "Workflow\\REFL" - - def name(self): - return "REFLReprocess" - - def summary(self): - return "Re-reduce REFL data for an entire experiment using saved parameters" - - def PyInit(self): - self.declareProperty("IPTS", '0', "IPTS number to process") - self.declareProperty(FileProperty(name="OutputDirectory",defaultValue="",action=FileAction.OptionalDirectory)) - self.declareProperty("LoadProcessed", False, "If True, data will be loaded instead of being processed") - self.declareProperty("Filter", "ts.txt", "String that the reduced data file name must contain") - - def PyExec(self): - from reduction_gui.reduction.reflectometer.refl_reduction import REFLReductionScripter - ipts = self.getProperty("IPTS").value - try: - ipts_number = int(ipts) - ipts = "IPTS-%s" % ipts_number - except: - pass - - Logger("REFLReprocess").notice("Processing %s" % ipts) - - # Locate the IPTS directory - ipts_dir = "/SNS/REF_L/%s/shared" % ipts - if not os.path.isdir(ipts_dir): - ipts_dir = ipts - - # Determine the output directory - output_dir = self.getProperty("OutputDirectory").value - if len(output_dir)==0: - output_dir = ipts_dir - - load_only = self.getProperty("LoadProcessed").value - if load_only: - return self.load_processed(output_dir) - - # Reprocess the data - if os.path.isdir(ipts_dir): - for item in os.listdir(ipts_dir): - if item.endswith('.xml'): - try: - Logger("REFLReprocess").notice("Processing %s" % os.path.join(ipts_dir, item)) - - refl = REFLReductionScripter() - options = REFLOptions() - refl.attach(options) - refl.from_xml(os.path.join(ipts_dir, item)) - code = refl.to_script() - exec(code, globals(), locals()) - self.stitch_data(os.path.join(ipts_dir, item), output_dir, - q_min=options.get_state().data_sets[0].q_min, - q_step=options.get_state().data_sets[0].q_step) - except: - Logger("REFLReprocess").error(str(sys.exc_info()[1])) - else: - Logger("REFLReprocess").error("%s not a valid directory" % ipts_dir) - - def load_processed(self, output_dir): - filter_string = self.getProperty("Filter").value - if not os.path.isdir(output_dir): - Logger("REFLReprocess").error("%s not a valid directory" % output_dir) - return - - for item in os.listdir(output_dir): - if item.endswith('.txt') and \ - (len(filter_string)==0 or item.find(filter_string)>=0): - basename, _ = os.path.splitext(item) - Load(Filename=os.path.join(output_dir, item), OutputWorkspace=basename) - (_name,_ts) = basename.split('_#') - CloneWorkspace(InputWorkspace=basename, OutputWorkspace=_name) - - def stitch_data(self, input_file, output_dir, q_min, q_step): - from LargeScaleStructures.data_stitching import DataSet, Stitcher#, RangeSelector - # Identify the data sets to stitch and order them - workspace_list = [] - _list_name = [] - _list_ts = [] - ws_list = AnalysisDataService.getObjectNames() - for item in ws_list: - if item.endswith('ts'): - (_name,_ts) = item.split('_#') - _list_name.append(item) - _list_ts.append(_ts) - - _name_ts = sorted(zip(_list_ts, _list_name)) - _ts_sorted, workspace_list = list(zip(*_name_ts)) - - # Stitch the data - s = Stitcher() - - q_max = 0 - for item in workspace_list: - data = DataSet(item) - data.load(True, True) - dummy_x_min, x_max = data.get_range() - if x_max > q_max: - q_max = x_max - s.append(data) - - s.set_reference(0) - s.compute() - - # Apply the scaling factors - for data in s._data_sets: - Scale(InputWorkspace=str(data), OutputWorkspace=data._ws_scaled, - Operation="Multiply", Factor=data.get_scale()) - SaveAscii(InputWorkspace=str(data), Filename=os.path.join(output_dir, '%s.txt' % str(data))) - - output_file = input_file.replace('.xml', '_reprocessed.txt') - Logger("REFLReprocess").notice("Saving to %s" % output_file) - - output_ws = _average_y_of_same_x_(q_min, q_step, q_max) - SaveAscii(InputWorkspace=output_ws, Filename=output_file) - - -def weightedMean(data_array, error_array): - """ - Code taken out as-is from base_ref_reduction.py - """ - sz = len(data_array) - - # calculate the numerator of mean - dataNum = 0 - for i in range(sz): - if not data_array[i] == 0: - tmpFactor = float(data_array[i]) / float((pow(error_array[i],2))) - dataNum += tmpFactor - - # calculate denominator - dataDen = 0 - for i in range(sz): - if not error_array[i] == 0: - tmpFactor = 1./float((pow(error_array[i],2))) - dataDen += tmpFactor - - if dataDen == 0: - mean = 0 - mean_error = 0 - else: - mean = float(dataNum) / float(dataDen) - mean_error = math.sqrt(1/dataDen) - - return [mean, mean_error] - - -def _average_y_of_same_x_(q_min, q_step, q_max=2): - """ - - Code taken out as-is from base_ref_reduction.py - - 2 y values sharing the same x-axis will be average using - the weighted mean - """ - - ws_list = AnalysisDataService.getObjectNames() - scaled_ws_list = [] - - # Get the list of scaled histos - for ws in ws_list: - if ws.endswith("_scaled"): - scaled_ws_list.append(ws) - - # get binning parameters - #_from_q = str(state.data_sets[0].q_min) - #_bin_size = str(state.data_sets[0].q_step) - #_bin_max = str(2) - #binning_parameters = _from_q + ',-' + _bin_size + ',' + _bin_max - binning_parameters = "%s,-%s,%s" % (q_min, q_step, q_max) - - # Convert each histo to histograms and rebin to final binning - for ws in scaled_ws_list: - new_name = "%s_histo" % ws - ConvertToHistogram(InputWorkspace=ws, OutputWorkspace=new_name) - Rebin(InputWorkspace=new_name, Params=binning_parameters, - OutputWorkspace=new_name) - - # Take the first rebinned histo as our output - data_y = mtd[scaled_ws_list[0]+'_histo'].dataY(0) - data_e = mtd[scaled_ws_list[0]+'_histo'].dataE(0) - - # Add in the other histos, averaging the overlaps - for i in range(1, len(scaled_ws_list)): - data_y_i = mtd[scaled_ws_list[i]+'_histo'].dataY(0) - data_e_i = mtd[scaled_ws_list[i]+'_histo'].dataE(0) - for j in range(len(data_y_i)): - if data_y[j]>0 and data_y_i[j]>0: - [data_y[j], data_e[j]] = weightedMean([data_y[j], data_y_i[j]], [data_e[j], data_e_i[j]]) - elif (data_y[j] == 0) and (data_y_i[j]>0): - data_y[j] = data_y_i[j] - data_e[j] = data_e_i[j] - - return scaled_ws_list[0]+'_histo' - -############################################################################################# - - -AlgorithmFactory.subscribe(REFLReprocess) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py index 8386bd6e2c803e131e73f635cec57a7400f9b548..c113cd2419a09fbbd73436a8f2420f5df1db48d2 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/ReactorSANSResolution.py @@ -14,6 +14,9 @@ class ReactorSANSResolution(PythonAlgorithm): def category(self): return "SANS" + def seeAlso(self): + return [ "EQSANSResolution" ] + def name(self): return "ReactorSANSResolution" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py index f1e7aac47404815bd7b5ce6e21500b406ec2d9cb..609eac3ad081ef23f629009f9b63e574280d7f57 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SavePlot1D.py @@ -24,6 +24,9 @@ class SavePlot1D(mantid.api.PythonAlgorithm): """ return "DataHandling\\Plots" + def seeAlso(self): + return [ "SavePlot1DAsJson","StringToPng" ] + def name(self): """ Algorithm name """ diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py index b5b4ff4bd1bab5d1614c78ff308232d461e72e97..cdf13d6bccecbbd9384f4770f1be2c7788f259aa 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SaveVulcanGSS.py @@ -20,6 +20,9 @@ class SaveVulcanGSS(PythonAlgorithm): """ return "Workflow\\Diffraction\\DataHandling" + def seeAlso(self): + return [ "SaveGSS" ] + def name(self): """ name of algorithm """ @@ -368,7 +371,7 @@ class SaveVulcanGSS(PythonAlgorithm): # property run_start and duration exist utctime = numpy.datetime64(run.getProperty('run_start').value) - time0 = numpy.datetime64("1990-01-01T0:0:0") + time0 = numpy.datetime64("1990-01-01T00:00:00") total_nanosecond_start = int((utctime - time0) / numpy.timedelta64(1, 'ns')) total_nanosecond_stop = total_nanosecond_start + int(duration*1.0E9) diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py index 2abf5198c05ebaaffd583e336188bd9ac85d5d28..d3d6ec5964e25cb2e90ab82273062a30f9c9ec5b 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SimpleShapeMonteCarloAbsorption.py @@ -39,6 +39,9 @@ class SimpleShapeMonteCarloAbsorption(DataProcessorAlgorithm): def category(self): return 'Workflow\\Inelastic;CorrectionFunctions\\AbsorptionCorrections;Workflow\\MIDAS' + def seeAlso(self): + return [ "CalculateMonteCarloAbsorption","MonteCarloAbsorption" ] + def summary(self): return 'Calculates absorption corrections for a given sample shape.' diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py index c40af07035c96746cbd7daa3a64dbaf6b2ba27b5..c4862b3d183b265324f17c622608d1baaca999c7 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/SingleCrystalDiffuseReduction.py @@ -25,6 +25,9 @@ class SingleCrystalDiffuseReduction(DataProcessorAlgorithm): def category(self): return "Diffraction\\Reduction" + def seeAlso(self): + return [ "ConvertToMD","MDNormSCD" ] + def name(self): return "SingleCrystalDiffuseReduction" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py index 441becd92311edba49574dc8e107268f0e207c70..9c29136b9a20f471fb3ece14c1c47ff9366971b3 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/TimeSlice.py @@ -60,6 +60,9 @@ class TimeSlice(PythonAlgorithm): def summary(self): return 'Performa an integration on a raw file over a specified time of flight range' + def seeAlso(self): + return [ "Integration" ] + def PyInit(self): self.declareProperty(StringArrayProperty(name='InputFiles'), doc='Comma separated list of input files') diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py index 2258416e97f528d1e4303155b021e7e0102b1d6d..8c1507ddbddcf34b9cc21b594194669abaf9932b 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/USANSReduction.py @@ -23,6 +23,9 @@ class USANSReduction(PythonAlgorithm): def category(self): return "SANS" + def seeAlso(self): + return [ "USANSSimulation" ] + def name(self): return "USANSReduction" diff --git a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py index 20bba523daf18b598dda3c7bc13f8d16112e519d..833f14602932d7c0b7b96caa168e4addc8e3e5f3 100644 --- a/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py +++ b/Framework/PythonInterface/plugins/algorithms/WorkflowAlgorithms/VesuvioDiffractionReduction.py @@ -25,6 +25,9 @@ class VesuvioDiffractionReduction(DataProcessorAlgorithm): def category(self): return 'Diffraction\\Reduction' + def seeAlso(self): + return [ "ISISIndirectDiffractionReduction" ] + def summary(self): return ('Performs diffraction reduction for VESUVIO. This algorithm is deprecated (April-2017).') diff --git a/Framework/PythonInterface/plugins/algorithms/sfCalculator.py b/Framework/PythonInterface/plugins/algorithms/sfCalculator.py deleted file mode 100644 index 35e94a2784ed4d08a4cf135e96c4f70304137efb..0000000000000000000000000000000000000000 --- a/Framework/PythonInterface/plugins/algorithms/sfCalculator.py +++ /dev/null @@ -1,1441 +0,0 @@ -#pylint: disable=invalid-name,too-many-arguments,too-many-lines,too-many-instance-attributes, too-many-locals,too-many-branches -from __future__ import (absolute_import, division, print_function) -from mantid.simpleapi import * -import numpy as np -import os.path - -PRECISION = 0.020 - - -class sfCalculator(object): - - ref_date = '2014-10-01' # when the detector has been rotated - - INDEX = 0 - - tof_min = None #microS - tof_max = None #microS - - #range of x pixel to use in the X integration (we found out that there - #is a frame effect that introduces noise) - x_pixel_min = 0 #default is 90 - x_pixel_max = 255 #default is 190 (must be below 256) - - #from,width,to in microS - #rebin_parameters = '0,50,200000' - rebin_parameters = '0,50,100000' - - #turn on or off the plots - bPlot = False - bFittingPlot = False - - #size of detector - alpha_pixel_nbr = 256 - beta_pixel_nbr = 304 #will be integrated over this dimension - - #name of numerators and denominators - numerator = None #ex: AiD0 - denominator = None #ex: AiD1 - - y_axis_numerator = None - y_axis_error_numerator = None - y_axis_denominator = None - y_axis_error_denominator = None - x_axis = None - - #define the peak region - n_peak_pixel_min = 130 - n_peak_pixel_max = 135 - d_peak_pixel_min = 130 - d_peak_pixel_max = 135 - - peak_pixel_min = None - peak_pixel_max = None - back_pixel_min = None - back_pixel_max = None - - #define the background range used in the background subtraction - n_back_pixel_min = 125 - n_back_pixel_max = 140 - d_back_pixel_min = 125 - d_back_pixel_max = 140 - - y_axis_ratio = None - y_axis_error_ratio = None - x_axis_ratio = None - - is_nexus_detector_rotated_flag = True - - a = None - b = None - error_a = None - error_b = None - - def __init__(self, numerator=None, denominator=None, - tof_range=None): - - print('---> initialize calculation') - - if tof_range is None: - self.tof_min = 10000 - self.tof_max = 21600 - else: - self.tof_min = tof_range[0] - self.tof_max = tof_range[1] - - self.numerator = numerator - self.denominator = denominator - - self.x_axis_ratio = None - self.y_axis_error_ratio = None - self.y_axis_ratio = None - - def setNumerator(self, minPeak, maxPeak, minBack, maxBack): - - print('---> set numerator (' + self.numerator + ')') - - if minPeak != 0: - self.n_peak_pixel_min = minPeak - if maxPeak != 0 : - self.n_peak_pixel_max = maxPeak - if minBack != 0: - self.n_back_pixel_min = minBack - if maxBack != 0: - self.n_back_pixel_max = maxBack - - def setDenominator(self, minPeak, maxPeak, minBack, maxBack): - - print('---> set denominator (' + self.denominator + ')') - - if minPeak != 0: - self.d_peak_pixel_min = minPeak - if maxPeak != 0: - self.d_peak_pixel_max = maxPeak - if minBack != 0: - self.d_back_pixel_min = minBack - if maxBack != 0: - self.d_back_pixel_max = maxBack - - def run(self): - """ - Perform the calculation - - """ - - #perform calculation for numerator - self._calculateFinalYAxis(bNumerator=True) - -# #DEBUGGING -# -# #output the data to fit to DEBUG -# x_axis = self.x_axis_ratio -# y_axis = self.y_axis_numerator -# y_error_axis = self.y_axis_error_numerator -# -# print 'create sfOutputTest#' -# filename = "/SNS/users/j35/sfOutputTest#%d.txt" % sfCalculator.INDEX -# # filename = "/home/j35/Desktop/sfOutputTest#%d.txt" % sfCalculator.INDEX -# print filename -# sfCalculator.INDEX += 1 -# -# f=open(filename,'w') -# -# for i in range(len(x_axis)): -# f.write(str(x_axis[i]) + "," + str(y_axis[i]) + "," + str(y_error_axis[i]) + "\n"); -# -# f.close - #END of DEBUGGING - - #perform calculation for denominator - self._calculateFinalYAxis(bNumerator=False) - -# #DEBUGGING -# -# #output the data to fit to DEBUG -# x_axis = self.x_axis_ratio -# y_axis = self.y_axis_denominator -# y_error_axis = self.y_axis_error_denominator -# -# print 'create sfOutputTest#' -# filename = "/SNS/users/j35/sfOutputTest#%d.txt" % sfCalculator.INDEX -# # filename = "/home/j35/Desktop/sfOutputTest#%d.txt" % sfCalculator.INDEX -# print filename -# sfCalculator.INDEX += 1 -# -# f=open(filename,'w') -# -# for i in range(len(x_axis)): -# f.write(str(x_axis[i]) + "," + str(y_axis[i]) + "," + str(y_error_axis[i]) + "\n"); -# -# f.close -# #END of DEBUGGING - - #calculate y_axis of numerator/denominator -# self._x_axis_ratio = self._x_axis - - ## code to replace this - #self.y_axis_ratio = self.y_axis_numerator / self.y_axis_denominator - - sz = np.size(self.y_axis_numerator) - new_y_axis_ratio = np.zeros(sz) - for i in range(sz): - - if self.y_axis_denominator[i] == 0: - self.y_axis_denominator[i] = 1 - -# print i -# print self.y_axis_numerator[i] -# print self.y_axis_denominator[i] -# print - - new_y_axis_ratio[i] = float(self.y_axis_numerator[i]) / float(self.y_axis_denominator[i]) - self.y_axis_ratio = new_y_axis_ratio - - ## code to replace this -# self.y_axis_error_ratio = ((self.y_axis_error_numerator / -# self.y_axis_numerator) ** 2 + -# (self.y_axis_error_denominator / -# self.y_axis_denominator) ** 2) -# self.y_axis_error_ratio = np.sqrt(self.y_axis_error_ratio) -# self.y_axis_error_ratio *= self.y_axis_ratio - new_y_axis_error_ratio = np.zeros(sz) - for i in range(sz): - - if self.y_axis_numerator[i] == 0: - self.y_axis_numerator[i] = 1 - - tmp_value = (float(self.y_axis_error_numerator[i]) / float(self.y_axis_numerator[i])) **2 + \ - (float(self.y_axis_error_denominator[i]) / float(self.y_axis_denominator[i])) **2 - tmp_value = np.sqrt(tmp_value) - new_y_axis_error_ratio[i] = self.y_axis_ratio[i]* tmp_value - self.y_axis_error_ratio = new_y_axis_error_ratio - - def isNexusTakeAfterRefDate(self, nexus_date): - ''' - This function parses the output.date and returns true if this date is after the ref date - ''' - nexus_date_acquisition = nexus_date.split('T')[0] - - if nexus_date_acquisition > self.ref_date: - return True - else: - return False - - def _calculateFinalYAxis(self, bNumerator=True): - """ - run full calculation for numerator or denominator - """ - if bNumerator is True: - filen = self.numerator -# _id = self.id_numerator - self.peak_pixel_min = self.n_peak_pixel_min - self.peak_pixel_max = self.n_peak_pixel_max - self.back_pixel_min = self.n_back_pixel_min - self.back_pixel_max = self.n_back_pixel_max - else: - filen = self.denominator -# _id = self.id_denominator - self.peak_pixel_min = self.d_peak_pixel_min - self.peak_pixel_max = self.d_peak_pixel_max - self.back_pixel_min = self.d_back_pixel_min - self.back_pixel_max = self.d_back_pixel_max - - nexus_file_numerator = filen - print('----> loading nexus file: ' + nexus_file_numerator) - EventDataWks = LoadEventNexus(Filename=nexus_file_numerator) - - self.is_nexus_detector_rotated_flag = self.isNexusTakeAfterRefDate(EventDataWks.getRun().getProperty('run_start').value) - - if self.is_nexus_detector_rotated_flag: - self.alpha_pixel_nbr = 304 - self.beta_pixel_nbr = 256 - else: - self.alpha_pixel_nbr = 256 - self.beta_pixel_nbr = 304 #will be integrated over this dimension - - proton_charge = self._getProtonCharge(EventDataWks) - print('----> rebinning ') - HistoDataWks = Rebin(InputWorkspace=EventDataWks, - Params=self.rebin_parameters) - -# mt2 = mtd['HistoDataWks'] -# x_axis = mt2.readX(0)[:] - - x_axis = HistoDataWks.readX(0)[:] - self.x_axis = x_axis - - OutputWorkspace = self._createIntegratedWorkspace(InputWorkspace=HistoDataWks, - proton_charge=proton_charge, - from_pixel=self.peak_pixel_min, - to_pixel=self.peak_pixel_max) - - DataWks = self._removeBackground(InputWorkspace=OutputWorkspace, - from_peak=self.peak_pixel_min, - to_peak=self.peak_pixel_max, - from_back=self.back_pixel_min, - to_back=self.back_pixel_max, - tof_min = self.tof_min, - tof_max = self.tof_max) - -# print '----> Convert to histogram' -# IntegratedDataWks = ConvertToHistogram(InputWorkspace=OutputWorkspace) -# -# print '----> Transpose' -# TransposeIntegratedDataWks = Transpose(InputWorkspace=IntegratedDataWks) -# -# print '----> convert to histogram' -# TransposeIntegratedDataWks_t = ConvertToHistogram(InputWorkspace=TransposeIntegratedDataWks) -# -# print '----> flat background1' -# TransposeHistoFlatDataWks_1 = FlatBackground(InputWorkspace=TransposeIntegratedDataWks_t, -# StartX=self.back_pixel_min, -# EndX=self.peak_pixel_min, -# Mode='Mean', -# OutputMode="Return Background") -# -# print '----> flat background2' -# TransposeHistoFlatDataWks_2 = FlatBackground(InputWorkspace=TransposeIntegratedDataWks_t, -# StartX=self.peak_pixel_max, -# EndX=self.back_pixel_max, -# Mode='Mean', -# OutputMode="Return Background") -# -# print '----> transpose flat background 1 -> data1' -# DataWks_1 = Transpose(InputWorkspace=TransposeHistoFlatDataWks_1); -# -# print '----> transpose flat background 2 -> data2' -# DataWks_2 = Transpose(InputWorkspace=TransposeHistoFlatDataWks_2); -# -# print '----> convert to histogram data2' -# DataWks_1 = ConvertToHistogram(InputWorkspace=DataWks_1); -# -# print '----> convert to histogram data1' -# DataWks_2 = ConvertToHistogram(InputWorkspace=DataWks_2) -# -# print '----> rebin workspace data1' -# DataWks_1 = RebinToWorkspace(WorkspaceToRebin=DataWks_1, -# WorkspacetoMatch=IntegratedDataWks) -# -# print '----> rebin workspace data2' -# DataWks_2 = RebinToWorkspace(WorkspaceToRebin=DataWks_2, -# WorkspacetoMatch=IntegratedDataWks) -# -# print '----> weighted mean' -# DataWksWeightedMean = WeightedMean(InputWorkspace1=DataWks_1, -# InputWorkspace2=DataWks_2) -# -# print '----> minus' -# DataWks = Minus(LHSWorkspace=IntegratedDataWks, -# RHSWorkspace=DataWksWeightedMean) - -# if not bNumerator: -# import sys -# sys.exit("now we are working with denominator") - - -# mt3 = mtd['DataWks'] - self._calculateFinalAxis(Workspace=DataWks, - bNumerator=bNumerator) - print('done with _calculateFinalAxis and back in calculatefinalaxis') #REMOVEME - - #cleanup workspaces - DeleteWorkspace(EventDataWks) - DeleteWorkspace(HistoDataWks) -# DeleteWorkspace(IntegratedDataWks) -# DeleteWorkspace(TransposeIntegratedDataWks) -# DeleteWorkspace(TransposeIntegratedDataWks_t) -# DeleteWorkspace(TransposeHistoFlatDataWks_1) -# DeleteWorkspace(TransposeHistoFlatDataWks_2) - DeleteWorkspace(DataWks) - - print('done with cleaning workspaces in line 247') - - def _calculateFinalAxis(self, Workspace=None, bNumerator=None): - """ - this calculates the final y_axis and y_axis_error of numerator - and denominator - """ - - print('----> calculate final axis') - mt = Workspace - x_axis = mt.readX(0)[:] - self.x_axis = x_axis - - counts_vs_tof = mt.readY(0)[:] - counts_vs_tof_error = mt.readE(0)[:] - -## this is not use anymore as the integration is done in the previous step -# counts_vs_tof = np.zeros(len(x_axis)-1) -# counts_vs_tof_error = np.zeros(len(x_axis)-1) -# -# for x in range(self.alpha_pixel_nbr): -# counts_vs_tof += mt.readY(x)[:] -# counts_vs_tof_error += mt.readE(x)[:] ** 2 -# counts_vs_tof_error = np.sqrt(counts_vs_tof_error) - -# -# #for DEBUGGING -# #output data into ascii file -# f=open('/home/j35/Desktop/myASCII.txt','w') -# if (not bNumerator): -# f.write(self.denominator + "\n") -# -# for i in range(len(counts_vs_tof)): -# f.write(str(x_axis[i]) + "," + str(counts_vs_tof[i]) + "\n") -# f.close -# import sys -# sys.exit("Stop in _calculateFinalAxis") -## end of for DEBUGGING #so far, so good ! - - index_tof_min = self._getIndex(self.tof_min, x_axis) - index_tof_max = self._getIndex(self.tof_max, x_axis) - - if bNumerator is True: - self.y_axis_numerator = counts_vs_tof[index_tof_min:index_tof_max].copy() - self.y_axis_error_numerator = counts_vs_tof_error[index_tof_min:index_tof_max].copy() - self.x_axis_ratio = self.x_axis[index_tof_min:index_tof_max].copy() - else: - self.y_axis_denominator = counts_vs_tof[index_tof_min:index_tof_max].copy() - self.y_axis_error_denominator = counts_vs_tof_error[index_tof_min:index_tof_max].copy() - self.x_axis_ratio = self.x_axis[index_tof_min:index_tof_max].copy() - - print('done with _calculateFinalAxis') - - def _createIntegratedWorkspace(self, - InputWorkspace=None, - OutputWorkspace=None, - proton_charge=None, - from_pixel=0, - to_pixel=255): - """ - This creates the integrated workspace over the second pixel range - (beta_pixel_nbr here) and - returns the new workspace handle - """ - - print('-----> Create Integrated workspace ') - x_axis = InputWorkspace.readX(0)[:] - x_size = to_pixel - from_pixel + 1 - y_axis = np.zeros((self.alpha_pixel_nbr, len(x_axis) - 1)) - y_error_axis = np.zeros((self.alpha_pixel_nbr, len(x_axis) - 1)) - y_range = np.arange(x_size) + from_pixel - -# for x in range(self.beta_pixel_nbr): -# for y in y_range: -# index = int(self.alpha_pixel_nbr * x + y) -## y_axis[y, :] += InputWorkspace.readY(index)[:] -# y_axis[y, :] += InputWorkspace.readY(index)[:] -# y_error_axis[y, :] += ((InputWorkspace.readE(index)[:]) * -# (InputWorkspace.readE(index)[:])) - - if self.is_nexus_detector_rotated_flag: - for x in range(256): - for y in y_range: - index = int(y+x*304) - # y_axis[y, :] += InputWorkspace.readY(index)[:] - y_axis[y, :] += InputWorkspace.readY(index)[:] - y_error_axis[y, :] += ((InputWorkspace.readE(index)[:]) * - (InputWorkspace.readE(index)[:])) - - else: - for x in range(304): - for y in y_range: - index = int(y+x*256) - # y_axis[y, :] += InputWorkspace.readY(index)[:] - y_axis[y, :] += InputWorkspace.readY(index)[:] - y_error_axis[y, :] += ((InputWorkspace.readE(index)[:]) * - (InputWorkspace.readE(index)[:])) - -# #DEBUG -# f=open('/home/j35/myASCIIfromCode.txt','w') -# new_y_axis = np.zeros((len(x_axis)-1)) -# -# for y in range(256): -# new_y_axis += y_axis[y,:] -# -# for i in range(len(x_axis)-1): -# f.write(str(x_axis[i]) + "," + str(new_y_axis[i]) + "\n"); -# f.close -# -# print sum(new_y_axis) -# -# #END OF DEBUG - ## so far, worsk perfectly (tested with portal vs Mantid vs Matlab - - y_axis = y_axis.flatten() - y_error_axis = np.sqrt(y_error_axis) - #plot_y_error_axis = _y_error_axis #for output testing only - #plt.imshow(plot_y_error_axis, aspect='auto', origin='lower') - y_error_axis = y_error_axis.flatten() - - #normalization by proton beam - y_axis /= (proton_charge * 1e-12) - y_error_axis /= (proton_charge * 1e-12) - - OutputWorkspace = CreateWorkspace(DataX=x_axis, - DataY=y_axis, - DataE=y_error_axis, - Nspec=self.alpha_pixel_nbr) - - return OutputWorkspace - - def weighted_mean(self, data, error): - - sz = len(data) - - #calculate numerator - dataNum = 0 - for i in range(sz): - if data[i] != 0: - tmpFactor = float(data[i]) / (error[i]**2) - dataNum += tmpFactor - - #calculate denominator - dataDen = 0 - for i in range(sz): - if error[i] != 0: - tmpFactor = float(1) / (error[i]**2) - dataDen += tmpFactor - - if dataDen == 0: - dataDen = 1 - - mean = dataNum / dataDen - mean_error = np.sqrt(dataDen) - - return (mean, mean_error) - - def removeValueFromArray(self, data, background): - # Will remove the background value from each of the data - # element (data is an array) - - sz = len(data) - new_data = np.zeros(sz) - for i in range(sz): - new_data[i] = data[i] - background - - return new_data - - def removeValueFromArrayError(self, data_error, background_error): - # will calculate the new array of error when removing - # a single value from an array - - sz = len(data_error) - new_data_error = np.zeros(sz) - for i in range(sz): - new_data_error[i] = np.sqrt(data_error[i]**2 + background_error**2) - - return new_data_error - - def sumWithError(self, peak, peak_error): - # add the array element using their weight and return new error as well - - sz = len(peak) - sum_peak = 0 - sum_peak_error = 0 - for i in range(sz): - sum_peak += peak[i] - sum_peak_error += peak_error[i]**2 - - sum_peak_error = np.sqrt(sum_peak_error) - return [sum_peak, sum_peak_error] - - #pylint: disable=unused-argument - def _removeBackground(self, - InputWorkspace=None, - from_peak= 0, - to_peak=256, - from_back=0, - to_back=256, - tof_min = 0, - tof_max = 200000): - - # retrieve various axis - tof_axis = InputWorkspace.readX(0)[:] - nbr_tof = len(tof_axis)-1 - - # make big array of data - if self.is_nexus_detector_rotated_flag: - data = np.zeros((304,nbr_tof)) - error = np.zeros((304,nbr_tof)) - for x in range(304): - data[x,:] = InputWorkspace.readY(x)[:] - error[x,:] = InputWorkspace.readE(x)[:] - - else: - data = np.zeros((256,nbr_tof)) - error = np.zeros((256,nbr_tof)) - for x in range(256): - data[x,:] = InputWorkspace.readY(x)[:] - error[x,:] = InputWorkspace.readE(x)[:] - - peak_array = np.zeros(nbr_tof) - peak_array_error = np.zeros(nbr_tof) - - bMinBack = False - bMaxBack = False - - min_back = 0 - min_back_error = 0 - max_back = 0 - max_back_error = 0 - - for t in range(nbr_tof-1): - - _y_slice = data[:,t] - _y_error_slice = error[:,t] - - _y_slice = _y_slice.flatten() - _y_error_slice = _y_error_slice.flatten() - - if from_back < (from_peak-1): - range_back_min = _y_slice[from_back : from_peak] - range_back_error_min = _y_error_slice[from_back : from_peak] - [min_back, min_back_error] = self.weighted_mean(range_back_min, range_back_error_min) - bMinBack = True - - if (to_peak+1) < to_back: - range_back_max = _y_slice[to_peak+1: to_back+1] - range_back_error_max = _y_error_slice[to_peak+1: to_back+1] - [max_back, max_back_error] = self.weighted_mean(range_back_max, range_back_error_max) - bMaxBack = True - - # if we have a min and max background - if bMinBack & bMaxBack: - [background, background_error] = self.weighted_mean([min_back,max_back],[min_back_error,max_back_error]) -# - # if we don't have a max background, we use min background - if not bMaxBack: - background = min_back - background_error = min_back_error -# - # if we don't have a min background, we use max background - if not bMinBack: - background = max_back - background_error = max_back_error - - tmp_peak = _y_slice[from_peak:to_peak+1] - tmp_peak_error = _y_error_slice[from_peak:to_peak+1] - - new_tmp_peak = self.removeValueFromArray(tmp_peak, background) - new_tmp_peak_error = self.removeValueFromArrayError(tmp_peak_error, background_error) - - [final_value, final_error] = self.sumWithError(new_tmp_peak, new_tmp_peak_error) - - peak_array[t] = final_value - peak_array_error[t] = final_error - - # make new workspace - y_axis = peak_array.flatten() - y_error_axis = peak_array_error.flatten() - - DataWks = CreateWorkspace(DataX=tof_axis[0:-1], - DataY=y_axis, - DataE=y_error_axis, - Nspec=1) - -# import sys -# sys.exit("in _removeBackground... so far, so good!") - - return DataWks - - def _getIndex(self, value, array): - """ - returns the index where the value has been found - """ - return array.searchsorted(value) - - def _getProtonCharge(self, st=None): - """ - Returns the proton charge of the given workspace in picoCoulomb - """ - if st is not None: - mt_run = st.getRun() - proton_charge_mtd_unit = mt_run.getProperty('gd_prtn_chrg').value - proton_charge = proton_charge_mtd_unit / 2.77777778e-10 - return proton_charge - return None - - def __mul__(self, other): - """ - operator * between two instances of the class - """ - - product = sfCalculator() - - product.numerator = self.numerator + '*' + other.numerator - product.denominator = self.denominator + '*' + other.denominator - - product.x_axis_ratio = self.x_axis_ratio - - ## replace code by - #product.y_axis_ratio = self.y_axis_ratio * other.y_axis_ratio - sz = len(self.y_axis_ratio) - new_y_axis_ratio = np.zeros(sz) - for i in range(sz): - new_y_axis_ratio[i] = self.y_axis_ratio[i] * other.y_axis_ratio[i] - product.y_axis_ratio = new_y_axis_ratio - - ## replace code by - #product.y_axis_error_ratio = product.y_axis_ratio * np.sqrt((other.y_axis_error_ratio / other.y_axis_ratio)**2 +\ - # (self.y_axis_error_ratio / self.y_axis_ratio)**2) - new_y_axis_error_ratio = np.zeros(sz) - for i in range(sz): - - # make sure we don't divide b 0 - if other.y_axis_ratio[i] == 0: - other.y_axis_ratio[i] = 1 - if self.y_axis_ratio[i] == 0: - self.y_axis_ratio[i] = 1 - - tmp_product = (other.y_axis_error_ratio[i] / other.y_axis_ratio[i]) ** 2 + \ - (self.y_axis_error_ratio[i] / self.y_axis_ratio[i]) ** 2 - tmp_product = np.sqrt(tmp_product) - new_y_axis_error_ratio[i] = tmp_product * product.y_axis_ratio[i] - product.y_axis_error_ratio = new_y_axis_error_ratio - - return product - - def fit(self): - """ - This is going to fit the counts_vs_tof with a linear expression and return the a and - b coefficients (y=a+bx) - """ - - DataToFit = CreateWorkspace(DataX=self.x_axis_ratio, - DataY=self.y_axis_ratio, - DataE=self.y_axis_error_ratio, - Nspec=1) - - print('replaceSpecialValues') - DataToFit = ReplaceSpecialValues(InputWorkspace=DataToFit, - NaNValue=0, - NaNError=0, - InfinityValue=0, - InfinityError=0) - -# ResetNegatives(InputWorkspace='DataToFit', -# OutputWorkspace='DataToFit', -# AddMinimum=0) - -# #DEBUG -# #output the data to fit to DEBUG -# x_axis = DataToFit.readX(0)[:] -# y_axis = DataToFit.readY(0)[:] -# y_error_axis = DataToFit.readE(0)[:] -# -# print 'create sfOutputTest#' -# filename = "/home/j35/sfOutputTest#%d.txt" % sfCalculator.INDEX -# print filename -# sfCalculator.INDEX += 1 -# -# f=open(filename,'w') -# -# for i in range(len(x_axis)): -# f.write(str(x_axis[i]) + "," + str(y_axis[i]) + "," + str(y_error_axis[i]) + "\n"); -# -# f.close -# #END OF DEBUG - - try: - - Fit(InputWorkspace=DataToFit, - Function="name=UserFunction, Formula=a+b*x, a=1, b=2", - Output='res') - - except: - - xaxis = self.x_axis_ratio - sz = len(xaxis) - xmin = xaxis[0] - xmax = xaxis[sz/2] - - DataToFit = CropWorkspace(InputWorkspace=DataToFit, - XMin=xmin, - XMax=xmax) - - Fit(InputWorkspace=DataToFit, - Function='name=UserFunction, Formula=a+b*x, a=1, b=2', - Output='res') - - res = mtd['res_Parameters'] - - self.a = res.cell(0,1) - self.b = res.cell(1,1) - self.error_a = res.cell(0,2) - self.error_b = res.cell(1,2) - -# self.a = res.getDouble("Value", 0) -# self.b = res.getDouble("Value", 1) -# self.error_a = res.getDouble("Error", 0) -# self.error_b = res.getDouble("Error", 1) - - -def plotObject(instance): - -# return - -# print 'a: ' + str(instance.a[-1]) -# print 'b: ' + str(instance.b[-1]) - - figure() - errorbar(instance.x_axis_ratio, - instance.y_axis_ratio, - instance.y_axis_error_ratio, - marker='s', - mfc='red', - linestyle='', - label='Exp. data') - - if instance.a is not None: - x = linspace(10000, 22000, 100) - _label = "%.3f + x*%.2e" % (instance.a, instance.b) - plot(x, instance.a + instance.b * x, label=_label) - - xlabel("TOF (microsS)") - ylabel("Ratio") - - title(instance.numerator + '/' + instance.denominator) - show() - legend() - - -def recordSettings(a, b, error_a, error_b, name, instance): - """ - This function will record the various fitting parameters and the - name of the ratio - """ - print('--> recoding settings') - a.append(instance.a) - b.append(instance.b) - error_a.append(instance.error_a) - error_b.append(instance.error_b) - name.append(instance.numerator + '/' + instance.denominator) - - -def variable_value_splitter(variable_value): - """ - This function split the variable that looks like "LambdaRequested:3.75" - and returns a dictionnary of the variable name and value - """ - - _split = variable_value.split('=') - variable = _split[0] - value = _split[1] - return {'variable':variable, 'value':value} - - -def isWithinRange(value1, value2): - """ - This function checks if the two values and return true if their - difference is <= PRECISION - """ - diff = abs(float(value1)) - abs(float(value2)) - if abs(diff) <= PRECISION: - return True - else: - return False - - -def outputFittingParameters(a, b, error_a, error_b, - lambda_requested, - incident_medium, - S1H, S2H, - S1W, S2W, - output_file_name): - """ - Create an ascii file of the various fittings parameters - y=a+bx - 1st column: incident medium - 2nd column: lambda requested - 3rd column: S1H value - 4th column: S2H value - 5th column: S1W value - 6th column: S2W value - 7th column: a - 7th column: b - 8th column: error_a - 9th column: error_b - """ - - print('--> output fitting parameters') - - bFileExist = False - #First we need to check if the file already exist - if os.path.isfile(output_file_name): - bFileExist = True - - #then if it does, parse the file and check if following infos are - #already defined: - # lambda_requested, S1H, S2H, S1W, S2W - if bFileExist: - f = open(output_file_name, 'r') - text = f.readlines() -# split_lines = text.split('\n') - split_lines = text - - entry_list_to_add = [] - - try: - - sz = len(a) - for i in range(sz): - - _match = False - - for _line in split_lines: - if _line[0] == '#': - continue - - _line_split = _line.split(' ') - _incident_medium = variable_value_splitter(_line_split[0]) - - if _incident_medium['value'].strip() == incident_medium.strip(): - _lambdaRequested = variable_value_splitter(_line_split[1]) - if isWithinRange(_lambdaRequested['value'], lambda_requested): - _s1h = variable_value_splitter(_line_split[2]) - if isWithinRange(_s1h['value'], S1H[i]): - _s2h = variable_value_splitter(_line_split[3]) - if isWithinRange(_s2h['value'],S2H[i]): - _s1w = variable_value_splitter(_line_split[4]) - if isWithinRange(_s1w['value'],S1W[i]): - _s2w = variable_value_splitter(_line_split[5]) - if isWithinRange(_s2w['value'],S2W[i]): - _match = True - break - - if not _match: - entry_list_to_add.append(i) - - except: - #replace file because this one has the wrong format - _content = ['#y=a+bx\n', '#\n', - '#lambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b\n', '#\n'] - sz = len(a) - for i in range(sz): - - _line = 'IncidentMedium=' + incident_medium.strip() + ' ' - _line += 'LambdaRequested=' + str(lambda_requested) + ' ' - - _S1H = "{0:.2f}".format(abs(S1H[i])) - _S2H = "{0:.2f}".format(abs(S2H[i])) - _S1W = "{0:.2f}".format(abs(S1W[i])) - _S2W = "{0:.2f}".format(abs(S2W[i])) - _a = "{0:}".format(a[i]) - _b = "{0:}".format(b[i]) - _error_a = "{0:}".format(float(error_a[i])) - _error_b = "{0:}".format(float(error_b[i])) - - _line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' ' - _line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' ' - _line += 'a=' + _a + ' ' - _line += 'b=' + _b + ' ' - _line += 'error_a=' + _error_a + ' ' - _line += 'error_b=' + _error_b + '\n' - _content.append(_line) - - f = open(output_file_name, 'w') - f.writelines(_content) - f.close() - return - - _content = [] - for j in entry_list_to_add: - - _line = 'IncidentMedium=' + incident_medium + ' ' - _line += 'LambdaRequested=' + str(lambda_requested) + ' ' - - _S1H = "{0:.2f}".format(abs(S1H[j])) - _S2H = "{0:.2f}".format(abs(S2H[j])) - _S1W = "{0:.2f}".format(abs(S1W[j])) - _S2W = "{0:.2f}".format(abs(S2W[j])) - _a = "{0:}".format(a[j]) - _b = "{0:}".format(b[j]) - _error_a = "{0:}".format(float(error_a[j])) - _error_b = "{0:}".format(float(error_b[j])) - - _line += 'S1H=' + _S1H + ' ' + 'S2iH=' + _S2H + ' ' - _line += 'S1W=' + _S1W + ' ' + 'S2iW=' + _S2W + ' ' - _line += 'a=' + _a + ' ' - _line += 'b=' + _b + ' ' - _line += 'error_a=' + _error_a + ' ' - _line += 'error_b=' + _error_b + '\n' - _content.append(_line) - - f = open(output_file_name, 'a') - f.writelines(_content) - f.close() - - else: - - _content = ['#y=a+bx\n', '#\n', - '#lambdaRequested[Angstroms] S1H[mm] (S2/Si)H[mm] S1W[mm] (S2/Si)W[mm] a b error_a error_b\n', '#\n'] - sz = len(a) - for i in range(sz): - - _line = 'IncidentMedium=' + incident_medium.strip() + ' ' - _line += 'LambdaRequested=' + str(lambda_requested) + ' ' - - _S1H = "{0:.2f}".format(abs(S1H[i])) - _S2H = "{0:.2f}".format(abs(S2H[i])) - _S1W = "{0:.2f}".format(abs(S1W[i])) - _S2W = "{0:.2f}".format(abs(S2W[i])) - _a = "{0:}".format(a[i]) - _b = "{0:}".format(b[i]) - _error_a = "{0:}".format(float(error_a[i])) - _error_b = "{0:}".format(float(error_b[i])) - - _line += 'S1H=' + _S1H + ' ' + 'S2iH=' + _S2H + ' ' - _line += 'S1W=' + _S1W + ' ' + 'S2iW=' + _S2W + ' ' - _line += 'a=' + _a + ' ' - _line += 'b=' + _b + ' ' - _line += 'error_a=' + _error_a + ' ' - _line += 'error_b=' + _error_b + '\n' - _content.append(_line) - - f = open(output_file_name, 'w') - f.writelines(_content) - f.close() - - -def createIndividualList(string_list_files): - """ - Using the list_files, will produce a dictionary of the run - number and number of attenuator - ex: - list_files = "1000:0, 1001:1, 1002:1, 1003:2" - return {1000:0, 1001:1, 1002:2, 1003:2} - """ - if string_list_files == '': - return None - first_split = string_list_files.split(',') - - list_runs = [] - list_attenuator= [] - - _nbr_files = len(first_split) - for i in range(_nbr_files): - _second_split = first_split[i].split(':') - list_runs.append(_second_split[0].strip()) - list_attenuator.append(int(_second_split[1].strip())) - - return {'list_runs':list_runs, - 'list_attenuator':list_attenuator} - - -def getLambdaValue(mt): - """ - return the lambdaRequest value - """ - mt_run = mt.getRun() - _lambda = mt_run.getProperty('LambdaRequest').value - return _lambda - - -def getSh(mt, top_tag, bottom_tag): - """ - returns the height and units of the given slits - """ - mt_run = mt.getRun() - st = mt_run.getProperty(top_tag).value - sb = mt_run.getProperty(bottom_tag).value - sh = float(sb[0]) - float(st[0]) - units = mt_run.getProperty(top_tag).units - return sh, units - - -def getSheight(mt, index): - """ - return the DAS hardware slits height of slits # index - """ - mt_run = mt.getRun() - if index == '2': - try: - tag = 'SiVHeight' - value = mt_run.getProperty(tag).value - except: - tag = 'S2VHeight' - value = mt_run.getProperty(tag).value - else: - tag = 'S1VHeight' - value = mt_run.getProperty(tag).value - - return value[0] - - -def getS1h(mt=None): - """ - returns the height and units of the slit #1 - """ - if mt is not None: -# _h, units = getSh(mt, 's1t', 's1b') - _h = getSheight(mt, '1') - return _h - return None - - -def getS2h(mt=None): - """ - returns the height and units of the slit #2 - """ - if mt is not None: -# _h, units = getSh(mt, 's2t', 's2b') - _h = getSheight(mt, '2') - return _h - return None - - -def getSwidth(mt, index): - """ - returns the width and units of the given index slits - defined by the DAS hardware - """ - mt_run = mt.getRun() - if index == '2': - try: - tag = 'SiHWidth' - value = mt_run.getProperty(tag).value - except: - tag = 'S2HWidth' - value = mt_run.getProperty(tag).value - else: - tag = 'S1HWidth' - value = mt_run.getProperty(tag).value - return value[0] - - -def getSw(mt, left_tag, right_tag): - """ - returns the width and units of the given slits - """ - mt_run = mt.getRun() - sl = mt_run.getProperty(left_tag).value - sr = mt_run.getProperty(right_tag).value - sw = float(sl[0]) - float(sr[0]) - units = mt_run.getProperty(left_tag).units - return sw, units - - -def getS1w(mt=None): - """ - returns the width and units of the slit #1 - """ - if mt is not None: -# _w, units = getSw(mt, 's1l', 's1r') - _w = getSwidth(mt, '1') - return _w - return None - - -def getS2w(mt=None): - """ - returns the width and units of the slit #2 - """ - if mt is not None: -# _w, units = getSh(mt, 's2l', 's2r') - _w = getSwidth(mt, '2') - return _w - return None - - -def getSlitsValueAndLambda(full_list_runs, - S1H, S2H, - S1W, S2W, lambdaRequest): - """ - Retrieve the S1H (slit 1 height), - S2H (slit 2 height), - S1W (slit 1 width), - S2W (slit 2 width) and - lambda requested values - """ - _nbr_files = len(full_list_runs) - print('> Retrieving Slits and Lambda Requested for each file:') - for i in range(_nbr_files): - _full_file_name = full_list_runs[i] - print('-> ' + _full_file_name) - tmpWks = LoadEventNexus(Filename=_full_file_name, - MetaDataOnly='1') -# mt1 = mtd['tmpWks'] - _s1h_value = getS1h(tmpWks) - _s2h_value = getS2h(tmpWks) - S1H[i] = _s1h_value - S2H[i] = _s2h_value - - _s1w_value = getS1w(tmpWks) - _s2w_value = getS2w(tmpWks) - S1W[i] = _s1w_value - S2W[i] = _s2w_value - - _lambda_value = getLambdaValue(tmpWks) - lambdaRequest[i] = _lambda_value - - -def isRunsSorted(dummy_list_runs, S1H, S2H): - """ - Make sure the files have been sorted - """ - sz = len(S1H) - sTotal = np.zeros(sz) - for i in range(sz): - sTotal[i] = S1H[i] + S2H[i] - - sorted_sTotal = sorted(sTotal) - - for i in range(len(sTotal)): - _left = list(sTotal)[i] - _right = sorted_sTotal[i] - - _left_formated = "%2.1f" % _left - _right_formated = "%2.1f" % _right - if _left_formated != _right_formated: - return False - - return True - - -def calculateAndFit(numerator='', - denominator='', - list_peak_back_numerator=None, - list_peak_back_denominator=None, - list_objects=None, - tof_range=None): - if list_objects is None: - list_objects=[] - print('--> running calculate and fit algorithm') - - cal1 = sfCalculator(numerator=numerator, - denominator=denominator, - tof_range=tof_range) - - cal1.setNumerator(minPeak=list_peak_back_numerator[0], - maxPeak=list_peak_back_numerator[1], - minBack=list_peak_back_numerator[2], - maxBack=list_peak_back_numerator[3]) - - cal1.setDenominator(minPeak=list_peak_back_denominator[0], - maxPeak=list_peak_back_denominator[1], - minBack=list_peak_back_denominator[2], - maxBack=list_peak_back_denominator[3]) - - cal1.run() - print('Done with cal1.run()') - - if list_objects != [] and list_objects[-1] is not None: - new_cal1 = cal1 * list_objects[-1] - new_cal1.fit() - return new_cal1 - else: - cal1.fit() - return cal1 - - -def showhelp(): - """ - Here the user will have information about how the command line - works - """ - print('sfCalculator help:') - print() - print('example:') - print(' > sfCalculator.calculate(string_runs="55889:0, 55890:1, 55891:1, 55892:2",') - print(' list_') - -#if __name__ == '__main__': - - -def calculate(string_runs=None,\ - # list_attenuator=None, - list_peak_back=None, - incident_medium=None, - output_file_name=None, - tof_range=None): - """ - In this current version, the program will automatically calculates - the scaling function for up to, and included, 6 attenuators. - A output file will then be produced with the following format: - S1H S2H a b error_a error_b - .... - where y=a+bx - x axis is in microS - - The string runs has to be specified this way: - string_runs = "run#1:nbr_attenuator, run#2:nbr_attenuator...." - - the list_peak_back is specified this way: - list_peak_back = - [[peak_min_run1, peak_max_run1, back_min_run1, back_max_run1], - [peak_min_run2, peak_max_run2, back_min_run2, back_max_run2], - [...]] - - output_path = where the scaling factor files will be written - tof_range - - """ - - list_attenuator = None - - #use default string files if not provided - if string_runs is None: - #Input from user -# list_runs = ['55889', '55890', '55891', '55892', '55893', '55894', -# '55895', '55896', '55897', '55898', '55899', '55900', -# '55901', '55902'] - list_runs = ['55889', '55890', '55891', '55892', '55893', '55894'] - nexus_path = '/mnt/hgfs/j35/results/' - pre = 'REF_L_' - nexus_path_pre = nexus_path + pre - post = '_event.nxs' - - for (offset, item) in enumerate(list_runs): - list_runs[offset] = nexus_path_pre + item + post - - else: - dico = createIndividualList(string_runs) - list_runs = dico['list_runs'] - - for (offset, item) in enumerate(list_runs): - try: - _File = FileFinder.findRuns("REF_L%d" %int(item))[0] - list_runs[offset] = _File - except RuntimeError: - msg = "RefLReduction: could not find run %s\n" %item - msg += "Add your data folder to your User Data Directories in the File menu" - raise RuntimeError(msg) - - list_attenuator = dico['list_attenuator'] - - if incident_medium is None: - incident_medium = "H20" #default value - - if list_attenuator is None: -# list_attenuator = [0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4] - list_attenuator = [0, 1, 1, 1, 1, 1] - - if list_peak_back is None: - list_peak_back = np.zeros((len(list_runs), 4)) #[peak_min, peak_max, back_min, back_max] -# list_peak_back[9, ] = [128, 136, 120, 145] -# list_peak_back[11, ] = [125, 140, 115, 150] -# list_peak_back[10, ] = [128, 136, 120, 145] -# list_peak_back[13, ] = [120, 145, 105, 155] -# list_peak_back[12, ] = [125, 140, 115, 150] - - ##### - #Input file should be as it is here ! - ##### - - #retrieve the S1H and S2H val/units for each NeXus - #retrieve the lambdaRequest value (Angstrom) - S1H = {} - S2H = {} - S1W = {} - S2W = {} - lambdaRequest = {} - getSlitsValueAndLambda(list_runs, S1H, S2H, S1W, S2W, lambdaRequest) - - #Make sure all the lambdaRequested are identical within a given range - lambdaRequestPrecision = 0.01 #1% - - for i in lambdaRequest: - _localValue = float(lambdaRequest[i][0]) - _localValueRate = lambdaRequestPrecision * _localValue - _leftValue = _localValue - _localValueRate - _rightValue = _localValue + _localValueRate - - if (_localValue < _leftValue) or (_localValue > _rightValue): - raise Exception("lambda requested do not match !") - - #make sure the file are sorted from smaller to bigger openning - if isRunsSorted(list_runs, S1H, S2H): - - #initialize record fitting parameters arrays - a = [] - b = [] - error_a = [] - error_b = [] - name = [] - - finalS1H = [] - finalS2H = [] - - finalS1W = [] - finalS2W = [] - - #array of True/False flags that will allow us - #to rescale the calculation on the first attenuator - _first_A = [] - for dummy_j in range(len(np.unique(list_attenuator))): - _first_A.append(True) - - #array of index of first attenuator - _index_first_A = [] - for dummy_j in range(len(np.unique(list_attenuator))): - _index_first_A.append(-1) - - index_numerator = -1 - index_denominator = -1 - - list_objects = [] - - for i in range(len(list_runs)): - - print('> Working with index: ' + str(i)) - _attenuator = list_attenuator[i] - - if _attenuator == 0: - continue - else: - if _first_A[_attenuator] is True: - _first_A[_attenuator] = False - _index_first_A[_attenuator] = i - continue - else: - index_numerator = i - index_denominator = _index_first_A[_attenuator] - - print('-> numerator : ' + str(list_runs[index_numerator])) - print('-> denominator: ' + str(list_runs[index_denominator])) - cal = calculateAndFit(numerator=list_runs[index_numerator], - denominator=list_runs[index_denominator], - list_peak_back_numerator=list_peak_back[index_numerator], - list_peak_back_denominator=list_peak_back[index_denominator], - list_objects=list_objects, - tof_range=tof_range) - print('-> Done with Calculate and Fit') - - recordSettings(a, b, error_a, error_b, name, cal) - - if i < (len(list_runs) - 1) and list_attenuator[i + 1] == (_attenuator+1): - list_objects.append(cal) - - #record S1H and S2H - finalS1H.append(S1H[index_numerator]) - finalS2H.append(S2H[index_numerator]) - - #record S1W and S2W - finalS1W.append(S1W[index_numerator]) - finalS2W.append(S2W[index_numerator]) - - #output the fitting parameters in an ascii - _lambdaRequest = "{0:.2f}".format(lambdaRequest[0][0]) - -# output_pre = 'SFcalculator_lr' + str(_lambdaRequest) -# output_ext = '.txt' -# output_file = output_path + '/' + output_pre + output_ext - - if (output_file_name is None) or (output_file_name == ''): - output_file_name = "RefLsf.cfg" - - outputFittingParameters(a, b, error_a, error_b, - _lambdaRequest, - incident_medium, - finalS1H, finalS2H, - finalS1W, finalS2W, - output_file_name) - - print('Done !') - -# else: -# """ -# sort the files -# """ -# pass diff --git a/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py b/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py index 88bc8f31c327e8f7db764bd6c26dbf338b513fef..2ac4ea055a8760748e1ae4e2a990bd58bcb86821 100644 --- a/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py +++ b/Framework/PythonInterface/test/python/mantid/api/AlgorithmTest.py @@ -22,6 +22,7 @@ class AlgorithmTest(unittest.TestCase): self.assertEquals(1, len(self._load.categories())) self.assertEquals('DataHandling', self._load.categories()[0]) self.assertEquals('', self._load.helpURL()) + self.assertEquals(["LoadNexus", "LoadRaw", "LoadBBY"], self._load.seeAlso()) def test_get_unknown_property_raises_error(self): self.assertRaises(RuntimeError, self._load.getProperty, "NotAProperty") diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SaveReflectionsTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SaveReflectionsTest.py index a977957f0ff089d5209a5bd2a47c87b74389a1f8..1310c3fa408e1bb2cfb07246ad1362f2d9e4dd69 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SaveReflectionsTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SaveReflectionsTest.py @@ -54,7 +54,7 @@ class SaveReflectionsTest(unittest.TestCase): def _create_indexed_workspace(self, fractional_peaks, ndim, hklm): # Create table with the number of columns we need types = ['int', 'long64', 'double', 'double', 'double', 'double', 'double', 'double', - 'double', 'double', 'double', 'float', 'str', 'float', 'float', 'V3D', 'V3D'] + 'double', 'double', 'double', 'float', 'str', 'float', 'float', 'V3D', 'V3D', 'int'] indexed = CreateEmptyTableWorkspace() names = fractional_peaks.getColumnNames() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/SortXAxisTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/SortXAxisTest.py index 211ba767192a7a7e8d38e4611af7d7b84ccf2736..9b43e770f953ed20e7eaef4600dd635f58969ac8 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/SortXAxisTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/SortXAxisTest.py @@ -1,16 +1,16 @@ from __future__ import (absolute_import, division, print_function) import unittest -from mantid.kernel import * -from mantid.api import * -from mantid.simpleapi import * +from mantid.simpleapi import AlgorithmManager, CreateWorkspace, DeleteWorkspace, SortXAxis + class SortXAxisTest(unittest.TestCase): + def test_x_ascending(self): - dataX = [1, 2, 3] # In ascending order, so y and e will need to be reversed. - dataY = [1, 2, 3] - dataE = [1, 2, 3] + dataX = [1., 2., 3.] # In ascending order, so y and e will need to be reversed. + dataY = [1., 2., 3.] + dataE = [1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=True) # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) @@ -24,11 +24,10 @@ class SortXAxisTest(unittest.TestCase): DeleteWorkspace(unsortedws) DeleteWorkspace(sortedws) - def test_x_descending(self): - dataX = [3, 2, 1] # In descending order, so y and e will need to be reversed. - dataY = [1, 2, 3] - dataE = [1, 2, 3] + dataX = [3., 2., 1.] # In descending order, so y and e will need to be reversed. + dataY = [1., 2., 3.] + dataE = [1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=True) # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) @@ -45,9 +44,9 @@ class SortXAxisTest(unittest.TestCase): DeleteWorkspace(sortedws) def test_on_multiple_spectrum(self): - dataX = [3, 2, 1, 3, 2, 1] # In descending order, so y and e will need to be reversed. - dataY = [1, 2, 3, 1, 2, 3] - dataE = [1, 2, 3, 1, 2, 3] + dataX = [3., 2., 1., 3., 2., 1.] # In descending order, so y and e will need to be reversed. + dataY = [1., 2., 3., 1., 2., 3.] + dataE = [1., 2., 3., 1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=True, NSpec=2) dataY.reverse() dataE.reverse() @@ -70,11 +69,10 @@ class SortXAxisTest(unittest.TestCase): DeleteWorkspace(unsortedws) DeleteWorkspace(sortedws) - def test_sorts_x_histogram_ascending(self): - dataX = [1, 2, 3, 4] - dataY = [1, 2, 3] - dataE = [1, 2, 3] + dataX = [1., 2., 3., 4.] + dataY = [1., 2., 3.] + dataE = [1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=False) # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) @@ -90,9 +88,9 @@ class SortXAxisTest(unittest.TestCase): DeleteWorkspace(sortedws) def test_sorts_x_histogram_descending(self): - dataX = [4, 3, 2, 1] - dataY = [1, 2, 3] - dataE = [1, 2, 3] + dataX = [4., 3., 2., 1.] + dataY = [1., 2., 3.] + dataE = [1., 2., 3.] unsortedws = CreateWorkspace(DataX=dataX,DataY=dataY,DataE=dataE,UnitX='TOF',Distribution=False) # Run the algorithm sortedws = SortXAxis(InputWorkspace=unsortedws) @@ -113,9 +111,9 @@ class SortXAxisTest(unittest.TestCase): # Create unsorted workspace parent = AlgorithmManager.createUnmanaged('Load') create_ws_alg = parent.createChildAlgorithm("CreateWorkspace") - dataX = [4, 3, 2, 1] - dataY = [1, 2, 3] - dataE = [1, 2, 3] + dataX = [4., 3., 2., 1.] + dataY = [1., 2., 3.] + dataE = [1., 2., 3.] create_ws_alg.setProperty("DataX", dataX) create_ws_alg.setProperty("DataY", dataY) create_ws_alg.setProperty("DataE", dataE) @@ -137,5 +135,49 @@ class SortXAxisTest(unittest.TestCase): self.assertEqual(dataY, sortedY.tolist()) self.assertEqual(dataE, sortedE.tolist()) + def test_dx_multiple_spectrum(self): + dataX = [3, 2, 1, 3, 2, 1] # In descending order, so y and e will need to be reversed. + dataY = [1, 2, 3, 1, 2, 3] + dx = [1, 2, 3, 1, 2, 3] + unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, Dx=dx, UnitX='TOF', Distribution=True, NSpec=2) + dx.reverse() + # Run the algorithm + sortedws = SortXAxis(InputWorkspace=unsortedws) + # Check the resulting data values for 1st spectrum. + sortedDx = sortedws.readDx(0) + self.assertEqual(dx[0:3], sortedDx.tolist()) + # Check the resulting data values for 2nd spectrum. + sortedDx = sortedws.readDx(1) + self.assertEqual(dx[3:], sortedDx.tolist()) + DeleteWorkspace(unsortedws) + DeleteWorkspace(sortedws) + + def test_dx_histogram_ascending(self): + dataX = [1., 2., 3., 4.] + dataY = [1., 2., 3.] + dx = [1., 2., 3.] + unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, Dx=dx, UnitX='TOF', Distribution=False) + # Run the algorithm + sortedws = SortXAxis(InputWorkspace=unsortedws) + sortedDx = sortedws.readDx(0) + # Check the resulting data values. Sorting operation should have resulted in no changes + self.assertEqual(dx, sortedDx.tolist()) + DeleteWorkspace(unsortedws) + DeleteWorkspace(sortedws) + + def test_sort_descending(self): + dataX = [1., 2., 3., 4.] + dataY = [1., 2., 3.] + unsortedws = CreateWorkspace(DataX=dataX, DataY=dataY, UnitX='TOF', Distribution=False) + # Run the algorithm + sortedws = SortXAxis(InputWorkspace=unsortedws, Ordering="Descending") + sortedX = sortedws.readX(0) + sortedY = sortedws.readY(0) + # Check the resulting data values. Sorting operation should have resulted in no changes + self.assertEqual([4., 3., 2., 1.], sortedX.tolist()) + self.assertEqual([3., 2., 1.], sortedY.tolist()) + DeleteWorkspace(unsortedws) + DeleteWorkspace(sortedws) + if __name__ == '__main__': - unittest.main() \ No newline at end of file + unittest.main() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py index 53c5fc76a66af2e1cae2f1f5fa0c19083df9eff8..423566183dffa449437dc2a5f12129ee0e3171f5 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/SANSStitchTest.py @@ -198,7 +198,7 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = [1.5] * 9 - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array))) + np.testing.assert_equal(y_array, expected_y_array) def test_strip_special_values(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -267,9 +267,8 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = [0.5] * 9 - - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='can gets subtracted so expect 1 - 0.5 as output signal. Proves the can workspace gets used correctly.') + + np.testing.assert_equal(y_array, expected_y_array) def test_scale_both_without_can(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -315,9 +314,8 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = lab_workspace.readY(0) # We scale and shift to the back (lab) detectors - - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='All data should be scaled and shifted to the LAB scale=1 shift=-5') + + np.testing.assert_equal(y_array, expected_y_array) def test_scale_both_without_can_with_q_fit_range(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -369,9 +367,8 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = [7497.5, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 7502, 10.0] # We scale and shift to the back (lab) detectors - - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='All data should be scaled and shifted to the LAB scale=1 shift=-5') + + np.testing.assert_equal(y_array, expected_y_array) def test_shift_only_without_can(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -414,9 +411,7 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = lab_workspace.readY(0) # We scale and shift to the back (lab) detectors - - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='All data should be scaled and shifted to the LAB scale=1 shift=-5') + np.testing.assert_equal(y_array, expected_y_array) def test_scale_only_without_can(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -460,8 +455,7 @@ class SANSStitchTest(unittest.TestCase): expected_y_array = lab_workspace.readY(0) # We scale and shift to the back (lab) detectors - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='All data should be scaled and shifted to the LAB scale=1 shift=-5') + np.testing.assert_equal(y_array, expected_y_array) def test_scale_none_with_can_and_q_merge_range_equal(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -508,9 +502,8 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = [0.5] * 5 + [1.5] * 4 - - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='can gets subtracted so expect 1 - 0.5 as output signal. Proves the can workspace gets used correctly.') + + np.testing.assert_equal(y_array, expected_y_array) def test_scale_none_with_can_and_q_merge_range(self): create_alg = AlgorithmManager.create('CreateWorkspace') @@ -557,9 +550,158 @@ class SANSStitchTest(unittest.TestCase): y_array = out_ws.readY(0) expected_y_array = [0.5] * 2 + [1.0] * 5 + [1.5] * 2 + + np.testing.assert_equal(y_array, expected_y_array) + + def test_that_merge_range_greater_than_overlap_bounds_set_to_upper_bound(self): + # This tests that if a merge_max or merge_min is specified greater than the overlap region of + # the HAB and LAB the relevant value is set to the maximum value. + create_alg = AlgorithmManager.create('CreateWorkspace') + create_alg.setChild(True) + create_alg.initialize() + create_alg.setProperty('DataX', range(0, 10)) + create_alg.setProperty('DataY', [1] * 9) + create_alg.setProperty('NSpec', 1) + create_alg.setProperty('UnitX', 'MomentumTransfer') + create_alg.setPropertyValue('OutputWorkspace', 'out_ws') + create_alg.execute() + single_spectra_input = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [2] * 9) + create_alg.execute() + single_spectra_input_HAB = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [0.5] * 9) + create_alg.execute() + smaller_single_spectra_input = create_alg.getProperty('OutputWorkspace').value + + alg = AlgorithmManager.create('SANSStitch') + alg.setChild(True) + alg.initialize() + alg.setProperty('Mode', 'None') + alg.setProperty('HABCountsSample', single_spectra_input_HAB) + alg.setProperty('LABCountsSample', single_spectra_input) + alg.setProperty('HABNormSample', single_spectra_input) + alg.setProperty('LABNormSample', single_spectra_input) + alg.setProperty('ProcessCan', True) + alg.setProperty('HABCountsCan', smaller_single_spectra_input) + alg.setProperty('LABCountsCan', smaller_single_spectra_input) + alg.setProperty('HABNormCan', single_spectra_input) + alg.setProperty('LABNormCan', single_spectra_input) + alg.setProperty('OutputWorkspace', 'dummy_name') + alg.setProperty('ShiftFactor', 0.0) + alg.setProperty('ScaleFactor', 1.0) + alg.setProperty('MergeMask', True) + alg.setProperty('MergeMin', 50) + alg.setProperty('MergeMax', 50) + alg.execute() + out_ws = alg.getProperty('OutputWorkspace').value + + self.assertTrue(isinstance(out_ws, MatrixWorkspace)) + + y_array = out_ws.readY(0) + + expected_y_array = [0.5] * 9 + np.testing.assert_equal(y_array, expected_y_array) + + def test_that_merge_range_less_than_overlap_bounds_set_to_lower_bound(self): + # This tests that if a merge_max or merge_min is specified greater than the overlap region of + # the HAB and LAB the relevant value is set to the maximum value. + create_alg = AlgorithmManager.create('CreateWorkspace') + create_alg.setChild(True) + create_alg.initialize() + create_alg.setProperty('DataX', range(0, 10)) + create_alg.setProperty('DataY', [1] * 9) + create_alg.setProperty('NSpec', 1) + create_alg.setProperty('UnitX', 'MomentumTransfer') + create_alg.setPropertyValue('OutputWorkspace', 'out_ws') + create_alg.execute() + single_spectra_input = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [2] * 9) + create_alg.execute() + single_spectra_input_HAB = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [0.5] * 9) + create_alg.execute() + smaller_single_spectra_input = create_alg.getProperty('OutputWorkspace').value + + alg = AlgorithmManager.create('SANSStitch') + alg.setChild(True) + alg.initialize() + alg.setProperty('Mode', 'None') + alg.setProperty('HABCountsSample', single_spectra_input_HAB) + alg.setProperty('LABCountsSample', single_spectra_input) + alg.setProperty('HABNormSample', single_spectra_input) + alg.setProperty('LABNormSample', single_spectra_input) + alg.setProperty('ProcessCan', True) + alg.setProperty('HABCountsCan', smaller_single_spectra_input) + alg.setProperty('LABCountsCan', smaller_single_spectra_input) + alg.setProperty('HABNormCan', single_spectra_input) + alg.setProperty('LABNormCan', single_spectra_input) + alg.setProperty('OutputWorkspace', 'dummy_name') + alg.setProperty('ShiftFactor', 0.0) + alg.setProperty('ScaleFactor', 1.0) + alg.setProperty('MergeMask', True) + alg.setProperty('MergeMin', 0) + alg.setProperty('MergeMax', 0) + alg.execute() + out_ws = alg.getProperty('OutputWorkspace').value + + self.assertTrue(isinstance(out_ws, MatrixWorkspace)) + + y_array = out_ws.readY(0) - self.assertTrue(all(map(lambda element: element in y_array, expected_y_array)), - msg='can gets subtracted so expect 1 - 0.5 as output signal. Proves the can workspace gets used correctly.') + expected_y_array = [1.0] + [1.5] * 8 + + np.testing.assert_equal(y_array, expected_y_array) + + def test_that_zero_merge_range_has_discrete_transition(self): + # This tests that if a merge_max or merge_min is specified greater than the overlap region of + # the HAB and LAB the relevant value is set to the maximum value. + create_alg = AlgorithmManager.create('CreateWorkspace') + create_alg.setChild(True) + create_alg.initialize() + create_alg.setProperty('DataX', range(0, 10)) + create_alg.setProperty('DataY', [1] * 9) + create_alg.setProperty('NSpec', 1) + create_alg.setProperty('UnitX', 'MomentumTransfer') + create_alg.setPropertyValue('OutputWorkspace', 'out_ws') + create_alg.execute() + single_spectra_input = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [2] * 9) + create_alg.execute() + single_spectra_input_HAB = create_alg.getProperty('OutputWorkspace').value + create_alg.setProperty('DataY', [0.5] * 9) + create_alg.execute() + smaller_single_spectra_input = create_alg.getProperty('OutputWorkspace').value + + alg = AlgorithmManager.create('SANSStitch') + alg.setChild(True) + alg.initialize() + alg.setProperty('Mode', 'None') + alg.setProperty('HABCountsSample', single_spectra_input_HAB) + alg.setProperty('LABCountsSample', single_spectra_input) + alg.setProperty('HABNormSample', single_spectra_input) + alg.setProperty('LABNormSample', single_spectra_input) + alg.setProperty('ProcessCan', True) + alg.setProperty('HABCountsCan', smaller_single_spectra_input) + alg.setProperty('LABCountsCan', smaller_single_spectra_input) + alg.setProperty('HABNormCan', single_spectra_input) + alg.setProperty('LABNormCan', single_spectra_input) + alg.setProperty('OutputWorkspace', 'dummy_name') + alg.setProperty('ShiftFactor', 0.0) + alg.setProperty('ScaleFactor', 1.0) + alg.setProperty('MergeMask', True) + alg.setProperty('MergeMin', 5) + alg.setProperty('MergeMax', 5) + alg.execute() + out_ws = alg.getProperty('OutputWorkspace').value + + self.assertTrue(isinstance(out_ws, MatrixWorkspace)) + + y_array = out_ws.readY(0) + + expected_y_array = [0.5] * 5 + [1.5] * 4 + + np.testing.assert_equal(y_array, expected_y_array) + def test_that_can_merge_2D_reduction_when_fitting_set_to_none(self): # create an input workspace that has multiple spectra diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToQTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToQTest.py index 4aa9101962a359dcf6c9923a6b02defc5ee64384..8e82ac329302f4134dd45c130ffed239ed16bb8e 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToQTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSConvertToQTest.py @@ -4,10 +4,11 @@ import mantid from sans.common.general_functions import (create_unmanaged_algorithm) from sans.common.constants import EMPTY_NAME -from sans.common.enums import (SANSFacility, SampleShape, ReductionDimensionality, RangeStepType) +from sans.common.enums import (SANSFacility, SampleShape, ReductionDimensionality, RangeStepType, SANSInstrument) from sans.test_helper.test_director import TestDirector from sans.state.convert_to_q import get_convert_to_q_builder from sans.state.data import get_data_builder +from sans.test_helper.file_information_mock import SANSFileInformationMock class SANSConvertToQTest(unittest.TestCase): @@ -35,7 +36,8 @@ class SANSConvertToQTest(unittest.TestCase): use_gravity=False, dim=ReductionDimensionality.OneDim): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_state = data_builder.build() diff --git a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSScaleTest.py b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSScaleTest.py index e2faa22f796ce63ec8861184dfdb8e090cf0d26f..a671f78df7c6ef951c3c094186e5d272a85f16be 100644 --- a/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSScaleTest.py +++ b/Framework/PythonInterface/test/python/plugins/algorithms/WorkflowAlgorithms/sans/SANSScaleTest.py @@ -5,10 +5,11 @@ import math from sans.common.general_functions import (create_unmanaged_algorithm) from sans.common.constants import EMPTY_NAME -from sans.common.enums import (SANSFacility, SampleShape) +from sans.common.enums import (SANSFacility, SampleShape, SANSInstrument) from sans.test_helper.test_director import TestDirector from sans.state.scale import get_scale_builder from sans.state.data import get_data_builder +from sans.test_helper.file_information_mock import SANSFileInformationMock class SANSScaleTest(unittest.TestCase): @@ -28,11 +29,12 @@ class SANSScaleTest(unittest.TestCase): def _get_sample_state(width, height, thickness, shape, scale): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_state = data_builder.build() - scale_builder = get_scale_builder(data_state) + scale_builder = get_scale_builder(data_state, file_information) scale_builder.set_scale(scale) scale_builder.set_thickness(thickness) scale_builder.set_width(width) diff --git a/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h index 747c3af568cdf959829aad73fda1ce418c0eecbb..56c48dc08ff1c944c96ab380958580ebb881d5a6 100644 --- a/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/AbortRemoteJob2Test.h @@ -98,9 +98,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); AbortRemoteJob2 ab; diff --git a/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h b/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h index 3bf0389ec81c4b960e18014b834b9147fc187502..5583ee32899f8f8fbe4efe3aa66be25cf41551e3 100644 --- a/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/AbortRemoteJobTest.h @@ -96,9 +96,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); AbortRemoteJob ab; diff --git a/Framework/RemoteAlgorithms/test/Authenticate2Test.h b/Framework/RemoteAlgorithms/test/Authenticate2Test.h index 8e048de0530b7128e700f292b66230e8c8b12161..3dfb66430a7fce1d0b1849ac5c770dcb839f3c9a 100644 --- a/Framework/RemoteAlgorithms/test/Authenticate2Test.h +++ b/Framework/RemoteAlgorithms/test/Authenticate2Test.h @@ -99,9 +99,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Authenticate2 auth; diff --git a/Framework/RemoteAlgorithms/test/AuthenticateTest.h b/Framework/RemoteAlgorithms/test/AuthenticateTest.h index 1014fded63acc6b58605433f2d4ee74496a66c95..f8a074242f205f8ce09c098838000745fbcfe89a 100644 --- a/Framework/RemoteAlgorithms/test/AuthenticateTest.h +++ b/Framework/RemoteAlgorithms/test/AuthenticateTest.h @@ -99,9 +99,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Authenticate auth; diff --git a/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h index 41ded2ee0ca38e998febb347d633fb0b0f24604b..9d5dc8c434648c3fd88f6bfb5e014fe6f3ec6ba9 100644 --- a/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/DownloadRemoteFile2Test.h @@ -104,9 +104,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); DownloadRemoteFile2 dl; diff --git a/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h b/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h index 4b18bde6ea718f0dcb6d5252a20fc502200487f5..7ecc3244762fe770139e72cec2ab2480527fdd3d 100644 --- a/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/DownloadRemoteFileTest.h @@ -104,9 +104,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); DownloadRemoteFile dl; diff --git a/Framework/RemoteAlgorithms/test/Logout2Test.h b/Framework/RemoteAlgorithms/test/Logout2Test.h index 1b337710d588889ac46546689abd10f05d294314..fc271f6d8ac4913e3a8e47cefbe5159270382d0f 100644 --- a/Framework/RemoteAlgorithms/test/Logout2Test.h +++ b/Framework/RemoteAlgorithms/test/Logout2Test.h @@ -72,9 +72,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); // test that job managers are created correctly for different facilities - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); Logout2 lo; diff --git a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h index b845d38a2138e95835e521b9d8d43aa1f022f1cf..6ec451c56581c8770b17b03554ee0148576f0832 100644 --- a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobs2Test.h @@ -81,9 +81,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const auto facName = testFacility.first; + const auto compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryAllRemoteJobs2 qar; diff --git a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h index 1d00df8c2c2304a6db57f444661bb43fd10a9c44..da759801f3c9dc1e7defd69c7b643df203f7b7b4 100644 --- a/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h +++ b/Framework/RemoteAlgorithms/test/QueryAllRemoteJobsTest.h @@ -81,9 +81,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryAllRemoteJobs qar; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h index 691e371466fea193570a41b4e39972e4c9f38484..3d02988843a9902d9fbf23b3bf8f8ff49cb14dcd 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteFile2Test.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteFile2 qrf; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h b/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h index 46d71b39742d59c22240ed812dbfd82540854e4d..04427da07913f098b849e41bd1a7e3b8ff116690 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteFileTest.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteFile qrf; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h index d8863c6d5d8185b610b615d32f08c4c9b9efc3cb..bd7403c56412350f1fe202b5e21305b6e8a5ed00 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteJob2Test.h @@ -90,9 +90,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteJob2 qr; diff --git a/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h b/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h index c5d2ea8d43027208ff0e373ef6299b4b83c75cdb..97cd9d135e08eb93b6a68dfe21d9764db1110f68 100644 --- a/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/QueryRemoteJobTest.h @@ -88,9 +88,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); QueryRemoteJob qr; diff --git a/Framework/RemoteAlgorithms/test/SimpleJSONTest.h b/Framework/RemoteAlgorithms/test/SimpleJSONTest.h index dc3b312fad0a7f977df32627b08c30e4e5dc81cd..749a4f3d640aad5060760baebed28859325d5eb8 100644 --- a/Framework/RemoteAlgorithms/test/SimpleJSONTest.h +++ b/Framework/RemoteAlgorithms/test/SimpleJSONTest.h @@ -143,7 +143,7 @@ public: void test_JSONObjectExampleServerResponseLonger() { const std::string longerJsonStr = - "{\"v1\": \"[1, a, 3]\",\"" + errName + "\":\"" + errVal + "\"}"; + R"({"v1": "[1, a, 3]",")" + errName + "\":\"" + errVal + "\"}"; std::istringstream inputLong(longerJsonStr); std::string res; @@ -156,7 +156,7 @@ public: TS_ASSERT_EQUALS(true, ol[errName].getValue(res)); TS_ASSERT_EQUALS(res, errVal); - const std::string l2JsonStr = "{\"v1\": \"[1, a, 3]\",\"" + errName + + const std::string l2JsonStr = R"({"v1": "[1, a, 3]",")" + errName + "\":\"" + errVal + "\", \"" + versName + "\": \"" + versVal + "\" }" "\"}"; @@ -173,7 +173,7 @@ public: TS_ASSERT_EQUALS(res, versVal); const std::string l3JsonStr = "{ \"" + impName + "\": \"" + impVal + - "\", \"v1\": \"[1, a, longer str, a4]\",\"" + + R"(", "v1": "[1, a, longer str, a4]",")" + errName + "\":\"" + errVal + "\", \"" + versName + "\": \"" + versVal + "\" }" "\"}"; @@ -201,7 +201,7 @@ public: TS_ASSERT_THROWS(initFromStream(jo, istr), JSONParseException); TS_ASSERT_THROWS_NOTHING(prettyPrint(jo, out, 0)); - std::string strOK = "{ \"key1\": \"val1\"}"; + std::string strOK = R"({ "key1": "val1"})"; std::istringstream istrOK(strOK); JSONObject j2; TS_ASSERT_THROWS_NOTHING(initFromStream(j2, istrOK)); diff --git a/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h b/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h index ffadba3eac9497b368bed243e23af70fe6fd1470..f6c86ce31953bffdd1728b190f8632c70fb9b699 100644 --- a/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h +++ b/Framework/RemoteAlgorithms/test/StartRemoteTransaction2Test.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StartRemoteTransaction2 start; diff --git a/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h b/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h index 27a2dfa80f567b454b32be0bb9a2c124f14c7586..006b409dfc69eac3637480befba8760e2d1935b8 100644 --- a/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h +++ b/Framework/RemoteAlgorithms/test/StartRemoteTransactionTest.h @@ -91,9 +91,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StartRemoteTransaction start; diff --git a/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h b/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h index 9153fe74d25590f2cd5ea36a57fdd483e379364a..1c3cf78170dea502db28def9f2448060f03ce680 100644 --- a/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h +++ b/Framework/RemoteAlgorithms/test/StopRemoteTransaction2Test.h @@ -93,9 +93,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StopRemoteTransaction2 stop; diff --git a/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h b/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h index 75c87b5ddeb152b020bc4c002be2431ededb8b5f..1449876e8363727b357506bf0e68bb2425e4c426 100644 --- a/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h +++ b/Framework/RemoteAlgorithms/test/StopRemoteTransactionTest.h @@ -93,9 +93,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); StopRemoteTransaction stop; diff --git a/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h b/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h index 8e1ef644caf37575847e035db1c340c9e53bf87f..edf6b121523379bcc75c4bb8446ec34ca0dafae2 100644 --- a/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h +++ b/Framework/RemoteAlgorithms/test/SubmitRemoteJob2Test.h @@ -157,9 +157,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h b/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h index 520cb3d0ca86e53f32b3bed0b871ffdac0ba3c2b..cbe9053f8adacb5e5a8dd02aa803bfab73ddaca9 100644 --- a/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h +++ b/Framework/RemoteAlgorithms/test/SubmitRemoteJobTest.h @@ -157,9 +157,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h b/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h index ebdd6c318fd5564a58715b753bad895f41cc11e3..18a8031f5f8a746cce99dc3ca8f9edc37d841863 100644 --- a/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h +++ b/Framework/RemoteAlgorithms/test/UploadRemoteFile2Test.h @@ -124,9 +124,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h b/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h index 2b0f241c2a65d7b6ef7d7925bc8a5726eb0dfdf0..1801ad928e076d38b790737633f711926a4e047f 100644 --- a/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h +++ b/Framework/RemoteAlgorithms/test/UploadRemoteFileTest.h @@ -124,9 +124,9 @@ public: const Mantid::Kernel::FacilityInfo &prevFac = Mantid::Kernel::ConfigService::Instance().getFacility(); - for (size_t fi = 0; fi < testFacilities.size(); fi++) { - const std::string facName = testFacilities[fi].first; - const std::string compName = testFacilities[fi].second; + for (auto &testFacility : testFacilities) { + const std::string facName = testFacility.first; + const std::string compName = testFacility.second; Mantid::Kernel::ConfigService::Instance().setFacility(facName); diff --git a/Framework/RemoteJobManagers/test/MantidWebServiceAPIJobManagerTest.h b/Framework/RemoteJobManagers/test/MantidWebServiceAPIJobManagerTest.h index ca1f9a7dca3701b33c7fcb486795663546ee69c3..0ac25091d436a8ceab67c47a28b0a397d6d24b55 100644 --- a/Framework/RemoteJobManagers/test/MantidWebServiceAPIJobManagerTest.h +++ b/Framework/RemoteJobManagers/test/MantidWebServiceAPIJobManagerTest.h @@ -54,8 +54,7 @@ class MockMantidAPIStatusNotFoundWithErrMsg : public MantidWebServiceAPIJobManager { public: MockMantidAPIStatusNotFoundWithErrMsg() : MantidWebServiceAPIJobManager() { - is.str("{\"foo\": \"err_msg\", \"Err_Msg\"=\"fake error\", \"param\": " - "\"1\", }"); + is.str(R"({"foo": "err_msg", "Err_Msg"="fake error", "param": "1", })"); } protected: diff --git a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h index 1a66516d4862553b424ae4df8997a5e5b108d65d..1fa14856f81fd26cf0e5aeef0baa27d77660c3e6 100644 --- a/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h +++ b/Framework/SINQ/inc/MantidSINQ/InvertMDDim.h @@ -44,6 +44,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"TransformMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Transforms"; diff --git a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h index 4efa2af544fbb19a29cf73bfe6f52aa8fdff1d1a..60103f10790e943b1d69f6f3cc42a69485366069 100644 --- a/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h +++ b/Framework/SINQ/inc/MantidSINQ/LoadFlexiNexus.h @@ -61,6 +61,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"LoadNexus"}; + } /// Algorithm's category for identification const std::string category() const override { return "DataHandling\\Nexus"; } diff --git a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h index 6e0e2bf436196baa7443a909329ffa9200d16188..df1acebf62d6393122c14924bed9d856d8719030 100644 --- a/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h +++ b/Framework/SINQ/inc/MantidSINQ/MDHistoToWorkspace2D.h @@ -49,6 +49,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"ConvertMDHistoToMatrixWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Transforms"; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiCreatePeaksFromCell.h b/Framework/SINQ/inc/MantidSINQ/PoldiCreatePeaksFromCell.h index 4344c9b4c3d05159ff4d66eff036ea57184d256d..d4302a395021a624af4292d8a347882fafbdd4b7 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiCreatePeaksFromCell.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiCreatePeaksFromCell.h @@ -45,6 +45,9 @@ class MANTID_SINQ_DLL PoldiCreatePeaksFromCell : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PoldiCreatePeaksFromFile"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h index ac94ab78835010e22e8f28ee047c02408b78abb2..e462465b739b7dfd2ca00b491810e81c82c820e6 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks1D2.h @@ -88,6 +88,9 @@ public: } int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PoldiFitPeaks2D"}; + } const std::string category() const override; protected: diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h index c59149bb3b44f3aa51c5d789bf3c9d9b7ab1a979..f74ce705f7a0a8b64aa270e90686f7404160912b 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiFitPeaks2D.h @@ -56,6 +56,9 @@ class MANTID_SINQ_DLL PoldiFitPeaks2D : public API::Algorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"PoldiFitPeaks1D"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h index 3af9624cf8bf021b10d1c7ebb4d8f7d62fcdd911..eb0672a6c575d8ee67ff563de651d086ce9900a9 100644 --- a/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h +++ b/Framework/SINQ/inc/MantidSINQ/PoldiUtilities/PoldiMockInstrumentHelpers.h @@ -534,7 +534,7 @@ public: BraggScatterer_sptr atomSi = BraggScattererFactory::Instance().createScatterer( "IsotropicAtomBraggScatterer", - "{\"Element\":\"Si\",\"Position\":\"0,0,0\",\"U\":\"0.005\"}"); + R"({"Element":"Si","Position":"0,0,0","U":"0.005"})"); CompositeBraggScatterer_sptr atoms = CompositeBraggScatterer::create(); atoms->addScatterer(atomSi); diff --git a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h index 8fbafa364e7ca8a3c4a6ac6de9214ed2b2826f31..89de58f5554dc26aac719255d189a423e80a6e9a 100644 --- a/Framework/SINQ/inc/MantidSINQ/ProjectMD.h +++ b/Framework/SINQ/inc/MantidSINQ/ProjectMD.h @@ -43,6 +43,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"CutMD", "BinMD"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Slicing"; diff --git a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h index 52d9b8611a60b992c547b6fb3254059e52e8d34b..2905071f819c407d921e1a88881a81a5643a182e 100644 --- a/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h +++ b/Framework/SINQ/inc/MantidSINQ/SINQTranspose3D.h @@ -52,7 +52,9 @@ public: const std::string summary() const override { return "SINQ specific MD data reordering"; } - + const std::vector<std::string> seeAlso() const override { + return {"TransposeMD", "Transpose"}; + } /// Algorithm's version int version() const override { return (1); } /// Algorithm's category for identification diff --git a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h index 4199b0bf83a9aa9c45837bd853bdb04d1a642384..61f584a5769cee5f099c920bab1a7347421aa7dd 100644 --- a/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h +++ b/Framework/SINQ/inc/MantidSINQ/SliceMDHisto.h @@ -46,6 +46,9 @@ public: /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SliceMD", "IntegrateMDHistoWorkspace"}; + } /// Algorithm's category for identification const std::string category() const override { return "MDAlgorithms\\Slicing"; diff --git a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h index e4fd2201eee32641c28a63a02a8a15f51a061978..9fd47f6fd0c2be607cc041f921ecb003aff2f43b 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1D2Test.h +++ b/Framework/SINQ/test/PoldiFitPeaks1D2Test.h @@ -100,8 +100,8 @@ public: std::vector<Property *> properties = fitPeaks1D.getProperties(); std::unordered_set<std::string> names; - for (size_t i = 0; i < properties.size(); ++i) { - names.insert(properties[i]->name()); + for (auto &property : properties) { + names.insert(property->name()); } TS_ASSERT_EQUALS(names.count("InputWorkspace"), 1); diff --git a/Framework/SINQ/test/PoldiFitPeaks1DTest.h b/Framework/SINQ/test/PoldiFitPeaks1DTest.h index 5fef57ec078c66f53a436b0b1deb7d2812a552b7..e8ff092bb0c1a0535d88eddd36673cabed47ed9c 100644 --- a/Framework/SINQ/test/PoldiFitPeaks1DTest.h +++ b/Framework/SINQ/test/PoldiFitPeaks1DTest.h @@ -102,8 +102,8 @@ public: std::vector<Property *> properties = fitPeaks1D.getProperties(); std::unordered_set<std::string> names; - for (size_t i = 0; i < properties.size(); ++i) { - names.insert(properties[i]->name()); + for (auto &property : properties) { + names.insert(property->name()); } TS_ASSERT_EQUALS(names.count("InputWorkspace"), 1); diff --git a/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h b/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h index b0906c2fa9120d39198de4f436770f27634718fd..302ef9bc8294228df0a9c860c3078b5ae7149a1d 100644 --- a/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h +++ b/Framework/SINQ/test/PoldiIndexKnownCompoundsTest.h @@ -669,9 +669,9 @@ private: } void storeRandomWorkspaces(const std::vector<std::string> &wsNames) { - for (auto it = wsNames.begin(); it != wsNames.end(); ++it) { + for (const auto &wsName : wsNames) { WorkspaceCreationHelper::storeWS( - *it, WorkspaceCreationHelper::create1DWorkspaceRand(10, true)); + wsName, WorkspaceCreationHelper::create1DWorkspaceRand(10, true)); } } @@ -684,8 +684,8 @@ private: } void removeRandomWorkspaces(const std::vector<std::string> &wsNames) { - for (auto it = wsNames.begin(); it != wsNames.end(); ++it) { - WorkspaceCreationHelper::removeWS(*it); + for (const auto &wsName : wsNames) { + WorkspaceCreationHelper::removeWS(wsName); } } diff --git a/Framework/SINQ/test/PoldiInstrumentAdapterTest.h b/Framework/SINQ/test/PoldiInstrumentAdapterTest.h index aab05fa210ad97fcfc3528731bd058d6ef35a086..46b88a7e51a9970d3825c9e31f806fea6278f8a2 100644 --- a/Framework/SINQ/test/PoldiInstrumentAdapterTest.h +++ b/Framework/SINQ/test/PoldiInstrumentAdapterTest.h @@ -195,7 +195,7 @@ public: TestablePoldiInstrumentAdapter instrumentAdapter; // Throw on null-pointer - TS_ASSERT_THROWS(instrumentAdapter.getExtractorForProperty(0), + TS_ASSERT_THROWS(instrumentAdapter.getExtractorForProperty(nullptr), std::invalid_argument); TS_ASSERT_THROWS_NOTHING(instrumentAdapter.getExtractorForProperty( m_run.getProperty("chopperspeed_double"))); diff --git a/Framework/SINQ/test/PoldiPeakCollectionTest.h b/Framework/SINQ/test/PoldiPeakCollectionTest.h index 5f91b3dd074c82498e01c6d166a53d0f2e802f8f..89d64a02f26946d79f46943fe40e4c2893349c45 100644 --- a/Framework/SINQ/test/PoldiPeakCollectionTest.h +++ b/Framework/SINQ/test/PoldiPeakCollectionTest.h @@ -390,10 +390,10 @@ private: BraggScatterer_sptr cs = BraggScattererFactory::Instance().createScatterer( "IsotropicAtomBraggScatterer", - "{\"Element\":\"Cs\",\"Position\":\"0.5,0.5,0.5\",\"U\":\"0.005\"}"); + R"({"Element":"Cs","Position":"0.5,0.5,0.5","U":"0.005"})"); BraggScatterer_sptr cl = BraggScattererFactory::Instance().createScatterer( "IsotropicAtomBraggScatterer", - "{\"Element\":\"Cl\",\"Position\":\"0,0,0\",\"U\":\"0.005\"}"); + R"({"Element":"Cl","Position":"0,0,0","U":"0.005"})"); CompositeBraggScatterer_sptr atoms = CompositeBraggScatterer::create(); atoms->addScatterer(cs); diff --git a/Framework/SINQ/test/PoldiPeakSearchTest.h b/Framework/SINQ/test/PoldiPeakSearchTest.h index 6cf85b25ef884598b1f5c60ed4dc6656c536c4fa..b4534d07500df0e93ae8d2996ae5fdf9f91e9da5 100644 --- a/Framework/SINQ/test/PoldiPeakSearchTest.h +++ b/Framework/SINQ/test/PoldiPeakSearchTest.h @@ -123,10 +123,9 @@ public: std::vector<double> testXData(testYData.size()); double x = 0.0; - for (std::vector<double>::iterator iterX = testXData.begin(); - iterX != testXData.end(); ++iterX) { + for (double &iterX : testXData) { x += 1.0; - *iterX = x; + iterX = x; } std::list<std::vector<double>::const_iterator> maxima = diff --git a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h index 48098cfef3b48bb063a659262326e7739300c869..d8fe26e372db5718eba173512ecd74a91afe33b7 100644 --- a/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h +++ b/Framework/ScriptRepository/test/ScriptRepositoryTestImpl.h @@ -363,8 +363,8 @@ public: TS_ASSERT_THROWS_NOTHING(list_files = repo->listFiles()); TS_ASSERT(list_files.size() == 5); // check that all the files at the central repository are inside - for (int i = 0; i < 5; i++) - TSM_ASSERT_THROWS_NOTHING(test_entries[i], repo->info(test_entries[i])); + for (auto &test_entry : test_entries) + TSM_ASSERT_THROWS_NOTHING(test_entry, repo->info(test_entry)); } /** @@ -478,9 +478,8 @@ public: TS_ASSERT_THROWS_NOTHING(list_of_files = repo->listFiles()); std::cout << "After update, the files are: "; - for (std::vector<string>::iterator it = list_of_files.begin(); - it != list_of_files.end(); it++) { - std::cout << *it << ", "; + for (auto &list_of_file : list_of_files) { + std::cout << list_of_file << ", "; } std::cout << '\n'; TS_ASSERT(list_of_files.size() == 1); diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h index 46de8bd791d337a10365b18421bb5f5fba0d1650..b90561823689da025b5094e7896fdae580094042 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/MDEventsTestHelper.h @@ -423,7 +423,7 @@ static void feedMDBox(MDBoxBase<MDLeanEvent<nd>, nd> *box, size_t repeat = 1, allDone = Mantid::Kernel::Utils::NestedForLoop::Increment(nd, counters, index_max); } - box->refreshCache(NULL); + box->refreshCache(nullptr); } //------------------------------------------------------------------------------------- diff --git a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h index b49022e4ae06281ec0d877d17aa5b09efc022b14..516e70ebfc2fcfa29f0c5b67db71fe0bb47336cb 100644 --- a/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h +++ b/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h @@ -135,10 +135,12 @@ Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWhereYIsWorkspaceIndex(int nhist, int numBoundaries); Mantid::DataObjects::Workspace2D_sptr create2DWorkspace123( int64_t nHist, int64_t nBins, bool isHist = false, - const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>()); + const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>(), + bool hasDx = false); Mantid::DataObjects::Workspace2D_sptr create2DWorkspace154( int64_t nHist, int64_t nBins, bool isHist = false, - const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>()); + const std::set<int64_t> &maskedWorkspaceIndices = std::set<int64_t>(), + bool hasDx = false); Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithValuesAndXerror( int64_t nHist, int64_t nBins, bool isHist, double xVal, double yVal, double eVal, double dxVal, @@ -164,8 +166,9 @@ create2DWorkspaceBinned(int nhist, int numVals, double x0 = 0.0, * Filled with Y = 2.0 and E = sqrt(2.0)w */ Mantid::DataObjects::Workspace2D_sptr -create2DWorkspaceBinned(int nhist, const int numBoundaries, - const double xBoundaries[]); +create2DWorkspaceNonUniformlyBinned(int nhist, const int numBoundaries, + const double xBoundaries[], + bool hasDx = false); struct returnOne { double operator()(const double, size_t) { return 1; } @@ -228,7 +231,8 @@ void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, Mantid::DataObjects::Workspace2D_sptr create2DWorkspaceWithFullInstrument( int nhist, int nbins, bool includeMonitors = false, bool startYNegative = false, bool isHistogram = true, - const std::string &instrumentName = std::string("testInst")); + const std::string &instrumentName = std::string("testInst"), + bool hasDx = false); /** * Create a workspace as for create2DWorkspaceWithFullInstrument, but including diff --git a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp index 4eeb696bb68a4d341934b5b43aa0a4cdd8a1c4ef..bd6dbfe1d9601af31ad07a0bb3f1eb5da57d779b 100644 --- a/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp +++ b/Framework/TestHelpers/src/WorkspaceCreationHelper.cpp @@ -30,12 +30,14 @@ #include "MantidGeometry/Instrument/ReferenceFrame.h" #include "MantidGeometry/Objects/ShapeFactory.h" #include "MantidHistogramData/LinearGenerator.h" +#include "MantidHistogramData/HistogramDx.h" #include "MantidIndexing/IndexInfo.h" #include "MantidKernel/MersenneTwister.h" #include "MantidKernel/OptionalBool.h" #include "MantidKernel/TimeSeriesProperty.h" #include "MantidKernel/UnitFactory.h" #include "MantidKernel/VectorHelper.h" +#include "MantidKernel/make_cow.h" #include "MantidKernel/make_unique.h" #include "MantidKernel/V3D.h" @@ -195,20 +197,36 @@ Workspace2D_sptr create2DWorkspaceThetaVsTOF(int nHist, int nBins) { return outputWS; } +/** + * @brief create2DWorkspaceWithValues + * @param nHist :: Number of spectra + * @param nBins :: Number of points (not bin edges!) + * @param isHist :: Flag if it is a histogram or point data + * @param maskedWorkspaceIndices :: Mask workspace indices + * @param xVal :: bin edge or point + * @param yVal :: y value + * @param eVal :: error values + * @param hasDx :: wether workspace has dx values defined (default is false) + * @return A workspace filled with nBins bins or points and nHist spectra of the + * values yVal and the error eVal as well as Dx values which are copies of the y + * values + */ Workspace2D_sptr create2DWorkspaceWithValues(int64_t nHist, int64_t nBins, bool isHist, const std::set<int64_t> &maskedWorkspaceIndices, - double xVal, double yVal, double eVal) { + double xVal, double yVal, double eVal, + bool hasDx = false) { auto x1 = Kernel::make_cow<HistogramData::HistogramX>( isHist ? nBins + 1 : nBins, LinearGenerator(xVal, 1.0)); Counts y1(nBins, yVal); CountStandardDeviations e1(nBins, eVal); + auto dx = Kernel::make_cow<HistogramData::HistogramDx>(nBins, yVal); auto retVal = boost::make_shared<Workspace2D>(); - retVal->initialize(nHist, isHist ? nBins + 1 : nBins, nBins); + retVal->initialize(nHist, createHisto(isHist, y1, e1)); for (int i = 0; i < nHist; i++) { - retVal->setX(i, x1); - retVal->setCounts(i, y1); - retVal->setCountStandardDeviations(i, e1); + retVal->setSharedX(i, x1); + if (hasDx) + retVal->setSharedDx(i, dx); retVal->getSpectrum(i).setDetectorID(i); retVal->getSpectrum(i).setSpectrumNo(i); } @@ -231,16 +249,18 @@ Workspace2D_sptr create2DWorkspaceWithValuesAndXerror( Workspace2D_sptr create2DWorkspace123(int64_t nHist, int64_t nBins, bool isHist, - const std::set<int64_t> &maskedWorkspaceIndices) { - return create2DWorkspaceWithValues(nHist, nBins, isHist, - maskedWorkspaceIndices, 1.0, 2.0, 3.0); + const std::set<int64_t> &maskedWorkspaceIndices, + bool hasDx) { + return create2DWorkspaceWithValues( + nHist, nBins, isHist, maskedWorkspaceIndices, 1.0, 2.0, 3.0, hasDx); } Workspace2D_sptr create2DWorkspace154(int64_t nHist, int64_t nBins, bool isHist, - const std::set<int64_t> &maskedWorkspaceIndices) { - return create2DWorkspaceWithValues(nHist, nBins, isHist, - maskedWorkspaceIndices, 1.0, 5.0, 4.0); + const std::set<int64_t> &maskedWorkspaceIndices, + bool hasDx) { + return create2DWorkspaceWithValues( + nHist, nBins, isHist, maskedWorkspaceIndices, 1.0, 5.0, 4.0, hasDx); } Workspace2D_sptr maskSpectra(Workspace2D_sptr workspace, @@ -252,7 +272,7 @@ Workspace2D_sptr maskSpectra(Workspace2D_sptr workspace, workspace->setInstrument(instrument); std::string xmlShape = "<sphere id=\"shape\"> "; - xmlShape += "<centre x=\"0.0\" y=\"0.0\" z=\"0.0\" /> "; + xmlShape += R"(<centre x="0.0" y="0.0" z="0.0" /> )"; xmlShape += "<radius val=\"0.05\" /> "; xmlShape += "</sphere>"; xmlShape += "<algebra val=\"shape\" /> "; @@ -303,31 +323,34 @@ Workspace2D_sptr create2DWorkspaceBinned(int nhist, int numVals, double x0, Counts y(numVals, 2); CountStandardDeviations e(numVals, M_SQRT2); auto retVal = boost::make_shared<Workspace2D>(); - retVal->initialize(nhist, numVals + 1, numVals); - for (int i = 0; i < nhist; i++) { + retVal->initialize(nhist, createHisto(true, y, e)); + for (int i = 0; i < nhist; i++) retVal->setBinEdges(i, x); - retVal->setCounts(i, y); - retVal->setCountStandardDeviations(i, e); - } return retVal; } /** Create a 2D workspace with this many histograms and bins. The bins are * assumed to be non-uniform and given by the input array * Filled with Y = 2.0 and E = M_SQRT2w + * If hasDx is true, all spectra will have dx values, starting from 0.1 and + * increased by 0.1 for each bin. */ -Workspace2D_sptr create2DWorkspaceBinned(int nhist, const int numBoundaries, - const double xBoundaries[]) { +Workspace2D_sptr create2DWorkspaceNonUniformlyBinned(int nhist, + const int numBoundaries, + const double xBoundaries[], + bool hasDx) { BinEdges x(xBoundaries, xBoundaries + numBoundaries); const int numBins = numBoundaries - 1; Counts y(numBins, 2); CountStandardDeviations e(numBins, M_SQRT2); + auto dx = Kernel::make_cow<HistogramData::HistogramDx>( + numBins, LinearGenerator(0.1, .1)); auto retVal = boost::make_shared<Workspace2D>(); - retVal->initialize(nhist, numBins + 1, numBins); + retVal->initialize(nhist, createHisto(true, y, e)); for (int i = 0; i < nhist; i++) { retVal->setBinEdges(i, x); - retVal->setCounts(i, y); - retVal->setCountStandardDeviations(i, e); + if (hasDx) + retVal->setSharedDx(i, dx); } return retVal; } @@ -360,11 +383,11 @@ void addNoise(Mantid::API::MatrixWorkspace_sptr ws, double noise, * from the centre of the * previous. * Data filled with: Y: 2.0, E: M_SQRT2, X: nbins of width 1 starting at 0 + * The flag hasDx is responsible for creating dx values or not */ -Workspace2D_sptr -create2DWorkspaceWithFullInstrument(int nhist, int nbins, bool includeMonitors, - bool startYNegative, bool isHistogram, - const std::string &instrumentName) { +Workspace2D_sptr create2DWorkspaceWithFullInstrument( + int nhist, int nbins, bool includeMonitors, bool startYNegative, + bool isHistogram, const std::string &instrumentName, bool hasDx) { if (includeMonitors && nhist < 2) { throw std::invalid_argument("Attempting to 2 include monitors for a " "workspace with fewer than 2 histograms"); @@ -373,9 +396,10 @@ create2DWorkspaceWithFullInstrument(int nhist, int nbins, bool includeMonitors, Workspace2D_sptr space; if (isHistogram) space = create2DWorkspaceBinned( - nhist, nbins); // A 1:1 spectra is created by default + nhist, nbins, hasDx); // A 1:1 spectra is created by default else - space = create2DWorkspace123(nhist, nbins, false); + space = + create2DWorkspace123(nhist, nbins, false, std::set<int64_t>(), hasDx); space->setTitle( "Test histogram"); // actually adds a property call run_title to the logs space->getAxis(0)->setUnit("TOF"); diff --git a/Framework/Types/test/DateAndTimeTest.h b/Framework/Types/test/DateAndTimeTest.h index 33f52df1d342e0aa681ac9bf0196a8fb0fa2c15c..91d17bd25ae72467beac1b222a67ee38e94b1f73 100644 --- a/Framework/Types/test/DateAndTimeTest.h +++ b/Framework/Types/test/DateAndTimeTest.h @@ -279,7 +279,7 @@ public: void test_time_t_support() { DateAndTime t; - std::time_t current = time(NULL); + std::time_t current = time(nullptr); t.set_from_time_t(current); // if (cur.day() < 28) // Annoying bug at the end of a month { TS_ASSERT_EQUALS(current, t.to_time_t()); } diff --git a/Framework/WorkflowAlgorithms/CMakeLists.txt b/Framework/WorkflowAlgorithms/CMakeLists.txt index 7bdb72de478154de29dec5ea24968c3423065de9..adbf431c1653738462031a5978e752d5f99ddec3 100644 --- a/Framework/WorkflowAlgorithms/CMakeLists.txt +++ b/Framework/WorkflowAlgorithms/CMakeLists.txt @@ -29,7 +29,6 @@ set ( SRC_FILES src/MuonProcess.cpp src/MuonPairAsymmetryCalculator.cpp src/ProcessIndirectFitParameters.cpp - src/RefReduction.cpp src/RefRoi.cpp src/SANSBeamFinder.cpp src/SANSBeamFluxCorrection.cpp @@ -76,7 +75,6 @@ set ( INC_FILES inc/MantidWorkflowAlgorithms/MuonProcess.h inc/MantidWorkflowAlgorithms/MuonPairAsymmetryCalculator.h inc/MantidWorkflowAlgorithms/ProcessIndirectFitParameters.h - inc/MantidWorkflowAlgorithms/RefReduction.h inc/MantidWorkflowAlgorithms/RefRoi.h inc/MantidWorkflowAlgorithms/SANSBeamFinder.h inc/MantidWorkflowAlgorithms/SANSBeamFluxCorrection.h diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h index a5c16c6eb349f0b6b1eb89f28292c4e36866a639..241a2131006c100c080182fb861c0b56b29a91a9 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/AlignAndFocusPowder.h @@ -65,6 +65,9 @@ public: /// Algorithm's version for identification overriding a virtual method int version() const override { return 1; } + const std::vector<std::string> seeAlso() const override { + return {"AlignAndFocusPowderFromFiles"}; + } /// Algorithm's category for identification overriding a virtual method const std::string category() const override { diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/LoadEventAndCompress.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/LoadEventAndCompress.h index ce8aaf3dba4de77b153588cdbcd056751365b10f..ec88cb90c0de8360cb9fdb5c9e58e2e13b93c304 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/LoadEventAndCompress.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/LoadEventAndCompress.h @@ -35,6 +35,9 @@ class DLLExport LoadEventAndCompress : public API::DataProcessorAlgorithm { public: const std::string name() const override; int version() const override; + const std::vector<std::string> seeAlso() const override { + return {"LoadEventNexus", "CompressEvents"}; + } const std::string category() const override; const std::string summary() const override; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefReduction.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefReduction.h deleted file mode 100644 index 749f1f43c9926e449b57caa823947ed6db6a2523..0000000000000000000000000000000000000000 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefReduction.h +++ /dev/null @@ -1,87 +0,0 @@ -#ifndef MANTID_ALGORITHMS_RefReduction_H_ -#define MANTID_ALGORITHMS_RefReduction_H_ - -//---------------------------------------------------------------------- -// Includes -//---------------------------------------------------------------------- -#include "MantidAPI/Algorithm.h" -#include "MantidAPI/MatrixWorkspace_fwd.h" -#include "MantidDataObjects/EventWorkspace.h" - -namespace Mantid { -namespace WorkflowAlgorithms { -/** - Data reduction for reflectometry - - Copyright © 2012 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> - Code Documentation is available at: <http://doxygen.mantidproject.org> -*/ - -class DLLExport RefReduction : public API::Algorithm { -public: - /// Algorithm's name - const std::string name() const override { return "RefReduction"; } - /// Summary of algorithms purpose - const std::string summary() const override { - return "Data reduction for reflectometry."; - } - /// Algorithm's version - int version() const override { return (1); } - /// Algorithm's category for identification - const std::string category() const override { - return "Workflow\\Reflectometry"; - } - -private: - /// Initialisation code - void init() override; - /// Execution code - void exec() override; - - static const std::string PolStateOffOff; - static const std::string PolStateOnOff; - static const std::string PolStateOffOn; - static const std::string PolStateOnOn; - static const std::string PolStateNone; - - static const int NX_PIXELS; - static const int NY_PIXELS; - static const double PIXEL_SIZE; - - std::string m_output_message; - - API::MatrixWorkspace_sptr processData(const std::string polarization); - API::MatrixWorkspace_sptr processNormalization(); - API::IEventWorkspace_sptr loadData(const std::string dataRun, - const std::string polarization); - double calculateAngleREFM(API::MatrixWorkspace_sptr workspace); - double calculateAngleREFL(API::MatrixWorkspace_sptr workspace); - API::MatrixWorkspace_sptr subtractBackground(API::MatrixWorkspace_sptr dataWS, - API::MatrixWorkspace_sptr rawWS, - int peakMin, int peakMax, - int bckMin, int bckMax, - int lowResMin, int lowResMax); -}; - -} // namespace Algorithms -} // namespace Mantid - -#endif /*MANTID_ALGORITHMS_RefReduction_H_*/ diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefRoi.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefRoi.h index 389114be9071f9ee01b1ad30eb3e8c83811ceca6..fd629644542c71120d670d1e110e34c25ec3fbde 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefRoi.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/RefRoi.h @@ -48,6 +48,7 @@ public: } /// Algorithm's version int version() const override { return (1); } + /// Algorithm's category for identification const std::string category() const override { return "Workflow\\Reflectometry"; diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFluxCorrection.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFluxCorrection.h index 1c274a53cf641a283bee39b9f7eb3bd1c8c2feeb..3aa3e9b374c52548347f0d8572e08469be745b2b 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFluxCorrection.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSBeamFluxCorrection.h @@ -24,6 +24,9 @@ public: } /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SANSSolidAngleCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "Workflow\\SANS\\UsesPropertyManager;" diff --git a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSolidAngleCorrection.h b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSolidAngleCorrection.h index a161140b047a7a0a162258da29c3c76e103888b2..9a0fc2d782ef7151617dbb3058c447e6db1c1980 100644 --- a/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSolidAngleCorrection.h +++ b/Framework/WorkflowAlgorithms/inc/MantidWorkflowAlgorithms/SANSSolidAngleCorrection.h @@ -44,6 +44,9 @@ public: } /// Algorithm's version int version() const override { return (1); } + const std::vector<std::string> seeAlso() const override { + return {"SANSBeamFluxCorrection"}; + } /// Algorithm's category for identification const std::string category() const override { return "Workflow\\SANS\\UsesPropertyManager;" diff --git a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp index ca1966529fef5d90e05ca6d0897d5e8365f43bbb..e5eda43ad15fc2cb8d50564551d0c897411a2d89 100644 --- a/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp +++ b/Framework/WorkflowAlgorithms/src/EQSANSLoad.cpp @@ -231,7 +231,7 @@ void EQSANSLoad::readModeratorPosition(const std::string &line) { void EQSANSLoad::readSourceSlitSize(const std::string &line) { boost::regex re_key("wheel", boost::regex::icase); if (boost::regex_search(line, re_key)) { - boost::regex re_sig("([1-8]) wheel[ ]*([1-3])[ \\t]*=[ \\t]*(\\w+)"); + boost::regex re_sig(R"(([1-8]) wheel[ ]*([1-3])[ \t]*=[ \t]*(\w+))"); boost::smatch posVec; if (boost::regex_search(line, posVec, re_sig)) { if (posVec.size() == 4) { diff --git a/Framework/WorkflowAlgorithms/src/RefReduction.cpp b/Framework/WorkflowAlgorithms/src/RefReduction.cpp deleted file mode 100644 index 381da79c0b5259b6dec6b98a10f00f51cce364bf..0000000000000000000000000000000000000000 --- a/Framework/WorkflowAlgorithms/src/RefReduction.cpp +++ /dev/null @@ -1,817 +0,0 @@ -#include "MantidWorkflowAlgorithms/RefReduction.h" -#include "MantidAPI/AnalysisDataService.h" -#include "MantidGeometry/Instrument/DetectorInfo.h" -#include "MantidAPI/FileFinder.h" -#include "MantidAPI/MatrixWorkspace.h" -#include "MantidAPI/Run.h" -#include "MantidDataObjects/EventWorkspace.h" -#include "MantidGeometry/Instrument.h" -#include "MantidKernel/ArrayProperty.h" -#include "MantidKernel/ListValidator.h" -#include "MantidKernel/TimeSeriesProperty.h" -#include "MantidKernel/VisibleWhenProperty.h" - -#include "Poco/File.h" -#include "Poco/NumberFormatter.h" -#include "Poco/String.h" -#include <algorithm> - -namespace Mantid { -namespace WorkflowAlgorithms { - -// Register the algorithm into the AlgorithmFactory -DECLARE_ALGORITHM(RefReduction) - -const std::string RefReduction::PolStateOffOff("entry-Off_Off"); -const std::string RefReduction::PolStateOnOff("entry-On_Off"); -const std::string RefReduction::PolStateOffOn("entry-Off_On"); -const std::string RefReduction::PolStateOnOn("entry-On_On"); -const std::string RefReduction::PolStateNone("entry"); - -const int RefReduction::NX_PIXELS(304); -const int RefReduction::NY_PIXELS(256); -const double RefReduction::PIXEL_SIZE(0.0007); - -using namespace Kernel; -using namespace API; -using namespace Geometry; -using namespace DataObjects; - -void RefReduction::init() { - declareProperty("DataRun", "", "Run number of the data set to be reduced"); - declareProperty(make_unique<ArrayProperty<int>>("SignalPeakPixelRange"), - "Pixel range for the signal peak"); - - declareProperty( - "SubtractSignalBackground", false, - "If true, the background will be subtracted from the signal peak"); - declareProperty(make_unique<ArrayProperty<int>>("SignalBackgroundPixelRange"), - "Pixel range for background around the signal peak"); - - declareProperty( - "CropLowResDataAxis", false, - "If true, the low-resolution pixel range will be limited to the" - " range given by the LowResDataAxisPixelRange property"); - declareProperty(make_unique<ArrayProperty<int>>("LowResDataAxisPixelRange"), - "Pixel range for the signal peak in the low-res direction"); - - declareProperty("PerformNormalization", true, - "If true, the normalization will be performed"); - declareProperty("NormalizationRun", "", - "Run number of the normalization data set"); - declareProperty(make_unique<ArrayProperty<int>>("NormPeakPixelRange"), - "Pixel range for the normalization peak"); - - declareProperty("SubtractNormBackground", false, - "It true, the background will be subtracted" - " from the normalization peak"); - declareProperty(make_unique<ArrayProperty<int>>("NormBackgroundPixelRange"), - "Pixel range for background around the normalization peak"); - - declareProperty("CropLowResNormAxis", false, - "If true, the low-resolution pixel range" - " will be limited to be the range given by the " - "LowResNormAxisPixelRange property"); - declareProperty( - make_unique<ArrayProperty<int>>("LowResNormAxisPixelRange"), - "Pixel range for the normalization peak in the low-res direction"); - - declareProperty("Theta", EMPTY_DBL(), - "Scattering angle (takes precedence over meta data)"); - declareProperty("TOFMin", EMPTY_DBL(), "Minimum TOF cut"); - declareProperty("TOFMax", EMPTY_DBL(), "Maximum TOF cut"); - - declareProperty("TOFStep", 400.0, "Step size of TOF histogram"); - declareProperty("NBins", EMPTY_INT(), "Number of bins in TOF histogram " - "(takes precedence over TOFStep if " - "given)"); - - declareProperty("ReflectivityPixel", EMPTY_DBL()); - declareProperty("DetectorAngle", EMPTY_DBL()); - declareProperty("DetectorAngle0", EMPTY_DBL()); - declareProperty("DirectPixel", EMPTY_DBL()); - declareProperty("PolarizedData", true, "If true, the algorithm will look for " - "polarization states in the data set"); - setPropertySettings( - "ReflectivityPixel", - make_unique<VisibleWhenProperty>("Instrument", IS_EQUAL_TO, "REF_M")); - setPropertySettings("DetectorAngle", make_unique<VisibleWhenProperty>( - "Instrument", IS_EQUAL_TO, "REF_M")); - setPropertySettings( - "DetectorAngle0", - make_unique<VisibleWhenProperty>("Instrument", IS_EQUAL_TO, "REF_M")); - setPropertySettings("DirectPixel", make_unique<VisibleWhenProperty>( - "Instrument", IS_EQUAL_TO, "REF_M")); - - declareProperty("AngleOffset", EMPTY_DBL(), - "Scattering angle offset in degrees"); - setPropertySettings("AngleOffset", make_unique<VisibleWhenProperty>( - "Instrument", IS_EQUAL_TO, "REF_L")); - - std::vector<std::string> instrOptions{"REF_L", "REF_M"}; - declareProperty("Instrument", "REF_M", - boost::make_shared<StringListValidator>(instrOptions), - "Instrument to reduce for"); - declareProperty("OutputWorkspacePrefix", "reflectivity", - "Prefix to give the output workspaces"); - declareProperty("OutputMessage", "", Direction::Output); -} - -/// Execute algorithm -void RefReduction::exec() { - const std::string instrument = getProperty("Instrument"); - m_output_message = "------ " + instrument + " reduction ------\n"; - - // Process each polarization state - if (getProperty("PolarizedData")) { - processData(PolStateOffOff); - processData(PolStateOnOff); - processData(PolStateOffOn); - processData(PolStateOnOn); - } else { - processData(PolStateNone); - } - setPropertyValue("OutputMessage", m_output_message); -} - -MatrixWorkspace_sptr RefReduction::processData(const std::string polarization) { - m_output_message += "Processing " + polarization + '\n'; - const std::string dataRun = getPropertyValue("DataRun"); - IEventWorkspace_sptr evtWS = loadData(dataRun, polarization); - // wrong entry name - if (!evtWS) - return nullptr; - - MatrixWorkspace_sptr dataWS = - boost::dynamic_pointer_cast<MatrixWorkspace>(evtWS); - MatrixWorkspace_sptr dataWSTof = - boost::dynamic_pointer_cast<MatrixWorkspace>(evtWS); - - // If we have no events, stop here - if (evtWS->getNumberEvents() == 0) - return dataWS; - - // Get low-res pixel range - int low_res_min = 0; - int low_res_max = 0; - const bool cropLowRes = getProperty("CropLowResDataAxis"); - const std::vector<int> lowResRange = getProperty("LowResDataAxisPixelRange"); - if (cropLowRes) { - if (lowResRange.size() < 2) { - g_log.error() << "LowResDataAxisPixelRange parameter should be a vector " - "of two values\n"; - throw std::invalid_argument("LowResDataAxisPixelRange parameter should " - "be a vector of two values"); - } - low_res_min = lowResRange[0]; - low_res_max = lowResRange[1]; - m_output_message += " |Cropping low-res axis: [" + - Poco::NumberFormatter::format(low_res_min) + ", " + - Poco::NumberFormatter::format(low_res_max) + "]\n"; - } - - // Get peak range - const std::vector<int> peakRange = getProperty("SignalPeakPixelRange"); - if (peakRange.size() < 2) { - g_log.error() - << "SignalPeakPixelRange parameter should be a vector of two values\n"; - throw std::invalid_argument( - "SignalPeakPixelRange parameter should be a vector of two values"); - } - - // Get scattering angle in degrees - double theta = getProperty("Theta"); - const std::string instrument = getProperty("Instrument"); - const bool integrateY = instrument == "REF_M"; - - // Get pixel ranges in real pixels - int xmin = 0; - int xmax = 0; - int ymin = 0; - int ymax = 0; - if (integrateY) { - if (isEmpty(theta)) - theta = calculateAngleREFM(dataWS); - if (!cropLowRes) - low_res_max = NY_PIXELS - 1; - xmin = 0; - xmax = NX_PIXELS - 1; - ymin = low_res_min; - ymax = low_res_max; - } else { - if (isEmpty(theta)) - theta = calculateAngleREFL(dataWS); - if (!cropLowRes) - low_res_max = NX_PIXELS - 1; - ymin = 0; - ymax = NY_PIXELS - 1; - xmin = low_res_min; - xmax = low_res_max; - } - m_output_message += " |Scattering angle: " + - Poco::NumberFormatter::format(theta, 6) + " deg\n"; - - // Subtract background - if (getProperty("SubtractSignalBackground")) { - // Get background range - const std::vector<int> bckRange = getProperty("SignalBackgroundPixelRange"); - if (bckRange.size() < 2) { - g_log.error() << "SignalBackgroundPixelRange parameter should be a " - "vector of two values\n"; - throw std::invalid_argument("SignalBackgroundPixelRange parameter should " - "be a vector of two values"); - } - - IAlgorithm_sptr convAlg = - createChildAlgorithm("ConvertToMatrixWorkspace", 0.50, 0.55); - convAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - convAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", dataWS); - convAlg->executeAsChildAlg(); - - dataWS = - subtractBackground(dataWS, dataWS, peakRange[0], peakRange[1], - bckRange[0], bckRange[1], low_res_min, low_res_max); - m_output_message += " |Subtracted background [" + - Poco::NumberFormatter::format(bckRange[0]) + ", " + - Poco::NumberFormatter::format(bckRange[1]) + "]\n"; - } - - // Process normalization run - if (getProperty("PerformNormalization")) { - MatrixWorkspace_sptr normWS = processNormalization(); - IAlgorithm_sptr rebinAlg = - createChildAlgorithm("RebinToWorkspace", 0.50, 0.55); - rebinAlg->setProperty<MatrixWorkspace_sptr>("WorkspaceToRebin", normWS); - rebinAlg->setProperty<MatrixWorkspace_sptr>("WorkspaceToMatch", dataWS); - rebinAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", normWS); - rebinAlg->executeAsChildAlg(); - normWS = rebinAlg->getProperty("OutputWorkspace"); - - IAlgorithm_sptr divAlg = createChildAlgorithm("Divide", 0.55, 0.65); - divAlg->setProperty<MatrixWorkspace_sptr>("LHSWorkspace", dataWS); - divAlg->setProperty<MatrixWorkspace_sptr>("RHSWorkspace", normWS); - divAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", dataWS); - divAlg->executeAsChildAlg(); - - IAlgorithm_sptr repAlg = - createChildAlgorithm("ReplaceSpecialValues", 0.55, 0.65); - repAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - repAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", dataWS); - repAlg->setProperty("NaNValue", 0.0); - repAlg->setProperty("NaNError", 0.0); - repAlg->setProperty("InfinityValue", 0.0); - repAlg->setProperty("InfinityError", 0.0); - repAlg->executeAsChildAlg(); - m_output_message += "Normalization completed\n"; - } - - // // Integrate over Y - // IAlgorithm_sptr refAlg = createChildAlgorithm("RefRoi", 0.90, 0.95); - // refAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - // refAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - // refAlg->setProperty("NXPixel", NX_PIXELS); - // refAlg->setProperty("NYPixel", NY_PIXELS); - // refAlg->setProperty("YPixelMin", ymin); - // refAlg->setProperty("YPixelMax", ymax); - // refAlg->setProperty("XPixelMin", xmin); - // refAlg->setProperty("XPixelMax", xmax); - // refAlg->setProperty("IntegrateY", integrateY); - // refAlg->setProperty("ScatteringAngle", theta); - // refAlg->executeAsChildAlg(); - // - // // Convert back to TOF - // IAlgorithm_sptr convAlgToTof = createChildAlgorithm("ConvertUnits", - // 0.85, 0.90); - // convAlgToTof->setProperty<MatrixWorkspace_sptr>("InputWorkspace", - // dataWS); - // convAlgToTof->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", - // dataWSTof); - // convAlgToTof->setProperty("Target", "TOF"); - // convAlgToTof->executeAsChildAlg(); - // - // MatrixWorkspace_sptr outputWS2 = - // convAlgToTof->getProperty("OutputWorkspace"); - // declareProperty(new WorkspaceProperty<>("OutputWorkspace_jc_" + - // polarization, "TOF_"+polarization, Direction::Output)); - // setProperty("OutputWorkspace_jc_" + polarization, outputWS2); - - // integrated over Y and keep in lambda scale - IAlgorithm_sptr refAlg1 = createChildAlgorithm("RefRoi", 0.90, 0.95); - refAlg1->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - refAlg1->setProperty("NXPixel", NX_PIXELS); - refAlg1->setProperty("NYPixel", NY_PIXELS); - refAlg1->setProperty("ConvertToQ", false); - refAlg1->setProperty("YPixelMin", ymin); - refAlg1->setProperty("YPixelMax", ymax); - refAlg1->setProperty("XPixelMin", xmin); - refAlg1->setProperty("XPixelMax", xmax); - refAlg1->setProperty("IntegrateY", integrateY); - refAlg1->setProperty("ScatteringAngle", theta); - refAlg1->executeAsChildAlg(); - MatrixWorkspace_sptr outputWS2 = refAlg1->getProperty("OutputWorkspace"); - std::string polarizationTranslation(polarization); - std::replace(polarizationTranslation.begin(), polarizationTranslation.end(), - '-', '_'); - declareProperty(Kernel::make_unique<WorkspaceProperty<>>( - "OutputWorkspace_jc_" + polarizationTranslation, "Lambda_" + polarization, - Direction::Output)); - setProperty("OutputWorkspace_jc_" + polarizationTranslation, outputWS2); - - // Conversion to Q - IAlgorithm_sptr refAlg = createChildAlgorithm("RefRoi", 0.90, 0.95); - refAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", dataWS); - refAlg->setProperty("NXPixel", NX_PIXELS); - refAlg->setProperty("NYPixel", NY_PIXELS); - refAlg->setProperty("ConvertToQ", true); - - refAlg->setProperty("YPixelMin", ymin); - refAlg->setProperty("YPixelMax", ymax); - refAlg->setProperty("XPixelMin", xmin); - refAlg->setProperty("XPixelMax", xmax); - refAlg->setProperty("IntegrateY", integrateY); - refAlg->setProperty("ScatteringAngle", theta); - refAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr output2DWS = refAlg->getProperty("OutputWorkspace"); - std::vector<int> spectra; - for (int i = peakRange[0]; i < peakRange[1] + 1; i++) - spectra.push_back(i); - - IAlgorithm_sptr grpAlg = createChildAlgorithm("GroupDetectors", 0.95, 0.99); - grpAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", output2DWS); - grpAlg->setProperty("SpectraList", spectra); - grpAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr outputWS = grpAlg->getProperty("OutputWorkspace"); - - const std::string prefix = getPropertyValue("OutputWorkspacePrefix"); - if (polarization == PolStateNone) { - declareProperty(Kernel::make_unique<WorkspaceProperty<>>( - "OutputWorkspace", prefix, Direction::Output)); - setProperty("OutputWorkspace", outputWS); - declareProperty(Kernel::make_unique<WorkspaceProperty<>>( - "OutputWorkspace2D", "2D_" + prefix, Direction::Output)); - setProperty("OutputWorkspace2D", output2DWS); - } else { - std::string wsName = prefix + polarization; - Poco::replaceInPlace(wsName, "entry", ""); - declareProperty(Kernel::make_unique<WorkspaceProperty<>>( - "OutputWorkspace_" + polarizationTranslation, wsName, - Direction::Output)); - setProperty("OutputWorkspace_" + polarizationTranslation, outputWS); - declareProperty(Kernel::make_unique<WorkspaceProperty<>>( - "OutputWorkspace2D_" + polarizationTranslation, "2D_" + wsName, - Direction::Output)); - setProperty("OutputWorkspace2D_" + polarizationTranslation, output2DWS); - } - m_output_message += "Reflectivity calculation completed\n"; - return outputWS; -} - -MatrixWorkspace_sptr RefReduction::processNormalization() { - m_output_message += "Processing normalization\n"; - - const std::string normRun = getPropertyValue("NormalizationRun"); - IEventWorkspace_sptr evtWS = loadData(normRun, PolStateNone); - MatrixWorkspace_sptr normWS = - boost::dynamic_pointer_cast<MatrixWorkspace>(evtWS); - - const std::vector<int> peakRange = getProperty("NormPeakPixelRange"); - - int low_res_min = 0; - int low_res_max = 0; - int xmin = 0; - int xmax = 0; - int ymin = 0; - int ymax = 0; - - const bool cropLowRes = getProperty("CropLowResNormAxis"); - const std::vector<int> lowResRange = getProperty("LowResNormAxisPixelRange"); - if (cropLowRes) { - if (lowResRange.size() < 2) { - g_log.error() << "LowResNormAxisPixelRange parameter should be a vector " - "of two values\n"; - throw std::invalid_argument("LowResNormAxisPixelRange parameter should " - "be a vector of two values"); - } - low_res_min = lowResRange[0]; - low_res_max = lowResRange[1]; - m_output_message + " |Cropping low-res axis: [" + - Poco::NumberFormatter::format(low_res_min) + ", " + - Poco::NumberFormatter::format(low_res_max) + "]\n"; - } - - const std::string instrument = getProperty("Instrument"); - const bool integrateY = instrument == "REF_M"; - if (integrateY) { - if (!cropLowRes) - low_res_max = NY_PIXELS - 1; - xmin = peakRange[0]; - xmax = peakRange[1]; - ymin = low_res_min; - ymax = low_res_max; - } else { - if (!cropLowRes) - low_res_max = NX_PIXELS - 1; - ymin = peakRange[0]; - ymax = peakRange[1]; - xmin = low_res_min; - xmax = low_res_max; - } - - if (getProperty("SubtractNormBackground")) { - // Get background range - const std::vector<int> bckRange = getProperty("NormBackgroundPixelRange"); - if (bckRange.size() < 2) { - g_log.error() << "NormBackgroundPixelRange parameter should be a vector " - "of two values\n"; - throw std::invalid_argument("NormBackgroundPixelRange parameter should " - "be a vector of two values"); - } - - IAlgorithm_sptr convAlg = - createChildAlgorithm("ConvertToMatrixWorkspace", 0.50, 0.55); - convAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", normWS); - convAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", normWS); - convAlg->executeAsChildAlg(); - - normWS = - subtractBackground(normWS, normWS, peakRange[0], peakRange[1], - bckRange[0], bckRange[1], low_res_min, low_res_max); - m_output_message += " |Subtracted background [" + - Poco::NumberFormatter::format(bckRange[0]) + ", " + - Poco::NumberFormatter::format(bckRange[1]) + "]\n"; - } - IAlgorithm_sptr refAlg = createChildAlgorithm("RefRoi", 0.6, 0.65); - refAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", normWS); - refAlg->setProperty("NXPixel", NX_PIXELS); - refAlg->setProperty("NYPixel", NY_PIXELS); - refAlg->setProperty("ConvertToQ", false); - refAlg->setProperty("SumPixels", true); - refAlg->setProperty("NormalizeSum", true); - refAlg->setProperty("AverageOverIntegratedAxis", integrateY); - refAlg->setProperty("YPixelMin", ymin); - refAlg->setProperty("YPixelMax", ymax); - refAlg->setProperty("XPixelMin", xmin); - refAlg->setProperty("XPixelMax", xmax); - refAlg->setProperty("IntegrateY", integrateY); - refAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr outputNormWS = refAlg->getProperty("OutputWorkspace"); - return outputNormWS; -} - -IEventWorkspace_sptr RefReduction::loadData(const std::string dataRun, - const std::string polarization) { - const std::string instrument = getProperty("Instrument"); - - // Check whether dataRun refers to an existing workspace - // Create a good name for the raw workspace - std::string ws_name = "__ref_" + dataRun + "-" + polarization + "_raw"; - IEventWorkspace_sptr rawWS; - if (AnalysisDataService::Instance().doesExist(dataRun)) { - rawWS = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(dataRun); - g_log.notice() << "Found workspace: " << dataRun << '\n'; - m_output_message += " |Input data run is a workspace: " + dataRun + "\n"; - } else if (AnalysisDataService::Instance().doesExist(ws_name)) { - rawWS = AnalysisDataService::Instance().retrieveWS<EventWorkspace>(ws_name); - g_log.notice() << "Using existing workspace: " << ws_name << '\n'; - m_output_message += - " |Found workspace from previous reduction: " + ws_name + "\n"; - } else { - // If we can't find a workspace, find a file to load - std::string path = FileFinder::Instance().getFullPath(dataRun); - - if (path.empty() || !Poco::File(path).exists()) { - try { - std::vector<std::string> paths = - FileFinder::Instance().findRuns(instrument + dataRun); - path = paths[0]; - } catch (Exception::NotFoundError &) { /* Pass. We report the missing file - later. */ - } - } - - if (path.empty() || !Poco::File(path).exists()) { - try { - std::vector<std::string> paths = - FileFinder::Instance().findRuns(dataRun); - path = paths[0]; - } catch (Exception::NotFoundError &) { /* Pass. We report the missing file - later. */ - } - } - - if (Poco::File(path).exists()) { - g_log.notice() << "Found: " << path << '\n'; - m_output_message += " |Loading from " + path + "\n"; - IAlgorithm_sptr loadAlg = createChildAlgorithm("LoadEventNexus", 0, 0.2); - loadAlg->setProperty("Filename", path); - if (polarization != PolStateNone) - loadAlg->setProperty("NXentryName", polarization); - try { - loadAlg->executeAsChildAlg(); - } catch (...) { - g_log.notice() << "Could not load polarization " << polarization; - return nullptr; - } - - Workspace_sptr temp = loadAlg->getProperty("OutputWorkspace"); - rawWS = boost::dynamic_pointer_cast<IEventWorkspace>(temp); - if (rawWS->getNumberEvents() == 0) { - g_log.notice() << "No data in " << polarization << '\n'; - m_output_message += " |No data for " + polarization + "\n"; - return rawWS; - } - - // Move the detector to the right position - if (instrument == "REF_M") { - const auto &detInfo = rawWS->detectorInfo(); - const size_t detIndex0 = detInfo.indexOf(0); - double det_distance = detInfo.position(detIndex0).Z(); - auto dp = rawWS->run().getTimeSeriesProperty<double>("SampleDetDis"); - double sdd = dp->getStatistics().mean / 1000.0; - IAlgorithm_sptr mvAlg = - createChildAlgorithm("MoveInstrumentComponent", 0.2, 0.25); - mvAlg->setProperty<MatrixWorkspace_sptr>("Workspace", rawWS); - mvAlg->setProperty("ComponentName", "detector1"); - mvAlg->setProperty("Z", sdd - det_distance); - mvAlg->setProperty("RelativePosition", true); - mvAlg->executeAsChildAlg(); - g_log.notice() << "Ensuring correct Z position: Correction = " - << Poco::NumberFormatter::format(sdd - det_distance) - << " m\n"; - } - AnalysisDataService::Instance().addOrReplace(ws_name, rawWS); - } else { - g_log.error() << "Could not find a data file for " << dataRun << '\n'; - throw std::invalid_argument( - "Could not find a data file for the given input"); - } - } - - // Crop TOF as needed and set binning - double tofMin = getProperty("TOFMin"); - double tofMax = getProperty("TOFMax"); - if (isEmpty(tofMin) || isEmpty(tofMax)) { - const auto &x = rawWS->x(0); - if (isEmpty(tofMin)) - tofMin = *std::min_element(x.begin(), x.end()); - if (isEmpty(tofMax)) - tofMax = *std::max_element(x.begin(), x.end()); - } - - int nBins = getProperty("NBins"); - double tofStep = getProperty("TOFStep"); - if (!isEmpty(nBins)) - tofStep = (tofMax - tofMin) / nBins; - else - nBins = static_cast<int>(floor((tofMax - tofMin) / tofStep)); - - std::vector<double> params; - params.push_back(tofMin); - params.push_back(tofStep); - params.push_back(tofMax); - - IAlgorithm_sptr rebinAlg = createChildAlgorithm("Rebin", 0.25, 0.3); - rebinAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", rawWS); - rebinAlg->setProperty("Params", params); - rebinAlg->setProperty("PreserveEvents", true); - rebinAlg->executeAsChildAlg(); - MatrixWorkspace_sptr outputWS = rebinAlg->getProperty("OutputWorkspace"); - m_output_message += " |TOF binning: " + - Poco::NumberFormatter::format(tofMin) + " to " + - Poco::NumberFormatter::format(tofMax) + " in steps of " + - Poco::NumberFormatter::format(tofStep) + " microsecs\n"; - - // Normalise by current - IAlgorithm_sptr normAlg = - createChildAlgorithm("NormaliseByCurrent", 0.3, 0.35); - normAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", outputWS); - normAlg->executeAsChildAlg(); - outputWS = normAlg->getProperty("OutputWorkspace"); - - // Convert to wavelength - IAlgorithm_sptr convAlg = createChildAlgorithm("ConvertUnits", 0.35, 0.4); - convAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", outputWS); - convAlg->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", outputWS); - convAlg->setProperty("Target", "Wavelength"); - convAlg->executeAsChildAlg(); - - // Rebin in wavelength - const auto &x = outputWS->x(0); - double wlMin = *std::min_element(x.begin(), x.end()); - double wlMax = *std::max_element(x.begin(), x.end()); - - std::vector<double> wl_params; - wl_params.push_back(wlMin); - wl_params.push_back((wlMax - wlMin) / nBins); - wl_params.push_back(wlMax); - - IAlgorithm_sptr rebinAlg2 = createChildAlgorithm("Rebin", 0.25, 0.3); - rebinAlg2->setProperty<MatrixWorkspace_sptr>("InputWorkspace", outputWS); - rebinAlg2->setProperty<MatrixWorkspace_sptr>("OutputWorkspace", outputWS); - rebinAlg2->setProperty("Params", wl_params); - rebinAlg2->setProperty("PreserveEvents", true); - rebinAlg2->executeAsChildAlg(); - - IEventWorkspace_sptr outputEvtWS = - boost::dynamic_pointer_cast<IEventWorkspace>(outputWS); - return outputEvtWS; -} - -double RefReduction::calculateAngleREFM(MatrixWorkspace_sptr workspace) { - double dangle = getProperty("DetectorAngle"); - if (isEmpty(dangle)) { - Mantid::Kernel::Property *prop = workspace->run().getProperty("DANGLE"); - if (!prop) - throw std::runtime_error("DetectorAngle property not given as input, and " - "could not find the log entry DANGLE either"); - Mantid::Kernel::TimeSeriesProperty<double> *dp = - dynamic_cast<Mantid::Kernel::TimeSeriesProperty<double> *>(prop); - if (!dp) - throw std::runtime_error( - "The log entry DANGLE could not" - "be interpreted as a property of type time series of double"); - dangle = dp->getStatistics().mean; - } - - double dangle0 = getProperty("DetectorAngle0"); - if (isEmpty(dangle0)) { - Mantid::Kernel::Property *prop = workspace->run().getProperty("DANGLE0"); - if (!prop) - throw std::runtime_error("DetectorAngle0 property not given aas input, " - "and could not find the log entry DANGLE0 " - "either"); - Mantid::Kernel::TimeSeriesProperty<double> *dp = - dynamic_cast<Mantid::Kernel::TimeSeriesProperty<double> *>(prop); - if (!dp) - throw std::runtime_error( - "The log entry DANGLE0 could not " - "be interpreted as a property of type time series of double values"); - dangle0 = dp->getStatistics().mean; - } - - Mantid::Kernel::Property *prop = workspace->run().getProperty("SampleDetDis"); - Mantid::Kernel::TimeSeriesProperty<double> *dp = - dynamic_cast<Mantid::Kernel::TimeSeriesProperty<double> *>(prop); - if (!dp) - throw std::runtime_error("SampleDetDis was not a TimeSeriesProperty"); - const double det_distance = dp->getStatistics().mean / 1000.0; - - double direct_beam_pix = getProperty("DirectPixel"); - if (isEmpty(direct_beam_pix)) { - auto dp = workspace->run().getTimeSeriesProperty<double>("DIRPIX"); - direct_beam_pix = dp->getStatistics().mean; - } - - double ref_pix = getProperty("ReflectivityPixel"); - if (ref_pix == 0 || isEmpty(ref_pix)) { - const std::vector<int> peakRange = getProperty("SignalPeakPixelRange"); - if (peakRange.size() < 2) { - g_log.error() << "SignalPeakPixelRange parameter should be a vector of " - "two values\n"; - throw std::invalid_argument( - "SignalPeakPixelRange parameter should be a vector of two values"); - } - ref_pix = (peakRange[0] + peakRange[1]) / 2.0; - } - - double theta = - (dangle - dangle0) * M_PI / 180.0 / 2.0 + - ((direct_beam_pix - ref_pix) * PIXEL_SIZE) / (2.0 * det_distance); - - return theta * 180.0 / M_PI; -} - -double RefReduction::calculateAngleREFL(MatrixWorkspace_sptr workspace) { - auto dp = workspace->run().getTimeSeriesProperty<double>("ths"); - const double ths = dp->getStatistics().mean; - - dp = workspace->run().getTimeSeriesProperty<double>("tthd"); - const double tthd = dp->getStatistics().mean; - - double offset = getProperty("AngleOffset"); - if (isEmpty(offset)) - offset = 0.0; - return tthd - ths + offset; -} - -MatrixWorkspace_sptr RefReduction::subtractBackground( - MatrixWorkspace_sptr dataWS, MatrixWorkspace_sptr rawWS, int peakMin, - int peakMax, int bckMin, int bckMax, int lowResMin, int lowResMax) { - const std::string instrument = getProperty("Instrument"); - const bool integrateY = instrument == "REF_M"; - - int xmin = 0; - int xmax = 0; - int ymin = 0; - int ymax = 0; - if (integrateY) { - ymin = lowResMin; - ymax = lowResMax; - } else { - xmin = lowResMin; - xmax = lowResMax; - } - - // Look for overlap with data peak - if (bckMin < peakMin && bckMax > peakMax) { - // Background on the left - if (integrateY) { - xmin = bckMin; - xmax = peakMin - 1; - } else { - ymin = bckMin; - ymax = peakMin - 1; - } - IAlgorithm_sptr leftAlg = createChildAlgorithm("RefRoi", 0.6, 0.65); - leftAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", rawWS); - leftAlg->setProperty("NXPixel", NX_PIXELS); - leftAlg->setProperty("NYPixel", NY_PIXELS); - leftAlg->setProperty("ConvertToQ", false); - leftAlg->setProperty("SumPixels", true); - leftAlg->setProperty("NormalizeSum", true); - leftAlg->setProperty("AverageOverIntegratedAxis", integrateY); - leftAlg->setProperty("YPixelMin", ymin); - leftAlg->setProperty("YPixelMax", ymax); - leftAlg->setProperty("XPixelMin", xmin); - leftAlg->setProperty("XPixelMax", xmax); - leftAlg->setProperty("IntegrateY", integrateY); - leftAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr leftWS = leftAlg->getProperty("OutputWorkspace"); - - // Background on the right - if (integrateY) { - xmin = peakMax + 1; - xmax = bckMax; - } else { - ymin = peakMax + 1; - ymax = bckMax; - } - IAlgorithm_sptr rightAlg = createChildAlgorithm("RefRoi", 0.6, 0.65); - rightAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", rawWS); - rightAlg->setProperty("NXPixel", NX_PIXELS); - rightAlg->setProperty("NYPixel", NY_PIXELS); - rightAlg->setProperty("ConvertToQ", false); - rightAlg->setProperty("SumPixels", true); - rightAlg->setProperty("NormalizeSum", true); - rightAlg->setProperty("AverageOverIntegratedAxis", integrateY); - rightAlg->setProperty("YPixelMin", ymin); - rightAlg->setProperty("YPixelMax", ymax); - rightAlg->setProperty("XPixelMin", xmin); - rightAlg->setProperty("XPixelMax", xmax); - rightAlg->setProperty("IntegrateY", integrateY); - rightAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr rightWS = rightAlg->getProperty("OutputWorkspace"); - - // Average the two sides and subtract from peak - dataWS = dataWS - (leftWS + rightWS) / 2.0; - return dataWS; - - } else { - - // Check for overlaps - if (bckMax > peakMin && bckMax < peakMax) { - g_log.notice() << "Background range overlaps with peak\n"; - bckMax = peakMin - 1; - } - if (bckMin < peakMax && bckMin > peakMin) { - g_log.notice() << "Background range overlaps with peak\n"; - bckMin = peakMax + 1; - } - - if (integrateY) { - xmin = bckMin; - xmax = bckMax; - } else { - ymin = bckMin; - ymax = bckMax; - } - - IAlgorithm_sptr refAlg = createChildAlgorithm("RefRoi", 0.6, 0.65); - refAlg->setProperty<MatrixWorkspace_sptr>("InputWorkspace", rawWS); - refAlg->setProperty("NXPixel", NX_PIXELS); - refAlg->setProperty("NYPixel", NY_PIXELS); - refAlg->setProperty("ConvertToQ", false); - refAlg->setProperty("SumPixels", true); - refAlg->setProperty("NormalizeSum", true); - refAlg->setProperty("AverageOverIntegratedAxis", integrateY); - refAlg->setProperty("YPixelMin", ymin); - refAlg->setProperty("YPixelMax", ymax); - refAlg->setProperty("XPixelMin", xmin); - refAlg->setProperty("XPixelMax", xmax); - refAlg->setProperty("IntegrateY", integrateY); - refAlg->executeAsChildAlg(); - - MatrixWorkspace_sptr cropWS = refAlg->getProperty("OutputWorkspace"); - - dataWS = dataWS - cropWS; - return dataWS; - } -} - -} // namespace Algorithms -} // namespace Mantid diff --git a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h index 044e013d5764b5d0268098caa6e413ccf71c5b01..592fac50c42b58868b2dafc16f4149087169e173 100644 --- a/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h +++ b/Framework/WorkflowAlgorithms/test/ExtractQENSMembersTest.h @@ -178,7 +178,7 @@ private: createResultWorkspace(const std::vector<std::string> &members, const std::vector<double> &dataX) const { MatrixWorkspace_sptr resultWorkspace = - WorkspaceCreationHelper::create2DWorkspaceBinned( + WorkspaceCreationHelper::create2DWorkspaceNonUniformlyBinned( static_cast<int>(members.size()), static_cast<int>(dataX.size()), dataX.data()); diff --git a/MantidPlot/CMakeLists.txt b/MantidPlot/CMakeLists.txt index 14147fcf7c18fde969c2d50b0897df1be755348e..60cfcede842792ab7832b83c275e891d8792452b 100644 --- a/MantidPlot/CMakeLists.txt +++ b/MantidPlot/CMakeLists.txt @@ -740,7 +740,6 @@ copy_files_to_dir ( "${PY_FILES}" set( MTDPLOTPY_FILES __init__.py proxies.py - pyplot.py qtiplot.py ) copy_files_to_dir ( "${MTDPLOTPY_FILES}" @@ -893,7 +892,6 @@ set ( MANTIDPLOT_TEST_PY_FILES MantidPlotMdiSubWindowTest.py MantidPlotTiledWindowTest.py MantidPlotInputArgsCheck.py - MantidPlotPyplotGeneralTest.py ) if ( MAKE_VATES ) diff --git a/MantidPlot/mantidplot.py b/MantidPlot/mantidplot.py index af726851aca867f785646bcbed40dca11e647d8e..c038cd11e64a9c49fcb36b47f01cd46a75ae45d6 100644 --- a/MantidPlot/mantidplot.py +++ b/MantidPlot/mantidplot.py @@ -10,8 +10,5 @@ from __future__ import (absolute_import, division, import pymantidplot from pymantidplot import * -# import pyplot and also bring it into the standard MantidPlot namespace -import pymantidplot.pyplot -from pymantidplot.pyplot import * # and the old qtiplot stuff import pymantidplot.qtiplot diff --git a/MantidPlot/pymantidplot/pyplot.py b/MantidPlot/pymantidplot/pyplot.py deleted file mode 100644 index 00d2763ca14fab8b58293ae8ab27a45f77ff58a8..0000000000000000000000000000000000000000 --- a/MantidPlot/pymantidplot/pyplot.py +++ /dev/null @@ -1,1598 +0,0 @@ -"""============================================================================ -New Python command line interface for plotting in Mantid (a la matplotlib) -============================================================================ - -The idea behind this new module is to provide a simpler, more -homogeneous command line interface (CLI) to the Mantid plotting -functionality. This new interface is meant to resemble matplotlib as -far as possible, and to provide a more manageable, limited number of -plot options. - -The module is at a very early stage of development and provides -limited functionality. This is very much work in progress at the -moment. The module is subject to changes and feedback is very much -welcome! - -Simple plots can be created and manipulated with a handul of -commands. See the following examples. - -Plot an array (python list) ---------------------------- - -.. code-block:: python - - # plot array - plot([0.1, 0.3, 0.2, 4]) - # plot x-y - plot([0.1, 0.2, 0.3, 0.4], [1.2, 1.3, 0.2, 0.8]) - -Plot an array with a different style ------------------------------------- - -The plot commands that are described here accept a list of options -(kwargs) as parameters passed by name. With these options you can -modify plot properties, such as line styles, colors, axis scale, -etc. The following example illustrates the use of a few options. You -can refer to the list of options provided further down in this -document. In principle, any combination of options is supported, as -long as it makes sense! - -.. code-block:: python - - a = [0.1, 0.3, 0.2, 4] - plot(a) - import numpy as np - y = np.sin(np.linspace(-2.28, 2.28, 1000)) - plot(y, linestyle='-.', marker='o', color='red') - -If you have used the traditional Mantid command line interface in -Python you will probably remember the plotSpectrum, plotBin and plotMD -functions. These are supported in this new interface as shown in the -following examples. - -Plot a Mantid workspace ------------------------ - -You can pass one or more workspaces to the plot function. By default -it will plot the spectra of the workspace(s), selecting them by the -indices specified in the second argument. This behavior is similar to -the plotSpectrum function of the traditional mantidplot module. This is -a simple example that produces plots of spectra: - -.. code-block:: python - - # first, load a workspace. You can do this with a Load command or just from the GUI menus - ws = Load("/path/to/MAR11060.raw", OutputWorkspace="foo") - # 1 spectrum plot - plot(ws, 100) - # 3 spectra plot - plot(ws, [100, 101, 102]) - -======================== -Different types of plots -======================== - -The plot() function provides a unified interface to different types of -plots, including specific graphs of spectra, bins, multidimensional -workspaces, etc. These specific types of plots are explained in the -next sections. plot() makes a guess as to what tool to use to plot a -workspace. For example, if you pass an MD workspace it will make an MD -plot. But you can request a specific type of plot by specifying a -keyword argument ('tool'). The following tools (or different types of -plots) are supported: - -+------------------------+------------------------------------------------------------+-----------------------+ -| Tool | tool= parameter values (all are equivalent aliases) | Old similar function | -+========================+============================================================+=======================+ -| plot spectra (default) | 'plot_spectrum', 'spectrum', 'plot_sp', 'sp' | plotSpectrum | -+------------------------+------------------------------------------------------------+-----------------------+ -| plot bins | 'plot_bin', 'bin' | plotBin | -+------------------------+------------------------------------------------------------+-----------------------+ -| plot MD | 'plot_md', 'md' | plotMD | -+------------------------+------------------------------------------------------------+-----------------------+ - -The last column of the table lists the functions that produce similar -plots in the traditional MantidPlot Python plotting interface. For the -time being this module only supports these types of specific -plots. Note that the traditional plotting interface of MantidPlot -provides support for many more specific types of plots. These or -similar ones will be added in this module in future releases: - -* plot2D -* plot3D -* plotSlice -* instrumentWindow -* waterFallPlot -* mergePlots -* stemPlot - -Plot spectra using workspace objects and workspace names --------------------------------------------------------- - -It is also possible to pass workspace names to plot, as in the -following example where we plot a few spectra: - -.. code-block:: python - - # please make sure that you use the right path and file name - mar = Load('/path/to/MAR11060.raw', OutputWorkspace="MAR11060") - plot('MAR11060', [10,100,500]) - plot(mar,[3, 500, 800]) - -Let's load one more workspace so we can see some examples with list of -workspaces - -.. code-block:: python - - loq=Load('/path/to/LOQ48097.raw', OutputWorkspace="LOQ48097") - -The next lines are all equivalent, you can use workspace objects or -names in the list passed to plot: - -.. code-block:: python - - plot([mar, 'LOQ48097'], [800, 900]) - plot([mar, loq], [800, 900]) - plot(['MAR11060', loq], [800, 900]) - -Here, the plot function is making a guess and plotting the spectra of -these workspaces (instead of the bins or anything else). You can make -that choice more explicit by specifying the 'tool' argument. In this -case we use 'plot_spectrum' (which also has shorter aliases: -'spectrum', or simply 'sp' as listed in the table above): - -.. code-block:: python - - plot(['MAR11060', loq], [800, 900], tool='plot_spectrum') - plot(['MAR11060', loq], [801, 901], tool='sp') - -Alternatively, you can use the plot_spectrum command, which is -equivalent to the plot command with the keyword argument -tool='plot_spectrum': - -.. code-block:: python - - plot_spectrum(['MAR11060', loq], [800, 900]) - -Plotting bins -------------- - -To plot workspace bins you can use the keyword 'tool' with the value -'plot_bin' (or equivalent 'bin'), like this: - -.. code-block:: python - - ws = Load('/path/to/HRP39182.RAW', OutputWorkspace="HRP39182") - plot(ws, [1, 5, 7, 100], tool='plot_bin') - -or, alternatively, you can use the plot_bin command: - -.. code-block:: python - - plot_bin(ws, [1, 5, 7, 100], linewidth=4, linestyle=':') - -Plotting MD workspaces ----------------------- - -Similarly, to plot MD workspaces you can use the keyword 'tool' with -the value 'plot_md' (or 'md' as a short alias), like this: - -.. code-block:: python - - simple_md_ws = CreateMDWorkspace(Dimensions='3',Extents='0,10,0,10,0,10',Names='x,y,z',Units='m,m,m',SplitInto='5',MaxRecursionDepth='20',OutputWorkspace=MDWWorkspaceName) - plot(simple_md_ws, tool='plot_md') - -or a specific plot_md command: - -.. code-block:: python - - plot_md(simple_md_wsws) - -For simplicity, these examples use a dummy MD workspace. Please refer -to the Mantid (http://www.mantidproject.org/MBC_MDWorkspaces) for a -more real example, which necessarily gets more complicated and data -intensive. - -========================= -Changing style properties -========================= - -You can modify the style of your plots. For example like this (for a -full list of options currently supported, see below). - -.. code-block:: python - - lines = plot(loq, [100, 104], tool='plot_spectrum', linestyle='-.', marker='*', color='red') - -Notice that the plot function returns a list of lines, which -correspond to the spectra lines. At present the lines have limited -functionality. Essentially, the data underlying these lines can be -retrieved as follows: - -.. code-block:: python - - lines[0].get_xdata() - lines[0].get_ydata() - -If you use plot_spectrum, the number of elements in the output lines -should be equal to the number of bins in the corresponding -workspace. Conversely, if you use plot_bin, the number of elements in -the output lines should be equal to the number of spectra in the -workspace. - -To modify the figure, you first need to obtain the figure object -that represents the figure where the lines are displayed. Once you do -so you can for example set the title of the figure like this: - -.. code-block:: python - - fig = lines[0].figure() - fig.suptitle('Example figure title') - -Other properties can be modified using different functions, as in -matplotlib's pyplot. For example: - -.. code-block:: python - - title('Test plot of LOQ') - xlabel('ToF') - ylabel('Counts') - ylim(0, 8) - xlim(1e3, 4e4) - xscale('log') - grid('on') - -By default, these functions manipulate the current figure (the last or -most recently shown figure). You can also save the current figure into -a file like this: - -.. code-block:: python - - savefig('example_saved_figure.png') - -where the file format is guessed from the file extension. The same -extensions as in the MantidPlot figure export dialog are supported, -including jpg, png, tif, ps, and svg. - -The usage of these functions very similar to the matlab and/or -pyplot functions with the same names. The list of functions -currently supported is provided further below. - -Additional options supported as keyword arguments (kwargs): ------------------------------------------------------------ - -There is a couple of important plot options that are set as keyword -arguments: - - -+------------+------------------------+ -|Option name | Values supported | -+============+========================+ -|error_bars | True, False (default) | -+------------+------------------------+ -|hold | on, off | -+------------+------------------------+ - -error_bars has the same meaning as in the traditional mantidplot plot -functions: it defines whether error bars should be added to the -plots. hold has the same behavior as in matplotlib and pyplot. If the -value of hold is 'on' in a plot command, the new plot will be drawn on -top of the current plot window, without clearing it. This makes it -possible to make plots incrementally. - -For example, one can add two spectra from a workspace using the -following command: - -.. code-block:: python - - lines = plot(loq, [100, 102], linestyle='-.', color='red') - -But similar results can be obtained by plotting one of the spectra by -a first command, and then plotting the second spectra in a subsequent -command with the hold parameter enabled: - -.. code-block:: python - - lines = plot(loq, 100, linestyle='-.', color='red') - lines = plot(loq, 102, linestyle='-.', color='blue', hold='on') - -After the two commands above, any subsequent plot command that passes -hold='on' as a parameter would add new spectra into the same plot. An -alternative way of doing this is explained next. Note however that -using the hold property to combine different types of plots -(plot_spectrum, plot_bin, etc.) will most likely produce useless -results. - -Multi-plot commands -------------------- - -In this version of pyplot there is limited support for multi-plot -commands (as in pyplot and matlab). For example, you can type commands -like the following: - -.. code-block:: python - - plot(ws, [100, 101], 'r', ws, [200, 201], 'b', tool='plot_spectrum') - -This command will plot spectra 100 and 101 in red and spectra 200 and -201 in blue on the same figure. You can also combine different -workspaces, for example: - -.. code-block:: python - - plot(ws, [100, 101], 'r', mar, [50, 41], 'b', tool='plot_spectrum') - - -Style options supported as keyword arguments --------------------------------------------- - -Unless otherwise stated, these options are in principle supported in -all the plot variants. These options have the same (or as closed as -possible) meaning as in matplotlib. - -+------------+---------------------------------------------------------+ -|Option name | Values supported | -+============+=========================================================+ -|linewidth | real values | -+------------+---------------------------------------------------------+ -|linestyle | '-', '--', '-.' '.' | -+------------+---------------------------------------------------------+ -|marker | None/"None" 'o', 'v', '^', '<', '>', 's', '*', | -| | 'h', '|', '_' | -+------------+---------------------------------------------------------+ -|color | color character or string ('b', 'blue', 'g', 'green', | -| | 'k', 'black', 'y', 'yellow', 'c', 'cyan', 'r', 'red'. | -| | 'm', 'magenta', etc.). RGB colors are not supported at | -| | the moment. | -+------------+---------------------------------------------------------+ - -Modifying the plot axes ------------------------ - -You can modify different properties of the plot axes via functions, as -seen before. This includes the x and y axis titles, limits and scale -(linear or logarithmic). For example: - -.. code-block:: python - - ylabel('Counts') - ylim(0, 8) - yscale('log') - -An alternative is to use equivalent methods provided by the Figure and -Axes objects. For this you first need to retrieve the figure and axes -where a plot (or line) has been shown. - -.. code-block:: python - - lines = plot(mar,[3, 500, 800]) - fig = lines[0].figure() - all_ax = fig.axes() # fig.axes() returns in principle a list - ax = all_ax[0] # but we only use one axes - ax.set_ylabel('Counts') - ax.set_xlabel('ToF') - ax.set_ylim(0, 8) - ax.set_xlim(1e2, 4e4) - ax.set_xscale('log') - -Functions that modify plot properties -------------------------------------- - -Here is a list of the functions supported at the moment. They offer -the same functionality as their counterparts in matplotlib's -pyplot. - -- title -- xlabel -- ylabel -- ylim -- xlim -- axis -- xscale -- yscale -- grid -- savefig - -This is a limited list of functions that should be sufficient for -basic plots. These functions are presently provided as an example of -this type of interface, and some of them provide functionality similar -or equivalent to several of the keyword arguments for plot commands -detailed in this documentation. Some others produce results equivalent -to the more object oriented methods described above. For example, the -function xlabel is equivalent to the method set_xlabel applied on the -Axes object for the current figure. - -This module is by default imported into the standard MantidPlot -namespace. You can use the functions and classes included here without -any prefix or adding this module name prefix (pymantidplot.pyplot), as -in the following example: - -.. code-block:: python - - # Two equivalent lines: - pymantidplot.pyplot.plot([1, 3, 2]) - plot([1, 3, 2]) - -Note that the plot() function of this module has replaced the -traditional plot() function of MantidPlot which has been moved into a -package called qtiplot. To use it you can do as follows: - -.. code-block:: python - - pymantidplot.qtiplot.plot('MAR11060', [800, 801]) - # or if you prefer shorter prefixes: - import pymantidplot.qtiplot as qtiplt - qtiplt.plot('MAR11060', [800, 801]) - - -Below is the reference documentation of the classes and functions -included in this module. - -""" -# Copyright © 2014-2015 ISIS Rutherford Appleton Laboratory, NScD -# Oak Ridge National Laboratory & European Spallation Source -# -# This file is part of Mantid. -# Mantid is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 3 of the License, or -# (at your option) any later version. -# -# Mantid is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. -# -# File change history is stored at: <https://github.com/mantidproject/mantid>. -# Code Documentation is available at: <http://doxygen.mantidproject.org> -from __future__ import (absolute_import, division, - print_function) - -try: - import _qti -except ImportError: - raise ImportError('The \'mantidplot\' and \'pymantidplot.pyplot\' modules can only be used from within MantidPlot.') - -import numpy as np -from PyQt4 import Qt, QtGui, QtCore -from mantid.api import (IMDWorkspace as IMDWorkspace, MatrixWorkspace as MatrixWorkspace, AlgorithmManager as AlgorithmManager, AnalysisDataService as ADS) -from mantid.api import mtd -# return __is_workspace(arg) or (mantid.api.mtd.doesExist(arg) and isinstance(mantid.api.mtd[arg], mantid.api.IMDWorkspace)) -try: - from mantid.simpleapi import CreateWorkspace -except ImportError: - def CreateWorkspace(*args, **kwargs): - raise RuntimeError("CreateWorkspace function not available") - -import mantidplot -import mantidqtpython -from six import string_types - -class Line2D(): - """ - A very minimal replica of matplotlib.Line.Line2D. The true Line2D - is a sublcass of matplotlib.artist and provides tons of - functionality. At the moment this just provides get_xdata(), - get_ydata(), and figure() methods. It also holds its Graph - object and through it it would be possible to provide - additional selected functionality. Keep in mind that providing - GUI line/plot manipulation functionality would require a proxy - for this class. - """ - - def __init__(self, graph, index, x_data, y_data, fig=None): - self._graph = graph - self._index = index # will (may) be needed to change properties of this line - self._xdata = x_data - self._ydata = y_data - self._fig = fig - - def get_xdata(self): - return self._xdata - - def get_ydata(self): - return self._ydata - - def figure(self): - return self._fig - -class Axes(): - """ - A very minimal replica of matplotlib.axes.Axes. The true Axes is a - sublcass of matplotlib.artist and provides tons of functionality. - At the moment this just provides a few set methods for properties - such as labels and axis limits. - """ - - """Many plot manipulation functions that are provided in - matplolib through Axes objects, for example to manipulate the x/y - ticks, are not currently supported. Objects of this class hold - their Figure object. Presently every figure has a single Axes - object, and there is no support for multiple axes (as in - fig.add_axes() or fix.axes()). - """ - - def __init__(self, fig, xscale='linear', yscale='linear'): - self._fig = fig - # state of x and y scale kept here. C++ Graph.isLog() not yet exposed - self._xscale = xscale - self._yscale = yscale - - def axis(self, lims): - """ - Set the boundaries or limits of the x and y axes - - @param lims :: list or vector specifying min x, max x, min y, max y - """ - l = __last_fig()._graph.activeLayer() - if 4 != len(lims): - raise ValueError("Error: 4 real values are required for the x and y axes limits") - l.setScale(*lims) - - def set_xlabel(self, lbl): - """ - Set the label or title of the x axis - - @param lbl :: x axis lbl - """ - l = self.get_figure()._graph.activeLayer() - l.setXTitle(lbl) - - def set_ylabel(self, lbl): - """ - Set the label or title of the y axis - - @param lbl :: y axis lbl - """ - l = self.get_figure()._graph.activeLayer() - l.setYTitle(lbl) - - def set_xlim(self, xmin, xmax): - """ - Set the boundaries of the x axis - - @param xmin :: minimum value - @param xmax :: maximum value - """ - l = self.get_figure()._graph.activeLayer() - l.setAxisScale(2, xmin, xmax) - - def set_ylim(self, ymin, ymax): - """ - Set the boundaries of the y axis - - @param ymin :: minimum value - @param ymax :: maximum value - """ - l = self.get_figure()._graph.activeLayer() - l.setAxisScale(0, ymin, ymax) - - def set_xscale(self, scale_str): - """ - Set the type of scale of the x axis - - @param scale_str :: either 'linear' for linear scale or 'log' for logarithmic scale - """ - if 'log' != scale_str and 'linear' != scale_str: - raise ValueError("You need to specify either 'log' or 'linear' type of scale for the x axis." ) - - l = self.get_figure()._graph.activeLayer() - if scale_str == 'log': - if 'log' == self._yscale: - l.logLogAxes() - else: - l.logXLinY() - elif scale_str == 'linear': - if 'log' == self._yscale: - l.logYlinX() - else: - l.linearAxes() - self._xscale = scale_str - - def set_yscale(self, scale_str): - """ - Set the type of scale of the y axis - - @param scale_str :: either 'linear' for linear scale or 'log' for logarithmic scale - """ - if 'log' != scale_str and 'linear' != scale_str: - raise ValueError("You need to specify either 'log' or 'linear' type of scale for the y axis." ) - - l = self.get_figure()._graph.activeLayer() - if scale_str == 'log': - if 'log' == self._xscale: - l.logLogAxes() - else: - l.logYlinX() - elif scale_str == 'linear': - if 'log' == self._xscale: - l.logXLinY() - else: - l.linearAxes() - self._yscale = scale_str - - def get_figure(self, ): - """ - Get the figure where this Axes object is included - - Returns :: figure object for the figure that contains this Axes - """ - return self._fig - - -class Figure(): - """ - A very minimal replica of matplotlib.figure.Figure. This class is - here to support manipulation of multiple figures from the command - line. - """ - - """For the moment this is just a very crude wrapper for Graph - (proxy to qti Multilayer), and it is here just to hide (the rather - obscure) Graph from users. - """ - # Holds the set of figure ids (integers) as they're being created and/or destroyed - __figures = {} - # Always increasing seq number, not necessarily the number of figures in the dict - __figures_seq = 0 - - def __init__(self, num): - if isinstance(num, int): - # normal matplotlib use, like figure(2) - missing = -1 - fig = Figure.__figures.get(num, missing) - if missing == fig: - self._graph = Figure.__empty_graph() - Figure.__figures[num] = self - if num > Figure.__figures_seq: - Figure.__figures_seq = num - self._axes = Axes(self) - else: - if None == fig._graph._getHeldObject(): - # has been destroyed! - self._graph = Figure.__empty_graph() - self._axes = Axes(self) - else: - self._graph = fig._graph - self._axes = fig._axes - elif isinstance(num, mantidplot.proxies.Graph): - if None == num._getHeldObject(): - # deleted Graph! - self._graph = Figure.__empty_graph() - else: - self._graph = num - num = Figure.__make_new_fig_number() - Figure.__figures[num] = self - self._axes = Axes(self) - else: - raise ValueError("To create a Figure you need to specify a figure number or a Graph object." ) - - def suptitle(self, title): - """ - Set a title for the figure - - @param title :: title string - """ - l = self._graph.activeLayer() - l.setTitle(title) - - def axes(self): - """ - Obtain the list of axes in this figure. - - Returns :: list of axes. Presently only one Axes object is supported - and this method returns a single object list - """ - return [self._axes] - - def savefig(self, name): - """ - Save current plot into a file. The format is guessed from the file extension (.eps, .png, .jpg, etc.) - - @param name :: file name - """ - if not name: - raise ValueError("Error: you need to specify a non-empty file name") - l = self._graph.activeLayer() - l.export(name); - - @classmethod - def fig_seq(cls): - """ Helper method, returns the current sequence number for figures""" - return cls.__figures_seq - - @classmethod - def __make_new_fig_number(cls): - """ Helper method, creates and return a new figure number""" - num = cls.__figures_seq - avail = False - while not avail: - missing = -1 - fig = cls.__figures.get(num, missing) - if missing == fig: - avail = True # break - else: - num += 1 - cls.__figures_seq = num - return num - - @staticmethod - def __empty_graph(): - """Helper method, just create a new Graph with an 'empty' plot""" - lines = plot([0]) - return lines._graph - - -def __empty_fig(): - """Helper function, for the functional interface. Makes a blank/empty figure""" - lines = plot([0]) # for the very first figure, this would generate infinite recursion! - return Figure(lines[0]._graph) - -# TODO/TOTHINK: no 'hold' function support for now. How to handle multi-plots with different types/tools? Does it make sense at all? -__hold_status = False - -__last_shown_fig = None - -def __last_fig(): - """ - Helper function, especially for the functional interface. - Avoid using it inside the plot_spectrum, plot_bin, etc. as there's risk of infinite recursion - Returns :: last figure, creating new one if there was none - """ - global __last_shown_fig - if not __last_shown_fig: - f = __empty_fig() - __last_shown_fig = f - return __last_shown_fig - -def __update_last_shown_fig(g): - """ - Helper function, especially for the functional interface. - @param g :: graph object - Returns :: new last fig - """ - global __last_shown_fig - __last_shown_fig = Figure(g) - return __last_shown_fig - -def __is_array(arg): - """ - Is the argument a python or numpy list? - @param arg :: argument - - Returns :: True if the argument is a python or numpy list - """ - return isinstance(arg, list) or isinstance(arg, np.ndarray) - -def __is_array_or_int(arg): - """ - Is the argument a valid workspace index/indices, which is to say: - Is the argument an int, or python or numpy list? - @param arg :: argument - - Returns :: True if the argument is an integer, or a python or numpy list - """ - return isinstance(arg, int) or __is_array(arg) - - -def __is_registered_workspace_name(arg): - """" - Check whether the argument passed is the name of a registered workspace - - @param arg :: argument (supposedly a workspace name) - - Returns :: True if arg is a correct workspace name - """ - return (isinstance(arg, string_types) and mtd.doesExist(arg) and isinstance(mtd[arg], IMDWorkspace)) - -def __is_valid_single_workspace_arg(arg): - """" - Check whether the argument passed can be used as a workspace input. Note that this differs from - __is_workspace() in that workspace names are also accepted. Throws ValueError with informative - message if arg is not a valid workspace object or name. - - @param arg :: argument (supposedly one workspace, possibly given by name) - - Returns :: True if arg can be accepted as a workspace - """ - if __is_workspace(arg) or __is_registered_workspace_name(arg): - return True - else: - return False - -def __is_valid_workspaces_arg(arg): - """" - Check whether the argument passed can be used as a workspace(s) input. Note that this differs from - __is_workspace() in that lists of workspaces and workspace names are also accepted. - - @param arg :: argument (supposedly one or more workspaces, possibly given by name) - - Returns :: True if arg can be accepted as a workspace or a list of workspaces - """ - if __is_valid_single_workspace_arg(arg): - return True - else: - if 0 == len(arg): - return False - for name in arg: - # name can be a workspace name or a workspace object - try: - __is_valid_single_workspace_arg(name) - except: - raise ValueError("This parameter passed in a list of workspaces is not a valid workspace: " + str(name)) - return True - -def __is_data_pair(a, b): - """ - Are the two arguments passed (a and b) a valid data pair for plotting, like in plot(x, y) or - plot(ws, [0, 1, 2])? - @param a :: first argument passed (supposedly array or workspace(s)) - @param b :: second argument (supposedly an array of values, or indices) - - Returns :: True if the arguments can be used to plot something is an integer, or a python or numpy list - """ - res = (__is_array(a) and __is_array(b)) or (__is_valid_workspaces_arg(a) and __is_array_or_int(b)) - return res - -def __is_workspace(arg): - """ - Is the argument a Mantid MatrixWorkspace? - @param arg :: argument - - Returns :: True if the argument a MatrixWorkspace - """ - return isinstance(arg, MatrixWorkspace) - -def __is_array_of_workspaces(arg): - """ - Is the argument a sequence of Mantid MatrixWorkspaces? - @param arg :: argument - - Returns :: True if the argument is a sequence of MatrixWorkspace - """ - return __is_array(arg) and len(arg) > 0 and __is_workspace(arg[0]) - - -def __create_workspace(x, y, name="__array_dummy_workspace"): - """ - Create a workspace. Also puts it in the ADS with __ name - @param x :: x array - @param y :: y array - @param name :: workspace name - - Returns :: Workspace - """ - alg = AlgorithmManager.create("CreateWorkspace") - alg.setChild(True) - alg.initialize() - # fake empty workspace (when doing plot([]), cause setProperty needs non-empty data) - if [] == x: - x = [0] - if [] == y: - y = [0] - alg.setProperty("DataX", x) - alg.setProperty("DataY", y) - name = name + "_" + str(Figure.fig_seq()) - alg.setPropertyValue("OutputWorkspace", name) - alg.execute() - ws = alg.getProperty("OutputWorkspace").value - ADS.addOrReplace(name, ws) # Cannot plot a workspace that is not in the ADS - return ws - - -def __list_of_lines_from_graph(g, first_line=0): - """ - Produces a python list of line objects, with one object per line plotted on the passed graph - Note: at the moment these objects are of class Line2D which is much simpler than matplotlib.lines.Line2D - This function should always be part of the process of creating a new figure/graph, and it guarantees - that this figure being created is registered as the last shown figure. - - @param g :: graph (with several plot layers = qti Multilayer) - @param first_line :: index to start from (useful for hold='on', multi-plots, etc.) - - Returns :: List of line objects - """ - if None == g: - raise ValueError("Got empty Graph object, cannot get its lines." ) - # assume we use a single layer - active = g.activeLayer() - res = [] - for i in range(first_line, active.numCurves()): - x_data = [] - y_data = [] - d = active.curve(i).data() - for i in range(0, active.curve(i).data().size()): - x_data.append(d.x(i)) - y_data.append(d.y(i)) - res.append(Line2D(g, i, x_data, y_data)) - - fig = __update_last_shown_fig(g) - for lines in res: - lines._fig = fig - - return res; - -def __matplotlib_defaults(l): - """ - Tries to (approximately) mimic the default plot properties of a pylab.plot() - @param l :: layer (plot) from a mantidplot Graph object - - Returns :: nothing, just modifies properties of the layer passed - """ - if None == l: - raise ValueError("Got empty Layer object, cannot modify its properties." ) - l.removeLegend() - for i in range(0, l.numCurves()): - l.setCurveLineColor(i, __color_char_to_color_idx['b']) - l.setTitle(' ') - l.setXTitle(' ') - l.setYTitle(' ') - -__marker_to_plotsymbol = { - None: _qti.PlotSymbol.NoSymbol, "None": _qti.PlotSymbol.NoSymbol, - 'o': _qti.PlotSymbol.Ellipse, 'v': _qti.PlotSymbol.DTriangle, '^': _qti.PlotSymbol.UTriangle, - '<': _qti.PlotSymbol.LTriangle, '>': _qti.PlotSymbol.RTriangle, 's': _qti.PlotSymbol.Rect, - '*': _qti.PlotSymbol.Star1, 'h': _qti.PlotSymbol.Hexagon, '|': _qti.PlotSymbol.VLine, - '_': _qti.PlotSymbol.HLine -} - -"""Contains all the supported line styles""" -__linestyle_to_qt_penstyle = { - '-': QtCore.Qt.SolidLine, '--': QtCore.Qt.DashLine, - '-.': QtCore.Qt.DashDotLine, ':': QtCore.Qt.DotLine -} # other available: Qt.DashDotDotLine, Qt.CustomDashLine - -def __apply_linestyle(graph, linestyle, first_line=0): - """ - Sets the linestyle of lines/curves of the active layer of the graph passed - - @param graph :: mantidplot graph (figure) - @param linestyle :: linestyle string - @param first_line :: index of first line to which the linestyle will apply - (useful when in hold mode / adding lines) - - Returns :: nothing, just modifies the line styles of the active layer of the graph passed - """ - global __linestyle_to_qt_penstyle - wrong = 'inexistent' - penstyle = __linestyle_to_qt_penstyle.get(linestyle, wrong) - if wrong == penstyle: - raise ValueError("Wrong linestyle given, unrecognized: " + linestyle) - l = graph.activeLayer() - for i in range(first_line, l.numCurves()): - l.setCurveLineStyle(i, penstyle) - -# beware this is not Qt.Qt.color_name (black, etc.) -__color_char_to_color_idx = { - 'k': 0, 'r': 1, 'g': 2, 'b': 3, 'c': 4, 'm': 5, 'y': 18, - 'black': 0, 'red': 1, 'green': 2, 'blue': 3, 'cyan': 4, 'magenta': 5, 'orange': 6, - 'purple': 7, 'darkGreen': 8, 'darkBlue': 9, 'brown': 10, 'gray': 17, 'yellow': 18 -} - -def __apply_line_color(graph, c, first_line=0): - """ - Sets the color of curves of the active layer of the graph passed - - @param graph :: mantidplot graph (figure) - @param c :: color string - @param first_line :: index of first line to which the color will apply - (useful when in hold mode / adding lines) - - Returns :: nothing, just modifies the line styles of the active layer of the graph passed - """ - inex = 'inexistent' - col_idx = __color_char_to_color_idx.get(c, inex) - if inex == col_idx: - col_idx = QtGui.QColor(c) - l = graph.activeLayer() - for i in range(first_line, l.numCurves()): - l.setCurveLineColor(i, col_idx) # beware this is not Qt.Qt.black, but could be faked with QtGui.QColor("orange") - -def __apply_marker(graph, marker, first_line=0): - """ - Sets the marker of curves of the active layer of the graph passed - - @param graph :: mantidplot graph (figure) - @param marker :: line marker character - @param first_line :: index of first line to which the color will apply - (useful when in hold mode / adding lines) - - Returns :: nothing - """ - wrong = 'inexistent' - sym_code = __marker_to_plotsymbol.get(marker, wrong) - if wrong == sym_code: - raise ValueError("Warning: unrecognized marker: " + str(marker)) - sym = _qti.PlotSymbol(sym_code, QtGui.QBrush(), QtGui.QPen(), QtCore.QSize(5,5)) - l = graph.activeLayer() - for idx in range(first_line, l.numCurves()): - l.setCurveSymbol(idx, sym) - -def __is_marker(char): - """ Is it a marker character - @param char :: suspected marker character coming from a linestyle string - Returns :: True if it's a marker character - """ - inex = 'inexistent' - m = __marker_to_plotsymbol.get(char, inex) - return m != inex - -__linestyle_to_qt_penstyle = { - '-': QtCore.Qt.SolidLine, '--': QtCore.Qt.DashLine, - '-.': QtCore.Qt.DashDotLine, ':': QtCore.Qt.DotLine -} # other available: Qt.DashDotDotLine, Qt.CustomDashLine - -def __is_linestyle(stl, i): - """ - Check if we have a linestyle string in string s at position i - @param stl :: input (style) string, for example: '-.g', 'r', ':b' - @param i :: index where to start checking in string s - - Returns :: 0 if no linestyle string is identified, length of the string (1 or 2) otherwise - """ - global __linestyle_to_qt_penstyle - - if len(stl) <= i: - return 0 - - if len(stl) > i+1: - if '-' == stl[i+1] or '.' == stl[i+1]: - # can check 2 chars - wrong = 'inexistent' - penstyle = __linestyle_to_qt_penstyle.get(stl[i:i+2], wrong) - if wrong != penstyle: - return 2 - - if '-'==stl[i] or ':'==stl[i]: - return 1 - else: - return 0 - -def __apply_plot_args(graph, first_line, *args): - """ - Applies args, like '-r' etc. - @param graph :: a graph (or figure) that can contain multiple layers - @param first_line :: first line to which the options will apply (useful when in hold mode / adding lines) - @param args :: plot arguments - - Returns :: nothing, just uses kwargs to modify properties of the layer passed - """ - if None==graph or len(args) < 1 or ((),) == args: - return - - for a in args: - if isinstance(a, string_types): - # this will eat characters as they come, without minding much the past/previous characters - # users can chain as many modifiers as they wish. It could be modified to be more strict/picky - i = 0 - while i < len(a): - linestyle_len = __is_linestyle(a,i) - if linestyle_len > 0: - __apply_linestyle(graph, a[i:i+linestyle_len], first_line) - i += linestyle_len - elif __is_marker(a[i]): - __apply_marker(graph, a[i:], first_line) - i += 1 - elif a[i].isalpha(): - __apply_line_color(graph, a[i], first_line) - i += 1 - else: - # TOTHINK - error here? like this? sure? or just a warning? - raise ValueError("Unrecognized character in input string: " + str(a[i])) - else: - raise ValueError("Expecting style string, but got an unrecognized input parameter: " + str(a) + ", of type: " + str(type(a))) - -def __apply_plot_kwargs(graph, first_line=0, **kwargs): - """ - Applies kwargs - @param graph :: a graph (or figure) that can contain multiple layers - - Returns :: nothing, just uses kwargs to modify properties of the layer passed - """ - if None==graph or None==kwargs or ((),) == kwargs: - return - - for key in kwargs: - if 'linestyle' == key: - __apply_linestyle(graph, kwargs[key]) - - elif 'linewidth' == key: - l = graph.activeLayer() - for i in range(first_line, l.numCurves()): - l.setCurveLineWidth(i, kwargs[key]) - - elif 'color' == key: - __apply_line_color(graph, kwargs[key], first_line) - - elif 'marker' == key: - __apply_marker(graph, kwargs[key], first_line) - -def __is_multiplot_command(*args, **kwargs): - """ - Finds out if the passed *args make a valid multi-plot command. At the same time, splits the - multi-plot command line into individual plot commands. - - @param args :: curve data and options. - @param kwargs :: plot keyword options - - Returns :: tuple: (boolean: whether it is a multiplot command, list of single plot commands as tuples) - """ - # A minimum multi-plot command would be plot(x, y, z, w) or plot(ws1, idx1, ws2, idx2) - nargs = len(args) - # this will be a list with the sequence of individual plots (a tuples, each describing a single plot) - plots_seq = [] - if nargs < 4: - return (False, []) - i = 0 - while i < nargs: - a = [] - b = [] - style = '' - if (nargs-i) >= 3: - if __is_data_pair(args[i], args[i+1]): - a = args[i] - b = args[i+1] - i += 2 - else: - return (False, []); - # can have style string, but don't get confused with single workspace name strings! - if (not __is_registered_workspace_name(args[i])) and isinstance(args[i], string_types): - style = args[i] - i += 1 - plots_seq.append((a,b,style)) - - elif (nargs-i) >= 2: - if __is_data_pair(args[i], args[i+1]): - a = args[i] - b = args[i+1] - i += 2 - else: - return (False, []) - plots_seq.append((a, b, '')) - - elif (nargs-i) > 0: - raise ValueError("Not plottable. I do not know what to do with this last parameter: " + args[i] + ", of type " + str(type(args))) - - return (i == nargs, plots_seq) - -def __process_multiplot_command(plots_seq, **kwargs): - """ - Make one plot at a time when given a multi-plot command. - - @param plots_seq :: list of individual plot parameters - @param kwargs :: plot style options - - Returns :: the list of curves included in the plot - """ - lines = [] - if len(plots_seq) >= 1: - if not 'hold' in kwargs: - kwargs['hold'] = 'off' - lines = plot(*(plots_seq[0]), **kwargs) - for i in range(1, len(plots_seq)): - kwargs['hold'] = 'on' - lines.extend(plot(*(plots_seq[i]), **kwargs)) - return lines - -def __translate_hold_kwarg(**kwargs): - """ - Helper function to translate from hold='on'/'off' kwarg to a True/False value for the - mantidplot window and window error_bars - - @param kwargs :: keyword arguments passed to a plot function, this function only cares about hold. Any - value different from 'on' will be considered as 'off' - - Returns :: tuple with a couple of values: True/False value for window, and True/False for clearWindow, - to be used with plotSpectrum, plotBin, etc. - """ - # window and clearWindow - window_val = None - clearWindow_val = False - hold_name = 'hold' - missing_off = -1 - str_val = kwargs.get(hold_name, missing_off) - if str_val != missing_off and str_val == 'on': - if None == __last_shown_fig: - window_val = None - else: - window_val = __last_fig()._graph - clearWindow_val = False - - return window_val, clearWindow_val - -def __translate_error_bars_kwarg(**kwargs): - """ - Helper function to translate from error_bars=True/False kwarg to a True/False value for the - mantidplot error_bars argument - - @param kwargs :: keyword arguments passed to a plot function. This function only cares about 'error_bars'. - Any value different from 'True' will be considered as 'False' - - Returns :: True/False value for error_bars, to be used with plotSpectrum, plotBin, etc. - - """ - # error_bars param - bars_val = False - bars_name = 'error_bars' - missing_off = -1 - str_val = kwargs.get(bars_name, missing_off) - if str_val != missing_off and str_val == 'True': - bars_val = True - - return bars_val - -def __translate_distribution_kwarg(**kwargs): - """ - Helper function to translate from distribution=DistributionDefault/DistributionTrue/DistributionFalse kwarg to a - mantidplot distribution argument - - @param kwargs :: keyword arguments passed to a plot function. This function only cares about 'distribution'. - - Returns :: DistributionDefault/DistributionTrue/DistributionFalse value for distribution, to be used with plotSpectrum, plotBin, etc. - - """ - # distribution param - distr_val = False - distr_name = 'distribution' - missing_off = mantidqtpython.MantidQt.DistributionDefault - str_val = kwargs.get(distr_name, missing_off) - if str_val != missing_off and str_val == 'DistributionTrue': - distr_val = mantidqtpython.DistributionTrue - elif str_val != missing_off and str_val == 'DistributionFalse': - distr_val = mantidqtpython.DistributionFalse - - return distr_val - -def __plot_as_workspace(*args, **kwargs): - """ - plot spectrum via qti plotting framework to plot a workspace. - - @param args :: curve data and options. - @param kwargs :: plot line options - - Returns :: List of line objects - """ - return plot_spectrum(*args, **kwargs) - -def __plot_as_workspaces_list(*args, **kwargs): - """ - Plot a series of workspaces - @param args :: curve data and options. - @param kwargs :: plot line options - - Returns :: List of line objects - """ - # mantidplot.plotSpectrum can already handle 1 or more input workspaces. - return __plot_as_workspace(*args, **kwargs) - - -def __plot_as_array(*args, **kwargs): - """ - Plot from an array - @param args :: curve data and options. - @param kwargs :: plot line options - - Returns :: the list of curves (1) included in the plot - """ - y = args[0] - idx_style = len(args) # have to guess if we get plot(x,'r'), or plot(x, y, 'r') or no style string - if len(args) > 1: - if __is_array(args[1]): - ws = __create_workspace(y, args[1]) - idx_style = 2 - elif isinstance(args[1], string_types): - x = list(range(0, len(y), 1)) # 0 to n, incremented by 1. - ws = __create_workspace(x, y) - # have to assume that args[1] is a style string - idx_style = 1 - else: - raise ValueError("Inputs are of type: " + str(type(args)) + ". Not plottable." ) - else: - x = list(range(0, len(y), 1)) - ws = __create_workspace(x, y) - - lines = __plot_as_workspace(ws, [0], *args[idx_style:], **kwargs) - graph = None - if len(lines) > 0: - graph = lines[0]._graph - else: - raise Exception("Could not plot a workspace: " + ws) - # something to improve: if the C++ Graph class provided a plot1D that doesn't do show(), so that - # we could modify properties behind the scene and at the end do the show(). Con: do we really need - # to load the qti layer with more methods because of outer layers like here? - if 0 == len(kwargs): - __matplotlib_defaults(graph.activeLayer()) - return __list_of_lines_from_graph(graph) - -def __plot_with_tool(tool, *args, **kwargs): - bin_tool_names = ['plot_bin', 'bin'] - spectrum_tool_names = ['plot_spectrum', 'plot_sp', 'spectrum', 'sp'] - md_tool_names = ['plot_md', 'md'] - - if len(args) < 2: - if tool in bin_tool_names: - raise ValueError("To plot bins (using '%s' as tool) you need to give at least two parameters, where the second parameter selects the bins"%tool) - elif tool in spectrum_tool_names: - raise ValueError("To plot spectra (using '%s' as tool) you need to give at least two parameters, where the second parameter selects the spectrum(a)"%tool) - - if tool in bin_tool_names: - return plot_bin(args[0], args[1], *args[2:], **kwargs) - elif tool in md_tool_names: - return plot_md(args[0], *args[1:], **kwargs) - elif tool in spectrum_tool_names: - return plot_spectrum(args[0], args[1], *args[2:], **kwargs) - # here you would add slice/spectrum/instrument viewer, etc. and maybe you'll want to put them in a dict - else: - raise ValueError("Unrecognized tool specified: '" + tool + ";. Cannot plot this. ") - -def __plot_with_best_guess(*args, **kwargs): - y = args[0] - if __is_array(y): - if __is_array_of_workspaces(y): - return __plot_as_workspaces_list(*args, **kwargs) - else: - return __plot_as_array(*args, **kwargs) - else: - # mantidplot.plotSpectrum can handle workspace names (strings) - return __plot_as_workspace(*args, **kwargs) - -def plot_bin(workspaces, indices, *args, **kwargs): - """ - X-Y plot of the bin counts in a workspace. - - Plots one or more bin, selected by indices, using spectra numbers as x-axis and bin counts for - each spectrum as y-axis. - - @param workspaces :: workspace or list of workspaces (both workspace objects and names accepted) - @param indices :: indices of the bin(s) to plot - - Returns :: the list of curves included in the plot - """ - # Find optional params to plotBin - bars_val = __translate_error_bars_kwarg(**kwargs) - window_val, clearWindow_val = __translate_hold_kwarg(**kwargs) - - # to change properties on the new lines being added - first_line = 0 - if None != window_val: - first_line = window_val.activeLayer().numCurves() - - graph = mantidplot.plotBin(workspaces, indices, error_bars=bars_val, type=-1, window=window_val, clearWindow=clearWindow_val) - - __apply_plot_args(graph, first_line, *args) - __apply_plot_kwargs(graph, first_line, **kwargs) - - return __list_of_lines_from_graph(graph, first_line) - - -def plot_md(workspaces, *args, **kwargs): - """ - X-Y plot of an MDWorkspace. - - @param workspaces :: workspace or list of workspaces (both workspace objects and names accepted) - - Returns :: the list of curves included in the plot - """ - # Find optional params to plotBin - bars_val = __translate_error_bars_kwarg(**kwargs) - window_val, clearWindow_val = __translate_hold_kwarg(**kwargs) - - # to change properties on the new lines being added - first_line = 0 - if None != window_val: - first_line = window_val.activeLayer().numCurves() - - graph = mantidplot.plotMD(workspaces, normalization=mantidplot.DEFAULT_MD_NORMALIZATION, error_bars=bars_val, window=window_val, clearWindow=clearWindow_val) - - __apply_plot_args(graph, first_line, *args) - __apply_plot_kwargs(graph, first_line, **kwargs) - - return __list_of_lines_from_graph(graph, first_line) - - -def plot_spectrum(workspaces, indices, *args, **kwargs): - """X-Y Plot of spectra in a workspace. - - Plots one or more spectra, selected by indices, using bin boundaries as x-axis - and the spectra values in each bin as y-axis. - - @param workspaces :: workspace or list of workspaces (both workspace objects and names accepted) - @param indices :: indices of the spectra to plot, given as a single integer or a list of integers - - Returns :: the list of curves included in the plot - - """ - # Find optional params to plotSpectrum - bars_val = __translate_error_bars_kwarg(**kwargs) - distr_val = __translate_distribution_kwarg(**kwargs) - window_val, clearWindow_val = __translate_hold_kwarg(**kwargs) - - # to change properties on the new lines being added - first_line = 0 - if None != window_val: - first_line = window_val.activeLayer().numCurves() - - graph = mantidplot.plotSpectrum(workspaces, indices, error_bars=bars_val, type=-1, window=window_val, clearWindow=clearWindow_val) - - __apply_plot_args(graph, first_line, *args) - __apply_plot_kwargs(graph, first_line, **kwargs) - - return __list_of_lines_from_graph(graph, first_line) - - -def plot(*args, **kwargs): - """ - Plot the data in various forms depending on what arguments are passed. Currently supported - inputs: arrays (as Python lists or numpy arrays) and workspaces (by name or workspace objects). - - @param args :: curve data and options - @param kwargs :: plot line options - - Returns :: the list of curves included in the plot - - args can take different forms depending on what you plot. You can plot: - - * a python list or array (x) for example like this: plot(x) - - * a workspace (ws) for example like this: plot(ws, [100,101]) # this will plot spectra 100 and 101 - - * a list of workspaces (ws, ws2, ws3, etc.) for example like this: plot([ws, ws2, ws3], [100,101]) - - * workspaces identified by their names: plot(['HRP39182', 'MAR11060.nxs'], [100,101]) - - You can also pass matplotlib/pyplot style strings as arguments, for example: plot(x, '-.') - - As keyword arguments (kwargs) you can specify multiple - parameters, for example: linewidth, linestyle, marker, color. - - An important keyword argument is tool. At the moment the - following values are supported (they have long and short aliases): - - * To plot spectra: 'plot_spectrum' OR 'spectrum' OR 'plot_sp' OR 'sp' (default for workspaces). - * To plot bins: 'plot_bin' OR 'bin' - * To do an MD plot: 'plot_md' OR 'md' - - Please see the documentation of this module (use help()) for more details. - - """ - nargs = len(args) - if nargs < 1: - raise ValueError("You did not pass any argument. You must provide data to plot.") - - # TOTHINK: should there be an exception if it's plot_md (tool='plot_md') - (is_it, plots_seq) = __is_multiplot_command(*args, **kwargs) - if is_it: - return __process_multiplot_command(plots_seq, **kwargs) - elif len(args) > 3: - raise ValueError("Could not interpret the arguments passed. You passed more than 3 positional arguments but this does not seem to be a correct multi-plot command. Please check your command and make sure that the workspaces given are correct.") - - # normally guess; exception if e.g. a parameter tool='plot_bin' is given - try: - tool_val = kwargs['tool'] - del kwargs['tool'] - return __plot_with_tool(tool_val, *args, **kwargs) - except KeyError: - return __plot_with_best_guess(*args, **kwargs) - - -#============================================================================= -# Functions, for pyplot / old matlab style manipulation of figures -#============================================================================= - -def xlim(xmin, xmax): - """ - Set the boundaries of the x axis - - @param xmin :: minimum value - @param xmax :: maximum value - """ - l = __last_fig()._graph.activeLayer() - l.setAxisScale(2, xmin, xmax) - -def ylim(ymin, ymax): - """ - Set the boundaries of the y axis - - @param ymin :: minimum value - @param ymax :: maximum value - """ - l = __last_fig()._graph.activeLayer() - l.setAxisScale(0, ymin, ymax) - -def xlabel(lbl): - """ - Set the label or title of the x axis - - @param lbl :: x axis lbl - """ - l = __last_fig()._graph.activeLayer() - l.setXTitle(lbl) - -def ylabel(lbl): - """ - Set the label or title of the y axis - - @param lbl :: y axis lbl - """ - l = __last_fig()._graph.activeLayer() - l.setYTitle(lbl) - -def title(title): - """ - Set title of the active plot - - @param title :: title string - """ - l = __last_fig()._graph.activeLayer() - l.setTitle(title) - -def axis(lims): - """ - Set the boundaries or limits of the x and y axes - - @param lims :: list or vector specifying min x, max x, min y, max y - """ - l = __last_fig()._graph.activeLayer() - if 4 != len(lims): - raise ValueError("Error: 4 real values are required for the x and y axes limits") - l.setScale(*lims) - -def yscale(scale_str): - """ - Set the type of scale of the y axis - - @param scale_str :: either 'linear' for linear scale or 'log' for logarithmic scale - """ - ax = __last_fig()._axes - ax.set_yscale(scale_str) - -def xscale(scale_str): - """ - Set the type of scale of the x axis - - @param scale_str :: either 'linear' for linear scale or 'log' for logarithmic scale - """ - ax = __last_fig()._axes - ax.set_xscale(scale_str) - -def grid(opt='on'): - """ - Enable a grid on the active plot (horizontal and vertical) - - @param title :: 'on' to enable - """ - l = __last_fig()._graph.activeLayer() - if None == opt or 'on' == opt: - l.showGrid() - elif 'off' == opt: - # TODO is there support for a 'hideGrid' in qti? Apparently not. - print("Sorry, hiding/disabling grids is currenlty not supported") - -def figure(num=None): - """ - Return Figure object for a new figure or an existing one (if there is any - with the number passed as parameter). - - @param num :: figure number (optional). If empty, a new figure is created. - """ - if not num: - return __empty_fig() - else: - if num < 0: - raise ValueError("The figure number must be >= 0") - - return Figure(num) - -def savefig(name): - """ - Save current plot into a file. The format is guessed from the file extension (.eps, .png, .jpg, etc.) - - @param name :: file name - """ - if not name: - raise ValueError("Error: you need to specify a non-empty file name") - l = __last_fig()._graph.activeLayer() - l.export(name); diff --git a/MantidPlot/pymantidplot/qtiplot.py b/MantidPlot/pymantidplot/qtiplot.py index e3848d12bac53e7a198bb6c087e421a9b8f2b033..0c2af7a2968eef770c8d36a72b9041e3b74bb858 100644 --- a/MantidPlot/pymantidplot/qtiplot.py +++ b/MantidPlot/pymantidplot/qtiplot.py @@ -19,9 +19,6 @@ from PyQt4 import QtCore #----------------------------------------------------------------------------- # Intercept qtiplot "plot" command and forward to plotSpectrum for a workspace -# -# This function has been moved inside qtiplot when pymantidplot.pyplot (which -# has another plot() function) was imported into the standard MantidPlot namespace def plot(source, *args, **kwargs): """Create a new plot given a workspace, table or matrix. diff --git a/MantidPlot/src/ApplicationWindow.cpp b/MantidPlot/src/ApplicationWindow.cpp index 04133721a85cc01cfca2b1872dec68a8937e2c72..0da334bba9ee7ea4832ed9f94e0929c956004f10 100644 --- a/MantidPlot/src/ApplicationWindow.cpp +++ b/MantidPlot/src/ApplicationWindow.cpp @@ -2446,7 +2446,7 @@ Graph3D *ApplicationWindow::dataPlot3D(const QString &caption, posX = formula.indexOf("(", pos); QString yCol = formula.mid(pos + 1, posX - pos - 1); - Graph3D *plot = new Graph3D("", this, 0); + Graph3D *plot = new Graph3D("", this, nullptr); plot->addData(w, xCol, yCol, xl, xr, yl, yr, zl, zr); plot->update(); @@ -2466,7 +2466,7 @@ Graph3D *ApplicationWindow::newPlot3D() { QString label = generateUniqueName(tr("Graph")); - Graph3D *plot = new Graph3D("", this, 0); + Graph3D *plot = new Graph3D("", this, nullptr); plot->setWindowTitle(label); plot->setName(label); @@ -2486,7 +2486,7 @@ Graph3D *ApplicationWindow::plotXYZ(Table *table, const QString &zColName, QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - Graph3D *plot = new Graph3D("", this, 0); + Graph3D *plot = new Graph3D("", this, nullptr); QString label = generateUniqueName(tr("Graph")); plot->setWindowTitle(label); plot->setName(label); @@ -2531,7 +2531,7 @@ Graph3D *ApplicationWindow::openPlotXYZ(const QString &caption, int yCol = w->colIndex(yColName); int zCol = w->colIndex(zColName); - Graph3D *plot = new Graph3D("", this, 0); + Graph3D *plot = new Graph3D("", this, nullptr); plot->loadData(w, xCol, yCol, zCol, xl, xr, yl, yr, zl, zr); QString label = caption; @@ -2584,7 +2584,7 @@ void ApplicationWindow::exportMatrix() { return; ImageExportDialog *ied = - new ImageExportDialog(this, m != NULL, d_extended_export_dialog); + new ImageExportDialog(this, m != nullptr, d_extended_export_dialog); ied->setDirectory(workingDir); ied->selectFilter(d_image_export_filter); if (ied->exec() != QDialog::Accepted) @@ -3051,7 +3051,7 @@ void ApplicationWindow::setPreferences(Graph *g) { *creates a new empty table */ Table *ApplicationWindow::newTable() { - Table *w = new Table(scriptingEnv(), 30, 2, "", this, 0); + Table *w = new Table(scriptingEnv(), 30, 2, "", this, nullptr); initTable(w, generateUniqueName(tr("Table"))); w->showNormal(); return w; @@ -3061,7 +3061,7 @@ Table *ApplicationWindow::newTable() { *used when opening a project file */ Table *ApplicationWindow::newTable(const QString &caption, int r, int c) { - Table *w = new Table(scriptingEnv(), r, c, "", this, 0); + Table *w = new Table(scriptingEnv(), r, c, "", this, nullptr); initTable(w, caption); if (w->objectName() != caption) { // the table was renamed renamedTables << caption << w->objectName(); @@ -3083,7 +3083,7 @@ bool ApplicationWindow::isDeleteWorkspacePromptEnabled() { Table *ApplicationWindow::newTable(int r, int c, const QString &name, const QString &legend) { - Table *w = new Table(scriptingEnv(), r, c, legend, this, 0); + Table *w = new Table(scriptingEnv(), r, c, legend, this, nullptr); initTable(w, name); return w; } @@ -3095,7 +3095,7 @@ Table *ApplicationWindow::newTable(const QString &caption, int r, int c, if (lst.count() == 2) legend = lst[1]; - Table *w = new Table(scriptingEnv(), r, c, legend, this, 0); + Table *w = new Table(scriptingEnv(), r, c, legend, this, nullptr); QStringList rows = text.split("\n", QString::SkipEmptyParts); QString rlist = rows[0]; @@ -3117,7 +3117,7 @@ Table *ApplicationWindow::newTable(const QString &caption, int r, int c, Table *ApplicationWindow::newHiddenTable(const QString &name, const QString &label, int r, int c, const QString &text) { - Table *w = new Table(scriptingEnv(), r, c, label, this, 0); + Table *w = new Table(scriptingEnv(), r, c, label, this, nullptr); if (!text.isEmpty()) { QStringList rows = text.split("\n", QString::SkipEmptyParts); @@ -3194,14 +3194,14 @@ Note *ApplicationWindow::newNote(const QString &caption) { } Matrix *ApplicationWindow::newMatrix(int rows, int columns) { - Matrix *m = new Matrix(scriptingEnv(), rows, columns, "", this, 0); + Matrix *m = new Matrix(scriptingEnv(), rows, columns, "", this, nullptr); initMatrix(m, generateUniqueName(tr("Matrix"))); m->showNormal(); return m; } Matrix *ApplicationWindow::newMatrix(const QString &caption, int r, int c) { - Matrix *w = new Matrix(scriptingEnv(), r, c, "", this, 0); + Matrix *w = new Matrix(scriptingEnv(), r, c, "", this, nullptr); initMatrix(w, caption); if (w->objectName() != caption) // the matrix was renamed renamedTables << caption << w->objectName(); @@ -3397,14 +3397,14 @@ ApplicationWindow::matrixToTable(Matrix *m, Table *w = nullptr; if (conversionType == Direct) { - w = new Table(scriptingEnv(), rows, cols, "", this, 0); + w = new Table(scriptingEnv(), rows, cols, "", this, nullptr); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) w->setCell(i, j, m->cell(i, j)); } } else if (conversionType == XYZ) { int tableRows = rows * cols; - w = new Table(scriptingEnv(), tableRows, 3, "", this, 0); + w = new Table(scriptingEnv(), tableRows, 3, "", this, nullptr); for (int i = 0; i < rows; i++) { for (int j = 0; j < cols; j++) { int cell = i * cols + j; @@ -3415,7 +3415,7 @@ ApplicationWindow::matrixToTable(Matrix *m, } } else if (conversionType == YXZ) { int tableRows = rows * cols; - w = new Table(scriptingEnv(), tableRows, 3, "", this, 0); + w = new Table(scriptingEnv(), tableRows, 3, "", this, nullptr); for (int i = 0; i < cols; i++) { for (int j = 0; j < rows; j++) { int cell = i * rows + j; @@ -3600,7 +3600,7 @@ Matrix *ApplicationWindow::tableToMatrix(Table *t) { int cols = t->numCols(); QString caption = generateUniqueName(tr("Matrix")); - Matrix *m = new Matrix(scriptingEnv(), rows, cols, "", this, 0); + Matrix *m = new Matrix(scriptingEnv(), rows, cols, "", this, nullptr); initMatrix(m, caption); for (int i = 0; i < rows; i++) { @@ -5701,7 +5701,7 @@ void ApplicationWindow::exportGraph() { return; ImageExportDialog *ied = - new ImageExportDialog(this, plot2D != NULL, d_extended_export_dialog); + new ImageExportDialog(this, plot2D != nullptr, d_extended_export_dialog); ied->setDirectory(workingDir); ied->selectFilter(d_image_export_filter); if (ied->exec() != QDialog::Accepted) @@ -5764,7 +5764,7 @@ void ApplicationWindow::exportLayer() { return; ImageExportDialog *ied = - new ImageExportDialog(this, g != NULL, d_extended_export_dialog); + new ImageExportDialog(this, g != nullptr, d_extended_export_dialog); ied->setDirectory(workingDir); ied->selectFilter(d_image_export_filter); if (ied->exec() != QDialog::Accepted) @@ -5837,7 +5837,7 @@ void ApplicationWindow::exportAllGraphs() { foreach (MdiSubWindow *w, windows) { const std::string windowClassName = w->metaObject()->className(); if (windowClassName == "MultiLayer") { - plot3D = 0; + plot3D = nullptr; plot2D = dynamic_cast<MultiLayer *>(w); if (!plot2D) continue; @@ -5851,7 +5851,7 @@ void ApplicationWindow::exportAllGraphs() { continue; } } else if (windowClassName == "Graph3D") { - plot2D = 0; + plot2D = nullptr; plot3D = dynamic_cast<Graph3D *>(w); if (!plot3D) continue; @@ -6137,7 +6137,7 @@ void ApplicationWindow::savetoNexusFile() { void ApplicationWindow::loadDataFile() { // Ask user for file QString fn = QFileDialog::getOpenFileName( - 0, tr("Mantidplot - Open file to load"), + nullptr, tr("Mantidplot - Open file to load"), AlgorithmInputHistory::Instance().getPreviousDirectory()); if (fn != "") { loadDataFileByName(fn); @@ -6438,7 +6438,7 @@ void ApplicationWindow::showTitleDialog() { Graph *g = ml->activeGraph(); if (g) { - TextDialog *td = new TextDialog(TextDialog::LayerTitle, this, 0); + TextDialog *td = new TextDialog(TextDialog::LayerTitle, this, nullptr); td->setGraph(g); td->exec(); } @@ -6462,7 +6462,7 @@ void ApplicationWindow::showAxisTitleDialog() { if (!g) return; - TextDialog *td = new TextDialog(TextDialog::AxisTitle, this, 0); + TextDialog *td = new TextDialog(TextDialog::AxisTitle, this, nullptr); td->setGraph(g); td->exec(); } @@ -7606,7 +7606,7 @@ void ApplicationWindow::removePoints() { this, tr("MantidPlot"), // Mantid tr("This will modify the data in the worksheets!\nAre you sure you " "want to continue?"), - tr("Continue"), tr("Cancel"), 0, 1)) { + tr("Continue"), tr("Cancel"), nullptr, 1)) { case 0: g->setActiveTool(new DataPickerTool(g, this, DataPickerTool::Remove, info, SLOT(setText(const QString &)))); @@ -7651,7 +7651,7 @@ void ApplicationWindow::movePoints() { this, tr("MantidPlot"), // Mantid tr("This will modify the data in the worksheets!\nAre you sure you " "want to continue?"), - tr("Continue"), tr("Cancel"), 0, 1)) { + tr("Continue"), tr("Cancel"), nullptr, 1)) { case 0: if (g) { g->setActiveTool(new DataPickerTool(g, this, DataPickerTool::Move, info, @@ -8345,7 +8345,7 @@ void ApplicationWindow::showTextDialog() { if (!l) return; - TextDialog *td = new TextDialog(TextDialog::TextMarker, this, 0); + TextDialog *td = new TextDialog(TextDialog::TextMarker, this, nullptr); td->setLegendWidget(l); td->exec(); } @@ -9825,9 +9825,10 @@ void ApplicationWindow::closeEvent(QCloseEvent *ce) { delete scriptingWindow; scriptingWindow = nullptr; } - /// Ensure interface python references are cleaned up before the interpreter - /// shuts down + // Ensure all python references are cleaned up before the interpreter shuts + // down delete m_iface_script; + delete m_interpreterDock; // Emit a shutting_down() signal that can be caught by // independent QMainWindow objects to know when MantidPlot @@ -10467,7 +10468,7 @@ void ApplicationWindow::chooseHelpFolder() { QFileInfo hfi(helpFilePath); QString dir = QFileDialog::getExistingDirectory( this, tr("Choose the location of the MantidPlot help folder!"), - hfi.dir().absolutePath(), 0 /**QFileDialog::ShowDirsOnly*/); + hfi.dir().absolutePath(), nullptr /**QFileDialog::ShowDirsOnly*/); if (!dir.isEmpty()) { helpFilePath = dir + "index.html"; @@ -10522,7 +10523,7 @@ void ApplicationWindow::showHelp() { void ApplicationWindow::showPlotWizard() { QStringList lst = tableNames(); if (lst.count() > 0) { - PlotWizard *pw = new PlotWizard(this, 0); + PlotWizard *pw = new PlotWizard(this, nullptr); pw->setAttribute(Qt::WA_DeleteOnClose); connect(pw, SIGNAL(plot(const QStringList &)), this, SLOT(multilayerPlot(const QStringList &))); @@ -13366,7 +13367,7 @@ Graph3D *ApplicationWindow::openMatrixPlot3D(const QString &caption, if (!m) return nullptr; - Graph3D *plot = new Graph3D("", this, 0, 0); + Graph3D *plot = new Graph3D("", this, nullptr, nullptr); plot->setWindowTitle(caption); plot->setName(caption); plot->addMatrixData(m, xl, xr, yl, yr, zl, zr); @@ -13390,7 +13391,7 @@ Graph3D *ApplicationWindow::plot3DMatrix(Matrix *m, int style) { QApplication::setOverrideCursor(Qt::WaitCursor); QString label = generateUniqueName(tr("Graph")); - Graph3D *plot = new Graph3D("", this, 0); + Graph3D *plot = new Graph3D("", this, nullptr); plot->addMatrixData(m); plot->customPlotStyle(style); customPlot3D(plot); @@ -14409,7 +14410,7 @@ bool ApplicationWindow::deleteFolder(Folder *f) { this, tr("MantidPlot - Delete folder?"), // Mantid tr("Delete folder '%1' and all the windows it contains?") .arg(f->objectName()), - tr("Yes"), tr("No"), 0, 0)) + tr("Yes"), tr("No"), nullptr, 0)) return false; else { Folder *parent = projectFolder(); @@ -14858,7 +14859,8 @@ void ApplicationWindow::showScriptWindow(bool forceVisible, bool quitting) { // it doesn't respect the always on top // flag, it is treated as a sub window of its parent const bool capturePrint = !quitting; - scriptingWindow = new ScriptingWindow(scriptingEnv(), capturePrint, NULL); + scriptingWindow = + new ScriptingWindow(scriptingEnv(), capturePrint, nullptr); scriptingWindow->setObjectName("ScriptingWindow"); scriptingWindow->setAttribute(Qt::WA_DeleteOnClose, false); connect(scriptingWindow, SIGNAL(closeMe()), this, diff --git a/MantidPlot/src/ConfigDialog.cpp b/MantidPlot/src/ConfigDialog.cpp index c674a20ae33cff1a78e88808be41185e552fe955..447d0f7d273a4089499714d3e92cb9534659c6d9 100644 --- a/MantidPlot/src/ConfigDialog.cpp +++ b/MantidPlot/src/ConfigDialog.cpp @@ -3105,7 +3105,7 @@ void ConfigDialog::chooseTranslationsFolder() { QFileInfo tfi(app->d_translations_folder); QString dir = QFileDialog::getExistingDirectory( this, tr("Choose the location of the MantidPlot translations folder!"), - tfi.dir().absolutePath(), 0 /**QFileDialog::ShowDirsOnly*/); + tfi.dir().absolutePath(), nullptr /**QFileDialog::ShowDirsOnly*/); if (!dir.isEmpty()) { app->d_translations_folder = dir; @@ -3130,7 +3130,7 @@ void ConfigDialog::chooseHelpFolder() { void ConfigDialog::addPythonScriptsDirs() { QString dir = QFileDialog::getExistingDirectory( this, tr("Add a python scripts directory"), "", - 0 /**QFileDialog::ShowDirsOnly*/); + nullptr /**QFileDialog::ShowDirsOnly*/); if (!dir.isEmpty()) { QString dirs = lePythonScriptsDirs->text(); if (!dirs.isEmpty()) { @@ -3144,7 +3144,7 @@ void ConfigDialog::addPythonScriptsDirs() { void ConfigDialog::addPythonPluginDirs() { QString dir = QFileDialog::getExistingDirectory( this, tr("Add a python extension directory"), "", - 0 /**QFileDialog::ShowDirsOnly*/); + nullptr /**QFileDialog::ShowDirsOnly*/); if (!dir.isEmpty()) { QString dirs = lePythonPluginsDirs->text(); if (!dirs.isEmpty()) { @@ -3157,7 +3157,7 @@ void ConfigDialog::addPythonPluginDirs() { void ConfigDialog::addInstrumentDir() { QString dir = QFileDialog::getExistingDirectory( - this, tr("Select new instrument definition directory"), "", 0); + this, tr("Select new instrument definition directory"), "", nullptr); if (!dir.isEmpty()) { leInstrumentDir->setText(dir); } diff --git a/MantidPlot/src/Graph.cpp b/MantidPlot/src/Graph.cpp index 3fd93f5639af75a18628482e21de7547d527f40c..a19870e6eeb2f32cc1610ea8dedbb5271761e2ef 100644 --- a/MantidPlot/src/Graph.cpp +++ b/MantidPlot/src/Graph.cpp @@ -3094,7 +3094,7 @@ void Graph::removePie() { QList<PieLabel *> labels = pieCurve->labelsList(); foreach (PieLabel *l, labels) - l->setPieCurve(0); + l->setPieCurve(nullptr); d_plot->removeCurve(c_keys[0]); d_plot->replot(); diff --git a/MantidPlot/src/Graph3D.cpp b/MantidPlot/src/Graph3D.cpp index 7ca8869de627f224a80a76923587ccca2268d940..7362252c2e05882bacb3a746cddc6edc135747a8 100644 --- a/MantidPlot/src/Graph3D.cpp +++ b/MantidPlot/src/Graph3D.cpp @@ -2497,7 +2497,7 @@ MantidQt::API::IProjectSerialisable * Graph3D::loadFromProject(const std::string &lines, ApplicationWindow *app, const int fileVersion) { Q_UNUSED(fileVersion); - auto graph = new Graph3D("", app, "", 0); + auto graph = new Graph3D("", app, "", nullptr); std::vector<std::string> lineVec, valVec; boost::split(lineVec, lines, boost::is_any_of("\n")); diff --git a/MantidPlot/src/Mantid/FitParameterTie.cpp b/MantidPlot/src/Mantid/FitParameterTie.cpp index 02352d7bb47908bd2f504332f43ce228cc702bb5..d51c05a2719e20af3a1a3b23ed5faa1892044965 100644 --- a/MantidPlot/src/Mantid/FitParameterTie.cpp +++ b/MantidPlot/src/Mantid/FitParameterTie.cpp @@ -42,7 +42,7 @@ void FitParameterTie::set(const QString &estr) { // rx matches function identifiers in the parameter names and captures the // function index: // for f12.Sigma rx.cap(1).toInt() returns 12 - QRegExp rx("\\bf(\\d+)\\."); + QRegExp rx(R"(\bf(\d+)\.)"); if (rx.indexIn(parName) < 0) { throw std::invalid_argument( diff --git a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp index 0c0e61b2bae4b589d03dc5bc8728cb1f682d7fc0..07137f9e90df10bb8bae65ab026e62455f14b0b4 100644 --- a/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp +++ b/MantidPlot/src/Mantid/InstrumentWidget/InstrumentWindow.cpp @@ -23,7 +23,7 @@ using namespace MantidQt::MantidWidgets; InstrumentWindow::InstrumentWindow(const QString &wsName, const QString &label, ApplicationWindow *parent, const QString &name) - : MdiSubWindow(parent, label, name, 0) { + : MdiSubWindow(parent, label, name, nullptr) { m_instrumentWidget = new InstrumentWidget(wsName, this); this->setWidget(m_instrumentWidget); diff --git a/MantidPlot/src/Mantid/MantidMatrix.cpp b/MantidPlot/src/Mantid/MantidMatrix.cpp index 76e3aedee0c5ff8c1547195e2dff05212d99e484..bdd87147b94ca635f1fed2168a2ae255af313cd5 100644 --- a/MantidPlot/src/Mantid/MantidMatrix.cpp +++ b/MantidPlot/src/Mantid/MantidMatrix.cpp @@ -210,7 +210,7 @@ void MantidMatrix::viewChanged(int index) { void MantidMatrix::setup(Mantid::API::MatrixWorkspace_const_sptr ws, int start, int end) { if (!ws) { - QMessageBox::critical(0, "WorkspaceMatrixModel error", + QMessageBox::critical(nullptr, "WorkspaceMatrixModel error", "2D workspace expected."); m_rows = 0; m_cols = 0; @@ -468,8 +468,8 @@ void MantidMatrix::setRange(double min, double max) { double **MantidMatrix::allocateMatrixData(int rows, int columns) { double **data = (double **)malloc(rows * sizeof(double *)); if (!data) { - QMessageBox::critical(0, tr("MantidPlot") + " - " + - tr("Memory Allocation Error"), + QMessageBox::critical(nullptr, tr("MantidPlot") + " - " + + tr("Memory Allocation Error"), tr("Not enough memory, operation aborted!")); return nullptr; } @@ -481,8 +481,8 @@ double **MantidMatrix::allocateMatrixData(int rows, int columns) { free(data[j]); free(data); - QMessageBox::critical(0, tr("MantidPlot") + " - " + - tr("Memory Allocation Error"), + QMessageBox::critical(nullptr, tr("MantidPlot") + " - " + + tr("Memory Allocation Error"), tr("Not enough memory, operation aborted!")); return nullptr; } @@ -736,7 +736,7 @@ void MantidMatrix::attachMultilayer(MultiLayer *ml) { */ MultiLayer *MantidMatrix::plotGraph2D(GraphOptions::CurveType type) { if (numRows() == 1) { - QMessageBox::critical(0, "MantidPlot - Error", + QMessageBox::critical(nullptr, "MantidPlot - Error", "Cannot plot a workspace with only one spectrum."); return nullptr; } diff --git a/MantidPlot/src/Mantid/MantidTable.cpp b/MantidPlot/src/Mantid/MantidTable.cpp index 295b08302052dd65f515ce48747fac56e5484fdd..a9a58a128d506051954f8c4765e1459eb7d12988 100644 --- a/MantidPlot/src/Mantid/MantidTable.cpp +++ b/MantidPlot/src/Mantid/MantidTable.cpp @@ -35,7 +35,7 @@ MantidTable::MantidTable(ScriptingEnv *env, : static_cast<int>(ws->rowCount()), transpose ? static_cast<int>(ws->rowCount() + 1) : static_cast<int>(ws->columnCount()), - label, parent, "", 0), + label, parent, "", nullptr), m_ws(ws), m_wsName(ws->getName()), m_transposed(transpose) { d_table->blockResizing(true); diff --git a/MantidPlot/src/Mantid/MantidUI.cpp b/MantidPlot/src/Mantid/MantidUI.cpp index 48bc194af55fcc4cf0e33e7960576903fa1c144e..a67ed40590ca12365844b06f30f9ab1317ab21da 100644 --- a/MantidPlot/src/Mantid/MantidUI.cpp +++ b/MantidPlot/src/Mantid/MantidUI.cpp @@ -213,9 +213,9 @@ MantidUI::MantidUI(ApplicationWindow *aw) : m_finishedLoadDAEObserver(*this, &MantidUI::handleLoadDAEFinishedNotification), m_configServiceObserver(*this, &MantidUI::handleConfigServiceUpdate), - m_appWindow(aw), m_lastShownInstrumentWin(NULL), - m_lastShownSliceViewWin(NULL), m_lastShownSpectrumViewerWin(NULL), - m_lastShownColorFillWin(NULL), m_lastShown1DPlotWin(NULL), + m_appWindow(aw), m_lastShownInstrumentWin(nullptr), + m_lastShownSliceViewWin(nullptr), m_lastShownSpectrumViewerWin(nullptr), + m_lastShownColorFillWin(nullptr), m_lastShown1DPlotWin(nullptr), m_vatesSubWindow(nullptr) //, m_spectrumViewWindow(NULL) { @@ -925,7 +925,7 @@ void MantidUI::showSpectrumViewer() { try { viewer = new MantidQt::SpectrumView::SpectrumView(m_appWindow); } catch (std::runtime_error &e) { - m_lastShownSpectrumViewerWin = NULL; + m_lastShownSpectrumViewerWin = nullptr; g_log.error() << "Could not create spectrum viewer: " << e.what() << "\n"; throw std::runtime_error(e); @@ -981,7 +981,7 @@ void MantidUI::showSliceViewer() { w = MantidQt::Factory::WidgetFactory::Instance()->createSliceViewerWindow( wsName, ""); } catch (std::runtime_error &e) { - m_lastShownSliceViewWin = NULL; + m_lastShownSliceViewWin = nullptr; g_log.error() << "Could not create slice viewer: " << e.what() << "\n"; throw std::runtime_error(e); } @@ -1025,7 +1025,7 @@ Show Algorithm History Details in a window . void MantidUI::showAlgorithmHistory() { QString wsName = getSelectedWorkspaceName(); Mantid::API::Workspace_const_sptr wsptr = getWorkspace(wsName); - if (NULL != wsptr) { + if (nullptr != wsptr) { // If the workspace has any AlgorithHistory ... if (!wsptr->getHistory().empty()) { // ... create and display the window. @@ -1314,8 +1314,8 @@ Table *MantidUI::createDetectorTable( const int nrows = indices.empty() ? static_cast<int>(ws->getNumberHistograms()) : static_cast<int>(indices.size()); - Table *t = - new Table(appWindow()->scriptingEnv(), nrows, ncols, "", appWindow(), 0); + Table *t = new Table(appWindow()->scriptingEnv(), nrows, ncols, "", + appWindow(), nullptr); appWindow()->initTable( t, appWindow()->generateUniqueName(wsName + "-Detectors-")); // Set the column names @@ -2140,7 +2140,7 @@ void MantidUI::showMantidInstrument(const QString &wsName) { InstrumentWindow *insWin = getInstrumentView(wsName); if (!insWin) { - m_lastShownInstrumentWin = NULL; + m_lastShownInstrumentWin = nullptr; return; } @@ -2220,8 +2220,9 @@ void MantidUI::saveProject(bool saved) { if (!saved) { QString savemsg = tr("Save changes to project: <p><b> %1 </b> ?").arg("untitled"); - int result = QMessageBox::information(appWindow(), tr("MantidPlot"), - savemsg, tr("Yes"), tr("No"), 0, 2); + int result = + QMessageBox::information(appWindow(), tr("MantidPlot"), savemsg, + tr("Yes"), tr("No"), nullptr, 2); if (result == 0) appWindow()->saveProject(); } @@ -2405,7 +2406,7 @@ void MantidUI::importString(const QString &logName, const QString &data, } Table *t = new Table(appWindow()->scriptingEnv(), loglines.size(), 1, "", - appWindow(), 0); + appWindow(), nullptr); if (!t) return; // Have to replace "_" since the legend widget uses them to separate things @@ -2441,8 +2442,8 @@ void MantidUI::importStrSeriesLog(const QString &logName, const QString &data, QStringList loglines = data.split("\n", QString::SkipEmptyParts); int rowcount(loglines.count()); - Table *t = - new Table(appWindow()->scriptingEnv(), rowcount, 2, "", appWindow(), 0); + Table *t = new Table(appWindow()->scriptingEnv(), rowcount, 2, "", + appWindow(), nullptr); if (!t) return; QString label; @@ -2541,7 +2542,7 @@ void MantidUI::importNumSeriesLog(const QString &wsName, const QString &logName, int colCount = 2; Table *t = new Table(appWindow()->scriptingEnv(), rowcount, colCount, "", - appWindow(), 0); + appWindow(), nullptr); if (!t) return; // Have to replace "_" since the legend widget uses them to separate things @@ -2857,7 +2858,7 @@ Table *MantidUI::createTableFromSpectraList(const QString &tableName, bool isHistogram = workspace->isHistogramData(); int no_cols = static_cast<int>(indexList.size()); Table *t = new Table(appWindow()->scriptingEnv(), numRows, (1 + c) * no_cols, - "", appWindow(), 0); + "", appWindow(), nullptr); appWindow()->initTable(t, appWindow()->generateUniqueName(tableName + "-")); // t->askOnCloseEvent(false); @@ -3127,7 +3128,7 @@ MultiLayer *MantidUI::plot1D(const QMultiMap<QString, int> &toPlot, return nullptr; } // Force waterfall option to false if only 1 curve - if ((NULL == plotWindow || clearWindow) && toPlot.size() == 1) + if ((nullptr == plotWindow || clearWindow) && toPlot.size() == 1) waterfallPlot = false; ScopedOverrideCursor waitCursor; @@ -3325,7 +3326,7 @@ void MantidUI::drawColorFillPlots(const QStringList &wsNames, cit != wsNames.end(); ++cit) { const bool hidden = true; MultiLayer *plot = - this->drawSingleColorFillPlot(*cit, curveType, NULL, hidden); + this->drawSingleColorFillPlot(*cit, curveType, nullptr, hidden); if (plot) plots.append(plot); } @@ -3391,7 +3392,7 @@ MultiLayer *MantidUI::drawSingleColorFillPlot(const QString &wsName, ScopedOverrideCursor waitCursor; bool reusePlots = workspacesDockPlot1To1(); - if ((!reusePlots && NULL == window) || + if ((!reusePlots && nullptr == window) || (reusePlots && !m_lastShownColorFillWin)) // needs to create a new window { try { @@ -3401,7 +3402,7 @@ MultiLayer *MantidUI::drawSingleColorFillPlot(const QString &wsName, window->hide(); } } catch (std::runtime_error &e) { - m_lastShownColorFillWin = NULL; + m_lastShownColorFillWin = nullptr; g_log.error() << "Could not create color fill plot: " << e.what() << "\n"; throw std::runtime_error(e); } @@ -3409,7 +3410,7 @@ MultiLayer *MantidUI::drawSingleColorFillPlot(const QString &wsName, m_lastShownColorFillWin = window; } else { if (nullptr == window) { - if (NULL == m_lastShownColorFillWin) + if (nullptr == m_lastShownColorFillWin) return nullptr; window = m_lastShownColorFillWin; } @@ -3736,7 +3737,7 @@ Table *MantidUI::createTableFromBins( return nullptr; Table *t = new Table(appWindow()->scriptingEnv(), numRows, - c * bins.size() + 1, "", appWindow(), 0); + c * bins.size() + 1, "", appWindow(), nullptr); appWindow()->initTable(t, appWindow()->generateUniqueName(wsName + "-")); for (int i = 0; i < bins.size(); i++) { diff --git a/MantidPlot/src/PythonScript.cpp b/MantidPlot/src/PythonScript.cpp index 9c74de4d8d2e9ac354b4ff485c7c924c48284b85..09d6074ccf515e7207a95dd5ae487552d921ea54 100644 --- a/MantidPlot/src/PythonScript.cpp +++ b/MantidPlot/src/PythonScript.cpp @@ -556,7 +556,7 @@ QVariant PythonScript::evaluateImpl() { if (pystring) { PyObject *asUTF8 = PyUnicode_EncodeUTF8(PyUnicode_AS_UNICODE(pystring), - (int)PyUnicode_GET_DATA_SIZE(pystring), NULL); + (int)PyUnicode_GET_DATA_SIZE(pystring), nullptr); Py_DECREF(pystring); if (asUTF8) { qret = QVariant(QString::fromUtf8(PyString_AS_STRING(asUTF8))); diff --git a/MantidPlot/src/TiledWindow.cpp b/MantidPlot/src/TiledWindow.cpp index 58d522c6f5b2e4d616a3b89bc86cb8b931a4a236..f7ff58ad82a8d410635d90188dfa81f72aad98f0 100644 --- a/MantidPlot/src/TiledWindow.cpp +++ b/MantidPlot/src/TiledWindow.cpp @@ -911,7 +911,7 @@ void TiledWindow::selectRange(int row1, int col1, int row2, int col2) { void TiledWindow::removeSelectionTo(TiledWindow::RemoveDestination to) { foreach (Tile *tile, m_selection) { MdiSubWindow *widget = removeTile(tile); - if (widget == NULL) { + if (widget == nullptr) { throw std::logic_error("TiledWindow: Empty tile is found in slection."); } sendWidgetTo(widget, to); diff --git a/MantidPlot/src/importOPJ.cpp b/MantidPlot/src/importOPJ.cpp index a041ae55b1d52d7ad6f7ea0d2f68337b570bf99c..35df0ddf0183f867f911e48430139b389f3d63d1 100644 --- a/MantidPlot/src/importOPJ.cpp +++ b/MantidPlot/src/importOPJ.cpp @@ -501,7 +501,7 @@ bool ImportOPJ::importNotes(const OPJFile &opj) { int visible_count = 0; for (int n = 0; n < opj.numNotes(); n++) { QString name = opj.noteName(n); - QRegExp rx("^@\\((\\S+)\\)$"); + QRegExp rx(R"(^@\((\S+)\)$)"); if (rx.indexIn(name) == 0) name = rx.cap(1); @@ -1175,8 +1175,8 @@ bool ImportOPJ::importGraphs(const OPJFile &opj) { vector<text> texts = opj.layerTexts(g, l); if (style != GraphOptions::Pie) { for (size_t i = 0; i < texts.size(); ++i) { - addText(texts[i], graph, 0, layerRect, fFontScaleFactor, fXScale, - fYScale); + addText(texts[i], graph, nullptr, layerRect, fFontScaleFactor, + fXScale, fYScale); } } @@ -1358,8 +1358,8 @@ QString ImportOPJ::parseOriginText(const QString &str) { QString ImportOPJ::parseOriginTags(const QString &str) { QString line = str; // Lookbehind conditions are not supported - so need to reverse string - QRegExp rx("\\)[^\\)\\(]*\\((?!\\s*[buig\\+\\-]\\s*\\\\)"); - QRegExp rxfont("\\)[^\\)\\(]*\\((?![^\\:]*\\:f\\s*\\\\)"); + QRegExp rx(R"(\)[^\)\(]*\((?!\s*[buig\+\-]\s*\\))"); + QRegExp rxfont(R"(\)[^\)\(]*\((?![^\:]*\:f\s*\\))"); QString linerev = strreverse(line); QString lBracket = strreverse("&lbracket;"); QString rBracket = strreverse("&rbracket;"); @@ -1396,10 +1396,10 @@ QString ImportOPJ::parseOriginTags(const QString &str) { // replace \b(...), \i(...), \u(...), \g(...), \+(...), \-(...), \f:font(...) // tags - QString rxstr[] = {"\\\\\\s*b\\s*\\(", "\\\\\\s*i\\s*\\(", - "\\\\\\s*u\\s*\\(", "\\\\\\s*g\\s*\\(", - "\\\\\\s*\\+\\s*\\(", "\\\\\\s*\\-\\s*\\(", - "\\\\\\s*f\\:[^\\(]*\\("}; + QString rxstr[] = {R"(\\\s*b\s*\()", R"(\\\s*i\s*\()", + R"(\\\s*u\s*\()", R"(\\\s*g\s*\()", + R"(\\\s*\+\s*\()", R"(\\\s*\-\s*\()", + R"(\\\s*f\:[^\(]*\()"}; int postag[] = {0, 0, 0, 0, 0, 0, 0}; QString ltag[] = {"<b>", "<i>", "<u>", "<font face=Symbol>", "<sup>", "<sub>", "<font face=%1>"}; @@ -1407,7 +1407,7 @@ QString ImportOPJ::parseOriginTags(const QString &str) { "</sup>", "</sub>", "</font>"}; QRegExp rxtags[7]; for (int i = 0; i < 7; ++i) - rxtags[i].setPattern(rxstr[i] + "[^\\(\\)]*\\)"); + rxtags[i].setPattern(rxstr[i] + R"([^\(\)]*\))"); bool flag = true; while (flag) { diff --git a/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp b/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp index 0ebcec2d711dec5d5a9bbae28cbd21f06be1a59b..c599b26d407bc9ebab0f423874f9454a244ce0e1 100644 --- a/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp +++ b/MantidPlot/src/lib/3rdparty/qtcolorpicker/src/qtcolorpicker.cpp @@ -605,10 +605,7 @@ void ColorPickerPopup::insertColor(const QColor &col, const QString &text, QColor ColorPickerPopup::color(int index) const { if (index < 0 || index > (int)items.count() - 1) return QColor(); - - // cppcheck-suppress cstyleCast - ColorPickerPopup *that = (ColorPickerPopup *)this; - return that->items.at(index)->color(); + return this->items.at(index)->color(); } /*! \internal diff --git a/MantidPlot/src/lib/src/TextFormatButtons.cpp b/MantidPlot/src/lib/src/TextFormatButtons.cpp index 54a29ade87b5615596c8c3eb6c8906dc7c0828f4..12b6dae42efbd09574a79932c0fea5ba1f9a5988 100644 --- a/MantidPlot/src/lib/src/TextFormatButtons.cpp +++ b/MantidPlot/src/lib/src/TextFormatButtons.cpp @@ -457,10 +457,10 @@ void TextFormatButtons::addSymbol(const QString &letter) { else if (letter == QString(QChar(4 + s))) connectedTextEdit->textCursor().insertText("\\int"); else if (letter == QString(QChar(5 + s))) - connectedTextEdit->textCursor().insertText("\\int \\!\\!\\! \\int"); + connectedTextEdit->textCursor().insertText(R"(\int \!\!\! \int)"); else if (letter == QString(QChar(6 + s))) connectedTextEdit->textCursor().insertText( - "\\int \\!\\!\\! \\int \\!\\!\\! \\int"); + R"(\int \!\!\! \int \!\!\! \int)"); else if (letter == QString(QChar(7 + s))) connectedTextEdit->textCursor().insertText("\\oint"); diff --git a/MantidPlot/src/origin/tree.hh b/MantidPlot/src/origin/tree.hh index bd6a2576a4a0036644360f4429fe324cc787c322..c036254fb88100cfc64e741de9d0e9d476ce294f 100644 --- a/MantidPlot/src/origin/tree.hh +++ b/MantidPlot/src/origin/tree.hh @@ -713,7 +713,7 @@ typename tree<T, tree_node_allocator>::fixed_depth_iterator tree<T, tree_node_al template <class T, class tree_node_allocator> typename tree<T, tree_node_allocator>::sibling_iterator tree<T, tree_node_allocator>::begin(const iterator_base& pos) const { - assert(pos.node!=0); + assert(pos.node!=nullptr); if(pos.node->first_child==nullptr) { return end(pos); } @@ -764,7 +764,7 @@ template <class T, class tree_node_allocator> template <typename iter> iter tree<T, tree_node_allocator>::parent(iter position) { - assert(position.node!=0); + assert(position.node!=nullptr); return iter(position.node->parent); } @@ -1667,7 +1667,7 @@ template <class T, class tree_node_allocator> int tree<T, tree_node_allocator>::depth(const iterator_base& it) { tree_node* pos=it.node; - assert(pos!=0); + assert(pos!=nullptr); int ret=0; while(pos->parent!=nullptr) { pos=pos->parent; @@ -2119,7 +2119,7 @@ tree<T, tree_node_allocator>::pre_order_iterator::pre_order_iterator(const sibli template <class T, class tree_node_allocator> typename tree<T, tree_node_allocator>::pre_order_iterator& tree<T, tree_node_allocator>::pre_order_iterator::operator++() { - assert(this->node!=0); + assert(this->node!=nullptr); if(!this->skip_current_children_ && this->node->first_child != nullptr) { this->node=this->node->first_child; } diff --git a/MantidPlot/test/MantidPlotPyplotGeneralTest.py b/MantidPlot/test/MantidPlotPyplotGeneralTest.py deleted file mode 100644 index 5a89029aa2241dda72474752ce26b311057d815b..0000000000000000000000000000000000000000 --- a/MantidPlot/test/MantidPlotPyplotGeneralTest.py +++ /dev/null @@ -1,250 +0,0 @@ -"""General tests for the basic interface of mantidplot.pyplot - -Tests correct creation of output lines from plots (with correct -Figure, Graph, etc. data), and proper handling (exception) of wrong -input parameters. Tests plotting of normal arrays and workspaces with the following tools ('tool' kwarg): plot_spectrum, plot_bin, plot_ - -""" -from __future__ import (absolute_import, division, print_function) -import mantidplottests -from mantidplottests import * -import time -import numpy as np -from PyQt4 import QtGui, QtCore - -# =============== Create fake workspaces to plot ======================= -X1 = np.linspace(0,10, 100) -Y1 = 1000*(np.sin(X1)**2) + X1*10 -X1 = np.append(X1, 10.1) - -X2 = np.linspace(2,12, 100) -Y2 = 500*(np.cos(X2/2.)**2) + 20 -X2 = np.append(X2, 12.10) - -X = np.append(X1, X2) -Y = np.append(Y1, Y2) -E = np.sqrt(Y) - -# this one has 2 spectra -WorkspaceName2D = 'fake ws' -CreateWorkspace(OutputWorkspace=WorkspaceName2D, DataX=list(X), DataY=list(Y), DataE=list(E), NSpec=2, - UnitX="TOF", YUnitLabel="Counts", WorkspaceTitle="Test/faked data Workspace, 2 spectra") - -sec_X3 = np.linspace(2,12, 100) -sec_Y3 = 200*(np.tan(sec_X3/2.4)**2) + 15 -sec_X3 = np.append(sec_X3, 12.10) - -sec_X = np.append(X, sec_X3) -sec_Y = np.append(Y, sec_Y3) -sec_E = np.power(sec_Y, 0.6) - -# this one has 3 spectra -SecondWorkspaceName2D = 'another fake ws' -CreateWorkspace(OutputWorkspace=SecondWorkspaceName2D, DataX=list(sec_X), DataY=list(sec_Y), DataE=list(sec_E), NSpec=3, - UnitX="TOF", YUnitLabel="Counts", WorkspaceTitle="Test/faked data Workspace, 3 spectra") - -# plot_md needs an MD workspace with a single non-integrated dimension -MDWWorkspaceName = 'mdw' -mdSignal = np.sin(list(range(0,100,1))) -errInput = mdSignal/20.5 -CreateMDHistoWorkspace(Dimensionality="1", Names='x', Units='m', Extents='0,10', NumberOfBins=len(mdSignal), SignalInput=mdSignal, ErrorInput=errInput, OutputWorkspace=MDWWorkspaceName) - -class MantidPlotPyplotGeneralTest(unittest.TestCase): - - def setUp(self): - self.g = None - - def tearDown(self): - """Clean up by closing the created window """ - windows = self.g - if not self.g: - return - if type(self.g) != list: - windows = [self.g] - for window in windows: - self.close_win_by_graph(window) - - def close_win_by_graph(self, g): - if None != g: - g.confirmClose(False) - g.close() - QtCore.QCoreApplication.processEvents() - - def test_nothing(self): - return True - - def check_output_lines(self, lines, expected_len): - """ Check that the lines returned by a plot are correctly built """ - self.assertTrue(expected_len==len(lines)) - for i in range(0, len(lines)): - self.assertTrue(isinstance(lines[i], Line2D)) - self.assertTrue(isinstance(lines[i].figure(), Figure)) - self.assertTrue(isinstance(lines[i]._graph, proxies.Graph)) - self.assertTrue(isinstance(lines[i].figure()._graph, proxies.Graph)) - - def close_win(self, lines): - """ - Close a plot window. Use this on your test windows to prevent very likely - segfaults at the end of the tests. - - @param lines :: lines object as returned by the plot function - """ - if len(lines) > 0: - self.close_win_by_graph(lines[0]._graph) - - def test_plot_spectrum_ok(self): - lines_spec = plot_spectrum(WorkspaceName2D, [0, 1]) - self.check_output_lines(lines_spec, 2) - self.close_win(lines_spec) - - tool_names = ['plot_spectrum', 'plot_sp', 'spectrum', 'sp'] - for tname in tool_names: - lines = plot(WorkspaceName2D, [0, 1], tool=tname) - self.check_output_lines(lines, 2) - self.close_win(lines) - - if self.assertTrue(len(lines) == len(lines_spec)): - for i in range(0, len(lines)): - self.assertEqual(lines[i].get_xdata(), lines_spec[i].get_xdata()) - self.assertEqual(lines[i].get_ydata(), lines_spec[i].get_ydata()) - - def test_plot_bin_ok(self): - lines_bin = plot_bin(WorkspaceName2D, [0, 1, 2]) - self.check_output_lines(lines_bin, 3) - self.close_win(lines_bin) - - tool_names = ['plot_bin', 'bin'] - for tname in tool_names: - lines = plot(WorkspaceName2D, [0, 1, 2], tool=tname) - self.check_output_lines(lines, 3) - self.close_win(lines) - - if self.assertTrue(len(lines) == len(lines_bin)): - for i in range(0, len(lines)): - self.assertEqual(lines[i].get_xdata(), lines2_bin[i].get_xdata()) - self.assertEqual(lines[i].get_ydata(), lines2_bin[i].get_ydata()) - - def test_lines_get_data(self): - y = [0.2, 0.5, 0.1, 0.6] - # note this assumes that plot will make a dummy workspace using 0,1,2... as X - x = list(range(0, len(y), 1)) - - lines = plot(y) - self.check_output_lines(lines, 1) - # and here also check the values - if 1==len(lines): - self.assertEqual(lines[0].get_xdata(), x) - self.assertEqual(lines[0].get_ydata(), y) - self.close_win(lines) - - def test_plot_md_ok(self): - lines = plot_md(MDWWorkspaceName) - self.assertEqual(len(lines), 1) - self.close_win(lines) - - tool_names = ['plot_md', 'md'] - for tnames in tool_names: - lines = plot(MDWWorkspaceName, tool='plot_md') - self.assertEqual(len(lines), 1) - self.close_win(lines) - - # now see what happens with non-md workspaces - self.assertRaises(ValueError, plot, WorkspaceName2D, tool='plot_md') - - self.assertRaises(ValueError, plot_md, WorkspaceName2D) - - def test_plot_array_ok(self): - val = [] # empty data, will be replaced with a dummy (0,0) and generate a 'point' line - lines = plot(val) - self.check_output_lines(lines, 1) - self.close_win(lines) - - def test_plot_with_more_functions(self): - lines = plot(WorkspaceName2D, [0,1], tool='plot_spectrum', linewidth=2, linestyle='--', marker='v') - xlim(0, 1) - ylim(0, 1) - xlabel('X foo label') - ylabel('Y bar label') - title('baz title') - axis([0, 1, 0, 1]) - grid('off') - grid('on') - self.check_output_lines(lines, 2) - self.close_win(lines) - - def test_plot_with_style_args(self): - # note that these tests also use various aliases for the tool name 'plot_spectrum' - # Not adding all the possible combinations here, as this suite is becoming time consuming - lines = plot(WorkspaceName2D, [0,1], '--g', tool='plot_spectrum') - self.check_output_lines(lines, 2) - self.close_win(lines) - - lines = plot(WorkspaceName2D, [0,1], 'y:>', tool='plot_sp') - self.check_output_lines(lines, 2) - self.close_win(lines) - - def test_plot_with_style_args_and_kwargs(self): - lines = plot(WorkspaceName2D, [0,1], '-.m', tool='spectrum') - self.check_output_lines(lines, 2) - self.close_win(lines) - - lines = plot(WorkspaceName2D, [0,1], 'r-.>', tool='sp') - self.check_output_lines(lines, 2) - self.close_win(lines) - - def test_plot_with_kwargs(self): - lines = plot(WorkspaceName2D, [0,1], tool='plot_spectrum', linewidth=3, linestyle='-.', marker='v') - self.check_output_lines(lines, 2) - self.close_win(lines) - - lines = plot(WorkspaceName2D, [0,1], tool='plot_sp', linewidth=3, linestyle='-.', marker='v') - self.check_output_lines(lines, 2) - self.close_win(lines) - - lines = plot(SecondWorkspaceName2D, [0,1, 2], tool='sp', linewidth=3, linestyle='-.', marker='v') - self.check_output_lines(lines, 3) - self.close_win(lines) - - def test_plot_with_none_marker(self): - lines = plot(WorkspaceName2D, [0,1], tool='plot_spectrum', linestyle='--', marker=None) - self.check_output_lines(lines, 2) - self.close_win(lines) - - lines = plot(WorkspaceName2D, 0, tool='plot_spectrum', color='y', marker='None') - self.check_output_lines(lines, 1) - self.close_win(lines) - - def test_wrong_kwargs(self): - # funny kwargs should have no big consequences - lines = plot(WorkspaceName2D, [0,1], tool='plot_spectrum', linewidth=3, linestyle='-.', - marker='v', funny_foo='bar', funny_baz='qux') - self.check_output_lines(lines, 2) - self.close_win(lines) - - def test_multi_plot_commands(self): - lines = plot(WorkspaceName2D, [0,1], SecondWorkspaceName2D, [0, 1, 2]) - self.check_output_lines(lines, 5) - self.close_win(lines) - - lines = plot(WorkspaceName2D, [0,1], SecondWorkspaceName2D, [0, 1, 2]) - self.check_output_lines(lines, 5) - self.close_win(lines) - - # this one mixes up positional and kw args - self.assertRaises(ValueError, plot, - WorkspaceName2D, [0,1], WorkspaceName2D, tool='plot_spectrum') - - def test_savefig(self): - # save a minimal figure just to check that the file is written - import os - - lines = plot([0, 0.5, 0.1]) - tmp_figname = 'pyplot_tmp_fig_test.png' - savefig(tmp_figname) - self.close_win(lines) - - self.assertTrue(os.path.exists(tmp_figname)) - os.remove(tmp_figname) - -# Run the unit tests -mantidplottests.runTests(MantidPlotPyplotGeneralTest) diff --git a/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAuto.py b/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAuto.py deleted file mode 100644 index f61dc4634f95d9e9c7c45bbc92b1cf19a361fda8..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAuto.py +++ /dev/null @@ -1,55 +0,0 @@ -# pylint: disable=no-init,invalid-name,attribute-defined-outside-init -""" -This system test verifies that OFFSPEC data is processed correctly by -ReflectometryReductionOneAuto -""" - -import stresstesting -from mantid.simpleapi import * - - -class OFFSPECReflRedOneAuto(stresstesting.MantidStressTest): - def runTest(self): - offspec75 = Load("OFFSPEC00027575.raw") #th=0.35 - offspec76 = Load("OFFSPEC00027576.raw") #th=1.00 - offspec78 = Load("OFFSPEC00027578.raw") #th=1.70 - offspec85 = Load("OFFSPEC00027585.raw") #transmission run - - #Process using ReflectometryReductionOneAuto - ivq_75, __, __ = ReflectometryReductionOneAuto(offspec75, - ThetaIn=0.70,#2*th - MomentumTransferStep=1e-3, - FirstTransmissionRun=offspec85, - Version=1) - - ivq_76, __, __ = ReflectometryReductionOneAuto(offspec76, - ThetaIn=2.00,#2*th - MomentumTransferStep=1e-3, - FirstTransmissionRun=offspec85, - Version=1) - - ivq_78, __, __ = ReflectometryReductionOneAuto(offspec78, - ThetaIn=3.40,#2*th - MomentumTransferStep=1e-3, - FirstTransmissionRun=offspec85, - Version=1) - - ivq_75_76, __ = Stitch1D(ivq_75, ivq_76, Params="1e-3") - #pylint: disable=unused-variable - ivq_75_76_78, __ = Stitch1D(ivq_75_76, ivq_78, Params="0,1e-3,0.25") - return True - - def validate(self): - ''' - we only wish to check the Q-range in this system test. It is not necessary - to check the Instrument definition or Instrument Parameters - ''' - self.disableChecking = ["Instrument"] - return ("ivq_75_76_78","OFFSPECReflRedOneAuto_good_v3.nxs") - - def requiredFiles(self): - return ["OFFSPEC00027575.raw", - "OFFSPEC00027576.raw", - "OFFSPEC00027578.raw", - "OFFSPEC00027585.raw", - "OFFSPECReflRedOneAuto_good_v3.nxs"] diff --git a/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAutoPolarizationCorrection.py b/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAutoPolarizationCorrection.py deleted file mode 100644 index b4aaf1e46802965bff96694d9069b9289226984d..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/OFFSPECReflRedOneAutoPolarizationCorrection.py +++ /dev/null @@ -1,48 +0,0 @@ -# pylint: disable=no-init, invalid-name, line-too-long, attribute-defined-outside-init - -""" -This system test verifies that OFFSPEC data is processed correctly -by ReflectometryReductionAutoOne with PolarizationCorrection performed -as part of the workflow. -""" - -import stresstesting -from mantid.simpleapi import * - - -class OFFSPECReflRedOneAutoPolarizationCorrection(stresstesting.MantidStressTest): - def runTest(self): - inputWorkspace = Load("OFFSPEC00033767.nxs") - transmissionGroup = Load("OFFSPEC00033772.nxs") - #set up our transmission workspace - transWorkspace = CreateTransmissionWorkspaceAuto(transmissionGroup, - AnalysisMode="MultiDetectorAnalysis", - ProcessingInstructions="110-120", - WavelengthMin=2.0, WavelengthMax=12.0, Version=1) - # set up our efficiency constants - CRho=[1] - CAlpha=[1] - CAp=[1] - CPp=[1] - #run reflectometryReductionOneAuto - __, _IvsLam_polCorr,__ = ReflectometryReductionOneAuto(inputWorkspace, AnalysisMode="MultiDetectorAnalysis", - ProcessingInstructions="110-120", - FirstTransmissionRun=transWorkspace, - ThetaIn="1.2",WavelengthMin=2.0, - WavelengthMax=12.0,CorrectionAlgorithm='None', - PolarizationAnalysis='PA', MomentumTransferStep=0.1, - CPp=CPp,CAp=CAp,CRho=CRho,CAlpha=CAlpha, Version=1) - return True - - def validate(self): - ''' - we only wish to check the data from PolarizationCorrection in this system test. - It is not necessary to check the Instrument definition or Instrument Parameters - ''' - self.disableChecking = ["Instrument"] - return ("_IvsLam_polCorr", "OFFSPECReflRedOneAutoPolarizationCorrection_good_v2.nxs") - - def requiredFiles(self): - return ["OFFSPEC00033767.nxs", - "OFFSPEC00033772.nxs", - "OFFSPECReflRedOneAutoPolarizationCorrection_good_v2.nxs"] diff --git a/Testing/SystemTests/tests/analysis/REFLReduction.py b/Testing/SystemTests/tests/analysis/REFLReduction.py deleted file mode 100644 index 695a73a25b62e09ee0979c5f1eb46c5fe32801d7..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/REFLReduction.py +++ /dev/null @@ -1,44 +0,0 @@ -#pylint: disable=no-init,attribute-defined-outside-init -import stresstesting -from mantid import * -from mantid.simpleapi import * - - -class REFLReduction(stresstesting.MantidStressTest): - def runTest(self): - #TODO: The reduction algorithm should not require an absolute path - scaling_factor_file = FileFinder.getFullPath("directBeamDatabaseFall2014_IPTS_11601_2.cfg") - - RefLReduction(RunNumbers=[119814], - NormalizationRunNumber=119690, - SignalPeakPixelRange=[154, 166], - SubtractSignalBackground=True, - SignalBackgroundPixelRange=[151, 169], - NormFlag=True, - NormPeakPixelRange=[154, 160], - NormBackgroundPixelRange=[151, 163], - SubtractNormBackground=True, - LowResDataAxisPixelRangeFlag=True, - LowResDataAxisPixelRange=[99, 158], - LowResNormAxisPixelRangeFlag=True, - LowResNormAxisPixelRange=[98, 158], - TOFRange=[29623.0, 42438.0], - IncidentMediumSelected='2InDiamSi', - GeometryCorrectionFlag=False, - QMin=0.005, - QStep=0.01, - AngleOffset=0.009, - AngleOffsetError=0.001, - ScalingFactorFile=scaling_factor_file, - SlitsWidthFlag=True, - OutputWorkspace='reflectivity_119814') - - def validate(self): - # Be more tolerant with the output. - self.tolerance = 0.0001 - - self.disableChecking.append('Instrument') - self.disableChecking.append('Sample') - self.disableChecking.append('SpectraMap') - self.disableChecking.append('Axes') - return "reflectivity_119814", 'REFL_119814_combined_data.nxs' diff --git a/Testing/SystemTests/tests/analysis/REFLWithBackground.py b/Testing/SystemTests/tests/analysis/REFLWithBackground.py deleted file mode 100644 index 356ebf18a0e156634c43a822901096a0a036bf67..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/REFLWithBackground.py +++ /dev/null @@ -1,44 +0,0 @@ -#pylint: disable=no-init,attribute-defined-outside-init -import stresstesting -from mantid import * -from mantid.simpleapi import * - - -class REFLWithBackground(stresstesting.MantidStressTest): - def runTest(self): - #TODO: The reduction algorithm should not require an absolute path - scaling_factor_file = FileFinder.getFullPath("directBeamDatabaseFall2014_IPTS_11601_2.cfg") - - RefLReduction(RunNumbers=[119816], - NormalizationRunNumber=119692, - SignalPeakPixelRange=[155, 165], - SubtractSignalBackground=True, - SignalBackgroundPixelRange=[146, 165], - NormFlag=True, - NormPeakPixelRange=[154, 162], - NormBackgroundPixelRange=[151, 165], - SubtractNormBackground=True, - LowResDataAxisPixelRangeFlag=True, - LowResDataAxisPixelRange=[99, 158], - LowResNormAxisPixelRangeFlag=True, - LowResNormAxisPixelRange=[118, 137], - TOFRange=[9610, 22425], - IncidentMediumSelected='2InDiamSi', - GeometryCorrectionFlag=False, - QMin=0.005, - QStep=0.01, - AngleOffset=0.009, - AngleOffsetError=0.001, - ScalingFactorFile=scaling_factor_file, - SlitsWidthFlag=True, - OutputWorkspace='reflectivity_119816') - - def validate(self): - # Be more tolerant with the output. - self.tolerance = 0.0001 - - self.disableChecking.append('Instrument') - self.disableChecking.append('Sample') - self.disableChecking.append('SpectraMap') - self.disableChecking.append('Axes') - return "reflectivity_119816", 'REFL_119816.nxs' diff --git a/Testing/SystemTests/tests/analysis/REFMReduction.py b/Testing/SystemTests/tests/analysis/REFMReduction.py deleted file mode 100644 index 0174b83145e1c2d237947c87313d1b2d1f61ccdb..0000000000000000000000000000000000000000 --- a/Testing/SystemTests/tests/analysis/REFMReduction.py +++ /dev/null @@ -1,36 +0,0 @@ -#pylint: disable=no-init,attribute-defined-outside-init -import stresstesting -from mantid import * - -from mantid.simpleapi import * - - -class REFMReduction(stresstesting.MantidStressTest): - def runTest(self): - RefReduction(DataRun=str(9709), - NormalizationRun=str(9684), - SignalPeakPixelRange=[216, 224], - SubtractSignalBackground=True, - SignalBackgroundPixelRange=[172, 197], - PerformNormalization=True, - NormPeakPixelRange=[226, 238], - NormBackgroundPixelRange=[130, 183], - SubtractNormBackground=False, - CropLowResDataAxis=True, - CropLowResNormAxis=False, - LowResDataAxisPixelRange = [86, 159], - NBins=40, - Theta=0.086, - PolarizedData=True, - Instrument="REF_M", - OutputWorkspacePrefix='reflectivity') - - def validate(self): - # Be more tolerant with the output, mainly because of the errors. - # The following tolerance check the errors up to the third digit. - self.tolerance = 0.25 - self.disableChecking.append('Instrument') - self.disableChecking.append('Sample') - self.disableChecking.append('SpectraMap') - self.disableChecking.append('Axes') - return "reflectivity-Off_Off", 'REFMReduction_off_off.nxs' diff --git a/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py b/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py index fa50ef68a99925cc341bfb8bcf241347c0be1b4e..1bcc521268f9098643e669d290d5201f13c04ed2 100644 --- a/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSBatchReductionTest.py @@ -10,6 +10,7 @@ from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, ISISReductionMode, OutputMode) from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm +from sans.common.file_information import SANSFileInformationFactory # ----------------------------------------------- @@ -60,7 +61,10 @@ class SANSBatchReductionTest(unittest.TestCase): def test_that_batch_reduction_evaluates_LAB(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -73,7 +77,7 @@ class SANSBatchReductionTest(unittest.TestCase): data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB) @@ -104,13 +108,16 @@ class SANSBatchReductionTest(unittest.TestCase): def test_batch_reduction_on_multiperiod_file(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D0005512") + + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D0005512") data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("MASKSANS2Doptions.091A") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB) diff --git a/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py b/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py index 0e804a29ca70327c0ccceda3ffb6d277da6f57d5..93ae75e3eb0c5faf8476c5554540a8e216dcb2cb 100644 --- a/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py +++ b/Testing/SystemTests/tests/analysis/SANSBeamCentreFinderCoreTest.py @@ -13,6 +13,7 @@ from sans.common.enums import (DetectorType, DataType, SANSFacility) from sans.user_file.state_director import StateDirectorISIS from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm +from sans.common.file_information import SANSFileInformationFactory # ----------------------------------------------- @@ -139,7 +140,10 @@ class SANSBeamCentreFinderCoreTest(unittest.TestCase): def test_that_beam_centre_core_produces_correct_workspaces(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -147,7 +151,7 @@ class SANSBeamCentreFinderCoreTest(unittest.TestCase): data_state = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_state) + user_file_director = StateDirectorISIS(data_state, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py b/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py index fdf746abf2015e956f1d4194b817d37e74437026..e66b54b735d21feecd6230cdb0d8b6ee0ebdd8a5 100644 --- a/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py +++ b/Testing/SystemTests/tests/analysis/SANSDiagnosticPageTest.py @@ -13,6 +13,7 @@ from sans.user_file.state_director import StateDirectorISIS from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm from sans.gui_logic.models.diagnostics_page_model import run_integral +from sans.common.file_information import SANSFileInformationFactory # ----------------------------------------------- @@ -72,13 +73,15 @@ class SANSDiagnosticPageTest(unittest.TestCase): def test_that_produces_correct_workspace_for_SANS2D(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_calibration("TUBE_SANS2D_BOTH_31681_25Sept15.nxs") data_state = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_state) + user_file_director = StateDirectorISIS(data_state, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! @@ -104,13 +107,15 @@ class SANSDiagnosticPageTest(unittest.TestCase): def test_that_produces_correct_workspace_multiperiod_LARMOR(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("LARMOR00013065") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("LARMOR00013065") data_builder.set_calibration("80tubeCalibration_1-05-2015_r3157-3160.nxs") data_state = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_state) + user_file_director = StateDirectorISIS(data_state, file_information) user_file_director.set_user_file("USER_LARMOR_151B_LarmorTeam_80tubes_BenchRot1p4_M4_r3699.txt") # Construct the final state diff --git a/Testing/SystemTests/tests/analysis/SANSLoadTest.py b/Testing/SystemTests/tests/analysis/SANSLoadTest.py index 931ace253e87b295c2df3c5576e91ee69f0b8b6c..154b26f95f78e853e923bf16750aa137cf87f363 100644 --- a/Testing/SystemTests/tests/analysis/SANSLoadTest.py +++ b/Testing/SystemTests/tests/analysis/SANSLoadTest.py @@ -17,6 +17,7 @@ from sans.common.constants import (CALIBRATION_WORKSPACE_TAG, SANS_FILE_TAG) from sans.test_helper.test_director import TestDirector from sans.common.enums import SANSFacility from sans.state.data import get_data_builder +from sans.common.file_information import SANSFileInformationFactory def remove_all_workspaces_from_ads(): @@ -48,9 +49,11 @@ class SANSLoadFactoryTest(unittest.TestCase): def test_that_valid_file_information_does_not_raise(self): # Arrange load_factory = SANSLoadDataFactory() + file_information_factory = SANSFileInformationFactory() ws_name_sample = "SANS2D00022024" - data_builder = get_data_builder(SANSFacility.ISIS) + file_information = file_information_factory.create_sans_file_information(ws_name_sample) + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter(ws_name_sample) data = data_builder.build() @@ -77,7 +80,10 @@ class SANSLoadTest(unittest.TestCase): can_scatter=None, can_trans=None, can_direct=None, calibration=None, sample_scatter_period=None, sample_trans_period=None, sample_direct_period=None, can_scatter_period=None, can_trans_period=None, can_direct_period=None): - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information(sample_scatter) + + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter(sample_scatter) # Set the file names diff --git a/Testing/SystemTests/tests/analysis/SANSMaskWorkspaceTest.py b/Testing/SystemTests/tests/analysis/SANSMaskWorkspaceTest.py index e13344e5d13db3dffbc24fd082199c5ce5f26e52..068fbf1bec195b7a5aa00a9d8e95f11c0c9b2045 100644 --- a/Testing/SystemTests/tests/analysis/SANSMaskWorkspaceTest.py +++ b/Testing/SystemTests/tests/analysis/SANSMaskWorkspaceTest.py @@ -11,6 +11,7 @@ from sans.common.enums import SANSFacility from sans.test_helper.test_director import TestDirector from sans.state.data import get_data_builder from sans.state.mask import get_mask_builder +from sans.common.file_information import SANSFileInformationFactory def get_masked_spectrum_numbers(workspace): @@ -95,7 +96,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_spectra_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() @@ -168,7 +171,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_block_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() @@ -210,7 +215,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_cross_block_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() @@ -264,7 +271,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): file_name = create_shape_xml_file(shape_xml) # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() mask_builder = get_mask_builder(data_info) @@ -293,7 +302,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_general_time_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() mask_builder = get_mask_builder(data_info) @@ -339,7 +350,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_detector_specific_time_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() mask_builder = get_mask_builder(data_info) @@ -379,7 +392,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_angle_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() @@ -427,7 +442,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_beam_stop_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() mask_builder = get_mask_builder(data_info) @@ -463,7 +480,9 @@ class SANSMaskWorkspaceTest(unittest.TestCase): def test_that_cylinder_masking_is_applied(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00028827") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00028827") data_info = data_builder.build() mask_builder = get_mask_builder(data_info) diff --git a/Testing/SystemTests/tests/analysis/SANSMoveTest.py b/Testing/SystemTests/tests/analysis/SANSMoveTest.py index 0592d97700c9bb57c2e99460ee394179144af7f3..dc03d813eb54aebcb5637625338a005dd03f944a 100644 --- a/Testing/SystemTests/tests/analysis/SANSMoveTest.py +++ b/Testing/SystemTests/tests/analysis/SANSMoveTest.py @@ -16,6 +16,7 @@ from sans.common.enums import (SANSFacility, DetectorType) from sans.test_helper.test_director import TestDirector from sans.state.move import get_move_builder from sans.state.data import get_data_builder +from sans.common.file_information import SANSFileInformationFactory def load_workspace(file_name): @@ -67,7 +68,9 @@ class SANSMoveTest(unittest.TestCase): @staticmethod def _get_simple_state(sample_scatter, lab_x_translation_correction=None, lab_z_translation_correction=None): # Set the data - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information(sample_scatter) + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter(sample_scatter) data_info = data_builder.build() diff --git a/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py b/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py index 7f63d5befa5ade499a17274795aba721758b7cb9..a9a4537a6459177aa4dd1f3b402548b3157076ab 100644 --- a/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py +++ b/Testing/SystemTests/tests/analysis/SANSReductionCoreTest.py @@ -13,6 +13,7 @@ from sans.common.enums import (DetectorType, DataType, SANSFacility) from sans.user_file.state_director import StateDirectorISIS from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm +from sans.common.file_information import SANSFileInformationFactory # ----------------------------------------------- @@ -131,7 +132,9 @@ class SANSReductionCoreTest(unittest.TestCase): def test_that_reduction_core_evaluates_LAB(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -139,7 +142,7 @@ class SANSReductionCoreTest(unittest.TestCase): data_state = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_state) + user_file_director = StateDirectorISIS(data_state, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! diff --git a/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py b/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py index 4baa83623cd38ef79eee916eaa4a6fe76c64d63b..e7f10a0ef7c6435b2ba59641503cb136cd2669b3 100644 --- a/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py +++ b/Testing/SystemTests/tests/analysis/SANSSingleReductionTest.py @@ -11,6 +11,7 @@ from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, ISISReductionMode, ReductionDimensionality, FitModeForMerge) from sans.common.constants import EMPTY_NAME from sans.common.general_functions import create_unmanaged_algorithm +from sans.common.file_information import SANSFileInformationFactory # ----------------------------------------------- @@ -126,7 +127,9 @@ class SANSSingleReductionTest(unittest.TestCase): def test_that_single_reduction_evaluates_LAB(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -138,7 +141,7 @@ class SANSSingleReductionTest(unittest.TestCase): data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB) @@ -178,7 +181,9 @@ class SANSSingleReductionTest(unittest.TestCase): def test_that_single_reduction_evaluates_HAB(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -190,7 +195,7 @@ class SANSSingleReductionTest(unittest.TestCase): data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.HAB) @@ -230,7 +235,9 @@ class SANSSingleReductionTest(unittest.TestCase): def test_that_single_reduction_evaluates_merged(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -242,7 +249,7 @@ class SANSSingleReductionTest(unittest.TestCase): data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.Merged) @@ -293,7 +300,9 @@ class SANSSingleReductionTest(unittest.TestCase): def test_that_single_reduction_evaluates_LAB_for_2D_reduction(self): # Arrange # Build the data information - data_builder = get_data_builder(SANSFacility.ISIS) + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information("SANS2D00034484") + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00034484") data_builder.set_sample_transmission("SANS2D00034505") data_builder.set_sample_direct("SANS2D00034461") @@ -305,7 +314,7 @@ class SANSSingleReductionTest(unittest.TestCase): data_info = data_builder.build() # Get the rest of the state from the user file - user_file_director = StateDirectorISIS(data_info) + user_file_director = StateDirectorISIS(data_info, file_information) user_file_director.set_user_file("USER_SANS2D_154E_2p4_4m_M3_Xpress_8mm_SampleChanger.txt") # Set the reduction mode to LAB user_file_director.set_reduction_builder_reduction_mode(ISISReductionMode.LAB) diff --git a/Testing/SystemTests/tests/analysis/SortHKLTest.py b/Testing/SystemTests/tests/analysis/SortHKLTest.py index 31618635e17605442fd5c7eaa82794f4b55dc03d..2360e0f09ec889e2e8294a768afc36202ca4e1ab 100644 --- a/Testing/SystemTests/tests/analysis/SortHKLTest.py +++ b/Testing/SystemTests/tests/analysis/SortHKLTest.py @@ -116,9 +116,9 @@ class SortHKLTest(HKLStatisticsTestMixin, stresstesting.MantidStressTest): centering_name = self._centering_map[space_group[0]] # pylint: disable=unused-variable - sorted_hkls, chi2, statistics = SortHKL(InputWorkspace=reflections, - PointGroup=point_group_name, - LatticeCentering=centering_name) + sorted_hkls, chi2, statistics, equivInten = SortHKL(InputWorkspace=reflections, + PointGroup=point_group_name, + LatticeCentering=centering_name) return statistics.row(0), sorted_hkls diff --git a/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py b/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py index 43d0db3aa068eafe603bdf17361e06b4926ebb71..54709bc99223e9c6ce96f7f1719e375472e77761 100644 --- a/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py +++ b/Testing/SystemTests/tests/analysis/VesuvioCommandsTest.py @@ -22,6 +22,8 @@ def _is_old_boost_version(): if any(dist): if 'Red Hat' in dist[0] and dist[1].startswith('7'): return True + if 'Scientific Linux' in dist[0] and dist[1].startswith('7'): + return True if dist[0] == 'Ubuntu' and dist[1] == '14.04': return True diff --git a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py index a91e3fcfa216bc4efc236abf825bb7d0bc5c2314..4f1d4f67a6e00f4deb6d289506c9b683ccbd181a 100644 --- a/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py +++ b/Testing/SystemTests/tests/analysis/VesuvioCorrectionsTest.py @@ -53,6 +53,8 @@ def _is_old_boost_version(): if any(dist): if 'Red Hat' in dist[0] and dist[1].startswith('7'): return True + if 'Scientific Linux' in dist[0] and dist[1].startswith('7'): + return True if dist[0] == 'Ubuntu' and dist[1] == '14.04': return True diff --git a/Testing/SystemTests/tests/analysis/reference/L2QReferenceResult.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/L2QReferenceResult.nxs.md5 index 309459a3b1c478ef048fa1a80b8d26c0a545a267..e2e298fb93f01e9614ef7e7179e3fb5c7693ca26 100644 --- a/Testing/SystemTests/tests/analysis/reference/L2QReferenceResult.nxs.md5 +++ b/Testing/SystemTests/tests/analysis/reference/L2QReferenceResult.nxs.md5 @@ -1 +1 @@ -57144b9309c8dbb1232a15c6daa2e904 \ No newline at end of file +1445797a969c8f96e9ffe402af0dded7 diff --git a/Testing/SystemTests/tests/analysis/reference/QuickReferenceResult.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/QuickReferenceResult.nxs.md5 index 74079775cfa039ecf45d8f2b179315ca03272c8b..15dd6430cabde6b3f4a2d6bd259bbf5e142d8219 100644 --- a/Testing/SystemTests/tests/analysis/reference/QuickReferenceResult.nxs.md5 +++ b/Testing/SystemTests/tests/analysis/reference/QuickReferenceResult.nxs.md5 @@ -1 +1 @@ -24e66b8ccfde55c58ac97d71d736211d \ No newline at end of file +0e367a48dd764b901c9176d37f5bf713 diff --git a/Testing/SystemTests/tests/analysis/reference/QuickStitchedReferenceResult.nxs.md5 b/Testing/SystemTests/tests/analysis/reference/QuickStitchedReferenceResult.nxs.md5 index 7966506607d91e3e7274a8fa01a8a5425dcb2bad..4a3b6c8a4078e8aa65e5f85670abc29eb8cd83c5 100644 --- a/Testing/SystemTests/tests/analysis/reference/QuickStitchedReferenceResult.nxs.md5 +++ b/Testing/SystemTests/tests/analysis/reference/QuickStitchedReferenceResult.nxs.md5 @@ -1 +1 @@ -8f7725692c8f287ce01b8648e64e70b2 \ No newline at end of file +f19753635948066d7ce6a45e58640f6f diff --git a/buildconfig/CMake/DarwinSetup.cmake b/buildconfig/CMake/DarwinSetup.cmake index 4fb0b32f8552dee6eefdea1f3a072551b3209225..5f18b652f2be1eb9e9af3eb618ca0b5cff9d42b4 100644 --- a/buildconfig/CMake/DarwinSetup.cmake +++ b/buildconfig/CMake/DarwinSetup.cmake @@ -84,10 +84,18 @@ if ( NOT TARGET mantidpython ) configure_file ( ${CMAKE_MODULE_PATH}/Packaging/osx/mantidpython_osx ${CMAKE_BINARY_DIR}/mantidpython_osx_install @ONLY ) endif () + +# directives similar to linux for conda framework-only build +set ( BIN_DIR bin ) +set ( ETC_DIR etc ) +set ( LIB_DIR lib ) +set ( PLUGINS_DIR plugins ) + + ########################################################################### # Mac-specific installation setup ########################################################################### - +if ( ENABLE_MANTIDPLOT ) set ( CMAKE_INSTALL_PREFIX "" ) set ( CPACK_PACKAGE_EXECUTABLES MantidPlot ) set ( INBUNDLE MantidPlot.app/ ) @@ -199,3 +207,4 @@ set ( MACOSX_BUNDLE_ICON_FILE MantidPlot.icns ) string (REPLACE " " "" CPACK_SYSTEM_NAME ${OSX_CODENAME}) set ( CPACK_GENERATOR DragNDrop ) +endif () \ No newline at end of file diff --git a/buildconfig/CMake/FindSphinx.cmake b/buildconfig/CMake/FindSphinx.cmake index ddffff3e2e56c679c41886cfd80e795bc0eb5b09..4db68670cd43af51d89107fd272a8e7df962659a 100644 --- a/buildconfig/CMake/FindSphinx.cmake +++ b/buildconfig/CMake/FindSphinx.cmake @@ -11,22 +11,14 @@ # main() #============================================================= - -FIND_FILE(_find_sphinx_py FindSphinx.py PATHS ${CMAKE_MODULE_PATH}) - -if (version_string) # chop out the version number - string (REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1" SPHINX_VERSION ${version_string}) -endif() - +find_file (_find_sphinx_py FindSphinx.py PATHS ${CMAKE_MODULE_PATH}) # import sphinx-build to attempt to get the version execute_process (COMMAND ${PYTHON_EXECUTABLE} ${_find_sphinx_py} OUTPUT_VARIABLE sphinx_output RESULT_VARIABLE sphinx_result) +string (STRIP "${sphinx_output}" sphinx_output) -if (${sphinx_result} STREQUAL "0")# AND version_string) - if (version_string) - list(GET sphinx_output 0 version_string) - endif() +if (${sphinx_result} STREQUAL "0") list(GET sphinx_output 1 SPHINX_PACKAGE_DIR) else() message(STATUS "failed to run FindSphinx.py returned ${sphinx_result}") diff --git a/buildconfig/CMake/FindSphinx.py b/buildconfig/CMake/FindSphinx.py index 3e2ba70b4e354ee931a1cca601e1f98d6284b481..ecb75f60f01bd3bc347be8bf335b02aeb1b0f353 100644 --- a/buildconfig/CMake/FindSphinx.py +++ b/buildconfig/CMake/FindSphinx.py @@ -1,2 +1,3 @@ +import os.path as osp import sphinx -print('{0};{1}'.format(sphinx.__version__, sphinx.package_dir)) +print('{0};{1}'.format(sphinx.__version__, osp.dirname(sphinx.__file__))) diff --git a/buildconfig/CMake/GoogleTest.in b/buildconfig/CMake/GoogleTest.in index 2db620992e6e46d906686238da87c07ad3f50c5b..e37efa6f5bfca2f3074140a7607c69afd960982e 100644 --- a/buildconfig/CMake/GoogleTest.in +++ b/buildconfig/CMake/GoogleTest.in @@ -15,6 +15,7 @@ ExternalProject_Add(googletest PATCH_COMMAND "@GIT_EXECUTABLE@" reset --hard ${_tag} COMMAND "@GIT_EXECUTABLE@" apply --whitespace fix "@CMAKE_SOURCE_DIR@/buildconfig/CMake/googletest_override.patch" COMMAND "@GIT_EXECUTABLE@" apply --whitespace fix "@CMAKE_SOURCE_DIR@/buildconfig/CMake/googletest_static.patch" + COMMAND "@GIT_EXECUTABLE@" apply --whitespace fix "@CMAKE_SOURCE_DIR@/buildconfig/CMake/googletest_msvc_cpp11.patch" CONFIGURE_COMMAND "" BUILD_COMMAND "" INSTALL_COMMAND "" diff --git a/buildconfig/CMake/googletest_msvc_cpp11.patch b/buildconfig/CMake/googletest_msvc_cpp11.patch new file mode 100644 index 0000000000000000000000000000000000000000..339251b3bcb19f54b863abb811b0eaa12c7d3cf9 --- /dev/null +++ b/buildconfig/CMake/googletest_msvc_cpp11.patch @@ -0,0 +1,41 @@ +diff --git a/googletest/include/gtest/internal/gtest-port.h b/googletest/include/gtest/internal/gtest-port.h +index 5529ba544..331483e73 100644 +--- a/googletest/include/gtest/internal/gtest-port.h ++++ b/googletest/include/gtest/internal/gtest-port.h +@@ -325,7 +325,7 @@ + // -std={c,gnu}++{0x,11} is passed. The C++11 standard specifies a + // value for __cplusplus, and recent versions of clang, gcc, and + // probably other compilers set that too in C++11 mode. +-# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L ++# if __GXX_EXPERIMENTAL_CXX0X__ || __cplusplus >= 201103L || _MSC_VER >= 1900 + // Compiling in at least C++11 mode. + # define GTEST_LANG_CXX11 1 + # else +@@ -357,12 +357,16 @@ + #if GTEST_STDLIB_CXX11 + # define GTEST_HAS_STD_BEGIN_AND_END_ 1 + # define GTEST_HAS_STD_FORWARD_LIST_ 1 +-# define GTEST_HAS_STD_FUNCTION_ 1 ++# if !defined(_MSC_VER) || (_MSC_FULL_VER >= 190023824) // works only with VS2015U2 and better ++# define GTEST_HAS_STD_FUNCTION_ 1 ++# endif + # define GTEST_HAS_STD_INITIALIZER_LIST_ 1 + # define GTEST_HAS_STD_MOVE_ 1 + # define GTEST_HAS_STD_SHARED_PTR_ 1 + # define GTEST_HAS_STD_TYPE_TRAITS_ 1 + # define GTEST_HAS_STD_UNIQUE_PTR_ 1 ++# define GTEST_HAS_UNORDERED_MAP_ 1 ++# define GTEST_HAS_UNORDERED_SET_ 1 + #endif + + // C++11 specifies that <tuple> provides std::tuple. +@@ -660,7 +664,8 @@ typedef struct _RTL_CRITICAL_SECTION GTEST_CRITICAL_SECTION; + // support TR1 tuple. libc++ only provides std::tuple, in C++11 mode, + // and it can be used with some compilers that define __GNUC__. + # if (defined(__GNUC__) && !defined(__CUDACC__) && (GTEST_GCC_VER_ >= 40000) \ +- && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) || _MSC_VER >= 1600 ++ && !GTEST_OS_QNX && !defined(_LIBCPP_VERSION)) \ ++ || (_MSC_VER >= 1600 && _MSC_VER < 1900) + # define GTEST_ENV_HAS_TR1_TUPLE_ 1 + # endif + diff --git a/buildconfig/Jenkins/buildscript b/buildconfig/Jenkins/buildscript index ce0f5519f113e149e442e91c0799093d3bb11f97..814eca620ec6dab2214bae1d686912c19132efc1 100755 --- a/buildconfig/Jenkins/buildscript +++ b/buildconfig/Jenkins/buildscript @@ -14,7 +14,7 @@ SCRIPT_DIR=$(dirname "$0") ############################################################################### # System discovery ############################################################################### -if [[ ${NODE_LABELS} == *rhel7* ]] || [[ ${NODE_LABELS} == *centos7* ]]; then +if [[ ${NODE_LABELS} == *rhel7* ]] || [[ ${NODE_LABELS} == *centos7* ]] || [[ ${NODE_LABELS} == *scilin7* ]]; then ON_RHEL7=true fi if [[ ${NODE_LABELS} == *ubuntu* ]]; then @@ -25,7 +25,7 @@ if [[ ${NODE_LABELS} == *osx* ]]; then fi ############################################################################### -# All nodes currently have PARAVIEW_DIR=5.2.0 and PARAVIEW_NEXT_DIR=5.3.0-RC1 +# All nodes currently have PARAVIEW_DIR and PARAVIEW_NEXT_DIR set ############################################################################### export PARAVIEW_DIR=${PARAVIEW_DIR} @@ -68,18 +68,36 @@ fi # For pull requests decide on what to build based on changeset and Jenkins # parameters. -BUILDPKG=true -SYSTEMTESTS=false +DO_BUILD_CODE=true +DO_UNITTESTS=true +DO_DOCTESTS_USER=true +DO_BUILD_DEVDOCS=true +DO_BUILD_PKG=true +DO_SYSTEMTESTS=false if [[ ${PRBUILD} == true ]]; then - if [[ -n ${BUILD_PACKAGE} ]]; then - BUILDPKG=${BUILD_PACKAGE} + if ${SCRIPT_DIR}/check_for_changes dev-docs-only || ${SCRIPT_DIR}/check_for_changes user-docs-only; then + DO_BUILD_CODE=false + DO_UNITTESTS=false fi + DO_DOCTESTS_USER=false + DO_BUILD_DEVDOCS=false + DO_BUILD_PKG=${BUILD_PACKAGE:-false} + DO_SYSTEMTESTS=false + if [[ ${ON_RHEL7} == true ]]; then - if ${SCRIPT_DIR}/check_for_changes docs-gui-only; then - SYSTEMTESTS=false + # rhel does system testing + if ! ${SCRIPT_DIR}/check_for_changes docs-gui-only; then + DO_BUILD_PKG=true + DO_SYSTEMTESTS=true + fi + elif [[ ${ON_UBUNTU} == true ]]; then + # ubuntu does the docs build + if ${SCRIPT_DIR}/check_for_changes dev-docs-only; then + DO_BUILD_CODE=false + DO_DOCTESTS_USER=false else - BUILDPKG=true - SYSTEMTESTS=true + DO_BUILD_CODE=true # code needs to be up to date + DO_DOCTESTS_USER=true fi fi fi @@ -105,6 +123,7 @@ if [[ "$CLEANBUILD" == true ]]; then fi if [ -d $BUILD_DIR ]; then rm -rf ${BUILD_DIR:?}/bin ${BUILD_DIR:?}/ExternalData + find ${BUILD_DIR:?} -name 'TEST-*.xml' -delete if [[ -n ${CLEAN_EXTERNAL_PROJECTS} && "${CLEAN_EXTERNAL_PROJECTS}" == true ]]; then rm -rf $BUILD_DIR/eigen-* rm -rf $BUILD_DIR/googletest-* @@ -183,7 +202,7 @@ fi ############################################################################### # Packaging options ############################################################################### -if [[ "$BUILDPKG" == true ]]; then +if [[ ${DO_BUILD_PKG} == true ]]; then PACKAGINGVARS="-DPACKAGE_DOCS=ON" # Set some variables relating to the linux packages if [[ "${ON_MACOS}" == true ]]; then @@ -266,11 +285,13 @@ fi ############################################################################### # Build step ############################################################################### -${CMAKE_EXE} --build . -- -j${BUILD_THREADS:?} -${CMAKE_EXE} --build . --target AllTests -- -j${BUILD_THREADS:?} +if [[ ${DO_BUILD_CODE} == true ]]; then + ${CMAKE_EXE} --build . -- -j${BUILD_THREADS:?} + ${CMAKE_EXE} --build . --target AllTests -- -j${BUILD_THREADS:?} +fi ############################################################################### -# static analysis builds stop here +# Static analysis builds or stop here ############################################################################### if [[ $USE_CLANG ]] && [[ ${JOB_NAME} == *clang_tidy* ]]; then exit 0 @@ -280,30 +301,46 @@ fi ############################################################################### # Run the unit tests ############################################################################### -# Remove any Mantid.user.properties file -userprops=~/.mantid/Mantid.user.properties -rm -f $userprops -$CTEST_EXE -j${BUILD_THREADS:?} --schedule-random --output-on-failure +# Prevent race conditions when creating the user config directory +userconfig_dir=$HOME/.mantid +rm -fr $userconfig_dir +mkdir -p $userconfig_dir +touch $userconfig_dir/Mantid.user.properties + +if [[ ${DO_UNITTESTS} == true ]]; then + $CTEST_EXE -j${BUILD_THREADS:?} --schedule-random --output-on-failure +fi ############################################################################### -# Run the documentation tests on Ubuntu when doing a pull request build but not for python 3. +# User Documentation ############################################################################### -if [[ ${ON_UBUNTU} == true ]] && [[ ${PRBUILD} == true ]]; then +if [[ ${DO_DOCTESTS_USER} == true ]]; then # Remove doctrees directory so it forces a full reparse. It seems that # without this newly added doctests are not executed if [ -d $BUILD_DIR/docs/doctrees ]; then - rm -rf $BUILD_DIR/docs/doctrees/* + rm -fr $BUILD_DIR/docs/doctrees/* fi # Build HTML to verify that no referencing errors have crept in. ${CMAKE_EXE} --build . --target docs-html ${CMAKE_EXE} --build . --target docs-test fi +############################################################################### +# Developer Documentation +############################################################################### +# Uncomment this when the dev-docs are ready to build without warnings +# if [[ ${DO_BUILD_DEVDOCS} == true ]]; then +# if [ -d $BUILD_DIR/dev-docs/doctree ]; then +# rm -fr $BUILD_DIR/dev-docs/doctree/* +# fi +# ${CMAKE_EXE} --build . --target dev-docs-html +# fi + ############################################################################### # Create the install kit if required. This includes building the Qt help # documentation ############################################################################### -if [[ ${BUILDPKG} == true ]]; then +if [[ ${DO_BUILD_PKG} == true ]]; then # Workaround so that the target can find the properties file # CMake doesn't easily allow environment variables on custom targets if [[ ${ON_MACOS} == true ]]; then @@ -328,7 +365,7 @@ fi # Run the system tests if required. Run from a package to have at least one # Linux checks it install okay ############################################################################### -if [[ ${SYSTEMTESTS} == true ]]; then +if [[ ${DO_SYSTEMTESTS} == true ]]; then if [[ ${PRBUILD} == true ]]; then EXTRA_ARGS="--exclude-in-pull-requests" $SCRIPT_DIR/systemtests else diff --git a/buildconfig/Jenkins/buildscript.bat b/buildconfig/Jenkins/buildscript.bat index 190353049b998d219c7e23b432989b6a18e8b6b6..56697b7ec81e645dddc046c7b41060bc2d0b9b6a 100755 --- a/buildconfig/Jenkins/buildscript.bat +++ b/buildconfig/Jenkins/buildscript.bat @@ -97,6 +97,7 @@ if "!CLEANBUILD!" == "yes" ( if EXIST %BUILD_DIR% ( rmdir /S /Q %BUILD_DIR%\bin %BUILD_DIR%\ExternalData + for /f %%F in ('dir /b /a-d /S "TEST-*.xml"') do del /Q %%F >/nul if "!CLEAN_EXTERNAL_PROJECTS!" == "true" ( rmdir /S /Q %BUILD_DIR%\eigen-download %BUILD_DIR%\eigen-src rmdir /S /Q %BUILD_DIR%\googletest-download %BUILD_DIR%\googletest-src @@ -157,10 +158,14 @@ if ERRORLEVEL 1 exit /B %ERRORLEVEL% ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: :: Run the tests ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::: -:: Remove the user properties file just in case anything polluted it +:: Remove any user configuration and create a blank user properties file +:: This prevents race conditions when creating the user config directory set USERPROPS=bin\%BUILD_CONFIG%\Mantid.user.properties del %USERPROPS% - +set CONFIGDIR=%APPDATA%\mantidproject\mantid +rmdir /S /Q %CONFIGDIR% +mkdir %CONFIGDIR% +call cmake.exe -E touch %USERPROPS% call ctest.exe -C %BUILD_CONFIG% -j%BUILD_THREADS% --schedule-random --output-on-failure if ERRORLEVEL 1 exit /B %ERRORLEVEL% diff --git a/buildconfig/Jenkins/check_for_changes b/buildconfig/Jenkins/check_for_changes index 27e070d4afec173ae8094bb60784b5cc765f3bb0..8c51dc4e6c601dfabcc565f428185f8b2254c5e7 100755 --- a/buildconfig/Jenkins/check_for_changes +++ b/buildconfig/Jenkins/check_for_changes @@ -18,33 +18,35 @@ case "$TYPE" in exit $(git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.py) ;; cpp) - if $(! git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.h) - then - exit $FOUND - fi - if $(! git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.cpp) - then - exit $FOUND - fi - if $(! git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.cxx) - then + git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.h || exit $FOUND + git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.cpp || exit $FOUND + git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.cxx || exit $FOUND + git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.tcc || exit $FOUND + exit $NOTFOUND + ;; + # For the -only cases FOUND=1 means that there were other changes besides the case + # Note that these checks CANNOT be replaced with "git diff --quiet ... dev-docs" because this only + # checks if there were changes in a given directory and not if they are the ONLY changes + dev-docs-only) + if git diff --name-only ${BRANCH_TIP} ${BRANCH_BASE} -- | grep -q -E -v '^dev-docs/'; then exit $FOUND + else + exit $NOTFOUND fi - if $(! git diff --quiet ${BRANCH_TIP} ${BRANCH_BASE} -- \*\.tcc) - then + ;; + user-docs-only) + if git diff --name-only ${BRANCH_TIP} ${BRANCH_BASE} -- | grep -q -E -v '^docs/'; then exit $FOUND + else + exit $NOTFOUND fi - exit $NOTFOUND ;; docs-gui-only) - # FOUND=1 iff changes are limited to docs or GUI only - # Find all changed files and grep for required type. -v inverts match so grep=0 means - # there are other changes besides this - if git diff --name-only ${BRANCH_TIP} ${BRANCH_BASE} -- | grep -q -E -v '^docs/|^dev-docs/|^qt/|^MantidPlot/'; then - exit $FOUND - else - exit $NOTFOUND - fi + if git diff --name-only ${BRANCH_TIP} ${BRANCH_BASE} -- | grep -q -E -v '^docs/|^dev-docs/|^qt/|^MantidPlot/'; then + exit $FOUND + else + exit $NOTFOUND + fi ;; *) echo "do not have case for type \"$TYPE\"" diff --git a/buildconfig/Jenkins/jenkins-slave.sh b/buildconfig/Jenkins/jenkins-slave.sh index 8d94719c1b255951dbd4bd7599dcbd17bbe0f612..4fad34ad8a3fb2684316ccb82d08d51673a63b1b 100755 --- a/buildconfig/Jenkins/jenkins-slave.sh +++ b/buildconfig/Jenkins/jenkins-slave.sh @@ -71,17 +71,18 @@ if [ -f ${HOME}/jenkins-linode/${JAR_FILE} ]; then elif [ -f ${HOME}/Jenkins/${JAR_FILE} ]; then JAR_FILE=${HOME}/Jenkins/${JAR_FILE} else - JAR_FILE=/tmp/${JAR_FILE} - if [ ! -f ${JAR_FILE} ]; then - echo "Downloading slave jar file to ${JAR_FILE}" + JAR_FILE_TMP=/tmp/${JAR_FILE} + if [ ! -f ${JAR_FILE_TMP} ]; then + echo "Downloading slave jar file to ${JAR_FILE_TMP}" if [ $(command -v curl) ]; then - echo "curl -o ${JAR_FILE} ${JENKINS_URL}/jnlpJars/${JAR_FILE}" - curl -o ${JAR_FILE} ${JENKINS_URL}/jnlpJars/${JAR_FILE} + echo "curl -o ${JAR_FILE_TMP} ${JENKINS_URL}/jnlpJars/${JAR_FILE}" + curl -o ${JAR_FILE_TMP} ${JENKINS_URL}/jnlpJars/${JAR_FILE} else echo "Need curl to download ${JENKINS_URL}/jnlpJars/${JAR_FILE}" exit -1 fi fi + JAR_FILE=${JAR_FILE_TMP} fi echo "starting ..." diff --git a/buildconfig/class_maker.py b/buildconfig/class_maker.py index e00641cfbc6000dc50a70ec35909b2daaf59b324..5c02dcada8e8c8e333ebff8101e7ee094f1c1257 100755 --- a/buildconfig/class_maker.py +++ b/buildconfig/class_maker.py @@ -254,7 +254,7 @@ def write_rst(subproject, classname, filename, args): .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/dev-docs/CMakeLists.txt b/dev-docs/CMakeLists.txt index 38c441b03eccf42c5135415969b882da37b0558a..a833065f69b1e62c76a95d07425b566e3e8b70a9 100644 --- a/dev-docs/CMakeLists.txt +++ b/dev-docs/CMakeLists.txt @@ -6,9 +6,21 @@ set ( BUILDER html ) set ( OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/${BUILDER} ) set ( DOCTREE_DIR ${CMAKE_CURRENT_BINARY_DIR}/doctree ) -add_custom_target ( dev-docs-${BUILDER} - COMMAND python -m sphinx -b ${BUILDER} -d ${DOCTREE_DIR} ${CMAKE_CURRENT_LIST_DIR}/source ${OUT_DIR} - COMMENT "Building html developer documentation" ) +# We try to execute Sphinx directly through python -m to avoid problems +# with the startup scripts on Windows. They are not always reliable +# as they can have hardcoded paths in them. However, older versions of +# Sphinx dont't allow python -m execution. Assume +# we are running on Linux and `sphinx-build` is available in these cases +if ( EXISTS ${SPHINX_PACKAGE_DIR}/__main__.py ) + add_custom_target ( dev-docs-${BUILDER} + COMMAND ${PYTHON_EXECUTABLE} -m sphinx -b ${BUILDER} -d ${DOCTREE_DIR} ${CMAKE_CURRENT_LIST_DIR}/source ${OUT_DIR} + COMMENT "Building html developer documentation" ) +else () + add_custom_target ( dev-docs-${BUILDER} + COMMAND sphinx-build -b ${BUILDER} -d ${DOCTREE_DIR} ${CMAKE_CURRENT_LIST_DIR}/source ${OUT_DIR} + COMMENT "Building html developer documentation" ) +endif () + # Group within VS and exclude from whole build set_target_properties ( dev-docs-html PROPERTIES FOLDER "Documentation" EXCLUDE_FROM_DEFAULT_BUILD 1 diff --git a/dev-docs/source/AutomatedBuildProcess.rst b/dev-docs/source/AutomatedBuildProcess.rst new file mode 100644 index 0000000000000000000000000000000000000000..09fd38e6887cbc66f51e67e31cda01bd94d9437f --- /dev/null +++ b/dev-docs/source/AutomatedBuildProcess.rst @@ -0,0 +1,70 @@ +=========================== +The Automated Build Process +=========================== + +.. contents:: Contents + :local: + +Summary +^^^^^^^ + +If your changes break the master builds in any way, on any platform, +then it is your responsibility to fix the error immediately! + +The Details +^^^^^^^^^^^ + +You should follow the :ref:`GitWorkflow`. When you open a +pull request (or commit to an already open pull request) the automated +build process will start. There will be a different build for each +platform/job. A status will appear for each job in the pull request. + +The status for each build will be either pending, success or failed. + +.. image:: images/BuildStatuses.png + +To see the details of a particular build in Jenkins click on Details +next to the status. To restart a build, if it failed with a spurious +error not related to your code changes, then you can restart that +particular build by selecting Rebuild in Jenkins. Then press rebuild +again on the next screen while not changing any of the parameters. If +you don't have permission to restart builds in Jenkins you will have +to ask someone who does. + +.. image:: images/RestartBuild.png + +Other Notes +^^^^^^^^^^^ + +The build will fail if it cannot be cleanly merged with master. + +Leeroy will check every 10 minutes for any missed builds, should the +GitHub hooks fail to activate or the build server was down when the +pull request was opened. + +The pull request builder we are using is called `Leeroy +<https://github.com/mantidproject/leeroy>`_. + +You can find a list of all the pull request Jenkins jobs at `here +<http://builds.mantidproject.org/view/Pull%20Requests/>`_. + +Master Pipeline +^^^^^^^^^^^^^^^ + +The `master pipeline <http://builds.mantidproject.org/view/Master%20Pipeline/>`_ +is a series of jobs that periodically run against code on the ``master`` branch. +Their purpose is to provide reasonable assurance that the code currently in +``master`` is usable in its current state. + +The main tasks carried out by the pipeline are, for each supported platform: + +* Build Mantid and installers (``master_clean-PLATFORM``) +* Run automated testing (``master_clean-PLATFORM``, + ``master_systemtests-PLATFORM``, ``master_doctests``) +* Deploy installers to nightly download locations (``master_deploy``) + +The pipeline view in Jenkins shows the order of dependency between these jobs. + +The most upstream jobs (i.e. ``master_clean-PLATFORM``) are triggered to start +at midnight UTC assuming there were changes pushed to the ``master`` branch +since the last time they ran. diff --git a/dev-docs/source/BuildingOnOSX.rst b/dev-docs/source/BuildingOnOSX.rst new file mode 100644 index 0000000000000000000000000000000000000000..092a7724e68576c7bc582729d0ab75b948f64ca7 --- /dev/null +++ b/dev-docs/source/BuildingOnOSX.rst @@ -0,0 +1,440 @@ +.. _BuildingOnOSX: + +================ +Building on OS X +================ + +.. contents:: + :local: + +The following are instructions to build on various versions of OS X: + +################################## +OS X 10.9 using clang and macports +################################## + +*Disclaimer* + +This instruction considers that you either use macports or need them for your other development projects. It also +considers that you need to compile Mantid by yourself. In other cases please either `download a Mantid dmg package <http://download.mantidproject.org/>`_ or follow the instructions below. Warning: +it is not recommended to have both, homebrew and macports installed simultaneously on one mac. + +Instruction +----------- +1. Install Xcode and macports following the instructions on https://guide.macports.org/chunked/installing.html if needed. + +2. Install Mantid prerequisites via ``sudo port install package_name`` + +3. Things to take care about: + +- By default, POCO libraries in macports are missing libCrypto and libNetSSL. If you have the POCO libraries already installed, uninstall them: ``sudo port uninstall poco``, then install as: ``sudo port install poco +ssl``. +- Install OpenCascade libraries as: ``sudo port install oce -tbb``. + +- libNeXus: macports do not contain libNeXus. + + 1. Download the source code from the `NeXus developers website <http://download.nexusformat.org/kits/>`_. + 2. Build and install it: + + .. code-block:: sh + + % ./configure --prefix=/opt/local + % make + % sudo make install + + You may need to install additional packages to be able to build libNeXus. + + 3. libNeXus must be recompiled after update of the macports if it's dependencies have been updated. Otherwise it may depend on some non-existent libraries. + +- jsoncpp: ``mantid/Code/Mantid/Framework/DataObjects/src/NoShape.cpp`` line 3 contains: ``#include <jsoncpp/json/json.h>`` but in macports there is no ``jsoncpp`` folder in the ``/opt/local/include``, ``json.h`` is located in ``/opt/local/include/json``. As a temporary solution, you may create a symbolic link: + + .. code-block:: sh + + % sudo mkdir /opt/local/include/jsoncpp + % cd /opt/local/include/jsoncpp + % sudo ln -s ../json + +4. Run cmake. It may be needed to specify the compiler as well as the path to include files. I use the following cmake options: + +.. code-block:: sh + + cmake -DCMAKE_C_COMPILER=/usr/bin/clang \ + -DCMAKE_CXX_COMPILER=/usr/bin/clang++ -G 'Unix Makefiles' \ + -DCMAKE_PREFIX_PATH=/opt/local \ + -DCMAKE_BUILD_TYPE=Release \ + -DENABLE_CPACK=True \ + -DPOCO_INCLUDE_DIR=/opt/local/include \ + -DQWTPLOT3D_INCLUDE_DIR=/opt/local/include/qwtplot3d \ + -DJSONCPP_INCLUDE_DIR=/opt/local/include \ + -DOPENCASCADE_INCLUDE_DIR=/opt/local/include/oce \ + -DPYTHON_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Headers \ + -DSIP_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Headers \ + -DPYTHON_NUMPY_INCLUDE_DIR=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/include \ + -DPYTHON_EXECUTABLE=/opt/local/bin/python \ + -DPYLINT_EXECUTABLE=/opt/local/bin/pylint-2.7 \ + -DSPHINX_EXECUTABLE=/opt/local/bin/sphinx-build-2.7 \ + -DPACKAGE_DOCS=FALSE \ + -DDOCS_HTML=TRUE \ + -DPYQT4_PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/PyQt4 \ + -DSITEPACKAGES_PATH=/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages \ + -DOPENSSL_ROOT_DIR=/opt/local \ + -DMAKE_VATES=FALSE \ + -DMACPORTS=TRUE \ + -DCMAKE_INSTALL_PREFIX=path_where_to_install_mantid /path_to_repository/mantid/Code/Mantid + +5. Pay attention that packaging of the documentation is switched off. I did not manage to build it for the moment. +6. Build mantid running ``make`` or ``make -j number_of_threads`` +7. You may create the dmg package running the ``make package`` command +8. You may also install Mantid using the ``make install`` command. *Warning*: if you do not want to install Mantid in /Applications, correct the CMAKE_INSTALL_PREFIX in the ``cmake_install.cmake`` file in your build directory. + +Building VATES +-------------- +Starting from Mantid 3.4, it is possible to build it with VATES support using macports. + +1. Build Paraview using the following instruction: :ref:`BuildingVATES`. + +2. Set cmake option ``-DMAKE_VATES=TRUE`` + +3. Set path to the paraview build directory: ``-DParaView_DIR=/put_your_path_here`` + +4. Run steps 6-7(8) to build/install Mantid + + +########################################## +OS X 10.10 and 10.11 using clang and Xcode +########################################## +These instructions are from the assumptions of a blank newly installed Mac and want to use the system python. Other python distributions may work but have not been tested. + +1. First install Xcode and then clone the mantid git repository. + +- The last version to support OS X Mavericks is Xcode 6.2 +- The last version to support OS X Yosemite is Xcode 7.2.1 +- As of August 1, 2016, our OS X El Capitan build server is running Xcode 7.3.1 + +2. Install Apple's Command Line tools (without this then /usr/include will not exist) + +.. code-block:: sh + + xcode-select --install + +2. Install `Homebrew <http://brew.sh>`_. If you already have Homebrew and are upgrading the OS follow the `instructions here <http://ryantvenge.com/2014/09/ruby-homebrea-yosemite/>`_: + +.. code-block:: sh + + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +3. Add the necessary 'taps'. The last 4 are to use qt4. + +In order to be able to 'tap' the ``mantidproject/mantid`` 'tap' we need to have a couple of packages installed + +.. code-block:: sh + + brew install git + brew install git-lfs + + brew tap homebrew/science + brew tap mantidproject/mantid + brew tap caskroom/cask + brew tap cartr/qt4 + brew tap-pin cartr/qt4 + +5. Install required dependencies (will make a mantid-developer formula soon) + If you plan on distributing your application bundle, change ``brew install`` to ``brew install --build-bottle`` + +.. code-block:: sh + + brew cask install xquartz + # mactex is optional, needed for parsing equations in qthelp documentation. + brew cask install mactex + brew install openssl + brew install cmake + brew install qt@4 --with-qt3support --build-bottle + # sip,pyqt and qscintilla2 bring in homebrew's python if + # installed with --build-bottle. And add --build-from-source. + brew install sip --build-from-source --without-python3 + brew install pyqt@4 --build-from-source --without-python3 + brew install qscintilla2qt4 --build-from-source + brew install qt --build-bottle + brew install pyqt --build-from-source + brew install qscintilla2 --build-from-source --without-python3 + brew install poco --c++11 + brew install boost --c++11 + # boost-python brings in homebrew's python if installed with --build-bottle. + brew install boost-python --c++11 --build-from-source + brew install gsl + brew install hdf5 --c++11 + brew install libmxml + brew install muparser + #Several unit tests fail with NeXus v4.4.2 + #https://github.com/mantidproject/mantid/issues/17001 + brew install nexusformat --c++11 + brew install jsoncpp + brew install tbb --c++11 + brew install opencascade --build-bottle + brew install qwt5 + brew install qwtplot3d + brew install google-perftools + brew install librdkafka + +6. Uninstall homebrew Python that some of the dependencies insist on installing + +.. code-block:: sh + + brew uninstall python + +6. Optional: for cmake-gui + +.. code-block:: sh + + brew cask install cmake + +7. Now to install the other python package dependencies: + +.. code-block:: sh + + sudo easy_install pip + sudo -H pip install sphinx + # https://github.com/mantidproject/mantid/issues/13481 + sudo -H pip install "ipython[notebook]==3.2.1" + # qtconsole only required with ipython 4+ + #sudo -H pip install qtconsole + sudo -H pip install qtpy + sudo -H pip install pygments + sudo -H pip install pyzmq + sudo -H pip install pycifrw + # Version matches Windows/RHEL/Ubuntu (trusty) + sudo -H pip install PyYAML==3.10 + # Version matches Windows/RHEL/Ubuntu (trusty) + sudo -H pip install mock==1.0.1 + +8. Install the theme for sphinx + +.. code-block:: sh + + sudo pip install sphinx_bootstrap_theme + +9. Install other python dependencies + + +.. code-block:: sh + + sudo pip install psutil + brew install h5py + +9. Add Homebrew’s site-packages to your python path. + +.. code-block:: sh + + mkdir -p ~/Library/Python/2.7/lib/python/site-packages + echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth + +10. Now you need to patch a header in your python! + +- If building on the command line with make or ninja. + + .. code-block:: sh + + cd /usr/include/python2.7 + + or + + .. code-block:: sh + + cd /System/Library/Frameworks/Python.framework/Headers + + then + + .. code-block:: sh + + sudo cp pyport.h pyport.h.original + sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch + +- If building with Xcode on OS X Yosemite + + .. code-block:: sh + + cd /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk/System/Library/Frameworks/Python.framework/Versions/2.7/include/python2.7 + + + then + + .. code-block:: sh + + sudo cp pyport.h pyport.h.original + sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch + + **Note**: If Xcode updates for any reason, the patch will be lost. + + +11. Now run CMake and select the Xcode generator with the default native compilers. + +12. Now open the project in Xcode (doing this from the command line to ensure the PYTHONPATH is correctly picked up by Xcode). + + .. code-block:: sh + + cd /path/to/my/build/dir + open Mantid.xcodeproj + +Troubleshooting +--------------- +1. The main problem that can arise is due to python path issues. This usually either arises at the CMake or Run from Xcode steps. It is because the PYTHONPATH is not being picked up. +2. If you have upgraded to Mavericks (OS X 10.9) from a previous version of OS X with homebrew already installed then you may encounter some issues related to the fact that the default std lib has changed. The easiest way to avoid this is to remove and then re-install all your formulas. +3. You may find that if you build the ``MantidPlot`` target then you will get errors when you run, such as *Can't start python* and *Cannot load Curve Fitting Plugins*, this is due to the fact that the MantidPlot target does not contain all the dependencies. You are best, if you are unsure of the hierarchy, to just use the ALL_BUILD target and then just switch to the MantidPlot target in order to run. +4. NOTE that you might need to run ``./MantidPlot.app/Contents/MacOS/MantidPlot`` from the ``BUILD-DIR/bin`` (instead of ``open MantidPlot.app`` OR ``./MantidPlot`` from ``BUILD-DIR/bin/MantidPlot.app/Contents/MacOS/``) to get the library paths correct. Otherwise the issues above might show up (at least on OS X 10.11 El Capitan). +5. Upgrading HDF5 requires also rebuilding nexusformat, h5py, and ParaView. + + +########## +OS X 10.12 +########## +The following instructions setup the build environment for mantid using clang compiler and python provided by the system, and all the other dependencies installed with brew. The drawback is that one has little control over python version and OpenMP will not be found. Make sure you have Qt Creator IDE and optionally cmake (GUI) app installed. + +1. Install Xcode from AppStore +2. Install Xcode command line tools + +.. code-block:: sh + + xcode-select --install + +3. Install home-brew package manager + +.. code-block:: sh + + ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)" + +4. Add the necessary 'taps' + +In order to be able to 'tap' the `mantidproject/mantid` 'tap' we need to have a couple of packages installed + +.. code-block:: sh + + brew install git + brew install git-lfs + + brew tap mantidproject/mantid + brew tap caskroom/cask + brew tap cartr/qt4 + brew tap-pin cartr/qt4 + +5. Install the necessary dependencies. Note that some of these will bring brew python with them as dependency. + +.. code-block:: sh + + brew cask install xquartz + brew cask install mactex + brew install openssl + brew install cmake + brew install ninja --without-test + brew install qt@4 --build-bottle + brew install sip --build-from-source --without-python + brew install pyqt@4 --build-from-source + brew install qscintilla2qt4 --build-from-source --without-python + brew install qt --build-bottle + brew install pyqt --build-from-source + brew install qscintilla2 --build-from-source --without-python + brew install poco + brew install boost --c++11 + brew install boost-python --c++11 --build-from-source + brew install gsl + brew install gcc + brew install hdf5 --c++11 + brew install libmxml + brew install muparser + brew install nexusformat --c++11 + brew install jsoncpp + brew install tbb --c++11 + brew install opencascade --build-bottle + brew install qwt5 + brew install qwtplot3d + brew install google-perftools + brew install librdkafka + +If, while configuring Mantid, cmake complains that it cannot find sip, uninstall the package by ``brew uninstall --ignore-dependencies sip``, reinstall it using the line above and follow the instructions on how to add Homebrew's site-packages to Python ``sys.path``. + + +6. Uninstall the brew python if it has been previously installed + +.. code-block:: sh + + brew uninstall --ignore-dependencies python3 + +7. Install pip python package manager + +.. code-block:: sh + + sudo easy_install pip + +8. Install necessary python packages with pip + +.. code-block:: sh + + sudo -H pip install sphinx --ignore-installed + sudo -H pip install "ipython[notebook]==3.2.1" + sudo -H pip install qtpy + sudo -H pip install pycifrw + sudo -H pip install PyYAML==3.10 + sudo -H pip install mock==1.0.1 + sudo pip install sphinx_bootstrap_theme + sudo pip install psutil + sudo pip install qtawesome + sudo pip install "matplotlib>=2.1.2" + +9. Install h5py + +.. code-block:: sh + + brew install h5py + +10. Add Homebrew’s site-packages to your python path. + +.. code-block:: sh + + mkdir -p ~/Library/Python/2.7/lib/python/site-packages + echo '/usr/local/lib/python2.7/site-packages' > ~/Library/Python/2.7/lib/python/site-packages/homebrew.pth + +11. Git clone the mantid repository + +12. Disable the system integrity protection (SIP). To do this + + - restart the computer + - before the apple logo appears press `Command+R` to enter the recovery mode + - when in recovery mode, go to `Utilities>Terminal` and type + + .. code-block:: sh + + csrutil disable + + - reboot again + +13. Now that SIP is disabled we can do the necessary patch: + +.. code-block:: sh + + cd /usr/include/python2.7 + sudo cp pyport.h pyport.h.original + sudo patch pyport.h $MANTIDCHECKOUTROOT/buildconfig/pyport.patch + +14. Enable again the system integrity protection by repeating Step 12 and typing this time: + +.. code-block:: sh + + csrutil enable + +15. Open mantid project from Qt Creator, and you should be able to run cmake and build, given the right environment: + +.. code-block:: sh + + CC=/usr/bin/clang + CXX=/usr/bin/clang++ + PATH=/usr/local/bin/:$PATH + +Local bin contains the symlink to the brew packages, which have to come first in path, before `/usr/bin`. That's why it is important not to have python or clang (with this setup) in brew. + + +16. Add to your `.profile` + +.. code-block:: sh + + export PYTHONPATH=$BUILDMANTID/bin + + +17. You should now be able to mantid. diff --git a/dev-docs/source/BuildingVATES.rst b/dev-docs/source/BuildingVATES.rst new file mode 100644 index 0000000000000000000000000000000000000000..8df1e0e1c999a565500aa9238665aa1888f44d92 --- /dev/null +++ b/dev-docs/source/BuildingVATES.rst @@ -0,0 +1,121 @@ +.. _BuildingVATES: + +============== +Building VATES +============== + +.. contents:: + :local: + +What Is the VSI? +---------------- + +The VSI stands for VATES Simple Interface. This is best thought of as the way to visualise 3D+ dimensional data in Mantid. Mantid stores n dimensional data in MDWorkspaces, which may be rendered using the ParaView visualisation tools. + +How Do I Get the VSI? +--------------------- + +The VSI components are part of the Mantid distribution. + +ParaView +-------- + +The visualisation components for the VSI require the ParaView visualisation platform. However, the CMake option ``MAKE_VATES``, can be used to turn off its use. The patch files used in this section as well as build scripts for Windows & OSX/Linux which automate the steps described below can be found `here <https://github.com/mantidproject/paraview-build>`__. + +- Execute the following lines from the command prompt + +.. code-block:: sh + + git clone https://gitlab.kitware.com/paraview/paraview.git <Your ParaView source root> + cd <Your ParaView source root> + git checkout v5.4.0 + git submodule init + git submodule update + +The VSI uses a custom data array layout to minimize memory copies. The name and header must be available to ParaView at compile time. + +.. code-block:: sh + + mkdir vtkMDHWSignalArray + cd vtkMDHWSignalArray + wget https://raw.githubusercontent.com/mantidproject/paraview-build/2b28ebc5fd40ad727ca66772522bf220b834c1f7/vtkMDHWSignalArray/vtkMDHWSignalArray.h + SIGNAL_NAME=vtkArrayDispatch_extra_arrays=vtkMDHWSignalArray\<double\> + SIGNAL_HEADER=vtkArrayDispatch_extra_headers=<path to vtkMDHWSignalArray.h> + +Everyone is encouraged to apply the `additional patchfiles <https://github.com/mantidproject/paraview-build/tree/875fe2a3c800996b75591c8dbe26909b51bdf963/patches>`__ in our buildscript. + +Building ParaView +------------------ + +This is the visualisation plugins to build and use. This works on Windows/Linux/Mac. Download the source code and build using CMake out of source. You'll need the Qt development libraries, in order to build the GUI and also python. For Windows user, the Third_Party directory contains qmake as well as all the development libraries you should need to build Paraview. + +The scripts and cmake cache files used by the build servers are available `here <https://github.com/mantidproject/paraview-build/tree/875fe2a3c800996b75591c8dbe26909b51bdf963>`__. + +.. code-block:: sh + + cd <Your paraview source root> + mkdir Build + cd Build + + cmake -D$SIGNAL_NAME -D$SIGNAL_HEADER -C<path to common.cmake> -C<path to platform specific cache file> .. + cmake --build . + +Building the VSI +---------------- + +- Get Paraview (see above) +- Edit the CMake configuration for Mantid + + - Via CMake enable ``MAKE_VATES`` (If editing from the GUI, press ``Configure`` after checking this) + - Via CMake set ``ParaView_DIR`` to the directory where paraview has been built. +- Make Mantid + +This should produce the VSI related binaries for Mantid as well as plugins usable by ParaView. + +Sample Mantid cmake command +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +This build command enables the VSI: + +.. code-block:: sh + + cmake -G Ninja -DCMAKE_BUILD_TYPE=Release -DMAKE_VATES=TRUE -DParaView_DIR=~/Code/paraview/build ../Code/Mantid + cmake --build . + +Additional Libraries for Paraview/Mantid +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Ubuntu: The package list from :ref:`GettingStarted` contains all the required libraries. + +Using Paraview Plugins +---------------------- + +This section will be fleshed-out or appear as a separate page in the near future. + +- Launch the Paraview GUI +- Go to Tools -> Manage Plugins and load the MantidParaview... libraries listed above (except for MantidParaViewQtWidgets) +- There are several reasons why you may get a warning symbol when you try to load the plugins (see troubleshooting) +- Of those loaded plugins, you may wish to expand them using the (+) tree and assigning them as autoload, so that they are immediately available the next time Paraview is launched. +- You can now open a sqw file in Paraview. +- Use the Rebinning Cutter filter to rebin,integrate,rearrange,slice the workspace. + +Help +---- + +We suggest contacting the core Mantid development team if any problems are experienced. + +Troubleshooting +--------------- + +- Can't load plugins + + - Have you built both Mantid and Paraview to be either Debug or Release (both the same)? + - Do you have the Mantid binaries present and in the right order in the system path (windows)? + +- Can't start-up Paraview + + - Try deleting or temporarily renaming the ParaView directory in ``%APPDATA/Roaming%`` Paraview may be crashing as it's trying to autoload plugins that are causing problems. + +- Cannot complete the loading of a file + + - Check you have ``MANTIDPATH`` set correctly. diff --git a/dev-docs/source/BuildingWithCMake.rst b/dev-docs/source/BuildingWithCMake.rst new file mode 100644 index 0000000000000000000000000000000000000000..e5678263fcfca5cf1855ac5cc2a5e9798995c373 --- /dev/null +++ b/dev-docs/source/BuildingWithCMake.rst @@ -0,0 +1,121 @@ +.. _BuildingWithCMake: + +=================== +Building with CMake +=================== + +.. contents:: + :local: + +CMake is the build system for the entirety of Mantid (Framework, MantidQt & MantidPlot). It is used to generate native build files for your platform, which can be Makefiles (for use with make, nmake or jom) for command line builds or project/solution files for an IDE (e.g. Visual Studio, Eclipse, Qt Creator, XCode). + +Environment +########### + +The :ref:`GettingStarted` page describes how to set up your environment to build Mantid. Follow those instructions and install the Mantid dependencies first. + +Also, if you use the Ninja generator then the executable is called ``ninja-build``. + +CCache +###### + +Mantid's cmake is configure to use the `ccache <https://ccache.samba.org/>`_ tool if it is available. It is highly recommended that this be used on Linux/macOS systems. + +For Linux either run either + +.. code-block:: sh + + sudo yum install ccache + +on Red Hat, or + +.. code-block:: sh + + sudo apt-get install ccache + +on Ubuntu. + +For macOS run: + +.. code-block:: sh + + brew install ccache + +After it is installed run ``ccache --max-size=20G`` to increase the size of the cache. + +If you're build with ``ccache`` exhibits warnings that are not usually present then try setting the ``ccache --set-config=run_second_cpp="true"`` config option (or set ``CCACHE_CPP2=yes`` environment variable on older versions). + +Network Drives +-------------- + +The default location for the cache directory is ``$HOME/.ccache``. If you're home directory is on a network-mounted drive then the location of this cache be moved to provide the best performance. On newer versions of ``ccache`` run ``ccache --set-config=cache_dir=PATH_TO_CACHE``. Older versions (<3.2) do not allow this and must fall back to setting the ``CCACHE_DIR`` environment variable in your shell profile. + +Configuring your build +###################### + +CMake encourages the use of 'out of source' builds. This means that all generated files are placed in a separate directory structure to the source files. This separation makes a full clean easier (you just delete everything) and means that you can have different types of build (Release, Debug, different compiler versions, ....) in separate places (N.B. For Visual Studio & XCode, you can still select the type of build from within the IDE). + +From the command line +--------------------- + +* If wanting an out of source build, create the directory you want to build in and ``cd`` into it. +* On Windows, you may need to be in a Visual Studio Command Prompt. +* Run ``cmake /path/to/Mantid``, or to ``/path/to/Mantid/Framework`` if you only want a build of the Framework (typically not recommended, but possible nonetheless). This will generate build files using the default generator for your platform (e.g. Unix Makefiles on Linux). +* If you want to use a specific generator (run ``cmake --help`` for a list of available generators for your platform), use the ``-G`` option, e.g. ``cmake -G"NMake Makefiles" /path/to/Mantid``. +* If you want to set the build type (e.g. Release, Debug) you can run cmake with the ``-i`` option or by passing the argument ``-DCMAKE_BUILD_TYPE=Debug`` to cmake. The default is Release. +* Please note that the executable is called ``cmake3`` on Red Hat 7 / CentOS7. + +From the CMake gui +------------------ + +* The cmake gui is available from, e.g., the Windows Program menu or the command line executable ``cmake-gui``. +* Start it and click the "Browse Source" button to point to ``/path/to/Mantid``, or to ``/path/to/Mantid/Framework`` if you only want a build of the Framework (typically not recommended, but possible nonetheless). +* Click "Browse Build" and point to the directory you want to build into - it's recommended that you create a new directory for this (see above), though it can be the same as the source directory. +* Click "Configure" down near the bottom of the window. +* A new window will appear asking which 'Generator' you want to use. Choose one and click OK (N.B. VS2010 = Visual Studio 10, and note that you should append Win64 to this for a 64 bit build). +* Wait a while.... +* You will be presented with a list of options in red that can in principle be changed. You probably don't want to change anything, except perhaps checking "MAKE_VATES" if you want to build that. +* Click "Configure" again and wait.... +* Finally, click "Generate". This will create the build files, e.g. there will be a Mantid.sln in the directory you selected as your build directory. + +Data Files Location +------------------- + +Mantid used the CMake ExternalData system for managing testing data. See :ref:`DataFilesForTesting` for further instructions. + +With Qt Creator +--------------- + +`Qt Creator <http://qt.nokia.com/products/developer-tools/>`_ has some really nice features (it's cross-platform, you can directly open Qt Designer within it, you can highlight a Qt type and go directly to it's help page, it knows about Qt types when debugging....). +The nice feature in this context is that it has CMake support built in. So you can just open the project by pointing to the main CMakeLists file and then run CMake all within the IDE itself. + +Building and working with CMake +############################### + +* You can now start your IDE and point to or import the generated solution/project files or run ``make``, ``nmake`` or ``jom`` to build the whole of Mantid (sub-targets are available - run ``make help`` to see them). +* '''Visual Studio users''': Use the ``visual-studio.bat`` generated in the build directory to start the IDE. This sets up the environment correctly. +* You should typically never have to run CMake manually again (unless you want to create a new, separate build) - it will be run automatically if one of the CMake input files changes. +* It should be rare that you will need to edit the CMake build (``CMakeLists.txt``) files. The most common occurrence will be when you add a new file. This must be added to the corresponding CMakeLists file, e.g. if you add a file to Kernel, edit ``Mantid/Framework/Kernel/CMakeLists.txt`` to add the source, header and test files to the long lists of filepaths at the top of the file. +* The class maker utility (:ref:`ToolsOverview`) can edit the ``CMakeList.txt`` for you automatically +* There are similar places in the Qt projects for ui files and files that need moc-ing. +* If you add a new dependency, that will need to be added (this is less straightforward - do ask for help). +* Cache variables can be added via the CMake Gui or by running ``ccmake``. + +Building the installer package +############################## + +* For Windows only, you first need to install NSIS, available at: http://nsis.sourceforge.net/Download. Ensure that the install directory is added to the PATH. You should be able to type ``makensis /?`` in a command prompt. +* Run CMake with "ENABLE_CPACK" enabled. If using the GUI you need to click the "Advanced" checkbox to see this option. +* You will now have a build target called "PACKAGE" available to create the installer package. + +Caveats and Known Issues +######################## + +* For Visual Studio & XCode, the libraries and executable are put into ``Mantid/bin/Release``, ``Debug``, etc. +* There is a known issue with using source control with Eclipse on an out of source build. Set the cache variable ``ECLIPSE_CDT4_GENERATE_SOURCE_PROJECT`` to true and CMake will generate a set of 'dummy' project files within the source tree so that you can import that project and use it for source control actions. + +Tips +#### + +* Running unit test executables directly with the CMake-generated ``Mantid.properties`` file will lead to a bunch of logging output to the console. You are encouraged to use CTest instead, which suppresses this output automatically. Otherwise, adding the line ``logging.channels.consoleChannel.class = NullChannel`` to your Mantid.user.properties file will turn if off. +* If you have more than one gcc and want to build with a version other than the default (e.g. on RedHat), setting CC & CXX environment variables is one way to make it so. diff --git a/dev-docs/source/Communication.rst b/dev-docs/source/Communication.rst new file mode 100644 index 0000000000000000000000000000000000000000..4344a5157a0619472ec79800774afb8f8dcd016f --- /dev/null +++ b/dev-docs/source/Communication.rst @@ -0,0 +1,42 @@ +.. _Communication: + +.. toctree:: + :hidden: + + DevelopmentTeam + +Communication +============== + +How to contact people in the development team +--------------------------------------------- + +* :ref:`Development Team <DevelopmentTeam>` Contact Details +* Developer email list (closed list for developers only) mantid-developers@mantidproject.org +* `Slack <http://mantid.slack.com/>`__: instant messaging and calls + +Support +------- + +* Email Mantid-help@mantidproject.org goes to a short list of developers, who create tickets and assign to others. +* `Forum <http://forum.mantidproject.org/>`__ with discussions for general and technique help requests + +Meetings & other information +---------------------------- + +Text +^^^^ + +* Informal discussions, and daily status - `Slack <http://mantid.slack.com/>`__ +* Set your picture on `Gravatar <https://secure.gravatar.com/>`__ to get it to appear in github/slack/etc + +Video conference +^^^^^^^^^^^^^^^^ + +* Mantid Review - Every fortnight update on significant changes & plans + +Face to Face +^^^^^^^^^^^^ + +* Annual Developer Workshop + diff --git a/dev-docs/source/DataFilesForTesting.rst b/dev-docs/source/DataFilesForTesting.rst new file mode 100644 index 0000000000000000000000000000000000000000..3f917e39c95dd9284e80de14b50365a57ec0f495 --- /dev/null +++ b/dev-docs/source/DataFilesForTesting.rst @@ -0,0 +1,282 @@ +.. _DataFilesForTesting: + +====================== +Data Files for Testing +====================== + +.. contents:: + :local: + +Summary +####### + +This page gives an overview of how data files are managed within Mantid. + + +Motivation +########## + +Some unit tests use a small amount of data that is created by the test +harness and others load data from a file. Take the example of +``ApplyCalibrationTest``. In its first test, testSimple, it creates a +workspace with 10 detectors using +``WorkspaceCreationHelper::create2DWorkspaceWithFullInstrument()``. In +the second test, testComplex, it reads a file +**IDFs_for_UNIT_TESTING/MAPS_Definition_Reduced.xml**, which contains +the definition of a MAPS instrument with the number of detectors reduced +much to ensure it is read quickly but preserving the other properties of +this instrument. However, new tests should avoid even loading of this +nature unless there is a strong justification for doing so. + +Main issues: + +- need to store data, mainly for testing, alongside the code +- some data needs to be versioned +- merging system tests back with main code requires handling large data + files +- git is bad at handling binary files + +Possible solutions: + +- don't have any reference to data in git and force developers to + manage the data stored on a file server +- extensions to git, e.g. + `git-fat <https://github.com/jedbrown/git-fat>`__, + `git-annex <https://git-annex.branchable.com/>`__ to deal with large + files +- CMake's + `ExternalData <http://www.kitware.com/source/home/post/107>`__ + +We have chosen to use CMake as it is already in use as a build system +and it doesn't involve introducing extra work with git. + + +CMake's External Data +##################### + +.. figure:: images/ExternalDataSchematic.png + :alt: Image originated at http://www.kitware.com/source/home/post/107 + :align: center + + Image originated at http://www.kitware.com/source/home/post/107 + +Terminology: + +- content - the real data +- content link - text file containing a hash (MD5) of the real content. + The filename is the filename of the real data plus the ``.md5`` + extension +- object - a file that stores the real data and whose name is the MD5 + hash of the content + +Overview: + +- git does not store any content, it only stores content links +- content is stored on a remote server that can be accessed via a + ``http`` link +- running cmake sets up build rules so that the content is downloaded + when dependent projects are built + + +Local Object Store +################## + +CMake does not download content directly but stores the content in a +*Local Object Store*, whose location is defined by the +``ExternalData_OBJECT_STORES`` CMake variable. This allows it to share +content between build trees, especially useful for continuous +integration servers. + + +Binary Root +########### + +The final step is to create the *real* filename and symbolic link (copy +on windows) it to the object in the local object store. The location of +the *real* filenames is controlled by the ``ExternalData_BINARY_ROOT`` +CMake variable and defaults to ``build/ExternalData``. + + +Using Existing Data +################### + +There are two places files may be found: + +- `../mantid/Testing/Data/UnitTest <https://github.com/mantidproject/mantid/tree/master/Testing/Data/UnitTest>`__ +- `../mantid/instrument/IDFs_for_UNIT_TESTING <https://github.com/mantidproject/mantid/tree/master/instrument/IDFs_for_UNIT_TESTING>`__ + for test `IDF <IDF>`__ files + + +Adding A New File(s) +#################### + +A helper git command is defined called ``add-test-data``. It would be +called like this: + +.. code-block:: sh + + git add-test-data Testing/Data/UnitTest/INST12345.nxs + +This does the following: + +- computes the MD5 hash of the data, e.g. + ``d6948514d78db7fe251efb6cce4a9b83`` +- stores the MD5 hash in a file called + ``Testing/Data/UnitTest/INST12345.nxs.md5`` +- renames the original data file to + ``Testing/Data/UnitTest/d6948514d78db7fe251efb6cce4a9b83`` +- runs ``git add Testing/Data/UnitTest/INST12345.nxs.md5`` +- tells the user to upload the file(s), + ``d6948514d78db7fe251efb6cce4a9b83``, to the remote store (URL: + http://198.74.56.37/ftp/external-data/upload) +- re-run cmake + +Notes: + +- You need to use a shell to add & modify data files under Windows in + this way. Not every shell works as described, though `Github for + Windows <https://windows.github.com/>`__ shell would allow you to do + everything described here step by step without deviations. + Unfortunately, MINGW32 shell you have to select to do that is not the + most convenient shell under Windows. In addition to that, + ``add-test-data`` script is currently broken (at least was on + 20/11/2015) . This is why I would suggest to use small python script, + provided below, which would calculate md5 hash, create the ``.md5`` + file and rename your test or reference file according to the hash sum + calculated. You then have to manually put ``.md5`` file to requested + reference data location and add it to Git by usual means. The + hash-sum named file should be, as in the case of Unix, placed to the + `remote store <http://198.74.56.37/ftp/external-data/upload>`__ +- Note, that ILL test data should be placed under ``ILL/${INSTRUMENT}`` + subdirectories (e.g. ``ILL/IN16B``), and should not contain any + instrument prefix in the file name. + + +Developer Setup +############### + +**You need cmake 2.8.11+** + +To add the ``add-test-data`` command alias to git run + +.. code-block:: sh + + git config alias.add-test-data '!bash -c "tools/Development/git/git-add-test-data $*"' + +in the git bash shell. The single quotes are important so that bash +doesn't expand the exclamation mark as a variable. + +It is advised that CMake is told where to put the "real" data as the +default is ``$HOME/MantidExternalData`` on Linux/Mac or +``C:/MantidExternalData`` on Windows. Over time the store will grow so +it is recommended that it be placed on a disk with a large amount of +space. CMake uses the ``MANTID_DATA_STORE`` variable to define where the +data is stored. + +Example cmake command: + +Linux/Mac: + +.. code-block:: sh + + mkdir -p build + cmake -DMANTID_DATA_STORE=/home/mgigg/Data/LocalObjectStore ../Code/Mantid + +Windows: + +.. code-block:: sh + + mkdir build + cmake -DMANTID_DATA_STORE=D:/Data/LocalObjectStore ../Code/Mantid + +Setting With Dropbox: + +This is for people in the ORNL dropbox share and has the effect of +reducing external network traffic. There is a +`gist <http://gist.github.com/peterfpeterson/638490530e37c3d8dba5>`__ +for getting dropbox running on linux. + +.. code-block:: sh + + mkdir build + cmake -DMANTID_DATA_STORE=/home/mgigg/Dropbox\ \(ORNL\)/MantidExternalData ../Code/Mantid + +If you don't want to define the MANTID_DATA_STORE everytime you run +cmake, you can link the default data store location to the Dropbox one. + +.. code-block:: sh + + ln -s ~/Dropbox\ \(ORNL\)/MantidExternalData ~ + +Proxy Settings +-------------- + +If you are sitting behind a proxy server then the shell or Visual studio +needs to know about the proxy server. You must set the ``http_proxy`` +environment variable to ``http://HOSTNAME:PORT``. + +On Windows you go to **Control Panel->System and +Security->System->Advanced System settings->Environment Variables** and +click **New...** to add a variable. + +On Linux/Mac you will need to set the variable in the shell profile or +on Linux you can set it system wide in ``/etc/environment``. + +Troubleshooting +--------------- + +If you find that your tests cannot find the data they require check the +following gotchas: + +- Check that you have uploaded the original file renamed as a hash to + the Mantid file repository +- Check that you have re-run CMake in the build directory. +- Check that you have removed any user defined data search directories + in ~/.mantid +- Check that you have rebuilt the test executable you're trying to run +- Check that you have rebuilt the SystemTestData target + +Python script to produce hash files +----------------------------------- + +.. code:: python + + #!/usr/bin/python + import hashlib + import os,sys + + def md5sum(filename, blocksize=65536): + """Calculate md5 hash sum of a file provided """ + hash = hashlib.md5() + with open(filename, "rb") as f: + for block in iter(lambda: f.read(blocksize), b""): + hash.update(block) + return hash.hexdigest() + + def save_sum(filename,md_sum): + """Save hash sum into file with appropriate filename""" + md_fname = filename+'.md5' + with open(md_fname) as f: + f.write(md_sum) + + if __name__ == '__main__': + + if len(sys.argv)<2 or not os.path.isfile(sys.argv[1]): + print "Usage: hash_file.py file_name" + exit(1) + + filename = sys.argv[1] + + path,fname = os.path.split(filename) + hash_sum = md5sum(filename) + print "MD SUM FOR FILE: {0} is {1}".format(fname,hash_sum) + + # save hash sum in file with original file name and extension .md5 + save_sum(os.path.join(path,fname),hash_sum) + + # Rename hashed file into hash sum name. + hash_file = os.path.join(path,hash_sum) + if os.path.isfile(hash_file): + print "file: {0} already exist".format(hash_sum) + else: + os.rename(filename,hash_file) diff --git a/dev-docs/source/DebuggingUnitTests.rst b/dev-docs/source/DebuggingUnitTests.rst new file mode 100644 index 0000000000000000000000000000000000000000..0e84d56e6a5675bbf80d0dd198bfce682118f750 --- /dev/null +++ b/dev-docs/source/DebuggingUnitTests.rst @@ -0,0 +1,101 @@ +Debugging Unit Tests +==================== + +.. contents:: + :local: + +Using gdb +--------- + +Debugging typically requires the test executable to be run directly, +rather than via ctest (which typically spawns off a separate process to +run the actual tests). So an example of debugging from the command line +using gdb would be:: + + $ gdb bin/AlgorithmsTest + (gdb) r RebinTest + +If you do need to run ctest in order to debug - if, for example, a test +is failing when run in ctest, but not if run directly - then you can +start the test off and then attach to the actual test executable from +another terminal (or your IDE). You may need to pause or slow down the +test using, e.g., the method described for Visual Studio debugging +below. + +If the issue is with a python unit test, the call is slightly more +complicated:: + + $  env PYTHONPATH=$PWD/bin gdb --args python2 /full/path/to/mantid/Framework/PythonInterface/test/python/mantid/kernel/TimeSeriesPropertyTest.py + (gdb) run + +Within Eclipse +-------------- + +#. Go to Run->Debug Configurations +#. Create a new Debug Configuration. I called mine "DataHandling Test + Debug". +#. For me, it worked best using the "Standard Create Process Launcher" + (bottom option on the "Main" tab) +#. Set the C/C++ application to the path to the test executable, e.g. + bin/DataHandlingTest +#. Under the "Arguments" tab, add the name of the test class you want to + debug under "Program arguments", e.g. LoadTest + + #. To only run one test in a class, you can add the particular test + to run, e.g. "LoadTest test_exec" + +#. Under "Common" you can put the debug config in your "favorites" menu. + +You can then run the debugger on this configuration from the Run menu or +the toolbar. + +Within Visual Studio (debugging run method) +------------------------------------------- + +I've found that this method works with Visual Studio Express (which does +not allow "attach to process"). + +- Right-click the test project, e.g. DataObjectsTest. +- Select Properties. + + - Under Debugging -> Command Arguments, type in the test suite and, + optionally, single test name. e.g. "EventListTest + test_MinusOperator_inPlace_3cases" in the screenshot below. + +.. figure:: images/VisualStudioTestDebugProperties.png + :alt: VisualStudioTestDebugProperties.png + + VisualStudioTestDebugProperties.png + +- Put a break point somewhere in the test code that will be run. +- Select the project and click Debug -> Start Debugging. +- Fun test debugging times! + +Within Visual Studio (attach to process version) +------------------------------------------------ + +The process here is not as straight forward as it is in eclipse. It +involves a few steps, but it does work! + +1. Edit the test to add a pause at the start of the test you are +interested in. This will make the test wait for keyboard input, all you +need to do is hit enter, but you can use this delay to attach to the +debugger to running process. +:: + + std::string s; + std::getline(std::cin,s); + +| 2. Run ctest with the appropriate arguments to run the test you are + investigating. +| 3. When the test pauses for input within visual studio select + Debug\Attach to Process... |AttachToProcess.png| +| 4. Select the test executable (e.g. DataHandlingTest.exe) from the + list and click attach. Visual studio will change to debug mode. +| 5. Set any breakpoints you want, go back to the runner.exe window and + hit enter to stop the pause. This should then ctach on any breakpoints + you have set. +| 6. VERY IMPORTANT - Clean up when you have done, and do not check in + with any paused tests! + +.. |AttachToProcess.png| image:: images/AttachToProcess.png diff --git a/dev-docs/source/DesignDocumentGuides.rst b/dev-docs/source/DesignDocumentGuides.rst new file mode 100644 index 0000000000000000000000000000000000000000..4b5221765f5ab82bade4e68c3032273f4feabb7d --- /dev/null +++ b/dev-docs/source/DesignDocumentGuides.rst @@ -0,0 +1,121 @@ +.. _DesignDocumentGuidelines: + +========================== +Design Document Guidelines +========================== + +.. contents:: + :local: + +A good design document minimises unexpected complications by addressing +them before the code is written. A document will provide you, your +manager and your team with a common vocabulary for talking about the +project. Writing an effective design document can be tricky in itself +they often add unnecessary complexity if not done with care. These +guidelines are to help you generate effective and simple design +documents. + +Before starting, all Mantid design documents must be written in +`markdown <http://en.wikipedia.org/wiki/Markdown>`__ format with the md +extension. After approval from the the Mantid Project :ref:`TSC`, they should be stored +`here <https://github.com/mantidproject/documents/tree/master/Design>`__ +or in one of the subdirectories of that directory. This page covers what +happens between those points. + +Guidelines on Sections +###################### + +We want to avoid a prescriptive approach to design document layout. +Design documents are about communicating design ideas, not a box ticking +exercise, so developers are expected to use their own professional +judgement about what goes into them. We are not providing templates for +this reason. The following are guidelines for writing your design +document, to help give you some direction. + +Motivation +---------- + +- Why does this design document exist? +- What is the overview of the problem? +- What use cases exist showing the present issue? For example scripting + issues. +- How does this link in with long-term requirements such as SSC outputs +- **This section should be readable by non developers**. Not everyone + knows that the ADS stands for the Analysis Data Service and wider + stakeholders definitely will not + +Dictionary of Terms +------------------- + +Your opportunity to pair abbreviations to longer explanations. This is +not always necessary in documents where there are no special terms to +explain. If you need one, a two column table would be sufficient. + +Potential Solutions +------------------- + +It is important that you consider a wide range of possible solutions, +and don't just put forward your favourite. Remember that the design +document is a way of avoiding mistakes before coding, so spend some time +considering how several possibilities could be made to work. + +For each potential solution, you should probably consider: + +- Keep it brief and high-level at this stage +- What would the scope of the changes be? +- What are the pros/cons of this solution? + +Chosen Solution +--------------- + +You should provide logical reasons why you are choosing to adopt +solution A over solution B, C, D ... As the project grows in size, we +may need to be able to understand in the future the reasons why certain +designs have been adopted. If you are unsure which solution would be +best, you may submit the partially complete design document to the :ref:`TSC` for help. Design +is itself an iterative process and documents are frequently not accepted +first time around, so be prepared to make amendments, and don't take it +personally if corrections are required. + +How will we verify the design, what are the use cases that could be used +to verify the solution? + +Implementation Detail +--------------------- + +You could merge this section here with the one above if you wish. + +- Use feedback to correct and clarify. +- Add more implementation detail. Diagrams are great, but you don't + have to use strict UML, and use the appropriate UML diagrams + depending upon the solution. Diagrams should help you and readers to + understand the solution in a simple way, not make it more + complicated. +- Could someone else follow the design and implement it? You may not be + the one implementing this, and it's even more likely that you will + not be the only one maintaining it. + +Sign Off +-------- + +Design documents help us to manage risk and reduce cost to the project. +We have had some bad experiences in the past where high-risk changes +have been made ad-hoc. You must get approval from the :ref:`TSC` before embarking on the work outlined in the +design document. + +Cheat Sheet and Checklist +######################### + +The guidelines above do not need to be strictly followed, but the +following are necessary: + +#. Can non experts understand the motivation for these changes? +#. Are your design decisions traceable? Does your design document link + from requirements through to implementation details in a traceable + manner? +#. Can someone else implement this? +#. Has the :ref:`TSC` approved the design. +#. What use cases verify that this design work +#. Documents must be version controlled and live in a subdirectory of + `here <https://github.com/mantidproject/documents/tree/master/Design>`__ + as a `markdown <http://en.wikipedia.org/wiki/Markdown>`__ document diff --git a/dev-docs/source/DeveloperAccounts.rst b/dev-docs/source/DeveloperAccounts.rst new file mode 100644 index 0000000000000000000000000000000000000000..fbdebd33394ba679c7e10241fa524bb3f801aa14 --- /dev/null +++ b/dev-docs/source/DeveloperAccounts.rst @@ -0,0 +1,63 @@ +.. _DeveloperAccounts: + +================== +Developer Accounts +================== + +.. contents:: + :local: + +User Names +---------- + +Simple, easy to recognise user names are preferred. For example "Nick Draper", or if spaces are not allowed "NickDraper". + +Account Creation +---------------- + +- Create a **Mantid Wiki** account; follow `this link <https://www.mantidproject.org/Special:RequestAccount>`__. +- Sign up to the **Mantid Developers** email list; follow `this link <http://lists.mantidproject.org/mailman/listinfo/mantid-developers>`__. +- Sign up for the **Mantid Slack** channel; follow `this link <https://mantid.slack.com/>`__. +- If you don't already have one, sign up for a **Github** account; follow `this link <https://github.com/>`__. + + Remember that your username should be easily identifiable. + + Contact one of the "Owners" on `this list <https://github.com/orgs/mantidproject/people?query=role%3Aowner>`__ to add you to the developer team. + + Set up Git on your workstation; see `this guide <https://help.github.com/articles/set-up-git/>`__. + + The Git workflow is described on the :ref:`GitWorkflow` page. + +- Consider signing up for **Skype**; follow `this link <https://www.skype.com/>`__. +- Sign up for a **Gravatar** account; follow `this link <https://en.gravatar.com/>`__. + +SNS Git +------- + +If you are based at SNS, in order to be able to ssh out of the lab, you need to do the following: + +- Install "Corkscrew" using your package manager. +- Add the following lines to ~/.ssh/config: + + +.. code:: bash + + ProxyCommand corkscrew snowman.ornl.gov 3128 %h %p + Host github.com + +Introducing Yourself +-------------------- + +- Post a short introduction of yourself to the rest of the team in the General chatroom on Mantid Slack. +- Add yourself together with your contact details and a photo (selfies are fine) to :ref:`DevelopmentTeam`. + +Admin Notes +----------- + +These are notes for account admins on how to add new users. + +- **Wiki** + + Go to the `special pages index <https://www.mantidproject.org/Special:SpecialPages>`_. + + Select Login/Create Account. + + Select the Create Account link at the top of the box. + + Username should be first name (space) surname. + + User will be sent an email to verify. + +- **Github** + - Add the username provided to the mantid-developers team at `https://github.com/organizations/mantidproject/teams <https://github.com/organizations/mantidproject/teams>`_. diff --git a/dev-docs/source/DevelopmentAndReleaseCycle.rst b/dev-docs/source/DevelopmentAndReleaseCycle.rst new file mode 100644 index 0000000000000000000000000000000000000000..9cb8dd18563d54e4a98302647cc565535cf7528c --- /dev/null +++ b/dev-docs/source/DevelopmentAndReleaseCycle.rst @@ -0,0 +1,27 @@ +.. _DevelopmentAndReleaseCycle: + +============================= +Development and Release Cycle +============================= + +Mantid makes 3 point releases per year. The list of current milestones, along with their +expected release dates, is shown at https://github.com/mantidproject/mantid/milestones. The rough +structure of the development cycle is shown in the following figure: + +.. figure:: images/DevelopmentAndReleaseCycle.png + :alt: Development and Release cycle + +Each release is divided, roughly, into: + +* a 3 month development period where new features and bugfixes are developed +* a 3 week code freeze where the code is tested and prepared for the next release + + * during the freeze a 2 week beta-test period is given to users to test the upcoming + release candidate (deployed in the form of a nightly build). + +Feature development occurs on the `master <https://github.com/mantidproject/mantid/tree/master>`__ branch. At the code +freeze, once all pull requests marked for the release have been merged, a new branch is created for the next release. Fixes +found during testing are merged to the release branch and the master remains open to changes not destined for this release. + +The maintenance period generally overlaps with the tail end of the code freeze. All maintenance tasks occur on the +master branch and should not disturb the release branch. diff --git a/dev-docs/source/DevelopmentTeam.rst b/dev-docs/source/DevelopmentTeam.rst new file mode 100644 index 0000000000000000000000000000000000000000..af0cb984ac13c98c5aad3f6e7259587c416406a6 --- /dev/null +++ b/dev-docs/source/DevelopmentTeam.rst @@ -0,0 +1,110 @@ +.. _DevelopmentTeam: + +Development Team +================ + ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Name | Location | Areas of | Contact | +| | | Knowledge | details | ++============================+=============+================================================================+=========================================+ +| Nick Draper(PM) | RAL, UK | Project management, | | email: nick.draper@stfc.ac.uk | +| | | User Requirements, | | skype: nicholas_draper | +| .. image:: | | Architectural design, | | phone: +44(0)1235 567212 | +| images/NDraper.jpg | | Geometry design, | | +| :width: 100px | | dispute resolution | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Peter Peterson | ORNL, US | | | email: petersonpf@ornl.gov | +| | | | | skype: peterfpeterson | +| .. image:: | | | | +| images/PPeterson.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Mathieu Doucet | ORNL, US | Small angle | | email: doucetm@ornl.gov | +| | | neutron | | skype: mathieu.doucet | +| .. image:: | | scattering | | +| images/MDoucet.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Martyn Gigg | RAL, UK | | | email: martyn.gigg@stfc.ac.uk | +| | | | | phone: +44(0)1235 445228 | +| .. image:: | | | | +| images/MGigg.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Roman Tolchenov | RAL, UK | Curve fitting and optimisation, MantidPlot user interface | | email: roman.tolchenov@stfc.ac.uk | +| | | | | phone: +44(0)1235 445852 | +| .. image:: | | | | +| images/RTolchenov.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Anders | RAL, UK | Instrument and Parameter definitions, Curve fitting and | | email: anders.markvardsen@stfc.ac.uk | +| Markvardsen | | optimisation, Muon data reduction and user interface | | skype: thomas_heldig | +| | | | | phone: +44(0)1235 445137 | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Karl Palmen | RAL, UK | | | email: karl.palmen@stfc.ac.uk | +| | | | | slack: karl_palmen | +| | | | | phone: +44(0)1235 445794 | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Owen Arnold | RAL, UK | Project Manager for ESS In-Kind team at ISIS. Live Data | | email: owen.arnold@stfc.ac.uk | +| | | Reduction, Visualisation and Instrument Control | | skype: owen_arnold | +| .. image:: | | | | phone: +44(0)1235 565253 | +| images/OArnold.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Michael Hart | RAL, UK | ESS In-Kind team at ISIS. Live Data Reduction, Visualisation | | email: michael.hart@stfc.ac.uk | +| | | and Instrument Control | | phone: +44(0)1235 445253 | +| | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Lamar Moore | RAL, UK | ESS In-Kind team at ISIS. Live Data Reduction, Visualisation | | email: lamar.moore@stfc.ac.uk | +| | | and Instrument Control | | skype: lamar.mantid | +| .. image:: | | | | phone: +44(0)1235 565253 | +| images/LMoore.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Jean Bilheaux | ORNL, US | | | email: bilheuxjm@ornl.gov | +| | | | | skype: jeanbilheux | +| .. image:: | | | | phone: +1 865-241-6969 | +| images/JBilheaux.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Andrei Savici | ORNL, US | Triple Axis, Inelastic Resolution and Fitting, Single Crystal | | email: saviciat@ornl.gov | +| | | Diffraction and Inelastic | | skype: a_savici | +| .. image:: | | | | phone: +1 917-543-5535 | +| images/ASavici.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Jose Borreguero | ORNL, US | Quasielastic model fitting, MD simulations | | email: borreguerojm@ornl.gov | +| | | | | skype: jmborr | +| .. image:: | | | | phone: +1 678 793 6463 | +| images/JBorreguero.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Vickie Lynch | ORNL, US | | | email: lynchve@ornl.gov | +| | | | | skype: ornlmantid_vickie | +| .. image:: | | | | phone: +1 865-574-0623 | +| images/VLynch.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Wenduo Zhou | ORNL, US | | | email: zhouw@ornl.gov | +| | | | | skype: wenduozhou | +| .. image:: | | | | +| images/WZhou.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Ricardo Ferraz Leal | ORNL, US | Data reduction for HFIR SANS (BioSANS and GPSANS) | | email: ferrazlealrm@ornl.gov | +| | | | | skype: ricferrazleal | +| .. image:: | | | | +| images/RFerrazLeal.jpg | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Ross Whitfield | ORNL, US | | email: whitfieldre@ornl.gov | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Gagik Vardanyan | ILL, FR | | | email: vardanyan@ill.fr | +| | | | | skype: vardanyan_ILL | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ +| Gemma Guest | RAL, UK | Large scale structures at ISIS (reflectometry and small angle | | email: gemma.guest@stfc.ac.uk | +| | | neutron scattering) | | skype: live:gemmabguest | +| .. image:: | | | | phone: +44(0)1235 394011 | +| images/GGuest.png | | | | +| :width: 100px | | | | ++----------------------------+-------------+----------------------------------------------------------------+-----------------------------------------+ diff --git a/dev-docs/source/DoxygenSetup.rst b/dev-docs/source/DoxygenSetup.rst new file mode 100644 index 0000000000000000000000000000000000000000..0c7f3b2d2104fe1842c126c3a01200bc49ca7808 --- /dev/null +++ b/dev-docs/source/DoxygenSetup.rst @@ -0,0 +1,83 @@ +Doxygen Setup +============= + +Unix Console Doxygen Setup +-------------------------- + ++-----------------+-----------------------------------------------------------------------------------------+ +| | Check for | You may well already have doxygen installed but is it most likely | +| | doxygen | in your systems repositories. | +| | If not, build from source | +| | `here <http://www.stack.nl/~dimitri/doxygen/download.html#srcbin>`__. | ++-----------------+-----------------------------------------------------------------------------------------+ +| Run cmake | CMake will genereate the doyxgen config file | +| | in ${CMAKE_DIR}/Framework/Doxygen/Mantid.doxyfile | ++-----------------+-----------------------------------------------------------------------------------------+ +| | You're done! | - Type 'make doxygen' | +| | Try! | - This will run doxygen, showing the output in the console. You may | +| | want to pipe warnings to a file to make them easy to read later: | +| | 'make doxygen 2> doxygen_errors.log' | +| | - The documentation will go into a subdir doxygen/html of the | +| | directory where cmake was run from. | ++-----------------+-----------------------------------------------------------------------------------------+ + +Visual Studio Doxygen Setup +--------------------------- + ++-----------------+-----------------------------------------------------------------------------------------+ +| Install doxygen | Download the | +| binaries | `Windows binaries <http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc>`__ | +| | and install them. I'll assume in the following you installed doxygen in | +| | c:\program files\doxygen | ++-----------------+-----------------------------------------------------------------------------------------+ +| Rerun CMake | Run cmake for the build to ensure that the Mantid.doxyfile is created | ++-----------------+-----------------------------------------------------------------------------------------+ +| Add VC++ Tool: | - Tools\External Tool then click Add | +| "DoxyGen" | - Title: &DoxyGen | +| | - Command: C:\Program Files\Doxygen\bin\doxygen.exe | +| | - Arguments: "$(SolutionDir)\Framework\Doxygen\Mantid.doxyfile" (include the quotes!) | +| | - Initial Directory: $(SolutionDir)\Build | +| | - Check the "Use output window" box | ++-----------------+-----------------------------------------------------------------------------------------+ +| Add VC++ Tool: | - Tools\External Tool then click Add | +| "view DoxyGen" | - Title: &View DoxyGen | +| | - Command your favorite browser, e.g. C:\program Files\internet Explorer\iexplore.exe | +| | or C:\Program Files (x86)\Google\Chrome\Application\chrome.exe | +| | - Arguments: "$(SolutionDir)doxygen\html\index.html" | +| | - Initial Directory: leave empty | ++-----------------+-----------------------------------------------------------------------------------------+ +| You're done! | - Choose Tools/DoxyGen from the menu, and watch the magic happen (DoxyGen will log | +| Try! "DoxyGen" | it's progress and complaints to the output window). Clicking on a warning message | +| | will take you to the location in the code of the warning. | +| | - Choose Tools/View DoxyGen to explore the documentation. | +| | - The "Main Page" is probably rather boring. Click on "Namespaces" in the menu line to | +| | browse your classes etc. | ++-----------------+-----------------------------------------------------------------------------------------+ + +Eclipse Doxygen Setup +--------------------- + ++-----------------+-----------------------------------------------------------------------------------------+ +| Check for | You may well already have doxygen installed, but if not you can install it at the same | +| doxygen | time as the plugin below via the update site | ++-----------------+-----------------------------------------------------------------------------------------+ +| Run cmake | This will generate the doxygen config file in | +| | ${CMake_DIR}/Framework/Doxygen/Mantid.doxygen | ++-----------------+-----------------------------------------------------------------------------------------+ +| Install Eclipse | - `Eclox <http://eclox.eu/>`_ is a frontend plugin for Eclipse. | +| plugin: "Eclox" | - Install it using the Eclipse Update Manager | +| | - To do this go to Help -> Software Updates... | +| | - Select the 'Available Software' tab then the 'Add Site...' button | +| | - Enter `http://download.gna.org/eclox/update` as the location | +| | - Eclipse will add the site to the list and you can open the tree to select and install | +| | Eclox | ++-----------------+-----------------------------------------------------------------------------------------+ +| You're done! | - You'll now have a 'build doxygen' button in your toolbar (a blue '@') | +| Try! | - The first time you click it you'll be prompted for the configuration file. Point it | +| | at ${CMake_DIR}/Framework/Doxygen/Mantid.doxygen | +| | - This will run doxygen, showing the output in the console and adding warnings symbols | +| | on the source files (as for compilation warnings). Hovering over these will show the | +| | warning. | +| | - The documentation will go into a subdir doxygen/html of the directory where cmake was | +| | run from. | ++-----------------+-----------------------------------------------------------------------------------------+ diff --git a/dev-docs/source/FlowchartCreation.rst b/dev-docs/source/FlowchartCreation.rst new file mode 100644 index 0000000000000000000000000000000000000000..8b1db35c64aec5b0e6eabb11486d45221222fe25 --- /dev/null +++ b/dev-docs/source/FlowchartCreation.rst @@ -0,0 +1,65 @@ +.. _FlowchartCreation: + +================== +Flowchart Creation +================== + +.. contents:: + :local: + + +The flowchart diagrams are created by writing ``graphviz`` .dot files that describe the diagram in plain text, and placing them into ``docs/source/diagrams``. These can then be rendered in documentation by using the diagram directive in an .rst file: + +.. code-block:: rest + + .. diagram:: AlgorithmName-v1_wkflw.dot + +Examples of this can be found in `ReflectometryReductionOne1.rst <https://raw.githubusercontent.com/mantidproject/mantid/master/docs/source/algorithms/ReflectometryReductionOne-v1.rst>`__ and `ReflectometryReductionOneAuto-v1.rst <https://raw.githubusercontent.com/mantidproject/mantid/master/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst>`__. + +The .dot format is quite simple¸ but very powerful for describing graphs. The approach we use is to describe all the nodes (shapes) we want first, grouping them into their types, and then defining how they're connected. + +To provide a uniform look to all the workflow diagrams, templated keywords are provided which are swapped out with the correct styling options when the documentation is built. They are of the form ``${context}_style``. They're defined by the `diagram directive <https://raw.githubusercontent.com/mantidproject/mantid/master/docs/sphinxext/mantiddoc/directives/diagram.py>`__. + +An algorithm that takes one input workspace and scales it by a given parameter/property if it was given, may look like this: + +:: + + digraph DiagramName { + //Comments are inserted in the same way as C++ + label = "MultiplyByParam Workflow Diagram" + $global_style + + subgraph params { + //These keywords beginning with $ are replaced with commands to style all the nodes in the subgraph correctly + $param_style + inputWorkspace [label="InputWorkspace"] + outputWorkspace [label="OutputWorkspace"] + coefficient [label="Coefficient"] + } + + subgraph decisions { + $decision_style + checkCoefficient [label="Was Coefficient\ngiven?"] + } + + subgraph algorithms { + $algorithm_style + scale [label="Scale"] + } + + //Define the connections, labelling some of them + inputWorkspace -> checkCoefficient + coefficient -> scale [label="Factor"] + checkCoefficient -> scale [label="Yes"] + checkCoefficient -> outputWorkspace [label="No"] + scale -> outputWorkspace + } + +While creating the diagrams it's inconvenient to recompile the documentation with each change, so you may want to render the graph manually. This can be achieved on linux or cygwin by running the following command. *You may need to comment out the "$foo_style" lines when manually rendering as they are not valid graphviz syntax* (you can do this on the fly using sed to avoid having to edit the file). + +:: + + dot -Tpng -o output_image.png input_file.dot # render a graph manually + sed 's/\$/\/\/$/g' input_file.dot | dot -Tpng -o output_image.png # excludes $foo_style lines + +You can also render them in a web browser using this `online graph renderer <http://www.webgraphviz.com/>`__. diff --git a/dev-docs/source/GUIDesignGuidelines.rst b/dev-docs/source/GUIDesignGuidelines.rst new file mode 100644 index 0000000000000000000000000000000000000000..e545781ef223e468c3c164d8779d1389ba501806 --- /dev/null +++ b/dev-docs/source/GUIDesignGuidelines.rst @@ -0,0 +1,292 @@ +.. _GuiDesignGuidelines: + +===================== +GUI Design Guidelines +===================== + +.. contents:: + :local: + +Summary +####### + +This page describes guidelines that should be followed when +implementing an interface in MantidPlot. The aim is to encourage a +consistent approach to developing interfaces. + +.. _GuiDesignGuidelinesMVPIntro: + +MVP (Model View Presenter) +########################## + +GUIs in Mantid aim to use the MVP pattern. The MVP pattern is a +generic concept for how to structure GUI code. MVP allows components +of the GUI to be tested separately and automatically. It also allows +for greater flexibility. Decoupling the model and view means that if +the developer wants to experiment with, for example, a different GUI +toolkit, or a different method of doing their calculations, then it is +easy and safe to swap out components. A description of each component +is given below. + +To illustrate MVP, a simple example of a calculator GUI has been +created using Python (the concepts of MVP can be applied to any +programming language). This example can be found in +:ref:`MVPCalculatorGUIExample`, and you can run it with +``python Calculator.py``. + +It is good practice to have model, view or presenter (as appropriate) +at the end of the name for each file (e.g. FFTView, FFTModel, +FFTPresenter), and each component should be a class in its own +right. Within the MVP pattern the model and view never exchange any +information directly. + +Model +----- + +The model is where the 'hard sums' take place within GUI. Any Mantid +algorithms should be run in the model, as well any other calculations +that may need to be performed. + +It is possible that a presenter may have multiple models. For example +if two GUIs require the same calculation (e.g. mean) but not all +of the model (one GUI may need standard deviation and the other the +median), then it would be sensible for there to be three models (with +the mean model being shared). This prevents code duplication and makes +maintenance easier. + +It is important to note that the values used in the calculations +should be received from the presenter (more of which below). + +.. _GuiDesignGuidelinesMVPView: + +View +---- + +The view determines the look of the GUI. In passive-view MVP, there +will generally be very little logic in the view. A view should define +the following sections: + +* The look of the GUI (often this will be defined in a Qt ``.ui`` file + instead) +* **Get** methods to return values from the widgets (text input, + checkbox etc) +* **Set** methods to update the output from the GUI (eg. plot some + data, fill in some text boxes) + +A view will probably also contain **connections**. A detailed +explanation of signals and slots can be foud `here +<http://doc.qt.io/archives/qt-4.8/signalsandslots.html>`_. Briefly, a +widget may emit **signals**. For example QPushButton emits the signal +``clicked`` when it is clicked. In order to handle the button being +clicked, the view will implement a **slot** method. This method does +whatever we need for a button click. To ensure that this method is +called whenever the button is clicked, we connect the ``clicked`` +signal of our button to the ``handleButtonClick`` slot of our view. + +The view should have a parent - this will be the widget containing +it. An example of a parent would be a main window containing tabs - +the children of the main window would be the tabs, and the children of +the tabs would be the widgets contained within the tabs. + +Presenter +--------- + +The presenter acts as a 'go-between'. It receives data from the view, +passes it to the model for processing, receives it back from the model +and passes it to the view to be displayed to the user. The presenter +generally should contain relatively simple logic (though it will be +more complex than the view). + +The model and the view are stored as members of the presenter +class. These should be passed into the presenter at initialisation. + +It is important to note that the model and view should have as little +access as possible to the presenter. Presenter-model communication is +simple - the presenter generally just calls methods on the +presenter. Presenter-view communication is slightly more +involved. There are two ways of doing it: + +* **Connections** - the presenter may contain connections as well as + the view. You may choose to define custom signals in your view, such + as a ``plotRequested`` signal to announce that the user has asked to + plot some data, probably by clicking a button. The presenter will + need to implement a slot (let's call it ``handlePlotRequested``) to + handle this, which gets the relevant data from the model and passes + it to the view. We then need to connect the signal to the slot in + the presenter's constructor. It is also possible for a signal + emitted by a view to be caught in the presenter of a parent view. In + order to communicate by connections using Qt in C++ the presenter + must inherit from ``QObject``. It's generally considered good + practice to avoid having Qt in the presenter, so this method works + best for GUIs written in Python (or another language with a more + relaxed type system). + + - Note that is good practice to handle all signals in the presenter + if you can, even if it is possible to just handle them in the + view. This is because by going through the presenter we can unit + test the handling of the signals. +* **Notify** - the presenter may instead allow the view to 'notify' + it. This can be achieved by implementing a set of possible + notifications (in C++ an enum class works well) and a method + ``notify(notification)`` on the presenter. In the above example, + ``handlePlotRequested`` is still needed, but now ``notify`` invokes + it whenever it is passed a ``plotRequested`` notification. This + method requires the view to have a pointer to the presenter, which + introduces a circular dependency and leaks information about the + presenter to the view. The leak can be resolved by having the + presenter implement an interface which exposes **only** the + ``notify`` method, and having the view keep a pointer to + this. + +Doing presenter-view communication with connections is the cleaner of +the two, so this method should be used unless writing a GUI in +C++. You'll notice that, in both cases, the view never passes data +(for example, the input from a text box) directly to the presenter, +instead it justs tells the presenter that something needs to be +done. In passive-view MVP the presenter, in handling this, gets any +data it needs from the view using the view's **get** methods. + +Testing MVP Components +---------------------- + +MVP allows us to write automated tests for a large amount of the +GUI. We can write independent tests for the presenter and model, but +usually not the view (for this reason, the view should be as simple as +possible, ideally containing no logic at all). + +**Mocking** is very useful tool for testing the presenter. Mocking +allows us to return a predefined result from a method of either the +view or the model. + +It is useful to mock out the model because, providing that we've +written adequate tests for it, we don't care what the output is in the +tests for the presenter - we just care that the presenter handles it +correctly. The model may perform time-consuming calculations, such as +fitting, so by returning a dummy value from the fitting method we cut +down the time our tests take to run. We can also potentially change +how the model works - if the GUI uses an algorithm which undergoes +some changes, such as applying a different set of corrections, the +tests for the presenter will be unaffected. + +It's useful to mock out the view because we don't want to have to +manually input data every time the unit tests are run - instead we can +mock the **get** methods to simulate the user entering data. + +Using `GMock +<https://github.com/google/googletest/blob/master/googlemock/docs/Documentation.md>`_ +in C++, or `unittest.mock +<https://docs.python.org/3/library/unittest.mock.html>`_ in Python, we +can set expectations in the unit tests for certain methods to be +called, and with certain arguments. + +Qt Designer +########### + +The layout of all interfaces and reusable widgets should be done by +using the Qt's `Designer +<http://qt-project.org/doc/qt-4.8/designer-manual.html>`_ tool. This +has several advantages: + +* immediate visual feedback of what the widget/interface will look + like +* far easier to maintain, e.g. moving a control is a simple drag and + drop +* reduces the amount of hand-written code required + +If it is felt that the design must be hand coded then this should be +discussed with a senior developer. + +Reusable Widgets +################ + +Many interfaces will require similar functionality. For example, the +ability to enter a filename string to search for a file along with a +'Browse' button to select a file from the filesystem. This type of +behaviour should be captured in a new composite widget that can be +reused by other components. + +The new widget should be placed in the MantidWidgets plugin and a +wrapper created in the DesignerPlugins plugin so that the new widget +type can be used from within the Qt Designer. + +The current set of reusable items are: + ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| Class Name | Parent Class | Abiltity | ++=========================+===============+==============================================================================================================================================================+ +| AlgorithmSelectorWidget | QWidget | A text box and tree widget to select an algorithm | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| CatalogSearch | QWidget | An interface interface to the catalog system | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| CatalogSelector | QWidget | Displays the available catalog services | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| CheckBoxHeader | QHeaderView | Enables checkboxes to exist in the table header | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ColorBarWidget | QWidget | Show a color bar that can accompany a colored bidimensional plot | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| DataSelector | MantidWidget | A box to select if input is from a file or workspace along with the appropriate widget to choose a workspace or file. | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| DisplayCurveFit | MantidWidget | A plot to display the results of a curve fitting process | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| FindReplaceDialog | QDialog | A dialog box to find/replace text within a ScriptEditor | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| FitPropertyBrowser | QDockWidget | Specialisation of QPropertyBrowser for defining fitting functions | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| FunctionBrowser | QWidget | Provides a wiget to alter the parameters of a function | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| InstrumentSelector | QCombobox | A selection box populated with a list of instruments for the current facility | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| LineEditWithClear | QLineEdit | A QLineEdit with a button to clear the text | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| MessageDisplay | QWidget | Display messages from the logging system | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| MWRunFiles | MantidWidget | Provides a line edit to enter filenames and a browse button to browse the file system | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| MWView | QWidget | A colored, bidimensional plot of a matrix workspace | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ProcessingAlgoWidget | QWidget | A composite widget that allows a user to select if a processing step is achieved using an algorithm or a Python script. It also provides a script editor. | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| ScriptEditor | QsciScintilla | The main script editor widget behind the ScriptWindow | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ +| WorkspaceSelector | QComboBox | A selection box showing the workspaces currently in Mantid. It can be restricted by type. | ++-------------------------+---------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +Python +###### + +Interfaces can also be created in Python using the `PyQt4 +<http://pyqt.sourceforge.net/Docs/PyQt4/>`_ package. The code for the +interface should be placed in a Python `package +<https://docs.python.org/2/tutorial/modules.html#packages>`_ under the +``Code/Mantid/scripts`` directory. It should be named after the interface +name (without spaces). The code within the package should be +structured to avoid placing all of the code in a single file, +i.e. separate files for different classes etc. Sub packages are +recommended for grouping together logical sets of files. + +For the interface to appear from within MantidPlot create a startup +python file under the ``Code/Mantid/scripts`` directory. Assuming the code +for the interface is in a directory called foo_app then the startup +file would look like: + +.. code-block:: python + + from foo_app import FooGUI + + app = FooGUI() + app.show() + +where ``FooGUI`` is the ``MainWindow`` for the interface. Some more +detailed documentation on creating GUIs in Python can be found at +:ref:`QtDesignerForPython`. + +Designer +-------- + +As with the C++ GUI the Qt Designer should be used for layouts of all +widgets and the main interface. It is recommended that the ``.ui`` +files be placed in a ``ui`` subdirectory of the interface package. To +generate PyQt code from the UI xml you will need to run the ``pyuic4`` +program that ships with PyQt4. It is also recommended that the output +file is named, using the ``-o`` argument, ``ui_[widgetname].py`` and +placed in the ``ui`` subdirectory. diff --git a/dev-docs/source/GettingStarted.rst b/dev-docs/source/GettingStarted.rst index bfbbe1927dcd6659d91b26cb9aaa644c0afe7443..929dd0976f0148941d9a213ddf155bde5e53ad5a 100644 --- a/dev-docs/source/GettingStarted.rst +++ b/dev-docs/source/GettingStarted.rst @@ -1,14 +1,16 @@ -=========================== -Getting Started with Mantid -=========================== +.. _GettingStarted: + +=============== +Getting Started +=============== .. contents:: :local: -Prerequisites -############# +Environment +########### -Some intial setup is required before being able to build the code. This is platform +Some initial setup is required before being able to build the code. This is platform specific and described here. Windows @@ -18,23 +20,26 @@ Install the following: * `Visual Studio 2015 Community Edition <https://go.microsoft.com/fwlink/?LinkId=532606&clcid=0x409>`_. If you are at RAL then ask for the location of the locally-cached offline version. -* `Git <https://git-scm.com/download/win>`_ -* `Git LFS <https://git-lfs.github.com/>`_ - - * After installation open Git Bash and run ``git lfs install`` - +* `Git <https://git-scm.com/>`_. After installation open Git Bash and run ``git lfs install``. * `CMake <https://cmake.org/download/>`_ -* `MiKTeX <https://miktex.org/download>`_. Instructions are available - `here <https://miktex.org/howto/install-miktex>`_. +* `MiKTeX <https://miktex.org/download>`_. Instructions are + `available here <https://miktex.org/howto/install-miktex>`_. * `NSIS <http://nsis.sourceforge.net/Download>`_ (optional). Used for building packages +`Graphviz <http://graphviz.org/download/>`__ is required to generate the workflow diagrams in the documentation. +Unfortunately CMake can't find it out of the box and the following steps are required to make this link + +* open regedit +* add a new key ``[HKEY_LOCAL_MACHINE\\SOFTWARE\\ATT\\Graphviz]`` +* create a new string value named ``InstallPath`` within this key and set the value + to point to the install directory of Graphviz. + Linux ----- Red Hat/Cent OS/Fedora -^^^^^^^^^^^^^^^^^^^^^^ - -Follow the instructions at http://download.mantidproject.org/redhat.html to add the +~~~~~~~~~~~~~~~~~~~~~~ +Follow the `Red Hat instructions <http://download.mantidproject.org/redhat.html>`_ to add the stable release yum repository and then install the ``mantid-developer`` package: .. code-block:: sh @@ -42,9 +47,8 @@ stable release yum repository and then install the ``mantid-developer`` package: yum install mantid-developer Ubuntu -^^^^^^ - -Follow the instructions at http://download.mantidproject.org/ubuntu.html to add the +~~~~~~ +Follow the `Ubuntu instructions <http://download.mantidproject.org/ubuntu.html>`_ to add the stable release repository and mantid ppa. Download the latest `mantid-developer <https://sourceforge.net/projects/mantid/files/developer>`_ package and install it: @@ -56,3 +60,41 @@ package and install it: where ``X.Y.Z`` should be replaced with the version that was downloaded. +OSX +--- +The build environment on OS X is described here :ref:`BuildingOnOSX`. + +Getting the Mantid code +############################ +We use `Git`_ as our version control system (VCS). The master copies of our repositories are located at `GitHub <http://github.com/mantidproject>`_. We have a number of repositories, of which the main one (the one containing all the source code for Mantid itself) is called simply `mantid <http://github.com/mantidproject/mantid>`_. + +If you are not already set up with Git, you can follow these `instructions <https://git-scm.com/book/en/v2/Getting-Started-First-Time-Git-Setup>`_. + +If you are at RAL then please run the following commands before cloning the repository: + +.. code-block:: sh + + git config --global url.git@github.com:mantidproject.insteadOf http://mantidweb.nd.rl.ac.uk/mirror/git/ + +This will speed up the clone and intial cmake run considerably. + +There are a number of URLs via which the code can be checked out using various protocols. The easiest way to get the one you want is to select the protocol you want on the right side of the `mantid <http://github.com/mantidproject/mantid>`_ repository page on github and copy the url into your clipboard. The way to clone the repository via ssh on the command line, into a directory called Mantid, is: + +.. code-block:: sh + + git clone git@github.com:mantidproject/mantid.git + +If at RAL now remove the config section above + +.. code-block:: sh + + git config --global --unset url.git@github.com:mantidproject + + +Building Mantid +############### +See :ref:`BuildingWithCMake` for information about building Mantid. + +Building VATES +############## +See :ref:`BuildingVATES` for infromation about building VATES. diff --git a/dev-docs/source/GitWorkflow.rst b/dev-docs/source/GitWorkflow.rst new file mode 100644 index 0000000000000000000000000000000000000000..465c0266e343f3952967c0ccdff5128cd16427cf --- /dev/null +++ b/dev-docs/source/GitWorkflow.rst @@ -0,0 +1,190 @@ +.. _GitWorkflow: + +=================== +Mantid Git Workflow +=================== + +.. contents:: Contents + :local: + +Summary +^^^^^^^ + +This page describes the workflow used in conjunction with `Git +<http://git-scm.com>`_ and `GitHub <https://www.github.com/>`_ for +those who have push access to the repository. + +Go `here +<https://services.github.com/on-demand/downloads/github-git-cheat-sheet.pdf>`__ +for a cheatsheet of Git commands. + +Go `here <https://github.com/k88hudson/git-flight-rules>`__ for a +(fairly) comprehensive guide to solving your various Git problems. + +Description +^^^^^^^^^^^ + +We follow the `GitHub flow +<https://guides.github.com/introduction/flow/index.html>`_, using +branches for new work and pull requests for verifying the work. + +The steps for a new piece of work can be summarised as follows: + +1. Push up or `create <https://guides.github.com/features/issues>`_ an + issue `here <https://github.com/mantidproject/mantid/issues>`__ +2. Create a branch from master, using the naming convention described + at :ref:`GitWorkflowPublicPrivateBranches` +3. Do the work and commit changes to the branch. Push the branch + regularly to GitHub to make sure no work is accidentally lost +4. When you are finished with the work, ensure that all of the unit + tests, documentation tests and system tests if necessary pass on + your own machine +5. Open a pull request (:ref:`GitWorkflowPullRequests`) + from the `GitHub branches + <https://github.com/mantidproject/mantid/branches/>`_ page + + - This will check with the buildservers for cross-platform + compatibility + - If any issues come up, continue working on your branch and push + to GitHub - the pull request will update automatically + +.. _GitWorkflowPublicPrivateBranches: + +Public and Private Branches +^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +When naming `public branches +<http://github.com/mantidproject/mantid/branches>`_ that will be +pushed to GitHub, please follow the convention of +``issuenumber_short_description``. This will allow others to discover +what the branch is for (issue number) and quickly know what is being +done there (short description). Please remember that public branches +should not be rebased. + +For private branches please follow the convention +``yourname/issuenumber_short_description``. You can sync these with +GitHub (for backup reasons) and rebase. Since the branch name is +prefixed with your name people will know, by convention, that it is a +private branch and can be rebased, deleted, etc at the owner's +whim. Changing a private branch is done by simply renaming the branch +to drop the prefix. + + +.. _GitWorkflowPullRequests: + +Pull Requests +^^^^^^^^^^^^^ + +For an general overview of using pull requests on GitHub look `here +<https://help.github.com/articles/using-pull-requests/>`__. + +When creating a pull request you should: + +- Ensure that the title succinctly describes the changes so it is easy + to read on the overview page + + - The title should **not** contain the issue number +- `Reference the issue which the pull request is closing <https://github.com/blog/1506-closing-issues-via-pull-requests>`_, using one of `these <https://help.github.com/articles/closing-issues-via-commit-messages>`_ keywords +- Ensure the description follows the format described by the `PR + template + <https://github.com/mantidproject/mantid/blob/master/.github/PULL_REQUEST_TEMPLATE.md>`_ + on GitHub + +A good example is `here <https://github.com/mantidproject/mantid/pull/18713>`__. + +Recommended reading: `How to Write the Perfect Pull Request +<https://github.com/blog/1943-how-to-write-the-perfect-pull-request>`_ + +Stale Pull Requests +------------------- + +Pull requests that go an extended period of time without any activity +are considered stale and will be picked up by a (partially) automated +bot which will notify those that are required to take action in order +to keep the review process going. + +This is also used to notify developers of pull requests that develop +conflicts with the base branch and that fail continuous integration +tests, in those two cases the age of the pull request is ignored. + +The reasons a pull request may be flagged up currently are: + +- Conflicts with base branch +- Failing CI +- Last developer has left the Mantid team +- Nobody has reviewed the PR +- An assigned reviewer has yet to complete a review +- A gatekeeper has not second reviewed an approved PR +- A review from a specific user was requested but that user has yet to complete a review +- The developer has yet to act on comments left in a review + + +(code for the bot is currently `here +<https://github.com/DanNixon/mantid_pr_bot>`__) + +Code Freeze +^^^^^^^^^^^ + +At the start of a *code freeze* before a major release there will be a +release branch created with the name ``release-vX.Y``, where ``X.Y`` +are the major and minor version numbers, respectively. At this point +only bugfixes should be applied to this release branch so that it can +be stabilized for the release. The release branch will be merged to +``master`` periodically so bugfixes do not need to be separately +merged to ``master``. + +New Branches +------------ + +During the code freeze it is important to ensure that a new branch is +created from the correct base branch depending on the scope of the +changes: + +- ``master``: maintenance fixes, new features. Command: ``git fetch -p && git checkout --no-track -b MYBRANCH_NAME origin/master`` +- ``release-vX.Y``: bugfixes. Command: ``git fetch -p && git checkout --no-track -b MYBRANCH_NAME origin/release-X.Y`` + +Pull Requests +------------- + +Open pull requests as normal to ask to merge your branch with its +intended target. + +.. image:: images/CodeFreezePR.png + +Fixing a PR with an Incorrect Base Branch +----------------------------------------- + +The target branch on GitHub needs to match the base branch used in the +commands above when the branch was initially created. If the compare +view shows changes other than your own it is most likely that the base +branch is incorrect and it needs to be fixed. + +As an example consider the scenario where a branch named ``topic`` has +been based off the ``master`` branch as follows: + +.. code-block:: bash + + o---o---o---o---o master + | \ + | o---o---o topic + \ + o---o---o---o---o release + +where we actually want the ``topic`` branch based off ``release`` +instead i.e. + +.. code-block:: bash + + o---o---o---o---o master + \ + o---o---o---o---o release + \ + o'---o'---o' topic + +To fix this situation we use the ``rebase`` command, providing the +``--onto`` option as follows: + +.. code-block:: bash + + git fetch + git rebase --onto origin/release origin/master topic diff --git a/dev-docs/source/HandlingXML.rst b/dev-docs/source/HandlingXML.rst new file mode 100644 index 0000000000000000000000000000000000000000..1f7ad335fe1016250ec1e893f99f799f1e8c6993 --- /dev/null +++ b/dev-docs/source/HandlingXML.rst @@ -0,0 +1,85 @@ +Handling XML +============ + +This page provides an introduction into reading/writing XML effectively +within Mantid. In Mantid, we use Poco to handling XML serialisation. A +useful introductory presentation can be found `here. <http://pocoproject.org/slides/170-XML.pdf>`__ + +**This page is a work in progress.** + +Examples +-------- + +Parsing +~~~~~~~ + +.. code-block:: cpp + + + #include <Poco/DOM/Document.h> + #include <Poco/DOM/DOMParser.h> + #include <Poco/DOM/Element.h> + + Poco::XML::DOMParser pParser; + Poco::AutoPtr<Poco::XML::Document> pDoc; + try { + pDoc = pParser.parseString(cuboidStr); + } catch (...) { + // Handle the failure as appropriate + } + // Get pointer to root element + Poco::XML::Element *pRootElem = pDoc->documentElement(); + +Iterating over an element's children +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: cpp + + Poco::XML::Element *pRootElem = pDoc->documentElement(); + //Iterate over every child node (non-recursively) + for (Node *pNode = pRootElem->firstChild(); pNode != 0; pNode = pNode->nextSibling()) { + auto pElem = dynamic_cast<Poco::XML::Element*>(pNode); + if(pElem) { + //We can now do something with this element safely + } + } + +Inspecting an element +~~~~~~~~~~~~~~~~~~~~~ + +.. code-block:: cpp + + Poco::XML::Element *pElem; + + //Reasonably quick operations + const std::string tag = pElem->tagName(); //for <foo>bar</foo> the tag is 'foo' + const std::string value = pElem->innerText(); //for the above example: 'bar' + Poco::XML::Node *pNext = pElem->nextSibling(); + Poco::XML::Node *pPrev = pElem->previousSibling(); + Poco::XML::Node *pChild = pElem->firstChild(); //avoid lastChild, it's expensive + +Avoid NodeList +-------------- + +There are numerous functions that return a ``Poco::XML::NodeList``. You +should avoid using them and the list they return as best you can. + +NodeList is a very inefficient container. Its ``item`` method has a cost +equivalent to the value of ``i`` given to it, and its ``length`` method +a cost of ``n``, where ``n`` is the number of nodes in the list. + +This means that running the following is horrendously slow: + +.. code-block:: cpp + + // NEVER DO THIS + Poco::AutoPtr<Poco::XML::NodeList> pElems = pElem->getElementsByTagName("foo"); + for(int i = 0; i < pElems->length(); ++i) { // length costs N, and is called N times (N² cost) + Poco::XML::Node* pNode = pElems->item(i); // item costs at least i and is called N times, with i from 0 -> N-1 (N² + N cost) + } + // NEVER DO THIS + +Even if the compiler is smart enough to optimise ``pElems->length()`` to +a single call, we still have N² + N performance at best. Instead, we +should **always** use the iteration example given earlier, as that runs +in N time, instead of N². diff --git a/dev-docs/source/InstrumentViewer.rst b/dev-docs/source/InstrumentViewer.rst new file mode 100644 index 0000000000000000000000000000000000000000..bbb9b67200c065742a1471c6cf88fb7c48eb56c1 --- /dev/null +++ b/dev-docs/source/InstrumentViewer.rst @@ -0,0 +1,51 @@ +.. _InstrumentViewer: + +======================== +Instrument Viewer Widget +======================== + +.. contents:: + :local: + +Overview +-------- + +Mantid visualisation system allows users to view the geometry of an instrument and also select and query individual detectors. +An instrument is always shown in the context of a workspace containing data recorded with this instrument. +The detectors are coloured according to the data in the corresponding spectra of the workspace. +The user can select individual detectors by clicking on them and request to see the data recorded by this detector as a table or a graph. +The instrument view also allows users to see close-ups of any component. + +.. figure:: images/InstrumentWidget.jpg + :align: center + :width: 635 + +Implementation +-------------- + +MantidPlot uses :code:`OpenGL` to plot the geometry. :code:`Instrument3DWidget` represents the view window and controls the viewport and the scene. +The base class for a visual element is :code:`GLObject`. :code:`Actors` and :code:`MantidObject` inherit from it. :code:`Actors` represent the instrument components. + +.. figure:: images/InstrumentViewClassDiagram.jpg + :align: center + :width: 752 + +Detector Picking +---------------- + +Detector picking is a process of selecting a detector in the instrument view by clicking on it. +When the user clicks the mouse inside the viewport in the picking mode, MantidPlot creates a hidden image of the instrument in which detectors are given colours encoding the detector's index in the instrument tree. +On the mouse click a colour is read in and decoded back into the index. + +Geometry Handlers and Renderers +------------------------------- + +Each object has a geometry handler attached to it. +The handler is responsible for creating the mesh and rendering the object. +Handlers have different methods of creating meshes. +For example, :code:`GluGeometryHandler` can create simple shapes such as spheres and cylinders, :code:`OCGeometryHandler` creates more complex geometries combining simple shapes together. +:code:`CacheGeometryHandler` reads previously saved geometries from a file. + +.. figure:: images/GeometryHandlers.jpg + :align: center + :width: 793 diff --git a/dev-docs/source/IssueTracking.rst b/dev-docs/source/IssueTracking.rst new file mode 100644 index 0000000000000000000000000000000000000000..004dd47754f2406b8f1f9430b292b95fc493d5e4 --- /dev/null +++ b/dev-docs/source/IssueTracking.rst @@ -0,0 +1,135 @@ +===================== +Mantid Issue Tracking +===================== + +Mantid uses GitHub issues to track new feature and bugfix +development. The issue tracker can be found at `GitHub +<https://github.com/mantidproject/mantid/issues>`_ + +.. contents:: Contents + :local: + +Workflow +^^^^^^^^ + +Every piece of work starts with an open issue. To find issues that are +assigned to you see the section +:ref:`IssueTrackingYourIssues`. How an issue is closed is +then dependent on its requirements: + +- Code changes required: generate a **pull request** + (:ref:`GitWorkflowPullRequests`) + + - Make sure the issue is referenced with ``#issue-number``. It will + then be closed when the pull request is merged +- No code changes required: Close the issue, with a comment explaining + why the issue should be closed, for example: + + - This is a duplicate of #1234 + - This works for me, when I try the following steps .... + - I've spoken to the author of this issue and it does not happen for + them either anymore + - Contacted the instrument scientists that raised this issue and it + has been solved since version 3.4 + - After further investigation we are not going to continue with this + for the following reasons ... The author of this ticket has been + informed. + - (If the issue is an **umbrella** issue, indicated by the + **Roadmap** label) All points in this issue have been addressed + elsewhere (see issues X, Y, Z) + +Creating an Issue +^^^^^^^^^^^^^^^^^ + +Go `here <https://github.com/mantidproject/mantid/issues/new>`__ to +create a new issue. Make sure you assign the appropriate labels (see +:ref:`IssueTrackingLabels`) and milestone. + +.. _IssueTrackingLabels: + +Labels +^^^^^^ + +GitHub allows you to assign various labels to your issues and pull +requests. Labelling your issues and pull requests adequately will +ensure that they are picked up by the right people. + +Labels fall into several groups: (*please note that 'ticket' is used +to refer to either an issue or a PR on this page*) + +- **Component** - which area of Mantid the ticket concerns. The ticket + may be relevant to more than one area. Some commonly used + **Component** labels are: + + - **Framework**: tickets relating to Algorithms, Workspaces and + SimpleAPI + - **GUI** - tickets relating either to the main MantidPlot GUI, or + one if its custom interfaces + - **Python** - whether the change will be implemented in + Python. This is useful for labelling PRs, as branches in which all + changes are in Python often don't need to be rebuilt to be tested, + so can be picked up more quickly +- **Group** - you may belong to a group within Mantid, such as the + Reflectometry group. Use the corresponding label so that others in + your group can easily find your work to review it +- **Misc** - some of the more common **misc** labels are described + below: + + - **Bug** - used for issues or PRs which reference a specific bug in + the software (as opposed to a new feature, or general + improvements) + - **Induction** - if you come across an issue that may be good for a + new starter (not too difficult, low risk, the relevant code is + comprehensively tested, low(ish) priority) don't hog it for + yourself! Put this label on it so that it can be picked up as an + introduction to the Mantid codebase + - **Roadmap** - useful when planning out a large piece of work - use + this to map out the steps you'll need to take along the way. This + will usually subsume several smaller issues +- **Priority** + + - **Priority: High** - use this if your ticket needs picking up + right away, for instance if it relates to a bug which affects a + large number of users +- **Patch candidate** - following a release, low-risk tickets with + high impact on users will be considered for a follow-up (or *patch* + release). If your ticket matches this description, consider + labelling it as a patch candidate +- **Quality** - not all of Mantid is well-written. Use one of these + labels if your ticket involves improving the quality of the Mantid + codebase (these changes will usually be invisible to users) +- **State: In Progress** - use this label on a PR if the work in that + PR is still ongoing, and you don't want a review yet. **REMEMBER TO + REMOVE IT ONCE YOUR WORK IS READY FOR REVIEW** + +Filtering Issues +^^^^^^^^^^^^^^^^ + +GitHub has a powerful issue filtering system that is described `here +<https://help.github.com/articles/searching-issues>`__. Below we list +some common searches that developers will need. It is advised to +bookmark these URLs. + +.. _IssueTrackingYourIssues: + +Your Issues +----------- + +You can view the issues assigned to you by visiting the `list of +issues <https://github.com/mantidproject/mantid/issues>`_, clicking on +the assignee drop down box and finding your name. + +For Review +---------- + +These are useful links to view when you are looking to review/test an +issue or pull request: + +- Go `here + <https://github.com/mantidproject/mantid/pulls?utf8=%E2%9C%93&q=-author%3AGITHUB-NAME-HERE+is%3Apr+is%3Aopen+-label%3A%22State%3A+In+Progress%22+no%3Aassignee+status%3Asuccess>`__ + for pull requests that you did not create and no one else is + assigned. Please replace GITHUB-NAME-HERE with your GitHub username +- Go `here + <https://github.com/mantidproject/mantid/issues?utf8=%E2%9C%93&q=-assignee%3AGITHUB-NAME-HERE+is%3Aissue+is%3Aopen+label%3A%22State%3A+Review+Required%22+>`__ + for issues with no code changes to review. Please replace + GITHUB-NAME-HERE with your GitHub username diff --git a/dev-docs/source/JenkinsConfiguration.rst b/dev-docs/source/JenkinsConfiguration.rst new file mode 100644 index 0000000000000000000000000000000000000000..cceb36dac91b1b959a724ca3ed1eab9133f116f3 --- /dev/null +++ b/dev-docs/source/JenkinsConfiguration.rst @@ -0,0 +1,460 @@ +.. _JenkinsConfiguration: + +===================== +Jenkins Configuration +===================== + +.. contents:: + :local: + +Summary +####### + +Mantid uses the `Jenkins <https://jenkins.io/>`__ automation server to +support the continuous integration requirements of Mantid. This document +aims to describe the general setup of the system. + +Introduction +############ + +Jenkins works on a 'master->slave' principle. The master node is +responsible for orchestrating jobs and managing the slave nodes, where the +work is actually performed. The master node is located at +http://builds.mantidproject.org and each facility is responsible for providing +hardware to act as slaves for the various required configurations. + +General Setup +############# + +The master node is set to a fixed TCP port for JNLP slave agents under +http://builds.mantidproject.org/configureSecurity. + +The anonymous jenkins user has the following rights: Overall Read, +Slave Connect, Job Read, View Read. + +Setting up a New Slave +###################### + +Machine Setup +------------- + +Set up a local ``builder`` account that will be used by the slave. + +Install the :ref:`required prerequisites <GettingStarted>` for the relevant OS. + +.. note:: + For Windows the `Command line Visual C++ build tools <http://landinghub.visualstudio.com/visual-cpp-build-tools>`__ + may be used in place of a full Visual Studio install from version 2017 onwards (the 2015 tools contain a broken `vcvarsall.bat`). + +Windows +------- + +* Ensure that the location of ``msbuild.exe`` (``C:\Windows\Microsoft.NET\Framework64\v4.0.30319``) is on the ``PATH`` + +Slave Connection +^^^^^^^^^^^^^^^^ + +There are following additional steps required to be able to connect a +Windows slave using JNLP as a Windows service : + +#. Setup the slave on the master node using "New Node" under + http://builds.mantidproject.org/computer/. If "New Node" is not visible + then you do not have the required permissions - ask an admin for help. It is + recommended that you copy from an existing node of a similar type. +#. Once configured on the master, remote desktop to the slave, open a browser and connect to the webpage of the + slave, .e.g. http://builds.mantidproject.org/computer/ornl-pc73896/ +#. Click on the **connect** button to launch the JNLP client. +#. Once the client is launched, you can select "Install as Windows + Service" from the clients menu. If you have a proxy then see the + section below for further configuration steps. +#. Once installed change the recovery behaviour for + the service. Do this by right-clicking on the Jenkins + service->Properties->Recovery. Change the first, second, subsequent + failures to restart the service. +#. Change the account that the service uses to log on by right-clicking + on the Jenkins service->Properties->Log On and enter the details in + the builder account +#. Change the "Startup type:" of the service to be "Automatic (Delayed Start)" +#. Ensure the msbuild directory is on the ``PATH`` +#. Finally reboot the slave (this is the easiest way for the Jenkins to + start trying to reconnect to it) + +Note that changes to ``PATH`` require restarting the Jenkins service in +order to be reflected in the build environment. + +Connecting Through a Proxy Server +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +It is a little more tricky to windows slaves connected through a +proxy.To do this you must modify the java arguments that are used to +start the ``jenkins-slave`` process. Once the "Install as a Windows +Service" has completed you should + +#. Find a directory on the machine such as ``C:\Jenkins``` or whatever + was configured in the slave config. +#. Open the ``jenkins-slave.xml`` file +#. Edit the tag and add ``-Dhttp.proxyHost=PROXYHOST`` + ``-Dhttp.proxyPort=PROXYPORT`` to the list +#. Save the file and restart the service (or machine) + + +Linux +----- + +Install an ssh server. + +Install ``ccache``. After installing run ``ccache --max-size=20G`` from the ``builder`` account. + +Install a vnc server and from the ``builder`` account run ``vncpasswd`` to set a password on the VNC server. It +can be any password. + +Ensure ``curl`` is installed + +Any machines acting as performance test servers will require ``mysqldb`` to be installed. + +Ubuntu +^^^^^^ + +Configure `automatic security updates <https://help.ubuntu.com/community/AutomaticSecurityUpdates>`__. + +Install ``gdebi-core`` package to allow installing ``.deb`` files. + +The ``builder`` account must be setup to be able to run ``gdebi`` non-interactively. Use ``visudo`` to add the following +exception got ``builder``:: + + # Allow no password for gdebi + builder ALL=(ALL)NOPASSWD:/usr/bin/gdebi, /usr/bin/dpkg + ## Disable tty requirement for gdebi and dpkg command + Defaults!/usr/bin/gdebi !requiretty + Defaults!/usr/bin/dpkg !requiretty + +Red Hat +^^^^^^^ + +The ``builder`` account must be setup to be able to run ``yum`` non-interactively. Use ``visudo`` to add the following +exception got ``builder``:: + + ## Allow no password for yum + builder ALL = NOPASSWD: /usr/bin/yum,/bin/rpm + ## Disable tty requirement for yum command + Defaults!/bin/rpm !requiretty + Defaults!/usr/bin/yum !requiretty + +Mac OS +------ + +Enable `SSH ("Remote Login") and VNC ("Remote Management") <https://apple.stackexchange.com/a/73919>`__. If you have +connection issues from a non-OS X client then try adjusting your color depth settings (True Color 32bpp works on Remmina). + +Install ``cppcheck`` from brew. + +The ``builder`` account must be setup to be able to run ``gdebi`` non-interactively. Use ``visudo`` to add the following +exception got ``builder``:: + + + # Allow builder to install packages without a password + builder ALL=(ALL)NOPASSWD:/usr/sbin/installer, /bin/rm + # Disable tty requirement + Defaults!/usr/sbin/installer !requiretty + Defaults!/bin/rm !requiretty + +In order to run the MantidPlot tests, which require a connection to the windowing system, the user that is running the jenkins slave must +have logged in. This is most easily done by VNC - connect, log in, +then disconnect. If you see errors such as:: + + _RegisterApplication(), FAILED TO establish the default connection to the WindowServer, + _CGSDefaultConnection() is NULL. + +then no one is logged in to the system. + +Linux/Mac Connection Notes +-------------------------- + +The jenkins JNLP connections are maintained by a crontab entry. The +script is in the `mantid repository +<https://github.com/mantidproject/mantid/blob/master/buildconfig/Jenkins/jenkins-slave.sh>`__. + +The comments at the top describe a typical crontab entry for the script. This needs to be manually set for each slave. Ensure the script is +marked executable after downloading it. Also ensure the entry in the crontab +has the correct ``PATH`` setting (by default cron uses a reduced ``PATH`` entry). On macOS ``latex`` and ``sysctl`` +should be available. + +Post-Connection Setup - All Systems +----------------------------------- + +Ensure the new machine is added to the relevant `ParaView build job <http://builds.mantidproject.org/view/ParaView/>`__ and build +ParaView. Set the ``PARAVIEW_DIR`` & ``PARAVIEW_NEXT_DIR`` variables +(it's easiest to just look at the configuration for one of the other +nodes of a similar type. + +Misc Groovy Scripts +################### + +The following is a collection of groovy scripts that can be run either +at http://builds.mantidproject.org/script (for master node) or on a +given node, e.g `isis-mantidx3 <http://builds.mantidproject.org/computer/isis-mantidlx3/script>`__. +You must have admin privileges to run them. + +https://github.com/jenkinsci/jenkins-scripts/tree/master/scriptler was helpful for coming up with some of these. + +Print the Value of an Environment Variable on All Nodes +------------------------------------------------------- + +.. code-block:: groovy + + import jenkins.model.* + import hudson.model.* + import hudson.slaves.* + + VARIABLE_NAME = "PARAVIEW_DIR" + + nodes = Jenkins.instance.getNodes() + println("Displaying values of " + VARIABLE_NAME + " on all nodes") + println() + for(node in nodes) { + node_props = node.nodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class) + if(node_props.size() == 1) { + env_vars = node_props[0].getEnvVars() + if(env_vars.containsKey(VARIABLE_NAME)) { + pv_dir = env_vars.get(VARIABLE_NAME, "") + } else { + pv_dir = VARIABLE_NAME + " not set." + } + println(node.getDisplayName() + ": " + pv_dir) + } else { + pv_dir = VARIABLE_NAME + " not set." + } + } + +Update ParaView variables on nodes +---------------------------------- + +**After running this script the variables look like they are updated but +are in fact cached on the slaves so the new values don't take effect +without disconnecting and forcing each slave to reconnect** + +.. code-block:: groovy + + import jenkins.model.* + import hudson.model.* + import hudson.slaves.* + + VARIABLE_NAME = "PARAVIEW_NEXT_DIR" + VERSION = "ParaView-5.1.2" + + jenkins = Jenkins.instance + nodes = jenkins.getNodes() + println("Displaying values of " + VARIABLE_NAME + " on all nodes") + println() + for(node in nodes) { + node_props = node.nodeProperties.getAll(hudson.slaves.EnvironmentVariablesNodeProperty.class) + if(node_props.size() == 1) { + env_vars = node_props[0].getEnvVars() + if(env_vars.containsKey(VARIABLE_NAME)) { + def pv_dir = node.createPath(env_vars.get(VARIABLE_NAME, "")); + if(pv_dir) { + def pv_build_dir = pv_dir.getParent(); + def pv_dir_new = pv_build_dir.child(VERSION); + println(node.getDisplayName() + ": Updating $VARIABLE_NAME from '" + pv_dir.toString() + "' to '" + pv_dir_new.toString() + "'"); + env_vars.put(VARIABLE_NAME, pv_dir_new.toString()); + } + else { + println(node.getDisplayName() + " has variable set but " + env_vars.get(VARIABLE_NAME, "") + " does not exist"); + } + } else { + println(node.getDisplayName() + ": $VARIABLE_NAME " + "not set.") + } + } else { + println(node.getDisplayName() + ": $VARIABLE_NAME " + "not set.") + } + } + jenkins.save(); + +Check existence of ParaView builds +---------------------------------- + +.. code-block:: groovy + + import hudson.model.* + + nodes = Jenkins.instance.slaves + + PV_VERSION = "5.1.2" + + for (node in nodes) { + FilePath root = node.getRootPath(); + if(root) { + FilePath fp = root.getParent(); + // assume this is $HOME on osx/linux & drive: on Windows + if(fp.toString().startsWith("C:")) { + fp = fp.child("Builds") + } else { + fp = fp.child("build"); + } + fp = fp.child("ParaView-$PV_VERSION"); + if(!fp.exists()) { + println(node.getDisplayName() + " does not have PV 5.1.2") + } + } + } + +Remove directories across multiple nodes +---------------------------------------- + +It is advised to ensure nothing is running and pause the build queue. + +Master Incremental +^^^^^^^^^^^^^^^^^^ + +.. code-block:: groovy + + import hudson.model.* + + nodes = Jenkins.instance.slaves + + JOBNAME = "master_incremental" + + + for (node in nodes) { + labels = ["osx-10.10-build", "rhel6-build", "rhel7-build", "ubuntu-14.04-build", "ubuntu-16.04-build", "win7"]; + for (nodeLabel in labels) { + FilePath fp = node.createPath(node.getRootPath().toString() + File.separator + "workspace" + File.separator + JOBNAME + File.separator + "label" + File.separator + nodeLabel + File.separator + "build"); + if(fp!=null && fp.exists()) { + println(fp.toString()) + fp.deleteRecursive() + } + } + } + +Pull Requests +^^^^^^^^^^^^^ + +.. code-block:: groovy + + import hudson.model.* + + nodes = Jenkins.instance.slaves + + JOB_PREFIX = "pull_requests-" + suffixes = ["win7", "osx", "ubuntu", "ubuntu-python3", "rhel7"]; + + for (node in nodes) { + for (suffix in suffixes) { + FilePath fp = node.createPath(node.getRootPath().toString() + File.separator + "workspace" + File.separator + JOB_PREFIX + suffix + File.separator + "build"); + if(fp!=null && fp.exists()) { + println(fp.toString()) + fp.deleteRecursive() + } + } + } + +Update Branches For Jobs +------------------------ + +.. code-block:: groovy + + import hudson.plugins.git.GitSCM + import hudson.plugins.git.BranchSpec + import static com.google.common.collect.Lists.newArrayList; + + def NEW_BRANCH = "*/release-v3.8" + + // Access to the Hudson Singleton + def jenkins = jenkins.model.Jenkins.instance; + + // Retrieve matching jobs + def allItems = jenkins.items + def chosenJobs = allItems.findAll{job -> job.name =- /release_/}; + + println "Updating branch for chosen jobs to $NEW_BRANCH" + println "" + // Do work + chosenJobs.each { job -> + def scm = job.scm; + if (scm instanceof GitSCM && job.name != "release_nightly_deploy" ) { + //def newScm = scm.clone() + println "Updating branch for " + job.name + scm.branches = newArrayList(new BranchSpec(NEW_BRANCH)) + println "Branch for " + job.name + ": " + scm.branches + println "" + } + } + +List All SCM Urls +----------------- + +.. code-block:: groovy + + import jenkins.model.*; + import hudson.model.*; + import hudson.tasks.*; + import hudson.plugins.git.*; + import org.eclipse.jgit.transport.RemoteConfig; + import org.eclipse.jgit.transport.URIish; + + for(project in Hudson.instance.items) { + scm = project.scm; + if (scm instanceof hudson.plugins.git.GitSCM) { + for (RemoteConfig cfg : scm.getRepositories()) { + for (URIish uri : cfg.getURIs()) { + println("SCM " + uri.toString() + " for project " + project); + } + } + } + } + +Print All Loggers +----------------- + +.. code-block:: groovy + + import java.util.logging.*; + + LogManager.getLogManager().getLoggerNames().each() { + println "${it}"; + } + +Run a Process +------------- + +.. code-block:: groovy + + Process p = "cmd /c dir".execute() + println "${p.text}" + + # kill process on windows + Process p = "cmd /c Taskkill /F /IM MantidPlot.exe".execute() + println "${p.text}" + +Update default values for job parameters +---------------------------------------- + +.. code-block:: groovy + + import hudson.model.* + + def SUFFIX_VARIABLE = "PACKAGE_SUFFIX" + def NEW_SUFFIX = "nightly" + + // Access to the Hudson Singleton + def jenkins = jenkins.model.Jenkins.instance; + + // Retrieve matching jobs + def chosenJobs = ["release_clean-rhel7"] //, "release_clean-ubuntu-16.04", "release_clean-ubuntu"] + + println "Updating default package suffix for chosen jobs to ${NEW_SUFFIX}" + println "" + // Do work + chosenJobs.each { jobName -> + job = jenkins.getItem(jobName) + println(job) + paramsDef = job.getAction(ParametersDefinitionProperty) + params = paramsDef.getParameterDefinitions() + params.each { it -> + if(it.getName() == SUFFIX_VARIABLE) { + println("Updating default value of '${SUFFIX_VARIABLE}' variable to '${NEW_SUFFIX}'") + it.setDefaultValue(NEW_SUFFIX) + } + } + + } diff --git a/dev-docs/source/LoadAlgorithmHook.rst b/dev-docs/source/LoadAlgorithmHook.rst new file mode 100644 index 0000000000000000000000000000000000000000..3c9c0d92504158357c0749d96eb90c16d1dd146b --- /dev/null +++ b/dev-docs/source/LoadAlgorithmHook.rst @@ -0,0 +1,63 @@ +=================== +Load Algorithm Hook +=================== + +.. contents:: + :local: + +The Load Algorithm +################## +This page describes how to register a new file loading algorithm so that it can be used through +the general-purpose :ref:`Load <algm-Load>` algorithm. +The :ref:`Load <algm-Load>` algorithm is a special algorithm as does very little work itself. +It instead tries to search for the most suitable algorithm for a given file and then uses this +algorithm as a child to load the file. An algorithm wishing to be included as part of the search +must register itself slightly differently and not use ``DECLARE_ALGORITHM`` macro. + +The process of searching for the correct loader needs to be fairly quick as it will be especially +noticeable in the GUI if the process takes a long time. To speed up the process the loaders are +currently split into 2 categories: + +- HDF - Currently only HDF4/5 +- NonHDF - The rest + +A quick check is performed, using ``HDFDescriptor::isHDF()``, to test whether the file looks like a +`HDF <http://www.hdfgroup.org/>`__ file. +If the check succeeds then only the HDF group of loaders are checked, otherwise only the NonHDF group are checked. + +Descriptors +########### +To avoid the file being opened/closed by each ``confidence`` method, a ``Descriptor`` object is provided. +The actual ``Descriptor`` class depends on whether the file is a HDF file or not. + +HDF +--- +To register an algorithm as a HDF loader use the IHDFLoader interface as a base class for your algorithm. +In your cpp file include the ``MantidAPI/RegisterFileLoader.h`` header and use the ``DECLARE_HDF_FILELOADER`` +macro *instead* of the standard ``DECLARE_ALGORITHM`` macro. + +The interface requires that the method ``virtual int confidence(Kernel::HDFDescriptor & descriptor) const = 0;`` +be overloaded in the inheriting class. It should use the provided descriptor to check whether the loader is +able to load the wrapped file and return a confidence level as an integer. + +HDFDescriptor +^^^^^^^^^^^^^ +This provides methods to query characteristics of the current file to avoid repeated accessing of the tree. + +Non-HDF +------- +To register an algorithm as a Non-HDF loader use the ``IFileLoader`` interface as a base class for your algorithm. +In your cpp file include the ``MantidAPI/RegisterFileLoader.h`` header and use the ``DECLARE_FILELOADER`` macro +*instead* of the standard ``DECLARE_ALGORITHM`` macro. + +The interface requires that the method ``virtual int confidence(Kernel::FileDescriptor & descriptor) const = 0;`` +be overloaded in the inheriting class. It should use the provided descriptor to check whether the loader is +able to load the wrapped file and return a confidence level as an integer. + +FileDescriptor +^^^^^^^^^^^^^^ + +This provides methods to query some characteristics of the current file and also access the open stream to avoid +repeated opening/closing of the file. *Avoid* closing the stream. The code calling the ``confidence`` method ensures +that the stream is back at the start of the file before checking the next loader so simply use the stream as +necessary and leave it as it is. diff --git a/dev-docs/source/Logging.rst b/dev-docs/source/Logging.rst new file mode 100644 index 0000000000000000000000000000000000000000..da2fb4b3e1c386bd6e69736bfd1f074351663b53 --- /dev/null +++ b/dev-docs/source/Logging.rst @@ -0,0 +1,151 @@ +.. _Logging: + +======= +Logging +======= + +.. contents:: + :local: + +Overview +-------- + +The Mantid logging system is a useful tool for garnering more information about the operation of the program. +It is used to output messages from the framework to a channel, for example a file or the screen. +Including calls to the logging system in your code can greatly aid in assessing its running - successful or otherwise. +Logging is provided by the `Mantid::Kernel::Logger <http://doxygen.mantidproject.org/nightly/d2/d78/classMantid_1_1Kernel_1_1Logger.html>`_ class, which is a thin wrapper around the `Poco::Logger <https://pocoproject.org/docs/Poco.Logger.html>`_. + +Logging Levels +-------------- + +There are 7 log levels supported with increasing priority and decreasing verboseness: + ++---------------+-----------------------------------------------------------------------------------------------+ +| Level | Description on what to log | ++===============+===============================================================================================+ +| DEBUG | Anything that may be useful to understand what the code has been doing for debugging purposes.| +| | E.g. parameter values, milestones, internal variable values. | +| | Log at this level often throughout your code. | ++---------------+-----------------------------------------------------------------------------------------------+ +| INFORMATION | Useful information to relay back to the user of the framework. | ++---------------+-----------------------------------------------------------------------------------------------+ +| NOTICE | Really important information that should be displayed to the user, this should be minimal. | +| | Algorithms log at this level when starting/finishing. This is the default logging level. | ++---------------+-----------------------------------------------------------------------------------------------+ +| WARNING | Something was wrong but the framework was able to continue despite the problem. | ++---------------+-----------------------------------------------------------------------------------------------+ +| ERROR | An error has occurred but the framework is able to handle it and continue. | ++---------------+-----------------------------------------------------------------------------------------------+ +| CRITICAL | An important error has occurred, the framework can continue but it is advisable to restart. | ++---------------+-----------------------------------------------------------------------------------------------+ +| FATAL | An unrecoverable error has occurred and the application will terminate. | ++---------------+-----------------------------------------------------------------------------------------------+ + +Configuring the Log Level +------------------------- + +For the logging to work you will need to have configured the logging service. This will occur when you do either of the following: + +- Call :code:`FrameworkManager.initialise()` +- Get a reference to the :code:`ConfigService` singleton + +When the framework is initialised, it attempts to read a file called :code:`Mantid.properties` that it assumes will be available in the current working directory. +This contains among other things the logging configuration. See the :ref:`properties file <mantid:Properties File>` overview for more information. + +Here is an example: + +.. code-block:: text + + logging.loggers.root.level = debug + logging.loggers.root.channel.class = SplitterChannel + logging.loggers.root.channel.channel1 = consoleChannel + logging.loggers.root.channel.channel2 = fileChannel + logging.channels.consoleChannel.class = ConsoleChannel + logging.channels.consoleChannel.formatter = f1 + logging.channels.fileChannel.class = FileChannel + logging.channels.fileChannel.path = mantid.log + logging.channels.fileChannel.formatter.class = PatternFormatter + logging.channels.fileChannel.formatter.pattern = %Y-%m-%d %H:%M:%S,%i [%I] %p %s - %t + logging.formatters.f1.class = PatternFormatter + logging.formatters.f1.pattern = %s-[%p] %t + logging.formatters.f1.times = UTC + +This specifies that the logging comments will go to the console as well as a file called :code:`mantid.log`. +In the example here the level is set to debug, so all the messages will be output. +In production this will usually be set to information. +One could also alter the logging level programmatically using :code:`ConfigService`. +For example, in :code:`python`: + +.. code-block:: python + + cfg = ConfigService.Instance() + cfg.setConsoleLogLevel(5) # notice + +Note, that this affects the current session only; to change the level permanently, one needs to save the configuration to the file. + +Usage Example in C++ +-------------------- + +In the .h: + +.. code-block:: cpp + + #include "Logger.h" + + class A + { + private: + + /// Static reference to the logger class + static Logger& g_log; + } + +In the .cpp: + +.. code-block:: cpp + + A::func() + { + g_log.error("Log message"); + g_log.information() << "Flightpath found to be " << distance << " metres.\n"; + } + +Usage Example in Python +----------------------- + +Inside the algorithms: + +.. code-block:: python + + self.log().information('Number of scan steps is something') + +In general: + +.. code-block:: python + + from mantid.kernel import logger + logger.warning('this is a custom warning') + +Tips +---- + +- If logging data that takes significant resources to generate the message, use the :code:`is(priority)` function of the logger to check if the message would actually be output: + + .. code-block:: cpp + + if (g_log.is(Logger::PRIO_DEBUG)) + { + // generate message and output to log. + } + +- If you need to dump binary data, use the dump method of the logger. Note that all dump messages are sent at debug level: + + .. code-block:: cpp + + /// Logs the given message at debug level, followed by the data in buffer. + void dump(const std::string& msg, const void* buffer, std::size_t length); + +- Note, that logging can slow down code significantly, so avoid overusing it, especially in large and nested loops. +- In workflow algorithms consider setting an offset to the child algorithm log levels, or disable them completely, otherwise the log output can be too verbose with the low priority levels, such as debug or information. +- Note, that the *Results Log* widget in MantidPlot offers only five options to show the logs (from debug to error). +- Note, that too verbose logs when shown in the *Results Log* can slow down and even freeze the MantidPlot GUI for some time. So choose wisely what log level to show. diff --git a/dev-docs/source/MVPTutorial/AddButton.rst b/dev-docs/source/MVPTutorial/AddButton.rst new file mode 100644 index 0000000000000000000000000000000000000000..f4a07fbdce9ad2d2ab49b912447d29462e058e96 --- /dev/null +++ b/dev-docs/source/MVPTutorial/AddButton.rst @@ -0,0 +1,98 @@ +=============== +Adding a Button +=============== + +In this task a GUI is created containing a single button. + +The View +######## + +The below code creates a QWidget containing a single button. When the +button is pressed it will print a message to the terminal screen. It +should be noted that in practice this should be avoided and will be +discussed in `this section <ReceivingSignalFromView.html>`_. + +First we need to import the relevant packages, this includes PyQt. + +.. code-block:: python + + from __future__ import (absolute_import,division,print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + +We then create the View class as a QWidget. Each View will have a +parent. As a result, the View will automatically be destroyed if the +parent is destroyed (unless the View has been removed, via docking, +from the parent). + +.. code-block:: python + + class view(QtGui.QWidget): + + def __init__(self, parent=None): + super(view, self).__init__(parent) + +Next we create a layout and add a button to it + +.. code-block:: python + + grid = QtGui.QGridLayout() + self.button = QtGui.QPushButton('Hi', self) + self.button.setStyleSheet("background-color:lightgrey") + + # connect button to signal + self.button.clicked.connect(self.btn_click) + # add button to layout + grid.addWidget(self.button) + # set the layout for the view widget + self.setLayout(grid) + +The above connect statement means that when the button is pressed, the +function ``btn_click`` is called: + +.. code-block:: python + + def btn_click(self): + print("Hello world") + +The Main +######## + +To run the GUI we need a 'main' module. Assuming that the above has +all been saved in ``view.py``, the ``main.py`` will contain: + +.. code-block:: python + + from __future__ import (absolute_import,division,print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + + import view + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self,parent=None): + super(demo,self).__init__(parent) + + self.window=QtGui.QMainWindow() + my_view = view.view() + # set the view for the main window + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + app = qapp() + window = demo() + window.show() + app.exec_() diff --git a/dev-docs/source/MVPTutorial/AddComboBox.rst b/dev-docs/source/MVPTutorial/AddComboBox.rst new file mode 100644 index 0000000000000000000000000000000000000000..c7162460716359aa17f9c2dfe68f7254b97e3fc9 --- /dev/null +++ b/dev-docs/source/MVPTutorial/AddComboBox.rst @@ -0,0 +1,21 @@ +============== +Add a ComboBox +============== + +A ComboBox is useful when there is a finite list of options that the +user can choose from. If a line edit was used instead then a typo +would prevent the GUI from working correctly; a ComboBox prevents this +possibility. + +The following code should be added to the View's ``__init__`` function. + +.. code-block:: python + + self.combo = QtGui.QComboBox() + options = ["one", "two", "three"] + self.combo.addItems(options) + grid.addWidget(self.combo) + +The first line creates a ComboBox widget. The second line defines the +options that will be displayed within the ComboBox and the third line +adds the options to the ComboBox. The last line adds it to the layout. diff --git a/dev-docs/source/MVPTutorial/AddLabel.rst b/dev-docs/source/MVPTutorial/AddLabel.rst new file mode 100644 index 0000000000000000000000000000000000000000..da59ee92c3ea79138e852de097325d538324aa53 --- /dev/null +++ b/dev-docs/source/MVPTutorial/AddLabel.rst @@ -0,0 +1,19 @@ +============== +Adding a Label +============== + +In this section we will add a label to the GUI. A label is a text +display that cannot be edited by the user. + +To add a label we need to add three lines to the View. The first +creates the label widget, the second assigns the label's value (what +it will display) and the last line adds it to the layout of the view. + +.. code-block:: python + + self.label = QtGui.QLabel() + self.label.setText("Button") + grid.addWidget(self.label) + +This code should be added in the View's constructor (ie its +``__init__`` function). diff --git a/dev-docs/source/MVPTutorial/AddLineEdit.rst b/dev-docs/source/MVPTutorial/AddLineEdit.rst new file mode 100644 index 0000000000000000000000000000000000000000..b2c4cbfb978dbacb16ca1bf1b80c9b17705f9d32 --- /dev/null +++ b/dev-docs/source/MVPTutorial/AddLineEdit.rst @@ -0,0 +1,23 @@ +============== +Add a LineEdit +============== + +Sometimes it is necessary for the user to input some information. The +most versatile way of allowing this is to use a line edit, which +allows a user to enter arbitrary text. Adding the following code to +the ``__init__`` function of the View will add a line edit: + +.. code-block:: python + + self.text = QtGui.QLineEdit() + grid.addWidget(self.text) + +It is possible to have a default value within the line edit. It is +also possible to make it impossible for the user to modify the line +edit (useful for tables). + +Care should be taken before using a line edit as it can give a user +too much freedom. If you know that the input is an integer then a +`spin box <AddSpinBox.html>`_ is better. If there is a finite list of +possible options then a `combo box <AddComboBox.html>`_ would be a +better choice. diff --git a/dev-docs/source/MVPTutorial/AddSpinBox.rst b/dev-docs/source/MVPTutorial/AddSpinBox.rst new file mode 100644 index 0000000000000000000000000000000000000000..86a3abb414f4dc0d0d10f248a4c31e28368465eb --- /dev/null +++ b/dev-docs/source/MVPTutorial/AddSpinBox.rst @@ -0,0 +1,16 @@ +============== +Add a Spin Box +============== + +A spin box is a useful way to ensure that the user only selects +integer values. The user can type an integer into the spin box or +increment the value using the arrows. It is also possible to place +constraints on the spin box such as a maximum value. + +.. code-block:: python + + self.spin = QtGui.QSpinBox() + grid.addWidget(self.spin) + +To add a spin box to the GUI the above code needs to be added to the +``__init__`` function of the View. diff --git a/dev-docs/source/MVPTutorial/CalculatorExample/Calculator.py b/dev-docs/source/MVPTutorial/CalculatorExample/Calculator.py new file mode 100644 index 0000000000000000000000000000000000000000..143b51351daa0402be809c7e32a862e69f0eeaff --- /dev/null +++ b/dev-docs/source/MVPTutorial/CalculatorExample/Calculator.py @@ -0,0 +1,37 @@ +from Presenter import Presenter +from Model import Model +from View import View + +import PyQt4.QtGui as QtGui + +import sys + + +class Demo(QtGui.QMainWindow): + """ Wrapper class for setting the main window""" + def __init__(self, parent=None): + super(Demo, self).__init__(parent) + + self.window = QtGui.QMainWindow() + demo_view = View() + demo_model = Model() + # create presenter + self.presenter = Presenter(demo_view, demo_model) + # set the view for the main window + self.setCentralWidget(demo_view) + self.setWindowTitle("MVP Demo") + + +def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + +if __name__ == "__main__": + app = qapp() + window = Demo() + window.show() + app.exec_() diff --git a/dev-docs/source/MVPTutorial/CalculatorExample/Model.py b/dev-docs/source/MVPTutorial/CalculatorExample/Model.py new file mode 100644 index 0000000000000000000000000000000000000000..c9c883a022d5f334b82654cfe80e7b23fdb1a8c7 --- /dev/null +++ b/dev-docs/source/MVPTutorial/CalculatorExample/Model.py @@ -0,0 +1,10 @@ +class Model(object): + def __init__(self): + self.result = 0 + + def calc(self, value1, operation, value2): + if operation == "+": + self.result = value1 + value2 + elif operation == "-": + self.result = value1 - value2 + return self.result diff --git a/dev-docs/source/MVPTutorial/CalculatorExample/Presenter.py b/dev-docs/source/MVPTutorial/CalculatorExample/Presenter.py new file mode 100644 index 0000000000000000000000000000000000000000..d160d22e3f57b3cb2cfbdde4b1415bb551ef741f --- /dev/null +++ b/dev-docs/source/MVPTutorial/CalculatorExample/Presenter.py @@ -0,0 +1,43 @@ +class Presenter(object): + # Pass the view and model into the presenter + def __init__(self, demo_view, demo_model): + self.model = demo_model + self.view = demo_view + + # Define the initial view + # Note that, in the view, the drop-down could be replaced with a set of + # tick boxes and this line would remain unchanged - an advantage of + # decoupling the presenter and view + self.view.set_options('operations', ['+', '-']) + self.view.set_options('display', ['print', 'update', 'print and update']) + self.printToScreen = True + self.view.hide_display() + + # Connect to the view's custom signals + self.view.btnSignal.connect(self.handle_button) + self.view.displaySignal.connect(self.display_update) + + # The final two methods handle the signals + def display_update(self): + display = self.view.get_display() + if display == 'update': + self.printToScreen = False + self.view.show_display() + elif display == 'print': + self.printToScreen = True + self.view.hide_display() + else: + self.printToScreen = True + self.view.show_display() + + def handle_button(self): + # Get the values from view + value1 = self.view.get_value(0) + operation = self.view.get_operation() + value2 = self.view.get_value(2) + # The model does the hard work for us + result = self.model.calc(value1, operation, value2) + + if self.printToScreen: + print result + self.view.setResult(result) diff --git a/dev-docs/source/MVPTutorial/CalculatorExample/View.py b/dev-docs/source/MVPTutorial/CalculatorExample/View.py new file mode 100644 index 0000000000000000000000000000000000000000..1ffd2c4288c1c55b65ababc1a7fac85826c29bf5 --- /dev/null +++ b/dev-docs/source/MVPTutorial/CalculatorExample/View.py @@ -0,0 +1,91 @@ +import PyQt4.QtGui as QtGui +import PyQt4.QtCore as QtCore + + +class View(QtGui.QDialog): + # In PyQt signals are the first thing to be defined in a class: + displaySignal = QtCore.pyqtSignal() + btnSignal = QtCore.pyqtSignal() + + def __init__(self, parent=None): + # Call QDialog's constructor + super(View, self).__init__(parent) + + # Initialise the widgets for the view (this can also be done from Qt Creator + self.table = QtGui.QTableWidget() + self.table.setWindowTitle("MVP Demo") + self.table.resize(400, 250) + self.table.setRowCount(5) + self.table.setColumnCount(2) + self.table.setHorizontalHeaderLabels(QtCore.QString("name;value;").split(";")) + + # Set display values in the widgets + keys = ['value 1', 'operation', 'value 2', 'display', 'result'] + self.combo = {} + self.create_combo_table(1, 1, 'operations') + self.create_combo_table(3, 1, 'display') + for row in range(len(keys)): + self.set_names(keys[row], row) + + # Initialise layout of the widget and add child widgets to it + grid = QtGui.QGridLayout() + grid.addWidget(self.table) + + self.button = QtGui.QPushButton('Calculate', self) + self.button.setStyleSheet("background-color:lightgrey") + grid.addWidget(self.button) + + # Connect button click handler method to the button's 'clicked' signal + self.button.clicked.connect(self.btn_click) + # connect method to handle combo box selection changing to the corresponding signal + self.combo['display'].currentIndexChanged.connect(self.display_changed) + + # Set the layout for the view widget + self.setLayout(grid) + + # The next two methods handle the signals connected to in the presenter + # They emit custom signals that can be caught by a presenter + def btn_click(self): + self.btnSignal.emit() + + def display_changed(self): + self.displaySignal.emit() + + # Populate view + def create_combo_table(self, row, col, key): + self.combo[key] = QtGui.QComboBox() + options = ['test'] + self.combo[key].addItems(options) + self.table.setCellWidget(row, col, self.combo[key]) + + # The next 5 methods update the appearance of the view. + + def set_options(self, key, options): + self.combo[key].clear() + self.combo[key].addItems(options) + + def set_names(self, name, row): + text = QtGui.QTableWidgetItem(name) + text.setFlags(QtCore.Qt.ItemIsEnabled) + self.table.setItem(row, 0, text) + + # Update the view with the result of a calculation + def setResult(self, value): + self.table.setItem(4, 1, QtGui.QTableWidgetItem(str(value))) + + def hide_display(self): + self.table.setRowHidden(4, True) + + def show_display(self): + self.table.setRowHidden(4, False) + + # Finally, we have the get methods to allow the presenter to read the user's input + + def get_value(self, row): + return float(self.table.item(row, 1).text()) + + def get_operation(self): + return self.combo['operations'].currentText() + + def get_display(self): + return self.combo["display"].currentText() diff --git a/dev-docs/source/MVPTutorial/CalculatorExample/index.rst b/dev-docs/source/MVPTutorial/CalculatorExample/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..f54745ec4bd5a4df34733e09af308c1ac57096a8 --- /dev/null +++ b/dev-docs/source/MVPTutorial/CalculatorExample/index.rst @@ -0,0 +1,12 @@ +.. _MVPCalculatorGUIExample: + +========================== +MVP Calculator GUI Example +========================== + +See the following files for the calculator GUI described in :ref:`GuiDesignGuidelinesMVPIntro`. + +- :download:`Main module <Calculator.py>` +- :download:`Model.py <Model.py>` +- :download:`Presenter.py <Presenter.py>` +- :download:`View.py <View.py>` diff --git a/dev-docs/source/MVPTutorial/CompleteGUI.rst b/dev-docs/source/MVPTutorial/CompleteGUI.rst new file mode 100644 index 0000000000000000000000000000000000000000..c3e4ae7d61667851514f40fba3d81be7ff8145da --- /dev/null +++ b/dev-docs/source/MVPTutorial/CompleteGUI.rst @@ -0,0 +1,179 @@ +=========================== +Complete GUI from Exercises +=========================== + +Main module +########### + +.. code-block:: python + + from __future__ import (absolute_import,division,print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + + import model + import masterView + import masterPresenter + + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self, parent=None): + super(demo,self).__init__(parent) + + data_model = model.DataGenerator() + colour_model = model.ColourConvertor() + + self.window = QtGui.QMainWindow() + + my_view = masterView.MasterView(parent=self) + self.master_presenter = masterPresenter.MasterPresenter(my_view, data_model, colour_model) + + # set the view for the main window + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + app = qapp() + window = demo() + window.show() + app.exec_() + +which has the addition of the data and colour models being passed to +the Presenter. This makes it easier for us to replace the Model at a +later date. + +Master View +########### + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import view + import plotView + + import numpy as np + + class MasterView(QtGui.QWidget): + + def __init__(self, parent=None): + super(MasterView, self).__init__(parent) + + grid = QtGui.QVBoxLayout(self) + self.plot_view = plotView.PlotView() + self.options_view=view.view() + + grid.addWidget(self.plot_view) + grid.addWidget(self.options_view) + + self.setLayout(grid) + + def getOptionView(self): + return self.options_view + + def getPlotView(self): + return self.plot_view + +Master Presenter +################ + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import model + import presenter + import plotPresenter + + class MasterPresenter(object): + + def __init__(self, view, data_model, colour_model): + self.view = view + + self.data_model = data_model + self.colour_model = colour_model + + colours = self.colour_model.getColourSelection() + + self.presenter = presenter.Presenter(self.view.getOptionView(), colours) + self.plot_presenter = plotPresenter.PlotPresenter(self.view.getPlotView()) + # connect statements + self.view.getOptionView().plotSignal.connect(self.updatePlot) + + # handle signals + def updatePlot(self): + # only care about the colour if the button is pressed + colour, freq,phi = self.presenter.getPlotInfo() + grid_lines = self.presenter.getGridLines() + + self.data_model.genData(freq,phi ) + x_data = self.data_model.getXData() + y_data = self.data_model.getYData() + + self.plot_presenter.plot(x_data, y_data, grid_lines, colour) + +The signal from the View is caught here and the models are used to create the correct plot. + +Plot Presenter +############## + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + class PlotPresenter(object): + + def __init__(self, view): + self.view = view + + def plot(self, x_data, y_data, grid_lines, colour_code): + self.view.addData(x_data, y_data, grid_lines, colour_code, "x") + +PlotView +######## + +Unchanged from `Matplotlib and MVP <Matplotlib.html>`_. + +Presenter +######### + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + + class Presenter(object): + + def __init__(self, view, colours): + self.view = view + self.view.setColours(colours) + + def getPlotInfo(self): + return str(self.view.getColour()), self.view.getFreq(), self.view.getPhase() + + def getGridLines(self): + return self.view.getGridLines() + +View +#### + +Unchanged from `Model Exercise Solution <ModelExerciseSolution.html>`_. + +Model +##### + +Unchanged from `Model Exercise Solution <ModelExerciseSolution.html>`_. diff --git a/dev-docs/source/MVPTutorial/ExtractInfoFromView.rst b/dev-docs/source/MVPTutorial/ExtractInfoFromView.rst new file mode 100644 index 0000000000000000000000000000000000000000..eed9386f820c81fdfccccef6942af7cc7d52e47c --- /dev/null +++ b/dev-docs/source/MVPTutorial/ExtractInfoFromView.rst @@ -0,0 +1,67 @@ +==================================== +Extracting Information from the View +==================================== + +The Presenter will need a way to obtain information from the +View. This can be done by **get** methods, as with normal +classes. Here is a simple example of how a **get** method for the view can +be used. + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + + class view(QtGui.QWidget): + + doSomethingSignal = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super(view, self).__init__(parent) + + self.button = QtGui.QPushButton('Hi', self) + self.button.setStyleSheet("background-color:lightgrey") + # connect button to signal + self.button.clicked.connect(self.btn_click) + + self.label = QtGui.QLabel() + self.label.setText("Button") + + # add widgets to layout + self.sub_layout = QtGui.QHBoxLayout() + self.sub_layout.addWidget(self.label) + self.sub_layout.addWidget(self.button) + + grid = QtGui.QVBoxLayout(self) + grid.addLayout(self.sub_layout) + + self.value = QtGui.QLineEdit() + grid.addWidget(self.value) + + + # set the layout for the view widget + self.setLayout(grid) + + #send signals + def btn_click(self): + print ("hellow from view") + self.doSomethingSignal.emit() + + def getValue(self): + return float(self.value.text()) + +The last function ``getValue`` returns the value of the line +edit. Since ``text()`` returns a string the output is type cast into a +float. + +The Presenter has the following code added to the ``handleButton`` method: + +.. code-block:: python + + value = self.view.getValue() + print("Value is "+str(value)) + +which gets the value from the View and then prints it to the screen. diff --git a/dev-docs/source/MVPTutorial/Introduction.rst b/dev-docs/source/MVPTutorial/Introduction.rst new file mode 100644 index 0000000000000000000000000000000000000000..1cca72c91708d41770e909bbe200aa776de6efb8 --- /dev/null +++ b/dev-docs/source/MVPTutorial/Introduction.rst @@ -0,0 +1,26 @@ +================ +MVP Introduction +================ + +The MVP (model, view, presenter) pattern is a set of guidelines for +creating easy to maintain GUIs (graphical user interfaces). In +general: + +- The View contains the 'look' of the GUI +- The Model does the 'hard sums' for the GUI (e.g. runs algorithms) +- The Presenter acts as a go between for the View and Model + +It is important to note that the View should be simple (no logic) and +is usually not tested. The Model can be tested in a similar way to +other Python tests. The Model and View never communicate with each +other directly. The Presenter will extract relevant information from +the View and pass it to the Model. The Presenter may then pass the +result of the Model to the View. The Presenter will contain the GUI +logic and is tested using **mocking**. + +These are guidelines and do not form a set of rules. It is sometimes +open to interpretation if some files are classed as a View or a Model +(this will be discussed in detail later). + +A more thorough explanation of MVP can be found at +:ref:`GuiDesignGuidelinesMVPIntro`. diff --git a/dev-docs/source/MVPTutorial/Layouts.rst b/dev-docs/source/MVPTutorial/Layouts.rst new file mode 100644 index 0000000000000000000000000000000000000000..43a1bba04cb2032638c4c7493cfe7e90c15d987e --- /dev/null +++ b/dev-docs/source/MVPTutorial/Layouts.rst @@ -0,0 +1,39 @@ +======= +Layouts +======= + +In the previous task a label was added to the View. However, the label +appeared below the button. It would be sensible to place the label +next to the button. This is possible by using **layouts**. + +So far we have used the vertical layout (``QtGui.QVBoxLayout``) and we +will now use the horizontal layout. It is possible to add sub-layouts +to a layout, which we will do here by adding a horizontal layout to +the vertical one. The order in which widgets are added to the layout +will determine their location. + +In the View we will replace the ``__init__`` with the following: + +.. code-block:: python + + def __init__(self, parent=None): + super(view, self).__init__(parent) + + self.button = QtGui.QPushButton('Hi', self) + self.button.setStyleSheet("background-color:lightgrey") + + # connect button to signal + self.button.clicked.connect(self.btn_click) + self.label = QtGui.QLabel() + self.label.setText("Button") + + # add widgets to layout + self.sub_layout = QtGui.QHBoxLayout() + self.sub_layout.addWidget(self.label) + self.sub_layout.addWidget(self.button) + + grid = QtGui.QVBoxLayout(self) + grid.addLayout(self.sub_layout) + + # set the layout for the view widget + self.setLayout(grid) diff --git a/dev-docs/source/MVPTutorial/Matplotlib.rst b/dev-docs/source/MVPTutorial/Matplotlib.rst new file mode 100644 index 0000000000000000000000000000000000000000..22972a4f8a83c403fd2c561d9e9517c48ae32514 --- /dev/null +++ b/dev-docs/source/MVPTutorial/Matplotlib.rst @@ -0,0 +1,73 @@ +================== +Matplotlib and MVP +================== + +The next step towards the goal of creating a GUI that allows users to +manipulate a sine wave plot, is to produce the plot itself. + +For the purposes of this tutorial it is assumed that the user is +familiar with Matplotlib, if not see `Matplotlib documentation +<https://matplotlib.org/users/pyplot_tutorial.html>`_. + +The Matplotlib functions could be considered to be a Model or a View +and there is no correct answer to which. It could be a Model as it +does something with the data, however it could be considered to be a +view as (in this case) it is used purely as a visual +representation. This ambiguity is why MVP is only a pattern and not a +set of rules. On this occasion it has been decided that it should be a +View. + +This view will exist alongside with the view from the exercise. So we +will need to call it something different, such as PlotView. + +The View has the following imports: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + import matplotlib.pyplot as plt + + from matplotlib.backends.backend_qt4agg import FigureCanvasQTAgg as FigureCanvas + +The fourth line imports Matplotlib and the last line allows it to +interface with the GUI. + +The main class is shown below and contains methods for adding data to +the plot and creating an empty plot (no data). + +.. code-block:: python + + class PlotView(QtGui.QWidget): + def __init__(self, parent=None): + super(PlotView, self).__init__(parent) + + self.figure = plt.figure() + grid = QtGui.QVBoxLayout(self) + self.draw() + self.canvas = self.getWidget() + grid.addWidget(self.canvas) + self.setLayout(grid) + + def draw(self): + ax = self.figure.add_subplot(111) + ax.clear() + ax.set_xlim([0.0, 10.5]) + ax.set_ylim([-1.05, 1.05]) + ax.set_xlabel("time ($s$)") + ax.set_ylabel("$f(t)$") + return ax + + def getWidget(self): + return FigureCanvas(self.figure) + + def addData(self, xvalues, yvalues, colour, marker): + ax = self.draw() + ax.plot(xvalues, yvalues, color=colour, marker=marker, linestyle="--") + self.canvas.draw() + +The ``draw`` method creates the plot area without any data. The widget +is obtained from the ``getWidget`` function. The final method adds +data to the plot area, the ``self.canvas.draw()`` updates the plot +area so it will contain the data. diff --git a/dev-docs/source/MVPTutorial/Mocking.rst b/dev-docs/source/MVPTutorial/Mocking.rst new file mode 100644 index 0000000000000000000000000000000000000000..631779fc777d6831a48419696f10ddbfc372666e --- /dev/null +++ b/dev-docs/source/MVPTutorial/Mocking.rst @@ -0,0 +1,76 @@ +===================== +Mocking the Presenter +===================== + +The view should be so simple that it does not require +testing. However, the presenter contains logic and should therefore be +tested. When testing the presenter we do not want to create the actual +GUI, instead we just want to ensure that the correct calls are made, +this is done via mocking see `unittest docs +<https://docs.python.org/3/library/unittest.mock-examples.html>`_ for +a detailed discussion. Here we will have a brief discussion of the +main points. + +First are the import statements + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import sys + import presenter + import view + + import unittest + if sys.version_info.major == 3: + from unittest import mock + else: + import mock + +A different import is used for ``mock``, depending on whether we're +using Python 2 or 3. + +The test class is then initialised: + +.. code-block:: python + + class presenterTest(unittest.TestCase): + def setUp(self): + self.view = mock.create_autospec(view.view) + + # mock view + self.view.doSomethingSignal = mock.Mock() + self.view.btn_click = mock.Mock() + self.view.getValue = mock.Mock(return_value=3.14) + + self.presenter = presenter.Presenter(self.view) + +``create_autospec`` mocks the class contained within the brackets. We +then need to explicitly mock the methods using ``mock.Mock``. In +addtion, when a return value is needed, this is provided in the call +to ``mock.Mock``. + +A test is shown below: + +.. code-block:: python + + def test_doSomething(self): + self.presenter.handleButton() + assert(self.view.getValue.call_count == 1) + +We call the ``handleButton`` function and then use ``call_count`` to +ensure that the method from the View is called the correct number of +times. This is a more robust method for checking how many times a +function is called. + +There is a ``assert_called_once`` function however this should be +avoided as it can easily lead to errors. This is because it is +expected that the function ``assert_called_twice`` exists but it does +not, however when you run the test it will always pass. + +The last bit of code is to execute the tests: + +.. code-block:: python + + if __name__ == "__main__": + unittest.main() diff --git a/dev-docs/source/MVPTutorial/MockingExercise.rst b/dev-docs/source/MVPTutorial/MockingExercise.rst new file mode 100644 index 0000000000000000000000000000000000000000..1770a54c068c818bde111f9bcd4c8da033d74c87 --- /dev/null +++ b/dev-docs/source/MVPTutorial/MockingExercise.rst @@ -0,0 +1,11 @@ +================ +Mocking Exercise +================ + +In this exercise you will mock the Presenter from the `Presenter +Exercise <PresenterExercise.html>`_. All of the methods should be +mocked and the return values should be present only when necessary (on +this occasion the values do not matter). The ``updatePlot`` function +should be tested to make sure that it calls the correct methods. + +See `here <MockingExerciseSolution.html>`_ for the solution. diff --git a/dev-docs/source/MVPTutorial/MockingExerciseSolution.rst b/dev-docs/source/MVPTutorial/MockingExerciseSolution.rst new file mode 100644 index 0000000000000000000000000000000000000000..14f8be65e83fc8d13e15fc7b36a982a4ef1222e9 --- /dev/null +++ b/dev-docs/source/MVPTutorial/MockingExerciseSolution.rst @@ -0,0 +1,44 @@ +========================= +Mocking Exercise Solution +========================= + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import sys + import presenter + import view + + import unittest + if sys.version_info.major == 3: + from unittest import mock + else: + import mock + + class presenterTest(unittest.TestCase): + def setUp(self): + self.view = mock.create_autospec(view.view) + + # mock view + self.view.plotSignal = mock.Mock() + self.view.getColour = mock.Mock(return_value="black") + self.view.getGridLines =mock.Mock(return_value=True) + self.view.getFreq =mock.Mock(return_value=3.14) + self.view.getPhase =mock.Mock(return_value=0.56) + self.view.buttonPressed = mock.Mock() + self.view.setTableRow = mock.Mock() + self.view.addWidgetToTable = mock.Mock() + self.view.addITemToTable = mock.Mock() + + self.presenter = presenter.Presenter(self.view) + + def test_updatePlot(self): + self.presenter.updatePlot() + assert(self.view.getColour.call_count == 1) + assert(self.view.getGridLines.call_count == 1) + assert(self.view.getFreq.call_count == 1) + assert(self.view.getPhase.call_count == 1) + + if __name__ == "__main__": + unittest.main() diff --git a/dev-docs/source/MVPTutorial/Model.rst b/dev-docs/source/MVPTutorial/Model.rst new file mode 100644 index 0000000000000000000000000000000000000000..ea0df87b65c0d2471587feb8503150b35b961cbf --- /dev/null +++ b/dev-docs/source/MVPTutorial/Model.rst @@ -0,0 +1,36 @@ +============== +A Simple Model +============== + +Models are used to do the 'hard sums' within the GUI. It is possible +to have multiple models within a single presenter, as we will see with +this example. For this example we have kept the models fairly simple, +in reality they will be much more complex. + +The first model generates the data for the user: + +.. code-block:: python + + import numpy as np + + class DataGenerator(object): + + def __init__(self): + self.x_data = np.linspace(0.0, 10.0, 100) + self.y_data = [] + + def genData(self, freq, phi): + self.y_data = np.sin(freq * self.x_data + phi) + + def getXData(self): + return self.x_data + + def getYData(self): + return self.y_data + +The model methods can be split into three types initialisation, a +calculate button and get methods. + +In this case we have a distinct second method. Usually this will be +placed into its own file, however for simplicity we will contain it +within the same file as the above code. diff --git a/dev-docs/source/MVPTutorial/ModelExercise.rst b/dev-docs/source/MVPTutorial/ModelExercise.rst new file mode 100644 index 0000000000000000000000000000000000000000..c3559b53d9ea1a8c77e8b0452b3bfbb2d25f18b3 --- /dev/null +++ b/dev-docs/source/MVPTutorial/ModelExercise.rst @@ -0,0 +1,18 @@ +==================== +Model (MVP) Exercise +==================== + +In the previous section we did not need to update the View. However, +the Model contains a dictionary which contains the allowed colour +options. The GUI should show the same allowed values as the the +Model. To achieve this you will need to add: + +1. A method to the Model for getting the allowed colours + +2. A method in the View to update the ComboBox values to match some +input values + +3. In the initialisation of the Presenter get the allowed colours from +the Model and pass them to the View + +See `here <ModelExerciseSolution.html>`_ for the solution. diff --git a/dev-docs/source/MVPTutorial/ModelExerciseSolution.rst b/dev-docs/source/MVPTutorial/ModelExerciseSolution.rst new file mode 100644 index 0000000000000000000000000000000000000000..835bec9e2d275f6f43ac8f0710cab937f7c0dc8c --- /dev/null +++ b/dev-docs/source/MVPTutorial/ModelExerciseSolution.rst @@ -0,0 +1,33 @@ +======================= +Model Exercise Solution +======================= + +The Model should now contain the following method in the +``ColourConvertor`` class: + +.. code-block:: python + + def getColourSelection(self): + return self.colour_table.keys() + +The View should contain the following method: + +.. code-block:: python + + def setColours(self,options): + self.colours.clear() + self.colours.addItems(options) + +The Presenter initialisation should now be: + +.. code-block:: python + + def __init__(self, view, data_model, colour_model): + self.view = view + self.data_model = data_model + self.colour_model = colour_model + + colours = self.colour_model.getColourSelection() + self.view.setColours(colours) + # connect statements + self.view.plotSignal.connect(self.updatePlot) diff --git a/dev-docs/source/MVPTutorial/MultipleViews.rst b/dev-docs/source/MVPTutorial/MultipleViews.rst new file mode 100644 index 0000000000000000000000000000000000000000..115cf9916ace43097508371df0095f1808c9dee2 --- /dev/null +++ b/dev-docs/source/MVPTutorial/MultipleViews.rst @@ -0,0 +1,86 @@ +============== +Multiple Views +============== + + +It is possible to have an MVP pattern within other MVP patterns. If +each complete MVP pattern is considered to be a widget then having an +MVP pattern embedded into another MVP is effectively just adding +another widget. This can be very useful for creating small versatile +widgets that may be used in multiple GUIs. + +We will combine the View from the exercise and the PlotView from the +previous section into a single view. To achieve this we will create a +'master' view: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import numpy as np + import plotView + import view + + class MasterView(QtGui.QWidget): + + def __init__(self, parent=None): + super(MasterView, self).__init__(parent) + + grid = QtGui.QVBoxLayout(self) + self.plot_view = plotView.PlotView(parent=self) + x_data = np.linspace(0.0, 10.0, 100) + y_data = np.sin(x_data) + self.plot_view.addData(x_data, y_data, "b", "x") + + grid.addWidget(self.plot_view) + + self.options_view = view.view(parent=self) + + grid.addWidget(self.options_view) + self.setLayout(grid) + +The important thing to note here is that when the PlotView and View +are created the parent is set to be the masterView. + +The main only needs to import the masterView: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + + import masterView + + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self, parent=None): + super(demo, self).__init__(parent) + + self.window = QtGui.QMainWindow() + my_view = masterView.MasterView() + # set the view for the main window + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + app = qapp() + window = demo() + window.show() + app.exec_() + diff --git a/dev-docs/source/MVPTutorial/PresenterExercise.rst b/dev-docs/source/MVPTutorial/PresenterExercise.rst new file mode 100644 index 0000000000000000000000000000000000000000..de947f2237034a7af584a484d8a31eda8905d417 --- /dev/null +++ b/dev-docs/source/MVPTutorial/PresenterExercise.rst @@ -0,0 +1,18 @@ +================== +Presenter Exercise +================== + +In this exercise you will create a Presenter for View.py. + +Using the View from the previous exercise (the one which contains a +table) create a Presenter to handle the button press. When the button +is pressed the following should be output: + +- The line colour +- If the grid lines are on or off +- The frequency +- The phase + +The ``main`` module will also need updating to handle these changes. + +See `here <PresenterExerciseSolution.html>`_ for the solution. diff --git a/dev-docs/source/MVPTutorial/PresenterExerciseSolution.rst b/dev-docs/source/MVPTutorial/PresenterExerciseSolution.rst new file mode 100644 index 0000000000000000000000000000000000000000..a0cb6caedd2c6f08524f767eb5aa2c322c2aef09 --- /dev/null +++ b/dev-docs/source/MVPTutorial/PresenterExerciseSolution.rst @@ -0,0 +1,149 @@ +=========================== +Presenter Exercise Solution +=========================== + +View +#### + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + + class view(QtGui.QWidget): + + plotSignal = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super(view, self).__init__(parent) + + grid = QtGui.QVBoxLayout(self) + + self.table = QtGui.QTableWidget(self) + self.table.setRowCount(4) + self.table.setColumnCount(2) + + grid.addWidget(self.table) + + self.colours = QtGui.QComboBox() + options=["Blue", "Green", "Red"] + self.colours.addItems(options) + + self.grid_lines= QtGui.QTableWidgetItem() + self.grid_lines.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) + self.grid_lines.setCheckState(QtCore.Qt.Unchecked) + self.addItemToTable("Show grid lines", self.grid_lines, 1) + + self.freq = QtGui.QTableWidgetItem("1.0") + self.phi = QtGui.QTableWidgetItem("0.0") + + self.addWidgetToTable("Colour", self.colours, 0) + self.addItemToTable("Frequency", self.freq, 2) + self.addItemToTable("Phase", self.phi, 3) + + self.plot = QtGui.QPushButton('Add', self) + self.plot.setStyleSheet("background-color:lightgrey") + + grid.addWidget(self.plot) + + self.setLayout(grid) + + self.plot.clicked.connect(self.buttonPressed) + + def getColour(self): + return self.colours.currentText() + + def getGridLines(self): + return self.grid_lines.checkState() == QtCore.Qt.Checked + + def getFreq(self): + return float(self.freq.text()) + + def getPhase(self): + return float(self.phi.text()) + + def buttonPressed(self): + self.plotSignal.emit() + + def setTableRow(self, name, row): + text = QtGui.QTableWidgetItem(name) + text.setFlags(QtCore.Qt.ItemIsEnabled) + col = 0 + self.table.setItem(row, col, text) + + def addWidgetToTable(self, name, widget, row): + self.setTableRow(name, row) + col = 1 + self.table.setCellWidget(row, col, widget) + + def addItemToTable(self, name, widget, row): + self.setTableRow(name, row) + col = 1 + self.table.setItem(row, col, widget) + +Presenter +######### + +.. code-block:: python + + from __future__ import (absolute_import ,division, print_function) + + class Presenter(object): + + # pass the view and model into the presenter + def __init__(self, view): + self.view = view + + self.view.plotSignal.connect(self.updatePlot) + + # handle signals + def updatePlot(self): + print("The table settings are:") + print(" colour : " + str(self.view.getColour())) + print(" Grid lines : " + str(self.view.getGridLines())) + print(" Frequency : " + str(self.view.getFreq())) + print(" Phase : " + str(self.view.getPhase())) + +Main module +########### + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + + import view + import presenter + + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self, parent=None): + super(demo,self).__init__(parent) + + self.window = QtGui.QMainWindow() + my_view = view.view() + self.presenter = presenter.Presenter(my_view) + # set the view for the main window + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + app = qapp() + window = demo() + window.show() + app.exec_() diff --git a/dev-docs/source/MVPTutorial/ReceivingSignalFromView.rst b/dev-docs/source/MVPTutorial/ReceivingSignalFromView.rst new file mode 100644 index 0000000000000000000000000000000000000000..5a6beb71c3f33e6b276219c6ac27c7f922488fa6 --- /dev/null +++ b/dev-docs/source/MVPTutorial/ReceivingSignalFromView.rst @@ -0,0 +1,123 @@ +================================ +Receiving a signal from the view +================================ + +In the `Add Button <AddButton.html>`_ section we had the response to a button press +within the View. In practice this is not a good implementation. If the +response was more complicated then it would be difficult to maintain +the View as it would become extremely long. Furthermore creating the +look of the GUI is fairly simple and any logic/responses should be +contained within the Presenter. + +In this section we will make a simple Presenter for when a button is +pressed. First we will start with the View: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + + class view(QtGui.QWidget): + + doSomethingSignal = QtCore.pyqtSignal() + + def __init__(self, parent=None): + super(view, self).__init__(parent) + + self.button = QtGui.QPushButton('Hi', self) + self.button.setStyleSheet("background-color:lightgrey") + # connect button to signal + self.button.clicked.connect(self.btn_click) + + self.label = QtGui.QLabel() + self.label.setText("Button") + + # add widgets to layout + self.sub_layout = QtGui.QHBoxLayout() + self.sub_layout.addWidget(self.label) + self.sub_layout.addWidget(self.button) + + grid = QtGui.QVBoxLayout(self) + grid.addLayout(self.sub_layout) + # set the layout for the view widget + self.setLayout(grid) + + #send signals + def btn_click(self): + print ("hellow from view") + self.doSomethingSignal.emit() + +The above code has two new additions. The first is the creation of a +custom signal on line eight. It is also possible to pass objects with +the signals. The second addition is that ``btn_click`` now emits the +custom signal and will be caught by the Presenter. + +The Presenter is initialised with the View and must be a member of the +Presenter class. It is therefore possible to change the View by +passing a different one to the presenter. For example you may want to +have the widgets in a grid or in a table. The Presenter connects the +custom signal from the View to its own function (``handleButton``). + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + class Presenter(object): + + # pass the view and model into the presenter + def __init__(self, view): + self.view = view + + self.view.doSomethingSignal.connect(self.handleButton) + + # handle signals + def handleButton(self): + print("hello world, from the presenter") + +The main is now: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + import view + import presenter + + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self, parent=None): + super(demo, self).__init__(parent) + + self.window = QtGui.QMainWindow() + my_view = view.view(self) + self.my_presenter = presenter.Presenter(my_view) + # set the view for the main window + + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + + app = qapp() + window = demo() + window.show() + app.exec_() + +The View and Presenter are both created, but only the Presenter has to +be a member of the demo class. The View is created to be passed to the +Presenter and the View could easily be replaced. diff --git a/dev-docs/source/MVPTutorial/Tables.rst b/dev-docs/source/MVPTutorial/Tables.rst new file mode 100644 index 0000000000000000000000000000000000000000..d496434b975365fe09dfdc5597a6283ca2284f8a --- /dev/null +++ b/dev-docs/source/MVPTutorial/Tables.rst @@ -0,0 +1,49 @@ +====== +Tables +====== + +Tables are useful way to display a set of related options to a +user. To add a table widget to a GUI the following lines need to be +added to the ``__init__`` function of the View: + +.. code-block:: python + + self.table = QtGui.QTableWidget(self) + self.table.setRowCount(2) + self.table.setColumnCount(2) + grid.addWidget(self.table) + +The first line creates the widget. The second and third lines +determine the size of the table. The fourth line adds it to the +layout. + +To add (non-editable) labels to the table the following code is needed: + +.. code-block:: python + + text = QtGui.QTableWidgetItem(("test")) + text.setFlags(QtCore.Qt.ItemIsEnabled) + row = 0 + col = 0 + self.table.setItem(row, col, text) + + row = 1 + text2 = QtGui.QTableWidgetItem(("another test")) + text2.setFlags(QtCore.Qt.ItemIsEnabled) + self.table.setItem(row, col, text2) + + row = 0 + col = 1 + self.table.setCellWidget(row, col, self.combo) + row = 1 + self.table.setCellWidget(row, col, self.spin) + +The first line creates a widget with the label ``test`` and the second +flag ensures that a user cannot edit the value. The label is added to +the table with the ``setItem`` function. + +A useful feature of tables is that they can contain a widget within +one of the cells. The last five lines of the above code adds a +ComboBox and spin box to the table. It is important to note that the +widgets will now only appear within the table. + diff --git a/dev-docs/source/MVPTutorial/ViewExercise1.rst b/dev-docs/source/MVPTutorial/ViewExercise1.rst new file mode 100644 index 0000000000000000000000000000000000000000..d2311e122f03b45fea871d6b5d3eeab735c6de31 --- /dev/null +++ b/dev-docs/source/MVPTutorial/ViewExercise1.rst @@ -0,0 +1,23 @@ +=============== +View Exercise 1 +=============== + +A GUI should help a user to easily manipulate the behaviour of the +code (by changing variables etc.). For example consider creating a +plot of a sine wave. In this exercise you will create a view which +contains the options for manipulating the plot. + +The GUI should contain a single table and a button for updating the +plot. The table should include options for: + +- Setting the line colour (red, blue, green) +- Setting the grid lines +- Entering a frequency +- Entering a phase shift + +The previous sections are not an exhaustive list of possible widgets. + +The pages `Matplotlib and MVP <Matplotlib.html>`_ and `MultipleView +<MultipleViews.html>`_ will be useful for the exercise. + +The solution can be found `here <ViewExercise1Solution.html>`_. diff --git a/dev-docs/source/MVPTutorial/ViewExercise1Solution.rst b/dev-docs/source/MVPTutorial/ViewExercise1Solution.rst new file mode 100644 index 0000000000000000000000000000000000000000..cc17fdfcdf3fe37e224e206f2951e23ae66a822a --- /dev/null +++ b/dev-docs/source/MVPTutorial/ViewExercise1Solution.rst @@ -0,0 +1,112 @@ +======================== +View Exercise 1 Solution +======================== + +main.py +####### + +.. code-block:: python + + from __future__ import (absolute_import,division,print_function) + + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + import sys + + import view + + """ + A wrapper class for setting the main window + """ + class demo(QtGui.QMainWindow): + def __init__(self,parent=None): + super(demo,self).__init__(parent) + + self.window = QtGui.QMainWindow() + my_view = view.view() + + # set the view for the main window + self.setCentralWidget(my_view) + self.setWindowTitle("view tutorial") + + def qapp(): + if QtGui.QApplication.instance(): + _app = QtGui.QApplication.instance() + else: + _app = QtGui.QApplication(sys.argv) + return _app + + app = qapp() + window = demo() + window.show() + app.exec_() + +view.py +####### + +.. code-block:: python + + from __future__ import (absolute_import,division,print_function) + import PyQt4.QtGui as QtGui + import PyQt4.QtCore as QtCore + + + class view(QtGui.QWidget): + + def __init__(self, parent=None): + super(view, self).__init__(parent) + + grid = QtGui.QVBoxLayout(self) + + self.table = QtGui.QTableWidget(self) + self.table.setRowCount(4) + self.table.setColumnCount(2) + grid.addWidget(self.table) + + self.colours = QtGui.QComboBox() + options = ["Blue", "Green", "Red"] + self.colours.addItems(options) + + self.grid_lines = QtGui.QTableWidgetItem() + self.grid_lines.setFlags(QtCore.Qt.ItemIsUserCheckable | QtCore.Qt.ItemIsEnabled) + self.grid_lines.setCheckState(QtCore.Qt.Unchecked) + self.addItemToTable("Show grid lines", self.grid_lines, 1) + + self.freq = QtGui.QTableWidgetItem("1.0") + self.phi = QtGui.QTableWidgetItem("0.0") + + self.addWidgetToTable("Colour", self.colours, 0) + self.addItemToTable("Frequency", self.freq, 2) + self.addItemToTable("Phase", self.phi, 3) + + self.plot = QtGui.QPushButton('Add', self) + self.plot.setStyleSheet("background-color:lightgrey") + + grid.addWidget(self.plot) + + self.setLayout(grid) + + def setTableRow(self, name, row): + text = QtGui.QTableWidgetItem(name) + text.setFlags(QtCore.Qt.ItemIsEnabled) + col = 0 + self.table.setItem(row, col, text) + + def addWidgetToTable(self, name, widget, row): + self.setTableRow(name,row) + col = 1 + self.table.setCellWidget(row, col, widget) + + def addItemToTable(self, name, widget, row): + self.setTableRow(name, row) + col = 1 + self.table.setItem(row, col, widget) + +In the above code the following functions have been added to prevent +repetition of code: + +- ``setTableRow`` sets the label for the table row +- ``addWidgetToTable`` adds a widget to the table +- ``addItemToTable`` adds an item to the table (needed because the + frequency and phase are items and not widgets) diff --git a/dev-docs/source/MVPTutorial/index.rst b/dev-docs/source/MVPTutorial/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..a9fcb3795dad870ab39fa9168dad62583bd89919 --- /dev/null +++ b/dev-docs/source/MVPTutorial/index.rst @@ -0,0 +1,39 @@ +============ +MVP Tutorial +============ + +The following tutorial introduces how to create a Graphical User +Interface (GUI) using PyQt. Some knowledge of Python is assumed. + +The concepts carry over into Qt in C++. + +Duration: 6 hours as a hands-on course with exercises. + +.. toctree:: + :maxdepth: 1 + + Introduction + AddButton + AddLabel + Layouts + AddLineEdit + AddComboBox + AddSpinBox + Tables + ViewExercise1 + Matplotlib + MultipleViews + ViewExercise1Solution + ReceivingSignalFromView + ExtractInfoFromView + PresenterExercise + PresenterExerciseSolution + Mocking + MockingExercise + MockingExerciseSolution + Model + ModelExercise + ModelExerciseSolution + CompleteGUI + CalculatorExample/index + diff --git a/dev-docs/source/MultiThreadingInAlgorithms.rst b/dev-docs/source/MultiThreadingInAlgorithms.rst new file mode 100644 index 0000000000000000000000000000000000000000..61abaed070a1f3a182c1d3577f6c3ec782f6fcc0 --- /dev/null +++ b/dev-docs/source/MultiThreadingInAlgorithms.rst @@ -0,0 +1,65 @@ +============================ +Multithreading in Algorithms +============================ + +Mantid uses `OpenMP <http://openmp.org/wp/about-openmp/>`__ to improve +performance within algorithms by parallelizing ``for`` loops. A tutorial +devoted to the technology can be found `here <https://computing.llnl.gov/tutorials/openMP/>`__. + +Access to the OpenMP API is via a set of macros defined in +`MultiThreading.h <https://github.com/mantidproject/mantid/blob/master/Framework/Kernel/inc/MantidKernel/MultiThreaded.h>`__. +This accomplishes seamless fall-back to single-threaded behaviour for +compilers that don't have OpenMP available, as well as providing +protection against multithreading when non-thread-safe workspaces are in use. + +The canonical way to use OpenMP in an algorithm loop (typically +one over the spectra in a workspace) is as follows: + +.. code:: cpp + + PARALLEL_FOR_IF(Kernel::threadSafe(*inputWS, *outputWS)) + for (int i = 0; i < numSpec; ++i) + { + PARALLEL_START_INTERUPT_REGION + + // .... algorithm code .... + + PARALLEL_END_INTERUPT_REGION + } + PARALLEL_CHECK_INTERUPT_REGION + + +The main work is in the first statement, which contains the +instruction invoking OpenMP, but only if the workspaces given are +thread-safe. Analogous macros are available for zero, 2 or 3 workspaces. +Any workspace that is accessed within the loop should be included. There +is then also a set of slightly verbose interrupt instructions, which +prevent exceptions escaping from a parallel region (which would +otherwise cause program termination) - this includes dealing with +algorithm cancellation. + +Ensuring thread-safety +---------------------- + +The first rule is this: **Don't write to shared variables.** Or, if you +do, protect the write with PARALLEL\_CRITICAL or PARALLEL\_ATOMIC calls. +Note that a write to a workspace data spectrum selected by the loop +index is not typically a shared write (though see below). + +One gotcha comes from the use of copy-on-write pointers to store the +workspace data. Here's an example: + +.. code:: cpp + + // Get references to the x data + const auto& xIn = inputWS->x(i); + auto& xOut = outputWS->mutableX(i); + +This can cause problems in the case where the input and output +workspaces are the same. Although the call to ``outputWS->x()`` to get a +reference to the output data may look innocuous, in the case where +different spectra are pointing to the same underlying data array this +call will cause the array to be copied, which will invalidate the +reference obtained to the input data in the previous line. The solution +is to make sure the non-const calls come before the const ones (in this +case by reversing the two lines). diff --git a/dev-docs/source/PatchReleaseChecklist.rst b/dev-docs/source/PatchReleaseChecklist.rst new file mode 100644 index 0000000000000000000000000000000000000000..29c4231ec09594a08063de455c7ad7ae4e592ac6 --- /dev/null +++ b/dev-docs/source/PatchReleaseChecklist.rst @@ -0,0 +1,151 @@ +.. _PatchReleaseChecklist: + +======================= +Patch Release Checklist +======================= + +.. contents:: + :local: + +These are the steps involved in performing a Mantid patch release. To +perform a full release look see :ref:`ReleaseChecklist`. + +Request +####### + +* Anyone may request a patch release, but that request must be intially + approved by Project manager (Nick) or one of the team leaders (Pete + or Mattieu). + +Authorisation +############# + +* The Project Manager and Team leaders must meet to authorise the patch + release. +* During the meeting other high value, low impact changes may be + considered for inclusion for the release. Any that are to be included + must be added to the patch release notes. +* The Project Manager will create a new milestone in github, and all + tickets to be included must be moved to that milestone. +* A developer will be nominated to be the main reviewer and compiler of + the patch. + +Development +########### + +The patch release will be prepared based off the branch used to +construct to most recent major point release, e.g. ``release-v3.9`` +would be used for any ``3.9.x`` patches. Changes for the patch should be made using the standard GitHub +workflow for merging code with ``master``. The issue and pull request should then have the ``PatchCandidate`` label applied to them. These +commits will then be cherry picked from ``master`` on to the release branch. + +Release Branch +############## + +The release branch will currently have its version fixed to exact +version of the last major/patch release. It is not a requirement but +advised to unfix the patch number while the patch is being compiled. +This prevents the nightly builds from generating a collection of packages that have +exactly the same version. The patch number can be unfixed by commenting the line in +https://www.github.com/mantidproject/mantid/blob/release-vX.Y/buildconfig/CMake/VersionNumber.cmake#L9, where +``X.Y`` should be replace with the appropriate numbers. + +Release Notes +------------- + +Once the patch version has been unfixed the main reviewer should +create a skeleton set of patch release notes on the release branch +using the `python helper tool <https://www.github.com/mantidproject/mantid/blob/master/tools/release_generator/patch.py>`__. + +Cherry Picking & Code Review +---------------------------- + +It is the job of the main reviewer of the release to review each +issue/pull request marked ``PatchCandiate`` and decide if the risks of +the changes are low enough to include in a release that will not +undergo full beta testing by scientists. If it is acceptable then on the release branch for each pull request: + +* find the list of commit ``SHA1`` values in that pull request +* check if any of these commits has altered the release notes for the + next major release +* if not then pass all commits in the order oldest->newest to + ``git cherry-pick -x`` +* if release notes were modified in a commit on their own then pass all + commits except this one in the order oldest->newest to + ``git cherry-pick -x`` +* if a commit has a mixture of code/release note changes then: + + * pass the list of commits up to but not including this commit to + ``git cherry-pick -x`` + * now pass this single commit to ``git cherry-pick -x -n`` and it + will not make a commit. Remove the major release note changes and + commit ``git add``/``git commit`` + * if there are any remaining commits after this then pass them to + ``git cherry-pick -x`` as before. + +* finally add a commit that updates the patch release notes with this + pull request link and description in the table. + +Once cherry picked the milestone of the original pull request should be +updated to the patch milestone. + +Nightly Builds +############## + +The `Jenkins Release Pipeline <http://builds.mantidproject.org/view/Release%20Pipeline/>`__ contains jobs +that check for changes on the current release branch each night (00:00 GMT). Any detected changes will cause a clean build of the code followed by a run of the system tests. The Linux clean builds should have the `PACKAGE_SUFFIX` set to `nightly` while testing the patch. + +These jobs should be checked each morning to confirm that everything is green. + +Release Day +########### + +On the day of release a few steps are required: + +* update the patch version: +* navigate to + {{site.mantidrepo}}/blob/release-X.Y./buildconfig/CMake/VersionNumber.cmake, + where ``X`` & ``Y`` are the major and minor release versions + respectively. +* edit the ``VERSION_PATCH`` to the required number for the patch and + commit the result. +* run a manual build of all of the OS jobs under {{ + site.mantidreleasebuilds }} and when asked for a suffix use an empty + string +* wait for the builds to finish (will take more than 1 cup of + tea/coffee/beverage of choice) + +While waiting for the builds create a new release on GitHub, using a tag +of the form ``v.X.Y.Z`` and populate with information from the release +notes (see a previous version of the format). + +Once the builds complete have the development team run unscripted +testing on the packages generated by the clean release builds. In +particular the issues intended to be fixed should be tested. + +Once the testing has passed: + +* Use the manual deploy job at {{ site.mantidreleasebuilds }} to deploy + packages and documentation to the public web. +* The windows binary will **not** be deployed and must be signed by + someone at ISIS and uploaded to sourceforge manually +* Put packages on GitHub +* RHEL 7 only: Build the suffix-package ``mantidXY`` by running another + clean RHEL 7 build at {{ site.mantidreleasebuilds }} but use the + suffix XY, where ``X`` is the major version and ``Y`` is the minor + version (currently used at SNS) +* Have someone at the SNS follow the instructions + `here <http://www.mantidproject.org/Fermi_cluster_at_ORNL>`__ to + deploy an MPI version of the patch release. +* Create new DOI using the scripts in the codebase and instructions on + :ref:`release checklist <ReleaseChecklist>`. +* Send an email, including the text of the release notes, to the + following lists +* ``mantid-announce@mantidproject.org`` +* ``mantid-developers@mantidproject.org`` +* ``nobugs@nobugsconference.org`` +* ``news@neutronsources.org`` +* ``neutron@neutronsources.org`` +* Add topic to the news page on the `forum <http://forum.mantidproject.org/>`__ +* Close the release milestone in github +* Remove the patch candidate tag from pull requests (if not already done) diff --git a/dev-docs/source/ProfilingWithValgrind.rst b/dev-docs/source/ProfilingWithValgrind.rst new file mode 100644 index 0000000000000000000000000000000000000000..d5e66f6621a95e757cce0fde21432c784f2cd755 --- /dev/null +++ b/dev-docs/source/ProfilingWithValgrind.rst @@ -0,0 +1,173 @@ +.. _ProfilingWithValgrind: + +Profiling with Valgrind +======================= + +Summary +------- + +Describes how to use the +`callgrind <http://valgrind.org/docs/manual/cl-manual.html>`__ plugin to +the `valgrind <http://valgrind.org/>`__ tool set to profile your code. + +*Note: Valgrind is a Linux only tool* + +Installation +------------ + +You will need to install both *valgrind* & the visualizer tool +*kcachegrind* - both of which should be available in your distribution's +repositories. + +Ubuntu +~~~~~~ + +:: + + >> apt-get install valgrind kcachegrind + +Red Hat/Fedora +~~~~~~~~~~~~~~ + +:: + + >> yum install valgrind kcachegrind + +Preparation +----------- + +To be most effective valgrind requires that debugging information be +present in the binaries that are being instrumented, although a full +debug build is not required. On gcc this means compiling with the *-g* +flag. For Mantid the recommended setup is to use a separate build with +the *CMAKE_BUILD_TYPE* set to *RelWithDebInfo*. This provides a good +balance between performance and availability of debugging information. + +Running the Profiler +-------------------- + +The profiler can instrument the code in a number of different ways. Some +of these will be described here. For more detail information see the +`callgrind manual <http://valgrind.org/docs/manual/cl-manual.html>`__. + +During execution the callgrind tool creates many output file named +*callgrind.output.pid.X*. For this reason it is recommended that each +profile run be executed from within a separate directory, named with a +description of the activity. This allows the separate profiled runs to +be found more easily in the future. + +**Beware**: The code will execute many times (factors of 10) slower than +when not profiling - this is just a consequence of how valgrind +instruments the code. + +Profile a Whole Program Run +~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +This is the simplest mode of operation. Simply pass the program +executable, along with any arguments to the valgrind executable: + +:: + + >> valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes <executable> [args...] + +Profile Selected Portions of the Code +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +For larger pieces of code it can be quite likely that you wish to +profile only a selected portion of it. This is possible if you have a +access to recompile the source code of the binaries to be instrumented +as valgrind has a C api that can be used talk to the profiler. It uses a +set of +`macros <http://valgrind.org/docs/manual/cl-manual.html#cl-manual.clientrequests>`__ +to instruct the profiler what to do when it hits certain points of the +code. + +As an example take a simple main function composed of several function +calls: + +.. code:: cpp + + int main() + { + foo1(); + bar1(); + foo2(); + foo3(); + } + +To profile only the call to ``bar1()`` then you would do the following +to the code: + +.. code:: cpp + + #include <valgrind/callgrind.h> + + int main() + { + foo1(); + CALLGRIND_START_INSTRUMENTATION; + CALLGRIND_TOGGLE_COLLECT; + bar1(); + CALLGRIND_TOGGLE_COLLECT; + CALLGRIND_STOP_INSTRUMENTATION; + foo2(); + foo3(); + } + +After recompiling the code you would then run the profiler again but +this time adding the *--instr-atstart=no --collect-atstart=no* flags, +like so + +:: + + >> valgrind --tool=callgrind --dump-instr=yes --simulate-cache=yes --collect-jumps=yes --collect-atstart=no --instr-atstart=no <executable> [args...] + +The *--instru-at-start=no* is not strictly necessary but it will speed +up the code up until the profiling point at the cost of the less +accuracy about the cache usage. See +`here <http://valgrind.org/docs/manual/cl-manual.html#opt.instr-atstart>`__ +more details. + +Visualisation +------------- + +Callgrind produces a large amount of data about the program's execution. +It is most easily understood using the *kcachegrind* GUI tool. This +reads the information produced by callgrind and creates a list of +function calls along with information on timings of each of the calls +during the profiled run. If the source code is available it can also +show the lines of code that relate to the functions being inspected. + +.. figure:: images/KCachegrind_MantidPlot.png + :alt: Example of KCachegrind display a profile of MantidPlot starting up and closing down + + Example of KCachegrind display a profile of MantidPlot starting up + and closing down + +By default KCachegrind shows the number of instructions fetched within +its displays. This can be changed using the drop-down box at the top +right of the screen. The *Instruction Fetch* and *Cycle Estimation* are +generally the most widely used and roughly correlate to the amount of +time spent performing the displayed functions. + +Some of the key features display are: + +Flat Profile View +~~~~~~~~~~~~~~~~~ + +- Incl. - Sum of itself + all child calls as a percentage of the whole. + Programs with little static allocation should have main() at 100%. + Units are those selected by the to-right drop-down +- Self - Exclusive count spent in the selected function. Units are + those selected by the to-right drop-down +- Called - Number of times the function was called. + +Function Call Detail +~~~~~~~~~~~~~~~~~~~~ + +Click on function in flat view to get more detail on the right. + +Displays details about the selected function call plus details about all +child calls it made. The *call graph* tab at the bottom gives a nice +graphical overview of the relative function cost. + diff --git a/dev-docs/source/Python3.rst b/dev-docs/source/Python3.rst new file mode 100644 index 0000000000000000000000000000000000000000..55fc190b999744cd6a0383b834c8ba4689323200 --- /dev/null +++ b/dev-docs/source/Python3.rst @@ -0,0 +1,118 @@ +======== +Python 3 +======== + +Python 2 has an `end-of-life date set for 2020 <http://legacy.python.org/dev/peps/pep-0373/>`_ +and now that most third-party packages support both 2 and 3 we are starting to think about a +migration strategy for Mantid. + +.. contents:: + :local: + +Building Against Python 3 +######################### + +This is currently only possible on a Linux system with a pre-installed version of python 3. You need +to install some additional packages as shown below: + +.. code-block:: sh + + apt-get install python3-sip-dev python3-pyqt4 python3-numpy python3-scipy python3-sphinx \ + python3-sphinx-bootstrap-theme python3-dateutil python3-matplotlib ipython3-qtconsole \ + python3-h5py python3-yaml + +or on fedora, with slightly different package names + +.. code-block:: sh + + dnf install python3-sip-devel python3-PyQt4-devel python3-numpy python3-scipy python3-sphinx \ + python3-sphinx-theme-bootstrap python3-dateutil python3-matplotlib python3-ipython-gui \ + boost-python3-devel python3-h5py python3-yaml + +then set ``-DPYTHON_EXECUTABLE=/usr/bin/python3`` when running cmake before building. + +.. warning:: + If any of these packages are installed via pip, this could cause conflicts. + Install as described here only. + +Supporting Python 2 and 3 +######################### + +Python 3 introduces many exciting new features. For a full description see the official Python 3 +changes document. For a shorter overview see +`here <https://asmeurer.github.io/python3-presentation/slides.html#1>`__ or +`here <http://python3porting.com/differences.html>`__. + +Some features of Python 3 have been backported to Python 2.x within the +`__future__ <https://docs.python.org/2.7/library/__future__.html?highlight=future#module-__future__>`_ +module. These make it easier to write code that is compatible with both versions. + +This cheat sheet provides helpful examples of how to write code in a 2/3 compatible manner. Where an +option is given to use either the `six <https://pythonhosted.org/six/>`_ or +`future <https://pypi.python.org/pypi/future>`_ (not to be confused with ``__future__``!) modules +then ``six`` is used. + +All new code should be written to be compatible with Python 2 & 3 and as a minimum the first import +line of the module should be: + +.. code-block:: python + + from __future__ import (absolute_import, division, print_function) + +It is quite common to also see ``unicode_literals`` in the above import list, however, when running +under Python 2 ``Boost.Python`` will not automatically convert a Python ``str`` to C++ ``std::string`` +automatically if the string is unicode. When running with Python 3 ``Boost.Python`` will do this +conversion automatically for unicode strings so this is in fact not a huge issue going forward. + +Migrating From Python 2 to 3 +############################ + +One way to migrate a file from python 2 to 3 is as follows... + +.. warning:: + | To perform the following procedure on windows: + | 1. Git Bash or similar will be required. + | 2. To run the ``2to3`` script you will need to start the command-prompt.bat in the build directory and run ``%PYTHONHOME%\Scripts\2to3`` + +Run the following script to run the python 2 to 3 translation tool and rename the file to ``filename.py.bak`` + +.. code-block:: sh + + 2to3 --no-diffs -w filename.py + mv filename.py{,.bak}; + + +Run **one** of the following commands to append the import statement listed above. + +.. code-block:: sh + + awk '/(from|import)/ && !x {print "from __future__ import (absolute_import, division, print_function)\n"; x=1} 1' \ + filename.py.bak > filename.py + +**or** + +.. code-block:: sh + + sed -i '0,/^import\|from.*/s/^import\|from.*/from __future__ import (absolute_import, division, print_function)\n&/' filename.py + +Check each changed block, + +- If any change has replaced ``xrange`` with ``range`` then add ``from six.moves import range`` + to the imports list +- If any change has replaced ``ifilterfalse`` with ``filterfalse`` from ``itertools`` then replace a + statement like ``from itertools import filterfalse`` with ``from six.moves import filterfalse`` in the + imports list. There are more cases like this documented `here <https://pythonhosted.org/six/#module-six.moves>`_. +- If any change has replaced ``for k, v in knights.iteritems()`` with ``for k, v in knights.items()`` + then add ``from six import iteritems`` to the import list and update the replacement to + ``for k, v in iteritems(knights)``. + +In some cases like ``range``, pylint will complain about `Replacing builtin 'range'` or similar. +Make sure to put the proper ignore statement on that line using ``#pylint: disable=redefined-builtin``. + +Check the code still runs as expected in Python 2. + +.. note:: + ``2to3`` will try to keep the type of the objects the same. So, for example ``range(5)`` will + become ``list(range(5))``. This is not necessary if you use it just for iteration. Things like + ``for i in range(5)`` will work in both versions of Python, you don't need to transform it into a + list. diff --git a/dev-docs/source/PythonVSCppAlgorithms.rst b/dev-docs/source/PythonVSCppAlgorithms.rst new file mode 100644 index 0000000000000000000000000000000000000000..80993461f751c1366d9e5635f7d0d71bb2cc59e9 --- /dev/null +++ b/dev-docs/source/PythonVSCppAlgorithms.rst @@ -0,0 +1,79 @@ +.. _PythonVSCppAlgorithms: + +======================== +Python vs C++ Algorithms +======================== + +.. contents:: + :local: + +Overview +-------- + +Mantid can be extended both with python and C++ algorithms as plug-ins. There are a number of considerations to take into account when deciding which language to choose. +These are summarised in the table and discussed below. Generally, it is recommended to implement **atomic** operations in C++, and **workflows** in python. + +Algorithm Language Comparison +----------------------------- + ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| Consideration | C++ | Python | ++=======================+========================================================================================================+============================================================================+ +| **Execution Speed** | Generally much faster (order of magnitude, and beyond), since compiled. | Generally slower. Numpy should be used wherever possible. | +| | Lots of optimisations can be made. OpenMP parallelisation for trivial loops (e.g. loops over spectra). | Large loops should be avoided, especially the nested ones. | +| | | Provides no means for trivial parallelisation. | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **Creation** | Generally slower and more complicated, but you do get the advantage of compile-time type checking. | Generally easier and faster. | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **Workflow** | Large overhead when setting and getting the properties of child algorithms. | Very convenient and concise for workflows thanks to the python SimpleAPI. | +| | Can quickly grow cumbersome, if many child algorithms have to be run. | | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **Testability** | Easy in C++ | Easy in python | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **API Accessibility** | Full | Some of the framework functionality is not exposed to python. | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **User Readability** | Users are not generally expected to understand C++ code. | Better readability. Power users are expected to understand python code. | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ +| **User Modifiability**| Users can not change C++ algorithms, since they are shipped in the compiled form. | Users can play with python algorithms, since they are shipped as source. | +| | | It is not advised, of course, do to so, but in case of a spurious result, | +| | | they have the opportunity to play with the algorithm before contacting us. | ++-----------------------+--------------------------------------------------------------------------------------------------------+----------------------------------------------------------------------------+ + +Multiple Possibilities in Mantid +-------------------------------- + +There are many ways to extend Mantid to add new features not present out-of-the-box. + +The easiest way to extend Mantid, and possibly the best starting place for any improvements, is a python script. Mantid provides a very high level of scriptable control, including plotting and visualisation as well as the execution of core routines. The scripting manual for Mantid provides an overview of the possibilities offered for scripting, including automatic generation via the graphical user interface for Mantid. + +:ref:`Algorithms <Algorithm>` and :ref:`workspaces <Workspace>` are core concepts in Mantid. Generally, an Algorithm does something based on input workspaces, either to create a new one from the results, or to modify the input in-place. One reason to create an Algorithm, is because you have a script containing a well-defined and useful procedure, that you would like to share with a wider audience. It usually requires a low amount of effort to adapt a python script into one or more Python Algorithms. + +Core Mantid Algorithms as well as some user defined Algorithms, are generally written in C++. There are a number of advantages to doing this (which are covered later), but also some serious disadvantages. When thinking about writing new functionality against Mantid, C++ does not need to be the default option. + +Should I Write a C++ Algorithm? +------------------------------- +The main reason to write algorithms in C++ is that you can often significantly reduce the run-time processing time over code written in Python. Looping over large volumes of data tends to be fastest in C++. Mantid also has facilities for running your Algorithm in a multi-threaded context when assembled in C++. + +Writing an algorithm in C++ gives you all the advantages associated with a compiled language including compile-time type checking. Some developers find this advantage significant enough to make writing C++ algorithms faster than Python equivalents. + +Writing clean Mantid Algorithm code in C++ is sometimes not a good idea. Here are some brief reasons why: + +For workflow Algorithms consisting mainly of child-algorithms execution, child-algorithm set-up in C++ can be long-winded and more fragile than Python. +There are many different ways to do the same thing in C++, and therefore more ways to get it wrong. +You are responsible for all the heap-allocated memory, as well as other resources you create. +Our target platforms have different compilers, with different interpretations of the same C++ standard, this can make writing cross-platform code tricky. +Compiler and linker outputs can be verbose, particularly in the presence of templated code. + +Should I Write a Python Algorithm? +---------------------------------- +Python algorithms are generally easier to put together than those assembled in C++. Because python has a limited dictionary, the barriers to writing effective code are much lower. Furthermore, not all algorithms need to run at the speed of light. For Algorithms that are only fed small volumes of data from small instruments, the user will not notice the difference between it running in half a second in Python or a tenth of a second in C++. + +It's more natural to convert a python script into a python Algorithm than directly into a C++ algorithm. In many cases, the algorithm functionality is best assembled by procedural execution of existing algorithms. For this, the python API provides the best means of executing an algorithm in a single line, using well defined, named variables. An algorithm of this nature will take up only a few lines in Python and therefore be very easy to read and maintain. + +Python algorithms also benefit from automatic GUI creation when they are registered with Mantid, so they can be used equally well through the command line, or through MantidPlot graphically. + +Python algorithms are great for editing and re-registering. Users can tweak existing Python algorithms or generate their own, without the complication of setting up a build environment. They can also more easily be re-issued to fix particular issues than C++ algorithms. + +Note for Mantid Developers +-------------------------- +Developers creating new algorithms in python must still generate unit tests for them. When an algorithm breaks, users do not care what language they are written in. The developer test suites allow you to create the same level of test coverage in python as you would in C++. Developers should also take care to ensure that the test exercises all of the code, as Python provides no compile-time type checking. diff --git a/dev-docs/source/QtDesignerForPython.rst b/dev-docs/source/QtDesignerForPython.rst new file mode 100644 index 0000000000000000000000000000000000000000..1ff4b8845df66de76ccf6ba80a9bb5e21ee77587 --- /dev/null +++ b/dev-docs/source/QtDesignerForPython.rst @@ -0,0 +1,230 @@ +.. _QtDesignerForPython: + +====================== +Qt Designer for Python +====================== + +Motivation +---------- + +Code for setting up individual widgets and the layout of a view can +become large and difficult to maintain by hand. It usually easier to +edit such code using a drag and drop WYSIWYG (What You See Is What You +Get) editor such as Qt Creator/Designer. However, doing so requires some +additional actions at build time. + +Implementation +-------------- + +Qt Creator was not originally designed to work with Python, and it is +therefore not possible to directly save or export the layout as a +Python script. Instead you must first save the layout in a ``.ui`` +file and use the ``pyuic4`` tool to convert it to a python script. + +Integration With CMake +---------------------- + +Running this tool manually for each ui file in the project would +quickly become infeasible. Fortunately it is easy to integrate this +with the cmake build using the ``UiToPy`` function defined in +``buildconfig/CMake/UiToPy.cmake``. This function takes a list of ui +files and a name to be used for a cmake target. It will produce a +target with the specified name, which, when built runs the ``pyuic4`` +command on each of the ``.ui`` files to generate a ``.py`` file with a +``ui_`` prefix in the same directory. + +For example the following CMakeLists.txt: + +.. code:: cmake + + include(UiToPy) + set(UI_FILES + sans_data_processor_window.ui + settings_diagnostic_tab.ui + masking_table.ui + ) + + UiToPy(UI_FILES CompileUISANSDataProcessorInterface) + +Produces a cmake target ``CompileUISANSDataProcessorInterface`` which +when built runs:: + + pyuic4 sans_data_processor_window.ui -o ui_sans_data_processor_window.py + pyuic4 settings_diagnostic_tab.ui -o ui_settings_diagnostic_tab.py + pyuic4 masking_table.ui -o ui_masking_table.py + +The generated target also runs a script wrap_pyui.py which prepends +``#pylint: skip-file`` to the top of the generated file. + +It is worth noting that for the main Mantid repository, in most cases +``include(UiToPy)`` can be omitted since the majority of Python GUIs +have their ``.ui`` files under the ``scripts/Interface/ui`` directory +and so ``scripts/Interface/ui/CMakeLists.txt`` performs this include. + +Using the Generated Script +-------------------------- + +When following the MVP design pattern as described at +:ref:`GuiDesignGuidelinesMVPIntro`, the generated file alone is not sufficient +as a :ref:`GuiDesignGuidelinesMVPView`. Directly accessing the widgets and the +signals defined on the view from the presenter moves the view +implementation details into the presenter, which makes it harder to +change the names and types of widgets used to display the +information. Instead it is best to create a separate Python file which +imports the generated one and adds a separate view class which +inherits from the generated one. + +.. code:: python + + import ui_add_runs_page # This imports the file generated by pyuic. + + class AddRunsPage(QtGui.QWidget, ui_add_runs_page.Ui_AddRunsPage): + pass + +You can then add separate methods to the view for accessing and mutating +the content of the widgets as well as add any necessary signals which +form the interface to the view. + +.. code:: python + + import ui_add_runs_page # This imports the file generated by pyuic. + + class AddRunsPage(QtGui.QWidget, ui_add_runs_page.Ui_AddRunsPage): + outFileChanged = pyqtSignal() + + def __init__(self, parent=None): + super(AddRunsPage, self).__init__(parent) + self.setupUi(self) + self._connect_signals() + + def _connect_signals(self): + self.fileNameEdit.editingFinished.connect(self.outFileChanged) + + def out_file_name(self): + return self.fileNameEdit.text().encode('utf-8') + +Keeping GUIs modular using Widgets +################################## + +.. _motivation-1: + +Motivation +---------- + +When designing a GUI in QtCreator it is often too easy to end up with +the entire interface in a single UI file. This can then lead to having a +single presenter for the entire GUI and sometimes even a single model. +This makes the UI harder to maintain as a whole and difficult to re-use, +move and separate out individual sections. + +Instead when building a GUI it is sometimes better to separate parts of +the interface into smaller views and presenters which form a hierarchy +of widgets. For example the new SANS Run Summation page is in it's own +UI file and uses two separate widgets - a ``RunSelectorWidget`` and a +``SummationSettingsWidget``. Although these widgets are not currently +used in any other interface, they are still isolated from the Run +Summation tab and could easily be used in another interface should the +need arise. The code is also better organised and more modular as a +result of this clean separation. + +.. _implementation-1: + +Implementation +-------------- + +Assuming we start with QtCreator with .ui file open which contains a +section of an interface which we wish to move to its own widget. We must +start by creating a new .ui file + +1. Go to *File* > *New File Or Project* and select *Qt Designer Form* +from the list of templates. + +.. image:: images/MVPPythonViews/NewForm.png + +2. Then select *Widget* from the list of form templates. + +.. image:: images/MVPPythonViews/SelectTemplate.png + +3. Enter the name for the file and save it to the location containing +the corresponding CMakeLists.txt + +.. image:: images/MVPPythonViews/NewFileName.png + +4. Click *Next* and adjust any project management settings as you wish +before clicking *Finish*. + +At this point you should have an empty Widget in the design area. + +.. image:: images/MVPPythonViews/SelectFile.png + +You can switch between the two ``.ui`` files using the menu in the top left. + +5. Next, copy the components you wish to move into the new widget and +paste them into the new file. + +.. image:: images/MVPPythonViews/CopyFromMainUI.png + +.. image:: images/MVPPythonViews/PasteIntoWidget.png + +6. Make adjustments to the layout and resize behaviour of the widget as +you see fit. + +.. image:: images/MVPPythonViews/AdjustWidgetLayout.png + +7. Add the following CMake snippet to your CMakeLists.txt, note that +you may already have a target for generating the Python files in which +case you can simply add your new ``.ui`` file to the list of existing +``.ui`` files. + +.. code:: cmake + + set(UI_FILES + my_widget.ui + ) + + UiToPy(UI_FILES CompileUIMyWidget) + +Test that this has worked by saving your ``.ui`` file and re-running +the build, the output should contain a line similar to the following: + +``[1/1] Generating scripts/Interface/ui/sans/ui_my_widget.py`` + +8. Add a separate python file containing the `View <GuiDesignGuidelinesMVPView>`__ +class which extends the generated one. + +.. code:: python + + # my_widget.py + import ui_my_widget + + class MyWidget(QtGui.QWidget, ui_add_runs_page.Ui_MyWidget): + pass + +9. Return to the original interface file, delete the components you +copied across and replace them with a single *Widget* component found in +the containers section. + +.. image:: images/MVPPythonViews/PreReplacedWidget.png + +.. image:: images/MVPPythonViews/PostReplacedWidget.png + +10. Right click on the newly created widget container and select +*Promote To...* + +.. image:: images/MVPPythonViews/PromoteWidget.png + +11. For the *Promoted Class Name* field enter the name of the view +class. If you are taking the advice given above, this should be the name +of the class which inherits from the generated +``ui_my_widget.Ui_MyWidget`` class. + +12. For the *Header File* field enter the fully qualified path of the +python module which contains the class mentioned above. + +13. You can leave the *Global Include* box un-ticked. Finish the +promotion by pressing *Add* and then *Promote*. + +.. image:: images/MVPPythonViews/CompletePromote.png + +14. Save your ui files, re-run and launch the build to see the finished +result. diff --git a/dev-docs/source/ReleaseChecklist.rst b/dev-docs/source/ReleaseChecklist.rst new file mode 100644 index 0000000000000000000000000000000000000000..22f90135f140c86a271dbaa7ba26be6b743a6a1e --- /dev/null +++ b/dev-docs/source/ReleaseChecklist.rst @@ -0,0 +1,214 @@ +.. _ReleaseChecklist: + +================= +Release Checklist +================= + +.. contents:: + :local: + +These are the steps involved in performing a full Mantid release. To +request or perform a patch release look at the +`patch release +checklist <%7B%7B%20site.url%20%7D%7D/release_checklist/patch/>`__ + +Timeline +######## + +Releases are normally planned to occur on a Friday, therefore this +page will be refer to days assuming that is correct, if the final +release day is not planned to be Friday then the names of the days +will have to be changed + +Friday, Release-4 weeks +####################### + +**Task Priorities**: Development, Testing, Documentation. + +* Send an email to Mantid-developers reminding developers of the + impending release and stating that they have only 5 days left before + the code freeze. +* Send an email to beta test users explaining the dates for the + testing, and stating they will have more detail on the start of the + first day. +* Invite staff to the release presentation + +Friday, Release-3 weeks +####################### + +**Task Priorities**: Final Development until code freeze, Testing, +Documentation. + +Code Freeze +----------- + +* Send an email to Mantid-developers asking everyone to ensure they + have closed their tickets, stating the code freeze is in place, and + warning developers that non-blocker tickets will be moved from this + release on Monday. +* Final Testing afternoon, attempt to drive the pull requests for this + milestone down to 0. +* Collect all of the completed, fixed tickets for that iteration. +* Parse through the list and short list all of the "major points" that + may be important to the users. + +Monday, Release-2 weeks & 4 days +################################ + +**Task Priorities**: Blocker bug fixes, Testing, Release Notes. + +Unscripted and Final Testing (technical tasks) +---------------------------------------------- + +* Ensure the + `master build and system + test <http://builds.mantidproject.org/view/Master%20Builds/>`__ + jobs have passed for all build environments for this release. +* Complete any ticket testing remaining from Friday +* Run + `open-release-testing <http://builds.mantidproject.org/view/All/job/open-release-testing/>`__ + to create the release branch and prepare build jobs +* Enable and update the release branch name for + `merge\_release\_into\_master <http://builds.mantidproject.org/view/All/job/merge_release_into_master/>`__ +* Check state of all open pull requests for this milestone and update + the base branch to the new release branch accordingly. +* Create a skeleton set of release notes for the next version +* Perform unscripted testing following the instructions described + `here <https://www.mantidproject.org/Unscripted_Manual_Testing>`__. + +Tuesday, Release- 2 weeks & 3 days +################################## + +**Task Priorities**: Blocker bug fixes, Testing, Release Presentation +preparation, Release Notes, Next release development. + +Beta Test Open +-------------- + +* Before sending an email to users, ensure that the Usage data .zip + file containing usage data is up-to-date. This is done by downloading + the current .zip from sourceforge, adding any missing files, and + resending it. +* Send an email to beta test users explaining where to download the + installers and how to report issues. +* Developers to arrange to meet with their beta testers. + +Monday, Release- 4 days +####################### + +**Task Priorities**: Blocker bug fixes, Testing, Release Presentation +preparation, Release Notes, Next release development. + +Beta Test Closes +---------------- + +* At the end of the day email the beta test users thanking them. + +Wednesday, Release-2 days +######################### + +**Task Priorities**: Blocker bug fixes, Testing, Release Notes, Next +release development. + +Thursday, Release-1 day +----------------------- + +**Task Priorities**: Blocker bug fixes, Testing, Release Notes, Next +release development. + +Final Code Changes +------------------ + +* This is the final day for code changes to the build for blocker + tickets + +Friday, Release day +################### + +'''Task Priorities''': Blocker bug fixes, Testing, Release Notes, Next +release development. + +Release (technical tasks) +------------------------- + +Once the unscripted testing has passed: + +* Check the release notes and remove the "Under Construction" paragraph + on the main index page. +* Disable release deploy jobs by executing + `close-release-testing <http://builds.mantidproject.org/view/All/job/close-release-testing>`__ + job. +* On the ``release-vX.Y`` branch, update major & minor versions + accordingly in ``buildconfig/CMake/VersionNumber.cmake``. Also + uncomment ``VERSION_PATCH`` and set it to ``0``. +* Merge ``release`` branch back to ``master`` +* Comment out patch number on ``master`` branch +* Draft a `new + release <https://github.com/mantidproject/mantid/releases>`__ on + GitHub. The new tag should be created based of the release branch in + the form ``vX.Y.Z`` +* Hit build on `release kit + builds <http://builds.mantidproject.org/view/Release%20Pipeline/>`__ + and set the ``PACKAGE_SUFFIX`` parameter to an empty string +* After all of the packages have been smoke tested build the + ``release_deploy`` job to put the packages (not windows) on + Sourceforge. +* Kick off the build for ``mantidXY`` on RHEL7 for SNS: + http://builds.mantidproject.org/job/release_clean-rhel7/ with suffix + ``XY`` +* Make sure someone at ISIS signs the Windows binary and uploads this + manually to Sourceforge +* Set the default package for each OS to the new version +* Upload packages to GitHub once they are ready and have been checked +* Publish the page +* Update the `download <http://download.mantidproject.org>`__ page, + following the instructions + `here <https://github.com/mantidproject/download.mantidproject.org>`__ +* Publish the draft release on GitHub (this will create the tag too). + +Finalise +======== + +* Send an email, including the text of the release notes, to the + following lists +* ``mantid-announce@mantidproject.org`` +* ``mantid-developers@mantidproject.org`` +* ``nobugs@nobugsconference.org`` +* ``news@neutronsources.org`` +* ``neutron@neutronsources.org`` +* Create a new item on the forum news +* Close the release milestone in the issue tracker + +Generate DOI (technical tasks) +------------------------------ + +This requires that a tag has been created for this release, this is done +automatically if a new +`release <https://github.com/mantidproject/mantid/releases>`__ has been +created on GitHub. + +* Make sure that you have updated your local copy of git to grab the + new tag. ``git fetch -p`` +* If the script below fails you may need to update the authors list and + push the updates to master. Look for ``authors.py`` in the + ``tools/DOI`` directory. It does not matter that these are not on the + release branch. + +``python tools/DOI/doi.py --username=_____ X.Y.Z`` + +* Major/minor/patch version numbers must be supplied, as well as a + username which can be found in the `Protected + Information <http://www.mantidproject.org/Protected_Information>`__ + section. The script will prompt for the password. Note that only + MediaWiki admins have access rights to the page. +* A corresponding version tag must be present in the Mantid repo. + +Next release plan +----------------- + +* Prepare the Next release plan. +* Gather user descriptions of priority tickets from developers for the + next release. +* Decide on priority maintenance tasks for the next release. +* Inject Items from the Facility scientific computing strategic plans. +* Compile to a document and release diff --git a/dev-docs/source/RemoteJobSubmissionAPI.rst b/dev-docs/source/RemoteJobSubmissionAPI.rst new file mode 100644 index 0000000000000000000000000000000000000000..4133388f09f1f4e35a77068fd841f64347453947 --- /dev/null +++ b/dev-docs/source/RemoteJobSubmissionAPI.rst @@ -0,0 +1,390 @@ +.. _RemoteJobSubmissionAPI: + +========================= +Remote Job Submission API +========================= + +.. contents:: + :local: + +This document describes the web service API that the Mantid Framework uses to submit algorithms to remote compute +resources. The API is designed to be flexible enough that it can be implemented for just about any compute resource at +nearly any facility. This document should hopefully contain enough detail for programmers & sysadmins at other +facilities to implement the API and allow Mantid users to submit jobs to compute resources at those other facilities. + +A 'compute resource' may be any computer capable of running the Mantid framework. This could range from a single large +server, to some sort of Beowulf cluster to machines with specialized hardware such as GPU's or Intel MIC's. The idea is +that the 'compute resource' will be used to execute tasks that are impractical to run on the user's local workstation. + +The reference implementation is the Fermi cluster at the Oak Ridge Spallation Neutron Source (fermi.ornl.gov). Specific +details of the implementation on Fermi are used as examples throughout this document. + +Basic Requirements For API Implementations +========================================== + +The Mantid framework has certain expectations for the API and it's the responsibility of API implementations to meet +these expectations: + +#. The API provides a mechanism for executing python scripts in an environment that includes the Mantid framework. (ie: + one where "from mantid.simpleapi import \*" works) (Note: exactly \*how\* this happens is purposely left up to the + implementor.) +#. Scripts are executed in a batch environment - interactive scripts are not supported and scripts must be able to run + without input from the user. +#. No mechanism for passing command line parameters to the python scripts is provided. Things like experiment and run + numbers must be hard-coded into the script. (We consider this acceptable because we expect a new script to be + auto-generated by MantidPlot for each job.) +#. Scripts can write output to what is the current working directory when the script starts. These output files will be + available for download back to MantidPlot (or wherever) once the script finishes. +#. Files that were uploaded prior to running the script will be available from the script's working directory. +#. Authentication is used to prevent individual users from interfering with others' jobs (or even reading their files) +#. Data from the various API calls is returned in two ways: the standard HTTP status codes (200, 404, 500, etc...) and + JSON text in the body. (Note: There's no HTML markup in the output.) In the case of error status codes, the JSON + output will contain a field called 'error_msg' who's value is a string describing the error. +#. Clients should assume that all parts of the URL - including query parameters - are case sensitive. However, servers + don't \*have\* to accept URL's with improper case, but may if it makes the code simpler. + +Versioning +========== + +A quick Google search shows that versioning web API's is tricky. The technique employed here will be to use a major +version plus optional extensions. + +Between major versions there are no guarantees of backwards or forwards compatibility. Changing the major version is +essentially starting over from scratch with a clean slate. The major version starts at 1 and will hopefully never +change. + +Backwards-compatible changes are handled by means of optional extensions. + +A server must implement all of the functions defined in the base level of the version and a client may assume those +functions exist. A server is NOT required to implement the extensions (they're optional) and a client may query the +server to discover which extensions are implemented. (Note that what the server returns is really just a name. It's up +to the client and server implementers to agree on exactly what that name means and then document it - presumably here in +this API doc.) + +Backwards-incompatible changes to the API are not allowed. That includes the URL itself, the GET or POST variables it +expects and the JSON that it outputs. If changes are needed, they can be handled through the extension mechanism. For +example, more GET or POST variables could be accepted by the server, so long as they are not required. An extension +should be created (and documented here) so that a client may query the server about whether it supports the new +variables. + +Old GET or POST variables cannot be deleted however. This would break clients that expect to use them. If there's a case +where old varibles no longer make sense, then a completely new URL should be created (and again, documented as an +extension). + +Similar rules apply to the JSON data returned by the API. Extra fields can be added to the JSON returned by a URL, but +original fields may not be removed. + +It's worth noting that it is possible for extensions to be mutually exclusive. + +Authentication +============== + +The initial API uses HTTP Basic-Auth name/password combo for authentication. (Other methods may be added via API +extensions as described above.) Upon successful authentication, a session cookie is created. All other URL's require +this session cookie. + +Because the Basic-Auth scheme does not encrypt the password when it is sent to the server, the use of the HTTPS protocol +is **STRONGLY** encouraged. + +Note that HTTP Basic-Auth is simply the mechanism for passing a username/password combo to the web service. Exactly how +the web service uses that combo to authenticate (and authorize) a user is not specified by the API. Individual +implementations are free to do what they like. (For example, the implementation on Fermi checks the username & password +against an LDAP server.) + +Transactions +============ + +The API details below mention starting & stopping transactions. It should be noted that in this context, the word +transaction doesn't really have anything to do with databases. In this context, transactions are a mechanism for the web +service to associate files with specific jobs. Multiple jobs may be submitted under a given transaction. + +Note that the API doesn't specify how this association occurs. That is a detail left up to the individual +implementation. However, remember the points in the Basic Requirements section above about scripts reading from and +writing to their current working directory while not allowing other users to see or modify their files. That implies +that each job will store files in its own directory and will execute scripts from that directory. (This is, in fact, how +the implementation on Fermi works.) + +A user must start a transaction after authenticating, but before transferring files or submitting job scripts. When the +user's job (or jobs) has finished and the user no longer needs the files associated with the transaction, he or she +should end the transaction. This will allow the web service to delete the files and recover the disk space. + +A Note About File Uploads +========================= + +It is generally assumed that the input files for the submitted python scripts are already available on the compute +resource (presumably via some kind of network filesystem). Thus, although the API allows for file uploads, this is +really intended for relatively small support files that a particular script might need. The HTTP protocol really isn't +intended or suitable for transferring the sort of multi-gigabyte files that are likely to be the inputs for these python +scripts. + +API v1 URL's +============ + +General notes: + +- All URL's expect GET requests unless otherwise noted. +- The session cookie returned by the authentication URL is required by all other URL's (except for the info URL) +- Success is indicated by an HTTP status code in the 200 range. (Typically, 200, but in some cases 201.) Errors are + indicated with error codes in the 400 and 500 range. +- In the case of errors, the JSON output will include a field named "Err_Msg" whose value is a text string describing + the particular error. + + +Information +----------- + ++--------------------------------+-------------------------------------------------------------------------------------+ +| Description | Returns information about the server including the API version and supported | +| | extensions. | ++--------------------------------+-------------------------------------------------------------------------------------+ +| URL | <base_url>/info | ++--------------------------------+-------------------------------------------------------------------------------------+ +| Query Parameters | None | ++--------------------------------+-------------------------------------------------------------------------------------+ +| JSON Output | API_Version : <integer> API_Extensions : [<extension_1>, <extensions_2>, .... ] | +| | Implementation_Specific_Post_Variables : [ <variable_1>, <variable_2>, .... ] | ++--------------------------------+-------------------------------------------------------------------------------------+ +| Notes | May be called without first authenticating. The | +| | 'Implementation_Specific_Submit_Variables' field lists the particular POST | +| | variables that this implementation requires when submitting a job. See the | +| | 'Job Submission <#Job_Submission>`__ URL. | ++--------------------------------+-------------------------------------------------------------------------------------+ + +Authentication +-------------- + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Authenticate to the web service. | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/authenticate | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | Username and password are passed in using HTTP Basic | +| | Authentication Returns a session cookie which must be | +| | passed to the other URL's | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +Transactions +------------ + +This URL has two forms: one to start a new transaction and the other to end an existing transaction. + ++-------------------------------------------------+--------------------------------------------------------------------+ +| Description | Start a new transaction | ++-------------------------------------------------+--------------------------------------------------------------------+ +| URL | <base_url>/transaction | ++-------------------------------------------------+--------------------------------------------------------------------+ +| Query Parameters | Action=Start | ++-------------------------------------------------+--------------------------------------------------------------------+ +| JSON Output | TransID : <string> | ++-------------------------------------------------+--------------------------------------------------------------------+ +| Notes |  | ++-------------------------------------------------+--------------------------------------------------------------------+ + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | End an existing transaction | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/transaction | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | Action=Stop TransID=<transaction_id> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | Once a transaction is stopped, any files associated with | +| | it will no longer be available for download and the | +| | server is free to delete those files. | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +File Transfer +------------- + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Transfer a file from the server back to the client | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/download | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | TransID=<transaction ID> File=<filename> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output |  | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | <filename> does not include any path information. The | +| | actual directory where the file is stored is chosen by | +| | the web service and hidden from the user | ++-----------------------------------------------------------+-----------------------------------------------------------+ + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Transfer one or more files from the client up to the | +| | server | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/upload | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | This is a POST method Multiple files may be submitted | +| | with one call | +| | File(s) are submitted as | +| | multipart form data (ie: "Content-Type: | +| | multipart/form-data" header) | +| | File names should not include | +| | any directory or path information. (Exactly where the | +| | file is stored is left to the web service to determine.) | +| | The transaction ID must also be | +| | specified as form data with a field name of "TransID" | +| | On success, returns a "201 - Created" status code | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +File Listing +------------ + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Return a listing of files associated with the specified | +| | transaction | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/files | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | TransID=<transaction ID> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | Files : [ <file_1>, <file_2>, ... <file_n> ] | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | No guarantees are made about the order files are listed | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +Job Submission +-------------- + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Submit a python script for execution on the compute | +| | resource | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/submit | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Mandatory POST Variables | TransID : <trans_id> | +| | ScriptName : <name_of_python_script> | +| | <name_of_python_script> : <python code> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Optional POST Variables | JobName : <name> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Implementation Specific POST Variables | NumNodes : <number_of_nodes> | +| | CoresPerNode: <cores_per_node> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | JobID : <job_id> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | This is a POST method | +| | Request is submitted as multipart form data (ie: | +| | "Content-Type: multipart/form-data" header) | +| | POST variables listed above are individual form data | +| | fields | +| | The content of the "ScriptName" field specifies the name | +| | of the python script. There must be another field with | +| | this name that actually contains the python code. This | +| | allows the web service to keep track of multiple scripts | +| | associated with the same transaction. | +| | The JobName variable allows the user to specify a name | +| | for a job. The name is included in the output of queries. | +| | (Presumably, the user will pick a name that's more | +| | descriptive and easier to remember than the automatically | +| | assigned job ID.) | +| | The Implementation Specific Post Variables are - like the | +| | name says - specific to a particular implementation. They | +| | may not be applicable to all implementations and it's | +| | valid for an implementation to ignore those that aren't. | +| | Which variables are required by a specific implementation | +| | are listed in the `Information <#Information>`__ URL. | +| | (The two specified above are used by the Fermi | +| | implementation, and would probably be valid for all | +| | compute clusters.) | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +Job Query +--------- + +This URL has two forms: one to query a specific job and one to query all of a user's jobs. + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Query all jobs submitted by the user | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/query | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | <job_id> : <job_description_object> | +| | <job_id> : <job_description_object> | +| | <job_id> : <job_description_object> | +| | etc... | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | See below for a description of the job_description_object | +| | The length of time the compute resource will 'remember' | +| | jobs is up to the implementer, but several days should be | +| | considered an absolute minimum. (A user should be able to | +| | submit a job on Friday and still be able to query it on | +| | Monday morning.) | ++-----------------------------------------------------------+-----------------------------------------------------------+ + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Query one specific job submitted by the user | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/query | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | JobID : <job_id> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | <job_id> : <job_description_object> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | See below for a description of the job_description_object | +| | The length of time the compute resource will 'remember' | +| | jobs is up to the implementer, but several days should be | +| | considered an absolute minimum. (A user should be able to | +| | submit a job on Friday and still be able to query it on | +| | Monday morning.) | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +The job description object is a JSON object who's fields contain specific information about the job. The fields are: + +- TransID - The transaction ID the job is associated with +- JobName - The name that was given to the submit API +- ScriptName - The name of the python script that was executed +- JobStatus - The execution status of the job. Will be one of: RUNNING, QUEUED, COMPLETED, REMOVED, DEFERRED, IDLE or + UNKNOWN + +Job Abort +--------- + ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Description | Abort a previously submitted job. Jobs that are queued | +| | will be dequeued. Jobs that are running will be stopped | +| | immediately. Jobs that have already completed will simply | +| | be ignored. | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| URL | <base_url>/abort | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Query Parameters | JobID : <job_id> | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| JSON Output | None | ++-----------------------------------------------------------+-----------------------------------------------------------+ +| Notes | Returns a 400 error code if the job ID does not exist. | ++-----------------------------------------------------------+-----------------------------------------------------------+ + +API v1 Extensions +================= + +JOB_DATES +--------- + +The JOB_DATES extension adds three fields to the job_description_object that is returned by queries. The fields are +"SubmitDate", "StartDate" & "CompletionDate" which represent the dates (including time) that the job was first +submitted, when it started executing and when it stopped (either because it finished or because it was interrupted for +some reason). The values are ISO8601 strings suitable for importing into a Mantid DateAndTime object. + +AUTH_USER_NAME +-------------- + +The AUTH_USER_NAME extension adds a single field the the JSON text returned by the 'info' URL. The field name is +'Authenticated_As' and its value is either the name of the user that's been authenticated, or empty if no authentication +has taken place yet. + diff --git a/dev-docs/source/RunningTheUnitTests.rst b/dev-docs/source/RunningTheUnitTests.rst new file mode 100644 index 0000000000000000000000000000000000000000..eac7145fa91c27c2f7910040730411bf40cc4570 --- /dev/null +++ b/dev-docs/source/RunningTheUnitTests.rst @@ -0,0 +1,135 @@ +.. _RunningTheUnitTests: + +====================== +Running the Unit Tests +====================== + +.. contents:: + :local: + +Overview +######## + +We use `CTest <http://www.cmake.org/cmake/help/ctest-2-8-docs.html>`__ +for building and running our unit tests. This wraps the underlying +`cxxtest <cxxtest>`__ or other (e.g. pyunit) test code. + +CMake/CTest: Command Line using a makefile generator +#################################################### + +The unit tests are currently excluded from the 'all' target. To build +the all the tests, including the dependent framework code (in all these +examples in parallel using 8 cores): + +.. code-block:: sh + + make -j8 AllTests + +To build only one package of tests (and its dependencies): + +.. code-block:: sh + + make -j8 KernelTest + +To run all the tests: + +.. code-block:: sh + + ctest -j8 + +To build and run all the tests in one shot: + +.. code-block:: sh + + make -j8 check + +To run a specific test or set of tests (will run all those that match +the search string): + +.. code-block:: sh + + ctest -R KernelTest_TimerTest + +So to run all tests in a suite (using a search string): + +.. code-block:: sh + + ctest -j8 -R KernelTest + +To exclude things from your tests (matches the string as with the -R +option) - useful for those building the performance tests: + +.. code-block:: sh + + ctest -j8 -E Performance + +Useful CTest Options +#################### + +``ctest -h`` gives the full list of command line arguments. Some useful +ones to note are: + +- ``--output-on-failure``: displays the log and any stderr output that + is otherwise hidden by CTest. +- ``--schedule-random``: run the tests in a random order. Useful to + weed out accidental dependencies +- ``--repeat-until-fail``\ : require each test to run times without + failing in order to pass. Useful to try and find random failures + +Running Unit Tests Manually +########################### + +Starting in your build folder (e.g. Mantid/Code/debug): + +- Running an entire test suite (e.g. KernelTest): + + .. code-block:: sh + + ctest -j8 -R KernelTest + bin/KernelTest + +- Running a specific test class. + + .. code-block:: sh + + ctest -R MyTestClassName + bin/KernelTest MyTestClassName + +- Running a specific test. + + .. code-block:: sh + + bin/KernelTest MyTestClassName MySingleTestName`` + + - Not possible with ctest. + +Visual Studio/ XCode note +######################### + +In Visual Studio the user can alter the properties of the subset of +tests (inside the unitTest directory (e.g. AlgorithmTest). In the +properties box it is possible to specify a specific test to run by +typing its name in the TargetName box. Then to execute the test, right +click the subset of tests and select debug and then start new instance. + +To run the tests under one of these environments then you will need to +open a command window and change to the build directory. Once there you +can run the tests by selecting the configuration; + +.. code-block:: sh + + ctest -C Debug -j4 + +This runs all tests in Debug mode (note that this will NOT build any +outdated libraries). To select a subset use the ``-R`` option: + +.. code-block:: sh + + ctest -C Release -R Kernel -j4 + + (-R Kernel), with 4 cores (-j4), in Release mode (-C Release). + +Debugging unit tests +#################### + +See the instructions `here <DebuggingUnitTests>`__ diff --git a/dev-docs/source/Standards/AlgorithmDocumentation.rst b/dev-docs/source/Standards/AlgorithmDocumentation.rst new file mode 100644 index 0000000000000000000000000000000000000000..dc03d48a52c5f9caaebd04855dcdf63a71e309f0 --- /dev/null +++ b/dev-docs/source/Standards/AlgorithmDocumentation.rst @@ -0,0 +1,194 @@ +.. _AlgorithmDocumentation: + +======================= +Algorithm Documentation +======================= + +.. contents:: + :local: + +Summary +======= + +This page deals with the specifics of how to document an algorithm. For a more general guide to the Mantid documentation system see `Documentation Guide For Devs <DocumentationGuideForDevs.html>`__. + +How to Document an Algorithm +============================ + +Algorithm documentation is stored in two places. + +* The code (.cpp / .h / .py) files: For strings that are needed in the GUI for tooltips etc. +* The .rst file: For all other documentation, including the algorithm description and `usage examples <AlgorithmUsageExamples.html>`__. + +The Code Files +-------------- + +The code files hold documentation in two important areas. + +The ``summary`` method + The summary method should return a string (in plain text) that describes in a short sentence the purpose of the algorithm. This is used to provide a summary in the algorithm dialog box and in the algorithm documentation web page. + +In C++: (This example uses the .h file, you could of course implement it in the .cpp file) + +.. code-block:: c++ + + /// Algorithm's name for identification overriding a virtual method + const std::string name() const override { return "Rebin";} + + ///Summary of algorithms purpose + const std::string summary() const override {return "Rebins data with new X bin boundaries.";} + +Property Descriptions +--------------------- + +Each property declaration in the init method of the .cpp file should include a description. This is used as a tooltip, and in the 'properties' table on the algorithm's documentation web page. + +.. note:: + + The tooltip may only show the description up to the first dot. Be sure that the first sentence in the description gives enough information to understand the purpose of the property. + +For example: + +.. code-block:: c++ + + declareProperty( + new WorkspaceProperty<>("InputWorkspace", "", Direction::Input), + "Workspace containing the input data"); + declareProperty( + new WorkspaceProperty<>("OutputWorkspace","",Direction::Output), + "The name to give the output workspace"); + declareProperty( + new ArrayProperty<double>("Params", boost::make_shared<RebinParamsValidator>()), + "A comma separated list of first bin boundary, width, last bin boundary. Optionally " + "this can be followed by a comma and more widths and last boundary pairs. " + "Optionally this can also be a single number, which is the bin width. " + "In this case, the boundary of binning will be determined by minimum and maximum TOF " + "values among all events, or previous binning boundary, in case of event Workspace, or " + "non-event Workspace, respectively. Negative width values indicate logarithmic binning. "); + +Workflow algorithms +=================== + +There should be a flow chart for workflow algorithms. See `here <FlowchartCreation.html>`__ on how to make one. + +Algorithm Directives +==================== + +We have defined several custom directives using the Sphinx extension framework. These are defined to generate the information from an algorithm that is not required to be hand written, i.e the properties table. Each .rst file that is documenting an algorithm should use these directives. + +As the **Description** and **Usage** of an algorithm *cannot* be obtained automatically, it must be manually entered. The structure of an algorithm's .rst is: + +.. code-block:: rest + + .. algorithm:: + + .. summary:: + + .. alias:: + + .. properties:: + + Description + ----------- + + The description of your algorithm here. + + Usage + ----- + + A custom usage example. + + .. categories:: + + .. sourcelink:: + +``.. algorithm ::`` + This directive has several pieces of functionality, which includes: + +* A referable link is created for the algorithm. This allows other documentation pages create references to it (e.g. create links to it). +* Insertion of the page title (which is the name of the algorithm, including the version). +* Insertion of a screenshot of the algorithm's dialog. +* Insertion of the Table Of Contents. + +``.. summary::`` + The content of the summary method declared in your algorithm is output as HTML, for example, the following method is used in Rebin: + +.. code-block:: c++ + + /// Summary of algorithms purpose + const std::string summary() const override { + return "Rebins data with new X bin boundaries. For EventWorkspaces, you can very quickly rebin in-place by keeping the same output name and PreserveEvents=true."; + } + +``.. alias::`` + This directive obtains aliases from the required ``alias`` method in the algorithm, for example, the following method is used in Rebin: + +.. code-block:: c++ + + /// Algorithm's aliases + const std::string alias() const override { return "rebin"; } + +``.. properties::`` + As mentioned above, it is *critical* that you include a description for the properties of your algorithm. This directive obtains all of the algorithm's properties (set inside the algorithm's ``init`` method) and outputs in a table format. + +``.. categories::`` + By default, this directive obtains the categories that were set in the ``categories`` method the algorithm. For example, in Rebin the category method is in the header and contains: + +.. code-block:: c++ + + /// Algorithm's category for identification + const std::string category() const override {return "Transforms\\Rebin";} + +When the HTML is generate a categories list is built that contains: Algorithms, Transforms and Rebin. + +It is possible to add additional categories by passing the directive arguments, for example, the following would output the above categories, and also `Example`: + +.. code-block: rest + + .. categories:: Algorithms, Transforms, Rebin, Example + +``..sourcelink ::`` + This directive adds links to the algorithms source code. + +Description +=========== + +This section must be manually entered. The description is an extension of the summary, and must contain a detailed overview of the algorithm's functionality. + +Referencing Other Algorithms +---------------------------- + +Every algorithm and version has been marked with a tag that can be used to reference it from other documents. If you need to reference the latest version of an algorithm, e.g. DiffractionFocussing, then in Sphinx you type would type + +.. code-block:: rest + + :ref:`DiffractionFocussing <algm-DiffractionFocussing>` + +If you need to reference a particular version then you would type + +.. code-block:: rest + + :ref:`DiffractionFocussing version 2 <algm-DiffractionFocussing-v2>` + +where the first part outside the angle brackets defines the link text and the part inside the angle brackets references the tag name. + +Usage +===== + +This section *must* be manually entered. The usage is a 'code' example of the algorithm in use. The `testcode` directive must be used to verify the usage code you entered works correctly. See `here <AlgorithmUsageExamples>`__ for more information on how to write usage examples. + +Building the Documentation +========================== + +One can update the documentation for a particular algorithm after changes have been introduced into the corresponding documentation file. Assuming you are in the build directory and want to update the documentation for Rebin: + +:: + + bin/MantidPlot -xq docs/runsphinx_html.py -R Rebin # builds HTML documentation + bin/MantidPlot -xq docs/runsphinx_qthelp.py -R Rebin # builds Qt-help documentation + +or with vanilla python + +:: + + python docs/runsphinx_html.py -m $PWD/bin -R Rebin diff --git a/dev-docs/source/Standards/AlgorithmUsageExamples.rst b/dev-docs/source/Standards/AlgorithmUsageExamples.rst new file mode 100644 index 0000000000000000000000000000000000000000..3c8ee85ebc3789e7b1a5f89e2d8815f158a3a4d0 --- /dev/null +++ b/dev-docs/source/Standards/AlgorithmUsageExamples.rst @@ -0,0 +1,224 @@ +.. _AlgorithmUsageExamples: + +======================== +Algorithm Usage Examples +======================== + +.. contents:: + :local: + +Introduction +============ + +A *usage example* is part of the documentation page of an algorithm. + +From a user's point of view, the main purposes of usage examples are: + +* Getting started using the algorithm as part of a Python script +* Understanding the algorithm +* Showing hints/comments etc. that help understand Mantid Python scripting in general + +The usage examples are written in `reStructuredText <http://docutils.sourceforge.net/rst.html>`__, which can be converted to HTML and the code in the usage examples can be tested. The image below demonstrates an example of converting reStructuredText to HTML. + +Guide +===== + +The example below show the proposed way to format an usage example in reStructuredText. + +.. code-block:: rest + + Usage + ----- + + **Example - simple rebin of a histogram workspace:** + + .. testcode:: ExHistSimple + + # create histogram workspace + dataX = [0,1,2,3,4,5,6,7,8,9] # or use dataX=range(0,10) + dataY = [1,1,1,1,1,1,1,1,1] # or use dataY=[1]*9 + ws = CreateWorkspace(dataX, dataY) + + # rebin from min to max with size bin = 2 + ws = Rebin(ws, 2) + + print "The rebinned X values are: " + str(ws.readX(0)) + print "The rebinned Y values are: " + str(ws.readY(0)) + + + Output: + + .. testoutput:: ExHistSimple + + The rebinned X values are: [ 0. 2. 4. 6. 8. 9.] + The rebinned Y values are: [ 2. 2. 2. 2. 1.] + +What is required is: + +* Short description explaining the example, formatted as shown above, i.e. using ``**`` to embolden the text. +* A ``.. testcode::`` section, with a unique 'namespace' name, here ``ExHistSimple``. This 'namespace' is not shown when converted to HTML, but is used in testing the code. This section contains the actual Python code demonstrating a usage of the algorithm. This code block contains commented code, finishing with one or more Python ``print`` lines as shown +* A ``.. testoutput::`` section. This section must have a matching 'namespace' name to the ``..testcode::`` section. It simply contains a copy of the text that is printed out in the ``..testcode::`` section. +* Include the "Output:" string above the ``..testoutput::`` directive. + +What is optional: + +* A ``..testcleanup::`` section. This section must have a matching 'namespace' name to the ``..testcode::`` section. Here, add Python code to do any cleanup of files etc. that were created by the tests. See the notes below for things that are cleaned automatically. + +Notes: + +* The configuration has a global "testcleanup" implemented which calls ``FrameworkManager::clear()`` to clear algorithms, workspaces & instruments so these are dealt with automatically. +* There must be a clear blank line before the ``.. testcode::`` and ``.. testoutput`` directives or the test is ignored. As with unit tests you should write a failing test first to ensure it is running. + +What is worth keeping in mind is: + +* *Assume the user is new to Python*. Consider giving hints to more advanced Python in comments, or introduce a simple example first. +* Use comments. +* Use Python ``print`` to output results, which, where possible, helps to understand the algorithm. + +A Jenkins job tests that the usage examples are not broken, i.e. that they continue to provide a working demonstration against the current build. It is vital to stress that the purpose of usage testing is *not to replace unit testing* (or system testing). The purpose of usage testing (better described as demonstration examples), is to provide some happy-path examples, which, where this is possible, can assist the user understanding of the Python code. This is very different from the purposes of testing in general, see `here <UnitTestGoodPractice.html>`__. + +Additional benefits of usage examples: + +* Quick look-up for developers on how to use a certain algorithm in Python scripting +* Allow the user to test that scripts return expected output in their installed Mantid versions +* Additional test coverage of Mantid Python API + +Using CreateSampleWorkspace and CreateWorkspace +----------------------------------------------- + +There are many ways to create sample workspaces. For example :ref:`CreateMDHistoWorkspace <algm-CreateMDHistoWorkspace>`, :ref:`CreateSampleWorkspace <algm-CreateSampleWorkspace>` and :ref:`CreateWorkspace <algm-CreateWorkspace>`. CreateSampleWorkspace creates a fully defined workspace (either event or histogram) but for creating simple histogram workspace CreateWorkspace may be a better option. Above is shown an example where CreateWorkspace is used. Below is a more complex use of CreateSampleWorkspace: + +.. code-block:: rest + + Usage + ----- + + **Example - Fit a Gaussian to a peak in a spectrum:** + + .. testcode:: ExFitPeak + + # create a workspace with a gaussian peak sitting on top of a linear (here flat) background + ws = CreateSampleWorkspace(Function="User Defined", UserDefinedFunction="name=LinearBackground, \ + A0=0.3;name=Gaussian, PeakCentre=5, Height=10, Sigma=0.7", NumBanks=1, BankPixelWidth=1, XMin=0, XMax=10, BinWidth=0.1) + + # Setup the data to fit: + workspaceIndex = 0 # the spectrum with which WorkspaceIndex to fit + startX = 1 # specify fitting region + endX = 9 # + + # Setup the model, here a Gaussian, to fit to data + tryCentre = '4' # A start guess on peak centre + sigma = '1' # A start guess on peak width + height = '8' # A start guess on peak height + myFunc = 'name=Gaussian, Height='+height+', PeakCentre='+tryCentre+', Sigma='+sigma + # here purposely haven't included a linear background which mean fit will not be spot on + # to include a linear background uncomment the line below + #myFunc = 'name=LinearBackground, A0=0.3;name=Gaussian, Height='+height+', PeakCentre='+tryCentre+', Sigma='+sigma + + # Do the fitting + fitStatus, chiSq, covarianceTable, paramTable, fitWorkspace = Fit(InputWorkspace='ws', \ + WorkspaceIndex=0, StartX = startX, EndX=endX, Output='fit', Function=myFunc) + + print "The fit was: " + fitStatus + print("chi-squared of fit is: %.2f" % chiSq) + print("Fitted Height value is: %.2f" % paramTable.column(1)[0]) + print("Fitted centre value is: %.2f" % paramTable.column(1)[1]) + print("Fitted sigma value is: %.2f" % paramTable.column(1)[2]) + # fitWorkspace contains the data, the calculated and the difference patterns + print "Number of spectra in fitWorkspace is: " + str(fitWorkspace.getNumberHistograms()) + print("The 20th y-value of the calculated pattern: %.4f" % fitWorkspace.readY(1)[19]) + + .. testcleanup:: ExFitPeak + + DeleteWorkspace(ws) + + Output: + + .. testoutput:: ExFitPeak + + The fit was: success + chi-squared of fit is: 0.14 + Fitted Height value is: 9.79 + Fitted centre value is: 5.05 + Fitted sigma value is: 0.77 + Number of spectra in fitWorkspace is: 3 + The 20th y-value of the calculated pattern: 0.2361 + +For a more simple use of CreateSampleWorkspace see example below (note if no arguments are given then a histogram workspace is created): + +.. code-block:: rest + + Usage + ----- + + **Example - use option PreserveEvents:** + + .. testcode:: ExEventRebin + + # create some event workspace + ws = CreateSampleWorkspace(WorkspaceType="Event") + + print "What type is the workspace before 1st rebin: " + str(type(ws)) + # rebin from min to max with size bin = 2 preserving event workspace (default behaviour) + ws = Rebin(ws, 2) + print "What type is the workspace after 1st rebin: " + str(type(ws)) + ws = Rebin(ws, 2, PreserveEvents=False) + print "What type is the workspace after 2nd rebin: " + str(type(ws)) + # note you can also check the type of a workspace using: print isinstance(ws, IEventWorkspace) + + .. testcleanup:: ExEventRebin + + DeleteWorkspace(ws) + + Output: + + .. testoutput:: ExEventRebin + + What type is the workspace before 1st rebin: <class 'mantid.api._api.IEventWorkspace'> + What type is the workspace after 1st rebin: <class 'mantid.api._api.IEventWorkspace'> + What type is the workspace after 2nd rebin: <class 'mantid.api._api.MatrixWorkspace'> + +When needing to load a data file +-------------------------------- + +Instructions to add a new data file to the repository are available `here <DataFilesForTesting.html>`__. Files from the repository will be bundled up into a .zip file, and this .zip made available for download from the Mantid download page. + +If you use files you must add the line + +.. code-block:: rest + + .. include:: ../usagedata-note.txt + +as shown in the example below. This will generate a note to the user explaining how to download the UsageData. + +.. code-block:: rest + + Usage + ----- + + .. include:: ../usagedata-note.txt + + **Example - Load ISIS histogram Nexus file:** + (see :ref:`LoadISISNexus <algm-LoadISISNexus>` for more options) + + .. testcode:: ExLoadISISnexusHist + + # Load ISIS LOQ histogram dataset + ws = Load('LOQ49886.nxs') + + print "The 1st x-value of the first spectrum is: " + str(ws.readX(0)[0]) + + .. testcleanup:: ExLoadISISnexusHist + + DeleteWorkspace(ws) + + Output: + + .. testoutput:: ExLoadISISnexusHist + + The 1st x-value of the first spectrum is: 5.0 + +Running the Tests +================= + +See `here <DocumentationGuideForDevs.html>`__ for how to run and test the usage examples locally. diff --git a/dev-docs/source/Standards/CPPStandards.rst b/dev-docs/source/Standards/CPPStandards.rst new file mode 100644 index 0000000000000000000000000000000000000000..89a81e6236a1b36414f0812b61c0ad6789c411b5 --- /dev/null +++ b/dev-docs/source/Standards/CPPStandards.rst @@ -0,0 +1,378 @@ +.. _CppCodingStandards: + +==================== +C++ Coding Standards +==================== + +.. contents:: Contents + :local: + +References +^^^^^^^^^^ + +- `LLVM Coding standard <http://llvm.org/docs/CodingStandards.html>`__ +- *The C++ Programming Language* (third edition), Bjarne Stroustrup +- `C++ ANSI Standards <http://www.open-std.org/jtc1/sc22/wg21/>`__ + +Overview +^^^^^^^^ + +Mantid follow the LLVM C++ coding standards and standards on this +page. Where these standards overlap the standards on this page take +precedence. + +`This page +<https://github.com/mantidproject/mantid/wiki/clang-format>`__ +describes a tool that you may find useful for checking your code +satisfies LLVM whitespace conventions. It's also useful to set up your +text editor to use `two spaces instead of tabs +<http://llvm.org/docs/CodingStandards.html#use-spaces-instead-of-tabs>`__. + +Files +^^^^^ + +- Header files will use the ``.h`` extension. +- Code body files will use the ``.cpp`` file extension. +- All ``.cpp`` files must have a corresponding ``.h`` file. + +Headers +^^^^^^^ + +Header Files +------------ + +All header files in a project must have a header comment. In many +cases this will be included as part of the class header, but any +header files that do not contain classes must include the same +information as a file header. The information that must be included +is: + +- class description +- Copyright +- GPL license text + +Layout of Header File +--------------------- + +The contents of the header file should be arranged in the following +order: + +- ``#include`` directives in the following order, where each section shold be + sorted alphabetically: + + - Main Module Header + - Mantid Headers from the same project + - Mantid headers from other projects + - 3rd party library headers + - System ``#include`` directives +- Forward declarations of other classes +- Global constants, enumerations & typedefs +- Doxygen class description +- Class definition: + + - Public constants, enumerations & types + - Public constructors & destructors + - Public functions & operators + - Protected functions + - Private constants, enumerations & types + - Private functions + - Private variables + - Bodies of inline functions and (for a template class) member + functions. + +In most cases header files should only contain a single class. The only +exceptions to this should be for internal utility classes, and extremely +small highly related classes such as exception classes. + +CPP file Headers +---------------- + +We will not be including body file headers. The relevant class file +header in the ``.h`` file will suffice. + +Function headers +---------------- + +These will follow the style put forward in the `Doxygen documentation +<http://www.stack.nl/~dimitri/doxygen/docblocks.html>`__. Headers +comments must be included above all functions definitions and should +describe the function, all parameters and returns values as a minimum. + +Where a function is declared in the header file and defined in the +``.cpp`` file the following approach should be taken: + +- The header file need only contain documentation for items that do + not appear in a ``.cpp`` file (e.g. the class itself, member + variables, inlined methods and templated classes). This keeps the + header files compact and easier to read. Brief comments can + optionally be included (as in the example below). + +Example header file function declaration + +.. code-block:: c++ + + /// Creates an instance of an algorithm + IAlgorithm* createAlgorithm(const std::string& algName, const int& version); + +Example CPP file function definition + +.. code-block:: c++ + + /** Creates and initialises an instance of an algorithm + * + * @param algName The name of the algorithm required + * @param version The version of the algorithm + * @return A pointer to the created algorithm + * + * @throw NotFoundError Thrown if algorithm requested is not registered + */ + IAlgorithm* FrameworkManagerImpl::createAlgorithm(const std::string& algName, const int& version) { + IAlgorithm* alg = AlgorithmManager::Instance().create(algName,version).get(); + return alg; + } + +Naming Conventions +^^^^^^^^^^^^^^^^^^ + +Names should be descriptive and meaningful, but not too long (say <20 +characters). This is helped by sensible and consistent (across the +project) use of abbreviations. + +- **Constants** (including static const members): All upper + case. Internal words separated by underscore eg: ``ERROR_NO_DATA`` +- **Classes, namespaces, structs, enums (and enum values) and typedefs**: + PascalCase (First letter upper case, then lower + case. Internal words begin with upper case letter). +- **Function Names**: function names will be in camelCase (starting + with a lower case character and capital for each later word). +- **Variable Names / Type Prefixes**: variables will be given sensible + descriptive names. Type prefixes will not be used. variable names + in Mantid are usually camelCase (starting with a lower case + character and capital for each later word). +- **Scope Prefixes** + - Static member variables use a ``g_`` prefix. + - Non-static member variables use an ``m_`` prefix. +- **Local variables used as integer loop counters** As an exception, + these may use very short names like ``i, j, k, l`` eg. ``for (int + i = 0; i < 5; i++)`` + +Preprocessor +^^^^^^^^^^^^ + +1. Use of the pre-processor should be minimised. Constants and type + aliases should be declared using ``const`` and ``typedef`` rather + than ``#define``, and functions should be used in favour of macros. +2. ``#include`` statements should use quotes (``""``) for inclusion of + Mantid code and angle brackets (``<>``) for system files (this + includes headers from ``Third_Party``) +3. All header files should have guards against repeated inclusion, + with the guard flags named consistently. (See `here + <https://en.wikipedia.org/wiki/Include_guard>`__ for an + explanation) +4. Header files should only include those other header files within + the project that are necessary (e.g. for definition of the base + class). In many cases a forward declaration of the form ``class + CPidClientObject;`` is sufficient, and this helps to avoid cyclical + inclusions of headers. +5. It should be possible to compile each header file + individually. That is, a file consisting solely of ``#include + "header.h"`` should compile without errors. This avoids + undocumented interdependencies between headers. + +Classes and Namespaces +^^^^^^^^^^^^^^^^^^^^^^ + +1. There should be only one class or namespace declared in each header + file. This recommendation should only be relaxed where classes are + closely tied together. +2. There should be only one class or namespace defined per body file + (unless classes are closely tied as in (1) above). All the + definitions for that class/namespace should be in the one file + (unless this yields a source file that is unmanageably large). +3. Data members should be private. Access to data from other classes + should only be through protected or public methods (or by + ‘friends’, but see item 8). Inside a large class, consider + reserving direct access to private data members for a smaller + manageable core of member functions. +4. All constructors for a class must initialise all its member variables + that do not have a default constructor (including primitive and + pointer types). +5. All base classes must have a virtual destructor. + + - This may be disregarded only in exceptional circumstances when + the overhead of a virtual-table would significantly affect + performance. Such a class must not be subclassed, and must be + adequately commented to warn other developers against subclassing + the class. + - In addition, it is recommended that where possible, programming + techniques are used to prevent inheritance of classes with a + non-virtual destructor. While comments may suffice they can + easily be ignored or misunderstood, particularly by inexperienced + developers + +6. Classes’ constructors and destructors must not call their own virtual + member functions, directly or indirectly. (C++ does not resolve such + function calls polymorphically.) +7. Do not define special members functions when they would be + identical to those automatically generated by the compiler. Use ``= + delete`` to remove invalid compiler-generated versions. Consider + following the `rule-of-zero <https://rmf.io/cxx11/rule-of-zero/>`__ + and writing an additional class for resource management. +8. The use of ``friend`` should be avoided and its use requires + justification. As an exception, overloads of the ``<<`` and ``>>`` + operators for serialising the class may be declared as ``friend``. +9. Use of multiple inheritance should be restricted to cases in which + the second and subsequent base classes are all interfaces. (An + interface in this context is a class consisting only of pure virtual + functions.). +10. Virtual inheritance should only be used when the base class + involved is an interface. +11. Unions and bitfields should only be used where essential for + performance, or where required for interfacing with a third party + library. + +Mantid Namespaces +----------------- + +All Mantid code lives within a minimum of a two tiered namespace. The +outer namespace for all Mantid code is Mantid, and this is followed by +a namespace identifying the library that contains the code. Third and +further level namespaces may be used to section code to further +improve readability and maintenance. + +Functions and Variables +^^^^^^^^^^^^^^^^^^^^^^^ + +1. Variables, functions parameters, and function return values must have + explicit types (no defaulting to ``int``). +2. A function declaration should not use ``void`` to indicate an empty + parameter list. +3. Parameters in function prototypes should include names, not just + their types. For example, use ``void eraseRange(int nFirst, int + nLast);`` rather than ``void eraseRange(int, int);`` as this + improves self-documentation. +4. Non-static member functions should be declared ``const`` if logically + they do not alter the state of the class instance. +5. Simple accessor functions may be inline (e.g. ``inline int + getCount() const { return m_nCount;}``). Otherwise, inline + functions should be avoided unless essential for performance. +6. Operators should be overloaded sparingly. Operator overloads should + behave in accordance with the semantics of the operator as applied + to primitive types, or according to established conventions + (e.g. ``<<`` and ``>>`` for serialisation). +7. ‘Magic numbers’ must not be used in the code. Constants and + enumerations must be used instead. + +Expressions and Statements +^^^^^^^^^^^^^^^^^^^^^^^^^^ + +1. Integers should not be cast to Booleans. For example, prefer ``if (x + != 0)`` rather than ``if(x)`` +2. The new style type casting must be used in place of the old C style + type casts. If casting up or down an inheritance hierarchy, use + ``dynamic_cast`` (which performs a run-time type check) rather than + ``static_cast``. +3. Function calls with side effects, and the ``++``/``--``/assignment operators, + should only be called as a standalone statement rather than embedded + inside an expression. + + - It is permissible, although discouraged, to have a function call + with side effects as the right-operand of ``&&`` or ``||``. Any such + instances must be commented in detail to alert other developers to + the fact that the function is not always called. +4. ``for`` and ``while`` loops should not use ``break`` and + ``continue`` where they can be avoided. Where they are required, + comments should draw attention to them as an alternative exit point + from the loop. +5. A ``for`` loop should only have one control variable, and should + not modify it in the body. +6. ``switch`` statements must include a ``default`` clause, even if + only to catch errors. +7. Each ``case`` of a ``switch`` statement must either end with a + ``break``/``return``, or contain a clear comment to alert other + developers to the fact that execution will fall through to the next + case. Multiple ``case`` labels (with no code between them) are, + however, permitted for the same block of code. +8. ``goto`` must be avoided. When there is a need to break out of two + or more nested loops in one go, the loops should be moved to a + separate function where 'return' can be used instead. + +Comments +^^^^^^^^ + +1. Sufficient commenting (to the level mandated by this document) of a + piece of code must be performed at the same time as the code is + written. It must not be put off until the end of development. When + code is updated, all relevant comments must be updated as well + (including those in the header). +2. ‘Dead code’ must not be kept in the source code. (‘Dead code’ here + means code that has been commented out or unconditionally + suppressed in some other way, for example using ``#if 0`` + preprocessor directives.) + + - In the (rare) instances that dead code would serve an important + documentation purpose for ongoing development, the dead code must + be placed in an external location and may be referenced from the + ‘live’ source code. +3. Comments must be indented to the same level as the code to which + they refer. +4. The language used in comments must be professional and to the + point. Flippant or derogatory remarks must be avoided. +5. The collection of comments in a function must, on its own, be + sufficient that a competent C++ developer can pick up the function + for subsequent development. +6. Comments on a single line should use ``//`` rather than ``/* … */``. +7. No code block should exceed 20 statement lines without a comment of + some sort. In general all code should contain 15% comment lines. +8. The style of the comments is not mandated here. However the following + are general recommendations: + + - Comments should always be used to describe potential “difficult†+ sections of code utilising, for example, special algorithms + - Comments should be used in particular to explain branch conditions + in ``if ... else`` and ``switch { case ...``-like statements + - **Comments should be written at a higher level of abstraction + than the code to which they pertain, rather than merely + restating it** + +Error Handling +^^^^^^^^^^^^^^ + +The type of error handling needed depends on what the code is +doing. In daemon / service type of program almost nothing may be +allowed to cause the process to terminate, whereas in some utility +programs it may be acceptable to terminate for many error +conditions. This is a design issue and the strictness of application +of the following should take into account the use of the code. + +1. The developer should identify all errors that can be generated by a + function and ensure that they are dealt with appropriately at some + point in the system. This may be within the function itself or + higher up in the call stack. +2. All exceptions must be caught and handled properly. (This may + include terminating the program cleanly, for instance if no more + memory can be allocated.) +3. Public functions should check their input parameters before using + them. This checking may be made using the ``assert()`` macro or + similar mechanism, and so only checked in the debug build, in which + case comprehensive testing must be performed of the release build. +4. All error status values returned from a function call must be checked + or explicitly ignored. (To explicitly ignore a function call's return + value cast it to void, e.g. ``(void) f(a, b);``) +5. When using ``dynamic_cast`` on a pointer, a check must be made that + the result is not ``null`` (i.e. that the cast was successful). +6. Destructors must not throw any exceptions, directly or indirectly. + (Exceptions encountered while calling destructors during stack + unwinding from an earlier exception will cause immediate program + termination.) +7. Where the language permits it, and where the occurrence of errors + can be identified at coding time (e.g. opening a file), errors + should be trapped on an individual basis, rather than using a + catch-all error handler. +8. Error messages displayed to the user must be understandable and + informative. They must suggest an action to the user, which will + resolve the problem, for example: + + - No further action is required. + - Check the XYZ input data and then repeat the process. + - Contact the system administrator. diff --git a/dev-docs/source/Standards/DocumentationGuideForDevs.rst b/dev-docs/source/Standards/DocumentationGuideForDevs.rst new file mode 100644 index 0000000000000000000000000000000000000000..a022439e85589f6dab17661f6fb862f058d534d2 --- /dev/null +++ b/dev-docs/source/Standards/DocumentationGuideForDevs.rst @@ -0,0 +1,249 @@ +.. _DocumentationGuideForDevs: + +============================ +Documentation Guide for Devs +============================ + +.. contents:: + :local: + +Rationale +========= + +The algorithm documentation approach aims to: + +#. Keep .cpp files clean and easy to maintain. +#. Make the documentation files easier to edit, supporting the use of external editors. +#. Simplify the Mantid documentation workflow. + +To do this we have harmonised most of our documentation workflow to use sphinx, extended a bit by some Mantid custom tag extensions. + +Prerequisites +============= + +The documentation build requires: + +Sphinx +------ + +* `Sphinx <http://www.sphinx-doc.org/en/master/>`__ +* `Sphinx bootstrap theme <https://pypi.python.org/pypi/sphinx-bootstrap-theme/>`__ + +These are bundled with the Python distrbution on Windows but other platforms will need to install them following the installation instructions `here <https://github.com/mantidproject/mantid/blob/master/docs/README.md>`__. It is recommended that ``pip`` is used over ``easy_install``. + +LaTeX +----- + +To view the equations built with the documentation you will need an installation of LaTeX on your system. + +Linux +##### + +If you have installed the mantid-develop package then you should have a working latex distribution. If not, use your package manager and search for a suitable candidate, most likely named something like ``texlive``. + +MacOS +##### + +See `here <http://tug.org/mactex/>`__ for instructions on installing ``MacTeX``. + +Windows +####### + +Download and install ``MikTeX`` from `here <https://miktex.org/download>`__. + +During installation there will be a question with a drop-down box relating to installing packages on demand - make sure "Ask first" is selected. + +The first build of one of the ``docs-*`` targets after ``MikTeX`` has installed will raise a dialog, similar to this asking you if it is okay to install a package. For developers behind a proxy you will need to click on the "Change" button and enter the proxy information and select a new download location on the set of dialogs that appear before returning back to the main dialog. Check the box saying don't ask again and click install. + +reST editors/IDE plugins +======================== + +Several free & proprietary editors support syntax-highlighting reST. A list of the most notable ones can be found `here <https://stackoverflow.com/questions/2746692/restructuredtext-tool-support>`__. + +Restview +-------- + +A really handy tool whilst writing out .rst files is `restview <https://pypi.python.org/pypi/restview>`__ which can be easily installed using ``pip``. It opens a webpage with the rst file processed and refreshes the page automatically whenever the .rst file is saved. This can help you quickly track down that unexpected space or missing newline without having to rebuild the documentation each time. It does not support sphinx directives so links will produce errors on the page which need to be checked by building the documentation using Mantid. The syntax to use it is: + +``restview path/to/file.rst`` + +The reStructuredText File +========================= + +`reStructuredText <http://docutils.sourceforge.net/rst.html>`__ is a markup format and is converted into themed html pages using Sphinx. A primer on reStructuredText can be found here along with a single-page cheat sheet. + +The source files are .rst files which are located in the ``docs/source`` directory in the repository. There are various subdirectories based on the type of object being documented, i.e. ``docs/source/algorithms``, ``docs/source/functions``. + +The documentation pages is aimed at *users*, not developers, and all information should be targeted for the users. Information for developers should go into doxygen/code-comments in the code or into ``dev-docs``. + +Directives +---------- + +Sphinx is built on the ``docutils`` package that allows for directives to be inserted in to reST comments. For example: + +.. code-block:: rest + + .. warning:: + This text will show up surrounded by a coloured box. + +tells sphinx to treat the the given text differently and flag it so that a user will see it as a warning. The name of the directive is ``warning`` and the ``..`` is a reST comment syntax. The directive name must be followed by ``::`` so that Sphinx process knows it has a directive command and not just plain text. For a list of directives known to Sphinx, see `here <http://www.sphinx-doc.org/en/master/rest.html#directives>`__. + +Comments +-------- + +If you wish to place comments in the reST file that will not be rendered anywhere then start the line/block with ``..``. See `here <http://sphinx-doc.org/rest.html#comments>`__ for more details. + +Algorithms +---------- + +The algorithm documentation has a slightly more rigid structure and is described in more detail `here <AlgorithmDocumentation.html>`__ and `here <AlgorithmUsageExamples.html>`__. + +Interfaces +---------- + +For documenting custom interfaces, it is recommended that you consult `this <InterfaceDocumentation.html>`__ page, which explains how to document them, and which directives may be used in more detail. + +How to define titles, sections etc. +----------------------------------- + +The syntax for headers in restructuredText is the header followed by a line containing symbols such as hyphens. It is possible to use different punctuation to create headers but within the Mantid .rst files we standardize on the characters used as follows: + +The title of the page + Should be the first header of your .rst file, and generally only occur once. (This is done for you in an algorithm with the ``.. algorithm::`` directive) + +.. code-block:: rest + + ============================================= + Page title (e.g. Workspace) - This outputs H1 + ============================================= + +Section headings + Sections, such as the description of an algorithm, can be created with the following syntax + +.. code-block:: rest + + # Description - This outputs H2 + ------------------------------- + +Sub-sections + The following is used to create a sub-section of the above section. This must follow after the above to be parsed correctly. + +.. code-block:: rest + + Sub-heading - This outputs h3 + ############################# + +Sub-sub-sections + The following is used to create a sub-header for the sub-heading above. This must also follow after the above header to be parsed correctly. + +.. code-block:: rest + + Sub-sub-heading - Outputs h4 + ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Things to Avoid +=============== + +If you have weird messages about sphinx warnings that happen on “Console outputâ€, those are coming either from summary functions in algorithms or from parameter descriptions. In these + +* *Do not* use ``*`` in parameter names or summary. This yields “Inline emphasis start-string without end-string†warnings. +* *Do not* use things like ``|Q|``. This yields sphinx error “Undefined substitution referencedâ€. +* When using hyperlinks with a label, try to use anonymous hyperlinks (two underscores instead of one) to avoid name clashes. + * ```MD <http://mysite.com/MD1.html>`__`` and ```MD <http://mysite.com/MD2.html>`__`` instead of ```MD <http://mysite.com/MD1.html>`_`` and ```MD <http://mysite.com/MD2.html>`_``. The second on will result in a warning. + +Common Warnings and Fixes +------------------------- + +While building the final output, Sphinx will emit warning messages if it things the input restructured text is malformed. This section lists some more common warnings along with suggestions for fixes. + +Explicit markup ends without a blank line; unexpected unindent. +############################################################### + +This is caused by the lack of a blank line between an indented explicit markup block and more unindented text, e.g. + +.. code-block:: rest + + .. testcode:: ExHist + + print "This is a test" + Output: <------------- There should be a blank line above this + + .. testoutput:: ExHist + +It can be fixed by having a blank line between the indented block and the unindented text. + +Inline interpreted text or phrase reference start-string without end-string +########################################################################### + +This is caused by using one of the `inline markup tags <http://www.sphinx-doc.org/en/master/rest.html#inline-markup>`__, where the text being wrapped splits over multiple lines. In these cases the directive variant of the inline markup should be used. One example is the ``:math:`` tag being spread over multiple lines. The tag ``:math:`` must only be used for inline markup, i.e. when there is no newline in the math string. For multi-line maths markup you must use the ``.. math::`` directive instead. + +.. code-block:: rest + + :math:`\rm U \rm B \left( + \begin{array}{c} + h_i \\ + k_i \\ + l_i \\ + \end{array} + \right) = \rm Q_{gon,i}` (1) + +should be written + +.. code-block:: rest + + .. math:: + <------------------ intentional blank line + \rm U \rm B \left( + \begin{array}{c} + h_i \\ + k_i \\ + l_i \\ + \end{array} + \right) = \rm Q_{gon,i} (1) + <------------------ intentional blank line + +where there is an explicit blank line after the final line of latex. See `here <http://sphinx-doc.org/ext/math.html>`__ for more information. + +image file not readable +####################### + +This indicates the that image referenced by ``.. image::`` or ``.. figure::`` cannot be accessed. Either the image is not there or the reference is incorrect. + +Image links in Sphinx are either relative, in which case it is relative to the current document or absolute in which case the path is assumed relative to the root of the source tree (the directory containing the conf.py) + +Unknown directive type "foo" +############################ + +Sphinx has encountered a line starting with ``.. foo::``, where ``foo`` is expected to be a known directive. + +The fix is to correct the name of the directive. + +Warnings on console (in the build servers) +########################################## + +These type of errors occur in the summary function and/or in documentation of parameters in the init function. See `Things to Avoid`_. + +Running documentation tests locally +=================================== + +The usage tests are executed using a driver script, ``runsphinx_doctest.py``, that is generated by CMake in the ``docs`` directory. A top-level target, ``docs-test``, is created for each generator that invokes the script without any arguments and subsequently executes all of the available usage tests. + +The driver script has been written to accept additional arguments in order to be able to limit the number of tests that are executed. To run a subset of the available tests, the script must be called manually and supplied with the ``-R TESTREGEX`` argument. The regex is applied to the filename of the document and will match anywhere within the name. The script can be called using either a plain Python interpreter or the MantidPlot executable. If using a plain Python interpreter then you will need to either have your ``PYTHONPATH`` set to find the ``mantid`` module or you can provide the ``-m MANTIDPATH`` option to have the script find the module for you. + +It is recommended that the tests are run with MantidPlot as this is the easiest way to be sure that they are being run with the current build copy. As an example, to run any files that have Rebin in the filename you would type (assuming you are in the build directory): + +:: + + bin/MantidPlot -xq docs/runsphinx_doctest.py -R Rebin + +or with vanilla python + +:: + + python docs/runsphinx_doctest.py -m $PWD/bin -R Rebin + +For multi-configuration generators such as Visual Studio or XCode you will need to pick the configuration by choosing the apporiate directory, e.g. for MSVC debug (remembering that the slashes need to be backslash and not forward slash): + +:: + + bin\Debug\MantidPlot -xq docs\runsphinx_doctest.py -R Rebin diff --git a/dev-docs/source/Standards/InterfaceDocumentation.rst b/dev-docs/source/Standards/InterfaceDocumentation.rst new file mode 100644 index 0000000000000000000000000000000000000000..1e49cbb60f01c4148f95f1665f3a1f07918d55f5 --- /dev/null +++ b/dev-docs/source/Standards/InterfaceDocumentation.rst @@ -0,0 +1,53 @@ +.. _InterfaceDocumentation: + +======================= +Interface Documentation +======================= + +.. contents:: + :local: + +Summary +======= + +This page deals with the specifics of how to document Custom Interfaces. For a more general guide to the Mantid documentation system see `Documentation Guide For Devs <DocumentationGuideForDevs.html>`__. + +The ``interface`` Directive +=========================== + +This directive allows you to insert a screenshot of the interface into the documentation. It has one required argument: the name of the interface, as given by the interface's ``name()`` method. Several options, detailed below, may also be provided to further control the behaviour of this directive. + +The inserted screenshots are generated automatically when the documentation is being compiled. This is preferable to screenshots taken manually as these will automatically stay up to date. + +Options +------- + +widget + You can give the name of a widget in the interface to only take a screenshot of that widget. If not given, a screenshot of the entire interface will be inserted. + +align + This specifies the alignment to use for the screenshot. Valid settings are *left*, *center*, and *right*. Defaults to *center*. + +Examples +======== + +This inserts a screenshot of the Muon Analysis interface: + +.. code-block:: rest + + .. interface:: Muon Analysis + +This inserts a screenshot of the Muon Analysis interface's Grouping Options tab: + +.. code-block:: rest + + .. interface:: Muon Analysis + :widget: GroupingOptions + +This inserts a screenshot of the main table in the ISIS Reflectometry custom interface, aligned to the right: + +.. code-block:: rest + + .. interface:: ISIS Reflectometry + :widget: viewTable + :align: right diff --git a/dev-docs/source/Standards/Libraries.rst b/dev-docs/source/Standards/Libraries.rst new file mode 100644 index 0000000000000000000000000000000000000000..391175de080f0403e08b36a239af3187098e9bf1 --- /dev/null +++ b/dev-docs/source/Standards/Libraries.rst @@ -0,0 +1,53 @@ +.. _Libraries: + +========= +Libraries +========= + +.. contents:: Contents + :local: + +Summary +^^^^^^^ + +This page describes the preferred libraries used with the Mantid code +base. + +General +^^^^^^^ + +- Use libraries from `std <http://en.cppreference.com/w/cpp>`_ where possible. +- `Boost <http://www.boost.org>`_ header-only libraries are also + always available. The following compiled Boost libraries are + available: + + - regex + - date_time + - python + - serialization + - others required must be discussed with the TSC + +- Eigen is used for fast linear algebra calculations +- Poco is also used for: + + - asynchronous method support + - application configuration + - logging + - path handling (will eventually be replaced by std::filesystem) + - networking + - XML parsing + +Specific Recommendations +^^^^^^^^^^^^^^^^^^^^^^^^ + +Regex +----- + +Prefer ``boost::regex`` over ``std::regex`` (bugs in ``std::regex`` +until gcc 5 and some platforms still use gcc 4.8) + +String Algorithms (chop, ends_with etc) +--------------------------------------- + +- Prefer Boost algorithms if possible +- Some string utilities also exist in ``MantidKernel/Strings.h`` diff --git a/dev-docs/source/Standards/MantidStandards.rst b/dev-docs/source/Standards/MantidStandards.rst new file mode 100644 index 0000000000000000000000000000000000000000..adfa95c3beecd23abf4a54afb0fd2f2394b5ca90 --- /dev/null +++ b/dev-docs/source/Standards/MantidStandards.rst @@ -0,0 +1,119 @@ +================ +Mantid Standards +================ + +These standards relate specifically to the implementation of the +Mantid framework and the MantidPlot application. + +.. contents:: Contents + :local: + +General Notes on Naming +^^^^^^^^^^^^^^^^^^^^^^^ + +The items described on this page form part of the public interface to +Mantid, which means that their names are hard to change once they are +out in the wild. As naming is one of the most difficult tasks to `do +well <http://martinfowler.com/bliki/TwoHardThings.html>`_, it is +important to take time and care when choosing a name. Some guidance on +naming in a more code-related context can be found `here +<http://blog.codinghorror.com/i-shall-call-it-somethingmanager/>`_ but +the advice should still be applicable to naming Mantid concepts. + +Algorithms +^^^^^^^^^^ + +Standards to follow when implementing an `algorithm +<http://docs.mantidproject.org/nightly/concepts/Algorithm.html>`_ in +both C++ and Python. + +Naming +------ + +Algorithm names start with a capital letter and have a capital letter +for each new word, with no underscores. Use alphabet and numeric +characters only. Numbers are only allowed after the first character. + +Names should be descriptive but not too long (max 20 chars). If +possible, avoid abbreviations unless they are common and well +understood. To avoid a proliferation of different synonyms for +algorithms that have a common goal, e.g. Create... vs Generate..., we +standardise on a set of prefixes for common tasks: + ++-----------------------------------------------------------------------+------------------+--------------------+ +| Task | Preferred Prefix | Example | ++=======================================================================+==================+====================+ +| Creating a new object, e.g. workspace, with exception of file loaders | Create | CreateMDWorkspace | ++-----------------------------------------------------------------------+------------------+--------------------+ +| Loading a file | Load | LoadMappingTable | ++-----------------------------------------------------------------------+------------------+--------------------+ +| Applying a value to an existing object, e.g set UB matrix | Set | SetUB | ++-----------------------------------------------------------------------+------------------+--------------------+ +| Retrieve a value, e.g. Ei | Get | GetDetectorOffsets | ++-----------------------------------------------------------------------+------------------+--------------------+ +| Adding a new item to an existing list | Add | AddSampleLog | ++-----------------------------------------------------------------------+------------------+--------------------+ +| Search for something, e.g. peaks | Find | FindPeaks | ++-----------------------------------------------------------------------+------------------+--------------------+ + +Categories +---------- + +Plain english using `Title Case +<http://www.grammar-monster.com/lessons/capital_letters_title_case.htm>`_. Connecting +words should have lower case first letters. Use alphabet characters +only, numbers are not allowed, e.g. Muon or SANS. + +Properties +---------- + +Property names start with a capital letter and have a capital letter +for each new word, with no underscores. Use alphabet and numeric +characters only. Numbers are only allowed after the first character. + +Wherever possible and unambiguous, the primary input workspace should +be called ``InputWorkspace`` and the primary output workspace should +be called ``OutputWorkspace``. An algorithm with a single In/Out +workspace should name its property ``Workspace``. Certain groups of +algorithms have other standards to adhere to. + +Fit Functions +^^^^^^^^^^^^^ + +Standards to following when implementing a fitting function (both C++ +& Python). + +Naming +------ + +Function names start with a capital letter and have a capital letter +for each new word, with no underscores. Use alphabet and numeric +characters only. Numbers are only allowed after the first character. + + +Categories +---------- + +Plain english using `Title Case +<http://www.grammar-monster.com/lessons/capital_letters_title_case.htm>`_. Connecting +words should have lower case first letters. Numbers are not allowed. + +Parameters +---------- + +Parameter names must: + +- Start with a capital letter +- Have a capital letter for each new word (e.g. 'InputWorkspace') +- Use alphanumeric characters only (i.e. cannot contain any of these ``/,._-'\"`` or whitespace) +- Can contain numbers but only allowed after the first character. + +Notable exceptions to these rules are lattice constants (i.e. a, b, c, +alpha, beta, gamma). + +Workspace Names +^^^^^^^^^^^^^^^ + +No firm restrictions. The use of two underscores as a prefix will mark +the workspace as hidden. It is recommended to use only the alphabet, +numeric and the underscore characters. diff --git a/dev-docs/source/Standards/PythonStandards.rst b/dev-docs/source/Standards/PythonStandards.rst new file mode 100644 index 0000000000000000000000000000000000000000..605cb141fb1b2d304da235dd770f7cac3cdbb2af --- /dev/null +++ b/dev-docs/source/Standards/PythonStandards.rst @@ -0,0 +1,65 @@ +======================= +Python Coding Standards +======================= + +.. contents:: Contents + :local: + +Style +^^^^^ + +- Unless otherwise specified, follow `PEP 8 + <https://www.python.org/dev/peps/pep-0008>`_; this means using + `snake_case <https://en.wikipedia.org/wiki/Snake_case>`_ +- Use `flake8 <http://flake8.pycqa.org/en/latest>`_ to check + for problems in this area. Remember that PEP 8 is only a guide, so + respect the style of the surrounding code as a primary goal +- Always use four spaces for indentation +- For docstrings please follow `Docstring Conventions PEP 257 + <https://www.python.org/dev/peps/pep-0257>`_ and document code to + aid `sphinx + <https://pythonhosted.org/an_example_pypi_project/sphinx.html#full-code-example>`_ + +None checks +----------- + +Prefer ``if obj is not None:`` over ``if obj:``. The latter invokes +``object.__nonzero__`` whereas the former simply compares that obj +references the same object as ``None``. + +Imports +------- + +Imports should be grouped in the following order: + +1. stdlib +2. third party libraries +3. local modules + +Each group should be alphabetically sorted and separate by a newline, e.g. + +.. code-block:: python + + import sys + + from qtpy.QtWidgets import QMainWindow + + from mypackage.subpkg import MyClass + +Python/Qt +^^^^^^^^^ + +Use the `qtpy <https://pypi.python.org/pypi/QtPy>`_ module to hide the +differences between PyQt versions. When working with signals, use the +new style. For naming new custom signals, use the ``sig_`` prefix: + +.. code-block:: python + + from qtpy.QtCore import Signal + ... + + class MyWidget(...): + """Funky new widget""" + + # Signals + sig_run_a_thing_happened = Signal(str, str, str, bool, bool) diff --git a/dev-docs/source/Standards/UnitTestStandards.rst b/dev-docs/source/Standards/UnitTestStandards.rst new file mode 100644 index 0000000000000000000000000000000000000000..04c82103bbe978cd21506f636321e904f2834976 --- /dev/null +++ b/dev-docs/source/Standards/UnitTestStandards.rst @@ -0,0 +1,25 @@ +.. _UnitTestCodingStandards: + +========================== +Unit Test Coding Standards +========================== + +The code for unit test classes should follow the standards as set out +in :ref:`CppCodingStandards` with the following differences. + +- The file and class name should be of the form ``ClassNameTest``, for + example ``WorkspaceTest``, ``LoggerTest`` +- Test classes do not need to be included in a namespace. +- Test methods within the test classes must start with the word 'test' + and then describe the test. For example ``test_readXValues``, + ``test_invalidLogString`` +- Other utility methods may be used in test classes but must not start + with the word test +- During debugging Test methods may be disabled by prefixing the + method name with 'x'. However if any disabled tests are to be + checked in this must be accompanied with comments explaining why the + test is disabled and when it may be enabled again. +- Code headers are not required if the above standards are met as the + use of the class will be obvious from the class name and method + names. + diff --git a/dev-docs/source/Standards/index.rst b/dev-docs/source/Standards/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..20709a3f984ff07e6e82d93b1a044750509481ac --- /dev/null +++ b/dev-docs/source/Standards/index.rst @@ -0,0 +1,44 @@ +.. _Standards: + +========= +Standards +========= + +Coding Standards +---------------- + +Coding standards are vital for creating a maintainable and extensible +system. However in order for them to be effective they have to be +accepted and supported by the entire development team. + +Code produced by code generators is not covered directly by this +procedure. Programmers must apply the underlying principles of this +procedure in a sensible manner to code generated automatically. + +.. toctree:: + :maxdepth: 1 + + MantidStandards + CPPStandards + UnitTestStandards + PythonStandards + +Documentation Standards +----------------------- + +.. toctree:: + :maxdepth: 1 + + DocumentationGuideForDevs + AlgorithmDocumentation + AlgorithmUsageExamples + InterfaceDocumentation + + +Guidelines +---------- + +.. toctree:: + :maxdepth: 1 + + Libraries diff --git a/dev-docs/source/SystemTests.rst b/dev-docs/source/SystemTests.rst new file mode 100644 index 0000000000000000000000000000000000000000..faf2276d5cd16cf94279d625c05ff6d240e861e4 --- /dev/null +++ b/dev-docs/source/SystemTests.rst @@ -0,0 +1,228 @@ +.. _SystemTests: + +============ +System Tests +============ + +.. contents:: + :local: + +Overview +######## + +System tests are high-level tests, which check that Mantid is able to +reproduce accepted, standardised results as part of its calculations, +when executing user stories. The system test suite is written against +Mantid's Python API. + +As part of our nightly-build and nightly-test procedure, Mantid's system +tests are run as acceptance tests. The nightly-test jobs deploy a +packaged version of Mantid to the target OS, before executing the system +tests scripts on that environment. + +Writing a Test +############## + +The (python) code for the system tests can be found in the git +repository at +`mantidproject/mantid <http://github.com/mantidproject/mantid>`__, under +the ``Testing/SystemTests`` directory. + +Like their 'stress' equivalents (`stress testing <Stress_Tests>`__), +system tests inherit from the stresstesting.MantidStressTest class. The +methods that need to be overridden are ``runTest(self)``, where the +python code that runs the test should be placed, and ``validate(self)``, +which should simply return a pair of strings: the name of the final +workspace that results from the ``runTest`` method and the name of a +nexus file that should be saved in the ReferenceResults sub-directory in +the repository. The test code itself is likely to be the output of a +*Save History* command, though it can be any python code. In the +unlikely case of files being used during a system test, implement the +method ``requiredFiles`` which should return a list of filenames without +paths. The file to validate against should be included as well. If any +of those files are missing the test will be marked as skipped. + +The tests should be added to the ``Testing/SystemTests/tests/analysis``, +with the template result going in the ``reference`` sub-folder. It will +then be included in the suite of tests from the following night. + +Specifying Validation +--------------------- + +You may need to inform the System Test Suite about the format of that +the benchmark workspace you wish to validate against. By default, the +system tests assume that the second argument returned by the validate +tuple is the name of a nexus file to validate against. However you can +override the validateMethod on a test with any one of three options. + +- WorkspaceToNexus (Benchmark workspace is stored as a Nexus file) + (default) +- WorkspaceToWorkspace (Benchmark workspace is stored as a workspace) +- ValidateAscii (Benchmark workspace is stored as an ascii file) + +For example: + +.. code-block:: python + + def validateMethod(self): + return 'WorkspaceToNeXus' + +No Workspace Validation +----------------------- + +If the system test does not need comparison/validation against a +standard workpace, then this step can be skipped. Simply omitting the + +.. code-block:: python + + def validate(self): + +method from the system test is sufficient. + +Skipping tests +-------------- + +Tests can be skipped based on arbitrary criteria by implementing the +``skipTests`` method and returning True if your criteria are met, and +False otherwise. Examples are the availability of a data file or of +certain python modules (e.g. for the XML validation tests). + +Target Platform Based on Free Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some tests consume a large amount memory resources, and are therefore +best executed on hardware where enough memory is available. You can set +a minimum RAM specification by overriding requiredMemoryMB: + +.. code-block:: python + + def requiredMemoryMB(self): + return 2000 + +The above function limits the test to run on a machine where there is at +least 2GB of free memory. + +Target Platform Based on Free Memory +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Some tests require very large files that cannot be placed in the shared +repository. The ``requiredFiles()`` method returns a list of these files +so that they test can check that they are all available. If all files +are not available then the tests are skipped. + +.. code-block:: python + + def requiredFiles(self): + return ['a.nxs', 'b.nxs'] + +The above function limits the test to run on a machine that can find the +files 'a.nxs' & 'b.nxs' + +Set the Tolerance +----------------- + +You may specialise the tolerance used by ``CompareWorkspace`` in your +system test. + +.. code-block:: python + + self.tolerance = 0.00000001 + +Disable Some Checks +------------------- + +You may disable some checks performed by the ``CompareWorkspaces`` +algorithm by appending them to the disableChecking list, which, by +default, is empty. + +.. code-block:: python + + # A list of things not to check when validating + self.disableChecking = [] + +Assertions +---------- + +Additional assertions can be used as the basis for your own comparison +tests. The following assertions are already implemented in the base +class. + +.. code-block:: python + + def assertTrue(self, value, msg=""): + def assertEqual(self, value, expected, msg=""): + def assertDelta(self, value, expected, delta, msg=""): + def assertLessThan(self, value, expected, msg=""): + def assertGreaterThan(self, value, expected, msg=""): + +Running Tests Locally +##################### + +CMake configures a script file called ``systemtest`` (``systemtest.bat`` +on Windows) in the root of the build directory. This file is the driver +script to execute the system tests that runs the lower-level +``Testing/SystemTests/scripts/runSystemTests.py`` script but ensures +that the environment is set up correctly for that particular build and +that the required test data has been updated. The script accepts a +``-h`` option to print out the standard usage information. + +Usage differs depending on whether you are using a single-configuration +generator with CMake, for example Makefiles/Ninja, or a +multi-configuration generator such as Visual Studio or Xcode. + +Visual Studio/Xcode +------------------- + +The user must first open command-prompt from, the build directory. The +script requires the developer to select the configuration that will be +used to execute the tests, one of: *Release*, *Debug*, *RelWithDebInfo* +or 'MinSizeRelease''. Note that the script does not build the code so +the chosen configuration must have already been built. An example to +execute all of the tests for the release configuration would be (in the +command-prompt): + +.. code-block:: sh + + > systemtest -C Release + +Makefile-like Generators +------------------------ + +The script requires no additional arguments as the configuration is +fixed when running CMake, e.g. + +.. code-block:: sh + + cd build + systemtest + +Selecting Tests To Run +---------------------- + +The most important option on the script is the ``-R`` option. This +restricts the tests that will run to those that match the given regex, +e.g. + +.. code-block:: sh + + cd build + systemtest -R SNS + # or for msvc/xcode + systemtest -C <cfg> -R SNS + +would run all of the tests whose name contains SNS. + +Adding New Data & References Files +---------------------------------- + +The data is managed by CMake's external data system that is described by +`Data_Files_in_Mantid <Data_Files_in_Mantid>`__. Please see `Adding a +new file <Data_Files_in_Mantid#Adding_A_New_File>`__ for how to add new +files. + +Best Practice +############# + +- Always check your test works locally before making it public. +- User stories should come from the users themselves where possible. +- Take care to set the tolerance to an acceptable level. diff --git a/dev-docs/source/TSC.rst b/dev-docs/source/TSC.rst new file mode 100644 index 0000000000000000000000000000000000000000..dcab065a261074c5a96fbfde823d4d495ce5c7e4 --- /dev/null +++ b/dev-docs/source/TSC.rst @@ -0,0 +1,13 @@ +.. _TSC: + +============================ +Technical Steering Committee +============================ + +Please see the `TSC terms <https://github.com/mantidproject/documents/blob/master/Project-Management/TechnicalSteeringCommittee/TSC-Terms.md>`__ +for a description of the aims of this committee including a list of current members. + +Contact email: mantid-tech@mantidproject.org + +Minutes and reports from Technical Steering Committee meetings can be found +`here <http://github.com/mantidproject/documents/tree/master/Project-Management/TechnicalSteeringCommittee>`__. diff --git a/dev-docs/source/TestingUtilities.rst b/dev-docs/source/TestingUtilities.rst new file mode 100644 index 0000000000000000000000000000000000000000..5f109ed05d074c0a0a159fb286bec3ed61d5bb5d --- /dev/null +++ b/dev-docs/source/TestingUtilities.rst @@ -0,0 +1,50 @@ +.. _TestingUtilities: + +================= +Testing Utilities +================= + +.. contents:: + :local: + +Summary +####### + +This page will provide developers with details of testing utilities, such as helper files, which are +useful in creating unit tests. + + +Helper Functions +################ + +C++ +--- + +The following helper files have been found in the +`Mantid/Framework/TestHelpers <http://github.com/mantidproject/mantid/tree/master/Framework/TestHelpers>`__ +package: + +- `BinaryOperationMDTestHelper <http://doxygen.mantidproject.org/d1/d4f/namespaceBinaryOperationMDTestHelper.html>`__ +- ComponentCreationHelper + `ComponentCreationHelper <http://doxygen.mantidproject.org/d8/d8d/namespaceComponentCreationHelper.html>`__ + This creates instrument components that can then be used in a unit test. +- ICatTestHelper +- `MDEventsTestHelper <http://doxygen.mantidproject.org/d5/d75/namespaceMantid_1_1MDEvents_1_1MDEventsTestHelper.html>`__ +- `SANSInstrumentCreationHelper <http://doxygen.mantidproject.org/d9/dbf/classSANSInstrumentCreationHelper.html>`__ +- `ScopedFileHelper <http://doxygen.mantidproject.org/d7/d7f/classScopedFileHelper_1_1ScopedFile.html#details>`__ + This creates a file that is automatically deleted when no longer needed. +- `WorkspaceCreationHelper <http://doxygen.mantidproject.org/d1/db6/namespaceWorkspaceCreationHelper.html>`__ + This creates simple workspaces that can be used in a unit test. One of these workspaces has a full instrument. + +Python +------ + +There are some ``testhelpers`` which are only available in Python, they can +be found in the ``testhelpers``-package. + +- ``make_decorator`` - A function that returns a decorator for an + algorithm without executing it. +- ``TemporaryFileHelper`` - A class that creates named temporary files + and deletes them automatically when the object is deleted. Basically + a thin wrapper around `NamedTemporaryFile <https://docs.python.org/2/library/tempfile.html>`__ + from the tempfile package. diff --git a/dev-docs/source/ToolsOverview.rst b/dev-docs/source/ToolsOverview.rst new file mode 100644 index 0000000000000000000000000000000000000000..f16eee15b303e123baea71e4448fd61b57996d75 --- /dev/null +++ b/dev-docs/source/ToolsOverview.rst @@ -0,0 +1,161 @@ +.. _ToolsOverview: + +============== +Tools Overview +============== + +Creating classes: class_maker.py +-------------------------------- + +**To make it faster to create a new class**. This is a small python +script located in /buildconfig/. It generates the .cpp, .h and test +files for a class along with some code stubs. It can also flesh out more +methods for new Algorithms, using the "--alg" option. + +:: + + usage: class_maker.py [-h] [--force] [--test] [--alg] SUBPROJECT CLASSNAME + Utility to create Mantid class files: header, source and test. + positional arguments: +  SUBPROJECT  The subproject under Framework/; e.g. Kernel +  CLASSNAME   Name of the class to create + optional arguments: +  -h, --help  show this help message and exit +  --force     Force overwriting existing files. Use with caution! +  --test      Create only the test file. +  --alg       Create an Algorithm stub. This adds some methods common to +              algorithms. + +Moving/Renaming classes: move_class.py +-------------------------------------- + +This python script is located in in /buidconfig/. It will move a class +from one subproject to another and/or rename the class. Namespaces and +cmakelists are adjusted. For details, run: + +``buildconfig/move_class.py --help`` + +Deleting a class: delete_class.py +--------------------------------- + +This python script is located in in /buildconfig/. It will delete a +class from one subproject. CMakeList.txt is adjusted. For details, run: + +``buildconfig/delete_class.py --help`` + +Leak checking etc +----------------- + +Linux +~~~~~ + +`Memcheck <http://valgrind.org/docs/manual/mc-manual.html>`__ + +- Keeps track of allocs/deallocs and reports anything missing at exit. +- Slow but thorough +- Useful options to run with + +``valgrind --tool=memcheck --leak-check=full --show-reachable=yes --num-callers=20 --track-fds=yes --track-origins=yes --freelist-vol=500000000 ``\ \ `` [args...]`` + +Windows +~~~~~~~ + +`Visual Leak Detector <https://vld.codeplex.com/releases>`__ + +#. Setup the additional paths as defined in the readme file +#. Adjust the configuration file, "C:\Program Files\Visual Leak + Detector\vld.ini" to output to both File and debugger by changing the + ``ReportTo`` to + +``ReportTo = both`` + +#. Add #include <vld.h> to the system.h file in Kernel +#. Compile everything in debug +#. Running unit tests should now create a file memory_leak_report.txt in + the test directory. +#. IMPORTANT remove the #include <vld.ini> before checking in. + +Thread checking +--------------- + +`Helgrind <http://valgrind.org/docs/manual/hg-manual.html>`__ or `drd <http://valgrind.org/docs/manual/drd-manual.html>`__ +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Identifies race conditions & dead-locks +- Slow but accurate +- A pain to get working with OpenMP. GCC must be recompiled to use a different call to create OMP threads or helgrind/drd cannot "see" the thread calls. Use this `script <https://github.com/UCSCSlang/Adversarial-Helgrind/raw/master/drd/scripts/download-and-build-gcc>`__ to recompile the same version off gcc that is onyour system. The script will need editing to change the appropriate variables. + +Profiling +--------- + +.. _linux-1: + +Linux +~~~~~ + +`Callgrind/KCachegrind <http://kcachegrind.sourceforge.net/cgi-bin/show.cgi/KcacheGrindIndex>`__ + +- KCachegrind visualizes callgrind output. +- See :ref:`Profiling With Valgrind <ProfilingWithValgrind>` for help on + running callgrind + +`gperftools <https://github.com/gperftools/gperftools>`__ + +- Takes snapshot of run and prints percentage of calls in functions + +See here for a list of other tools: +http://www.pixelbeat.org/programming/profiling/ + +.. _windows-1: + +Windows +~~~~~~~ + +`Very Sleepy <http://www.codersnotes.com/sleepy/>`__ (Windows): + +- Start/stop recording of program using a button +- Not as detailed or flexible as callgrind + +IWYU +---- + +`include what you +use <https://code.google.com/p/include-what-you-use/>`__ (iwyu) is a +clang-based tool for determining what include statements are needed in +C/C++ files. Below are instructions for getting it to run with mantid on +linux which is a filled in version of `this +bug <https://code.google.com/p/include-what-you-use/issues/detail?id=164>`__. + +#. Install the software. The version available from system installs + should be fine (e.g. yum or apt-get). +#. Get a copy of + `iwyu_tool.py <https://code.google.com/p/include-what-you-use/source/browse/trunk/iwyu_tool.py>`__ + which is in the project's repository, but may not be installed if you + got it from your operating system locations (e.g. yum). +#. Run ``cmake -DCMAKE_EXPORT_COMPILE_COMMANDS=TRUE``. This will + generate an extra file, ``compile_commands.json``, in your build area + which has instructions on compiling every file in mantid. +#. Run :literal:`iwyu_tool.py -p `pwd` 2> iwyu.log` to generate the + report of changes redirecting into the file ``iwyu.log``. This will + take a long time since it is going through the whole repository. If + you want it for a single file, then supply that as an additional + argument with full path. Only one file can be supplied at a time. +#. Run ``fix_includes < iwyu.log`` and compile the results. Depending on + how you installed iwyu, the program may be called + ``fix_includes.py``. If it doesn't compile, the most likely suspect + is that iwyu included a private header. See `iwyu instructions for + users <https://code.google.com/p/include-what-you-use/wiki/InstructionsForUsers#How_to_Run>`__ + for ways to handle this. Generally, they suggest deleting the + offending lines. +#. Check that your build path didn't make it into source files. Since + ``compile_commands.json`` has full paths, iwyu will put full paths in + the include statements. This will not produce an error on your + system, but it will on the build servers. The easiest way to check is + to use `the silver + searcher <https://github.com/ggreer/the_silver_searcher>`__ to check + for your username in your source tree. +#. Enjoy your success. + +**Note:** ``iwyu`` outputs to ``stderr`` and always returns a failure +status code since it generates no output. The output stream also affects +``iwyu_tool.py`` diff --git a/dev-docs/source/UnitTestGoodPractice.rst b/dev-docs/source/UnitTestGoodPractice.rst new file mode 100644 index 0000000000000000000000000000000000000000..4863ea9233958ccf388445dac15ebcf446aa53b1 --- /dev/null +++ b/dev-docs/source/UnitTestGoodPractice.rst @@ -0,0 +1,191 @@ +.. _UnitTestGoodPractice: + +======================= +Unit Test Good Practice +======================= + +.. contents:: + :local: + +General Guidance +################ + +What to test +------------ + +Simply put you should test. + +- Every public member of a class. +- That the class can be cast to any of the interfaces or base classes + it inherits from. +- Any private or protected members. + + - That aren’t directly covered by a public method test. + - That do any significant processing. + +For each method you are testing you should include tests for the +following: + +- To confirm that the methods meet the requirements associated with + them. Thus the test should verify that the function does what it is + supposed to do. +- To confirm the expected behaviour for boundary and special values. +- To confirm that exceptions are thrown when expected. + +How to test private or protected members of a class +--------------------------------------------------- + +Testing the internals of a class can be considered harmful as it exposes +the internals of the class, which can arguably be freely changed (so +long as it does not affect the function of the public interface). +However there are cases where the internals of a class need unit tests +either due to complexity or tracking down specific bugs. + +In the circumstance where the implementation within the private/protected +methods of a class is sufficiently complex, such to require dedicated unit +tests, this code should be moved into a separate class(es). + +Protected +~~~~~~~~~ + +Within the test library you can add a new testable class that inherits +from the class you need to test. This class can simply expose any +protected methods as testable public methods. + +Private +~~~~~~~ + +There is no ideal way to test a private member of a class as they are +intentionally hidden from the class interface. There are two options to +consider in preference order: + +#. Change the protection level to protected and follow the approach + above. +#. Declare the test class as a friend, which can access private members. + +Good practices for writing tests +-------------------------------- + +The following are good practices for writing your unit tests. Many of +them are standard good coding practices. You will notice that in several +situations they can clash with each other, in this case common sense +needs to be applied. + +- Unit tests should test one method only. This allows you to easily + identify what failed if the test fails. +- Unit tests should not be coupled together, therefore one unit test + **CANNOT** rely on another unit test having completed first. + +These two often clash, in which case it is often better to compromise on +the first, and in fact we have relaxed this rule for Mantid (see below). + +- Units tests should use realistic data +- Unit tests should use small and simple data sets. + +Again these can often conflict. + +- Each test class should be named after the class it is testing (e.g. + tests for the ``AlgorithmFactory`` should go in a ``AlgorithmFactoryTest`` + class). +- Each test within a test class should use a descriptive test name, + prefixed with test (tests for the ``CreateAlgorithm`` method would be + included in ``testCreateAlgorithm``). If there are specific tests for + failure situations then these should be added to the end (e.g. + ``testCreateAlgorithmNoAlgorithmException``). THE AIM IS THAT FROM THE + TEST METHOD NAME ALONE, YOU SHOULD BE ABLE TO IDENTIFY THE PROBLEM. + +Other More General Points +~~~~~~~~~~~~~~~~~~~~~~~~~ + +- Tests should be **fast**, ideally really fast - certainly not more + than a few seconds. Unit tests test functionality, performance tests + can be used to check stress and timings. +- Untestable code is a code-smell, if you can't get the code under test + it probably needs refactoring. +- Weight your testing to be destructive rather than demonstrative. + Destructive tests have a higher efficacy for finding bugs. + +Mantid-specific Guidelines +########################## + +- As noted above, you can assume that individual tests within a cxxtest + suite will be run in order. +- There must be **no relative paths** (or, more obviously, absolute + ones) used in tests as with CMake the code can be build anywhere with + respect to the source tree. Make use of the datasearch.directories + property (which CMake configures to hold correct paths for a given + build). +- Ideally, test suites should not have a constructor. If one is + required, the following boiler-plate code **must** be inserted in the + test class: + + .. code-block:: c++ + + static NameOfTest *createSuite() { return new NameOfTest(); } + static void destroySuite(NameOfTest *suite) { delete suite; } + + where ``NameOfTest`` is the name of the test class. Without this, the + class is turned into a static meaning that the constructor is run at + initialisation even if (via an argument) you are not going to run that + particular test suite. Also, this can cause problems if running tests in + parallel. + +- Be cautious in use of the ``setUp()``and ``tearDown()`` methods. Be aware + that if you use these in your suite they will be run before/after + **every single** individual test. That's fine if it's the behaviour + you really need, but we have found that to be rare - use the + constructor or set things up within the test. +- To avoid clashes, use unique names for workspaces that will go into + the [Analysis Data Service], perhaps by prepending the name of the + test suite. Even better, don't put workspaces into the ADS in the + first place: for example, an InputWorkspace property can be set via + pointer instead of by name. +- Clean up the ADS at (or before) the end of the test suite. + +Using files in Unit tests +------------------------- + +Files for unit tests bloat our repository and slow down the testing +process. Therefore unless the prime purpose of the algorithms is to load +or save a file then you should not use a file in your unit tests. + +How do I get a workspace filled with data? + Firstly you want to think about how much data you really need, unit + tests need to be fast so you don't want too much data. + Secondly you should use and extend helper classes (like + `1 <https://github.com/mantidproject/mantid/blob/master/Framework/TestHelpers/inc/MantidTestHelpers/WorkspaceCreationHelper.h>`__) + to provide the workspaces for you. Keep things as generic as you can + and it will help you and others for other tests. + More details of this will be provided at `Testing Utilities <TestingUtilities>`__. +I want a workspace with a valid instrument definition and Spectra-detector map + As above use or extend a method in one of the `helper classes <TestingUtilities>`__ + that actually creates a minimal workspace for you in code - it will + only hurt the first time but everyone will benefit. + Loading instrument XML files in debug **really** hurts performance; + avoid this like the plague. +What if it **really** needs a file + First justify your reasoning with the PM or Lead developer + Ensure the file is as small as possible. Perhaps edit the file to + only contain 2 spectra + Note: this is not the same as just loading 2 spectra from a large + file. + Do not use a relative path to a file + Used the `Scoped + File <https://github.com/mantidproject/mantid/blob/master/Framework/TestHelpers/inc/MantidTestHelpers/ScopedFileHelper.h>`__ + helper, to ensure that resources are cleaned-up in an exception safe + manner. + +Mocking +####### + +Mocking is a very powerful tool that allows you to simulate components +in your unit environment and check how your code operates within this +environment. Mocking allows you to avoid creating Fake objects of any +kind, and results in fast executing code with a very high test coverage. +See `Mocking <Mocking>`__ in Mantid to find out what it is and how it +works. + +.. figure:: images/Mocking.png + :alt: Object under test using Mocking to isolate the testing.|400px + + Object under test using Mocking to isolate the testing.|400px diff --git a/dev-docs/source/VisualStudioBuildImpact.rst b/dev-docs/source/VisualStudioBuildImpact.rst new file mode 100644 index 0000000000000000000000000000000000000000..2d8f5cb11ba74567b2f3c7c0028836c8b8a00025 --- /dev/null +++ b/dev-docs/source/VisualStudioBuildImpact.rst @@ -0,0 +1,60 @@ +Visual Studio Build Impact +========================== + +Building Mantid on Visual Studio can take a while, and really tie up the +computer. This is because Visual Studio starts all of the compilation +processes at normal priority, so they compete as equals with everything +you are doing. + +So you might think that you can open task manage and reduce the priority +of all the cl.exe processes, well there can be quite a few, and no it +won't work for long as these processes are replaced for every file it +compiles. + +What you want to do it hunt down the MSBuild.exe processes and reduce +the priority of them, there should be the same number as you have +logical processors. The MSBuild processes spawn all of the compiler and +linker tasks, an they inherit the priority of the MSBuild process. + +Script +------ + +Of course if you don't want to do this yourself then you can use this +script. + +:: + + Const BELOW_NORMAL = 16384 + + strComputer = "." + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") + + Set colProcesses = objWMIService.ExecQuery _ + ("Select * from Win32_Process Where Name = 'MSBuild.exe'") + For Each objProcess in colProcesses + objProcess.SetPriority(BELOW_NORMAL) + Next + +Save it as Reduce_Build_Impact.vbs, and use when things are running like +a dog! + +Monitoring Script +----------------- + +If you don't want to keep running the script for each build, here's one +that keeps a watch on your system every 5 seconds. + +:: + + Const BELOW_NORMAL = 16384 + + strComputer = "." + Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") + Do While true + Set colProcesses = objWMIService.ExecQuery _ + ("Select * from Win32_Process Where Name = 'MSBuild.exe'") + For Each objProcess in colProcesses + objProcess.SetPriority(BELOW_NORMAL) + Next + WScript.Sleep 5000 + loop diff --git a/dev-docs/source/WritingAnAlgorithm.rst b/dev-docs/source/WritingAnAlgorithm.rst new file mode 100644 index 0000000000000000000000000000000000000000..01f567db695e7c1d265b2c4c3e92f54685dfce65 --- /dev/null +++ b/dev-docs/source/WritingAnAlgorithm.rst @@ -0,0 +1,249 @@ +.. _WritingAnAlgorithm: + +Writing An Algorithm +==================== + +.. contents:: + :local: + +Introduction +############ + +Mantid's `plugin <https://www.mantidproject.org/Plugin>`__ architecture has been engineered so that it is easy for a user +to write their own algorithm. This page is a primer for the user about to write their first algorithm and assumes no +great knowledge of C++. +It covers the basics, with links to more advanced options where appropriate. Note if you are looking to add a +`plugin <https://www.mantidproject.org/Plugin>`__ fit function rather than an algorithm then see +`Writing a Fit Function <https://www.mantidproject.org/Writing_a_Fit_Function>`__. +There is special description for the case when you are looking to add a custom `MD conversion plugin <WritingCustomConvertToMDTransformation>`__. + +Alternatively, you can implement your algorithm in `Python <https://www.mantidproject.org/Extending_Mantid_With_Python>`__. +See `Python Vs C++ Algorithms <https://www.mantidproject.org/Python_Vs_C%2B%2B_Algorithms>`__ for a comparison of Mantid's +two programming languages. + +All `algorithms <https://www.mantidproject.org/Algorithm>`__ in Mantid `inherit <http://en.wikipedia.org/wiki/Inheritance_(computer_science)>`__ +from a base ``Algorithm`` class, which provides the support and services required for running a specific +algorithm and greatly simplifies the process of writing a new one. + +Getting Started +############### +The first step is to create a new directory, with any name of your choice, under your MantidInstall directory +(on Windows, probably located at ``C:\\MantidInstall``). Alternatively, you can just do everything in the +UserAlgorithms directory. The UserAlgorithms directory contains a simple Python script called ``createAlg.py``. +This can be used to create a new 'empty' algorithm - to create one called 'MyAlg' you should type ``python +createAlg.py myAlg category``, where category is an optional argument to set the algorithm's category. +To do the same thing 'by hand', create files called ``MyAlg.h`` and ``MyAlg.cpp`` and paste in the following +boilerplate C++ code (changing each occurrence of 'MyAlg' to your chosen algorithm name): + +**Header file (MyAlg.h)**: + +.. code-block:: cpp + + #ifndef MYALG_H_ + #define MYALG_H_ + + #include "MantidAPI/Algorithm.h" + + class MyAlg : public Mantid::API::Algorithm + { + public: + /// (Empty) Constructor + MyAlg() : Mantid::API::Algorithm() {} + /// Virtual destructor + virtual ~MyAlg() {} + /// Algorithm's name + virtual const std::string name() const { return "MyAlg"; } + /// Algorithm's version + virtual const int version() const { return (1); } + /// Algorithm's category for identification + virtual const std::string category() const { return "UserDefined"; } + + private: + /// Initialisation code + void init(); + /// Execution code + void exec(); + }; + + #endif /*MYALG_H_*/ + +**Source file (MyAlg.cpp)**: + +.. code-block:: cpp + + #include "MyAlg.h" + + // Register the algorithm into the AlgorithmFactory + DECLARE_ALGORITHM(MyAlg); + + void MyAlg::init() + { + } + + void MyAlg::exec() + { + } + +At this point you will already have something that will compile and run. To do so (on Windows), copy the files +``build.bat`` & ``SConstruct`` from ``UserAlgorithms`` into the directory containing your code and execute ``build.bat``. +If you then start MantidPlot your algorithm will appear in the list of available algorithms and could be run. +But, of course, it won't do anything of interest until you have written some algorithm code... + +Coding the Algorithm +#################### + +You will see that the algorithm skeletons set up in the last section contain two methods/functions/subroutines +called ``init`` and ``exec``. It will be no surprise to discover that these will, respectively, contain the code to +initialise and execute the algorithm, which goes in the ``.cpp`` file between the curly brackets of each method. +Note that these are private methods (i.e. cannot be called directly); an algorithm is run by calling the base +class's ``initialize()`` and ``execute()`` methods, which provide additional services such as the validation of properties, +fetching workspaces from the ``AnalysisDataService``, handling errors and filling the workspace histories. + +Initialization +-------------- + +The initialization (init) method is executed by the ``FrameworkManager`` when an algorithm is requested and must +contain the declaration of the properties required by the algorithm. Atypically, it can also contain other +initialization code such as the calculation of constants used by the algorithm, so long as this does not +rely on the values of any of the properties. + +Calls to the ``declareProperty`` method are used to add a property to this algorithm. See the properties page +for more information on the types of properties supported and the example algorithms in ``UserAlgorithms`` +(especially `PropertyAlgorithm <http://svn.mantidproject.org/mantid/trunk/Code/Mantid/UserAlgorithms/PropertyAlgorithm.cpp>`__ +and `WorkspaceAlgorithm <http://svn.mantidproject.org/mantid/trunk/Code/Mantid/UserAlgorithms/WorkspaceAlgorithm.cpp>`__) +for further guidance on how to use them. + +For the simple types (integer, double or string), the basic syntax is:: + + declareProperty("UniquePropertyName",value); + +An optional `validator <https://www.mantidproject.org/Properties#Validators>`__ or +`directional argument <https://www.mantidproject.org/Properties#Direction>`__ (input, output or both) +can also be appended. The syntax for other property types (``WorkspaceProperty`` & ``ArrayProperty``) is more +complex - see the `properties <https://www.mantidproject.org/Properties#Direction>`__ page or the +example algorithms in `UserAlgorithms <https://www.mantidproject.org/UserAlgorithms>`__ for further details. + +Execution +######### + +Fetching properties +------------------- + +Before the data can be processed, the first task is likely to be to fetch the values of the input properties. +This uses the ``getProperty`` method as follows:: + + TYPE myProperty = getProperty("PropertyName"); + +where ``TYPE`` is the type of the property (``int``, ``double``, ``std::string``, ``std::vector``...). Note that the +value of a ``WorkspaceProperty`` is a `shared pointer <https://www.mantidproject.org/Shared_Pointer>`__ +to the workspace, which is referred to as ``Mantid::API::Workspace_sptr`` or ``Mantid::API::Workspace_const_sptr``. +The latter should be used for input workspaces that will not need to be changed in the course of the algorithm. + +If a handle is required on the property itself, rather than just its value, then the same method is used as follows:: + + Mantid::Kernel::Property* myProperty = getProperty("PropertyName"); + +This is useful, for example, for checking whether or not an optional property has been set (using Property's +``isDefault()`` method). + +Creating the output workspace +----------------------------- + +Usually, the result of an algorithm will be stored in another new workspace and the algorithm +will need to create that new workspace through a call to the ``WorkspaceFactory``. For the (common) +example where the output workspace should be of the same type and size as the input one, the code +would read as follows:: + + Mantid::API::Workspace_sptr outputWorkspace = Mantid::API::WorkspaceFactory::Instance().create(inputWorkspace); + +where ``inputWorkspace`` is a shared pointer to the input workspace. + +It is also important to, at some point, set the output workspace property to point at this workspace. +This is achieved through a call to the ``setProperty`` method as follows:: + + setProperty("OutputWorkspacePropertyName",outputWorkspace); + +where ``outputWorkspace`` is a shared pointer to the created output workspace. + +Using workspaces +---------------- + +The bulk of most algorithms will involve the manipulation of the data contained in workspaces +and information on how to interact with these is given `here <https://www.mantidproject.org/Interacting_with_Workspaces>`__. +The more advanced user may also want to refer to the full +`workspace documentation <http://doxygen.mantidproject.org/nightly/d3/de9/classMantid_1_1API_1_1Workspace.html>`__. + +Those familiar with C++ should make use of private methods and data members to break up the execution code into +more manageable and readable sections. + +Further Features +################ + +The advanced user is referred to the `full documentation page <http://doxygen.mantidproject.org/nightly/d3/de9/classMantid_1_1API_1_1Workspace.html>`__ +for the ``Algorithm`` base class to explore the full range of methods available for use within an algorithm. +A few aspects are highlighted below. + +Child Algorithms +---------------- + +Algorithms may wish to make use of the functionality of other algorithms as part of their execution. +For example, if a units change is required the ``ConvertUnits`` algorithm could be used. Mantid therefore +has the concept of a child algorithm and this is accessed through a call to the +``createChildAlgorithm`` method as follows:: + + Mantid::API::Algorithm_sptr childAlg = createChildAlgorithm("AlgorithmName"); + +This call will also initialise the algorithm, so the algorithm's properties can then be set and it can be executed:: + + childAlg->setPropertyValue("number", 0); + childAlg->setProperty<Workspace_sptr>("Workspace",workspacePointer); + childAlg->execute(); + +Logging +------- + +The ``g_log`` object enables access to the `logging <Logging>`__ facilities of Mantid, and is an invaluable +tool in understanding the running of your algorithms. + +Enhancing asynchronous running +------------------------------ + +Any algorithm can be run asynchronously (e.g. by MantidPlot) without modification. However, some features +are only enabled if code is added within the ``exec()`` method. ``Algorithm::interruption_point()`` should +be called at appropriate intervals so that the algorithm's execution can be interrupted. +``Algorithm::progress(double p)`` reports the progress of the algorithm. ``p`` must be between +0 (start) and 1 (finish). + +Exceptions +---------- + +It is fine to throw exceptions in your algorithms in the event of an unrecoverable failure. +These will be caught in the base Algorithm class, which will report the failure of the algorithm. + +Validation of inputs +-------------------- + +`Validators <https://www.mantidproject.org/Properties#Validators>`__ allow you to give feedback +to the user if the input of a property is incorrect (for example, typing non-numeric characters +in a number field). + +For more advanced validation, override the ``Algorithm::validateInputs()`` method. This is a +method that returns a map where: + +- The key is the name of the property that is in error. + +- The value is a string describing the error. + +This method allows you to provide validation that depends on several property values at once +(something that cannot be done with ``IValidator``). Its default implementation returns an empty map, +signifying no errors. + +It will be called in dialogs **after** parsing all inputs and setting the properties, but **before** executing. +It is also called again in the ``execute()`` call, which will throw if this returns something. + +In the MantidPlot GUI, this will set a "star" ``*`` label next to each property that is reporting an error. +This makes it easier for users to find where they went wrong. + +If your ``validateInputs()`` method validates an input workspace property, bear in mind that the user +could provide a ``WorkspaceGroup`` (or an unexpected type of workspace) - when retrieving the property, +check that casting it to its intended type succeeded before attempting to use it. diff --git a/dev-docs/source/WritingCustomConvertToMDTransformation.rst b/dev-docs/source/WritingCustomConvertToMDTransformation.rst new file mode 100644 index 0000000000000000000000000000000000000000..6267db5a2089ebd5680a5074ea7f286d0e58f29e --- /dev/null +++ b/dev-docs/source/WritingCustomConvertToMDTransformation.rst @@ -0,0 +1,197 @@ +.. _WritingCustomConvertToMDTransformation: + +Writing a Custom ConvertToMD Transformation +=========================================== + +.. contents:: + :local: + +Introduction +############ + +This information is intended for a developer who needs to write a customized +`ConvertToMD class <http://docs.mantidproject.org/nightly/algorithms/ConvertToMD.html>`__ (plugin). The +plugin then becomes automatically available to use in the +`ConvertToMD <http://docs.mantidproject.org/nightly/algorithms/ConvertToMD.html>`__ algorithm and via the +`Create MD workspaces <http://www.mantidproject.org/Create_MD_Workspace_GUI>`__ +interface to produce multidimensional workspace for further visualization and analysis. + +As the MD transformation factory is similar to the `Dynamic Factory <http://www.mantidproject.org/Dynamic_Factory>`__ +used for `converting units <http://docs.mantidproject.org/nightly/concepts/UnitFactory.html>`__, the +procedure of writing a custom ``ConvertToMD`` transformation is very similar to adding a new unit to use +with `ConvertUnits <http://docs.mantidproject.org/nightly/algorithms/ConvertUnits.html>`__ algorithm +or writing a new algorithm to use with Mantid. + +The plugin interface deals with the task of converting a generic n-dimensional point of a ``MatrixWorkspace`` +into a generic m-dimensional point of an ``MDWorkspace`` using the necessary parameters. + +Examples of such transformations could be a conversion of signal and error at detector num +at specific time of flight plus log values for temperature and pressure (**The instrument's +space**: 4 numbers + information about the detector) into 6-D point in the **Physical space +qx,qy,qz,dE,T,P** (qx,qy,qz -- the components of momentum transfer) or into 3-D point in +**Physical space \|Q\|,dE,Fugacity** (\|Q\| - modulus of momentum transfer). + +Writing a simple custom plugin +############################## + +Summary +------- + +If a single point of a ``MatrixWorkspace`` together with correspondent log files can be converted into a single +``MDEvent`` (multidimensional point of MD workspace), a simple custom plugin can be written to do this transformation. +The existing framework in this case deals with all other tasks, namely the iterations over source workspace, +conversion of the workspace units into the units of the conversion formula, defining the target workspace, +constructing ``MDEvent`` instances and adding these events to the ``MDWorkspace``. + +A ``ConvertToMD`` plugin implements ``MDTransfInterface``, so to write a plugin you must write a class +which inherits from this interface and register this class with ``MDTransfFactory``. The macro to +register the class with the factory is similar to the macro used to register an algorithm with +Mantid or a ``Unit`` class with the Unit conversion factory. The macro is located in ``MDTransfFactory.h``. + +The class inheriting from ``MDTransfInterface`` performs two tasks: + +- Define the target ``MDWorkspace`` and its dimensions (both the number of dimensions and the dimension units). + +- Initialize the transformation and define a formula to transform a single point of input data into output data. + +These two tasks are mainly independent, but implemented within a single class to be handled by the single dynamic factory. +**Note that the functions which define the target MDWorkspace are called before the MDTransfFactory initialize function.** +The ``initialize`` function accepts the ``MDWorkspace`` description and is expected to fully define all class variables used during +the transformation from a point of a ``MatrixWorkspace`` into an MD point of a target ``MDWorkspace``. + +Workflow +-------- +This workflow is implemented in the ``ConvertToMD`` algorithm's ``exec()`` function. + +#. Select a conversion and obtain additional algorithm parameters from the algorithm interface. + +#. Build ``MDWorkspace`` description (call ``MDTransfFactory`` and ask for the conversion plugin parameters). + +#. Build new ``MDWorkspace`` on the basis of its description (if new workspace is requested or check if existing workspace is suitable). + +#. Initialize the conversion plugin (using ``MDWSDescription``). + +#. Run the conversion itself by looping over detectors and their values (use ``MDTransfFactory`` and selected conversion plugin to convert + each input point into output MD point). + +The ``MDTransformationFactory`` is deployed twice during the conversion. The methods used during each conversion stage are clearly +specified in ``MDTransformationInterface.h``. + +Defining the target workspace +----------------------------- + +This describes steps 1-3 of the workflow. + +The input data at this stage are the name of the plugin and the outputs -- the information necessary for the transformation to work +including the number of output dimensions, units for the selected physical transformation formula, units of the target workspace, etc. + +The methods used while defining the workspace should not access or change anything accessed through this pointer of +the custom plugin. The result of the first stage is a ``MDWSDescription`` class, which can be considered +as a large XML string that provides a common interface to different data obtained from the algorithm's parameters. +Any data users want to transfer to the custom plugin can be added to this class, as long as this does not lead to +excessive memory usage or overhead. + +The ``MDWSDescription`` class is copy constructable and assignable and if these operators fail due to the changes +to the class, custom copy constructor and assignment operators have to be defined. + +Doing the transformation +------------------------ + +This describes steps 4-5 of the workflow. + +The input data at this stage are points of the "Experimental Space", e.g. coordinates of points in the input workspace and +additional information about these points, e.g. detectors coordinates and log files for values of interest. The output values +are the vectors of the coordinates of the selected points in the space of interest and (possibly) modified/corrected values of +the signal and error at this point. + +During the second stage of the transformation, the algorithm calculates the multidimensional coordinates of MD points in the +target workspace, places these coordinates into an MD vector of coordinates and modifies the neutron signal/error if necessary +(e.g. Lorentz corrections). This stage can be best described by the pseudo-code below. It describes performing the conversion +over the whole workspace: + +.. code-block:: cpp + + /** initialize all internal variables used for transformation of workspace into MD workspace + WorkspaceDescription -- the workspace description obtained on the first stage of the transformation */ + plugin->initialize(WorkspaceDescription); + /** calculate generic variables, which are usually placed in logs and do not depend on detectors positions + or neutron counts (e.g. temperature) and place these values into proper position in the coordinates vector. */ + if(!plugin->calcGenericVariables(std::vector<coord_t> &Coord, size_t N_Dimensions)) + return; // finish if these data are out of range requested + + for(i in array of detectors) + { + /** Here we calculate all MD coordinates which depend on detectors position only. The plugin also + changes the internal plugin values which depend on detector's position e.g. sets up the unit conversion */ + if(!plugin->calcYDepCoordinates(std::vector<coord_t> &Coord,size_t i)) + continue; // skip detector if these data are out of range requested + + /** obtain signal and error, array, corresponding to the i-th detector */ + spectra[i] = InputWorkspace->getSpectraCorrespondingToTheDetector(size_t i); + + /**Convert units into the units, requested by the plugin */ + MantidVector X = convertUnits(spectra[i].X_coordinates); + for(j in spectra[i]) + { + Signal = spectra[i].Signal[j]; + Error = spectra[i].Error[j]; + /**Calculate remaining MD coordinates and put them into vector of coordinates. + Modify Signal and error if the signal and error depends on Coord */ + plugin->calcMatrixCoordinates(const MantidVec& X, size_t i, size_t j, + std::vector<coord_t> &Coord, Signal, Error); + + /**Convert Coord signal and error to MD event with coordinate Coord and add the MDEvent to MD workspace*/ + AddPointToMDWorkspace(Coord,Signal,Error); + } + } + +PreprocessDetectorsToMD with custom plugins +------------------------------------------- + +Unit conversion uses the angular positions and sample-detector distances. +This information is usually expensive to calculate so it is calculated separately by the +`PreprocessDetectorsToMD <http://docs.mantidproject.org/nightly/algorithms/PreprocessDetectorsToMD-v1.html>`__ algorithm. +The detector information can be extracted directly from the input workspace, but consider checking the table workspace +returned by `PreprocessDetectorsToMD <http://docs.mantidproject.org/nightly/algorithms/PreprocessDetectorsToMD-v1.html>`__ +and check if the information is already provided there. + +`PreprocessDetectorsToMD <http://docs.mantidproject.org/nightly/algorithms/PreprocessDetectorsToMD-v1.html>`__ can also +be modified to add some additional detector information. This information can then be added to the resulting table workspace +and used in the custom plugin. +All currently existing plugins use the information about the detector's positions calculated by +`PreprocessDetectorsToMD <http://docs.mantidproject.org/nightly/algorithms/PreprocessDetectorsToMD-v1.html>`__. + +Complex Transformations +####################### + +It is possible that the approach of converting a single point of a ``MatrixWorkspace`` into a single ``MDEvent`` is +incorrect or inefficient for what is required. In this situation, more complex changes to the conversion framework +have to be implemented. +To make the changes one needs to understand the interaction between different classes involved in the conversion. + +The class diagram with all main classes involved in the conversion is presented below: + +.. figure:: images/ConvertToMDClassDiagram.gif + :alt: ConvertToMDClassDiagram.gif + +Two factories are involved into the conversion. ``MDTransfFactory`` deals with different formulae to +transform a single matrix point into an MD point. The other factory (``ConvToMDSelector`` and the algorithm inheriting +from ``ConvToMDBase``) deal with different kinds of workspaces. There are currently two workspaces that can be transformed +into an ``MDWorkspace``, namely ``EventWorkspace`` and ``MatrixWorkspace``. ``ConvToMDSelector`` identifies which algorithm to +deploy based on the input workspace. + +If the input workspace has some special properties (e.g. a workspace obtained for an experiment with a rotating crystal, +which has special units of time of flight with a special time series attached which describe a crystal position), +the ``ConvToMDSelector`` should be modified to identify such a workspace and an additional class inheriting from +``ConvToMDBase`` to deal with such workspaces has to be written. + +There are two other important classes in the diagram. The first one is ``MDWSDescription``, briefly mentioned above. +The purpose of this class is to collect all input information from the algorithm interface and transfer this information +through the common interface in a way convenient for a plugin to use. The user who is writing his own plugin is expected to +add all the information necessary for the plugin to work to this class. + +Another is the ``MDEventWSWrapper``. This class interfaces ``MDEventWorkspace``. The ``MDEventWorkspace`` is templated by number +of dimensions and the purpose of ``MDEventWSWrapper`` is to provide a unified interface to this workspace regardless of the +number of workspace dimensions calculated during the run. It uses ``MDEventWorkspace`` methods for which the +``IMDWorkspace`` interface to the ``MDEventWorkspace`` is not efficient. You do not usually need to modify this class unless +you are modifying ``MDEventWorkspace`` code. diff --git a/dev-docs/source/WritingPerformanceTests.rst b/dev-docs/source/WritingPerformanceTests.rst new file mode 100644 index 0000000000000000000000000000000000000000..d22a8bc8595dc87a211e003c3a69c5e867980ca3 --- /dev/null +++ b/dev-docs/source/WritingPerformanceTests.rst @@ -0,0 +1,154 @@ +.. _WritingPerformanceTests: + +========================= +Writing Performance Tests +========================= + +.. contents:: + :local: + +Overview +######## + +The point of Performance Tests is to track the performance of a piece of +code through time, so that it will be easy to pinpoint any change that +reduced the performance of a particular bit of code. Performance Tests +will be built and run by a build job, that will track the history of +timing vs revision. The Jenkins job that runs the performance tests +sends out an email when the performance of a test is lowered by more +than a threshold percentage (currently 25%), relative to the average of +a few previous tests. + +How to Write C++ Performance Tests +################################## + +An ideal performance test is neither too fast, nor too slow. The +precision of timing will be insufficient if the test runs in much less +than a second; tests that run for several minutes should also be +avoided. + +C++ performance tests are written in the same way as unit tests, and in +the same file as the unit tests for a particular class, except that you +will add *Performance* to the end of the name of the test suite. For +example, in MyAlgorithmTest.h: + +.. code-block:: c++ + + class MyAlgorithmTest : public CxxTest::TestSuite { +   // Put in your usual, quick unit tests here + }; +   + class MyAlgorithmTestPerformance : public CxxTest::TestSuite { + public: + MatrixWorkspace_sptr WS; +   int numpixels; +    +   void setUp() { +      // Put in any code needed to set up your test, +      // but that should NOT be counted in the execution time. +   } +    +   void tearDown() { +   // Clean-up code, also NOT counted in execution time. +   } +    +   void test_slow_performance() { +      // Put in a unit test that will be slow. +   } + }; + +Only the presence/absence of the word Performance is used to determine +if it is a Performance test. As with unit tests, your suite name has to +match the file name. + +You may include ASSERT's in the same way as a unit test to check that +results are meaningful, but that is unnecessary since these tests are +for performance, not function. Avoid adding so many assert's that it +would slow down your test. + +Running Performance Tests +######################### + +Performance tests targets are not added by default when running +cmake/make. To add them as ctest targets, enable them with the flag: + +.. code-block:: sh + + cmake -DCXXTEST_ADD_PERFORMANCE=TRUE + +After re-building, you can then run performance tests with the command: + +.. code-block:: sh + + ctest [-C Release|Debug] -R Performance + +And run regular unit tests, excluding the slow performance ones, with: + +.. code-block:: sh + + ctest [-C Release|Debug] -E Performance + +where the -C option is required for multi-configuration builds like +Visual Studio & XCode. + +The resulting .XML files will contain the detailed timing (of just the +test portion without setUp/tearDown time). + +Note that newly added performance tests will not be registered with +ctest until cmake has been re-run. + +Running tests without ctest +--------------------------- + +The tests are still built into every test executable, even if you have +not set the flag. For example, + +.. code-block:: sh + + AlgorithmsTest --help-tests + +will list all the available tests. If you run + +.. code-block:: sh + + AlgorithmsTest + +alone, it will SKIP the Performance Tests. You have to give the name of +the specific test suite you want to run, e.g, + +.. code-block:: sh + + AlgorithmsTest MyAlgorithmPerformanceTest + +Best Practice Advice +#################### + +- Performance tests are not System Tests. They should test the code at + the same granularity as the unit test suite. +- Performance tests are not Unit Tests. There is no need to perform + lots of assertions on the test results. +- Performance tests should perform enough work such that statistically + significant performance differences can be measured. +- The performance tests are executed often, so ideally they should + typically take 0.2 - 2 seconds to run. +- Always perform test set-up outside of the test method. That way your + timings will only relate to the target code you wish to measure. + +Jobs that monitor performance +############################# + +There is a job in Jenkins (our continuous integration system) that runs +the performance test suite and generates output that enables us to +easily monitor timings. The job runs a set of `performance tests on the +master branch of +Mantid <http://builds.mantidproject.org/job/master_performancetests2/>`__. +This job runs on a machine at the ESS, everytime that changes are merged +into the Mantid master branch, and stores the timing information in a +database, also generating HTML output via a `set of python +scripts <https://github.com/mantidproject/mantid/tree/master/Testing/PerformanceTests>`__. + +The timing output of these jobs are typically monitored manually on a +weekly basis to pick up any notable performance degradation. Although +automatic checking is available within the python scripts, the level of +instability in the timings meant that it always produced way too many +false positives to be useful. diff --git a/dev-docs/source/conf.py b/dev-docs/source/conf.py index ad87f97943d16c0e7ae6a3662abdb6d491ef5639..cebc195f782d159b2f5746fc5aac0c844752533e 100644 --- a/dev-docs/source/conf.py +++ b/dev-docs/source/conf.py @@ -127,9 +127,10 @@ html_theme_options = { 'navbar_site_name': "Mantid", # Add links to the nav bar. Third param of tuple is true to create absolute url. 'navbar_links': [ - ("Home", "http://www.mantidproject.org", True), + ("Home", "index"), ("Download", "http://download.mantidproject.org", True), - ("Documentation", "http://www.mantidproject.org/Documentation", True), + ("Wiki", "http://www.mantidproject.org", True), + ("User Documentation", "http://docs.mantidproject.org", True), ("Contact Us", "http://www.mantidproject.org/Contact", True), ], # Do not show the "Show source" button. diff --git a/dev-docs/source/images/ASavici.jpg b/dev-docs/source/images/ASavici.jpg new file mode 100644 index 0000000000000000000000000000000000000000..4f52c7a4ad9ef82c313d1c2eed0dc14486318146 Binary files /dev/null and b/dev-docs/source/images/ASavici.jpg differ diff --git a/dev-docs/source/images/AttachToProcess.png b/dev-docs/source/images/AttachToProcess.png new file mode 100644 index 0000000000000000000000000000000000000000..dd87f7ae7bab7ef8c594cdd96b02985e68125269 Binary files /dev/null and b/dev-docs/source/images/AttachToProcess.png differ diff --git a/dev-docs/source/images/BuildStatuses.png b/dev-docs/source/images/BuildStatuses.png new file mode 100644 index 0000000000000000000000000000000000000000..348fba6f755f9f18891078bbd6053e6d1d126081 Binary files /dev/null and b/dev-docs/source/images/BuildStatuses.png differ diff --git a/dev-docs/source/images/CodeFreezePR.png b/dev-docs/source/images/CodeFreezePR.png new file mode 100644 index 0000000000000000000000000000000000000000..610450cfd34335b1c9cae80101d5af16c893405f Binary files /dev/null and b/dev-docs/source/images/CodeFreezePR.png differ diff --git a/dev-docs/source/images/ConvertToMDClassDiagram.gif b/dev-docs/source/images/ConvertToMDClassDiagram.gif new file mode 100644 index 0000000000000000000000000000000000000000..bbce84fddae74cf8a16b6a460ab4660d08168578 Binary files /dev/null and b/dev-docs/source/images/ConvertToMDClassDiagram.gif differ diff --git a/dev-docs/source/images/DevelopmentAndReleaseCycle.png b/dev-docs/source/images/DevelopmentAndReleaseCycle.png new file mode 100644 index 0000000000000000000000000000000000000000..e221736354aaf8c81e08fedfceaaeb6a2294be4a Binary files /dev/null and b/dev-docs/source/images/DevelopmentAndReleaseCycle.png differ diff --git a/dev-docs/source/images/ExternalDataSchematic.png b/dev-docs/source/images/ExternalDataSchematic.png new file mode 100644 index 0000000000000000000000000000000000000000..26617234da52eb7f6735ff369eede41a14009f4f Binary files /dev/null and b/dev-docs/source/images/ExternalDataSchematic.png differ diff --git a/dev-docs/source/images/GGuest.png b/dev-docs/source/images/GGuest.png new file mode 100644 index 0000000000000000000000000000000000000000..8098591672d7346279365d52dddef7a4482533d8 Binary files /dev/null and b/dev-docs/source/images/GGuest.png differ diff --git a/dev-docs/source/images/GeometryHandlers.jpg b/dev-docs/source/images/GeometryHandlers.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a78c0c5de94126ce54e7d04a131ca69587c448b2 Binary files /dev/null and b/dev-docs/source/images/GeometryHandlers.jpg differ diff --git a/dev-docs/source/images/InstrumentViewClassDiagram.jpg b/dev-docs/source/images/InstrumentViewClassDiagram.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a6e75669282e791bb1f3bb14d0782a23d98b0797 Binary files /dev/null and b/dev-docs/source/images/InstrumentViewClassDiagram.jpg differ diff --git a/dev-docs/source/images/InstrumentWidget.jpg b/dev-docs/source/images/InstrumentWidget.jpg new file mode 100644 index 0000000000000000000000000000000000000000..252b96395837cc16ac93ca3a08df53c3bfec7e81 Binary files /dev/null and b/dev-docs/source/images/InstrumentWidget.jpg differ diff --git a/dev-docs/source/images/JBilheaux.jpg b/dev-docs/source/images/JBilheaux.jpg new file mode 100644 index 0000000000000000000000000000000000000000..97854cc92f4e2ca4d24e845a28174438a4e65cf5 Binary files /dev/null and b/dev-docs/source/images/JBilheaux.jpg differ diff --git a/dev-docs/source/images/JBorreguero.jpg b/dev-docs/source/images/JBorreguero.jpg new file mode 100644 index 0000000000000000000000000000000000000000..432c2ccb5a4b57a2ddd8009e224215033e2e2081 Binary files /dev/null and b/dev-docs/source/images/JBorreguero.jpg differ diff --git a/dev-docs/source/images/KCachegrind_MantidPlot.png b/dev-docs/source/images/KCachegrind_MantidPlot.png new file mode 100644 index 0000000000000000000000000000000000000000..ea1be216a8e931906e2e32bc54c531696313876d Binary files /dev/null and b/dev-docs/source/images/KCachegrind_MantidPlot.png differ diff --git a/dev-docs/source/images/LMoore.jpg b/dev-docs/source/images/LMoore.jpg new file mode 100644 index 0000000000000000000000000000000000000000..3734e6f2d1c09eecce2041b534303e5ed696f145 Binary files /dev/null and b/dev-docs/source/images/LMoore.jpg differ diff --git a/dev-docs/source/images/MDoucet.jpg b/dev-docs/source/images/MDoucet.jpg new file mode 100644 index 0000000000000000000000000000000000000000..58057ed6ec3288ba80ee138d773d10bccc89e888 Binary files /dev/null and b/dev-docs/source/images/MDoucet.jpg differ diff --git a/dev-docs/source/images/MGigg.jpg b/dev-docs/source/images/MGigg.jpg new file mode 100644 index 0000000000000000000000000000000000000000..28274291b3ca109fd1820cd3700816c6014c41a1 Binary files /dev/null and b/dev-docs/source/images/MGigg.jpg differ diff --git a/dev-docs/source/images/MVPPythonViews/AdjustWidgetLayout.png b/dev-docs/source/images/MVPPythonViews/AdjustWidgetLayout.png new file mode 100644 index 0000000000000000000000000000000000000000..f8862eabe08ad4b2cc906c6e29a6a80146ed3d03 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/AdjustWidgetLayout.png differ diff --git a/dev-docs/source/images/MVPPythonViews/CompletePromote.png b/dev-docs/source/images/MVPPythonViews/CompletePromote.png new file mode 100644 index 0000000000000000000000000000000000000000..e6d39047ed84736572fbea976b782d68b8e649b1 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/CompletePromote.png differ diff --git a/dev-docs/source/images/MVPPythonViews/CopyFromMainUI.png b/dev-docs/source/images/MVPPythonViews/CopyFromMainUI.png new file mode 100644 index 0000000000000000000000000000000000000000..98d3fadd4a79222fc6a8f99b5158b9521d671522 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/CopyFromMainUI.png differ diff --git a/dev-docs/source/images/MVPPythonViews/NewFileName.png b/dev-docs/source/images/MVPPythonViews/NewFileName.png new file mode 100644 index 0000000000000000000000000000000000000000..bec43e4033a4b72563df623c03260550623a0213 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/NewFileName.png differ diff --git a/dev-docs/source/images/MVPPythonViews/NewForm.png b/dev-docs/source/images/MVPPythonViews/NewForm.png new file mode 100644 index 0000000000000000000000000000000000000000..fd2794af39b9d32259060204cd346c5afcdf60c0 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/NewForm.png differ diff --git a/dev-docs/source/images/MVPPythonViews/PasteIntoWidget.png b/dev-docs/source/images/MVPPythonViews/PasteIntoWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..06ce203faa1aba7bbc1923372d0520d8a752fb10 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/PasteIntoWidget.png differ diff --git a/dev-docs/source/images/MVPPythonViews/PostReplacedWidget.png b/dev-docs/source/images/MVPPythonViews/PostReplacedWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..dc058966ba4b9e0d63d66e25b7cedaad3b61b40c Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/PostReplacedWidget.png differ diff --git a/dev-docs/source/images/MVPPythonViews/PreReplacedWidget.png b/dev-docs/source/images/MVPPythonViews/PreReplacedWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..8f19b3cfece59c4bc6082dad3a6d69bbdc7ed48d Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/PreReplacedWidget.png differ diff --git a/dev-docs/source/images/MVPPythonViews/PromoteWidget.png b/dev-docs/source/images/MVPPythonViews/PromoteWidget.png new file mode 100644 index 0000000000000000000000000000000000000000..726f34ecffc1f0471021b0ca6b400b7b5084b730 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/PromoteWidget.png differ diff --git a/dev-docs/source/images/MVPPythonViews/SelectFile.png b/dev-docs/source/images/MVPPythonViews/SelectFile.png new file mode 100644 index 0000000000000000000000000000000000000000..e1c94cc4650733d8ad0b7484def60b056bd0c8a6 Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/SelectFile.png differ diff --git a/dev-docs/source/images/MVPPythonViews/SelectTemplate.png b/dev-docs/source/images/MVPPythonViews/SelectTemplate.png new file mode 100644 index 0000000000000000000000000000000000000000..a18465c08c7d01d1a525b59a146dd65d06f7813b Binary files /dev/null and b/dev-docs/source/images/MVPPythonViews/SelectTemplate.png differ diff --git a/dev-docs/source/images/Mocking.png b/dev-docs/source/images/Mocking.png new file mode 100644 index 0000000000000000000000000000000000000000..ec518c080c0b1fc9fb54d108f3eb00d5e3bd2322 Binary files /dev/null and b/dev-docs/source/images/Mocking.png differ diff --git a/dev-docs/source/images/NDraper.jpg b/dev-docs/source/images/NDraper.jpg new file mode 100644 index 0000000000000000000000000000000000000000..7b1fa3d88134cc1b4bb625cc0c47a9248182ea8c Binary files /dev/null and b/dev-docs/source/images/NDraper.jpg differ diff --git a/dev-docs/source/images/OArnold.jpg b/dev-docs/source/images/OArnold.jpg new file mode 100644 index 0000000000000000000000000000000000000000..efa107d34139fcb79ab2ad5dbdf4abac73ab88e1 Binary files /dev/null and b/dev-docs/source/images/OArnold.jpg differ diff --git a/dev-docs/source/images/PPeterson.jpg b/dev-docs/source/images/PPeterson.jpg new file mode 100644 index 0000000000000000000000000000000000000000..9d287064d22745d98edb0c81ae224807b4c9a226 Binary files /dev/null and b/dev-docs/source/images/PPeterson.jpg differ diff --git a/dev-docs/source/images/RFerrazLeal.jpg b/dev-docs/source/images/RFerrazLeal.jpg new file mode 100644 index 0000000000000000000000000000000000000000..b6e8097a1b3e6fc0a93dc89971772d567ed43877 Binary files /dev/null and b/dev-docs/source/images/RFerrazLeal.jpg differ diff --git a/dev-docs/source/images/RTolchenov.jpg b/dev-docs/source/images/RTolchenov.jpg new file mode 100644 index 0000000000000000000000000000000000000000..85259769e2b07d0120b40268ac6ea6dfc7950173 Binary files /dev/null and b/dev-docs/source/images/RTolchenov.jpg differ diff --git a/dev-docs/source/images/RestartBuild.png b/dev-docs/source/images/RestartBuild.png new file mode 100644 index 0000000000000000000000000000000000000000..6c99976e3b7a86a66e48ef4c57ec22e73ea0a315 Binary files /dev/null and b/dev-docs/source/images/RestartBuild.png differ diff --git a/dev-docs/source/images/VLynch.jpg b/dev-docs/source/images/VLynch.jpg new file mode 100644 index 0000000000000000000000000000000000000000..e9d29886710360d41a5325ec73266fce2170f1f4 Binary files /dev/null and b/dev-docs/source/images/VLynch.jpg differ diff --git a/dev-docs/source/images/VisualStudioTestDebugProperties.png b/dev-docs/source/images/VisualStudioTestDebugProperties.png new file mode 100644 index 0000000000000000000000000000000000000000..2f92b379d8c080b1624f924f3a316c5c91eabf7c Binary files /dev/null and b/dev-docs/source/images/VisualStudioTestDebugProperties.png differ diff --git a/dev-docs/source/images/WZhou.jpg b/dev-docs/source/images/WZhou.jpg new file mode 100644 index 0000000000000000000000000000000000000000..98f98d99f0008f1d78b7df60db4b09cea2844687 Binary files /dev/null and b/dev-docs/source/images/WZhou.jpg differ diff --git a/dev-docs/source/index.rst b/dev-docs/source/index.rst index ebf236f4ac0c7affdda5a1112c1bec7d36493a52..0ac831a84b6a7dc6ddf437dea117753b039ee769 100644 --- a/dev-docs/source/index.rst +++ b/dev-docs/source/index.rst @@ -1,17 +1,18 @@ -.. Documentation master file - It contains a hidden root toctree directive so that Sphinx - has an internal index of all of the pages and doesn't - produce a plethora of warnings about most documents not being in - a toctree. - See http://sphinx-doc.org/tutorial.html#defining-document-structure - .. _contents: ======================= Developer Documentation ======================= -These pages contain the developer documentation for mantid version |release|. +.. toctree:: + :hidden: + + DevelopmentTeam + +These pages contain the developer documentation for mantid. They are aimed at those who are modifying the +source code of the project. For user documentation please see :ref:`here <mantid:contents>`. + +Meet the :ref:`team <DevelopmentTeam>`. ====== Guides @@ -20,10 +21,157 @@ Guides .. toctree:: :hidden: + DeveloperAccounts GettingStarted + BuildingOnOSX + BuildingWithCMake + BuildingVATES + Standards/index + DoxygenSetup + Python3 + +:doc:`DeveloperAccounts` + Details of the accounts required for developers. :doc:`GettingStarted` - Describes the process of obtaining and building the mantid code base + Describes the process of obtaining and building the mantid code base. + +:doc:`Standards <Standards/index>` + Details of coding and documentation standards for the project. Includes specifics regarding algorithms. + +:doc:`DoxygenSetup` + Configure a doxygen build locally. + +:doc:`Python3` + Building with Python 3 (Linux only). + +=================== +Development Process +=================== + +.. toctree:: + :hidden: + + DevelopmentAndReleaseCycle + Communication + IssueTracking + GitWorkflow + AutomatedBuildProcess + JenkinsConfiguration + ReleaseChecklist + PatchReleaseChecklist + TSC + DesignDocumentGuides + +:doc:`DevelopmentAndReleaseCycle` + An overview of the development cycle. + +:doc:`Communication` + Details various methods of communication used within the team. + +:doc:`IssueTracking` + Describes how issues are tracked over the project. + +:doc:`GitWorkflow` + Details the workflow used development with git and GitHub. + +:doc:`AutomatedBuildProcess` + Details the interaction of pull requests with the Jenkins CI builds. + +:doc:`JenkinsConfiguration` + Describes the setup of Jenkins system and how to add a new slave. + +:doc:`ReleaseChecklist` + How to perform a full release of Mantid. + +:doc:`PatchReleaseChecklist` + How to perform a patch release of Mantid. + +:doc:`TSC` + Overview of the role of the technical steering committee. + +:doc:`DesignDocumentGuides` + How to write a good design document. + +===== +Tools +===== + +.. toctree:: + :hidden: + + ToolsOverview + ProfilingWithValgrind + FlowchartCreation + VisualStudioBuildImpact + +:doc:`ToolsOverview` + Describes ``class_maker``, ``valgrind`` and related tools. + +:doc:`ProfilingWithValgrind` + How to use valgrind to profile your code. + +:doc:`FlowchartCreation` + Describes how to create a flow chart with dot. + +:doc:`VisualStudioBuildImpact` + Provides a script to reduce the impact of Visual Studio on machine performance. + +======= +Testing +======= + +.. toctree:: + :hidden: + + RunningTheUnitTests + DebuggingUnitTests + UnitTestGoodPractice + WritingPerformanceTests + SystemTests + DataFilesForTesting + TestingUtilities + +:doc:`RunningTheUnitTests` + Details on how to run the suite of unit tests. + +:doc:`DebuggingUnitTests` + Details on how to debug the suite of unit tests. + +:doc:`UnitTestGoodPractice` + Guidance on writing good unit tests. + +:doc:`WritingPerformanceTests` + A walk through of how to write a performance test. + +:doc:`SystemTests` + Guidance on working with the system tests. + +:doc:`DataFilesForTesting` + How to work with test data files in the mantid repository. + +:doc:`TestingUtilities` + Helper utlities used for testing. + +=============== +GUI Development +=============== + +.. toctree:: + :hidden: + + GUIDesignGuidelines + MVPTutorial/index + QtDesignerForPython + +:doc:`GUIDesignGuidelines` + Gives some guidelines to consider when developing a new graphical user interface. + +:doc:`MVP Tutorial <MVPTutorial/index>` + A hands-on tutorial on how to implement a user GUI using the Model-View-Presenter (MVP) pattern. + +:doc:`QtDesignerForPython` + Describes how to use the Qt designer to produce GUI views. =================== Component Overviews @@ -33,5 +181,14 @@ Component Overviews :maxdepth: 1 AlgorithmMPISupport + HandlingXML IndexProperty + InstrumentViewer ISISSANSReductionBackend + LoadAlgorithmHook + Logging + MultiThreadingInAlgorithms + PythonVSCppAlgorithms + RemoteJobSubmissionAPI + WritingAnAlgorithm + WritingCustomConvertToMDTransformation diff --git a/docs/source/algorithms/Abins-v1.rst b/docs/source/algorithms/Abins-v1.rst index 65eb426395c5b16ae989a4ed8c51c45494754be9..99c1e7ed0d03979a6d3ace25b51a7f9783c1ec49 100644 --- a/docs/source/algorithms/Abins-v1.rst +++ b/docs/source/algorithms/Abins-v1.rst @@ -11,7 +11,7 @@ Contributors: .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AbortRemoteJob-v1.rst b/docs/source/algorithms/AbortRemoteJob-v1.rst index bf611d704d82c0c9373c098a186649414b952b4d..c921941466f4770e64d1392eb61dc87ae2dc63b1 100644 --- a/docs/source/algorithms/AbortRemoteJob-v1.rst +++ b/docs/source/algorithms/AbortRemoteJob-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AbortRemoteJob-v2.rst b/docs/source/algorithms/AbortRemoteJob-v2.rst index 2d1f4dd5d100380da3904e70bbed2483cf4eb81a..460a24c0a6422ec1ab6c8e516ed149edf5938101 100644 --- a/docs/source/algorithms/AbortRemoteJob-v2.rst +++ b/docs/source/algorithms/AbortRemoteJob-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AbsorptionCorrection-v1.rst b/docs/source/algorithms/AbsorptionCorrection-v1.rst index 7684c333232d823aead13496e03830cf91216d5a..7ee7e67caee4d354d03e819a4cce0ec017c10e6b 100644 --- a/docs/source/algorithms/AbsorptionCorrection-v1.rst +++ b/docs/source/algorithms/AbsorptionCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AccumulateMD-v1.rst b/docs/source/algorithms/AccumulateMD-v1.rst index fdd1a6c4f81dbfbc87dc80a12205d3269f04aaf4..8b8b2ccb4ad2a809b79c3f71ebb2a1bd7a96cf23 100644 --- a/docs/source/algorithms/AccumulateMD-v1.rst +++ b/docs/source/algorithms/AccumulateMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddLogDerivative-v1.rst b/docs/source/algorithms/AddLogDerivative-v1.rst index c2880f978ff91702268d2ad8bbe7b11ec5f2cee0..dbb72ea38368f795c4a69d8f7a63812eb2c8d93f 100644 --- a/docs/source/algorithms/AddLogDerivative-v1.rst +++ b/docs/source/algorithms/AddLogDerivative-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddNote-v1.rst b/docs/source/algorithms/AddNote-v1.rst index d834faa400586c728ef3d610d0f5906ccc0669d9..c25491208f0209ee1a8ed9da0e178ef17689d1db 100644 --- a/docs/source/algorithms/AddNote-v1.rst +++ b/docs/source/algorithms/AddNote-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddPeak-v1.rst b/docs/source/algorithms/AddPeak-v1.rst index 6dae159033cc423eb3875cc317cf424c8d2e07c2..c92fc413894e4054c4d48a3d9131041d3c9373c8 100644 --- a/docs/source/algorithms/AddPeak-v1.rst +++ b/docs/source/algorithms/AddPeak-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddPeakHKL-v1.rst b/docs/source/algorithms/AddPeakHKL-v1.rst index ee71dc1ce113de791b6ce776d94910504422d6dc..62ec2126ebf41838569f02fa40670091a0d5ee38 100644 --- a/docs/source/algorithms/AddPeakHKL-v1.rst +++ b/docs/source/algorithms/AddPeakHKL-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddSampleLog-v1.rst b/docs/source/algorithms/AddSampleLog-v1.rst index 6cad3c0127071bca753c8aebee4939366f1a0ebb..86bcde338ab550f029561f0cc4ea172f52820bc8 100644 --- a/docs/source/algorithms/AddSampleLog-v1.rst +++ b/docs/source/algorithms/AddSampleLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddSampleLogMultiple-v1.rst b/docs/source/algorithms/AddSampleLogMultiple-v1.rst index 0f445b1e1f7e083c475c900b4308af25470d19d6..e736057e43f544bc2cc89c86d78572a40fab4b0f 100644 --- a/docs/source/algorithms/AddSampleLogMultiple-v1.rst +++ b/docs/source/algorithms/AddSampleLogMultiple-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AddTimeSeriesLog-v1.rst b/docs/source/algorithms/AddTimeSeriesLog-v1.rst index 1ef19324053249a1c9f31e810ef3d5ac75439022..8e3f3957f609da85cf9522b6b4cbff4ad77eaac4 100644 --- a/docs/source/algorithms/AddTimeSeriesLog-v1.rst +++ b/docs/source/algorithms/AddTimeSeriesLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AlignAndFocusPowder-v1.rst b/docs/source/algorithms/AlignAndFocusPowder-v1.rst index 03ec09a13f1abd17d6d774242d6ed10641738218..78db7695af2b10a5ffa871a0234b0b7ff8c63170 100644 --- a/docs/source/algorithms/AlignAndFocusPowder-v1.rst +++ b/docs/source/algorithms/AlignAndFocusPowder-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AlignAndFocusPowderFromFiles-v1.rst b/docs/source/algorithms/AlignAndFocusPowderFromFiles-v1.rst index 74130ed6f71434666944ce3df50e4ef4c0b8dada..6449505cca4a6e3f6da923ae925851c75b631105 100644 --- a/docs/source/algorithms/AlignAndFocusPowderFromFiles-v1.rst +++ b/docs/source/algorithms/AlignAndFocusPowderFromFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AlignComponents-v1.rst b/docs/source/algorithms/AlignComponents-v1.rst index cc15126ce789e3628d743a7b946873df455f0baa..0507aa62031478c7131c3bdcbe07c4661803be5c 100644 --- a/docs/source/algorithms/AlignComponents-v1.rst +++ b/docs/source/algorithms/AlignComponents-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AlignDetectors-v1.rst b/docs/source/algorithms/AlignDetectors-v1.rst index 74b8560ef5d0952a6952ace13da3bb837c452868..ab934df6daa1bc4d28e08337eb471b944d99af8d 100644 --- a/docs/source/algorithms/AlignDetectors-v1.rst +++ b/docs/source/algorithms/AlignDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AlphaCalc-v1.rst b/docs/source/algorithms/AlphaCalc-v1.rst index 10bea530d19f43f4cc8a4918ad82c9b07c5649bd..a633b1158953ec4dcde497c47e43886de8a3bc77 100644 --- a/docs/source/algorithms/AlphaCalc-v1.rst +++ b/docs/source/algorithms/AlphaCalc-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AndMD-v1.rst b/docs/source/algorithms/AndMD-v1.rst index b0aa22197567e14ea0684fa268154a01b95c0a9d..273bd7896e722d8e8e3323591ebbe8e857191b22 100644 --- a/docs/source/algorithms/AndMD-v1.rst +++ b/docs/source/algorithms/AndMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AngularAutoCorrelationsSingleAxis-v1.rst b/docs/source/algorithms/AngularAutoCorrelationsSingleAxis-v1.rst index 83068dda4a87aa6b7d612cf2cc5fa03d9523f0d7..fcc7eef89ef35481436f32fb6f57554588827f9d 100644 --- a/docs/source/algorithms/AngularAutoCorrelationsSingleAxis-v1.rst +++ b/docs/source/algorithms/AngularAutoCorrelationsSingleAxis-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AngularAutoCorrelationsTwoAxes-v1.rst b/docs/source/algorithms/AngularAutoCorrelationsTwoAxes-v1.rst index c6dd6717c61197280a0532f3b7370e00bdf85f27..644eae9ddfc15777d6e07eee970d4ad9a98a907f 100644 --- a/docs/source/algorithms/AngularAutoCorrelationsTwoAxes-v1.rst +++ b/docs/source/algorithms/AngularAutoCorrelationsTwoAxes-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AnnularRingAbsorption-v1.rst b/docs/source/algorithms/AnnularRingAbsorption-v1.rst index 6fcc2deab208f817866d3d8bc3a0a262eaed9def..212b9d069d7b8f4858e2266d0877ad6e7c385f95 100644 --- a/docs/source/algorithms/AnnularRingAbsorption-v1.rst +++ b/docs/source/algorithms/AnnularRingAbsorption-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AnvredCorrection-v1.rst b/docs/source/algorithms/AnvredCorrection-v1.rst index ed28378e62730f4e49f05f290cc70dc57f088434..cc95d0cd3aeadb27079877365826133185ebcf43 100644 --- a/docs/source/algorithms/AnvredCorrection-v1.rst +++ b/docs/source/algorithms/AnvredCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AppendGeometryToSNSNexus-v1.rst b/docs/source/algorithms/AppendGeometryToSNSNexus-v1.rst index 104ea18c9d3ea3a245d3827d3f967498fc65158c..d7ad2395c19fb2f4fb23ad7ec84147b5214f0a9a 100644 --- a/docs/source/algorithms/AppendGeometryToSNSNexus-v1.rst +++ b/docs/source/algorithms/AppendGeometryToSNSNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AppendSpectra-v1.rst b/docs/source/algorithms/AppendSpectra-v1.rst index 2ad75355f1a9cc6d77cbfa6f9a6c4305d605a7ee..9a2fa0e1bb8fd6a7f3b406ecd73b8c0e44f576a6 100644 --- a/docs/source/algorithms/AppendSpectra-v1.rst +++ b/docs/source/algorithms/AppendSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyCalibration-v1.rst b/docs/source/algorithms/ApplyCalibration-v1.rst index 44f4c7933996d02212a769c755923e6fde13b11e..5f599a50a1d0d1599ac9bdd16b23ece061340167 100644 --- a/docs/source/algorithms/ApplyCalibration-v1.rst +++ b/docs/source/algorithms/ApplyCalibration-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyDeadTimeCorr-v1.rst b/docs/source/algorithms/ApplyDeadTimeCorr-v1.rst index 3234aa9f0e9bf83feaae370eb4a85f61ae8434b1..09c864e0d8287fe3a36cc787742fedc41c3c8b5f 100644 --- a/docs/source/algorithms/ApplyDeadTimeCorr-v1.rst +++ b/docs/source/algorithms/ApplyDeadTimeCorr-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyDetailedBalance-v1.rst b/docs/source/algorithms/ApplyDetailedBalance-v1.rst index 2b9603ffc68e68aae14b499b5210ef8b26619a0a..4c7e957b96a4a97e6fe019fa35d39c38e09dd605 100644 --- a/docs/source/algorithms/ApplyDetailedBalance-v1.rst +++ b/docs/source/algorithms/ApplyDetailedBalance-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyDetectorScanEffCorr-v1.rst b/docs/source/algorithms/ApplyDetectorScanEffCorr-v1.rst index e458f48465933ddb46fedd9091667162b6d309dc..f1de79c88979c57d09b545fa3f5b2e78697f78f8 100644 --- a/docs/source/algorithms/ApplyDetectorScanEffCorr-v1.rst +++ b/docs/source/algorithms/ApplyDetectorScanEffCorr-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyPaalmanPingsCorrection-v1.rst b/docs/source/algorithms/ApplyPaalmanPingsCorrection-v1.rst index 3e548a2644c862e5ff2c6407d9c6050274bfb673..fe194338505a992a36790dc66ec5a62f24e526ad 100644 --- a/docs/source/algorithms/ApplyPaalmanPingsCorrection-v1.rst +++ b/docs/source/algorithms/ApplyPaalmanPingsCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ApplyTransmissionCorrection-v1.rst b/docs/source/algorithms/ApplyTransmissionCorrection-v1.rst index 2d2524e45194389b0da2ba770696e94e4d950bab..0e887cd4626d890de362f7069da55add6c0b39c5 100644 --- a/docs/source/algorithms/ApplyTransmissionCorrection-v1.rst +++ b/docs/source/algorithms/ApplyTransmissionCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AsymmetryCalc-v1.rst b/docs/source/algorithms/AsymmetryCalc-v1.rst index 311e2821e3cc7c8ec61f024f076cfc9997dd3ae2..670fac8573e12f86b9f4843dd214a3276318894c 100644 --- a/docs/source/algorithms/AsymmetryCalc-v1.rst +++ b/docs/source/algorithms/AsymmetryCalc-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Authenticate-v1.rst b/docs/source/algorithms/Authenticate-v1.rst index b53f067c18984c784d931380089cd4576781979d..664b7ea7fb280c17b12276276292c1beaeef652a 100644 --- a/docs/source/algorithms/Authenticate-v1.rst +++ b/docs/source/algorithms/Authenticate-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Authenticate-v2.rst b/docs/source/algorithms/Authenticate-v2.rst index 785ed8e1011c5dcfaf855414a539cdbde5aae18a..ae46874065e54a33ee5a13cf1b393711c118de79 100644 --- a/docs/source/algorithms/Authenticate-v2.rst +++ b/docs/source/algorithms/Authenticate-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/AverageLogData-v1.rst b/docs/source/algorithms/AverageLogData-v1.rst index a987825908e6aad802ff5ff565c38c1aa7764603..bec9ee6bc2daa6400f862797e837657234b79944 100644 --- a/docs/source/algorithms/AverageLogData-v1.rst +++ b/docs/source/algorithms/AverageLogData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BASISDiffraction-v1.rst b/docs/source/algorithms/BASISDiffraction-v1.rst index 4585559694528a4304019013bfac1f4ee2aad102..138a4783f1884e71d92b0203c68ed21f3951bb85 100644 --- a/docs/source/algorithms/BASISDiffraction-v1.rst +++ b/docs/source/algorithms/BASISDiffraction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -43,7 +43,7 @@ and isotropic scattering to determine instrument efficiency per detector. If no vanadium is provided, all detectors are assumed to have the same efficiency Determine Single Crystal Diffraction -==================================== +#################################### Creates a diffraction pattern from a set of runs implementing a rotational scan of the sample around the vertical axis. The @@ -52,7 +52,7 @@ corresponding goniometer's rotation should be logged under log name angle. Sample orientation -~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^ **VectorU**: Vector along k_i, when goniometer is at offset. @@ -60,7 +60,7 @@ Sample orientation offset. Diffraction preferences -~~~~~~~~~~~~~~~~~~~~~~~ +^^^^^^^^^^^^^^^^^^^^^^^ Most of the scattering occurs in the plane defined by VectorU and VectorV. Please choose Uproj and Vproj defining a plane that is as close as possible diff --git a/docs/source/algorithms/BASISReduction-v1.rst b/docs/source/algorithms/BASISReduction-v1.rst index 93dc4a8b287f91f860bd693e02ee020b9ce650cb..c0408383ab09ff343e9f02d9b43e60c80dbfcc7e 100644 --- a/docs/source/algorithms/BASISReduction-v1.rst +++ b/docs/source/algorithms/BASISReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BASISReduction311-v1.rst b/docs/source/algorithms/BASISReduction311-v1.rst index 430fb2017b6f7710fa927ced1bebaa18b7039c85..6ca9c90a26815ee27b1598428ad97708ba850505 100644 --- a/docs/source/algorithms/BASISReduction311-v1.rst +++ b/docs/source/algorithms/BASISReduction311-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -32,7 +32,7 @@ lower boundary the bin with the minimum momentum, the bin width, and the upper boundary ofthe bin with the maximum momentum. Reflection Selector -=================== +################### There are typical values for the properties of the 311 reflection: diff --git a/docs/source/algorithms/BayesQuasi-v1.rst b/docs/source/algorithms/BayesQuasi-v1.rst index 1fd36c075b17cafa2f09f3093a072439da353e19..720e00dc3fa1b4f65dc2c7cf49d826c9f69619e6 100644 --- a/docs/source/algorithms/BayesQuasi-v1.rst +++ b/docs/source/algorithms/BayesQuasi-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BayesStretch-v1.rst b/docs/source/algorithms/BayesStretch-v1.rst index 5fdf7020a3051b7b33e4830ec7c1517856bd9f02..2fe36ac54849d9e73eff3a83c6b9fdef8d951d1b 100644 --- a/docs/source/algorithms/BayesStretch-v1.rst +++ b/docs/source/algorithms/BayesStretch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Bin2DPowderDiffraction-v1.rst b/docs/source/algorithms/Bin2DPowderDiffraction-v1.rst index 32317820bc9db3d987805174dfe864834bc2dcf5..f890cf6ba4613a8a36cd8892efcf7598d422c3ec 100644 --- a/docs/source/algorithms/Bin2DPowderDiffraction-v1.rst +++ b/docs/source/algorithms/Bin2DPowderDiffraction-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BinMD-v1.rst b/docs/source/algorithms/BinMD-v1.rst index d55794cbcd476111f9d4678bf0d26b62ed428e7f..dd74733829faea1d70c13d73171ab5d070e177fd 100644 --- a/docs/source/algorithms/BinMD-v1.rst +++ b/docs/source/algorithms/BinMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BinWidthAtX-v1.rst b/docs/source/algorithms/BinWidthAtX-v1.rst index 9d65bc04234a63f50605ce9a74ffa879634c32ec..23434ef27e59a7ac391f18dff1a4b85612309bec 100644 --- a/docs/source/algorithms/BinWidthAtX-v1.rst +++ b/docs/source/algorithms/BinWidthAtX-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BinaryOperateMasks-v1.rst b/docs/source/algorithms/BinaryOperateMasks-v1.rst index c8b284618f9d717db99792b08265fc710c132f4c..e43c307252275c1c8091a8a95666f16cf79dd057 100644 --- a/docs/source/algorithms/BinaryOperateMasks-v1.rst +++ b/docs/source/algorithms/BinaryOperateMasks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/BroadcastWorkspace-v1.rst b/docs/source/algorithms/BroadcastWorkspace-v1.rst index ac4e4c529d0a28cc275df56fb9818ca058af1c8a..ca441f47ce6ae9d4b1b830fb0b90ce6ca32191c6 100644 --- a/docs/source/algorithms/BroadcastWorkspace-v1.rst +++ b/docs/source/algorithms/BroadcastWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalMuonDeadTime-v1.rst b/docs/source/algorithms/CalMuonDeadTime-v1.rst index 25e721cd2a81a3c2b5edc454728566b926723fcb..b34e67d828711c6c3788fbbb930cd7d4b76e8259 100644 --- a/docs/source/algorithms/CalMuonDeadTime-v1.rst +++ b/docs/source/algorithms/CalMuonDeadTime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalMuonDetectorPhases-v1.rst b/docs/source/algorithms/CalMuonDetectorPhases-v1.rst index 45edeb936159eed0eaef0efb0f5932fed0b2a525..833c17388531c6771d4a6413c8c7086be8c7b5a7 100644 --- a/docs/source/algorithms/CalMuonDetectorPhases-v1.rst +++ b/docs/source/algorithms/CalMuonDetectorPhases-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateChiSquared-v1.rst b/docs/source/algorithms/CalculateChiSquared-v1.rst index 03ba5e7f4a095c957738d4b764a31cdccd7614c1..e96c3a6b10ef2af55cd50f433b4d741f5c7cd61a 100644 --- a/docs/source/algorithms/CalculateChiSquared-v1.rst +++ b/docs/source/algorithms/CalculateChiSquared-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -34,7 +34,7 @@ Finally, ChiSquaredWeightedDividedByDOF is :math:`\chi_{4}^{2} = \chi_{3}^{2} / DOF` Parameter errors -================ +################ Setting the Output property to a non-empty string makes the algorithm explore the surface of the :math:`\chi^{2}` around its minimum and estimate the standard deviations for the parameters. The value of the property is a base name diff --git a/docs/source/algorithms/CalculateCostFunction-v1.rst b/docs/source/algorithms/CalculateCostFunction-v1.rst index 5bd9729208ffae7a40ed0b370b07cec32e5d58ae..eec1d6353e41fa6bb2ad84caf7467c022d560346 100644 --- a/docs/source/algorithms/CalculateCostFunction-v1.rst +++ b/docs/source/algorithms/CalculateCostFunction-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateCountRate-v1.rst b/docs/source/algorithms/CalculateCountRate-v1.rst index acdaee775c530e1c45455cf0ab4a4c6e2cb0a6d5..4239df77670319eb1f3d307ee9804a849e9163d4 100644 --- a/docs/source/algorithms/CalculateCountRate-v1.rst +++ b/docs/source/algorithms/CalculateCountRate-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateCoverageDGS-v1.rst b/docs/source/algorithms/CalculateCoverageDGS-v1.rst index 7dad0cf83de44bfbb50d4ef8c9de1c1655135a4b..53b665d420b9598c1717284a7566200452be106d 100644 --- a/docs/source/algorithms/CalculateCoverageDGS-v1.rst +++ b/docs/source/algorithms/CalculateCoverageDGS-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateDIFC-v1.rst b/docs/source/algorithms/CalculateDIFC-v1.rst index 6191fad999410a6355d750ef3f6e15b00001f69f..33baf51d2d551928098b12fc655a2e220c2ff025 100644 --- a/docs/source/algorithms/CalculateDIFC-v1.rst +++ b/docs/source/algorithms/CalculateDIFC-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateEfficiency-v1.rst b/docs/source/algorithms/CalculateEfficiency-v1.rst index 28cf323f3d29028b7a5805de00c529400d4f0162..7de882a71496a0ef8bd9dc464d2a15916981357f 100644 --- a/docs/source/algorithms/CalculateEfficiency-v1.rst +++ b/docs/source/algorithms/CalculateEfficiency-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateFlatBackground-v1.rst b/docs/source/algorithms/CalculateFlatBackground-v1.rst index 10195afcb26a7ef69f092ce3a47ac917002ddd32..5c01a59b2dd41c06b6c121ec4e4b6fb9da2b8af5 100644 --- a/docs/source/algorithms/CalculateFlatBackground-v1.rst +++ b/docs/source/algorithms/CalculateFlatBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateMonteCarloAbsorption-v1.rst b/docs/source/algorithms/CalculateMonteCarloAbsorption-v1.rst index 5a5e85e049c3d461fc0e73c8a55fa55aef8cbdb1..a9c5d549076647374ccf19db429eb55f83c45af3 100644 --- a/docs/source/algorithms/CalculateMonteCarloAbsorption-v1.rst +++ b/docs/source/algorithms/CalculateMonteCarloAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateMuonAsymmetry-v1.rst b/docs/source/algorithms/CalculateMuonAsymmetry-v1.rst index af7fda4820886fddfe633f98695355ea5ee77d50..21af76b939e588efa5ad98dc686fcfc363038e94 100644 --- a/docs/source/algorithms/CalculateMuonAsymmetry-v1.rst +++ b/docs/source/algorithms/CalculateMuonAsymmetry-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculatePeaksHKL-v1.rst b/docs/source/algorithms/CalculatePeaksHKL-v1.rst index 2d18a6150c5521a01b3a468a43c6b076dee53c7f..bbcac2512cf50d45e0f9b95d396a8ae5d0a74ec0 100644 --- a/docs/source/algorithms/CalculatePeaksHKL-v1.rst +++ b/docs/source/algorithms/CalculatePeaksHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculatePolynomialBackground-v1.rst b/docs/source/algorithms/CalculatePolynomialBackground-v1.rst index 4887185a85b59e06f4367d95b6008ed308fefab5..06f99fc8f85fb17700587238c3ddab411a72cb47 100644 --- a/docs/source/algorithms/CalculatePolynomialBackground-v1.rst +++ b/docs/source/algorithms/CalculatePolynomialBackground-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateSampleTransmission-v1.rst b/docs/source/algorithms/CalculateSampleTransmission-v1.rst index f062723d18ea07c642e1db87734d387198ef9108..b1bef7feac5129f82bfae19654a66e91c1624867 100644 --- a/docs/source/algorithms/CalculateSampleTransmission-v1.rst +++ b/docs/source/algorithms/CalculateSampleTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateSlits-v1.rst b/docs/source/algorithms/CalculateSlits-v1.rst index cca529d82fff7bdcfac3c3ae43cf9699ea8f889f..1b2967b0baa9a12b79ca56c2bfad365c806dd17a 100644 --- a/docs/source/algorithms/CalculateSlits-v1.rst +++ b/docs/source/algorithms/CalculateSlits-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateTransmission-v1.rst b/docs/source/algorithms/CalculateTransmission-v1.rst index 5bfd0afedd12934588f29ae9690714a27bb6f33f..461cfaa8fd65ffe269560b96820c738bed842d52 100644 --- a/docs/source/algorithms/CalculateTransmission-v1.rst +++ b/docs/source/algorithms/CalculateTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateTransmissionBeamSpreader-v1.rst b/docs/source/algorithms/CalculateTransmissionBeamSpreader-v1.rst index 71a50f3095f9e0bed59920c4b0b06a18b8f06090..010fbcf80f9fe7adb32f920b425a8b9c91a08541 100644 --- a/docs/source/algorithms/CalculateTransmissionBeamSpreader-v1.rst +++ b/docs/source/algorithms/CalculateTransmissionBeamSpreader-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateUMatrix-v1.rst b/docs/source/algorithms/CalculateUMatrix-v1.rst index f72fc9099416b7a8994a64a9468dfe9705e58111..b729b1be1c66a7060e62840070ad11a5f763185f 100644 --- a/docs/source/algorithms/CalculateUMatrix-v1.rst +++ b/docs/source/algorithms/CalculateUMatrix-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalculateZscore-v1.rst b/docs/source/algorithms/CalculateZscore-v1.rst index d444025b3f1aea28b0d79242cf92d3f9a6cb1a92..b422c76d5c65691d9e0f83e8c5040188b7ac5cb1 100644 --- a/docs/source/algorithms/CalculateZscore-v1.rst +++ b/docs/source/algorithms/CalculateZscore-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CalibrateRectangularDetectors-v1.rst b/docs/source/algorithms/CalibrateRectangularDetectors-v1.rst index 561db96cb82169c04c844ead79b871a43c949d2d..21b98f4b4200415d96ee1845f5bb4e7d25c2cb95 100644 --- a/docs/source/algorithms/CalibrateRectangularDetectors-v1.rst +++ b/docs/source/algorithms/CalibrateRectangularDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogDownloadDataFiles-v1.rst b/docs/source/algorithms/CatalogDownloadDataFiles-v1.rst index d0ff2cba2be25bed331e54a3cd4e47eefc206d59..462f7007d3e24f76b2b567bbe763a17f4593ed80 100644 --- a/docs/source/algorithms/CatalogDownloadDataFiles-v1.rst +++ b/docs/source/algorithms/CatalogDownloadDataFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogGetDataFiles-v1.rst b/docs/source/algorithms/CatalogGetDataFiles-v1.rst index 3688e18d63a69d74fb72e98c973385d3882ba03b..661daf99a694b18d733184885f0bfd014fb9405a 100644 --- a/docs/source/algorithms/CatalogGetDataFiles-v1.rst +++ b/docs/source/algorithms/CatalogGetDataFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogGetDataSets-v1.rst b/docs/source/algorithms/CatalogGetDataSets-v1.rst index 6727e74f9f2c5cc7dad5291ccad1cb2291037557..fa5707b91452d9306a5ac36d4a67e12c8cab71b4 100644 --- a/docs/source/algorithms/CatalogGetDataSets-v1.rst +++ b/docs/source/algorithms/CatalogGetDataSets-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogKeepAlive-v1.rst b/docs/source/algorithms/CatalogKeepAlive-v1.rst index 755580feafbc57c16d02f5171e49ee2cfe596b80..ec38fc828cabd0d406f1df9040548fbc5b0fec6e 100644 --- a/docs/source/algorithms/CatalogKeepAlive-v1.rst +++ b/docs/source/algorithms/CatalogKeepAlive-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogListInstruments-v1.rst b/docs/source/algorithms/CatalogListInstruments-v1.rst index 5fe41febc6db3d8b60eb6321d69be68dc6e6adde..8062a2c02b5043ff9b36f4a6369ccdc50dd79843 100644 --- a/docs/source/algorithms/CatalogListInstruments-v1.rst +++ b/docs/source/algorithms/CatalogListInstruments-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogListInvestigationTypes-v1.rst b/docs/source/algorithms/CatalogListInvestigationTypes-v1.rst index 9a265490df931d35d9fe95305af74613d75f588d..85ed1401cedf1cab099522a23ba5fe9aad600239 100644 --- a/docs/source/algorithms/CatalogListInvestigationTypes-v1.rst +++ b/docs/source/algorithms/CatalogListInvestigationTypes-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogLogin-v1.rst b/docs/source/algorithms/CatalogLogin-v1.rst index 34693f8be889e9e89fc82f025b24ebf3500445a3..dbcca9fa7e427afb902dddc35e133d23ed4b081c 100644 --- a/docs/source/algorithms/CatalogLogin-v1.rst +++ b/docs/source/algorithms/CatalogLogin-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogLogout-v1.rst b/docs/source/algorithms/CatalogLogout-v1.rst index 4c5e02a01cdfae4c14239a230460cd52c5a9554c..9f4b99432b1c79a0a7899f1da9e9bf17dde74adc 100644 --- a/docs/source/algorithms/CatalogLogout-v1.rst +++ b/docs/source/algorithms/CatalogLogout-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogMyDataSearch-v1.rst b/docs/source/algorithms/CatalogMyDataSearch-v1.rst index 54a479042e5a1cb3e9b6aaee87cf295b98beefd9..798ae42d16c791eebbdae16362f794ed4f12edd3 100644 --- a/docs/source/algorithms/CatalogMyDataSearch-v1.rst +++ b/docs/source/algorithms/CatalogMyDataSearch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogPublish-v1.rst b/docs/source/algorithms/CatalogPublish-v1.rst index 3e17d508178ef9aaf781c0cd4f0601cf8db47edd..d7a82865bcb027a70a8bb9283069e3772e31f0e2 100644 --- a/docs/source/algorithms/CatalogPublish-v1.rst +++ b/docs/source/algorithms/CatalogPublish-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CatalogSearch-v1.rst b/docs/source/algorithms/CatalogSearch-v1.rst index a57ff5abfc875f9a55df432366b60277e827598f..955cb0a4cde1931f49a12887533d892fbd8098bd 100644 --- a/docs/source/algorithms/CatalogSearch-v1.rst +++ b/docs/source/algorithms/CatalogSearch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CentroidPeaks-v1.rst b/docs/source/algorithms/CentroidPeaks-v1.rst index 29469ed3d93d6ce04ff30f915a1343cec1750737..68797211ba7a250a062817a855c06a656d72f389 100644 --- a/docs/source/algorithms/CentroidPeaks-v1.rst +++ b/docs/source/algorithms/CentroidPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CentroidPeaksMD-v1.rst b/docs/source/algorithms/CentroidPeaksMD-v1.rst index e36680d16e927bd77cdac68941edf68619477896..fe919f273ecd1566a3d3325a563b6f67113d4e73 100644 --- a/docs/source/algorithms/CentroidPeaksMD-v1.rst +++ b/docs/source/algorithms/CentroidPeaksMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CentroidPeaksMD-v2.rst b/docs/source/algorithms/CentroidPeaksMD-v2.rst index 72f79075cd1e0ad815e6fc50fc931c06cbd520da..98e01b64e9b252f3b0016d85c26517052e2b0e9b 100644 --- a/docs/source/algorithms/CentroidPeaksMD-v2.rst +++ b/docs/source/algorithms/CentroidPeaksMD-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChangeBinOffset-v1.rst b/docs/source/algorithms/ChangeBinOffset-v1.rst index 69738abb70a6e1865d9d49209ba111e42b5c7a9e..9ee68e7ee1b52c48906d104047e9a0365e64c8ac 100644 --- a/docs/source/algorithms/ChangeBinOffset-v1.rst +++ b/docs/source/algorithms/ChangeBinOffset-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChangeLogTime-v1.rst b/docs/source/algorithms/ChangeLogTime-v1.rst index 9e41dd1a69b69a4ba542f4b287415d50ac1ae798..38f19d3efd0052bc01d35622783e2419aaa1f3d2 100644 --- a/docs/source/algorithms/ChangeLogTime-v1.rst +++ b/docs/source/algorithms/ChangeLogTime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChangePulsetime-v1.rst b/docs/source/algorithms/ChangePulsetime-v1.rst index 00cd7903937c1b51f2aed21480a6ae8895d3955b..0ce29e0158ce386e810dc50cb9ecd887b9fb9521 100644 --- a/docs/source/algorithms/ChangePulsetime-v1.rst +++ b/docs/source/algorithms/ChangePulsetime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChangeQConvention-v1.rst b/docs/source/algorithms/ChangeQConvention-v1.rst index c76f26b1497a570b278a75c06317a1c9a3217643..bef585d464e0cce34a8e7c3785c7d190331ec699 100644 --- a/docs/source/algorithms/ChangeQConvention-v1.rst +++ b/docs/source/algorithms/ChangeQConvention-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChangeTimeZero-v1.rst b/docs/source/algorithms/ChangeTimeZero-v1.rst index 79804c894305842be556d2ad2016a1cb90fe5bc3..bd81c0b1c160b10139233003e20a43c049ad7b92 100644 --- a/docs/source/algorithms/ChangeTimeZero-v1.rst +++ b/docs/source/algorithms/ChangeTimeZero-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CheckForSampleLogs-v1.rst b/docs/source/algorithms/CheckForSampleLogs-v1.rst index d97dbd87a671dd6b61752a34935a841edfaf6db8..de24be8a0079e53a6b508f203944406897f05415 100644 --- a/docs/source/algorithms/CheckForSampleLogs-v1.rst +++ b/docs/source/algorithms/CheckForSampleLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CheckMantidVersion-v1.rst b/docs/source/algorithms/CheckMantidVersion-v1.rst index bfb5768748c0848e3770a18df662ded253427d8e..595e956309b44895322993a74ecd9dd95df62666 100644 --- a/docs/source/algorithms/CheckMantidVersion-v1.rst +++ b/docs/source/algorithms/CheckMantidVersion-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CheckWorkspacesMatch-v1.rst b/docs/source/algorithms/CheckWorkspacesMatch-v1.rst index ce78cc7d3c43aee7545b734914393f7f9fc5458f..34ba2f073a1614ed6559d3df52da86da0567ee49 100644 --- a/docs/source/algorithms/CheckWorkspacesMatch-v1.rst +++ b/docs/source/algorithms/CheckWorkspacesMatch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ChopData-v1.rst b/docs/source/algorithms/ChopData-v1.rst index 90ad0f9452199c6af8c14b126096b088619a3d81..07a53ced0fad12ed8fde6c6499f81c982895c14e 100644 --- a/docs/source/algorithms/ChopData-v1.rst +++ b/docs/source/algorithms/ChopData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CleanFileCache-v1.rst b/docs/source/algorithms/CleanFileCache-v1.rst index 236e24ec9ec2183470241246b3d759c5ca98f3ba..9e8c2fa0a757b678095873a689284b042d2a54c0 100644 --- a/docs/source/algorithms/CleanFileCache-v1.rst +++ b/docs/source/algorithms/CleanFileCache-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ClearCache-v1.rst b/docs/source/algorithms/ClearCache-v1.rst index d630d350ad907c0717edf3f5aaddf66b32a30d19..d4ae041fa314a7358ee1b8ee35721b4a8c32ec69 100644 --- a/docs/source/algorithms/ClearCache-v1.rst +++ b/docs/source/algorithms/ClearCache-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -20,7 +20,7 @@ Usage **Example - ClearCache** -.. testcode:: ClearCacheExample +.. code-block:: python filesRemoved = ClearCache(DownloadedInstrumentFileCache=True) @@ -32,8 +32,7 @@ Usage Output: -.. testoutput:: ClearCacheExample - :options: +ELLIPSIS +.. code-block:: python ... files were removed diff --git a/docs/source/algorithms/ClearInstrumentParameters-v1.rst b/docs/source/algorithms/ClearInstrumentParameters-v1.rst index 6b46c307eadb43bd2dde479be284783b13abe3ac..221189b6a350a7a9f2dc3ff263317872e02c2bb2 100644 --- a/docs/source/algorithms/ClearInstrumentParameters-v1.rst +++ b/docs/source/algorithms/ClearInstrumentParameters-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ClearMaskFlag-v1.rst b/docs/source/algorithms/ClearMaskFlag-v1.rst index a7954af4bf56087bf03c467ee1bfa0471fbdd8a0..d3697d77a46cfd44fa1dbdc16083c7475036a105 100644 --- a/docs/source/algorithms/ClearMaskFlag-v1.rst +++ b/docs/source/algorithms/ClearMaskFlag-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ClearMaskedSpectra-v1.rst b/docs/source/algorithms/ClearMaskedSpectra-v1.rst index 8574b039493519022bd0ec47722942f4b3c66b02..13a626fb6cdf37fb8bb16ea546f37ed821615750 100644 --- a/docs/source/algorithms/ClearMaskedSpectra-v1.rst +++ b/docs/source/algorithms/ClearMaskedSpectra-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ClearUB-v1.rst b/docs/source/algorithms/ClearUB-v1.rst index f7ddea6d04e6d15f8e44819a9ead3359312aba00..9edefe8e3860ac4e6483c7b5866bd03a904f652f 100644 --- a/docs/source/algorithms/ClearUB-v1.rst +++ b/docs/source/algorithms/ClearUB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CloneMDWorkspace-v1.rst b/docs/source/algorithms/CloneMDWorkspace-v1.rst index 3978dd6027783ad63014f92c8a353cdfc231622d..664ba2239bbd940b11d39ed3e44fd3bb7c6a6d82 100644 --- a/docs/source/algorithms/CloneMDWorkspace-v1.rst +++ b/docs/source/algorithms/CloneMDWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CloneWorkspace-v1.rst b/docs/source/algorithms/CloneWorkspace-v1.rst index d1b5458f355d7bade5f3fc35e693e3b86f0729c0..51718eba5019a5fd5101dc2cec0d232ab1f24d31 100644 --- a/docs/source/algorithms/CloneWorkspace-v1.rst +++ b/docs/source/algorithms/CloneWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CollectHB3AExperimentInfo-v1.rst b/docs/source/algorithms/CollectHB3AExperimentInfo-v1.rst index 8c4d91d2c0ca5b263344ef732c8d5426ffdbdf3c..075932fc57e96e1c13963f05b6579ad607a6aef2 100644 --- a/docs/source/algorithms/CollectHB3AExperimentInfo-v1.rst +++ b/docs/source/algorithms/CollectHB3AExperimentInfo-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CombinePeaksWorkspaces-v1.rst b/docs/source/algorithms/CombinePeaksWorkspaces-v1.rst index 1d3bf040e34af59af0b1831ba25a1f4a5fe2eaf1..f3f5534d12f27c82e56302ff53f109afb848666d 100644 --- a/docs/source/algorithms/CombinePeaksWorkspaces-v1.rst +++ b/docs/source/algorithms/CombinePeaksWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Comment-v1.rst b/docs/source/algorithms/Comment-v1.rst index aa250230abdf5da9e33eaf2036cb7bb06ab427ab..c592f7a2642e70383d56c3ec4d79aa69f3136fe6 100644 --- a/docs/source/algorithms/Comment-v1.rst +++ b/docs/source/algorithms/Comment-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CompactMD-v1.rst b/docs/source/algorithms/CompactMD-v1.rst index b49816bfe2f582d2d2b91954fadd367b19da1302..7eb52c0c5bf932dc588d9602cec3b1f82339cbe4 100644 --- a/docs/source/algorithms/CompactMD-v1.rst +++ b/docs/source/algorithms/CompactMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CompareMDWorkspaces-v1.rst b/docs/source/algorithms/CompareMDWorkspaces-v1.rst index f9c5e19a6cfa0e5795ef35b2e65905eef21a7018..6a95360b8497d102d4e9ee9b47fec92a1de2cd6b 100644 --- a/docs/source/algorithms/CompareMDWorkspaces-v1.rst +++ b/docs/source/algorithms/CompareMDWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CompareSampleLogs-v1.rst b/docs/source/algorithms/CompareSampleLogs-v1.rst index ce743b9a15440924fd4cb0df944b141f345b4181..6ba35f8a55eab816cc9a685668c00b841419ac9f 100644 --- a/docs/source/algorithms/CompareSampleLogs-v1.rst +++ b/docs/source/algorithms/CompareSampleLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CompareWorkspaces-v1.rst b/docs/source/algorithms/CompareWorkspaces-v1.rst index 10b56b5e7f30e19b77005aecf9f3b89522c441b7..edd066552cfe9d90acba1d7a4af214c7ae58226f 100644 --- a/docs/source/algorithms/CompareWorkspaces-v1.rst +++ b/docs/source/algorithms/CompareWorkspaces-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CompressEvents-v1.rst b/docs/source/algorithms/CompressEvents-v1.rst index b724fe240454a1a3a68fe6a90f98a937a312616b..31d04b4c265e2f995c8f80969bcdf73b55368e3a 100644 --- a/docs/source/algorithms/CompressEvents-v1.rst +++ b/docs/source/algorithms/CompressEvents-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -16,7 +16,7 @@ resolution. This switch is made by specifying a Without pulsetime resolution -============================ +############################ This algorithm starts by sorting the event lists by TOF (or whatever the independent axis is) and ignoring the pulsetime. Therefore you may @@ -43,7 +43,7 @@ changes to its X values (unit conversion for example), you have to use your best judgement for the Tolerance value. With pulsetime resolution -========================= +######################### Similar to the version without pulsetime resolution with a few key differences: diff --git a/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst b/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst index 48e59b72e4bc468c1f1749bc7f8158cd272da4fd..0a224767475ad0b3f9fe28c3cfbb367f62aefaab 100644 --- a/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst +++ b/docs/source/algorithms/ComputeCalibrationCoefVan-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ComputeIncoherentDOS-v1.rst b/docs/source/algorithms/ComputeIncoherentDOS-v1.rst index e6420dfc9ca66221f19fea17507bfc7c7c9c10ad..5d72a98029f2f4f85fc2aa622dbbc76428b58e91 100644 --- a/docs/source/algorithms/ComputeIncoherentDOS-v1.rst +++ b/docs/source/algorithms/ComputeIncoherentDOS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ComputeSensitivity-v1.rst b/docs/source/algorithms/ComputeSensitivity-v1.rst index 4d634d0189281f6bdc5c59d7d8f4ddf19d2e835a..d8a46b16cef52f37f75fd3c66453c3f08858f148 100644 --- a/docs/source/algorithms/ComputeSensitivity-v1.rst +++ b/docs/source/algorithms/ComputeSensitivity-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConjoinFiles-v1.rst b/docs/source/algorithms/ConjoinFiles-v1.rst index eb087a5e9ffba3fc4a65f52d574b6bf096dc5cc4..18c5fc1b4423d97617a5b9b18ae85fa36a358d01 100644 --- a/docs/source/algorithms/ConjoinFiles-v1.rst +++ b/docs/source/algorithms/ConjoinFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConjoinSpectra-v1.rst b/docs/source/algorithms/ConjoinSpectra-v1.rst index 5d12ae848478f90b9869dab522fc1d958633ee58..1de5a0aff85ac9eab4d1e70c164fa1681114ece7 100644 --- a/docs/source/algorithms/ConjoinSpectra-v1.rst +++ b/docs/source/algorithms/ConjoinSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConjoinWorkspaces-v1.rst b/docs/source/algorithms/ConjoinWorkspaces-v1.rst index ab027b06f819905a8b7b1df5e9c098faf4923ba3..a29f7aa4ffa2383a61b53b654098fcd24083c46c 100644 --- a/docs/source/algorithms/ConjoinWorkspaces-v1.rst +++ b/docs/source/algorithms/ConjoinWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConjoinXRuns-v1.rst b/docs/source/algorithms/ConjoinXRuns-v1.rst index 28b2c8b7803cd91ccd3505198b3ce595f8cdc69e..72524c195fbf05108da8f62627e89c842481e8e8 100644 --- a/docs/source/algorithms/ConjoinXRuns-v1.rst +++ b/docs/source/algorithms/ConjoinXRuns-v1.rst @@ -3,14 +3,14 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: Description ----------- -This algorithm joins the input workspaces into a single one by concatenating their spectra. The concatenation is done in the same order as in the input workspaces list. Consider using :ref:`SortXAxis <algm-SortXAxis>` afterwards, if necessary. The instrument and the units are copied from the first workspace. The sample logs are also copied from the first input, but the behaviour can be controlled by the instrument parameter file (IPF), as described in :ref:`MergeRuns <algm-MergeRuns>`. Furthermore, that behaviour can be overriden by providing input to the relevant optional properties of the algorithm. +This algorithm joins the input workspaces into a single one by concatenating their spectra. The concatenation is done in the same order as in the input workspaces list. Consider using :ref:`SortXAxis <algm-SortXAxis>` afterwards, if necessary. The instrument and the units are copied from the first workspace. The sample logs are also copied from the first input, but the behaviour can be controlled by the instrument parameter file (IPF), as described in :ref:`MergeRuns <algm-MergeRuns>`. Furthermore, that behaviour can be overriden by providing input to the relevant optional properties of the algorithm. This algorithm joins Dx values, if present. InputWorkspaces --------------- diff --git a/docs/source/algorithms/ConvertAxesToRealSpace-v1.rst b/docs/source/algorithms/ConvertAxesToRealSpace-v1.rst index fe11f4e7b475e4cc31670e6d5510261a5d076d5b..018ae20ab4a5c5fb45d6d55d996d0b27ae091007 100644 --- a/docs/source/algorithms/ConvertAxesToRealSpace-v1.rst +++ b/docs/source/algorithms/ConvertAxesToRealSpace-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertAxisByFormula-v1.rst b/docs/source/algorithms/ConvertAxisByFormula-v1.rst index 60d703e14b4f3d7b46953e690475d648f7b5a745..88cb4d06612375d2cd859aa78442a5e5b6d20fa5 100644 --- a/docs/source/algorithms/ConvertAxisByFormula-v1.rst +++ b/docs/source/algorithms/ConvertAxisByFormula-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertCWPDMDToSpectra-v1.rst b/docs/source/algorithms/ConvertCWPDMDToSpectra-v1.rst index a68b94e474bcce4b0d551ea976b2ba561fdf0c9a..39f63591a78b8b7e4e8702dbe27c2d8662d24446 100644 --- a/docs/source/algorithms/ConvertCWPDMDToSpectra-v1.rst +++ b/docs/source/algorithms/ConvertCWPDMDToSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertCWSDExpToMomentum-v1.rst b/docs/source/algorithms/ConvertCWSDExpToMomentum-v1.rst index f73282142aa6664a7fd9c12671ba551e60d2db06..b369acddac2ee23d237e905a55effd097eb3293a 100644 --- a/docs/source/algorithms/ConvertCWSDExpToMomentum-v1.rst +++ b/docs/source/algorithms/ConvertCWSDExpToMomentum-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertCWSDMDtoHKL-v1.rst b/docs/source/algorithms/ConvertCWSDMDtoHKL-v1.rst index a5fe1e7dceaaad46c26502eaad0fc7ac7eeaf641..5d07e1a6b65bb47dd5507a3326c1f000d92f2fd4 100644 --- a/docs/source/algorithms/ConvertCWSDMDtoHKL-v1.rst +++ b/docs/source/algorithms/ConvertCWSDMDtoHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertDiffCal-v1.rst b/docs/source/algorithms/ConvertDiffCal-v1.rst index 37ddd84ceabd61ee6ef7f7669f2b991b41998ec6..77f2f08a7b6de18083f895388a7cff98dc388b9a 100644 --- a/docs/source/algorithms/ConvertDiffCal-v1.rst +++ b/docs/source/algorithms/ConvertDiffCal-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertEmptyToTof-v1.rst b/docs/source/algorithms/ConvertEmptyToTof-v1.rst index 917c8f09d348c5800db4385427c31d3b894eb453..a9f436b2c3db803897c002958a76d87d9814bd3f 100644 --- a/docs/source/algorithms/ConvertEmptyToTof-v1.rst +++ b/docs/source/algorithms/ConvertEmptyToTof-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertFromDistribution-v1.rst b/docs/source/algorithms/ConvertFromDistribution-v1.rst index d4254dcd47e71bb53410978083bc3ae9dbc094a3..4e2a20cbf40e689661c0944e66f432ead1d7c0d7 100644 --- a/docs/source/algorithms/ConvertFromDistribution-v1.rst +++ b/docs/source/algorithms/ConvertFromDistribution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertMDHistoToMatrixWorkspace-v1.rst b/docs/source/algorithms/ConvertMDHistoToMatrixWorkspace-v1.rst index f43815f52678824ea801fdf1ae5fd7674bea2004..20247520553e0c4e1d4bd2ec5a197f9918bd529f 100644 --- a/docs/source/algorithms/ConvertMDHistoToMatrixWorkspace-v1.rst +++ b/docs/source/algorithms/ConvertMDHistoToMatrixWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertMultipleRunsToSingleCrystalMD-v1.rst b/docs/source/algorithms/ConvertMultipleRunsToSingleCrystalMD-v1.rst index 774bc57977458878f675ceb456a7c43bf1b5ab79..f26dd0f573fcfce6bd295204bd98c58b49205b61 100644 --- a/docs/source/algorithms/ConvertMultipleRunsToSingleCrystalMD-v1.rst +++ b/docs/source/algorithms/ConvertMultipleRunsToSingleCrystalMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertSnsRoiFileToMask-v1.rst b/docs/source/algorithms/ConvertSnsRoiFileToMask-v1.rst index e3315aae1c95d42c0708877555351f2be0ad91e0..daa157d1a89ad6cc20bb3edfc1ea5197b0e568df 100644 --- a/docs/source/algorithms/ConvertSnsRoiFileToMask-v1.rst +++ b/docs/source/algorithms/ConvertSnsRoiFileToMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertSpectrumAxis-v1.rst b/docs/source/algorithms/ConvertSpectrumAxis-v1.rst index 84599ff4a6562757005ead4435f4463d8534b51e..b9f2664bfdb1c571b39cb1b878af800c72215040 100644 --- a/docs/source/algorithms/ConvertSpectrumAxis-v1.rst +++ b/docs/source/algorithms/ConvertSpectrumAxis-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertSpectrumAxis-v2.rst b/docs/source/algorithms/ConvertSpectrumAxis-v2.rst index 1e79f4ab6e544f016b237721a1cbec0baff85cb2..862d0dae922c3de4a5a58ddb8ade800f56105328 100644 --- a/docs/source/algorithms/ConvertSpectrumAxis-v2.rst +++ b/docs/source/algorithms/ConvertSpectrumAxis-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertSpiceDataToRealSpace-v1.rst b/docs/source/algorithms/ConvertSpiceDataToRealSpace-v1.rst index ab02f5f03b42a72e0a3738023501bf3349d9e511..7b9e4474db0125b7d8b842f4d5f00ff129682757 100644 --- a/docs/source/algorithms/ConvertSpiceDataToRealSpace-v1.rst +++ b/docs/source/algorithms/ConvertSpiceDataToRealSpace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertTableToMatrixWorkspace-v1.rst b/docs/source/algorithms/ConvertTableToMatrixWorkspace-v1.rst index 8d86b1c18b62f8fe3f238db0898e7405941c1977..cbafc32b82d05596e745dabbb0cc415f17ccded2 100644 --- a/docs/source/algorithms/ConvertTableToMatrixWorkspace-v1.rst +++ b/docs/source/algorithms/ConvertTableToMatrixWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToConstantL2-v1.rst b/docs/source/algorithms/ConvertToConstantL2-v1.rst index abfa265e0139366892a0708a1852d43674fbc811..34ed360392dbab11717581f9380900f9442a3258 100644 --- a/docs/source/algorithms/ConvertToConstantL2-v1.rst +++ b/docs/source/algorithms/ConvertToConstantL2-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToDetectorFaceMD-v1.rst b/docs/source/algorithms/ConvertToDetectorFaceMD-v1.rst index 67ceea7278cea2e58213ac2fccc7ed167923c45c..8d14fc3b38c16d7c233dcd4d45cc636679173fbc 100644 --- a/docs/source/algorithms/ConvertToDetectorFaceMD-v1.rst +++ b/docs/source/algorithms/ConvertToDetectorFaceMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v1.rst b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v1.rst index c3733997857aa96776c3576d0731207a9c87297e..95f35cef4c419d6b8885908c730d33f04a4c089e 100644 --- a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v1.rst +++ b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v2.rst b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v2.rst index bd352ee617991140bf6c6605adc8c047c73e76ed..0b944bf3bf78ff11fb6a8347b205c34709ee8c8d 100644 --- a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v2.rst +++ b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v3.rst b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v3.rst index 513558ad5e9cd143de006e82eedfe78d33f8f81a..3f0ca34dd28a66f3f1a5d382baaa38f85b19958d 100644 --- a/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v3.rst +++ b/docs/source/algorithms/ConvertToDiffractionMDWorkspace-v3.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToDistribution-v1.rst b/docs/source/algorithms/ConvertToDistribution-v1.rst index d753ba8c5d557e33b1f3d346e94823bbc6390431..d1660ddaf72ff579adb828173b30b028ecc80cdf 100644 --- a/docs/source/algorithms/ConvertToDistribution-v1.rst +++ b/docs/source/algorithms/ConvertToDistribution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToEventWorkspace-v1.rst b/docs/source/algorithms/ConvertToEventWorkspace-v1.rst index 15217a14e9ce8d18b937d3c942f87b2264222be7..b5ed0670cba9c61fe7bcb44f113d6d3e984bd4a6 100644 --- a/docs/source/algorithms/ConvertToEventWorkspace-v1.rst +++ b/docs/source/algorithms/ConvertToEventWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToHistogram-v1.rst b/docs/source/algorithms/ConvertToHistogram-v1.rst index ba86710722ecba4f09ceb4f5f6fbb87932be2c87..a3a26052713815759fb5978756e29996c5b5dd44 100644 --- a/docs/source/algorithms/ConvertToHistogram-v1.rst +++ b/docs/source/algorithms/ConvertToHistogram-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToMD-v1.rst b/docs/source/algorithms/ConvertToMD-v1.rst index e822302682555ca0c97a5d72bf355a8e0497ea79..35b37c45c04ab3534278b2bd2846e498c77d88e5 100644 --- a/docs/source/algorithms/ConvertToMD-v1.rst +++ b/docs/source/algorithms/ConvertToMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToMDMinMaxGlobal-v1.rst b/docs/source/algorithms/ConvertToMDMinMaxGlobal-v1.rst index 974b11cc4ef5eeaaccf0c7c4e0d4260473b4881a..cbb9f6ad6639efb42a8b0bc681806f81a05e3e92 100644 --- a/docs/source/algorithms/ConvertToMDMinMaxGlobal-v1.rst +++ b/docs/source/algorithms/ConvertToMDMinMaxGlobal-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToMDMinMaxLocal-v1.rst b/docs/source/algorithms/ConvertToMDMinMaxLocal-v1.rst index 8974a0e5da4e7dde0a11ee90a0b79b018407e319..66bf54e4e013d7c439134451618c67febb5ff5f8 100644 --- a/docs/source/algorithms/ConvertToMDMinMaxLocal-v1.rst +++ b/docs/source/algorithms/ConvertToMDMinMaxLocal-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToMatrixWorkspace-v1.rst b/docs/source/algorithms/ConvertToMatrixWorkspace-v1.rst index 3aecaa2f8d8b5f6d63e3077adadbd8b9c64a3cd7..a95ed0e480b1b7b07dc34d1d6baa0c6bbc4e8797 100644 --- a/docs/source/algorithms/ConvertToMatrixWorkspace-v1.rst +++ b/docs/source/algorithms/ConvertToMatrixWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToPointData-v1.rst b/docs/source/algorithms/ConvertToPointData-v1.rst index 2eff633e845b951fa22402a418a595fd5b8aace2..b9811d6ab5ecdc4a64ae7cf86b90726e10a7185b 100644 --- a/docs/source/algorithms/ConvertToPointData-v1.rst +++ b/docs/source/algorithms/ConvertToPointData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToReflectometryQ-v1.rst b/docs/source/algorithms/ConvertToReflectometryQ-v1.rst index f97a14c55836cbb10bdbfb905bd96bda572637aa..a006f9bdc7cd8e690340779f65f05b6384a994fd 100644 --- a/docs/source/algorithms/ConvertToReflectometryQ-v1.rst +++ b/docs/source/algorithms/ConvertToReflectometryQ-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertToYSpace-v1.rst b/docs/source/algorithms/ConvertToYSpace-v1.rst index b1cc08cc506cab3c4c983239658cca78869ae515..42981b13a1b13d1b2529545c4cca43210965468d 100644 --- a/docs/source/algorithms/ConvertToYSpace-v1.rst +++ b/docs/source/algorithms/ConvertToYSpace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertUnits-v1.rst b/docs/source/algorithms/ConvertUnits-v1.rst index c755f197ba76df381c66d7f5e4a17233b0df78df..1e37613ff86e73b409bc51adcd7ed7f84d62df74 100644 --- a/docs/source/algorithms/ConvertUnits-v1.rst +++ b/docs/source/algorithms/ConvertUnits-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst b/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst index fc6e37b0c5370e561651e04b50337d62001ae349..c1c2d5f352359cac7aefc5c15be65363d233be42 100644 --- a/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst +++ b/docs/source/algorithms/ConvertUnitsUsingDetectorTable-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvolutionFitSequential-v1.rst b/docs/source/algorithms/ConvolutionFitSequential-v1.rst index df1d4afc7319f0d50d05b22674bb44ce0d54fa03..92b2d66d6e97f37b7479596211d8c4c2410edfc0 100644 --- a/docs/source/algorithms/ConvolutionFitSequential-v1.rst +++ b/docs/source/algorithms/ConvolutionFitSequential-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ConvolveWorkspaces-v1.rst b/docs/source/algorithms/ConvolveWorkspaces-v1.rst index fd67dcf082c47e52312259bbd36bf501aa01ab73..2ead5bc04637464fa81b2a764494379aaee627bf 100644 --- a/docs/source/algorithms/ConvolveWorkspaces-v1.rst +++ b/docs/source/algorithms/ConvolveWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CopyDetectorMapping-v1.rst b/docs/source/algorithms/CopyDetectorMapping-v1.rst index d03fe81b0830c1d62f01dd790b2a8629a1e93b94..f8b034681c936e9323cfd16f132ebe36f7be8731 100644 --- a/docs/source/algorithms/CopyDetectorMapping-v1.rst +++ b/docs/source/algorithms/CopyDetectorMapping-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CopyInstrumentParameters-v1.rst b/docs/source/algorithms/CopyInstrumentParameters-v1.rst index 434ea4a7f72753798383b815d21b518af0a6d017..678de4f69682c3bb894a3bdb5eed3a841ab8e2dd 100644 --- a/docs/source/algorithms/CopyInstrumentParameters-v1.rst +++ b/docs/source/algorithms/CopyInstrumentParameters-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CopyLogs-v1.rst b/docs/source/algorithms/CopyLogs-v1.rst index a9cb195add6e4379c7e242eae5ebcdf34ccd625b..a003eee7564c12f178f4775912e99fae6979edde 100644 --- a/docs/source/algorithms/CopyLogs-v1.rst +++ b/docs/source/algorithms/CopyLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CopySample-v1.rst b/docs/source/algorithms/CopySample-v1.rst index b86987f43c51bd514437e9ad831f972f473db7db..dd7c0c87dcdfc33397838220e88224856586fc9c 100644 --- a/docs/source/algorithms/CopySample-v1.rst +++ b/docs/source/algorithms/CopySample-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorelliCrossCorrelate-v1.rst b/docs/source/algorithms/CorelliCrossCorrelate-v1.rst index daec61b383639a1c2dca468418dcee019f805c3e..0f4905988f9a98d536fd6ebb6a510bed080ff47d 100644 --- a/docs/source/algorithms/CorelliCrossCorrelate-v1.rst +++ b/docs/source/algorithms/CorelliCrossCorrelate-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorrectKiKf-v1.rst b/docs/source/algorithms/CorrectKiKf-v1.rst index ec0daa197c7b7fb55e51b59a81a1c331cf1f55d0..77c39bb6e766dd6d29ce85d852e4917d18c75d8f 100644 --- a/docs/source/algorithms/CorrectKiKf-v1.rst +++ b/docs/source/algorithms/CorrectKiKf-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorrectLogTimes-v1.rst b/docs/source/algorithms/CorrectLogTimes-v1.rst index 12bb2c85c6ce55d8dc84de877a9405100f94e859..f460a676355e08aca54eb9f0c727c58d3c863d30 100644 --- a/docs/source/algorithms/CorrectLogTimes-v1.rst +++ b/docs/source/algorithms/CorrectLogTimes-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorrectTOF-v1.rst b/docs/source/algorithms/CorrectTOF-v1.rst index 9fe776bc90b585a1b305be7ce25ad30ccb1f442f..16eb68c6f1a366cb226436f92b27a49680b9daba 100644 --- a/docs/source/algorithms/CorrectTOF-v1.rst +++ b/docs/source/algorithms/CorrectTOF-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorrectTOFAxis-v1.rst b/docs/source/algorithms/CorrectTOFAxis-v1.rst index edebd7f668b1af564fdf09871d4ae1f04efb1100..92464f500e6803c096f8e52e582578786b753278 100644 --- a/docs/source/algorithms/CorrectTOFAxis-v1.rst +++ b/docs/source/algorithms/CorrectTOFAxis-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CorrectToFile-v1.rst b/docs/source/algorithms/CorrectToFile-v1.rst index 08d0ec0525bbd3d5b2e349d0700d26c1b3407fe6..75b1473c8889bb9dc4c767515efbd309484eb26c 100644 --- a/docs/source/algorithms/CorrectToFile-v1.rst +++ b/docs/source/algorithms/CorrectToFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CountReflections-v1.rst b/docs/source/algorithms/CountReflections-v1.rst index 5d404ab75c48be0b50faf0b9c57177744d127593..764b1c8fa2627c81a6ab49caa37da7e932f0e556 100644 --- a/docs/source/algorithms/CountReflections-v1.rst +++ b/docs/source/algorithms/CountReflections-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateCacheFilename-v1.rst b/docs/source/algorithms/CreateCacheFilename-v1.rst index 4f292a710662190be49346aef372da7d639c3295..c27b7b290bcdab9244d9fa899946a7d798b3602b 100644 --- a/docs/source/algorithms/CreateCacheFilename-v1.rst +++ b/docs/source/algorithms/CreateCacheFilename-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateCalFileByNames-v1.rst b/docs/source/algorithms/CreateCalFileByNames-v1.rst index 35952daf80fc12cdbb4ce8f2bcc6a82ecb28dbd6..d1dce35d1bdef230a7ddb53c964c63e7255094ea 100644 --- a/docs/source/algorithms/CreateCalFileByNames-v1.rst +++ b/docs/source/algorithms/CreateCalFileByNames-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateChopperModel-v1.rst b/docs/source/algorithms/CreateChopperModel-v1.rst index 0494f9b68c45e02bc5e7a92fe34bec1cd6910136..441734571edb4ddbd45ae0a47bee28dcad596e8f 100644 --- a/docs/source/algorithms/CreateChopperModel-v1.rst +++ b/docs/source/algorithms/CreateChopperModel-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateChunkingFromInstrument-v1.rst b/docs/source/algorithms/CreateChunkingFromInstrument-v1.rst index 3486c253d892a28e6318ad8992a3de44bcc1f093..d457ce06b8c8fc4b497b6af1a205148d20fc74c5 100644 --- a/docs/source/algorithms/CreateChunkingFromInstrument-v1.rst +++ b/docs/source/algorithms/CreateChunkingFromInstrument-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateDummyCalFile-v1.rst b/docs/source/algorithms/CreateDummyCalFile-v1.rst index 385ce99d981219c76c4115157081d56b550ba7dd..9f9f592fde7c6de93ae8eb2eed19dc2c58ba46dd 100644 --- a/docs/source/algorithms/CreateDummyCalFile-v1.rst +++ b/docs/source/algorithms/CreateDummyCalFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateEPP-v1.rst b/docs/source/algorithms/CreateEPP-v1.rst index 43a4b5f9bb2e8e0b26cfb30fceebf229b5dc1c0a..c450dbf8c90607628450b1a02f1551f8c8f65100 100644 --- a/docs/source/algorithms/CreateEPP-v1.rst +++ b/docs/source/algorithms/CreateEPP-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateEmptyTableWorkspace-v1.rst b/docs/source/algorithms/CreateEmptyTableWorkspace-v1.rst index 73e10d17ab6b47705d6c977af2f33b57bcb4b9a7..1f04900be24ff18923bb89178c83a722d60abd3d 100644 --- a/docs/source/algorithms/CreateEmptyTableWorkspace-v1.rst +++ b/docs/source/algorithms/CreateEmptyTableWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst b/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst index 6dc23cbb88b83863486f52c5e14ac90ca19dafc5..b2802e224aa01b66752eff5d0df3e1df06f1d7d8 100644 --- a/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst +++ b/docs/source/algorithms/CreateFlatEventWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateGroupingWorkspace-v1.rst b/docs/source/algorithms/CreateGroupingWorkspace-v1.rst index c472673786b026cfb187f4bdfbb430348ee0ace0..b8926c91a7ac7594b3d5442b6242f0b5fff600ab 100644 --- a/docs/source/algorithms/CreateGroupingWorkspace-v1.rst +++ b/docs/source/algorithms/CreateGroupingWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateLeBailFitInput-v1.rst b/docs/source/algorithms/CreateLeBailFitInput-v1.rst index c39b0896524ecd098e98e0e7787df18e103df2ea..e9c4749f8a6ff18ee876bce9836ea45ab4783a2e 100644 --- a/docs/source/algorithms/CreateLeBailFitInput-v1.rst +++ b/docs/source/algorithms/CreateLeBailFitInput-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateLogPropertyTable-v1.rst b/docs/source/algorithms/CreateLogPropertyTable-v1.rst index ec6bb4ceac7f54525652827e02acfcb62e0f5f17..6cddc1a741bbbc8b7ecd8b016bb5693a2bbef9d5 100644 --- a/docs/source/algorithms/CreateLogPropertyTable-v1.rst +++ b/docs/source/algorithms/CreateLogPropertyTable-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateLogTimeCorrection-v1.rst b/docs/source/algorithms/CreateLogTimeCorrection-v1.rst index 1208abebe3d129655b0829ca4685ffeef1b25179..dffd463ccc5519947f24035d44710cd44118d50c 100644 --- a/docs/source/algorithms/CreateLogTimeCorrection-v1.rst +++ b/docs/source/algorithms/CreateLogTimeCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateMD-v1.rst b/docs/source/algorithms/CreateMD-v1.rst index c995b084e3d1421e2e5a59a8702bda21df4ca037..826181d4ad5dbae947d779cc78d5f33b49eb326b 100644 --- a/docs/source/algorithms/CreateMD-v1.rst +++ b/docs/source/algorithms/CreateMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateMDHistoWorkspace-v1.rst b/docs/source/algorithms/CreateMDHistoWorkspace-v1.rst index f7d5b533368f7c5d10eb60aa2d8a2e187fca716f..1fb31629c1a805c9b1479781fefa954aba6c1e85 100644 --- a/docs/source/algorithms/CreateMDHistoWorkspace-v1.rst +++ b/docs/source/algorithms/CreateMDHistoWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateMDWorkspace-v1.rst b/docs/source/algorithms/CreateMDWorkspace-v1.rst index 01682818c6820c79086ffe8902b6a2f5bfd1f574..c39280179d65d6d7d92a02a0a5ca6288dee6dc14 100644 --- a/docs/source/algorithms/CreateMDWorkspace-v1.rst +++ b/docs/source/algorithms/CreateMDWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateModeratorModel-v1.rst b/docs/source/algorithms/CreateModeratorModel-v1.rst index b6419df33d868dc23924942913cbf38b894afae0..e5aef2c96b89fd2bbd239ea032532b9c71d061b5 100644 --- a/docs/source/algorithms/CreateModeratorModel-v1.rst +++ b/docs/source/algorithms/CreateModeratorModel-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreatePSDBleedMask-v1.rst b/docs/source/algorithms/CreatePSDBleedMask-v1.rst index 632ba9484bdf2159af3bc6ac269aab318bd2110f..9b680d7c3c040f941bbc30d9c3aa77f65796d1ee 100644 --- a/docs/source/algorithms/CreatePSDBleedMask-v1.rst +++ b/docs/source/algorithms/CreatePSDBleedMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreatePeaksWorkspace-v1.rst b/docs/source/algorithms/CreatePeaksWorkspace-v1.rst index 7538196ffafb22be8a937f64597a68167ef47d94..573908fc5547183b724831433d47ef038994f24b 100644 --- a/docs/source/algorithms/CreatePeaksWorkspace-v1.rst +++ b/docs/source/algorithms/CreatePeaksWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateSampleShape-v1.rst b/docs/source/algorithms/CreateSampleShape-v1.rst index e5ba9aff3f6b762f2e6bbba9e4de51ff3291f35a..d4de5dbd5bf095c3e6a624a6dbf0607e8d0ed7b9 100644 --- a/docs/source/algorithms/CreateSampleShape-v1.rst +++ b/docs/source/algorithms/CreateSampleShape-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateSampleWorkspace-v1.rst b/docs/source/algorithms/CreateSampleWorkspace-v1.rst index 3fd42ca473a1bf7148f76410acbdf24853e43cb0..088a661ce73ae44f711343fb99f382db15915c68 100644 --- a/docs/source/algorithms/CreateSampleWorkspace-v1.rst +++ b/docs/source/algorithms/CreateSampleWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -37,7 +37,7 @@ important set Random to false or uncheck the box. values should be set to a range symmetrical around x=0. Instrument -~~~~~~~~~~ +########## The instrument created by CreateSample workspace is very simple and looks like this. @@ -48,7 +48,7 @@ this. The sample is placed at the origin. The source is seperated from the sample in the negative direction by the value you specify in "SourceDistanceFromSample". -The instrument has "NumBanks" detector banks, each bank is moved down the X axis +The instrument has "NumBanks" detector banks, each bank is moved down the Z axis by "BankDistanceFromSample" from the sample or the previous bank. Each bank is a square rectangular bank comprising of "BankPixelWidth" pixels in diff --git a/docs/source/algorithms/CreateSimulationWorkspace-v1.rst b/docs/source/algorithms/CreateSimulationWorkspace-v1.rst index 2f3bb5ede9ad1017ebd33666fd7eafd09c0ef85f..3d072e2884030396624a7b1ec492eb4f702d180d 100644 --- a/docs/source/algorithms/CreateSimulationWorkspace-v1.rst +++ b/docs/source/algorithms/CreateSimulationWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateSingleValuedWorkspace-v1.rst b/docs/source/algorithms/CreateSingleValuedWorkspace-v1.rst index cdab8c58d7191b9ea4c70eeccc8b691d941ce7fc..a45cae2192a29c358e2f4cf3b600e86fcc5cd49b 100644 --- a/docs/source/algorithms/CreateSingleValuedWorkspace-v1.rst +++ b/docs/source/algorithms/CreateSingleValuedWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateTransmissionWorkspace-v1.rst b/docs/source/algorithms/CreateTransmissionWorkspace-v1.rst index d4a051e996461cfab9a62d525fa024b75d47d0b1..fc581c9a254bd023e73cf5d41a39733ac7bff604 100644 --- a/docs/source/algorithms/CreateTransmissionWorkspace-v1.rst +++ b/docs/source/algorithms/CreateTransmissionWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateTransmissionWorkspace-v2.rst b/docs/source/algorithms/CreateTransmissionWorkspace-v2.rst index 395469e382fa7b6396de8e487b21ebaffe39ef15..b4bc5f1ffcda580efbf0f0026afade20586d0c86 100644 --- a/docs/source/algorithms/CreateTransmissionWorkspace-v2.rst +++ b/docs/source/algorithms/CreateTransmissionWorkspace-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v1.rst b/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v1.rst index 57ac9a3c13c05db89ff50dc2fa306a8e4fe84744..f9e6e8527b401596085fd4c54ef9ed3523e9586b 100644 --- a/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v1.rst +++ b/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v2.rst b/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v2.rst index b599275fa98342e6a31ab4d8369a3640976d947e..7eee0bc60f82df327e5ff2d93c986b5123e73dd9 100644 --- a/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v2.rst +++ b/docs/source/algorithms/CreateTransmissionWorkspaceAuto-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateUserDefinedBackground-v1.rst b/docs/source/algorithms/CreateUserDefinedBackground-v1.rst index 3e9ee3da1275e95400169c0d3701699df946bf69..3ad76d3d2f851d0265bf6fe1651221e5103b66e9 100644 --- a/docs/source/algorithms/CreateUserDefinedBackground-v1.rst +++ b/docs/source/algorithms/CreateUserDefinedBackground-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CreateWorkspace-v1.rst b/docs/source/algorithms/CreateWorkspace-v1.rst index 253adc45156b444a2a36c1ff03aa300614c6a8a9..afdc4acb2435e7e5c701bec58ed30456964180e4 100644 --- a/docs/source/algorithms/CreateWorkspace-v1.rst +++ b/docs/source/algorithms/CreateWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -10,14 +10,15 @@ Description ----------- This algorithm constructs a :ref:`MatrixWorkspace <MatrixWorkspace>` -when passed a vector for each of the X, Y, and E data values. The unit -for the X Axis can optionally be specified as any of the units in the +when passed a vector for each of the X, Y and optionally E and Dx values. +The E values of the output workspace will be zero if not provided. +The unit for the X Axis can optionally be specified as any of the units in the Mantid `Unit Factory <http://www.mantidproject.org/Units>`__ (see `the list of units currently available <http://www.mantidproject.org/Units>`__). Multiple spectra may be created by supplying the NSpec Property (integer, default 1). When this is provided the vectors are split into equal-sized spectra (all -X, Y, E values must still be in a single vector for input). +X, Y, E, Dx values must still be in a single vector for input). When you use the input property ParentWorkspace, the new workspace is created with the same instrument (including its parameters), sample @@ -57,10 +58,17 @@ Usage dataX = [1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16] dataY = [1,2,3,4,5,6,7,8,9,10,11,12] + + # The workspace will be named "dataWS1", error values will be zero. + dataWS1 = CreateWorkspace(DataX=dataX, DataY=dataY, NSpec=4, UnitX="Wavelength") + + # Create a workspace containing the following error values: dataE = [1,2,3,4,5,6,7,8,9,10,11,12] - - # The workspace will be named "dataWS" - dataWS = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4,UnitX="Wavelength") + dataWS2 = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4, UnitX="Wavelength") + + # Create a workspace containing Dx values: + dX = [1,2,3,4,5,6,7,8,9,10,11,12] + dataWS3 = CreateWorkspace(DataX=dataX, DataY=dataY, DataE=dataE, NSpec=4, UnitX="Wavelength", Dx=dX) .. categories:: diff --git a/docs/source/algorithms/CropToComponent-v1.rst b/docs/source/algorithms/CropToComponent-v1.rst index dd58e21b903daecfda47dbbec548d84d997de739..c4513c0e53e7984ac01461b95d226d9e3f1e6004 100644 --- a/docs/source/algorithms/CropToComponent-v1.rst +++ b/docs/source/algorithms/CropToComponent-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CropWorkspace-v1.rst b/docs/source/algorithms/CropWorkspace-v1.rst index 7723bed4a499edeb4fcb81e1da4f29f78b73ec75..e99c98173566da67dfadde8145c7593c5e08f83d 100644 --- a/docs/source/algorithms/CropWorkspace-v1.rst +++ b/docs/source/algorithms/CropWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CropWorkspaceRagged-v1.rst b/docs/source/algorithms/CropWorkspaceRagged-v1.rst index 85ce724eecdf70f34dc838af7ec6026998ff3706..f09113db9c80f8ce1ba29382617f6c431752fb8d 100644 --- a/docs/source/algorithms/CropWorkspaceRagged-v1.rst +++ b/docs/source/algorithms/CropWorkspaceRagged-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CrossCorrelate-v1.rst b/docs/source/algorithms/CrossCorrelate-v1.rst index cfd7452b8dc7aa1830ab09ee8817daa96d7b23eb..870f9b7398f7fe55747ecd46742ac6e4670b348f 100644 --- a/docs/source/algorithms/CrossCorrelate-v1.rst +++ b/docs/source/algorithms/CrossCorrelate-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CrystalFieldEnergies-v1.rst b/docs/source/algorithms/CrystalFieldEnergies-v1.rst index cf102a0f030c99b473faf6398231c0a3658f7337..90d81130f6004a9a81a518b2096b5c91d58fd2fd 100644 --- a/docs/source/algorithms/CrystalFieldEnergies-v1.rst +++ b/docs/source/algorithms/CrystalFieldEnergies-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CuboidGaugeVolumeAbsorption-v1.rst b/docs/source/algorithms/CuboidGaugeVolumeAbsorption-v1.rst index 8b5b26683731a737ad4f26c1d4a02ada33cd63f2..3bf69ee0e9bb222480be19c4ae2b6dcc96329989 100644 --- a/docs/source/algorithms/CuboidGaugeVolumeAbsorption-v1.rst +++ b/docs/source/algorithms/CuboidGaugeVolumeAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CutMD-v1.rst b/docs/source/algorithms/CutMD-v1.rst index 7c77511cbc1199e97c023231229cbcc71867c1f1..ee98fac154f646c824904ad91b6c1a63db495960 100644 --- a/docs/source/algorithms/CutMD-v1.rst +++ b/docs/source/algorithms/CutMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -22,19 +22,19 @@ is that the same number of output workspaces are also given so that CutMD knows what to call each output workspace created. MDEventWorkspaces -~~~~~~~~~~~~~~~~~~~ +################# For input of type :ref:`MDEventWorkspace <MDWorkspace>` the algorithm uses :ref:`algm-BinMD` or :ref:`algm-SliceMD` to achieve the binning of the data. The choice of child algorithm used for slicing in this case is controlled by the NoPix option. MDHistoWorkspaces -~~~~~~~~~~~~~~~~~~~ +################# If the input is an :ref:`MDHistoWorkspace <MDHistoWorkspace>` :ref:`algm-BinMD` and :ref:`algm-SliceMD` are not made available as they needto get hold of the original MDEvents associated with an :ref:`MDEventWorkspace <MDWorkspace>` in order to perform the rebinning. As this information is missing from the MDHistoWorkspace images, those operations are forbidden. Instead, a limited subset of the operations are allowed, and are performed via :ref:`algm-IntegrateMDHistoWorkspace`. In this case, the Projection and NoPix properties are ignored. See :ref:`algm-IntegrateMDHistoWorkspace` for how the binning parameters are used. Projection Binning -~~~~~~~~~~~~~~~~~~ +################## The 'PnBin' property, where n is between 1 and 5, is used to specify the binning for the nth dimension of the output workspace. The dimension will be truncated to have extents 'minimum' and 'maximum', with 'stepsize' specifying the size of the bins inbetween. @@ -64,7 +64,7 @@ For ease of use, when using the python interface only, the 'PBins' keyword can b PBins accepts a tuple, or list, of PnBins parameters. The position in the list determines the dimension it corresponds to. See the Usage_ examples below. Creating Projections -~~~~~~~~~~~~~~~~~~~~ +#################### Projections are used by CutMD to transform the multidimensional data prior to cutting it. Projections are provided to CutMD in the form of a :ref:`TableWorkspace <Table Workspaces>`. @@ -124,7 +124,7 @@ call the created workspace: CutMD(..., Projection=proj.createWorkspace(), ...) Workflow -~~~~~~~~ +######## .. diagram:: CutMD-v1_wkflw.dot diff --git a/docs/source/algorithms/CylinderAbsorption-v1.rst b/docs/source/algorithms/CylinderAbsorption-v1.rst index 8de3994299d12ae6a81078f00505c0956b0956f3..a45bd481bab5cc5833400f7e2972e9377b8b2f98 100644 --- a/docs/source/algorithms/CylinderAbsorption-v1.rst +++ b/docs/source/algorithms/CylinderAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/CylinderPaalmanPingsCorrection-v2.rst b/docs/source/algorithms/CylinderPaalmanPingsCorrection-v2.rst index fdc45aeb0b045aa0fcb88dc27766ebdb26a1a7c5..f800ad52d144ba53c1c778fd4ee70bf170bc4718 100644 --- a/docs/source/algorithms/CylinderPaalmanPingsCorrection-v2.rst +++ b/docs/source/algorithms/CylinderPaalmanPingsCorrection-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DNSComputeDetEffCorrCoefs-v1.rst b/docs/source/algorithms/DNSComputeDetEffCorrCoefs-v1.rst index 70c207d35afe88f1e7052e5e2184431a07c1c05e..5d3dd875ebdfceeeb03987b7805eab200789f0e0 100644 --- a/docs/source/algorithms/DNSComputeDetEffCorrCoefs-v1.rst +++ b/docs/source/algorithms/DNSComputeDetEffCorrCoefs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DNSFlippingRatioCorr-v1.rst b/docs/source/algorithms/DNSFlippingRatioCorr-v1.rst index 438f785749e0f19ba84182699065993067f9a08f..612a739a34cfcd4cedec8d783a703276974e69f7 100644 --- a/docs/source/algorithms/DNSFlippingRatioCorr-v1.rst +++ b/docs/source/algorithms/DNSFlippingRatioCorr-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DNSMergeRuns-v1.rst b/docs/source/algorithms/DNSMergeRuns-v1.rst index 5221c1f2fea61f1e424f3a5868bec6ea6c1cf5b5..98aa84115fb4846cd7ec8ae60773f7c76d65ec8f 100644 --- a/docs/source/algorithms/DNSMergeRuns-v1.rst +++ b/docs/source/algorithms/DNSMergeRuns-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DPDFreduction-v1.rst b/docs/source/algorithms/DPDFreduction-v1.rst index 2c7841286a782df6902e756072e79c659485ce65..9785ef62655fba2566065dccae43f75da3b68a04 100644 --- a/docs/source/algorithms/DPDFreduction-v1.rst +++ b/docs/source/algorithms/DPDFreduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DSFinterp-v1.rst b/docs/source/algorithms/DSFinterp-v1.rst index e91143ecbb9512dec5046ba19a3104f090d372e9..cb029a2f452a608e86952d87e6e4117b28e9ec8c 100644 --- a/docs/source/algorithms/DSFinterp-v1.rst +++ b/docs/source/algorithms/DSFinterp-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DakotaChiSquared-v1.rst b/docs/source/algorithms/DakotaChiSquared-v1.rst index dd934df4d38f40b99e99da4985a949244f8ecf9b..633f76d8ea0887d92b3c5d1e3d1f66728de6f925 100644 --- a/docs/source/algorithms/DakotaChiSquared-v1.rst +++ b/docs/source/algorithms/DakotaChiSquared-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DefineGaugeVolume-v1.rst b/docs/source/algorithms/DefineGaugeVolume-v1.rst index f3ed5b24a46cee53a32a5f1f8daf3aee6d02f082..ac27a86068ba4fb7e57a5e5288c423d78a9f9725 100644 --- a/docs/source/algorithms/DefineGaugeVolume-v1.rst +++ b/docs/source/algorithms/DefineGaugeVolume-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DeleteLog-v1.rst b/docs/source/algorithms/DeleteLog-v1.rst index 6b5a99beb9b46b33cf68db554e41772bba0d75f8..2809ddcab41845ed8923bd0171e649a2dd61534b 100644 --- a/docs/source/algorithms/DeleteLog-v1.rst +++ b/docs/source/algorithms/DeleteLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DeleteTableRows-v1.rst b/docs/source/algorithms/DeleteTableRows-v1.rst index bf2abca08f477ab6985655530196f0556609aa0a..0bd251222d43013b031b8b3036d04312c15a6dde 100644 --- a/docs/source/algorithms/DeleteTableRows-v1.rst +++ b/docs/source/algorithms/DeleteTableRows-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DeleteWorkspace-v1.rst b/docs/source/algorithms/DeleteWorkspace-v1.rst index 4f9263dc2265b95bd1bd9c091934e29e0a0e4a0f..5c041cde4e1ce35eeaf111f737634b6f34bce99e 100644 --- a/docs/source/algorithms/DeleteWorkspace-v1.rst +++ b/docs/source/algorithms/DeleteWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DeleteWorkspaces-v1.rst b/docs/source/algorithms/DeleteWorkspaces-v1.rst index e7284d9ffeef1e88d743a132007af022782b6b05..0c51ae0d55c5806800cb881d3c7d5c99e30c8480 100644 --- a/docs/source/algorithms/DeleteWorkspaces-v1.rst +++ b/docs/source/algorithms/DeleteWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DeltaPDF3D-v1.rst b/docs/source/algorithms/DeltaPDF3D-v1.rst index bf8f9572f97e428d69ace20159f61b6e1c12a62b..8469c064d83b8c715f39d25a859f8e2ec1c2bb91 100644 --- a/docs/source/algorithms/DeltaPDF3D-v1.rst +++ b/docs/source/algorithms/DeltaPDF3D-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetectorDiagnostic-v1.rst b/docs/source/algorithms/DetectorDiagnostic-v1.rst index 9404c8d50f14f139bf599febe406742fe92f7688..ac630bf0fcd3729f65a0c7e9d1c4ff201f28396e 100644 --- a/docs/source/algorithms/DetectorDiagnostic-v1.rst +++ b/docs/source/algorithms/DetectorDiagnostic-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetectorEfficiencyCor-v1.rst b/docs/source/algorithms/DetectorEfficiencyCor-v1.rst index 6fb7716cad4769efdca481ccb074410ffb349829..339a831e674bf3c287e07a094344b21ce5a0ac45 100644 --- a/docs/source/algorithms/DetectorEfficiencyCor-v1.rst +++ b/docs/source/algorithms/DetectorEfficiencyCor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetectorEfficiencyCorUser-v1.rst b/docs/source/algorithms/DetectorEfficiencyCorUser-v1.rst index 4f35ff53463775cffaf812e626f6d9eb3d1a14b9..2039b8cb1f1b369058c4bc3c48faa710c1077b0e 100644 --- a/docs/source/algorithms/DetectorEfficiencyCorUser-v1.rst +++ b/docs/source/algorithms/DetectorEfficiencyCorUser-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetectorEfficiencyVariation-v1.rst b/docs/source/algorithms/DetectorEfficiencyVariation-v1.rst index e6ba5d1f11161f941e53d419147c079d665d7b81..8a21005e672d40a95e2bbd50d1dc9ce2fa613dd0 100644 --- a/docs/source/algorithms/DetectorEfficiencyVariation-v1.rst +++ b/docs/source/algorithms/DetectorEfficiencyVariation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetectorFloodWeighting-v1.rst b/docs/source/algorithms/DetectorFloodWeighting-v1.rst index 062a0fa633277e425f4ef57d8dc4dea982624fd7..35f13ab8f53b9ef8135240a6b61dbb0acad3ae32 100644 --- a/docs/source/algorithms/DetectorFloodWeighting-v1.rst +++ b/docs/source/algorithms/DetectorFloodWeighting-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DetermineChunking-v1.rst b/docs/source/algorithms/DetermineChunking-v1.rst index b7b5c49d77d77668cb8b26c8ab977567005d5094..adc7319c2c7260585bed7a3f733dec8cbc9e0105 100644 --- a/docs/source/algorithms/DetermineChunking-v1.rst +++ b/docs/source/algorithms/DetermineChunking-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsAbsoluteUnitsReduction-v1.rst b/docs/source/algorithms/DgsAbsoluteUnitsReduction-v1.rst index cf8ade09d03a29b7f12b41fae554b050eb2b4bfd..1b11f02914b57f8e12a1abad61492b3a6309db22 100644 --- a/docs/source/algorithms/DgsAbsoluteUnitsReduction-v1.rst +++ b/docs/source/algorithms/DgsAbsoluteUnitsReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsConvertToEnergyTransfer-v1.rst b/docs/source/algorithms/DgsConvertToEnergyTransfer-v1.rst index 7d319df7841690cf051e18b6fbe0f6cd6bea5bbc..392c82d4ac4e0c89e912d7d376cbf5638ef116aa 100644 --- a/docs/source/algorithms/DgsConvertToEnergyTransfer-v1.rst +++ b/docs/source/algorithms/DgsConvertToEnergyTransfer-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsDiagnose-v1.rst b/docs/source/algorithms/DgsDiagnose-v1.rst index 027400ea8ceeec872c8e9a31471a9c0d4b888560..e5670303700227e8a1426fcd017d8667bebc9d92 100644 --- a/docs/source/algorithms/DgsDiagnose-v1.rst +++ b/docs/source/algorithms/DgsDiagnose-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsPreprocessData-v1.rst b/docs/source/algorithms/DgsPreprocessData-v1.rst index 8a6bafdf2087a2a19a6f43c80c96038e6cabf364..5a8946e19eb69cdadce0be3813c75a2e0dba1231 100644 --- a/docs/source/algorithms/DgsPreprocessData-v1.rst +++ b/docs/source/algorithms/DgsPreprocessData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsProcessDetectorVanadium-v1.rst b/docs/source/algorithms/DgsProcessDetectorVanadium-v1.rst index 5431253860620c5fd1c978a999c977ee51501a47..d64d655e8f4676c82db01c5c90bb032a5985e0e9 100644 --- a/docs/source/algorithms/DgsProcessDetectorVanadium-v1.rst +++ b/docs/source/algorithms/DgsProcessDetectorVanadium-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsReduction-v1.rst b/docs/source/algorithms/DgsReduction-v1.rst index 0c4d1378c9e2e92338ff308f464812650c847d84..bb33cb66ae5763043df3b75ed2f5843f5bfa40f6 100644 --- a/docs/source/algorithms/DgsReduction-v1.rst +++ b/docs/source/algorithms/DgsReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DgsRemap-v1.rst b/docs/source/algorithms/DgsRemap-v1.rst index de6578e7a544fbde064e28d54e1316306bf4932d..aab6dcabeef0ff60777fca85a721648dbd360ec7 100644 --- a/docs/source/algorithms/DgsRemap-v1.rst +++ b/docs/source/algorithms/DgsRemap-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DiffPeaksWorkspaces-v1.rst b/docs/source/algorithms/DiffPeaksWorkspaces-v1.rst index 38eb213b99c53c5dc98d26745122b339edc2be0d..2e32649c61cd4305bdd3bbd4470f7feedfc28209 100644 --- a/docs/source/algorithms/DiffPeaksWorkspaces-v1.rst +++ b/docs/source/algorithms/DiffPeaksWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst b/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst index 2d780d5c8235dbe819631fe8129b3d8d14bde27e..a4b5d68e31b7e7656f767a79593bcb7a1d9cc6e3 100644 --- a/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst +++ b/docs/source/algorithms/DiffractionEventCalibrateDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DiffractionFocussing-v1.rst b/docs/source/algorithms/DiffractionFocussing-v1.rst index 8f5b311be9a5e2a759dbb559992c509c3b78abf1..f828f72e7db9480d047ccf30258e9ce38d06dd74 100644 --- a/docs/source/algorithms/DiffractionFocussing-v1.rst +++ b/docs/source/algorithms/DiffractionFocussing-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DiffractionFocussing-v2.rst b/docs/source/algorithms/DiffractionFocussing-v2.rst index 70b7718cc5963360519dfed1f1af314bf15eb873..52509fe68413ec16e61f39f3d4477889eec95400 100644 --- a/docs/source/algorithms/DiffractionFocussing-v2.rst +++ b/docs/source/algorithms/DiffractionFocussing-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLApplySelfShielding-v1.rst b/docs/source/algorithms/DirectILLApplySelfShielding-v1.rst index 2db0d942e6fbdc95d0986a0a76492c6468014536..99879060a622f49348fc7f795c8225f970e589bc 100644 --- a/docs/source/algorithms/DirectILLApplySelfShielding-v1.rst +++ b/docs/source/algorithms/DirectILLApplySelfShielding-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLCollectData-v1.rst b/docs/source/algorithms/DirectILLCollectData-v1.rst index 1f5df795ea85bbc94dee719e408a493897116e5a..a50c673a5f66bb03ef333f5a711c84a383e25362 100644 --- a/docs/source/algorithms/DirectILLCollectData-v1.rst +++ b/docs/source/algorithms/DirectILLCollectData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLDiagnostics-v1.rst b/docs/source/algorithms/DirectILLDiagnostics-v1.rst index 8201ca8e4d28002b176fa35ba33a30fcfc0aa623..116a1cbd1c029a2814a5ba594e4cadb242aeca81 100644 --- a/docs/source/algorithms/DirectILLDiagnostics-v1.rst +++ b/docs/source/algorithms/DirectILLDiagnostics-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLIntegrateVanadium-v1.rst b/docs/source/algorithms/DirectILLIntegrateVanadium-v1.rst index b96cba3937ddf1acc3c88ca473fd1f018d3d014a..e5b620a4f35b658f1449a59425bc6c0255f315f0 100644 --- a/docs/source/algorithms/DirectILLIntegrateVanadium-v1.rst +++ b/docs/source/algorithms/DirectILLIntegrateVanadium-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLReduction-v1.rst b/docs/source/algorithms/DirectILLReduction-v1.rst index f43b36417cd06d9c727fab25e60c6f5e2b85f105..41ac4fad906f450f758e34e4c0083d93f5e3a754 100644 --- a/docs/source/algorithms/DirectILLReduction-v1.rst +++ b/docs/source/algorithms/DirectILLReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DirectILLSelfShielding-v1.rst b/docs/source/algorithms/DirectILLSelfShielding-v1.rst index 6fe5566b416aa1b8434e5a72c1e2c16c1e147721..c6461fd83646ad0e9a2c6c7e8536e09c44724bdc 100644 --- a/docs/source/algorithms/DirectILLSelfShielding-v1.rst +++ b/docs/source/algorithms/DirectILLSelfShielding-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Divide-v1.rst b/docs/source/algorithms/Divide-v1.rst index 1a4cc08943045e22bdbdb18ce62bb77298b876ef..02147daae8f404e081e1aa8c9d974767bb446e4a 100644 --- a/docs/source/algorithms/Divide-v1.rst +++ b/docs/source/algorithms/Divide-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DivideMD-v1.rst b/docs/source/algorithms/DivideMD-v1.rst index 258ee5dc796b76f22122b176e0756823d0e97070..96f9264388244a3528bf896dab31cc30a530c38c 100644 --- a/docs/source/algorithms/DivideMD-v1.rst +++ b/docs/source/algorithms/DivideMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DownloadFile-v1.rst b/docs/source/algorithms/DownloadFile-v1.rst index 85d30aae197700fda30f3aecd30154ef3d2afcdb..cdb152d68626f5c0b5f90b4caa96fa4a2e4982ec 100644 --- a/docs/source/algorithms/DownloadFile-v1.rst +++ b/docs/source/algorithms/DownloadFile-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DownloadInstrument-v1.rst b/docs/source/algorithms/DownloadInstrument-v1.rst index 979d7d67152c0c37815b178a65c748fe8912e514..198d5a3d4861075cf03119eaa36cb67915038fa5 100644 --- a/docs/source/algorithms/DownloadInstrument-v1.rst +++ b/docs/source/algorithms/DownloadInstrument-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DownloadRemoteFile-v1.rst b/docs/source/algorithms/DownloadRemoteFile-v1.rst index baafb5ea5c99109b97878fd8f2045e2bb84c8eef..5ad4690b16938e5ed362abe4983cb12047b3679d 100644 --- a/docs/source/algorithms/DownloadRemoteFile-v1.rst +++ b/docs/source/algorithms/DownloadRemoteFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/DownloadRemoteFile-v2.rst b/docs/source/algorithms/DownloadRemoteFile-v2.rst index 11687fb4cf839a14bab989081118bd65b5a0b2d0..12dede5c008f07ccfaec57e449247d275b3666c8 100644 --- a/docs/source/algorithms/DownloadRemoteFile-v2.rst +++ b/docs/source/algorithms/DownloadRemoteFile-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSAzimuthalAverage1D-v1.rst b/docs/source/algorithms/EQSANSAzimuthalAverage1D-v1.rst index e6f083dbe8d52e5ddc08a1e68fbc1112ebca43e7..f83a4eeea4e5203caee2a21270febf85b24c0989 100644 --- a/docs/source/algorithms/EQSANSAzimuthalAverage1D-v1.rst +++ b/docs/source/algorithms/EQSANSAzimuthalAverage1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v1.rst b/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v1.rst index 4e7f412815c4fffe355225b48c34a7cb62ee0c30..e371b8e32b3f368e87d53fd71b3e13108c8f83d1 100644 --- a/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v1.rst +++ b/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v2.rst b/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v2.rst index 2be799e69f6850b7ef2060e84b3dc5c6b4664a24..9a4c6b31f2fb603bde6b6c7bf95e9822714d5190 100644 --- a/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v2.rst +++ b/docs/source/algorithms/EQSANSDarkCurrentSubtraction-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSDirectBeamTransmission-v1.rst b/docs/source/algorithms/EQSANSDirectBeamTransmission-v1.rst index 21cbc6fb083e9ce708aee73ca9db2ca6b55fe86d..7400110992a6c079b5e6d2078db8f4b13d52eaad 100644 --- a/docs/source/algorithms/EQSANSDirectBeamTransmission-v1.rst +++ b/docs/source/algorithms/EQSANSDirectBeamTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSLoad-v1.rst b/docs/source/algorithms/EQSANSLoad-v1.rst index 755d3e89472e2172d17927f83bc670d8d9478515..545dac3422e99aebfa9de4d1d589f734e40f2f8d 100644 --- a/docs/source/algorithms/EQSANSLoad-v1.rst +++ b/docs/source/algorithms/EQSANSLoad-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSMonitorTOF-v1.rst b/docs/source/algorithms/EQSANSMonitorTOF-v1.rst index 3c87c117223b94da7cc7bea02d12d5893e7aa3f7..8c1cdcc1f0c0850fb312a0658cd2c38a43c34eec 100644 --- a/docs/source/algorithms/EQSANSMonitorTOF-v1.rst +++ b/docs/source/algorithms/EQSANSMonitorTOF-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSNormalise-v1.rst b/docs/source/algorithms/EQSANSNormalise-v1.rst index 698fd88ac8a5a9e107f05671eb54e0d14b56ed1a..b54294e0ecde79754983fe595d49d3204eaefcb3 100644 --- a/docs/source/algorithms/EQSANSNormalise-v1.rst +++ b/docs/source/algorithms/EQSANSNormalise-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSPatchSensitivity-v1.rst b/docs/source/algorithms/EQSANSPatchSensitivity-v1.rst index b33bf402a501750cc5a477dc43b2d78fd41758e0..fbcf407733c3d04dee7c17bbe9dab71bc3fbea13 100644 --- a/docs/source/algorithms/EQSANSPatchSensitivity-v1.rst +++ b/docs/source/algorithms/EQSANSPatchSensitivity-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSQ2D-v1.rst b/docs/source/algorithms/EQSANSQ2D-v1.rst index ce876f73c0327ef61c0257534d2be3d3a2f37415..5c90e3e9ecc69bb23285434ff93fede712fc3a93 100644 --- a/docs/source/algorithms/EQSANSQ2D-v1.rst +++ b/docs/source/algorithms/EQSANSQ2D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSResolution-v1.rst b/docs/source/algorithms/EQSANSResolution-v1.rst index 2bdcc43d8cd8ae67a49ce2fe5f817f2fa95da6d0..8fa588e49a042a91ecc01aa804f20331145975da 100644 --- a/docs/source/algorithms/EQSANSResolution-v1.rst +++ b/docs/source/algorithms/EQSANSResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EQSANSTofStructure-v1.rst b/docs/source/algorithms/EQSANSTofStructure-v1.rst index 1316f72372d633707aacb7d64f4ba6b5bb4fbc1b..5e7db7dcb46e27fddcdacdf9907dd7a8d3795d63 100644 --- a/docs/source/algorithms/EQSANSTofStructure-v1.rst +++ b/docs/source/algorithms/EQSANSTofStructure-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EditInstrumentGeometry-v1.rst b/docs/source/algorithms/EditInstrumentGeometry-v1.rst index 5526e52a64036ce9dc515f581aef62e64f00c69c..8773eb259d3ce5c66308b97d90a8dde4d7848d50 100644 --- a/docs/source/algorithms/EditInstrumentGeometry-v1.rst +++ b/docs/source/algorithms/EditInstrumentGeometry-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ElasticWindow-v1.rst b/docs/source/algorithms/ElasticWindow-v1.rst index 636cfe3af37ff318cd386db8c360e96bec01723e..ca1f05c38ac00b34893c207d1f9eb26e327b7376 100644 --- a/docs/source/algorithms/ElasticWindow-v1.rst +++ b/docs/source/algorithms/ElasticWindow-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ElasticWindowMultiple-v1.rst b/docs/source/algorithms/ElasticWindowMultiple-v1.rst index a953d30b052b9e5ad24f6c70de145f781e1cf8a4..bbfbc8f62fc09aed441d15bec8f4c9d455097dae 100644 --- a/docs/source/algorithms/ElasticWindowMultiple-v1.rst +++ b/docs/source/algorithms/ElasticWindowMultiple-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnergyWindowScan-v1.rst b/docs/source/algorithms/EnergyWindowScan-v1.rst index 71f91e40b69d0c259fc8d92d59d314645c44edd2..c21ce61a4f4f2ec0a55cf5c52e8173222a1cbc49 100644 --- a/docs/source/algorithms/EnergyWindowScan-v1.rst +++ b/docs/source/algorithms/EnergyWindowScan-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggCalibrate-v1.rst b/docs/source/algorithms/EnggCalibrate-v1.rst index 0375eb44e530f5f8bd9b0391cdb4a4ca40bbb7aa..0327a8c1d60ad0134c6ef5d28389fe6f80dadbc1 100644 --- a/docs/source/algorithms/EnggCalibrate-v1.rst +++ b/docs/source/algorithms/EnggCalibrate-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggCalibrateFull-v1.rst b/docs/source/algorithms/EnggCalibrateFull-v1.rst index 5cac4656139d49d652d774abe2bda0d914e327c9..ee01751308a8004a02cb8f6c263a5ae161984768 100644 --- a/docs/source/algorithms/EnggCalibrateFull-v1.rst +++ b/docs/source/algorithms/EnggCalibrateFull-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggFitDIFCFromPeaks-v1.rst b/docs/source/algorithms/EnggFitDIFCFromPeaks-v1.rst index 7a3f1c2a8f31cf96d68054c8d44202f3a0f64c46..0faff5d7519df1963ccdac5b49896362c077cd30 100644 --- a/docs/source/algorithms/EnggFitDIFCFromPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitDIFCFromPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggFitPeaks-v1.rst b/docs/source/algorithms/EnggFitPeaks-v1.rst index 011bc6802ced80ffbd0f2d65ce19f949cf5f68b8..b94994f858a4545391caacd06b6ba1d2974e3711 100644 --- a/docs/source/algorithms/EnggFitPeaks-v1.rst +++ b/docs/source/algorithms/EnggFitPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggFocus-v1.rst b/docs/source/algorithms/EnggFocus-v1.rst index 12f2f1dd1206e2e076c91ed875e15d60ac8a0483..6883341f7be4c13ac2379ee697208f4699712b86 100644 --- a/docs/source/algorithms/EnggFocus-v1.rst +++ b/docs/source/algorithms/EnggFocus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EnggVanadiumCorrections-v1.rst b/docs/source/algorithms/EnggVanadiumCorrections-v1.rst index f980ed5fb93fc602d76cec4cd7ca88e8b92555e8..d1eae6232446e697bc04983337a48f6a19f1958a 100644 --- a/docs/source/algorithms/EnggVanadiumCorrections-v1.rst +++ b/docs/source/algorithms/EnggVanadiumCorrections-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EqualToMD-v1.rst b/docs/source/algorithms/EqualToMD-v1.rst index 847c6031f09bd62409b31bf9c089ced4b1d6aec3..1a59830e967de373ce14295b5cea3eb65f000cdc 100644 --- a/docs/source/algorithms/EqualToMD-v1.rst +++ b/docs/source/algorithms/EqualToMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EstimateDivergence-v1.rst b/docs/source/algorithms/EstimateDivergence-v1.rst index c7da06299303ad1c51fe162825860cbd66b0d02a..7d370fec154b3fdc8aa8cc52bd7bfdc73fab15f8 100644 --- a/docs/source/algorithms/EstimateDivergence-v1.rst +++ b/docs/source/algorithms/EstimateDivergence-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EstimateFitParameters-v1.rst b/docs/source/algorithms/EstimateFitParameters-v1.rst index 0d5f6b186e1de93ece9831834810e6477c50ed2f..6a4c58ed6eca43fc58f910ede21cb1ed22c728f8 100644 --- a/docs/source/algorithms/EstimateFitParameters-v1.rst +++ b/docs/source/algorithms/EstimateFitParameters-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EstimateMuonAsymmetryFromCounts-v1.rst b/docs/source/algorithms/EstimateMuonAsymmetryFromCounts-v1.rst index 7480c94af69078cd8d7908d3ef92249fa22d393e..ce63f658d1ec03d6405f99191d7196d90001883a 100644 --- a/docs/source/algorithms/EstimateMuonAsymmetryFromCounts-v1.rst +++ b/docs/source/algorithms/EstimateMuonAsymmetryFromCounts-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EstimatePeakErrors-v1.rst b/docs/source/algorithms/EstimatePeakErrors-v1.rst index f4783163738d039bc7cddf7f2b1fefa457fc435a..d8d424fca78f076955d8c86a33a80d6ccf23260b 100644 --- a/docs/source/algorithms/EstimatePeakErrors-v1.rst +++ b/docs/source/algorithms/EstimatePeakErrors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EstimateResolutionDiffraction-v1.rst b/docs/source/algorithms/EstimateResolutionDiffraction-v1.rst index e65e13f905c71ac70724acbad8c163c1727efb76..ec5daa91322c2033a096b8d471b36914b1be6b75 100644 --- a/docs/source/algorithms/EstimateResolutionDiffraction-v1.rst +++ b/docs/source/algorithms/EstimateResolutionDiffraction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EvaluateFunction-v1.rst b/docs/source/algorithms/EvaluateFunction-v1.rst index 74ff2c7d9ca629132f73beffd5d68492ffa7477c..41aa5710e3682d2e93f2398023081ad276736f6c 100644 --- a/docs/source/algorithms/EvaluateFunction-v1.rst +++ b/docs/source/algorithms/EvaluateFunction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/EvaluateMDFunction-v1.rst b/docs/source/algorithms/EvaluateMDFunction-v1.rst index 91f8acc66df3cb1d45a660e0486936a87771518f..0c0d2d28586002f8aa4957ca218bc5deabf65c59 100644 --- a/docs/source/algorithms/EvaluateMDFunction-v1.rst +++ b/docs/source/algorithms/EvaluateMDFunction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExaminePowderDiffProfile-v1.rst b/docs/source/algorithms/ExaminePowderDiffProfile-v1.rst index 431f6369d1d361c47c7acbe5a7851bf742aa1b4b..78612391ca1fa4705607cff6a41b85fe32f19292 100644 --- a/docs/source/algorithms/ExaminePowderDiffProfile-v1.rst +++ b/docs/source/algorithms/ExaminePowderDiffProfile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExampleSaveAscii-v1.rst b/docs/source/algorithms/ExampleSaveAscii-v1.rst index 6f061321b8261b5104ba7bf3ca29a51143508816..4236bf38c2683f7ac897282fa7d451486281f321 100644 --- a/docs/source/algorithms/ExampleSaveAscii-v1.rst +++ b/docs/source/algorithms/ExampleSaveAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Exponential-v1.rst b/docs/source/algorithms/Exponential-v1.rst index a08913dde2c45e787ff609f3842336a866672cf6..46d725e7142e7d5e21dc516ceefa20ca2a68839f 100644 --- a/docs/source/algorithms/Exponential-v1.rst +++ b/docs/source/algorithms/Exponential-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExponentialCorrection-v1.rst b/docs/source/algorithms/ExponentialCorrection-v1.rst index 369f24d942c622bb0e75c2faedf55bed283146e8..c060e683940133ef3480f93deafc3d3193f8ca21 100644 --- a/docs/source/algorithms/ExponentialCorrection-v1.rst +++ b/docs/source/algorithms/ExponentialCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExponentialMD-v1.rst b/docs/source/algorithms/ExponentialMD-v1.rst index 2076609d36e4e3b8d68f910cc143184d7ccbcc60..6207ef6a5ed964737aeb8761f791d9ea41909b87 100644 --- a/docs/source/algorithms/ExponentialMD-v1.rst +++ b/docs/source/algorithms/ExponentialMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExportExperimentLog-v1.rst b/docs/source/algorithms/ExportExperimentLog-v1.rst index 25967655bf6a061dfae2a0dd00b2164fdf93478a..19be177823c599db598e6a58c0d6a1bb5fabae0e 100644 --- a/docs/source/algorithms/ExportExperimentLog-v1.rst +++ b/docs/source/algorithms/ExportExperimentLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExportGeometry-v1.rst b/docs/source/algorithms/ExportGeometry-v1.rst index 53878c8d80451e9faf099d99d59f4f39441a3d10..1318b1a78527ee8a9c5ad6b3d9836e303ad0c11e 100644 --- a/docs/source/algorithms/ExportGeometry-v1.rst +++ b/docs/source/algorithms/ExportGeometry-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExportSampleLogsToCSVFile-v1.rst b/docs/source/algorithms/ExportSampleLogsToCSVFile-v1.rst index 51d77cd96ff035ec9e82455dfb20da82cc152221..085c78f0e285edac366f336693663985c2356ec8 100644 --- a/docs/source/algorithms/ExportSampleLogsToCSVFile-v1.rst +++ b/docs/source/algorithms/ExportSampleLogsToCSVFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -15,7 +15,7 @@ The header for the sample log csv file can also be created by this algorithm in a seperate *header* file. CSV File format -=============== +############### Sample logs are written to a csv file. A tab separates any two adjacent values. @@ -35,7 +35,7 @@ Here is the definition for the columns. *SampleLogNames* Header file -=========== +########### A sample log header file can be generated optionally. It contains theree lines described as below. @@ -46,7 +46,7 @@ It contains theree lines described as below. Usually it is the column names in the .csv file Time Zone -========= +######### The time stamps of sample logs are recorded as UTC time in SNS. Some users wants to see the exported sample log as the neutron facility's local time. diff --git a/docs/source/algorithms/ExportSpectraMask-v1.rst b/docs/source/algorithms/ExportSpectraMask-v1.rst index 92b65de4497b03674b20339ace2d1e3d58599b64..5bf6179e0cb1337de30222f62a264c0709b0f295 100644 --- a/docs/source/algorithms/ExportSpectraMask-v1.rst +++ b/docs/source/algorithms/ExportSpectraMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExportTimeSeriesLog-v1.rst b/docs/source/algorithms/ExportTimeSeriesLog-v1.rst index 3434bd092b51eb7281cfd14cf0ca1da8205cb83f..139228477de64cf180388fb5e03cda600e9f86e3 100644 --- a/docs/source/algorithms/ExportTimeSeriesLog-v1.rst +++ b/docs/source/algorithms/ExportTimeSeriesLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractFFTSpectrum-v1.rst b/docs/source/algorithms/ExtractFFTSpectrum-v1.rst index 7d75cd5a0624cdeb8ea37030c4294d5cdfdf0c9e..d87dd5f5888b8913878be7e2afecbd89c82967a0 100644 --- a/docs/source/algorithms/ExtractFFTSpectrum-v1.rst +++ b/docs/source/algorithms/ExtractFFTSpectrum-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractMask-v1.rst b/docs/source/algorithms/ExtractMask-v1.rst index 2a9dfa07dfac906df5e3650e46669658598dd59d..1f13ca0e28b5f4324f99ae8718128bbd45487917 100644 --- a/docs/source/algorithms/ExtractMask-v1.rst +++ b/docs/source/algorithms/ExtractMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -18,6 +18,8 @@ new MatrixWorkspace with a single X bin where: The spectra containing 0 are also marked as masked and the instrument link is preserved so that the instrument view functions correctly. +A list of masked detector IDs is also output. Note this contains the detector IDs which +are masked rather than the index or spectrum number. Usage ----- @@ -29,11 +31,11 @@ Usage #create a workspace with a 3*3 pixel detector bankPixelWidth = 3 ws = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=bankPixelWidth) - + #Mask out every other detector MaskDetectors(ws,WorkspaceIndexList=range(0,bankPixelWidth*bankPixelWidth,2)) - wsMask = ExtractMask(ws) + wsMask, maskList = ExtractMask(ws) #This mask can then be applied to another workspace ws2 = CreateSampleWorkspace(NumBanks=1,BankPixelWidth=bankPixelWidth) @@ -43,6 +45,9 @@ Usage print("n ws ws2") for i in range (ws.getNumberHistograms()): print("%i %-5s %s" % (i, ws.getDetector(i).isMasked(), ws2.getDetector(i).isMasked())) + + print("\nMasked detector IDs") + print(maskList) Output: @@ -59,6 +64,9 @@ Output: 6 True True 7 False False 8 True True + + Masked detector IDs + [ 9 11 13 15 17] .. categories:: diff --git a/docs/source/algorithms/ExtractMaskToTable-v1.rst b/docs/source/algorithms/ExtractMaskToTable-v1.rst index 35251f1b572874413e799e90af46c554a7b6a83e..7dab04928908856782234f3b1b61830017ee38f7 100644 --- a/docs/source/algorithms/ExtractMaskToTable-v1.rst +++ b/docs/source/algorithms/ExtractMaskToTable-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractMonitorWorkspace-v1.rst b/docs/source/algorithms/ExtractMonitorWorkspace-v1.rst index 0185717cdffeccf2a6d527dbcf3d703b218591ef..626c243bbb2a3bb7b2bdda0152799e2cf1bdfdbf 100644 --- a/docs/source/algorithms/ExtractMonitorWorkspace-v1.rst +++ b/docs/source/algorithms/ExtractMonitorWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractMonitors-v1.rst b/docs/source/algorithms/ExtractMonitors-v1.rst index 6b758461ae92904339b815e67ce7c3b9cb3d398e..d1c180bec8b1691bcb79e57668911241d41b7081 100644 --- a/docs/source/algorithms/ExtractMonitors-v1.rst +++ b/docs/source/algorithms/ExtractMonitors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractQENSMembers-v1.rst b/docs/source/algorithms/ExtractQENSMembers-v1.rst index 67f9613c6ccf9b8afb749945b2fc6561ba7cc04c..8ea5b640408287fb97c886c03ab21660a17d0bd2 100644 --- a/docs/source/algorithms/ExtractQENSMembers-v1.rst +++ b/docs/source/algorithms/ExtractQENSMembers-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractSingleSpectrum-v1.rst b/docs/source/algorithms/ExtractSingleSpectrum-v1.rst index 624dd7889b1ec0eb6a587521b328d5cf40778567..3dfb14755c4c932ffa1c177b44805eb5bb943487 100644 --- a/docs/source/algorithms/ExtractSingleSpectrum-v1.rst +++ b/docs/source/algorithms/ExtractSingleSpectrum-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractSpectra-v1.rst b/docs/source/algorithms/ExtractSpectra-v1.rst index 094704b06f804cbef7d0deb2064261ef2d1dfbc4..361a05673b8bcf94b8df086084771b77dbdea467 100644 --- a/docs/source/algorithms/ExtractSpectra-v1.rst +++ b/docs/source/algorithms/ExtractSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ExtractUnmaskedSpectra-v1.rst b/docs/source/algorithms/ExtractUnmaskedSpectra-v1.rst index 3d3a3ca9fc00f457a62d89d611c36f860fc92e05..439e06812cbdaf33af27d9f5cea0a9c1d857587d 100644 --- a/docs/source/algorithms/ExtractUnmaskedSpectra-v1.rst +++ b/docs/source/algorithms/ExtractUnmaskedSpectra-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FFT-v1.rst b/docs/source/algorithms/FFT-v1.rst index 23d8d392f4b37f2c901b3baa7ef116ef2dc1ba47..467c249b81709bd7fc9cc4239181355756d2683b 100644 --- a/docs/source/algorithms/FFT-v1.rst +++ b/docs/source/algorithms/FFT-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FFTDerivative-v1.rst b/docs/source/algorithms/FFTDerivative-v1.rst index fd926b6bbf5d8d5dacc2ff393c9e0c04d83ac61b..4e15e3737e21a10ceb0ee9e77a6ef49a1e9ab5ac 100644 --- a/docs/source/algorithms/FFTDerivative-v1.rst +++ b/docs/source/algorithms/FFTDerivative-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FFTSmooth-v1.rst b/docs/source/algorithms/FFTSmooth-v1.rst index 244a668c3db3d2311931b7e808e09ddbed4db73b..277c3e01e7862fb6ea2ef7e889ea42edf87a0ad2 100644 --- a/docs/source/algorithms/FFTSmooth-v1.rst +++ b/docs/source/algorithms/FFTSmooth-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FFTSmooth-v2.rst b/docs/source/algorithms/FFTSmooth-v2.rst index 1bef23441fa9d1c2c1f63958f524f23b54dbade3..9b44faa260f1261c08a17e50e22f8639a4bf7215 100644 --- a/docs/source/algorithms/FFTSmooth-v2.rst +++ b/docs/source/algorithms/FFTSmooth-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FakeISISEventDAE-v1.rst b/docs/source/algorithms/FakeISISEventDAE-v1.rst index dd8ccf50f955d24ba2ed4df6e515f024f5588696..1cbf89c3dd270c4a5301ee45f36d8ed352c2d49f 100644 --- a/docs/source/algorithms/FakeISISEventDAE-v1.rst +++ b/docs/source/algorithms/FakeISISEventDAE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -25,7 +25,10 @@ Usage **Example:** -.. testcode:: exFakeISISEventDAE +.. This test is currently hanging on macOS as the MonitorLiveData algorithm + is taking a long time to cancel + +.. code-block:: python from threading import Thread import time diff --git a/docs/source/algorithms/FakeISISHistoDAE-v1.rst b/docs/source/algorithms/FakeISISHistoDAE-v1.rst index 64be954cbced56b98848eb8a87ce33e02bcb82c4..8d65f2a33f540f5147c24b2be4059c25c3db4e0e 100644 --- a/docs/source/algorithms/FakeISISHistoDAE-v1.rst +++ b/docs/source/algorithms/FakeISISHistoDAE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FakeMDEventData-v1.rst b/docs/source/algorithms/FakeMDEventData-v1.rst index 2566749755edc5d75e9b5844c2ccfde93edaceb5..ecc8148bcba0d910239c2f614f4c0d70d8226665 100644 --- a/docs/source/algorithms/FakeMDEventData-v1.rst +++ b/docs/source/algorithms/FakeMDEventData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterBadPulses-v1.rst b/docs/source/algorithms/FilterBadPulses-v1.rst index d90b34fa8d438906d3e10522207b9a0263198d43..b98e55478c0c8cefc901bd27987f778b71d3bbf7 100644 --- a/docs/source/algorithms/FilterBadPulses-v1.rst +++ b/docs/source/algorithms/FilterBadPulses-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterByLogValue-v1.rst b/docs/source/algorithms/FilterByLogValue-v1.rst index 757d3077511bcb83499f5f4d800867303b258a91..0fa6a30a54a3dd39840f57bb7bd4871d18b22e22 100644 --- a/docs/source/algorithms/FilterByLogValue-v1.rst +++ b/docs/source/algorithms/FilterByLogValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterByTime-v1.rst b/docs/source/algorithms/FilterByTime-v1.rst index 075d9cd6d4ce2e367808a47ee1f900a669ce9949..c38d8a1d97ad1c559e0d1e25ea6aca4546371750 100644 --- a/docs/source/algorithms/FilterByTime-v1.rst +++ b/docs/source/algorithms/FilterByTime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterByXValue-v1.rst b/docs/source/algorithms/FilterByXValue-v1.rst index 120a8e3626f171b84ddb5bc0c03d463722563edb..78d3c576ea5a442d821a76ef723603577ab07f1b 100644 --- a/docs/source/algorithms/FilterByXValue-v1.rst +++ b/docs/source/algorithms/FilterByXValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterEvents-v1.rst b/docs/source/algorithms/FilterEvents-v1.rst index 40f20b1ae091a316562937393a1c068720f258ee..b8032b1853d2694102b52b2139355fa92b27155d 100644 --- a/docs/source/algorithms/FilterEvents-v1.rst +++ b/docs/source/algorithms/FilterEvents-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterEventsByLogValuePreNexus-v2.rst b/docs/source/algorithms/FilterEventsByLogValuePreNexus-v2.rst index f561ec03ba6462196d994dfd9949370d738e7b61..38dad32fd64bcd66ecaade737f301460331cc7bd 100644 --- a/docs/source/algorithms/FilterEventsByLogValuePreNexus-v2.rst +++ b/docs/source/algorithms/FilterEventsByLogValuePreNexus-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterLogByTime-v1.rst b/docs/source/algorithms/FilterLogByTime-v1.rst index 3a59a1ecd3255866ba099938b67ccfe01ece06b2..cc472181d1f8c353b4cf916a8ac75e60f74974f8 100644 --- a/docs/source/algorithms/FilterLogByTime-v1.rst +++ b/docs/source/algorithms/FilterLogByTime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FilterPeaks-v1.rst b/docs/source/algorithms/FilterPeaks-v1.rst index 0e2c5e8510f26806ba88a884e7eb2ceb913f6ce7..60b68602faa47c04ffdac867fb9f27f66f8831c5 100644 --- a/docs/source/algorithms/FilterPeaks-v1.rst +++ b/docs/source/algorithms/FilterPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindCenterOfMassPosition-v1.rst b/docs/source/algorithms/FindCenterOfMassPosition-v1.rst index 089aeba786c3e2a72c6e84e647f42645ee3cdaab..d3ce89a051092bfdc88adc68e4f4b5d32f36270a 100644 --- a/docs/source/algorithms/FindCenterOfMassPosition-v1.rst +++ b/docs/source/algorithms/FindCenterOfMassPosition-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindCenterOfMassPosition-v2.rst b/docs/source/algorithms/FindCenterOfMassPosition-v2.rst index 6e52fe5e4c59b50f61134e4523a07ecc2afcf5a2..807494f5f19438330e642fcccdf2a3bb63a71205 100644 --- a/docs/source/algorithms/FindCenterOfMassPosition-v2.rst +++ b/docs/source/algorithms/FindCenterOfMassPosition-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindClusterFaces-v1.rst b/docs/source/algorithms/FindClusterFaces-v1.rst index e9dc29408f41256c10c615ae87aebb124827b2dc..2aaab72b277ce334707245e4a86d825fe2f349a0 100644 --- a/docs/source/algorithms/FindClusterFaces-v1.rst +++ b/docs/source/algorithms/FindClusterFaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindDeadDetectors-v1.rst b/docs/source/algorithms/FindDeadDetectors-v1.rst index 9b2e143ec19b91b48ffa75831c27e5123b134215..61183a433f719809ecfd64c905f3f1a901282ebd 100644 --- a/docs/source/algorithms/FindDeadDetectors-v1.rst +++ b/docs/source/algorithms/FindDeadDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindDetectorsInShape-v1.rst b/docs/source/algorithms/FindDetectorsInShape-v1.rst index 396988effb94fd4de0137525dea4c93b7dcee0d9..6a5e7072d7bc754b4ec96ac841dfa411eb76243a 100644 --- a/docs/source/algorithms/FindDetectorsInShape-v1.rst +++ b/docs/source/algorithms/FindDetectorsInShape-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindDetectorsOutsideLimits-v1.rst b/docs/source/algorithms/FindDetectorsOutsideLimits-v1.rst index 1533d25ddaa87184d675276c7e50a26a80bfea0f..3b4d4cbeeaddfabc5cc4909fd39efe19f8515169 100644 --- a/docs/source/algorithms/FindDetectorsOutsideLimits-v1.rst +++ b/docs/source/algorithms/FindDetectorsOutsideLimits-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindDetectorsPar-v1.rst b/docs/source/algorithms/FindDetectorsPar-v1.rst index 4ba2c875bdd5863d42d4eda7583d62568de4e826..26102ba80274f1ed6dbbb4c1c7bb1be2ee663c47 100644 --- a/docs/source/algorithms/FindDetectorsPar-v1.rst +++ b/docs/source/algorithms/FindDetectorsPar-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindEPP-v1.rst b/docs/source/algorithms/FindEPP-v1.rst index e3e3334e8964df233a9422a44d2b2ce58bfaa89a..689deffb32291925359773af8d27a8914f60cc1f 100644 --- a/docs/source/algorithms/FindEPP-v1.rst +++ b/docs/source/algorithms/FindEPP-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindEPP-v2.rst b/docs/source/algorithms/FindEPP-v2.rst index 5d21c8caf27c5c1e12403f093a1c978c26dfca50..6d9bf273840e450aea7ff311e6fb0f4e8f9b880e 100644 --- a/docs/source/algorithms/FindEPP-v2.rst +++ b/docs/source/algorithms/FindEPP-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindPeakBackground-v1.rst b/docs/source/algorithms/FindPeakBackground-v1.rst index 74a0ba5dbc1ecad94b04ff36568381c3d47b9d79..13fe933f2bec15837591eb6a41fad34e994f92be 100644 --- a/docs/source/algorithms/FindPeakBackground-v1.rst +++ b/docs/source/algorithms/FindPeakBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindPeaks-v1.rst b/docs/source/algorithms/FindPeaks-v1.rst index 065598ee6f040f4cf8f65089ab4161cbe6f5a245..7e0ca332f4876b2813bd9398f3a2da7756aa12fe 100644 --- a/docs/source/algorithms/FindPeaks-v1.rst +++ b/docs/source/algorithms/FindPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindPeaksMD-v1.rst b/docs/source/algorithms/FindPeaksMD-v1.rst index 5d799903afdfd42609c4a6b9845cc40d800a103d..924f356c771cc84af50d15d79f181f67d191252c 100644 --- a/docs/source/algorithms/FindPeaksMD-v1.rst +++ b/docs/source/algorithms/FindPeaksMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -145,24 +145,24 @@ file is availible in `Mantid system tests repository <https://github.com/mantidp def print_tableWS(pTWS,nRows): ''' Method to print part of the table workspace ''' - tab_names=pTWS.keys(); - + tab_names=pTWS.keys() + row = "" for name in tab_names: if len(name)>8: - name= name[0:8]; - print("| {0:8} ".format(name)) - print("|\n") - - for i in xrange(0,nRows): + name= name[:8] + row += "| {:8} ".format(name) + print(row + "|") + + for i in range(nRows): + row = "" for name in tab_names: col = pTWS.column(name); data2pr=col[i] if type(data2pr) is float: - print("| {0:>8.2f} ".format(data2pr)) + row += "| {:8.1f} ".format(data2pr) else: - print("| {0:>8} ".format(data2pr)) - print("|\n") - + row += "| {:8} ".format(str(data2pr)) + print(row + "|") # load test workspace Load(Filename=r'TOPAZ_3132_event.nxs',OutputWorkspace='TOPAZ_3132_event',LoadMonitors='1') @@ -183,17 +183,17 @@ file is availible in `Mantid system tests repository <https://github.com/mantidp #.. testoutput:: exFindPeaksMD - | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | - | 3132 | 1124984 | 0.00 | 0.00 | 0.00 | 3.10 | 8.49 | 14482.29 | 2.02 | 0.00 | 0.00 | 1668.00 | bank17 | 120.00 | 42.00 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | - | 3132 | 1156753 | 0.00 | 0.00 | 0.00 | 2.08 | 18.82 | 9725.74 | 1.30 | 0.00 | 0.00 | 1060.00 | bank17 | 145.00 | 166.00 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | - | 3132 | 1141777 | 0.00 | 0.00 | 0.00 | 1.71 | 28.09 | 7963.17 | 1.05 | 0.00 | 0.00 | 96.00 | bank17 | 17.00 | 108.00 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | - | 3132 | 1125241 | 0.00 | 0.00 | 0.00 | 1.55 | 33.86 | 7252.16 | 1.01 | 0.00 | 0.00 | 83.00 | bank17 | 121.00 | 43.00 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | - | 3132 | 1170598 | 0.00 | 0.00 | 0.00 | 1.55 | 34.12 | 7224.59 | 0.95 | 0.00 | 0.00 | 73.00 | bank17 | 166.00 | 220.00 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | - | 3132 | 1214951 | 0.00 | 0.00 | 0.00 | 1.89 | 22.79 | 8839.55 | 1.68 | 0.00 | 0.00 | 719.00 | bank18 | 231.00 | 137.00 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | - | 3132 | 1207827 | 0.00 | 0.00 | 0.00 | 1.71 | 27.89 | 7991.70 | 1.32 | 0.00 | 0.00 | 447.00 | bank18 | 19.00 | 110.00 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | - | 3132 | 1232949 | 0.00 | 0.00 | 0.00 | 1.24 | 53.28 | 5782.14 | 0.93 | 0.00 | 0.00 | 45.00 | bank18 | 53.00 | 208.00 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | - | 3132 | 1189484 | 0.00 | 0.00 | 0.00 | 1.14 | 63.42 | 5299.28 | 0.96 | 0.00 | 0.00 | 31.00 | bank18 | 108.00 | 38.00 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | - | 3132 | 1218337 | 0.00 | 0.00 | 0.00 | 1.01 | 79.81 | 4724.05 | 0.77 | 0.00 | 0.00 | 15.00 | bank18 | 33.00 | 151.00 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | + | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | PeakNumb | + | 3132 | 1124984 | 0.0 | 0.0 | 0.0 | 3.1 | 8.5 | 14482.3 | 2.0 | 0.0 | 0.0 | 1668.0 | bank17 | 120.0 | 42.0 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | 1 | + | 3132 | 1156753 | 0.0 | 0.0 | 0.0 | 2.1 | 18.8 | 9725.7 | 1.3 | 0.0 | 0.0 | 1060.0 | bank17 | 145.0 | 166.0 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | 2 | + | 3132 | 1141777 | 0.0 | 0.0 | 0.0 | 1.7 | 28.1 | 7963.2 | 1.0 | 0.0 | 0.0 | 96.0 | bank17 | 17.0 | 108.0 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | 3 | + | 3132 | 1125241 | 0.0 | 0.0 | 0.0 | 1.6 | 33.9 | 7252.2 | 1.0 | 0.0 | 0.0 | 83.0 | bank17 | 121.0 | 43.0 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | 4 | + | 3132 | 1170598 | 0.0 | 0.0 | 0.0 | 1.5 | 34.1 | 7224.6 | 0.9 | 0.0 | 0.0 | 73.0 | bank17 | 166.0 | 220.0 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | 5 | + | 3132 | 1214951 | 0.0 | 0.0 | 0.0 | 1.9 | 22.8 | 8839.5 | 1.7 | 0.0 | 0.0 | 719.0 | bank18 | 231.0 | 137.0 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | 6 | + | 3132 | 1207827 | 0.0 | 0.0 | 0.0 | 1.7 | 27.9 | 7991.7 | 1.3 | 0.0 | 0.0 | 447.0 | bank18 | 19.0 | 110.0 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | 7 | + | 3132 | 1232949 | 0.0 | 0.0 | 0.0 | 1.2 | 53.3 | 5782.1 | 0.9 | 0.0 | 0.0 | 45.0 | bank18 | 53.0 | 208.0 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | 8 | + | 3132 | 1189484 | 0.0 | 0.0 | 0.0 | 1.1 | 63.4 | 5299.3 | 1.0 | 0.0 | 0.0 | 31.0 | bank18 | 108.0 | 38.0 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | 9 | + | 3132 | 1218337 | 0.0 | 0.0 | 0.0 | 1.0 | 79.8 | 4724.1 | 0.8 | 0.0 | 0.0 | 15.0 | bank18 | 33.0 | 151.0 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | 10 | .. categories:: diff --git a/docs/source/algorithms/FindReflectometryLines-v1.rst b/docs/source/algorithms/FindReflectometryLines-v1.rst index 8658801e013f42af57adff0cd8459122cc7a49d6..959852929a21a44864e08f5f17c460e0f6be10e5 100644 --- a/docs/source/algorithms/FindReflectometryLines-v1.rst +++ b/docs/source/algorithms/FindReflectometryLines-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindSXPeaks-v1.rst b/docs/source/algorithms/FindSXPeaks-v1.rst index 91f6a7d0cf04248351e12b6d9deda8bb2eb96600..231ad55bb22e0eefa0e60063e5cdf11de690da27 100644 --- a/docs/source/algorithms/FindSXPeaks-v1.rst +++ b/docs/source/algorithms/FindSXPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindUBUsingFFT-v1.rst b/docs/source/algorithms/FindUBUsingFFT-v1.rst index d28fab4eba2815da1da1886b43ed2f50f9d6d36f..20db2c2cc337dc49873c24e6a4ff67383ec2ec98 100644 --- a/docs/source/algorithms/FindUBUsingFFT-v1.rst +++ b/docs/source/algorithms/FindUBUsingFFT-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindUBUsingIndexedPeaks-v1.rst b/docs/source/algorithms/FindUBUsingIndexedPeaks-v1.rst index f642030ababeffc07362f34a5a34a6a2dfd102f5..ca033741902560dd1b180c1c887b7e978e5e317e 100644 --- a/docs/source/algorithms/FindUBUsingIndexedPeaks-v1.rst +++ b/docs/source/algorithms/FindUBUsingIndexedPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindUBUsingLatticeParameters-v1.rst b/docs/source/algorithms/FindUBUsingLatticeParameters-v1.rst index 1d8012832fd618895f8a1b5083108474958f5960..bdf33137bce63442ec0d9e770fa227572eefff87 100644 --- a/docs/source/algorithms/FindUBUsingLatticeParameters-v1.rst +++ b/docs/source/algorithms/FindUBUsingLatticeParameters-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FindUBUsingMinMaxD-v1.rst b/docs/source/algorithms/FindUBUsingMinMaxD-v1.rst index e3c3fac4117d740d2ab13ac8a5dd2ed1b5da4e23..f49ad16a667dc2133f00f94658320b661c35d813 100644 --- a/docs/source/algorithms/FindUBUsingMinMaxD-v1.rst +++ b/docs/source/algorithms/FindUBUsingMinMaxD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Fit-v1.rst b/docs/source/algorithms/Fit-v1.rst index 035b0430a80232ed73337d74293b2f047bc5ea8f..1b2237850be5f6cbf32cfa300463e224f585a726 100644 --- a/docs/source/algorithms/Fit-v1.rst +++ b/docs/source/algorithms/Fit-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FitGaussian-v1.rst b/docs/source/algorithms/FitGaussian-v1.rst index 779dd6ba6da4a9b2722b8665f41849e7fad85a1d..c6f36f47c7496eb5c14e9d951c260575a8aca6d6 100644 --- a/docs/source/algorithms/FitGaussian-v1.rst +++ b/docs/source/algorithms/FitGaussian-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FitPeak-v1.rst b/docs/source/algorithms/FitPeak-v1.rst index 0149c2ebf09b15df50917f656e824f3b5454131e..47a93d71844c2e5bc701033a6e5a8460e177eec7 100644 --- a/docs/source/algorithms/FitPeak-v1.rst +++ b/docs/source/algorithms/FitPeak-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FitPowderDiffPeaks-v1.rst b/docs/source/algorithms/FitPowderDiffPeaks-v1.rst index 04796e007eb77eb7145ee504c60c915852133e7b..ce7ec4115642e46324a8509c57b2e9b14c0df893 100644 --- a/docs/source/algorithms/FitPowderDiffPeaks-v1.rst +++ b/docs/source/algorithms/FitPowderDiffPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FitResolutionConvolvedModel-v1.rst b/docs/source/algorithms/FitResolutionConvolvedModel-v1.rst index 2d8770ff4f101fb34cd88a979eaf9a4c54557db7..992e88294ed18d4f215129779bf38d1f775473a2 100644 --- a/docs/source/algorithms/FitResolutionConvolvedModel-v1.rst +++ b/docs/source/algorithms/FitResolutionConvolvedModel-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FixGSASInstrumentFile-v1.rst b/docs/source/algorithms/FixGSASInstrumentFile-v1.rst index fe76a35484bf0a99a8867c5ccd939d4079039eb1..e7c62fd3c165f466f271aba30523ec63743c6e2c 100644 --- a/docs/source/algorithms/FixGSASInstrumentFile-v1.rst +++ b/docs/source/algorithms/FixGSASInstrumentFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FlatPlateAbsorption-v1.rst b/docs/source/algorithms/FlatPlateAbsorption-v1.rst index 1ef508555216b7e32a86d944769184d155394b61..b7807180e3d3f46d57cf663de6053bab7464d382 100644 --- a/docs/source/algorithms/FlatPlateAbsorption-v1.rst +++ b/docs/source/algorithms/FlatPlateAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/FlatPlatePaalmanPingsCorrection-v1.rst b/docs/source/algorithms/FlatPlatePaalmanPingsCorrection-v1.rst index 1cf5a9118b4df6a334ef118db7892e2ae66674cc..fe854b26b83f4ce8550c166061bd526ff3e77f3d 100644 --- a/docs/source/algorithms/FlatPlatePaalmanPingsCorrection-v1.rst +++ b/docs/source/algorithms/FlatPlatePaalmanPingsCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GSASIIRefineFitPeaks-v1.rst b/docs/source/algorithms/GSASIIRefineFitPeaks-v1.rst index 638d651e1f2e066429942664a376598cbf07fb35..b0ebe932a37cd182c21c2fb4b41b160394073ffe 100644 --- a/docs/source/algorithms/GSASIIRefineFitPeaks-v1.rst +++ b/docs/source/algorithms/GSASIIRefineFitPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GatherWorkspaces-v1.rst b/docs/source/algorithms/GatherWorkspaces-v1.rst index 3e58b64aef50be660ed550ac2195a2e57d776df3..cdcd8907366c5bde3f6956f12fbec6387e41f131 100644 --- a/docs/source/algorithms/GatherWorkspaces-v1.rst +++ b/docs/source/algorithms/GatherWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GeneralisedSecondDifference-v1.rst b/docs/source/algorithms/GeneralisedSecondDifference-v1.rst index 8d9c9a05ee1936c0fd7682305689b6445dfef879..94359793ffba5a2e51dce897d24fc25840f9c0b5 100644 --- a/docs/source/algorithms/GeneralisedSecondDifference-v1.rst +++ b/docs/source/algorithms/GeneralisedSecondDifference-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GenerateEventsFilter-v1.rst b/docs/source/algorithms/GenerateEventsFilter-v1.rst index f08d70e464ced94ca3b8b878f085c92d370233a2..d1f49e3ce329239d488a837551aad01df27958bb 100644 --- a/docs/source/algorithms/GenerateEventsFilter-v1.rst +++ b/docs/source/algorithms/GenerateEventsFilter-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GenerateGroupingPowder-v1.rst b/docs/source/algorithms/GenerateGroupingPowder-v1.rst index 1e60ca05e6fb269f36e9f8f5e4bdde3f83446079..fd0bf506a2b35230c172b8e7751a676cfc9a42f8 100644 --- a/docs/source/algorithms/GenerateGroupingPowder-v1.rst +++ b/docs/source/algorithms/GenerateGroupingPowder-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GenerateGroupingSNSInelastic-v1.rst b/docs/source/algorithms/GenerateGroupingSNSInelastic-v1.rst index be4e371ec3fb747c6348267006df75d8e68325de..9247cc1f73f6e535422e685ec37063c0abd9c35f 100644 --- a/docs/source/algorithms/GenerateGroupingSNSInelastic-v1.rst +++ b/docs/source/algorithms/GenerateGroupingSNSInelastic-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GenerateIPythonNotebook-v1.rst b/docs/source/algorithms/GenerateIPythonNotebook-v1.rst index 5f5d2f6066e18af71b2664c0fd42ad69243a63b1..fe434664c108c08d82ebbe1257404dd31aba4a65 100644 --- a/docs/source/algorithms/GenerateIPythonNotebook-v1.rst +++ b/docs/source/algorithms/GenerateIPythonNotebook-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GeneratePeaks-v1.rst b/docs/source/algorithms/GeneratePeaks-v1.rst index ba3f9dd6a809c533e655a4b0fe8e7149637f771e..bd8e69b466f4b2762b3d68bfb1e67de27d79823c 100644 --- a/docs/source/algorithms/GeneratePeaks-v1.rst +++ b/docs/source/algorithms/GeneratePeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GeneratePythonScript-v1.rst b/docs/source/algorithms/GeneratePythonScript-v1.rst index 120ec60cc48b46ec9f72d05bc7a5e6a037dac4c5..d4e7b1958f7d00c8d2ac53a046103ea049896196 100644 --- a/docs/source/algorithms/GeneratePythonScript-v1.rst +++ b/docs/source/algorithms/GeneratePythonScript-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetAllEi-v1.rst b/docs/source/algorithms/GetAllEi-v1.rst index ac64d4a3fbe58b2fcf1c320705e3f4a3a6495ac3..b5585acaaea5895352c2cd63becf03da933b5a78 100644 --- a/docs/source/algorithms/GetAllEi-v1.rst +++ b/docs/source/algorithms/GetAllEi-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetDetOffsetsMultiPeaks-v1.rst b/docs/source/algorithms/GetDetOffsetsMultiPeaks-v1.rst index 2f15f722ff0dd012c15ed2ee40b8ae6d9cd68693..cf7c75e13ccfbc30b61cf18453b9aaf1c5087171 100644 --- a/docs/source/algorithms/GetDetOffsetsMultiPeaks-v1.rst +++ b/docs/source/algorithms/GetDetOffsetsMultiPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetDetectorOffsets-v1.rst b/docs/source/algorithms/GetDetectorOffsets-v1.rst index c7e6cbc02259548f7799f7cc5be25fdbee46d78c..79b10bfde4d548e5b3bfc2973e6e2feb25f88566 100644 --- a/docs/source/algorithms/GetDetectorOffsets-v1.rst +++ b/docs/source/algorithms/GetDetectorOffsets-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetEi-v1.rst b/docs/source/algorithms/GetEi-v1.rst index f6f69d097d0931201f6322117c223c39016a5c08..d977599197ed9f01011bd0e9d2cf323bd5042590 100644 --- a/docs/source/algorithms/GetEi-v1.rst +++ b/docs/source/algorithms/GetEi-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetEi-v2.rst b/docs/source/algorithms/GetEi-v2.rst index d9e7061a00fe41af20230ae73ca278416ae36de1..f18f493f4797b3fb3cfb1c1da1f36741f2c6f160 100644 --- a/docs/source/algorithms/GetEi-v2.rst +++ b/docs/source/algorithms/GetEi-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetEiMonDet-v1.rst b/docs/source/algorithms/GetEiMonDet-v1.rst index 163093133aac7412ca5a750156e7f37e4e2fdb6c..3e4934fb1d4c7ea2aab5e2d3705ce4fc8693cd85 100644 --- a/docs/source/algorithms/GetEiMonDet-v1.rst +++ b/docs/source/algorithms/GetEiMonDet-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetEiMonDet-v2.rst b/docs/source/algorithms/GetEiMonDet-v2.rst index bb8169cd3504a97622cd41eb3159d07d034363cd..da019e1c2b05b5bf7d846b403ab192d4ab36a792 100644 --- a/docs/source/algorithms/GetEiMonDet-v2.rst +++ b/docs/source/algorithms/GetEiMonDet-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetEiT0atSNS-v1.rst b/docs/source/algorithms/GetEiT0atSNS-v1.rst index 94e0a89f2fc6e899e16244e45fb11adc088e5781..d3872c02d6d9451e1fea3045f55deef7d6547924 100644 --- a/docs/source/algorithms/GetEiT0atSNS-v1.rst +++ b/docs/source/algorithms/GetEiT0atSNS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetIPTS-v1.rst b/docs/source/algorithms/GetIPTS-v1.rst index 67d94d2baef30e172f2f3e5614af9d0199d81a44..88ba39f2e3aba72c98785be7e5b04341deae50fc 100644 --- a/docs/source/algorithms/GetIPTS-v1.rst +++ b/docs/source/algorithms/GetIPTS-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetQsInQENSData-v1.rst b/docs/source/algorithms/GetQsInQENSData-v1.rst index 62c6fd51566abb9181124a7a524f05725bd08ddb..f29900f1ce81ef50bae6e23ed7665ba4254670a5 100644 --- a/docs/source/algorithms/GetQsInQENSData-v1.rst +++ b/docs/source/algorithms/GetQsInQENSData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetSpiceDataRawCountsFromMD-v1.rst b/docs/source/algorithms/GetSpiceDataRawCountsFromMD-v1.rst index 640c995a9225d995a20bffc6a9d3fe599103a419..b9f6afae76083fcc16702d32a75840620e9443d2 100644 --- a/docs/source/algorithms/GetSpiceDataRawCountsFromMD-v1.rst +++ b/docs/source/algorithms/GetSpiceDataRawCountsFromMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GetTimeSeriesLogInformation-v1.rst b/docs/source/algorithms/GetTimeSeriesLogInformation-v1.rst index 7cad594900fe8238abf09acdf71f3b3cf0bed021..bd1c6e92217cb9f70c199ff4fc3c2ad51a08af46 100644 --- a/docs/source/algorithms/GetTimeSeriesLogInformation-v1.rst +++ b/docs/source/algorithms/GetTimeSeriesLogInformation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GoniometerAnglesFromPhiRotation-v1.rst b/docs/source/algorithms/GoniometerAnglesFromPhiRotation-v1.rst index 55f0eef6c72dc80e4c804c886cee14be1baab96d..c13a7586e6cb430b0e92ad1b968444e94807b9f3 100644 --- a/docs/source/algorithms/GoniometerAnglesFromPhiRotation-v1.rst +++ b/docs/source/algorithms/GoniometerAnglesFromPhiRotation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GreaterThanMD-v1.rst b/docs/source/algorithms/GreaterThanMD-v1.rst index 1b4bfccb9239c108ef0355484b01f022c9d23d04..1cc76e43f7ee832398a202967bc65abdddbf17cc 100644 --- a/docs/source/algorithms/GreaterThanMD-v1.rst +++ b/docs/source/algorithms/GreaterThanMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GroupDetectors-v1.rst b/docs/source/algorithms/GroupDetectors-v1.rst index 1cb598e2ca4d95285a95b12b3d4d4b774046d0a7..248238931e76446716d42aa4c144e4515cef79d3 100644 --- a/docs/source/algorithms/GroupDetectors-v1.rst +++ b/docs/source/algorithms/GroupDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GroupDetectors-v2.rst b/docs/source/algorithms/GroupDetectors-v2.rst index f2cb66ff129ca9afd684e9c767f298a7b22e94a4..64c22b32792d1beab34ee36d911af3bdd5f52cc8 100644 --- a/docs/source/algorithms/GroupDetectors-v2.rst +++ b/docs/source/algorithms/GroupDetectors-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/GroupWorkspaces-v1.rst b/docs/source/algorithms/GroupWorkspaces-v1.rst index 08bc6389d67d1f94afeb82b91620d9cc026281c5..28ea510b27ea25fa4c0d04e718df638fd0b9c169 100644 --- a/docs/source/algorithms/GroupWorkspaces-v1.rst +++ b/docs/source/algorithms/GroupWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HFIRDarkCurrentSubtraction-v1.rst b/docs/source/algorithms/HFIRDarkCurrentSubtraction-v1.rst index 1fa07f3cabb735527478f8635962705286271e78..cb4a74af464ef18d737c31e87084071e68627f72 100644 --- a/docs/source/algorithms/HFIRDarkCurrentSubtraction-v1.rst +++ b/docs/source/algorithms/HFIRDarkCurrentSubtraction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HFIRLoad-v1.rst b/docs/source/algorithms/HFIRLoad-v1.rst index 8e54f84b8a5a53da61a28a277ee68bbac48cc2a5..ed9733f4b43df287070828118adffd384656fad9 100644 --- a/docs/source/algorithms/HFIRLoad-v1.rst +++ b/docs/source/algorithms/HFIRLoad-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HFIRSANSNormalise-v1.rst b/docs/source/algorithms/HFIRSANSNormalise-v1.rst index 600633def4b162d84204040485d67f254249b259..019999cebd5c2c94b6b1aa95cfdde99e5d89d14e 100644 --- a/docs/source/algorithms/HFIRSANSNormalise-v1.rst +++ b/docs/source/algorithms/HFIRSANSNormalise-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HFIRSANSReduction-v1.rst b/docs/source/algorithms/HFIRSANSReduction-v1.rst index 76fc0da3670304bd68d1bb4ffad9a3f789cded0b..1e332d172849de8b3879482a9066462317b05bd6 100644 --- a/docs/source/algorithms/HFIRSANSReduction-v1.rst +++ b/docs/source/algorithms/HFIRSANSReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HRPDSlabCanAbsorption-v1.rst b/docs/source/algorithms/HRPDSlabCanAbsorption-v1.rst index 95be4bc13f0191c17953013149aa92619ce59d46..845656a7c5c6da6f60d712574e2662714374c5e1 100644 --- a/docs/source/algorithms/HRPDSlabCanAbsorption-v1.rst +++ b/docs/source/algorithms/HRPDSlabCanAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HasUB-v1.rst b/docs/source/algorithms/HasUB-v1.rst index 8c3a702a195209c004f50d81d33306100fd3597a..ed71dd485a21944db88f134dbd113b37f975e205 100644 --- a/docs/source/algorithms/HasUB-v1.rst +++ b/docs/source/algorithms/HasUB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/He3TubeEfficiency-v1.rst b/docs/source/algorithms/He3TubeEfficiency-v1.rst index 7d941a22e8d5e31ce433fe5dced68abbcc79e133..945e7a90023f2b45e7ca3e04292319cbb5c441f5 100644 --- a/docs/source/algorithms/He3TubeEfficiency-v1.rst +++ b/docs/source/algorithms/He3TubeEfficiency-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/HyspecScharpfCorrection-v1.rst b/docs/source/algorithms/HyspecScharpfCorrection-v1.rst index dff4da2f7ebdbc2bd781e5d2f629a935976257f1..1ca4fb5fe2fcb8138841a90302e8ab04bda4f3e9 100644 --- a/docs/source/algorithms/HyspecScharpfCorrection-v1.rst +++ b/docs/source/algorithms/HyspecScharpfCorrection-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IQTransform-v1.rst b/docs/source/algorithms/IQTransform-v1.rst index c4979f152cfe617dd7b10a859d78db259b863bf2..e761d70aec645974c2066e2488d172456f3641f1 100644 --- a/docs/source/algorithms/IQTransform-v1.rst +++ b/docs/source/algorithms/IQTransform-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ISISIndirectDiffractionReduction-v1.rst b/docs/source/algorithms/ISISIndirectDiffractionReduction-v1.rst index ce585d201e532b76c79f7981059107b2151fef56..83fffd29bd1312dea0ae9c4407576a1dd5ebcd31 100644 --- a/docs/source/algorithms/ISISIndirectDiffractionReduction-v1.rst +++ b/docs/source/algorithms/ISISIndirectDiffractionReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ISISIndirectEnergyTransfer-v1.rst b/docs/source/algorithms/ISISIndirectEnergyTransfer-v1.rst index 5780800c69ef56131ec589fd7fa769608ff6e03b..2947a546a332080cd5e9b2189f3285a03be31566 100644 --- a/docs/source/algorithms/ISISIndirectEnergyTransfer-v1.rst +++ b/docs/source/algorithms/ISISIndirectEnergyTransfer-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IdentifyNoisyDetectors-v1.rst b/docs/source/algorithms/IdentifyNoisyDetectors-v1.rst index dbe3eea3d273ded58d3c258ce2938553190e764e..1291957226a09384bb262c5d52913e0768a92ced 100644 --- a/docs/source/algorithms/IdentifyNoisyDetectors-v1.rst +++ b/docs/source/algorithms/IdentifyNoisyDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ImportMDEventWorkspace-v1.rst b/docs/source/algorithms/ImportMDEventWorkspace-v1.rst index 56876d7e7d711abd485b7e8efcaec045ea7bd263..3f052d10474b47d467da80e92fc32e3234fcc102 100644 --- a/docs/source/algorithms/ImportMDEventWorkspace-v1.rst +++ b/docs/source/algorithms/ImportMDEventWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ImportMDHistoWorkspace-v1.rst b/docs/source/algorithms/ImportMDHistoWorkspace-v1.rst index 91d96eedf71b17b085b83e4722314522e9e5d2f8..fba81f8dc3e8e3cc7139eceec0a666690de491f7 100644 --- a/docs/source/algorithms/ImportMDHistoWorkspace-v1.rst +++ b/docs/source/algorithms/ImportMDHistoWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndexPeaks-v1.rst b/docs/source/algorithms/IndexPeaks-v1.rst index c67aa21333a4218a471191546354b069a1c5014e..bd66a8b1827bdcb9ad79c78a4270421d85802bc6 100644 --- a/docs/source/algorithms/IndexPeaks-v1.rst +++ b/docs/source/algorithms/IndexPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndexSXPeaks-v1.rst b/docs/source/algorithms/IndexSXPeaks-v1.rst index 497e71748a6e61f758220a856f5ff0883f22c093..189b1aee4184d36296a7f1ba8b1567c8d3b88f54 100644 --- a/docs/source/algorithms/IndexSXPeaks-v1.rst +++ b/docs/source/algorithms/IndexSXPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst b/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst index 3db9123cf879302eb8bf1bb3a1e7ad7c25e5f4d0..c9ca3327bab800297f6a4eaaeed0ff62dcd33690 100644 --- a/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst +++ b/docs/source/algorithms/IndirectAnnulusAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectAnnulusAbsorption-v2.rst b/docs/source/algorithms/IndirectAnnulusAbsorption-v2.rst index 77c89e34e5ca352f4a22a95c1bdb1260c3fa4746..b10c28f09301a31fd5f57972a57f630b93e5bc3f 100644 --- a/docs/source/algorithms/IndirectAnnulusAbsorption-v2.rst +++ b/docs/source/algorithms/IndirectAnnulusAbsorption-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectCalibration-v1.rst b/docs/source/algorithms/IndirectCalibration-v1.rst index cd1184579b0aca891c101a1cfa28edf60d730c8d..ada37e779c378cb18e2236640ce6afb859eb1472 100644 --- a/docs/source/algorithms/IndirectCalibration-v1.rst +++ b/docs/source/algorithms/IndirectCalibration-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst b/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst index e5973db26b9f39f564ee034ff8b6bd349780b625..9b3c2289fac553cced6af8586407bf83941a76bb 100644 --- a/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst +++ b/docs/source/algorithms/IndirectCylinderAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectCylinderAbsorption-v2.rst b/docs/source/algorithms/IndirectCylinderAbsorption-v2.rst index a32f50957cafdce41e50f6b2613d012901b6c424..25d58f1fbc47780d8cc5dfce1194ef6f75fa9ec7 100644 --- a/docs/source/algorithms/IndirectCylinderAbsorption-v2.rst +++ b/docs/source/algorithms/IndirectCylinderAbsorption-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectDiffScan-v1.rst b/docs/source/algorithms/IndirectDiffScan-v1.rst index d5358ad998dbd07094fb29b1daeac48ec584c428..ef8386c49ac4db447b90c22780d221b17ad4c635 100644 --- a/docs/source/algorithms/IndirectDiffScan-v1.rst +++ b/docs/source/algorithms/IndirectDiffScan-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst b/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst index 844b49e9abdc8ef7d7b492572ac5a70c743d4387..e9c662cb20fc0df10f4cc2a96eb8ca028f62804e 100644 --- a/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst +++ b/docs/source/algorithms/IndirectFlatPlateAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectFlatPlateAbsorption-v2.rst b/docs/source/algorithms/IndirectFlatPlateAbsorption-v2.rst index f5cd723fcbaa3e8bf202c3ac183d56a3f4cb7d97..cf8d8dd6ca52c9786c06fb376f93198409c3752b 100644 --- a/docs/source/algorithms/IndirectFlatPlateAbsorption-v2.rst +++ b/docs/source/algorithms/IndirectFlatPlateAbsorption-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectILLEnergyTransfer-v1.rst b/docs/source/algorithms/IndirectILLEnergyTransfer-v1.rst index 1044f48fc7ce54337c23030666b876fd5cfc6b05..d94b96d4c93b47fdbdffeee8a14b717323274113 100644 --- a/docs/source/algorithms/IndirectILLEnergyTransfer-v1.rst +++ b/docs/source/algorithms/IndirectILLEnergyTransfer-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectILLReductionFWS-v1.rst b/docs/source/algorithms/IndirectILLReductionFWS-v1.rst index 48e65b1f07a8c831766f3df5f7c2770cb5767257..94543460dbcacccfd18e08138af1c805ac42c3fa 100644 --- a/docs/source/algorithms/IndirectILLReductionFWS-v1.rst +++ b/docs/source/algorithms/IndirectILLReductionFWS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectILLReductionQENS-v1.rst b/docs/source/algorithms/IndirectILLReductionQENS-v1.rst index a0d6bb85580083446c8320e7c43f3bd544d18386..5910b816835020f5d5a48cfa627cea5191dc5348 100644 --- a/docs/source/algorithms/IndirectILLReductionQENS-v1.rst +++ b/docs/source/algorithms/IndirectILLReductionQENS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -13,7 +13,7 @@ Performs a multiple-file QENS (Quasi-Elastic Neutron Scattering) data reduction It uses internally the :ref:`IndirectILLEnergyTransfer <algm-IndirectILLEnergyTransfer>` algorithm. Multiple File Reduction -~~~~~~~~~~~~~~~~~~~~~~~ +####################### The algorithm is capable of running over multiple files. Run property needs to be specified following the syntax in :py:obj:`MultipleFileProperty <mantid.api.MultipleFileProperty>`. @@ -24,7 +24,7 @@ ignored. Use **Added Range** and **Added Stepped Range** instead (see ``CalibrationRun``, ``CalibrationBackgroundRun`` and ``AlignmentRun`` all the runs will be automatically summed. Unmirror Options -~~~~~~~~~~~~~~~~ +################ **IN16B** can record data with mirror sense, where the spectra for the acceleration and deceleration phase of the Doppler drive are recorded separately, or without. @@ -62,7 +62,7 @@ Options 5 and 7 require the ``AlignmentRun`` (vanadium) to determine the peak po Note, that both detector calibration and background subtraction are performed wing-by-wing, i.e. unmirroring is the very final step. Vanadium Calibration -~~~~~~~~~~~~~~~~~~~~ +#################### Integration range can be specified to integrate over spectra in ``CalibrationRun``. Note, that before integration, the spectra will be centered at 0-energy transfer (see Unmirror Option 6 above) for the calibration run. diff --git a/docs/source/algorithms/IndirectQuickRun-v1.rst b/docs/source/algorithms/IndirectQuickRun-v1.rst index d8f19257054f719e61470117ac25c7cc9ce371d9..93e79b5bfcb92d175094a3359aba9e30a033e113 100644 --- a/docs/source/algorithms/IndirectQuickRun-v1.rst +++ b/docs/source/algorithms/IndirectQuickRun-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectResolution-v1.rst b/docs/source/algorithms/IndirectResolution-v1.rst index 539852f2fcd792d747ae636ac9f23f24f320e030..07249bd02737d9ad16ec5b8b7ceaf2242c1c31e8 100644 --- a/docs/source/algorithms/IndirectResolution-v1.rst +++ b/docs/source/algorithms/IndirectResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectSampleChanger-v1.rst b/docs/source/algorithms/IndirectSampleChanger-v1.rst index c0f87a6e65ce49caf6cd15d173d61e95d7a1d8fa..93907aaa537e615e105a89557ea85a7d5eff8c6e 100644 --- a/docs/source/algorithms/IndirectSampleChanger-v1.rst +++ b/docs/source/algorithms/IndirectSampleChanger-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectTransmission-v1.rst b/docs/source/algorithms/IndirectTransmission-v1.rst index 142920a7bd86a7e7b7fc0f7d36dbd2b545fe44de..eeafe31920a0601fb99798469439f5f27379c6c2 100644 --- a/docs/source/algorithms/IndirectTransmission-v1.rst +++ b/docs/source/algorithms/IndirectTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IndirectTransmissionMonitor-v1.rst b/docs/source/algorithms/IndirectTransmissionMonitor-v1.rst index 68f881ad280232832103aa13e50284853311770c..9f9361a03eb342c2ae753d0c5d5a34610f8afc8b 100644 --- a/docs/source/algorithms/IndirectTransmissionMonitor-v1.rst +++ b/docs/source/algorithms/IndirectTransmissionMonitor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegrateByComponent-v1.rst b/docs/source/algorithms/IntegrateByComponent-v1.rst index d961ed53eeecc636349676ecb0fdac4272342dfd..f2460e09aac2a246aa905165b8efd0dbe52450b9 100644 --- a/docs/source/algorithms/IntegrateByComponent-v1.rst +++ b/docs/source/algorithms/IntegrateByComponent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegrateEPP-v1.rst b/docs/source/algorithms/IntegrateEPP-v1.rst index fdcbce9792eebddb012875c61286676ebea8d04e..2e2c65a53e45120e1869e51e8963f7b7c5ae7984 100644 --- a/docs/source/algorithms/IntegrateEPP-v1.rst +++ b/docs/source/algorithms/IntegrateEPP-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegrateEllipsoids-v1.rst b/docs/source/algorithms/IntegrateEllipsoids-v1.rst index 8e34678c0ef8b2de0c91117d3a9df3536548d810..23b4caf1dabcb745cb863f338efea5efc52b76f7 100644 --- a/docs/source/algorithms/IntegrateEllipsoids-v1.rst +++ b/docs/source/algorithms/IntegrateEllipsoids-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -273,17 +273,17 @@ file is availible in `Mantid system tests repository <https://github.com/mantidp .. code-block:: python :linenos: - | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | - | 3132 | 1124984 | -2.0 | -1.0 | 2.0 | 3.1 | 8.5 | 14482.3 | 2.0 | 120486.0 | 375.8 | 1668.0 | bank17 | 120.0 | 42.0 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | - | 3132 | 1156753 | -3.0 | -2.0 | 3.0 | 2.1 | 18.8 | 9725.7 | 1.3 | 149543.0 | 393.0 | 1060.0 | bank17 | 145.0 | 166.0 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | - | 3132 | 1141777 | -4.0 | -2.0 | 3.0 | 1.7 | 28.1 | 7963.2 | 1.0 | 8744.0 | 106.3 | 96.0 | bank17 | 17.0 | 108.0 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | - | 3132 | 1125241 | -4.0 | -2.0 | 4.0 | 1.6 | 33.9 | 7252.2 | 1.0 | 19740.0 | 146.2 | 83.0 | bank17 | 121.0 | 43.0 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | - | 3132 | 1170598 | -4.0 | -3.0 | 4.0 | 1.5 | 34.1 | 7224.6 | 0.9 | 15914.0 | 131.4 | 73.0 | bank17 | 166.0 | 220.0 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | - | 3132 | 1214951 | -2.0 | -1.0 | 4.0 | 1.9 | 22.8 | 8839.5 | 1.7 | 121852.0 | 352.9 | 719.0 | bank18 | 231.0 | 137.0 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | - | 3132 | 1207827 | -3.0 | -1.0 | 4.0 | 1.7 | 27.9 | 7991.7 | 1.3 | 64593.0 | 257.7 | 447.0 | bank18 | 19.0 | 110.0 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | - | 3132 | 1232949 | -4.0 | -2.0 | 6.0 | 1.2 | 53.3 | 5782.1 | 0.9 | 18247.0 | 139.3 | 45.0 | bank18 | 53.0 | 208.0 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | - | 3132 | 1189484 | -4.0 | -1.0 | 6.0 | 1.1 | 63.4 | 5299.3 | 1.0 | 13512.0 | 120.7 | 31.0 | bank18 | 108.0 | 38.0 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | - | 3132 | 1218337 | -5.0 | -2.0 | 7.0 | 1.0 | 79.8 | 4724.1 | 0.8 | 7411.0 | 88.3 | 15.0 | bank18 | 33.0 | 151.0 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | + | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | PeakNumb | + | 3132 | 1124984 | -2.0 | -1.0 | 2.0 | 3.1 | 8.5 | 14482.3 | 2.0 | 120486.0 | 375.8 | 1668.0 | bank17 | 120.0 | 42.0 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | 1 | + | 3132 | 1156753 | -3.0 | -2.0 | 3.0 | 2.1 | 18.8 | 9725.7 | 1.3 | 149543.0 | 393.0 | 1060.0 | bank17 | 145.0 | 166.0 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | 2 | + | 3132 | 1141777 | -4.0 | -2.0 | 3.0 | 1.7 | 28.1 | 7963.2 | 1.0 | 8744.0 | 106.3 | 96.0 | bank17 | 17.0 | 108.0 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | 3 | + | 3132 | 1125241 | -4.0 | -2.0 | 4.0 | 1.6 | 33.9 | 7252.2 | 1.0 | 19740.0 | 146.2 | 83.0 | bank17 | 121.0 | 43.0 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | 4 | + | 3132 | 1170598 | -4.0 | -3.0 | 4.0 | 1.5 | 34.1 | 7224.6 | 0.9 | 15914.0 | 131.4 | 73.0 | bank17 | 166.0 | 220.0 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | 5 | + | 3132 | 1214951 | -2.0 | -1.0 | 4.0 | 1.9 | 22.8 | 8839.5 | 1.7 | 121852.0 | 352.9 | 719.0 | bank18 | 231.0 | 137.0 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | 6 | + | 3132 | 1207827 | -3.0 | -1.0 | 4.0 | 1.7 | 27.9 | 7991.7 | 1.3 | 64593.0 | 257.7 | 447.0 | bank18 | 19.0 | 110.0 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | 7 | + | 3132 | 1232949 | -4.0 | -2.0 | 6.0 | 1.2 | 53.3 | 5782.1 | 0.9 | 18247.0 | 139.3 | 45.0 | bank18 | 53.0 | 208.0 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | 8 | + | 3132 | 1189484 | -4.0 | -1.0 | 6.0 | 1.1 | 63.4 | 5299.3 | 1.0 | 13512.0 | 120.7 | 31.0 | bank18 | 108.0 | 38.0 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | 9 | + | 3132 | 1218337 | -5.0 | -2.0 | 7.0 | 1.0 | 79.8 | 4724.1 | 0.8 | 7411.0 | 88.3 | 15.0 | bank18 | 33.0 | 151.0 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | 10 | .. categories:: diff --git a/docs/source/algorithms/IntegrateEllipsoidsTwoStep-v1.rst b/docs/source/algorithms/IntegrateEllipsoidsTwoStep-v1.rst index 8b7af21beb57ba2a1710e343000c62cecbbf9a0c..3104a0cd27efdaac11e77ab48f90d29ff561f65a 100644 --- a/docs/source/algorithms/IntegrateEllipsoidsTwoStep-v1.rst +++ b/docs/source/algorithms/IntegrateEllipsoidsTwoStep-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -315,17 +315,17 @@ availible in `Mantid system tests repository .. code-block:: python :linenos: - | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | - | 3132 | 1124984 | -2.0 | -1.0 | 2.0 | 3.1 | 8.5 | 14482.3 | 2.0 | 120486.0 | 375.8 | 1668.0 | bank17 | 120.0 | 42.0 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | - | 3132 | 1156753 | -3.0 | -2.0 | 3.0 | 2.1 | 18.8 | 9725.7 | 1.3 | 149543.0 | 393.0 | 1060.0 | bank17 | 145.0 | 166.0 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | - | 3132 | 1141777 | -4.0 | -2.0 | 3.0 | 1.7 | 28.1 | 7963.2 | 1.0 | 8744.0 | 106.3 | 96.0 | bank17 | 17.0 | 108.0 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | - | 3132 | 1125241 | -4.0 | -2.0 | 4.0 | 1.6 | 33.9 | 7252.2 | 1.0 | 19740.0 | 146.2 | 83.0 | bank17 | 121.0 | 43.0 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | - | 3132 | 1170598 | -4.0 | -3.0 | 4.0 | 1.5 | 34.1 | 7224.6 | 0.9 | 15914.0 | 131.4 | 73.0 | bank17 | 166.0 | 220.0 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | - | 3132 | 1214951 | -2.0 | -1.0 | 4.0 | 1.9 | 22.8 | 8839.5 | 1.7 | 121852.0 | 352.9 | 719.0 | bank18 | 231.0 | 137.0 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | - | 3132 | 1207827 | -3.0 | -1.0 | 4.0 | 1.7 | 27.9 | 7991.7 | 1.3 | 64593.0 | 257.7 | 447.0 | bank18 | 19.0 | 110.0 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | - | 3132 | 1232949 | -4.0 | -2.0 | 6.0 | 1.2 | 53.3 | 5782.1 | 0.9 | 18247.0 | 139.3 | 45.0 | bank18 | 53.0 | 208.0 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | - | 3132 | 1189484 | -4.0 | -1.0 | 6.0 | 1.1 | 63.4 | 5299.3 | 1.0 | 13512.0 | 120.7 | 31.0 | bank18 | 108.0 | 38.0 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | - | 3132 | 1218337 | -5.0 | -2.0 | 7.0 | 1.0 | 79.8 | 4724.1 | 0.8 | 7411.0 | 88.3 | 15.0 | bank18 | 33.0 | 151.0 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | + | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | PeakNumb | + | 3132 | 1124984 | -2.0 | -1.0 | 2.0 | 3.1 | 8.5 | 14482.3 | 2.0 | 120486.0 | 375.8 | 1668.0 | bank17 | 120.0 | 42.0 | [1.57771,1.21779,2.37854] | [2.99396,0.815958,0.00317344] | 1 | + | 3132 | 1156753 | -3.0 | -2.0 | 3.0 | 2.1 | 18.8 | 9725.7 | 1.3 | 149543.0 | 393.0 | 1060.0 | bank17 | 145.0 | 166.0 | [2.48964,1.45725,3.88666] | [4.52618,1.71025,0.129461] | 2 | + | 3132 | 1141777 | -4.0 | -2.0 | 3.0 | 1.7 | 28.1 | 7963.2 | 1.0 | 8744.0 | 106.3 | 96.0 | bank17 | 17.0 | 108.0 | [2.60836,2.31423,4.86391] | [5.69122,1.79492,-0.452799] | 3 | + | 3132 | 1125241 | -4.0 | -2.0 | 4.0 | 1.6 | 33.9 | 7252.2 | 1.0 | 19740.0 | 146.2 | 83.0 | bank17 | 121.0 | 43.0 | [3.15504,2.42573,4.75121] | [5.97829,1.63473,0.0118744] | 4 | + | 3132 | 1170598 | -4.0 | -3.0 | 4.0 | 1.5 | 34.1 | 7224.6 | 0.9 | 15914.0 | 131.4 | 73.0 | bank17 | 166.0 | 220.0 | [3.43363,1.70178,5.39301] | [6.07726,2.59962,0.281759] | 5 | + | 3132 | 1214951 | -2.0 | -1.0 | 4.0 | 1.9 | 22.8 | 8839.5 | 1.7 | 121852.0 | 352.9 | 719.0 | bank18 | 231.0 | 137.0 | [2.73683,1.43808,2.11574] | [3.5786,0.470838,1.00329] | 6 | + | 3132 | 1207827 | -3.0 | -1.0 | 4.0 | 1.7 | 27.9 | 7991.7 | 1.3 | 64593.0 | 257.7 | 447.0 | bank18 | 19.0 | 110.0 | [2.80324,2.29519,3.09134] | [4.71517,0.554412,0.37714] | 7 | + | 3132 | 1232949 | -4.0 | -2.0 | 6.0 | 1.2 | 53.3 | 5782.1 | 0.9 | 18247.0 | 139.3 | 45.0 | bank18 | 53.0 | 208.0 | [4.29033,2.63319,4.46168] | [6.52658,1.27985,1.00646] | 8 | + | 3132 | 1189484 | -4.0 | -1.0 | 6.0 | 1.1 | 63.4 | 5299.3 | 1.0 | 13512.0 | 120.7 | 31.0 | bank18 | 108.0 | 38.0 | [4.02414,3.39659,3.83664] | [6.4679,0.298896,0.726133] | 9 | + | 3132 | 1218337 | -5.0 | -2.0 | 7.0 | 1.0 | 79.8 | 4724.1 | 0.8 | 7411.0 | 88.3 | 15.0 | bank18 | 33.0 | 151.0 | [4.96622,3.61607,5.32554] | [7.99244,1.19363,0.892655] | 10 | .. categories:: diff --git a/docs/source/algorithms/IntegrateFlux-v1.rst b/docs/source/algorithms/IntegrateFlux-v1.rst index 04161a2ddd77d2ee7622a0abc4aa61d7e49569b8..6bda273ccce0ba637d54c9a5e2de6d7e9fdd5439 100644 --- a/docs/source/algorithms/IntegrateFlux-v1.rst +++ b/docs/source/algorithms/IntegrateFlux-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegrateMDHistoWorkspace-v1.rst b/docs/source/algorithms/IntegrateMDHistoWorkspace-v1.rst index 0f27858c11c22d17176c407784559a28771e0f04..40bd6a3c80b4e2ae817a8ef751c88d7b6fd4db8c 100644 --- a/docs/source/algorithms/IntegrateMDHistoWorkspace-v1.rst +++ b/docs/source/algorithms/IntegrateMDHistoWorkspace-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -13,12 +13,12 @@ Description Provides limited integration of a :ref:`MDHistoWorkspace <MDHistoWorkspace>` in n-dimensions. Integration is always axis-aligned. Dimensions can only be integrated out, but no finer rebinning is permitted. Dimensions that do not require further rebinning will be left intact provided that the the binning parameters for those dimensions are not specified. For dimensions that are integrated, limits should be provided to give the range of the data to keep. Binning -~~~~~~~ +####### The *P1Bin* corresponds to the first dimension of the MDHistoWorkspace, *P2Bin* to the second and so on. *P1Bin=[-1, 1]* indicates that we will integrate this dimension between -1 and 1. *P1Bins=[]* indicates that the shape of this dimension should be unchanged from the input. *P1Bins=[-1,0,1]* is a special case, the zero indicates that the same bin width as the input dimension would be used, but the minimum and maximum will also be used to crop the dimension. In this latter form, the limits may be expanded to ensure that there is no partial bins in the non-integrated dimension (see warning messages). Weights -~~~~~~~ +####### The algorithm works by creating the *OutputWorkspace* in the correct shape. Each bin in the OutputWorkspace is treated in turn. For each bin in the OutputWorkspace, we find those bins in the *InputWorkspace* that overlap and therefore could contribute to the OutputBin. For any contributing bin, we calculate the fraction overlap and treat this a weighting factor. For each contributing bin *Signal*, and :math:`Error^{2}`, and *Number of Events* values are extracted and multiplied by the weight. These values are summed for all contributing input bins before being assigned to the corresponding output bin. For plotting the *OutputWorkspace*, it is important to select the Number of Events normalization option to correctly account for the weights. diff --git a/docs/source/algorithms/IntegratePeakTimeSlices-v1.rst b/docs/source/algorithms/IntegratePeakTimeSlices-v1.rst index 7c95e0d49fd254afc3d78c176f74644e114a0f97..b328a21255eafbcc45d32a892aeac6093e5611d6 100644 --- a/docs/source/algorithms/IntegratePeakTimeSlices-v1.rst +++ b/docs/source/algorithms/IntegratePeakTimeSlices-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegratePeaksCWSD-v1.rst b/docs/source/algorithms/IntegratePeaksCWSD-v1.rst index 1f32f37597ac06b82db6462f2236ab9427007177..b6ec410b2a028573ee0353738140573bb8969feb 100644 --- a/docs/source/algorithms/IntegratePeaksCWSD-v1.rst +++ b/docs/source/algorithms/IntegratePeaksCWSD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegratePeaksHybrid-v1.rst b/docs/source/algorithms/IntegratePeaksHybrid-v1.rst index 23444e0a196c496364e40ee30a7d489fc732efaf..6c76bddc5fb763d81adf1c2c60569d1bd425eb61 100644 --- a/docs/source/algorithms/IntegratePeaksHybrid-v1.rst +++ b/docs/source/algorithms/IntegratePeaksHybrid-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegratePeaksMD-v1.rst b/docs/source/algorithms/IntegratePeaksMD-v1.rst index b0fb9c10c7579bf2aef89a03d71a94d589cd94c4..6e728bd8f1bbc83f25bd8417f8118ebc62bad272 100644 --- a/docs/source/algorithms/IntegratePeaksMD-v1.rst +++ b/docs/source/algorithms/IntegratePeaksMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegratePeaksMD-v2.rst b/docs/source/algorithms/IntegratePeaksMD-v2.rst index 9e159ed56c3bcc660a1742df507526975c2b0ba0..76b3bf4f930e09126a47f2847cdb83b4630200f9 100644 --- a/docs/source/algorithms/IntegratePeaksMD-v2.rst +++ b/docs/source/algorithms/IntegratePeaksMD-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -236,17 +236,17 @@ file is availible in `Mantid system tests repository <https://github.com/mantidp :linenos: - | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | - | 3132 | 1168209 | 0.0 | 0.0 | 0.0 | 1.1 | 66.9 | 5158.0 | 0.7 | 2160.9 | 32.3 | 1326.0 | bank17 | 81.0 | 211.0 | [4.42961,2.81707,7.86314] | [8.75838,3.55459,-0.205083] | - | 3132 | 1124983 | 0.0 | 0.0 | 0.0 | 1.6 | 33.9 | 7250.6 | 1.0 | 1990.0 | 14.4 | 1060.0 | bank17 | 119.0 | 42.0 | [3.14813,2.43563,4.75389] | [5.9822,1.62965,0.00130101] | - | 3132 | 1141521 | 0.0 | 0.0 | 0.0 | 1.7 | 28.1 | 7959.1 | 1.0 | 644.6 | 7.3 | 1034.0 | bank17 | 17.0 | 107.0 | [2.60893,2.31831,4.86248] | [5.69311,1.79103,-0.453311] | - | 3132 | 1125238 | 0.0 | 0.0 | 0.0 | 3.1 | 8.4 | 14518.9 | 2.0 | 750.5 | 2.2 | 880.0 | bank17 | 118.0 | 43.0 | [1.57116,1.21649,2.37775] | [2.98926,0.816337,-0.00161709] | - | 3132 | 1170852 | 0.0 | 0.0 | 0.0 | 1.6 | 34.0 | 7235.3 | 1.0 | 1826.4 | 14.7 | 762.0 | bank17 | 164.0 | 221.0 | [3.4229,1.70246,5.39532] | [6.0734,2.6008,0.271523] | - | 3132 | 1156497 | 0.0 | 0.0 | 0.0 | 2.1 | 18.9 | 9718.2 | 1.3 | 5137.6 | 13.4 | 518.0 | bank17 | 145.0 | 165.0 | [2.49117,1.46093,3.88649] | [4.5291,1.70753,0.129446] | - | 3132 | 1207828 | 0.0 | 0.0 | 0.0 | 1.7 | 27.9 | 7989.1 | 1.3 | 3233.6 | 12.7 | 1024.0 | bank18 | 20.0 | 110.0 | [2.80538,2.29342,3.08833] | [4.71342,0.553533,0.380727] | - | 3132 | 1218593 | 0.0 | 0.0 | 0.0 | 1.0 | 79.6 | 4729.3 | 0.8 | 3018.1 | 35.4 | 756.0 | bank18 | 33.0 | 152.0 | [4.96533,3.60693,5.32436] | [7.98578,1.19927,0.895763] | - | 3132 | 1232694 | 0.0 | 0.0 | 0.0 | 1.2 | 53.4 | 5772.9 | 0.9 | 3464.5 | 25.9 | 631.0 | bank18 | 54.0 | 207.0 | [4.29539,2.63813,4.45945] | [6.53086,1.27477,1.00974] | - | 3132 | 1200023 | 0.0 | 0.0 | 0.0 | 0.7 | 159.1 | 3345.1 | 0.6 | 3796.1 | 71.1 | 509.0 | bank18 | 151.0 | 79.0 | [6.75629,4.8092,5.93224] | [10.0166,0.773518,1.74245] | + | RunNumbe | DetID | h | k | l | Waveleng | Energy | TOF | DSpacing | Intens | SigInt | BinCount | BankName | Row | Col | QLab | QSample | PeakNumb | + | 3132 | 1168209 | 0.0 | 0.0 | 0.0 | 1.1 | 66.9 | 5158.0 | 0.7 | 2160.9 | 32.3 | 1326.0 | bank17 | 81.0 | 211.0 | [4.42961,2.81707,7.86314] | [8.75838,3.55459,-0.205083] | 1 | + | 3132 | 1124983 | 0.0 | 0.0 | 0.0 | 1.6 | 33.9 | 7250.6 | 1.0 | 1990.0 | 14.4 | 1060.0 | bank17 | 119.0 | 42.0 | [3.14813,2.43563,4.75389] | [5.9822,1.62965,0.00130101] | 2 | + | 3132 | 1141521 | 0.0 | 0.0 | 0.0 | 1.7 | 28.1 | 7959.1 | 1.0 | 644.6 | 7.3 | 1034.0 | bank17 | 17.0 | 107.0 | [2.60893,2.31831,4.86248] | [5.69311,1.79103,-0.453311] | 3 | + | 3132 | 1125238 | 0.0 | 0.0 | 0.0 | 3.1 | 8.4 | 14518.9 | 2.0 | 750.5 | 2.2 | 880.0 | bank17 | 118.0 | 43.0 | [1.57116,1.21649,2.37775] | [2.98926,0.816337,-0.00161709] | 4 | + | 3132 | 1170852 | 0.0 | 0.0 | 0.0 | 1.6 | 34.0 | 7235.3 | 1.0 | 1826.4 | 14.7 | 762.0 | bank17 | 164.0 | 221.0 | [3.4229,1.70246,5.39532] | [6.0734,2.6008,0.271523] | 5 | + | 3132 | 1156497 | 0.0 | 0.0 | 0.0 | 2.1 | 18.9 | 9718.2 | 1.3 | 5137.6 | 13.4 | 518.0 | bank17 | 145.0 | 165.0 | [2.49117,1.46093,3.88649] | [4.5291,1.70753,0.129446] | 6 | + | 3132 | 1207828 | 0.0 | 0.0 | 0.0 | 1.7 | 27.9 | 7989.1 | 1.3 | 3233.6 | 12.7 | 1024.0 | bank18 | 20.0 | 110.0 | [2.80538,2.29342,3.08833] | [4.71342,0.553533,0.380727] | 7 | + | 3132 | 1218593 | 0.0 | 0.0 | 0.0 | 1.0 | 79.6 | 4729.3 | 0.8 | 3018.1 | 35.4 | 756.0 | bank18 | 33.0 | 152.0 | [4.96533,3.60693,5.32436] | [7.98578,1.19927,0.895763] | 8 | + | 3132 | 1232694 | 0.0 | 0.0 | 0.0 | 1.2 | 53.4 | 5772.9 | 0.9 | 3464.5 | 25.9 | 631.0 | bank18 | 54.0 | 207.0 | [4.29539,2.63813,4.45945] | [6.53086,1.27477,1.00974] | 9 | + | 3132 | 1200023 | 0.0 | 0.0 | 0.0 | 0.7 | 159.1 | 3345.1 | 0.6 | 3796.1 | 71.1 | 509.0 | bank18 | 151.0 | 79.0 | [6.75629,4.8092,5.93224] | [10.0166,0.773518,1.74245] | 10 | .. categories:: diff --git a/docs/source/algorithms/IntegratePeaksMDHKL-v1.rst b/docs/source/algorithms/IntegratePeaksMDHKL-v1.rst index af9d3208f2e54f5022ba86cf61473130b0210735..fecbb7bbb719d16e2d4216ab3916038101396bb5 100644 --- a/docs/source/algorithms/IntegratePeaksMDHKL-v1.rst +++ b/docs/source/algorithms/IntegratePeaksMDHKL-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IntegratePeaksUsingClusters-v1.rst b/docs/source/algorithms/IntegratePeaksUsingClusters-v1.rst index a57d879043f2b69bf2df86e768dfe0112da0a8cf..ed9b40a93dfab992a86676389c6d29bf01bbdff0 100644 --- a/docs/source/algorithms/IntegratePeaksUsingClusters-v1.rst +++ b/docs/source/algorithms/IntegratePeaksUsingClusters-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Integration-v1.rst b/docs/source/algorithms/Integration-v1.rst index 5a98e9bc9d2ad84ce6bb324203ecedfc0ebadba7..254e64df5340ff2b091cbedea9644c905a29c3b2 100644 --- a/docs/source/algorithms/Integration-v1.rst +++ b/docs/source/algorithms/Integration-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/InterpolatingRebin-v1.rst b/docs/source/algorithms/InterpolatingRebin-v1.rst index 6749b30292b8033bd4e5faee80b62f16731f308b..41e9ec068aef6f11fa249d6a626ef1eb984f955a 100644 --- a/docs/source/algorithms/InterpolatingRebin-v1.rst +++ b/docs/source/algorithms/InterpolatingRebin-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/InvertMDDim-v1.rst b/docs/source/algorithms/InvertMDDim-v1.rst index eeb1dc83f562cc364d722b526a881032100e5c07..e007c5c9601e78b55d3feb10c2d0b91357cda2b1 100644 --- a/docs/source/algorithms/InvertMDDim-v1.rst +++ b/docs/source/algorithms/InvertMDDim-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/InvertMask-v1.rst b/docs/source/algorithms/InvertMask-v1.rst index 15441ddfb17d42d5cb83001dd66387941cc16a7b..4f4d8ce2bdd06fc602f9643726deb9a3b5291eec 100644 --- a/docs/source/algorithms/InvertMask-v1.rst +++ b/docs/source/algorithms/InvertMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IqtFitMultiple-v1.rst b/docs/source/algorithms/IqtFitMultiple-v1.rst index 8f13a394d0da598edb33ea2465700c347b7ecf50..6bbba0c5f27ff1c8446bb75ce5156d7664b1d3ed 100644 --- a/docs/source/algorithms/IqtFitMultiple-v1.rst +++ b/docs/source/algorithms/IqtFitMultiple-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/IqtFitSequential-v1.rst b/docs/source/algorithms/IqtFitSequential-v1.rst index 437d53abcade0041e4f629473999788cdaf6a206..6c62230170af024a48ab16f8f35e80b56d6f88c6 100644 --- a/docs/source/algorithms/IqtFitSequential-v1.rst +++ b/docs/source/algorithms/IqtFitSequential-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRAutoReduction-v1.rst b/docs/source/algorithms/LRAutoReduction-v1.rst index 0ec12ae2ef3f6bb7bb31c32e48357a651e9f3ef1..7f8726567c2a45d9c0d22cb4e96bc1377b7fba56 100644 --- a/docs/source/algorithms/LRAutoReduction-v1.rst +++ b/docs/source/algorithms/LRAutoReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRDirectBeamSort-v1.rst b/docs/source/algorithms/LRDirectBeamSort-v1.rst index 1fa9d3863959e77d94a321add929fd29f35dbb81..4b93e8c847fe1d7a82c2d85911687443979496bf 100644 --- a/docs/source/algorithms/LRDirectBeamSort-v1.rst +++ b/docs/source/algorithms/LRDirectBeamSort-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRPeakSelection-v1.rst b/docs/source/algorithms/LRPeakSelection-v1.rst index c295738b6f502dd6fa58f24de7417a44b428dbdf..ec3e442da68859ee7cca61fa9b0535dbcafcc5cd 100644 --- a/docs/source/algorithms/LRPeakSelection-v1.rst +++ b/docs/source/algorithms/LRPeakSelection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRPrimaryFraction-v1.rst b/docs/source/algorithms/LRPrimaryFraction-v1.rst index a3e47703b88593bd43a69d87d6ac5fbe4844d714..793948ac21b98faf9995606bb0eb2208994312b2 100644 --- a/docs/source/algorithms/LRPrimaryFraction-v1.rst +++ b/docs/source/algorithms/LRPrimaryFraction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRReflectivityOutput-v1.rst b/docs/source/algorithms/LRReflectivityOutput-v1.rst index dd826d0041a663301f254b4b339fe993016c6f98..ace259c22d1eb0a28aafbdcd419cf6c2892dcb51 100644 --- a/docs/source/algorithms/LRReflectivityOutput-v1.rst +++ b/docs/source/algorithms/LRReflectivityOutput-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRScalingFactors-v1.rst b/docs/source/algorithms/LRScalingFactors-v1.rst index cb585ea707839ab5d06a79ba982e9a57c82e72a3..7b7f19534b2cbb9363d7155d1d8b220d37dc18f4 100644 --- a/docs/source/algorithms/LRScalingFactors-v1.rst +++ b/docs/source/algorithms/LRScalingFactors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LRSubtractAverageBackground-v1.rst b/docs/source/algorithms/LRSubtractAverageBackground-v1.rst index 920fb7fb011eab48506b2b7c804015edbfea27ab..dc380f3d0abace9c48bc6fd17861063c5e3c6a2e 100644 --- a/docs/source/algorithms/LRSubtractAverageBackground-v1.rst +++ b/docs/source/algorithms/LRSubtractAverageBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LeBailFit-v1.rst b/docs/source/algorithms/LeBailFit-v1.rst index f99d6824839303df92fad52ea081cb9e9ffb6f9a..3cdafc2c9414113a285dc76b6e1e8566fb6074fa 100644 --- a/docs/source/algorithms/LeBailFit-v1.rst +++ b/docs/source/algorithms/LeBailFit-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LessThanMD-v1.rst b/docs/source/algorithms/LessThanMD-v1.rst index 380bfbe88460262f45768b8b6d6abcb3e71826f4..d23afd077e2b25efece34b3f8fe70bf3e7812d6b 100644 --- a/docs/source/algorithms/LessThanMD-v1.rst +++ b/docs/source/algorithms/LessThanMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LineProfile-v1.rst b/docs/source/algorithms/LineProfile-v1.rst index 7e6b73a9aca1ad2ccff13147ba3c6b6b319feb92..001d49a0dba6449aaa75ec66a294d533aec72d75 100644 --- a/docs/source/algorithms/LineProfile-v1.rst +++ b/docs/source/algorithms/LineProfile-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LiquidsReflectometryReduction-v1.rst b/docs/source/algorithms/LiquidsReflectometryReduction-v1.rst index 16639389fddf38c2aeb8814b4f02ba2934cfeba8..ffe35a7ac0d4046e27175213c5868f4672da1004 100644 --- a/docs/source/algorithms/LiquidsReflectometryReduction-v1.rst +++ b/docs/source/algorithms/LiquidsReflectometryReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Load-v1.rst b/docs/source/algorithms/Load-v1.rst index 02ca814359891da88cf0cfa6ab549c8a83671d64..6dc2e87c125d99b908a2b7d4b9c2c63ec92dd057 100644 --- a/docs/source/algorithms/Load-v1.rst +++ b/docs/source/algorithms/Load-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadAndMerge-v1.rst b/docs/source/algorithms/LoadAndMerge-v1.rst index 04ca1ab664c1fe6b17658adcfde51f84d4739cf5..bbc42f59fdd0a3d46db8295b7b3eff4be4cb9ee1 100644 --- a/docs/source/algorithms/LoadAndMerge-v1.rst +++ b/docs/source/algorithms/LoadAndMerge-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadAscii-v1.rst b/docs/source/algorithms/LoadAscii-v1.rst index 9b7b2851204595b87be161be12e67181076caec1..46fe9904a6dd075b0e52dade0e07b1de1c10fe3e 100644 --- a/docs/source/algorithms/LoadAscii-v1.rst +++ b/docs/source/algorithms/LoadAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadAscii-v2.rst b/docs/source/algorithms/LoadAscii-v2.rst index 7060d3037ee685d90e7ea1bee8d866eac8ffe85f..7420d024b0730e3b85b8321ef7a3354be5168c83 100644 --- a/docs/source/algorithms/LoadAscii-v2.rst +++ b/docs/source/algorithms/LoadAscii-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadBBY-v1.rst b/docs/source/algorithms/LoadBBY-v1.rst index 09d00219fd584d34075b6446fec96d185d76f8a0..7774d651ad4524ba5611bf33065f0feb2b52d0fe 100644 --- a/docs/source/algorithms/LoadBBY-v1.rst +++ b/docs/source/algorithms/LoadBBY-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadCIF-v1.rst b/docs/source/algorithms/LoadCIF-v1.rst index b92996f733fa468f0e077df1a9606bbcc7cede3b..7dd4c61516cda4b186ab36857131343e9e60858a 100644 --- a/docs/source/algorithms/LoadCIF-v1.rst +++ b/docs/source/algorithms/LoadCIF-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadCalFile-v1.rst b/docs/source/algorithms/LoadCalFile-v1.rst index 66e8c0a0fad29d143fe48114afff5ba62cec1167..d96a583b525319f3b1c25067dcc13cc3edf58961 100644 --- a/docs/source/algorithms/LoadCalFile-v1.rst +++ b/docs/source/algorithms/LoadCalFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadCanSAS1D-v1.rst b/docs/source/algorithms/LoadCanSAS1D-v1.rst index 67c40d640db338f87a223f57ffd4bab200b581f1..827e5ec4d7b919900764fb2a7ae9dbe2609152e2 100644 --- a/docs/source/algorithms/LoadCanSAS1D-v1.rst +++ b/docs/source/algorithms/LoadCanSAS1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadCanSAS1D-v2.rst b/docs/source/algorithms/LoadCanSAS1D-v2.rst index 70e703c0341f1da497db8359bebed3d484083ebd..94946cae452207dd0816d6b3ad698d8be7ff10c0 100644 --- a/docs/source/algorithms/LoadCanSAS1D-v2.rst +++ b/docs/source/algorithms/LoadCanSAS1D-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDNSLegacy-v1.rst b/docs/source/algorithms/LoadDNSLegacy-v1.rst index 4d55aa05bff60a1f7597cf004d8b957efd5b2d80..96aa684c7829712fde4674216648c00f20e1b251 100644 --- a/docs/source/algorithms/LoadDNSLegacy-v1.rst +++ b/docs/source/algorithms/LoadDNSLegacy-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDaveGrp-v1.rst b/docs/source/algorithms/LoadDaveGrp-v1.rst index 355da06a843b22dff39958e513742c74f15634d7..bb13d04d66c49e6112033b9f3c3d3e80d75c1274 100644 --- a/docs/source/algorithms/LoadDaveGrp-v1.rst +++ b/docs/source/algorithms/LoadDaveGrp-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDetectorInfo-v1.rst b/docs/source/algorithms/LoadDetectorInfo-v1.rst index 7a3545e0dbc3692d839cd81f8fd1301b50b39d0e..7fff57ebb66989bc47fdd0d1dcf8dc22717c39b3 100644 --- a/docs/source/algorithms/LoadDetectorInfo-v1.rst +++ b/docs/source/algorithms/LoadDetectorInfo-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDetectorsGroupingFile-v1.rst b/docs/source/algorithms/LoadDetectorsGroupingFile-v1.rst index 8481ea8e301a8bd25d541ecc25cd6d0d8c1360a2..d318557d986556b9c0301112af84ce4a4b519179 100644 --- a/docs/source/algorithms/LoadDetectorsGroupingFile-v1.rst +++ b/docs/source/algorithms/LoadDetectorsGroupingFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDiffCal-v1.rst b/docs/source/algorithms/LoadDiffCal-v1.rst index b2fc5741c14f477db64a9448b854942d964f2c0f..b83edb746f3c50eabb14214c02a9cefb89d9382e 100644 --- a/docs/source/algorithms/LoadDiffCal-v1.rst +++ b/docs/source/algorithms/LoadDiffCal-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadDspacemap-v1.rst b/docs/source/algorithms/LoadDspacemap-v1.rst index e92564e49306d7c18ce070a75b8c46419a5dcd8d..e00b75625777b19dad573c985a8bed21e1021ae9 100644 --- a/docs/source/algorithms/LoadDspacemap-v1.rst +++ b/docs/source/algorithms/LoadDspacemap-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEXED-v1.rst b/docs/source/algorithms/LoadEXED-v1.rst index 4682fdb07fff285b061d7fc8e20f3c4ad4fa45c9..3aa844d1bb85a8dbb07a4d9197cd3e81454e9455 100644 --- a/docs/source/algorithms/LoadEXED-v1.rst +++ b/docs/source/algorithms/LoadEXED-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEmptyInstrument-v1.rst b/docs/source/algorithms/LoadEmptyInstrument-v1.rst index 16d294756665094af1b521aa5c898372dbf25dd4..7044a542d27cb1dcadd1cb104aa9a92e8bc0b960 100644 --- a/docs/source/algorithms/LoadEmptyInstrument-v1.rst +++ b/docs/source/algorithms/LoadEmptyInstrument-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEmptyVesuvio-v1.rst b/docs/source/algorithms/LoadEmptyVesuvio-v1.rst index 4b8909997c656e4f6edb6d2b687cda35d1792e4d..795ddea4ad7f57b309f4393d983532f1fd11d22f 100644 --- a/docs/source/algorithms/LoadEmptyVesuvio-v1.rst +++ b/docs/source/algorithms/LoadEmptyVesuvio-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEventAndCompress-v1.rst b/docs/source/algorithms/LoadEventAndCompress-v1.rst index 7af29968e94db749312f7569e3f4fd1e49982942..12e7da3307134294f2c7905128c0842d30a3767f 100644 --- a/docs/source/algorithms/LoadEventAndCompress-v1.rst +++ b/docs/source/algorithms/LoadEventAndCompress-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEventNexus-v1.rst b/docs/source/algorithms/LoadEventNexus-v1.rst index 06ac964a6a818309ed40b669963214946d75cc88..1fdbd426fdc52c80b0da7d18888d7a8b958cbe4c 100644 --- a/docs/source/algorithms/LoadEventNexus-v1.rst +++ b/docs/source/algorithms/LoadEventNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadEventPreNexus-v2.rst b/docs/source/algorithms/LoadEventPreNexus-v2.rst index 9a27afe7943ba7331e02fe686873fda4db32e287..9cbbe010eff450594adc0cecd15a1348543dd1b6 100644 --- a/docs/source/algorithms/LoadEventPreNexus-v2.rst +++ b/docs/source/algorithms/LoadEventPreNexus-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadFITS-v1.rst b/docs/source/algorithms/LoadFITS-v1.rst index fc1b672d2f38c163dcf33fe41a9a8bad84725117..fbd48295ac5629612eb315ada358532e86da05ab 100644 --- a/docs/source/algorithms/LoadFITS-v1.rst +++ b/docs/source/algorithms/LoadFITS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadFlexiNexus-v1.rst b/docs/source/algorithms/LoadFlexiNexus-v1.rst index 4dede92da8dc8fb4c687f0d5cbf9e7d82251e76a..061164de428831e118e6c3c40248e875c9b78f64 100644 --- a/docs/source/algorithms/LoadFlexiNexus-v1.rst +++ b/docs/source/algorithms/LoadFlexiNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadFullprofFile-v1.rst b/docs/source/algorithms/LoadFullprofFile-v1.rst index a3954d7bb30a1c66a783d819a7bceed0d10e4d78..1bd0a740c3078bc549c9a87b8af819b00638b14e 100644 --- a/docs/source/algorithms/LoadFullprofFile-v1.rst +++ b/docs/source/algorithms/LoadFullprofFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadFullprofResolution-v1.rst b/docs/source/algorithms/LoadFullprofResolution-v1.rst index 36fbfebb1853808425f5859f02e208ede61d5170..53081fe10c8362fa2074181b0bb3eb7cc41efbc7 100644 --- a/docs/source/algorithms/LoadFullprofResolution-v1.rst +++ b/docs/source/algorithms/LoadFullprofResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadGSASInstrumentFile-v1.rst b/docs/source/algorithms/LoadGSASInstrumentFile-v1.rst index 6d26c479f30c8664791c93c56d44fd37c80496e5..c42932baaeb0e165d5247594d8173032d7fcf782 100644 --- a/docs/source/algorithms/LoadGSASInstrumentFile-v1.rst +++ b/docs/source/algorithms/LoadGSASInstrumentFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadGSS-v1.rst b/docs/source/algorithms/LoadGSS-v1.rst index 9b2162be7288a664bb0b528c3c2639e08df6226c..025cc510df9b9e3cab741ac3475add2873f1dbb5 100644 --- a/docs/source/algorithms/LoadGSS-v1.rst +++ b/docs/source/algorithms/LoadGSS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadHKL-v1.rst b/docs/source/algorithms/LoadHKL-v1.rst index e772121e42ef831f577b8fe3d1330c38838da71d..6222531baef2c1a9d2b811a0d35fc6a28fb930f6 100644 --- a/docs/source/algorithms/LoadHKL-v1.rst +++ b/docs/source/algorithms/LoadHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -12,7 +12,7 @@ Description Loads an ASCII .hkl file to a PeaksWorkspace. HKL File Format -*************** +############### File has same format that works successfully in GSAS and SHELX from ISAW: diff --git a/docs/source/algorithms/LoadIDFFromNexus-v1.rst b/docs/source/algorithms/LoadIDFFromNexus-v1.rst index 09fdf94e69b07be1128a2e8ba76fd97d3509ee8a..b707b491405544426fb57c46772b698bdafc47c8 100644 --- a/docs/source/algorithms/LoadIDFFromNexus-v1.rst +++ b/docs/source/algorithms/LoadIDFFromNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLDiffraction-v1.rst b/docs/source/algorithms/LoadILLDiffraction-v1.rst index 95c3221834d56955edf989dd43e1b4144201c138..eae3c9c3926e2adaf2897c8d9564e0bd817739ae 100644 --- a/docs/source/algorithms/LoadILLDiffraction-v1.rst +++ b/docs/source/algorithms/LoadILLDiffraction-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLIndirect-v2.rst b/docs/source/algorithms/LoadILLIndirect-v2.rst index 9b4b44df190e152de1991ff7619e31ba9c133fcb..43721433616b205ff47b536ddabcba6b3eb52c2c 100644 --- a/docs/source/algorithms/LoadILLIndirect-v2.rst +++ b/docs/source/algorithms/LoadILLIndirect-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLPolarizationFactors-v1.rst b/docs/source/algorithms/LoadILLPolarizationFactors-v1.rst index 02ff134d610ba9e88567f09018f6c3ed0e51ea4c..60cfcc5cf33ef137cc639d363261b1ee0feeeaa6 100644 --- a/docs/source/algorithms/LoadILLPolarizationFactors-v1.rst +++ b/docs/source/algorithms/LoadILLPolarizationFactors-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLReflectometry-v1.rst b/docs/source/algorithms/LoadILLReflectometry-v1.rst index f3cf3ad31e7e992487ed7025d53357164b7204d7..c43ab4f05bad7bde0ec577739f6a3942cd24b005 100644 --- a/docs/source/algorithms/LoadILLReflectometry-v1.rst +++ b/docs/source/algorithms/LoadILLReflectometry-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLSANS-v1.rst b/docs/source/algorithms/LoadILLSANS-v1.rst index c0accafcb7fa7cb8de2799bf68ff36679f085f02..2e51a0ba86041c5c1e30130b975b62377398d1fe 100644 --- a/docs/source/algorithms/LoadILLSANS-v1.rst +++ b/docs/source/algorithms/LoadILLSANS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadILLTOF-v2.rst b/docs/source/algorithms/LoadILLTOF-v2.rst index 6cac270c17417b2c09d1e5247e8d312a1c133171..fb36d146be60859c09fa5c1700b62f48a56f4fdb 100644 --- a/docs/source/algorithms/LoadILLTOF-v2.rst +++ b/docs/source/algorithms/LoadILLTOF-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadISISNexus-v2.rst b/docs/source/algorithms/LoadISISNexus-v2.rst index 92d8cbe22f7651c15394ab25b85512fc50c4bc1a..051bafc40f6fb71f649166eb737e9124199b0549 100644 --- a/docs/source/algorithms/LoadISISNexus-v2.rst +++ b/docs/source/algorithms/LoadISISNexus-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadInstrument-v1.rst b/docs/source/algorithms/LoadInstrument-v1.rst index 9bb17050731bffe22d3823c82e5c9024e3575b4b..742ede74498275023f8e003273898033fa8aac3e 100644 --- a/docs/source/algorithms/LoadInstrument-v1.rst +++ b/docs/source/algorithms/LoadInstrument-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadInstrumentFromNexus-v1.rst b/docs/source/algorithms/LoadInstrumentFromNexus-v1.rst index c7d47ac3c0dfad7a7fc63af18f044e41c373329c..d41423e0f7dbffef4e9e4201d4129d0750648b24 100644 --- a/docs/source/algorithms/LoadInstrumentFromNexus-v1.rst +++ b/docs/source/algorithms/LoadInstrumentFromNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadInstrumentFromRaw-v1.rst b/docs/source/algorithms/LoadInstrumentFromRaw-v1.rst index 8468aa33fd589d28daaec47a12c6dcc1bbddc35f..10277281419d3e77d88e045a192e0217021063bc 100644 --- a/docs/source/algorithms/LoadInstrumentFromRaw-v1.rst +++ b/docs/source/algorithms/LoadInstrumentFromRaw-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadIsawDetCal-v1.rst b/docs/source/algorithms/LoadIsawDetCal-v1.rst index 39dc33620d67e532766bb20401c05af859199c7f..65adcc7bab0a3d41975c817824003a5745f25617 100644 --- a/docs/source/algorithms/LoadIsawDetCal-v1.rst +++ b/docs/source/algorithms/LoadIsawDetCal-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadIsawPeaks-v1.rst b/docs/source/algorithms/LoadIsawPeaks-v1.rst index 8a27cedbe85a0aa9257a6b05d58e1670467c1992..754710cc55813662ec70c9812ec83bcaafc2d5a4 100644 --- a/docs/source/algorithms/LoadIsawPeaks-v1.rst +++ b/docs/source/algorithms/LoadIsawPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadIsawSpectrum-v1.rst b/docs/source/algorithms/LoadIsawSpectrum-v1.rst index aa2b05caee8d5307bff2fc9701e262512aee2a0e..a5fb42498577004698042e635f7a1efb7f209c7f 100644 --- a/docs/source/algorithms/LoadIsawSpectrum-v1.rst +++ b/docs/source/algorithms/LoadIsawSpectrum-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadIsawUB-v1.rst b/docs/source/algorithms/LoadIsawUB-v1.rst index d0565e842f035db0ec880a8900c04fc2f3c590a1..1112f519484bebccb2868fd1a2719398760090eb 100644 --- a/docs/source/algorithms/LoadIsawUB-v1.rst +++ b/docs/source/algorithms/LoadIsawUB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadLLB-v1.rst b/docs/source/algorithms/LoadLLB-v1.rst index 7fb60a344b96d74bc585631d9eae6779460b1d68..6bf029c5a06fd62487bee05f8bc73245e06430c0 100644 --- a/docs/source/algorithms/LoadLLB-v1.rst +++ b/docs/source/algorithms/LoadLLB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadLamp-v1.rst b/docs/source/algorithms/LoadLamp-v1.rst index d551753ff7acd498ed992429bdfa945d016d0afc..ebcef6ad50a2b0d063f231d3ece4d63f05fb2f07 100644 --- a/docs/source/algorithms/LoadLamp-v1.rst +++ b/docs/source/algorithms/LoadLamp-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadLiveData-v1.rst b/docs/source/algorithms/LoadLiveData-v1.rst index 2f0be8557dd26e817cda3fe00cd38dfe2d473912..a8224c0e971bd8fd3be3efefff12f1d70e29b88e 100644 --- a/docs/source/algorithms/LoadLiveData-v1.rst +++ b/docs/source/algorithms/LoadLiveData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadLog-v1.rst b/docs/source/algorithms/LoadLog-v1.rst index 79315d77c3eb6517e3f4a67bb0b9fa209f35585d..9dd0160c66b2d40150611781cdd6687c45801d13 100644 --- a/docs/source/algorithms/LoadLog-v1.rst +++ b/docs/source/algorithms/LoadLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadLogPropertyTable-v1.rst b/docs/source/algorithms/LoadLogPropertyTable-v1.rst index 11c227f673f9c4b77ff35d149fe79c646a7a1779..f34dde7c6825fd6aba017333a143b24b8c8bafcb 100644 --- a/docs/source/algorithms/LoadLogPropertyTable-v1.rst +++ b/docs/source/algorithms/LoadLogPropertyTable-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMD-v1.rst b/docs/source/algorithms/LoadMD-v1.rst index add4525edef8561436c64d27e127cd32af6ef1e6..377dd78987e872706cf0902081af6d6f2df98cbd 100644 --- a/docs/source/algorithms/LoadMD-v1.rst +++ b/docs/source/algorithms/LoadMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMLZ-v1.rst b/docs/source/algorithms/LoadMLZ-v1.rst index fcbb25c2efcf5ba4317a293a98555b0d2ccdfc9e..8efb00dbc4965ab958380542cbc0c06465459100 100644 --- a/docs/source/algorithms/LoadMLZ-v1.rst +++ b/docs/source/algorithms/LoadMLZ-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMappingTable-v1.rst b/docs/source/algorithms/LoadMappingTable-v1.rst index 694ade0b83684376795afe447911254f8dc4356d..f485e532664cb26cea628849b513f90c7b4b4cce 100644 --- a/docs/source/algorithms/LoadMappingTable-v1.rst +++ b/docs/source/algorithms/LoadMappingTable-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMask-v1.rst b/docs/source/algorithms/LoadMask-v1.rst index 223fcea04d39d5eedc140a1ffab1cc96a1680b56..572b110ace935d58f20eddc01a99acc5cfabbad6 100644 --- a/docs/source/algorithms/LoadMask-v1.rst +++ b/docs/source/algorithms/LoadMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMcStas-v1.rst b/docs/source/algorithms/LoadMcStas-v1.rst index b042f4d774288dba5ef71bd809c769b6d89506ae..3039803b2e52d6f50755e57f2a06055225fd4e83 100644 --- a/docs/source/algorithms/LoadMcStas-v1.rst +++ b/docs/source/algorithms/LoadMcStas-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMcStasNexus-v1.rst b/docs/source/algorithms/LoadMcStasNexus-v1.rst index 230d0405dbb00b6d96de72c484c0aa061ec68332..02422e3aa859489f523927b9e5968985a7b204b2 100644 --- a/docs/source/algorithms/LoadMcStasNexus-v1.rst +++ b/docs/source/algorithms/LoadMcStasNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMultipleGSS-v1.rst b/docs/source/algorithms/LoadMultipleGSS-v1.rst index 7aab060dd3dba7da955429ccface9c08c2aaebdb..4e3caa68595bd4daa472eec2639d8dddac292904 100644 --- a/docs/source/algorithms/LoadMultipleGSS-v1.rst +++ b/docs/source/algorithms/LoadMultipleGSS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMuonLog-v1.rst b/docs/source/algorithms/LoadMuonLog-v1.rst index e089716be96ffee53040448a177733541157da79..b9116c5c531aa0d6846cb9813222df03af3201d3 100644 --- a/docs/source/algorithms/LoadMuonLog-v1.rst +++ b/docs/source/algorithms/LoadMuonLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMuonNexus-v1.rst b/docs/source/algorithms/LoadMuonNexus-v1.rst index a798064a45b7b0e4d99320c925c7b47f8a3c10ab..489c79d9e7227ed572ece03e34ab94d22028fea6 100644 --- a/docs/source/algorithms/LoadMuonNexus-v1.rst +++ b/docs/source/algorithms/LoadMuonNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadMuonNexus-v2.rst b/docs/source/algorithms/LoadMuonNexus-v2.rst index a36ba6e4689a095cc188658eb058fb731396bce5..81fbbc40660a93f4d082691190b7d4849b9f2a50 100644 --- a/docs/source/algorithms/LoadMuonNexus-v2.rst +++ b/docs/source/algorithms/LoadMuonNexus-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNMoldyn3Ascii-v1.rst b/docs/source/algorithms/LoadNMoldyn3Ascii-v1.rst index 8d06bedd116cf74939206059b3e3517497eb5657..588dbb4aedd0aca309e72b6accfedb5d1ffbf134 100644 --- a/docs/source/algorithms/LoadNMoldyn3Ascii-v1.rst +++ b/docs/source/algorithms/LoadNMoldyn3Ascii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNMoldyn4Ascii-v1.rst b/docs/source/algorithms/LoadNMoldyn4Ascii-v1.rst index 72179b710986f3f4db9baace501499f93733ecf7..3c7b6c43857e3dfdc80e2c42ef3cc3e5356d232d 100644 --- a/docs/source/algorithms/LoadNMoldyn4Ascii-v1.rst +++ b/docs/source/algorithms/LoadNMoldyn4Ascii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNMoldyn4Ascii1D-v1.rst b/docs/source/algorithms/LoadNMoldyn4Ascii1D-v1.rst index 033966b156f5afd856c0c3829a500b2f01b9f59c..619825c4b5fe3bb8c6aef229d065d73422f97135 100644 --- a/docs/source/algorithms/LoadNMoldyn4Ascii1D-v1.rst +++ b/docs/source/algorithms/LoadNMoldyn4Ascii1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNXSPE-v1.rst b/docs/source/algorithms/LoadNXSPE-v1.rst index 97930210ae72d5261b839d527c36ccc73adebe1a..3837d2d616c03742ee53ef5e6eb042c1a7a0e32e 100644 --- a/docs/source/algorithms/LoadNXSPE-v1.rst +++ b/docs/source/algorithms/LoadNXSPE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNXcanSAS-v1.rst b/docs/source/algorithms/LoadNXcanSAS-v1.rst index 8da99f48766344a65dba8f38608f5f75f83770a7..b0264acbbc72cded736b6df93a42539cd8f63556 100644 --- a/docs/source/algorithms/LoadNXcanSAS-v1.rst +++ b/docs/source/algorithms/LoadNXcanSAS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNexus-v1.rst b/docs/source/algorithms/LoadNexus-v1.rst index 5ab2681bb8c65331654d6a3d28a718cc3a151de3..3a943ba388b9d22d25ab8820c5a8a60f0f2b8f7a 100644 --- a/docs/source/algorithms/LoadNexus-v1.rst +++ b/docs/source/algorithms/LoadNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNexusLogs-v1.rst b/docs/source/algorithms/LoadNexusLogs-v1.rst index fd20fc6c67360449fa595f7da27ab8d18cc681bf..b04d523dd59b99555f00d16aff5f1c6eb686bf92 100644 --- a/docs/source/algorithms/LoadNexusLogs-v1.rst +++ b/docs/source/algorithms/LoadNexusLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNexusMonitors-v1.rst b/docs/source/algorithms/LoadNexusMonitors-v1.rst index 8e8a3f6dfa259103c2e7516ede37a0e2a6c45bed..1108b568428a219d137b7c113e8c48a777d50336 100644 --- a/docs/source/algorithms/LoadNexusMonitors-v1.rst +++ b/docs/source/algorithms/LoadNexusMonitors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadNexusMonitors-v2.rst b/docs/source/algorithms/LoadNexusMonitors-v2.rst index 9a6fda08a2f8e8c5dd5d487a349f14f59217d8b3..d115c204cc94e705f047b4f61b08147643d5ef2a 100644 --- a/docs/source/algorithms/LoadNexusMonitors-v2.rst +++ b/docs/source/algorithms/LoadNexusMonitors-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -24,7 +24,7 @@ workspace. As a side-effect of the fix, the contained individual workspaces for each of the periods are named slightly differently. Event monitor and histogram monitor -=================================== +################################### There are two types of monitors, event monitors and histograms monitors. Both of them are of class *NXmonitor* in NeXus file. @@ -39,14 +39,14 @@ Both of them are of class *NXmonitor* in NeXus file. * period_index ISIS event monitor -================== +################## ISIS monitor of event mode may contain entry *data*. In this case, the monitor of event mode can be loaded in histogram mode. Load NeXus file containing both event monitor and histogram monitor -=================================================================== +################################################################### There are a few use cases to load monitor's data if the NeXus file has coexisting event monitors and histogram monitors. diff --git a/docs/source/algorithms/LoadNexusProcessed-v1.rst b/docs/source/algorithms/LoadNexusProcessed-v1.rst index d807be0ba03ed7892201de228c000218dd96036f..4ee1808037b1917e7cc2caef3821765d6dd1ae00 100644 --- a/docs/source/algorithms/LoadNexusProcessed-v1.rst +++ b/docs/source/algorithms/LoadNexusProcessed-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadPDFgetNFile-v1.rst b/docs/source/algorithms/LoadPDFgetNFile-v1.rst index fa232ab4999bab2023aa4f9ee5b6faed2e2d2db2..227fe09f03debc98c66c5d356e753b55160b024e 100644 --- a/docs/source/algorithms/LoadPDFgetNFile-v1.rst +++ b/docs/source/algorithms/LoadPDFgetNFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadParameterFile-v1.rst b/docs/source/algorithms/LoadParameterFile-v1.rst index fda8e1da56297b9ac58ec2b82dcbd8f2d4ad2c29..17836f3b9ca98828829cf2e5c8f5251345be4c56 100644 --- a/docs/source/algorithms/LoadParameterFile-v1.rst +++ b/docs/source/algorithms/LoadParameterFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadPreNexus-v1.rst b/docs/source/algorithms/LoadPreNexus-v1.rst index b78e915c4ee570ec048ea63a4e0a2264cd143d34..23c4a16fe12cf396ca204f930d70aecfbc82371d 100644 --- a/docs/source/algorithms/LoadPreNexus-v1.rst +++ b/docs/source/algorithms/LoadPreNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadPreNexusLive-v1.rst b/docs/source/algorithms/LoadPreNexusLive-v1.rst index 674c3b5a99d9ea0fefa350fb1cefb4904d4eaa7d..5e5ee7183892142183a78b72d5125b8c69fabdb5 100644 --- a/docs/source/algorithms/LoadPreNexusLive-v1.rst +++ b/docs/source/algorithms/LoadPreNexusLive-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadPreNexusMonitors-v1.rst b/docs/source/algorithms/LoadPreNexusMonitors-v1.rst index 4f45a04ca08fb7602824e37b7c0c3c8f18d78632..80292f10472c16cc2316c2900381a5fdd50276d4 100644 --- a/docs/source/algorithms/LoadPreNexusMonitors-v1.rst +++ b/docs/source/algorithms/LoadPreNexusMonitors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadQKK-v1.rst b/docs/source/algorithms/LoadQKK-v1.rst index 92721016f794a8c96550dfbbab70137c22fc3dcf..9942142869c3c96757a0cfaeedcd11367a2170ba 100644 --- a/docs/source/algorithms/LoadQKK-v1.rst +++ b/docs/source/algorithms/LoadQKK-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadRKH-v1.rst b/docs/source/algorithms/LoadRKH-v1.rst index 08d8e4c84aeff3b2965044686cbefbf823d575cf..ad8cbce7608f37c52e4791f641c74989750fb8a4 100644 --- a/docs/source/algorithms/LoadRKH-v1.rst +++ b/docs/source/algorithms/LoadRKH-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadRaw-v3.rst b/docs/source/algorithms/LoadRaw-v3.rst index 4a67346b1de281decacb0786fc5ed0f551872be6..7ccd96f0ad8d505f3b17aadee5889e1f6bc59c80 100644 --- a/docs/source/algorithms/LoadRaw-v3.rst +++ b/docs/source/algorithms/LoadRaw-v3.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadRawBin0-v1.rst b/docs/source/algorithms/LoadRawBin0-v1.rst index ac383e40ef00c66c35b8823e828f89a16dfad398..277cfb7f18be6b135978260cce2a8a6f99552260 100644 --- a/docs/source/algorithms/LoadRawBin0-v1.rst +++ b/docs/source/algorithms/LoadRawBin0-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadRawSpectrum0-v1.rst b/docs/source/algorithms/LoadRawSpectrum0-v1.rst index 93003f14ec466cb65b08e21e83bcf88578677809..6ec923a6a9208822a26684cbfca420319dde819e 100644 --- a/docs/source/algorithms/LoadRawSpectrum0-v1.rst +++ b/docs/source/algorithms/LoadRawSpectrum0-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSESANS-v1.rst b/docs/source/algorithms/LoadSESANS-v1.rst index eb1ca8b16b0d595cb68cf676ce1680efb65c63a5..6d6126ae6029ab4afbb949786b845d2f6d6fe55c 100644 --- a/docs/source/algorithms/LoadSESANS-v1.rst +++ b/docs/source/algorithms/LoadSESANS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSINQ-v1.rst b/docs/source/algorithms/LoadSINQ-v1.rst index 87fbda9bf56c58e87b599f04210077a0f7efb957..9fb18dd5a80d6b08d2e7954733d385dc262e17bf 100644 --- a/docs/source/algorithms/LoadSINQ-v1.rst +++ b/docs/source/algorithms/LoadSINQ-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSINQFile-v1.rst b/docs/source/algorithms/LoadSINQFile-v1.rst index 44fce4dd38fbdacdcfb7f0fac8b2823cc4c07e1e..773de1cbf46bf1de95d03da056a93ca72c3cea4c 100644 --- a/docs/source/algorithms/LoadSINQFile-v1.rst +++ b/docs/source/algorithms/LoadSINQFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSINQFocus-v1.rst b/docs/source/algorithms/LoadSINQFocus-v1.rst index c9693e0b067244a31d2accb9686b9da2b0de0884..91edd2507ee9f53d87c0eda72410892918033fd4 100644 --- a/docs/source/algorithms/LoadSINQFocus-v1.rst +++ b/docs/source/algorithms/LoadSINQFocus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSNSspec-v1.rst b/docs/source/algorithms/LoadSNSspec-v1.rst index 1f5ccfbd558a3883efbf9ad48148ea189b8094cf..0d356d3874df51cfbb56b9b4edaaa5d39a6d19de 100644 --- a/docs/source/algorithms/LoadSNSspec-v1.rst +++ b/docs/source/algorithms/LoadSNSspec-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSPE-v1.rst b/docs/source/algorithms/LoadSPE-v1.rst index cd8acb3fcbab83a6c1bb001a62ba8273797dc860..3f3a7f8595c1c8c6067caee8d831c59968e7e8ca 100644 --- a/docs/source/algorithms/LoadSPE-v1.rst +++ b/docs/source/algorithms/LoadSPE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSQW-v1.rst b/docs/source/algorithms/LoadSQW-v1.rst index 2420f3498c19dd5bb0266a521e15edffdcd112b6..c2ef22d9fcdd2cf878f02435839373f9a179a723 100644 --- a/docs/source/algorithms/LoadSQW-v1.rst +++ b/docs/source/algorithms/LoadSQW-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSQW-v2.rst b/docs/source/algorithms/LoadSQW-v2.rst index f0a40db3c265b1ac1e858550a7968703693c6add..6651f7cef591125bf4be092c8fed50068969bc6e 100644 --- a/docs/source/algorithms/LoadSQW-v2.rst +++ b/docs/source/algorithms/LoadSQW-v2.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSampleDetailsFromRaw-v1.rst b/docs/source/algorithms/LoadSampleDetailsFromRaw-v1.rst index 2b92c0b7005dbc1ab7b671e7c6e7e30d30cacf65..9f5f4aea40c4b832c8e2bc30955a680e13cfb23c 100644 --- a/docs/source/algorithms/LoadSampleDetailsFromRaw-v1.rst +++ b/docs/source/algorithms/LoadSampleDetailsFromRaw-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSassena-v1.rst b/docs/source/algorithms/LoadSassena-v1.rst index 0680ea202de148432432798afba5d5e5048cc9e5..a8978dffa8b0c5d13975ecc17d1119bd69132d4f 100644 --- a/docs/source/algorithms/LoadSassena-v1.rst +++ b/docs/source/algorithms/LoadSassena-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSpec-v1.rst b/docs/source/algorithms/LoadSpec-v1.rst index b37969d58cf7ec25653300ca8972574a4db4a0e4..d846c9b0693688878d938ace0647341d95daa01f 100644 --- a/docs/source/algorithms/LoadSpec-v1.rst +++ b/docs/source/algorithms/LoadSpec-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSpice2D-v1.rst b/docs/source/algorithms/LoadSpice2D-v1.rst index 857c87654c0c654c7be88e6ab2e5f30a16608888..d5d607ffefa86da266ad296e44a59b424aa223b7 100644 --- a/docs/source/algorithms/LoadSpice2D-v1.rst +++ b/docs/source/algorithms/LoadSpice2D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSpiceAscii-v1.rst b/docs/source/algorithms/LoadSpiceAscii-v1.rst index 93662c3b27203045c4e341728568139c4f079539..6bb9f483ea142b3685530b110d4024815b19ee97 100644 --- a/docs/source/algorithms/LoadSpiceAscii-v1.rst +++ b/docs/source/algorithms/LoadSpiceAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSpiceXML2DDet-v1.rst b/docs/source/algorithms/LoadSpiceXML2DDet-v1.rst index 05c83f510107ec310106c991f10128ae8dc6cc08..64f4f0d70bce32af7fcd4dbd86fcc0723c21f6d4 100644 --- a/docs/source/algorithms/LoadSpiceXML2DDet-v1.rst +++ b/docs/source/algorithms/LoadSpiceXML2DDet-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadSwans-v1.rst b/docs/source/algorithms/LoadSwans-v1.rst index 4f288ccee204435944d98587fdba67a6c3f96fcc..839f640e4e345ec90d8d684b05fed5e95ae8a6fa 100644 --- a/docs/source/algorithms/LoadSwans-v1.rst +++ b/docs/source/algorithms/LoadSwans-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadTBL-v1.rst b/docs/source/algorithms/LoadTBL-v1.rst index d0f355b638dfb575c882b291b10ca3ae0d247318..9951cb77d57fa9a9225c3c66aedc38ed2c524dc9 100644 --- a/docs/source/algorithms/LoadTBL-v1.rst +++ b/docs/source/algorithms/LoadTBL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadTOFRawNexus-v1.rst b/docs/source/algorithms/LoadTOFRawNexus-v1.rst index c9709cb383d334d9abccaf9e3a9b63863da29478..bc902c6f2fb2fdf43bb516607c8d1d2960e2643c 100644 --- a/docs/source/algorithms/LoadTOFRawNexus-v1.rst +++ b/docs/source/algorithms/LoadTOFRawNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVTK-v1.rst b/docs/source/algorithms/LoadVTK-v1.rst index 1ab52491815d4a7e7297e9da16e12f37c37b1d57..d047f11c134ac535cf5cbdd1e6d3408cf1071eae 100644 --- a/docs/source/algorithms/LoadVTK-v1.rst +++ b/docs/source/algorithms/LoadVTK-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVesuvio-v1.rst b/docs/source/algorithms/LoadVesuvio-v1.rst index 9adc889a649ba374b84f8c904aaee834e0774cd0..a9953c686f4087755e0b2ce811ae55038e3e9c9a 100644 --- a/docs/source/algorithms/LoadVesuvio-v1.rst +++ b/docs/source/algorithms/LoadVesuvio-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVisionElasticBS-v1.rst b/docs/source/algorithms/LoadVisionElasticBS-v1.rst index 2767b3a719dc8e57f337fb01b8a9f113d4c9c63a..0ee9821ec31cd109d9a5c0d6397e8594629dfdbe 100644 --- a/docs/source/algorithms/LoadVisionElasticBS-v1.rst +++ b/docs/source/algorithms/LoadVisionElasticBS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVisionElasticEQ-v1.rst b/docs/source/algorithms/LoadVisionElasticEQ-v1.rst index bb175164fc2167a97e8a8010e7c49a7ee2f9b2d0..f7b468e473750dce149be42d1c5953b14896cdb1 100644 --- a/docs/source/algorithms/LoadVisionElasticEQ-v1.rst +++ b/docs/source/algorithms/LoadVisionElasticEQ-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVisionInelastic-v1.rst b/docs/source/algorithms/LoadVisionInelastic-v1.rst index 30a39cdd2ce7dbacfce520fa089089cb3ad81805..0d063c9125c3cdd7a6844e201ba1442fbdae7b0e 100644 --- a/docs/source/algorithms/LoadVisionInelastic-v1.rst +++ b/docs/source/algorithms/LoadVisionInelastic-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LoadVulcanCalFile-v1.rst b/docs/source/algorithms/LoadVulcanCalFile-v1.rst index 0a10aab6597bf773a8f5be3bef663e4a0b51e0da..993e081745b9cd6a08c4b355d2c80540564c7d71 100644 --- a/docs/source/algorithms/LoadVulcanCalFile-v1.rst +++ b/docs/source/algorithms/LoadVulcanCalFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -17,7 +17,7 @@ By this algorithm, Vulcan's calibration file can be converted to the standard calibration file for SNSPowderReduction. Detector offset file -==================== +#################### There are :math:`62500` (:math:`50\times 1250`) rows in the offset file. In each row, the first value is the pixel ID; and the second is inner-module offset. @@ -35,14 +35,14 @@ from 0. - Line :math:`1250\times M_i + 1249`: pixel ID, inter bank correction Bad pixel file -============== +############## In bad pixel file, each line contains one and only one integer corresponding to the detector ID of a bad pixel. The bad pixels will be masked in the output MaskWorkspace. Conversion from offset in TOF to d-spacing -========================================== +########################################## With VULCAN's offsets in TOF, the calibration is done as the following. diff --git a/docs/source/algorithms/LoadWAND-v1.rst b/docs/source/algorithms/LoadWAND-v1.rst index 8d075bc5ef6b73265e34edeeffd2673eb6e00750..d5cd3e1a2dbc0a7cd61aa62aab096fd4120f3e58 100644 --- a/docs/source/algorithms/LoadWAND-v1.rst +++ b/docs/source/algorithms/LoadWAND-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Logarithm-v1.rst b/docs/source/algorithms/Logarithm-v1.rst index f73ddf933f3756df35825266d255e2d75aefb3cb..b4293fb2fd1e69c9ed255bd5ee2239edc7d049ed 100644 --- a/docs/source/algorithms/Logarithm-v1.rst +++ b/docs/source/algorithms/Logarithm-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LogarithmMD-v1.rst b/docs/source/algorithms/LogarithmMD-v1.rst index 8e569665a65d53f9410ef3ceb32b2f7d46dd022b..5164eabb2421e3a39b3ec1e588e08d56a54351bb 100644 --- a/docs/source/algorithms/LogarithmMD-v1.rst +++ b/docs/source/algorithms/LogarithmMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/LorentzCorrection-v1.rst b/docs/source/algorithms/LorentzCorrection-v1.rst index 509cdbc732430d80b4da324404cd923af2eff451..abd1e94191e3bce596416cc75735fb860cb63309 100644 --- a/docs/source/algorithms/LorentzCorrection-v1.rst +++ b/docs/source/algorithms/LorentzCorrection-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MDHistoToWorkspace2D-v1.rst b/docs/source/algorithms/MDHistoToWorkspace2D-v1.rst index 90c4d1cd41dbb2bb614b234301d766c88a90171e..45ee32e6b9f2ab1b9941b9681f7a3fa7f55156db 100644 --- a/docs/source/algorithms/MDHistoToWorkspace2D-v1.rst +++ b/docs/source/algorithms/MDHistoToWorkspace2D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MDNormDirectSC-v1.rst b/docs/source/algorithms/MDNormDirectSC-v1.rst index c47842c280d16b3d020a126de16f25bd3c62e7c8..353dbdbe8a1ec881188b6b50e6605215dd215b6c 100644 --- a/docs/source/algorithms/MDNormDirectSC-v1.rst +++ b/docs/source/algorithms/MDNormDirectSC-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MDNormSCD-v1.rst b/docs/source/algorithms/MDNormSCD-v1.rst index c54e1efe10ca7662f4993ed4a7daedfda3e37720..f99be5cb7590ac502352c0d609bd6a4e21d35747 100644 --- a/docs/source/algorithms/MDNormSCD-v1.rst +++ b/docs/source/algorithms/MDNormSCD-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MDNormSCDPreprocessIncoherent-v1.rst b/docs/source/algorithms/MDNormSCDPreprocessIncoherent-v1.rst index 221ddcfbb61381e7774e830f049ac35f36515b93..3b0bc08dc90eb8ff11c100c27042eca7cbc1e345 100644 --- a/docs/source/algorithms/MDNormSCDPreprocessIncoherent-v1.rst +++ b/docs/source/algorithms/MDNormSCDPreprocessIncoherent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MRFilterCrossSections-v1.rst b/docs/source/algorithms/MRFilterCrossSections-v1.rst index 3f214516448c32fed01d5710937b452fe6c6f4cf..75c7202df0c12d517394254512e116cc66bcd87f 100644 --- a/docs/source/algorithms/MRFilterCrossSections-v1.rst +++ b/docs/source/algorithms/MRFilterCrossSections-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MRInspectData-v1.rst b/docs/source/algorithms/MRInspectData-v1.rst index 657aab1595c72ef952b4dbfd92869a1768de6fc5..6fbd4f2e54af68fc4791736c125d6d710fe3211a 100644 --- a/docs/source/algorithms/MRInspectData-v1.rst +++ b/docs/source/algorithms/MRInspectData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MSDFit-v1.rst b/docs/source/algorithms/MSDFit-v1.rst index 96907467e77dcab04ba8fc4dbfcaa37cddd6b06a..f7b51e2cda468e30da3ebfe74171c9a69af73817 100644 --- a/docs/source/algorithms/MSDFit-v1.rst +++ b/docs/source/algorithms/MSDFit-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MagFormFactorCorrection-v1.rst b/docs/source/algorithms/MagFormFactorCorrection-v1.rst index 3e27e3937902cb3d934154e8f080bda2db50dca7..608b9cac232b04222c57e08cc959796e3f1c2005 100644 --- a/docs/source/algorithms/MagFormFactorCorrection-v1.rst +++ b/docs/source/algorithms/MagFormFactorCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskAngle-v1.rst b/docs/source/algorithms/MaskAngle-v1.rst index 0384c1e1da687df8db288fae2ce3535a84058194..f981b9458f741ca8fc2bfd8d84f1814ea31bbb93 100644 --- a/docs/source/algorithms/MaskAngle-v1.rst +++ b/docs/source/algorithms/MaskAngle-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskBTP-v1.rst b/docs/source/algorithms/MaskBTP-v1.rst index 611797be603c41b44e8c415b218a8d80e7e0c63f..bde4c6c2f856966cf65bc6563dc51f9205fbd862 100644 --- a/docs/source/algorithms/MaskBTP-v1.rst +++ b/docs/source/algorithms/MaskBTP-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskBins-v1.rst b/docs/source/algorithms/MaskBins-v1.rst index cbdeb1a00b168973176d157458e8f37584b84ef1..9af7cb8ee3d93bbd0a202b3c4117463d89ef675b 100644 --- a/docs/source/algorithms/MaskBins-v1.rst +++ b/docs/source/algorithms/MaskBins-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskBinsFromTable-v1.rst b/docs/source/algorithms/MaskBinsFromTable-v1.rst index 8ee464a6408329a145244fd543b6e02776d924d3..a83f9e89e420931f413553051e660544f62d57df 100644 --- a/docs/source/algorithms/MaskBinsFromTable-v1.rst +++ b/docs/source/algorithms/MaskBinsFromTable-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskDetectors-v1.rst b/docs/source/algorithms/MaskDetectors-v1.rst index b22bb7a85abaaa4d2c0aaba94ebfa121c7b33047..47ffae9c3c34f0e6f58f24db823fcb0c1ff59e40 100644 --- a/docs/source/algorithms/MaskDetectors-v1.rst +++ b/docs/source/algorithms/MaskDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskDetectorsIf-v1.rst b/docs/source/algorithms/MaskDetectorsIf-v1.rst index 276b40f34ea95c0e63690b257950703c01236c7c..a70292d2d40068dc2b5e49a96dc3515fa445c047 100644 --- a/docs/source/algorithms/MaskDetectorsIf-v1.rst +++ b/docs/source/algorithms/MaskDetectorsIf-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskDetectorsInShape-v1.rst b/docs/source/algorithms/MaskDetectorsInShape-v1.rst index 109d854381ef70e012b9f698bd7d8081d3a2f907..8dbcc0d049aa490e16097340ad405de634d2bc7a 100644 --- a/docs/source/algorithms/MaskDetectorsInShape-v1.rst +++ b/docs/source/algorithms/MaskDetectorsInShape-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskInstrument-v1.rst b/docs/source/algorithms/MaskInstrument-v1.rst index 5fbf728786696e7b6c46fb64d96627b8b36ebc92..b15ca47878119ffd12f1d6e5e3b8d841420c56cb 100644 --- a/docs/source/algorithms/MaskInstrument-v1.rst +++ b/docs/source/algorithms/MaskInstrument-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskMD-v1.rst b/docs/source/algorithms/MaskMD-v1.rst index d3b5086665f44b3918f1f64d588860e98c005ca8..6bb22cb9da5b3e85f950d6c97b1af4f45c0344f0 100644 --- a/docs/source/algorithms/MaskMD-v1.rst +++ b/docs/source/algorithms/MaskMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskPeaksWorkspace-v1.rst b/docs/source/algorithms/MaskPeaksWorkspace-v1.rst index b771d01ddbdb419d0b66dc532d7263a45207f140..5040e4f1f20d484fee859c619e6946778c15a0a9 100644 --- a/docs/source/algorithms/MaskPeaksWorkspace-v1.rst +++ b/docs/source/algorithms/MaskPeaksWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskSpectra-v1.rst b/docs/source/algorithms/MaskSpectra-v1.rst index d7f8ada91ec7eed36203b641f51b6a8a9e102269..b234da9e4ff63d6662a941a90b2237d146271e33 100644 --- a/docs/source/algorithms/MaskSpectra-v1.rst +++ b/docs/source/algorithms/MaskSpectra-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaskWorkspaceToCalFile-v1.rst b/docs/source/algorithms/MaskWorkspaceToCalFile-v1.rst index 11682c79abf521c4259af2e7dbe58c24efa3af55..74dd984691c807406e4f7505ea5d832d1731e5c3 100644 --- a/docs/source/algorithms/MaskWorkspaceToCalFile-v1.rst +++ b/docs/source/algorithms/MaskWorkspaceToCalFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MatchPeaks-v1.rst b/docs/source/algorithms/MatchPeaks-v1.rst index d245e56808a2ec73e8a70150585a6f12fd854249..c1fe7f9c15d024be1e79eede1d5829b6431d731b 100644 --- a/docs/source/algorithms/MatchPeaks-v1.rst +++ b/docs/source/algorithms/MatchPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Max-v1.rst b/docs/source/algorithms/Max-v1.rst index e0b69bbb7ef3c54122b7b8222d36a1b05454e3c6..3cf69b9415d430eae2e991dc943a062ef69ef7b7 100644 --- a/docs/source/algorithms/Max-v1.rst +++ b/docs/source/algorithms/Max-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MaxEnt-v1.rst b/docs/source/algorithms/MaxEnt-v1.rst index 1db090ec069ee32f3adc7059734f0099093cff3f..ffcb57b43c6aa21135531d4c2f9a53b94c8e677a 100644 --- a/docs/source/algorithms/MaxEnt-v1.rst +++ b/docs/source/algorithms/MaxEnt-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -100,33 +100,33 @@ the output workspaces whether the algorithm was evolving towards the correct sol On the other hand, the user must always check the validity of the solution by inspecting *EvolChi* and *EvolAngle*, whose values will be set to zero once the true maximum entropy solution is found. -.. table:: Table 1. Output workspaces for a real input workspace with M histograms and N bins +.. table:: Table 1. Output workspaces for a real input workspace with M histograms and N bins, taking J iterations. +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Workspace | Number of histograms | Number of bins | Description | +===================+==============================+================+====================================================================================================================================================================================================================================================================================================================+ - | EvolChi | M | MaxIterations | Evolution of :math:`\chi^2` until the solution is found. Then all values are set to zero. | + | EvolChi | M | J | For spectrum :math:`k` in the input workspace, evolution of :math:`\chi^2` until the solution is found | +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | EvolAngle | M | MaxIterations | Evolution of the angle between :math:`\nabla S` and :math:`\nabla \chi^2`, until the solution is found. Then all values are set to zero. | + | EvolAngle | M | J | For spectrum :math:`k` in the input workspace, evolution of the angle between :math:`\nabla S` and :math:`\nabla \chi^2`, until the solution is found | +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | ReconstructedImage| 2M | N | For spectrum :math:`s` in the input workspace, the reconstructed image is stored in spectra :math:`s` (real part) and :math:`s+M` (imaginary part) | + | ReconstructedImage| 2M | N | For spectrum :math:`k` in the input workspace, the reconstructed image is stored in spectra :math:`k` (real part) and :math:`k+M` (imaginary part) | +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | ReconstructedData | 2M | N | For spectrum :math:`s` in the input workspace, the reconstructed data are stored in spectrum :math:`s` (real part) and :math:`s+M` (imaginary part). Note that although the input is real, the imaginary part is recorded for debugging purposes, it should be zero for all data points. | + | ReconstructedData | 2M | N | For spectrum :math:`k` in the input workspace, the reconstructed data are stored in spectrum :math:`k` (real part) and :math:`k+M` (imaginary part). Note that although the input is real, the imaginary part is recorded for debugging purposes, it should be zero for all data points. | +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ -.. table:: Table 2. Output workspaces for a complex input workspace with 2M histograms and N bins. +.. table:: Table 2. Output workspaces for a complex input workspace with 2M histograms and N bins, taking J iterations. - +-------------------+------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | Workspace | Number of histograms | Number of bins | Description | - +===================+==============================+================+============================================================================================================================================================+ - | EvolChi | M | MaxIterations | Evolution of :math:`\chi^2` until the solution is found. Then all values are set to zero. | - +-------------------+------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | EvolAngle | M | MaxIterations | Evolution of the angle between :math:`\nabla S` and :math:`\nabla \chi^2`, until the solution is found. Then all values are set to zero. | - +-------------------+------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | ReconstructedImage| 2M | :math:`N` | For spectrum :math:`(s, s+M)` in the input workspace, the reconstructed image is stored in spectra :math:`s` (real part) and :math:`s+M` (imaginary part) | - +-------------------+------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ - | ReconstructedData | 2M | :math:`N` | For spectrum :math:`(s, s+M)` in the input workspace, the reconstructed data are stored in spectra :math:`s` (real part) and :math:`s+M` (imaginary part) | - +-------------------+------------------------------+----------------+------------------------------------------------------------------------------------------------------------------------------------------------------------+ + +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | Workspace | Number of histograms | Number of bins | Description | + +===================+==============================+================+==============================================================================================================================================================+ + | EvolChi | M | J | For spectrum :math:`(k, k+M)` in the input workspace, evolution of :math:`\chi^2` until the solution is found | + +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | EvolAngle | M | J | For spectrum :math:`(k, k+M)` in the input workspace, evolution of the angle between :math:`\nabla S` and :math:`\nabla \chi^2`, until the solution is found | + +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | ReconstructedImage| 2M | :math:`N` | For spectrum :math:`(k, k+M)` in the input workspace, the reconstructed image is stored in spectra :math:`k` (real part) and :math:`k+M` (imaginary part) | + +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ + | ReconstructedData | 2M | :math:`N` | For spectrum :math:`(k, k+M)` in the input workspace, the reconstructed data are stored in spectra :math:`k` (real part) and :math:`k+M` (imaginary part) | + +-------------------+------------------------------+----------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------+ Usage ----- @@ -380,6 +380,75 @@ where the first one refers to the real part of the entropy and the second one to about the image is available, as trying to reconstruct images that are inherently complex discarding the imaginary part will prevent the algorithm from converging. If the image is known to be real this property can be safely set to *False*. +Complex Data +------------ +If the input property "ComplexData* is set to *True*, the algorithm will assume complex data for the calculations with all the +real parts listed before all the imaginary parts. This means that if you have workspaces where the imaginary part immediately +follow the real part, such workspaces cannot be combined by using the :ref:`algm-AppendSpectra` algorithm because the resulting +output will not order the real and imaginary parts corrected as needed for this algorithm. The following usage example +shows how to combine two workspaces with complex data. + +.. testcode:: ExComplexData + + from math import pi, sin, cos + from random import random, seed + seed(0) + # Create complex data for a workspace + X = [] + YRe = [] + YIm = [] + E = [] + N = 200 + w = 3 + for i in range(0,N): + x = 2*pi*i/N + X.append(x) + YRe.append(cos(w*x)+(random()-0.5)*0.3) + YIm.append(sin(w*x)+(random()-0.5)*0.3) + E.append(0.1) + + seed(0) + # Create complex data for a second workspace + X2 = [] + YRe2 = [] + YIm2 = [] + E2 = [] + N2 = 200 + w2 = 4 + for i in range(0,N2): + x = 2*pi*i/N2 + X2.append(x) + YRe2.append(cos(w2*x)+(random()-0.5)*0.3) + YIm2.append(sin(w2*x)+(random()-0.5)*0.3) + E2.append(0.5) + + # Create two workspaces of one spectrum each + CreateWorkspace(OutputWorkspace='ws1',DataX=X+X,DataY=YRe+YIm,DataE=E+E,NSpec=2) + evolChiP, evolAngleP, imageP, dataP = MaxEnt(InputWorkspace='ws1', ComplexData=True, A=0.001, PositiveImage=True) + + print ("Number of iterations dataset1 separate: "+str( len(evolAngleP.readX(0)))) + + CreateWorkspace(OutputWorkspace='ws2',DataX=X2+X2,DataY=YRe2+YIm2,DataE=E2+E2,NSpec=2) + evolChiP2, evolAngleP2, imageP2, dataP2 = MaxEnt(InputWorkspace='ws2', ComplexData=True, A=0.001, PositiveImage=True) + + print ("Number of iterations dataset2 separate: "+str( len(evolAngleP2.readX(0)))) + + # Combine the two workspaces + CreateWorkspace(OutputWorkspace='wsCombined',DataX=X+X2+X+X2,DataY=YRe+YRe2+YIm+YIm2,DataE=E+E2+E+E2,NSpec=4) + evolChiC, evolAngleC, imageC, dataC = MaxEnt(InputWorkspace='wsCombined', ComplexData=True, A=0.001, PositiveImage=True) + + print ("Number of iterations dataset1 combined: "+str( len(evolAngleC.readX(0)))) + print ("Number of iterations dataset2 combined: "+str( len(evolAngleC.readX(1)))) + +Output: + +.. testoutput:: ExComplexData + + Number of iterations dataset1 separate: 11 + Number of iterations dataset2 separate: 7 + Number of iterations dataset1 combined: 11 + Number of iterations dataset2 combined: 7 + Increasing the number of points in the image -------------------------------------------- diff --git a/docs/source/algorithms/MaxMin-v1.rst b/docs/source/algorithms/MaxMin-v1.rst index 39961f5687b66d27a5ebd42b149f35befe94a8f1..8e335fd3a1d28ff9a30b0e06d08800df78a1cccf 100644 --- a/docs/source/algorithms/MaxMin-v1.rst +++ b/docs/source/algorithms/MaxMin-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MayersSampleCorrection-v1.rst b/docs/source/algorithms/MayersSampleCorrection-v1.rst index 7a1c489f2931f95fae92b4cbf00401bafa2a1f81..a2163c2834e517e45edbe5ff8950af581f1be8ab 100644 --- a/docs/source/algorithms/MayersSampleCorrection-v1.rst +++ b/docs/source/algorithms/MayersSampleCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Mean-v1.rst b/docs/source/algorithms/Mean-v1.rst index b73567b1784a9e52869896cf12e379842c96e573..d3452b87f5a38c5a2d766c8612812e9fcb8c3d13 100644 --- a/docs/source/algorithms/Mean-v1.rst +++ b/docs/source/algorithms/Mean-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MedianBinWidth-v1.rst b/docs/source/algorithms/MedianBinWidth-v1.rst index 9198e8ed0c9b507b8a6509ab0575949bc4d69cba..6d51bb1690a65f3bcc11ea29c4e1eeba95fca33a 100644 --- a/docs/source/algorithms/MedianBinWidth-v1.rst +++ b/docs/source/algorithms/MedianBinWidth-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MedianDetectorTest-v1.rst b/docs/source/algorithms/MedianDetectorTest-v1.rst index a995af4766ef20f42f8d89d522e3e191bf958d9b..dd467de839cedef559755656b5e0387f408f64f8 100644 --- a/docs/source/algorithms/MedianDetectorTest-v1.rst +++ b/docs/source/algorithms/MedianDetectorTest-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MergeCalFiles-v1.rst b/docs/source/algorithms/MergeCalFiles-v1.rst index 9a41a8f9224aecaae0a590e2173d1d7017d6084a..410472900e81c105747a32b66d31ef1301326b83 100644 --- a/docs/source/algorithms/MergeCalFiles-v1.rst +++ b/docs/source/algorithms/MergeCalFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MergeLogs-v1.rst b/docs/source/algorithms/MergeLogs-v1.rst index e4b257a2df5fbcfb861a121ff6ba0eb95fce38f5..f10702f4eacd077be486ce3fb61b4f10afa0159c 100644 --- a/docs/source/algorithms/MergeLogs-v1.rst +++ b/docs/source/algorithms/MergeLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MergeMD-v1.rst b/docs/source/algorithms/MergeMD-v1.rst index 2acf36e1fe878fadbe335dfefc90d4afb2f6292f..263470105bb4ecde08f70364601597bbd8928d45 100644 --- a/docs/source/algorithms/MergeMD-v1.rst +++ b/docs/source/algorithms/MergeMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MergeMDFiles-v1.rst b/docs/source/algorithms/MergeMDFiles-v1.rst index bbb7fa66d1c2640f696ea9266fcb6ccea523c42d..eb383fc1db543579fdea4e7856ee16222a226271 100644 --- a/docs/source/algorithms/MergeMDFiles-v1.rst +++ b/docs/source/algorithms/MergeMDFiles-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MergeRuns-v1.rst b/docs/source/algorithms/MergeRuns-v1.rst index 1ff0fbaf6a39249cd8bf972cf52eb01827488a87..1c41b77e816dcf0184a116e3d3cb247225e80e79 100644 --- a/docs/source/algorithms/MergeRuns-v1.rst +++ b/docs/source/algorithms/MergeRuns-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Min-v1.rst b/docs/source/algorithms/Min-v1.rst index 04328af539f7771ec46934f099f71bd55f42876a..d36da60edf2659484acc62bd0e0104ab65852bf3 100644 --- a/docs/source/algorithms/Min-v1.rst +++ b/docs/source/algorithms/Min-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Minus-v1.rst b/docs/source/algorithms/Minus-v1.rst index 27d3ff7dc7fd72ff1c10e599c70f6c80e628e4ab..77c371c156a2b3f3f7f02a5d82cceec0891695ee 100644 --- a/docs/source/algorithms/Minus-v1.rst +++ b/docs/source/algorithms/Minus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MinusMD-v1.rst b/docs/source/algorithms/MinusMD-v1.rst index df468c762969a6875724fa5dd33bd8514f130960..d55bb27197c815d7db7a2c80f3a75f991a36a876 100644 --- a/docs/source/algorithms/MinusMD-v1.rst +++ b/docs/source/algorithms/MinusMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ModeratorTzero-v1.rst b/docs/source/algorithms/ModeratorTzero-v1.rst index 7ec77175e2a9ac8db63bd5432e34339a919318f9..b03a405bd4bcc0966eb7e20ad4f85f2cff1f42eb 100644 --- a/docs/source/algorithms/ModeratorTzero-v1.rst +++ b/docs/source/algorithms/ModeratorTzero-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ModeratorTzeroLinear-v1.rst b/docs/source/algorithms/ModeratorTzeroLinear-v1.rst index f2352550059403f6aa2f313cc15fededbc0a41f8..7684fa4be21885922fa16171e24075d5d9fabce3 100644 --- a/docs/source/algorithms/ModeratorTzeroLinear-v1.rst +++ b/docs/source/algorithms/ModeratorTzeroLinear-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ModifyDetectorDotDatFile-v1.rst b/docs/source/algorithms/ModifyDetectorDotDatFile-v1.rst index 58aef3d2ae23e4938044711b203dbd9da31410da..0df84923b53e80c8ee7397a411676493f1e32254 100644 --- a/docs/source/algorithms/ModifyDetectorDotDatFile-v1.rst +++ b/docs/source/algorithms/ModifyDetectorDotDatFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MolDyn-v1.rst b/docs/source/algorithms/MolDyn-v1.rst index c29281247027363568e038e75c510a95534e1b73..c776859164ccb880f1594c67d4f017679e4b1a39 100644 --- a/docs/source/algorithms/MolDyn-v1.rst +++ b/docs/source/algorithms/MolDyn-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MonitorEfficiencyCorUser-v1.rst b/docs/source/algorithms/MonitorEfficiencyCorUser-v1.rst index 0c96ec724c1d1acfa91bab72f0e558a816e5edcc..bbf858a58c912bf2b36ce5d8fe2904945958199d 100644 --- a/docs/source/algorithms/MonitorEfficiencyCorUser-v1.rst +++ b/docs/source/algorithms/MonitorEfficiencyCorUser-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MonitorLiveData-v1.rst b/docs/source/algorithms/MonitorLiveData-v1.rst index cb3401f0a2f30263d61f66253ccab0c88f424b2e..7545e2311437dec9e0f595b21ba4557eebf116ae 100644 --- a/docs/source/algorithms/MonitorLiveData-v1.rst +++ b/docs/source/algorithms/MonitorLiveData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MonteCarloAbsorption-v1.rst b/docs/source/algorithms/MonteCarloAbsorption-v1.rst index eb8ae7c7effa96ff03a016651a62da20e8d4b950..bdc1e59726fbe4131bebfa236e3e1e535d0df518 100644 --- a/docs/source/algorithms/MonteCarloAbsorption-v1.rst +++ b/docs/source/algorithms/MonteCarloAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MostLikelyMean-v1.rst b/docs/source/algorithms/MostLikelyMean-v1.rst index 0573e797c957c37533b9555ab8fb8af7ea40dc6f..122cc8d600bda7c4512b4635232a2dfdf0e08fe5 100644 --- a/docs/source/algorithms/MostLikelyMean-v1.rst +++ b/docs/source/algorithms/MostLikelyMean-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MoveInstrumentComponent-v1.rst b/docs/source/algorithms/MoveInstrumentComponent-v1.rst index 579eca2db371c6903bfb701ea2092d0da0c954bb..7202f866af8470412f3be8603ab9b4738a301d62 100644 --- a/docs/source/algorithms/MoveInstrumentComponent-v1.rst +++ b/docs/source/algorithms/MoveInstrumentComponent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MultipleScatteringCylinderAbsorption-v1.rst b/docs/source/algorithms/MultipleScatteringCylinderAbsorption-v1.rst index 8ba34d07e087a113f0bbc3aa19e87538c15bdb94..bcb4b1ce649ed5156a2e90269f241aec0551b587 100644 --- a/docs/source/algorithms/MultipleScatteringCylinderAbsorption-v1.rst +++ b/docs/source/algorithms/MultipleScatteringCylinderAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Multiply-v1.rst b/docs/source/algorithms/Multiply-v1.rst index b8eb73ac9f9e53b0902a85c4f9df9b2cec7795f6..06f738f55e7d5ee7bbefa0f8d73eb1dbebe4e909 100644 --- a/docs/source/algorithms/Multiply-v1.rst +++ b/docs/source/algorithms/Multiply-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MultiplyMD-v1.rst b/docs/source/algorithms/MultiplyMD-v1.rst index ab23a28de8f3206f73c804abba911459bcb8975f..e63c67fa070d268fdbf754b845c62b57d8eff965 100644 --- a/docs/source/algorithms/MultiplyMD-v1.rst +++ b/docs/source/algorithms/MultiplyMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MultiplyRange-v1.rst b/docs/source/algorithms/MultiplyRange-v1.rst index fe72fcb0080c2408bf2421e54cbce970bb7d2b65..284891de161d4c4372225cf8a58b110dade59a1f 100644 --- a/docs/source/algorithms/MultiplyRange-v1.rst +++ b/docs/source/algorithms/MultiplyRange-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuonGroupDetectors-v1.rst b/docs/source/algorithms/MuonGroupDetectors-v1.rst index dcf6a7d1d765a0f8a7e414772b3afa21c46dfea1..9a9549927230556ead1bf9139426cc06237fa1aa 100644 --- a/docs/source/algorithms/MuonGroupDetectors-v1.rst +++ b/docs/source/algorithms/MuonGroupDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuonMaxent-v1.rst b/docs/source/algorithms/MuonMaxent-v1.rst index 5ea956f2d0d6eefaf68d3e59fb4a539aa6d68c56..c85399b6a5e87a2ac4d20536ea82f73d9c726f67 100644 --- a/docs/source/algorithms/MuonMaxent-v1.rst +++ b/docs/source/algorithms/MuonMaxent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuonProcess-v1.rst b/docs/source/algorithms/MuonProcess-v1.rst index 460e2348cfd2e1ada5e070dee427da5b10c6babf..f24b88fc76d1fbd1803c538be2b92c5075f9a2c0 100644 --- a/docs/source/algorithms/MuonProcess-v1.rst +++ b/docs/source/algorithms/MuonProcess-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuscatData-v1.rst b/docs/source/algorithms/MuscatData-v1.rst index 810162435cd4e2bbb04812cd345f478e17c261d8..e6a500e1efe644120b3b2d3dd25970bfca6595b4 100644 --- a/docs/source/algorithms/MuscatData-v1.rst +++ b/docs/source/algorithms/MuscatData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuscatFunc-v1.rst b/docs/source/algorithms/MuscatFunc-v1.rst index 3c0bd184bd6183b027ad9aca4bc3cb5f5c8a9f3d..921e759ba69a9b953532f403a1b1fc2776813ad7 100644 --- a/docs/source/algorithms/MuscatFunc-v1.rst +++ b/docs/source/algorithms/MuscatFunc-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/MuscatSofQW-v1.rst b/docs/source/algorithms/MuscatSofQW-v1.rst index 692b2bb76c7eaaeb7aabb787ff70d4a955536919..3442b17a9d2f8db60e692454527d01d159660f17 100644 --- a/docs/source/algorithms/MuscatSofQW-v1.rst +++ b/docs/source/algorithms/MuscatSofQW-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NMoldyn4Interpolation-v1.rst b/docs/source/algorithms/NMoldyn4Interpolation-v1.rst index 6209957c9c0dd207260d1e56a70b27cb52b3ebee..ff3d0a10409913a938145e1f7f944f4c22d72f34 100644 --- a/docs/source/algorithms/NMoldyn4Interpolation-v1.rst +++ b/docs/source/algorithms/NMoldyn4Interpolation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NRCalculateSlitResolution-v1.rst b/docs/source/algorithms/NRCalculateSlitResolution-v1.rst index bdd830f369c35ee35ef6af028d065c6bb5ed052b..1f729b8c20ced64dce0d2b712f7aa49c8cce1a62 100644 --- a/docs/source/algorithms/NRCalculateSlitResolution-v1.rst +++ b/docs/source/algorithms/NRCalculateSlitResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -17,7 +17,7 @@ using the theta log name provided. The effective inverse of this algorithm is :ref:`algm-CalculateSlits`. Beam Divergence -*************** +############### .. figure:: ../images/collimation_diagram.png :scale: 50 % diff --git a/docs/source/algorithms/NexusTester-v1.rst b/docs/source/algorithms/NexusTester-v1.rst index 6314e9a18afc2eaa2694b0696ce88a0934dea449..e2bac7eed2c2d9788a166401b6ff9ae650efc090 100644 --- a/docs/source/algorithms/NexusTester-v1.rst +++ b/docs/source/algorithms/NexusTester-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseByCurrent-v1.rst b/docs/source/algorithms/NormaliseByCurrent-v1.rst index ad9fbc58e87251e0fa5ff0a85b098a997b5d7833..b306fee5c54159625f1000e28e7e3f47e14af27e 100644 --- a/docs/source/algorithms/NormaliseByCurrent-v1.rst +++ b/docs/source/algorithms/NormaliseByCurrent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseByDetector-v1.rst b/docs/source/algorithms/NormaliseByDetector-v1.rst index a9d4792005530a0e4bbcdc2cfe64d265fe28fb35..b7d8f7d19c444bfe9769827fca0974bc332e1edc 100644 --- a/docs/source/algorithms/NormaliseByDetector-v1.rst +++ b/docs/source/algorithms/NormaliseByDetector-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseByPeakArea-v1.rst b/docs/source/algorithms/NormaliseByPeakArea-v1.rst index fb3e25279aeddd584f1a0cfb7ae3c89c4766b9f9..b11b2e9f47137084ca5381f962a2f8b69e5d42b3 100644 --- a/docs/source/algorithms/NormaliseByPeakArea-v1.rst +++ b/docs/source/algorithms/NormaliseByPeakArea-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseByThickness-v1.rst b/docs/source/algorithms/NormaliseByThickness-v1.rst index 437f5584ca7c451946eb66d8420a50b666d862cb..362f9dff526d75f221b59c6df21894d06dde68be 100644 --- a/docs/source/algorithms/NormaliseByThickness-v1.rst +++ b/docs/source/algorithms/NormaliseByThickness-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseSpectra-v1.rst b/docs/source/algorithms/NormaliseSpectra-v1.rst index d7e428c066435768ca84bae1a9401c48a9d23468..ef9b534a1f3044040f1761190726d10c1b7afcc9 100644 --- a/docs/source/algorithms/NormaliseSpectra-v1.rst +++ b/docs/source/algorithms/NormaliseSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseToMonitor-v1.rst b/docs/source/algorithms/NormaliseToMonitor-v1.rst index 520ea336220f699f86a6e843f472952ba5049163..79df1957337b68e9a6f6889356150a413b795155 100644 --- a/docs/source/algorithms/NormaliseToMonitor-v1.rst +++ b/docs/source/algorithms/NormaliseToMonitor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseToUnity-v1.rst b/docs/source/algorithms/NormaliseToUnity-v1.rst index 059fe586a0999153986feb5a61ff5a4639a896bf..637da1324fc2018911e493a8e14d5f7879ef4363 100644 --- a/docs/source/algorithms/NormaliseToUnity-v1.rst +++ b/docs/source/algorithms/NormaliseToUnity-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NormaliseVanadium-v1.rst b/docs/source/algorithms/NormaliseVanadium-v1.rst index 4bf7490ef3640e25d72011a04b6cb546874a8fef..c441ac08356614ef3a523a4e4de6dcd3e5896fa6 100644 --- a/docs/source/algorithms/NormaliseVanadium-v1.rst +++ b/docs/source/algorithms/NormaliseVanadium-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/NotMD-v1.rst b/docs/source/algorithms/NotMD-v1.rst index 3c87a3ee903972bee6221fd9f61e02c47d1531e6..49026f56f05e787af35643e2a67d2905430e3f99 100644 --- a/docs/source/algorithms/NotMD-v1.rst +++ b/docs/source/algorithms/NotMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst b/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst index 87bf5b6dc369d097dea3b1e95c6ac002e6be133e..c9bc8716db237f1cc4f9298635cfb9c38cde544c 100644 --- a/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst +++ b/docs/source/algorithms/OSIRISDiffractionReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OneMinusExponentialCor-v1.rst b/docs/source/algorithms/OneMinusExponentialCor-v1.rst index a35ca4c96320fc16fc5c2d5cc51384ed7f0d25de..c82a12a31969d596a7fb5744ca9a6d061e53e1b4 100644 --- a/docs/source/algorithms/OneMinusExponentialCor-v1.rst +++ b/docs/source/algorithms/OneMinusExponentialCor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OneStepMDEW-v1.rst b/docs/source/algorithms/OneStepMDEW-v1.rst index ab2b0dc463fb5ad401df978b8c38e94bfdd0bf6b..dc1664119db75a31a79b519a58c319d74a401472 100644 --- a/docs/source/algorithms/OneStepMDEW-v1.rst +++ b/docs/source/algorithms/OneStepMDEW-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OptimizeCrystalPlacement-v1.rst b/docs/source/algorithms/OptimizeCrystalPlacement-v1.rst index 712f492abf243fa83468c31d8c48a98d42ce2a02..d4527d6fdbfba4fe4c41c28e33c416768f54787e 100644 --- a/docs/source/algorithms/OptimizeCrystalPlacement-v1.rst +++ b/docs/source/algorithms/OptimizeCrystalPlacement-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OptimizeLatticeForCellType-v1.rst b/docs/source/algorithms/OptimizeLatticeForCellType-v1.rst index fb3a18d2d23c9753442f432370756fab1ccdb558..d3badd33dc0f915ea7c334956de5d5e469dea904 100644 --- a/docs/source/algorithms/OptimizeLatticeForCellType-v1.rst +++ b/docs/source/algorithms/OptimizeLatticeForCellType-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/OrMD-v1.rst b/docs/source/algorithms/OrMD-v1.rst index 6c32609d1c5cfd80b950828afba64d899152dce0..5731f041fcfa1bd2d38032e2a64245131df55bfc 100644 --- a/docs/source/algorithms/OrMD-v1.rst +++ b/docs/source/algorithms/OrMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PDCalibration-v1.rst b/docs/source/algorithms/PDCalibration-v1.rst index a916066df11347145cdb677c11f9fce550873713..fbaecc83cab2100881063b7e9c67af23324cde2b 100644 --- a/docs/source/algorithms/PDCalibration-v1.rst +++ b/docs/source/algorithms/PDCalibration-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PDDetermineCharacterizations-v1.rst b/docs/source/algorithms/PDDetermineCharacterizations-v1.rst index d34d55bc56009072b62e9a89f0343b7cf8d12140..3bbf4814847a6404574a59735e923a5c76ce37b7 100644 --- a/docs/source/algorithms/PDDetermineCharacterizations-v1.rst +++ b/docs/source/algorithms/PDDetermineCharacterizations-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PDFFourierTransform-v1.rst b/docs/source/algorithms/PDFFourierTransform-v1.rst index e1ab0936bfd4d201b9efc06ce15b4e96e2e533a1..de892da208fd3652c62e6f89c070fe929689410a 100644 --- a/docs/source/algorithms/PDFFourierTransform-v1.rst +++ b/docs/source/algorithms/PDFFourierTransform-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -32,7 +32,7 @@ Output Options -------------- **G(r)** -''''''''' +######## .. raw:: html @@ -84,7 +84,7 @@ otherwise **g(r)** -'''''''' +######## .. raw:: html @@ -111,7 +111,7 @@ transforms to **RDF(r)** -'''''''''' +########## .. raw:: html diff --git a/docs/source/algorithms/PDLoadCharacterizations-v1.rst b/docs/source/algorithms/PDLoadCharacterizations-v1.rst index 6fb3ad6727cc22c5f88899c336f9cd7651a399c5..48454d9e29068557729d8e4c6f0cb92a3475b81c 100644 --- a/docs/source/algorithms/PDLoadCharacterizations-v1.rst +++ b/docs/source/algorithms/PDLoadCharacterizations-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PDToGUDRUN-v1.rst b/docs/source/algorithms/PDToGUDRUN-v1.rst index 5f242e390a5d59a6a40d4a7433ccd64255d12fc5..1090a979c2e46ac0c63e984c5b40879c7dc4c1a0 100644 --- a/docs/source/algorithms/PDToGUDRUN-v1.rst +++ b/docs/source/algorithms/PDToGUDRUN-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PDToPDFgetN-v1.rst b/docs/source/algorithms/PDToPDFgetN-v1.rst index f37aae644e29dee983a0c7e1ab829a772546b5a4..52236db5af28db3533cc0b4442538f9149cf6edd 100644 --- a/docs/source/algorithms/PDToPDFgetN-v1.rst +++ b/docs/source/algorithms/PDToPDFgetN-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PaddingAndApodization-v1.rst b/docs/source/algorithms/PaddingAndApodization-v1.rst index a2a6dd46e16eef89178a4aae65e588424af214c2..365c47df7536082d55d39e1a1bc5170f3b35d1a3 100644 --- a/docs/source/algorithms/PaddingAndApodization-v1.rst +++ b/docs/source/algorithms/PaddingAndApodization-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Pause-v1.rst b/docs/source/algorithms/Pause-v1.rst index 3608265c5ab15ceb0f2ef93cbdeb3eb352424094..b8d05479ccd3a441d4f626226ca2315c051ed2b9 100644 --- a/docs/source/algorithms/Pause-v1.rst +++ b/docs/source/algorithms/Pause-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PawleyFit-v1.rst b/docs/source/algorithms/PawleyFit-v1.rst index 2d595ce71e36b1d5d8f4801b24d7cd0e5b2248c7..0304af84e3304d3865fe41d09439a52c8e2fe103 100644 --- a/docs/source/algorithms/PawleyFit-v1.rst +++ b/docs/source/algorithms/PawleyFit-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PeakIntegration-v1.rst b/docs/source/algorithms/PeakIntegration-v1.rst index 5883750d5d06cea702d89fe46fe3a59556c6db89..10f147f712bbb0d901d35b80b73da81e0f9b1073 100644 --- a/docs/source/algorithms/PeakIntegration-v1.rst +++ b/docs/source/algorithms/PeakIntegration-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PeakIntensityVsRadius-v1.rst b/docs/source/algorithms/PeakIntensityVsRadius-v1.rst index 3c2dfb61ec141539943007b225c7ce1bacf823f7..5bbcab8f5fefc6b06b3a35fca7f5f2fa07567113 100644 --- a/docs/source/algorithms/PeakIntensityVsRadius-v1.rst +++ b/docs/source/algorithms/PeakIntensityVsRadius-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PeaksInRegion-v1.rst b/docs/source/algorithms/PeaksInRegion-v1.rst index d31f554b61c8fcc59fd6d0d4341b0551a2fd25ed..416e628b74479109c896766a328d7936dc50e628 100644 --- a/docs/source/algorithms/PeaksInRegion-v1.rst +++ b/docs/source/algorithms/PeaksInRegion-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PeaksOnSurface-v1.rst b/docs/source/algorithms/PeaksOnSurface-v1.rst index 2120e70924cc30974d541d4fd1654970672f421a..9863d8155b84dd38bd66f84c057621039f1ba83b 100644 --- a/docs/source/algorithms/PeaksOnSurface-v1.rst +++ b/docs/source/algorithms/PeaksOnSurface-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PearlMCAbsorption-v1.rst b/docs/source/algorithms/PearlMCAbsorption-v1.rst index 98d3162d44126348119401fcc5a4358e84b62283..160bb9d855fe6698a0bc373d7f1a76dc3ace2936 100644 --- a/docs/source/algorithms/PearlMCAbsorption-v1.rst +++ b/docs/source/algorithms/PearlMCAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PerformIndexOperations-v1.rst b/docs/source/algorithms/PerformIndexOperations-v1.rst index 8884f4c92dd4a072e7596e16fdf01b46fe6ae982..cc43e6c55990a5df181c39f2d91a33eb4d0bb9b7 100644 --- a/docs/source/algorithms/PerformIndexOperations-v1.rst +++ b/docs/source/algorithms/PerformIndexOperations-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PhaseQuad-v1.rst b/docs/source/algorithms/PhaseQuad-v1.rst index 30f6d6da89ecb6bfaaaed11826ccfe8ae8e9b2c5..90ed1e0970868f0a3f92f29394f8e40532acdf84 100644 --- a/docs/source/algorithms/PhaseQuad-v1.rst +++ b/docs/source/algorithms/PhaseQuad-v1.rst @@ -16,7 +16,7 @@ the dataset using the algorithm :ref:`algm-RRFMuon`. Both algorithms are fully d by T.M. Riseman and J.H. Brewer [Hyp. Int., 65, (1990), 1107]. -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PlotAsymmetryByLogValue-v1.rst b/docs/source/algorithms/PlotAsymmetryByLogValue-v1.rst index bcdd84cedb0f572a9197683c2a27158e2aefd9c9..5f73a567df13c9fffd5c638bd1015d93667a5f7d 100644 --- a/docs/source/algorithms/PlotAsymmetryByLogValue-v1.rst +++ b/docs/source/algorithms/PlotAsymmetryByLogValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PlotPeakByLogValue-v1.rst b/docs/source/algorithms/PlotPeakByLogValue-v1.rst index 2abc311e9edcd62cf5adcbc398e0b0b3d52b5215..aaa63fab9c676456901c90181d54fdc13e284435 100644 --- a/docs/source/algorithms/PlotPeakByLogValue-v1.rst +++ b/docs/source/algorithms/PlotPeakByLogValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Plus-v1.rst b/docs/source/algorithms/Plus-v1.rst index ae8542c8964a4bea6378a872c4a0ceabad1dc68b..0e5ccdcf98eb0c71e97cbbd3815f6b47dfc02c3d 100644 --- a/docs/source/algorithms/Plus-v1.rst +++ b/docs/source/algorithms/Plus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PlusMD-v1.rst b/docs/source/algorithms/PlusMD-v1.rst index b61fe857e8bb352348bc8d485e9607d9b29eaeae..652d6a4f8b25871046c2dc629fcd72c0d71e862c 100644 --- a/docs/source/algorithms/PlusMD-v1.rst +++ b/docs/source/algorithms/PlusMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PointByPointVCorrection-v1.rst b/docs/source/algorithms/PointByPointVCorrection-v1.rst index 8cd77e9b2d9129797379113446c2942b2d917d60..9b5887582ea1204c3e96894ee458b7b139d6776a 100644 --- a/docs/source/algorithms/PointByPointVCorrection-v1.rst +++ b/docs/source/algorithms/PointByPointVCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoissonErrors-v1.rst b/docs/source/algorithms/PoissonErrors-v1.rst index ff71601af0216fb910ace03932b3b515157f2bda..e2afcc45783ca8e5a581861d87344bc57f7edb1c 100644 --- a/docs/source/algorithms/PoissonErrors-v1.rst +++ b/docs/source/algorithms/PoissonErrors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PolarizationCorrection-v1.rst b/docs/source/algorithms/PolarizationCorrection-v1.rst index f3ad00bdb846ab297a5984dd3c8d1ff922a14004..c42f2de3d7fec485a9e788ea88186a38b37e00d4 100644 --- a/docs/source/algorithms/PolarizationCorrection-v1.rst +++ b/docs/source/algorithms/PolarizationCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PolarizationEfficiencyCor-v1.rst b/docs/source/algorithms/PolarizationEfficiencyCor-v1.rst index 6768e8f5fdd09bbcc4a2a7c1fb4a63c2224cc9bd..a34480a2307b1035f6ee503f4b5b352f272d11bd 100644 --- a/docs/source/algorithms/PolarizationEfficiencyCor-v1.rst +++ b/docs/source/algorithms/PolarizationEfficiencyCor-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiAnalyseResiduals-v1.rst b/docs/source/algorithms/PoldiAnalyseResiduals-v1.rst index db4d53d023643f1509e39640ba992acc1263319e..4e7d1efd056eb3ed5e872bb9771b909e339ff5b7 100644 --- a/docs/source/algorithms/PoldiAnalyseResiduals-v1.rst +++ b/docs/source/algorithms/PoldiAnalyseResiduals-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiAutoCorrelation-v5.rst b/docs/source/algorithms/PoldiAutoCorrelation-v5.rst index 06d1a4746d6ce6343dde224b860e3c26879be2d2..fab4797afc75a89d9c25694c8b96f9e53bfc02c6 100644 --- a/docs/source/algorithms/PoldiAutoCorrelation-v5.rst +++ b/docs/source/algorithms/PoldiAutoCorrelation-v5.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiCreatePeaksFromCell-v1.rst b/docs/source/algorithms/PoldiCreatePeaksFromCell-v1.rst index 474852eb1f01b2eeb3ef66087403bf74180b5fba..949ea1c1e2e2912e61ca4d1d6058dc3e34a6d70f 100644 --- a/docs/source/algorithms/PoldiCreatePeaksFromCell-v1.rst +++ b/docs/source/algorithms/PoldiCreatePeaksFromCell-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiCreatePeaksFromFile-v1.rst b/docs/source/algorithms/PoldiCreatePeaksFromFile-v1.rst index 5ed11c6b4027641d31c3bac02db335057d8f42d4..12f8f906cb00f488bf8f59cd7d4a146389d90df3 100644 --- a/docs/source/algorithms/PoldiCreatePeaksFromFile-v1.rst +++ b/docs/source/algorithms/PoldiCreatePeaksFromFile-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiDataAnalysis-v1.rst b/docs/source/algorithms/PoldiDataAnalysis-v1.rst index 2ba86f8a52a3dd948256c1a25f170e46f6d52cbb..b3a40781d215c7948f8c41118a722103c40c809f 100644 --- a/docs/source/algorithms/PoldiDataAnalysis-v1.rst +++ b/docs/source/algorithms/PoldiDataAnalysis-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiFitPeaks1D-v1.rst b/docs/source/algorithms/PoldiFitPeaks1D-v1.rst index 97f082a76b1c826705698cccf3c7ed6bd9b33807..3043e2daef16bedcaa82e21008407af089d670fc 100644 --- a/docs/source/algorithms/PoldiFitPeaks1D-v1.rst +++ b/docs/source/algorithms/PoldiFitPeaks1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiFitPeaks1D-v2.rst b/docs/source/algorithms/PoldiFitPeaks1D-v2.rst index 3bc77b32254857fb891e5f045efd1c4597e2f71f..dabc74f453f0b9c9a7168ae3fdab679f0e8e9e98 100644 --- a/docs/source/algorithms/PoldiFitPeaks1D-v2.rst +++ b/docs/source/algorithms/PoldiFitPeaks1D-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiFitPeaks2D-v1.rst b/docs/source/algorithms/PoldiFitPeaks2D-v1.rst index d2cc1729a4a97e2b5e98487120210a3781a9981c..ebff26e15814f83851b7416b6034ac969d5791b1 100644 --- a/docs/source/algorithms/PoldiFitPeaks2D-v1.rst +++ b/docs/source/algorithms/PoldiFitPeaks2D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiIndexKnownCompounds-v1.rst b/docs/source/algorithms/PoldiIndexKnownCompounds-v1.rst index 615f830636cfd36e78bc6036e02efe370e34bdea..7557517576c76f649a74a2153ca876b50b0ef132 100644 --- a/docs/source/algorithms/PoldiIndexKnownCompounds-v1.rst +++ b/docs/source/algorithms/PoldiIndexKnownCompounds-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiLoadRuns-v1.rst b/docs/source/algorithms/PoldiLoadRuns-v1.rst index 8fb355dd2a0bb064b8adef8c3777624ce43d9d03..c2a82a3ce75a4529586238b284ac734e4bdc64b7 100644 --- a/docs/source/algorithms/PoldiLoadRuns-v1.rst +++ b/docs/source/algorithms/PoldiLoadRuns-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiMerge-v1.rst b/docs/source/algorithms/PoldiMerge-v1.rst index 43efce97d054a3ab99b2019153a08f71d244f009..f1bb1e512c8c9930409a90d2c8bc31ed75f01d10 100644 --- a/docs/source/algorithms/PoldiMerge-v1.rst +++ b/docs/source/algorithms/PoldiMerge-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiPeakSearch-v1.rst b/docs/source/algorithms/PoldiPeakSearch-v1.rst index e5f4a535f6bb696860f300eeaf971ebae78383df..6051f20db58db298ad7dfc0518f281072bc0fe95 100644 --- a/docs/source/algorithms/PoldiPeakSearch-v1.rst +++ b/docs/source/algorithms/PoldiPeakSearch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiPeakSummary-v1.rst b/docs/source/algorithms/PoldiPeakSummary-v1.rst index 058e6408ae5ff383617be56d2c01aa8cbb9f3b51..dda2634eabd862fb9c53094d702229055aa08f7e 100644 --- a/docs/source/algorithms/PoldiPeakSummary-v1.rst +++ b/docs/source/algorithms/PoldiPeakSummary-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PoldiTruncateData-v1.rst b/docs/source/algorithms/PoldiTruncateData-v1.rst index a8ad7c8454f5d0c96ad688bd26c9afb7b6ec47e8..3b29df5d33dc699d8794f970eee454f3bb82ac68 100644 --- a/docs/source/algorithms/PoldiTruncateData-v1.rst +++ b/docs/source/algorithms/PoldiTruncateData-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PolynomialCorrection-v1.rst b/docs/source/algorithms/PolynomialCorrection-v1.rst index 379471ffb8679d7b2a5f97bf445932a1ca863fc4..00c0a3a00004586038b2e846a3696246f0e3f37e 100644 --- a/docs/source/algorithms/PolynomialCorrection-v1.rst +++ b/docs/source/algorithms/PolynomialCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PowderDiffILLDetEffCorr-v1.rst b/docs/source/algorithms/PowderDiffILLDetEffCorr-v1.rst index 0aaa7f489d66d577ee9811cb244e3535640ecca0..a75276bce13c630312427493960432cd812f74fa 100644 --- a/docs/source/algorithms/PowderDiffILLDetEffCorr-v1.rst +++ b/docs/source/algorithms/PowderDiffILLDetEffCorr-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PowderDiffILLDetScanReduction-v1.rst b/docs/source/algorithms/PowderDiffILLDetScanReduction-v1.rst index c0770cf2a2399527d8c8474b2dff563a52882335..78114e0436400435861d458811c9c24a6de5b180 100644 --- a/docs/source/algorithms/PowderDiffILLDetScanReduction-v1.rst +++ b/docs/source/algorithms/PowderDiffILLDetScanReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PowderDiffILLReduction-v1.rst b/docs/source/algorithms/PowderDiffILLReduction-v1.rst index e176f63b647db61eaddc81d5c8fdd8df5f16a816..0aa17c738a05214690b6c58ab2f5dc5d86c82d2f 100644 --- a/docs/source/algorithms/PowderDiffILLReduction-v1.rst +++ b/docs/source/algorithms/PowderDiffILLReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Power-v1.rst b/docs/source/algorithms/Power-v1.rst index e265fc3f8be84a8347d048d6d91784d4703139f2..a5e2355783b9c3eb195ba61545c5d07ea9ce6efd 100644 --- a/docs/source/algorithms/Power-v1.rst +++ b/docs/source/algorithms/Power-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PowerLawCorrection-v1.rst b/docs/source/algorithms/PowerLawCorrection-v1.rst index 2c0a331cae57f8b3d6ed481d3a557c0957ad97be..2c6b4295d7825d2e7ba0529ee65072152a5d7119 100644 --- a/docs/source/algorithms/PowerLawCorrection-v1.rst +++ b/docs/source/algorithms/PowerLawCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PowerMD-v1.rst b/docs/source/algorithms/PowerMD-v1.rst index d9c9235dab872c6412438aa3433df5713be6ff41..cd3de950833ac5c9ae31aaeea911c9883bd0f7df 100644 --- a/docs/source/algorithms/PowerMD-v1.rst +++ b/docs/source/algorithms/PowerMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PredictFractionalPeaks-v1.rst b/docs/source/algorithms/PredictFractionalPeaks-v1.rst index 17cfee191374187b73d37f6e92888fdb09b5894a..665c80a9dd9f98bb2a023d894c25b77d3a9ea370 100644 --- a/docs/source/algorithms/PredictFractionalPeaks-v1.rst +++ b/docs/source/algorithms/PredictFractionalPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PredictPeaks-v1.rst b/docs/source/algorithms/PredictPeaks-v1.rst index e75114f7be9ce3133f7732344ecab1c23f43678b..e49f377c0b0048fa76cc52e59343ef6fb90f66d9 100644 --- a/docs/source/algorithms/PredictPeaks-v1.rst +++ b/docs/source/algorithms/PredictPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/PreprocessDetectorsToMD-v1.rst b/docs/source/algorithms/PreprocessDetectorsToMD-v1.rst index c33bc2138e4d7ce9464757784e578c24630af3e1..d1827a3046c21205f532febdb7cd5969b0ef233b 100644 --- a/docs/source/algorithms/PreprocessDetectorsToMD-v1.rst +++ b/docs/source/algorithms/PreprocessDetectorsToMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ProcessBackground-v1.rst b/docs/source/algorithms/ProcessBackground-v1.rst index fbaa512aa399c9a5f6b063c2f8d5eafbd1a3e116..3a9dfe1486cdb747446a2a001d23744357841de5 100644 --- a/docs/source/algorithms/ProcessBackground-v1.rst +++ b/docs/source/algorithms/ProcessBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ProcessIndirectFitParameters-v1.rst b/docs/source/algorithms/ProcessIndirectFitParameters-v1.rst index 9dac5faff4735b488d47d2c595be99d79141a514..3b6dae49d1a00170f593bc9495f43764286fd652 100644 --- a/docs/source/algorithms/ProcessIndirectFitParameters-v1.rst +++ b/docs/source/algorithms/ProcessIndirectFitParameters-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ProjectMD-v1.rst b/docs/source/algorithms/ProjectMD-v1.rst index 81ca4aadbbca0d041832f738bd262a001359989f..926a93f09d8e0da81f42222ab8b02c53beeb5a35 100644 --- a/docs/source/algorithms/ProjectMD-v1.rst +++ b/docs/source/algorithms/ProjectMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Q1D-v2.rst b/docs/source/algorithms/Q1D-v2.rst index 58211b2be981940a13afbccc5a7cbe9441093831..758cfa7e89f58f7d1e447d2b318752840064eb83 100644 --- a/docs/source/algorithms/Q1D-v2.rst +++ b/docs/source/algorithms/Q1D-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Q1DWeighted-v1.rst b/docs/source/algorithms/Q1DWeighted-v1.rst index dc9a32533cbed0a43ab5372c2c46d3ed2d61cd76..a378348812a801a47c0880eb246d50fd3fa95b4d 100644 --- a/docs/source/algorithms/Q1DWeighted-v1.rst +++ b/docs/source/algorithms/Q1DWeighted-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryAllRemoteJobs-v1.rst b/docs/source/algorithms/QueryAllRemoteJobs-v1.rst index cd0d0d952d010bf4e7ea4a6a8e78c8ae43e17926..e5fbcdff86d2c81f0f7a447d1a6ffb222cc67f40 100644 --- a/docs/source/algorithms/QueryAllRemoteJobs-v1.rst +++ b/docs/source/algorithms/QueryAllRemoteJobs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryAllRemoteJobs-v2.rst b/docs/source/algorithms/QueryAllRemoteJobs-v2.rst index 2f8f0e272da67c5c367d92ff395e85c092a3f2a8..927d6d70c5418c4869583cd70676fc3730e661a1 100644 --- a/docs/source/algorithms/QueryAllRemoteJobs-v2.rst +++ b/docs/source/algorithms/QueryAllRemoteJobs-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryMDWorkspace-v1.rst b/docs/source/algorithms/QueryMDWorkspace-v1.rst index a7e8b512695ea3707eda3645cad4aee03cf63079..5f44c2e97ae5778fa7b2d9f4acb2f776702b083a 100644 --- a/docs/source/algorithms/QueryMDWorkspace-v1.rst +++ b/docs/source/algorithms/QueryMDWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryRemoteFile-v1.rst b/docs/source/algorithms/QueryRemoteFile-v1.rst index 91c5b712556f01ceac9e4734a98af0e7b1f7ba7e..4c53fe1220510f384334d8e1f1cdd4aa77e42e39 100644 --- a/docs/source/algorithms/QueryRemoteFile-v1.rst +++ b/docs/source/algorithms/QueryRemoteFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryRemoteFile-v2.rst b/docs/source/algorithms/QueryRemoteFile-v2.rst index 41764288088b944962e46a178fcd4db77214b487..67173a6687cfeb45d978029bec1d9252573213be 100644 --- a/docs/source/algorithms/QueryRemoteFile-v2.rst +++ b/docs/source/algorithms/QueryRemoteFile-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryRemoteJob-v1.rst b/docs/source/algorithms/QueryRemoteJob-v1.rst index b8d7c1be07c403c3c6f4c8ea61b6179b6de8ceda..44f6aa6fd59452b1cd874682488fd908b4218e4a 100644 --- a/docs/source/algorithms/QueryRemoteJob-v1.rst +++ b/docs/source/algorithms/QueryRemoteJob-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/QueryRemoteJob-v2.rst b/docs/source/algorithms/QueryRemoteJob-v2.rst index 8f017f8c4a23713c51f8e6e14541f1ed7c791cd3..f52dac82412591eca1ff142c2d1ad7ea8bb2cbfb 100644 --- a/docs/source/algorithms/QueryRemoteJob-v2.rst +++ b/docs/source/algorithms/QueryRemoteJob-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Qxy-v1.rst b/docs/source/algorithms/Qxy-v1.rst index 7a191f7970c4ba8532c049e839b82c8b1252de83..378fff955ddc5c7cae8401b905c3a1558c8d81fb 100644 --- a/docs/source/algorithms/Qxy-v1.rst +++ b/docs/source/algorithms/Qxy-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/REFLReprocess-v1.rst b/docs/source/algorithms/REFLReprocess-v1.rst deleted file mode 100644 index 3862660e27418e3f17329aa6509e6e5da795d639..0000000000000000000000000000000000000000 --- a/docs/source/algorithms/REFLReprocess-v1.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. alias:: - -.. properties:: - -Description ------------ - -Re-reduce REFL data for an entire experiment using saved parameters - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/RRFMuon-v1.rst b/docs/source/algorithms/RRFMuon-v1.rst index be04df98f4f03dc0ce66a070f6dd4357a7bad4da..1ad5d6074e5cffeb9d7b617664538d40d8813dfc 100644 --- a/docs/source/algorithms/RRFMuon-v1.rst +++ b/docs/source/algorithms/RRFMuon-v1.rst @@ -14,7 +14,7 @@ This algorithm is frequently run after making a phase quadrature transformation article by T.M. Riseman and J.H. Brewer [Hyp. Int., 65, (1990), 1107]. -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RadiusSum-v1.rst b/docs/source/algorithms/RadiusSum-v1.rst index 36b1513aa96dae57be3cfa04bb2f9291e1c69eea..9242f12d3d3c5584daec19316f9eb0278878e51b 100644 --- a/docs/source/algorithms/RadiusSum-v1.rst +++ b/docs/source/algorithms/RadiusSum-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RawFileInfo-v1.rst b/docs/source/algorithms/RawFileInfo-v1.rst index 48166101012aa1df5a191f1f4a24db585fe1c643..1d9a6904b32553d66d3b779e83b61d518f23a767 100644 --- a/docs/source/algorithms/RawFileInfo-v1.rst +++ b/docs/source/algorithms/RawFileInfo-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RayTracerTester-v1.rst b/docs/source/algorithms/RayTracerTester-v1.rst index 251ee405ed56d618367a25d0f2caaa1036cba587..9e3bbdcdb92b3133e795447a8384e7df8e606d1d 100644 --- a/docs/source/algorithms/RayTracerTester-v1.rst +++ b/docs/source/algorithms/RayTracerTester-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ReactorSANSResolution-v1.rst b/docs/source/algorithms/ReactorSANSResolution-v1.rst index d8e589d65dbe3125bd813c4fe594f77ad6e2ecd6..905752dda9f867080ef0ea58efdeaf3c59d8824d 100644 --- a/docs/source/algorithms/ReactorSANSResolution-v1.rst +++ b/docs/source/algorithms/ReactorSANSResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ReadGroupsFromFile-v1.rst b/docs/source/algorithms/ReadGroupsFromFile-v1.rst index ed1bf892686434b51b4bfe3d21f2ec907a0e9c21..1b67b1337acd1c1c36d3798c82fb9583892d5f6a 100644 --- a/docs/source/algorithms/ReadGroupsFromFile-v1.rst +++ b/docs/source/algorithms/ReadGroupsFromFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RealFFT-v1.rst b/docs/source/algorithms/RealFFT-v1.rst index f0da140e26ff8103e05294bd0dbca6ebb83d0c8c..65b63330ddc9784079b832a36bf754a077be142f 100644 --- a/docs/source/algorithms/RealFFT-v1.rst +++ b/docs/source/algorithms/RealFFT-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Rebin-v1.rst b/docs/source/algorithms/Rebin-v1.rst index 593accdcd915f07846aeb10ed543e60e5c786b4c..1da69119acfdeb25ff8b5ff0bb88a2e912f6b0fb 100644 --- a/docs/source/algorithms/Rebin-v1.rst +++ b/docs/source/algorithms/Rebin-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -14,11 +14,11 @@ defines new boundaries in intervals :math:`x_i-x_{i+1}\,`. Positive :math:`\Delta x_i\,` make constant width bins, whilst negative ones create logarithmic binning using the formula :math:`x(j+1)=x(j)(1+|\Delta x_i|)\,` - + This algorithms is useful both in data reduction, but also in remapping :ref:`ragged workspace <Ragged_Workspace>` to a regular set of bin boundaries. - + Unless the FullBinsOnly option is enabled, the bin immediately before the specified boundaries :math:`x_2`, :math:`x_3`, ... :math:`x_i` is likely to have a different width from its neighbours because there can @@ -136,7 +136,7 @@ Output: The 2nd and 3rd rebinned X values are: [ 1.5 2.25] **Example - custom two regions rebinning:** - + .. testcode:: ExHistCustom # create histogram workspace diff --git a/docs/source/algorithms/Rebin2D-v1.rst b/docs/source/algorithms/Rebin2D-v1.rst index d9efd20d2ac63482ece4e919113ffa384152e62f..dda2cdb3205dd0beb75d97adf3cdb69925504170 100644 --- a/docs/source/algorithms/Rebin2D-v1.rst +++ b/docs/source/algorithms/Rebin2D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RebinByPulseTimes-v1.rst b/docs/source/algorithms/RebinByPulseTimes-v1.rst index 827d09ab25d198a0385bd9d971e0c65b899e54e0..7ace4e765283fcbcf6b6fc0a181f69027ddb481a 100644 --- a/docs/source/algorithms/RebinByPulseTimes-v1.rst +++ b/docs/source/algorithms/RebinByPulseTimes-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RebinByTimeAtSample-v1.rst b/docs/source/algorithms/RebinByTimeAtSample-v1.rst index 166f073353ab8224ace2c198eba9e573f545847c..e01c41d77981870eaba1d318542bed58e0fc9ae1 100644 --- a/docs/source/algorithms/RebinByTimeAtSample-v1.rst +++ b/docs/source/algorithms/RebinByTimeAtSample-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RebinToWorkspace-v1.rst b/docs/source/algorithms/RebinToWorkspace-v1.rst index 400aa5a5559d1f5c42a355fa468427044249d35b..fd20ffff3a8728e8cf12bb58960b6f72979d46b1 100644 --- a/docs/source/algorithms/RebinToWorkspace-v1.rst +++ b/docs/source/algorithms/RebinToWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -13,7 +13,7 @@ Takes an input workspace and alters the binning so that all it's spectra match that of the **first spectrum** of the second workspace. This algorithm simply builds a parameter list that is passed to the :ref:`algm-Rebin` algorithm, which actually does the work. - + .. categories:: .. sourcelink:: diff --git a/docs/source/algorithms/Rebunch-v1.rst b/docs/source/algorithms/Rebunch-v1.rst index 6113649edc2e18379ee758b254e3a2736fd0531a..87dc9446d42e4aacc64a4e23e4f244f06d5ce9e5 100644 --- a/docs/source/algorithms/Rebunch-v1.rst +++ b/docs/source/algorithms/Rebunch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RecordPythonScript-v1.rst b/docs/source/algorithms/RecordPythonScript-v1.rst index b4b3c921b02d5b890f973b5c4f57b06e21d21a23..b095e41acf56b9ffbe3e963c7b8865732d9bc1e8 100644 --- a/docs/source/algorithms/RecordPythonScript-v1.rst +++ b/docs/source/algorithms/RecordPythonScript-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RefLReduction-v1.rst b/docs/source/algorithms/RefLReduction-v1.rst deleted file mode 100644 index 9a878fdd9b1fe048f9bf82dc3652f0f5d57f34a2..0000000000000000000000000000000000000000 --- a/docs/source/algorithms/RefLReduction-v1.rst +++ /dev/null @@ -1,16 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. alias:: - -.. properties:: - -Description ------------ - -Liquids Reflectometer (REFL) reduction - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/RefReduction-v1.rst b/docs/source/algorithms/RefReduction-v1.rst deleted file mode 100644 index 80dc19fc12e561f50c24dc3167dca157c1721745..0000000000000000000000000000000000000000 --- a/docs/source/algorithms/RefReduction-v1.rst +++ /dev/null @@ -1,18 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. alias:: - -.. properties:: - -Description ------------ - -Reflectivity reduction workflow. This workflow algorithm computes the -specular and off-specular reflectivity for both REFM and REFL -instruments. - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/RefRoi-v1.rst b/docs/source/algorithms/RefRoi-v1.rst index 857c87654c0c654c7be88e6ab2e5f30a16608888..d5d607ffefa86da266ad296e44a59b424aa223b7 100644 --- a/docs/source/algorithms/RefRoi-v1.rst +++ b/docs/source/algorithms/RefRoi-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RefinePowderDiffProfileSeq-v1.rst b/docs/source/algorithms/RefinePowderDiffProfileSeq-v1.rst index 187da08e14329ba1d184fdcf33b9b60cdda28cd7..a296eb204bac65b65d86b24b2ce3f3244712cb91 100644 --- a/docs/source/algorithms/RefinePowderDiffProfileSeq-v1.rst +++ b/docs/source/algorithms/RefinePowderDiffProfileSeq-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RefinePowderInstrumentParameters-v3.rst b/docs/source/algorithms/RefinePowderInstrumentParameters-v3.rst index dabb9a3335045d2417880a298ba8780e801e4bce..db10e6fa19aed7c023e26adeb9bd0f5b3420ea23 100644 --- a/docs/source/algorithms/RefinePowderInstrumentParameters-v3.rst +++ b/docs/source/algorithms/RefinePowderInstrumentParameters-v3.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -19,7 +19,7 @@ FitPowderDiffPeaks(). Introduction -============ +############ In order to do Rietveld refinement to experimental data, the diffractometer’s profile should be calibrated by the standards, such as LaB6 or Ni, with known crystal structure and lattice parameters. @@ -45,8 +45,8 @@ Final Time-of-flight is calculated as: .. math:: TOF = n_{cross} TOF_e + (1-n_{cross}) TOF_t -Formular for calculating :math:`A(d)`, :math:`B(d)`, :math:`\sigma(d)` and :math:`\gamma(d)` -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Formula for calculating :math:`A(d)`, :math:`B(d)`, :math:`\sigma(d)` and :math:`\gamma(d)` +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :math:`\alpha(d)`: @@ -104,7 +104,7 @@ where Break down the problem -====================== +###################### If we can do the single peak fitting on each single diffraction peak in a certain range, then we can divide the optimization problem into 4 sub problems for :math:`X_0`, :math:`A`, @@ -136,13 +136,13 @@ with constraint: The coefficients in this function are strongly correlated to each other. Current Implementation -====================== +###################### Only the parameters of the function for :math:`X_0` are fitted in present implementation. Refinement Algorithm -==================== +#################### Two refinement algorithms, DirectFit and MonteCarlo, are provided. @@ -171,7 +171,7 @@ In future, constaint will be considered. How to use algorithm with other algorithms -========================================== +########################################## This algorithm is designed to work with other algorithms to do Le Bail fit. The introduction can be found in the wiki page of diff --git a/docs/source/algorithms/ReflectometryReductionOne-v1.rst b/docs/source/algorithms/ReflectometryReductionOne-v1.rst deleted file mode 100644 index a39a841536b2974ca73aa2ee1859678d6339f721..0000000000000000000000000000000000000000 --- a/docs/source/algorithms/ReflectometryReductionOne-v1.rst +++ /dev/null @@ -1,248 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. alias:: - -.. properties:: - -Description ------------ - -Reduces a single TOF reflectometry run into a mod Q vs I/I0 workspace. -Performs transmission corrections. Handles both point detector and -multidetector cases. The algorithm can correct detector locations based -on an input theta value. - -Historically the work performed by this algorithm was known as the Quick -script. - -If :literal:`MonitorBackgroundWavelengthMin` and -:literal:`MonitorBackgroundWavelengthMax` are both set to :literal:`0`, then -background normalization will not be performed on the monitors. - -The properties of this algorithm should be manually selected by the user. If you -wish to use the default values (found in the Instrument Defintion File) for the -properties of this algorithm, you may want to consider using -:ref:`algm-ReflectometryReductionOneAuto`. - -:ref:`algm-ReflectometryReductionOneAuto` also performs extra processing steps -such as Background subtraction and :ref:`algm-PolarizationCorrection`. If you -want to know how these processing steps are used, please refer to the -:ref:`algm-ReflectometryReductionOneAuto` documentation. - -High-Level Workflow -------------------- - -The diagram below displays a high-level version of the algorithm workflow, -illustrating the main steps taking place in the ReflectometryReductionOne -algorithm. These individual steps are described in more detail in the next -sections. - -.. diagram:: ReflectometryReductionOne_HighLvl-v1_wkflw.dot - -Low-Level Workflow ------------------- - -Conversion to Wavelength -######################## - -The following diagram describes the steps taken in converting the input -workspace into units of wavelength and dividing its constituent detectors by -monitors. - -.. diagram:: ReflectometryReductionOne_ConvertToWavelength-v1_wkflw.dot - -The default analysis mode is *PointDetectorAnalysis*. For PointAnalysisMode the -analysis can be roughly reduced to IvsLam = DetectorWS / sum(I0) / -TransmissionWS / sum(I0). For MultiDetectorAnalysis the analysis can be roughly -reduced to IvsLam = DetectorWS / RegionOfDirectBeamWS / sum(I0) / TransmissionWS -/ sum(I0). - -Transmission Correction -####################### - -This diagram shows how the resultant workspace of the previous step is corrected -by either by provided transmission runs or by a specific correction algorithm. - -.. diagram:: ReflectometryReductionOne_TransmissionCorrection-v1_wkflw.dot - -Transmission correction is a normalization step, which may be applied to both -*PointDetectorAnalysis* and *MultiDetectorAnalysis* reduction. - -Transmission runs are expected to be in TOF. The spectra numbers in the -Transmission run workspaces must be the same as those in the Input Run -workspace. If two Transmission runs are provided then the Stitching -parameters associated with the transmission runs will also be required. -If a single Transmission run is provided, then no stitching parameters -will be needed. - -The normalization by tranmission run(s) is optional. - -The input workspace provided to the workflow in this instance is the original -:literal:`InputWorkspace` after conversion to wavelength and normalization by -monitors, as shown in the previous :literal:`Conversion To Wavelength` diagram. - -The output workspace given is not the output to the whole algorithm. Rather it -will serve as the input workspace to the :literal:`Polynomial Correction` -workflow, where further steps will be applied to it. - -Polynomial Correction -===================== - -If no Transmission runs are provided, then polynomial correction can be -performed instead. Polynomial correction is enabled by setting the -:literal:`CorrectionAlgorithm` property. If set to -:literal:`PolynomialCorrection` it runs the :ref:`algm-PolynomialCorrection` -algorithm, with this algorithms :literal:`Polynomial` property used as its -:literal:`Coefficients` property. - -If the :literal:`CorrectionAlgorithm` property is set to -:literal:`ExponentialCorrection`, then the :Ref:`algm-ExponentialCorrection` -algorithm is used, with C0 and C1 taken from the :literal:`C0` and :literal:`C1` -properties. - -Detector Position Correction -############################ - -The diagram below describes how the input workspace is then corrected by -detector positions after transmission correction. - -.. diagram:: ReflectometryReductionOne_CorrectDetectorPositions-v1_wkflw.dot - -Detector Position Correction is used for when the position of the detector -is not aligned with the reflected beamline. The correction algorithm used is -:ref:`algm-SpecularReflectionPositionCorrect-v1` which is a purely vertical -position correction. - -The detector positions in this process are corrected in terms of -:literal:`ThetaIn`. In general, the detector posistions should always be -corrected unless the :literal:`InputWorkspace` already has the detectors in the -right positions. This can be achieved by running -:literal:`MoveInstrumentComponent` before :literal:`ReflectometryReductionOne`. - -Convert To Momentum Transfer (Q) -################################ - -The last diagram describes the steps involved in converting the input workspace -from units of wavelength into momentum transfer (Q). - -.. diagram:: ReflectometryReductionOne_ConvertToMomentum-v1_wkflw.dot - -ReflectometryReductionOne contains 2 post-processing options that will be -applied to the IvsQ workspace. These two options are `Rebin` and `Scale`. - -Rebinning -========= - -To Rebin your IvsQ workspace you will have to provide values for the following -properties: `MomentumTransferMinimum`, `MomentumTransferStep` and -`MomentumTransferMaximum`. These values will be appended to each other to form -your :ref:`algm-Rebin` Params. These values correspond to your `MinimumExtent`, -`BinWidth` and `MaximumExtent` respectively. - -If you provide a positive `MomentumTransferStep` value then the algorithm will -automatically negate this value which will allow for Logarithmic Rebinning. -Alternatively, a negative `MomentumTransferStep` will result in Linear -Rebinning. More details about the Rebinning process can be found in the -documentation for :ref:`algm-Rebin`. - -If no values are provided for `MomentumTransferMinimum` and -`MomentumTransferMaximum` then the algorithm will attempt to calculate these -values by using the equations below: - - :math:`Q_{min} = 2 \, k \, sin \, \theta = \frac{4 \pi sin \theta}{\lambda_{max}}` - - :math:`Q_{max} = 2 \, k \, sin \, \theta = \frac{4 \pi sin \theta}{\lambda_{min}}` - -Where :math:`\lambda_{min}` is the minimum extent of the `IvsLambda` Workspace -and :math:`\lambda_{max}` is the maximum extent of the `IvsLambda` Workspace. - -If you have not provided a value for `MomentumTransferStep` then the algorithm -will use :ref:`algm-NRCalculateSlitResolution` to calculate this value for you. - -Scaling -======= - -To apply a scaling to the IvsQ workspace that has been produced by the -reduction, you will need to provide a value for the `ScaleFactor` property in -the algorithm. The default for this value is 1.0 and thus no scaling is applied -to the workspace. The scaling of the IvsQ workspace is performed in-place by the -:ref:`algm-Scale` algorithm and your IvsQ workspace will be set to the product -of this algorithm. - -Source Rotation -=============== - -In the workflow diagram above, after we produce the IvsLambda workspace, it may -be necessary to rotate the position of the source to match the value of -ThetaOut (:math:`\theta_f`). - -Below we see the typical experimental setup for a Reflectometry instrument. The -source direction (Beam vector) is along the horizon. This setup is defined in -the Instrument Defintion File and this instrument setup will be attached to any -workspaces associated with that instrument. When we pass the IvsLambda workspace -to :ref:`algm-ConvertUnits` to produce an IvsQ workspace, -:ref:`algm-ConvertUnits` will assume that :math:`2\theta` is the angle between -the Beam vector and the sample-to-detector vector. When we have the typical -setup seen below, :math:`2\theta` will be exactly half the value we wish it to -be. - -.. figure:: /images/CurrentExperimentSetupForReflectometry.png - :width: 650px - :height: 250px - :align: center - -We rotate the position of the Source (and therefore the Beam vector) in the -Instrument Defintion associated with the IvsLambda workspace until the condition -:math:`\theta_i = \theta_f` is satisfied. This will achieve the desired result -for :math:`2\theta` (see below for rotated source diagram). After -:ref:`algm-ConvertUnits` has produced our IvsQ workspace, we will rotate the -position of the source back to its original position so that the experimental -setup remains unchanged for other algorithms that may need to manipulate/use it. - -.. figure:: /images/RotatedExperimentSetupForReflectometry.png - :width: 650px - :height: 250px - :align: center - - -Processing Instructions -####################### - -These enable a grouping pattern on workspace indices to yield only the detectors of interest. It allows usage of the operators :literal:`,:+-` to specify or exclude specific indices or to add -spectra together. See :literal:`Grouping Pattern` from :Ref:`algm-GroupDetectors` for further details on their usage. - -Usage ------ - -**Example - Reduce a Run** - -.. testcode:: ExReflRedOneSimple - - run = Load(Filename='INTER00013460.nxs') - # Basic reduction with no transmission run - IvsQ, IvsLam, thetaOut = ReflectometryReductionOne(InputWorkspace=run, ThetaIn=0.7, I0MonitorIndex=2, ProcessingInstructions='3:4', - WavelengthMin=1.0, WavelengthMax=17.0, - MonitorBackgroundWavelengthMin=15.0, MonitorBackgroundWavelengthMax=17.0, - MonitorIntegrationWavelengthMin=4.0, MonitorIntegrationWavelengthMax=10.0, Version=1) - - print("The first four IvsLam Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsLam.readY(0)[0], IvsLam.readY(0)[1], IvsLam.readY(0)[2], IvsLam.readY(0)[3])) - print("The first four IvsQ Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsQ.readY(0)[0], IvsQ.readY(0)[1], IvsQ.readY(0)[2], IvsQ.readY(0)[3])) - print("Theta out is the same as theta in: {}".format(thetaOut)) - - -Output: - -.. testoutput:: ExReflRedOneSimple - - The first four IvsLam Y values are: [ 0.0000e+00, 0.0000e+00, 7.8118e-07, 1.9346e-06 ] - The first four IvsQ Y values are: [ 1.3845e-03, 1.9717e-03, 2.7579e-03, 4.1467e-03 ] - Theta out is the same as theta in: 0.7 - - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/ReflectometryReductionOne-v2.rst b/docs/source/algorithms/ReflectometryReductionOne-v2.rst index aa317703b2667e5494131d063a3da99d72b4cee5..fe6b4df8b6b40b36b7d15060df9f2c6a27ab2142 100644 --- a/docs/source/algorithms/ReflectometryReductionOne-v2.rst +++ b/docs/source/algorithms/ReflectometryReductionOne-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -254,10 +254,10 @@ Output: .. testoutput:: ExReflRedOneTrans - 0.4592 + 0.4597 0.4654 - 0.7278 - 1.0305 + 0.7203 + 1.0512 .. categories:: diff --git a/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst b/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst deleted file mode 100644 index de816114e3f2feb392fa4ff9da17df161f9764eb..0000000000000000000000000000000000000000 --- a/docs/source/algorithms/ReflectometryReductionOneAuto-v1.rst +++ /dev/null @@ -1,166 +0,0 @@ -.. algorithm:: - -.. summary:: - -.. alias:: - -.. properties:: - -Description ------------ - -Facade over :ref:`algm-ReflectometryReductionOne`. - -Pulls numeric parameters out of the instrument parameters where possible. You can override any of these automatically applied defaults by providing your own value for the input. - -See :ref:`algm-ReflectometryReductionOne` for more information on the wrapped algorithm. - -ProcessingInstructions -###################### - -If ProcessingInstructions is not set its value is inferred from other properties: - -* If AnalysisMode = PointDetectorAnalaysis and PointDetectorStart = PointDetectorStop then the spectrum specified by PointDetectorStart is used. -* If AnalysisMode = PointDetectorAnalaysis and PointDetectorStart ≠PointDetectorStop then the sum of the spectra from PointDetectorStart to PointDetectorStop is used. -* If AnalysisMode = MultiDetectorAnalaysis then all of the spectra from MultiDetectorStart onwards are used. - -Note, the ProcessingInstructions are workspace indicies, not detector IDs. The first few workspaces may correspond to monitors, rather than detectors of interest. -For the syntax of this property, see :ref:`algm-GroupDetectors`. - -Workflow for WorkspaceGroups -############################ - -If a WorkspaceGroup is provided to ReflectometryReductionOneAuto, it will follow the steps shown in the diagram below to produce its output. - -.. diagram:: ReflectometryReductionOneAuto-v1-Groups_wkflw.dot - -Workflow for Polarization Correction -#################################### - -If polarization correction is enabled, it is performed as an additional step once the main processing has completed. -The following diagram shows how the :ref:`algm-PolarizationCorrection` algorithm is used. - -.. diagram:: ReflectometryReductionOneAuto-v1-PolarizationCorrection_wkflw.dot - -Polynomial Correction -##################### - -If no Transmission runs are provided, then polynomial correction can be -performed instead. Polynomial correction is enabled by setting the -:literal:`CorrectionAlgorithm` property. - -If set to :literal:`AutoDetect`, it looks at the instrument -parameters for the :literal:`correction` parameter. If it is set to -:literal:`polynomial`, then polynomial correction is performed using the -:ref:`algm-PolynomialCorrection` algorithm, with the polynomial string taken -from the instrument's :literal:`polynomial` parameter. If the -:literal:`correction` parameter is set to :literal:`exponential` instead, then -the :Ref:`algm-ExponentialCorrection` algorithm is used, with C0 and C1 taken -from the instrument parameters, :literal:`C0` and :literal:`C1`. - -These can be specified manually by setting the :literal:`CorrectionAlgorithm`, -:literal:`Polynomial`, :literal:`C0`, and :literal:`C1` properties accordingly. - -Usage ------ - -**Example - Reduce a Run** - -.. testcode:: ExReflRedOneAutoSimple - - run = Load(Filename='INTER00013460.nxs') - # Basic reduction with no transmission run - IvsQ, IvsLam, thetaOut = ReflectometryReductionOneAuto(InputWorkspace=run, ThetaIn=0.7, Version=1) - - print("The first four IvsLam Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsLam.readY(0)[0], IvsLam.readY(0)[1], IvsLam.readY(0)[2], IvsLam.readY(0)[3])) - print("The first four IvsQ Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsQ.readY(0)[0], IvsQ.readY(0)[1], IvsQ.readY(0)[2], IvsQ.readY(0)[3])) - print("Theta out is the same as theta in: {}".format(thetaOut)) - -Output: - -.. testoutput:: ExReflRedOneAutoSimple - - The first four IvsLam Y values are: [ 5.3860e-06, 9.3330e-06, 6.9796e-06, 6.5687e-06 ] - The first four IvsQ Y values are: [ 1.3648e-03, 1.9490e-03, 2.7277e-03, 4.0995e-03 ] - Theta out is the same as theta in: 0.7 - -**Example - Reduce a Run with a transmission run** - -.. testcode:: ExReflRedOneAutoTrans - - run = Load(Filename='INTER00013460.nxs') - trans = Load(Filename='INTER00013463.nxs') - # Basic reduction with a transmission run - IvsQ, IvsLam, thetaOut = ReflectometryReductionOneAuto(InputWorkspace=run, FirstTransmissionRun=trans, ThetaIn=0.7, Version=1) - - print("The first four IvsLam Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsLam.readY(0)[0], IvsLam.readY(0)[1], IvsLam.readY(0)[2], IvsLam.readY(0)[3])) - print("The first four IvsQ Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsQ.readY(0)[0], IvsQ.readY(0)[1], IvsQ.readY(0)[2], IvsQ.readY(0)[3])) - print("Theta out is the same as theta in: {}".format(thetaOut)) - -Output: - -.. testoutput:: ExReflRedOneAutoTrans - - The first four IvsLam Y values are: [ 3.2705e-05, 5.5450e-05, 3.9630e-05, 3.5770e-05 ] - The first four IvsQ Y values are: [ 9.3930e-01, 1.3251e+00, 1.2766e+00, 1.1977e+00 ] - Theta out is the same as theta in: 0.7 - -**Example - Reduce a Run overloading default parameters** - -.. testcode:: ExReflRedOneAutoOverload - - run = Load(Filename='INTER00013460.nxs') - # Reduction overriding the default values for MonitorBackgroundWavelengthMin and MonitorBackgroundWavelengthMax which would otherwise be retirieved from the workspace - IvsQ, IvsLam, thetaOut = ReflectometryReductionOneAuto(InputWorkspace=run, ThetaIn=0.7, MonitorBackgroundWavelengthMin=0.0, MonitorBackgroundWavelengthMax=1.0, Version=1) - - print("The first four IvsLam Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsLam.readY(0)[0], IvsLam.readY(0)[1], IvsLam.readY(0)[2], IvsLam.readY(0)[3])) - print("The first four IvsQ Y values are: [ {:.4e}, {:.4e}, {:.4e}, {:.4e} ]".format( - IvsQ.readY(0)[0], IvsQ.readY(0)[1], IvsQ.readY(0)[2], IvsQ.readY(0)[3])) - print("Theta out is the same as theta in: {}".format(thetaOut)) - -Output: - -.. testoutput:: ExReflRedOneAutoOverload - - The first four IvsLam Y values are: [ 5.3868e-06, 9.3344e-06, 6.9807e-06, 6.5696e-06 ] - The first four IvsQ Y values are: [ 1.3650e-03, 1.9493e-03, 2.7281e-03, 4.1001e-03 ] - Theta out is the same as theta in: 0.7 - -**Example - Polynomial correction** - -.. testcode:: ExReflRedOneAutoPoly - - run = Load(Filename='INTER00013460.nxs') - # Set up some paramters, allowing the algorithm to automatically detect the correction to use - SetInstrumentParameter(run, "correction", Value="polynomial") - SetInstrumentParameter(run, "polynomial", Value="0,0.5,1,2,3") - - IvsQ, IvsLam, thetaOut = ReflectometryReductionOneAuto(InputWorkspace=run, ThetaIn=0.7, Version=1) - - def findByName(histories, name): - return next(x for x in histories if x.name() == name) - - # Find the PolynomialCorrection entry in the workspace's history - algHist = IvsLam.getHistory() - refRedOneAutoHist = findByName(algHist.getAlgorithmHistories(), "ReflectometryReductionOneAuto") - refRedOneHist = findByName(refRedOneAutoHist.getChildHistories(), "ReflectometryReductionOne") - polyCorHist = findByName(refRedOneHist.getChildHistories(), "PolynomialCorrection") - - coefProp = findByName(polyCorHist.getProperties(), "Coefficients") - - print("Coefficients: '{}'".format(coefProp.value())) - -Output: - -.. testoutput:: ExReflRedOneAutoPoly - - Coefficients: '0,0.5,1,2,3' - -.. categories:: - -.. sourcelink:: diff --git a/docs/source/algorithms/ReflectometryReductionOneAuto-v2.rst b/docs/source/algorithms/ReflectometryReductionOneAuto-v2.rst index 2bb6d64880052340b85f7d877f04c954f744278d..4258f0d63cb608753b0818403fce8e1ca991567d 100644 --- a/docs/source/algorithms/ReflectometryReductionOneAuto-v2.rst +++ b/docs/source/algorithms/ReflectometryReductionOneAuto-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -43,7 +43,7 @@ The rest of the input properties are not inferred from the parameter file, and m property that allows users to specify a region of direct beam that will be used to normalize the detector signal. The region of direct beam is specified by workspace indices. For instance, :literal:`RegionOfDirectBeam='2-3'` means that spectra with workspace indices :literal:`2` and :literal:`3` will be summed and the resulting -workspace will be used as the direct beam workspace. +workspace will be used as the direct beam workspace. Transmission corrections can be optionally applied by providing either one or two transmission runs or polynomial corrections. Polynomial correction is enabled by setting the @@ -198,10 +198,10 @@ Output: 0.00441 0.00462 - 0.64241 - 0.41453 + 0.64231 + 0.41456 0.51029 - 0.52240 + 0.52241 .. categories:: diff --git a/docs/source/algorithms/Regroup-v1.rst b/docs/source/algorithms/Regroup-v1.rst index 0a3cf86c5396df7c4b80957efdd0e0b093d3549e..daf32889ffcb4f835552c1dba037990f9c9738d7 100644 --- a/docs/source/algorithms/Regroup-v1.rst +++ b/docs/source/algorithms/Regroup-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveBackground-v1.rst b/docs/source/algorithms/RemoveBackground-v1.rst index 87dd338d4d989631b31abb37a640ef084cd658c0..c4b3942aa40a35f987ee32bc7c0ea1f388835bc8 100644 --- a/docs/source/algorithms/RemoveBackground-v1.rst +++ b/docs/source/algorithms/RemoveBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveBins-v1.rst b/docs/source/algorithms/RemoveBins-v1.rst index ec8d56cea2f4838ec3b07035a7d201e136bf3b2b..4953808f4a3ad6f89b56bf31fa27032b363360c2 100644 --- a/docs/source/algorithms/RemoveBins-v1.rst +++ b/docs/source/algorithms/RemoveBins-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveExpDecay-v1.rst b/docs/source/algorithms/RemoveExpDecay-v1.rst index 97985ff7e3a27d8c79c0676470717b224753fbf6..4edaffbf4f45bf1bd6a4d6cc4387e8ceb8a45b43 100644 --- a/docs/source/algorithms/RemoveExpDecay-v1.rst +++ b/docs/source/algorithms/RemoveExpDecay-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveLogs-v1.rst b/docs/source/algorithms/RemoveLogs-v1.rst index de038a5308a374a5f19152170e56af453b902470..4944a4e094e55849e413d13d305911cd19dd847d 100644 --- a/docs/source/algorithms/RemoveLogs-v1.rst +++ b/docs/source/algorithms/RemoveLogs-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveLowResTOF-v1.rst b/docs/source/algorithms/RemoveLowResTOF-v1.rst index 9b4d0bdaafe5b0dccdb55dd878b53340d74b6f73..34a1c2c83c21000025d814bd65a2f95ef0940d65 100644 --- a/docs/source/algorithms/RemoveLowResTOF-v1.rst +++ b/docs/source/algorithms/RemoveLowResTOF-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveMaskedSpectra-v1.rst b/docs/source/algorithms/RemoveMaskedSpectra-v1.rst index eae7f4c961ca3ad2b743ec7a7d32310dbcb1dd9c..cb92f814c2db35077e4fc1631f241b5d029fcc99 100644 --- a/docs/source/algorithms/RemoveMaskedSpectra-v1.rst +++ b/docs/source/algorithms/RemoveMaskedSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemovePromptPulse-v1.rst b/docs/source/algorithms/RemovePromptPulse-v1.rst index 8f41765299f5d1051d215c37f6da139af32b0be2..172346cc8a6578fb4abadcabfb8fdae7108fa62d 100644 --- a/docs/source/algorithms/RemovePromptPulse-v1.rst +++ b/docs/source/algorithms/RemovePromptPulse-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst b/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst index 0c29f28a6d7884a1f0b85e035f0124c18790d431..afe1bcfe38d33e0917af9933dae402094769b6fe 100644 --- a/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst +++ b/docs/source/algorithms/RemoveWorkspaceHistory-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RenameLog-v1.rst b/docs/source/algorithms/RenameLog-v1.rst index 192fb28465e323512696c48e01b5cf80017a861b..83e74bcee0f7ff96b9aeead13d2228998c97bb42 100644 --- a/docs/source/algorithms/RenameLog-v1.rst +++ b/docs/source/algorithms/RenameLog-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RenameWorkspace-v1.rst b/docs/source/algorithms/RenameWorkspace-v1.rst index 0eeb092d51ce407fb223de2bc0527dedb3ac2549..c5d6e2d95e22849caab515882e7ea3478c10317c 100644 --- a/docs/source/algorithms/RenameWorkspace-v1.rst +++ b/docs/source/algorithms/RenameWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RenameWorkspaces-v1.rst b/docs/source/algorithms/RenameWorkspaces-v1.rst index 002feebc6e77d26f6d9e77eafd8580cefa955555..c1fc0899d85cfc4f49769cbf187bf70aa497414d 100644 --- a/docs/source/algorithms/RenameWorkspaces-v1.rst +++ b/docs/source/algorithms/RenameWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ReplaceSpecialValues-v1.rst b/docs/source/algorithms/ReplaceSpecialValues-v1.rst index d2015400deaf9e238bb13e902e38210fc6e4ed09..596da224c831c3f3afc0878baedf9d77a1aa7338 100644 --- a/docs/source/algorithms/ReplaceSpecialValues-v1.rst +++ b/docs/source/algorithms/ReplaceSpecialValues-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ReplicateMD-v1.rst b/docs/source/algorithms/ReplicateMD-v1.rst index ff6ac463e020cb8f13e143f22db32cdeafa82714..46b5d35df5be0e6335508dc7e649430109a843b5 100644 --- a/docs/source/algorithms/ReplicateMD-v1.rst +++ b/docs/source/algorithms/ReplicateMD-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ResNorm-v1.rst b/docs/source/algorithms/ResNorm-v1.rst index f611b50a596e8c5e703f36ca30c52ec2a65cf9d1..22d14ef8272e71d66803acab8e07bd7e37045652 100644 --- a/docs/source/algorithms/ResNorm-v1.rst +++ b/docs/source/algorithms/ResNorm-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ResNorm-v2.rst b/docs/source/algorithms/ResNorm-v2.rst index baa4ed715c282a51af242ecb6f0aab73bc6e6912..fc31d42f50819190480450dbe462a923671183f4 100644 --- a/docs/source/algorithms/ResNorm-v2.rst +++ b/docs/source/algorithms/ResNorm-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ResampleX-v1.rst b/docs/source/algorithms/ResampleX-v1.rst index 96b4bbf0c952550b6afb780c66ad182ae7e24193..eb4766d503d56f4690ec6ac1937d86cb813c97a7 100644 --- a/docs/source/algorithms/ResampleX-v1.rst +++ b/docs/source/algorithms/ResampleX-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ResetNegatives-v1.rst b/docs/source/algorithms/ResetNegatives-v1.rst index df5ea7243cd50554d91eacc3ec1722fc23d9086b..f026d6ba210d144c16b2ece9b13e0b80cc66e1b2 100644 --- a/docs/source/algorithms/ResetNegatives-v1.rst +++ b/docs/source/algorithms/ResetNegatives-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ResizeRectangularDetector-v1.rst b/docs/source/algorithms/ResizeRectangularDetector-v1.rst index 12a4ea95279462099b6e65ff8cc6baf7dfb13d1c..57bcc563f8e6f7ec81e96785e5b5e4fc4690e73e 100644 --- a/docs/source/algorithms/ResizeRectangularDetector-v1.rst +++ b/docs/source/algorithms/ResizeRectangularDetector-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RetrieveRunInfo-v1.rst b/docs/source/algorithms/RetrieveRunInfo-v1.rst index 74efd6c926c4347380cdf53ed88fdf2a5c0d9337..a15c206b9eb9dcae0549999fbb144b4d36ca72d7 100644 --- a/docs/source/algorithms/RetrieveRunInfo-v1.rst +++ b/docs/source/algorithms/RetrieveRunInfo-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RingProfile-v1.rst b/docs/source/algorithms/RingProfile-v1.rst index 565d0a4f98ae925f55682111c109e10ab3f91d90..6128ab0c3d49d747f8149b12574ada228be49bd1 100644 --- a/docs/source/algorithms/RingProfile-v1.rst +++ b/docs/source/algorithms/RingProfile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RotateInstrumentComponent-v1.rst b/docs/source/algorithms/RotateInstrumentComponent-v1.rst index ec0fba77cb83db0e26ca9ef723181b015f78b8e4..10b3d82729e5a7bd199a7c0d001b448b8345c30e 100644 --- a/docs/source/algorithms/RotateInstrumentComponent-v1.rst +++ b/docs/source/algorithms/RotateInstrumentComponent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RotateSource-v1.rst b/docs/source/algorithms/RotateSource-v1.rst index a076165b66242322cdf663c744f54b1734fa2c49..3c4fd67043668efaf05672e7591f4154c6cc735f 100644 --- a/docs/source/algorithms/RotateSource-v1.rst +++ b/docs/source/algorithms/RotateSource-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/RunPythonScript-v1.rst b/docs/source/algorithms/RunPythonScript-v1.rst index 3ef644b912c8a202c172c737be8505b57580888e..82c50218b7d9125ed68b74dd95ab34bb71ea588a 100644 --- a/docs/source/algorithms/RunPythonScript-v1.rst +++ b/docs/source/algorithms/RunPythonScript-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSAbsoluteScale-v1.rst b/docs/source/algorithms/SANSAbsoluteScale-v1.rst index 8f639082cdb5709eca542e668a00f1cd62b796d0..dfb8782b7d0bef92589442ecf5668dbe213832d7 100644 --- a/docs/source/algorithms/SANSAbsoluteScale-v1.rst +++ b/docs/source/algorithms/SANSAbsoluteScale-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSAzimuthalAverage1D-v1.rst b/docs/source/algorithms/SANSAzimuthalAverage1D-v1.rst index 351c5c2bc179e2886681cfcf654adff935736fcd..d42709129706e39201f9effece408bc326f02f01 100644 --- a/docs/source/algorithms/SANSAzimuthalAverage1D-v1.rst +++ b/docs/source/algorithms/SANSAzimuthalAverage1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSBeamFinder-v1.rst b/docs/source/algorithms/SANSBeamFinder-v1.rst index 336706fff43f7304aa711b76bc32d3dd995d283f..985aaac9c556170a6731798515f409edca6a151d 100644 --- a/docs/source/algorithms/SANSBeamFinder-v1.rst +++ b/docs/source/algorithms/SANSBeamFinder-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst b/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst index 28f5a224afd08f4faa4cbb02e8fa76aec149ab9f..89fa891a0efc74e983d71c0fb282e90106679d19 100644 --- a/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst +++ b/docs/source/algorithms/SANSBeamFluxCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSBeamSpreaderTransmission-v1.rst b/docs/source/algorithms/SANSBeamSpreaderTransmission-v1.rst index f5ec4f3ea21189d46b90c06e1ee0f065f4df4be9..7ca608d099c251d4ae109d356d3e2e546ad8d823 100644 --- a/docs/source/algorithms/SANSBeamSpreaderTransmission-v1.rst +++ b/docs/source/algorithms/SANSBeamSpreaderTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSCalculateTransmission-v1.rst b/docs/source/algorithms/SANSCalculateTransmission-v1.rst index 680e22aa1a6282936bfa9854bee92e304836846a..a2a195773ab6875e6ecc9a7a9198692ed194e897 100644 --- a/docs/source/algorithms/SANSCalculateTransmission-v1.rst +++ b/docs/source/algorithms/SANSCalculateTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSConvertToQ-v1.rst b/docs/source/algorithms/SANSConvertToQ-v1.rst index ae5eaf71e1d9a01b663ecd1191b7ebf0530937c6..50f3a9cb382dfd35efb80265dd939364a2a3966b 100644 --- a/docs/source/algorithms/SANSConvertToQ-v1.rst +++ b/docs/source/algorithms/SANSConvertToQ-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSConvertToWavelength-v1.rst b/docs/source/algorithms/SANSConvertToWavelength-v1.rst index e1809d3c9ead04bfe71e1976d43dd34a1b821849..8983cd04e78e4dbf9c347bf58d7431ab486d90c8 100644 --- a/docs/source/algorithms/SANSConvertToWavelength-v1.rst +++ b/docs/source/algorithms/SANSConvertToWavelength-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSConvertToWavelengthAndRebin-v1.rst b/docs/source/algorithms/SANSConvertToWavelengthAndRebin-v1.rst index 3dc3f2e2dad2263774072c71bb729037a63abc05..e4e63b6faf3dd1a7a4cc92c9f320b514e94be2a3 100644 --- a/docs/source/algorithms/SANSConvertToWavelengthAndRebin-v1.rst +++ b/docs/source/algorithms/SANSConvertToWavelengthAndRebin-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSCreateAdjustmentWorkspaces-v1.rst b/docs/source/algorithms/SANSCreateAdjustmentWorkspaces-v1.rst index d002ddc8f2b1cb6a7fc42930c25e309733ac52e4..5f44dc352006f555c87b01c1c34ee61e01fe462c 100644 --- a/docs/source/algorithms/SANSCreateAdjustmentWorkspaces-v1.rst +++ b/docs/source/algorithms/SANSCreateAdjustmentWorkspaces-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSCreateWavelengthAndPixelAdjustment-v1.rst b/docs/source/algorithms/SANSCreateWavelengthAndPixelAdjustment-v1.rst index 8e7a78335a976f6b86b820708e10ce8766577597..361a34ed1b9bd0f06838d442bc06cbb750049987 100644 --- a/docs/source/algorithms/SANSCreateWavelengthAndPixelAdjustment-v1.rst +++ b/docs/source/algorithms/SANSCreateWavelengthAndPixelAdjustment-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSCrop-v1.rst b/docs/source/algorithms/SANSCrop-v1.rst index 340047d864844ae6308053849a92d1c5169c9de2..f85e7c495262bb5bbf113019287f54ec52a82eda 100644 --- a/docs/source/algorithms/SANSCrop-v1.rst +++ b/docs/source/algorithms/SANSCrop-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSDarkRunBackgroundCorrection-v1.rst b/docs/source/algorithms/SANSDarkRunBackgroundCorrection-v1.rst index e047601d93a1e7a8d788f44a9086971ad25d4cbd..44245466bb056f4b1efb6dccad0ccca4dae1d509 100644 --- a/docs/source/algorithms/SANSDarkRunBackgroundCorrection-v1.rst +++ b/docs/source/algorithms/SANSDarkRunBackgroundCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSDirectBeamTransmission-v1.rst b/docs/source/algorithms/SANSDirectBeamTransmission-v1.rst index 9e860bf4b112570a6b21757b9d2c1f36081f67c5..dd4b153d066ebd8b52844afca84ad3cdbf01c396 100644 --- a/docs/source/algorithms/SANSDirectBeamTransmission-v1.rst +++ b/docs/source/algorithms/SANSDirectBeamTransmission-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSFitShiftScale-v1.rst b/docs/source/algorithms/SANSFitShiftScale-v1.rst index 63dbabb1a39d8b5b63edb2d94bacfaf19f87702f..9456909f7fa01bca8772c8744a74a6fbf6169405 100644 --- a/docs/source/algorithms/SANSFitShiftScale-v1.rst +++ b/docs/source/algorithms/SANSFitShiftScale-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSLoad-v1.rst b/docs/source/algorithms/SANSLoad-v1.rst index 1ce6490e87c835ff8159f36d00d5bc778efba538..67dffa65f4c93a739b04f2c239fa1a641510bd8e 100644 --- a/docs/source/algorithms/SANSLoad-v1.rst +++ b/docs/source/algorithms/SANSLoad-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSMask-v1.rst b/docs/source/algorithms/SANSMask-v1.rst index 54678ab58066c2228921c440bd8b6ec2d31ffcbf..1456c2085b483517d815a8814a459d0ab0b16ac7 100644 --- a/docs/source/algorithms/SANSMask-v1.rst +++ b/docs/source/algorithms/SANSMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSMaskWorkspace-v1.rst b/docs/source/algorithms/SANSMaskWorkspace-v1.rst index 8ab90994988c0d48995a5022478c53d38399ad79..910cf7f13423d4a757b73461e42e0e11932688a8 100644 --- a/docs/source/algorithms/SANSMaskWorkspace-v1.rst +++ b/docs/source/algorithms/SANSMaskWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSMove-v1.rst b/docs/source/algorithms/SANSMove-v1.rst index f9961d61393e7c0e11e16eb4fa67420f8a14fa2d..9fd885cd2fbb6dde110987965c2d52d97422b604 100644 --- a/docs/source/algorithms/SANSMove-v1.rst +++ b/docs/source/algorithms/SANSMove-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSNormalizeToMonitor-v1.rst b/docs/source/algorithms/SANSNormalizeToMonitor-v1.rst index 1ae60263d7abb455e1c319b2152f72e618f4678b..6428517cdce5f14ddff7e271ec641c4c82aa67cf 100644 --- a/docs/source/algorithms/SANSNormalizeToMonitor-v1.rst +++ b/docs/source/algorithms/SANSNormalizeToMonitor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSReduction-v1.rst b/docs/source/algorithms/SANSReduction-v1.rst index 572972a1d9729257766f2ca59ba113f9ad1e4bf8..b971806dd524ed6c8c8ef8bc487b2044eac097aa 100644 --- a/docs/source/algorithms/SANSReduction-v1.rst +++ b/docs/source/algorithms/SANSReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSSave-v1.rst b/docs/source/algorithms/SANSSave-v1.rst index 2c2cd936453e71d2143c9cd083f54a247c858688..3bb80b67177feb04ea435e91290576e7f7a1f48f 100644 --- a/docs/source/algorithms/SANSSave-v1.rst +++ b/docs/source/algorithms/SANSSave-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSScale-v1.rst b/docs/source/algorithms/SANSScale-v1.rst index d02b6ea156e3a4226c96e3a82cee4e0e9126a5bf..461a0fe494038b13a01b5c4089542f1851faa4af 100644 --- a/docs/source/algorithms/SANSScale-v1.rst +++ b/docs/source/algorithms/SANSScale-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSSensitivityCorrection-v1.rst b/docs/source/algorithms/SANSSensitivityCorrection-v1.rst index 0281a60b75eccb30f66a8a62a78a88b810acd21d..9b9381673ca60278e0260eab212564bc7f6e460f 100644 --- a/docs/source/algorithms/SANSSensitivityCorrection-v1.rst +++ b/docs/source/algorithms/SANSSensitivityCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSSliceEvent-v1.rst b/docs/source/algorithms/SANSSliceEvent-v1.rst index 3016309f4a6cbe39ab0c7be9738f0c6d980528df..77aad4d01d187986bed772ace25177d1cea50f73 100644 --- a/docs/source/algorithms/SANSSliceEvent-v1.rst +++ b/docs/source/algorithms/SANSSliceEvent-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSSolidAngleCorrection-v1.rst b/docs/source/algorithms/SANSSolidAngleCorrection-v1.rst index 2cd96afadf8f21489dc0cdb860cefe6cf3162598..ad5c4cebaa0d801cd7177d1c5584aae8e36ddd2e 100644 --- a/docs/source/algorithms/SANSSolidAngleCorrection-v1.rst +++ b/docs/source/algorithms/SANSSolidAngleCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSStitch-v1.rst b/docs/source/algorithms/SANSStitch-v1.rst index 938dd4683f8a5cd80210999d4f7effe6a0a11b23..9b20f09d4412a5f503bc02f60cb7622bd3d6d272 100644 --- a/docs/source/algorithms/SANSStitch-v1.rst +++ b/docs/source/algorithms/SANSStitch-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSSubtract-v1.rst b/docs/source/algorithms/SANSSubtract-v1.rst index b74a65c7042ff7726a6905826e3951a40b242d38..22674d01c9c4767a15f566cdded483fa81ee050d 100644 --- a/docs/source/algorithms/SANSSubtract-v1.rst +++ b/docs/source/algorithms/SANSSubtract-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SANSWideAngleCorrection-v1.rst b/docs/source/algorithms/SANSWideAngleCorrection-v1.rst index b3e6aac35bd809d66458ec5290a5c6412da4fd72..f2fd5aa11cdad04d2235637a7298f26b2519b5e0 100644 --- a/docs/source/algorithms/SANSWideAngleCorrection-v1.rst +++ b/docs/source/algorithms/SANSWideAngleCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SCDCalibratePanels-v1.rst b/docs/source/algorithms/SCDCalibratePanels-v1.rst index 43dac886c2461c010316d36bec457da1facaccf4..c07c43128af31621d822eed17e6197bfcbb5863f 100644 --- a/docs/source/algorithms/SCDCalibratePanels-v1.rst +++ b/docs/source/algorithms/SCDCalibratePanels-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -37,7 +37,7 @@ The panels and packs' parameters are optimized in parallel. An option is available to adjust the panel widths and heights for Rectangular Detectors in a second iteration with all the other parameters fixed. OUTPUT workspaces and files: -============================ +############################ 1) The results are saved to an ISAW-like DetCal file and optionally in an xml file that can be used with the :ref:`LoadParameterFile <algm-LoadParameterFile>` algorithm. diff --git a/docs/source/algorithms/SNAPReduce-v1.rst b/docs/source/algorithms/SNAPReduce-v1.rst index 7d79a441b31246feba4be7aa23ab6d68e65f3a07..3923b00263443a2feb5cd289db53dad3897287bc 100644 --- a/docs/source/algorithms/SNAPReduce-v1.rst +++ b/docs/source/algorithms/SNAPReduce-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SNSPowderReduction-v1.rst b/docs/source/algorithms/SNSPowderReduction-v1.rst index c4cfe68c4f843ba76fa891c33c0561a7372607ed..5ce240037e53fe715998e25108ce92923d6c756d 100644 --- a/docs/source/algorithms/SNSPowderReduction-v1.rst +++ b/docs/source/algorithms/SNSPowderReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SassenaFFT-v1.rst b/docs/source/algorithms/SassenaFFT-v1.rst index edcc923c834273e77e3020d5cf62ebf541c68889..910dcc900dfb4ae363b1d8a9031fbdc136009515 100644 --- a/docs/source/algorithms/SassenaFFT-v1.rst +++ b/docs/source/algorithms/SassenaFFT-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveANSTOAscii-v1.rst b/docs/source/algorithms/SaveANSTOAscii-v1.rst index 3f7e6cf70bb7034cd7cec4f62b91e14d97a7d6f7..b56cc467146ef84f35ca2319af374cc6067fb187 100644 --- a/docs/source/algorithms/SaveANSTOAscii-v1.rst +++ b/docs/source/algorithms/SaveANSTOAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveAscii-v1.rst b/docs/source/algorithms/SaveAscii-v1.rst index c7c417429d5c5ff11d8c2e1ff5195e2612d96348..2aa848631a306eaa4a2fcbb544e883bb742d22f7 100644 --- a/docs/source/algorithms/SaveAscii-v1.rst +++ b/docs/source/algorithms/SaveAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveAscii-v2.rst b/docs/source/algorithms/SaveAscii-v2.rst index a03c8dc8ffeaa666e2635a5cbf39a0efa063a718..a35e60f03bf289130b86ec3e87ce427584b81e71 100644 --- a/docs/source/algorithms/SaveAscii-v2.rst +++ b/docs/source/algorithms/SaveAscii-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveCSV-v1.rst b/docs/source/algorithms/SaveCSV-v1.rst index 627b3ca39867c205293d3cdb3348505487ecf2ba..43c7a7253f02a5842d408d5b1e94e71823eba75a 100644 --- a/docs/source/algorithms/SaveCSV-v1.rst +++ b/docs/source/algorithms/SaveCSV-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveCalFile-v1.rst b/docs/source/algorithms/SaveCalFile-v1.rst index e2e9171111bedd74aef6a602065c1ba4a6bfbf1e..5efebfccc2b97f5ec4e369422d12f647ad04a8e0 100644 --- a/docs/source/algorithms/SaveCalFile-v1.rst +++ b/docs/source/algorithms/SaveCalFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveCanSAS1D-v1.rst b/docs/source/algorithms/SaveCanSAS1D-v1.rst index e13fe9d5b5a3b51123f940ad6bb235a4b73f0550..016d4daafd22645023f0cfb207f19d24d9c45608 100644 --- a/docs/source/algorithms/SaveCanSAS1D-v1.rst +++ b/docs/source/algorithms/SaveCanSAS1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveCanSAS1D-v2.rst b/docs/source/algorithms/SaveCanSAS1D-v2.rst index e704f271dc33bff89348da252643b4c5f077407e..ed4ff014e3bb53d3c7e92d9bb1f40391cf782fb4 100644 --- a/docs/source/algorithms/SaveCanSAS1D-v2.rst +++ b/docs/source/algorithms/SaveCanSAS1D-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveDaveGrp-v1.rst b/docs/source/algorithms/SaveDaveGrp-v1.rst index a2267c636e00347f40723b1b66dacda2ff40067c..40ce0af178b2e78ef9ad8a1cb1cef9e2feb17381 100644 --- a/docs/source/algorithms/SaveDaveGrp-v1.rst +++ b/docs/source/algorithms/SaveDaveGrp-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveDetectorsGrouping-v1.rst b/docs/source/algorithms/SaveDetectorsGrouping-v1.rst index 5f356aca0f5c49dc66806023b2fbc2c1a89f8e9a..221ec51d2efd096f2ed9ac2c517a268bc06b736d 100644 --- a/docs/source/algorithms/SaveDetectorsGrouping-v1.rst +++ b/docs/source/algorithms/SaveDetectorsGrouping-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveDiffCal-v1.rst b/docs/source/algorithms/SaveDiffCal-v1.rst index fa6f577ccbee2fda17d92538d9a919a33210893d..a2ebc766f3da895fc275607b4940ac513be865b1 100644 --- a/docs/source/algorithms/SaveDiffCal-v1.rst +++ b/docs/source/algorithms/SaveDiffCal-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveDiffFittingAscii-v1.rst b/docs/source/algorithms/SaveDiffFittingAscii-v1.rst index 969d9245746f2c2debd61237d08ba1ac8400d45e..5997581c202f7559dffbe88d28ee17b8047d2821 100644 --- a/docs/source/algorithms/SaveDiffFittingAscii-v1.rst +++ b/docs/source/algorithms/SaveDiffFittingAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveDspacemap-v1.rst b/docs/source/algorithms/SaveDspacemap-v1.rst index 2ff397771fb27149fcbbcb3942d1d05300a72337..d49f557541d14a42800075307e6cef0b2f4f8a16 100644 --- a/docs/source/algorithms/SaveDspacemap-v1.rst +++ b/docs/source/algorithms/SaveDspacemap-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveFITS-v1.rst b/docs/source/algorithms/SaveFITS-v1.rst index 9ab62318637c39ac24c96c0f9864f78ecd65e64e..54337346cabd8059ccfd2d73be5fa56c417ec390 100644 --- a/docs/source/algorithms/SaveFITS-v1.rst +++ b/docs/source/algorithms/SaveFITS-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveFocusedXYE-v1.rst b/docs/source/algorithms/SaveFocusedXYE-v1.rst index 53a1c4186d35f31ba612daa4260091bf7629be99..d654cdfac33fdc9460d49b87f0ca3927d4450b4e 100644 --- a/docs/source/algorithms/SaveFocusedXYE-v1.rst +++ b/docs/source/algorithms/SaveFocusedXYE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveFullprofResolution-v1.rst b/docs/source/algorithms/SaveFullprofResolution-v1.rst index 621a9cc84bc86d2519290c2fec722ee3bd8d3cc9..5f4203d5af4dd7954abaa2b018120edf134764a1 100644 --- a/docs/source/algorithms/SaveFullprofResolution-v1.rst +++ b/docs/source/algorithms/SaveFullprofResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveGSASInstrumentFile-v1.rst b/docs/source/algorithms/SaveGSASInstrumentFile-v1.rst index f2690b6d6e39a72d8ca68dc90c61e86bf4a0910a..1b44511f1ab418ea2c6eeb388e2b7104e5d7feeb 100644 --- a/docs/source/algorithms/SaveGSASInstrumentFile-v1.rst +++ b/docs/source/algorithms/SaveGSASInstrumentFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveGSS-v1.rst b/docs/source/algorithms/SaveGSS-v1.rst index b94f8acfcaa2bfe24b2954433c9f11b2b11cbd90..c6d2a2c0f8deb8710a184c42dba34026918c0952 100644 --- a/docs/source/algorithms/SaveGSS-v1.rst +++ b/docs/source/algorithms/SaveGSS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveHKL-v1.rst b/docs/source/algorithms/SaveHKL-v1.rst index c2cc616f34603206472fb58ec6b245e4948d635f..c293e2eee2c6b547001263ec8879604591efb8b2 100644 --- a/docs/source/algorithms/SaveHKL-v1.rst +++ b/docs/source/algorithms/SaveHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveILLCosmosAscii-v1.rst b/docs/source/algorithms/SaveILLCosmosAscii-v1.rst index 41d27f23b358a6e912d28cdbe8e2b5d1e31d9d80..8864a170eecbcbf802bfd1620d782b8f81c265b2 100644 --- a/docs/source/algorithms/SaveILLCosmosAscii-v1.rst +++ b/docs/source/algorithms/SaveILLCosmosAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveISISNexus-v1.rst b/docs/source/algorithms/SaveISISNexus-v1.rst index 484ceecba5da998638867a8e526a8afae042dc6b..0454c04852281dda1ed8aee460c63c29d99ea95e 100644 --- a/docs/source/algorithms/SaveISISNexus-v1.rst +++ b/docs/source/algorithms/SaveISISNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveIsawDetCal-v1.rst b/docs/source/algorithms/SaveIsawDetCal-v1.rst index 39cb1d6e763b51478f9bf072758c3f7153267e58..c88fbe530795f7ef7ba906295311f93526715f5c 100644 --- a/docs/source/algorithms/SaveIsawDetCal-v1.rst +++ b/docs/source/algorithms/SaveIsawDetCal-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveIsawPeaks-v1.rst b/docs/source/algorithms/SaveIsawPeaks-v1.rst index 64357cacb45512080061310691fad12bc0b32acd..212ba072dea963c2c3053a65bcd2a77328ec152e 100644 --- a/docs/source/algorithms/SaveIsawPeaks-v1.rst +++ b/docs/source/algorithms/SaveIsawPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -30,6 +30,8 @@ Usage # Add two peaks to the peaks workspace AddPeak( pws, ws, TOF=100, DetectorID=101, Height=1 ) AddPeak( pws, ws, TOF=200, DetectorID=102, Height=2 ) + peak = pws.getPeak(1).setPeakNumber(2) + peak = pws.getPeak(2).setPeakNumber(3) # Save the peaks workspace to a file in the user's home directory isawPeaksFilePath = os.path.expanduser('~/MantidUsageExample_ISawFile.peaks') diff --git a/docs/source/algorithms/SaveIsawQvector-v1.rst b/docs/source/algorithms/SaveIsawQvector-v1.rst index be2e824c08ebd3b9e359736f60be9f661d934968..eb32744a5039bf4db8af6390b40933a399f5f8b4 100644 --- a/docs/source/algorithms/SaveIsawQvector-v1.rst +++ b/docs/source/algorithms/SaveIsawQvector-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveIsawUB-v1.rst b/docs/source/algorithms/SaveIsawUB-v1.rst index 11415c868c8459349cf7a559ab093c9368889c98..f364b22c295bff273c3f7ad87705bd84aa20e21a 100644 --- a/docs/source/algorithms/SaveIsawUB-v1.rst +++ b/docs/source/algorithms/SaveIsawUB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveLauenorm-v1.rst b/docs/source/algorithms/SaveLauenorm-v1.rst index 0ab304c56215c4616a6ac8c7de53e01953a5b927..862f9533d373fc92babe686213b55c6fbdce75fd 100644 --- a/docs/source/algorithms/SaveLauenorm-v1.rst +++ b/docs/source/algorithms/SaveLauenorm-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveMD-v1.rst b/docs/source/algorithms/SaveMD-v1.rst index e0ff00e221e22f83350229d5ba6c20e91aa151f6..ebda8ebaca76901e59dcaabf0d02fb87c26fdae7 100644 --- a/docs/source/algorithms/SaveMD-v1.rst +++ b/docs/source/algorithms/SaveMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveMD-v2.rst b/docs/source/algorithms/SaveMD-v2.rst index baf9a2f931ad27af951dafbe49c12b979bb47aa2..443ec2b3c5d4b538994f78df7df64f178dc6c52c 100644 --- a/docs/source/algorithms/SaveMD-v2.rst +++ b/docs/source/algorithms/SaveMD-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveMDWorkspaceToVTK-v1.rst b/docs/source/algorithms/SaveMDWorkspaceToVTK-v1.rst index 19c90a8f3286a0679fdd0575c4739bcc063ce5db..83ff41c6bb5ea928c34337e248c6cf336451ec66 100644 --- a/docs/source/algorithms/SaveMDWorkspaceToVTK-v1.rst +++ b/docs/source/algorithms/SaveMDWorkspaceToVTK-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveMask-v1.rst b/docs/source/algorithms/SaveMask-v1.rst index c94eb79e3ea6c47a79e47819eed3a920ca491ac3..8dcb04c173361cb635d7a56942c43be6c2ff941d 100644 --- a/docs/source/algorithms/SaveMask-v1.rst +++ b/docs/source/algorithms/SaveMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNISTDAT-v1.rst b/docs/source/algorithms/SaveNISTDAT-v1.rst index e9d30acff91cd6266b6a7c79dbd0b086600acdbb..7019a91dea78eef485dd6b39a54c3f8a2926a363 100644 --- a/docs/source/algorithms/SaveNISTDAT-v1.rst +++ b/docs/source/algorithms/SaveNISTDAT-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNXSPE-v1.rst b/docs/source/algorithms/SaveNXSPE-v1.rst index 61dcc9d20b3e998928066bf282fd6a8ef1fc7d57..c51ff193f95038d14d4e17d3c39a3d203db4875c 100644 --- a/docs/source/algorithms/SaveNXSPE-v1.rst +++ b/docs/source/algorithms/SaveNXSPE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNXTomo-v1.rst b/docs/source/algorithms/SaveNXTomo-v1.rst index 495f186f21cc0f4ad54e533177a688c690279d15..9c0ac61c0894720279c7d5cb87b533b2b244d5e5 100644 --- a/docs/source/algorithms/SaveNXTomo-v1.rst +++ b/docs/source/algorithms/SaveNXTomo-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNXcanSAS-v1.rst b/docs/source/algorithms/SaveNXcanSAS-v1.rst index 90a9535c6b23ed7eb2c6717d575d18ddd4aef06b..426c54d924169e25e682573ef110fcd3065ed6a6 100644 --- a/docs/source/algorithms/SaveNXcanSAS-v1.rst +++ b/docs/source/algorithms/SaveNXcanSAS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNexus-v1.rst b/docs/source/algorithms/SaveNexus-v1.rst index dd22495bd16685e41a92d91df0af6d4c053480a9..f9f19ce382bae0f1223639219615f9791977b705 100644 --- a/docs/source/algorithms/SaveNexus-v1.rst +++ b/docs/source/algorithms/SaveNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNexusPD-v1.rst b/docs/source/algorithms/SaveNexusPD-v1.rst index 2b18441beaf09055e4c5d19b2fdffbb4c2837d12..475405a9e571cde8ff003789bdb3582e318b7aee 100644 --- a/docs/source/algorithms/SaveNexusPD-v1.rst +++ b/docs/source/algorithms/SaveNexusPD-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveNexusProcessed-v1.rst b/docs/source/algorithms/SaveNexusProcessed-v1.rst index c0ee69902031bbc457d9a1c8c0765419740c0176..3f22356ced7371f7aa8236855b28422eca91d0ca 100644 --- a/docs/source/algorithms/SaveNexusProcessed-v1.rst +++ b/docs/source/algorithms/SaveNexusProcessed-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveOpenGenieAscii-v1.rst b/docs/source/algorithms/SaveOpenGenieAscii-v1.rst index 6d853c65781094c251a7a84a15c1fdab9de5ccd4..b0c021f2d7e34549484a207f492ccc9d57d0bc9d 100644 --- a/docs/source/algorithms/SaveOpenGenieAscii-v1.rst +++ b/docs/source/algorithms/SaveOpenGenieAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SavePAR-v1.rst b/docs/source/algorithms/SavePAR-v1.rst index 11274afe87b080bb80871a809851c2dbd15ce11f..78db4aa3108e0eefb62ffbc86170731967cb55e9 100644 --- a/docs/source/algorithms/SavePAR-v1.rst +++ b/docs/source/algorithms/SavePAR-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SavePDFGui-v1.rst b/docs/source/algorithms/SavePDFGui-v1.rst index 1b964b46487f3c36a715f61bcb99ea421ad64142..92352598e21e3f2abbb308ce4161a5fac7aa3d78 100644 --- a/docs/source/algorithms/SavePDFGui-v1.rst +++ b/docs/source/algorithms/SavePDFGui-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SavePHX-v1.rst b/docs/source/algorithms/SavePHX-v1.rst index 49ff0e73bb50dc739b1bebdef2662441fcd1b8df..09d5003a03a2f3eaef5a0ba78ec8c6ea9078fe64 100644 --- a/docs/source/algorithms/SavePHX-v1.rst +++ b/docs/source/algorithms/SavePHX-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveParameterFile-v1.rst b/docs/source/algorithms/SaveParameterFile-v1.rst index 3903cf34bd7a16d0ba5cf6deda24c5a531b89320..be2795351b61f3b294a849809b23a673523f4e20 100644 --- a/docs/source/algorithms/SaveParameterFile-v1.rst +++ b/docs/source/algorithms/SaveParameterFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SavePlot1D-v1.rst b/docs/source/algorithms/SavePlot1D-v1.rst index b5f9ad78c892a5caeb320cdd1fab6f4f90f99009..b29f32c4187ff9e3b61cd9cafd0ed54dfa1c4955 100644 --- a/docs/source/algorithms/SavePlot1D-v1.rst +++ b/docs/source/algorithms/SavePlot1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SavePlot1DAsJson-v1.rst b/docs/source/algorithms/SavePlot1DAsJson-v1.rst index 85bb7a8d062628aad864fac2e7a84bdde2c6c871..414c7e478f73259d89c96d64b5619dc9b8b0f6c0 100644 --- a/docs/source/algorithms/SavePlot1DAsJson-v1.rst +++ b/docs/source/algorithms/SavePlot1DAsJson-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveRKH-v1.rst b/docs/source/algorithms/SaveRKH-v1.rst index 30cb6726492170822fa491b4b5cd1885b91ebbf9..26c0ecdedb800d07dabe0bcb2abd06dee61c771e 100644 --- a/docs/source/algorithms/SaveRKH-v1.rst +++ b/docs/source/algorithms/SaveRKH-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveReflCustomAscii-v1.rst b/docs/source/algorithms/SaveReflCustomAscii-v1.rst index 96a531afc3f8a967ad360f0e20eb7cedef9a009c..81d9b39b96f726559e3f513b1bffa73eaafc1832 100644 --- a/docs/source/algorithms/SaveReflCustomAscii-v1.rst +++ b/docs/source/algorithms/SaveReflCustomAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveReflThreeColumnAscii-v1.rst b/docs/source/algorithms/SaveReflThreeColumnAscii-v1.rst index 842b71090339f8b9de0e0ffc4896bb7edb31cf8b..7f25d60b8e4b2bf92f31909fe185414dc19088aa 100644 --- a/docs/source/algorithms/SaveReflThreeColumnAscii-v1.rst +++ b/docs/source/algorithms/SaveReflThreeColumnAscii-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveReflections-v1.rst b/docs/source/algorithms/SaveReflections-v1.rst index f1578a110c7d542030997734367493085de0bac3..f4a9755cce75829c3533ac2ed54b952d747147f8 100644 --- a/docs/source/algorithms/SaveReflections-v1.rst +++ b/docs/source/algorithms/SaveReflections-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveSESANS-v1.rst b/docs/source/algorithms/SaveSESANS-v1.rst index 1d53164654ea5f9149407877b87f9f877eee6d8e..96b4819c112d9dfa4c73a25d8e77e546440450cf 100644 --- a/docs/source/algorithms/SaveSESANS-v1.rst +++ b/docs/source/algorithms/SaveSESANS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveSPE-v1.rst b/docs/source/algorithms/SaveSPE-v1.rst index 7cd4c44a9a0ae37a9a82ceef75f42e37b5d65722..fa29314aa71ff87dc2b396aa8894763d3bee1317 100644 --- a/docs/source/algorithms/SaveSPE-v1.rst +++ b/docs/source/algorithms/SaveSPE-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveTBL-v1.rst b/docs/source/algorithms/SaveTBL-v1.rst index f17c7d9eb7038df9ca541be9c15b0955ea8f9174..822c57f3c4aa91ba3f2dc75f4af44027d111db77 100644 --- a/docs/source/algorithms/SaveTBL-v1.rst +++ b/docs/source/algorithms/SaveTBL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveToSNSHistogramNexus-v1.rst b/docs/source/algorithms/SaveToSNSHistogramNexus-v1.rst index eb6f5f53a27a2a6b5ab7e93bb718e6c3e72b9bf2..fb5c24ebd953b9c7d4b3af2be8a548bdc596744e 100644 --- a/docs/source/algorithms/SaveToSNSHistogramNexus-v1.rst +++ b/docs/source/algorithms/SaveToSNSHistogramNexus-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveVTK-v1.rst b/docs/source/algorithms/SaveVTK-v1.rst index b0bc1962e20bdd43df82d7b7936faa62fd8ea864..9e4f3cbd409f20212ef041ecf25a5514c8df843e 100644 --- a/docs/source/algorithms/SaveVTK-v1.rst +++ b/docs/source/algorithms/SaveVTK-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveVulcanGSS-v1.rst b/docs/source/algorithms/SaveVulcanGSS-v1.rst index 02dad60760f689d4e78d3d59566ab810ab687726..db8f998453dab9c762a0742e56e96eead3a661ae 100644 --- a/docs/source/algorithms/SaveVulcanGSS-v1.rst +++ b/docs/source/algorithms/SaveVulcanGSS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveYDA-v1.rst b/docs/source/algorithms/SaveYDA-v1.rst index fd7e62d45193cfc2f61c29ac5a2c2d8acae6c542..a0c122544fcccab02d9e49cbb89b06ac190c245f 100644 --- a/docs/source/algorithms/SaveYDA-v1.rst +++ b/docs/source/algorithms/SaveYDA-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SaveZODS-v1.rst b/docs/source/algorithms/SaveZODS-v1.rst index a8eae4a0181688ad77f8c175e4617be41fed8388..b18e507c8860f33fd7006d1ecf473f9890a387e1 100644 --- a/docs/source/algorithms/SaveZODS-v1.rst +++ b/docs/source/algorithms/SaveZODS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Scale-v1.rst b/docs/source/algorithms/Scale-v1.rst index 2e9d12029745e2979a56e4d32b7b949f14f2ea59..0afc60473c318a61728dcec33044308bb6563562 100644 --- a/docs/source/algorithms/Scale-v1.rst +++ b/docs/source/algorithms/Scale-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ScaleX-v1.rst b/docs/source/algorithms/ScaleX-v1.rst index 443e864f69d7fd363d1359d3ad42d90ca915adbd..f73d22db3ed7f1fea30294cf14762a85675cf486 100644 --- a/docs/source/algorithms/ScaleX-v1.rst +++ b/docs/source/algorithms/ScaleX-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Segfault-v1.rst b/docs/source/algorithms/Segfault-v1.rst index 46d811401c311966fbb79473f19908782f5efb07..200d83f64c61299c76915e823836b3902c2debce 100644 --- a/docs/source/algorithms/Segfault-v1.rst +++ b/docs/source/algorithms/Segfault-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SelectCellOfType-v1.rst b/docs/source/algorithms/SelectCellOfType-v1.rst index 76a02f6b4385a7a5767c6a99eb8a4f0e593a087e..a0e36580cd47c9537940d6a8e2d55d03f2570225 100644 --- a/docs/source/algorithms/SelectCellOfType-v1.rst +++ b/docs/source/algorithms/SelectCellOfType-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SelectCellWithForm-v1.rst b/docs/source/algorithms/SelectCellWithForm-v1.rst index b85608ad3f82ae42b1c2e6432be9eccbdf4e4d8d..67219f6beb948b8e6b47d4061c815bc28559262a 100644 --- a/docs/source/algorithms/SelectCellWithForm-v1.rst +++ b/docs/source/algorithms/SelectCellWithForm-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SelectNexusFilesByMetadata-v1.rst b/docs/source/algorithms/SelectNexusFilesByMetadata-v1.rst index 6207b7c559184f2d95b20721450d3748eb479851..905a432444466bec9bd6bcb5100c7aa64dc57654 100644 --- a/docs/source/algorithms/SelectNexusFilesByMetadata-v1.rst +++ b/docs/source/algorithms/SelectNexusFilesByMetadata-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetBeam-v1.rst b/docs/source/algorithms/SetBeam-v1.rst index 6bafc93088ea781003cb3c8b2d24bedb31ae59ae..87cecd620e57aacd4b5d4f74c7695b4b1f01cd19 100644 --- a/docs/source/algorithms/SetBeam-v1.rst +++ b/docs/source/algorithms/SetBeam-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetDetScale-v1.rst b/docs/source/algorithms/SetDetScale-v1.rst index ca1a0e36a8a171faa0a228f24b3be63ea184c4e4..466cf165cef160a6cc78160ca354b83530b1f443 100644 --- a/docs/source/algorithms/SetDetScale-v1.rst +++ b/docs/source/algorithms/SetDetScale-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetGoniometer-v1.rst b/docs/source/algorithms/SetGoniometer-v1.rst index d8c47595fe3f1c1e5f7f539c2f2f9447a4583401..c13b71b14b8fd688fe093ff4e56ccb730163ed17 100644 --- a/docs/source/algorithms/SetGoniometer-v1.rst +++ b/docs/source/algorithms/SetGoniometer-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetInstrumentParameter-v1.rst b/docs/source/algorithms/SetInstrumentParameter-v1.rst index 07d3193ca4b258637101ec9eb7309f2be74969e2..b3280db781ee8ce758293fbe953307fe521fd939 100644 --- a/docs/source/algorithms/SetInstrumentParameter-v1.rst +++ b/docs/source/algorithms/SetInstrumentParameter-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetMDFrame-v1.rst b/docs/source/algorithms/SetMDFrame-v1.rst index a53653f95fe6e26bce51802cebd99fdf085e9f42..c722fcadd94d7a619c1835679d0029dcc0c8a579 100644 --- a/docs/source/algorithms/SetMDFrame-v1.rst +++ b/docs/source/algorithms/SetMDFrame-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetMDUsingMask-v1.rst b/docs/source/algorithms/SetMDUsingMask-v1.rst index 1c82ef7a0380cf25081f53770b69e2249071cdb7..97519a88c55391af015280a07e72957b1945d345 100644 --- a/docs/source/algorithms/SetMDUsingMask-v1.rst +++ b/docs/source/algorithms/SetMDUsingMask-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetSample-v1.rst b/docs/source/algorithms/SetSample-v1.rst index 50ed6a778b96239baec77b6b280ef78d8be794d2..9d7e6155da66eb0e672a2ef70814f158eb7807e6 100644 --- a/docs/source/algorithms/SetSample-v1.rst +++ b/docs/source/algorithms/SetSample-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetSampleMaterial-v1.rst b/docs/source/algorithms/SetSampleMaterial-v1.rst index 35cc486ecacbd1c620dbfeb5c6f09b28b759a306..af4760a9cb00987720ecc38ef96cf7fc48686085 100644 --- a/docs/source/algorithms/SetSampleMaterial-v1.rst +++ b/docs/source/algorithms/SetSampleMaterial-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetScalingPSD-v1.rst b/docs/source/algorithms/SetScalingPSD-v1.rst index 2e4d21652095f9296fdad9eed4247bc22d953027..10f5f85cf35737bcbd5e292254feaf3150f44313 100644 --- a/docs/source/algorithms/SetScalingPSD-v1.rst +++ b/docs/source/algorithms/SetScalingPSD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetSpecialCoordinates-v1.rst b/docs/source/algorithms/SetSpecialCoordinates-v1.rst index 8fc2df29a2fc4ccd2a120eaf7e2720d4b9dcac09..e712aae43efe64ad4044314a50ad1cdfb129b897 100644 --- a/docs/source/algorithms/SetSpecialCoordinates-v1.rst +++ b/docs/source/algorithms/SetSpecialCoordinates-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetUB-v1.rst b/docs/source/algorithms/SetUB-v1.rst index b577dfa18ab91ad5d5eb48a84e39ed959f6ceb6f..07961ff32cf842ede37e5b738656dae81487bd4b 100644 --- a/docs/source/algorithms/SetUB-v1.rst +++ b/docs/source/algorithms/SetUB-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetUncertainties-v1.rst b/docs/source/algorithms/SetUncertainties-v1.rst index 0c6e4e66d99fc841b837950d8721bd749e22ce38..ddd7b113893dd70952383c5838d2b08b50518433 100644 --- a/docs/source/algorithms/SetUncertainties-v1.rst +++ b/docs/source/algorithms/SetUncertainties-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetupEQSANSReduction-v1.rst b/docs/source/algorithms/SetupEQSANSReduction-v1.rst index 0473eefc42b8be532820090f0fadd0945a1e781f..b4927b948fa551949faa214e541c0b8327462a87 100644 --- a/docs/source/algorithms/SetupEQSANSReduction-v1.rst +++ b/docs/source/algorithms/SetupEQSANSReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetupHFIRReduction-v1.rst b/docs/source/algorithms/SetupHFIRReduction-v1.rst index c99561635efba677b089a8b4cdb2782dc814bab8..0ecfc4a76e174de54c6d9f7eba78aff499575287 100644 --- a/docs/source/algorithms/SetupHFIRReduction-v1.rst +++ b/docs/source/algorithms/SetupHFIRReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SetupILLD33Reduction-v1.rst b/docs/source/algorithms/SetupILLD33Reduction-v1.rst index 92d3513dd328c1d15459e4f06e81448de6b5b13d..e5dbb8669318c769e95786bb4bed2d6d45095e6c 100644 --- a/docs/source/algorithms/SetupILLD33Reduction-v1.rst +++ b/docs/source/algorithms/SetupILLD33Reduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ShiftLogTime-v1.rst b/docs/source/algorithms/ShiftLogTime-v1.rst index 4c2a0abc0905adfb7f46dd9abd4e75d75aff4a59..d66c3df887a49f4a18910264caaa00d0f9ef2808 100644 --- a/docs/source/algorithms/ShiftLogTime-v1.rst +++ b/docs/source/algorithms/ShiftLogTime-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ShowPeakHKLOffsets-v1.rst b/docs/source/algorithms/ShowPeakHKLOffsets-v1.rst index e3dedcf03eddd580ddac2a7c8ba1951969a634da..e22d8273d34c75a53aa3c0016aa07e7d673cfde4 100644 --- a/docs/source/algorithms/ShowPeakHKLOffsets-v1.rst +++ b/docs/source/algorithms/ShowPeakHKLOffsets-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ShowPossibleCells-v1.rst b/docs/source/algorithms/ShowPossibleCells-v1.rst index 9ff6b3bdec57983875cbf42b8cb27598bb67c6fd..8341b231a72dda6d074b753cb3dacfc28c076970 100644 --- a/docs/source/algorithms/ShowPossibleCells-v1.rst +++ b/docs/source/algorithms/ShowPossibleCells-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SignalOverError-v1.rst b/docs/source/algorithms/SignalOverError-v1.rst index ed1d90ef78b2bb2278ac9cbbea8cb79a27d2ae8c..2f8836135297394fa2b7fc1c6045a36a40f4e408 100644 --- a/docs/source/algorithms/SignalOverError-v1.rst +++ b/docs/source/algorithms/SignalOverError-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SimpleShapeMonteCarloAbsorption-v1.rst b/docs/source/algorithms/SimpleShapeMonteCarloAbsorption-v1.rst index bd0fca8d81c184bf1a2afccc8a445c47bcfeb61c..2df74518e4ad2311b5c9fa7a0a16234b34415f61 100644 --- a/docs/source/algorithms/SimpleShapeMonteCarloAbsorption-v1.rst +++ b/docs/source/algorithms/SimpleShapeMonteCarloAbsorption-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SimulateResolutionConvolvedModel-v1.rst b/docs/source/algorithms/SimulateResolutionConvolvedModel-v1.rst index 29ff13b3c9aeb631a6d753fe5f31b71ecc218679..bd38f354277595cb0315c8119fd25dfc40a19245 100644 --- a/docs/source/algorithms/SimulateResolutionConvolvedModel-v1.rst +++ b/docs/source/algorithms/SimulateResolutionConvolvedModel-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SimulatedDensityOfStates-v1.rst b/docs/source/algorithms/SimulatedDensityOfStates-v1.rst index 4237e7c85e7655a3b60ba563ec3bc0530d039a0e..08639ea28bff8e51f9750639344621a43a61546e 100644 --- a/docs/source/algorithms/SimulatedDensityOfStates-v1.rst +++ b/docs/source/algorithms/SimulatedDensityOfStates-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SingleCrystalDiffuseReduction-v1.rst b/docs/source/algorithms/SingleCrystalDiffuseReduction-v1.rst index 6efc6c78d5fbc38d84ce6ce38dd46545b8d7f330..95a91fb389de39fd00494d9e48f327a71b78bce7 100644 --- a/docs/source/algorithms/SingleCrystalDiffuseReduction-v1.rst +++ b/docs/source/algorithms/SingleCrystalDiffuseReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SliceMD-v1.rst b/docs/source/algorithms/SliceMD-v1.rst index a8a1a78110e3f1dc151452452c1168a63626cae2..5da7f957078bae5ee0ba9807b9626e9b8b47647f 100644 --- a/docs/source/algorithms/SliceMD-v1.rst +++ b/docs/source/algorithms/SliceMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SliceMDHisto-v1.rst b/docs/source/algorithms/SliceMDHisto-v1.rst index 9014403ae152c4cead83f43b12f091b9e769b862..aaafa5507b146e263f847ebcc4a5ed524c3a98d9 100644 --- a/docs/source/algorithms/SliceMDHisto-v1.rst +++ b/docs/source/algorithms/SliceMDHisto-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SmoothData-v1.rst b/docs/source/algorithms/SmoothData-v1.rst index c958fa0d90ad99a92b687dfd1f6ac35be4cdce72..c6058b2799a4162e020bbaacb1f63094d1b09e19 100644 --- a/docs/source/algorithms/SmoothData-v1.rst +++ b/docs/source/algorithms/SmoothData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SmoothMD-v1.rst b/docs/source/algorithms/SmoothMD-v1.rst index f138b9f5cd9fa8bfa2c1a6cc11b7fdfce9ff3de2..7dca3269a721bec8d8ee8817cdcc15e1091dcfd3 100644 --- a/docs/source/algorithms/SmoothMD-v1.rst +++ b/docs/source/algorithms/SmoothMD-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SmoothNeighbours-v1.rst b/docs/source/algorithms/SmoothNeighbours-v1.rst index 3ade8959f5887339cef30abad4ca7cb36ddc23a3..83520295a0d204d444da6ec15a878b19a705b81e 100644 --- a/docs/source/algorithms/SmoothNeighbours-v1.rst +++ b/docs/source/algorithms/SmoothNeighbours-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQW-v1.rst b/docs/source/algorithms/SofQW-v1.rst index fd6f42bb860fe8057a07970e5bb7874b88ae2500..117edc41efe957db76af5cee5ac0c71a77094686 100644 --- a/docs/source/algorithms/SofQW-v1.rst +++ b/docs/source/algorithms/SofQW-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQWCentre-v1.rst b/docs/source/algorithms/SofQWCentre-v1.rst index c98c26f5217d96189d66b522a3420873cf0701ab..da9e7a8db996e42b1fb1f34a82fcdb3d531db8ea 100644 --- a/docs/source/algorithms/SofQWCentre-v1.rst +++ b/docs/source/algorithms/SofQWCentre-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQWMoments-v1.rst b/docs/source/algorithms/SofQWMoments-v1.rst index a1854bd96aea81236b145a21175e91b97b77f5f1..2da6a995b3684db379325051dcbc3af4e530843b 100644 --- a/docs/source/algorithms/SofQWMoments-v1.rst +++ b/docs/source/algorithms/SofQWMoments-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQWMomentsScan-v1.rst b/docs/source/algorithms/SofQWMomentsScan-v1.rst index 643c8fc903a1549a82af5d002a4d144f8acc0ced..161c38ac964a21431584e1236bdf52365bd2c07c 100644 --- a/docs/source/algorithms/SofQWMomentsScan-v1.rst +++ b/docs/source/algorithms/SofQWMomentsScan-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQWNormalisedPolygon-v1.rst b/docs/source/algorithms/SofQWNormalisedPolygon-v1.rst index 8be67c4e960c89977cc52320fab46e5dc9ea0a3b..39c665271d02cafee00670ea93dbe9beb4714071 100644 --- a/docs/source/algorithms/SofQWNormalisedPolygon-v1.rst +++ b/docs/source/algorithms/SofQWNormalisedPolygon-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SofQWPolygon-v1.rst b/docs/source/algorithms/SofQWPolygon-v1.rst index f07a5cd549d5a9a01c55a1ce70f4eedb1a2d98ca..de2e5385c06d55ffde0caa9cc4520473abad53b9 100644 --- a/docs/source/algorithms/SofQWPolygon-v1.rst +++ b/docs/source/algorithms/SofQWPolygon-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SolidAngle-v1.rst b/docs/source/algorithms/SolidAngle-v1.rst index cf54086f2b72ace7c8e6a023395de44e38c4d159..632b576e013d8b672a78385e69790eedb1b51d34 100644 --- a/docs/source/algorithms/SolidAngle-v1.rst +++ b/docs/source/algorithms/SolidAngle-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortByQVectors-v1.rst b/docs/source/algorithms/SortByQVectors-v1.rst index b290618a9e1fdffb4e3365495bdb688cbe82ce84..1759811c40bcf4d54c2ad71ea21764e5b6ec3fdd 100644 --- a/docs/source/algorithms/SortByQVectors-v1.rst +++ b/docs/source/algorithms/SortByQVectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortDetectors-v1.rst b/docs/source/algorithms/SortDetectors-v1.rst index 8e6a0fbf357f5e75fe1541bd65fd963b061b57dd..120169ba367a4edf96c8fc23f828d8ac686cc5ed 100644 --- a/docs/source/algorithms/SortDetectors-v1.rst +++ b/docs/source/algorithms/SortDetectors-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortEvents-v1.rst b/docs/source/algorithms/SortEvents-v1.rst index 3d188ac2e6c1bab79a42bc41d1d6fa0ce11939a0..cc2d0d78bd01325b8851083c99e125d0bc957138 100644 --- a/docs/source/algorithms/SortEvents-v1.rst +++ b/docs/source/algorithms/SortEvents-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortHKL-v1.rst b/docs/source/algorithms/SortHKL-v1.rst index decf6733cfad51abb5386e33c63bf960e8394657..dd135aad819af38828a624bee4bb8f9bdba37b78 100644 --- a/docs/source/algorithms/SortHKL-v1.rst +++ b/docs/source/algorithms/SortHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -36,6 +36,15 @@ it belongs to, so that equivalent reflections have the same intensity and error Finally, the peaks in the output workspace are sorted by H, K and L. +The EquivalentsWorkspace contains specta that can be plotted for each set of +equivalent intensities. The X axis is the wavelength and the Y axis is the corrected intensity of the +peaks. The error is the difference in the intensity of that peak and the average for all equivalent +peaks. For example, see the 424 equivalent intensities in plot below. The intensity of the peak at +wavelength 0.5 is marked as an outlier by setting the error to the same value as the intensity. +The average intensity is 21903. + +.. figure:: /images/EquivalentIntensities.png + Usage ----- @@ -54,7 +63,7 @@ and rhombohedral centering: CellType='Hexagonal', Apply=True, Tolerance=0.2) # Run the SortHKL algorithm - sorted, chi2, statistics_table = SortHKL(peaks, PointGroup='-3m1 (Trigonal - Hexagonal)', + sorted, chi2, statistics_table, equivI = SortHKL(peaks, PointGroup='-3m1 (Trigonal - Hexagonal)', LatticeCentering='Rhombohedrally centred, obverse') statistics = statistics_table.row(0) diff --git a/docs/source/algorithms/SortPeaksWorkspace-v1.rst b/docs/source/algorithms/SortPeaksWorkspace-v1.rst index 778c0d233b5477e056caf4346f14ef5b9a91d883..96c37db81220ac23e5d3f9e2c0a063fd40b1018d 100644 --- a/docs/source/algorithms/SortPeaksWorkspace-v1.rst +++ b/docs/source/algorithms/SortPeaksWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortTableWorkspace-v1.rst b/docs/source/algorithms/SortTableWorkspace-v1.rst index 1bc493ab2c08876f8b03e6d773df7486d5aa8f73..0394b2223facab3a984e7da23be81a67002c93fd 100644 --- a/docs/source/algorithms/SortTableWorkspace-v1.rst +++ b/docs/source/algorithms/SortTableWorkspace-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SortXAxis-v1.rst b/docs/source/algorithms/SortXAxis-v1.rst index 7b14bd708d4c134a878730a0d16c99aef8ae72cd..aaef5edd17efc6c3a9804b3604811134c493cd89 100644 --- a/docs/source/algorithms/SortXAxis-v1.rst +++ b/docs/source/algorithms/SortXAxis-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -10,14 +10,12 @@ Description ----------- Clones the input :ref:`Matrix Workspaces <MatrixWorkspace>` and orders the -x-axis in an ascending fashion. Ensures that the y-axis and error data -is sorted in a consistent way with the x-axis. All x-values of the input -workspace MUST be in either a descending or ascending fashion before -passing to this algorithm. +x-axis in an ascending or descending fashion. Ensures that the y-axis and error data as well as optional Dx data +are sorted in a consistent way with the x-axis. This algorithm is for use with small workspaces loaded. It is particularly suitable for reformatting workspaces loaded via -:ref:`LoadAscii <algm-LoadAscii>`. Input workspaces must be a distribution. +:ref:`LoadAscii <algm-LoadAscii>`. Input workspaces must be point data. .. categories:: diff --git a/docs/source/algorithms/SpatialGrouping-v1.rst b/docs/source/algorithms/SpatialGrouping-v1.rst index 8093ac47e6fede7f321102f176ec2e6f88c902fd..2319b9bb8d5fab5acf022d1b089b13592c654f00 100644 --- a/docs/source/algorithms/SpatialGrouping-v1.rst +++ b/docs/source/algorithms/SpatialGrouping-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst b/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst index faf24f237d740145d56816a29192466502f1f445..fccdd37e59184ac0ee8aff44c31e26a417c016ab 100644 --- a/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst +++ b/docs/source/algorithms/SpecularReflectionCalculateTheta-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SpecularReflectionCalculateTheta-v2.rst b/docs/source/algorithms/SpecularReflectionCalculateTheta-v2.rst index 14916278a924066a440ec166e136c372ca2854c9..f5c58e38e2527a198db6821259f84cf8014cd11b 100644 --- a/docs/source/algorithms/SpecularReflectionCalculateTheta-v2.rst +++ b/docs/source/algorithms/SpecularReflectionCalculateTheta-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst b/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst index ae6d4ef34e12c33b1f3b39c740fe15c6f5b85900..a2d9cffa2c2079810e58da5ffc01cf2893868b77 100644 --- a/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst +++ b/docs/source/algorithms/SpecularReflectionPositionCorrect-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SpecularReflectionPositionCorrect-v2.rst b/docs/source/algorithms/SpecularReflectionPositionCorrect-v2.rst index 827a62c624b5e4e071f7428bcef4f9243a30cc61..1773378e9535431b5681566d76f58f7b87bf97e1 100644 --- a/docs/source/algorithms/SpecularReflectionPositionCorrect-v2.rst +++ b/docs/source/algorithms/SpecularReflectionPositionCorrect-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SphericalAbsorption-v1.rst b/docs/source/algorithms/SphericalAbsorption-v1.rst index 3d137c98345c06118837c2bf81fb2d13923ada88..2f1262a5dda0ced9aded76bde582787e40a25183 100644 --- a/docs/source/algorithms/SphericalAbsorption-v1.rst +++ b/docs/source/algorithms/SphericalAbsorption-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SplineBackground-v1.rst b/docs/source/algorithms/SplineBackground-v1.rst index f42331afc3c2f11c0640bb35c696f0cd18bffce7..29e87dffd4483e6cdf56fa4a7cede6d2c4b2a6dd 100644 --- a/docs/source/algorithms/SplineBackground-v1.rst +++ b/docs/source/algorithms/SplineBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SplineInterpolation-v1.rst b/docs/source/algorithms/SplineInterpolation-v1.rst index 0eafdfb4828a9b03c3101619a7a1f49233bbb3c4..3599cc0adeec3a3c331e708297f0e423abf88e1f 100644 --- a/docs/source/algorithms/SplineInterpolation-v1.rst +++ b/docs/source/algorithms/SplineInterpolation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SplineSmoothing-v1.rst b/docs/source/algorithms/SplineSmoothing-v1.rst index 1eaf64373a0d2fa2206956762ca36bedeaede88a..074d3dc85985862b468274462a215ee44723f0ba 100644 --- a/docs/source/algorithms/SplineSmoothing-v1.rst +++ b/docs/source/algorithms/SplineSmoothing-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Squares-v1.rst b/docs/source/algorithms/Squares-v1.rst index 2edc154dd395784fd226c6f5c977ee18db8b751a..b958f9d217bcc36ff65e1001d3bb2847c5d4fe33 100644 --- a/docs/source/algorithms/Squares-v1.rst +++ b/docs/source/algorithms/Squares-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StartLiveData-v1.rst b/docs/source/algorithms/StartLiveData-v1.rst index 8f4f36f574563fd5d987ae7fd9112cf7436a8df2..27df59b0e3d074c69a50808a8b5bee49f0344bfe 100644 --- a/docs/source/algorithms/StartLiveData-v1.rst +++ b/docs/source/algorithms/StartLiveData-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StartRemoteTransaction-v1.rst b/docs/source/algorithms/StartRemoteTransaction-v1.rst index a8ab4a1722e0686f22e507f8357fcf1d6d51e441..130597d207c3fea7f34fa6ffe95824e4ddbb8aed 100644 --- a/docs/source/algorithms/StartRemoteTransaction-v1.rst +++ b/docs/source/algorithms/StartRemoteTransaction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StartRemoteTransaction-v2.rst b/docs/source/algorithms/StartRemoteTransaction-v2.rst index cade65226dd4cab358d04453654ad38a37ffdeb1..830729b6a647edd1fbfca060a3cc6e457019895e 100644 --- a/docs/source/algorithms/StartRemoteTransaction-v2.rst +++ b/docs/source/algorithms/StartRemoteTransaction-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StatisticsOfPeaksWorkspace-v1.rst b/docs/source/algorithms/StatisticsOfPeaksWorkspace-v1.rst index cade0d0e2388288483e86df048562cf501245e7e..1006e3c230463e9097c855aab7e2361da2fdc736 100644 --- a/docs/source/algorithms/StatisticsOfPeaksWorkspace-v1.rst +++ b/docs/source/algorithms/StatisticsOfPeaksWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -62,7 +62,7 @@ Usage CellType='Hexagonal', Apply=True, Tolerance=0.2) # Run the SortHKL algorithm - sorted, statistics_table = StatisticsOfPeaksWorkspace(peaks, PointGroup='-3m1 (Trigonal - Hexagonal)', + sorted, statistics_table, equivI = StatisticsOfPeaksWorkspace(peaks, PointGroup='-3m1 (Trigonal - Hexagonal)', LatticeCentering='Rhombohedrally centred, obverse', SortBy='Overall') diff --git a/docs/source/algorithms/StatisticsOfTableWorkspace-v1.rst b/docs/source/algorithms/StatisticsOfTableWorkspace-v1.rst index 5c2ac6f561fe5b3312c3a5065477e5f7c745109c..c53256425cb77e93e359f54406064e57e344bf98 100644 --- a/docs/source/algorithms/StatisticsOfTableWorkspace-v1.rst +++ b/docs/source/algorithms/StatisticsOfTableWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StepScan-v1.rst b/docs/source/algorithms/StepScan-v1.rst index a280ea6762085e4555d3ee9f6c7fc4ff15810950..1bf845a392b374ce1fec3072e050a6fd07271f1b 100644 --- a/docs/source/algorithms/StepScan-v1.rst +++ b/docs/source/algorithms/StepScan-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Stitch1D-v3.rst b/docs/source/algorithms/Stitch1D-v3.rst index 010ebcdb32a900f7de9c9288609b80103db4dd53..f2286a97b3098b5e1f38cb2a98f858b2b4514193 100644 --- a/docs/source/algorithms/Stitch1D-v3.rst +++ b/docs/source/algorithms/Stitch1D-v3.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: @@ -73,52 +73,70 @@ Usage ----- **Example - a basic example using stitch1D to stitch two workspaces together.** -.. testcode:: ExStitch1DSimple +.. plot:: + :include-source: - import numpy as np + from mantid.simpleapi import * + import matplotlib.pyplot as plt + import numpy as np - def gaussian(x, mu, sigma): - """Creates a gaussian peak centered on mu and with width sigma.""" - return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2)) + def gaussian(x, mu, sigma): + """Creates a gaussian peak centered on mu and with width sigma.""" + return (1/ sigma * np.sqrt(2 * np.pi)) * np.exp( - (x-mu)**2 / (2*sigma**2)) - #create two histograms with a single peak in each one - x1 = np.arange(-1, 1, 0.02) - x2 = np.arange(0.4, 1.6, 0.02) - ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1) - ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)+1) + #create two histograms with a single peak in each one + x1 = np.arange(-1, 1, 0.02) + x2 = np.arange(0.4, 1.6, 0.02) + ws1 = CreateWorkspace(UnitX="1/q", DataX=x1, DataY=gaussian(x1[:-1], 0, 0.1)+1) + ws2 = CreateWorkspace(UnitX="1/q", DataX=x2, DataY=gaussian(x2[:-1], 1, 0.05)+1) - #stitch the histograms together - stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, StartOverlap=0.4, EndOverlap=0.6, Params=0.02) + #stitch the histograms together + stitched, scale = Stitch1D(LHSWorkspace=ws1, RHSWorkspace=ws2, StartOverlap=0.4, EndOverlap=0.6, Params=0.02) -Output: + # plot the individual workspaces alongside the stitched one + fig, axs = plt.subplots(nrows=1, ncols=2, subplot_kw={'projection':'mantid'}) -.. image:: /images/Stitch1D1.png - :scale: 65 % - :alt: Stitch1D output - :align: center + axs[0].plot(mtd['ws1'], wkspIndex=0, label='ws1') + axs[0].plot(mtd['ws2'], wkspIndex=0, label='ws2') + axs[0].legend() + axs[1].plot(mtd['stitched'], wkspIndex=0, color='k', label='stitched') + axs[1].legend() + # uncomment the following line to show the plot window + #fig.show() **Example - a practical example using reflectometry data and a scale factor.** -.. testcode:: ExStitch1DPractical +.. plot:: + :include-source: - trans1 = Load('INTER00013463') - trans2 = Load('INTER00013464') + from mantid.simpleapi import * + import matplotlib.pyplot as plt - trans1_wav = CreateTransmissionWorkspaceAuto(trans1) - trans2_wav = CreateTransmissionWorkspaceAuto(trans2) + trans1 = Load('INTER00013463') + trans2 = Load('INTER00013464') - stitched_wav, y = Stitch1D(trans1_wav, trans2_wav, UseManualScaleFactor=True, ManualScaleFactor=0.85) + trans1_wav = CreateTransmissionWorkspaceAuto(trans1) + trans2_wav = CreateTransmissionWorkspaceAuto(trans2) -Output: + stitched_wav, y = Stitch1D(trans1_wav, trans2_wav, UseManualScaleFactor=True, ManualScaleFactor=0.85) -.. image:: /images/Stitch1D2.png - :scale: 65 % - :alt: Stitch1D output - :align: center + # plot the individual and stitched workspaces next to each other + fig, axs = plt.subplots(nrows=1, ncols=2, subplot_kw={'projection':'mantid'}) + axs[0].plot(trans1_wav, wkspIndex=0, label=str(trans1_wav)) + axs[0].plot(trans2_wav, wkspIndex=0, label=str(trans2_wav)) + axs[0].legend() + # use same y scale on both plots + ylimits = axs[0].get_ylim() + axs[1].plot(stitched_wav, wkspIndex=0, color='k', label='stitched') + axs[1].legend() + axs[1].set_ylim(ylimits) + + # uncomment the following line to show the plot window + #fig.show() .. categories:: .. sourcelink:: - :filename: Stitch1D \ No newline at end of file + :filename: Stitch1D diff --git a/docs/source/algorithms/Stitch1DMany-v1.rst b/docs/source/algorithms/Stitch1DMany-v1.rst index 1b508dcb9c6d470f54de23ddbbebf7889a229026..20d10f3058aaa0dee2e8f26936c43b91d2a11181 100644 --- a/docs/source/algorithms/Stitch1DMany-v1.rst +++ b/docs/source/algorithms/Stitch1DMany-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StopRemoteTransaction-v1.rst b/docs/source/algorithms/StopRemoteTransaction-v1.rst index 125656b108fe494c806b3984df79df49ecdacd18..9ac246ac8918df64d0a89a57ed51ed49b1e1cdd5 100644 --- a/docs/source/algorithms/StopRemoteTransaction-v1.rst +++ b/docs/source/algorithms/StopRemoteTransaction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StopRemoteTransaction-v2.rst b/docs/source/algorithms/StopRemoteTransaction-v2.rst index 70fbf3dabbfc0f488010983b5e233e43875175f5..cf35f859f7bb4129a2c333f5f2027cec55d8d181 100644 --- a/docs/source/algorithms/StopRemoteTransaction-v2.rst +++ b/docs/source/algorithms/StopRemoteTransaction-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StringToPng-v1.rst b/docs/source/algorithms/StringToPng-v1.rst index 8e4af71b1a73a082ac4ee32db17d26b651275abf..9b4fc275e1656801726fd67439c5b0710264196b 100644 --- a/docs/source/algorithms/StringToPng-v1.rst +++ b/docs/source/algorithms/StringToPng-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StripPeaks-v1.rst b/docs/source/algorithms/StripPeaks-v1.rst index d78e605fca96681079ed638e6165ba88f77a6f3f..4f80cbf26663c077cfc1f610c176f6ed1e9f2e9e 100644 --- a/docs/source/algorithms/StripPeaks-v1.rst +++ b/docs/source/algorithms/StripPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StripVanadiumPeaks-v1.rst b/docs/source/algorithms/StripVanadiumPeaks-v1.rst index 8f8750870176b01770c6a5c18681f148c87c6f58..d3e4307fb67b2ac60db7eaab66236099c014489a 100644 --- a/docs/source/algorithms/StripVanadiumPeaks-v1.rst +++ b/docs/source/algorithms/StripVanadiumPeaks-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/StripVanadiumPeaks-v2.rst b/docs/source/algorithms/StripVanadiumPeaks-v2.rst index 9e7e84e974cb2c51e5204d445e089fb2987920fd..57a03fdff2ce6bae3ec9ca52c82046826b130318 100644 --- a/docs/source/algorithms/StripVanadiumPeaks-v2.rst +++ b/docs/source/algorithms/StripVanadiumPeaks-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SubmitRemoteJob-v1.rst b/docs/source/algorithms/SubmitRemoteJob-v1.rst index 98739d05b7da1d0296c719578b54d8986a660c67..3f8281395e18db86fb1ec3522357ceb7c88703a7 100644 --- a/docs/source/algorithms/SubmitRemoteJob-v1.rst +++ b/docs/source/algorithms/SubmitRemoteJob-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SubmitRemoteJob-v2.rst b/docs/source/algorithms/SubmitRemoteJob-v2.rst index cfc51ebbe4149ede98e8f3f571078cb0fcbcfceb..bcb7b407bf9cde4e07b2d37e42fc8e6bd1d5cc64 100644 --- a/docs/source/algorithms/SubmitRemoteJob-v2.rst +++ b/docs/source/algorithms/SubmitRemoteJob-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SuggestTibCNCS-v1.rst b/docs/source/algorithms/SuggestTibCNCS-v1.rst index 04af26e480ae5241e2c39777686b7c0788fc9224..79fdb56fb35b03cac380eded0170fc95baf1f9a1 100644 --- a/docs/source/algorithms/SuggestTibCNCS-v1.rst +++ b/docs/source/algorithms/SuggestTibCNCS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SuggestTibHYSPEC-v1.rst b/docs/source/algorithms/SuggestTibHYSPEC-v1.rst index b840407d0a4a5fe041dd351de7aa3a6007195e5c..eab72f852823cf2b7db1fc8f8da1240b9138bd6e 100644 --- a/docs/source/algorithms/SuggestTibHYSPEC-v1.rst +++ b/docs/source/algorithms/SuggestTibHYSPEC-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SumEventsByLogValue-v1.rst b/docs/source/algorithms/SumEventsByLogValue-v1.rst index 5dd2f94f0ded72b132ba604cb15a29617ba4b47a..5ee1996f11bb2fa803a85672dfa475327ffec359 100644 --- a/docs/source/algorithms/SumEventsByLogValue-v1.rst +++ b/docs/source/algorithms/SumEventsByLogValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SumNeighbours-v1.rst b/docs/source/algorithms/SumNeighbours-v1.rst index 628123ad700e594f4f6506f61c77c2fd7fb03ff8..eead73708f1265da353807d540749ebb73c50880 100644 --- a/docs/source/algorithms/SumNeighbours-v1.rst +++ b/docs/source/algorithms/SumNeighbours-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SumOverlappingTubes-v1.rst b/docs/source/algorithms/SumOverlappingTubes-v1.rst index 058ec3f915842ae859c13236bf1620b5edaa2572..f8aaa9319484d4567d0f23baf94ada994ffdaf5b 100644 --- a/docs/source/algorithms/SumOverlappingTubes-v1.rst +++ b/docs/source/algorithms/SumOverlappingTubes-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SumRowColumn-v1.rst b/docs/source/algorithms/SumRowColumn-v1.rst index 3515c060ba5d23cfe0c85eaaf789ea844c1b5ad7..55804d31c4366aec550af6ed1419e7930aef5fc1 100644 --- a/docs/source/algorithms/SumRowColumn-v1.rst +++ b/docs/source/algorithms/SumRowColumn-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SumSpectra-v1.rst b/docs/source/algorithms/SumSpectra-v1.rst index c25ddcdb0b8d30a816bf20825678661357775b15..824e84c11ba07b23188ecdb825f971858c8d8505 100644 --- a/docs/source/algorithms/SumSpectra-v1.rst +++ b/docs/source/algorithms/SumSpectra-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/SwapWidths-v1.rst b/docs/source/algorithms/SwapWidths-v1.rst index 72bb112d72922f63c023b9093e4835c0e45ec41b..c1360be66769c03204ed6b28cc9d6a65333b0cc1 100644 --- a/docs/source/algorithms/SwapWidths-v1.rst +++ b/docs/source/algorithms/SwapWidths-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Symmetrise-v1.rst b/docs/source/algorithms/Symmetrise-v1.rst index 1ff18b6d42c8359c3d06502bc736848929b12249..43edae0384ddcd4317b63b2a07c361a2252619d7 100644 --- a/docs/source/algorithms/Symmetrise-v1.rst +++ b/docs/source/algorithms/Symmetrise-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TOFSANSResolution-v1.rst b/docs/source/algorithms/TOFSANSResolution-v1.rst index 1de749e2a305b2576b623122936d8904607c2aba..404c8dce40d4245fe1d4a90d10327f1ed2aaee05 100644 --- a/docs/source/algorithms/TOFSANSResolution-v1.rst +++ b/docs/source/algorithms/TOFSANSResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TOFSANSResolutionByPixel-v1.rst b/docs/source/algorithms/TOFSANSResolutionByPixel-v1.rst index 4c651b60bb5f059c0733f88022c229c5410c35a6..19c146448cfdfe07fc61c469ccade7564ac13a94 100644 --- a/docs/source/algorithms/TOFSANSResolutionByPixel-v1.rst +++ b/docs/source/algorithms/TOFSANSResolutionByPixel-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TOFTOFCropWorkspace-v1.rst b/docs/source/algorithms/TOFTOFCropWorkspace-v1.rst index 5401eb666efa47c9342ab0c393994f05e775b219..57c006727d5b51be9ef7e4252e8cf3661c7ed38b 100644 --- a/docs/source/algorithms/TOFTOFCropWorkspace-v1.rst +++ b/docs/source/algorithms/TOFTOFCropWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TOFTOFMergeRuns-v1.rst b/docs/source/algorithms/TOFTOFMergeRuns-v1.rst index 9ebcd6ad5f0d8ad71a1ad6f750068830813bf04d..b7b8c9b38f26a5b6ea8baf9a0e1adb61e150b865 100644 --- a/docs/source/algorithms/TOFTOFMergeRuns-v1.rst +++ b/docs/source/algorithms/TOFTOFMergeRuns-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TOSCABankCorrection-v1.rst b/docs/source/algorithms/TOSCABankCorrection-v1.rst index 246cd57c330a0915f2610dc70df9e18f9d5879f6..9f62e5ec8bbf17a9a9c85de53fb9f9edb5e76e56 100644 --- a/docs/source/algorithms/TOSCABankCorrection-v1.rst +++ b/docs/source/algorithms/TOSCABankCorrection-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TestWorkspaceGroupProperty-v1.rst b/docs/source/algorithms/TestWorkspaceGroupProperty-v1.rst index 6697bc246c57291bf8c069eb583e816c45d1e2fd..49761c3a3f36de52dd20667ff7872b34ca93f403 100644 --- a/docs/source/algorithms/TestWorkspaceGroupProperty-v1.rst +++ b/docs/source/algorithms/TestWorkspaceGroupProperty-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ThresholdMD-v1.rst b/docs/source/algorithms/ThresholdMD-v1.rst index b093fe10fb312c62f9bcc9f8f68e5062a4cbefb0..d36b21dcb20717f7235fdc5bb4e4ac674aaf11ec 100644 --- a/docs/source/algorithms/ThresholdMD-v1.rst +++ b/docs/source/algorithms/ThresholdMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TimeSlice-v1.rst b/docs/source/algorithms/TimeSlice-v1.rst index 1093650e891166430a8f25312dab44c8f5e89367..fade64354530b6e210c7ec8f0469966278ee4998 100644 --- a/docs/source/algorithms/TimeSlice-v1.rst +++ b/docs/source/algorithms/TimeSlice-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TransformHKL-v1.rst b/docs/source/algorithms/TransformHKL-v1.rst index f7259e66b77854540c4f71f55438ba1e7c26eb1e..c45332e0205fa886e625e1c02fe7676c1a65a8c4 100644 --- a/docs/source/algorithms/TransformHKL-v1.rst +++ b/docs/source/algorithms/TransformHKL-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TransformMD-v1.rst b/docs/source/algorithms/TransformMD-v1.rst index e2df2485a9273ca636b9f23cc0992f5020aad00f..30d35a37f53492a9eec02f234554802b3757c7c7 100644 --- a/docs/source/algorithms/TransformMD-v1.rst +++ b/docs/source/algorithms/TransformMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TransformToIqt-v1.rst b/docs/source/algorithms/TransformToIqt-v1.rst index 65aa3e41c86194f75c46dfdb4604885438194705..fd6e7093f6bc586520fc4a3c0660b8cb1d2058d9 100644 --- a/docs/source/algorithms/TransformToIqt-v1.rst +++ b/docs/source/algorithms/TransformToIqt-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Transpose-v1.rst b/docs/source/algorithms/Transpose-v1.rst index 0f1b630b43aabf2003e227a0a3dd40c331514c1c..84cf52e8f8dc154e84921d75be91276b63a8cf70 100644 --- a/docs/source/algorithms/Transpose-v1.rst +++ b/docs/source/algorithms/Transpose-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/Transpose3D-v1.rst b/docs/source/algorithms/Transpose3D-v1.rst index ddb63add8e176353a946bc29be50902aaf202b18..386411cd11094d4181b14b9b016d4e1ef184c4c0 100644 --- a/docs/source/algorithms/Transpose3D-v1.rst +++ b/docs/source/algorithms/Transpose3D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/TransposeMD-v1.rst b/docs/source/algorithms/TransposeMD-v1.rst index 3d2715ce1eee33da28cc1dee78cc50792ddfb75c..72c3487cae2d45ff5ba715b4518a3806a5af7ad0 100644 --- a/docs/source/algorithms/TransposeMD-v1.rst +++ b/docs/source/algorithms/TransposeMD-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/USANSReduction-v1.rst b/docs/source/algorithms/USANSReduction-v1.rst index 9f069271b9a234ca772f423c6e4d8fc922296fcf..8779eac3736ab57c4fffde8babe45ad72573ab0b 100644 --- a/docs/source/algorithms/USANSReduction-v1.rst +++ b/docs/source/algorithms/USANSReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/USANSSimulation-v1.rst b/docs/source/algorithms/USANSSimulation-v1.rst index d785a71a2e2b428dce37fce865f14762b4b0386d..c549f0bfd1f6cc36464cf2658110353353ee8222 100644 --- a/docs/source/algorithms/USANSSimulation-v1.rst +++ b/docs/source/algorithms/USANSSimulation-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UnGroupWorkspace-v1.rst b/docs/source/algorithms/UnGroupWorkspace-v1.rst index 4e4a3c37951eac3e05f6a4b1d55e0195b5ac859e..8f84d2a36b2c9ad45abd9da1f7fad74c3759149d 100644 --- a/docs/source/algorithms/UnGroupWorkspace-v1.rst +++ b/docs/source/algorithms/UnGroupWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UnwrapMonitor-v1.rst b/docs/source/algorithms/UnwrapMonitor-v1.rst index 946dfe9321306d5f6923af28501076e07c6ed507..16c242f67f603fd25bea6aad661a89735c711435 100644 --- a/docs/source/algorithms/UnwrapMonitor-v1.rst +++ b/docs/source/algorithms/UnwrapMonitor-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UnwrapMonitorsInTOF-v1.rst b/docs/source/algorithms/UnwrapMonitorsInTOF-v1.rst index ac81cb41e135c4655dd352112adfbaee61ffb0de..4330b6de5502c424625e8db28784ac0a2940b340 100644 --- a/docs/source/algorithms/UnwrapMonitorsInTOF-v1.rst +++ b/docs/source/algorithms/UnwrapMonitorsInTOF-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UnwrapSNS-v1.rst b/docs/source/algorithms/UnwrapSNS-v1.rst index 2ebcc6c4e9548e1af53e0d947f3166ec0799be18..39b1d63ff8e35ce04a4ce5cbe107f6ac5a9e8ddf 100644 --- a/docs/source/algorithms/UnwrapSNS-v1.rst +++ b/docs/source/algorithms/UnwrapSNS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UpdateInstrumentFromFile-v1.rst b/docs/source/algorithms/UpdateInstrumentFromFile-v1.rst index 93ded29927b80a03b4a74cb446ce5a231ee00052..81011f0bd5dae09b9f00aca91f8fea1ec9f88d20 100644 --- a/docs/source/algorithms/UpdateInstrumentFromFile-v1.rst +++ b/docs/source/algorithms/UpdateInstrumentFromFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UpdatePeakParameterTableValue-v1.rst b/docs/source/algorithms/UpdatePeakParameterTableValue-v1.rst index ac2bcafff2dedc7c70b00951b83400417d8c4e50..dea5efa30f2fec5e3397494e08acbcc291d715d0 100644 --- a/docs/source/algorithms/UpdatePeakParameterTableValue-v1.rst +++ b/docs/source/algorithms/UpdatePeakParameterTableValue-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UpdateScriptRepository-v1.rst b/docs/source/algorithms/UpdateScriptRepository-v1.rst index a5800a9a21756d7ec15f16d7042fa4bf37ca7441..72188b53aee893c024da2aa44d81842740c52cfe 100644 --- a/docs/source/algorithms/UpdateScriptRepository-v1.rst +++ b/docs/source/algorithms/UpdateScriptRepository-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UploadRemoteFile-v1.rst b/docs/source/algorithms/UploadRemoteFile-v1.rst index 651dca4bb1b4febe1c098fad59582d6d7bb85368..058a5b2e4c262ec9b4e639b9773a294e4534b7a0 100644 --- a/docs/source/algorithms/UploadRemoteFile-v1.rst +++ b/docs/source/algorithms/UploadRemoteFile-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UploadRemoteFile-v2.rst b/docs/source/algorithms/UploadRemoteFile-v2.rst index 64e73c925b4502edba067a1024da2739ec58f4fc..83449f2f1d737370731af0b1f49d3a80e09cf3db 100644 --- a/docs/source/algorithms/UploadRemoteFile-v2.rst +++ b/docs/source/algorithms/UploadRemoteFile-v2.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/UserFunction1D-v1.rst b/docs/source/algorithms/UserFunction1D-v1.rst index 1d6a7543bf0f30eee1a89163fe09d090f06fa954..c0cd951ed5a69f51ff12e597d0cb3af0e69cf61e 100644 --- a/docs/source/algorithms/UserFunction1D-v1.rst +++ b/docs/source/algorithms/UserFunction1D-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VelocityAutoCorrelations-v1.rst b/docs/source/algorithms/VelocityAutoCorrelations-v1.rst index 79cc52d0f10d56e55ae676328d2621f16d0fd845..f7e87a97cef625d8c90eb28fdaa5231052f0f638 100644 --- a/docs/source/algorithms/VelocityAutoCorrelations-v1.rst +++ b/docs/source/algorithms/VelocityAutoCorrelations-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VelocityCrossCorrelations-v1.rst b/docs/source/algorithms/VelocityCrossCorrelations-v1.rst index 1921525dadaa102300e54038144182877edb09bd..5dfdb25767afb3aeb69bbf466a4c07b50b0a4adf 100644 --- a/docs/source/algorithms/VelocityCrossCorrelations-v1.rst +++ b/docs/source/algorithms/VelocityCrossCorrelations-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioCalculateGammaBackground-v1.rst b/docs/source/algorithms/VesuvioCalculateGammaBackground-v1.rst index 1f627b96cbc28d9ee874707435dcedbd1ae621b7..635e2a8cf6d88507625be070eb0a9068816e628b 100644 --- a/docs/source/algorithms/VesuvioCalculateGammaBackground-v1.rst +++ b/docs/source/algorithms/VesuvioCalculateGammaBackground-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioCalculateMS-v1.rst b/docs/source/algorithms/VesuvioCalculateMS-v1.rst index cbdf39587559556ed85e7e9f39cadf9617f3c4cd..8d767a4d48c5c550f46995bf1bf402656f4d0500 100644 --- a/docs/source/algorithms/VesuvioCalculateMS-v1.rst +++ b/docs/source/algorithms/VesuvioCalculateMS-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioCorrections-v1.rst b/docs/source/algorithms/VesuvioCorrections-v1.rst index 44259cdf5b1bbe72ad272d1c13cece74ed93aaa5..df786dfde681b710691dd874175a30d49fe63663 100644 --- a/docs/source/algorithms/VesuvioCorrections-v1.rst +++ b/docs/source/algorithms/VesuvioCorrections-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioDiffractionReduction-v1.rst b/docs/source/algorithms/VesuvioDiffractionReduction-v1.rst index 7e040f332f19c5298052d73e831fc00546dd9c4c..cfd9527e29fafae4b4c9e942a3583d252955b768 100644 --- a/docs/source/algorithms/VesuvioDiffractionReduction-v1.rst +++ b/docs/source/algorithms/VesuvioDiffractionReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioL1ThetaResolution-v1.rst b/docs/source/algorithms/VesuvioL1ThetaResolution-v1.rst index c27d0c3dc6dd974bee56930d111dbe3fe3d8aaa8..66258996068707e65d205dac2467bf66ff6ac105 100644 --- a/docs/source/algorithms/VesuvioL1ThetaResolution-v1.rst +++ b/docs/source/algorithms/VesuvioL1ThetaResolution-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioPeakPrediction-v1.rst b/docs/source/algorithms/VesuvioPeakPrediction-v1.rst index 1277abd0fcb2f54ef2316fb7c413a36050c3a30e..6404c8dc759aeb07fdbeb4462a2faf0b242c433e 100644 --- a/docs/source/algorithms/VesuvioPeakPrediction-v1.rst +++ b/docs/source/algorithms/VesuvioPeakPrediction-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioPreFit-v1.rst b/docs/source/algorithms/VesuvioPreFit-v1.rst index cd754da96cc197bec1df33bc487d18d59af542ed..c58ca280e29318310e6b5fb7c847a7da74117438 100644 --- a/docs/source/algorithms/VesuvioPreFit-v1.rst +++ b/docs/source/algorithms/VesuvioPreFit-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioResolution-v1.rst b/docs/source/algorithms/VesuvioResolution-v1.rst index 96a8742dedabc6cc24e4514fcead1b1b8cce46a4..dd7dc085ca565b8bf4dee0d667f2de4059b76d7f 100644 --- a/docs/source/algorithms/VesuvioResolution-v1.rst +++ b/docs/source/algorithms/VesuvioResolution-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioTOFFit-v1.rst b/docs/source/algorithms/VesuvioTOFFit-v1.rst index 44161ced3684a58b9cfbe710f7d7f2645d822c62..559ad342a23acfd20bb295ee474715038cbc5ca7 100644 --- a/docs/source/algorithms/VesuvioTOFFit-v1.rst +++ b/docs/source/algorithms/VesuvioTOFFit-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VesuvioThickness-v1.rst b/docs/source/algorithms/VesuvioThickness-v1.rst index 9933d3fe52a4a0b0fa7919ddc60a6511d7012ca5..fa04a4cdd4cd3612e958f270284b81696368affd 100644 --- a/docs/source/algorithms/VesuvioThickness-v1.rst +++ b/docs/source/algorithms/VesuvioThickness-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/ViewBOA-v1.rst b/docs/source/algorithms/ViewBOA-v1.rst index 8593a7c111ff00b682eb8dcc7b79030a355a74fc..a32bba25f598072f4e951796e86189c6853c46c5 100644 --- a/docs/source/algorithms/ViewBOA-v1.rst +++ b/docs/source/algorithms/ViewBOA-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/VisionReduction-v1.rst b/docs/source/algorithms/VisionReduction-v1.rst index 505fb6688264bf715442aaec40fe1efc0fb28dd6..318a948b85bcb3e1cce8700effca3e33a9cd28fb 100644 --- a/docs/source/algorithms/VisionReduction-v1.rst +++ b/docs/source/algorithms/VisionReduction-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/WeightedMean-v1.rst b/docs/source/algorithms/WeightedMean-v1.rst index c442760088bbcc79487f6b5aac6f846b6dbda992..ac5a7caa55b9c8472a7d4ab487c2b0e9d82d344e 100644 --- a/docs/source/algorithms/WeightedMean-v1.rst +++ b/docs/source/algorithms/WeightedMean-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/WeightedMeanMD-v1.rst b/docs/source/algorithms/WeightedMeanMD-v1.rst index a3cfcda5467970de2f6d4d99ef38d620d621a6dd..d62a77c1e13b857d3500f5a7439bfec45b0127ad 100644 --- a/docs/source/algorithms/WeightedMeanMD-v1.rst +++ b/docs/source/algorithms/WeightedMeanMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/WeightedMeanOfWorkspace-v1.rst b/docs/source/algorithms/WeightedMeanOfWorkspace-v1.rst index 637b0379f9d50d8bd4d04b93e02c18360c76ea3b..25aee5bfda8d44d2a7b4baff211001eaeea107df 100644 --- a/docs/source/algorithms/WeightedMeanOfWorkspace-v1.rst +++ b/docs/source/algorithms/WeightedMeanOfWorkspace-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/WienerSmooth-v1.rst b/docs/source/algorithms/WienerSmooth-v1.rst index bc20a9709c73db2cf919da55c6431504cffe6f75..6c71c5a4fd6a809b98e521df46fd6fd38586fb70 100644 --- a/docs/source/algorithms/WienerSmooth-v1.rst +++ b/docs/source/algorithms/WienerSmooth-v1.rst @@ -3,7 +3,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/WorkflowAlgorithmRunner-v1.rst b/docs/source/algorithms/WorkflowAlgorithmRunner-v1.rst index b8e98b33c731f2041534d1d7d75720eba3d7ec28..026912cf5675031185dec48001d3e30bcbfd7e96 100644 --- a/docs/source/algorithms/WorkflowAlgorithmRunner-v1.rst +++ b/docs/source/algorithms/WorkflowAlgorithmRunner-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/algorithms/XorMD-v1.rst b/docs/source/algorithms/XorMD-v1.rst index b25e5f071a2a363958c44cb07937a5b58df70a0f..20afc84b46bc235fdbb9d263e32a6811b1c56487 100644 --- a/docs/source/algorithms/XorMD-v1.rst +++ b/docs/source/algorithms/XorMD-v1.rst @@ -2,7 +2,7 @@ .. summary:: -.. alias:: +.. relatedalgorithms:: .. properties:: diff --git a/docs/source/api/python/index.rst b/docs/source/api/python/index.rst index 3490c7c58bb7cd9cdb70b3e5ede4a0ce6095bdc4..916a08dcbca686f1852057cb793b7d5aa5ff5a35 100644 --- a/docs/source/api/python/index.rst +++ b/docs/source/api/python/index.rst @@ -11,14 +11,6 @@ If you are new to Python in Mantid then we advise first looking at our `Mantid t For tutorials on how to use python in MantidPlot please see `MantidPlot: Python Scripting <https://www.mantidproject.org/MantidPlot:_Python_Scripting>`_. -Matplotlib-like plotting interface ----------------------------------- - -.. toctree:: - :maxdepth: 1 - - mantidplot.pyplot <mantidplot/pyplot/index> - Reference --------- .. toctree:: diff --git a/docs/source/api/python/mantidplot/index.rst b/docs/source/api/python/mantidplot/index.rst index a2be3b03524fc5774817e24b4c160eb8f9ac71ef..ade8a9d5a160d17b240f8156464f6c441ea5b78e 100644 --- a/docs/source/api/python/mantidplot/index.rst +++ b/docs/source/api/python/mantidplot/index.rst @@ -49,7 +49,6 @@ This package defines the Python interface to the MantidPlot application. For fra newTable.rst new_proxy.rst note.rst - plot.rst plot2D.rst plot3D.rst plotBin.rst @@ -72,11 +71,3 @@ This package defines the Python interface to the MantidPlot application. For fra waterfallPlot.rst windows.rst workspace.rst - -Submodules -########## - -.. toctree:: - :maxdepth: 1 - - pyplot/index diff --git a/docs/source/api/python/mantidplot/plot.rst b/docs/source/api/python/mantidplot/plot.rst deleted file mode 100644 index bd58de32ef173d502b38ecaf0c0761ad0007ca65..0000000000000000000000000000000000000000 --- a/docs/source/api/python/mantidplot/plot.rst +++ /dev/null @@ -1,8 +0,0 @@ -====== - plot -====== - -.. module:`mantidplot` - -.. autofunction:: mantidplot.plot - diff --git a/docs/source/api/python/mantidplot/pyplot/index.rst b/docs/source/api/python/mantidplot/pyplot/index.rst deleted file mode 100644 index 824d782aa05e6b6b660935b266beaf008c64d629..0000000000000000000000000000000000000000 --- a/docs/source/api/python/mantidplot/pyplot/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -=================================================== - :mod:`pyplot` --- Matplotlib-like plotting package -=================================================== - -New plotting interface ----------------------- - -This package provides a simple command line interface to the Mantid -plotting functionality, resembling matplotlib and its pyplot package -(http://matplotlib.org). The module is subject to changes and feedback -is very much welcome! - -.. automodule:: pymantidplot.pyplot - :members: - :show-inheritance: diff --git a/docs/source/concepts/UnitFactory.rst b/docs/source/concepts/UnitFactory.rst index fa884d662317037f7259a22d9fa28634835ce84e..60c483028f2fbc15caf9c12d30da34b267f412f6 100644 --- a/docs/source/concepts/UnitFactory.rst +++ b/docs/source/concepts/UnitFactory.rst @@ -61,7 +61,7 @@ here is the Bragg scattering angle (e.g. half of the Mantid z-axis) **Note on Wavelength**: If the emode property in -:ref: `ConvertUnits <algm-ConvertUnits>` +:ref:`ConvertUnits <algm-ConvertUnits>` is specified as inelastic Direct/Indirect (inelastic) then the conversion to wavelength will take into account the fixed initial/final energy respectively. Units conversion into elastic momentum transfer diff --git a/docs/source/images/CreateSampleWorkspaceInstrument.png b/docs/source/images/CreateSampleWorkspaceInstrument.png index b9ba27860a10c651e250aec6f4f5f824df889a62..a674aa7bbf3ca52f2f6766839846b9f213be8082 100644 Binary files a/docs/source/images/CreateSampleWorkspaceInstrument.png and b/docs/source/images/CreateSampleWorkspaceInstrument.png differ diff --git a/docs/source/images/EnggDiffExampleGSASOutput.png b/docs/source/images/EnggDiffExampleGSASOutput.png new file mode 100644 index 0000000000000000000000000000000000000000..243e9b1a650f0db305ba2aed4e030806a3f3282d Binary files /dev/null and b/docs/source/images/EnggDiffExampleGSASOutput.png differ diff --git a/docs/source/images/EquivalentIntensities.png b/docs/source/images/EquivalentIntensities.png new file mode 100644 index 0000000000000000000000000000000000000000..3ae944555dee084250097a0ab8ff84d6b1e0994a Binary files /dev/null and b/docs/source/images/EquivalentIntensities.png differ diff --git a/docs/source/interfaces/Engineering Diffraction Test Guide.rst b/docs/source/interfaces/Engineering Diffraction Test Guide.rst index efd4167ac2ab2e1276e70d0aae401ec2f690393d..3cc0464e99c5b389477768fe3ef75a75cb20354b 100644 --- a/docs/source/interfaces/Engineering Diffraction Test Guide.rst +++ b/docs/source/interfaces/Engineering Diffraction Test Guide.rst @@ -156,6 +156,43 @@ Negative Testing Ideas - Change any unlocked dialog boxes whilst `Fit` runs +.. _gsas-fitting-Engineering-Diffraction_test-ref: + +GSAS Fitting +^^^^^^^^^^^^ + +GSAS-style fitting allows the user to plot peaks from their focused +NeXuS file (obtained from +:ref:`focus-Engineering_Diffraction_test-ref`). + +After a fit has run, the plot should look something like below: + +.. image:: ../images/EnggDiffExampleGSASOutput.png + +If that fit output (the red line) is flat, or just follows the +background of the data, the fit was not unsuccessful. Make sure you're +using the right ``.cif`` and ``.prm`` files for your run. You can find +an example of files which work nicely together on most PRs related to +the GSAS tab or GSASIIRefineFitPeaks, or have a look `here +<https://github.com/mantidproject/mantid/files/1739753/GSASIIRefineFitPeaks.zip>`_. + +.. warning:: At the moment, you will also just get background if you + try to do a Pawley refinement, as this is still under + development, possibly requiring input from ENGINX + scientists or GSAS-II developers (probably both) + +You can navigate around the plot in the same way as the Fitting tab. + +Negative Testing Ideas +---------------------- + +- Using an unfocused .nxs file \- Mantid shouldn't crash +- Enter bad input into the text entries - this should be handled + elegantly +- Change any unlocked dialogs and click any unlocked buttons while + refinement is running +- Cancel the algorithm before exiting the GUI, and vice verse + .. _settings-Engineering_Diffraction_test-ref: Settings diff --git a/docs/source/interfaces/Engineering Diffraction.rst b/docs/source/interfaces/Engineering Diffraction.rst index 4885ad56c1de8da7d5111e6e30d8e3739b9d2917..fa846f2dc0c094f972cc34cb097c4963ae9de276 100644 --- a/docs/source/interfaces/Engineering Diffraction.rst +++ b/docs/source/interfaces/Engineering Diffraction.rst @@ -451,6 +451,75 @@ User may plot single peak fitting workspace in separate window by using Plot To Separate Window button, if the *engggui_fitting_single_peaks* is available. +.. _gsas-Engineering_Diffraction-ref: + +GSAS Fitting +------------ + +.. warning:: This is a new capability that is currently in a very + early stage of definition and implementation. Not all + options may be supported and/or consistent at the moment. + +The GSAS tab provides a graphical interface to the Mantid algorithm +:ref:`GSASIIRefineFitPeaks <algm-GSASIIRefineFitPeaks>`. This allows +users to perform GSAS-style fitting on their data from Mantid. + +The user must input the following files: + +- **Focused run file(s)** - these must have been generated either by + the **Fitting** tab or :ref:`EnggFocus <algm-EnggFocus>`. +- **Instrument Parameter File** - contains DIFA and DIFC GSAS + constants, will probably be of ``.prm`` format +- **Phase file(s)** - contain crystallographic information about the + sample in question. Currently only ``.cif`` files are supported + +The following parameters are also required: + +- **New GSAS-II Project** - GSASIIRefineFitPeaks creates a new + ``.gpx`` project here, which can be opened and inspected from the + GSAS-II GUI +- **GSAS-II Installation Directory** + + - This is the directory containing the GSAS-II executables and + Python libraries. In particular, it must contain + ``GSASIIscriptable.py``. This directory will normally be called + `GSASII`, if GSAS-II was installed normally + - You must have a version of GSAS-II from at least **February 2018** + to use the GUI. See :ref:`Installing_GSASII` for how to install a + compatible version +- **Refinement method** - can either be **Pawley** or + **Rietveld**. Pawley refinement is currently under development, so + Rietveld is recommended. + +Optionally, you may also supply: + +- **XMin** and **XMax** - the limits (in TOF) to perform fitting + within +- **DMin** - the minimum dSpacing to use for refinement when + performing Pawley refinement +- **Negative weight** - The weight for a penalty function applied + during a Pawley refinement on resulting negative intensities. + +To do a refinement, take the following steps: + +1. Load a run by selecting the focused NeXuS file using the + corresponding **Browse** button, then clicking **Load**. The run + number and bank ID (for example ``123456_1``) should appear in the + **Run Number** list in the **Preview** section. Click the label, + and the run willl be plotted +2. Select your input files, and input any additional parameters in the + **GSASIIRefineFitPeaks Controls** section +3. Click **Run Refinement**. Once complete, fitted peaks for the run + should be overplotted in the fitting area. In addition, Rwp + (goodness of fit index), Sigma and Gamma (peak broadening + coefficients) and lattice parameters should be displayed in the + **Fit Results** section. + +You can toggle the fitted peaks on and off with the **Plot Fitted +Peaks** checkbox, remove runs from the list with the **Remove Run** +button, and plot the run and fitted peaks to a larger, separate plot +using **Plot to separate window**. + .. _setting-Engineering_Diffraction-ref: Settings diff --git a/docs/source/release/index.rst b/docs/source/release/index.rst index c0be396b981fa717d7b8d9542a36ae700f4f1841..6b1ea51957a7ae80c4b4e51f8d286eb954e7da48 100644 --- a/docs/source/release/index.rst +++ b/docs/source/release/index.rst @@ -13,6 +13,7 @@ Release Notes * :ref:`v3.13.0 <v3.13.0>` +* :ref:`v3.12.1 <v3.12.1>` * :ref:`v3.12.0 <v3.12.0>` * :ref:`v3.11.0 <v3.11.0>` * :ref:`v3.10.1 <v3.10.1>` diff --git a/docs/source/release/v3.12.0/muon.rst b/docs/source/release/v3.12.0/muon.rst index 45740fd7982bbe24c56e6baa98eaefa220881be3..bb310b1277b2d8060cb490c5dbc955ddeeada2bf 100644 --- a/docs/source/release/v3.12.0/muon.rst +++ b/docs/source/release/v3.12.0/muon.rst @@ -38,6 +38,7 @@ Bug fixes ######### - Log values are no longer filtered by start time when loaded into muon analysis. +- Different options under `Settings`>`Data Binning` give different options for input (OSX bug, see Issue ##22167). Fixed in patch. Algorithms ---------- diff --git a/docs/source/release/v3.12.0/reflectometry.rst b/docs/source/release/v3.12.0/reflectometry.rst index b5e0ba2ba044d3ac637e5b80b5bcdbf158d6170a..ad414a4088bc5a283f4836f64e55c233719e9477 100644 --- a/docs/source/release/v3.12.0/reflectometry.rst +++ b/docs/source/release/v3.12.0/reflectometry.rst @@ -37,6 +37,7 @@ New features - CorrectDetectors - SummationType - ReductionType +- There is a new checkbox on the SaveASCII tab which automatically saves the 'IvsQ_binned' workspace for single row reductions and the stitched workspace for group reductions. Improvements ############ diff --git a/docs/source/release/v3.12.1/index.rst b/docs/source/release/v3.12.1/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..438f8b0e7be70b92e3653b33806fb5a33038e4c2 --- /dev/null +++ b/docs/source/release/v3.12.1/index.rst @@ -0,0 +1,90 @@ +.. _v3.12.1: + +=========================== +Mantid 3.12.1 Release Notes +=========================== + +.. contents:: Table of Contents + :local: + +This is a patch release that corrects some significant issues since :ref:`version 3.12.0 <v3.12.0>`. + +The main changes are: + +* Several fixes to the Muon Analysis GUI, including to the results table and fit menu. +* Several issues which caused mantid to crash have been fixed. +* Allowing the live listener funtionality to be used outside ISIS and from the python API. +* Fixing the header for TOPAS files. +* Removed version 1 of ``ReflectometryReductionOne`` and ``ReflectometryReductionOneAuto`` + +Citation +-------- + +Please cite any usage of Mantid as follows: + +- *Mantid 3.12.1: Manipulation and Analysis Toolkit for Instrument Data.; Mantid Project*. + `doi: 10.5286/Software/Mantid3.12.1 <http://dx.doi.org/10.5286/Software/Mantid3.12.1>`_ + +- Arnold, O. et al. *Mantid-Data Analysis and Visualization Package for Neutron Scattering and mu-SR Experiments.* Nuclear Instruments + and Methods in Physics Research Section A: Accelerators, Spectrometers, Detectors and Associated Equipment 764 (2014): 156-166 + `doi: 10.1016/j.nima.2014.07.029 <https://doi.org/10.1016/j.nima.2014.07.029>`_ + (`download bibtex <https://raw.githubusercontent.com/mantidproject/mantid/master/docs/source/mantid.bib>`_) + +Changes in this version +----------------------- + +* `22205 <https://github.com/mantidproject/mantid/pull/22205>`_ Fix header for TOPAS files +* `22213 <https://github.com/mantidproject/mantid/pull/22215>`_ Fix bug when using StartLiveData through Python API +* `22195 <https://github.com/mantidproject/mantid/pull/22195>`_ CrystalField Multi-spectrum resolution model segfault +* `22194 <https://github.com/mantidproject/mantid/pull/22194>`_ SofQW3 segfault +* `22190 <https://github.com/mantidproject/mantid/pull/22190>`_ OSX Muon Interface (No need for data) +* `22182 <https://github.com/mantidproject/mantid/pull/22182>`_ Update mslice to fix issue with matplotlib < 1.5 +* `22200 <https://github.com/mantidproject/mantid/pull/22200>`_ Fix unreliable tests: Disable ClearCache doc test +* `22244 <https://github.com/mantidproject/mantid/pull/22244>`_ MR: correct dQ +* `22178 <https://github.com/mantidproject/mantid/pull/22178>`_ Muon Analysis bug that disabled fit menu +* `22177 <https://github.com/mantidproject/mantid/pull/22177>`_ Muon analysis and results table +* `21655 <https://github.com/mantidproject/mantid/pull/21655>`_ Remove dependence of Kafka Live Listener on ISIS specific event data +* `22226 <https://github.com/mantidproject/mantid/pull/22226>`_ Error when deleting a workspace group in MantidPlot +* `20997 <https://github.com/mantidproject/mantid/pull/20997>`_ Re #20991: Updated Reflectometry IDFs + +Summary of impact +----------------- + ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| Issue | Impact | Solution | Side Effect | +| | | | Probability | ++=======+=========================================================================================+===========================+==============+ +| 22205 | Fix header for TOPAS files | Check for header type | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22215 | Fix bug when using StartLiveData through Python API | Remove kwarg if None | **medium** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22195 | CrystalField Multi-spectrum resolution model segfault | Check sizes | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22194 | SofQW3 segfault no longer occurs | Indexing change | **medium** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22190 | OSX Muon Interface data requirments fixed | GUI changes | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22182 | Update mslice to fix issue with matplotlib < 1.5 | Update sha1 | **medium** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22200 | Fix unreliable tests: Disable ClearCache doc test | Clear cache before build | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22244 | Fix dQ calculation in MR Reduction | Now uses radians | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22178 | Fix menu is Muon Analysis not disabled | Change enabled conditions | **medium** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22177 | Muon analysis results table generated correctly | Additional checks | **medium** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 21655 | Remove dependence of Kafka Live Listener on ISIS specific event data | Remove dependence | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 22226 | Error when deleting a workspace group in MantidPlot | Better thread safety | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 20997 | Updated Reflectometry IDFs | Changed IDFs | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ +| 20997 | Removed version 1 of ``ReflectometryReductionOne`` and ``ReflectometryReductionOneAuto``| Removed old algorithms | **low** | ++-------+-----------------------------------------------------------------------------------------+---------------------------+--------------+ + +.. _download page: http://download.mantidproject.org + +.. _forum: http://forum.mantidproject.org + +.. _GitHub release page: https://github.com/mantidproject/mantid/releases/tag/v3.12.1 diff --git a/docs/source/release/v3.13.0/diffraction.rst b/docs/source/release/v3.13.0/diffraction.rst index efd09463d072fd69ea153219491b7c67bd7bce2c..70306ff6672ecb254aa79d648ab36e11f1a62bc8 100644 --- a/docs/source/release/v3.13.0/diffraction.rst +++ b/docs/source/release/v3.13.0/diffraction.rst @@ -14,4 +14,20 @@ New Features - :ref:`PowderDiffILLDetEffCorr <algm-PowderDiffILLDetEffCorr>` is extended to compute the detector efficiencies also for the 2-dimensional scanning diffractometer D2B at the ILL. + +Engineering Diffraction +----------------------- + +- GSASIIRefineFitPeaks is now run asynchronously in the GUI, so the GSAS tab no longer locks when a refinement is run + :ref:`Release 3.13.0 <v3.13.0>` + +Single Crystal Diffraction +-------------------------- + +Improvements +############ + +- PeaksWorkspace has column added for the unique peak number so peaks can be found after sorting or filtering. + +- :ref:`StatisticsOfPeaksWorkspace <algm-StatisticsOfPeaksWorkspace>` has option to use a weighted Z score for determining which peaks are outliers and has a new output workspace for plotting intensities of equivalent peaks. diff --git a/docs/source/release/v3.13.0/framework.rst b/docs/source/release/v3.13.0/framework.rst index 89615c6d35261d2aed07bc4f826ef7c78cddfc20..178d86feb6ff920824bc8d6ff5348f28859968e3 100644 --- a/docs/source/release/v3.13.0/framework.rst +++ b/docs/source/release/v3.13.0/framework.rst @@ -9,4 +9,33 @@ Framework Changes putting new features at the top of the section, followed by improvements, followed by bug fixes. + +Algorithms +---------- + +New Features +############ + +- A list of Related Algorithms has been added to each algorithm, and is displayed in the documentation page of each algorithm as part of it's summary. + +New Algorithms +############## + + +Improved +######## + +- :ref:`Maxent <algm-Maxent>` when outputting the results of the iterations, it no longer pads with zeroes but + returns as many items as iterations done for each spectrum, making the iterations easy to count. +- :ref:`ConvertToPointData <algm-ConvertToPointData>` and :ref:`ConvertToHistogram <algm-ConvertToHistogram>` now propagate the Dx errors to the output. +- The algorithm :ref:`CreateWorkspace <algm-CreateWorkspace>` can now optionally receive the Dx errors. +- :ref:`ConjoinXRuns <algm-ConjoinXRuns>` joins Dx errors if present +- The algorithm :ref:`SortXAxis <algm-SortXAxis>` has a new input option that allows ascending (default) and descending sorting. Furthermore, Dx values will be considered if present. The documentation needed to be corrected. + +Bug fixes +######### + +- The documentation of the algorithm :ref:`algm-CreateSampleWorkspace` did not match its implementation. The axis in beam direction will now be correctly described as Z instead of X. +- The :ref:`ExtractMask <algm-ExtractMask>` algorithm now returns a non-empty list of detector ID's when given a MaskWorkspace. + :ref:`Release 3.13.0 <v3.13.0>` diff --git a/docs/source/release/v3.13.0/index.rst b/docs/source/release/v3.13.0/index.rst index a1dc52a6f3627e038555bcdce0f137a7271d8f88..ff34eec1b9cd51f35929d4bdf5f12502bb20c18f 100644 --- a/docs/source/release/v3.13.0/index.rst +++ b/docs/source/release/v3.13.0/index.rst @@ -36,6 +36,7 @@ Changes SANS <sans> Direct Inelastic <direct_inelastic> Indirect Inelastic <indirect_inelastic> + Instrument Visualization <instrument_view> Full Change Listings -------------------- diff --git a/docs/source/release/v3.13.0/instrument_view.rst b/docs/source/release/v3.13.0/instrument_view.rst new file mode 100644 index 0000000000000000000000000000000000000000..fadb882e2b08d29dddf462d71fab4869629844a8 --- /dev/null +++ b/docs/source/release/v3.13.0/instrument_view.rst @@ -0,0 +1,36 @@ +======================== +Instrument Visualization +======================== + +.. contents:: Table of Contents + :local: + +.. warning:: **Developers:** Sort changes under appropriate heading + putting new features at the top of the section, followed by + improvements, followed by bug fixes. + +Instrument View +--------------- + +The `Instrument View <https://www.mantidproject.org/MantidPlot:_Instrument_View>`__ visualization tool in Mantid has undergone some major changes under-the-hood which has resulted in a smoother, more responsive interface. +Instruments generally load faster as well. Below are a few noteworthy improvements to load times: + ++------------+-----------+ +| Instrument | Speedup | ++============+===========+ +| WISH | 5x | ++------------+-----------+ +| BASIS | 5x | ++------------+-----------+ +| GEM | 4x | ++------------+-----------+ +| SANS2D | 3x | ++------------+-----------+ +| POLARIS | 3x | ++------------+-----------+ +| CNCS | 2x | ++------------+-----------+ + +Tested on Windows 10. + +:ref:`Release 3.13.0 <v3.13.0>` \ No newline at end of file diff --git a/docs/source/release/v3.13.0/muon.rst b/docs/source/release/v3.13.0/muon.rst index 38a16b54f58a426ff6072735474fc87fca8d2e88..ab2cf91ed6c4141c1587ec51e400478ed6732103 100644 --- a/docs/source/release/v3.13.0/muon.rst +++ b/docs/source/release/v3.13.0/muon.rst @@ -4,9 +4,34 @@ MuSR Changes .. contents:: Table of Contents :local: + +Interface +--------- -.. warning:: **Developers:** Sort changes under appropriate heading - putting new features at the top of the section, followed by - improvements, followed by bug fixes. + +Interface +--------- + + +Improvements +############ + +Bug fixes +######### + +- Results table can now detect sequential fits. +- Fit options are not disabled after changing tabs. + +Algorithms +---------- + +New +### + +Improvements +############ + +Bug fixes +######### :ref:`Release 3.13.0 <v3.13.0>` diff --git a/docs/source/release/v3.13.0/reflectometry.rst b/docs/source/release/v3.13.0/reflectometry.rst index 7875f5476718bb0ae1ecf8099b01eb44bb63ea75..ee30ef43919a1a6e05ccc669a8ffc37d4722550b 100644 --- a/docs/source/release/v3.13.0/reflectometry.rst +++ b/docs/source/release/v3.13.0/reflectometry.rst @@ -9,4 +9,36 @@ Reflectometry Changes putting new features at the top of the section, followed by improvements, followed by bug fixes. +ISIS Reflectometry Interface +---------------------------- + +New features +############ + +Improvements +############ + +Bug fixes +######### + +Features Removed +################ + +* Added deprecation notice to ISIS Reflectometry (Old) due to be removed in March 2019. + +Algorithms +---------- + +* Removed version 1 of ``ReflectometryReductionOne`` and ``ReflectometryReductionOneAuto``. + +New features +############ + + +Improvements +############ + +Bug fixes +######### + :ref:`Release 3.13.0 <v3.13.0>` diff --git a/docs/source/release/v3.13.0/ui.rst b/docs/source/release/v3.13.0/ui.rst index 95ee154539c65bee7820b8b8540501c11c065cc5..57924a01424272acb984a5a9dd05d8daa2d3c4b0 100644 --- a/docs/source/release/v3.13.0/ui.rst +++ b/docs/source/release/v3.13.0/ui.rst @@ -10,3 +10,9 @@ UI & Usability Changes improvements, followed by bug fixes. :ref:`Release 3.13.0 <v3.13.0>` + + +MantidPlot +---------- + +- MantidPlot's pyplot API has been removed. diff --git a/docs/source/techniques/Directtools Python module.rst b/docs/source/techniques/Directtools Python module.rst deleted file mode 100644 index 6dcf5a66b8847f623cdb8cb439d3409d5daa4c26..0000000000000000000000000000000000000000 --- a/docs/source/techniques/Directtools Python module.rst +++ /dev/null @@ -1,19 +0,0 @@ -.. _Directtools Python module: - -================== -:mod:`directtools` -================== - -:literal:`directtools` is a Python module for quickly plotting standardized :math:`S(Q,E)` color fill plots as well as line profiles (cuts) in constant :math:`Q` and :math:`E`. The module also provides a few utility functions for inspecting and manipulating the :math:`S(Q,E)` workspace. - -Reference -========= - -.. autoclass:: directtools.SampleLogs - :members: __init__ - -.. automodule:: directtools - :members: dynamicsusceptibility, nanminmax, plotcuts, plotprofiles, plotconstE, - plotconstQ, plotSofQW, subplots, validQ, wsreport - -.. categories:: Techniques diff --git a/docs/source/techniques/DirecttoolsPythonModule.rst b/docs/source/techniques/DirecttoolsPythonModule.rst new file mode 100644 index 0000000000000000000000000000000000000000..0f78bf1aea744bae77fbdfd061040d169c13d7ec --- /dev/null +++ b/docs/source/techniques/DirecttoolsPythonModule.rst @@ -0,0 +1,147 @@ +.. _Directtools Python module: + +================== +:mod:`directtools` +================== + +:mod:`directtools` is a Python module for quickly plotting standardized :math:`S(Q,E)` color fill plots as well as line profiles (cuts) in constant :math:`Q` and :math:`E`. The module also provides a few utility functions for inspecting and manipulating the :math:`S(Q,E)` workspace. + +For a general introduction on using :mod:`matplotlib` with Mantid, see :ref:`this introduction <plotting>` + +The input workspaces are expected to have some specific sample logs, namely ``instrument.name``, ``Ei``, ``run_number``, ``start_time``, ``sample.temperature``. + +Examples +######## + +The default parameters for :func:`directtools.plotSofQW` give a view of the :math:`S(Q,E)` workspace around the elastic peak with sensible limits for the axes and intensity: + +.. plot:: + :include-source: + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + fig, ax = dt.plotSofQW('SofQW') + #fig.show() + +The :math:`Q`, :math:`E` and intensity limits can be changed using the optional parameters. The utility functions :func:`directtools.validQ` and :func:`directtools.nanminmax` might be helpful when determining suitable ranges: + +.. plot:: + :include-source: + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + EMin = -20. + QMax = dt.validQ('SofQW', EMin)[1] + VMax = 0.5 * dt.nanminmax('SofQW')[1] + + fig, axes = dt.plotSofQW('SofQW', QMax=QMax, EMin=EMin, VMax=VMax) + #fig.show() + +An important aspect of examining the :math:`S(Q,E)` workspace is to plot cuts at constant :math:`Q` and :math:`E`. This can be done by :func:`directtools.plotconstQ` and :func:`directtools.plotconstE`: + +.. plot:: + :include-source: + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + Q = 2. + dQ = 0.2 + fig, axes, cuts = dt.plotconstQ('SofQW', Q, dQ) + #fig.show() + +Any of the workspace, cut centre or cut width arguments can be a :class:`list` instead. This enables data comparison: + +.. plot:: + :include-source: + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + Q1 = 2. + Q2 = 3. + dQ = 0.2 + fig, axes, cuts = dt.plotconstQ('SofQW', [Q1, Q2], dQ) + #fig.show() + +The :func:`directtools.plotconstQ` and :func:`directtools.plotconstE` functions use :func:`directtools.plotcuts` to do the actual line profiles and plotting. The profiles are made by the :ref:`algm-LineProfile` algorithm, and all three plotting functions return a list of the produced line profile workspace names. + +If a line profile already exists, it can be plotted using :func:`directtools.plotprofiles`. This also accepts either a single line profile workspace or a list of workspaces enabling comparison: + +.. plot:: + :include-source: + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + E1 = 8. + dE = 2. + cut1 = LineProfile('SofQW', E1, dE, 'Horizontal') + label1 = 'At E = {} meV'.format(E1) + E2 = E1 - 4. + cut2 = LineProfile('SofQW', E2, dE, 'Horizontal') + label2 = 'At E = {} meV'.format(E2) + fig, axes = dt.plotprofiles([cut1, cut2], [label1, label2], style='m') + axes.legend() + #fig.show() + +:class:`directtools.SampleLogs` is a convenience class to import the sample logs of a workspace into a 'struct' like object in Python: + +.. testcode:: SampleLogsEx + + import directtools as dt + from mantid.simpleapi import * + + DirectILLCollectData(Run='ILL/IN4/084447.nxs', OutputWorkspace='data') + DirectILLReduction(InputWorkspace='data', OutputWorkspace='SofQW') + + # Works on any workspace, not just S(Q,E). + logs = dt.SampleLogs('SofQW') + print(logs.instrument.name) + print(logs.run_number) + +.. testcleanup:: SampleLogsEx + + mtd.clear() + +Output: + +.. testoutput:: SampleLogsEx + + IN4 + 84447 + +Reference +========= + +Classes +####### + +.. autoclass:: directtools.SampleLogs + :members: __init__ + +Functions +######### + +.. automodule:: directtools + :members: box2D, defaultrcParams, dynamicsusceptibility, nanminmax, plotconstE, + plotconstQ, plotcuts, plotprofiles, plotSofQW, subplots, validQ, wsreport + +.. categories:: Techniques diff --git a/docs/sphinxext/mantiddoc/directives/__init__.py b/docs/sphinxext/mantiddoc/directives/__init__.py index f6e7c496ec600f27ad1f1ae1b1f68f7995899d6d..7b4e06361b25012c7175753995a1616780980f5c 100644 --- a/docs/sphinxext/mantiddoc/directives/__init__.py +++ b/docs/sphinxext/mantiddoc/directives/__init__.py @@ -8,12 +8,12 @@ """ import mantiddoc.directives.algorithm -import mantiddoc.directives.alias import mantiddoc.directives.attributes import mantiddoc.directives.categories import mantiddoc.directives.diagram import mantiddoc.directives.interface import mantiddoc.directives.properties +import mantiddoc.directives.relatedalgorithms import mantiddoc.directives.sourcelink import mantiddoc.directives.summary @@ -25,11 +25,11 @@ def setup(app): app: The main Sphinx application object """ algorithm.setup(app) - alias.setup(app) attributes.setup(app) categories.setup(app) diagram.setup(app) interface.setup(app) properties.setup(app) + relatedalgorithms.setup(app) sourcelink.setup(app) summary.setup(app) diff --git a/docs/sphinxext/mantiddoc/directives/alias.py b/docs/sphinxext/mantiddoc/directives/alias.py deleted file mode 100644 index 5b6b6b9714c2334890dbfe4eaefe05a7b0d46f78..0000000000000000000000000000000000000000 --- a/docs/sphinxext/mantiddoc/directives/alias.py +++ /dev/null @@ -1,34 +0,0 @@ -from mantiddoc.directives.base import AlgorithmBaseDirective #pylint: disable=unused-import - - -class AliasDirective(AlgorithmBaseDirective): - - """ - Obtains the alias for a given algorithm based on it's name. - """ - - required_arguments, optional_arguments = 0, 0 - - def execute(self): - """ - Called by Sphinx when the ..alias:: directive is encountered. - """ - alg = self.create_mantid_algorithm(self.algorithm_name(), self.algorithm_version()) - alias = alg.alias() - if len(alias) == 0: - return [] - - self.add_rst(self.make_header("Alias")) - format_str = "This algorithm is also known as: **%s**" - self.add_rst(format_str % alias) - - return [] - -def setup(app): - """ - Setup the directives when the extension is activated - - Args: - app: The main Sphinx application object - """ - app.add_directive('alias', AliasDirective) diff --git a/docs/sphinxext/mantiddoc/directives/base.py b/docs/sphinxext/mantiddoc/directives/base.py index 3c73c1a4022ae9e62d0a147031753c9d195e778c..7d1884f27f21c33284b2b5059c1c61061a770c17 100644 --- a/docs/sphinxext/mantiddoc/directives/base.py +++ b/docs/sphinxext/mantiddoc/directives/base.py @@ -82,22 +82,32 @@ class BaseDirective(Directive): """ return self.state.document.settings.env.docname - def make_header(self, name, pagetitle=False): + def make_header(self, name, pagetitle=False, level=2): """ Makes a ReStructuredText title from the algorithm's name. Args: algorithm_name (str): The name of the algorithm to use for the title. - pagetitle (bool): If True, line is inserted above & below algorithm name. + pagetitle (bool): If True, this sets the level to 1 (overriding any other value). + level (int): 1-4 the level of the heading to be used. Returns: str: ReST formatted header with algorithm_name as content. """ + level_dict = {1:"=", 2:"-", 3:"#", 4:"^"} + if pagetitle: - line = "\n" + "=" * (len(name) + 1) + "\n" + level = 1 + if level not in level_dict: + env = self.state.document.settings.env + env.app.warn('base.make_header - Did not understand level ' +str(level)) + level = 2 + + line = "\n" + level_dict[level] * (len(name)) + "\n" + + if level == 1: return line + name + line else: - line = "\n" + "-" * len(name) + "\n" return name + line #---------------------------------------------------------------------------------------- @@ -178,6 +188,21 @@ class AlgorithmBaseDirective(BaseDirective): self._set_algorithm_name_and_version() return self.algm_version + def create_mantid_algorithm_by_name(self, algorithm_name): + """ + Create and initializes a Mantid algorithm using tha latest version. + + Args: + algorithm_name (str): The name of the algorithm to use for the title. + + Returns: + algorithm: An instance of a Mantid algorithm. + """ + from mantid.api import AlgorithmManager + alg = AlgorithmManager.createUnmanaged(algorithm_name) + alg.initialize() + return alg + def create_mantid_algorithm(self, algorithm_name, version): """ Create and initializes a Mantid algorithm. @@ -193,7 +218,7 @@ class AlgorithmBaseDirective(BaseDirective): alg = AlgorithmManager.createUnmanaged(algorithm_name, version) alg.initialize() return alg - + def create_mantid_ifunction(self, function_name): """ Create and initiializes a Mantid IFunction. diff --git a/docs/sphinxext/mantiddoc/directives/relatedalgorithms.py b/docs/sphinxext/mantiddoc/directives/relatedalgorithms.py new file mode 100644 index 0000000000000000000000000000000000000000..9b49d8dcc9f2e72141448e31262fc06dc68b6bd3 --- /dev/null +++ b/docs/sphinxext/mantiddoc/directives/relatedalgorithms.py @@ -0,0 +1,48 @@ +from mantiddoc.directives.base import AlgorithmBaseDirective #pylint: disable=unused-import + +class relatedalgorithmsDirective(AlgorithmBaseDirective): + + """ + Obtains the see also section for a given algorithm based on it's name. + This lists similar algorithms and aliases + """ + + required_arguments, optional_arguments = 0, 0 + + def execute(self): + """ + Called by Sphinx when the ..seealso:: directive is encountered. + """ + alg = self.create_mantid_algorithm(self.algorithm_name(), self.algorithm_version()) + seeAlsoList = alg.seeAlso() + alias = alg.alias() + link_rst = "" + if seeAlsoList: + for seeAlsoEntry in seeAlsoList: + #test the algorithm exists + try: + alg = self.create_mantid_algorithm_by_name(seeAlsoEntry) + link_rst += ":ref:`%s <algm-%s>`, " % (alg.name(), alg.name()) + except RuntimeError: + env = self.state.document.settings.env + env.app.warn('relatedalgorithms - Could not find algorithm "{0}" listed in the seeAlso for {1}.v{2}'.format( + seeAlsoEntry,self.algorithm_name(), self.algorithm_version())) + + if link_rst or alias: + self.add_rst(self.make_header("See Also",level=3)) + if link_rst: + link_rst = link_rst.rstrip(", ") # remove final separator + self.add_rst(link_rst + "\n\n") + if alias: + format_str = "This algorithm is also known as: **%s**" + self.add_rst(format_str % alias) + return [] + +def setup(app): + """ + Setup the directives when the extension is activated + + Args: + app: The main Sphinx application object + """ + app.add_directive('relatedalgorithms', relatedalgorithmsDirective) diff --git a/docs/sphinxext/mantiddoc/directives/sourcelink.py b/docs/sphinxext/mantiddoc/directives/sourcelink.py index de5b791e15f505e553995eaa7feb1918bc1c6f6d..990bfbf995912c2bb821683ade0290edb47a2647 100644 --- a/docs/sphinxext/mantiddoc/directives/sourcelink.py +++ b/docs/sphinxext/mantiddoc/directives/sourcelink.py @@ -7,7 +7,7 @@ from six import iteritems import mantid from .base import AlgorithmBaseDirective #pylint: disable=unused-import -LAST_MODIFIED_UNKNOWN = 'unknown' +from mantiddoc.tools.git_last_modified import get_file_last_modified_time class SourceLinkError(Exception): @@ -66,6 +66,8 @@ class SourceLinkDirective(AlgorithmBaseDirective): } file_lookup = {} + git_cache = {} + # will be filled in __source_root = None @@ -90,7 +92,8 @@ class SourceLinkDirective(AlgorithmBaseDirective): if file_paths[extension] is None: try: fname = self.find_source_file(file_name, extension) - file_paths[extension] = (fname, self.get_file_last_modified(fname)) \ + file_paths[extension] = ( + fname, get_file_last_modified_time(self.git_cache, self.source_root, fname)) \ if fname is not None else None except SourceLinkError as err: error_string += str(err) + "\n" @@ -103,7 +106,7 @@ class SourceLinkDirective(AlgorithmBaseDirective): else: # prepend the base framework directory fname = os.path.join(self.source_root, file_paths[extension]) - file_paths[extension] = (fname, self.get_file_last_modified(fname)) + file_paths[extension] = (fname, get_file_last_modified_time(self.git_cache, self.source_root, fname)) if not os.path.exists(file_paths[extension][0]): error_string += "Cannot find {} file at {}\n".format( extension, file_paths[extension][0]) @@ -255,19 +258,6 @@ class SourceLinkDirective(AlgorithmBaseDirective): url = "https://github.com/mantidproject/mantid/blob/" + mantid.kernel.revision_full() + url return url - def get_file_last_modified(self, filename): - """ - Gets the commit timestamp of the last commit to modify a given file. - """ - if not filename: - return LAST_MODIFIED_UNKNOWN - - proc = subprocess.Popen( - ['git', 'log', '-n 1', '--pretty=format:%cd', '--date=short', filename], - cwd=self.source_root, - stdout=subprocess.PIPE) - return str(proc.stdout.read().decode('utf-8')) - def setup(app): """ diff --git a/docs/sphinxext/mantiddoc/tools/git_last_modified.py b/docs/sphinxext/mantiddoc/tools/git_last_modified.py new file mode 100644 index 0000000000000000000000000000000000000000..d060d5b5be4473c4dacca945297261632eef98be --- /dev/null +++ b/docs/sphinxext/mantiddoc/tools/git_last_modified.py @@ -0,0 +1,53 @@ +import os +import re +import subprocess + + +LAST_MODIFIED_UNKNOWN = 'unknown' + + +def cache_subtree(cache, root, path): + proc = subprocess.Popen( + ['git', 'log', '--pretty=format:%cd', '--date=short', '--name-only', path], + cwd=root, + stdout=subprocess.PIPE) + + current_date_str = None + + date_regex = re.compile('\d\d\d\d\-\d\d\-\d\d') + filename_regex = re.compile('[\/\w,\s\-\_]+\.[A-Za-z]+') + + for line in proc.stdout: + line = str(line.decode('utf-8')).strip() + + if date_regex.match(line): + # This line contains the date that the subsequent files were last modified + current_date_str = line + + # Only take the first (most recent) appearence of each file + elif filename_regex.match(line) and line not in cache: + # This line contains a file that was modified on the last mentioned date + cache[line] = current_date_str + + +def get_file_last_modified_time(cache, root, filename): + # If cache is empty then start by caching all of Framework + # Will usually catch all the files you need + if len(cache) == 0: + cache_subtree(cache, root, 'Framework') + + source_filename = filename.replace(root, '') + if source_filename.startswith(os.path.sep): + source_filename = source_filename[1:] + + # Check if details for this file have already been cached + if source_filename not in cache: + # Cache the subtree for this file + subtree_path = os.path.dirname(filename) + cache_subtree(cache, root, subtree_path) + + # Make sure it is cached now + if source_filename not in cache: + return LAST_MODIFIED_UNKNOWN + + return cache[source_filename] diff --git a/instrument/D2B_2018-03-01_Definition.xml b/instrument/D2B_2018-03-01_Definition.xml new file mode 100644 index 0000000000000000000000000000000000000000..ae591739459fa910f3b65d38da6868b45cedc0f8 --- /dev/null +++ b/instrument/D2B_2018-03-01_Definition.xml @@ -0,0 +1,324 @@ +<?xml version="1.0" encoding="utf-8"?> +<!-- For help on the notation used to specify an Instrument Definition File see http://www.mantidproject.org/IDF --> +<instrument xmlns="http://www.mantidproject.org/IDF/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 Schema/IDFSchema.xsd" name="D2B" valid-from="2018-03-01 23:59:59" +valid-to="2100-01-31 23:59:59" last-modified="2018-03-20 14:05:02"> + <!-- Author: bush@ill.fr --> + <defaults> + <length unit="meter" /> + <angle unit="degree" /> + <reference-frame> + <!-- The z-axis is set parallel to and in the direction of the beam. The y-axis points up and the coordinate system is right handed. --> + <along-beam axis="z" /> + <pointing-up axis="y" /> + <handedness val="right" /> + </reference-frame> + </defaults> + <!-- Source position --> + <component type="monochromator"> + <location z="-2.997" /> + </component> + <type name="monochromator" is="Source" /> + <!-- Monitor position --> + <component type="monitor" idlist="monitors"> + <location z="-1.594" name="monitor" /> + </component> + <type name="monitor" is="monitor"> + <cuboid id="shape"> + <left-front-bottom-point x="-0.005" y="-0.005" z="-0.005" /> + <left-front-top-point x="-0.005" y="0.005" z="-0.005" /> + <left-back-bottom-point x="-0.005" y="-0.005" z="0.005" /> + <right-front-bottom-point x="0.005" y="-0.005" z="-0.005" /> + </cuboid> + <algebra val="shape" /> + </type> + <idlist idname="monitors"> + <id val="0" /> + </idlist> + <!-- Sample position --> + <component type="sample-position"> + <location x="0.0" y="0.0" z="0.0" /> + </component> + <type name="sample-position" is="SamplePos" /> + <!-- Detector IDs --> + <idlist idname="detectors"> + <id start="1" end="16384" /> + </idlist> + <!-- Detector list def --> + <component type="detectors" idlist="detectors"> + <location x="0.0" y="0.0" z="0.0" /> + </component> + <type name="detectors"> + <component type="standard_tube"> + <location r="1.296" t="-6.25" name="tube_1" /> + <location r="1.296" t="-7.5" name="tube_2" /> + <location r="1.296" t="-8.75" name="tube_3" /> + <location r="1.296" t="-10.0" name="tube_4" /> + <location r="1.296" t="-11.25" name="tube_5" /> + <location r="1.296" t="-12.5" name="tube_6" /> + <location r="1.296" t="-13.75" name="tube_7" /> + <location r="1.296" t="-15.0" name="tube_8" /> + <location r="1.296" t="-16.25" name="tube_9" /> + <location r="1.296" t="-17.5" name="tube_10" /> + <location r="1.296" t="-18.75" name="tube_11" /> + <location r="1.296" t="-20.0" name="tube_12" /> + <location r="1.296" t="-21.25" name="tube_13" /> + <location r="1.296" t="-22.5" name="tube_14" /> + <location r="1.296" t="-23.75" name="tube_15" /> + <location r="1.296" t="-25.0" name="tube_16" /> + <location r="1.296" t="-26.25" name="tube_17" /> + <location r="1.296" t="-27.5" name="tube_18" /> + <location r="1.296" t="-28.75" name="tube_19" /> + <location r="1.296" t="-30.0" name="tube_20" /> + <location r="1.296" t="-31.25" name="tube_21" /> + <location r="1.296" t="-32.5" name="tube_22" /> + <location r="1.296" t="-33.75" name="tube_23" /> + <location r="1.296" t="-35.0" name="tube_24" /> + <location r="1.296" t="-36.25" name="tube_25" /> + <location r="1.296" t="-37.5" name="tube_26" /> + <location r="1.296" t="-38.75" name="tube_27" /> + <location r="1.296" t="-40.0" name="tube_28" /> + <location r="1.296" t="-41.25" name="tube_29" /> + <location r="1.296" t="-42.5" name="tube_30" /> + <location r="1.296" t="-43.75" name="tube_31" /> + <location r="1.296" t="-45.0" name="tube_32" /> + <location r="1.296" t="-46.25" name="tube_33" /> + <location r="1.296" t="-47.5" name="tube_34" /> + <location r="1.296" t="-48.75" name="tube_35" /> + <location r="1.296" t="-50.0" name="tube_36" /> + <location r="1.296" t="-51.25" name="tube_37" /> + <location r="1.296" t="-52.5" name="tube_38" /> + <location r="1.296" t="-53.75" name="tube_39" /> + <location r="1.296" t="-55.0" name="tube_40" /> + <location r="1.296" t="-56.25" name="tube_41" /> + <location r="1.296" t="-57.5" name="tube_42" /> + <location r="1.296" t="-58.75" name="tube_43" /> + <location r="1.296" t="-60.0" name="tube_44" /> + <location r="1.296" t="-61.25" name="tube_45" /> + <location r="1.296" t="-62.5" name="tube_46" /> + <location r="1.296" t="-63.75" name="tube_47" /> + <location r="1.296" t="-65.0" name="tube_48" /> + <location r="1.296" t="-66.25" name="tube_49" /> + <location r="1.296" t="-67.5" name="tube_50" /> + <location r="1.296" t="-68.75" name="tube_51" /> + <location r="1.296" t="-70.0" name="tube_52" /> + <location r="1.296" t="-71.25" name="tube_53" /> + <location r="1.296" t="-72.5" name="tube_54" /> + <location r="1.296" t="-73.75" name="tube_55" /> + <location r="1.296" t="-75.0" name="tube_56" /> + <location r="1.296" t="-76.25" name="tube_57" /> + <location r="1.296" t="-77.5" name="tube_58" /> + <location r="1.296" t="-78.75" name="tube_59" /> + <location r="1.296" t="-80.0" name="tube_60" /> + <location r="1.296" t="-81.25" name="tube_61" /> + <location r="1.296" t="-82.5" name="tube_62" /> + <location r="1.296" t="-83.75" name="tube_63" /> + <location r="1.296" t="-85.0" name="tube_64" /> + <location r="1.296" t="-86.25" name="tube_65" /> + <location r="1.296" t="-87.5" name="tube_66" /> + <location r="1.296" t="-88.75" name="tube_67" /> + <location r="1.296" t="-90.0" name="tube_68" /> + <location r="1.296" t="-91.25" name="tube_69" /> + <location r="1.296" t="-92.5" name="tube_70" /> + <location r="1.296" t="-93.75" name="tube_71" /> + <location r="1.296" t="-95.0" name="tube_72" /> + <location r="1.296" t="-96.25" name="tube_73" /> + <location r="1.296" t="-97.5" name="tube_74" /> + <location r="1.296" t="-98.75" name="tube_75" /> + <location r="1.296" t="-100.0" name="tube_76" /> + <location r="1.296" t="-101.25" name="tube_77" /> + <location r="1.296" t="-102.5" name="tube_78" /> + <location r="1.296" t="-103.75" name="tube_79" /> + <location r="1.296" t="-105.0" name="tube_80" /> + <location r="1.296" t="-106.25" name="tube_81" /> + <location r="1.296" t="-107.5" name="tube_82" /> + <location r="1.296" t="-108.75" name="tube_83" /> + <location r="1.296" t="-110.0" name="tube_84" /> + <location r="1.296" t="-111.25" name="tube_85" /> + <location r="1.296" t="-112.5" name="tube_86" /> + <location r="1.296" t="-113.75" name="tube_87" /> + <location r="1.296" t="-115.0" name="tube_88" /> + <location r="1.296" t="-116.25" name="tube_89" /> + <location r="1.296" t="-117.5" name="tube_90" /> + <location r="1.296" t="-118.75" name="tube_91" /> + <location r="1.296" t="-120.0" name="tube_92" /> + <location r="1.296" t="-121.25" name="tube_93" /> + <location r="1.296" t="-122.5" name="tube_94" /> + <location r="1.296" t="-123.75" name="tube_95" /> + <location r="1.296" t="-125.0" name="tube_96" /> + <location r="1.296" t="-126.25" name="tube_97" /> + <location r="1.296" t="-127.5" name="tube_98" /> + <location r="1.296" t="-128.75" name="tube_99" /> + <location r="1.296" t="-130.0" name="tube_100" /> + <location r="1.296" t="-131.25" name="tube_101" /> + <location r="1.296" t="-132.5" name="tube_102" /> + <location r="1.296" t="-133.75" name="tube_103" /> + <location r="1.296" t="-135.0" name="tube_104" /> + <location r="1.296" t="-136.25" name="tube_105" /> + <location r="1.296" t="-137.5" name="tube_106" /> + <location r="1.296" t="-138.75" name="tube_107" /> + <location r="1.296" t="-140.0" name="tube_108" /> + <location r="1.296" t="-141.25" name="tube_109" /> + <location r="1.296" t="-142.5" name="tube_110" /> + <location r="1.296" t="-143.75" name="tube_111" /> + <location r="1.296" t="-145.0" name="tube_112" /> + <location r="1.296" t="-146.25" name="tube_113" /> + <location r="1.296" t="-147.5" name="tube_114" /> + <location r="1.296" t="-148.75" name="tube_115" /> + <location r="1.296" t="-150.0" name="tube_116" /> + <location r="1.296" t="-151.25" name="tube_117" /> + <location r="1.296" t="-152.5" name="tube_118" /> + <location r="1.296" t="-153.75" name="tube_119" /> + <location r="1.296" t="-155.0" name="tube_120" /> + <location r="1.296" t="-156.25" name="tube_121" /> + <location r="1.296" t="-157.5" name="tube_122" /> + <location r="1.296" t="-158.75" name="tube_123" /> + <location r="1.296" t="-160.0" name="tube_124" /> + <location r="1.296" t="-161.25" name="tube_125" /> + <location r="1.296" t="-162.5" name="tube_126" /> + <location r="1.296" t="-163.75" name="tube_127" /> + <location r="1.296" t="-165.0" name="tube_128" /> + </component> + </type> + <!-- Definition of standard_tube --> + <type name="standard_tube" outline="yes"> + <component type="standard_pixel"> + <location y="-0.175865234375" /> + <location y="-0.173095703125" /> + <location y="-0.170326171875" /> + <location y="-0.167556640625" /> + <location y="-0.164787109375" /> + <location y="-0.162017578125" /> + <location y="-0.159248046875" /> + <location y="-0.156478515625" /> + <location y="-0.153708984375" /> + <location y="-0.150939453125" /> + <location y="-0.148169921875" /> + <location y="-0.145400390625" /> + <location y="-0.142630859375" /> + <location y="-0.139861328125" /> + <location y="-0.137091796875" /> + <location y="-0.134322265625" /> + <location y="-0.131552734375" /> + <location y="-0.128783203125" /> + <location y="-0.126013671875" /> + <location y="-0.123244140625" /> + <location y="-0.120474609375" /> + <location y="-0.117705078125" /> + <location y="-0.114935546875" /> + <location y="-0.112166015625" /> + <location y="-0.109396484375" /> + <location y="-0.106626953125" /> + <location y="-0.103857421875" /> + <location y="-0.101087890625" /> + <location y="-0.098318359375" /> + <location y="-0.095548828125" /> + <location y="-0.092779296875" /> + <location y="-0.090009765625" /> + <location y="-0.087240234375" /> + <location y="-0.084470703125" /> + <location y="-0.081701171875" /> + <location y="-0.078931640625" /> + <location y="-0.076162109375" /> + <location y="-0.073392578125" /> + <location y="-0.070623046875" /> + <location y="-0.067853515625" /> + <location y="-0.065083984375" /> + <location y="-0.062314453125" /> + <location y="-0.059544921875" /> + <location y="-0.056775390625" /> + <location y="-0.054005859375" /> + <location y="-0.051236328125" /> + <location y="-0.048466796875" /> + <location y="-0.045697265625" /> + <location y="-0.042927734375" /> + <location y="-0.040158203125" /> + <location y="-0.037388671875" /> + <location y="-0.034619140625" /> + <location y="-0.031849609375" /> + <location y="-0.029080078125" /> + <location y="-0.026310546875" /> + <location y="-0.023541015625" /> + <location y="-0.020771484375" /> + <location y="-0.018001953125" /> + <location y="-0.015232421875" /> + <location y="-0.012462890625" /> + <location y="-0.009693359375" /> + <location y="-0.006923828125" /> + <location y="-0.004154296875" /> + <location y="-0.001384765625" /> + <location y="0.001384765625" /> + <location y="0.004154296875" /> + <location y="0.006923828125" /> + <location y="0.009693359375" /> + <location y="0.012462890625" /> + <location y="0.015232421875" /> + <location y="0.018001953125" /> + <location y="0.020771484375" /> + <location y="0.023541015625" /> + <location y="0.026310546875" /> + <location y="0.029080078125" /> + <location y="0.031849609375" /> + <location y="0.034619140625" /> + <location y="0.037388671875" /> + <location y="0.040158203125" /> + <location y="0.042927734375" /> + <location y="0.045697265625" /> + <location y="0.048466796875" /> + <location y="0.051236328125" /> + <location y="0.054005859375" /> + <location y="0.056775390625" /> + <location y="0.059544921875" /> + <location y="0.062314453125" /> + <location y="0.065083984375" /> + <location y="0.067853515625" /> + <location y="0.070623046875" /> + <location y="0.073392578125" /> + <location y="0.076162109375" /> + <location y="0.078931640625" /> + <location y="0.081701171875" /> + <location y="0.084470703125" /> + <location y="0.087240234375" /> + <location y="0.090009765625" /> + <location y="0.092779296875" /> + <location y="0.095548828125" /> + <location y="0.098318359375" /> + <location y="0.101087890625" /> + <location y="0.103857421875" /> + <location y="0.106626953125" /> + <location y="0.109396484375" /> + <location y="0.112166015625" /> + <location y="0.114935546875" /> + <location y="0.117705078125" /> + <location y="0.120474609375" /> + <location y="0.123244140625" /> + <location y="0.126013671875" /> + <location y="0.128783203125" /> + <location y="0.131552734375" /> + <location y="0.134322265625" /> + <location y="0.137091796875" /> + <location y="0.139861328125" /> + <location y="0.142630859375" /> + <location y="0.145400390625" /> + <location y="0.148169921875" /> + <location y="0.150939453125" /> + <location y="0.153708984375" /> + <location y="0.156478515625" /> + <location y="0.159248046875" /> + <location y="0.162017578125" /> + <location y="0.164787109375" /> + <location y="0.167556640625" /> + <location y="0.170326171875" /> + <location y="0.173095703125" /> + <location y="0.175865234375" /> + </component> + </type> + <type name="standard_pixel" is="detector"> + <cylinder id="shape"> + <centre-of-bottom-base x="0.0" y="-0.001384765625" z="0.0" /> + <axis x="0.0" y="1.0" z="0.0" /> + <radius val="0.000565486605872" /> + <height val="0.00276953125" /> + </cylinder> + <algebra val="shape" /> + </type> +</instrument> diff --git a/instrument/INTER_Definition.xml b/instrument/INTER_Definition.xml index f93d09929fa45b9d30ae7889b71fb57848529b70..fa286b8d69cdb06c8bc55b37896c2c6ad7c268d2 100644 --- a/instrument/INTER_Definition.xml +++ b/instrument/INTER_Definition.xml @@ -1,10 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> +<!-- For help on the notation used to specify an Instrument Definition File + see http://www.mantidproject.org/IDF --> <instrument xmlns="http://www.mantidproject.org/IDF/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd" - name="INTER" valid-from ="1900-01-31 23:59:59" - valid-to ="2100-01-31 23:59:59" - last-modified="2010-11-04 00:00:00"> + name="INTER" + valid-from="1900-01-31 23:59:59" + valid-to= "2017-02-13 23:59:59" + last-modified="2018-02-16 00:00:00"> + <defaults> <length unit="meter" /> <angle unit="degree" /> @@ -16,57 +20,34 @@ <default-view axis-view="z+"/> </defaults> - <!-- Definition of instrument specific parameters for data reduction (e.g. wavelength cutoffs etc.) , could go into paramter file - MonitorBackground= [7.6,8.5] - MonitorsToCorrect=[1] - PointDetectorStart=[0] # Note: Since we are removing the monitors in the load raw command they are not counted here. - PointDetectorStop=[0] - MultiDetectorStart=[1] - I0MonitorIndex=1 - --> - -<!-- here we need to add the other monitors --> - <!-- parameters for efficiency correction --> - <parameter name="correction" type="string"> - <value val="polynomial"/> - </parameter> - - <parameter name="polystring" type="string"> - <value val="35.5893,-24.5591,9.20375,-1.89265,0.222291,-0.0148746,0.00052709,-7.66807e-6"/> - <!--<value val="28.0051,-19.396,7.5629,-1.624,0.1986,-0.013783,0.00050478,-7.56647e-6"/>--> - </parameter> - - <!-- BRIEF DESCRIPTION OF Inter INSTRUMENT: - - Here Z=0 is defined by the neutron beam which slopes down at 2.3 deg. - from the horizon. This description is based on data provided by Tim - Charlton and Rob Dalgliesh. - - Note from Tim spreedsheet - theta is a rotation about the y axis - phi is a rotation about the x axis - chi is a rotation about the z axis - - Noticed the face of the monitors/detector shapes that faces the - beam/sample path is in this IDF defined to be the y-z plane. - - Note the status of the instrument during a run is stored in the - logfile RunNo_status.txt - --> +<!-- source and sample-position components START============================= --> + + <component type="source"> + <location z="-17.037" /> + </component> + <type name="source" is="Source"> + <properties> + 40mm(H) x 60mm(W) + </properties> + </type> + + <component type="some-surface-holder"> + <location x="0.0" y="0.0" z="0.0"/> + </component> + <type name="some-surface-holder" is="SamplePos"/> - <!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> +<!-- source and sample-position components END=============================== --> - <!-- detector components (including monitors) --> +<!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> +<!-- detector components (including monitors) --> + +<!-- ================MONITOR 1 START========================================= --> <component type="monitor1" idlist="monitor1"> - <location z="6.96" /> + <location z="-10.077" /> </component> <type name="monitor1" is="monitor"> - <!-- Shape specified at least big enough to cover the beam which - is 10mm high and 40mm wide. Note it is described as tube, hence - the choice of a cylinder shape. - --> <percent-transparency val="95" /> <cylinder id="shape"> <centre-of-bottom-base z="0.0" x="-0.02" y="0.0" /> @@ -76,17 +57,14 @@ </cylinder> <algebra val="shape" /> </type> +<!-- ================MONITOR 1 END=========================================== --> +<!-- ================MONITOR 2 START========================================= --> <component type="monitor2" idlist="monitor2"> - <location z="13.791" /> <!-- x = 23.0-5.05 --> + <location z="-3.246" /> </component> <type name="monitor2" is="monitor"> - <!-- Shape specified as a minimum needs to cover the beam which - is 10mm high and 40mm wide. The 'top' shape is included to - more easily recognise this monitor when visualised in MantidPlot. - This monitor is suppose to look a bit like a German hand grenade. - --> <percent-transparency val="95" /> <cuboid id="base"> <left-front-bottom-point z="0.04" x="-0.02" y="-0.01" /> @@ -101,23 +79,16 @@ <radius val="0.02" /> <height val="0.04" /> </cylinder> - <algebra val="base : top" /> </type> +<!-- ================MONITOR 2 END=========================================== --> +<!-- ================MONITOR 3 START========================================= --> <component type="monitor3" idlist="monitor3"> - <location z="16.785" /> <!-- 23.0-0.425 --> + <location z="-0.252" /> </component> <type name="monitor3" is="monitor"> - <!-- Shape specified as a minimum needs to cover the beam which - is 10mm high and 40mm wide. The 'top' shape is included to - more easily recognise this monitor when visualised in MantidPlot. - This monitor is suppose to look a bit like a German hand grenade. - - - - --> <percent-transparency val="95" /> <cuboid id="base"> <left-front-bottom-point z="0.04" x="-0.02" y="-0.01" /> @@ -135,26 +106,15 @@ <algebra val="base : top" /> </type> +<!-- ================MONITOR 2 END=========================================== --> +<!-- ================POINT DETECTOR START==================================== --> <component type="point-detector" idlist="point-detector"> - <location z="19.700" /> <!-- x= 23.0+2.6 --> - - <!-- Link to log file that stores the z position. This angle can be used to - calculate the z position since the distance along the x-axis between - the sample and this detector is known (2.6m). Also theta in the logfile is - assumed to in degrees, hence the reason for the pi/180=0.0174533 transformation - to radians factor in the eq attribute. - - - This calculation becomes more complex due to the detector table and height stage above it. - It should be revisited when the log files become more stable. - - We may actually want to draw in the table for clarity. - --> + <location z="2.663" /> <!-- x= 23.0+2.6 --> <parameter name="y"> - <logfile id="PD1H" eq="(value+201.0)/1000." extract-single-value-as="last_value"/> - <!--<logfile id="theta" eq="2.6*sin(value*0.0174533)" extract-single-value-as="last_value"/>--> + <!-- <logfile id="PD1H" eq="(value+201.0)/1000." extract-single-value-as="last_value"/> --> + <logfile id="theta" eq="2.663*sin(2*value*0.0174533)" extract-single-value-as="last_value"/> </parameter> </component> @@ -173,53 +133,13 @@ </cuboid> <algebra val="shape" /> </type> +<!-- ================POINT DETECTOR END====================================== --> - - <component type="point-detector2" idlist="point-detector2"> - - <location z="19.700" /> <!-- x= 23.0+2.6 --> - - <!-- Link to log file that stores the z position. This angle can be used to - calculate the z position since the distance along the x-axis between - the sample and this detector is known (2.6m). Also theta in the logfile is - assumed to in degrees, hence the reason for the pi/180=0.0174533 transformation - to radians factor in the eq attribute. - - - This calculation becomes more complex due to the detector table and height stage above it. - It should be revisited when the log files become more stable. - - We may actually want to draw in the table for clarity. - --> - <parameter name="y"> - <logfile id="PD1H" eq="(value+301.0)/1000" extract-single-value-as="last_value"/> - <!--<logfile id="Theta" eq="2.7*sin((value+1)*0.0174533)" extract-single-value-as="last_value"/> --> - </parameter> - - </component> - - <type name="point-detector2" is="detector"> - <!-- Not exactly sure about the dimensions of this one. But pretty sure - it at least covers the beam. Also, just in front of it is a slit which - at the end of day will determine which neutrons get through to this - detector I believe. - --> - <cuboid id="shape"> - <left-front-bottom-point z="0.01" x="-0.02" y="-0.005" /> - <left-front-top-point z="0.01" x="-0.02" y="0.005" /> - <left-back-bottom-point z="-0.01" x="-0.02" y="-0.005" /> - <right-front-bottom-point z="0.01" x="0.02" y="-0.005" /> - </cuboid> - <algebra val="shape" /> - </type> - - - - <!-- ################################### --> +<!-- ================LINEAR DETECTOR START=================================== --> <component type="panel" idstart="2001" idfillbyfirst="y" idstep="1" idstepbyrow="1"> - <location z="20.200" name="linear-detector"/> + <location z="3.163" name="linear-detector"/> <parameter name="y"> - <logfile id="Theta" eq="3.2*tan(value*0.0174533)-46*0.0012" extract-single-value-as="last_value"/> + <logfile id="Theta" eq="3.163*tan(2*value*0.0174533)-46*0.0012" extract-single-value-as="last_value"/> </parameter> </component> @@ -239,57 +159,12 @@ </cuboid> <algebra val="shape" /> </type> +<!-- ================LINEAR DETECTOR END-==================================== --> - - <!-- source and sample-position components --> - - <component type="source"> - <location /> - </component> - - <type name="source" is="Source"> - <properties> - 40mm(H) x 60mm(W) - </properties> - </type> - - - <component type="some-surface-holder"> - <!-- worry about linking relevant logfiles for y,z,theta,phi up later --> - <location z="17.037"/> - </component> - - <type name="some-surface-holder" is="SamplePos"> - </type> - - - <!-- other components --> - - <!-- Must change the distances below to match polref --> - - <component type="test" name="test1"> - <location z="13.200"/> - <parameter name="y"> - <value val="-0.1"/> - </parameter> - <location z="13.00" /> - <parameter name="y"> - <value val="0.1"/> - </parameter> - </component> - - <type name="test"> - <percent-transparency val="50" /> - <cuboid id="bottom"> - <left-front-bottom-point z="0.0005" x="-0.025" y="-0.03" /> - <left-front-top-point z="0.0005" x="-0.025" y="0.0" /> - <left-back-bottom-point z="-0.0005" x="-0.025" y="-0.03" /> - <right-front-bottom-point z="0.0005" x="0.025" y="-0.03" /> - </cuboid> - </type> +<!-- other components --> <component type="slit" name="slit1"> - <location z="14.801"/> + <location z="-2.236"/> <!-- This log file stores the vertical opening of slit --> <parameter name="vertical gap"> <logfile id="S1_VG" extract-single-value-as="last_value" /> @@ -297,15 +172,10 @@ <parameter name="y"> <logfile id="S1_VG" eq="-value*0.001/2.0" extract-single-value-as="last_value" /> </parameter> - - <parameter name="y2"> - <logfile id="S1_VG" eq="0.3+value*0.001/2.0" extract-single-value-as="last_value" /> - </parameter> - <location z="15.250" y="0.3"/> - </component> + </component> <component type="slit" name="slit2"> - <location z="16.724"/> + <location z="-0.313"/> <!-- This log file stores the vertical opening of this. Note this slit can also be translated in the z. However this info not stored in log file since it is not used in the data analysis process. --> @@ -315,7 +185,7 @@ </component> <component type="slit" name="slit3"> - <location z="18.200"/> <!-- x=23.0+0.960 --> + <location z="1.163"/> <!-- x=23.0+0.960 --> <!-- This log file stores the vertical opening of slit --> <parameter name="vertical gap"> <logfile id="S3_VG" extract-single-value-as="last_value" /> @@ -323,7 +193,7 @@ </component> <component type="slit" name="slit4"> - <location z="19.700"/> <!-- x=23.0+2.445 --> + <location z="2.663"/> <!-- x=23.0+2.445 --> <!-- This log file stores the vertical opening of slit. Note this slit is fixed to the point detector. --> <parameter name="vertical gap"> @@ -340,33 +210,15 @@ <right-front-bottom-point z="0.0005" x="0.025" y="-0.03" /> </cuboid> </type> - <!-- <cuboid id="top"> - <left-front-bottom-point z="0.0005" x="-0.025" y="0.01" /> - <left-front-top-point z="0.0005" x="-0.025" y="0.04" /> - <left-back-bottom-point z="-0.0005" x="-0.025" y="0.01" /> - <right-front-bottom-point z="0.0005" x="0.025" y="0.01" /> - </cuboid> - <algebra val="top : bottom" /> - <type name="slit2"></type> - <type name="slit3"></type> - <type name="slit4"></type> - --> - <component type="supermirror"> - <!-- Worry about linking relevant logfiles for z,theta up later --> <location z="28.52"/> <!-- x=32.0-3.480 --> </component> - <type name="supermirror" /> - - <!-- DETECTOR and MONITOR ID LISTS --> - - - +<!-- DETECTOR and MONITOR ID LISTS --> <idlist idname="monitor1"> <id val="1" /> </idlist> @@ -383,9 +235,6 @@ <id val="4" /> </idlist> - <idlist idname="point-detector2"> - <id val="5" /> - </idlist> <!-- <idlist idname="linear-detector"> <id start="2001" end="2240" /> diff --git a/instrument/INTER_Definition_2017.xml b/instrument/INTER_Definition_2017.xml new file mode 100644 index 0000000000000000000000000000000000000000..b29e15202d7fc3ea3acf122a9d0085d199f9f664 --- /dev/null +++ b/instrument/INTER_Definition_2017.xml @@ -0,0 +1,243 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- For help on the notation used to specify an Instrument Definition File + see http://www.mantidproject.org/IDF --> +<instrument xmlns="http://www.mantidproject.org/IDF/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd" + name="INTER" + valid-from="2017-02-14 00:00:00" + valid-to= "2100-01-31 23:59:59" + last-modified="2018-02-16 00:00:00"> + + <defaults> + <length unit="meter" /> + <angle unit="degree" /> + <reference-frame> + <along-beam axis="z" /> + <pointing-up axis="y" /> + <handedness val="right" /> + </reference-frame> + <default-view axis-view="z+"/> + </defaults> + +<!-- source and sample-position components START============================= --> + + <component type="source"> + <location z="-17.037" /> + </component> + <type name="source" is="Source"> + <properties> + 40mm(H) x 60mm(W) + </properties> + </type> + + <component type="some-surface-holder"> + <location x="0.0" y="0.0" z="0.0"/> + </component> + <type name="some-surface-holder" is="SamplePos"/> + +<!-- source and sample-position components END=============================== --> + + +<!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> +<!-- detector components (including monitors) --> + +<!-- ================MONITOR 1 START========================================= --> + <component type="monitor1" idlist="monitor1"> + <location z="-10.077" /> + </component> + + <type name="monitor1" is="monitor"> + <percent-transparency val="95" /> + <cylinder id="shape"> + <centre-of-bottom-base z="0.0" x="-0.02" y="0.0" /> + <axis z="0.0" x="1.0" y="0.0" /> + <radius val="0.01" /> + <height val="0.04" /> + </cylinder> + <algebra val="shape" /> + </type> +<!-- ================MONITOR 1 END=========================================== --> + +<!-- ================MONITOR 2 START========================================= --> + <component type="monitor2" idlist="monitor2"> + <location z="-3.246" /> + </component> + + <type name="monitor2" is="monitor"> + <percent-transparency val="95" /> + <cuboid id="base"> + <left-front-bottom-point z="0.04" x="-0.02" y="-0.01" /> + <left-front-top-point z="0.04" x="-0.02" y="0.01" /> + <left-back-bottom-point z="-0.04" x="-0.02" y="-0.01" /> + <right-front-bottom-point z="0.04" x="0.02" y="-0.01" /> + </cuboid> + + <cylinder id="top"> + <centre-of-bottom-base z="0.0" x="0.0" y="0.01" /> + <axis z="0.0" x="0.0" y="1.0" /> + <radius val="0.02" /> + <height val="0.04" /> + </cylinder> + <algebra val="base : top" /> + </type> +<!-- ================MONITOR 2 END=========================================== --> + +<!-- ================MONITOR 3 START========================================= --> + <component type="monitor3" idlist="monitor3"> + <location z="-0.252" /> + </component> + + <type name="monitor3" is="monitor"> + <percent-transparency val="95" /> + <cuboid id="base"> + <left-front-bottom-point z="0.04" x="-0.02" y="-0.01" /> + <left-front-top-point z="0.04" x="-0.02" y="0.01" /> + <left-back-bottom-point z="-0.04" x="-0.02" y="-0.01" /> + <right-front-bottom-point z="0.04" x="0.02" y="-0.01" /> + </cuboid> + + <cylinder id="top"> + <centre-of-bottom-base z="0.0" x="0.0" y="0.01" /> + <axis z="0.0" x="0.0" y="1.0" /> + <radius val="0.02" /> + <height val="0.04" /> + </cylinder> + + <algebra val="base : top" /> + </type> +<!-- ================MONITOR 2 END=========================================== --> + +<!-- ================POINT DETECTOR START==================================== --> + <component type="point-detector" idlist="point-detector"> + + <location z="2.663" /> <!-- x= 23.0+2.6 --> + <parameter name="y"> + <logfile id="PD1H" eq="(value+201.0)/1000." extract-single-value-as="last_value"/> + <!--<logfile id="theta" eq="2.6*sin(value*0.0174533)" extract-single-value-as="last_value"/>--> + </parameter> + + </component> + + <type name="point-detector" is="detector"> + <!-- Not exactly sure about the dimensions of this one. But pretty sure + it at least covers the beam. Also, just in front of it is a slit which + at the end of day will determine which neutrons get through to this + detector I believe. + --> + <cuboid id="shape"> + <left-front-bottom-point z="0.01" x="-0.02" y="-0.005" /> + <left-front-top-point z="0.01" x="-0.02" y="0.005" /> + <left-back-bottom-point z="-0.01" x="-0.02" y="-0.005" /> + <right-front-bottom-point z="0.01" x="0.02" y="-0.005" /> + </cuboid> + <algebra val="shape" /> + </type> +<!-- ================POINT DETECTOR END====================================== --> + +<!-- ================LINEAR DETECTOR START=================================== --> + <component type="panel" idstart="2001" idfillbyfirst="y" idstep="1" idstepbyrow="1"> + <location z="3.163" name="linear-detector"/> + <parameter name="y"> + <logfile id="Theta" eq="3.163*tan(2*value*0.0174533)-46*0.0012" extract-single-value-as="last_value"/> + </parameter> + + </component> + + <type name="panel" is="rectangular_detector" type="linear-detector-pixel" + xpixels="1" xstart="0.0" xstep="0.05" + ypixels="243" ystart="0.0" ystep="+0.0012" > + <properties/> + </type> + <!--"-0.0576"--> + <type name="linear-detector-pixel" is="detector"> + <cuboid id="shape"> + <left-front-bottom-point z="0.01" x="-0.025" y="-0.0006" /> + <left-front-top-point z="0.01" x="-0.025" y="0.0006" /> + <left-back-bottom-point z="-0.01" x="-0.025" y="-0.0006" /> + <right-front-bottom-point z="0.01" x="0.025" y="-0.0006" /> + </cuboid> + <algebra val="shape" /> + </type> +<!-- ================LINEAR DETECTOR END-==================================== --> + +<!-- other components --> + + <component type="slit" name="slit1"> + <location z="-2.236"/> + <!-- This log file stores the vertical opening of slit --> + <parameter name="vertical gap"> + <logfile id="S1VG" extract-single-value-as="last_value" /> + </parameter> + <parameter name="y"> + <logfile id="S1VG" eq="-value*0.001/2.0" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit2"> + <location z="-0.313"/> + <!-- This log file stores the vertical opening of this. Note this + slit can also be translated in the z. However this info not stored + in log file since it is not used in the data analysis process. --> + <parameter name="vertical gap"> + <logfile id="S2VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit3"> + <location z="1.163"/> <!-- x=23.0+0.960 --> + <!-- This log file stores the vertical opening of slit --> + <parameter name="vertical gap"> + <logfile id="S3VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit4"> + <location z="2.663"/> <!-- x=23.0+2.445 --> + <!-- This log file stores the vertical opening of slit. Note this slit + is fixed to the point detector. --> + <parameter name="vertical gap"> + <logfile id="S4VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <type name="slit"> + <percent-transparency val="50" /> + <cuboid id="bottom"> + <left-front-bottom-point z="0.0005" x="-0.025" y="-0.03" /> + <left-front-top-point z="0.0005" x="-0.025" y="0.0" /> + <left-back-bottom-point z="-0.0005" x="-0.025" y="-0.03" /> + <right-front-bottom-point z="0.0005" x="0.025" y="-0.03" /> + </cuboid> + </type> + + <component type="supermirror"> + <location z="28.52"/> <!-- x=32.0-3.480 --> + </component> + <type name="supermirror" /> + + + +<!-- DETECTOR and MONITOR ID LISTS --> + <idlist idname="monitor1"> + <id val="1" /> + </idlist> + + <idlist idname="monitor2"> + <id val="2" /> + </idlist> + + <idlist idname="monitor3"> + <id val="3" /> + </idlist> + + <idlist idname="point-detector"> + <id val="4" /> + </idlist> + + <!-- + <idlist idname="linear-detector"> + <id start="2001" end="2240" /> + </idlist> + --> +</instrument> diff --git a/instrument/SURF_Definition.xml b/instrument/SURF_Definition.xml index 41da6e13809972cc37be02ebb7e13d45b8a1e646..382c01e0c02513a1cbf825f1153fca4640082d51 100644 --- a/instrument/SURF_Definition.xml +++ b/instrument/SURF_Definition.xml @@ -1,10 +1,14 @@ <?xml version="1.0" encoding="UTF-8"?> -<instrument xmlns="http://www.mantidproject.org/IDF/1.0" +<!-- For help on the notation used to specify an Instrument Definition File + see http://www.mantidproject.org/IDF --> +<instrument xmlns="http://www.mantidproject.org/IDF/1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd" - name="SRF" valid-from ="2010-01-10 23:59:59" - valid-to ="2100-01-30 23:59:59" - last-modified="2010-11-04 00:00:00"> + name="SURF" + valid-from="2010-01-10 23:59:59" + valid-to="2017-02-13 23:59:59" + last-modified="2018-03-15 00:00:00"> + <defaults> <length unit="meter" /> <angle unit="degree" /> @@ -13,99 +17,87 @@ <pointing-up axis="y" /> <handedness val="right" /> </reference-frame> - <default-view axis-view="z-"/> + <default-view axis-view="z+"/> </defaults> - <!-- Definition of instrument specific parameters for data reduction (e.g. wavelength cutoffs etc.) , could go into paramter file - MonitorBackground= [7.6,8.5] - MonitorsToCorrect=[1] - PointDetectorStart=[0] # Note: Since we are removing the monitors in the load raw command they are not counted here. - PointDetectorStop=[0] - MultiDetectorStart=[1] - I0MonitorIndex=1 - --> - - <!-- BRIEF DESCRIPTION OF CRISP INSTRUMENT: - - Here Z=0 is defined by the neutron beam which slopes down at 1.5 deg. - from the horizon. This description is based on data provided by Tim - Charlton and Rob Dalgliesh. - - Note from Tim spreedsheet - theta is a rotation about the y axis - phi is a rotation about the x axis - chi is a rotation about the z axis - - Noticed the face of the monitors/detector shapes that faces the - beam/sample path is in this IDF defined to be the y-z plane. - - Note the status of the instrument during a run is stored in the - logfile RunNo_status.txt - --> - - - <!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> - - <!-- detector components (including monitors) --> - +<!-- source and sample-position components START============================= --> + + <component type="source"> + <location z="-8.869" /> + </component> + <type name="source" is="Source"> + <properties> + 40mm(H) x 60mm(W) + </properties> + </type> + + <component type="some-surface-holder"> + <location x="0.0" y="0.0" z="0.0"/> + </component> + <type name="some-surface-holder" is="SamplePos"/> + +<!-- source and sample-position components END=============================== --> + + +<!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> +<!-- detector components (including monitors) --> + +<!-- ================MONITOR 1 START========================================= --> <component type="monitor1" idlist="monitor1"> - <location z="7.2055"/> + <location z="-1.663"/> </component> - + <type name="monitor1" is="monitor"> <!-- Shape specified at least big enough to cover the beam which is 10mm high and 40mm wide. Note it is described as tube, hence the choice of a cylinder shape. - --> + --> <percent-transparency val="95" /> <cylinder id="shape"> <centre-of-bottom-base x="-0.02" y="0.0" z="0.0" /> - <axis x="1.0" y="0.0" z="0.0" /> + <axis x="1.0" y="0.0" z="0.0" /> <radius val="0.01" /> <height val="0.04" /> - </cylinder> + </cylinder> <algebra val="shape" /> - </type> - + </type> +<!-- ================MONITOR 1 END=========================================== --> + +<!-- ================MONITOR 2 START========================================= --> <component type="monitor2" idlist="monitor2"> - <location z="8.72" /> - </component> - + <location z="-0.149" /> + </component> + <type name="monitor2" is="monitor"> <!-- Original shape included a Sphere attached to the cuboid - but that was cosmetic only as it is not in the beam, - and was causing problems with opencascade on windows 8. - Therefore it has been removed. --> + but that was cosmetic only as it is not in the beam, + and was causing problems with opencascade on windows 8. + Therefore it has been removed. --> <percent-transparency val="95" /> <cuboid id="base"> <left-front-bottom-point x="0.02" y="-0.005" z="0.0" /> <left-front-top-point x="0.02" y="0.005" z="0.0" /> <left-back-bottom-point x="0.02" y="-0.005" z="-0.01" /> - <right-front-bottom-point x="-0.02" y="-0.005" z="0.0" /> + <right-front-bottom-point x="-0.02" y="-0.005" z="0.0" /> </cuboid> - - </type> - + </type> +<!-- ================MONITOR 2 END=========================================== --> + +<!-- ================POINT DETECTOR START==================================== --> <component type="point-detector" idlist="point-detector"> - <location z="11.43" /> - - <!-- Link to log file that stores the z position. This angle can be used to - calculate the y position since the distance along the z-axis between - the sample and this detector is known (11.43-8.869=2.561). Also theta in the logfile is - assumed to in degrees, hence the reason for the pi/180=0.0174533 transformation - to radians factor in the eq attribute. --> + <location z="2.561" /> <parameter name="y"> - <logfile id="theta" eq="2.561*sin(value*0.0174533)" /> + <logfile id="THETA" eq="2.561*sin(2*value*0.0174533)" extract-single-value-as="last_value"/> </parameter> - + </component> <type name="point-detector" is="detector"> <!-- Not exactly sure about the dimensions of this one. But pretty sure it at least covers the beam. Also, just in front of it is a slit which - at the end of day will determine which neutrons get through to this + at the end of day will determine which neutrons get through to this detector I believe. - --> + --> <cuboid id="shape"> <left-front-bottom-point x="0.02" y="-0.005" z="0.0" /> <left-front-top-point x="0.02" y="0.005" z="0.0" /> @@ -113,34 +105,20 @@ <right-front-bottom-point x="-0.02" y="-0.005" z="0.0" /> </cuboid> <algebra val="shape" /> - </type> + </type> +<!-- ================POINT DETECTOR END====================================== --> +<!-- ================AREA DETECTOR START=================================== --> <component type="panel" idstart="10001" idfillbyfirst="y" idstep="1" idstepbyrow="64"> - <location z="11.93" name="multi-detector"/> + <location z="3.061" name="multi-detector"/> </component> - - <!-- - <component type="multi-detector" idlist="multi-detector"> - --> - <!-- Link to log file that stores the z position --> -<!-- <parameter name="z"> - <logfile id="multi_det_height" eq="0.001*value" extract-single-value-as="position 1" /> - </parameter> - - <properties> - square pixels 2.2mm width in z-y direction - </properties> - - <location x="12.403" /> - </component> ---> - <type name="panel" is="rectangular_detector" type="multi-detector-pixel" + <type name="panel" is="rectangular_detector" type="multi-detector-pixel" xpixels="40" xstart="-0.044" xstep="+0.0022" ypixels="46" ystart="0.0" ystep="+0.0022" > <properties/> - </type> - + </type> + <type name="multi-detector-pixel" is="detector"> <cuboid id="shape"> <left-front-bottom-point x="0.01" y="-0.0011" z="-0.0011" /> @@ -149,65 +127,43 @@ <right-front-bottom-point x="0.01" y="0.0011" z="-0.0011" /> </cuboid> <algebra val="shape" /> - </type> + </type> - - <!-- source and sample-position components --> - <component type="source"> - <location /> - </component> - - <type name="source" is="Source"> - <properties> - 10mm(H) x 40mm(W) - </properties> - </type> - - - <component type="some-surface-holder"> - <!-- worry about linking relevant logfiles for y,z,theta,phi up later --> - <location z="8.869"/> - </component> + <!-- other components --> - <type name="some-surface-holder" is="SamplePos"> - </type> - - - <!-- other components --> - <component type="slit" name="slit1"> - <location z="7.032"/> + <location z="-1.873"/> <!-- This log file stores the vertical opening of slit --> - <parameter name="vertical gap"> + <parameter name="vertical gap"> <logfile id="S1" extract-single-value-as="last_value" /> </parameter> </component> - - <component type="slit" name="slit2"> - <location z="8.532"/> + + <component type="slit" name="slit2"> + <location z="-0.254"/> <!-- This log file stores the vertical opening of this. Note this slit can also be translated in the z. However this info not stored in log file since it is not used in the data analysis process. --> - <parameter name="vertical gap"> + <parameter name="vertical gap"> <logfile id="S2" extract-single-value-as="last_value" /> </parameter> - </component> - - <component type="slit" name="slit3"> - <location z="9.174"/> - <!-- This log file stores the vertical opening of slit --> + </component> + + <component type="slit" name="slit3"> + <location z="0.298"/> + <!-- This log file stores the vertical opening of slit --> <parameter name="vertical gap"> <logfile id="S3" extract-single-value-as="last_value" /> </parameter> - </component> - - <component type="slit" name="slit4"> - <location z="11.300"/> + </component> + + <component type="slit" name="slit4"> + <location z="2.431"/> <!-- This log file stores the vertical opening of slit. Note this slit is fixed to the point detector. --> - <parameter name="vertical gap"> - <logfile id="S4" extract-single-value-as="last_value" /> + <parameter name="vertical gap"> + <logfile id="S4" extract-single-value-as="last_value" /> </parameter> </component> @@ -220,76 +176,30 @@ <right-front-bottom-point z="0.0005" x="0.025" y="-0.03" /> </cuboid> </type> - - - - + + + <component type="supermirror"> <!-- Worry about linking relevant logfiles for z,theta up later --> - <location z="7.7685"/> - </component> - - <type name="supermirror" /> + <location z="-1.103"/> + </component> + <type name="supermirror" /> - <!-- DETECTOR and MONITOR ID LISTS --> <idlist idname="monitor1"> - <id val="20001" /> + <id val="20001" /> </idlist> - + <idlist idname="monitor2"> - <id val="20002" /> + <id val="20002" /> </idlist> <idlist idname="point-detector"> - <id val="30001" /> + <id val="30001" /> </idlist> -<!-- - <idlist idname="multi-detector"> - <id start="10001" end="10046" /> - <id start="10065" end="10110" /> - <id start="10129" end="10174" /> - <id start="10193" end="10238" /> - <id start="10257" end="10302" /> - <id start="10321" end="10366" /> - <id start="10385" end="10430" /> - <id start="10449" end="10494" /> - <id start="10513" end="10558" /> - <id start="10577" end="10622" /> - <id start="10641" end="10686" /> - <id start="10705" end="10750" /> - <id start="10769" end="10814" /> - <id start="10833" end="10878" /> - <id start="10897" end="10942" /> - <id start="10961" end="11006" /> - <id start="11025" end="11070" /> - <id start="11089" end="11134" /> - <id start="11153" end="11198" /> - <id start="11217" end="11262" /> - <id start="11281" end="11326" /> - <id start="11345" end="11390" /> - <id start="11409" end="11454" /> - <id start="11473" end="11518" /> - <id start="11537" end="11582" /> - <id start="11601" end="11646" /> - <id start="11665" end="11710" /> - <id start="11729" end="11774" /> - <id start="11793" end="11838" /> - <id start="11857" end="11902" /> - <id start="11921" end="11966" /> - <id start="11985" end="12030" /> - <id start="12049" end="12094" /> - <id start="12113" end="12158" /> - <id start="12177" end="12222" /> - <id start="12241" end="12286" /> - <id start="12305" end="12350" /> - <id start="12369" end="12414" /> - <id start="12433" end="12478" /> - <id start="12497" end="12542" /> - </idlist> - --> + </instrument> diff --git a/instrument/SURF_Definition_2017.xml b/instrument/SURF_Definition_2017.xml new file mode 100644 index 0000000000000000000000000000000000000000..4bec930ff53ae4cae65ca1babce15215822cf361 --- /dev/null +++ b/instrument/SURF_Definition_2017.xml @@ -0,0 +1,205 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- For help on the notation used to specify an Instrument Definition File + see http://www.mantidproject.org/IDF --> +<instrument xmlns="http://www.mantidproject.org/IDF/1.0" + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://www.mantidproject.org/IDF/1.0 http://schema.mantidproject.org/IDF/1.0/IDFSchema.xsd" + name="SURF" + valid-from="2017-02-14 00:00:00" + valid-to="2100-01-30 23:59:59" + last-modified="2018-03-15 00:00:00"> + + <defaults> + <length unit="meter" /> + <angle unit="degree" /> + <reference-frame> + <along-beam axis="z" /> + <pointing-up axis="y" /> + <handedness val="right" /> + </reference-frame> + <default-view axis-view="z+"/> + </defaults> + +<!-- source and sample-position components START============================= --> + + <component type="source"> + <location z="-8.869" /> + </component> + <type name="source" is="Source"> + <properties> + 40mm(H) x 60mm(W) + </properties> + </type> + + <component type="some-surface-holder"> + <location x="0.0" y="0.0" z="0.0"/> + </component> + <type name="some-surface-holder" is="SamplePos"/> + +<!-- source and sample-position components END=============================== --> + + +<!-- LIST OF PHYSICAL COMPONENTS (which the instrument consists of) --> +<!-- detector components (including monitors) --> + +<!-- ================MONITOR 1 START========================================= --> + <component type="monitor1" idlist="monitor1"> + <location z="-1.663"/> + </component> + + <type name="monitor1" is="monitor"> + <!-- Shape specified at least big enough to cover the beam which + is 10mm high and 40mm wide. Note it is described as tube, hence + the choice of a cylinder shape. + --> + <percent-transparency val="95" /> + <cylinder id="shape"> + <centre-of-bottom-base x="-0.02" y="0.0" z="0.0" /> + <axis x="1.0" y="0.0" z="0.0" /> + <radius val="0.01" /> + <height val="0.04" /> + </cylinder> + <algebra val="shape" /> + </type> +<!-- ================MONITOR 1 END=========================================== --> + +<!-- ================MONITOR 2 START========================================= --> + <component type="monitor2" idlist="monitor2"> + <location z="-0.149" /> + </component> + + <type name="monitor2" is="monitor"> + <!-- Original shape included a Sphere attached to the cuboid + but that was cosmetic only as it is not in the beam, + and was causing problems with opencascade on windows 8. + Therefore it has been removed. --> + <percent-transparency val="95" /> + <cuboid id="base"> + <left-front-bottom-point x="0.02" y="-0.005" z="0.0" /> + <left-front-top-point x="0.02" y="0.005" z="0.0" /> + <left-back-bottom-point x="0.02" y="-0.005" z="-0.01" /> + <right-front-bottom-point x="-0.02" y="-0.005" z="0.0" /> + </cuboid> + </type> +<!-- ================MONITOR 2 END=========================================== --> + +<!-- ================POINT DETECTOR START==================================== --> + <component type="point-detector" idlist="point-detector"> + <location z="2.561" /> + <parameter name="y"> + <logfile id="THETA" eq="2.561*sin(2*value*0.0174533)" extract-single-value-as="last_value"/> + </parameter> + + </component> + + <type name="point-detector" is="detector"> + <!-- Not exactly sure about the dimensions of this one. But pretty sure + it at least covers the beam. Also, just in front of it is a slit which + at the end of day will determine which neutrons get through to this + detector I believe. + --> + <cuboid id="shape"> + <left-front-bottom-point x="0.02" y="-0.005" z="0.0" /> + <left-front-top-point x="0.02" y="0.005" z="0.0" /> + <left-back-bottom-point x="0.02" y="-0.005" z="-0.01" /> + <right-front-bottom-point x="-0.02" y="-0.005" z="0.0" /> + </cuboid> + <algebra val="shape" /> + </type> +<!-- ================POINT DETECTOR END====================================== --> + +<!-- ================AREA DETECTOR START=================================== --> + <component type="panel" idstart="10001" idfillbyfirst="y" idstep="1" idstepbyrow="64"> + <location z="3.061" name="multi-detector"/> + </component> + + <type name="panel" is="rectangular_detector" type="multi-detector-pixel" + xpixels="40" xstart="-0.044" xstep="+0.0022" + ypixels="46" ystart="0.0" ystep="+0.0022" > + <properties/> + </type> + + <type name="multi-detector-pixel" is="detector"> + <cuboid id="shape"> + <left-front-bottom-point x="0.01" y="-0.0011" z="-0.0011" /> + <left-front-top-point x="0.01" y="-0.0011" z="0.0011" /> + <left-back-bottom-point x="-0.01" y="-0.0011" z="-0.0011" /> + <right-front-bottom-point x="0.01" y="0.0011" z="-0.0011" /> + </cuboid> + <algebra val="shape" /> + </type> + + + <!-- other components --> + + <component type="slit" name="slit1"> + <location z="-1.873"/> + <!-- This log file stores the vertical opening of slit --> + <parameter name="vertical gap"> + <logfile id="S1VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit2"> + <location z="-0.254"/> + <!-- This log file stores the vertical opening of this. Note this + slit can also be translated in the z. However this info not stored + in log file since it is not used in the data analysis process. --> + <parameter name="vertical gap"> + <logfile id="S2VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit3"> + <location z="0.298"/> + <!-- This log file stores the vertical opening of slit --> + <parameter name="vertical gap"> + <logfile id="S3VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <component type="slit" name="slit4"> + <location z="2.431"/> + <!-- This log file stores the vertical opening of slit. Note this slit + is fixed to the point detector. --> + <parameter name="vertical gap"> + <logfile id="S4VG" extract-single-value-as="last_value" /> + </parameter> + </component> + + <type name="slit"> + <percent-transparency val="50" /> + <cuboid id="bottom"> + <left-front-bottom-point z="0.0005" x="-0.025" y="-0.03" /> + <left-front-top-point z="0.0005" x="-0.025" y="0.0" /> + <left-back-bottom-point z="-0.0005" x="-0.025" y="-0.03" /> + <right-front-bottom-point z="0.0005" x="0.025" y="-0.03" /> + </cuboid> + </type> + + + + + <component type="supermirror"> + <!-- Worry about linking relevant logfiles for z,theta up later --> + <location z="-1.103"/> + </component> + + <type name="supermirror" /> + + + <!-- DETECTOR and MONITOR ID LISTS --> + + <idlist idname="monitor1"> + <id val="20001" /> + </idlist> + + <idlist idname="monitor2"> + <id val="20002" /> + </idlist> + + <idlist idname="point-detector"> + <id val="30001" /> + </idlist> + +</instrument> diff --git a/qt/paraview_ext/PVPlugins/Sources/MDEWSource/vtkMDEWSource.cxx b/qt/paraview_ext/PVPlugins/Sources/MDEWSource/vtkMDEWSource.cxx index a1124c1485d3335d41d18a9a78f0d839b1147ea0..73df2744afcee72234a0bfef4501d8bc0270e2d3 100644 --- a/qt/paraview_ext/PVPlugins/Sources/MDEWSource/vtkMDEWSource.cxx +++ b/qt/paraview_ext/PVPlugins/Sources/MDEWSource/vtkMDEWSource.cxx @@ -38,7 +38,7 @@ vtkStandardNewMacro(vtkMDEWSource) } /// Destructor -vtkMDEWSource::~vtkMDEWSource() {} +vtkMDEWSource::~vtkMDEWSource() = default; /* Setter for the recursion depth diff --git a/qt/paraview_ext/VatesAPI/inc/MantidVatesAPI/Normalization.h b/qt/paraview_ext/VatesAPI/inc/MantidVatesAPI/Normalization.h index e85e8c1a0b30369257c62fbbc2f1d0ddddb7207e..f66f86b272172f7b919d147fc5d54745269765da 100644 --- a/qt/paraview_ext/VatesAPI/inc/MantidVatesAPI/Normalization.h +++ b/qt/paraview_ext/VatesAPI/inc/MantidVatesAPI/Normalization.h @@ -4,6 +4,8 @@ #include "MantidAPI/DllConfig.h" #include "MantidGeometry/MDGeometry/MDTypes.h" +#include <memory> + namespace Mantid { namespace API { @@ -50,7 +52,7 @@ NormFuncIMDNodePtr makeMDEventNormalizationFunction( Determine which normalization function will be called on an IMDIterator of an IMDWorkspace */ -DLLExport Mantid::API::IMDIterator * +DLLExport std::unique_ptr<Mantid::API::IMDIterator> createIteratorWithNormalization(const VisualNormalization normalizationOption, Mantid::API::IMDWorkspace const *const ws); } diff --git a/qt/paraview_ext/VatesAPI/src/Normalization.cpp b/qt/paraview_ext/VatesAPI/src/Normalization.cpp index bea3316f82ca7756f1490c8f45693544f775f67c..46492b4e88a20db7178d32a5e52de3eaa986d8f3 100644 --- a/qt/paraview_ext/VatesAPI/src/Normalization.cpp +++ b/qt/paraview_ext/VatesAPI/src/Normalization.cpp @@ -46,7 +46,7 @@ Create iterators with correct normalization normalization to an IMDIterator. @param ws : workspace to fetch defaults from if needed @return new IMDIterator */ -DLLExport Mantid::API::IMDIterator * +DLLExport std::unique_ptr<Mantid::API::IMDIterator> createIteratorWithNormalization(const VisualNormalization normalizationOption, Mantid::API::IMDWorkspace const *const ws) { @@ -63,7 +63,7 @@ createIteratorWithNormalization(const VisualNormalization normalizationOption, } // Create the iterator - IMDIterator *iterator = ws->createIterator(); + auto iterator = ws->createIterator(); // Set normalization iterator->setNormalization(targetNormalization); // Return it diff --git a/qt/paraview_ext/VatesAPI/src/vtkMDHexFactory.cpp b/qt/paraview_ext/VatesAPI/src/vtkMDHexFactory.cpp index d4da34d2b69f59a362d4b467a14c297d65725387..ba303cfe6ac8f0047fefa9fc9964103aeb7c3de8 100644 --- a/qt/paraview_ext/VatesAPI/src/vtkMDHexFactory.cpp +++ b/qt/paraview_ext/VatesAPI/src/vtkMDHexFactory.cpp @@ -128,11 +128,9 @@ void vtkMDHexFactory::doCreate( // If slicing down to 3D, specify which dimensions to keep. if (this->slice) { - coords = std::unique_ptr<coord_t[]>( - box->getVertexesArray(numVertexes, 3, this->sliceMask.get())); + coords = box->getVertexesArray(numVertexes, 3, this->sliceMask.get()); } else { - coords = - std::unique_ptr<coord_t[]>(box->getVertexesArray(numVertexes)); + coords = box->getVertexesArray(numVertexes); } if (numVertexes == 8) { std::copy_n(coords.get(), 24, std::next(pointsPtr, i * 24)); diff --git a/qt/paraview_ext/VatesAPI/src/vtkMDHistoQuadFactory.cpp b/qt/paraview_ext/VatesAPI/src/vtkMDHistoQuadFactory.cpp index 71e0e15560f99b0001ea69e3d03f3a9878126f47..bbce429bbf827e6ed6bbb6887ca963879fcf5f2e 100644 --- a/qt/paraview_ext/VatesAPI/src/vtkMDHistoQuadFactory.cpp +++ b/qt/paraview_ext/VatesAPI/src/vtkMDHistoQuadFactory.cpp @@ -88,10 +88,9 @@ vtkMDHistoQuadFactory::create(ProgressAction &progressUpdating) const { coord_t incrementX = (maxX - minX) / static_cast<coord_t>(nBinsX); coord_t incrementY = (maxY - minY) / static_cast<coord_t>(nBinsY); - boost::scoped_ptr<MDHistoWorkspaceIterator> iterator( - dynamic_cast<MDHistoWorkspaceIterator *>( - createIteratorWithNormalization(m_normalizationOption, - m_workspace.get()))); + auto it = createIteratorWithNormalization(m_normalizationOption, + m_workspace.get()); + auto iterator = dynamic_cast<MDHistoWorkspaceIterator *>(it.get()); if (!iterator) { throw std::runtime_error( "Could not convert IMDIterator to a MDHistoWorkspaceIterator"); diff --git a/qt/paraview_ext/VatesAPI/src/vtkMDLineFactory.cpp b/qt/paraview_ext/VatesAPI/src/vtkMDLineFactory.cpp index 3379a5bf4a51a0d2e2d2ed3cc3b3c96e7aba6c42..38e144b2aec2f4fd9f29fb147e911e4d1f2b100c 100644 --- a/qt/paraview_ext/VatesAPI/src/vtkMDLineFactory.cpp +++ b/qt/paraview_ext/VatesAPI/src/vtkMDLineFactory.cpp @@ -75,8 +75,8 @@ vtkMDLineFactory::create(ProgressAction &progressUpdating) const { } // Ensure destruction in any event. - boost::scoped_ptr<IMDIterator> it( - createIteratorWithNormalization(m_normalizationOption, imdws.get())); + auto it = + createIteratorWithNormalization(m_normalizationOption, imdws.get()); // Create 2 points per box. vtkNew<vtkPoints> points; @@ -116,8 +116,8 @@ vtkMDLineFactory::create(ProgressAction &progressUpdating) const { useBox[iBox] = true; signals->InsertNextValue(static_cast<float>(signal_normalized)); - auto coords = std::unique_ptr<coord_t[]>( - it->getVertexesArray(nVertexes, nNonIntegrated, masks.get())); + auto coords = + it->getVertexesArray(nVertexes, nNonIntegrated, masks.get()); // Iterate through all coordinates. Candidate for speed improvement. for (size_t v = 0; v < nVertexes; ++v) { diff --git a/qt/paraview_ext/VatesAPI/src/vtkMDQuadFactory.cpp b/qt/paraview_ext/VatesAPI/src/vtkMDQuadFactory.cpp index 5fa55dc5f3f50d8d416945a71ad1d0064de4b72f..77fd67e7b5bd1225b8a51b1ca7f32c144c925250 100644 --- a/qt/paraview_ext/VatesAPI/src/vtkMDQuadFactory.cpp +++ b/qt/paraview_ext/VatesAPI/src/vtkMDQuadFactory.cpp @@ -71,8 +71,8 @@ vtkMDQuadFactory::create(ProgressAction &progressUpdating) const { // Make iterator, which will use the desired normalization. Ensure // destruction in any eventuality. - boost::scoped_ptr<IMDIterator> it( - createIteratorWithNormalization(m_normalizationOption, imdws.get())); + auto it = + createIteratorWithNormalization(m_normalizationOption, imdws.get()); // Create 4 points per box. vtkNew<vtkPoints> points; @@ -112,9 +112,8 @@ vtkMDQuadFactory::create(ProgressAction &progressUpdating) const { useBox[iBox] = true; signals->InsertNextValue(static_cast<float>(signal)); - auto coords = std::unique_ptr<coord_t[]>( - it->getVertexesArray(nVertexes, nNonIntegrated, masks.get())); - + auto coords = + it->getVertexesArray(nVertexes, nNonIntegrated, masks.get()); // Iterate through all coordinates. Candidate for speed improvement. for (size_t v = 0; v < nVertexes; ++v) { coord_t *coord = coords.get() + v * 2; diff --git a/qt/paraview_ext/VatesAPI/test/MockObjects.h b/qt/paraview_ext/VatesAPI/test/MockObjects.h index 25262bdcedec86053d0f0510d89286147a5a1f8b..0a58626c34f603f3d2e8a56d72503a5718fd5cef 100644 --- a/qt/paraview_ext/VatesAPI/test/MockObjects.h +++ b/qt/paraview_ext/VatesAPI/test/MockObjects.h @@ -102,7 +102,7 @@ public: return line; } - std::vector<Mantid::API::IMDIterator *> createIterators( + std::vector<std::unique_ptr<Mantid::API::IMDIterator>> createIterators( size_t = 1, Mantid::Geometry::MDImplicitFunction * = NULL) const override { throw std::runtime_error("Not Implemented"); diff --git a/qt/python/mantidqt/utils/qt/testing/__init__.py b/qt/python/mantidqt/utils/qt/testing/__init__.py index ec30caa54e0f7ce3eec82b539a7fc892e7fbf428..7aee12dd5186f33a0a0b11f28f2051f84a7ee57a 100644 --- a/qt/python/mantidqt/utils/qt/testing/__init__.py +++ b/qt/python/mantidqt/utils/qt/testing/__init__.py @@ -20,6 +20,7 @@ from __future__ import absolute_import from inspect import isfunction, ismethod +import gc from qtpy.QtCore import Qt from qtpy.QtWidgets import QApplication @@ -74,6 +75,7 @@ def _requires_qapp_impl(test_method): QAPP = QApplication(['']) test_method(self) QAPP.closeAllWindows() + gc.collect() return _wrapper diff --git a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py index 411e9f4e2e2f2b5887ac61eff3d55488d627458c..c4f2d103ae610553a13011075a47b527bd38af1d 100644 --- a/qt/python/mantidqt/widgets/test/test_jupyterconsole.py +++ b/qt/python/mantidqt/widgets/test/test_jupyterconsole.py @@ -34,16 +34,18 @@ class InProcessJupyterConsoleTest(unittest.TestCase): self.assertTrue(hasattr(widget, "kernel_manager")) self.assertTrue(hasattr(widget, "kernel_client")) self.assertTrue(len(widget.banner) > 0) + del widget def test_construction_with_banner_replaces_default(self): widget = InProcessJupyterConsole(banner="Hello!") self.assertEquals("Hello!", widget.banner) + del widget def test_construction_with_startup_code_adds_to_banner_and_executes(self): widget = InProcessJupyterConsole(startup_code="x = 1") self.assertTrue("x = 1" in widget.banner) self.assertEquals(1, widget.kernel_manager.kernel.shell.user_ns['x']) - + del widget if __name__ == '__main__': unittest.main() diff --git a/qt/scientific_interfaces/EnggDiffraction/CMakeLists.txt b/qt/scientific_interfaces/EnggDiffraction/CMakeLists.txt index 71f990d3547fb692bb83b7c0759712bc55afb729..8d9f7827172dae12201bca5493948fe99e3d3be1 100644 --- a/qt/scientific_interfaces/EnggDiffraction/CMakeLists.txt +++ b/qt/scientific_interfaces/EnggDiffraction/CMakeLists.txt @@ -5,6 +5,7 @@ set ( SRC_FILES EnggDiffGSASFittingModel.cpp EnggDiffGSASFittingPresenter.cpp EnggDiffGSASFittingViewQtWidget.cpp + EnggDiffGSASFittingWorker.cpp EnggDiffMultiRunFittingQtWidget.cpp EnggDiffMultiRunFittingWidgetAdder.cpp EnggDiffMultiRunFittingWidgetModel.cpp @@ -27,6 +28,7 @@ set ( INC_FILES EnggDiffGSASFittingModel.h EnggDiffGSASFittingPresenter.h EnggDiffGSASFittingViewQtWidget.h + EnggDiffGSASFittingWorker.h EnggDiffGSASRefinementMethod.h EnggDiffMultiRunFittingQtWidget.h EnggDiffMultiRunFittingWidgetAdder.h @@ -57,7 +59,9 @@ set ( MOC_FILES EnggDiffFittingPresenter.h EnggDiffFittingPresWorker.h EnggDiffFittingViewQtWidget.h + EnggDiffGSASFittingModel.h EnggDiffGSASFittingViewQtWidget.h + EnggDiffGSASFittingWorker.h EnggDiffractionPresenter.h EnggDiffractionPresWorker.h EnggDiffractionViewQtGUI.h diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp index 592ca3884517b5fb5cb7822027c54792ad6792b3..0aef4381f8da58456baf46f7ea545a9b275affb0 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.cpp @@ -19,20 +19,38 @@ std::string stripWSNameFromFilename(const std::string &fullyQualifiedFilename) { return filenameSegments[0]; } +std::string refinementMethodToString( + const MantidQt::CustomInterfaces::GSASRefinementMethod &method) { + switch (method) { + case MantidQt::CustomInterfaces::GSASRefinementMethod::PAWLEY: + return "Pawley refinement"; + case MantidQt::CustomInterfaces::GSASRefinementMethod::RIETVELD: + return "Rietveld refinement"; + default: + throw std::invalid_argument( + "Invalid refinement method: please contact the development team"); + } +} + } // anonymous namespace namespace MantidQt { namespace CustomInterfaces { + +EnggDiffGSASFittingModel::~EnggDiffGSASFittingModel() { + if (m_workerThread) { + if (m_workerThread->isRunning()) { + m_workerThread->wait(10); + } + } +} + void EnggDiffGSASFittingModel::addFitResultsToMaps( const RunLabel &runLabel, const double rwp, const double sigma, - const double gamma, const std::string &latticeParamsTableName) { + const double gamma, const API::ITableWorkspace_sptr latticeParams) { addRwp(runLabel, rwp); addSigma(runLabel, sigma); addGamma(runLabel, gamma); - - API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); - const auto latticeParams = - ADS.retrieveWS<API::ITableWorkspace>(latticeParamsTableName); addLatticeParams(runLabel, latticeParams); } @@ -69,34 +87,14 @@ std::string generateLatticeParamsName(const RunLabel &runLabel) { } } -API::MatrixWorkspace_sptr EnggDiffGSASFittingModel::doPawleyRefinement( - const GSASIIRefineFitPeaksParameters ¶ms) { - const auto outputWSName = generateFittedPeaksWSName(params.runLabel); - const auto latticeParamsName = generateLatticeParamsName(params.runLabel); - - const auto outputProperties = doGSASRefinementAlgorithm( - outputWSName, latticeParamsName, params, "Pawley refinement"); - - addFitResultsToMaps(params.runLabel, outputProperties.rwp, - outputProperties.sigma, outputProperties.gamma, - latticeParamsName); - - API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); - const auto fittedPeaks = ADS.retrieveWS<API::MatrixWorkspace>(outputWSName); - - return fittedPeaks; -} - GSASIIRefineFitPeaksOutputProperties EnggDiffGSASFittingModel::doGSASRefinementAlgorithm( - const std::string &outputWorkspaceName, - const std::string &latticeParamsName, - const GSASIIRefineFitPeaksParameters ¶ms, - const std::string &refinementMethod) { + const GSASIIRefineFitPeaksParameters ¶ms) { auto gsasAlg = API::AlgorithmManager::Instance().create("GSASIIRefineFitPeaks"); - gsasAlg->setProperty("RefinementMethod", refinementMethod); + gsasAlg->setProperty("RefinementMethod", + refinementMethodToString(params.refinementMethod)); gsasAlg->setProperty("InputWorkspace", params.inputWorkspace); gsasAlg->setProperty("InstrumentFile", params.instParamsFile); gsasAlg->setProperty("PhaseInfoFiles", @@ -118,7 +116,9 @@ EnggDiffGSASFittingModel::doGSASRefinementAlgorithm( gsasAlg->setProperty("RefineSigma", params.refineSigma); gsasAlg->setProperty("RefineGamma", params.refineGamma); - gsasAlg->setProperty("OutputWorkspace", outputWorkspaceName); + const auto outputWSName = generateFittedPeaksWSName(params.runLabel); + const auto latticeParamsName = generateLatticeParamsName(params.runLabel); + gsasAlg->setProperty("OutputWorkspace", outputWSName); gsasAlg->setProperty("LatticeParameters", latticeParamsName); gsasAlg->setProperty("SaveGSASIIProjectFile", params.gsasProjectFile); gsasAlg->execute(); @@ -126,25 +126,44 @@ EnggDiffGSASFittingModel::doGSASRefinementAlgorithm( const double rwp = gsasAlg->getProperty("Rwp"); const double sigma = gsasAlg->getProperty("Sigma"); const double gamma = gsasAlg->getProperty("Gamma"); - return GSASIIRefineFitPeaksOutputProperties(rwp, sigma, gamma); -} - -API::MatrixWorkspace_sptr EnggDiffGSASFittingModel::doRietveldRefinement( - const GSASIIRefineFitPeaksParameters ¶ms) { - const auto outputWSName = generateFittedPeaksWSName(params.runLabel); - const auto latticeParamsName = generateLatticeParamsName(params.runLabel); - - const auto outputProperties = doGSASRefinementAlgorithm( - outputWSName, latticeParamsName, params, "Rietveld refinement"); - - addFitResultsToMaps(params.runLabel, outputProperties.rwp, - outputProperties.sigma, outputProperties.gamma, - latticeParamsName); API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); const auto fittedPeaks = ADS.retrieveWS<API::MatrixWorkspace>(outputWSName); + const auto latticeParams = + ADS.retrieveWS<API::ITableWorkspace>(latticeParamsName); + return GSASIIRefineFitPeaksOutputProperties(rwp, sigma, gamma, fittedPeaks, + latticeParams, params.runLabel); +} - return fittedPeaks; +void EnggDiffGSASFittingModel::doRefinement( + const GSASIIRefineFitPeaksParameters ¶ms) { + m_workerThread = Mantid::Kernel::make_unique<QThread>(this); + EnggDiffGSASFittingWorker *worker = + new EnggDiffGSASFittingWorker(this, params); + worker->moveToThread(m_workerThread.get()); + + qRegisterMetaType< + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties>( + "GSASIIRefineFitPeaksOutputProperties"); + + connect(m_workerThread.get(), SIGNAL(started()), worker, + SLOT(doRefinement())); + connect(worker, + SIGNAL(refinementSuccessful(GSASIIRefineFitPeaksOutputProperties)), + this, SLOT(processRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &))); + connect(worker, SIGNAL(refinementFailed(const std::string &)), this, + SLOT(processRefinementFailed(const std::string &))); + connect(worker, SIGNAL(refinementCancelled()), this, + SLOT(processRefinementCancelled())); + connect(m_workerThread.get(), SIGNAL(finished()), m_workerThread.get(), + SLOT(deleteLater())); + connect(worker, + SIGNAL(refinementSuccessful(GSASIIRefineFitPeaksOutputProperties)), + worker, SLOT(deleteLater())); + connect(worker, SIGNAL(refinementFailed(const std::string &)), worker, + SLOT(deleteLater())); + m_workerThread->start(); } boost::optional<API::ITableWorkspace_sptr> @@ -187,5 +206,33 @@ EnggDiffGSASFittingModel::loadFocusedRun(const std::string &filename) const { return ws; } +void EnggDiffGSASFittingModel::processRefinementFailed( + const std::string &failureMessage) { + if (m_observer) { + m_observer->notifyRefinementFailed(failureMessage); + } +} + +void EnggDiffGSASFittingModel::processRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + addFitResultsToMaps(refinementResults.runLabel, refinementResults.rwp, + refinementResults.sigma, refinementResults.gamma, + refinementResults.latticeParamsWS); + if (m_observer) { + m_observer->notifyRefinementSuccessful(refinementResults); + } +} + +void EnggDiffGSASFittingModel::processRefinementCancelled() { + if (m_observer) { + m_observer->notifyRefinementCancelled(); + } +} + +void EnggDiffGSASFittingModel::setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) { + m_observer = observer; +} + } // CustomInterfaces } // MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h index 5fc0a4f4ed820fcfd2ec333c342957e2f0d3c90b..6413164958f96f567bc78d258376568326c7fe2d 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingModel.h @@ -2,22 +2,33 @@ #define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASFITTINGMODEL_H_ #include "DllConfig.h" +#include "EnggDiffGSASFittingWorker.h" #include "GSASIIRefineFitPeaksOutputProperties.h" #include "IEnggDiffGSASFittingModel.h" +#include "IEnggDiffGSASFittingObserver.h" #include "RunMap.h" +#include <QObject> +#include <QThread> + namespace MantidQt { namespace CustomInterfaces { class MANTIDQT_ENGGDIFFRACTION_DLL EnggDiffGSASFittingModel - : public IEnggDiffGSASFittingModel { + : public QObject, // Must be a QObject to run GSASIIRefineFitPeaksWorker + // asynchronously + public IEnggDiffGSASFittingModel { + Q_OBJECT + + friend void EnggDiffGSASFittingWorker::doRefinement(); public: - Mantid::API::MatrixWorkspace_sptr - doPawleyRefinement(const GSASIIRefineFitPeaksParameters ¶ms) override; + ~EnggDiffGSASFittingModel(); - Mantid::API::MatrixWorkspace_sptr - doRietveldRefinement(const GSASIIRefineFitPeaksParameters ¶ms) override; + void setObserver( + boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) override; + + void doRefinement(const GSASIIRefineFitPeaksParameters ¶ms) override; boost::optional<Mantid::API::ITableWorkspace_sptr> getLatticeParams(const RunLabel &runLabel) const override; @@ -50,6 +61,14 @@ protected: /// Add a sigma value to the sigma map void addSigma(const RunLabel &runLabel, const double sigma); +protected slots: + void processRefinementFailed(const std::string &failureMessage); + + void processRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &refinementResults); + + void processRefinementCancelled(); + private: static constexpr double DEFAULT_PAWLEY_DMIN = 1; static constexpr double DEFAULT_PAWLEY_NEGATIVE_WEIGHT = 0; @@ -60,11 +79,22 @@ private: RunMap<MAX_BANKS, double> m_rwpMap; RunMap<MAX_BANKS, double> m_sigmaMap; + boost::shared_ptr<IEnggDiffGSASFittingObserver> m_observer; + + std::unique_ptr<QThread> m_workerThread; + /// Add Rwp, sigma, gamma and lattice params table to their /// respective RunMaps - void addFitResultsToMaps(const RunLabel &runLabel, const double rwp, - const double sigma, const double gamma, - const std::string &latticeParamsTableName); + void + addFitResultsToMaps(const RunLabel &runLabel, const double rwp, + const double sigma, const double gamma, + const Mantid::API::ITableWorkspace_sptr latticeParams); + + void deleteWorkerThread(); + + /// Run GSASIIRefineFitPeaks + GSASIIRefineFitPeaksOutputProperties + doGSASRefinementAlgorithm(const GSASIIRefineFitPeaksParameters ¶ms); template <typename T> boost::optional<T> getFromRunMapOptional(const RunMap<MAX_BANKS, T> &map, @@ -74,15 +104,6 @@ private: } return boost::none; } - - /// Run GSASIIRefineFitPeaks - /// Note this must be virtual so that it can be mocked out by the helper class - /// in EnggDiffGSASFittingModelTest - virtual GSASIIRefineFitPeaksOutputProperties - doGSASRefinementAlgorithm(const std::string &fittedPeaksWSName, - const std::string &latticeParamsWSName, - const GSASIIRefineFitPeaksParameters ¶ms, - const std::string &refinementMethod); }; } // CustomInterfaces diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp index ddf68069d18543951129e39bdf724b27ce3e60bd..13faf7f5d6a8c6034c8db9a5116a67a8a2349e70 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.cpp @@ -47,8 +47,9 @@ void EnggDiffGSASFittingPresenter::notify( GSASIIRefineFitPeaksParameters EnggDiffGSASFittingPresenter::collectInputParameters( - const RunLabel &runLabel, const Mantid::API::MatrixWorkspace_sptr inputWS, - const GSASRefinementMethod refinementMethod) const { + const RunLabel &runLabel, + const Mantid::API::MatrixWorkspace_sptr inputWS) const { + const auto refinementMethod = m_view->getRefinementMethod(); const auto instParamFile = m_view->getInstrumentFileName(); const auto phaseFiles = m_view->getPhaseFileNames(); const auto pathToGSASII = m_view->getPathToGSASII(); @@ -89,16 +90,36 @@ void EnggDiffGSASFittingPresenter::displayFitResults(const RunLabel &runLabel) { m_view->displayGamma(*gamma); } -Mantid::API::MatrixWorkspace_sptr -EnggDiffGSASFittingPresenter::doPawleyRefinement( +void EnggDiffGSASFittingPresenter::doRefinement( const GSASIIRefineFitPeaksParameters ¶ms) { - return m_model->doPawleyRefinement(params); + m_model->doRefinement(params); } -Mantid::API::MatrixWorkspace_sptr -EnggDiffGSASFittingPresenter::doRietveldRefinement( - const GSASIIRefineFitPeaksParameters ¶ms) { - return m_model->doRietveldRefinement(params); +void EnggDiffGSASFittingPresenter::notifyRefinementCancelled() { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->showStatus("Ready"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementFailed( + const std::string &failureMessage) { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->userWarning("Refinement failed", failureMessage); + m_view->showStatus("Refinement failed"); + } +} + +void EnggDiffGSASFittingPresenter::notifyRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &refinementResults) { + if (!m_viewHasClosed) { + m_view->setEnabled(true); + m_view->showStatus("Ready"); + m_multiRunWidget->addFittedPeaks(refinementResults.runLabel, + refinementResults.fittedPeaksWS); + displayFitResults(refinementResults.runLabel); + } } void EnggDiffGSASFittingPresenter::processDoRefinement() { @@ -121,31 +142,11 @@ void EnggDiffGSASFittingPresenter::processDoRefinement() { } m_view->showStatus("Refining run"); - const auto refinementMethod = m_view->getRefinementMethod(); const auto refinementParams = - collectInputParameters(*runLabel, *inputWSOptional, refinementMethod); + collectInputParameters(*runLabel, *inputWSOptional); - try { - Mantid::API::MatrixWorkspace_sptr fittedPeaks; - - switch (refinementMethod) { - - case GSASRefinementMethod::PAWLEY: - fittedPeaks = doPawleyRefinement(refinementParams); - break; - - case GSASRefinementMethod::RIETVELD: - fittedPeaks = doRietveldRefinement(refinementParams); - break; - } - - m_multiRunWidget->addFittedPeaks(*runLabel, fittedPeaks); - displayFitResults(*runLabel); - } catch (const std::exception &ex) { - m_view->showStatus("An error occurred in refinement"); - m_view->userError("Refinement failed", ex.what()); - } - m_view->showStatus("Ready"); + m_view->setEnabled(false); + doRefinement(refinementParams); } void EnggDiffGSASFittingPresenter::processLoadRun() { diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h index 6e7198ed5ef15b15707b56016aa1f680c23f7568..8501c5a9689bf5657df830334fba55e600cc620b 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingPresenter.h @@ -2,6 +2,7 @@ #define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_ENGGDIFFGSASFITTINGPRESENTER_H_ #include "DllConfig.h" +#include "GSASIIRefineFitPeaksOutputProperties.h" #include "IEnggDiffGSASFittingModel.h" #include "IEnggDiffGSASFittingPresenter.h" #include "IEnggDiffGSASFittingView.h" @@ -35,6 +36,13 @@ public: void notify(IEnggDiffGSASFittingPresenter::Notification notif) override; + void notifyRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &refinementResults) override; + + void notifyRefinementFailed(const std::string &failureMessage) override; + + void notifyRefinementCancelled() override; + private: void processDoRefinement(); void processLoadRun(); @@ -46,24 +54,13 @@ private: /// presenter's various children GSASIIRefineFitPeaksParameters collectInputParameters(const RunLabel &runLabel, - const Mantid::API::MatrixWorkspace_sptr ws, - const GSASRefinementMethod refinementMethod) const; - - /** - Perform a Pawley refinement on a run - @param params Input parameters for GSASIIRefineFitPeaks - @return Fitted peaks workspace resulting from refinement - */ - Mantid::API::MatrixWorkspace_sptr - doPawleyRefinement(const GSASIIRefineFitPeaksParameters ¶ms); + const Mantid::API::MatrixWorkspace_sptr ws) const; /** - Perform a Rietveld refinement on a run + Perform a refinement on a run @param params Input parameters for GSASIIRefineFitPeaks - @return Fitted peaks workspace resulting from refinement */ - Mantid::API::MatrixWorkspace_sptr - doRietveldRefinement(const GSASIIRefineFitPeaksParameters ¶ms); + void doRefinement(const GSASIIRefineFitPeaksParameters ¶ms); /** Overplot fitted peaks for a run, and display lattice parameters and Rwp in diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp index 17f305f25a6d431712b1bef805fbed339efde27c..2e11e78962207f478c40e6d0fcf686ce66775523 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.cpp @@ -35,8 +35,10 @@ EnggDiffGSASFittingViewQtWidget::EnggDiffGSASFittingViewQtWidget( setupUI(); auto model = Mantid::Kernel::make_unique<EnggDiffGSASFittingModel>(); - m_presenter = Mantid::Kernel::make_unique<EnggDiffGSASFittingPresenter>( + auto *model_ptr = model.get(); + m_presenter = boost::make_shared<EnggDiffGSASFittingPresenter>( std::move(model), this, multiRunWidgetPresenter); + model_ptr->setObserver(m_presenter); m_presenter->notify(IEnggDiffGSASFittingPresenter::Start); } @@ -288,6 +290,16 @@ void EnggDiffGSASFittingViewQtWidget::setEnabled(const bool enabled) { m_ui.lineEdit_pawleyDMin->setEnabled(enabled); m_ui.lineEdit_pawleyNegativeWeight->setEnabled(enabled); + + m_ui.lineEdit_xMin->setEnabled(enabled); + m_ui.lineEdit_xMax->setEnabled(enabled); + + m_ui.checkBox_refineSigma->setEnabled(enabled); + m_ui.checkBox_refineGamma->setEnabled(enabled); + + m_ui.pushButton_doRefinement->setEnabled(enabled); + + m_multiRunWidgetView->setEnabled(enabled); } void EnggDiffGSASFittingViewQtWidget::setFocusedRunFileNames( diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h index fb35a097914e941615602d7df19d85ea122a20f3..1c37d6f1824661a5e5c5c1e06c08cb0eb37cffc2 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingViewQtWidget.h @@ -8,6 +8,7 @@ #include "IEnggDiffractionPythonRunner.h" #include "IEnggDiffractionUserMsg.h" +#include <boost/shared_ptr.hpp> #include <qwt_plot_curve.h> #include <qwt_plot_zoomer.h> @@ -63,7 +64,7 @@ public: boost::optional<double> getXMin() const override; - void setEnabled(const bool enabled); + void setEnabled(const bool enabled) override; void showStatus(const std::string &status) const override; @@ -94,7 +95,7 @@ private: boost::shared_ptr<EnggDiffMultiRunFittingQtWidget> m_multiRunWidgetView; - std::unique_ptr<IEnggDiffGSASFittingPresenter> m_presenter; + boost::shared_ptr<IEnggDiffGSASFittingPresenter> m_presenter; Ui::EnggDiffractionQtTabGSAS m_ui; diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.cpp new file mode 100644 index 0000000000000000000000000000000000000000..20acebc7b7384bc68836e2e2d30ec784d056fb01 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.cpp @@ -0,0 +1,30 @@ +#include "EnggDiffGSASFittingWorker.h" +#include "EnggDiffGSASFittingModel.h" + +#include "MantidAPI/Algorithm.h" + +namespace MantidQt { +namespace CustomInterfaces { + +EnggDiffGSASFittingWorker::EnggDiffGSASFittingWorker( + EnggDiffGSASFittingModel *model, + const GSASIIRefineFitPeaksParameters ¶ms) + : m_model(model), m_refinementParams(params) {} + +void EnggDiffGSASFittingWorker::doRefinement() { + try { + qRegisterMetaType< + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties>( + "GSASIIRefineFitPeaksOutputProperties"); + const auto outputProperties = + m_model->doGSASRefinementAlgorithm(m_refinementParams); + emit refinementSuccessful(outputProperties); + } catch (const Mantid::API::Algorithm::CancelException &) { + emit refinementCancelled(); + } catch (const std::exception &e) { + emit refinementFailed(e.what()); + } +} + +} // CustomInterfaces +} // MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.h new file mode 100644 index 0000000000000000000000000000000000000000..2a25b635a819d3bcb2b799fdf76971328bab8525 --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffGSASFittingWorker.h @@ -0,0 +1,44 @@ +#ifndef MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_ENGGDIFFGSASFITTINGWORKER_H_ +#define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_ENGGDIFFGSASFITTINGWORKER_H_ + +#include "GSASIIRefineFitPeaksOutputProperties.h" +#include "GSASIIRefineFitPeaksParameters.h" + +#include <QObject> + +/** +Worker for long-running tasks (ie GSASIIRefineFitPeaks) in the GSAS tab of the +Engineering Diffraction GUI. Emits finished() signal when refinement is complete +*/ +namespace MantidQt { +namespace CustomInterfaces { + +class EnggDiffGSASFittingModel; + +class EnggDiffGSASFittingWorker : public QObject { + Q_OBJECT + +public: + EnggDiffGSASFittingWorker(EnggDiffGSASFittingModel *model, + const GSASIIRefineFitPeaksParameters ¶ms); + +public slots: + void doRefinement(); + +signals: + void refinementSuccessful(GSASIIRefineFitPeaksOutputProperties); + + void refinementFailed(std::string); + + void refinementCancelled(); + +private: + EnggDiffGSASFittingModel *m_model; + + const GSASIIRefineFitPeaksParameters m_refinementParams; +}; + +} // namespace CustomInterfaces +} // namespace MantidQt + +#endif // MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_ENGGDIFFGSASFITTINGWORKER_H_ diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp index bae775c09683edac9d933abbbcfca03d1a8d0f4b..82318610eaffd61c57fd8c089089439091fa743d 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.cpp @@ -174,6 +174,14 @@ void EnggDiffMultiRunFittingQtWidget::resetPlotZoomLevel() { m_zoomTool->setZoomBase(true); } +void EnggDiffMultiRunFittingQtWidget::setEnabled(const bool enabled) { + m_ui.listWidget_runLabels->setEnabled(enabled); + m_ui.pushButton_removeRun->setEnabled(enabled); + m_ui.pushButton_plotToSeparateWindow->setEnabled(enabled); + m_ui.checkBox_plotFittedPeaks->setEnabled(enabled); + m_zoomTool->setEnabled(enabled); +} + void EnggDiffMultiRunFittingQtWidget::setMessageProvider( boost::shared_ptr<IEnggDiffractionUserMsg> messageProvider) { m_userMessageProvider = messageProvider; diff --git a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.h b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.h index dd2a830b1fa06dbabd9f25cddd8d542282ef02d5..a404957b44761dc7d9b780f79c793b3596f6baef 100644 --- a/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.h +++ b/qt/scientific_interfaces/EnggDiffraction/EnggDiffMultiRunFittingQtWidget.h @@ -46,6 +46,8 @@ public: void resetCanvas() override; + void setEnabled(const bool enabled) override; + void setMessageProvider( boost::shared_ptr<IEnggDiffractionUserMsg> messageProvider) override; diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp index 71a60c2d4ba44cf91e11dd66ab312b5c4fdc1738..981727e9b1b74060de63ddffbc33ec68d37d5938 100644 --- a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.cpp @@ -4,12 +4,19 @@ namespace MantidQt { namespace CustomInterfaces { GSASIIRefineFitPeaksOutputProperties::GSASIIRefineFitPeaksOutputProperties( - const double _rwp, const double _sigma, const double _gamma) - : rwp(_rwp), sigma(_sigma), gamma(_gamma) {} + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr _fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr _latticeParamsWS, + const RunLabel &_runLabel) + : rwp(_rwp), sigma(_sigma), gamma(_gamma), fittedPeaksWS(_fittedPeaksWS), + latticeParamsWS(_latticeParamsWS), runLabel(_runLabel) {} bool operator==(const GSASIIRefineFitPeaksOutputProperties &lhs, const GSASIIRefineFitPeaksOutputProperties &rhs) { - return lhs.rwp == rhs.rwp && lhs.sigma == rhs.sigma && lhs.gamma == rhs.gamma; + return lhs.rwp == rhs.rwp && lhs.sigma == rhs.sigma && + lhs.gamma == rhs.gamma && lhs.fittedPeaksWS == rhs.fittedPeaksWS && + lhs.latticeParamsWS == rhs.latticeParamsWS && + lhs.runLabel == rhs.runLabel; } bool operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, diff --git a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h index 3c692c460eb8e957780f34bf204c7ae5c1da69c9..0e5dec8b810f9c28d0dbd1e8e5225dbdc2b927a7 100644 --- a/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h +++ b/qt/scientific_interfaces/EnggDiffraction/GSASIIRefineFitPeaksOutputProperties.h @@ -2,17 +2,31 @@ #define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASIIREFINEFITPEAKSOUTPUTPROPERTIES_H_ #include "DllConfig.h" +#include "RunLabel.h" + +#include "MantidAPI/ITableWorkspace.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" + +#include <QMetaType> namespace MantidQt { namespace CustomInterfaces { struct MANTIDQT_ENGGDIFFRACTION_DLL GSASIIRefineFitPeaksOutputProperties { - GSASIIRefineFitPeaksOutputProperties(const double _rwp, const double _sigma, - const double _gamma); - - const double rwp; - const double sigma; - const double gamma; + GSASIIRefineFitPeaksOutputProperties( + const double _rwp, const double _sigma, const double _gamma, + const Mantid::API::MatrixWorkspace_sptr _fittedPeaksWS, + const Mantid::API::ITableWorkspace_sptr _latticeParamsWS, + const RunLabel &_runLabel); + + GSASIIRefineFitPeaksOutputProperties() = default; + + double rwp; + double sigma; + double gamma; + Mantid::API::MatrixWorkspace_sptr fittedPeaksWS; + Mantid::API::ITableWorkspace_sptr latticeParamsWS; + RunLabel runLabel; }; MANTIDQT_ENGGDIFFRACTION_DLL bool @@ -26,4 +40,7 @@ operator!=(const GSASIIRefineFitPeaksOutputProperties &lhs, } // MantidQt } // CustomInterfaces +Q_DECLARE_METATYPE( + MantidQt::CustomInterfaces::GSASIIRefineFitPeaksOutputProperties) + #endif // MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASIIREFINEFITPEAKSOUTPUTPROPERTIES_H_ diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffFittingPresenter.h index b10bed9363f0676c9a9e3d5140b50605a98f4c6c..c23b846c24fa136e4d0f69921329cb31083dbb44 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffFittingPresenter.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffFittingPresenter.h @@ -37,8 +37,6 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class IEnggDiffFittingPresenter { public: - virtual ~IEnggDiffFittingPresenter() = default; - /// These are user actions, triggered from the (passive) view, that need /// handling by the presenter enum Notification { diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingModel.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingModel.h index 8ae0e56fe649e52841b5f1360bafa5ed31423d83..e2f07235cca746daa327545bcdd09f24fcd9aa55 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingModel.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingModel.h @@ -2,13 +2,14 @@ #define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_IENGGDIFFGSASFITTINGMODEL_H_ #include "GSASIIRefineFitPeaksParameters.h" +#include "IEnggDiffGSASFittingObserver.h" #include "RunLabel.h" #include "MantidAPI/ITableWorkspace.h" #include "MantidAPI/MatrixWorkspace_fwd.h" #include <boost/optional.hpp> - +#include <boost/shared_ptr.hpp> #include <string> #include <utility> #include <vector> @@ -22,22 +23,10 @@ public: virtual ~IEnggDiffGSASFittingModel() = default; /** - Perform a Pawley refinement on a run - @param params Parameters to be passed to GSASIIRefineFitPeaks - @return Fitted peaks workspace resulting from refinement - @throws If GSASIIRefineFitPeaks throws - */ - virtual Mantid::API::MatrixWorkspace_sptr - doPawleyRefinement(const GSASIIRefineFitPeaksParameters ¶ms) = 0; - - /** - Perform a Rietveld refinement on a run + Perform a refinement on a run @param params Parameters to be passed to GSASIIRefineFitPeaks - @return Fitted peaks workspace resulting from refinement - @throws If GSASIIRefineFitPeaks throws */ - virtual Mantid::API::MatrixWorkspace_sptr - doRietveldRefinement(const GSASIIRefineFitPeaksParameters ¶ms) = 0; + virtual void doRefinement(const GSASIIRefineFitPeaksParameters ¶ms) = 0; /** Get refined lattice parameters for a run @@ -76,6 +65,10 @@ public: */ virtual Mantid::API::MatrixWorkspace_sptr loadFocusedRun(const std::string &filename) const = 0; + + /// set the observer for refinement + virtual void + setObserver(boost::shared_ptr<IEnggDiffGSASFittingObserver> observer) = 0; }; } // namespace MantidQt diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingObserver.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingObserver.h new file mode 100644 index 0000000000000000000000000000000000000000..ca3613dd3b4fcbea0f2976abbed246fb81fb8a0d --- /dev/null +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingObserver.h @@ -0,0 +1,25 @@ +#ifndef MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASFITTINGOBSERVER_H_ +#define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASFITTINGOBSERVER_H_ + +#include "GSASIIRefineFitPeaksOutputProperties.h" + +namespace MantidQt { +namespace CustomInterfaces { + +class IEnggDiffGSASFittingObserver { + +public: + virtual ~IEnggDiffGSASFittingObserver() = default; + + virtual void notifyRefinementSuccessful( + const GSASIIRefineFitPeaksOutputProperties &refinementResults) = 0; + + virtual void notifyRefinementFailed(const std::string &failureMessage) = 0; + + virtual void notifyRefinementCancelled() = 0; +}; + +} // CustomInterfaces +} // MantidQt + +#endif // MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_GSASFITTINGOBSERVER_H_ diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingPresenter.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingPresenter.h index 441965d04fc2845c01b23ff2655fd6ac7ed2c5ef..31c2f5639eb47dd5884e0c0dbf1033fba57f6181 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingPresenter.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingPresenter.h @@ -1,10 +1,12 @@ #ifndef MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_IENGGDIFFGSASFITTINGPRESENTER_H_ #define MANTIDQTCUSTOMINTERFACES_ENGGDIFFRACTION_IENGGDIFFGSASFITTINGPRESENTER_H_ +#include "IEnggDiffGSASFittingObserver.h" + namespace MantidQt { namespace CustomInterfaces { -class IEnggDiffGSASFittingPresenter { +class IEnggDiffGSASFittingPresenter : public IEnggDiffGSASFittingObserver { public: virtual ~IEnggDiffGSASFittingPresenter() = default; @@ -28,6 +30,13 @@ public: * @param notif Type of notification to process. */ virtual void notify(IEnggDiffGSASFittingPresenter::Notification notif) = 0; + + void notifyRefinementSuccessful(const GSASIIRefineFitPeaksOutputProperties & + refinementResults) override = 0; + + void notifyRefinementFailed(const std::string &failureMessage) override = 0; + + void notifyRefinementCancelled() override = 0; }; } // namespace CustomInterfaces diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingView.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingView.h index bd27f2828f1915285ece954e2a4070c81e047d3d..39ea836047970c0b708eee758c1ac2007f5063b5 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingView.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffGSASFittingView.h @@ -103,6 +103,9 @@ public: /// Get XMin parameter, if it is set virtual boost::optional<double> getXMin() const = 0; + /// Enable or disable the GUI + virtual void setEnabled(const bool enabled) = 0; + /// Update the view with current status virtual void showStatus(const std::string &status) const = 0; diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetAdder.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetAdder.h index 55657b8990bab2bad883577516a9408d06a0170c..03c3c3e8e2024dff5cac1b3f5f644abd0d214e98 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetAdder.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetAdder.h @@ -9,6 +9,7 @@ namespace CustomInterfaces { class IEnggDiffMultiRunFittingWidgetAdder { public: + virtual ~IEnggDiffMultiRunFittingWidgetAdder() = default; virtual void operator()(IEnggDiffMultiRunFittingWidgetOwner &owner) = 0; }; diff --git a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetView.h b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetView.h index a1eb4e0bc6ddd7115fd585d2ca3c6be55b1b8567..a38cdc2f82a0aa906ca31bf9405d3e931af7a3b7 100644 --- a/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetView.h +++ b/qt/scientific_interfaces/EnggDiffraction/IEnggDiffMultiRunFittingWidgetView.h @@ -56,6 +56,9 @@ public: /// Clear the plot area to avoid overplotting virtual void resetCanvas() = 0; + /// Enable/disable the widget + virtual void setEnabled(const bool enabled) = 0; + /// Connect a message provider to the view. Used to remove circular /// dependency between view and presenter virtual void setMessageProvider( diff --git a/qt/scientific_interfaces/EnggDiffraction/RunLabel.h b/qt/scientific_interfaces/EnggDiffraction/RunLabel.h index 9bfe8d22c646a9af9429ce1a481bc4e453840780..8af126e2225f16da7d375beaf758a9700aacd6ac 100644 --- a/qt/scientific_interfaces/EnggDiffraction/RunLabel.h +++ b/qt/scientific_interfaces/EnggDiffraction/RunLabel.h @@ -14,8 +14,10 @@ class MANTIDQT_ENGGDIFFRACTION_DLL RunLabel { public: RunLabel(const int runNumber, const size_t bank); - const int runNumber; - const std::size_t bank; + RunLabel() = default; + + int runNumber; + std::size_t bank; }; MANTIDQT_ENGGDIFFRACTION_DLL bool operator==(const RunLabel &lhs, diff --git a/qt/scientific_interfaces/General/DataComparison.cpp b/qt/scientific_interfaces/General/DataComparison.cpp index b080ceacf0dba5bdf30a37885d07ae71b8fb6619..9271231faac32c6158fda9d1371c58e360978893 100644 --- a/qt/scientific_interfaces/General/DataComparison.cpp +++ b/qt/scientific_interfaces/General/DataComparison.cpp @@ -108,7 +108,7 @@ void DataComparison::addData() { m_uiForm.twCurrentData->blockSignals(true); // If this is a WorkspaceGroup then add all items - if (wsGroup != NULL) { + if (wsGroup != nullptr) { size_t numWs = wsGroup->size(); for (size_t wsIdx = 0; wsIdx < numWs; wsIdx++) { addDataItem(wsGroup->getItem(wsIdx)); @@ -278,7 +278,7 @@ void DataComparison::removeSelectedData() { // Detach the old curve from the plot if it exists if (m_curves.contains(workspaceName)) - m_curves[workspaceName]->attach(NULL); + m_curves[workspaceName]->attach(nullptr); selectedItems = m_uiForm.twCurrentData->selectedItems(); } @@ -304,7 +304,7 @@ void DataComparison::removeAllData() { // Detach the old curve from the plot if it exists if (m_curves.contains(workspaceName)) - m_curves[workspaceName]->attach(NULL); + m_curves[workspaceName]->attach(nullptr); } // Replot the workspaces @@ -353,7 +353,7 @@ void DataComparison::plotWorkspaces() { // Detech the curve from the plot if (m_curves.contains(workspaceName)) - m_curves[workspaceName]->attach(NULL); + m_curves[workspaceName]->attach(nullptr); continue; } @@ -369,7 +369,7 @@ void DataComparison::plotWorkspaces() { // Detach the old curve from the plot if it exists if (m_curves.contains(workspaceName)) - m_curves[workspaceName]->attach(NULL); + m_curves[workspaceName]->attach(nullptr); QComboBox *colourSelector = dynamic_cast<QComboBox *>( m_uiForm.twCurrentData->cellWidget(row, COLOUR)); @@ -452,8 +452,8 @@ void DataComparison::workspaceIndexChanged() { */ void DataComparison::plotDiffWorkspace() { // Detach old curve - if (m_diffCurve != NULL) - m_diffCurve->attach(NULL); + if (m_diffCurve != nullptr) + m_diffCurve->attach(nullptr); // Do nothing if there are not two workspaces if (m_diffWorkspaceNames.first.isEmpty() || @@ -682,7 +682,7 @@ void DataComparison::preDeleteHandle( // Detach the old curve from the plot if it exists if (m_curves.contains(oldWsName)) - m_curves[oldWsName]->attach(NULL); + m_curves[oldWsName]->attach(nullptr); // Update the plot plotWorkspaces(); @@ -713,7 +713,7 @@ void DataComparison::renameHandle(const std::string &oldName, // Detach the old curve from the plot if it exists if (m_curves.contains(oldWsName)) - m_curves[oldWsName]->attach(NULL); + m_curves[oldWsName]->attach(nullptr); // Update the plot plotWorkspaces(); diff --git a/qt/scientific_interfaces/General/MantidEV.cpp b/qt/scientific_interfaces/General/MantidEV.cpp index d79ca6bef1aa9663a775046a62b98db22e1de483..e1868996ae6170f5103695b3882a2bb92f3391d8 100644 --- a/qt/scientific_interfaces/General/MantidEV.cpp +++ b/qt/scientific_interfaces/General/MantidEV.cpp @@ -495,7 +495,7 @@ void MantidEV::setDefaultState_slot() { */ void MantidEV::help_slot() { MantidQt::API::HelpWindow::showCustomInterface( - NULL, QString("SCD Event Data Reduction")); + nullptr, QString("SCD Event Data Reduction")); } /** diff --git a/qt/scientific_interfaces/General/StepScan.cpp b/qt/scientific_interfaces/General/StepScan.cpp index f83ff8297d8155e0accd70ded8653babab8612dd..c91c0e63471e3ef2d7403d0a71d6bd0932b451e4 100644 --- a/qt/scientific_interfaces/General/StepScan.cpp +++ b/qt/scientific_interfaces/General/StepScan.cpp @@ -410,7 +410,7 @@ void StepScan::expandPlotVarCombobox( // Try to cast to an ITimeSeriesProperty auto tsp = dynamic_cast<const ITimeSeriesProperty *>(*log); // Move on to the next one if this is not a TSP - if (tsp == NULL) + if (tsp == nullptr) continue; // Don't keep ones with only one entry if (tsp->realSize() < 2) diff --git a/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt b/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt index c19ec5c7672d3fa9f5623d32a1612c43a7ceff4c..c7aa041b84bccb6eb027fceff8604e15c7c37f34 100644 --- a/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt +++ b/qt/scientific_interfaces/ISISReflectometry/CMakeLists.txt @@ -11,6 +11,8 @@ set ( SRC_FILES QtReflSettingsTabView.cpp QtReflSettingsView.cpp ReflCatalogSearcher.cpp + ReflAsciiSaver.cpp + IReflAsciiSaver.cpp ReflDataProcessorPresenter.cpp ReflEventPresenter.cpp ReflEventTabPresenter.cpp @@ -57,7 +59,10 @@ set ( INC_FILES QtReflSaveTabView.h QtReflSettingsTabView.h QtReflSettingsView.h + QWidgetGroup.h ReflCatalogSearcher.h + ReflAsciiSaver.h + IReflAsciiSaver.h ReflDataProcessorMainPresenter.h ReflDataProcessorPresenter.h ReflEventPresenter.h diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.cpp b/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..5f427281db578de8cb1a7f5d5fd39659ceb342cd --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.cpp @@ -0,0 +1,25 @@ +#include "IReflAsciiSaver.h" +namespace MantidQt { +namespace CustomInterfaces { +InvalidSavePath::InvalidSavePath(std::string const &path) + : std::runtime_error("The path" + path + + "does not exist or is not a directory."), + m_path(path) {} +std::string const &InvalidSavePath::path() const { return m_path; } + +FileFormatOptions::FileFormatOptions(NamedFormat format, + std::string const &prefix, + bool includeTitle, + std::string const &separator, + bool includeQResolution) + : m_format(format), m_prefix(prefix), m_includeTitle(includeTitle), + m_separator(separator), m_includeQResolution(includeQResolution) {} +bool FileFormatOptions::shouldIncludeTitle() const { return m_includeTitle; } +bool FileFormatOptions::shouldIncludeQResolution() const { + return m_includeQResolution; +} +std::string const &FileFormatOptions::separator() const { return m_separator; } +std::string const &FileFormatOptions::prefix() const { return m_prefix; } +NamedFormat FileFormatOptions::format() const { return m_format; } +} +} diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.h b/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.h new file mode 100644 index 0000000000000000000000000000000000000000..4f11c3b35928e4517a6ab00617e4af3d9937be11 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/IReflAsciiSaver.h @@ -0,0 +1,51 @@ +#ifndef MANTID_ISISREFLECTOMETRY_IREFLASCIISAVER_H +#define MANTID_ISISREFLECTOMETRY_IREFLASCIISAVER_H +#include <vector> +#include <string> +#include "MantidAPI/IAlgorithm_fwd.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" +namespace MantidQt { +namespace CustomInterfaces { + +enum class NamedFormat { Custom, ThreeColumn, ANSTO, ILLCosmos }; + +class FileFormatOptions { +public: + FileFormatOptions(NamedFormat format, std::string const &prefix, + bool includeTitle, std::string const &separator, + bool includeQResolution); + bool shouldIncludeTitle() const; + bool shouldIncludeQResolution() const; + std::string const &separator() const; + std::string const &prefix() const; + NamedFormat format() const; + +private: + NamedFormat m_format; + std::string m_prefix; + bool m_includeTitle; + std::string m_separator; + bool m_includeQResolution; +}; + +class InvalidSavePath : public std::runtime_error { +public: + explicit InvalidSavePath(std::string const &path); + std::string const &path() const; + +private: + std::string m_path; +}; + +class IReflAsciiSaver { +public: + virtual bool isValidSaveDirectory(std::string const &filePath) const = 0; + virtual void save(std::string const &saveDirectory, + std::vector<std::string> const &workspaceNames, + std::vector<std::string> const &logParameters, + FileFormatOptions const &inputParameters) const = 0; + virtual ~IReflAsciiSaver() = default; +}; +} +} +#endif // MANTID_ISISREFLECTOMETRY_IREFLASCIISAVER_H diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflEventPresenter.h b/qt/scientific_interfaces/ISISReflectometry/IReflEventPresenter.h index a2b5ed7d775ca9476e6eb8aa413136539e992b83..56a2f66fa2066e8fa7aacec9916d2edbf1368d46 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflEventPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflEventPresenter.h @@ -34,6 +34,9 @@ along with this program. If not, see <http://www.gnu.org/licenses/>. File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ + +enum class SliceType { UniformEven, Uniform, Custom, LogValue }; + class IReflEventPresenter { public: virtual ~IReflEventPresenter(){}; @@ -45,6 +48,7 @@ public: virtual void onReductionPaused() = 0; virtual void onReductionResumed() = 0; + virtual void notifySliceTypeChanged(SliceType newSliceType) = 0; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflEventView.h b/qt/scientific_interfaces/ISISReflectometry/IReflEventView.h index ce247af9d75a74e8acb1d68ad0705c5bd4d3c13e..8eeb886061df79d338f3b17913e8ae0c331de7f1 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflEventView.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflEventView.h @@ -3,12 +3,11 @@ #include "DllConfig.h" #include <string> +#include "IReflEventPresenter.h" namespace MantidQt { namespace CustomInterfaces { -class IReflEventPresenter; - /** @class IReflEventView IReflEventView is the base view class for the Reflectometry "Event Handling" @@ -39,21 +38,20 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> class DLLExport IReflEventView { public: - /// Constructor IReflEventView(){}; - /// Destructor virtual ~IReflEventView(){}; - /// Returns the presenter managing this view virtual IReflEventPresenter *getPresenter() const = 0; - /// Slice type enums - enum class SliceType { UniformEven, Uniform, Custom, LogValue }; - - virtual std::string getTimeSlicingValues() const = 0; - virtual std::string getTimeSlicingType() const = 0; + virtual std::string getLogValueTimeSlicingValues() const = 0; + virtual std::string getCustomTimeSlicingValues() const = 0; + virtual std::string getUniformTimeSlicingValues() const = 0; + virtual std::string getUniformEvenTimeSlicingValues() const = 0; + virtual std::string getLogValueTimeSlicingType() const = 0; - virtual void enableAll() = 0; - virtual void disableAll() = 0; + virtual void enableSliceType(SliceType sliceType) = 0; + virtual void disableSliceType(SliceType sliceType) = 0; + virtual void enableSliceTypeSelection() = 0; + virtual void disableSliceTypeSelection() = 0; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflMainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/IReflMainWindowPresenter.h index 8594027f2dbccf47997c2521fbf2731a99e51322..3e42eff069c20c65fa4eceacf5d90a6762ee4e0b 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflMainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflMainWindowPresenter.h @@ -2,6 +2,7 @@ #define MANTID_ISISREFLECTOMETRY_IREFLMAINWINDOWPRESENTER_H #include "MantidQtWidgets/Common/DataProcessorUI/OptionsQMap.h" +#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" #include <string> @@ -49,6 +50,14 @@ public: virtual void notifyReductionPaused(int group) = 0; virtual void notifyReductionResumed(int group) = 0; + virtual void completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) = 0; + + virtual void completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) = 0; + /// Transmission runs for a specific run angle virtual MantidWidgets::DataProcessor::OptionsQMap getOptionsForAngle(int group, const double angle) const = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabPresenter.h b/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabPresenter.h index 88b851028eac9d0ce02371282c364805c9e6476e..6f23c0aba24f940210d56c782c00329a9244a3cb 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabPresenter.h @@ -1,5 +1,6 @@ #ifndef MANTID_ISISREFLECTOMETRY_IREFLSAVETABPRESENTER_H #define MANTID_ISISREFLECTOMETRY_IREFLSAVETABPRESENTER_H +#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" namespace MantidQt { namespace CustomInterfaces { @@ -43,9 +44,20 @@ public: filterWorkspaceListFlag, workspaceParamsFlag, saveWorkspacesFlag, - suggestSaveDirFlag + suggestSaveDirFlag, + autosaveEnabled, + autosaveDisabled, + savePathChanged }; + virtual void completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) = 0; + + virtual void completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) = 0; + /// Tell the presenter something happened virtual void notify(IReflSaveTabPresenter::Flag flag) = 0; virtual void onAnyReductionPaused() = 0; diff --git a/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabView.h b/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabView.h index 5eb8ff7bfaeb80485f9fa41f4c89e1638c31b002..3435d6a1694d051fe8912357f4535019c333e447 100644 --- a/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabView.h +++ b/qt/scientific_interfaces/ISISReflectometry/IReflSaveTabView.h @@ -38,14 +38,13 @@ File change history is stored at: <https://github.com/mantidproject/mantid>. Code Documentation is available at: <http://doxygen.mantidproject.org> */ -class DLLExport IReflSaveTabView { +class MANTIDQT_ISISREFLECTOMETRY_DLL IReflSaveTabView { public: /// Constructor IReflSaveTabView(){}; /// Destructor virtual ~IReflSaveTabView(){}; - /// Returns the presenter managing this view - virtual IReflSaveTabPresenter *getPresenter() const = 0; + virtual void subscribe(IReflSaveTabPresenter *presenter) = 0; virtual std::string getSavePath() const = 0; virtual void setSavePath(const std::string &path) const = 0; @@ -64,6 +63,17 @@ public: virtual void clearParametersList() const = 0; virtual void setWorkspaceList(const std::vector<std::string> &) const = 0; virtual void setParametersList(const std::vector<std::string> &) const = 0; + virtual void disallowAutosave() = 0; + + virtual void disableAutosaveControls() = 0; + virtual void enableAutosaveControls() = 0; + + virtual void enableFileFormatAndLocationControls() = 0; + virtual void disableFileFormatAndLocationControls() = 0; + virtual void giveUserCritical(const std::string &prompt, + const std::string &title) = 0; + virtual void giveUserInfo(const std::string &prompt, + const std::string &title) = 0; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/QWidgetGroup.h b/qt/scientific_interfaces/ISISReflectometry/QWidgetGroup.h new file mode 100644 index 0000000000000000000000000000000000000000..9ae1a81ee07ebabec6a78bd7c78bd52084593060 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/QWidgetGroup.h @@ -0,0 +1,35 @@ +#ifndef MANTID_ISISREFLECTOMETRY_QWIDGETGROUP_H +#define MANTID_ISISREFLECTOMETRY_QWIDGETGROUP_H +#include <cstddef> +#include <array> +#include <QWidget> +namespace MantidQt { +namespace CustomInterfaces { +template <std::size_t N> class QWidgetGroup { +public: + QWidgetGroup() : m_widgets() {} + explicit QWidgetGroup(std::array<QWidget *, N> const &widgets) + : m_widgets(widgets) {} + + void enable() { + for (auto *widget : m_widgets) + widget->setEnabled(true); + } + + void disable() { + for (auto *widget : m_widgets) + widget->setEnabled(false); + } + +private: + std::array<QWidget *, N> m_widgets; +}; + +template <typename... Ts> +QWidgetGroup<sizeof...(Ts)> makeQWidgetGroup(Ts... widgets) { + return QWidgetGroup<sizeof...(Ts)>( + std::array<QWidget *, sizeof...(Ts)>({{widgets...}})); +} +} +} +#endif // MANTID_ISISREFLECTOMETRY_QWIDGETGROUP_H diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.cpp index d18997387347c9da77bbb8f4424c1f807aaaf949..a99051a51d66776d096030174202f807f7f5953c 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.cpp @@ -9,138 +9,142 @@ namespace CustomInterfaces { * @param parent :: [input] The parent of this widget */ QtReflEventView::QtReflEventView(QWidget *parent) { - UNUSED_ARG(parent); initLayout(); - - // Insert slice-type to string pairs - m_sliceTypeMap[SliceType::UniformEven] = "UniformEven"; - m_sliceTypeMap[SliceType::Uniform] = "Uniform"; - m_sliceTypeMap[SliceType::Custom] = "Custom"; - m_sliceTypeMap[SliceType::LogValue] = "LogValue"; - - // Add slicing option buttons to list - m_buttonList.emplace_back(m_ui.uniformEvenButton); - m_buttonList.emplace_back(m_ui.uniformButton); - m_buttonList.emplace_back(m_ui.customButton); - m_buttonList.emplace_back(m_ui.logValueButton); - - // Whenever one of the slicing option buttons is selected, their corresponding - // entry is enabled, otherwise they remain disabled. - for (auto &button : m_buttonList) { - connect(button, SIGNAL(toggled(bool)), this, SLOT(toggleSlicingOptions())); - } - - toggleSlicingOptions(); // Run at least once - m_presenter.reset(new ReflEventPresenter(this)); } -//---------------------------------------------------------------------------------------------- -/** Destructor -*/ QtReflEventView::~QtReflEventView() {} -/** -Initialise the Interface -*/ -void QtReflEventView::initLayout() { m_ui.setupUi(this); } +void QtReflEventView::initLayout() { + m_ui.setupUi(this); + initUniformSliceTypeLayout(); + initUniformEvenSliceTypeLayout(); + initLogValueSliceTypeLayout(); + initCustomSliceTypeLayout(); + m_sliceTypeRadioButtons = + makeQWidgetGroup(m_ui.uniformEvenButton, m_ui.uniformButton, + m_ui.logValueButton, m_ui.customButton); +} -/** Returns the presenter managing this view -* @return :: A pointer to the presenter -*/ -IReflEventPresenter *QtReflEventView::getPresenter() const { +void QtReflEventView::initUniformSliceTypeLayout() { + m_uniformGroup = makeQWidgetGroup(m_ui.uniformEdit, m_ui.uniformLabel); + connect(m_ui.uniformButton, SIGNAL(toggled(bool)), this, + SLOT(toggleUniform(bool))); +} - return m_presenter.get(); +void QtReflEventView::initUniformEvenSliceTypeLayout() { + m_uniformEvenGroup = + makeQWidgetGroup(m_ui.uniformEvenEdit, m_ui.uniformEvenLabel); + connect(m_ui.uniformEvenButton, SIGNAL(toggled(bool)), this, + SLOT(toggleUniformEven(bool))); } -void QtReflEventView::enableAll() { - m_ui.uniformEvenEdit->setEnabled(true); - m_ui.uniformEdit->setEnabled(true); - m_ui.logValueEdit->setEnabled(true); - m_ui.logValueTypeEdit->setEnabled(true); - for (auto *button : m_buttonList) - button->setEnabled(true); +void QtReflEventView::initCustomSliceTypeLayout() { + m_customGroup = makeQWidgetGroup(m_ui.customEdit, m_ui.customLabel); + connect(m_ui.customButton, SIGNAL(toggled(bool)), this, + SLOT(toggleCustom(bool))); } -void QtReflEventView::disableAll() { - m_ui.uniformEvenEdit->setEnabled(false); - m_ui.uniformEdit->setEnabled(false); - m_ui.logValueEdit->setEnabled(false); - m_ui.logValueTypeEdit->setEnabled(false); - for (auto *button : m_buttonList) - button->setEnabled(false); +void QtReflEventView::initLogValueSliceTypeLayout() { + m_logValueGroup = + makeQWidgetGroup(m_ui.logValueTypeEdit, m_ui.logValueTypeLabel, + m_ui.logValueEdit, m_ui.logValueLabel); + connect(m_ui.logValueButton, SIGNAL(toggled(bool)), this, + SLOT(toggleLogValue(bool))); } -/** Returns the time slicing value(s) obtained from the selected widget -* @return :: Time slicing values +/** Returns the presenter managing this view +* @return :: A pointer to the presenter */ -std::string QtReflEventView::getTimeSlicingValues() const { - - std::string values; +IReflEventPresenter *QtReflEventView::getPresenter() const { + return m_presenter.get(); +} - switch (m_sliceType) { +void QtReflEventView::enableSliceType(SliceType sliceType) { + switch (sliceType) { + case SliceType::Uniform: + m_uniformGroup.enable(); + break; case SliceType::UniformEven: - values = m_ui.uniformEvenEdit->text().toStdString(); + m_uniformEvenGroup.enable(); + break; + case SliceType::Custom: + m_customGroup.enable(); + break; + case SliceType::LogValue: + m_logValueGroup.enable(); break; + } +} + +void QtReflEventView::disableSliceType(SliceType sliceType) { + switch (sliceType) { case SliceType::Uniform: - values = m_ui.uniformEdit->text().toStdString(); + m_uniformGroup.disable(); + break; + case SliceType::UniformEven: + m_uniformEvenGroup.disable(); break; case SliceType::Custom: - values = m_ui.customEdit->text().toStdString(); + m_customGroup.disable(); break; case SliceType::LogValue: - std::string slicingValues = m_ui.logValueEdit->text().toStdString(); - std::string logFilter = m_ui.logValueTypeEdit->text().toStdString(); - if (!slicingValues.empty() && !logFilter.empty()) - values = "Slicing=\"" + slicingValues + "\",LogFilter=" + logFilter; + m_logValueGroup.disable(); break; } +} - return values; +std::string QtReflEventView::getLogValueTimeSlicingType() const { + return textFrom(m_ui.logValueTypeEdit); } -/** Returns the type of time slicing that was selected as string -* @return :: Time slicing type -*/ -std::string QtReflEventView::getTimeSlicingType() const { +std::string QtReflEventView::getLogValueTimeSlicingValues() const { + return textFrom(m_ui.logValueEdit); +} - return m_sliceTypeMap.at(m_sliceType); +std::string QtReflEventView::getCustomTimeSlicingValues() const { + return textFrom(m_ui.customEdit); } -/** Enable slicing option entries for checked button and disable all others. -*/ -void QtReflEventView::toggleSlicingOptions() const { +std::string QtReflEventView::getUniformTimeSlicingValues() const { + return textFrom(m_ui.uniformEdit); +} + +std::string QtReflEventView::getUniformEvenTimeSlicingValues() const { + return textFrom(m_ui.uniformEvenEdit); +} - const auto checkedButton = m_ui.slicingOptionsButtonGroup->checkedButton(); +std::string QtReflEventView::textFrom(QLineEdit const *const widget) const { + return widget->text().toStdString(); +} - SliceType slicingTypes[4] = {SliceType::UniformEven, SliceType::Uniform, - SliceType::Custom, SliceType::LogValue}; +void QtReflEventView::disableSliceTypeSelection() { + m_sliceTypeRadioButtons.disable(); +} - std::vector<bool> entriesEnabled(m_buttonList.size(), false); - for (size_t i = 0; i < m_buttonList.size(); i++) { - if (m_buttonList[i] == checkedButton) { - m_sliceType = slicingTypes[i]; - entriesEnabled[i] = true; - break; - } - } +void QtReflEventView::enableSliceTypeSelection() { + m_sliceTypeRadioButtons.enable(); +} + +void QtReflEventView::toggleUniform(bool isChecked) { + if (isChecked) + m_presenter->notifySliceTypeChanged(SliceType::Uniform); +} - // UniformEven - m_ui.uniformEvenEdit->setEnabled(entriesEnabled[0]); - m_ui.uniformEvenLabel->setEnabled(entriesEnabled[0]); - // Uniform - m_ui.uniformEdit->setEnabled(entriesEnabled[1]); - m_ui.uniformLabel->setEnabled(entriesEnabled[1]); - // Custom - m_ui.customEdit->setEnabled(entriesEnabled[2]); - m_ui.customLabel->setEnabled(entriesEnabled[2]); - // LogValue - m_ui.logValueEdit->setEnabled(entriesEnabled[3]); - m_ui.logValueLabel->setEnabled(entriesEnabled[3]); - m_ui.logValueTypeEdit->setEnabled(entriesEnabled[3]); - m_ui.logValueTypeLabel->setEnabled(entriesEnabled[3]); +void QtReflEventView::toggleUniformEven(bool isChecked) { + if (isChecked) + m_presenter->notifySliceTypeChanged(SliceType::UniformEven); } +void QtReflEventView::toggleCustom(bool isChecked) { + if (isChecked) + m_presenter->notifySliceTypeChanged(SliceType::Custom); +} + +void QtReflEventView::toggleLogValue(bool isChecked) { + if (isChecked) + m_presenter->notifySliceTypeChanged(SliceType::LogValue); +} } // namespace CustomInterfaces } // namespace Mantid diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.h b/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.h index c2a4f749da9734b97045f61ffa6444fa15564a9f..7e523961a0b013cf27ff5779613aa273a7953ee3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.h +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflEventView.h @@ -3,6 +3,7 @@ #include "IReflEventView.h" #include "ui_ReflEventWidget.h" +#include "QWidgetGroup.h" #include <memory> namespace MantidQt { @@ -44,35 +45,44 @@ public: ~QtReflEventView() override; /// Returns the presenter managing this view IReflEventPresenter *getPresenter() const override; - /// Returns time-slicing values - std::string getTimeSlicingValues() const override; - /// Returns time-slicing type - std::string getTimeSlicingType() const override; + void initUniformSliceTypeLayout(); + void initUniformEvenSliceTypeLayout(); + void initLogValueSliceTypeLayout(); + void initCustomSliceTypeLayout(); + + void enableSliceType(SliceType sliceType) override; + void disableSliceType(SliceType sliceType) override; + + void enableSliceTypeSelection() override; + void disableSliceTypeSelection() override; - void enableAll() override; - void disableAll() override; + std::string getLogValueTimeSlicingType() const override; + std::string getLogValueTimeSlicingValues() const override; + std::string getCustomTimeSlicingValues() const override; + std::string getUniformTimeSlicingValues() const override; + std::string getUniformEvenTimeSlicingValues() const override; public slots: - /// Enable / disable slicing option entry fields - void toggleSlicingOptions() const; + void toggleUniform(bool isChecked); + void toggleUniformEven(bool isChecked); + void toggleCustom(bool isChecked); + void toggleLogValue(bool isChecked); private: /// Initialise the interface void initLayout(); + std::string textFrom(QLineEdit const *const widget) const; + QWidgetGroup<2> m_uniformGroup; + QWidgetGroup<2> m_uniformEvenGroup; + QWidgetGroup<4> m_logValueGroup; + QWidgetGroup<2> m_customGroup; + QWidgetGroup<4> m_sliceTypeRadioButtons; /// The widget Ui::ReflEventWidget m_ui; /// The presenter std::unique_ptr<IReflEventPresenter> m_presenter; - - /// Current slice type - mutable SliceType m_sliceType; - /// Slice type to string conversion map - std::map<SliceType, std::string> m_sliceTypeMap; - - /// List of radio buttons - std::vector<QRadioButton *> m_buttonList; }; } // namespace Mantid diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp index ee29e44a1c13a1c28e5bc4892342ac0be6b868ba..3ef0846c9094abe2de064bd43fd840ba6b4c0638 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.cpp @@ -3,7 +3,10 @@ #include "QtReflRunsTabView.h" #include "QtReflSaveTabView.h" #include "QtReflSettingsTabView.h" +#include "ReflSaveTabPresenter.h" #include "ReflMainWindowPresenter.h" +#include "ReflAsciiSaver.h" +#include "MantidKernel/make_unique.h" #include <QMessageBox> @@ -38,8 +41,9 @@ void QtReflMainWindowView::initLayout() { connect(m_ui.helpButton, SIGNAL(clicked()), this, SLOT(helpPressed())); // Create the presenter - m_presenter.reset(new ReflMainWindowPresenter( - this, runsPresenter, eventPresenter, settingsPresenter, savePresenter)); + m_presenter = Mantid::Kernel::make_unique<ReflMainWindowPresenter>( + this, runsPresenter, eventPresenter, settingsPresenter, + std::move(savePresenter)); } void QtReflMainWindowView::helpPressed() { @@ -84,12 +88,13 @@ IReflSettingsTabPresenter *QtReflMainWindowView::createSettingsTab() { /** Creates the 'Save ASCII' tab and returns a pointer to its presenter * @return :: A pointer to the presenter managing the 'Save ASCII' tab */ -IReflSaveTabPresenter *QtReflMainWindowView::createSaveTab() { +std::unique_ptr<IReflSaveTabPresenter> QtReflMainWindowView::createSaveTab() { + auto saveTabView = Mantid::Kernel::make_unique<QtReflSaveTabView>(this); + m_ui.mainTab->addTab(saveTabView.get(), QString("Save ASCII")); - QtReflSaveTabView *saveTab = new QtReflSaveTabView(this); - m_ui.mainTab->addTab(saveTab, QString("Save ASCII")); - - return saveTab->getPresenter(); + auto saver = Mantid::Kernel::make_unique<ReflAsciiSaver>(); + return Mantid::Kernel::make_unique<ReflSaveTabPresenter>( + std::move(saver), std::move(saveTabView)); } /** diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.h b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.h index 6cb5f70be8faa9205ce42622e159ed3632299e3f..b193895b9446255d481dcc8dd392309a221faa9b 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.h +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflMainWindowView.h @@ -80,7 +80,7 @@ private: /// Creates the 'Settings' tab IReflSettingsTabPresenter *createSettingsTab(); /// Creates the 'Save ASCII' tab - IReflSaveTabPresenter *createSaveTab(); + std::unique_ptr<IReflSaveTabPresenter> createSaveTab(); /// Interface definition with widgets for the main interface window Ui::RelMainWindowWidget m_ui; diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.cpp b/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.cpp index 9d96d85b0169ceae1d6b7b49aef2238191343c5a..7cb6ab7fa7672b1f4940226dfd8bee684dafd502 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.cpp @@ -2,6 +2,8 @@ #include "ReflSaveTabPresenter.h" #include <boost/algorithm/string.hpp> +#include <QMessageBox> +#include <QFileDialog> namespace MantidQt { namespace CustomInterfaces { @@ -9,12 +11,17 @@ namespace CustomInterfaces { /** Constructor * @param parent :: The parent of this view */ -QtReflSaveTabView::QtReflSaveTabView(QWidget *parent) : m_presenter() { - +QtReflSaveTabView::QtReflSaveTabView(QWidget *parent) : m_presenter(nullptr) { UNUSED_ARG(parent); initLayout(); } +void QtReflSaveTabView::subscribe(IReflSaveTabPresenter *presenter) { + m_presenter = presenter; + populateListOfWorkspaces(); + suggestSaveDir(); +} + /** Destructor */ QtReflSaveTabView::~QtReflSaveTabView() {} @@ -32,18 +39,50 @@ void QtReflSaveTabView::initLayout() { SLOT(filterWorkspaceList())); connect(m_ui.listOfWorkspaces, SIGNAL(itemDoubleClicked(QListWidgetItem *)), this, SLOT(requestWorkspaceParams())); + connect(m_ui.saveReductionResultsCheckBox, SIGNAL(stateChanged(int)), this, + SLOT(onAutosaveChanged(int))); + connect(m_ui.savePathEdit, SIGNAL(editingFinished()), this, + SLOT(onSavePathChanged())); + connect(m_ui.savePathBrowseButton, SIGNAL(clicked()), this, + SLOT(browseToSaveDirectory())); +} - m_presenter.reset(new ReflSaveTabPresenter(this)); - populateListOfWorkspaces(); - suggestSaveDir(); +void QtReflSaveTabView::browseToSaveDirectory() { + auto savePath = QFileDialog::getExistingDirectory( + this, "Select the directory to save to."); + if (!savePath.isEmpty()) { + m_ui.savePathEdit->setText(savePath); + onSavePathChanged(); + } } -/** Returns the presenter managing this view -* @return :: A pointer to the presenter -*/ -IReflSaveTabPresenter *QtReflSaveTabView::getPresenter() const { +void QtReflSaveTabView::onSavePathChanged() { + m_presenter->notify(IReflSaveTabPresenter::Flag::savePathChanged); +} + +void QtReflSaveTabView::onAutosaveChanged(int state) { + if (state == Qt::CheckState::Checked) + m_presenter->notify(IReflSaveTabPresenter::Flag::autosaveEnabled); + else + m_presenter->notify(IReflSaveTabPresenter::Flag::autosaveDisabled); +} + +void QtReflSaveTabView::disableAutosaveControls() { + m_ui.autosaveGroup->setEnabled(false); +} + +void QtReflSaveTabView::enableAutosaveControls() { + m_ui.autosaveGroup->setEnabled(true); +} - return m_presenter.get(); +void QtReflSaveTabView::enableFileFormatAndLocationControls() { + m_ui.fileFormatGroup->setEnabled(true); + m_ui.fileLocationGroup->setEnabled(true); +} + +void QtReflSaveTabView::disableFileFormatAndLocationControls() { + m_ui.fileFormatGroup->setEnabled(false); + m_ui.fileLocationGroup->setEnabled(false); } /** Returns the save path @@ -133,6 +172,10 @@ bool QtReflSaveTabView::getQResolutionCheck() const { return m_ui.qResolutionCheckBox->isChecked(); } +void QtReflSaveTabView::disallowAutosave() { + m_ui.saveReductionResultsCheckBox->setCheckState(Qt::CheckState::Unchecked); +} + /** Returns the separator type * @return :: The separator */ @@ -204,5 +247,28 @@ void QtReflSaveTabView::suggestSaveDir() const { m_presenter->notify(IReflSaveTabPresenter::suggestSaveDirFlag); } +/** +Show an critical error dialog +@param prompt : The prompt to appear on the dialog +@param title : The text for the title bar of the dialog +*/ +void QtReflSaveTabView::giveUserCritical(const std::string &prompt, + const std::string &title) { + QMessageBox::critical(this, QString::fromStdString(title), + QString::fromStdString(prompt), QMessageBox::Ok, + QMessageBox::Ok); +} + +/** +Show an information dialog +@param prompt : The prompt to appear on the dialog +@param title : The text for the title bar of the dialog +*/ +void QtReflSaveTabView::giveUserInfo(const std::string &prompt, + const std::string &title) { + QMessageBox::information(this, QString::fromStdString(title), + QString::fromStdString(prompt), QMessageBox::Ok, + QMessageBox::Ok); +} } // namespace CustomInterfaces } // namespace Mantid diff --git a/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.h b/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.h index f2270146072be511473d82a44bb36761e5c5726d..353f893f0e72863277b544aa7fda51716501e243 100644 --- a/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.h +++ b/qt/scientific_interfaces/ISISReflectometry/QtReflSaveTabView.h @@ -44,8 +44,8 @@ public: QtReflSaveTabView(QWidget *parent = nullptr); /// Destructor ~QtReflSaveTabView() override; - /// Returns the presenter managing this view - IReflSaveTabPresenter *getPresenter() const override; + + void subscribe(IReflSaveTabPresenter *presenter) override; /// Returns the save path std::string getSavePath() const override; @@ -81,6 +81,19 @@ public: /// Sets the 'List of logged parameters' widget void setParametersList(const std::vector<std::string> &) const override; + void disallowAutosave() override; + + void disableAutosaveControls() override; + void enableAutosaveControls() override; + + void enableFileFormatAndLocationControls() override; + void disableFileFormatAndLocationControls() override; + + void giveUserCritical(const std::string &prompt, + const std::string &title) override; + void giveUserInfo(const std::string &prompt, + const std::string &title) override; + public slots: /// Populate the 'List of workspaces' widget void populateListOfWorkspaces() const; @@ -92,12 +105,16 @@ public slots: void saveWorkspaces() const; /// Suggest a save directory void suggestSaveDir() const; + void browseToSaveDirectory(); + + void onSavePathChanged(); + void onAutosaveChanged(int state); private: /// Initialize the interface void initLayout(); /// The presenter - std::unique_ptr<IReflSaveTabPresenter> m_presenter; + IReflSaveTabPresenter *m_presenter; /// The widget Ui::ReflSaveTabWidget m_ui; }; diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.cpp new file mode 100644 index 0000000000000000000000000000000000000000..c4ef14add7e9d4d6250e44dfb400ef52c7e40d54 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.cpp @@ -0,0 +1,115 @@ +#include "ReflAsciiSaver.h" +#include "MantidAPI/AlgorithmManager.h" +#include "MantidAPI/AnalysisDataService.h" +#include "MantidAPI/MatrixWorkspace.h" +#include <Poco/Path.h> +#include <Poco/File.h> +namespace MantidQt { +namespace CustomInterfaces { + +Mantid::API::IAlgorithm_sptr +ReflAsciiSaver::algorithmForFormat(NamedFormat format) { + auto create = + [](std::string const &algorithmName) -> Mantid::API::IAlgorithm_sptr { + return Mantid::API::AlgorithmManager::Instance().create(algorithmName); + }; + switch (format) { + case NamedFormat::Custom: + return create("SaveReflCustomAscii"); + case NamedFormat::ThreeColumn: + return create("SaveReflThreeColumnAscii"); + case NamedFormat::ANSTO: + return create("SaveANSTOAscii"); + case NamedFormat::ILLCosmos: + return create("SaveILLCosmosAscii"); + default: + throw std::runtime_error("Unknown save format."); + } +} + +std::string ReflAsciiSaver::extensionForFormat(NamedFormat format) { + switch (format) { + case NamedFormat::Custom: + return ".dat"; + case NamedFormat::ThreeColumn: + return ".dat"; + case NamedFormat::ANSTO: + return ".txt"; + case NamedFormat::ILLCosmos: + return ".mft"; + default: + throw std::runtime_error("Unknown save format."); + } +} + +bool ReflAsciiSaver::isValidSaveDirectory(std::string const &path) const { + if (!path.empty()) { + try { + auto pocoPath = Poco::Path().parseDirectory(path); + auto pocoFile = Poco::File(pocoPath); + return pocoFile.exists() && pocoFile.canWrite(); + } catch (Poco::PathSyntaxException &) { + return false; + } + } else + return false; +} + +namespace { +template <typename T> +void setPropertyIfSupported(Mantid::API::IAlgorithm_sptr alg, + std::string const &propertyName, T const &value) { + if (alg->existsProperty(propertyName)) + alg->setProperty(propertyName, value); +} +} + +std::string ReflAsciiSaver::assembleSavePath( + std::string const &saveDirectory, std::string const &prefix, + std::string const &name, std::string const &extension) const { + auto path = Poco::Path(saveDirectory).makeDirectory(); + path.append(prefix + name + extension); + return path.toString(); +} + +Mantid::API::MatrixWorkspace_sptr +ReflAsciiSaver::workspace(std::string const &workspaceName) const { + return Mantid::API::AnalysisDataService::Instance() + .retrieveWS<Mantid::API::MatrixWorkspace>(workspaceName); +} + +Mantid::API::IAlgorithm_sptr ReflAsciiSaver::setUpSaveAlgorithm( + std::string const &saveDirectory, + Mantid::API::MatrixWorkspace_sptr workspace, + std::vector<std::string> const &logParameters, + FileFormatOptions const &fileFormat) const { + auto saveAlg = algorithmForFormat(fileFormat.format()); + auto extension = extensionForFormat(fileFormat.format()); + if (fileFormat.shouldIncludeTitle()) + setPropertyIfSupported(saveAlg, "Title", workspace->getTitle()); + + setPropertyIfSupported(saveAlg, "LogList", logParameters); + setPropertyIfSupported(saveAlg, "WriteDeltaQ", + fileFormat.shouldIncludeQResolution()); + saveAlg->setProperty("Separator", fileFormat.separator()); + saveAlg->setProperty("Filename", + assembleSavePath(saveDirectory, fileFormat.prefix(), + workspace->getName(), extension)); + saveAlg->setProperty("InputWorkspace", workspace); + return saveAlg; +} + +void ReflAsciiSaver::save(std::string const &saveDirectory, + std::vector<std::string> const &workspaceNames, + std::vector<std::string> const &logParameters, + FileFormatOptions const &fileFormat) const { + // Setup the appropriate save algorithm + if (isValidSaveDirectory(saveDirectory)) + for (auto const &name : workspaceNames) + setUpSaveAlgorithm(saveDirectory, workspace(name), logParameters, + fileFormat)->execute(); + else + throw InvalidSavePath(saveDirectory); +} +} +} diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.h b/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.h new file mode 100644 index 0000000000000000000000000000000000000000..08616d3205d8203d9d5ab6c2103436f9375a7d44 --- /dev/null +++ b/qt/scientific_interfaces/ISISReflectometry/ReflAsciiSaver.h @@ -0,0 +1,39 @@ +#ifndef MANTID_ISISREFLECTOMETRY_REFLASCIISAVER_H +#define MANTID_ISISREFLECTOMETRY_REFLASCIISAVER_H +#include <vector> +#include <string> +#include "MantidAPI/IAlgorithm_fwd.h" +#include "MantidAPI/MatrixWorkspace_fwd.h" +#include "IReflAsciiSaver.h" + +namespace MantidQt { +namespace CustomInterfaces { +class ReflAsciiSaver : public IReflAsciiSaver { +public: + static Mantid::API::IAlgorithm_sptr algorithmForFormat(NamedFormat format); + static std::string extensionForFormat(NamedFormat format); + + bool isValidSaveDirectory(std::string const &filePath) const override; + void save(std::string const &saveDirectory, + std::vector<std::string> const &workspaceNames, + std::vector<std::string> const &logParameters, + FileFormatOptions const &inputParameters) const override; + +private: + Mantid::API::IAlgorithm_sptr + setUpSaveAlgorithm(std::string const &saveDirectory, + Mantid::API::MatrixWorkspace_sptr workspace, + std::vector<std::string> const &logParameters, + FileFormatOptions const &fileFormat) const; + + std::string assembleSavePath(std::string const &saveDirectory, + std::string const &prefix, + std::string const &name, + std::string const &extension) const; + + Mantid::API::MatrixWorkspace_sptr + workspace(std::string const &workspaceName) const; +}; +} +} +#endif // MANTID_ISISREFLECTOMETRY_REFLASCIISAVER_H diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorMainPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorMainPresenter.h index 4da34c4cf5823f7f6c851ea0cb2eaf329deac021..b723fa605d5616bb8df25dc002d8f32bb5cfde36 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorMainPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorMainPresenter.h @@ -5,8 +5,6 @@ namespace MantidQt { namespace CustomInterfaces { /** @class ReflDataProcessorMainPresenter -TODO: description - Copyright © 2011-16 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge National Laboratory & European Spallation Source diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.cpp index 8e4c2bd4ac44007e5a230f7afe43c69c104b843a..4784b2740af3c07c1e47c96f6e0c56ac57389efa 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.cpp @@ -539,6 +539,19 @@ bool ReflDataProcessorPresenter::processGroupAsEventWS( return errors; } +void ReflDataProcessorPresenter::completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &groupData, + std::string const &workspaceName) { + m_mainPresenter->completedGroupReductionSuccessfully(groupData, + workspaceName); +} + +void ReflDataProcessorPresenter::completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &groupData, + std::string const &workspaceName) { + m_mainPresenter->completedRowReductionSuccessfully(groupData, workspaceName); +} + /** Processes a group of non-event workspaces * * @param groupID :: An integer number indicating the id of this group diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.h index d4c14b878cb09c870c350a38071b4f4fa1862982..c57e56b407de083e7612f634dbe90b3cb46a98c8 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflDataProcessorPresenter.h @@ -105,6 +105,12 @@ public: // Add entry for the number of slices for all rows in a group void addNumGroupSlicesEntry(int groupID, size_t numSlices); + void + completedRowReductionSuccessfully(GroupData const &groupData, + std::string const &workspaceName) override; + void completedGroupReductionSuccessfully( + GroupData const &groupData, std::string const &workspaceName) override; + private: // Get the processing options for this row OptionsMap getProcessingOptions(RowData_sptr data) override; diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.cpp index 6bc30c3d1e985742ad7f9a3dbc611b7ed866585b..e355ecdf72f25e705a12943a12a9b372a343564d 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.cpp @@ -10,7 +10,10 @@ namespace CustomInterfaces { /** Constructor * @param view :: The view we are handling */ -ReflEventPresenter::ReflEventPresenter(IReflEventView *view) : m_view(view) {} +ReflEventPresenter::ReflEventPresenter(IReflEventView *view) + : m_view(view), m_sliceType(SliceType::UniformEven) { + m_view->enableSliceType(m_sliceType); +} /** Destructor */ @@ -20,20 +23,63 @@ ReflEventPresenter::~ReflEventPresenter() {} * @return :: The time-slicing values */ std::string ReflEventPresenter::getTimeSlicingValues() const { + switch (m_sliceType) { + case SliceType::UniformEven: + return m_view->getUniformEvenTimeSlicingValues(); + case SliceType::Uniform: + return m_view->getUniformTimeSlicingValues(); + case SliceType::Custom: + return m_view->getCustomTimeSlicingValues(); + case SliceType::LogValue: { + auto slicingValues = m_view->getLogValueTimeSlicingValues(); + auto logFilter = m_view->getLogValueTimeSlicingType(); + return logFilterAndSliceValues(slicingValues, logFilter); + } + default: + throw std::runtime_error("Unrecognized slice type."); + } +} - return m_view->getTimeSlicingValues(); +std::string ReflEventPresenter::logFilterAndSliceValues( + std::string const &slicingValues, std::string const &logFilter) const { + if (!slicingValues.empty() && !logFilter.empty()) + return "Slicing=\"" + slicingValues + "\",LogFilter=" + logFilter; + else + return ""; } /** Returns the time-slicing type * @return :: The time-slicing type */ std::string ReflEventPresenter::getTimeSlicingType() const { + switch (m_sliceType) { + case SliceType::UniformEven: + return "UniformEven"; + case SliceType::Uniform: + return "Uniform"; + case SliceType::Custom: + return "Custom"; + case SliceType::LogValue: + return "LogValue"; + default: + throw std::runtime_error("Unrecognized slice type."); + } +} - return m_view->getTimeSlicingType(); +void ReflEventPresenter::onReductionPaused() { + m_view->enableSliceType(m_sliceType); + m_view->enableSliceTypeSelection(); } -void ReflEventPresenter::onReductionPaused() { m_view->enableAll(); } +void ReflEventPresenter::onReductionResumed() { + m_view->disableSliceType(m_sliceType); + m_view->disableSliceTypeSelection(); +} -void ReflEventPresenter::onReductionResumed() { m_view->disableAll(); } +void ReflEventPresenter::notifySliceTypeChanged(SliceType newSliceType) { + m_view->disableSliceType(m_sliceType); + m_view->enableSliceType(newSliceType); + m_sliceType = newSliceType; +} } } diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.h index 0e4dbe124c6dcc35271b9192e443203f79b344c6..37b51da3185e3329c3b7eeeee60f548b8aad41c6 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflEventPresenter.h @@ -51,10 +51,14 @@ public: void onReductionPaused() override; void onReductionResumed() override; + void notifySliceTypeChanged(SliceType newSliceType) override; private: + std::string logFilterAndSliceValues(std::string const &slicingValues, + std::string const &logFilter) const; /// The view we are managing IReflEventView *m_view; + SliceType m_sliceType; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflEventWidget.ui b/qt/scientific_interfaces/ISISReflectometry/ReflEventWidget.ui index 6f83ec0442cb63310d68423a6b0ad3c6d3977fd2..8aabf0c1e193b348898c622567b03a6102aa83ad 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflEventWidget.ui +++ b/qt/scientific_interfaces/ISISReflectometry/ReflEventWidget.ui @@ -53,6 +53,9 @@ </item> <item row="0" column="1"> <widget class="QLineEdit" name="uniformEvenEdit"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="toolTip"> <string>The number of evenly sized slices to split the event data into</string> </property> @@ -60,6 +63,9 @@ </item> <item row="0" column="2"> <widget class="QLabel" name="uniformEvenLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>even time slices</string> </property> @@ -87,6 +93,9 @@ </item> <item row="1" column="1"> <widget class="QLineEdit" name="uniformEdit"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="toolTip"> <string>The length of time in seconds each slice should cover</string> </property> @@ -94,6 +103,9 @@ </item> <item row="1" column="2"> <widget class="QLabel" name="uniformLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>(sec) slices</string> </property> @@ -132,6 +144,9 @@ </item> <item> <widget class="QLabel" name="customLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Python list (sec)</string> </property> @@ -139,6 +154,9 @@ </item> <item> <widget class="QLineEdit" name="customEdit"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="toolTip"> <string>A comma separated list of values indicating the times (in seconds) at which to slice the data</string> </property> @@ -175,6 +193,9 @@ </item> <item> <widget class="QLabel" name="logValueLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Python list</string> </property> @@ -182,6 +203,9 @@ </item> <item> <widget class="QLineEdit" name="logValueEdit"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="toolTip"> <string>A comma separated list of values indicating the log values at which to slice the data</string> </property> @@ -189,6 +213,9 @@ </item> <item> <widget class="QLabel" name="logValueTypeLabel"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="text"> <string>Log name</string> </property> @@ -196,6 +223,9 @@ </item> <item> <widget class="QLineEdit" name="logValueTypeEdit"> + <property name="enabled"> + <bool>false</bool> + </property> <property name="toolTip"> <string>The name of the log value to slice on</string> </property> diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp index 057c05ad29c669d25dfde3e554dfe07c965e6c66..ac94f825336a299ce6807ee46c5aa018d3170a9e 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.cpp @@ -23,10 +23,10 @@ ReflMainWindowPresenter::ReflMainWindowPresenter( IReflMainWindowView *view, IReflRunsTabPresenter *runsPresenter, IReflEventTabPresenter *eventPresenter, IReflSettingsTabPresenter *settingsPresenter, - IReflSaveTabPresenter *savePresenter) + std::unique_ptr<IReflSaveTabPresenter> savePresenter) : m_view(view), m_runsPresenter(runsPresenter), m_eventPresenter(eventPresenter), m_settingsPresenter(settingsPresenter), - m_savePresenter(savePresenter), m_isProcessing(false) { + m_savePresenter(std::move(savePresenter)), m_isProcessing(false) { // Tell the tab presenters that this is going to be the main presenter m_runsPresenter->acceptMainPresenter(this); @@ -41,6 +41,16 @@ ReflMainWindowPresenter::ReflMainWindowPresenter( */ ReflMainWindowPresenter::~ReflMainWindowPresenter() {} +void ReflMainWindowPresenter::completedGroupReductionSuccessfully( + GroupData const &group, std::string const &workspaceName) { + m_savePresenter->completedGroupReductionSuccessfully(group, workspaceName); +} + +void ReflMainWindowPresenter::completedRowReductionSuccessfully( + GroupData const &group, std::string const &workspaceName) { + m_savePresenter->completedRowReductionSuccessfully(group, workspaceName); +} + void ReflMainWindowPresenter::notifyReductionPaused(int group) { m_isProcessing = false; m_savePresenter->onAnyReductionPaused(); diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.h index c2a24bb0715269a4bfe1b128ebcc545dc2eda0ef..4212994c0edd99d6a11851b6b68a15275d0c846f 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflMainWindowPresenter.h @@ -3,6 +3,7 @@ #include "DllConfig.h" #include "IReflMainWindowPresenter.h" +#include <memory> namespace MantidQt { namespace CustomInterfaces { @@ -47,7 +48,7 @@ public: IReflRunsTabPresenter *runsPresenter, IReflEventTabPresenter *eventPresenter, IReflSettingsTabPresenter *settingsPresenter, - IReflSaveTabPresenter *savePresenter); + std::unique_ptr<IReflSaveTabPresenter> savePresenter); /// Destructor ~ReflMainWindowPresenter() override; @@ -87,6 +88,13 @@ public: void notifyReductionPaused(int group) override; void notifyReductionResumed(int group) override; + void completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) override; + void completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) override; + private: /// Check for Settings Tab null pointer void checkSettingsPtrValid(IReflSettingsTabPresenter *pointer) const; @@ -106,7 +114,7 @@ private: /// The presenter of tab 'Settings' IReflSettingsTabPresenter *m_settingsPresenter; /// The presenter of tab 'Save ASCII' - IReflSaveTabPresenter *m_savePresenter; + std::unique_ptr<IReflSaveTabPresenter> m_savePresenter; /// State boolean on whether runs are currently being processed or not mutable bool m_isProcessing; }; diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp index a6b157a098fec9494be9c3eb561bbe5730b8089f..e842a967cde20ab5ef5d1cfe93cc126b44f1672b 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.cpp @@ -159,6 +159,16 @@ void ReflRunsTabPresenter::notify(IReflRunsTabPresenter::Flag flag) { // a flag we aren't handling. } +void ReflRunsTabPresenter::completedGroupReductionSuccessfully( + GroupData const &group, std::string const &workspaceName) { + m_mainPresenter->completedGroupReductionSuccessfully(group, workspaceName); +} + +void ReflRunsTabPresenter::completedRowReductionSuccessfully( + GroupData const &group, std::string const &workspaceNames) { + m_mainPresenter->completedRowReductionSuccessfully(group, workspaceNames); +} + /** Pushes the list of commands (actions) */ void ReflRunsTabPresenter::pushCommands() { diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h index 67e3ac646319b14014b2d8d5d01d7f3ba2611cb0..facd80a7ff85d1cfb386e315ab0a6d28dd23a337 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflRunsTabPresenter.h @@ -5,6 +5,7 @@ #include "DllConfig.h" #include "IReflRunsTabPresenter.h" #include "MantidQtWidgets/Common/DataProcessorUI/DataProcessorMainPresenter.h" +#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" #include <boost/shared_ptr.hpp> namespace MantidQt { @@ -89,6 +90,12 @@ public: void confirmReductionPaused(int group) override; void confirmReductionResumed(int group) override; void settingsChanged(int group) override; + void completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &) override; + void completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceNames) override; private: /// The search model diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.cpp b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.cpp index 31ee91b63b00fa440f78d60be62f82f8cd7ac162..a03a5502674c23f5392f266212f50e8f377bbea4 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.cpp +++ b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.cpp @@ -18,15 +18,17 @@ namespace CustomInterfaces { using namespace Mantid::API; -/** Constructor +/** +* @param saver :: The model to use to save the files * @param view :: The view we are handling */ -ReflSaveTabPresenter::ReflSaveTabPresenter(IReflSaveTabView *view) - : m_view(view), m_mainPresenter() { +ReflSaveTabPresenter::ReflSaveTabPresenter( + std::unique_ptr<IReflAsciiSaver> saver, + std::unique_ptr<IReflSaveTabView> view) + : m_view(std::move(view)), m_saver(std::move(saver)), m_mainPresenter(), + m_shouldAutosave(false) { - m_saveAlgs = {"SaveReflCustomAscii", "SaveReflThreeColumnAscii", - "SaveANSTOAscii", "SaveILLCosmosAscii"}; - m_saveExts = {".dat", ".dat", ".txt", ".mft"}; + m_view->subscribe(this); } /** Destructor @@ -41,9 +43,17 @@ void ReflSaveTabPresenter::acceptMainPresenter( m_mainPresenter = mainPresenter; } -void ReflSaveTabPresenter::onAnyReductionPaused() { populateWorkspaceList(); } +void ReflSaveTabPresenter::onAnyReductionPaused() { + populateWorkspaceList(); + m_view->enableAutosaveControls(); + m_view->enableFileFormatAndLocationControls(); +} -void ReflSaveTabPresenter::onAnyReductionResumed() {} +void ReflSaveTabPresenter::onAnyReductionResumed() { + m_view->disableAutosaveControls(); + if (shouldAutosave()) + m_view->disableFileFormatAndLocationControls(); +} void ReflSaveTabPresenter::notify(IReflSaveTabPresenter::Flag flag) { switch (flag) { @@ -57,14 +67,56 @@ void ReflSaveTabPresenter::notify(IReflSaveTabPresenter::Flag flag) { populateParametersList(); break; case saveWorkspacesFlag: - saveWorkspaces(); + saveSelectedWorkspaces(); break; case suggestSaveDirFlag: suggestSaveDir(); break; + case autosaveDisabled: + disableAutosave(); + break; + case autosaveEnabled: + enableAutosave(); + break; + case savePathChanged: + onSavePathChanged(); + } +} + +void ReflSaveTabPresenter::enableAutosave() { + if (isValidSaveDirectory(m_view->getSavePath())) { + m_shouldAutosave = true; + } else { + m_shouldAutosave = false; + m_view->disallowAutosave(); + errorInvalidSaveDirectory(); } } +void ReflSaveTabPresenter::disableAutosave() { m_shouldAutosave = false; } + +void ReflSaveTabPresenter::onSavePathChanged() { + if (shouldAutosave() && !isValidSaveDirectory(m_view->getSavePath())) + warnInvalidSaveDirectory(); +} + +void ReflSaveTabPresenter::completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) { + UNUSED_ARG(group); + if (shouldAutosave()) + saveWorkspaces(std::vector<std::string>({workspaceName})); +} + +bool ReflSaveTabPresenter::shouldAutosave() const { return m_shouldAutosave; } + +void ReflSaveTabPresenter::completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) { + if (!MantidWidgets::DataProcessor::canPostprocess(group) && shouldAutosave()) + saveWorkspaces(std::vector<std::string>({workspaceName})); +} + /** Fills the 'List of Workspaces' widget with the names of all available * workspaces */ @@ -125,66 +177,83 @@ void ReflSaveTabPresenter::populateParametersList() { m_view->setParametersList(logs); } -/** Saves selected workspaces -*/ -void ReflSaveTabPresenter::saveWorkspaces() { - // Check that save directory is valid - std::string saveDir = m_view->getSavePath(); - if (saveDir.empty() || Poco::File(saveDir).isDirectory() == false) { - m_mainPresenter->giveUserCritical("Directory specified doesn't exist or " - "was invalid for your operating system", - "Invalid directory"); - return; - } +bool ReflSaveTabPresenter::isValidSaveDirectory(std::string const &directory) { + return m_saver->isValidSaveDirectory(directory); +} - // Check that at least one workspace has been selected for saving - auto wsNames = m_view->getSelectedWorkspaces(); - if (wsNames.empty()) { - m_mainPresenter->giveUserCritical("No workspaces selected. You must select " - "the workspaces to save.", - "No workspaces selected"); +void ReflSaveTabPresenter::error(std::string const &message, + std::string const &title) { + m_view->giveUserCritical(message, title); +} + +void ReflSaveTabPresenter::warn(std::string const &message, + std::string const &title) { + m_view->giveUserInfo(message, title); +} + +void ReflSaveTabPresenter::warnInvalidSaveDirectory() { + warn("You just changed the save path to a directory which " + "doesn't exist or is not writable.", + "Invalid directory"); +} + +void ReflSaveTabPresenter::errorInvalidSaveDirectory() { + error("The save path specified doesn't exist or is " + "not writable.", + "Invalid directory"); +} + +NamedFormat ReflSaveTabPresenter::formatFromIndex(int formatIndex) const { + switch (formatIndex) { + case 0: + return NamedFormat::Custom; + case 1: + return NamedFormat::ThreeColumn; + case 2: + return NamedFormat::ANSTO; + case 3: + return NamedFormat::ILLCosmos; + default: + throw std::runtime_error("Unknown save format."); } +} - // Obtain workspace titles - std::vector<std::string> wsTitles(wsNames.size()); - std::transform(wsNames.begin(), wsNames.end(), wsTitles.begin(), - [](std::string s) { - return AnalysisDataService::Instance() - .retrieveWS<MatrixWorkspace>(s) - ->getTitle(); - }); - - // Create the appropriate save algorithm - bool titleCheck = m_view->getTitleCheck(); - auto selectedParameters = m_view->getSelectedParameters(); - bool qResolutionCheck = m_view->getQResolutionCheck(); - std::string separator = m_view->getSeparator(); - std::string prefix = m_view->getPrefix(); - int formatIndex = m_view->getFileFormatIndex(); - std::string algName = m_saveAlgs[formatIndex]; - std::string extension = m_saveExts[formatIndex]; - IAlgorithm_sptr saveAlg = AlgorithmManager::Instance().create(algName); - - for (size_t i = 0; i < wsNames.size(); i++) { - // Add any additional algorithm-specific properties and execute - if (algName != "SaveANSTOAscii") { - if (titleCheck) - saveAlg->setProperty("Title", wsTitles[i]); - saveAlg->setProperty("LogList", selectedParameters); - } - if (algName == "SaveReflCustomAscii") { - saveAlg->setProperty("WriteDeltaQ", qResolutionCheck); - } +FileFormatOptions ReflSaveTabPresenter::getSaveParametersFromView() const { + return FileFormatOptions( + /*format=*/formatFromIndex(m_view->getFileFormatIndex()), + /*prefix=*/m_view->getPrefix(), + /*includeTitle=*/m_view->getTitleCheck(), + /*separator=*/m_view->getSeparator(), + /*includeQResolution=*/m_view->getQResolutionCheck()); +} + +void ReflSaveTabPresenter::saveWorkspaces( + std::vector<std::string> const &workspaceNames, + std::vector<std::string> const &logParameters) { + auto savePath = m_view->getSavePath(); + if (m_saver->isValidSaveDirectory(savePath)) + m_saver->save(savePath, workspaceNames, logParameters, + getSaveParametersFromView()); + else + errorInvalidSaveDirectory(); +} - auto path = Poco::Path(saveDir); - auto wsName = wsNames[i]; - path.append(prefix + wsName + extension); - saveAlg->setProperty("Separator", separator); - saveAlg->setProperty("Filename", path.toString()); - saveAlg->setProperty( - "InputWorkspace", - AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>(wsName)); - saveAlg->execute(); +/** Saves workspaces with the names specified. */ +void ReflSaveTabPresenter::saveWorkspaces( + std::vector<std::string> const &workspaceNames) { + auto selectedLogParameters = m_view->getSelectedParameters(); + saveWorkspaces(workspaceNames, selectedLogParameters); +} + +/** Saves selected workspaces */ +void ReflSaveTabPresenter::saveSelectedWorkspaces() { + // Check that at least one workspace has been selected for saving + auto workspaceNames = m_view->getSelectedWorkspaces(); + if (workspaceNames.empty()) { + error("No workspaces selected", "No workspaces selected. " + "You must select the workspaces to save."); + } else { + saveWorkspaces(workspaceNames); } } diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.h b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.h index 9c99f770d30f6304c213347e6e265256f63d4f37..6e9f00ecc053e5dda9c0bda4cbe867250f42efb3 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.h +++ b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabPresenter.h @@ -5,6 +5,10 @@ #include "IReflSaveTabPresenter.h" #include <vector> #include <string> +#include <memory> +#include <MantidKernel/ConfigPropertyObserver.h> +#include <boost/optional.hpp> +#include "IReflAsciiSaver.h" namespace MantidQt { namespace CustomInterfaces { @@ -43,16 +47,29 @@ class MANTIDQT_ISISREFLECTOMETRY_DLL ReflSaveTabPresenter : public IReflSaveTabPresenter { public: /// Constructor - ReflSaveTabPresenter(IReflSaveTabView *view); + ReflSaveTabPresenter(std::unique_ptr<IReflAsciiSaver> saver, + std::unique_ptr<IReflSaveTabView> view); /// Destructor ~ReflSaveTabPresenter() override; /// Accept a main presenter void acceptMainPresenter(IReflMainWindowPresenter *mainPresenter) override; void notify(IReflSaveTabPresenter::Flag flag) override; + void completedGroupReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) override; + void completedRowReductionSuccessfully( + MantidWidgets::DataProcessor::GroupData const &group, + std::string const &workspaceName) override; void onAnyReductionPaused() override; void onAnyReductionResumed() override; private: + bool isValidSaveDirectory(std::string const &directory); + void onSavePathChanged(); + void warnInvalidSaveDirectory(); + void errorInvalidSaveDirectory(); + void warn(std::string const &message, std::string const &title); + void error(std::string const &message, std::string const &title); /// Adds all workspace names to the list of workspaces void populateWorkspaceList(); /// Adds all workspace params to the list of logged parameters @@ -62,18 +79,25 @@ private: /// Suggest a save directory void suggestSaveDir(); /// Save selected workspaces to a directory - void saveWorkspaces(); + void saveSelectedWorkspaces(); + /// Save specified workspaces to a directory + void saveWorkspaces(std::vector<std::string> const &workspaceNames); + void saveWorkspaces(std::vector<std::string> const &workspaceNames, + std::vector<std::string> const &logParameters); /// Obtains all available workspace names std::vector<std::string> getAvailableWorkspaceNames(); + NamedFormat formatFromIndex(int formatIndex) const; + FileFormatOptions getSaveParametersFromView() const; + void enableAutosave(); + void disableAutosave(); + bool shouldAutosave() const; /// The view - IReflSaveTabView *m_view; + std::unique_ptr<IReflSaveTabView> m_view; + std::unique_ptr<IReflAsciiSaver> m_saver; /// The main presenter IReflMainWindowPresenter *m_mainPresenter; - /// Names of possible save algorithms - std::vector<std::string> m_saveAlgs; - /// Extensions used for each save algorithm - std::vector<std::string> m_saveExts; + bool m_shouldAutosave; }; } } diff --git a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabWidget.ui b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabWidget.ui index f90507e4f7646bd62dcdf69741ca4a13b84607c3..d38e4f2da4170f7196a5823fa83b5dca85fcaad9 100644 --- a/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabWidget.ui +++ b/qt/scientific_interfaces/ISISReflectometry/ReflSaveTabWidget.ui @@ -1,351 +1,368 @@ <?xml version="1.0" encoding="UTF-8"?> <ui version="4.0"> <class>ReflSaveTabWidget</class> - <widget class="QWidget" name="ReflSaveTabWidget"> - <property name="geometry"> - <rect> - <x>0</x> - <y>0</y> - <width>959</width> - <height>346</height> - </rect> - </property> - <property name="windowTitle"> - <string>Save ASCII</string> - </property> - <layout class="QVBoxLayout" name="verticalLayout"> - <property name="margin"> - <number>20</number> - </property> + <widget class="QWidget" name="ReflSaveTabWidget"> + <property name="geometry"> + <rect> + <x>0</x> + <y>0</y> + <width>988</width> + <height>672</height> + </rect> + </property> + <property name="windowTitle"> + <string>Save ASCII</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout" stretch="0,1"> + <item> + <widget class="QGroupBox" name="fileLocationGroup"> + <property name="title"> + <string>File Names and Location</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout_3"> <item> - <layout class="QHBoxLayout" name="horizontalLayout"> - <item> - <widget class="QLabel" name="savePathLabel"> - <property name="text"> - <string>Save path:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="savePathEdit"/> - </item> - <item> - <widget class="QLabel" name="prefixLabel"> - <property name="text"> - <string>Prefix:</string> - </property> - </widget> - </item> - <item> - <widget class="QLineEdit" name="prefixEdit"/> - </item> - <item> - <spacer name="prefixSpacer"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> + <widget class="QLabel" name="savePathLabel"> + <property name="text"> + <string>Save Path:</string> + </property> + </widget> + </item> + <item> + <widget class="QLineEdit" name="savePathEdit"/> + </item> + <item> + <widget class="QPushButton" name="savePathBrowseButton"> + <property name="text"> + <string>Browse To Directory</string> + </property> + </widget> + </item> + <item> + <widget class="QLabel" name="fileNameLabel"> + <property name="text"> + <string>File Name Prefix:</string> + </property> + </widget> </item> <item> - <widget class="QGroupBox" name="customSaveGroup"> - <property name="title"> - <string>Custom save</string> + <widget class="QLineEdit" name="prefixEdit"/> + </item> + </layout> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="detailedOptionsLayout" stretch="2,1"> + <item> + <layout class="QVBoxLayout" name="saveTypesLayout" stretch="0,1"> + <item> + <widget class="QGroupBox" name="customSaveGroupBox"> + <property name="title"> + <string>Custom Save</string> + </property> + <layout class="QHBoxLayout" name="horizontalLayout"> + <property name="leftMargin"> + <number>6</number> </property> - <layout class="QGridLayout" name="customSaveLayout"> - <property name="margin"> - <number>20</number> - </property> - <item row ="0" column="0"> - <widget class="QLabel" name="filterLabel"> + <item> + <layout class="QVBoxLayout" name="workspaceListLayout"> + <item> + <widget class="QLabel" name="listOfWorkspacesLabel"> <property name="text"> - <string>Filter</string> + <string><b>List Of Workspaces</b></string> </property> - </widget> - </item> - <item row="0" column="1"> - <widget class="QLineEdit" name="filterEdit"/> - </item> - <item row="0" column="2"> - <widget class="QCheckBox" name="regexCheckBox"/> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="regexLabel"> - <property name="text"> - <string>Regex</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <spacer name="customSaveSpacer0"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row ="1" column="0" colspan="4"> - <widget class="QLabel" name="listOfWorkspacesLabel"> - <property name="text"> - <string>List Of Workspaces</string> - </property> - </widget> - </item> - <item row="1" column="4"> - <spacer name="customSaveSpacer1"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row ="1" column="5"> - <widget class="QLabel" name="listOfLoggedParametersLabel"> - <property name="text"> - <string>List Of Logged Parameters</string> - </property> - </widget> - </item> - <item row ="2" column="0" colspan="4"> - <widget class="QListWidget" name="listOfWorkspaces"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - <item row="2" column="4"> - <spacer name="customSaveSpacer2"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row ="2" column="5"> - <widget class="QListWidget" name="listOfLoggedParameters"> - <property name="selectionMode"> - <enum>QAbstractItemView::ExtendedSelection</enum> - </property> - </widget> - </item> - <item row="3" column="0" colspan="4"> - <widget class="QPushButton" name="refreshButton"> - <property name="text"> - <string>Refresh</string> - </property> - </widget> - </item> - <item row="3" column="4"> - <spacer name="customSaveSpacer3"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + </widget> </item> - <item row="3" column="5" rowspan="4"> - <widget class="QGroupBox" name="customFormatOptionsGroup"> - <property name="title"> - <string>Custom Format Options</string> + <item> + <layout class="QHBoxLayout" name="workspaceFilterLayout"> + <item> + <widget class="QLineEdit" name="filterEdit"> + <property name="placeholderText"> + <string>Filter Workspaces</string> </property> - <layout class="QGridLayout" name="customFormatOptionsLayout"> - <item row="0" column="0"> - <widget class="QCheckBox" name="titleCheckBox"/> - </item> - <item row="0" column="1"> - <widget class="QLabel" name="titleLabel"> - <property name="text"> - <string>Title</string> - </property> - </widget> - </item> - <item row="0" column="2"> - <widget class="QCheckBox" name="qResolutionCheckBox"/> - </item> - <item row="0" column="3"> - <widget class="QLabel" name="qResolutionLabel"> - <property name="text"> - <string>Q resolution</string> - </property> - </widget> - </item> - <item row="0" column="4"> - <spacer name="customFormatOptionsSpacer0"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - <item row="1" column="0" colspan="5"> - <widget class="QGroupBox" name="separatorGroup"> - <property name="title"> - <string>Separator</string> - </property> - <layout class="QGridLayout" name="separatorLayout"> - <item row="0" column="0"> - <widget class="QRadioButton" name="commaRadioButton"> - <property name="text"> - <string>Comma</string> - </property> - <property name="checked"> - <bool>true</bool> - </property> - <attribute name="buttonGroup"> - <string notr="true">separatorButtonGroup</string> - </attribute> - </widget> - </item> - <item row="0" column="1"> - <widget class="QRadioButton" name="spaceRadioButton"> - <property name="text"> - <string>Space</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">separatorButtonGroup</string> - </attribute> - </widget> - </item> - <item row="0" column="2"> - <widget class="QRadioButton" name="tabRadioButton"> - <property name="text"> - <string>Tab</string> - </property> - <attribute name="buttonGroup"> - <string notr="true">separatorButtonGroup</string> - </attribute> - </widget> - </item> - <item row="0" column="3"> - <spacer name="separatorSpacer0"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> - </item> - </layout> - </widget> - </item> - </layout> - </widget> - </item> - <item row ="5" column="0"> - <widget class="QLabel" name="fileFormatLabel"> + </widget> + </item> + <item> + <widget class="QCheckBox" name="regexCheckBox"> <property name="text"> - <string>File format</string> + <string>Regex</string> </property> - </widget> + </widget> + </item> + </layout> </item> - <item row="5" column="1" colspan="3"> - <widget class="QComboBox" name="fileFormatComboBox"> - <item> - <property name="text"> - <string>Custom format (*.dat)</string> - </property> - </item> - <item> - <property name="text"> - <string>3 column (*.dat)</string> - </property> - </item> - <item> - <property name="text"> - <string>ANSTO, MotoFit, 4 column (*.txt)</string> - </property> - </item> - <item> - <property name="text"> - <string>ILL Cosmos (*.mft)</string> - </property> - </item> - <property name="font"> - <font> - <bold>true</bold> - </font> - </property> - </widget> + <item> + <widget class="QListWidget" name="listOfWorkspaces"> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> </item> - <item row="5" column="4"> - <spacer name="customSaveSpacer5"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> + <item> + <widget class="QPushButton" name="refreshButton"> + <property name="text"> + <string>Refresh</string> + </property> + </widget> </item> - <item row="6" column="0" colspan="4"> - <widget class="QPushButton" name="saveButton"> - <property name="text"> - <string>Save</string> - </property> - </widget> + </layout> + </item> + <item> + <layout class="QVBoxLayout" name="loggedParametersLayout"> + <item> + <widget class="QLabel" name="listOfLoggedParametersLabel"> + <property name="text"> + <string><b>List Of Logged Parameters</b></string> + </property> + <property name="textFormat"> + <enum>Qt::RichText</enum> + </property> + </widget> </item> - <item row="6" column="4"> - <spacer name="customSaveSpacer6"> - <property name="orientation"> - <enum>Qt::Horizontal</enum> - </property> - <property name="sizeHint" stdset="0"> - <size> - <width>20</width> - <height>20</height> - </size> - </property> - </spacer> + <item> + <widget class="QListWidget" name="listOfLoggedParameters"> + <property name="selectionMode"> + <enum>QAbstractItemView::ExtendedSelection</enum> + </property> + </widget> </item> - </layout> + </layout> + </item> + </layout> </widget> - </item> + </item> + <item> + <widget class="QGroupBox" name="autosaveGroup"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Preferred" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="title"> + <string>Automatic Save</string> + </property> + <layout class="QVBoxLayout" name="verticalLayout_3"> + <item> + <widget class="QCheckBox" name="saveReductionResultsCheckBox"> + <property name="toolTip"> + <string>Saves stitched workspaces for multi-row group reductions and IvsQ_binned workspaces for reductions single row reductions.</string> + </property> + <property name="text"> + <string>Save as ASCII on completion</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QGroupBox" name="fileFormatGroup"> + <property name="styleSheet"> + <string notr="true">.QGroupBox { + border-bottom: transparent; + border-left: transparent; + border-right: transparent; +}</string> + </property> + <property name="title"> + <string>File Format</string> + </property> + <property name="alignment"> + <set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set> + </property> + <layout class="QVBoxLayout" name="verticalLayout_4" stretch="0,0,0,0,0,0"> + <property name="leftMargin"> + <number>6</number> + </property> + <property name="topMargin"> + <number>6</number> + </property> + <property name="rightMargin"> + <number>6</number> + </property> + <property name="bottomMargin"> + <number>6</number> + </property> + <item> + <widget class="QCheckBox" name="titleCheckBox"> + <property name="text"> + <string>Title</string> + </property> + </widget> + </item> + <item> + <widget class="QCheckBox" name="qResolutionCheckBox"> + <property name="text"> + <string>Q resolution</string> + </property> + </widget> + </item> + <item> + <layout class="QHBoxLayout" name="separatorButtons"> + <property name="sizeConstraint"> + <enum>QLayout::SetMinimumSize</enum> + </property> + <item> + <widget class="QLabel" name="separatorLabel"> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>20</height> + </size> + </property> + <property name="text"> + <string>Separator:</string> + </property> + </widget> + </item> + <item> + <widget class="QRadioButton" name="commaRadioButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="text"> + <string>Comma</string> + </property> + <property name="checked"> + <bool>true</bool> + </property> + <attribute name="buttonGroup"> + <string notr="true">separatorButtonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QRadioButton" name="spaceRadioButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Space</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">separatorButtonGroup</string> + </attribute> + </widget> + </item> + <item> + <widget class="QRadioButton" name="tabRadioButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="Minimum" vsizetype="Fixed"> + <horstretch>0</horstretch> + <verstretch>0</verstretch> + </sizepolicy> + </property> + <property name="text"> + <string>Tab</string> + </property> + <attribute name="buttonGroup"> + <string notr="true">separatorButtonGroup</string> + </attribute> + </widget> + </item> + </layout> + </item> + <item> + <widget class="QComboBox" name="fileFormatComboBox"> + <property name="font"> + <font> + <weight>75</weight> + <bold>true</bold> + </font> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <item> + <property name="text"> + <string>Custom format (*.dat)</string> + </property> + </item> + <item> + <property name="text"> + <string>3 column (*.dat)</string> + </property> + </item> + <item> + <property name="text"> + <string>ANSTO, MotoFit, 4 column (*.txt)</string> + </property> + </item> + <item> + <property name="text"> + <string>ILL Cosmos (*.mft)</string> + </property> + </item> + </widget> + </item> + <item> + <spacer name="verticalSpacer"> + <property name="orientation"> + <enum>Qt::Vertical</enum> + </property> + <property name="sizeHint" stdset="0"> + <size> + <width>20</width> + <height>40</height> + </size> + </property> + </spacer> + </item> + <item> + <widget class="QPushButton" name="saveButton"> + <property name="sizePolicy"> + <sizepolicy hsizetype="MinimumExpanding" vsizetype="Preferred"> + <horstretch>0</horstretch> + <verstretch>3</verstretch> + </sizepolicy> + </property> + <property name="minimumSize"> + <size> + <width>0</width> + <height>0</height> + </size> + </property> + <property name="maximumSize"> + <size> + <width>16777215</width> + <height>131</height> + </size> + </property> + <property name="styleSheet"> + <string notr="true"/> + </property> + <property name="text"> + <string>Save</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> </layout> - </widget> - <tabstops/> - <customwidgets/> + </item> + </layout> + </widget> <resources/> <connections/> -<buttongroups> + <buttongroups> <buttongroup name="separatorButtonGroup"/> -</buttongroups> + </buttongroups> </ui> diff --git a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp index e2a78dcc7d02ce157b3e07070d937b8c7b95cbba..ea6b73f4e77d1e04f117d4f32a378d41e02c2d67 100644 --- a/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp +++ b/qt/scientific_interfaces/ISISSANS/SANSPlotSpecial.cpp @@ -423,16 +423,16 @@ void SANSPlotSpecial::setupTable() { m_derivatives["Rg"] = new QTableWidgetItem(); m_derivatives["Rg"]->setToolTip("Radius of gyration"); - m_units["Rg"] = QString::fromUtf8("\xc3\x85"); + m_units["Rg"] = QString::fromUtf8(R"(Ã…)"); m_derivatives["Rg,xs"] = new QTableWidgetItem(*m_emptyCell); m_derivatives["Rg,xs"]->setToolTip("Cross-sectional radius of gyration"); - m_units["Rg,xs"] = QString::fromUtf8("\xc3\x85"); + m_units["Rg,xs"] = QString::fromUtf8(R"(Ã…)"); m_derivatives["R"] = new QTableWidgetItem(*m_emptyCell); m_derivatives["R"]->setToolTip("Equivalent spherical radius"); - m_units["R"] = QString::fromUtf8("\xc3\x85"); + m_units["R"] = QString::fromUtf8(R"(Ã…)"); m_derivatives["T"] = new QTableWidgetItem(*m_emptyCell); m_derivatives["T"]->setToolTip("Thickness"); - m_units["T"] = QString::fromUtf8("\xc3\x85"); + m_units["T"] = QString::fromUtf8(R"(Ã…)"); m_derivatives["C"] = new QTableWidgetItem(); m_derivatives["C"]->setToolTip("Concentration"); m_units["C"] = "g/cm^3"; @@ -460,7 +460,7 @@ void SANSPlotSpecial::setupTable() { m_units["V"] = "(unitless)"; m_derivatives["Zeta"] = new QTableWidgetItem(*m_emptyCell); m_derivatives["Zeta"]->setToolTip("Characteristic length"); - m_units["Zeta"] = QString::fromUtf8("\xc3\x85"); + m_units["Zeta"] = QString::fromUtf8(R"(Ã…)"); m_derivatives["(S/V)"] = new QTableWidgetItem(); m_derivatives["(S/V)"]->setToolTip("Surface area-to-volume ratio"); m_units["(S/V)"] = "cm^-1"; diff --git a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp index ed5a8be8ee02d33faf3331803801e27007e612a7..20f2186aaee7a4c26a3ba786398b1601c3a7e310 100644 --- a/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/AbsorptionCorrections.cpp @@ -63,7 +63,7 @@ AbsorptionCorrections::AbsorptionCorrections(QWidget *parent) : CorrectionsTab(parent) { m_uiForm.setupUi(parent); - QRegExp regex("[A-Za-z0-9\\-\\(\\)]*"); + QRegExp regex(R"([A-Za-z0-9\-\(\)]*)"); QValidator *formulaValidator = new QRegExpValidator(regex, this); m_uiForm.leSampleChemicalFormula->setValidator(formulaValidator); m_uiForm.leCanChemicalFormula->setValidator(formulaValidator); diff --git a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp index 3bf5a5a050293e750dff4ee2f5635140a2aed216..5f1dc8ab1079856cad6e539975c8d1a605343c23 100644 --- a/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp +++ b/qt/scientific_interfaces/Indirect/ApplyAbsorptionCorrections.cpp @@ -255,7 +255,7 @@ void ApplyAbsorptionCorrections::run() { "Would you like to interpolate this workspace to " "match the sample?"; - result = QMessageBox::question(NULL, tr("Interpolate corrections?"), + result = QMessageBox::question(nullptr, tr("Interpolate corrections?"), tr(text.c_str()), QMessageBox::YesToAll, QMessageBox::Yes, QMessageBox::No); } diff --git a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp index ed80f16fc2ca9c8af6185ce271bb1696a1c5c4ec..f16c0812867e34d1eca9b1f049b72feb8dc25614 100644 --- a/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp +++ b/qt/scientific_interfaces/Indirect/CalculatePaalmanPings.cpp @@ -33,7 +33,7 @@ CalculatePaalmanPings::CalculatePaalmanPings(QWidget *parent) connect(m_uiForm.dsSample, SIGNAL(dataReady(const QString &)), this, SLOT(fillCorrectionDetails(const QString &))); - QRegExp regex("[A-Za-z0-9\\-\\(\\)]*"); + QRegExp regex(R"([A-Za-z0-9\-\(\)]*)"); QValidator *formulaValidator = new QRegExpValidator(regex, this); m_uiForm.leSampleChemicalFormula->setValidator(formulaValidator); m_uiForm.leCanChemicalFormula->setValidator(formulaValidator); diff --git a/qt/scientific_interfaces/Indirect/ConvFit.cpp b/qt/scientific_interfaces/Indirect/ConvFit.cpp index 4928651d5fe6ba5e67cd45cd93b8e98b7b2746c8..f84281861a466f00634e869fda41da46a04dbf12 100644 --- a/qt/scientific_interfaces/Indirect/ConvFit.cpp +++ b/qt/scientific_interfaces/Indirect/ConvFit.cpp @@ -709,7 +709,7 @@ double ConvFit::getInstrumentResolution(MatrixWorkspace_sptr workspace) const { // If the analyser component is not already in the data file then load it // from the parameter file - if (inst->getComponentByName(analyser) == NULL || + if (inst->getComponentByName(analyser) == nullptr || inst->getComponentByName(analyser) ->getNumberParameter("resolution") .size() == 0) { @@ -729,7 +729,7 @@ double ConvFit::getInstrumentResolution(MatrixWorkspace_sptr workspace) const { inst = workspace->getInstrument(); } - if (inst->getComponentByName(analyser) != NULL) { + if (inst->getComponentByName(analyser) != nullptr) { resolution = inst->getComponentByName(analyser) ->getNumberParameter("resolution")[0]; } else { diff --git a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp index 96eaa31924158e7a5dc03f473eeff255feaf8cb9..df1c5609c6bccf6ed40f65ef5d09bc383940dbfb 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDataReduction.cpp @@ -177,9 +177,9 @@ void IndirectDataReduction::instrumentSetupChanged( m_instWorkspace = loadInstrumentIfNotExist(instrumentName.toStdString(), analyser.toStdString(), reflection.toStdString()); - instrumentLoadingDone(m_instWorkspace == NULL); + instrumentLoadingDone(m_instWorkspace == nullptr); - if (m_instWorkspace != NULL) + if (m_instWorkspace != nullptr) emit newInstrumentConfiguration(); } @@ -270,14 +270,14 @@ QMap<QString, QString> IndirectDataReduction::getInstrumentDetails() { if (instrumentName == "IRIS" && analyser == "fmica") analyser = "mica"; - if (m_instWorkspace == NULL) { + if (m_instWorkspace == nullptr) { g_log.warning("Instrument workspace not loaded"); return instDetails; } // Get the instrument auto instrument = m_instWorkspace->getInstrument(); - if (instrument == NULL) { + if (instrument == nullptr) { g_log.warning("Instrument workspace has no instrument"); return instDetails; } @@ -292,7 +292,7 @@ QMap<QString, QString> IndirectDataReduction::getInstrumentDetails() { QString value = getInstrumentParameterFrom(instrument, key); - if (value.isEmpty() && component != NULL) + if (value.isEmpty() && component != nullptr) value = getInstrumentParameterFrom(component, key); instDetails[QString::fromStdString(key)] = value; diff --git a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp index 9c4f85695895eb6e3f3884a0aa3a42d13979b08c..3dac377a3374a2eb209791177383df61bbe2b435 100644 --- a/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectDiffractionReduction.cpp @@ -163,7 +163,7 @@ void IndirectDiffractionReduction::run() { */ void IndirectDiffractionReduction::algorithmComplete(bool error) { // Handles completion of the diffraction algorithm chain - disconnect(m_batchAlgoRunner, 0, this, SLOT(algorithmComplete(bool))); + disconnect(m_batchAlgoRunner, nullptr, this, SLOT(algorithmComplete(bool))); // Delete grouping workspace, if created. if (AnalysisDataService::Instance().doesExist(m_groupingWsName)) { diff --git a/qt/scientific_interfaces/Indirect/IndirectTab.cpp b/qt/scientific_interfaces/Indirect/IndirectTab.cpp index 80374143906b27f01145f021b6425ce7402e2fdf..1518c450d6ad05c5f2c42909df7d14fd5aebaa47 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTab.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTab.cpp @@ -112,7 +112,7 @@ void IndirectTab::exportPythonScript() { // Create an algorithm dialog for the script export algorithm MantidQt::API::InterfaceManager interfaceManager; MantidQt::API::AlgorithmDialog *dlg = interfaceManager.createDialogFromName( - "GeneratePythonScript", -1, NULL, false, props, "", enabled); + "GeneratePythonScript", -1, nullptr, false, props, "", enabled); // Show the dialog dlg->show(); diff --git a/qt/scientific_interfaces/Indirect/IndirectTransmissionCalc.cpp b/qt/scientific_interfaces/Indirect/IndirectTransmissionCalc.cpp index 55984fe81316772c4b8928ba3c3b0b39dfb191ae..c02192dea4c1dff197f87730e10811e73d8084a2 100644 --- a/qt/scientific_interfaces/Indirect/IndirectTransmissionCalc.cpp +++ b/qt/scientific_interfaces/Indirect/IndirectTransmissionCalc.cpp @@ -28,7 +28,7 @@ IndirectTransmissionCalc::IndirectTransmissionCalc(QWidget *parent) * Run any tab setup code. */ void IndirectTransmissionCalc::setup() { - QRegExp chemicalFormulaRegex("[A-Za-z0-9\\-\\(\\)]*"); + QRegExp chemicalFormulaRegex(R"([A-Za-z0-9\-\(\)]*)"); QValidator *chemicalFormulaValidator = new QRegExpValidator(chemicalFormulaRegex, this); m_uiForm.leChemicalFormula->setValidator(chemicalFormulaValidator); diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp index 3aa8a088184bba339ea42a4ecd1d610b8b3deab4..4fb92f80dbf3e040b640069f1108cea4e020507e 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.cpp @@ -2591,7 +2591,7 @@ void MuonAnalysis::changeTab(int newTabIndex) { if (m_currentTab == m_uiForm.DataAnalysis) // Leaving DA tab { // Say MantidPlot to use default fit prop. browser - emit setFitPropertyBrowser(NULL); + emit setFitPropertyBrowser(nullptr); // Reset cached config option ConfigService::Instance().setString(PEAK_RADIUS_CONFIG, m_cachedPeakRadius); @@ -2909,7 +2909,7 @@ void MuonAnalysis::hideEvent(QHideEvent *) { // If closed while on DA tab, reassign fit property browser to default one if (m_currentTab == m_uiForm.DataAnalysis) - emit setFitPropertyBrowser(NULL); + emit setFitPropertyBrowser(nullptr); } /** diff --git a/qt/scientific_interfaces/Muon/MuonAnalysis.ui b/qt/scientific_interfaces/Muon/MuonAnalysis.ui index 3b593c28acc735b19e9d3702c6b0836a838726d2..ee5436983dc3763f0761ee3a43f7b4201438dbcf 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysis.ui +++ b/qt/scientific_interfaces/Muon/MuonAnalysis.ui @@ -2260,7 +2260,7 @@ p, li { white-space: pre-wrap; } <property name="minimumSize"> <size> <width>0</width> - <height>100</height> + <height>140</height> </size> </property> <property name="title"> @@ -2389,6 +2389,12 @@ p, li { white-space: pre-wrap; } <layout class="QGridLayout" name="gridLayout_29"> <item row="0" column="0"> <widget class="QLabel" name="optionBinStep_3"> + <property name="minimumSize"> + <size> + <width>20</width> + <height>30</height> + </size> + </property> <property name="toolTip"> <string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd"> <html><head><meta name="qrichtext" content="1" /><style type="text/css"> @@ -2407,7 +2413,14 @@ p, li { white-space: pre-wrap; } </widget> </item> <item row="0" column="1"> - <widget class="QLineEdit" name="binBoundaries"/> + <widget class="QLineEdit" name="binBoundaries"> + <property name="minimumSize"> + <size> + <width>10</width> + <height>10</height> + </size> + </property> + </widget> </item> <item row="0" column="2"> <spacer name="horizontalSpacer_8"> @@ -2433,6 +2446,12 @@ p, li { white-space: pre-wrap; } <verstretch>0</verstretch> </sizepolicy> </property> + <property name="minimumSize"> + <size> + <width>10</width> + <height>10</height> + </size> + </property> <property name="maximumSize"> <size> <width>30</width> @@ -2641,8 +2660,8 @@ p, li { white-space: pre-wrap; } <rect> <x>0</x> <y>0</y> - <width>131</width> - <height>23</height> + <width>165</width> + <height>26</height> </rect> </property> <layout class="QHBoxLayout" name="horizontalLayout_KeepNPlots"> diff --git a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp index a495340e88094e9dd6aa23f8565e3022012d2878..e5b520c4e7e78f1c9d054037d44e5d5fbcdc4078 100644 --- a/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp +++ b/qt/scientific_interfaces/Muon/MuonAnalysisResultTableTab.cpp @@ -305,11 +305,22 @@ MuonAnalysisResultTableTab::getMultipleFitWorkspaces(const QString &label, QStringList workspaces; - for (auto it = wsNames.begin(); it != wsNames.end(); it++) { - if (!isFittedWs(*it)) - continue; // Doesn't pass basic checks + for (auto subGroup = wsNames.begin(); subGroup != wsNames.end(); subGroup++) { + auto wsGroup = ads.retrieveWS<WorkspaceGroup>(*subGroup); + if (sequential) { + std::vector<std::string> tmpNames = wsGroup->getNames(); + for (auto it = tmpNames.begin(); it != tmpNames.end(); it++) { + if (!isFittedWs(*it)) + continue; // Doesn't pass basic checks - workspaces << QString::fromStdString(wsBaseName(*it)); + workspaces << QString::fromStdString(wsBaseName(*it)); + } + } else { + if (!isFittedWs(*subGroup)) + continue; // Doesn't pass basic checks + + workspaces << QString::fromStdString(wsBaseName(*subGroup)); + } } return workspaces; diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelMock.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelMock.h index c0c652246075b66b551b6dbabae296219e1104de..00e09220c5a29c04eb3452452682c61bfc1ba00f 100644 --- a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelMock.h +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelMock.h @@ -13,13 +13,8 @@ using namespace MantidQt::CustomInterfaces; class MockEnggDiffGSASFittingModel : public IEnggDiffGSASFittingModel { public: - MOCK_METHOD1(doPawleyRefinement, - Mantid::API::MatrixWorkspace_sptr( - const GSASIIRefineFitPeaksParameters ¶ms)); - - MOCK_METHOD1(doRietveldRefinement, - Mantid::API::MatrixWorkspace_sptr( - const GSASIIRefineFitPeaksParameters ¶ms)); + MOCK_METHOD1(doRefinement, + void(const GSASIIRefineFitPeaksParameters ¶ms)); MOCK_CONST_METHOD1(getGamma, boost::optional<double>(const RunLabel &runLabel)); @@ -37,6 +32,9 @@ public: MOCK_CONST_METHOD1(loadFocusedRun, Mantid::API::MatrixWorkspace_sptr( const std::string &filename)); + + MOCK_METHOD1(setObserver, + void(boost::shared_ptr<IEnggDiffGSASFittingObserver> observer)); }; GCC_DIAG_ON_SUGGEST_OVERRIDE diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h index 3fab6902c3f6b3c10cf5394cd1c79b10a7a41724..78078fef0df5fb82334dc8cc48a4d77a97c69322 100644 --- a/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingModelTest.h @@ -53,12 +53,7 @@ public: void addSigmaValue(const RunLabel &runLabel, const double sigma); -private: - inline GSASIIRefineFitPeaksOutputProperties - doGSASRefinementAlgorithm(const std::string &fittedPeaksWSName, - const std::string &latticeParamsWSName, - const GSASIIRefineFitPeaksParameters ¶ms, - const std::string &refinementMethod) override; + void doRefinement(const GSASIIRefineFitPeaksParameters ¶ms) override; }; inline void @@ -83,15 +78,10 @@ TestEnggDiffGSASFittingModel::addSigmaValue(const RunLabel &runLabel, addSigma(runLabel, sigma); } -inline GSASIIRefineFitPeaksOutputProperties -TestEnggDiffGSASFittingModel::doGSASRefinementAlgorithm( - const std::string &fittedPeaksWSName, - const std::string &latticeParamsWSName, - const GSASIIRefineFitPeaksParameters ¶ms, - const std::string &refinementMethod) { +void TestEnggDiffGSASFittingModel::doRefinement( + const GSASIIRefineFitPeaksParameters ¶ms) { // Mock method - just create some dummy output and ignore all the parameters UNUSED_ARG(params); - UNUSED_ARG(refinementMethod); const static std::array<std::string, 3> columnHeadings = {{"a", "b", "c"}}; const static std::array<std::array<double, 3>, 1> targetTableValues = { @@ -100,13 +90,14 @@ TestEnggDiffGSASFittingModel::doGSASRefinementAlgorithm( createDummyTable(columnHeadings, targetTableValues); API::AnalysisDataServiceImpl &ADS = API::AnalysisDataService::Instance(); - ADS.add(latticeParamsWSName, latticeParams); + ADS.add("LATTICEPARAMS", latticeParams); API::MatrixWorkspace_sptr ws = WorkspaceCreationHelper::create2DWorkspaceBinned(4, 4, 0.5); - ADS.add(fittedPeaksWSName, ws); + ADS.add("FITTEDPEAKS", ws); - return GSASIIRefineFitPeaksOutputProperties(1, 2, 3); + processRefinementSuccessful(GSASIIRefineFitPeaksOutputProperties( + 1, 2, 3, ws, latticeParams, params.runLabel)); } } // Anonymous namespace @@ -237,12 +228,9 @@ public: API::MatrixWorkspace_sptr inputWS = API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); - API::MatrixWorkspace_sptr fittedPeaks; TS_ASSERT_THROWS_NOTHING( - fittedPeaks = - model.doPawleyRefinement(createGSASIIRefineFitPeaksParameters( - inputWS, runLabel, GSASRefinementMethod::PAWLEY))); - TS_ASSERT(fittedPeaks); + model.doRefinement(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::PAWLEY))); const auto rwp = model.getRwp(runLabel); TS_ASSERT(rwp); @@ -269,12 +257,9 @@ public: API::MatrixWorkspace_sptr inputWS = API::WorkspaceFactory::Instance().create("Workspace2D", 1, 10, 10); - API::MatrixWorkspace_sptr fittedPeaks; TS_ASSERT_THROWS_NOTHING( - fittedPeaks = - model.doRietveldRefinement(createGSASIIRefineFitPeaksParameters( - inputWS, runLabel, GSASRefinementMethod::RIETVELD))); - TS_ASSERT(fittedPeaks); + model.doRefinement(createGSASIIRefineFitPeaksParameters( + inputWS, runLabel, GSASRefinementMethod::RIETVELD))); const auto rwp = model.getRwp(runLabel); TS_ASSERT(rwp); diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingPresenterTest.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingPresenterTest.h index 67c37fda45287617e3658771cf06312e17829191..9775d7a4d9dfcf74b7eff48fec1a2399d539758e 100644 --- a/qt/scientific_interfaces/test/EnggDiffGSASFittingPresenterTest.h +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingPresenterTest.h @@ -68,53 +68,10 @@ public: RunLabel(123, 1), GSASRefinementMethod::RIETVELD, "Instrument file", {"Phase1", "Phase2"}, "GSASHOME", "GPX.gpx", boost::none, boost::none, 10000, 40000, true, false); + setRefinementParamsExpectations(params); - EXPECT_CALL(*m_mockMultiRunWidgetPtr, getSelectedRunLabel()) - .Times(1) - .WillOnce(Return(params.runLabel)); - - EXPECT_CALL(*m_mockMultiRunWidgetPtr, getFocusedRun(params.runLabel)) - .Times(1) - .WillOnce(Return(params.inputWorkspace)); - EXPECT_CALL(*m_mockViewPtr, getRefinementMethod()) - .Times(1) - .WillOnce(Return(params.refinementMethod)); - EXPECT_CALL(*m_mockViewPtr, getInstrumentFileName()) - .Times(1) - .WillOnce(Return(params.instParamsFile)); - EXPECT_CALL(*m_mockViewPtr, getPhaseFileNames()) - .Times(1) - .WillOnce(Return(params.phaseFiles)); - EXPECT_CALL(*m_mockViewPtr, getPathToGSASII()) - .Times(1) - .WillOnce(Return(params.gsasHome)); - EXPECT_CALL(*m_mockViewPtr, getGSASIIProjectPath()) - .Times(1) - .WillOnce(Return(params.gsasProjectFile)); - EXPECT_CALL(*m_mockViewPtr, getPawleyDMin()) - .Times(1) - .WillOnce(Return(params.dMin)); - EXPECT_CALL(*m_mockViewPtr, getPawleyNegativeWeight()) - .Times(1) - .WillOnce(Return(params.negativeWeight)); - EXPECT_CALL(*m_mockViewPtr, getXMin()) - .Times(1) - .WillOnce(Return(params.xMin)); - EXPECT_CALL(*m_mockViewPtr, getXMax()) - .Times(1) - .WillOnce(Return(params.xMax)); - EXPECT_CALL(*m_mockViewPtr, getRefineSigma()) - .Times(1) - .WillOnce(Return(params.refineSigma)); - EXPECT_CALL(*m_mockViewPtr, getRefineGamma()) - .Times(1) - .WillOnce(Return(params.refineGamma)); - - EXPECT_CALL(*m_mockModelPtr, doRietveldRefinement(params)) - .Times(1) - .WillOnce(Throw(std::runtime_error("Failure reason"))); - EXPECT_CALL(*m_mockViewPtr, - userError("Refinement failed", "Failure reason")); + EXPECT_CALL(*m_mockViewPtr, setEnabled(false)).Times(1); + EXPECT_CALL(*m_mockModelPtr, doRefinement(params)).Times(1); presenter->notify(IEnggDiffGSASFittingPresenter::DoRefinement); assertMocksUsedCorrectly(); @@ -128,53 +85,10 @@ public: RunLabel(123, 1), GSASRefinementMethod::PAWLEY, "Instrument file", {"Phase1", "Phase2"}, "GSASHOME", "GPX.gpx", 1, 2, 10000, 40000, true, false); + setRefinementParamsExpectations(params); - EXPECT_CALL(*m_mockMultiRunWidgetPtr, getSelectedRunLabel()) - .Times(1) - .WillOnce(Return(params.runLabel)); - - EXPECT_CALL(*m_mockMultiRunWidgetPtr, getFocusedRun(params.runLabel)) - .Times(1) - .WillOnce(Return(params.inputWorkspace)); - EXPECT_CALL(*m_mockViewPtr, getRefinementMethod()) - .Times(1) - .WillOnce(Return(params.refinementMethod)); - EXPECT_CALL(*m_mockViewPtr, getInstrumentFileName()) - .Times(1) - .WillOnce(Return(params.instParamsFile)); - EXPECT_CALL(*m_mockViewPtr, getPhaseFileNames()) - .Times(1) - .WillOnce(Return(params.phaseFiles)); - EXPECT_CALL(*m_mockViewPtr, getPathToGSASII()) - .Times(1) - .WillOnce(Return(params.gsasHome)); - EXPECT_CALL(*m_mockViewPtr, getGSASIIProjectPath()) - .Times(1) - .WillOnce(Return(params.gsasProjectFile)); - EXPECT_CALL(*m_mockViewPtr, getPawleyDMin()) - .Times(1) - .WillOnce(Return(params.dMin)); - EXPECT_CALL(*m_mockViewPtr, getPawleyNegativeWeight()) - .Times(1) - .WillOnce(Return(params.negativeWeight)); - EXPECT_CALL(*m_mockViewPtr, getXMin()) - .Times(1) - .WillOnce(Return(params.xMin)); - EXPECT_CALL(*m_mockViewPtr, getXMax()) - .Times(1) - .WillOnce(Return(params.xMax)); - EXPECT_CALL(*m_mockViewPtr, getRefineSigma()) - .Times(1) - .WillOnce(Return(params.refineSigma)); - EXPECT_CALL(*m_mockViewPtr, getRefineGamma()) - .Times(1) - .WillOnce(Return(params.refineGamma)); - - EXPECT_CALL(*m_mockModelPtr, doPawleyRefinement(params)) - .Times(1) - .WillOnce(Throw(std::runtime_error("Failure reason"))); - EXPECT_CALL(*m_mockViewPtr, - userError("Refinement failed", "Failure reason")); + EXPECT_CALL(*m_mockViewPtr, setEnabled(false)).Times(1); + EXPECT_CALL(*m_mockModelPtr, doRefinement(params)).Times(1); presenter->notify(IEnggDiffGSASFittingPresenter::DoRefinement); assertMocksUsedCorrectly(); @@ -251,6 +165,54 @@ public: assertMocksUsedCorrectly(); } + void test_notifyRefinementFailed() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockViewPtr, + userWarning("Refinement failed", "Failure Reason")); + EXPECT_CALL(*m_mockViewPtr, setEnabled(true)); + EXPECT_CALL(*m_mockViewPtr, showStatus("Refinement failed")); + + presenter->notifyRefinementFailed("Failure Reason"); + assertMocksUsedCorrectly(); + } + + void test_notifyRefinementSuccessful() { + auto presenter = setUpPresenter(); + const Mantid::API::MatrixWorkspace_sptr fittedPeaks( + WorkspaceCreationHelper::create2DWorkspaceBinned(1, 100)); + const auto latticeParams = + Mantid::API::WorkspaceFactory::Instance().createTable(); + const RunLabel runLabel(123, 1); + const GSASIIRefineFitPeaksOutputProperties refinementResults( + 1, 2, 3, fittedPeaks, latticeParams, runLabel); + + EXPECT_CALL(*m_mockMultiRunWidgetPtr, + addFittedPeaks(runLabel, fittedPeaks)); + EXPECT_CALL(*m_mockViewPtr, setEnabled(true)); + EXPECT_CALL(*m_mockViewPtr, showStatus("Ready")); + + // make sure displayFitResults(runLabel) is getting called + EXPECT_CALL(*m_mockModelPtr, getLatticeParams(runLabel)) + .Times(1) + .WillOnce(Return(boost::none)); + ON_CALL(*m_mockModelPtr, getRwp(runLabel)).WillByDefault(Return(1)); + ON_CALL(*m_mockModelPtr, getSigma(runLabel)).WillByDefault(Return(1)); + ON_CALL(*m_mockModelPtr, getGamma(runLabel)).WillByDefault(Return(1)); + + presenter->notifyRefinementSuccessful(refinementResults); + assertMocksUsedCorrectly(); + } + + void test_notifyRefinementCancelled() { + auto presenter = setUpPresenter(); + EXPECT_CALL(*m_mockViewPtr, setEnabled(true)).Times(1); + EXPECT_CALL(*m_mockViewPtr, showStatus("Ready")).Times(1); + + presenter->notifyRefinementCancelled(); + + assertMocksUsedCorrectly(); + } + private: MockEnggDiffGSASFittingModel *m_mockModelPtr; MockEnggDiffGSASFittingView *m_mockViewPtr; @@ -283,6 +245,50 @@ private: delete m_mockViewPtr; } } + + void setRefinementParamsExpectations( + const GSASIIRefineFitPeaksParameters ¶ms) { + EXPECT_CALL(*m_mockMultiRunWidgetPtr, getSelectedRunLabel()) + .Times(1) + .WillOnce(Return(params.runLabel)); + + EXPECT_CALL(*m_mockMultiRunWidgetPtr, getFocusedRun(params.runLabel)) + .Times(1) + .WillOnce(Return(params.inputWorkspace)); + EXPECT_CALL(*m_mockViewPtr, getRefinementMethod()) + .Times(1) + .WillOnce(Return(params.refinementMethod)); + EXPECT_CALL(*m_mockViewPtr, getInstrumentFileName()) + .Times(1) + .WillOnce(Return(params.instParamsFile)); + EXPECT_CALL(*m_mockViewPtr, getPhaseFileNames()) + .Times(1) + .WillOnce(Return(params.phaseFiles)); + EXPECT_CALL(*m_mockViewPtr, getPathToGSASII()) + .Times(1) + .WillOnce(Return(params.gsasHome)); + EXPECT_CALL(*m_mockViewPtr, getGSASIIProjectPath()) + .Times(1) + .WillOnce(Return(params.gsasProjectFile)); + EXPECT_CALL(*m_mockViewPtr, getPawleyDMin()) + .Times(1) + .WillOnce(Return(params.dMin)); + EXPECT_CALL(*m_mockViewPtr, getPawleyNegativeWeight()) + .Times(1) + .WillOnce(Return(params.negativeWeight)); + EXPECT_CALL(*m_mockViewPtr, getXMin()) + .Times(1) + .WillOnce(Return(params.xMin)); + EXPECT_CALL(*m_mockViewPtr, getXMax()) + .Times(1) + .WillOnce(Return(params.xMax)); + EXPECT_CALL(*m_mockViewPtr, getRefineSigma()) + .Times(1) + .WillOnce(Return(params.refineSigma)); + EXPECT_CALL(*m_mockViewPtr, getRefineGamma()) + .Times(1) + .WillOnce(Return(params.refineGamma)); + } }; #endif // MANTID_CUSTOM_INTERFACES_ENGGDIFFGSASFITTINGPRESENTERTEST_H_ diff --git a/qt/scientific_interfaces/test/EnggDiffGSASFittingViewMock.h b/qt/scientific_interfaces/test/EnggDiffGSASFittingViewMock.h index e7cfb6692de4ed44d53fe23863457c2d93d24596..09f5e555c7c33ae3f450e7ba71dfe211d8f705df 100644 --- a/qt/scientific_interfaces/test/EnggDiffGSASFittingViewMock.h +++ b/qt/scientific_interfaces/test/EnggDiffGSASFittingViewMock.h @@ -57,6 +57,8 @@ public: MOCK_METHOD0(resetCanvas, void()); + MOCK_METHOD1(setEnabled, void(const bool)); + MOCK_CONST_METHOD0(showRefinementResultsSelected, bool()); MOCK_CONST_METHOD1(showStatus, void(const std::string &status)); diff --git a/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetViewMock.h b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetViewMock.h index 064394c78fcc1bfa84481ba15a958ac653c1891b..40dec6660cc302b2ed6e4cd39e7e3e8253fbd438 100644 --- a/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetViewMock.h +++ b/qt/scientific_interfaces/test/EnggDiffMultiRunFittingWidgetViewMock.h @@ -36,6 +36,8 @@ public: MOCK_METHOD0(resetCanvas, void()); + MOCK_METHOD1(setEnabled, void(const bool)); + MOCK_METHOD1( setMessageProvider, void(boost::shared_ptr<IEnggDiffractionUserMsg> messageProvider)); diff --git a/qt/scientific_interfaces/test/MuonAnalysisFitDataPresenterTest.h b/qt/scientific_interfaces/test/MuonAnalysisFitDataPresenterTest.h index ff0ffe24258073e7fada37da00846265719b6590..98bfaf2258929465bf23f85077de9df9aca3dcd5 100644 --- a/qt/scientific_interfaces/test/MuonAnalysisFitDataPresenterTest.h +++ b/qt/scientific_interfaces/test/MuonAnalysisFitDataPresenterTest.h @@ -245,7 +245,7 @@ public: void test_setAssignedFirstRun_loadCurrentRun() { setupGroupPeriodSelections(); const boost::optional<QString> currentRunPath{ - "\\\\musr\\data\\MUSRauto_A.tmp"}; + R"(\\musr\data\MUSRauto_A.tmp)"}; const QString wsName("MUSR00061335; Pair; long; Asym; 1; #1"); EXPECT_CALL(*m_dataSelector, setWorkspaceDetails(QString("00061335"), QString("MUSR"), @@ -706,7 +706,7 @@ public: const QString wsName("MUSR00061335; Group; fwd; Asym; 1; #1"); const QStringList wsNameList{wsName}; const boost::optional<QString> currentRunPath{ - "\\\\musr\\data\\MUSRauto_A.tmp"}; + R"(\\musr\data\MUSRauto_A.tmp)"}; // Expect it will update the workspace names EXPECT_CALL(*m_fitBrowser, setWorkspaceNames(wsNameList)).Times(1); diff --git a/qt/scientific_interfaces/test/ReflEventPresenterTest.h b/qt/scientific_interfaces/test/ReflEventPresenterTest.h index 1b609697e0b517d7c69281441d27911e4ad0de68..e52f24ad56035992331094aa32607bee3496344d 100644 --- a/qt/scientific_interfaces/test/ReflEventPresenterTest.h +++ b/qt/scientific_interfaces/test/ReflEventPresenterTest.h @@ -26,40 +26,50 @@ public: ReflEventPresenterTest() {} - void test_get_slicing_values() { + void testDefaultGetSlicingValues() { MockEventView mockView; ReflEventPresenter presenter(&mockView); - EXPECT_CALL(mockView, getTimeSlicingValues()).Times(Exactly(1)); + EXPECT_CALL(mockView, getUniformEvenTimeSlicingValues()).Times(Exactly(1)); presenter.getTimeSlicingValues(); TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); } - void test_get_slicing_type() { + void testGetSlicingType() { MockEventView mockView; ReflEventPresenter presenter(&mockView); + presenter.notifySliceTypeChanged(SliceType::LogValue); + TS_ASSERT_EQUALS("LogValue", presenter.getTimeSlicingType()); + } + + void testDisablesControlsOnReductionResumed() { + MockEventView mockView; + ReflEventPresenter presenter(&mockView); + EXPECT_CALL(mockView, disableSliceType(_)).Times(AtLeast(1)); + EXPECT_CALL(mockView, disableSliceTypeSelection()).Times(AtLeast(1)); - EXPECT_CALL(mockView, getTimeSlicingType()).Times(Exactly(1)); - presenter.getTimeSlicingType(); + presenter.onReductionResumed(); TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); } - void testDisablesControlsOnReductionResumed() { + void testDisablesCorrectControlsOnReductionResumed() { MockEventView mockView; ReflEventPresenter presenter(&mockView); - EXPECT_CALL(mockView, disableAll()).Times(AtLeast(1)); + presenter.notifySliceTypeChanged(SliceType::Custom); + EXPECT_CALL(mockView, disableSliceType(SliceType::Custom)) + .Times(AtLeast(1)); presenter.onReductionResumed(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); } - void testEnabledControlsOnReductionPaused() { + void testEnablesControlsOnReductionPaused() { MockEventView mockView; ReflEventPresenter presenter(&mockView); - EXPECT_CALL(mockView, enableAll()).Times(AtLeast(1)); + EXPECT_CALL(mockView, enableSliceType(SliceType::UniformEven)) + .Times(AtLeast(1)); presenter.onReductionPaused(); diff --git a/qt/scientific_interfaces/test/ReflMainWindowPresenterTest.h b/qt/scientific_interfaces/test/ReflMainWindowPresenterTest.h index e4638da9685aee3a1ca1f9eb8e06153b4ebbaa42..327fe54a8926c643c65d61844923c80371c08325 100644 --- a/qt/scientific_interfaces/test/ReflMainWindowPresenterTest.h +++ b/qt/scientific_interfaces/test/ReflMainWindowPresenterTest.h @@ -6,6 +6,7 @@ #include <gtest/gtest.h> #include "../ISISReflectometry/ReflMainWindowPresenter.h" +#include "MantidKernel/make_unique.h" #include "ReflMockObjects.h" using namespace MantidQt::CustomInterfaces; @@ -33,10 +34,11 @@ public: MockRunsTabPresenter mockRunsTabPresenter; MockEventTabPresenter mockEventTabPresenter; MockSettingsTabPresenter mockSettingsTabPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsTabPresenter, &mockEventTabPresenter, - &mockSettingsTabPresenter, &mockSaveTabPresenter); + &mockSettingsTabPresenter, std::move(mockSaveTabPresenter)); // Should call the settings tab to get the values double angle = 0.5; @@ -60,10 +62,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); // Should call the settings tab to get the options EXPECT_CALL(mockSettingsPresenter, getTransmissionOptions(0)) @@ -85,10 +88,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); // Should call the settings tab to get the options EXPECT_CALL(mockSettingsPresenter, getReductionOptions(0)) @@ -111,10 +115,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); // Should call the settings tab to get the options EXPECT_CALL(mockSettingsPresenter, getStitchOptions(0)).Times(Exactly(1)); @@ -131,10 +136,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); EXPECT_CALL(mockView, giveUserCritical("Prompt", "Title")) .Times(Exactly(1)); @@ -147,10 +153,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); EXPECT_CALL(mockView, giveUserInfo("Prompt", "Title")).Times(Exactly(1)); presenter.giveUserInfo("Prompt", "Title"); @@ -162,10 +169,11 @@ public: MockRunsTabPresenter mockRunsPresenter; MockEventTabPresenter mockEventPresenter; MockSettingsTabPresenter mockSettingsPresenter; - MockSaveTabPresenter mockSaveTabPresenter; + auto mockSaveTabPresenter = + Mantid::Kernel::make_unique<MockSaveTabPresenter>(); ReflMainWindowPresenter presenter( &mockView, &mockRunsPresenter, &mockEventPresenter, - &mockSettingsPresenter, &mockSaveTabPresenter); + &mockSettingsPresenter, std::move(mockSaveTabPresenter)); EXPECT_CALL(mockView, runPythonAlgorithm("Python code to run")) .Times(Exactly(1)); diff --git a/qt/scientific_interfaces/test/ReflMockObjects.h b/qt/scientific_interfaces/test/ReflMockObjects.h index 2f26bf30bba4ce23dd7530e3fdd1fab239a50aab..cf32ed1e2c17e5179793d8c4e9853ff0f9a409e0 100644 --- a/qt/scientific_interfaces/test/ReflMockObjects.h +++ b/qt/scientific_interfaces/test/ReflMockObjects.h @@ -20,8 +20,10 @@ #include "../ISISReflectometry/ReflSearchModel.h" #include "../ISISReflectometry/ExperimentOptionDefaults.h" #include "../ISISReflectometry/InstrumentOptionDefaults.h" +#include "../ISISReflectometry/IReflAsciiSaver.h" #include "MantidQtWidgets/Common/DataProcessorUI/Command.h" #include "MantidQtWidgets/Common/DataProcessorUI/OptionsMap.h" +#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" #include <gmock/gmock.h> using namespace MantidQt::CustomInterfaces; @@ -130,10 +132,15 @@ public: class MockEventView : public IReflEventView { public: // Global options - MOCK_CONST_METHOD0(getTimeSlicingValues, std::string()); - MOCK_CONST_METHOD0(getTimeSlicingType, std::string()); - MOCK_METHOD0(enableAll, void()); - MOCK_METHOD0(disableAll, void()); + MOCK_METHOD1(enableSliceType, void(SliceType)); + MOCK_METHOD1(disableSliceType, void(SliceType)); + MOCK_METHOD0(enableSliceTypeSelection, void()); + MOCK_METHOD0(disableSliceTypeSelection, void()); + MOCK_CONST_METHOD0(getLogValueTimeSlicingValues, std::string()); + MOCK_CONST_METHOD0(getCustomTimeSlicingValues, std::string()); + MOCK_CONST_METHOD0(getUniformTimeSlicingValues, std::string()); + MOCK_CONST_METHOD0(getUniformEvenTimeSlicingValues, std::string()); + MOCK_CONST_METHOD0(getLogValueTimeSlicingType, std::string()); // Calls we don't care about IReflEventPresenter *getPresenter() const override { return nullptr; } @@ -157,9 +164,17 @@ public: MOCK_CONST_METHOD1(setWorkspaceList, void(const std::vector<std::string> &)); MOCK_CONST_METHOD0(clearParametersList, void()); MOCK_CONST_METHOD1(setParametersList, void(const std::vector<std::string> &)); - - // Calls we don't care about - IReflSaveTabPresenter *getPresenter() const override { return nullptr; } + MOCK_CONST_METHOD0(getAutosavePrefixInput, std::string()); + MOCK_METHOD1(subscribe, void(IReflSaveTabPresenter *)); + MOCK_METHOD0(disallowAutosave, void()); + MOCK_METHOD0(disableAutosaveControls, void()); + MOCK_METHOD0(enableAutosaveControls, void()); + MOCK_METHOD0(enableFileFormatAndLocationControls, void()); + MOCK_METHOD0(disableFileFormatAndLocationControls, void()); + MOCK_METHOD2(giveUserCritical, + void(const std::string &, const std::string &)); + MOCK_METHOD2(giveUserInfo, void(const std::string &, const std::string &)); + virtual ~MockSaveTabView() = default; }; class MockMainWindowView : public IReflMainWindowView { @@ -195,6 +210,7 @@ public: MOCK_CONST_METHOD0(getTimeSlicingType, std::string()); MOCK_METHOD0(onReductionPaused, void()); MOCK_METHOD0(onReductionResumed, void()); + MOCK_METHOD1(notifySliceTypeChanged, void(SliceType)); ~MockEventPresenter() override{}; }; @@ -253,6 +269,12 @@ public: class MockSaveTabPresenter : public IReflSaveTabPresenter { public: + MOCK_METHOD2(completedRowReductionSuccessfully, + void(MantidQt::MantidWidgets::DataProcessor::GroupData const &, + std::string const &)); + MOCK_METHOD2(completedGroupReductionSuccessfully, + void(MantidQt::MantidWidgets::DataProcessor::GroupData const &, + std::string const &)); void notify(IReflSaveTabPresenter::Flag flag) override { UNUSED_ARG(flag); }; void acceptMainPresenter(IReflMainWindowPresenter *presenter) override { UNUSED_ARG(presenter); @@ -272,6 +294,12 @@ public: MOCK_CONST_METHOD1(getStitchOptions, std::string(int)); MOCK_CONST_METHOD1(setInstrumentName, void(const std::string &instName)); MOCK_CONST_METHOD0(getInstrumentName, std::string()); + MOCK_METHOD2(completedRowReductionSuccessfully, + void(MantidQt::MantidWidgets::DataProcessor::GroupData const &, + std::string const &)); + MOCK_METHOD2(completedGroupReductionSuccessfully, + void(MantidQt::MantidWidgets::DataProcessor::GroupData const &, + std::string const &)); MOCK_METHOD1(notify, void(IReflMainWindowPresenter::Flag)); MOCK_METHOD1(notifyReductionPaused, void(int)); MOCK_METHOD1(notifyReductionResumed, void(int)); @@ -323,6 +351,16 @@ public: ~MockICatalogInfo() override {} }; +class MockReflAsciiSaver : public IReflAsciiSaver { +public: + MOCK_CONST_METHOD1(isValidSaveDirectory, bool(std::string const &)); + MOCK_CONST_METHOD4(save, + void(std::string const &, std::vector<std::string> const &, + std::vector<std::string> const &, + FileFormatOptions const &)); + virtual ~MockReflAsciiSaver() = default; +}; + GCC_DIAG_ON_SUGGEST_OVERRIDE #endif /*MANTID_CUSTOMINTERFACES_REFLMOCKOBJECTS_H*/ diff --git a/qt/scientific_interfaces/test/ReflSaveTabPresenterTest.h b/qt/scientific_interfaces/test/ReflSaveTabPresenterTest.h index b41f6c4613c6cb6ef12944ab16a4b6c8b8bdd420..62a625240ac686d2ff49da15be5a9ef666d2f8e6 100644 --- a/qt/scientific_interfaces/test/ReflSaveTabPresenterTest.h +++ b/qt/scientific_interfaces/test/ReflSaveTabPresenterTest.h @@ -10,6 +10,8 @@ #include "MantidAPI/FrameworkManager.h" #include "MantidAPI/AlgorithmManager.h" #include "MantidAPI/MatrixWorkspace.h" +#include "MantidKernel/ConfigService.h" +#include "MantidKernel/make_unique.h" #include "MantidAPI/Run.h" #include "ReflMockObjects.h" #include "Poco/File.h" @@ -36,9 +38,18 @@ public: ReflSaveTabPresenterTest() { FrameworkManager::Instance(); } + bool verifyAndClearMocks() { + auto metViewExpections = Mock::VerifyAndClearExpectations(m_mockViewPtr); + TS_ASSERT(metViewExpections); + auto metSaverExpectations = + Mock::VerifyAndClearExpectations(m_mockSaverPtr); + TS_ASSERT(metSaverExpectations); + return metViewExpections && metSaverExpectations; + } + void testPopulateWorkspaceList() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); std::vector<std::string> wsNames = {"ws1", "ws2", "ws3"}; createWS(wsNames[0]); @@ -53,89 +64,151 @@ public: groupAlg->setProperty("OutputWorkspace", "groupWs"); groupAlg->execute(); - EXPECT_CALL(mockView, clearWorkspaceList()).Times(Exactly(1)); + EXPECT_CALL(*m_mockViewPtr, clearWorkspaceList()).Times(Exactly(1)); // Workspaces 'groupWs' and 'tableWS' should not be included in the // workspace list - EXPECT_CALL(mockView, setWorkspaceList(wsNames)).Times(Exactly(1)); + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(wsNames)).Times(Exactly(1)); presenter.notify(IReflSaveTabPresenter::populateWorkspaceListFlag); AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + + TS_ASSERT(verifyAndClearMocks()); + } + + void testDisablesAutosaveControlsWhenProcessing() { + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); + + EXPECT_CALL(*m_mockViewPtr, disableAutosaveControls()); + presenter.onAnyReductionResumed(); + + TS_ASSERT(verifyAndClearMocks()); + } + + void expectHasValidSaveDirectory(MockReflAsciiSaver &m_mockSaver) { + ON_CALL(m_mockSaver, isValidSaveDirectory(_)).WillByDefault(Return(true)); + } + + void testDisablesFileFormatControlsWhenProcessingAndAutosaveEnabled() { + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); + + expectHasValidSaveDirectory(*m_mockSaverPtr); + presenter.notify(IReflSaveTabPresenter::Flag::autosaveEnabled); + + EXPECT_CALL(*m_mockViewPtr, disableFileFormatAndLocationControls()); + presenter.onAnyReductionResumed(); + + TS_ASSERT(verifyAndClearMocks()); + } + + void testEnablesFileFormatControlsWhenProcessingFinishedAndAutosaveEnabled() { + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); + + expectHasValidSaveDirectory(*m_mockSaverPtr); + presenter.notify(IReflSaveTabPresenter::Flag::autosaveEnabled); + presenter.onAnyReductionResumed(); + + EXPECT_CALL(*m_mockViewPtr, enableFileFormatAndLocationControls()); + presenter.onAnyReductionPaused(); + + TS_ASSERT(verifyAndClearMocks()); + } + + void testEnablesAutosaveControlsWhenProcessingFinished() { + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); + + expectHasValidSaveDirectory(*m_mockSaverPtr); + presenter.notify(IReflSaveTabPresenter::Flag::autosaveEnabled); + + presenter.onAnyReductionResumed(); + EXPECT_CALL(*m_mockViewPtr, enableFileFormatAndLocationControls()); + presenter.onAnyReductionPaused(); + + TS_ASSERT(verifyAndClearMocks()); } void testRefreshWorkspaceList() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); createWS("ws1"); - EXPECT_CALL(mockView, clearWorkspaceList()).Times(Exactly(2)); - EXPECT_CALL(mockView, setWorkspaceList(std::vector<std::string>{"ws1"})) + EXPECT_CALL(*m_mockViewPtr, clearWorkspaceList()).Times(Exactly(2)); + EXPECT_CALL(*m_mockViewPtr, + setWorkspaceList(std::vector<std::string>{"ws1"})) .Times(Exactly(1)); - EXPECT_CALL(mockView, + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(std::vector<std::string>{"ws1", "ws2"})) .Times(Exactly(1)); presenter.notify(IReflSaveTabPresenter::populateWorkspaceListFlag); createWS("ws2"); presenter.notify(IReflSaveTabPresenter::populateWorkspaceListFlag); AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + + TS_ASSERT(verifyAndClearMocks()); } void testFilterWorkspaceNoRegex() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); createWS("anotherWs"); createWS("different"); createWS("someWsName"); - EXPECT_CALL(mockView, clearWorkspaceList()).Times(Exactly(2)); - EXPECT_CALL(mockView, setWorkspaceList(std::vector<std::string>{ - "anotherWs", "different", "someWsName"})) + EXPECT_CALL(*m_mockViewPtr, clearWorkspaceList()).Times(Exactly(2)); + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(std::vector<std::string>{ + "anotherWs", "different", "someWsName"})) .Times(Exactly(1)); - EXPECT_CALL(mockView, getFilter()).Times(Exactly(1)).WillOnce(Return("Ws")); - EXPECT_CALL(mockView, getRegexCheck()) + EXPECT_CALL(*m_mockViewPtr, getFilter()) + .Times(Exactly(1)) + .WillOnce(Return("Ws")); + EXPECT_CALL(*m_mockViewPtr, getRegexCheck()) .Times(Exactly(1)) .WillOnce(Return(false)); - EXPECT_CALL(mockView, setWorkspaceList(std::vector<std::string>{ - "anotherWs", "someWsName"})).Times(Exactly(1)); + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(std::vector<std::string>{ + "anotherWs", "someWsName"})) + .Times(Exactly(1)); presenter.notify(IReflSaveTabPresenter::populateWorkspaceListFlag); presenter.notify(IReflSaveTabPresenter::filterWorkspaceListFlag); AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + + TS_ASSERT(verifyAndClearMocks()); } void testFilterWorkspaceWithRegex() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); createWS("_42"); createWS("apple_113"); createWS("grape_"); createWS("pear_cut"); - EXPECT_CALL(mockView, clearWorkspaceList()).Times(Exactly(2)); - EXPECT_CALL(mockView, setWorkspaceList(std::vector<std::string>{ - "_42", "apple_113", "grape_", "pear_cut"})) + EXPECT_CALL(*m_mockViewPtr, clearWorkspaceList()).Times(Exactly(2)); + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(std::vector<std::string>{ + "_42", "apple_113", "grape_", "pear_cut"})) .Times(Exactly(1)); - EXPECT_CALL(mockView, getFilter()) + EXPECT_CALL(*m_mockViewPtr, getFilter()) .Times(Exactly(1)) .WillOnce(Return("[a-zA-Z]*_[0-9]+")); - EXPECT_CALL(mockView, getRegexCheck()) + EXPECT_CALL(*m_mockViewPtr, getRegexCheck()) .Times(Exactly(1)) .WillOnce(Return(true)); - EXPECT_CALL(mockView, + EXPECT_CALL(*m_mockViewPtr, setWorkspaceList(std::vector<std::string>{"_42", "apple_113"})) .Times(Exactly(1)); presenter.notify(IReflSaveTabPresenter::populateWorkspaceListFlag); presenter.notify(IReflSaveTabPresenter::filterWorkspaceListFlag); AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + TS_ASSERT(verifyAndClearMocks()); } void testPopulateParametersList() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); createWS("ws1"); std::vector<std::string> logs; @@ -147,69 +220,84 @@ public: logs.push_back((*it)->name()); } - EXPECT_CALL(mockView, clearParametersList()).Times(Exactly(1)); - EXPECT_CALL(mockView, getCurrentWorkspaceName()) + EXPECT_CALL(*m_mockViewPtr, clearParametersList()).Times(Exactly(1)); + EXPECT_CALL(*m_mockViewPtr, getCurrentWorkspaceName()) .Times(Exactly(1)) .WillOnce(Return("ws1")); - EXPECT_CALL(mockView, setParametersList(logs)).Times(Exactly(1)); + EXPECT_CALL(*m_mockViewPtr, setParametersList(logs)).Times(Exactly(1)); presenter.notify(IReflSaveTabPresenter::workspaceParamsFlag); AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + TS_ASSERT(verifyAndClearMocks()); } void testSaveWorkspaces() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); - std::string savePath = createSavePath(); std::vector<std::string> wsNames = {"ws1", "ws2", "ws3"}; createWS(wsNames[0]); createWS(wsNames[1]); createWS(wsNames[2]); - EXPECT_CALL(mockView, getSavePath()) - .Times(Exactly(1)) - .WillOnce(Return(savePath)); - EXPECT_CALL(mockView, getTitleCheck()) - .Times(Exactly(1)) - .WillOnce(Return(false)); - EXPECT_CALL(mockView, getSelectedParameters()) - .Times(Exactly(1)) - .WillOnce(Return(std::vector<std::string>())); - EXPECT_CALL(mockView, getQResolutionCheck()) - .Times(Exactly(1)) - .WillOnce(Return(false)); - EXPECT_CALL(mockView, getSeparator()) + EXPECT_CALL(*m_mockViewPtr, getSavePath()).Times(AtLeast(1)); + EXPECT_CALL(*m_mockViewPtr, getTitleCheck()) + .Times(AtLeast(1)) + .WillRepeatedly(Return(false)); + EXPECT_CALL(*m_mockViewPtr, getSelectedParameters()) + .Times(AtLeast(1)) + .WillRepeatedly(Return(std::vector<std::string>())); + EXPECT_CALL(*m_mockViewPtr, getQResolutionCheck()) + .Times(AtLeast(1)) + .WillRepeatedly(Return(false)); + EXPECT_CALL(*m_mockViewPtr, getSeparator()) + .Times(AtLeast(1)) + .WillRepeatedly(Return("comma")); + EXPECT_CALL(*m_mockViewPtr, getPrefix()) .Times(Exactly(1)) - .WillOnce(Return("comma")); - EXPECT_CALL(mockView, getPrefix()).Times(Exactly(1)).WillOnce(Return("")); - EXPECT_CALL(mockView, getFileFormatIndex()) - .Times(Exactly(1)) - .WillOnce(Return(0)); - EXPECT_CALL(mockView, getSelectedWorkspaces()) - .Times(Exactly(1)) - .WillOnce(Return(wsNames)); + .WillOnce(Return("")); + EXPECT_CALL(*m_mockViewPtr, getFileFormatIndex()) + .Times(AtLeast(1)) + .WillRepeatedly(Return(0)); + EXPECT_CALL(*m_mockViewPtr, getSelectedWorkspaces()) + .Times(AtLeast(1)) + .WillRepeatedly(Return(wsNames)); + + EXPECT_CALL(*m_mockSaverPtr, isValidSaveDirectory(_)) + .Times(AtLeast(1)) + .WillRepeatedly(Return(true)); + EXPECT_CALL(*m_mockSaverPtr, save(_, _, _, _)).Times(AtLeast(1)); + presenter.notify(IReflSaveTabPresenter::saveWorkspacesFlag); - for (auto it = wsNames.begin(); it != wsNames.end(); it++) { - Poco::File(savePath + *it + ".dat").remove(); - } + AnalysisDataService::Instance().clear(); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + TS_ASSERT(verifyAndClearMocks()); } void testSuggestSaveDir() { - MockSaveTabView mockView; - ReflSaveTabPresenter presenter(&mockView); + ReflSaveTabPresenter presenter(std::move(m_mockSaver), + std::move(m_mockView)); std::string saveDir = Mantid::Kernel::ConfigService::Instance().getString( "defaultsave.directory"); - EXPECT_CALL(mockView, setSavePath(saveDir)); + EXPECT_CALL(*m_mockViewPtr, setSavePath(saveDir)); presenter.notify(IReflSaveTabPresenter::suggestSaveDirFlag); - TS_ASSERT(Mock::VerifyAndClearExpectations(&mockView)); + TS_ASSERT(verifyAndClearMocks()); } private: + std::unique_ptr<NiceMock<MockReflAsciiSaver>> m_mockSaver; + NiceMock<MockReflAsciiSaver> *m_mockSaverPtr; + std::unique_ptr<MockSaveTabView> m_mockView; + MockSaveTabView *m_mockViewPtr; + + void setUp() override { + m_mockSaver = Mantid::Kernel::make_unique<NiceMock<MockReflAsciiSaver>>(); + m_mockSaverPtr = m_mockSaver.get(); + m_mockView = Mantid::Kernel::make_unique<MockSaveTabView>(); + m_mockViewPtr = m_mockView.get(); + } + void createWS(std::string name) { Workspace2D_sptr ws = WorkspaceCreationHelper::create2DWorkspace(10, 10); AnalysisDataService::Instance().addOrReplace(name, ws); @@ -220,17 +308,6 @@ private: WorkspaceFactory::Instance().createTable("TableWorkspace"); AnalysisDataService::Instance().addOrReplace(name, ws); } - - std::string createSavePath() { - // First attempt to obtain path from default save directory - std::string savePath = Mantid::Kernel::ConfigService::Instance().getString( - "defaultsave.directory"); - if (savePath.empty()) - // Otherwise use current path as save directory - savePath = Poco::Path::current(); - - return savePath; - } }; #endif /* MANTID_CUSTOMINTERFACES_REFLSAVETABPRESENTERTEST_H */ diff --git a/qt/widgets/common/CMakeLists.txt b/qt/widgets/common/CMakeLists.txt index 2a25dd34ccdcb981b9403f6316671522ca51095f..9f5d9147edf10fb8b5d7f8d8560ba517704146a4 100644 --- a/qt/widgets/common/CMakeLists.txt +++ b/qt/widgets/common/CMakeLists.txt @@ -54,6 +54,7 @@ set ( SRC_FILES src/CatalogSelector.cpp src/CheckboxHeader.cpp src/DataProcessorUI/AbstractTreeModel.cpp + src/DataProcessorUI/TreeData.cpp src/DataProcessorUI/GenerateNotebook.cpp src/DataProcessorUI/OneLevelTreeManager.cpp src/DataProcessorUI/OptionsMap.cpp diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorMainPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorMainPresenter.h index 5e7d1f6e49b21836bc88dca963acd2f167fbd6f6..af2a46a457d07c78e70c80338e896804c835241c 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorMainPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/DataProcessorMainPresenter.h @@ -3,6 +3,7 @@ #include "MantidKernel/System.h" #include "MantidQtWidgets/Common/DataProcessorUI/OptionsQMap.h" +#include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" #include <QSet> #include <QString> @@ -81,6 +82,10 @@ public: /// Handle data reduction paused/resumed confirmation virtual void confirmReductionPaused(int group) { UNUSED_ARG(group); } virtual void confirmReductionResumed(int group) { UNUSED_ARG(group); } + virtual void completedGroupReductionSuccessfully(GroupData const &, + std::string const &){}; + virtual void completedRowReductionSuccessfully(GroupData const &, + std::string const &){}; }; } } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h index 0006933317a2174af411ac6f36b9cf737a432d26..868e721aaaecafd4334a8e5e3f64b462a39547ce 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenter.h @@ -39,8 +39,8 @@ class TreeManager; class GenericDataProcessorPresenterThread; using RowItem = std::pair<int, RowData_sptr>; -using RowQueue = std::queue<RowItem>; -using GroupQueue = std::queue<std::pair<int, RowQueue>>; +using RowQueue = std::vector<RowItem>; +using GroupQueue = std::vector<std::pair<int, RowQueue>>; /** @class GenericDataProcessorPresenter @@ -224,6 +224,12 @@ protected: // Plotting virtual void plotRow(); virtual void plotGroup(); + virtual void + completedRowReductionSuccessfully(GroupData const &groupData, + std::string const &workspaceName); + virtual void + completedGroupReductionSuccessfully(GroupData const &groupData, + std::string const &workspaceName); void plotWorkspaces(const QOrderedSet<QString> &workspaces); // Get the name of a post-processed workspace QString getPostprocessedWorkspaceName( @@ -240,11 +246,13 @@ protected: void saveNotebook(const TreeData &data); protected slots: void reductionError(QString ex); - void threadFinished(const int exitCode); + void groupThreadFinished(const int exitCode); + void rowThreadFinished(const int exitCode); void issueNotFoundWarning(QString const &granule, QSet<QString> const &missingWorkspaces); private: + void threadFinished(const int exitCode); void applyDefaultOptions(std::map<QString, QVariant> &options); void setPropertiesFromKeyValueString(Mantid::API::IAlgorithm_sptr alg, const std::string &hiddenOptions, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterThread.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterThread.h index 5299b717ed81b1f5afc51502767ffe0780babc67..203a4f45cf4d041719167b268712ca71a7e63dc2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterThread.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GenericDataProcessorPresenterThread.h @@ -46,9 +46,6 @@ public: // Establish connections between parent and worker connect(this, SIGNAL(started()), worker, SLOT(startWorker())); connect(worker, SIGNAL(finished(int)), this, SLOT(workerFinished(int))); - connect(worker, SIGNAL(finished(int)), parent, SLOT(threadFinished(int))); - connect(worker, SIGNAL(reductionErrorSignal(QString)), parent, - SLOT(reductionError(QString)), Qt::QueuedConnection); // Early deletion of thread and worker connect(this, SIGNAL(finished()), this, SLOT(deleteLater()), Qt::DirectConnection); diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GridDelegate.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GridDelegate.h index 8f8cad70c3ccb600c969a3955aa1b3b7164e36e8..d0604dda6fb704957016c4e0edc156bfe5e28b93 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GridDelegate.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/GridDelegate.h @@ -7,7 +7,8 @@ namespace DataProcessor { class GridDelegate : public QStyledItemDelegate { public: - explicit GridDelegate(QObject *parent = 0) : QStyledItemDelegate(parent){}; + explicit GridDelegate(QObject *parent = nullptr) + : QStyledItemDelegate(parent){}; void paint(QPainter *painter, const QStyleOptionViewItem &option, const QModelIndex &index) const override { diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h index 271e0a810425f9ffacc5faa66596a8202ebceeaa..083d35422c0c9115ad5519f3314569ffce5349e0 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/DataProcessorUI/TreeData.h @@ -26,16 +26,16 @@ Code Documentation is available at: <http://doxygen.mantidproject.org> */ +#include <QStringList> #include "MantidKernel/System.h" #include "MantidQtWidgets/Common/DataProcessorUI/OptionsMap.h" #include "MantidQtWidgets/Common/DataProcessorUI/PostprocessingAlgorithm.h" #include "MantidQtWidgets/Common/DataProcessorUI/PreprocessingAlgorithm.h" #include "MantidQtWidgets/Common/DataProcessorUI/ProcessingAlgorithm.h" #include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" +#include "MantidQtWidgets/Common/DllOption.h" #include "MantidQtWidgets/Common/DataProcessorUI/WhiteList.h" -#include <QStringList> - namespace MantidQt { namespace MantidWidgets { namespace DataProcessor { @@ -144,6 +144,7 @@ private: using GroupData = std::map<int, RowData_sptr>; using TreeData = std::map<int, GroupData>; +EXPORT_OPT_MANTIDQT_COMMON bool canPostprocess(GroupData const &group); } } } diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/FindFilesThreadPoolManagerMockObjects.h b/qt/widgets/common/inc/MantidQtWidgets/Common/FindFilesThreadPoolManagerMockObjects.h index f75564fb9476858ddfe1832d54e300579f88d12e..cfd3f86393bb2284c495084829846abe849195f2 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/FindFilesThreadPoolManagerMockObjects.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/FindFilesThreadPoolManagerMockObjects.h @@ -19,7 +19,7 @@ void qSleep(int ms) { Sleep(uint(ms)); #else struct timespec ts = {ms / 1000, (ms % 1000) * 1000 * 1000}; - nanosleep(&ts, NULL); + nanosleep(&ts, nullptr); #endif } } // namespace diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h index dce046f397697f053b8c4f4d3e0bfef96bb4b66b..4dfe27cbb0051c5731921282707c767d1e5674a4 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/MantidHelpWindow.h @@ -20,7 +20,7 @@ class EXPORT_OPT_MANTIDQT_COMMON MantidHelpWindow Q_OBJECT public: - MantidHelpWindow(QWidget *parent = 0, Qt::WindowFlags flags = 0); + MantidHelpWindow(QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr); ~MantidHelpWindow() override; void showPage(const std::string &url = std::string()) override; diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h index f2208d87826333e6a34ac5b4cd6dc55260f27fb8..dedd26e011df9c2caf797b1a86ad8d050a314540 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/QtPropertyBrowser/qtpropertymanager.h @@ -1138,7 +1138,7 @@ static void setMinimumValue( QtProperty *property, const Value &minVal) { void (PropertyManagerPrivate::*setSubPropertyRange)( QtProperty *, ValueChangeParameter, ValueChangeParameter, - ValueChangeParameter) = 0; + ValueChangeParameter) = nullptr; setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>( manager, managerPrivate, propertyChangedSignal, valueChangedSignal, @@ -1160,7 +1160,7 @@ static void setMaximumValue( QtProperty *property, const Value &maxVal) { void (PropertyManagerPrivate::*setSubPropertyRange)( QtProperty *, ValueChangeParameter, ValueChangeParameter, - ValueChangeParameter) = 0; + ValueChangeParameter) = nullptr; setBorderValue<ValueChangeParameter, PropertyManagerPrivate, PropertyManager, Value, PrivateData>( manager, managerPrivate, propertyChangedSignal, valueChangedSignal, diff --git a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h index 9fceb9b3b0840483e71cde297471a5442d9991d8..9c8200f160ee9a6a8d80ca1a9d2f685a23eef114 100644 --- a/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h +++ b/qt/widgets/common/inc/MantidQtWidgets/Common/pqHelpWindow.h @@ -75,8 +75,8 @@ class EXPORT_OPT_MANTIDQT_COMMON pqHelpWindow : public QMainWindow { using Superclass = QMainWindow; public: - pqHelpWindow(QHelpEngine *engine, QWidget *parent = 0, - Qt::WindowFlags flags = 0); + pqHelpWindow(QHelpEngine *engine, QWidget *parent = nullptr, + Qt::WindowFlags flags = nullptr); public slots: /// Requests showing of a particular page. The url must begin with "qthelp:" diff --git a/qt/widgets/common/src/AlgorithmSelectorWidget.cpp b/qt/widgets/common/src/AlgorithmSelectorWidget.cpp index 465619911e41ec5779b1575100eeec63af9b0fa0..cd42f9b917b69f95e7a119f61b49539ab6401db2 100644 --- a/qt/widgets/common/src/AlgorithmSelectorWidget.cpp +++ b/qt/widgets/common/src/AlgorithmSelectorWidget.cpp @@ -293,7 +293,7 @@ void AlgorithmTreeWidget::update() { this->addTopLevelItem(catItem); } else { QString cn = subCats[0]; - QTreeWidgetItem *catItem = NULL; + QTreeWidgetItem *catItem = nullptr; int n = subCats.size(); for (int j = 0; j < n; j++) { if (categories.contains(cn)) { diff --git a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp index 4e6ee7ccf9b0bf902661b198fd1a5afd612c971f..0dc8cf342ef9726559d492661c2a32938eb4c58d 100644 --- a/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp +++ b/qt/widgets/common/src/DataProcessorUI/GenericDataProcessorPresenter.cpp @@ -63,6 +63,10 @@ bool workspaceExists(QString const &workspaceName) { void removeWorkspace(QString const &workspaceName) { AnalysisDataService::Instance().remove(workspaceName.toStdString()); } + +template <typename T> void pop_front(std::vector<T> &queue) { + queue.erase(queue.begin()); +} } namespace MantidQt { @@ -397,7 +401,7 @@ void GenericDataProcessorPresenter::process() { return; // Add all row items to queue - rowQueue.push(row); + rowQueue.emplace_back(row); // Set group as unprocessed if settings have changed or the expected // output workspaces cannot be found @@ -408,7 +412,7 @@ void GenericDataProcessorPresenter::process() { if (!isProcessed(row.first, group.first)) maxProgress++; } - m_group_queue.emplace(group.first, rowQueue); + m_group_queue.emplace_back(group.first, rowQueue); } // Create progress reporter bar @@ -465,29 +469,36 @@ void GenericDataProcessorPresenter::nextRow() { m_nextActionFlag = ReductionFlag::ReduceRowFlag; // Reduce next row m_rowItem = rqueue.front(); - rqueue.pop(); + pop_front(rqueue); // Skip reducing rows that are already processed if (!isProcessed(m_rowItem.first, groupIndex)) { startAsyncRowReduceThread(&m_rowItem, groupIndex); return; } } else { - m_group_queue.pop(); + pop_front(m_group_queue); // Set next action flag m_nextActionFlag = ReductionFlag::ReduceGroupFlag; // Skip post-processing groups that are already processed or only contain a // single row - if (!isProcessed(groupIndex) && m_groupData.size() > 1) { - startAsyncGroupReduceThread(m_groupData, groupIndex); - return; + if (!isProcessed(groupIndex)) { + if (m_groupData.size() > 1) { + startAsyncGroupReduceThread(m_groupData, groupIndex); + return; + } } } - // Row / group skipped, perform next action doNextAction(); } +void GenericDataProcessorPresenter::completedGroupReductionSuccessfully( + GroupData const &, std::string const &) {} + +void GenericDataProcessorPresenter::completedRowReductionSuccessfully( + GroupData const &, std::string const &) {} + /** Process a new group */ @@ -500,23 +511,27 @@ void GenericDataProcessorPresenter::nextGroup() { return; } - // Clear group data from any previously processed groups - m_groupData.clear(); - if (!m_group_queue.empty()) { // Set next action flag m_nextActionFlag = ReductionFlag::ReduceRowFlag; // Reduce first row auto &rqueue = m_group_queue.front().second; m_rowItem = rqueue.front(); - rqueue.pop(); + // Clear group data from any previously processed groups + m_groupData.clear(); + for (auto &&row : rqueue) + m_groupData[row.first] = row.second; + pop_front(rqueue); + // Skip reducing rows that are already processed - if (!isProcessed(m_rowItem.first, m_group_queue.front().first)) + if (!isProcessed(m_rowItem.first, m_group_queue.front().first)) { startAsyncRowReduceThread(&m_rowItem, m_group_queue.front().first); - else + } else { doNextAction(); + } } else { - // If "Output Notebook" checkbox is checked then create an ipython notebook + // If "Output Notebook" checkbox is checked then create an ipython + // notebook if (m_view->getEnableNotebook()) saveNotebook(m_selectedData); endReduction(); @@ -531,6 +546,10 @@ void GenericDataProcessorPresenter::startAsyncRowReduceThread(RowItem *rowItem, auto *worker = new GenericDataProcessorPresenterRowReducerWorker( this, rowItem, groupIndex); + + connect(worker, SIGNAL(finished(int)), this, SLOT(rowThreadFinished(int))); + connect(worker, SIGNAL(reductionErrorSignal(QString)), this, + SLOT(reductionError(QString)), Qt::QueuedConnection); m_workerThread.reset(new GenericDataProcessorPresenterThread(this, worker)); m_workerThread->start(); } @@ -543,6 +562,9 @@ void GenericDataProcessorPresenter::startAsyncGroupReduceThread( auto *worker = new GenericDataProcessorPresenterGroupReducerWorker( this, groupData, groupIndex); + connect(worker, SIGNAL(finished(int)), this, SLOT(groupThreadFinished(int))); + connect(worker, SIGNAL(reductionErrorSignal(QString)), this, + SLOT(reductionError(QString)), Qt::QueuedConnection); m_workerThread.reset(new GenericDataProcessorPresenterThread(this, worker)); m_workerThread->start(); } @@ -583,6 +605,22 @@ void GenericDataProcessorPresenter::threadFinished(const int exitCode) { } } +void GenericDataProcessorPresenter::groupThreadFinished(const int exitCode) { + + auto postprocessedWorkspace = + getPostprocessedWorkspaceName(m_groupData).toStdString(); + completedGroupReductionSuccessfully(m_groupData, postprocessedWorkspace); + threadFinished(exitCode); +} + +void GenericDataProcessorPresenter::rowThreadFinished(const int exitCode) { + completedRowReductionSuccessfully( + m_groupData, + m_rowItem.second->reducedName(m_processor.defaultOutputPrefix()) + .toStdString()); + threadFinished(exitCode); +} + /** Display a dialog to choose save location for notebook, then save the notebook there @@ -654,8 +692,10 @@ Workspace_sptr GenericDataProcessorPresenter::prepareRunWorkspace( auto const outputName = preprocessingListToString(runs, preprocessor.prefix(), preprocessor.separator()); - /* Ideally, this should be executed as a child algorithm to keep the ADS tidy, - * but that doesn't preserve history nicely, so we'll just take care of tidying + /* Ideally, this should be executed as a child algorithm to keep the ADS + * tidy, + * but that doesn't preserve history nicely, so we'll just take care of + * tidying * up in the event of failure. */ IAlgorithm_sptr alg = @@ -693,12 +733,14 @@ Workspace_sptr GenericDataProcessorPresenter::prepareRunWorkspace( alg->execute(); if (runIt != --runs.end()) { - // After the first execution we replace the LHS with the previous output + // After the first execution we replace the LHS with the previous + // output setAlgorithmProperty(alg.get(), preprocessor.lhsProperty(), outputName); } } } catch (...) { - // If we're unable to create the full workspace, discard the partial version + // If we're unable to create the full workspace, discard the partial + // version removeWorkspace(outputName); // We've tidied up, now re-throw. throw; @@ -1093,7 +1135,8 @@ void GenericDataProcessorPresenter::notify(DataProcessorPresenter::Flag flag) { pause(); break; } - // Not having a 'default' case is deliberate. gcc issues a warning if there's + // Not having a 'default' case is deliberate. gcc issues a warning if + // there's // a flag we aren't handling. } @@ -1442,7 +1485,8 @@ void GenericDataProcessorPresenter::plotWorkspaces( void GenericDataProcessorPresenter::showOptionsDialog() { auto options = new QtDataProcessorOptionsDialog(m_view, m_view->getPresenter()); - // By default the dialog is only destroyed when ReflMainView is and so they'll + // By default the dialog is only destroyed when ReflMainView is and so + // they'll // stack up. // This way, they'll be deallocated as soon as they've been closed. options->setAttribute(Qt::WA_DeleteOnClose, true); diff --git a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp index 78a32013ba7f4c11ecba1ac2f1d8451da526f603..7382690c4be57ad8c196c5879ac11f1a0990929c 100644 --- a/qt/widgets/common/src/DataProcessorUI/TreeData.cpp +++ b/qt/widgets/common/src/DataProcessorUI/TreeData.cpp @@ -1,7 +1,9 @@ #include "MantidQtWidgets/Common/DataProcessorUI/TreeData.h" + namespace MantidQt { namespace MantidWidgets { namespace DataProcessor { +bool canPostprocess(GroupData const &group) { return group.size() > 1; } // Constructors RowData::RowData(const int columnCount) : m_isProcessed{false} { diff --git a/qt/widgets/common/src/FileDialogHandler.cpp b/qt/widgets/common/src/FileDialogHandler.cpp index 5c7f51f0b2cff664f4b2cf06154f16806a69febb..d19a00267049beb174eac3ed153d22dab6e27dd4 100644 --- a/qt/widgets/common/src/FileDialogHandler.cpp +++ b/qt/widgets/common/src/FileDialogHandler.cpp @@ -6,7 +6,7 @@ #include <sstream> namespace { // anonymous namespace -const boost::regex FILE_EXT_REG_EXP{"^.+\\s+\\((\\S+)\\)$"}; +const boost::regex FILE_EXT_REG_EXP{R"(^.+\s+\((\S+)\)$)"}; const QString ALL_FILES("All Files (*)"); QString getExtensionFromFilter(const QString &selectedFilter) { diff --git a/qt/widgets/common/src/FitPropertyBrowser.cpp b/qt/widgets/common/src/FitPropertyBrowser.cpp index 498f7f24cbdc6b9713296267089e4afa81a1df7c..f845baea5485f363df266ba310831a4a52f24746 100644 --- a/qt/widgets/common/src/FitPropertyBrowser.cpp +++ b/qt/widgets/common/src/FitPropertyBrowser.cpp @@ -1784,8 +1784,8 @@ void FitPropertyBrowser::postDeleteHandle(const std::string &wsName) { */ bool FitPropertyBrowser::isWorkspaceValid( Mantid::API::Workspace_sptr ws) const { - return (dynamic_cast<Mantid::API::MatrixWorkspace *>(ws.get()) != 0 || - dynamic_cast<Mantid::API::ITableWorkspace *>(ws.get()) != 0); + return (dynamic_cast<Mantid::API::MatrixWorkspace *>(ws.get()) != nullptr || + dynamic_cast<Mantid::API::ITableWorkspace *>(ws.get()) != nullptr); } bool FitPropertyBrowser::isWorkspaceAGroup() const { diff --git a/qt/widgets/common/src/MantidWSIndexDialog.cpp b/qt/widgets/common/src/MantidWSIndexDialog.cpp index 8347bd0bf9f2dc891cca4b8eba60f40e2c2f155b..2cf7ec17bf592c0885f3ce1fa291aa8abd1273b1 100644 --- a/qt/widgets/common/src/MantidWSIndexDialog.cpp +++ b/qt/widgets/common/src/MantidWSIndexDialog.cpp @@ -207,7 +207,7 @@ QMultiMap<QString, std::set<int>> MantidWSIndexWidget::getPlots() const { boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( m_wsNames[i].toStdString())); - if (NULL == ws) + if (nullptr == ws) continue; const Mantid::spec2index_map spec2index = @@ -690,7 +690,7 @@ void MantidWSIndexWidget::checkForSpectraAxes() { boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( (*it).toStdString())); - if (NULL == ws) + if (nullptr == ws) continue; bool hasSpectra = false; for (int i = 0; i < ws->axes(); i++) { @@ -718,7 +718,7 @@ void MantidWSIndexWidget::generateWsIndexIntervals() { boost::dynamic_pointer_cast<const Mantid::API::MatrixWorkspace>( Mantid::API::AnalysisDataService::Instance().retrieve( (*it).toStdString())); - if (NULL == ws) + if (nullptr == ws) continue; const int endWs = static_cast<int>(ws->getNumberHistograms() - diff --git a/qt/widgets/common/src/MultifitSetupDialog.cpp b/qt/widgets/common/src/MultifitSetupDialog.cpp index db316764958ed20e5580fccbc57b3d13efe8a9b6..5bfc07aa79ee0bd2821a88e30af88e5fe194e191 100644 --- a/qt/widgets/common/src/MultifitSetupDialog.cpp +++ b/qt/widgets/common/src/MultifitSetupDialog.cpp @@ -32,7 +32,7 @@ MultifitSetupDialog::MultifitSetupDialog(FitPropertyBrowser *fitBrowser) ui.paramTable->insertRow(ui.paramTable->rowCount()); model->setData(model->index(j, 0), QString::fromStdString(f->parameterName(i))); - ui.paramTable->item(j, 0)->setFlags(0); + ui.paramTable->item(j, 0)->setFlags(nullptr); model->setData(model->index(j, 1), ""); ui.paramTable->item(j, 1)->setCheckState(Qt::Unchecked); } diff --git a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp index 52fb3e30fa3364b8e602adc5d4963967c2edb955..b20a7f817c648dc0f87ba56ff1a3af20dc7313b8 100644 --- a/qt/widgets/common/src/MuonFitPropertyBrowser.cpp +++ b/qt/widgets/common/src/MuonFitPropertyBrowser.cpp @@ -336,12 +336,10 @@ void MuonFitPropertyBrowser::setFitEnabled(bool yes) { } void MuonFitPropertyBrowser::checkFitEnabled() { - if (m_reselectGroupBtn->isVisible()) { + if (count() == 0) { setFitEnabled(false); - } else if (getAutoBackgroundString() != "") { - setFitEnabled(true); } else { - setFitEnabled(false); + setFitEnabled(true); } } /** @@ -1042,7 +1040,7 @@ bool MuonFitPropertyBrowser::isWorkspaceValid(Workspace_sptr ws) const { if (workspaceName.endsWith("_Workspace")) return false; - return dynamic_cast<MatrixWorkspace *>(ws.get()) != 0; + return dynamic_cast<MatrixWorkspace *>(ws.get()) != nullptr; } void MuonFitPropertyBrowser::finishHandle(const IAlgorithm *alg) { @@ -1198,8 +1196,8 @@ void MuonFitPropertyBrowser::setMultiFittingMode(bool enabled) { setAllGroups(); setAllPeriods(); setAutoBackgroundName(""); - - } else { // clear current selection + this->clear(); // force update of composite function + } else { // clear current selection if (m_autoBackground != "") { setAutoBackgroundName(m_autoBackground); addAutoBackground(); diff --git a/qt/widgets/common/src/PropertyHandler.cpp b/qt/widgets/common/src/PropertyHandler.cpp index 337f88313b15ff0dab15b5c50b0ea41ab5b37af1..140e87261feacf23d7992e334bec45cb43e994fc 100644 --- a/qt/widgets/common/src/PropertyHandler.cpp +++ b/qt/widgets/common/src/PropertyHandler.cpp @@ -44,7 +44,7 @@ PropertyHandler::~PropertyHandler() {} /// overrides virtual init() which is called from IFunction::setHandler(...) void PropertyHandler::init() { m_browser->m_changeSlotsEnabled = false; - if (m_parent == NULL) { // the root composite function + if (m_parent == nullptr) { // the root composite function m_item = m_browser->m_functionsGroup; } else if (m_item == nullptr) { if (!m_parent->getHandler()) { @@ -538,7 +538,7 @@ PropertyHandler::findCompositeFunction(QtBrowserItem *item) const { for (size_t i = 0; i < m_cf->nFunctions(); i++) { Mantid::API::CompositeFunction_const_sptr res = getHandler(i)->findCompositeFunction(item); - if (res != NULL) + if (res != nullptr) return res; } return Mantid::API::CompositeFunction_sptr(); @@ -555,7 +555,7 @@ PropertyHandler::findFunction(QtBrowserItem *item) const { return Mantid::API::IFunction_sptr(); for (size_t i = 0; i < m_cf->nFunctions(); i++) { Mantid::API::IFunction_const_sptr res = getHandler(i)->findFunction(item); - if (res != NULL) + if (res != nullptr) return res; } return Mantid::API::IFunction_sptr(); @@ -927,9 +927,9 @@ Mantid::API::IFunction_sptr PropertyHandler::changeType(QtProperty *prop) { f = Mantid::API::FunctionFactory::Instance().createFunction( fnName.toStdString()); } catch (std::exception &e) { - QMessageBox::critical(NULL, "Mantid - Error", "Cannot create function " + - fnName + "\n" + - e.what()); + QMessageBox::critical(nullptr, "Mantid - Error", + "Cannot create function " + fnName + "\n" + + e.what()); return Mantid::API::IFunction_sptr(); } diff --git a/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp b/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp index 069dfec78e40dc310a1de3161f7e6b381b68d735..8833948710c46b8356fbd18f7b5e89c05e8a11a6 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qteditorfactory.cpp @@ -841,7 +841,7 @@ void QtLineEditFactoryPrivate::slotRegExpChanged(QtProperty *property, QLineEdit *editor = itEditor.next(); editor->blockSignals(true); const QValidator *oldValidator = editor->validator(); - QValidator *newValidator = 0; + QValidator *newValidator = nullptr; if (regExp.isValid()) { newValidator = new QRegExpValidator(regExp, editor); } diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp index 1a4b465548252acae1e144877278e99902d6ce4f..0f3a896401503d81c91f49bfe5b36dec1bff81a7 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowser.cpp @@ -1783,7 +1783,7 @@ QtAbstractPropertyBrowser::insertProperty(QtProperty *property, while (pos < pendingList.count()) { QtProperty *prop = pendingList.at(pos); if (prop == property) - return 0; + return nullptr; if (prop == afterProperty) { newPos = pos + 1; } @@ -1819,10 +1819,11 @@ void QtAbstractPropertyBrowser::removeProperty(QtProperty *property) { if (pendingList.at(pos) == property) { d_ptr->m_subItems.removeAt(pos); // perhaps this two lines d_ptr->removeSubTree( - property, 0); // should be moved down after propertyRemoved call. + property, + nullptr); // should be moved down after propertyRemoved call. // propertyRemoved(property, 0); - d_ptr->removeBrowserIndexes(property, 0); + d_ptr->removeBrowserIndexes(property, nullptr); // when item is deleted, item will call removeItem for top level items, // and itemRemoved for nested items. diff --git a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp index 997c7b4111f65b5ededeb77514a22021615aaa9f..577f0648bff874b30fca4926e00588c302d14817 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qtpropertybrowserutils.cpp @@ -97,7 +97,7 @@ namespace { // Translation function for Qt4/Qt5. Qt5 has no encoding option QString translateUtf8Encoded(const char *context, const char *key, - const char *disambiguation = 0, int n = -1) { + const char *disambiguation = nullptr, int n = -1) { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) return QApplication::translate(context, key, disambiguation, QApplication::UnicodeUTF8, n); diff --git a/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp b/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp index 80229ea10fb1b1f3574b2017140535db88980235..4ec953bc4b9c28c317287d843d8086501e7fed5e 100644 --- a/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp +++ b/qt/widgets/common/src/QtPropertyBrowser/qttreepropertybrowser.cpp @@ -103,7 +103,7 @@ namespace { // Translation function for Qt4/Qt5. Qt5 has no encoding option QString translateUtf8Encoded(const char *context, const char *key, - const char *disambiguation = 0, int n = -1) { + const char *disambiguation = nullptr, int n = -1) { #if QT_VERSION < QT_VERSION_CHECK(5, 0, 0) return QApplication::translate(context, key, disambiguation, QApplication::UnicodeUTF8, n); @@ -483,8 +483,8 @@ QtBrowserItem *QtTreePropertyBrowserPrivate::currentItem() const { void QtTreePropertyBrowserPrivate::setCurrentItem(QtBrowserItem *browserItem, bool block) { const bool blocked = block ? m_treeWidget->blockSignals(true) : false; - if (browserItem == 0) - m_treeWidget->setCurrentItem(0); + if (browserItem == nullptr) + m_treeWidget->setCurrentItem(nullptr); else m_treeWidget->setCurrentItem(m_indexToItem.value(browserItem)); if (block) @@ -575,7 +575,7 @@ void QtTreePropertyBrowserPrivate::propertyRemoved(QtBrowserItem *index) { QTreeWidgetItem *item = m_indexToItem.value(index); if (m_treeWidget->currentItem() == item) { - m_treeWidget->setCurrentItem(0); + m_treeWidget->setCurrentItem(nullptr); } delete item; diff --git a/qt/widgets/common/src/SaveWorkspaces.cpp b/qt/widgets/common/src/SaveWorkspaces.cpp index 9f234bb042d30532b4e66e2f4cda571347cb5eed..838afb6a84ba13ebc88b0f10fc0ecaf0fae3f9a8 100644 --- a/qt/widgets/common/src/SaveWorkspaces.cpp +++ b/qt/widgets/common/src/SaveWorkspaces.cpp @@ -446,7 +446,7 @@ void SaveWorkspaces::saveFileBrowse() { ? QFileDialog::DontConfirmOverwrite : static_cast<QFileDialog::Option>(0); QString oFile = QFileDialog::getSaveFileName(this, title, prevPath, filter, - NULL, userCon); + nullptr, userCon); if (!oFile.isEmpty()) { m_fNameEdit->setText(oFile); diff --git a/qt/widgets/common/src/SlitCalculator.cpp b/qt/widgets/common/src/SlitCalculator.cpp index f908023a796b777305c61ff4494316fd23273151..594217bd700c38437ffdf57f1e1dcdf90589953f 100644 --- a/qt/widgets/common/src/SlitCalculator.cpp +++ b/qt/widgets/common/src/SlitCalculator.cpp @@ -62,8 +62,8 @@ void SlitCalculator::setupSlitCalculatorWithInstrumentValues( auto slit2Component = instrument->getComponentByName("slit2"); auto sampleComponent = instrument->getComponentByName("some-surface-holder"); // check that they have been fetched from the IDF - if (slit1Component.get() != NULL && slit2Component.get() != NULL && - sampleComponent.get() != NULL) { + if (slit1Component.get() != nullptr && slit2Component.get() != nullptr && + sampleComponent.get() != nullptr) { // convert from meters to millimeters const double s1s2 = 1e3 * (slit1Component->getDistance(*slit2Component)); // set value in field of slitCalculator diff --git a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp index b491ee8266ef555bfac3935c6b429eb2d5ffb41f..5b785c9b3f2f3292f0477eb08293c11f91f2f26a 100644 --- a/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp +++ b/qt/widgets/common/src/WorkspacePresenter/WorkspaceTreeWidget.cpp @@ -491,7 +491,7 @@ void WorkspaceTreeWidget::filterWorkspaces(const std::string &filterText) { item->setHidden(false); } - if (item->parent() == NULL) { + if (item->parent() == nullptr) { // No parent, I am a top level workspace - show me item->setHidden(false); } else { @@ -733,9 +733,8 @@ void WorkspaceTreeWidget::populateChildData(QTreeWidgetItem *item) { Workspace_sptr workspace = userData.value<Workspace_sptr>(); if (auto group = boost::dynamic_pointer_cast<WorkspaceGroup>(workspace)) { - const size_t nmembers = group->getNumberOfEntries(); - for (size_t i = 0; i < nmembers; ++i) { - auto ws = group->getItem(i); + auto members = group->getAllItems(); + for (const auto &ws : members) { auto *node = addTreeEntry(std::make_pair(ws->getName(), ws), item); excludeItemFromSort(node); if (shouldBeSelected(node->text(0))) diff --git a/qt/widgets/common/src/WorkspaceSelector.cpp b/qt/widgets/common/src/WorkspaceSelector.cpp index ff46217badec91527bc80ff30c635fe40541507d..5e885ea90aa91e5c7ee1d2711ae3437731781235 100644 --- a/qt/widgets/common/src/WorkspaceSelector.cpp +++ b/qt/widgets/common/src/WorkspaceSelector.cpp @@ -145,7 +145,7 @@ void WorkspaceSelector::setValidatingAlgorithm(const QString &algName) { // try to cast property to WorkspaceProperty Mantid::API::WorkspaceProperty<> *wsProp = dynamic_cast<Mantid::API::WorkspaceProperty<> *>(*it); - if (wsProp != NULL) { + if (wsProp != nullptr) { m_algPropName = QString::fromStdString((*it)->name()); break; } diff --git a/qt/widgets/common/src/pqHelpWindow.cxx b/qt/widgets/common/src/pqHelpWindow.cxx index e84364deec18fb88b55697122795f50131b403a5..f9d19ee4229ab77596b622b77bc5acb30f512beb 100644 --- a/qt/widgets/common/src/pqHelpWindow.cxx +++ b/qt/widgets/common/src/pqHelpWindow.cxx @@ -146,7 +146,7 @@ public: pqNetworkAccessManager(QHelpEngineCore *helpEngine, QNetworkAccessManager *manager, QObject *parentObject) : Superclass(parentObject), Engine(helpEngine) { - Q_ASSERT(manager != NULL && helpEngine != NULL); + Q_ASSERT(manager != nullptr && helpEngine != nullptr); this->setCache(manager->cache()); this->setCookieJar(manager->cookieJar()); @@ -205,7 +205,7 @@ private: pqHelpWindow::pqHelpWindow(QHelpEngine *engine, QWidget *parentObject, Qt::WindowFlags parentFlags) : Superclass(parentObject, parentFlags), m_helpEngine(engine) { - Q_ASSERT(engine != NULL); + Q_ASSERT(engine != nullptr); Ui::pqHelpWindow ui; ui.setupUi(this); diff --git a/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h b/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h index fe471deac8526754f99cac06855cb6a1cdcb37a0..fda3bd3be5d3dd154ef01b1321bc0399832abff3 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenerateNotebookTest.h @@ -152,10 +152,10 @@ public: auto notebookLines = splitIntoLines(generatedNotebook); const QString result[] = { - "{", " \"metadata\" : {", " \"name\" : \"Mantid Notebook\"", + "{", " \"metadata\" : {", R"( "name" : "Mantid Notebook")", " },", " \"nbformat\" : 3,", " \"nbformat_minor\" : 0,", " \"worksheets\" : [", " {", " \"cells\" : [", - " {", " \"cell_type\" : \"markdown\",", + " {", R"( "cell_type" : "markdown",)", }; // Check that the first 10 lines are output as expected @@ -841,7 +841,7 @@ public: "'IvsLam_TOF_12345', ScaleFactor = '1', ThetaIn = '0.5')\\n\","); TS_ASSERT_EQUALS(notebookLines[48].toStdString(), loadAndReduceString); - auto postProcessString = QString(" \"input\" : \"\","); + auto postProcessString = QString(R"( "input" : "",)"); TS_ASSERT_EQUALS(notebookLines[56], postProcessString); auto groupWorkspacesString = std::string( @@ -876,7 +876,7 @@ public: "'IvsLam_TOF_12346', ScaleFactor = '1', ThetaIn = '1.5')\\n\","; TS_ASSERT_EQUALS(notebookLines[77].toStdString(), loadAndReduceString); - postProcessString = " \"input\" : \"\","; + postProcessString = R"( "input" : "",)"; TS_ASSERT_EQUALS(notebookLines[85], postProcessString); groupWorkspacesString = diff --git a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h index 97d545b6165adc7dba233f895a25776b98934cf4..c36523b94b6b078a137322a9fea24540af8779e1 100644 --- a/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h +++ b/qt/widgets/common/test/DataProcessorUI/GenericDataProcessorPresenterTest.h @@ -101,9 +101,9 @@ private: m_manager->setProcessed(true, rowItem->first, groupIndex); } catch (std::exception &ex) { reductionError(QString(ex.what())); - threadFinished(1); + rowThreadFinished(1); } - threadFinished(0); + rowThreadFinished(0); } // non-async group reduce @@ -115,9 +115,9 @@ private: m_manager->setProcessed(true, groupIndex); } catch (std::exception &ex) { reductionError(QString(ex.what())); - threadFinished(1); + groupThreadFinished(1); } - threadFinished(0); + groupThreadFinished(0); } // Overriden non-async methods have same implementation as parent class diff --git a/qt/widgets/common/test/FindFilesThreadPoolManagerTest.h b/qt/widgets/common/test/FindFilesThreadPoolManagerTest.h index 5d5996179b3274ed2824bb0862aea672e74b70f5..e1cc013e734b2f8145314a66649b2a8c1317a777 100644 --- a/qt/widgets/common/test/FindFilesThreadPoolManagerTest.h +++ b/qt/widgets/common/test/FindFilesThreadPoolManagerTest.h @@ -29,7 +29,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); // Arrange FakeMWRunFiles *widget = new FakeMWRunFiles(); @@ -56,7 +56,7 @@ public: poolManager.createWorker(widget, parameters); // Block and wait for all the threads to process poolManager.waitForDone(); - QApplication::processEvents(); + QCoreApplication::processEvents(); // Assert const auto results = widget->getResults(); @@ -72,7 +72,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); // Arrange FakeMWRunFiles widget; @@ -118,7 +118,7 @@ public: // Block and wait for all the threads to process poolManager.waitForDone(); - QApplication::processEvents(); + QCoreApplication::processEvents(); // Assert const auto results = widget.getResults(); diff --git a/qt/widgets/common/test/FindFilesWorkerTest.h b/qt/widgets/common/test/FindFilesWorkerTest.h index f491c72bc0e8bb8db73131cb21c6f0487de0122f..6f1469861009a76ea27284fe530a4d740c3127b5 100644 --- a/qt/widgets/common/test/FindFilesWorkerTest.h +++ b/qt/widgets/common/test/FindFilesWorkerTest.h @@ -28,7 +28,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); auto parameters = createFileSearch("IRS26173"); auto worker = new FindFilesWorker(parameters); @@ -52,7 +52,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); auto parameters = createFileSearch("IRS26173"); parameters.algorithmName = ""; @@ -79,7 +79,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); auto parameters = createFileSearch("ThisFileDoesNotExist"); auto worker = new FindFilesWorker(parameters); @@ -100,7 +100,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); auto parameters = createFileSearch(""); auto worker = new FindFilesWorker(parameters); @@ -121,7 +121,7 @@ public: int argc = 1; char name[] = "DummyTestingApplication"; char *argv = name; - QApplication app(argc, &argv); + QCoreApplication app(argc, &argv); auto parameters = createFileSearch(""); parameters.isOptional = true; diff --git a/qt/widgets/common/test/ParseKeyValueStringTest.h b/qt/widgets/common/test/ParseKeyValueStringTest.h index ee09cdd2afaf2e553ef2c3f57ceb8f05164c304f..9b2f84085088a2df25bd2aba63ba212d428b718a 100644 --- a/qt/widgets/common/test/ParseKeyValueStringTest.h +++ b/qt/widgets/common/test/ParseKeyValueStringTest.h @@ -12,7 +12,7 @@ class ParseKeyValueStringTest : public CxxTest::TestSuite { public: void testParseKeyValueString() { std::map<std::string, std::string> kvp = parseKeyValueString( - "a = 1,b=2.0, c=3, d='1,2,3',e=\"4,5,6\",f=1+1=2, g = '\\''"); + R"(a = 1,b=2.0, c=3, d='1,2,3',e="4,5,6",f=1+1=2, g = '\'')"); TS_ASSERT_EQUALS(kvp["a"], "1"); TS_ASSERT_EQUALS(kvp["b"], "2.0"); @@ -33,7 +33,7 @@ public: void testParseKeyValueQString() { std::map<QString, QString> kvp = parseKeyValueQString( - "a = 1,b=2.0, c=3, d='1,2,3',e=\"4,5,6\",f=1+1=2, g = '\\''"); + R"(a = 1,b=2.0, c=3, d='1,2,3',e="4,5,6",f=1+1=2, g = '\'')"); TS_ASSERT_EQUALS(kvp["a"], "1"); TS_ASSERT_EQUALS(kvp["b"], "2.0"); diff --git a/qt/widgets/instrumentview/CMakeLists.txt b/qt/widgets/instrumentview/CMakeLists.txt index 04520f23ba7b3144942462938bbafc22889f97e5..acf4828ccf872ad39f5fcc1a837e3a4d1b036091 100644 --- a/qt/widgets/instrumentview/CMakeLists.txt +++ b/qt/widgets/instrumentview/CMakeLists.txt @@ -1,16 +1,11 @@ set ( SRC_FILES + src/BankRenderingHelpers.cpp src/BinDialog.cpp src/CollapsiblePanel.cpp src/ColorMapWidget.cpp - src/CompAssemblyActor.cpp - src/ComponentActor.cpp src/DetXMLFile.cpp - src/GLActor.cpp - src/GLActorCollection.cpp - src/GLActorVisitor.cpp src/GLColor.cpp src/GLObject.cpp - src/ICompAssemblyActor.cpp src/InstrumentActor.cpp src/InstrumentTreeModel.cpp src/InstrumentTreeWidget.cpp @@ -18,12 +13,11 @@ set ( SRC_FILES src/InstrumentWidgetMaskTab.cpp src/InstrumentWidgetPickTab.cpp src/InstrumentWidgetRenderTab.cpp + src/InstrumentRenderer.cpp src/InstrumentWidgetTab.cpp src/InstrumentWidgetTreeTab.cpp src/MantidGLWidget.cpp src/MaskBinsData.cpp - src/ObjCompAssemblyActor.cpp - src/ObjComponentActor.cpp src/OneCurvePlot.cpp src/OpenGLError.cpp src/PanelsSurface.cpp @@ -32,15 +26,13 @@ set ( SRC_FILES src/Projection3D.cpp src/ProjectionSurface.cpp src/RectF.cpp - src/RectangularDetectorActor.cpp src/RotationSurface.cpp - src/SampleActor.cpp src/Shape2D.cpp src/Shape2DCollection.cpp src/SimpleWidget.cpp - src/StructuredDetectorActor.cpp src/UCorrectionDialog.cpp src/UnwrappedCylinder.cpp + src/UnwrappedDetector.cpp src/UnwrappedSphere.cpp src/UnwrappedSurface.cpp src/Viewport.cpp @@ -72,23 +64,19 @@ set ( MOC_FILES ) set ( INC_FILES + inc/MantidQtWidgets/InstrumentView/BankRenderingHelpers.h inc/MantidQtWidgets/InstrumentView/BinDialog.h inc/MantidQtWidgets/InstrumentView/CollapsiblePanel.h inc/MantidQtWidgets/InstrumentView/ColorMapWidget.h - inc/MantidQtWidgets/InstrumentView/CompAssemblyActor.h - inc/MantidQtWidgets/InstrumentView/ComponentActor.h inc/MantidQtWidgets/InstrumentView/DetXMLFile.h inc/MantidQtWidgets/InstrumentView/DllOption.h - inc/MantidQtWidgets/InstrumentView/GLActor.h - inc/MantidQtWidgets/InstrumentView/GLActorCollection.h - inc/MantidQtWidgets/InstrumentView/GLActorVisitor.h inc/MantidQtWidgets/InstrumentView/GLColor.h inc/MantidQtWidgets/InstrumentView/GLObject.h - inc/MantidQtWidgets/InstrumentView/ICompAssemblyActor.h inc/MantidQtWidgets/InstrumentView/InstrumentActor.h inc/MantidQtWidgets/InstrumentView/InstrumentTreeModel.h inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h + inc/MantidQtWidgets/InstrumentView/InstrumentRenderer.h inc/MantidQtWidgets/InstrumentView/InstrumentWidgetMaskTab.h inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h inc/MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h @@ -97,8 +85,6 @@ set ( INC_FILES inc/MantidQtWidgets/InstrumentView/InstrumentWidgetTypes.h inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h inc/MantidQtWidgets/InstrumentView/MaskBinsData.h - inc/MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h - inc/MantidQtWidgets/InstrumentView/ObjComponentActor.h inc/MantidQtWidgets/InstrumentView/OneCurvePlot.h inc/MantidQtWidgets/InstrumentView/OpenGLError.h inc/MantidQtWidgets/InstrumentView/PanelsSurface.h @@ -107,15 +93,13 @@ set ( INC_FILES inc/MantidQtWidgets/InstrumentView/Projection3D.h inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h inc/MantidQtWidgets/InstrumentView/RectF.h - inc/MantidQtWidgets/InstrumentView/RectangularDetectorActor.h inc/MantidQtWidgets/InstrumentView/RotationSurface.h - inc/MantidQtWidgets/InstrumentView/SampleActor.h inc/MantidQtWidgets/InstrumentView/Shape2D.h inc/MantidQtWidgets/InstrumentView/Shape2DCollection.h inc/MantidQtWidgets/InstrumentView/SimpleWidget.h - inc/MantidQtWidgets/InstrumentView/StructuredDetectorActor.h inc/MantidQtWidgets/InstrumentView/UCorrectionDialog.h inc/MantidQtWidgets/InstrumentView/UnwrappedCylinder.h + inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h inc/MantidQtWidgets/InstrumentView/UnwrappedSphere.h inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h inc/MantidQtWidgets/InstrumentView/Viewport.h diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BankRenderingHelpers.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BankRenderingHelpers.h new file mode 100644 index 0000000000000000000000000000000000000000..8a8fd3b296da0521abc361c1296ef2ffff232b10 --- /dev/null +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/BankRenderingHelpers.h @@ -0,0 +1,39 @@ +#ifndef BANKRENDERINGHELPERS_H +#define BANKRENDERINGHELPERS_H +#include "DllOption.h" +#include "MantidQtWidgets/InstrumentView/GLColor.h" +#include <vector> + +namespace Mantid { +namespace Geometry { +class ComponentInfo; +} +} // namespace Mantid + +namespace MantidQt { +namespace MantidWidgets { +namespace BankRenderingHelpers { + +EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW std::pair<size_t, size_t> +getCorrectedTextureSize(const size_t width, const size_t height); + +/** Render RectangularDetector Bank as bitmap texture +Makes OpenGL calls for drawing the bank in an OpenGL window. NB glBegin() and +glEnd() are called within this function. +*/ +EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW void +renderRectangularBank(const Mantid::Geometry::ComponentInfo &compInfo, + size_t index); + +/** Render Structured Detector Bank as quads +Makes OpenGL calls for drawing the bank in an OpenGL window. NB glBegin() and +glEnd() are called within this function. +*/ +EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW void +renderStructuredBank(const Mantid::Geometry::ComponentInfo &compInfo, + size_t index, const std::vector<GLColor> &color); +} // namespace RenderingHelpers +} // namespace MantidWidgets +} // namespace MantidQt + +#endif // BANKRENDERINGHELPERS_H \ No newline at end of file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/CompAssemblyActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/CompAssemblyActor.h deleted file mode 100644 index 9116c22d17a99060ca3771bd6bba980159ba57cf..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/CompAssemblyActor.h +++ /dev/null @@ -1,90 +0,0 @@ -#ifndef COMPASSEMBLY_ACTOR__H_ -#define COMPASSEMBLY_ACTOR__H_ - -#include "ICompAssemblyActor.h" -#include "GLActor.h" - -#include "MantidGeometry/IComponent.h" -#include "MantidKernel/V3D.h" -/** - \class CompAssemblyActor - \brief This class wraps the ICompAssembly into Actor. - \author Srikanth Nagella - \date March 2009 - \version 1.0 - - This class has the implementation for calling the children of ICompAssembly's - IObjComponent to render themselves - and call the ICompAssemblys. This maintains the count of the children for easy - lookup. - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class ICompAssembly; -class CSGObject; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class InstrumentActor; - -class ObjComponentActor; - -class CompAssemblyActor : public ICompAssemblyActor { -public: - CompAssemblyActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID); ///< Constructor - ~CompAssemblyActor() override; - std::string type() const override { - return "CompAssemblyActor"; - } ///< Type of the GL object - void draw(bool picking = false) const override; ///< Method that defines - /// ObjComponent geometry. Calls - /// ObjComponent draw method - void setChildVisibility(bool) override; - bool hasChildVisible() const override; - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - void setColors() override; - -protected: - mutable std::vector<ObjComponentActor *> - mChildObjCompActors; ///< List of ObjComponent Actors - mutable std::vector<ICompAssemblyActor *> - mChildCompAssemActors; ///< List of CompAssembly Actors -private: - void AppendBoundingBox(const Mantid::Kernel::V3D &minBound, - const Mantid::Kernel::V3D &maxBound); -}; - -} // MantidWidgets -} // MantidQt - -#endif /*GLTRIANGLE_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ComponentActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ComponentActor.h deleted file mode 100644 index ce4a12ef49c401ed1bcc026386a7782ca10d7e90..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ComponentActor.h +++ /dev/null @@ -1,82 +0,0 @@ -#ifndef COMPONENT_ACTOR_H_ -#define COMPONENT_ACTOR_H_ -#include "GLActor.h" -#include "GLColor.h" - -#include "MantidGeometry/IComponent.h" - -/** - \class ObjComponentActor - \brief ObjComponentActor is an actor class for rendering ObjComponents. - \author Srikanth Nagella - \date March 2009 - \version 1.0 - - This class has the implementation for rendering ObjComponents in OpenGL and - it inherits from the GLActor - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Geometry { -class IObjComponent; -class IDetector; -class ObjCompAssembly; -class CompAssembly; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class InstrumentActor; - -class ComponentActor : public GLActor { -public: - ComponentActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID); ///< Default Constructor - virtual std::string type() const { - return "ComponentActor"; - } ///< Type of the GL object - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - boost::shared_ptr<const Mantid::Geometry::IComponent> getComponent() const; - boost::shared_ptr<const Mantid::Geometry::IObjComponent> - getObjComponent() const; - boost::shared_ptr<const Mantid::Geometry::IDetector> getDetector() const; - boost::shared_ptr<const Mantid::Geometry::ObjCompAssembly> - getObjCompAssembly() const; - boost::shared_ptr<const Mantid::Geometry::CompAssembly> - getCompAssembly() const; - virtual void setColors() {} - /// Check if the component is a non-detector. - bool isNonDetector() const; - -protected: - const InstrumentActor &m_instrActor; - Mantid::Geometry::ComponentID m_id; ///< Component ID -}; -} // MantidWidgets -} // MantidQt - -#endif /*COMPONENT_ACTOR_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActor.h deleted file mode 100644 index 35d61fe78e9efae526986745f14fcda45ebb48c4..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActor.h +++ /dev/null @@ -1,118 +0,0 @@ -/**________________________________________________ -* Library : NTK -* Name : GLActor.h -* Author : L.C.Chapon -* Date : 8 Nov 2006 -* Description : Base class for all objects in a 3D Scene. -* Methods are provide to position and -* rotate the objects. The objects can also -* be set as active or not. Actors maintian safe pointer -* to a GLObject. -*________________________________________________ -*/ -#ifndef GLACTOR_H_ -#define GLACTOR_H_ -#include "MantidKernel/V3D.h" -#include "GLObject.h" -#include "GLColor.h" -#include <boost/shared_ptr.hpp> - -#include <ostream> - -#include <QObject> -#include <QList> -#include <QRgb> - -namespace Mantid { -namespace Geometry { -class IDetector; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class GLActorVisitor; -class GLActorConstVisitor; - -/** -\class GLActor -\brief An actor class that holds geometry objects with its position. -\author Chapon Laurent & Srikanth Nagella -\date August 2008 -\version 1.0 - -Base class for all objects in a 3D Scene. Methods are provided to position and -rotate the objects. -The objects can also be set as active or not. Actors maintain safe pointer to a -GLObject. - -Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -enum class GLActorVisiblity : char { VISIBLE, HIDDEN, ALWAYS_HIDDEN }; - -class GLActor : public QObject { -public: - /// Rules for visitor propagation. If vistor's visit(...) method returns true - /// the propagation can be continued (VisitAll) or abandoned (Finish) - enum VisitorAcceptRule { VisitAll, Finish }; - GLActor() : m_visible(GLActorVisiblity::VISIBLE) {} - ///< Virtual destructor - ~GLActor() override; - /// Toggle the visibility of the actor. - virtual void setVisibility(bool on); - /// Toggle the visibility of the child actors (if exist). - virtual void setChildVisibility(bool on) { setVisibility(on); } - /// Sets the current component to always hide - void setAlwaysHidden() { m_visible = GLActorVisiblity::ALWAYS_HIDDEN; } - /// Check if any child is visible - virtual bool hasChildVisible() const { return true; } - /// Get the visibility status. - bool isVisible() const { return m_visible == GLActorVisiblity::VISIBLE; } - /// Draw the actor in 3D. - virtual void draw(bool picking = false) const = 0; - /// Get the 3D bounding box of the actor - virtual void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const = 0; - /// Accept a visitor - virtual bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll); - /// Accept a const visitor - virtual bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const; - /// Convert a "pick ID" to a colour to put into the pick image. - static GLColor makePickColor(size_t pickID); - /// Decode a pick colour and return corresponding "pick ID" - static size_t decodePickColor(const QRgb &c); - /// Decode a pick colour and return corresponding "pick ID" - static size_t decodePickColor(unsigned char r, unsigned char g, - unsigned char b); - /// Get colour of a component which doesn't have any counts associated with - /// it. - static GLColor defaultDetectorColor(); - -protected: - GLActorVisiblity m_visible; ///< Flag whether the actor is visible or not -}; - -} // MantidWidgets -} // MantidQt - -#endif /*GLACTOR_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorCollection.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorCollection.h deleted file mode 100644 index 78c2d909ac6778f08d226d784e69396515688a7e..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorCollection.h +++ /dev/null @@ -1,74 +0,0 @@ -#ifndef GLACTORCOLLECTION_H_ -#define GLACTORCOLLECTION_H_ -#include "GLActor.h" - -#include "MantidKernel/V3D.h" - -#include <vector> - -namespace MantidQt { -namespace MantidWidgets { -/** -\class GLActorCollection -\brief An actor class collection -\author Chapon Laurent & Srikanth Nagella -\date August 2008 -\version 1.0 - - -GLActorCollection has the list of GLActor. - -Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ - -class GLActorCollection : public GLActor { -public: - GLActorCollection(); ///< Default Constructor - ~GLActorCollection() override; ///< Destructor - void setChildVisibility(bool) override; - bool hasChildVisible() const override; - void draw(bool picking = false) const override; - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - - void addActor(GLActor *); - void removeActor(GLActor *); - int getNumberOfActors(); - GLActor *getActor(int index); - void invalidateDisplayList() const; - -private: - void drawGL(bool picking = false) const; - mutable std::vector<GLActor *> - mActorsList; ///< Vector of GLActors for fast access. - Mantid::Kernel::V3D m_minBound; - Mantid::Kernel::V3D m_maxBound; - mutable GLuint m_displayListId[2]; - mutable bool m_useDisplayList[2]; -}; -} // MantidWidgets -} // MantidQt - -#endif /*GLACTORCOLLECTION_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorVisitor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorVisitor.h deleted file mode 100644 index 401783ed5355f659a9c80ae5475ced6dd7ab4ab0..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLActorVisitor.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef GLACTORVISITOR_H -#define GLACTORVISITOR_H - -namespace MantidQt { -namespace MantidWidgets { -class GLActor; -class GLActorCollection; -class ComponentActor; -class CompAssemblyActor; -class ObjCompAssemblyActor; -class RectangularDetectorActor; -class StructuredDetectorActor; -class InstrumentActor; - -/** -* A base class for an actor visitor. -*/ -class GLActorVisitor { -public: - /// Virtual destructor. - virtual ~GLActorVisitor() {} - /// Abstract method that must be implemented in sub-classes - virtual bool visit(GLActor *) = 0; - virtual bool visit(GLActorCollection *); - virtual bool visit(CompAssemblyActor *); - virtual bool visit(ObjCompAssemblyActor *); - virtual bool visit(ComponentActor *); - virtual bool visit(InstrumentActor *); - virtual bool visit(RectangularDetectorActor *); - virtual bool visit(StructuredDetectorActor *); -}; - -/** -* A base class for an actor visitor (const version). -*/ -class GLActorConstVisitor { -public: - /// Virtual destructor. - virtual ~GLActorConstVisitor() {} - /// Abstract method that must be implemented in sub-classes - virtual bool visit(const GLActor *) = 0; - virtual bool visit(const GLActorCollection *); - virtual bool visit(const CompAssemblyActor *); - virtual bool visit(const ObjCompAssemblyActor *); - virtual bool visit(const ComponentActor *); - virtual bool visit(const InstrumentActor *); - virtual bool visit(const RectangularDetectorActor *); - virtual bool visit(const StructuredDetectorActor *); -}; - -/* -* The visit() method implemented by sub-classes must return true if an actor -* is set visible and false otherwise. This is requered by -*GLActorCollection::accept() -* method to determine whether the collection itself is visible or not. -* -* All visitors changing visibility should be sub-classed from this base class. -*/ -class SetVisibilityVisitor : public GLActorVisitor {}; - -/** -* Set all actors visible. -*/ -class SetAllVisibleVisitor : public SetVisibilityVisitor { -public: - explicit SetAllVisibleVisitor(bool showNonDet) : m_showNonDet(showNonDet) {} - using GLActorVisitor::visit; - bool visit(GLActor *) override; - bool visit(ComponentActor *actor) override; - -private: - bool m_showNonDet; -}; -} // MantidWidgets -} // MantidQt - -#endif // GLACTORVISITOR_H diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLColor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLColor.h index 5cda5822dd6ab57edea8e1d88e9f5964f1b56e97..6ea19cc70dbc64962f98c36fa3df7053ccf704ba 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLColor.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/GLColor.h @@ -41,7 +41,7 @@ class GLColor { public: /// Default Constructor GLColor(float red = 0, float green = 0, float blue = 0, float alpha = 1.0f); - GLColor(int r, int g, int b); + GLColor(int r, int g, int b, int a = 255); /// Destructor virtual ~GLColor(); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ICompAssemblyActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ICompAssemblyActor.h deleted file mode 100644 index 21cbebe5e5465bb6635a765674dd87a5eab1a0bb..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ICompAssemblyActor.h +++ /dev/null @@ -1,77 +0,0 @@ -#ifndef ICOMPASSEMBLY_ACTOR__H_ -#define ICOMPASSEMBLY_ACTOR__H_ -#include "ComponentActor.h" -#include "MantidGeometry/IComponent.h" -#include "MantidKernel/V3D.h" - -#include <boost/shared_ptr.hpp> - -#include <map> - -/** - \class ICompAssemblyActor - \brief This class wraps the ICompAssembly into Actor. - \author Srikanth Nagella - \date March 2009 - \version 1.0 - - This class has the interface Comp assembly actors. - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Kernel { -class V3D; -} - -namespace Geometry { -class ICompAssembly; -class CSGObject; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class InstrumentActor; -class ObjComponentActor; - -class ICompAssemblyActor : public ComponentActor { -public: - ICompAssemblyActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID); ///< Constructor - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - - std::string type() const override { - return "ICompAssemblyActor"; - } ///< Type of the GL object - size_t getNumberOfDetectors() const { return mNumberOfDetectors; } - -protected: - size_t mNumberOfDetectors; - Mantid::Kernel::V3D minBoundBox; - Mantid::Kernel::V3D maxBoundBox; -}; -} // MantidWidgets -} // MantidQt - -#endif /*GLTRIANGLE_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h index a68f04d17423992f241c3543040ff1c7e814960f..1a47db2898e20c5d91c9bc96b6ba21a905b13376 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentActor.h @@ -2,19 +2,14 @@ #define INSTRUMENTACTOR_H_ #include "DllOption.h" -#include "GLActor.h" -#include "GLActorCollection.h" -#include "GLActorVisitor.h" +#include "MantidGeometry/Rendering/OpenGL_Headers.h" #include "GLColor.h" #include "MantidAPI/MatrixWorkspace_fwd.h" #include "MantidAPI/SpectraDetectorTypes.h" -#include "MantidGeometry/IObjComponent.h" #include "MantidQtWidgets/LegacyQwt/MantidColorMap.h" #include "MaskBinsData.h" -#include "SampleActor.h" - +#include "MantidGeometry/IComponent.h" #include <boost/weak_ptr.hpp> -#include <map> #include <vector> //------------------------------------------------------------------ @@ -26,15 +21,16 @@ class MatrixWorkspace; class IMaskWorkspace; } namespace Geometry { -class IObjComponent; class Instrument; -class IDetector; +class ComponentInfo; +class DetectorInfo; } } namespace MantidQt { namespace MantidWidgets { -class ObjComponentActor; + +class InstrumentRenderer; /** \class InstrumentActor @@ -48,37 +44,34 @@ interface for picked ObjComponent and other operation for selective rendering of the instrument */ -class EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW InstrumentActor : public GLActor { +class EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW InstrumentActor : public QObject { Q_OBJECT public: + /// Invalid workspace index in detector index to workspace index lookup + static const size_t INVALID_INDEX; /// Constructor InstrumentActor(const QString &wsName, bool autoscaling = true, double scaleMin = 0.0, double scaleMax = 0.0); ///< Destructor - ~InstrumentActor() override; - ///< Type of the GL object - virtual std::string type() const { return "InstrumentActor"; } + ~InstrumentActor(); /// Draw the instrument in 3D - void draw(bool picking = false) const override; + void draw(bool picking = false) const; /// Return the bounding box in 3D void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override { - m_scene.getBoundingBox(minBound, maxBound); - } - /// Run visitors callback on each component - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - /// Run visitors callback on each component (const version) - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; + Mantid::Kernel::V3D &maxBound) const; + /// Set a component (and all its children) visible. + void setComponentVisible(size_t componentIndex); /// Toggle the visibility of the child actors (if exist). - void setChildVisibility(bool) override; + void setChildVisibility(bool); /// Check if any child is visible - bool hasChildVisible() const override; + bool hasChildVisible() const; /// Get the underlying instrument + std::vector<size_t> getMonitors() const; boost::shared_ptr<const Mantid::Geometry::Instrument> getInstrument() const; /// Get the associated data workspace boost::shared_ptr<const Mantid::API::MatrixWorkspace> getWorkspace() const; + const Mantid::Geometry::ComponentInfo &componentInfo() const; + const Mantid::Geometry::DetectorInfo &detectorInfo() const; /// Get the mask displayed but not yet applied as a MatrxWorkspace boost::shared_ptr<Mantid::API::MatrixWorkspace> getMaskMatrixWorkspace() const; @@ -88,10 +81,12 @@ public: void invertMaskWorkspace() const; /// Get the mask displayed but not yet applied as a IMaskWorkspace boost::shared_ptr<Mantid::API::IMaskWorkspace> getMaskWorkspace() const; + boost::shared_ptr<Mantid::API::IMaskWorkspace> + getMaskWorkspaceIfExists() const; /// Apply the mask in the attached mask workspace to the data. void applyMaskWorkspace(); /// Add a range of bins for masking - void addMaskBinsData(const QList<int> &detIDs); + void addMaskBinsData(const std::vector<size_t> &indices); /// Remove the attached mask workspace without applying the mask. /// Remove the bin masking data. void clearMasks(); @@ -137,32 +132,27 @@ public: bool wholeRange() const; /// Get the number of detectors in the instrument. - size_t ndetectors() const { return m_detIDs.size(); } - /// Get a reference to a detector by a pick ID converted form a color in - /// the pick image. - const Mantid::Geometry::IDetector &getDetectorByPickID(size_t pickID) const; - /// Get a reference to a detector by a detector ID. - const Mantid::Geometry::IDetector & - getDetectorByDetID(Mantid::detid_t detID) const; + size_t ndetectors() const; // { return m_detIDs.size(); } + /// Get a detector index by a detector ID. + size_t getDetectorByDetID(Mantid::detid_t detID) const; /// Get a detector ID by a pick ID converted form a color in the pick image. Mantid::detid_t getDetID(size_t pickID) const; + QList<Mantid::detid_t> getDetIDs(const std::vector<size_t> &dets) const; /// Get a component ID for a non-detector. Mantid::Geometry::ComponentID getComponentID(size_t pickID) const; - /// Cache detector positions. - void cacheDetPos() const; /// Get position of a detector by a pick ID converted form a color in the pick /// image. - const Mantid::Kernel::V3D &getDetPos(size_t pickID) const; + const Mantid::Kernel::V3D getDetPos(size_t pickID) const; /// Get a vector of IDs of all detectors in the instrument. - const std::vector<Mantid::detid_t> &getAllDetIDs() const { return m_detIDs; } - /// Get displayed color of a detector by its detector ID. - GLColor getColor(Mantid::detid_t id) const; - /// Get the workspace index of a detector by its detector ID. - size_t getWorkspaceIndex(Mantid::detid_t id) const; - /// Get the integrated counts of a detector by its detector ID. - double getIntegratedCounts(Mantid::detid_t id) const; + const std::vector<Mantid::detid_t> &getAllDetIDs() const; + /// Get displayed color of a detector by its index. + GLColor getColor(size_t index) const; + /// Get the workspace index of a detector by its detector Index. + size_t getWorkspaceIndex(size_t index) const; + /// Get the integrated counts of a detector by its detector Index. + double getIntegratedCounts(size_t index) const; /// Sum the counts in detectors - void sumDetectors(QList<int> &dets, std::vector<double> &x, + void sumDetectors(const std::vector<size_t> &dets, std::vector<double> &x, std::vector<double> &y, size_t size = 0) const; /// Calc indexes for min and max bin values void getBinMinMaxIndex(size_t wi, size_t &imin, size_t &imax) const; @@ -170,9 +160,6 @@ public: /// Update the detector colors to match the integrated counts within the /// current integration range. void updateColors(); - /// Invalidate the OpenGL display lists to force full re-drawing of the - /// instrument and creation of new lists. - void invalidateDisplayLists() const { m_scene.invalidateDisplayList(); } /// Toggle display of the guide and other non-detector instrument components void showGuides(bool); /// Get the guide visibility status @@ -195,10 +182,18 @@ public: void initMaskHelper() const; bool hasMaskWorkspace() const; bool hasBinMask() const; + QString getParameterInfo(size_t index) const; + std::string getDefaultAxis() const; + std::string getDefaultView() const; + std::string getInstrumentName() const; + std::vector<std::string> getStringParameter(const std::string &name, + bool recursive = true) const; /// Load the state of the actor from a Mantid project file. void loadFromProject(const std::string &lines); /// Save the state of the actor to a Mantid project file. std::string saveToProject() const; + /// Returns indices of all non-detector components in Instrument. + const std::vector<size_t> &components() const { return m_components; } signals: void colorMapChanged(); @@ -207,6 +202,7 @@ private: void setUpWorkspace( boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, double scaleMin, double scaleMax); + void setupPhysicalInstrumentIfExists(); void resetColors(); void loadSettings(); void saveSettings(); @@ -216,19 +212,13 @@ private: calculateIntegratedSpectra(const Mantid::API::MatrixWorkspace &workspace); /// Sum the counts in detectors if the workspace has equal bins for all /// spectra - void sumDetectorsUniform(QList<int> &dets, std::vector<double> &x, + void sumDetectorsUniform(const std::vector<size_t> &dets, + std::vector<double> &x, std::vector<double> &y) const; /// Sum the counts in detectors if the workspace is ragged - void sumDetectorsRagged(QList<int> &dets, std::vector<double> &x, - std::vector<double> &y, size_t size) const; - - size_t pushBackDetid(Mantid::detid_t) const; - void pushBackNonDetid(ObjComponentActor *actor, - Mantid::Geometry::ComponentID compID) const; - void setupPickColors(); - - boost::shared_ptr<Mantid::API::IMaskWorkspace> - getMaskWorkspaceIfExists() const; + void sumDetectorsRagged(const std::vector<size_t> &dets, + std::vector<double> &x, std::vector<double> &y, + size_t size) const; /// The workspace whose data are shown const boost::weak_ptr<const Mantid::API::MatrixWorkspace> m_workspace; @@ -237,8 +227,6 @@ private: mutable boost::shared_ptr<Mantid::API::MatrixWorkspace> m_maskWorkspace; /// A helper object that keeps bin masking data. mutable MaskBinsData m_maskBinsData; - /// The colormap - MantidColorMap m_colorMap; QString m_currentColorMapFilename; /// integrated spectra std::vector<double> m_specIntegrs; @@ -260,97 +248,22 @@ private: bool m_showGuides; /// Color map scale type: linear or log GraphOptions::ScaleType m_scaleType; - - /// The workspace's detector ID to workspace index map - Mantid::detid2index_map m_detid2index_map; - - /// All det ids in the instrument in order of pickIDs, populated by Obj..Actor - /// constructors - mutable std::vector<Mantid::detid_t> m_detIDs; - /// All non-detector component IDs in order of pickIDs. For any index i a - /// pickID of the component - /// is m_detIDs.size() + i. - mutable std::vector<Mantid::Geometry::ComponentID> m_nonDetIDs; - /// Temporary stores addresses of actors for non-detector components until - /// initialisation completes - mutable std::vector<ObjComponentActor *> m_nonDetActorsTemp; - - /// All detector positions, in order of pickIDs, populated by Obj..Actor - /// constructors - mutable std::vector<Mantid::Kernel::V3D> m_detPos; /// Position to refer to when detector not found const Mantid::Kernel::V3D m_defaultPos; - /// Colors in order of workspace indexes - mutable std::vector<GLColor> m_colors; - /// Colour of a masked detector - GLColor m_maskedColor; - /// Colour of a "failed" detector - GLColor m_failedColor; - /// The collection of actors for the instrument components - GLActorCollection m_scene; + /// Colors in order of component info + std::vector<size_t> m_monitors; + std::vector<size_t> m_components; static double m_tolerance; - friend class ObjComponentActor; - friend class ObjCompAssemblyActor; - friend class RectangularDetectorActor; - friend class StructuredDetectorActor; -}; - -/** -* Sets visibility of an actor with a particular ComponentID -* and makes all other components invisible. -*/ -class SetVisibleComponentVisitor : public SetVisibilityVisitor { -public: - explicit SetVisibleComponentVisitor(const Mantid::Geometry::ComponentID id) - : m_id(id) {} - bool visit(GLActor *) override; - bool visit(GLActorCollection *) override; - bool visit(ComponentActor *actor) override; - bool visit(CompAssemblyActor *actor) override; - bool visit(ObjCompAssemblyActor *actor) override; - bool visit(InstrumentActor *actor) override; - bool visit(RectangularDetectorActor *actor) override; - bool visit(StructuredDetectorActor *actor) override; - Mantid::Geometry::ComponentID getID() const { return m_id; } - -private: - Mantid::Geometry::ComponentID m_id; -}; - -/** -* Set visibility of all actors of non-detector components. -* Pass true to constructor to set them visible and false to make them invisible. -*/ -class SetVisibleNonDetectorVisitor : public SetVisibilityVisitor { -public: - /// Constructor - /// @param on :: If true then all non-detectors will be made visible or - /// invisible if false. - explicit SetVisibleNonDetectorVisitor(bool on) : m_on(on) {} - using GLActorVisitor::visit; - bool visit(GLActor *) override; - -private: - bool m_on; -}; - -/** -* Finds an actor with a particular ComponentID -*/ -class FindComponentVisitor : public GLActorVisitor { -public: - explicit FindComponentVisitor(const Mantid::Geometry::ComponentID id) - : m_id(id), m_actor(nullptr) {} - using GLActorVisitor::visit; - bool visit(GLActor *) override; - ComponentActor *getActor() const { return m_actor; } + std::vector<bool> m_isCompVisible; + std::vector<size_t> m_detIndex2WsIndex; -private: - Mantid::Geometry::ComponentID m_id; - mutable ComponentActor *m_actor; + bool m_isPhysicalInstrument; + std::unique_ptr<Mantid::Geometry::ComponentInfo> m_physicalComponentInfo; + std::unique_ptr<Mantid::Geometry::DetectorInfo> m_physicalDetectorInfo; + std::unique_ptr<InstrumentRenderer> m_renderer; }; } // MantidWidgets diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentRenderer.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentRenderer.h new file mode 100644 index 0000000000000000000000000000000000000000..880cbc9e36617e3cb48fac3336abfc9bd5c010d7 --- /dev/null +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentRenderer.h @@ -0,0 +1,74 @@ +#ifndef INSTRUMENTRENDERER_H_ +#define INSTRUMENTRENDERER_H_ + +#include "DllOption.h" +#include "GLColor.h" +#include "MantidGeometry/Rendering/OpenGL_Headers.h" +#include "MantidQtWidgets/LegacyQwt/MantidColorMap.h" +#include <QString> + +namespace MantidQt { +namespace MantidWidgets { +class InstrumentActor; + +class EXPORT_OPT_MANTIDQT_INSTRUMENTVIEW InstrumentRenderer { +private: + const InstrumentActor &m_actor; + std::vector<GLColor> m_colors; + std::vector<GLColor> m_pickColors; + mutable GLuint m_displayListId[2]; + mutable bool m_useDisplayList[2]; + mutable std::vector<GLuint> m_textureIDs; + mutable std::vector<size_t> m_textureIndices; + mutable std::map<size_t, size_t> m_reverseTextureIndexMap; + mutable std::vector<std::vector<char>> colorTextures; + mutable std::vector<std::vector<char>> pickTextures; + std::vector<double> m_specIntegrs; + MantidColorMap m_colorMap; + +public: + InstrumentRenderer(const InstrumentActor &actor); + ~InstrumentRenderer(); + void renderInstrument(const std::vector<bool> &visibleComps, bool showGuides, + bool picking = false); + void reset(); + + void changeScaleType(int type); + + void changeNthPower(double nth_power); + + void loadColorMap(const QString &fname); + + const MantidColorMap &getColorMap() const { return m_colorMap; } + + GLColor getColor(size_t index) const; + + static GLColor makePickColor(size_t pickID); + + static size_t decodePickColor(const QRgb &c); + +private: + void resetColors(); + void resetPickColors(); + void draw(const std::vector<bool> &visibleComps, bool showGuides, + bool picking); + void drawRectangularBank(size_t bankIndex, bool picking); + void drawStructuredBank(size_t bankIndex, bool picking); + void drawTube(size_t bankIndex, bool picking); + void drawSingleDetector(size_t detIndex, bool picking); + void generateRectangularTexture(std::vector<char> &texture, + const std::vector<GLColor> &colors, + size_t bankIndex); + + void uploadRectangularTexture(const std::vector<char> &texture, + size_t textureIndex) const; + + void generateTubeTexture(std::vector<char> &texture, + const std::vector<GLColor> &colors, + size_t bankIndex); + void uploadTubeTexture(const std::vector<char> &texture, + size_t textureIndex) const; +}; +} // namespace MantidWidgets +} // namespace MantidQt +#endif // INSTRUMENTRENDERER_H_ \ No newline at end of file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeModel.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeModel.h index a53cd4cac13fd1ee408d7a372621d67edbfb7024..86d54b58d767ba1a35fc49c8e6825facbb0e5b0f 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeModel.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeModel.h @@ -33,10 +33,12 @@ public: QModelIndex parent(const QModelIndex &index) const override; int rowCount(const QModelIndex &paren = QModelIndex()) const override; int columnCount(const QModelIndex &parent = QModelIndex()) const override; + static size_t extractIndex(const QModelIndex &index); private: /// instrument widget to which the model corresponds const InstrumentWidget *m_instrWidget; + mutable std::vector<size_t> m_componentIndices; }; } // MantidWidgets } // MantidQt diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h index 7cd33fc0129cacec17e07d469e17e75b2522f8a0..1e22e4bbd533ceb353a09e98b737e8632712342a 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h @@ -36,7 +36,7 @@ public: public slots: void sendComponentSelectedSignal(const QModelIndex); signals: - void componentSelected(const Mantid::Geometry::ComponentID); + void componentSelected(size_t); private: InstrumentWidget *m_instrWidget; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h index eefd8644c4bfc5f3773b9ed97eb66e12766c80fa..2260a08c1e45bdb14554e1401774bcc070e7a47d 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidget.h @@ -172,7 +172,7 @@ protected: public slots: void tabChanged(int); - void componentSelected(Mantid::Geometry::ComponentID id); + void componentSelected(size_t componentIndex); void executeAlgorithm(const QString &, const QString &); void executeAlgorithm(Mantid::API::IAlgorithm_sptr); diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h index ff9ac33ad3975560ded738728b910a90dd18d381..83ce8c02bc5ac380c25d2492161645e9958b3740 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h @@ -200,12 +200,11 @@ public slots: void clear(); private: - QString displayDetectorInfo(Mantid::detid_t detid); + QString displayDetectorInfo(size_t index); QString displayNonDetectorInfo(Mantid::Geometry::ComponentID compID); QString displayPeakInfo(Mantid::Geometry::IPeak *peak); QString displayPeakAngles(const std::pair<Mantid::Geometry::IPeak *, Mantid::Geometry::IPeak *> &peaks); - QString getParameterInfo(const Mantid::Geometry::IComponent &comp); QString getPeakOverlayInfo(); InstrumentWidgetPickTab *m_tab; @@ -238,7 +237,7 @@ public: InstrumentWidget *instrWidget, OneCurvePlot *plot); void setEnabled(bool on) { m_enabled = on; } void setPlotData(size_t pickID); - void setPlotData(QList<int> detIDs); + void setPlotData(const std::vector<size_t> &detIndices); void updatePlot(); void clear(); void savePlotToWorkspace(); @@ -256,17 +255,17 @@ private slots: void addPeak(double x, double y); private: - void plotSingle(int detid); - void plotTube(int detid); - void plotTubeSums(int detid); - void plotTubeIntegrals(int detid); - void prepareDataForSinglePlot(int detid, std::vector<double> &x, + void plotSingle(size_t detindex); + void plotTube(size_t detindex); + void plotTubeSums(size_t detindex); + void plotTubeIntegrals(size_t detindex); + void prepareDataForSinglePlot(size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err = nullptr); - void prepareDataForSumsPlot(int detid, std::vector<double> &x, + void prepareDataForSumsPlot(size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err = nullptr); - void prepareDataForIntegralsPlot(int detid, std::vector<double> &x, + void prepareDataForIntegralsPlot(size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err = nullptr); static double getOutOfPlaneAngle(const Mantid::Kernel::V3D &pos, @@ -281,7 +280,7 @@ private: bool m_enabled; TubeXUnits m_tubeXUnits; ///< quantity the time bin integrals to be plotted against - int m_currentDetID; + size_t m_currentPickID; }; } // MantidWidgets diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h index 6407cc16b80dc41ae471995ba790aa1eebe4154c..0a06893e4a2d755e1eb79e7277c7b697779cf8a1 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MantidGLWidget.h @@ -34,7 +34,7 @@ public slots: void enableLighting(bool); void updateView(bool picking = true); void updateDetectors(); - void componentSelected(Mantid::Geometry::ComponentID id); + void componentSelected(size_t componentIndex); protected: void initializeGL() override; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MaskBinsData.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MaskBinsData.h index f50f2554b98f1562fbf17236cdcaac2d34291c57..2ffd97d42783b466f6725c6bffd7aa9b6307bc52 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MaskBinsData.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/MaskBinsData.h @@ -36,7 +36,7 @@ File change history is stored at: <https://github.com/mantidproject/mantid> */ class MaskBinsData { public: - void addXRange(double start, double end, const QList<int> &indices); + void addXRange(double start, double end, const std::vector<size_t> &indices); void mask(const std::string &wsName) const; bool isEmpty() const; void subtractIntegratedSpectra(const Mantid::API::MatrixWorkspace &workspace, @@ -53,7 +53,7 @@ private: BinMask(double s = 0.0, double e = 0.0) : start(s), end(e) {} double start; double end; - QList<int> spectra; + std::vector<size_t> spectra; }; QList<BinMask> m_masks; }; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h deleted file mode 100644 index 8cde9c9a31afd8b7fe8a86968dee755097658063..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h +++ /dev/null @@ -1,93 +0,0 @@ -#ifndef OBJCOMPASSEMBLY_ACTOR__H_ -#define OBJCOMPASSEMBLY_ACTOR__H_ -#include "ICompAssemblyActor.h" - -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidKernel/V3D.h" - -class TexObject; -namespace Mantid { -namespace Geometry { -class ObjCompAssembly; -} -} - -namespace MantidQt { -namespace MantidWidgets { -/** -\class ObjCompAssemblyActor -\brief This class wraps the ICompAssembly into Actor. -\author Srikanth Nagella -\date March 2009 -\version 1.0 - -This class has the implementation for calling the children of ICompAssembly's -IObjComponent to render themselves -and call the ICompAssemblys. This maintains the count of the children for easy -lookup. - -Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -class ObjCompAssemblyActor : public ICompAssemblyActor { -public: - /// Constructor - ObjCompAssemblyActor(const InstrumentActor &instrActor, - Mantid::Geometry::ComponentID compID); - ~ObjCompAssemblyActor() override; ///< Destructor - std::string type() const override { - return "ObjCompAssemblyActor"; - } ///< Type of the GL object - void draw(bool picking = false) const override; ///< Method that defines - /// ObjComponent geometry. Calls - /// ObjComponent draw method - // virtual void getBoundingBox(Mantid::Kernel::V3D& - // minBound,Mantid::Kernel::V3D& maxBound)const; - void setColors() override; - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - -private: - void setDetectorColor(unsigned char *data, size_t i, - GLColor c) const; ///< set colour to a detector - void setDataColors() const; - void setPickColors() const; - void generateTexture(unsigned char *data, unsigned int &id) const; - /// Swap between drawing counts and drawing detector code colours - void swap(); - const unsigned char *getColor(int i) const; - - std::vector<Mantid::detid_t> m_detIDs; ///< List of Component IDs - mutable unsigned int m_idData; ///< OpenGL texture id - mutable unsigned int m_idPick; ///< OpenGL texture id - int m_n; ///< texture size in one dimension, the other dimension is 1 - unsigned char *m_data; ///< texture colour data - unsigned char *m_pick_data; ///< texture with detector code colours - mutable bool - m_texturesGenerated; ///< true if the textures have been generated -}; - -} // MantidWidgets -} // MantidQt - -#endif /*OBJCOMPASSEMBLY_ACTOR__H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjComponentActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjComponentActor.h deleted file mode 100644 index 6ffe582de33f1320781dbb6857e10fc32481172d..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ObjComponentActor.h +++ /dev/null @@ -1,78 +0,0 @@ -#ifndef OBJCOMPONENT_ACTOR_H_ -#define OBJCOMPONENT_ACTOR_H_ -#include "ComponentActor.h" -#include "GLColor.h" -/** - \class ObjComponentActor - \brief ObjComponentActor is an actor class for rendering ObjComponents. - \author Srikanth Nagella - \date March 2009 - \version 1.0 - - This class has the implementation for rendering ObjComponents in OpenGL and - it inherits from the GLActor - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Kernel { -class V3D; -} - -namespace Geometry { -class IObjComponent; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class InstrumentActor; - -class ObjComponentActor : public ComponentActor { -public: - ObjComponentActor( - const InstrumentActor &instrActor, - Mantid::Geometry::ComponentID compID); ///< Default Constructor - ~ObjComponentActor() override; ///< Destructor - std::string type() const override { - return "ObjComponentActor"; - } ///< Type of the GL object - void draw(bool picking = false) const override; ///< Method that defines - /// ObjComponent geometry. Calls - /// ObjComponent draw method - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - void setColors() override; - - void setColor(const GLColor &c) { m_dataColor = c; } - -private: - void setPickColor(const GLColor &c) { m_pickColor = c; } - - GLColor m_dataColor; - GLColor m_pickColor; - - friend class InstrumentActor; -}; -} // MantidWidgets -} // MantidQt - -#endif /*OBJCOMPONENT_ACTOR_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PanelsSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PanelsSurface.h index b397935ac3cdf92b3da0a15cb1025fcfb27d009f..950a7742afd885c0f8ced3c62944d95f5b09fbb3 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PanelsSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/PanelsSurface.h @@ -4,6 +4,7 @@ #include "UnwrappedSurface.h" #include <QPolygonF> +#include <boost/optional.hpp> namespace MantidQt { namespace MantidWidgets { @@ -11,8 +12,6 @@ class PanelsSurface; struct FlatBankInfo { explicit FlatBankInfo(PanelsSurface *s); - /// Component id of the bank - Mantid::Geometry::ComponentID id; /// Bank's rotation Mantid::Kernel::Quat rotation; /// Starting index of bank's detectors in m_unwrappedDetectors vector @@ -53,41 +52,31 @@ public: double &) const override; protected: + boost::optional<std::pair<std::vector<size_t>, Mantid::Kernel::V3D>> + findFlatPanels(size_t rootIndex, const std::vector<size_t> &children, + std::vector<bool> &visited); + + void processStructured(const std::vector<size_t> &children, size_t rootIndex); + + void processTubes(size_t rootIndex, std::vector<bool> &visited); + + std::pair<std::vector<size_t>, Mantid::Kernel::V3D> + processUnstructured(const std::vector<size_t> &children, size_t rootIndex, + std::vector<bool> &visited); + void rotate(const UnwrappedDetector &udet, Mantid::Kernel::Quat &R) const override; - // void drawCustom(QPainter *painter) const; - // Setup the projection axes void setupAxes(); - // Setup the projection axes - void setupBasisAxes(const Mantid::Kernel::V3D &zaxis, - Mantid::Kernel::V3D &xaxis, - Mantid::Kernel::V3D &yaxis) const; - // Find all flat banks of detectors. - void findFlatBanks(); - // Add a flat bank - void addFlatBank(Mantid::Geometry::ComponentID bankId, - const Mantid::Kernel::V3D &normal, - QList<Mantid::Geometry::ComponentID> objCompAssemblies); // Add a flat bank - void addFlatBankOfDetectors(Mantid::Geometry::ComponentID bankId, - const Mantid::Kernel::V3D &normal, - QList<Mantid::Geometry::ComponentID> detectors); - // Add a component assembly containing a flat array of ObjCompAssemblies - void addObjCompAssemblies(Mantid::Geometry::ComponentID bankId); - // Add a component assembly - void addCompAssembly(Mantid::Geometry::ComponentID bankId); - // Add a rectangular detector - void addRectangularDetector(Mantid::Geometry::ComponentID bankId); - // Add a structured detector - void addStructuredDetector(Mantid::Geometry::ComponentID bankId); - // Calculate bank rotation + void addFlatBankOfDetectors(const Mantid::Kernel::V3D &normal, + const std::vector<size_t> &detectors); + void constructFromComponentInfo(); Mantid::Kernel::Quat calcBankRotation(const Mantid::Kernel::V3D &detPos, Mantid::Kernel::V3D normal) const; // Add a detector from an assembly - void addDetector(const Mantid::Geometry::IDetector &det, - const Mantid::Kernel::V3D &refPos, int index, - Mantid::Kernel::Quat &rotation); + void addDetector(size_t detIndex, const Mantid::Kernel::V3D &refPos, + int index, Mantid::Kernel::Quat &rotation); // Spread the banks over the projection plane void spreadBanks(); // Find index of the largest bank @@ -109,9 +98,8 @@ protected: /// Keep info of the flat banks QList<FlatBankInfo *> m_flatBanks; /// Maps detector ids to indices of FlatBankInfos in m_flatBanks - QMap<Mantid::detid_t, int> m_detector2bankMap; + QMap<size_t, int> m_detector2bankMap; - friend class FlatBankFinder; friend struct FlatBankInfo; }; diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Projection3D.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Projection3D.h index 5d9f901a5d5854bd3f9c403ab6d00abf27a8100c..045a6b751c21acfeaf04dfb8bebf0459e0b4f90a 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Projection3D.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/Projection3D.h @@ -39,9 +39,9 @@ public: void set3DAxesState(bool on); void setWireframe(bool on); - void componentSelected(Mantid::Geometry::ComponentID = nullptr) override; - void getSelectedDetectors(QList<int> &dets) override; - void getMaskedDetectors(QList<int> &dets) const override; + void componentSelected(size_t componentIndex) override; + void getSelectedDetectors(std::vector<size_t> &detIndices) override; + void getMaskedDetectors(std::vector<size_t> &detIndices) const override; void resize(int, int) override; QString getInfoText() const override; /// Load settings for the 3D projection from a project file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h index 50e4c840ab282671df92f0b9612b366491e9fe53..ec0a58801bb248da75feb22af393b4fd44a3a609 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/ProjectionSurface.h @@ -109,13 +109,14 @@ public: virtual bool hasSelection() const; virtual int getDetectorID(int x, int y) const; - virtual const Mantid::Geometry::IDetector &getDetector(int x, int y) const; + virtual size_t getDetector(int x, int y) const; /// NULL deselects components and selects the whole instrument - virtual void componentSelected(Mantid::Geometry::ComponentID = nullptr) = 0; - /// fill in a list of detector ids which were selected by the selction tool - virtual void getSelectedDetectors(QList<int> &dets) = 0; - /// fill in a list of detector ids which were masked by the mask shapes - virtual void getMaskedDetectors(QList<int> &dets) const = 0; + virtual void componentSelected(size_t componentIndex) = 0; + /// fill in a list of detector indices which were selected by the selction + /// tool + virtual void getSelectedDetectors(std::vector<size_t> &detIndices) = 0; + /// fill in a list of detector indices which were masked by the mask shapes + virtual void getMaskedDetectors(std::vector<size_t> &detIndices) const = 0; virtual QString getInfoText() const; /// Change the interaction mode diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/RectangularDetectorActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/RectangularDetectorActor.h deleted file mode 100644 index 887dcf9a2bb41a13fe961c11b674f66574ce9cac..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/RectangularDetectorActor.h +++ /dev/null @@ -1,114 +0,0 @@ -#ifndef RECTANGULAR_DETECTOR_ACTOR__H_ -#define RECTANGULAR_DETECTOR_ACTOR__H_ -#include "GLActor.h" -#include "ObjComponentActor.h" -#include "ICompAssemblyActor.h" -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidKernel/V3D.h" -/** - \class RectangularDetectorActor - \brief This class wraps a RectangularDetector into Actor. - \author Janik Zikovsky - \date October 7 2010 - \version 1.0 - - This class is used to render a RectangularDetector as a bitmap and plot it. - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class ICompAssembly; -class CSGObject; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class ObjComponentActor; - -class RectangularDetectorActor : public ICompAssemblyActor { -public: - /// Constructor - RectangularDetectorActor(const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID); - /// Destructor - ~RectangularDetectorActor() override; - -private: - void AppendBoundingBox(const Mantid::Kernel::V3D &minBound, - const Mantid::Kernel::V3D &maxBound); - -protected: - /// The rectangular detector - boost::shared_ptr<const Mantid::Geometry::RectangularDetector> mDet; - - void init() const; - void redraw(); - int findDetectorIDUsingColor(int rgb); - virtual void initChilds(bool) {} - -public: - std::string type() const override { - return "RectangularDetectorActor"; - } ///< Type of the GL object - - void draw(bool picking = false) const override; ///< Method that - /// defines - /// ObjComponent - /// geometry. Calls - /// ObjComponent - /// draw method - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - bool isChildDetector(const Mantid::Geometry::ComponentID &id) const; - void setColors() override; - - int genTexture(char *&image_data, std::vector<GLColor> &list, - bool useDetectorIDs); - void uploadTexture(char *&image_data) const; - -private: - /// Texture ID that holds the texture. - mutable unsigned int mTextureID; - - /// Pointer to the array holding the texture color data - mutable char *image_data; - - /// Pointer to the array holding the color data for picking the scene - mutable char *pick_data; - - /// pick ids - std::vector<size_t> m_pickIDs; -}; - -} // MantidWidgets -} // MantidQt - -#endif /*RECTANGULAR_DETECTOR_ACTOR__H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/SampleActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/SampleActor.h deleted file mode 100644 index cb46c0c637f357391b73d6be01f0068eec750a2c..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/SampleActor.h +++ /dev/null @@ -1,79 +0,0 @@ -#ifndef SMAPLE_ACTOR_H_ -#define SMAPLE_ACTOR_H_ -#include "GLActor.h" -#include "GLColor.h" -#include "ObjComponentActor.h" - -#include <boost/shared_ptr.hpp> - -/** - \class SampleActor - \brief SampleActor is an actor class for rendering Samples. - \author Roman Tolchenov - \date 04/07/2011 - \version 1.0 - - This class has the implementation for rendering SampleActor in OpenGL and it - inherits from the GLActor - - Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge - National Laboratory & European Spallation Source - - This file is part of Mantid. - - Mantid is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - Mantid is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program. If not, see <http://www.gnu.org/licenses/>. - - File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace API { -class Sample; -} -namespace Geometry { -class IObjComponent; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class InstrumentActor; - -class SampleActor : public GLActor { -public: - SampleActor(const InstrumentActor &instrActor, - const Mantid::API::Sample &sample, - const ObjComponentActor *samplePosActor); ///< Constructor - virtual std::string type() const { - return "SampleActor"; - } ///< Type of the GL object - void draw(bool picking) const override; - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - void setColor(const GLColor &c) { m_color = c; } - const ObjComponentActor *getSamplePosActor() const { - return m_samplePosActor; - } - -protected: - const InstrumentActor &m_instrActor; - const Mantid::API::Sample &m_sample; - const ObjComponentActor *m_samplePosActor; - boost::shared_ptr<const Mantid::Geometry::IObjComponent> m_samplePos; - GLColor m_color; -}; - -} // MantidWidgets -} // MantidQt - -#endif /*SMAPLE_ACTOR_H_*/ diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/StructuredDetectorActor.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/StructuredDetectorActor.h deleted file mode 100644 index 07e72cb3e303f2ae96213cfaeaa477444d12839a..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/StructuredDetectorActor.h +++ /dev/null @@ -1,100 +0,0 @@ -#ifndef STRUCTUREDDETECTORACTOR -#define STRUCTUREDDETECTORACTOR -#include "GLActor.h" -#include "ICompAssemblyActor.h" -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidKernel/V3D.h" -#include "ObjComponentActor.h" -/** -\class StructuredDetectorActor -\brief This class wraps a StructuredDetector into Actor. -\author Lamar Moore -\date March 9 2016 -\version 1.0 - -This class is used to render a StructuredDetector as a bitmap and plot it. - -Copyright © 2007 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge -National Laboratory & European Spallation Source - -This file is part of Mantid. - -Mantid is free software; you can redistribute it and/or modify -it under the terms of the GNU General Public License as published by -the Free Software Foundation; either version 3 of the License, or -(at your option) any later version. - -Mantid is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -GNU General Public License for more details. - -You should have received a copy of the GNU General Public License -along with this program. If not, see <http://www.gnu.org/licenses/>. - -File change history is stored at: <https://github.com/mantidproject/mantid> -*/ -namespace Mantid { -namespace Kernel { -class V3D; -} -namespace Geometry { -class ICompAssembly; -class CSGObject; -} -} - -namespace MantidQt { -namespace MantidWidgets { -class ObjComponentActor; - -class StructuredDetectorActor : public ICompAssemblyActor { -public: - /// Constructor - StructuredDetectorActor(const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID); - /// Destructor - ~StructuredDetectorActor() override; - -private: - void AppendBoundingBox(const Mantid::Kernel::V3D &minBound, - const Mantid::Kernel::V3D &maxBound); - -protected: - /// The structured detector - boost::shared_ptr<const Mantid::Geometry::StructuredDetector> m_det; - std::vector<GLColor> m_clist; - std::vector<size_t> m_pickIds; - std::vector<GLColor> m_pickColors; - - void init() const; - void redraw(); - int findDetectorIDUsingColor(int rgb); - virtual void initChilds(bool) {} - -public: - std::string type() const override { - return "StructuredDetectorActor"; - } ///< Type of the GL object - - void draw(bool picking = false) const override; ///< Method that - /// defines - /// ObjComponent - /// geometry. Calls - /// ObjComponent - /// draw method - void getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const override; - bool accept(GLActorVisitor &visitor, - VisitorAcceptRule rule = VisitAll) override; - bool accept(GLActorConstVisitor &visitor, - VisitorAcceptRule rule = VisitAll) const override; - bool isChildDetector(const Mantid::Geometry::ComponentID &id) const; - void setColors() override; -}; - -} // MantidWidgets -} // MantidQt - -#endif // STRUCTUREDDETECTORACTOR \ No newline at end of file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h new file mode 100644 index 0000000000000000000000000000000000000000..f5482189f25d59d55193988399ac0c222dcb4187 --- /dev/null +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedDetector.h @@ -0,0 +1,48 @@ +#ifndef UNWRAPPEDDETECTOR_H +#define UNWRAPPEDDETECTOR_H + +#include "MantidGeometry/IDTypes.h" +#include "MantidKernel/Quat.h" +#include "MantidKernel/V3D.h" +#include "MantidQtWidgets/InstrumentView/GLColor.h" +#include <boost/shared_ptr.hpp> +#include <limits> + +namespace Mantid { +namespace Geometry { +class IDetector; +class IObject; +} // namespace Geometry +} // namespace Mantid + +namespace MantidQt { +namespace MantidWidgets { +/** +\class UnwrappedDetector +\brief Class helper for drawing detectors on unwraped surfaces +\date 15 Nov 2010 +\author Roman Tolchenov, Tessella plc + +This class keeps information used to draw a detector on an unwrapped surface. + +*/ +class UnwrappedDetector { +public: + UnwrappedDetector(); + UnwrappedDetector(GLColor color, size_t detIndex); + UnwrappedDetector(const UnwrappedDetector &other); + UnwrappedDetector &operator=(const UnwrappedDetector &other); + bool empty() const; + GLColor color; ///< red, green, blue colour components (0 - 255) + double u; ///< horizontal "unwrapped" coordinate + double v; ///< vertical "unwrapped" coordinate + double width; ///< detector width in units of u + double height; ///< detector height in units of v + double uscale; ///< scaling factor in u direction + double vscale; ///< scaling factor in v direction + size_t detIndex = std::numeric_limits<size_t>::max(); ///< Detector Index in + ///< ComponentInfo/DetectorInfo. +}; +} // namespace MantidWidgets +} // namespace MantidQt +#endif \ No newline at end of file diff --git a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h index 3dab3355bba4787b9ac7a8a684ccd3b86432190d..82549f3f16ee68c63c01f2d90c683ff5660e1ff8 100644 --- a/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h +++ b/qt/widgets/instrumentview/inc/MantidQtWidgets/InstrumentView/UnwrappedSurface.h @@ -3,10 +3,10 @@ #include "MantidKernel/V3D.h" #include "MantidKernel/Quat.h" -#include "MantidGeometry/IComponent.h" #include "MantidGeometry/Objects/IObject.h" #include "InstrumentActor.h" #include "ProjectionSurface.h" +#include "UnwrappedDetector.h" #include <boost/shared_ptr.hpp> #include <QImage> @@ -31,39 +31,6 @@ class GL3DWidget; namespace MantidQt { namespace MantidWidgets { - -/** -\class UnwrappedDetector -\brief Class helper for drawing detectors on unwraped surfaces -\date 15 Nov 2010 -\author Roman Tolchenov, Tessella plc - -This class keeps information used to draw a detector on an unwrapped surface. - -*/ -class UnwrappedDetector { -public: - UnwrappedDetector(); - UnwrappedDetector(const unsigned char *c, - const Mantid::Geometry::IDetector &det); - UnwrappedDetector(const UnwrappedDetector &other); - UnwrappedDetector &operator=(const UnwrappedDetector &other); - bool isValid() const; - unsigned char color[3]; ///< red, green, blue colour components (0 - 255) - double u; ///< horizontal "unwrapped" coordinate - double v; ///< vertical "unwrapped" coordinate - double width; ///< detector width in units of u - double height; ///< detector height in units of v - double uscale; ///< scaling factor in u direction - double vscale; ///< scaling factor in v direction - Mantid::detid_t detID; ///< Detector ID - Mantid::Kernel::V3D position; ///< Detector position - Mantid::Kernel::Quat rotation; ///< Detector orientation - boost::shared_ptr<const Mantid::Geometry::IObject> - shape; ///< Shape of the detector - Mantid::Kernel::V3D scaleFactor; ///< Detector's scale factor -}; - /** * @class UnwrappedSurface * @brief Performs projection of an instrument onto a 2D surface and unwrapping @@ -92,9 +59,9 @@ public: /** @name Implemented public virtual methods */ //@{ - void componentSelected(Mantid::Geometry::ComponentID = nullptr) override; - void getSelectedDetectors(QList<int> &dets) override; - void getMaskedDetectors(QList<int> &dets) const override; + void componentSelected(size_t componentIndex) override; + void getSelectedDetectors(std::vector<size_t> &detIndices) override; + void getMaskedDetectors(std::vector<size_t> &detIndices) const override; void setPeaksWorkspace(boost::shared_ptr<Mantid::API::IPeaksWorkspace> pws); QString getInfoText() const override; RectF getSurfaceBounds() const override; @@ -179,10 +146,7 @@ protected: /** @name Protected methods */ //@{ - void setColor(int index, bool picking) const; - void calcAssemblies(const Mantid::Geometry::IComponent *comp, - const QRectF &compRect); - void cacheAllAssemblies(); + void setColor(size_t index, bool picking) const; void createPeakShapes(const QRect &viewport) const; //@} @@ -196,9 +160,6 @@ protected: /// Info needed to draw detectors onto unwrapped image std::vector<UnwrappedDetector> m_unwrappedDetectors; - /// Bounding rectangles of detector assemblies - QMap<Mantid::Geometry::ComponentID, QRectF> m_assemblies; - bool m_flippedView; ///< if false the image is seen from the sample. if true /// the view is looking towards the sample. mutable bool m_startPeakShapes; ///< set to true to start creating diff --git a/qt/widgets/instrumentview/src/BankRenderingHelpers.cpp b/qt/widgets/instrumentview/src/BankRenderingHelpers.cpp new file mode 100644 index 0000000000000000000000000000000000000000..586a8f324fe210e5fbc1ff977365610bc43ec37e --- /dev/null +++ b/qt/widgets/instrumentview/src/BankRenderingHelpers.cpp @@ -0,0 +1,193 @@ +#include "MantidQtWidgets/InstrumentView/BankRenderingHelpers.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Objects/ShapeFactory.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Rendering/OpenGL_Headers.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidKernel/Quat.h" + +using Mantid::Kernel::V3D; +using Mantid::Kernel::Quat; +namespace { +struct Corners { + V3D bottomLeft; + V3D bottomRight; + V3D topRight; + V3D topLeft; +}; + +Mantid::Kernel::Logger g_log("BankRenderingHelpers"); + +// Round a number up to the nearest power of 2 +size_t roundToNearestPowerOfTwo(size_t val) { + size_t rounded = 2; + while (val > rounded) + rounded *= 2; + return rounded; +} + +Corners findCorners(const Mantid::Geometry::ComponentInfo &compInfo, + size_t bankIndex) { + auto rotation = compInfo.rotation(bankIndex); + auto position = compInfo.position(bankIndex); + auto bank = compInfo.quadrilateralComponent(bankIndex); + Corners c; + c.bottomLeft = compInfo.position(bank.bottomLeft); + c.bottomRight = compInfo.position(bank.bottomRight); + c.topRight = compInfo.position(bank.topRight); + c.topLeft = compInfo.position(bank.topLeft); + rotation.conjugate(); + rotation.rotate(c.bottomLeft); + rotation.rotate(c.bottomRight); + rotation.rotate(c.topLeft); + rotation.rotate(c.topRight); + rotation.rotate(position); + c.bottomLeft -= position; + c.bottomRight -= position; + c.topRight -= position; + c.topLeft -= position; + return c; +} + +void addVertex(const V3D &pos) { + glVertex3f(static_cast<GLfloat>(pos.X()), static_cast<GLfloat>(pos.Y()), + static_cast<GLfloat>(pos.Z())); +} + +void setBankNormal(const V3D &pos1, const V3D &pos2, const V3D &basePos) { + // Set the bank normal to facilitate lighting effects + auto vec1 = pos1 - basePos; + auto vec2 = pos2 - basePos; + auto normal = vec1.cross_prod(vec2); + normal.normalize(); + glNormal3f(static_cast<GLfloat>(normal.X()), static_cast<GLfloat>(normal.Y()), + static_cast<GLfloat>(normal.Z())); +} + +void extractHexahedron(const Mantid::Geometry::IObject &shape, + std::vector<V3D> &hex) { + const auto &shapeInfo = shape.getGeometryHandler()->shapeInfo(); + const auto &points = shapeInfo.points(); + hex.assign(points.begin(), points.begin() + 4); +} + +void rotateHexahedron(std::vector<V3D> &hex, const Quat &rotation) { + for (auto &pos : hex) + rotation.rotate(pos); +} + +void offsetHexahedronPosition(std::vector<V3D> &hex, const V3D &offset) { + for (auto &pos : hex) + pos += offset; +} +} // namespace + +namespace MantidQt { +namespace MantidWidgets { +namespace BankRenderingHelpers { + +std::pair<size_t, size_t> getCorrectedTextureSize(const size_t width, + const size_t height) { + return {roundToNearestPowerOfTwo(width), roundToNearestPowerOfTwo(height)}; +} + +void renderRectangularBank(const Mantid::Geometry::ComponentInfo &compInfo, + size_t index) { + auto c = findCorners(compInfo, index); + auto bank = compInfo.quadrilateralComponent(index); + auto xstep = + (c.bottomRight.X() - c.bottomLeft.X()) / static_cast<double>(bank.nX); + auto ystep = + (c.topRight.Y() - c.bottomLeft.Y()) / static_cast<double>(bank.nY); + auto name = compInfo.name(index); + // Because texture colours are combined with the geometry colour + // make sure the current colour is white + glColor3f(1.0f, 1.0f, 1.0f); + + // Nearest-neighbor scaling + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); + glEnable(GL_TEXTURE_2D); // enable texture mapping + + size_t texx, texy; + auto res = getCorrectedTextureSize(bank.nX, bank.nY); + texx = res.first; + texy = res.second; + double tex_frac_x = static_cast<double>(bank.nX) / static_cast<double>(texx); + double tex_frac_y = static_cast<double>(bank.nY) / static_cast<double>(texy); + + glBegin(GL_QUADS); + + auto basePos = c.bottomLeft; + + // Set the bank normal to facilitate lighting effects + setBankNormal(c.bottomRight, c.topLeft, basePos); + + glTexCoord2f(0.0, 0.0); + addVertex(c.bottomLeft - basePos + V3D((xstep * -0.5), (ystep * -0.5), 0.0)); + + glTexCoord2f(static_cast<GLfloat>(tex_frac_x), 0.0); + addVertex(c.bottomRight - basePos + V3D((xstep * 0.5), (ystep * -0.5), 0.0)); + + glTexCoord2f(static_cast<GLfloat>(tex_frac_x), + static_cast<GLfloat>(tex_frac_y)); + addVertex(c.topRight - basePos + V3D((xstep * 0.5), (ystep * 0.5), 0.0)); + + glTexCoord2f(0.0, static_cast<GLfloat>(tex_frac_y)); + addVertex(c.topLeft - basePos + V3D((xstep * -0.5), (ystep * 0.5), 0.0)); + + glEnd(); + + if (glGetError() > 0) + g_log.error() << "OpenGL error in renderRectangularBank() \n"; + + glDisable( + GL_TEXTURE_2D); // stop texture mapping - not sure if this is necessary. +} + +void renderStructuredBank(const Mantid::Geometry::ComponentInfo &compInfo, + size_t index, const std::vector<GLColor> &color) { + glBegin(GL_QUADS); + + const auto &columns = compInfo.children(index); + auto colWidth = (columns.size()) * 3; + auto baseIndex = compInfo.children(columns[0])[0]; + const auto &baseShapeInfo = + compInfo.shape(baseIndex).getGeometryHandler()->shapeInfo(); + auto basePos = baseShapeInfo.points()[0]; + std::vector<V3D> hex(4); + + setBankNormal(baseShapeInfo.points()[1], baseShapeInfo.points()[3], basePos); + + for (size_t x = 0; x < colWidth; x += 3) { + auto index = x / 3; + const auto &column = compInfo.children(columns[index]); + for (size_t y = 0; y < column.size() - 1; ++y) { + extractHexahedron(compInfo.shape(column[y]), hex); + offsetHexahedronPosition(hex, -basePos); + rotateHexahedron(hex, compInfo.rotation(column[y])); + offsetHexahedronPosition(hex, compInfo.position(column[y])); + + glColor3ub((GLubyte)color[column[y]].red(), + (GLubyte)color[column[y]].green(), + (GLubyte)color[column[y]].blue()); + glVertex3f(static_cast<GLfloat>(hex[0].X()), + static_cast<GLfloat>(hex[0].Y()), 0); + glVertex3f(static_cast<GLfloat>(hex[1].X()), + static_cast<GLfloat>(hex[1].Y()), 0); + glVertex3f(static_cast<GLfloat>(hex[2].X()), + static_cast<GLfloat>(hex[2].Y()), 0); + glVertex3f(static_cast<GLfloat>(hex[3].X()), + static_cast<GLfloat>(hex[3].Y()), 0); + } + } + + glEnd(); + + if (glGetError() > 0) + g_log.error() << "OpenGL error in renderStructuredBank() \n"; +} +} // namespace BankRenderingHelpers +} // namespace MantidWidgets +} // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/instrumentview/src/CompAssemblyActor.cpp b/qt/widgets/instrumentview/src/CompAssemblyActor.cpp deleted file mode 100644 index e60b5679340609c77b8f5a38cc74ad3ce11f140b..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/CompAssemblyActor.cpp +++ /dev/null @@ -1,271 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/CompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/RectangularDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/StructuredDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/OpenGLError.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" - -#include "MantidGeometry/Instrument.h" -#include "MantidKernel/V3D.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/ICompAssembly.h" -#include "MantidGeometry/Instrument/ObjCompAssembly.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidKernel/Exception.h" - -#include <cfloat> - -using Mantid::Geometry::IComponent; -using Mantid::Geometry::IObjComponent; -using Mantid::Geometry::ICompAssembly; -using Mantid::Geometry::ObjCompAssembly; -using Mantid::Geometry::ComponentID; -using Mantid::Geometry::RectangularDetector; -using Mantid::Geometry::StructuredDetector; - -namespace MantidQt { -namespace MantidWidgets { - -/** -* This is a constructor for CompAssembly Actor -* @param instrActor :: the current instrument actor -* @param compID :: the current component ID -*/ -CompAssemblyActor::CompAssemblyActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID) - : ICompAssemblyActor(instrActor, compID) { - boost::shared_ptr<const IComponent> CompPtr = getComponent(); - - // bounding box of the overall instrument - Mantid::Kernel::V3D minBound; - Mantid::Kernel::V3D maxBound; - // Iterate through CompAssembly children - boost::shared_ptr<const ICompAssembly> CompAssemPtr = - boost::dynamic_pointer_cast<const ICompAssembly>(CompPtr); - if (CompAssemPtr != boost::shared_ptr<ICompAssembly>()) { - int nChild = CompAssemPtr->nelements(); - for (int i = 0; i < nChild; i++) { - boost::shared_ptr<IComponent> ChildCompPtr = (*CompAssemPtr)[i]; - boost::shared_ptr<ICompAssembly> ChildCAPtr = - boost::dynamic_pointer_cast<ICompAssembly>(ChildCompPtr); - - // If the child is a CompAssembly then create a CompAssemblyActor for the - // child - if (ChildCAPtr) { - boost::shared_ptr<ObjCompAssembly> ChildOCAPtr = - boost::dynamic_pointer_cast<ObjCompAssembly>(ChildCompPtr); - boost::shared_ptr<RectangularDetector> ChildRDPtr = - boost::dynamic_pointer_cast<RectangularDetector>(ChildCompPtr); - boost::shared_ptr<StructuredDetector> ChildSDPtr = - boost::dynamic_pointer_cast<StructuredDetector>(ChildCompPtr); - - if (ChildSDPtr) { - StructuredDetectorActor *iActor = new StructuredDetectorActor( - instrActor, ChildSDPtr->getComponentID()); - iActor->getBoundingBox(minBound, maxBound); - AppendBoundingBox(minBound, maxBound); - mNumberOfDetectors += iActor->getNumberOfDetectors(); - mChildCompAssemActors.push_back(iActor); - } else if (ChildRDPtr) { - // If the child is a RectangularDetector, then create a - // RectangularDetectorActor for it. - RectangularDetectorActor *iActor = new RectangularDetectorActor( - instrActor, ChildCAPtr->getComponentID()); - iActor->getBoundingBox(minBound, maxBound); - AppendBoundingBox(minBound, maxBound); - mNumberOfDetectors += iActor->getNumberOfDetectors(); - mChildCompAssemActors.push_back(iActor); - } else if (ChildOCAPtr) { - ObjCompAssemblyActor *iActor = new ObjCompAssemblyActor( - instrActor, ChildCAPtr->getComponentID()); - iActor->getBoundingBox(minBound, maxBound); - AppendBoundingBox(minBound, maxBound); - mNumberOfDetectors += iActor->getNumberOfDetectors(); - mChildCompAssemActors.push_back(iActor); - } else { - CompAssemblyActor *iActor = - new CompAssemblyActor(instrActor, ChildCAPtr->getComponentID()); - iActor->getBoundingBox(minBound, maxBound); - AppendBoundingBox(minBound, maxBound); - mNumberOfDetectors += iActor->getNumberOfDetectors(); - mChildCompAssemActors.push_back(iActor); - } - } else // it has to be a ObjComponent child, create a ObjComponentActor - // for the child use the same display list attribute - { - boost::shared_ptr<Mantid::Geometry::IObjComponent> ChildObjPtr = - boost::dynamic_pointer_cast<Mantid::Geometry::IObjComponent>( - ChildCompPtr); - ObjComponentActor *iActor = - new ObjComponentActor(instrActor, ChildCompPtr->getComponentID()); - iActor->getBoundingBox(minBound, maxBound); - AppendBoundingBox(minBound, maxBound); - mChildObjCompActors.push_back(iActor); - mNumberOfDetectors++; - } - } - } -} - -/** -* Destructor which removes the actors created by this object -*/ -CompAssemblyActor::~CompAssemblyActor() { - // Remove all the child CompAssembly Actors - for (std::vector<ICompAssemblyActor *>::iterator iAssem = - mChildCompAssemActors.begin(); - iAssem != mChildCompAssemActors.end(); ++iAssem) - delete (*iAssem); - mChildCompAssemActors.clear(); - // Remove all the child ObjComponent Actors - for (std::vector<ObjComponentActor *>::iterator iObjComp = - mChildObjCompActors.begin(); - iObjComp != mChildObjCompActors.end(); ++iObjComp) - delete (*iObjComp); - mChildObjCompActors.clear(); -} - -/** -* This function is concrete implementation that renders the Child ObjComponents -* and Child CompAssembly's -*/ -void CompAssemblyActor::draw(bool picking) const { - OpenGLError::check("CompAssemblyActor::draw(0)"); - // Only draw the CompAssembly Children only if they are visible - if (isVisible()) { - // Iterate through the ObjCompActor children and draw them - for (std::vector<ObjComponentActor *>::iterator itrObjComp = - mChildObjCompActors.begin(); - itrObjComp != mChildObjCompActors.end(); ++itrObjComp) { - // Only draw the ObjCompActor if its visible - if ((*itrObjComp)->isVisible()) { - // std::cout << (*itrObjComp)->getName() << " is gonna draw. From - // define()\n"; - (*itrObjComp)->draw(picking); - OpenGLError::check("draw " + (*itrObjComp)->getComponent()->getName()); - } else { - // std::cout << (*itrObjComp)->getName() << " is not visible\n"; - } - } - // Iterate through the CompAssemblyActor children and draw them - for (std::vector<ICompAssemblyActor *>::iterator itrObjAssem = - mChildCompAssemActors.begin(); - itrObjAssem != mChildCompAssemActors.end(); ++itrObjAssem) { - if ((*itrObjAssem)->isVisible()) { - // std::cout << (*itrObjAssem)->getName() << " is gonna draw. From - // define()\n"; - (*itrObjAssem)->draw(picking); - } - } - } else { - // std::cout << this->getName() << " is not visible\n"; - } - OpenGLError::check("CompAssemblyActor::draw()"); -} - -bool CompAssemblyActor::accept(GLActorVisitor &visitor, - VisitorAcceptRule rule) { - for (std::vector<ObjComponentActor *>::iterator itrObjComp = - mChildObjCompActors.begin(); - itrObjComp != mChildObjCompActors.end(); ++itrObjComp) { - if ((**itrObjComp).accept(visitor, rule) && rule == Finish) - return true; - } - for (std::vector<ICompAssemblyActor *>::iterator itrObjAssem = - mChildCompAssemActors.begin(); - itrObjAssem != mChildCompAssemActors.end(); ++itrObjAssem) { - if ((**itrObjAssem).accept(visitor, rule) && rule == Finish) - return true; - } - return visitor.visit(this); -} - -bool CompAssemblyActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule rule) const { - for (std::vector<ObjComponentActor *>::iterator itrObjComp = - mChildObjCompActors.begin(); - itrObjComp != mChildObjCompActors.end(); ++itrObjComp) { - if ((**itrObjComp).accept(visitor, rule) && rule == Finish) - return true; - } - for (std::vector<ICompAssemblyActor *>::iterator itrObjAssem = - mChildCompAssemActors.begin(); - itrObjAssem != mChildCompAssemActors.end(); ++itrObjAssem) { - if ((**itrObjAssem).accept(visitor, rule) && rule == Finish) - return true; - } - return visitor.visit(this); -} - -//------------------------------------------------------------------------------------------------ -/** -* Append the bounding box CompAssembly bounding box -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void CompAssemblyActor::AppendBoundingBox(const Mantid::Kernel::V3D &minBound, - const Mantid::Kernel::V3D &maxBound) { - if (minBoundBox[0] > minBound[0]) - minBoundBox[0] = minBound[0]; - if (minBoundBox[1] > minBound[1]) - minBoundBox[1] = minBound[1]; - if (minBoundBox[2] > minBound[2]) - minBoundBox[2] = minBound[2]; - if (maxBoundBox[0] < maxBound[0]) - maxBoundBox[0] = maxBound[0]; - if (maxBoundBox[1] < maxBound[1]) - maxBoundBox[1] = maxBound[1]; - if (maxBoundBox[2] < maxBound[2]) - maxBoundBox[2] = maxBound[2]; -} - -void CompAssemblyActor::setColors() { - for (std::vector<ICompAssemblyActor *>::iterator iAssem = - mChildCompAssemActors.begin(); - iAssem != mChildCompAssemActors.end(); ++iAssem) { - (**iAssem).setColors(); - } - for (std::vector<ObjComponentActor *>::iterator iObjComp = - mChildObjCompActors.begin(); - iObjComp != mChildObjCompActors.end(); ++iObjComp) { - (**iObjComp).setColors(); - } -} - -void CompAssemblyActor::setChildVisibility(bool on) { - GLActor::setVisibility(on); - for (std::vector<ObjComponentActor *>::iterator itrObjComp = - mChildObjCompActors.begin(); - itrObjComp != mChildObjCompActors.end(); ++itrObjComp) { - (**itrObjComp).setVisibility(on); - } - for (std::vector<ICompAssemblyActor *>::iterator itrObjAssem = - mChildCompAssemActors.begin(); - itrObjAssem != mChildCompAssemActors.end(); ++itrObjAssem) { - (**itrObjAssem).setChildVisibility(on); - } -} - -bool CompAssemblyActor::hasChildVisible() const { - for (std::vector<ObjComponentActor *>::iterator itrObjComp = - mChildObjCompActors.begin(); - itrObjComp != mChildObjCompActors.end(); ++itrObjComp) { - if ((**itrObjComp).isVisible()) - return true; - } - for (std::vector<ICompAssemblyActor *>::iterator itrObjAssem = - mChildCompAssemActors.begin(); - itrObjAssem != mChildCompAssemActors.end(); ++itrObjAssem) { - if ((**itrObjAssem).hasChildVisible()) - return true; - } - return false; -} - -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/ComponentActor.cpp b/qt/widgets/instrumentview/src/ComponentActor.cpp deleted file mode 100644 index 36a0b1108b96c3118e0d99df4768684d082dcdab..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/ComponentActor.cpp +++ /dev/null @@ -1,76 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/ComponentActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" - -#include "MantidGeometry/Instrument.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/Instrument/ObjCompAssembly.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidGeometry/Instrument/CompAssembly.h" - -using namespace Mantid; -using namespace Geometry; - -namespace MantidQt { -namespace MantidWidgets { -ComponentActor::ComponentActor(const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID) - : GLActor(), m_instrActor(instrActor), m_id(compID) {} - -bool ComponentActor::accept(GLActorVisitor &visitor, - GLActor::VisitorAcceptRule) { - return visitor.visit(this); -} - -bool ComponentActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule) const { - return visitor.visit(this); -} - -boost::shared_ptr<const Mantid::Geometry::IComponent> -ComponentActor::getComponent() const { - return m_instrActor.getInstrument()->getComponentByID(m_id); -} - -boost::shared_ptr<const Mantid::Geometry::IObjComponent> -ComponentActor::getObjComponent() const { - return boost::dynamic_pointer_cast<const Mantid::Geometry::IObjComponent>( - getComponent()); -} - -boost::shared_ptr<const Mantid::Geometry::IDetector> -ComponentActor::getDetector() const { - return boost::dynamic_pointer_cast<const Mantid::Geometry::IDetector>( - getComponent()); -} - -boost::shared_ptr<const Mantid::Geometry::ObjCompAssembly> -ComponentActor::getObjCompAssembly() const { - return boost::dynamic_pointer_cast<const Mantid::Geometry::ObjCompAssembly>( - getComponent()); -} - -boost::shared_ptr<const Mantid::Geometry::CompAssembly> -ComponentActor::getCompAssembly() const { - return boost::dynamic_pointer_cast<const Mantid::Geometry::CompAssembly>( - getComponent()); -} - -/** -* A component is a non-detector if it's an ObjComponent (has a shape) and not an -ObjCompAssembly -* (a single object) and not a RectangularDetector (which is an assembly) or a -StructuredDetector -(which is an assembly). -*/ -bool ComponentActor::isNonDetector() const { - auto obj = getObjComponent(); - return obj && !getObjCompAssembly() && !getDetector() && - !boost::dynamic_pointer_cast< - const Mantid::Geometry::RectangularDetector>(obj) && - !boost::dynamic_pointer_cast< - const Mantid::Geometry::StructuredDetector>(obj); -} - -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/DetXMLFile.cpp b/qt/widgets/instrumentview/src/DetXMLFile.cpp index ec8aefa181632f422dfa41f7995b128b8950987c..f4b6ab1853f670b5ff50ae6ef7897d1d890dc85e 100644 --- a/qt/widgets/instrumentview/src/DetXMLFile.cpp +++ b/qt/widgets/instrumentview/src/DetXMLFile.cpp @@ -21,7 +21,7 @@ DetXMLFile::DetXMLFile(const std::vector<int> &detector_list, m_delete = false; std::ofstream out(m_fileName.toStdString().c_str()); out << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \n<detector-grouping> \n"; - out << "<group name=\"sum\"> <detids val=\""; + out << R"(<group name="sum"> <detids val=")"; std::vector<int>::const_iterator idet = detector_list.begin(); for (; idet != detector_list.end(); ++idet) { if (!exclude.contains(*idet)) { @@ -82,7 +82,7 @@ void DetXMLFile::makeListFile(const QList<int> &dets) { void DetXMLFile::makeSumFile(const QList<int> &dets) { std::ofstream out(m_fileName.toStdString().c_str()); out << "<?xml version=\"1.0\" encoding=\"UTF-8\" ?> \n<detector-grouping> \n"; - out << "<group name=\"sum\"> <detids val=\""; + out << R"(<group name="sum"> <detids val=")"; foreach (int det, dets) { out << det << ','; } out << "\"/> </group> \n</detector-grouping>\n"; } diff --git a/qt/widgets/instrumentview/src/GLActor.cpp b/qt/widgets/instrumentview/src/GLActor.cpp deleted file mode 100644 index 452855bcafe0f666ccb6fbdd0e5d6876eccbe9f9..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/GLActor.cpp +++ /dev/null @@ -1,56 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/GLActor.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" - -namespace MantidQt { -namespace MantidWidgets { -GLActor::~GLActor() {} - -void GLActor::setVisibility(bool on) { - if (m_visible == GLActorVisiblity::ALWAYS_HIDDEN) { - // If we are always hidden do not change the visibility - return; - } - if (on) { - m_visible = GLActorVisiblity::VISIBLE; - } else { - m_visible = GLActorVisiblity::HIDDEN; - } -} - -bool GLActor::accept(GLActorVisitor &visitor, VisitorAcceptRule) { - return visitor.visit(this); -} - -bool GLActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule) const { - return visitor.visit(this); -} - -GLColor GLActor::makePickColor(size_t pickID) { - pickID += 1; - unsigned char r, g, b; - r = (unsigned char)(pickID / 65536); - g = (unsigned char)((pickID % 65536) / 256); - b = (unsigned char)((pickID % 65536) % 256); - return GLColor(r, g, b); -} - -size_t GLActor::decodePickColor(const QRgb &c) { - return decodePickColor((unsigned char)qRed(c), (unsigned char)qGreen(c), - (unsigned char)qBlue(c)); -} - -size_t GLActor::decodePickColor(unsigned char r, unsigned char g, - unsigned char b) { - unsigned int index = r; - index *= 256; - index += g; - index *= 256; - index += b - 1; - return index; -} - -GLColor GLActor::defaultDetectorColor() { return GLColor(200, 200, 200); } - -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/GLActorCollection.cpp b/qt/widgets/instrumentview/src/GLActorCollection.cpp deleted file mode 100644 index 4e092285e6ed4f53ab9e810bed9524605c236557..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/GLActorCollection.cpp +++ /dev/null @@ -1,178 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/GLActorCollection.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" -#include "MantidQtWidgets/InstrumentView/OpenGLError.h" - -#include "MantidKernel/Exception.h" - -#include <algorithm> -#include <cfloat> -#include <functional> -#include <stdexcept> - -namespace MantidQt { -namespace MantidWidgets { -GLActorCollection::GLActorCollection() - : GLActor(), m_minBound(DBL_MAX, DBL_MAX, DBL_MAX), - m_maxBound(-DBL_MAX, -DBL_MAX, -DBL_MAX) { - m_displayListId[0] = 0; - m_displayListId[1] = 0; - m_useDisplayList[0] = false; - m_useDisplayList[1] = false; -} - -GLActorCollection::~GLActorCollection() { - for (std::vector<GLActor *>::iterator i = mActorsList.begin(); - i != mActorsList.end(); ++i) { - delete (*i); - } - mActorsList.clear(); - for (size_t i = 0; i < 2; ++i) { - if (m_displayListId[i] != 0) { - glDeleteLists(m_displayListId[i], 1); - } - } -} - -/** -* This method does the drawing by calling the list of actors to draw themselfs -*/ -void GLActorCollection::draw(bool picking) const { - if (!isVisible()) - return; - OpenGLError::check("GLActorCollection::draw(0)"); - size_t i = picking ? 1 : 0; - if (m_useDisplayList[i]) { - glCallList(m_displayListId[i]); - } else if (m_displayListId[i] == 0) { - m_displayListId[i] = glGenLists(1); - // child actors can also create display lists, so delay - // until all the children have finished making theirs - drawGL(picking); - } else { - m_useDisplayList[i] = true; - glNewList(m_displayListId[i], - GL_COMPILE); // Construct display list for object representation - drawGL(picking); - glEndList(); - if (glGetError() == GL_OUT_OF_MEMORY) // Throw an exception - throw Mantid::Kernel::Exception::OpenGLError( - "OpenGL: Out of video memory"); - glCallList(m_displayListId[i]); - } - OpenGLError::check("GLActorCollection::draw()"); -} - -void GLActorCollection::drawGL(bool picking) const { - for (std::vector<GLActor *>::const_iterator it = mActorsList.begin(); - it != mActorsList.end(); ++it) { - (**it).draw(picking); - } -} - -bool GLActorCollection::accept(GLActorVisitor &visitor, - VisitorAcceptRule rule) { - for (std::vector<GLActor *>::const_iterator it = mActorsList.begin(); - it != mActorsList.end(); ++it) { - if ((**it).accept(visitor, rule) && rule == Finish) - return true; - } - return visitor.visit(this); -} - -bool GLActorCollection::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule rule) const { - for (std::vector<GLActor *>::const_iterator it = mActorsList.begin(); - it != mActorsList.end(); ++it) { - if ((**it).accept(visitor, rule) && rule == Finish) - return true; - } - return visitor.visit(this); -} - -/** -* This method addes a new actor to the collection. -* @param a :: input actor to be added to the list -*/ -void GLActorCollection::addActor(GLActor *a) { - if (!a) { - return; - } - mActorsList.push_back(a); - Mantid::Kernel::V3D minBound; - Mantid::Kernel::V3D maxBound; - a->getBoundingBox(minBound, maxBound); - if (m_minBound[0] > minBound[0]) - m_minBound[0] = minBound[0]; - if (m_minBound[1] > minBound[1]) - m_minBound[1] = minBound[1]; - if (m_minBound[2] > minBound[2]) - m_minBound[2] = minBound[2]; - if (m_maxBound[0] < maxBound[0]) - m_maxBound[0] = maxBound[0]; - if (m_maxBound[1] < maxBound[1]) - m_maxBound[1] = maxBound[1]; - if (m_maxBound[2] < maxBound[2]) - m_maxBound[2] = maxBound[2]; -} - -/** -* Remove the input actor from the collection -* @param :: input actor to be removed from the list -*/ -void GLActorCollection::removeActor(GLActor *) { - throw std::runtime_error("Removing actor not implemented"); -} - -/** -* This method returns the number of actors in the collection -* @return integer value of number of actors in collection -*/ -int GLActorCollection::getNumberOfActors() { - return static_cast<int>(mActorsList.size()); -} - -/** -* This method returns the actor at the given index -* @param index :: is the index in actor collection to be returned -* @return a pointer to the actor at a given index -*/ -GLActor *GLActorCollection::getActor(int index) { - if (index < 0 || index > static_cast<int>(mActorsList.size())) - return nullptr; - return mActorsList.at(index); -} - -void GLActorCollection::getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const { - minBound = m_minBound; - maxBound = m_maxBound; -} - -void GLActorCollection::invalidateDisplayList() const { - for (size_t i = 0; i < 2; ++i) { - if (m_displayListId[i] != 0) { - glDeleteLists(m_displayListId[i], 1); - m_displayListId[i] = 0; - m_useDisplayList[i] = false; - } - } -} - -void GLActorCollection::setChildVisibility(bool on) { - GLActor::setVisibility(on); - for (std::vector<GLActor *>::const_iterator it = mActorsList.begin(); - it != mActorsList.end(); ++it) { - (**it).setChildVisibility(on); - } -} - -bool GLActorCollection::hasChildVisible() const { - for (std::vector<GLActor *>::const_iterator it = mActorsList.begin(); - it != mActorsList.end(); ++it) { - if ((**it).hasChildVisible()) - return true; - } - return false; -} -} -} diff --git a/qt/widgets/instrumentview/src/GLActorVisitor.cpp b/qt/widgets/instrumentview/src/GLActorVisitor.cpp deleted file mode 100644 index 176bd6992502b34b00345e82e9f69ee61df8a78d..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/GLActorVisitor.cpp +++ /dev/null @@ -1,82 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" -#include "MantidQtWidgets/InstrumentView/GLActor.h" -#include "MantidQtWidgets/InstrumentView/GLActorCollection.h" -#include "MantidQtWidgets/InstrumentView/ComponentActor.h" -#include "MantidQtWidgets/InstrumentView/CompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/RectangularDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/StructuredDetectorActor.h" - -namespace MantidQt { -namespace MantidWidgets { -// Default visit implementations just call visit(GLActor*) - -bool GLActorVisitor::visit(GLActorCollection *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(CompAssemblyActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(ObjCompAssemblyActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(ComponentActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(InstrumentActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(RectangularDetectorActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorVisitor::visit(StructuredDetectorActor *actor) { - return this->visit(static_cast<GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const GLActorCollection *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const CompAssemblyActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const ObjCompAssemblyActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const ComponentActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const InstrumentActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const RectangularDetectorActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool GLActorConstVisitor::visit(const StructuredDetectorActor *actor) { - return this->visit(static_cast<const GLActor *>(actor)); -} - -bool SetAllVisibleVisitor::visit(GLActor *actor) { - actor->setVisibility(true); - return true; -} - -bool SetAllVisibleVisitor::visit(ComponentActor *actor) { - bool on = (!actor->isNonDetector()) || m_showNonDet; - actor->setVisibility(on); - return true; -} -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/GLColor.cpp b/qt/widgets/instrumentview/src/GLColor.cpp index 37b30138a1ae20baf3c9da5fcd38d2824dce99fe..7a31a62fa863c355bd164dd1c7fe929c29b9c104 100644 --- a/qt/widgets/instrumentview/src/GLColor.cpp +++ b/qt/widgets/instrumentview/src/GLColor.cpp @@ -24,11 +24,11 @@ GLColor::GLColor(float red, float green, float blue, float alpha) { m_rgba[3] = (unsigned char)(alpha * 255); } -GLColor::GLColor(int r, int g, int b) { +GLColor::GLColor(int r, int g, int b, int a) { m_rgba[0] = (unsigned char)r; m_rgba[1] = (unsigned char)g; m_rgba[2] = (unsigned char)b; - m_rgba[3] = 255; + m_rgba[3] = (unsigned char)a; } /** diff --git a/qt/widgets/instrumentview/src/GLObject.cpp b/qt/widgets/instrumentview/src/GLObject.cpp index a4eb4a7838bfc8ec2d09bcddd3dfb4732be40da2..c071256d77372ba82604fa40cc56d4eedcca4496 100644 --- a/qt/widgets/instrumentview/src/GLObject.cpp +++ b/qt/widgets/instrumentview/src/GLObject.cpp @@ -2,7 +2,6 @@ #include <windows.h> #endif #include "MantidQtWidgets/InstrumentView/GLObject.h" -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" #include "MantidKernel/Exception.h" #include "MantidKernel/System.h" diff --git a/qt/widgets/instrumentview/src/ICompAssemblyActor.cpp b/qt/widgets/instrumentview/src/ICompAssemblyActor.cpp deleted file mode 100644 index 6c8d90c69eb0a6d01194675ceb4fa0be4d430de6..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/ICompAssemblyActor.cpp +++ /dev/null @@ -1,36 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/ICompAssemblyActor.h" -#include <cfloat> - -#include "MantidKernel/V3D.h" -#include "MantidGeometry/IComponent.h" - -using namespace Mantid; -using namespace Geometry; - -namespace MantidQt { -namespace MantidWidgets { -/** -* This is a constructor for CompAssembly Actor -* @param instrActor :: the instrument actor -* @param compID :: the component ID -*/ -ICompAssemblyActor::ICompAssemblyActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID) - : ComponentActor(instrActor, compID), mNumberOfDetectors(0), - minBoundBox(DBL_MAX, DBL_MAX, DBL_MAX), - maxBoundBox(-DBL_MAX, -DBL_MAX, -DBL_MAX) {} - -//------------------------------------------------------------------------------------------------ -/** -* Return the bounding box -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void ICompAssemblyActor::getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const { - minBound = minBoundBox; - maxBound = maxBoundBox; -} -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/InstrumentActor.cpp b/qt/widgets/instrumentview/src/InstrumentActor.cpp index 633e33f7c1cec4097bce89cab0f45fc10e793059..6fa546621457812d4a210e71104c9f6988293fce 100644 --- a/qt/widgets/instrumentview/src/InstrumentActor.cpp +++ b/qt/widgets/instrumentview/src/InstrumentActor.cpp @@ -1,12 +1,7 @@ #include "MantidQtWidgets/InstrumentView/InstrumentActor.h" #include "MantidQtWidgets/Common/TSVSerialiser.h" -#include "MantidQtWidgets/InstrumentView/CompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/ComponentActor.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/RectangularDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/StructuredDetectorActor.h" +#include "MantidQtWidgets/InstrumentView/InstrumentRenderer.h" +#include "MantidQtWidgets/InstrumentView/OpenGLError.h" #include "MantidAPI/AnalysisDataService.h" #include "MantidAPI/CommonBinsValidator.h" @@ -15,10 +10,13 @@ #include "MantidAPI/IMaskWorkspace.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/SpectrumInfo.h" +#include "MantidTypes/SpectrumDefinition.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Instrument/InstrumentVisitor.h" #include "MantidKernel/ConfigService.h" #include "MantidKernel/Exception.h" @@ -31,6 +29,7 @@ #include <QMessageBox> #include <QSettings> +#include <limits> #include <numeric> using namespace Mantid::Kernel::Exception; @@ -40,115 +39,120 @@ using namespace Mantid; namespace MantidQt { namespace MantidWidgets { +namespace { +bool isPhysicalView() { + std::string view = Mantid::Kernel::ConfigService::Instance().getString( + "instrument.view.geometry"); + + return boost::iequals("Default", view) || boost::iequals("Physical", view); +} -/// to be used in std::transform -struct Sqrt { - double operator()(double x) { return sqrt(x); } -}; +} // namespace +const size_t InstrumentActor::INVALID_INDEX = + std::numeric_limits<size_t>::max(); double InstrumentActor::m_tolerance = 0.00001; /** -* Constructor. Creates a tree of GLActors. Each actor is responsible for -* displaying insrument components in 3D. -* Some of the components have "pick ID" assigned to them. Pick IDs can be -* uniquely converted to a RGB colour value -* which in turn can be used for picking the component from the screen. -* @param wsName :: Workspace name -* @param autoscaling :: True to start with autoscaling option on. If on the min -* and max of -* the colormap scale are defined by the min and max of the data. -* @param scaleMin :: Minimum value of the colormap scale. Used to assign -* detector colours. Ignored if autoscaling == true. -* @param scaleMax :: Maximum value of the colormap scale. Used to assign -* detector colours. Ignored if autoscaling == true. -*/ + * Constructor. Creates a tree of GLActors. Each actor is responsible for + * displaying insrument components in 3D. + * Some of the components have "pick ID" assigned to them. Pick IDs can be + * uniquely converted to a RGB colour value + * which in turn can be used for picking the component from the screen. + * @param wsName :: Workspace name + * @param autoscaling :: True to start with autoscaling option on. If on the min + * and max of + * the colormap scale are defined by the min and max of the data. + * @param scaleMin :: Minimum value of the colormap scale. Used to assign + * detector colours. Ignored if autoscaling == true. + * @param scaleMax :: Maximum value of the colormap scale. Used to assign + * detector colours. Ignored if autoscaling == true. + */ InstrumentActor::InstrumentActor(const QString &wsName, bool autoscaling, double scaleMin, double scaleMax) : m_workspace(AnalysisDataService::Instance().retrieveWS<MatrixWorkspace>( wsName.toStdString())), m_ragged(true), m_autoscaling(autoscaling), m_defaultPos(), - m_maskedColor(100, 100, 100), m_failedColor(200, 200, 200) { + m_isPhysicalInstrument(false) { // settings loadSettings(); auto sharedWorkspace = m_workspace.lock(); + if (!sharedWorkspace) throw std::logic_error( "InstrumentActor passed a workspace that isn't a MatrixWorkspace"); + setupPhysicalInstrumentIfExists(); + + for (size_t i = 0; i < componentInfo().size(); ++i) { + if (!componentInfo().isDetector(i)) + m_components.push_back(i); + else if (detectorInfo().isMonitor(i)) + m_monitors.push_back(i); + } + + m_isCompVisible.assign(componentInfo().size(), true); + + m_renderer.reset(new InstrumentRenderer(*this)); + m_renderer->changeScaleType(m_scaleType); // set up the color map if (!m_currentColorMapFilename.isEmpty()) { loadColorMap(m_currentColorMapFilename, false); } - m_colorMap.changeScaleType(m_scaleType); // set up data ranges and colours setUpWorkspace(sharedWorkspace, scaleMin, scaleMax); - Instrument_const_sptr instrument = getInstrument(); - // If the instrument is empty, maybe only having the sample and source - const int nelements = instrument->nelements(); - if ((nelements == 0) || (nelements == 1 && (instrument->getSource() || - instrument->getSample())) || - (nelements == 2 && instrument->getSource() && instrument->getSample())) { + if (detectorInfo().size() == 0) { QMessageBox::warning(nullptr, "MantidPlot - Warning", "This instrument appears to contain no detectors", "OK"); } - - // this adds actors for all instrument components to the scene and fills in - // m_detIDs - m_scene.addActor(new CompAssemblyActor(*this, instrument->getComponentID())); - setupPickColors(); - - if (!m_showGuides) { - // hide guide and other components - showGuides(m_showGuides); - } } /** -* Destructor -*/ + * Destructor + */ InstrumentActor::~InstrumentActor() { saveSettings(); } /** -* Set up the workspace: calculate the value ranges, set the colours. -* @param sharedWorkspace :: A shared pointer to the workspace. -* @param scaleMin :: Minimum limit on the color map axis. If autoscale this -* value is ignored. -* @param scaleMax :: Maximum limit on the color map axis. If autoscale this -* value is ignored. -*/ + * Set up the workspace: calculate the value ranges, set the colours. + * @param sharedWorkspace :: A shared pointer to the workspace. + * @param scaleMin :: Minimum limit on the color map axis. If autoscale this + * value is ignored. + * @param scaleMax :: Maximum limit on the color map axis. If autoscale this + * value is ignored. + */ void InstrumentActor::setUpWorkspace( boost::shared_ptr<const Mantid::API::MatrixWorkspace> sharedWorkspace, double scaleMin, double scaleMax) { - const size_t nHist = sharedWorkspace->getNumberHistograms(); m_WkspBinMinValue = DBL_MAX; m_WkspBinMaxValue = -DBL_MAX; - for (size_t i = 0; i < nHist; ++i) { - const auto &values = sharedWorkspace->x(i); + const auto &spectrumInfo = sharedWorkspace->spectrumInfo(); + m_detIndex2WsIndex.resize(componentInfo().size(), INVALID_INDEX); + for (size_t wi = 0; wi < spectrumInfo.size(); ++wi) { + const auto &values = sharedWorkspace->x(wi); double xtest = values.front(); if (!std::isinf(xtest)) { - if (xtest < m_WkspBinMinValue) { + if (xtest < m_WkspBinMinValue) m_WkspBinMinValue = xtest; - } else if (xtest > m_WkspBinMaxValue) { + else if (xtest > m_WkspBinMaxValue) m_WkspBinMaxValue = xtest; - } else { - } } xtest = values.back(); if (!std::isinf(xtest)) { - if (xtest < m_WkspBinMinValue) { + if (xtest < m_WkspBinMinValue) m_WkspBinMinValue = xtest; - } else if (xtest > m_WkspBinMaxValue) { + else if (xtest > m_WkspBinMaxValue) m_WkspBinMaxValue = xtest; - } else { - } } + + const auto &specDef = spectrumInfo.spectrumDefinition(wi); + for (auto info : specDef) + m_detIndex2WsIndex[info.first] = wi; } // set some values as the variables will be used @@ -156,54 +160,57 @@ void InstrumentActor::setUpWorkspace( m_DataMinValue = -DBL_MAX; m_DataMaxValue = DBL_MAX; - if (!m_autoscaling) { + if (!m_autoscaling) setDataMinMaxRange(scaleMin, scaleMax); - } + setDataIntegrationRange(m_WkspBinMinValue, m_WkspBinMaxValue); resetColors(); // set the ragged flag using a workspace validator auto wsValidator = Mantid::API::CommonBinsValidator(); m_ragged = !wsValidator.isValid(sharedWorkspace).empty(); - - /// Keep the pointer to the detid2index map - m_detid2index_map = sharedWorkspace->getDetectorIDToWorkspaceIndexMap(); } -/** Used to set visibility of an actor corresponding to a particular component -* When selecting a component in the InstrumentTreeWidget -* -* @param visitor :: Visitor to be accepted bu this actor. -* @param rule :: A rule defining visitor acceptance by assembly actors. -*/ -bool InstrumentActor::accept(GLActorVisitor &visitor, VisitorAcceptRule rule) { - bool ok = m_scene.accept(visitor, rule); - visitor.visit(this); - invalidateDisplayLists(); - return ok; +void InstrumentActor::setupPhysicalInstrumentIfExists() { + if (!isPhysicalView()) + return; + + auto sharedWorkspace = getWorkspace(); + Mantid::Kernel::ReadLock _lock(*sharedWorkspace); + + auto instr = sharedWorkspace->getInstrument()->getPhysicalInstrument(); + if (instr) { + auto infos = InstrumentVisitor::makeWrappers(*instr); + m_physicalComponentInfo = std::move(infos.first); + m_physicalDetectorInfo = std::move(infos.second); + m_isPhysicalInstrument = true; + } } -bool InstrumentActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule rule) const { - bool ok = m_scene.accept(visitor, rule); - visitor.visit(this); - return ok; +void InstrumentActor::setComponentVisible(size_t componentIndex) { + setChildVisibility(false); + const auto &compInfo = componentInfo(); + auto children = compInfo.componentsInSubtree(componentIndex); + m_isCompVisible[componentIndex] = true; + for (auto child : children) + m_isCompVisible[child] = true; + + resetColors(); } void InstrumentActor::setChildVisibility(bool on) { - m_scene.setChildVisibility(on); - auto guidesVisitor = SetVisibleNonDetectorVisitor(m_showGuides); - m_scene.accept(guidesVisitor); + std::fill(m_isCompVisible.begin(), m_isCompVisible.end(), on); } bool InstrumentActor::hasChildVisible() const { - return m_scene.hasChildVisible(); + return std::any_of(m_isCompVisible.begin(), m_isCompVisible.end(), + [](bool visible) { return visible; }); } /** Returns the workspace relating to this instrument view. -* !!!! DON'T USE THIS TO GET HOLD OF THE INSTRUMENT !!!! -* !!!! USE InstrumentActor::getInstrument() BELOW !!!! -*/ + * !!!! DON'T USE THIS TO GET HOLD OF THE INSTRUMENT !!!! + * !!!! USE InstrumentActor::getInstrument() BELOW !!!! + */ MatrixWorkspace_const_sptr InstrumentActor::getWorkspace() const { auto sharedWorkspace = m_workspace.lock(); @@ -214,9 +221,17 @@ MatrixWorkspace_const_sptr InstrumentActor::getWorkspace() const { return sharedWorkspace; } +void InstrumentActor::getBoundingBox(Mantid::Kernel::V3D &minBound, + Mantid::Kernel::V3D &maxBound) const { + const auto &compInfo = componentInfo(); + auto bb = compInfo.boundingBox(compInfo.root()); + minBound = bb.minPoint(); + maxBound = bb.maxPoint(); +} + /** Returns the mask workspace relating to this instrument view as a * MatrixWorkspace -*/ + */ MatrixWorkspace_sptr InstrumentActor::getMaskMatrixWorkspace() const { if (!m_maskWorkspace) { initMaskHelper(); @@ -225,7 +240,7 @@ MatrixWorkspace_sptr InstrumentActor::getMaskMatrixWorkspace() const { } /** set the mask workspace -*/ + */ void InstrumentActor::setMaskMatrixWorkspace( MatrixWorkspace_sptr wsMask) const { m_maskWorkspace = wsMask; @@ -252,10 +267,10 @@ void InstrumentActor::invertMaskWorkspace() const { } /** -* Returns the mask workspace relating to this instrument view as a -* IMaskWorkspace. -* Guarantees to return a valid pointer -*/ + * Returns the mask workspace relating to this instrument view as a + * IMaskWorkspace. + * Guarantees to return a valid pointer + */ IMaskWorkspace_sptr InstrumentActor::getMaskWorkspace() const { if (!m_maskWorkspace) { initMaskHelper(); @@ -264,10 +279,10 @@ IMaskWorkspace_sptr InstrumentActor::getMaskWorkspace() const { } /** -* Returns the mask workspace relating to this instrument view as a -* IMaskWorkspace -* if it exists or empty pointer if it doesn't. -*/ + * Returns the mask workspace relating to this instrument view as a + * IMaskWorkspace + * if it exists or empty pointer if it doesn't. + */ IMaskWorkspace_sptr InstrumentActor::getMaskWorkspaceIfExists() const { if (!m_maskWorkspace) return IMaskWorkspace_sptr(); @@ -275,8 +290,8 @@ IMaskWorkspace_sptr InstrumentActor::getMaskWorkspaceIfExists() const { } /** -* Apply mask stored in the helper mask workspace to the data workspace. -*/ + * Apply mask stored in the helper mask workspace to the data workspace. + */ void InstrumentActor::applyMaskWorkspace() { auto wsName = getWorkspace()->getName(); if (m_maskWorkspace) { @@ -304,8 +319,8 @@ void InstrumentActor::applyMaskWorkspace() { } /** -* Removes the mask workspace. -*/ + * Removes the mask workspace. + */ void InstrumentActor::clearMasks() { bool needColorRecalc = false; if (m_maskWorkspace) { @@ -323,97 +338,79 @@ void InstrumentActor::clearMasks() { } } -Instrument_const_sptr InstrumentActor::getInstrument() const { - Instrument_const_sptr retval; - - // Look to see if we have set the property in the properties file - // to define our 'default' view - std::string view = Mantid::Kernel::ConfigService::Instance().getString( - "instrument.view.geometry"); +std::vector<size_t> InstrumentActor::getMonitors() const { return m_monitors; } +Instrument_const_sptr InstrumentActor::getInstrument() const { auto sharedWorkspace = getWorkspace(); Mantid::Kernel::ReadLock _lock(*sharedWorkspace); - if (boost::iequals("Default", view) || boost::iequals("Physical", view)) { + if (isPhysicalView()) { // First see if there is a 'physical' instrument available. Use it if there // is. - retval = sharedWorkspace->getInstrument()->getPhysicalInstrument(); - } else if (boost::iequals("Neutronic", view)) { - retval = sharedWorkspace->getInstrument(); + auto instr = sharedWorkspace->getInstrument()->getPhysicalInstrument(); + if (instr) + return instr; } - if (!retval) { - // Otherwise get hold of the 'main' instrument and use that - retval = sharedWorkspace->getInstrument(); - } - - return retval; + return sharedWorkspace->getInstrument(); } const MantidColorMap &InstrumentActor::getColorMap() const { - return m_colorMap; -} - -/// Get a detector reference given a pick ID. -const Mantid::Geometry::IDetector & -InstrumentActor::getDetectorByPickID(size_t pickID) const { - return getDetectorByDetID(m_detIDs.at(pickID)); + return m_renderer->getColorMap(); } -/// Get a reference to a detector by a detector ID. -const Mantid::Geometry::IDetector & -InstrumentActor::getDetectorByDetID(Mantid::detid_t detID) const { - const auto &detectorInfo = getWorkspace()->detectorInfo(); - auto detectorIndex = detectorInfo.indexOf(detID); - return detectorInfo.detector(detectorIndex); +size_t InstrumentActor::getDetectorByDetID(Mantid::detid_t detID) const { + const auto &detInfo = detectorInfo(); + return detInfo.indexOf(detID); } Mantid::detid_t InstrumentActor::getDetID(size_t pickID) const { - if (pickID < m_detIDs.size()) { - return m_detIDs[pickID]; + const auto &detInfo = detectorInfo(); + if (pickID < detInfo.size()) { + return detInfo.detectorIDs()[pickID]; } return -1; } +QList<Mantid::detid_t> +InstrumentActor::getDetIDs(const std::vector<size_t> &dets) const { + QList<Mantid::detid_t> detIDs; + detIDs.reserve(static_cast<int>(dets.size())); + for (auto det : dets) + detIDs.append(getDetID(det)); + return detIDs; +} + /** -* Get a component id of a picked component. -*/ + * Get a component id of a picked component. + */ Mantid::Geometry::ComponentID InstrumentActor::getComponentID(size_t pickID) const { - size_t ndet = m_detIDs.size(); auto compID = Mantid::Geometry::ComponentID(); - if (pickID < ndet) { - auto &det = getDetectorByPickID(m_detIDs[pickID]); - compID = det.getComponentID(); - } else if (pickID < ndet + m_nonDetIDs.size()) { - compID = m_nonDetIDs[pickID - ndet]; - } + const auto &compInfo = componentInfo(); + if (pickID < compInfo.size()) + compID = compInfo.componentID(pickID)->getComponentID(); return compID; } /** Retrieve the workspace index corresponding to a particular detector -* @param id The detector id -* @returns The workspace index containing data for this detector -* @throws Exception::NotFoundError If the detector is not represented in the -* workspace -*/ -size_t InstrumentActor::getWorkspaceIndex(Mantid::detid_t id) const { - auto mapEntry = m_detid2index_map.find(id); - if (mapEntry == m_detid2index_map.end()) { - throw Kernel::Exception::NotFoundError("Detector ID not in workspace", id); - } - - return mapEntry->second; + * @param index The detector index + * @returns The workspace index containing data for this detector + * @throws Exception::NotFoundError If the detector is not represented in the + * workspace + */ +size_t InstrumentActor::getWorkspaceIndex(size_t index) const { + return m_detIndex2WsIndex[index]; } /** -* Set an interval in the data workspace x-vector's units in which the data are -* to be -* integrated to calculate the detector colours. -* -* @param xmin :: The lower bound. -* @param xmax :: The upper bound. -*/ + * Set an interval in the data workspace x-vector's units in which the data are + * to be + * integrated to calculate the detector colours. + * + * @param xmin :: The lower bound. + * @param xmax :: The upper bound. + */ void InstrumentActor::setIntegrationRange(const double &xmin, const double &xmax) { setDataIntegrationRange(xmin, xmax); @@ -421,34 +418,32 @@ void InstrumentActor::setIntegrationRange(const double &xmin, } /** Gives the total signal in the spectrum relating to the given detector -* @param id The detector id -* @return The signal, or -1 if the detector is not represented in the workspace -*/ -double InstrumentActor::getIntegratedCounts(Mantid::detid_t id) const { - try { - size_t i = getWorkspaceIndex(id); - return m_specIntegrs.at(i); - } catch (NotFoundError &) { - // If the detector is not represented in the workspace + * @param index The detector index + * @return The signal + */ +double InstrumentActor::getIntegratedCounts(size_t index) const { + auto i = getWorkspaceIndex(index); + if (i == INVALID_INDEX) return -1.0; - } + return m_specIntegrs.at(i); } /** -* Sum counts in detectors for purposes of rough plotting against the units on -* the x-axis. -* Checks (approximately) if the workspace is ragged or not and uses the -* appropriate summation -* method. -* -* @param dets :: A list of detector IDs to sum. -* @param x :: (output) Time of flight values (or whatever values the x axis has) -* to plot against. -* @param y :: (output) The sums of the counts for each bin. -* @param size :: (optional input) Size of the output vectors. If not given it -* will be determined automatically. -*/ -void InstrumentActor::sumDetectors(QList<int> &dets, std::vector<double> &x, + * Sum counts in detectors for purposes of rough plotting against the units on + * the x-axis. + * Checks (approximately) if the workspace is ragged or not and uses the + * appropriate summation + * method. + * + * @param dets :: A list of detector Indices to sum. + * @param x :: (output) Time of flight values (or whatever values the x axis + * has) to plot against. + * @param y :: (output) The sums of the counts for each bin. + * @param size :: (optional input) Size of the output vectors. If not given it + * will be determined automatically. + */ +void InstrumentActor::sumDetectors(const std::vector<size_t> &dets, + std::vector<double> &x, std::vector<double> &y, size_t size) const { Mantid::API::MatrixWorkspace_const_sptr ws = getWorkspace(); if (size > ws->blocksize() || size == 0) { @@ -465,30 +460,25 @@ void InstrumentActor::sumDetectors(QList<int> &dets, std::vector<double> &x, } /** -* Sum counts in detectors for purposes of rough plotting against the units on -* the x-axis. -* Assumes that all spectra share the x vector. -* -* @param dets :: A list of detector IDs to sum. -* @param x :: (output) Time of flight values (or whatever values the x axis has) -* to plot against. -* @param y :: (output) The sums of the counts for each bin. -*/ -void InstrumentActor::sumDetectorsUniform(QList<int> &dets, + * Sum counts in detectors for purposes of rough plotting against the units on + * the x-axis. + * Assumes that all spectra share the x vector. + * + * @param dets :: A list of detector Indices to sum. + * @param x :: (output) Time of flight values (or whatever values the x axis + * has) to plot against. + * @param y :: (output) The sums of the counts for each bin. + */ +void InstrumentActor::sumDetectorsUniform(const std::vector<size_t> &dets, std::vector<double> &x, std::vector<double> &y) const { - size_t wi; - bool isDataEmpty = dets.isEmpty(); + bool isDataEmpty = dets.empty(); - if (!isDataEmpty) { - try { - wi = getWorkspaceIndex(dets[0]); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - isDataEmpty = - true; // Detector doesn't have a workspace index relating to it - } - } + auto wi = getWorkspaceIndex(dets[0]); + + if (wi == INVALID_INDEX) + isDataEmpty = true; if (isDataEmpty) { x.clear(); @@ -498,6 +488,7 @@ void InstrumentActor::sumDetectorsUniform(QList<int> &dets, // find the bins inside the integration range size_t imin, imax; + getBinMinMaxIndex(wi, imin, imax); Mantid::API::MatrixWorkspace_const_sptr ws = getWorkspace(); @@ -505,34 +496,32 @@ void InstrumentActor::sumDetectorsUniform(QList<int> &dets, x.assign(XPoints.begin() + imin, XPoints.begin() + imax); y.resize(x.size(), 0); // sum the spectra - foreach (int id, dets) { - try { - size_t index = getWorkspaceIndex(id); - const auto &Y = ws->y(index); - std::transform(y.begin(), y.end(), Y.begin() + imin, y.begin(), - std::plus<double>()); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - continue; // Detector doesn't have a workspace index relating to it - } + for (auto det : dets) { + auto index = getWorkspaceIndex(det); + if (index == INVALID_INDEX) + continue; + const auto &Y = ws->y(index); + std::transform(y.begin(), y.end(), Y.begin() + imin, y.begin(), + std::plus<double>()); } } /** -* Sum counts in detectors for purposes of rough plotting against the units on -* the x-axis. -* Assumes that all spectra have different x vectors. -* -* @param dets :: A list of detector IDs to sum. -* @param x :: (output) Time of flight values (or whatever values the x axis has) -* to plot against. -* @param y :: (output) The sums of the counts for each bin. -* @param size :: (input) Size of the output vectors. -*/ -void InstrumentActor::sumDetectorsRagged(QList<int> &dets, + * Sum counts in detectors for purposes of rough plotting against the units on + * the x-axis. + * Assumes that all spectra have different x vectors. + * + * @param dets :: A list of detector IDs to sum. + * @param x :: (output) Time of flight values (or whatever values the x axis + * has) to plot against. + * @param y :: (output) The sums of the counts for each bin. + * @param size :: (input) Size of the output vectors. + */ +void InstrumentActor::sumDetectorsRagged(const std::vector<size_t> &dets, std::vector<double> &x, std::vector<double> &y, size_t size) const { - if (dets.isEmpty() || size == 0) { + if (dets.empty() || size == 0) { x.clear(); y.clear(); return; @@ -549,20 +538,18 @@ void InstrumentActor::sumDetectorsRagged(QList<int> &dets, size_t nSpec = 0; // number of actual spectra to add // fill in the temp workspace with the data from the detectors - foreach (int id, dets) { - try { - size_t index = getWorkspaceIndex(id); - dws->setHistogram(nSpec, ws->histogram(index)); - double xmin = dws->x(nSpec).front(); - double xmax = dws->x(nSpec).back(); - if (xmin < xStart) - xStart = xmin; - if (xmax > xEnd) - xEnd = xmax; - ++nSpec; - } catch (Mantid::Kernel::Exception::NotFoundError &) { - continue; // Detector doesn't have a workspace index relating to it - } + for (auto det : dets) { + auto index = getWorkspaceIndex(det); + if (index == INVALID_INDEX) + continue; + dws->setHistogram(nSpec, ws->histogram(index)); + double xmin = dws->x(nSpec).front(); + double xmax = dws->x(nSpec).back(); + if (xmin < xStart) + xStart = xmin; + if (xmax > xEnd) + xEnd = xmax; + ++nSpec; } if (nSpec == 0) { @@ -615,50 +602,12 @@ void InstrumentActor::sumDetectorsRagged(QList<int> &dets, } /** -* Recalculate the detector colors based on the integrated values in -* m_specIntegrs and -* the masking information in .... -*/ + * Recalculate the detector colors based on the integrated values in + * m_specIntegrs and + * the masking information in .... + */ void InstrumentActor::resetColors() { - QwtDoubleInterval qwtInterval(m_DataMinScaleValue, m_DataMaxScaleValue); - m_colors.resize(m_specIntegrs.size()); - - auto sharedWorkspace = getWorkspace(); - const auto &spectrumInfo = sharedWorkspace->spectrumInfo(); - - IMaskWorkspace_sptr mask = getMaskWorkspaceIfExists(); - - for (int iwi = 0; iwi < int(m_specIntegrs.size()); iwi++) { - size_t wi = size_t(iwi); - double integratedValue = m_specIntegrs[wi]; - try { - // Find if the detector is masked - const auto &dets = sharedWorkspace->getSpectrum(wi).getDetectorIDs(); - bool masked = false; - - if (mask) { - masked = mask->isMasked(dets); - } else { - masked = spectrumInfo.hasDetectors(wi) && spectrumInfo.isMasked(wi); - } - - if (masked) { - m_colors[wi] = m_maskedColor; - } else { - QRgb color = m_colorMap.rgb(qwtInterval, integratedValue); - m_colors[wi] = GLColor(qRed(color), qGreen(color), qBlue(color)); - } - } catch (NotFoundError &) { - m_colors[wi] = m_failedColor; - continue; - } - } - if (m_scene.getNumberOfActors() > 0) { - if (auto actor = dynamic_cast<CompAssemblyActor *>(m_scene.getActor(0))) { - actor->setColors(); - invalidateDisplayLists(); - } - } + m_renderer->reset(); emit colorMapChanged(); } @@ -668,114 +617,61 @@ void InstrumentActor::updateColors() { } /** -* @param on :: True or false for on or off. -*/ + * @param on :: True or false for on or off. + */ void InstrumentActor::showGuides(bool on) { - auto visitor = SetVisibleNonDetectorVisitor(on); - this->accept(visitor); m_showGuides = on; + resetColors(); } -GLColor InstrumentActor::getColor(Mantid::detid_t id) const { - try { - size_t i = getWorkspaceIndex(id); - return m_colors.at(i); - } catch (NotFoundError &) { - // Return the first color if the detector is not represented in the - // workspace - return m_colors.front(); - } +GLColor InstrumentActor::getColor(size_t index) const { + return m_renderer->getColor(index); } -void InstrumentActor::draw(bool picking) const { m_scene.draw(picking); } +void InstrumentActor::draw(bool picking) const { + m_renderer->renderInstrument(m_isCompVisible, m_showGuides, picking); +} /** -* @param fname :: A color map file name. -* @param reset_colors :: An option to reset the detector colors. -*/ + * @param fname :: A color map file name. + * @param reset_colors :: An option to reset the detector colors. + */ void InstrumentActor::loadColorMap(const QString &fname, bool reset_colors) { - m_colorMap.loadMap(fname); + m_renderer->loadColorMap(fname); m_currentColorMapFilename = fname; - if (reset_colors) { + if (reset_colors) resetColors(); - } -} - -//------------------------------------------------------------------------------ -/** Add a detector ID to the pick list (m_detIDs) -* The order of detids define the pickIDs for detectors. -* -* @param id :: detector ID to add. -* @return pick ID of the added detector -*/ -size_t InstrumentActor::pushBackDetid(Mantid::detid_t id) const { - m_detIDs.push_back(id); - return m_detIDs.size() - 1; } //------------------------------------------------------------------------------ -/** Add a non-detector component ID to the pick list (m_nonDetIDs) -* -* @param actor :: ObjComponentActor for the component added. -* @param compID :: component ID to add. -*/ -void InstrumentActor::pushBackNonDetid( - ObjComponentActor *actor, Mantid::Geometry::ComponentID compID) const { - m_nonDetActorsTemp.push_back(actor); - m_nonDetIDs.push_back(compID); -} - -//------------------------------------------------------------------------------ -/** -* Set pick colors to non-detectors strored by calls to pushBackNonDetid(). -*/ -void InstrumentActor::setupPickColors() { - assert(m_nonDetActorsTemp.size() == m_nonDetIDs.size()); - auto nDets = m_detIDs.size(); - for (size_t i = 0; i < m_nonDetActorsTemp.size(); ++i) { - m_nonDetActorsTemp[i]->setPickColor(makePickColor(nDets + i)); - } - m_nonDetActorsTemp.clear(); -} - -//------------------------------------------------------------------------------ -/** If needed, cache the detector positions for all detectors. -* Call this BEFORE getDetPos(). -* Does nothing if the positions have already been cached. -*/ -void InstrumentActor::cacheDetPos() const { - if (m_detPos.size() != m_detIDs.size()) { - m_detPos.clear(); - for (size_t pickID = 0; pickID < m_detIDs.size(); pickID++) { - auto &det = this->getDetectorByPickID(pickID); - m_detPos.push_back(det.getPos()); - } +/** Get the detector position + * + * @param pickID :: pick Index maching the getDetector() calls; + * @return the real-space position of the detector + */ +const Mantid::Kernel::V3D InstrumentActor::getDetPos(size_t pickID) const { + const auto &detInfo = detectorInfo(); + if (pickID < detInfo.size()) { + return detInfo.position(pickID); } + return m_defaultPos; } -//------------------------------------------------------------------------------ -/** Get the cached detector position -* -* @param pickID :: pick Index maching the getDetector() calls; -* @return the real-space position of the detector -*/ -const Mantid::Kernel::V3D &InstrumentActor::getDetPos(size_t pickID) const { - if (pickID < m_detPos.size()) { - return m_detPos.at(pickID); - } - return m_defaultPos; +const std::vector<Mantid::detid_t> &InstrumentActor::getAllDetIDs() const { + const auto &detInfo = detectorInfo(); + return detInfo.detectorIDs(); } /** -* @param type :: 0 - linear, 1 - log10. -*/ + * @param type :: 0 - linear, 1 - log10. + */ void InstrumentActor::changeScaleType(int type) { - m_colorMap.changeScaleType(static_cast<GraphOptions::ScaleType>(type)); + m_renderer->changeScaleType(type); resetColors(); } void InstrumentActor::changeNthPower(double nth_power) { - m_colorMap.setNthPower(nth_power); + m_renderer->changeNthPower(nth_power); resetColors(); } @@ -795,7 +691,7 @@ void InstrumentActor::saveSettings() { QSettings settings; settings.beginGroup("Mantid/InstrumentWidget"); settings.setValue("ColormapFile", m_currentColorMapFilename); - settings.setValue("ScaleType", (int)m_colorMap.getScaleType()); + settings.setValue("ScaleType", (int)m_renderer->getColorMap().getScaleType()); settings.setValue("ShowGuides", m_showGuides); settings.endGroup(); } @@ -830,28 +726,29 @@ bool InstrumentActor::wholeRange() const { m_BinMaxValue == m_WkspBinMaxValue; } +size_t InstrumentActor::ndetectors() const { return detectorInfo().size(); } + /** -* Set autoscaling of the y axis. If autoscaling is on the minValue() and -* maxValue() -* return the actual min and max values in the data. If autoscaling is off -* minValue() and maxValue() are fixed and do not change after changing the x -* integration range. -* @param on :: On or Off. -*/ + * Set autoscaling of the y axis. If autoscaling is on the minValue() and + * maxValue() + * return the actual min and max values in the data. If autoscaling is off + * minValue() and maxValue() are fixed and do not change after changing the x + * integration range. + * @param on :: On or Off. + */ void InstrumentActor::setAutoscaling(bool on) { m_autoscaling = on; if (on) { m_DataMinScaleValue = m_DataMinValue; m_DataMaxScaleValue = m_DataMaxValue; - // setIntegrationRange(m_DataMinValue,m_DataMaxValue); resetColors(); } } /** -* Extracts the current applied mask to the main workspace -* @returns the current applied mask to the main workspace -*/ + * Extracts the current applied mask to the main workspace + * @returns the current applied mask to the main workspace + */ Mantid::API::MatrixWorkspace_sptr InstrumentActor::extractCurrentMask() const { const std::string maskName = "__InstrumentActor_MaskWorkspace"; Mantid::API::IAlgorithm *alg = @@ -869,8 +766,8 @@ Mantid::API::MatrixWorkspace_sptr InstrumentActor::extractCurrentMask() const { } /** -* Initialize the helper mask workspace with the mask from the data workspace. -*/ + * Initialize the helper mask workspace with the mask from the data workspace. + */ void InstrumentActor::initMaskHelper() const { if (m_maskWorkspace) return; @@ -885,30 +782,30 @@ void InstrumentActor::initMaskHelper() const { } /** -* Checks if the actor has a mask workspace attached. -*/ + * Checks if the actor has a mask workspace attached. + */ bool InstrumentActor::hasMaskWorkspace() const { return m_maskWorkspace != nullptr; } /** -* Find a rotation from one orthonormal basis set (Xfrom,Yfrom,Zfrom) to -* another orthonormal basis set (Xto,Yto,Zto). Both sets must be right-handed -* (or same-handed, I didn't check). The method doesn't check the sets for -* orthogonality -* or normality. The result is a rotation quaternion such that: -* R.rotate(Xfrom) == Xto -* R.rotate(Yfrom) == Yto -* R.rotate(Zfrom) == Zto -* @param Xfrom :: The X axis of the original basis set -* @param Yfrom :: The Y axis of the original basis set -* @param Zfrom :: The Z axis of the original basis set -* @param Xto :: The X axis of the final basis set -* @param Yto :: The Y axis of the final basis set -* @param Zto :: The Z axis of the final basis set -* @param R :: The output rotation as a quaternion -* @param out :: Debug printout flag -*/ + * Find a rotation from one orthonormal basis set (Xfrom,Yfrom,Zfrom) to + * another orthonormal basis set (Xto,Yto,Zto). Both sets must be right-handed + * (or same-handed, I didn't check). The method doesn't check the sets for + * orthogonality + * or normality. The result is a rotation quaternion such that: + * R.rotate(Xfrom) == Xto + * R.rotate(Yfrom) == Yto + * R.rotate(Zfrom) == Zto + * @param Xfrom :: The X axis of the original basis set + * @param Yfrom :: The Y axis of the original basis set + * @param Zfrom :: The Z axis of the original basis set + * @param Xto :: The X axis of the final basis set + * @param Yto :: The Y axis of the final basis set + * @param Zto :: The Z axis of the final basis set + * @param R :: The output rotation as a quaternion + * @param out :: Debug printout flag + */ void InstrumentActor::BasisRotation(const Mantid::Kernel::V3D &Xfrom, const Mantid::Kernel::V3D &Yfrom, const Mantid::Kernel::V3D &Zfrom, @@ -994,15 +891,15 @@ void InstrumentActor::BasisRotation(const Mantid::Kernel::V3D &Xfrom, } /** -* Calculate a rotation to look in a particular direction. -* -* @param eye :: A direction to look in -* @param up :: A vector showing the 'up' direction after the rotation. It -* doesn't have to be normal to eye -* just non-collinear. If up is collinear to eye the actual 'up' direction is -* undefined. -* @param R :: The result rotation. -*/ + * Calculate a rotation to look in a particular direction. + * + * @param eye :: A direction to look in + * @param up :: A vector showing the 'up' direction after the rotation. It + * doesn't have to be normal to eye + * just non-collinear. If up is collinear to eye the actual 'up' direction is + * undefined. + * @param R :: The result rotation. + */ void InstrumentActor::rotateToLookAt(const Mantid::Kernel::V3D &eye, const Mantid::Kernel::V3D &up, Mantid::Kernel::Quat &R) { @@ -1039,11 +936,11 @@ void InstrumentActor::rotateToLookAt(const Mantid::Kernel::V3D &eye, } /** -* Find the offsets in the spectrum's x vector of the bounds of integration. -* @param wi :: The works[ace index of the spectrum. -* @param imin :: Index of the lower bound: x_min == x(wi)[imin] -* @param imax :: Index of the upper bound: x_max == x(wi)[imax] -*/ + * Find the offsets in the spectrum's x vector of the bounds of integration. + * @param wi :: The works[ace index of the spectrum. + * @param imin :: Index of the lower bound: x_min == x(wi)[imin] + * @param imax :: Index of the upper bound: x_max == x(wi)[imax] + */ void InstrumentActor::getBinMinMaxIndex(size_t wi, size_t &imin, size_t &imax) const { Mantid::API::MatrixWorkspace_const_sptr ws = getWorkspace(); @@ -1078,8 +975,8 @@ void InstrumentActor::getBinMinMaxIndex(size_t wi, size_t &imin, } /** -* Set the minimum and the maximum data values on the color map scale. -*/ + * Set the minimum and the maximum data values on the color map scale. + */ void InstrumentActor::setDataMinMaxRange(double vmin, double vmax) { if (vmin < m_DataMinValue) { vmin = m_DataMinValue; @@ -1105,15 +1002,14 @@ void InstrumentActor::setDataIntegrationRange(const double &xmin, auto workspace = getWorkspace(); calculateIntegratedSpectra(*workspace); + std::set<size_t> monitorIndices; - // get the workspace indices of monitors in order to exclude them from finding - // of the max value - auto monitorIDs = getInstrument()->getMonitors(); - // clang-format off - // because it indents this line half way across the page (?) - auto monitorIndices = workspace->getIndicesFromDetectorIDs(monitorIDs); - // clang-format on - + for (auto monitor : m_monitors) { + auto index = getWorkspaceIndex(monitor); + if (index == INVALID_INDEX) + continue; + monitorIndices.emplace(index); + } // check that there is at least 1 non-monitor spectrum if (monitorIndices.size() == m_specIntegrs.size()) { // there are only monitors - cannot skip them @@ -1129,31 +1025,31 @@ void InstrumentActor::setDataIntegrationRange(const double &xmin, m_DataMinValue = DBL_MAX; m_DataMaxValue = -DBL_MAX; - // Now we need to convert to a vector where each entry is the sum for the - // detector ID at that spot (in integrated_values). + if (std::any_of(m_specIntegrs.begin(), m_specIntegrs.end(), + [](double val) { return !std::isfinite(val); })) + throw std::runtime_error( + "The workspace contains values that cannot be displayed (infinite " + "or NaN).\n" + "Please run ReplaceSpecialValues algorithm for correction."); + + const auto &spectrumInfo = workspace->spectrumInfo(); + + // Ignore monitors if multiple detectors aren't grouped. for (size_t i = 0; i < m_specIntegrs.size(); i++) { - // skip the monitors - if (std::find(monitorIndices.begin(), monitorIndices.end(), i) != - monitorIndices.end()) { + const auto &spectrumDefinition = spectrumInfo.spectrumDefinition(i); + if (spectrumDefinition.size() == 1 && + std::find(monitorIndices.begin(), monitorIndices.end(), i) != + monitorIndices.end()) continue; - } - double sum = m_specIntegrs[i]; - if (!std::isfinite(sum)) { - throw std::runtime_error( - "The workspace contains values that cannot be displayed (infinite " - "or NaN).\n" - "Please run ReplaceSpecialValues algorithm for correction."); - } - // integrated_values[i] = sum; - if (sum < m_DataMinValue) { + + auto sum = m_specIntegrs[i]; + + if (sum < m_DataMinValue) m_DataMinValue = sum; - } - if (sum > m_DataMaxValue) { + if (sum > m_DataMaxValue) m_DataMaxValue = sum; - } - if (sum > 0 && sum < m_DataPositiveMinValue) { + if (sum > 0 && sum < m_DataPositiveMinValue) m_DataPositiveMinValue = sum; - } } } @@ -1164,14 +1060,17 @@ void InstrumentActor::setDataIntegrationRange(const double &xmin, } /// Add a range of bins for masking -void InstrumentActor::addMaskBinsData(const QList<int> &detIDs) { - QList<int> indices; - foreach (int id, detIDs) { - auto index = m_detid2index_map[id]; - indices.append(static_cast<int>(index)); +void InstrumentActor::addMaskBinsData(const std::vector<size_t> &indices) { + std::vector<size_t> wsIndices; + wsIndices.reserve(indices.size()); + for (auto det : indices) { + auto index = getWorkspaceIndex(det); + if (index == INVALID_INDEX) + continue; + wsIndices.emplace_back(index); } - if (!indices.isEmpty()) { - m_maskBinsData.addXRange(m_BinMinValue, m_BinMaxValue, indices); + if (!indices.empty()) { + m_maskBinsData.addXRange(m_BinMinValue, m_BinMaxValue, wsIndices); auto workspace = getWorkspace(); calculateIntegratedSpectra(*workspace); resetColors(); @@ -1181,95 +1080,79 @@ void InstrumentActor::addMaskBinsData(const QList<int> &detIDs) { /// Show if bin masks have been defined. bool InstrumentActor::hasBinMask() const { return !m_maskBinsData.isEmpty(); } -//-------------------------------------------------------------------------// -bool SetVisibleComponentVisitor::visit(GLActor *actor) { - actor->setVisibility(false); - return false; -} - -bool SetVisibleComponentVisitor::visit(GLActorCollection *actor) { - bool visible = actor->hasChildVisible(); - actor->setVisibility(visible); - return visible; -} - -bool SetVisibleComponentVisitor::visit(ComponentActor *actor) { - bool on = actor->getComponent()->getComponentID() == m_id; - actor->setVisibility(on); - return on; -} - -bool SetVisibleComponentVisitor::visit(CompAssemblyActor *actor) { - bool visible = false; - if (actor->getComponent()->getComponentID() == m_id) { - visible = true; - actor->setChildVisibility(true); - } else { - visible = actor->hasChildVisible(); - actor->setVisibility(visible); +QString InstrumentActor::getParameterInfo(size_t index) const { + auto instr = getInstrument(); + const auto &compInfo = componentInfo(); + + auto compID = compInfo.componentID(index); + auto comp = instr->getComponentByID(compID); + + QString text = ""; + std::map<Mantid::Geometry::ComponentID, std::vector<std::string>> + mapCmptToNameVector; + + auto paramNames = comp->getParameterNamesByComponent(); + for (auto itParamName = paramNames.begin(); itParamName != paramNames.end(); + ++itParamName) { + // build the data structure I need Map comp id -> vector of names + std::string paramName = itParamName->first; + Mantid::Geometry::ComponentID paramCompId = itParamName->second; + // attempt to insert this will fail silently if the key already exists + if (mapCmptToNameVector.find(paramCompId) == mapCmptToNameVector.end()) { + mapCmptToNameVector.emplace(paramCompId, std::vector<std::string>()); + } + // get the vector out and add the name + mapCmptToNameVector[paramCompId].emplace_back(paramName); } - return visible; -} - -bool SetVisibleComponentVisitor::visit(ObjCompAssemblyActor *actor) { - bool on = actor->getComponent()->getComponentID() == m_id; - actor->setVisibility(on); - return on; -} -bool SetVisibleComponentVisitor::visit(InstrumentActor *actor) { - bool visible = false; - if (actor->getInstrument()->getComponentID() == m_id) { - visible = true; - actor->setChildVisibility(true); - } else { - visible = actor->hasChildVisible(); - actor->setVisibility(visible); + // walk out from the selected component + const Mantid::Geometry::IComponent *paramComp = comp.get(); + boost::shared_ptr<const Mantid::Geometry::IComponent> parentComp; + while (paramComp) { + auto id = paramComp->getComponentID(); + auto &compParamNames = mapCmptToNameVector[id]; + if (compParamNames.size() > 0) { + text += QString::fromStdString("\nParameters from: " + + paramComp->getName() + "\n"); + std::sort(compParamNames.begin(), compParamNames.end(), + Mantid::Kernel::CaseInsensitiveStringComparator()); + for (auto itParamName = compParamNames.begin(); + itParamName != compParamNames.end(); ++itParamName) { + std::string paramName = *itParamName; + // no need to search recursively as we are asking from the matching + // component + std::string paramValue = + paramComp->getParameterAsString(paramName, false); + if (paramValue != "") { + text += QString::fromStdString(paramName + ": " + paramValue + "\n"); + } + } + } + parentComp = paramComp->getParent(); + paramComp = parentComp.get(); } - return visible; -} -bool SetVisibleComponentVisitor::visit(RectangularDetectorActor *actor) { - bool on = actor->getComponent()->getComponentID() == m_id || - actor->isChildDetector(m_id); - actor->setVisibility(on); - return on; + return text; } -bool SetVisibleComponentVisitor::visit(StructuredDetectorActor *actor) { - bool on = actor->getComponent()->getComponentID() == m_id || - actor->isChildDetector(m_id); - actor->setVisibility(on); - return on; +std::string InstrumentActor::getDefaultAxis() const { + return getInstrument()->getDefaultAxis(); } -//-------------------------------------------------------------------------// -/** -* Visits an actor and if it is a "non-detector" sets its visibility. -* -* @param actor :: A visited actor. -* @return always false to traverse all the instrument tree. -*/ -bool SetVisibleNonDetectorVisitor::visit(GLActor *actor) { - ComponentActor *comp = dynamic_cast<ComponentActor *>(actor); - if (comp && comp->isNonDetector()) { - actor->setVisibility(m_on); - } - return false; +std::string InstrumentActor::getDefaultView() const { + return getInstrument()->getDefaultView(); } -//-------------------------------------------------------------------------// -bool FindComponentVisitor::visit(GLActor *actor) { - ComponentActor *comp = dynamic_cast<ComponentActor *>(actor); - if (comp) { - if (comp->getComponent()->getComponentID() == m_id) { - m_actor = comp; - return true; - } - } - return false; +std::string InstrumentActor::getInstrumentName() const { + const auto &compInfo = componentInfo(); + return compInfo.name(compInfo.root()); } +std::vector<std::string> +InstrumentActor::getStringParameter(const std::string &name, + bool recursive) const { + return getInstrument()->getStringParameter(name, recursive); +} /** * Save the state of the instrument actor to a project file. * @return string representing the current state of the instrumet actor. @@ -1304,5 +1187,26 @@ void InstrumentActor::loadFromProject(const std::string &lines) { } } -} // MantidWidgets -} // MantidQt +/** If instrument.geometry.view is set to Default or Physical, then the physical + * instrument componentInfo is returned. Othewise this returns the neutronic + * version. + */ +const Mantid::Geometry::ComponentInfo &InstrumentActor::componentInfo() const { + if (m_isPhysicalInstrument) + return *m_physicalComponentInfo; + else + return getWorkspace()->componentInfo(); +} + +/** If instrument.geometry.view is set to Default or Physical, then the physical +* instrument detectorInfo is returned. Othewise this returns the neutronic +* version. +*/ +const Mantid::Geometry::DetectorInfo &InstrumentActor::detectorInfo() const { + if (m_isPhysicalInstrument) + return *m_physicalDetectorInfo; + else + return getWorkspace()->detectorInfo(); +} +} // namespace MantidWidgets +} // namespace MantidQt diff --git a/qt/widgets/instrumentview/src/InstrumentRenderer.cpp b/qt/widgets/instrumentview/src/InstrumentRenderer.cpp new file mode 100644 index 0000000000000000000000000000000000000000..72aa10f1f53c8ada5feb77ccea0c5a2daff148a2 --- /dev/null +++ b/qt/widgets/instrumentview/src/InstrumentRenderer.cpp @@ -0,0 +1,442 @@ +#include "MantidQtWidgets/InstrumentView/InstrumentRenderer.h" +#include "MantidAPI/IMaskWorkspace.h" +#include "MantidBeamline/ComponentType.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Objects/IObject.h" +#include "MantidGeometry/Rendering/GeometryHandler.h" +#include "MantidGeometry/Rendering/ShapeInfo.h" +#include "MantidKernel/Exception.h" +#include "MantidKernel/Quat.h" +#include "MantidQtWidgets/InstrumentView/BankRenderingHelpers.h" +#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" +#include "MantidQtWidgets/InstrumentView/OpenGLError.h" + +using namespace MantidQt::MantidWidgets; + +namespace MantidQt { +namespace MantidWidgets { + +namespace { +size_t decodePickColorRGB(unsigned char r, unsigned char g, unsigned char b) { + unsigned int index = r; + index *= 256; + index += g; + index *= 256; + index += b - 1; + return index; +} + +void updateVisited(std::vector<bool> &visited, + const std::vector<size_t> &components) { + for (auto component : components) + visited[component] = true; +} +} // namespace + +InstrumentRenderer::InstrumentRenderer(const InstrumentActor &actor) + : m_actor(actor) { + + m_displayListId[0] = 0; + m_displayListId[1] = 0; + m_useDisplayList[0] = false; + m_useDisplayList[1] = false; + + const auto &componentInfo = actor.componentInfo(); + size_t numTextures = 0; + for (size_t i = componentInfo.root(); !componentInfo.isDetector(i); --i) { + auto type = componentInfo.componentType(i); + if (type == Mantid::Beamline::ComponentType::Rectangular || + type == Mantid::Beamline::ComponentType::OutlineComposite) { + m_textureIndices.push_back(i); + m_reverseTextureIndexMap[i] = numTextures; + numTextures++; + } + } + + if (numTextures > 0) { + m_textureIDs.resize(numTextures, 0); + colorTextures.resize(numTextures); + pickTextures.resize(numTextures); + } +} + +InstrumentRenderer::~InstrumentRenderer() { + for (size_t i = 0; i < 2; ++i) { + if (m_displayListId[i] != 0) { + glDeleteLists(m_displayListId[i], 1); + } + } +} + +void InstrumentRenderer::renderInstrument(const std::vector<bool> &visibleComps, + bool showGuides, bool picking) { + if (std::none_of(visibleComps.cbegin(), visibleComps.cend(), + [](bool visible) { return visible; })) + return; + + OpenGLError::check("InstrumentActor::draw()"); + size_t i = picking ? 1 : 0; + if (m_useDisplayList[i]) { + glCallList(m_displayListId[i]); + } else { + m_displayListId[i] = glGenLists(1); + m_useDisplayList[i] = true; + glNewList(m_displayListId[i], + GL_COMPILE); // Construct display list for object representation + draw(visibleComps, showGuides, picking); + glEndList(); + if (glGetError() == GL_OUT_OF_MEMORY) // Throw an exception + throw Mantid::Kernel::Exception::OpenGLError( + "OpenGL: Out of video memory"); + glCallList(m_displayListId[i]); + } + OpenGLError::check("InstrumentActor::draw()"); +} + +void InstrumentRenderer::draw(const std::vector<bool> &visibleComps, + bool showGuides, bool picking) { + const auto &compInfo = m_actor.componentInfo(); + std::vector<bool> visited(compInfo.size(), false); + + for (size_t i = compInfo.root(); i != std::numeric_limits<size_t>::max(); + --i) { + auto type = compInfo.componentType(i); + if (type == Mantid::Beamline::ComponentType::Infinite) + continue; + + if (type == Mantid::Beamline::ComponentType::Rectangular) { + updateVisited(visited, compInfo.componentsInSubtree(i)); + if (visibleComps[i]) + drawRectangularBank(i, picking); + continue; + } + + if (type == Mantid::Beamline::ComponentType::OutlineComposite) { + updateVisited(visited, compInfo.componentsInSubtree(i)); + if (visibleComps[i]) + drawTube(i, picking); + continue; + } + + if (type == Mantid::Beamline::ComponentType::Structured) { + updateVisited(visited, compInfo.componentsInSubtree(i)); + if (visibleComps[i]) + drawStructuredBank(i, picking); + continue; + } + + if (!compInfo.isDetector(i) && !showGuides) { + visited[i] = true; + continue; + } + + if (compInfo.hasValidShape(i) && visibleComps[i] && !visited[i]) { + visited[i] = true; + drawSingleDetector(i, picking); + } + } +} + +void InstrumentRenderer::drawRectangularBank(size_t bankIndex, bool picking) { + const auto &compInfo = m_actor.componentInfo(); + glPushMatrix(); + + auto bank = compInfo.quadrilateralComponent(bankIndex); + auto pos = compInfo.position(bank.bottomLeft); + auto scale = compInfo.scaleFactor(bankIndex); + glTranslated(pos.X(), pos.Y(), pos.Z()); + glScaled(scale[0], scale[1], scale[2]); + + auto rot = compInfo.rotation(bankIndex); + if (!(rot.isNull())) { + double deg, ax0, ax1, ax2; + rot.getAngleAxis(deg, ax0, ax1, ax2); + glRotated(deg, ax0, ax1, ax2); + } + + auto ti = m_reverseTextureIndexMap[bankIndex]; + glBindTexture(GL_TEXTURE_2D, m_textureIDs[ti]); + uploadRectangularTexture(picking ? pickTextures[ti] : colorTextures[ti], + bankIndex); + + BankRenderingHelpers::renderRectangularBank(compInfo, bankIndex); + + glBindTexture(GL_TEXTURE_2D, 0); + glPopMatrix(); +} + +void InstrumentRenderer::drawStructuredBank(size_t bankIndex, bool picking) { + const auto &compInfo = m_actor.componentInfo(); + glPushMatrix(); + + auto bank = compInfo.quadrilateralComponent(bankIndex); + const auto &shapeInfo = + compInfo.shape(bank.bottomLeft).getGeometryHandler()->shapeInfo(); + auto pos = shapeInfo.points()[0]; + pos.setZ(compInfo.position(bank.bottomLeft).Z()); + auto scale = compInfo.scaleFactor(bankIndex); + glTranslated(pos.X(), pos.Y(), pos.Z()); + glScaled(scale[0], scale[1], scale[2]); + + BankRenderingHelpers::renderStructuredBank(compInfo, bankIndex, + picking ? m_pickColors : m_colors); + + glPopMatrix(); +} + +void InstrumentRenderer::drawTube(size_t bankIndex, bool picking) { + const auto &compInfo = m_actor.componentInfo(); + glPushMatrix(); + + auto pos = compInfo.position(bankIndex); + auto rot = compInfo.rotation(bankIndex); + auto scale = compInfo.scaleFactor(bankIndex); + glTranslated(pos.X(), pos.Y(), pos.Z()); + glScaled(scale[0], scale[1], scale[2]); + double deg, ax0, ax1, ax2; + rot.getAngleAxis(deg, ax0, ax1, ax2); + glRotated(deg, ax0, ax1, ax2); + + auto ti = m_reverseTextureIndexMap[bankIndex]; + glColor3f(1.0f, 1.0f, 1.0f); + glEnable(GL_TEXTURE_2D); + glBindTexture(GL_TEXTURE_2D, m_textureIDs[ti]); + uploadTubeTexture(picking ? pickTextures[ti] : colorTextures[ti], bankIndex); + + compInfo.shape(bankIndex).draw(); + + glBindTexture(GL_TEXTURE_2D, 0); + glPopMatrix(); +} + +void InstrumentRenderer::drawSingleDetector(size_t detIndex, bool picking) { + const auto &compInfo = m_actor.componentInfo(); + if (picking) + m_pickColors[detIndex].paint(); + else + m_colors[detIndex].paint(); + glPushMatrix(); + // Translate + auto pos = compInfo.position(detIndex); + if (!pos.nullVector()) + glTranslated(pos[0], pos[1], pos[2]); + + // Rotate + auto rot = compInfo.rotation(detIndex); + if (!rot.isNull()) { + double deg, ax0, ax1, ax2; + rot.getAngleAxis(deg, ax0, ax1, ax2); + glRotated(deg, ax0, ax1, ax2); + } + + // Scale + auto scale = compInfo.scaleFactor(detIndex); + if (scale != Mantid::Kernel::V3D(1, 1, 1)) + glScaled(scale[0], scale[1], scale[2]); + + compInfo.shape(detIndex).draw(); + glPopMatrix(); +} + +void InstrumentRenderer::reset() { + resetColors(); + resetPickColors(); + + if (m_textureIDs.size() > 0) { + const auto &compInfo = m_actor.componentInfo(); + for (size_t i = 0; i < m_textureIDs.size(); i++) { + auto type = compInfo.componentType(m_textureIndices[i]); + + if (type == Mantid::Beamline::ComponentType::Rectangular) { + generateRectangularTexture(colorTextures[i], m_colors, + m_textureIndices[i]); + generateRectangularTexture(pickTextures[i], m_pickColors, + m_textureIndices[i]); + } else if (type == Mantid::Beamline::ComponentType::OutlineComposite) { + generateTubeTexture(colorTextures[i], m_colors, m_textureIndices[i]); + generateTubeTexture(pickTextures[i], m_pickColors, m_textureIndices[i]); + } + } + } + + /// Invalidate the OpenGL display lists to force full re-drawing of the + /// instrument and creation of new lists. + for (size_t i = 0; i < 2; ++i) { + if (m_displayListId[i] != 0) { + glDeleteLists(m_displayListId[i], 1); + m_displayListId[i] = 0; + m_useDisplayList[i] = false; + } + } +} + +void InstrumentRenderer::resetColors() { + QwtDoubleInterval qwtInterval(m_actor.minValue(), m_actor.maxValue()); + auto sharedWorkspace = m_actor.getWorkspace(); + const auto &compInfo = m_actor.componentInfo(); + const auto &detInfo = m_actor.detectorInfo(); + auto color = m_colorMap.rgb(qwtInterval, 0); + m_colors.assign(compInfo.size(), + GLColor(qRed(color), qGreen(color), qBlue(color), 1)); + auto invalidColor = GLColor(80, 80, 80, 1); + auto maskedColor = GLColor(100, 100, 100, 1); + + Mantid::API::IMaskWorkspace_sptr mask = m_actor.getMaskWorkspaceIfExists(); + const auto &detectorIDs = detInfo.detectorIDs(); + for (size_t det = 0; det < detInfo.size(); ++det) { + auto masked = false; + + if (mask) + masked = mask->isMasked(detectorIDs[det]); + if (detInfo.isMasked(det) || masked) + m_colors[det] = maskedColor; + else { + auto integratedValue = m_actor.getIntegratedCounts(det); + if (integratedValue > -1) { + auto color = m_colorMap.rgb(qwtInterval, integratedValue); + m_colors[det] = GLColor( + qRed(color), qGreen(color), qBlue(color), + static_cast<int>(255 * (integratedValue / m_actor.maxValue()))); + } else + m_colors[det] = invalidColor; + } + } + + for (const auto comp : m_actor.components()) + m_colors[comp] = maskedColor; +} + +void InstrumentRenderer::resetPickColors() { + const auto &compInfo = m_actor.componentInfo(); + m_pickColors.resize(compInfo.size()); + + for (size_t i = 0; i < compInfo.size(); ++i) { + m_pickColors[i] = makePickColor(i); + } +} + +void InstrumentRenderer::changeScaleType(int type) { + m_colorMap.changeScaleType(static_cast<GraphOptions::ScaleType>(type)); +} + +void InstrumentRenderer::changeNthPower(double nth_power) { + m_colorMap.setNthPower(nth_power); +} + +GLColor InstrumentRenderer::getColor(size_t index) const { + if (index <= m_colors.size() - 1) + return m_colors.at(index); + + return m_colors.front(); +} + +GLColor InstrumentRenderer::makePickColor(size_t pickID) { + pickID += 1; + unsigned char r, g, b; + r = static_cast<unsigned char>(pickID / 65536); + g = static_cast<unsigned char>((pickID % 65536) / 256); + b = static_cast<unsigned char>((pickID % 65536) % 256); + return GLColor(r, g, b); +} + +size_t InstrumentRenderer::decodePickColor(const QRgb &c) { + return decodePickColorRGB(static_cast<unsigned char>(qRed(c)), + static_cast<unsigned char>(qGreen(c)), + static_cast<unsigned char>(qBlue(c))); +} + +void InstrumentRenderer::loadColorMap(const QString &fname) { + m_colorMap.loadMap(fname); +} + +void InstrumentRenderer::generateRectangularTexture( + std::vector<char> &texture, const std::vector<GLColor> &colors, + size_t bankIndex) { + const auto &compInfo = m_actor.componentInfo(); + auto bank = compInfo.quadrilateralComponent(bankIndex); + // Round size up to nearest power of 2 + auto res = BankRenderingHelpers::getCorrectedTextureSize(bank.nX, bank.nY); + auto texSizeX = res.first; + auto texSizeY = res.second; + + // Texture width is 3 times wider due to RGB values + texture.resize(texSizeX * texSizeY * 3, 0); // fill with black + + const auto &children = compInfo.children(bankIndex); + auto colWidth = children.size() * 3; + for (size_t x = 0; x < colWidth; x += 3) { + const auto &dets = compInfo.detectorsInSubtree(children[x / 3]); + for (size_t y = 0; y < dets.size(); ++y) { + auto det = dets[y]; + auto ti = (y * texSizeX * 3) + x; + texture[ti] = static_cast<char>(colors[det].red()); + texture[ti + 1] = static_cast<char>(colors[det].green()); + texture[ti + 2] = static_cast<char>(colors[det].blue()); + } + } +} + +void InstrumentRenderer::generateTubeTexture(std::vector<char> &texture, + const std::vector<GLColor> &colors, + size_t bankIndex) { + const auto &compInfo = m_actor.componentInfo(); + const auto &children = compInfo.children(bankIndex); + texture.resize(children.size() * 3); + + for (size_t i = 0; i < children.size(); ++i) { + auto col = colors[children[i]]; + auto pos = i * 3; + texture[pos] = static_cast<unsigned char>(col.red()); + texture[pos + 1] = static_cast<unsigned char>(col.green()); + texture[pos + 2] = static_cast<unsigned char>(col.blue()); + } +} + +void InstrumentRenderer::uploadRectangularTexture( + const std::vector<char> &texture, size_t textureIndex) const { + auto bank = m_actor.componentInfo().quadrilateralComponent(textureIndex); + auto res = BankRenderingHelpers::getCorrectedTextureSize(bank.nX, bank.nY); + auto xsize = res.first; + auto ysize = res.second; + + auto ti = m_reverseTextureIndexMap[textureIndex]; + if (m_textureIDs[ti] != 0) + glDeleteTextures(1, &m_textureIDs[ti]); + + glGenTextures(1, &m_textureIDs[ti]); + glBindTexture(GL_TEXTURE_2D, m_textureIDs[ti]); + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + + // Allow lighting effects + glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE); + + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, static_cast<GLsizei>(xsize), + static_cast<GLsizei>(ysize), 0, GL_RGB, GL_UNSIGNED_BYTE, + texture.data()); +} + +void InstrumentRenderer::uploadTubeTexture(const std::vector<char> &texture, + size_t textureIndex) const { + auto ti = m_reverseTextureIndexMap[textureIndex]; + if (m_textureIDs[ti] > 0) + glDeleteTextures(1, &m_textureIDs[ti]); + + glPixelStorei(GL_UNPACK_ALIGNMENT, 1); + glGenTextures(1, &m_textureIDs[ti]); + glBindTexture(GL_TEXTURE_2D, m_textureIDs[ti]); + + glTexImage2D(GL_TEXTURE_2D, 0, 3, 1, static_cast<GLsizei>(texture.size() / 3), + 0, GL_RGB, GL_UNSIGNED_BYTE, texture.data()); + + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); +} + +} // namespace MantidWidgets +} // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/instrumentview/src/InstrumentTreeModel.cpp b/qt/widgets/instrumentview/src/InstrumentTreeModel.cpp index 73c8037b4b1ee8b27b55bee3d545a3977bbb9bc2..e9be7feccfb9a08f365cb1c0c26c7bb28c28605c 100644 --- a/qt/widgets/instrumentview/src/InstrumentTreeModel.cpp +++ b/qt/widgets/instrumentview/src/InstrumentTreeModel.cpp @@ -5,6 +5,7 @@ #endif #include "MantidKernel/Exception.h" #include "MantidGeometry/ICompAssembly.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Instrument.h" #include "MantidAPI/MatrixWorkspace.h" @@ -14,13 +15,17 @@ using Mantid::Geometry::IObjComponent; namespace MantidQt { namespace MantidWidgets { - /** -* Constructor for tree model to display instrument tree -*/ + * Constructor for tree model to display instrument tree + */ InstrumentTreeModel::InstrumentTreeModel(const InstrumentWidget *instrWidget, QObject *parent) - : QAbstractItemModel(parent), m_instrWidget(instrWidget) {} + : QAbstractItemModel(parent), m_instrWidget(instrWidget) { + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + m_componentIndices.resize(componentInfo.size()); + std::iota(m_componentIndices.begin(), m_componentIndices.end(), 0); +} /** * Destructor for instrument display tree @@ -34,22 +39,16 @@ InstrumentTreeModel::~InstrumentTreeModel() {} * Returns 0 for the ObjComponent = I'm an end point. */ int InstrumentTreeModel::columnCount(const QModelIndex &parent) const { - try { - if (parent.isValid()) { - auto instr = m_instrWidget->getInstrumentActor().getInstrument(); - boost::shared_ptr<const IComponent> comp = instr->getComponentByID( - static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer())); - boost::shared_ptr<const ICompAssembly> objcomp = - boost::dynamic_pointer_cast<const ICompAssembly>(comp); - if (objcomp) - return 1; - return 0; - } else - return 1; - } catch (...) { - // std::cout<<"Exception :: columnCount"<<'\n'; - return 0; - } + if (!parent.isValid()) + return 1; + + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + auto index = extractIndex(parent); + if (componentInfo.children(index).size() > 0) + return 1; + + return 0; } /** @@ -57,25 +56,17 @@ int InstrumentTreeModel::columnCount(const QModelIndex &parent) const { * string will be instrument name */ QVariant InstrumentTreeModel::data(const QModelIndex &index, int role) const { - try { - if (role != Qt::DisplayRole) - return QVariant(); - - auto instr = m_instrWidget->getInstrumentActor().getInstrument(); - - if (!index.isValid()) // not valid has to return the root node - return QString(instr->getName().c_str()); - - boost::shared_ptr<const IComponent> ins = instr->getComponentByID( - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())); - if (ins) { - return QString(ins->getName().c_str()); - } - return QString("Error"); - } catch (...) { - // std::cout<<" Exception: in data"<<'\n'; - return 0; - } + if (role != Qt::DisplayRole) + return QVariant(); + + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + + if (!index.isValid()) // not valid has to return the root node + return QString::fromStdString(componentInfo.name(componentInfo.root())); + + auto compIndex = extractIndex(index); + return QString::fromStdString(componentInfo.name(compIndex)); } /** @@ -104,79 +95,52 @@ QVariant InstrumentTreeModel::headerData(int section, */ QModelIndex InstrumentTreeModel::index(int row, int column, const QModelIndex &parent) const { - // std::cout<<"Index +++++++++ row"<<row<<" column "<<column<<" is valid - //"<<parent.isValid()<<'\n'; - try { - boost::shared_ptr<const ICompAssembly> parentItem; - auto instr = m_instrWidget->getInstrumentActor().getInstrument(); - if (!parent.isValid()) // invalid parent, has to be the root node i.e + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + if (!parent.isValid()) { // invalid parent, has to be the root node i.e // instrument - return createIndex(row, column, instr->getComponentID()); - - boost::shared_ptr<const IComponent> comp = instr->getComponentByID( - static_cast<Mantid::Geometry::ComponentID>(parent.internalPointer())); - parentItem = boost::dynamic_pointer_cast<const ICompAssembly>(comp); - if (!parentItem) { - boost::shared_ptr<const IObjComponent> objcomp = - boost::dynamic_pointer_cast<const IObjComponent>(comp); - if (objcomp) - return QModelIndex(); - // Not an instrument so check for Component Assembly - parentItem = boost::dynamic_pointer_cast<const ICompAssembly>(instr); - } - // If component assembly pick the Component at the row index. if row index - // is higher than number - // of components in assembly return empty model index - if (parentItem->nelements() < row) { - return QModelIndex(); - } else { - return createIndex(row, column, - (void *)((*parentItem)[row]->getComponentID())); - } - } catch (...) { - std::cout << "InstrumentTreeModel::index(" << row << "," << column - << ") threw an exception.\n"; + return createIndex(row, column, &m_componentIndices[componentInfo.root()]); } - return QModelIndex(); + auto index = extractIndex(parent); + const auto &children = componentInfo.children(index); + + if (index == componentInfo.source() || index == componentInfo.sample() || + static_cast<int>(children.size()) <= row) + return QModelIndex(); + + return createIndex(row, column, &m_componentIndices[children[row]]); } /** * Returns the parent model index. */ QModelIndex InstrumentTreeModel::parent(const QModelIndex &index) const { - // std::cout<<"parent +++++++++ row"<<index.row()<<" column - //"<<index.column()<<" is valid "<<index.isValid()<<'\n'; - try { - if (!index.isValid()) // the index corresponds to root so there is no parent - // for root return empty. - return QModelIndex(); - - auto instr = m_instrWidget->getInstrumentActor().getInstrument(); - - if (instr->getComponentID() == - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())) - return QModelIndex(); - - boost::shared_ptr<const IComponent> child = instr->getComponentByID( - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())); - if (child->getParent()->getComponentID() == instr->getComponentID()) - return createIndex(0, 0, instr->getComponentID()); - boost::shared_ptr<const IComponent> parent = - instr->getComponentByID(child->getParent()->getComponentID()); - boost::shared_ptr<const IComponent> greatParent = - instr->getComponentByID(parent->getParent()->getComponentID()); - boost::shared_ptr<const ICompAssembly> greatParentAssembly = - boost::dynamic_pointer_cast<const ICompAssembly>(greatParent); - int iindex = 0; - for (int i = 0; i < greatParentAssembly->nelements(); i++) - if ((*greatParentAssembly)[i]->getComponentID() == - parent->getComponentID()) - iindex = i; - return createIndex(iindex, 0, (void *)parent->getComponentID()); - } catch (...) { - // std::cout<<"Exception: in parent"<<'\n'; + if (!index.isValid()) // the index corresponds to root so there is no parent + // for root return empty. + return QModelIndex(); + + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + auto compIndex = extractIndex(index); + + if (compIndex == componentInfo.root()) + return QModelIndex(); + + auto parent = componentInfo.parent(compIndex); + if (parent == componentInfo.root()) + return createIndex(0, 0, &m_componentIndices[componentInfo.root()]); + + auto grandParent = componentInfo.parent(parent); + const auto &grandParentElems = componentInfo.children(grandParent); + + int row = 0; + for (auto child : grandParentElems) { + if (child == parent) + break; + row++; } - return QModelIndex(); + + return createIndex(row, 0, &m_componentIndices[parent]); } /** @@ -184,37 +148,22 @@ QModelIndex InstrumentTreeModel::parent(const QModelIndex &index) const { * ObjComponent row count will be 0. */ int InstrumentTreeModel::rowCount(const QModelIndex &parent) const { - // std::cout<<"rowCount +++++++++ row"<<parent.row()<<" column - //"<<parent.column()<<" is valid "<<parent.isValid()<<'\n'; - - try { - if (!parent.isValid()) // Root node row count is one. - { - return 1; // boost::dynamic_pointer_cast<ICompAssembly>(m_instrument)->nelements(); - } else { - auto instr = m_instrWidget->getInstrumentActor().getInstrument(); - if (instr->getComponentID() == static_cast<Mantid::Geometry::ComponentID>( - parent.internalPointer())) { - return instr->nelements(); - } - boost::shared_ptr<const IComponent> comp = - instr->getComponentByID(static_cast<Mantid::Geometry::ComponentID>( - parent - .internalPointer())); // static_cast<IComponent*>(parent.internalPointer()); - boost::shared_ptr<const ICompAssembly> assembly = - boost::dynamic_pointer_cast<const ICompAssembly>(comp); - if (assembly) { - return assembly->nelements(); - } - boost::shared_ptr<const IObjComponent> objcomp = - boost::dynamic_pointer_cast<const IObjComponent>(comp); - if (objcomp) - return 0; - } - } catch (...) { - // std::cout<<"Exception: in rowCount"<<'\n'; - } + if (!parent.isValid()) // Root node row count is one. + return 1; + + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + auto index = extractIndex(parent); + const auto &children = componentInfo.children(index); + if (children.size() > 0) + return static_cast<int>(children.size()); + return 0; } + +size_t InstrumentTreeModel::extractIndex(const QModelIndex &index) { + auto indexPtr = static_cast<size_t *>(index.internalPointer()); + return *indexPtr; +} } // MantidWidgets } // MantidQt diff --git a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp index 7c544f93935c4a9da0b21bf04f370f004a54adb4..b1413de658ea0ab178dbf1ddd2320a1bfaf9b26d 100644 --- a/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentTreeWidget.cpp @@ -6,9 +6,9 @@ #include "MantidKernel/Exception.h" #include "MantidGeometry/ICompAssembly.h" #include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidAPI/Sample.h" -#include "MantidQtWidgets/InstrumentView/GLActor.h" #include <queue> #include <QMessageBox> #include <QString> @@ -35,73 +35,17 @@ void InstrumentTreeWidget::getSelectedBoundingBox(const QModelIndex &index, double &xmax, double &ymax, double &zmax, double &xmin, double &ymin, double &zmin) { - Mantid::Geometry::Instrument_const_sptr instrument = - m_instrWidget->getInstrumentActor().getInstrument(); - // Check whether its instrument - boost::shared_ptr<const Mantid::Geometry::IComponent> selectedComponent; - if (instrument->getComponentID() == - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())) - selectedComponent = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - instrument); - else - selectedComponent = instrument->getComponentByID( - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer())); + const auto &componentInfo = + m_instrWidget->getInstrumentActor().componentInfo(); + auto compIndex = InstrumentTreeModel::extractIndex(index); + auto bb = componentInfo.boundingBox(compIndex); - // get the bounding box for the component - xmax = ymax = zmax = -DBL_MAX; - xmin = ymin = zmin = DBL_MAX; - Mantid::Geometry::BoundingBox boundBox; - std::queue<boost::shared_ptr<const Mantid::Geometry::IComponent>> CompList; - CompList.push(selectedComponent); - while (!CompList.empty()) { - boost::shared_ptr<const Mantid::Geometry::IComponent> tmp = - CompList.front(); - CompList.pop(); - boost::shared_ptr<const Mantid::Geometry::IObjComponent> tmpObj = - boost::dynamic_pointer_cast<const Mantid::Geometry::IObjComponent>(tmp); - if (tmpObj) { - try { - // std::cerr << int(tmpObj->getComponentID()) << ' ' << - // int(instrument->getSample()->getComponentID()) << '\n'; - if (tmpObj->getComponentID() == - instrument->getSample()->getComponentID()) { - boundBox = m_instrWidget->getInstrumentActor() - .getWorkspace() - ->sample() - .getShape() - .getBoundingBox(); - boundBox.moveBy(tmpObj->getPos()); - } else { - tmpObj->getBoundingBox(boundBox); - } - double txmax(boundBox.xMax()), tymax(boundBox.yMax()), - tzmax(boundBox.zMax()), txmin(boundBox.xMin()), - tymin(boundBox.yMin()), tzmin(boundBox.zMin()); - if (txmax > xmax) - xmax = txmax; - if (tymax > ymax) - ymax = tymax; - if (tzmax > zmax) - zmax = tzmax; - if (txmin < xmin) - xmin = txmin; - if (tymin < ymin) - ymin = tymin; - if (tzmin < zmin) - zmin = tzmin; - } catch (Mantid::Kernel::Exception::NullPointerException &) { - } - } else if (boost::dynamic_pointer_cast< - const Mantid::Geometry::ICompAssembly>(tmp)) { - boost::shared_ptr<const Mantid::Geometry::ICompAssembly> tmpAssem = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - tmp); - for (int idx = 0; idx < tmpAssem->nelements(); idx++) { - CompList.push((*tmpAssem)[idx]); - } - } - } + xmax = bb.xMax(); + ymax = bb.yMax(); + zmax = bb.zMax(); + xmin = bb.xMin(); + ymin = bb.yMin(); + zmin = bb.zMin(); } QModelIndex @@ -121,11 +65,9 @@ InstrumentTreeWidget::findComponentByName(const QString &name) const { void InstrumentTreeWidget::sendComponentSelectedSignal( const QModelIndex index) { - Mantid::Geometry::ComponentID id = - static_cast<Mantid::Geometry::ComponentID>(index.internalPointer()); - auto visitor = SetVisibleComponentVisitor(id); - m_instrWidget->getInstrumentActor().accept(visitor); - emit componentSelected(id); + auto selectedIndex = InstrumentTreeModel::extractIndex(index); + m_instrWidget->getInstrumentActor().setComponentVisible(selectedIndex); + emit componentSelected(selectedIndex); } /** Get a list of components that have been expanded diff --git a/qt/widgets/instrumentview/src/InstrumentWidget.cpp b/qt/widgets/instrumentview/src/InstrumentWidget.cpp index a7f95ce00e731a280b2fc77054eeca320ca5ef9e..ce2567b09b38c6c2bef0c95a0884346692c34302 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidget.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidget.cpp @@ -7,6 +7,7 @@ #include "MantidQtWidgets/InstrumentView/InstrumentWidgetPickTab.h" #include "MantidQtWidgets/InstrumentView/InstrumentWidgetRenderTab.h" #include "MantidQtWidgets/InstrumentView/InstrumentWidgetTreeTab.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidAPI/Axis.h" #include "MantidAPI/IMaskWorkspace.h" @@ -259,8 +260,8 @@ void InstrumentWidget::init(bool resetGeometry, bool autoscaling, if (resetGeometry || !surface) { if (setDefaultView) { // set the view type to the instrument's default view - QString defaultView = QString::fromStdString( - m_instrumentActor->getInstrument()->getDefaultView()); + QString defaultView = + QString::fromStdString(m_instrumentActor->getDefaultView()); if (defaultView == "3D" && Mantid::Kernel::ConfigService::Instance().getString( "MantidOptions.InstrumentView.UseOpenGL") != "On") { @@ -400,13 +401,11 @@ void InstrumentWidget::setSurfaceType(int type) { // If anything throws during surface creation, store error message here QString errorMessage; try { - Mantid::Geometry::Instrument_const_sptr instr = - m_instrumentActor->getInstrument(); - Mantid::Geometry::IComponent_const_sptr sample = instr->getSample(); - if (!sample) { + const auto &componentInfo = m_instrumentActor->componentInfo(); + if (!componentInfo.hasSample()) { throw InstrumentHasNoSampleError(); } - Mantid::Kernel::V3D sample_pos = sample->getPos(); + auto sample_pos = componentInfo.samplePosition(); auto axis = getSurfaceAxis(surfaceType); // create the surface @@ -824,11 +823,10 @@ void InstrumentWidget::setBinRange(double xmin, double xmax) { * is visible the rest of the instrument is hidden. * @param id :: The component id. */ -void InstrumentWidget::componentSelected(ComponentID id) { +void InstrumentWidget::componentSelected(size_t componentIndex) { auto surface = getSurface(); if (surface) { - surface->componentSelected(id); - // surface->updateView(); + surface->componentSelected(componentIndex); updateInstrumentView(); } } @@ -1215,8 +1213,7 @@ QString InstrumentWidget::getSettingsGroupName() const { */ QString InstrumentWidget::getInstrumentSettingsGroupName() const { return QString::fromAscii(InstrumentWidgetSettingsGroup) + "/" + - QString::fromStdString( - getInstrumentActor().getInstrument()->getName()); + QString::fromStdString(getInstrumentActor().getInstrumentName()); } bool InstrumentWidget::hasWorkspace(const std::string &wsName) const { diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetMaskTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetMaskTab.cpp index 75bc66eb95cd63a41fc923b0555e063fcbcfe1d7..a70b38899dd489ba248ddc06f0511b1522af1859 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetMaskTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetMaskTab.cpp @@ -729,9 +729,10 @@ void InstrumentWidgetMaskTab::saveMaskToTable() { */ void InstrumentWidgetMaskTab::extractDetsToWorkspace() { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - QList<int> dets; + std::vector<size_t> dets; m_instrWidget->getSurface()->getMaskedDetectors(dets); - DetXMLFile mapFile(dets); + const auto &actor = m_instrWidget->getInstrumentActor(); + DetXMLFile mapFile(actor.getDetIDs(dets)); std::string fname = mapFile(); if (!fname.empty()) { std::string workspaceName = m_instrWidget->getWorkspaceName().toStdString(); @@ -751,9 +752,10 @@ void InstrumentWidgetMaskTab::extractDetsToWorkspace() { */ void InstrumentWidgetMaskTab::sumDetsToWorkspace() { QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); - QList<int> dets; + std::vector<size_t> dets; m_instrWidget->getSurface()->getMaskedDetectors(dets); - DetXMLFile mapFile(dets, DetXMLFile::Sum); + DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getDetIDs(dets), + DetXMLFile::Sum); std::string fname = mapFile(); if (!fname.empty()) { @@ -773,9 +775,10 @@ void InstrumentWidgetMaskTab::saveIncludeGroupToFile() { QString fname = m_instrWidget->getSaveFileName("Save grouping file", "XML files (*.xml);;All (*)"); if (!fname.isEmpty()) { - QList<int> dets; + std::vector<size_t> dets; m_instrWidget->getSurface()->getMaskedDetectors(dets); - DetXMLFile mapFile(dets, DetXMLFile::Sum, fname); + DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getDetIDs(dets), + DetXMLFile::Sum, fname); } } @@ -783,10 +786,10 @@ void InstrumentWidgetMaskTab::saveExcludeGroupToFile() { QString fname = m_instrWidget->getSaveFileName("Save grouping file", "XML files (*.xml);;All (*)"); if (!fname.isEmpty()) { - QList<int> dets; + std::vector<size_t> dets; m_instrWidget->getSurface()->getMaskedDetectors(dets); - DetXMLFile mapFile(m_instrWidget->getInstrumentActor().getAllDetIDs(), dets, - fname); + const auto &actor = m_instrWidget->getInstrumentActor(); + DetXMLFile mapFile(actor.getAllDetIDs(), actor.getDetIDs(dets), fname); } } @@ -1109,11 +1112,12 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { m_instrWidget->updateInstrumentView(); // to refresh the pick image Mantid::API::IMaskWorkspace_sptr wsFresh; - QList<int> dets; + const auto &actor = m_instrWidget->getInstrumentActor(); + std::vector<size_t> dets; // get detectors covered by the shapes m_instrWidget->getSurface()->getMaskedDetectors(dets); - if (!dets.isEmpty()) { - auto wsMask = m_instrWidget->getInstrumentActor().getMaskWorkspace(); + if (!dets.empty()) { + auto wsMask = actor.getMaskWorkspace(); // have to cast up to the MaskWorkspace to get access to clone() std::set<Mantid::detid_t> detList; @@ -1122,21 +1126,22 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { // but not if the mask is fresh and empty if (wsMask->getNumberMasked() > 0) { wsFresh = boost::dynamic_pointer_cast<Mantid::API::IMaskWorkspace>( - m_instrWidget->getInstrumentActor().extractCurrentMask()); - m_instrWidget->getInstrumentActor().invertMaskWorkspace(); + actor.extractCurrentMask()); + actor.invertMaskWorkspace(); } } - foreach (int id, dets) { detList.insert(id); } + for (auto det : dets) + detList.insert(actor.getDetID(det)); if (!detList.empty()) { // try to mask each detector separately and ignore any failure - for (auto det = detList.begin(); det != detList.end(); ++det) { + for (auto det : detList) { try { if (isROI && wsFresh) { - if (wsMask->isMasked(*det)) - wsFresh->setMasked(*det); + if (wsMask->isMasked(det)) + wsFresh->setMasked(det); } else { - wsMask->setMasked(*det); + wsMask->setMasked(det); } } catch (...) { } @@ -1160,7 +1165,7 @@ void InstrumentWidgetMaskTab::storeDetectorMask(bool isROI) { } void InstrumentWidgetMaskTab::storeBinMask() { - QList<int> dets; + std::vector<size_t> dets; // get detectors covered by the shapes m_instrWidget->getSurface()->getMaskedDetectors(dets); // mask some bins diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp index 496923915c005bed1c06245cdf02d353e0591335..5b38aa26b77d345da00c8383f69718701331eccc 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetPickTab.cpp @@ -18,6 +18,8 @@ #include "MantidAPI/Sample.h" #include "MantidAPI/WorkspaceFactory.h" #include "MantidGeometry/Crystal/OrientedLattice.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" #include "MantidKernel/V3D.h" #include "qwt_scale_widget.h" @@ -51,10 +53,20 @@ namespace MantidWidgets { using namespace boost::math; -/// to be used in std::transform -struct Sqrt { - double operator()(double x) { return sqrt(x); } -}; +namespace { +// Get the phi angle between the detector with reference to the origin +// Makes assumptions about beam direction. Legacy code and not robust. +double getPhi(const Mantid::Kernel::V3D &pos) { + return std::atan2(pos[1], pos[0]); +} + +// Calculate the phi angle between detector and beam, and then offset. +// Makes assumptions about beam direction. Legacy code and not robust. +double getPhiOffset(const Mantid::Kernel::V3D &pos, const double offset) { + double avgPos = getPhi(pos); + return avgPos < 0 ? -(offset + avgPos) : offset - avgPos; +} +} // namespace /** * Constructor. @@ -729,7 +741,7 @@ void InstrumentWidgetPickTab::updatePlotMultipleDetectors() { return; ProjectionSurface &surface = *getSurface(); if (surface.hasMasks()) { - QList<int> dets; + std::vector<size_t> dets; surface.getMaskedDetectors(dets); m_plotController->setPlotData(dets); } else { @@ -804,7 +816,8 @@ ComponentInfoController::ComponentInfoController( QTextEdit *infoDisplay) : QObject(tab), m_tab(tab), m_instrWidget(instrWidget), m_selectionInfoDisplay(infoDisplay), m_freezePlot(false), - m_instrWidgetBlocked(false), m_currentPickID(-1) {} + m_instrWidgetBlocked(false), + m_currentPickID(std::numeric_limits<size_t>::max()) {} /** * Display info on a component refered to by a pick ID. @@ -817,10 +830,10 @@ void ComponentInfoController::displayInfo(size_t pickID) { } const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); QString text = ""; - int detid = actor.getDetID(pickID); - if (detid >= 0) { - text += displayDetectorInfo(detid); + if (componentInfo.isDetector(pickID)) { + text += displayDetectorInfo(pickID); } else if (auto componentID = actor.getComponentID(pickID)) { text += displayNonDetectorInfo(componentID); } else { @@ -838,57 +851,52 @@ void ComponentInfoController::displayInfo(size_t pickID) { /** * Return string with info on a detector. -* @param detid :: A detector ID. +* @param index :: A detector Index. */ -QString ComponentInfoController::displayDetectorInfo(Mantid::detid_t detid) { +QString ComponentInfoController::displayDetectorInfo(size_t index) { if (m_instrWidgetBlocked) { clear(); return ""; } QString text; - if (detid >= 0) { - // collect info about selected detector and add it to text - const auto &actor = m_instrWidget->getInstrumentActor(); - auto &det = actor.getDetectorByDetID(detid); - - text = "Selected detector: " + QString::fromStdString(det.getName()) + "\n"; - text += "Detector ID: " + QString::number(detid) + '\n'; - QString wsIndex; - try { - wsIndex = QString::number(actor.getWorkspaceIndex(detid)); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - // Detector doesn't have a workspace index relating to it - wsIndex = "None"; - } - text += "Workspace index: " + wsIndex + '\n'; - Mantid::Kernel::V3D pos = det.getPos(); - text += "xyz: " + QString::number(pos.X()) + "," + - QString::number(pos.Y()) + "," + QString::number(pos.Z()) + '\n'; - double r, t, p; - pos.getSpherical(r, t, p); - text += "rtp: " + QString::number(r) + "," + QString::number(t) + "," + - QString::number(p) + '\n'; - Mantid::Geometry::ICompAssembly_const_sptr parent = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - det.getParent()); - if (parent) { - QString textpath; - while (parent) { - textpath = "/" + QString::fromStdString(parent->getName()) + textpath; - parent = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - parent->getParent()); - } - text += "Component path:" + textpath + "/" + - QString::fromStdString(det.getName()) + '\n'; + + // collect info about selected detector and add it to text + const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); + auto detid = actor.getDetID(index); + + text = "Selected detector: " + + QString::fromStdString(componentInfo.name(index)) + "\n"; + text += "Detector ID: " + QString::number(detid) + '\n'; + QString wsIndex; + auto ws = actor.getWorkspaceIndex(index); + wsIndex = ws == InstrumentActor::INVALID_INDEX ? "None" : QString::number(ws); + text += "Workspace index: " + wsIndex + '\n'; + Mantid::Kernel::V3D pos = componentInfo.position(index); + text += "xyz: " + QString::number(pos.X()) + "," + QString::number(pos.Y()) + + "," + QString::number(pos.Z()) + '\n'; + double r, t, p; + pos.getSpherical(r, t, p); + text += "rtp: " + QString::number(r) + "," + QString::number(t) + "," + + QString::number(p) + '\n'; + if (componentInfo.hasParent(index)) { + QString textpath; + auto parent = index; + while (componentInfo.hasParent(parent)) { + parent = componentInfo.parent(parent); + textpath = + "/" + QString::fromStdString(componentInfo.name(parent)) + textpath; } - const double integrated = actor.getIntegratedCounts(detid); + text += "Component path:" + textpath + "/" + + QString::fromStdString(componentInfo.name(index)) + '\n'; + + const double integrated = actor.getIntegratedCounts(index); const QString counts = integrated == -1.0 ? "N/A" : QString::number(integrated); text += "Counts: " + counts + '\n'; // display info about peak overlays - text += getParameterInfo(det); + text += actor.getParameterInfo(index); } return text; } @@ -900,19 +908,19 @@ QString ComponentInfoController::displayDetectorInfo(Mantid::detid_t detid) { */ QString ComponentInfoController::displayNonDetectorInfo( Mantid::Geometry::ComponentID compID) { - auto component = - m_instrWidget->getInstrumentActor().getInstrument()->getComponentByID( - compID); + const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); + auto component = componentInfo.indexOf(compID); QString text = "Selected component: "; - text += QString::fromStdString(component->getName()) + '\n'; - Mantid::Kernel::V3D pos = component->getPos(); + text += QString::fromStdString(componentInfo.name(component)) + '\n'; + Mantid::Kernel::V3D pos = componentInfo.position(component); text += "xyz: " + QString::number(pos.X()) + "," + QString::number(pos.Y()) + "," + QString::number(pos.Z()) + '\n'; double r, t, p; pos.getSpherical(r, t, p); text += "rtp: " + QString::number(r) + "," + QString::number(t) + "," + QString::number(p) + '\n'; - text += getParameterInfo(*component); + text += actor.getParameterInfo(component); return text; } @@ -1040,59 +1048,6 @@ void ComponentInfoController::displayAlignPeaksInfo( m_selectionInfoDisplay->setText(QString::fromStdString(text.str())); } -/** -* Form a string for output from the components instrument parameters -*/ -QString ComponentInfoController::getParameterInfo( - const Mantid::Geometry::IComponent &comp) { - QString text = ""; - std::map<Mantid::Geometry::ComponentID, std::vector<std::string>> - mapCmptToNameVector; - - auto paramNames = comp.getParameterNamesByComponent(); - for (auto itParamName = paramNames.begin(); itParamName != paramNames.end(); - ++itParamName) { - // build the data structure I need Map comp id -> vector of names - std::string paramName = itParamName->first; - Mantid::Geometry::ComponentID paramCompId = itParamName->second; - // attempt to insert this will fail silently if the key already exists - if (mapCmptToNameVector.find(paramCompId) == mapCmptToNameVector.end()) { - mapCmptToNameVector.emplace(paramCompId, std::vector<std::string>()); - } - // get the vector out and add the name - mapCmptToNameVector[paramCompId].push_back(paramName); - } - - // walk out from the selected component - const Mantid::Geometry::IComponent *paramComp = ∁ - boost::shared_ptr<const Mantid::Geometry::IComponent> parentComp; - while (paramComp) { - auto id = paramComp->getComponentID(); - auto &compParamNames = mapCmptToNameVector[id]; - if (compParamNames.size() > 0) { - text += QString::fromStdString("\nParameters from: " + - paramComp->getName() + "\n"); - std::sort(compParamNames.begin(), compParamNames.end(), - Mantid::Kernel::CaseInsensitiveStringComparator()); - for (auto itParamName = compParamNames.begin(); - itParamName != compParamNames.end(); ++itParamName) { - std::string paramName = *itParamName; - // no need to search recursively as we are asking from the matching - // component - std::string paramValue = - paramComp->getParameterAsString(paramName, false); - if (paramValue != "") { - text += QString::fromStdString(paramName + ": " + paramValue + "\n"); - } - } - } - parentComp = paramComp->getParent(); - paramComp = parentComp.get(); - } - - return text; -} - /** * Return non-detector info to be displayed in the selection info display. */ @@ -1123,7 +1078,7 @@ DetectorPlotController::DetectorPlotController(InstrumentWidgetPickTab *tab, OneCurvePlot *plot) : QObject(tab), m_tab(tab), m_instrWidget(instrWidget), m_plot(plot), m_plotType(Single), m_enabled(true), m_tubeXUnits(DETECTOR_ID), - m_currentDetID(-1) { + m_currentPickID(std::numeric_limits<size_t>::max()) { connect(m_plot, SIGNAL(clickedAt(double, double)), this, SLOT(addPeak(double, double))); } @@ -1134,25 +1089,25 @@ DetectorPlotController::DetectorPlotController(InstrumentWidgetPickTab *tab, * @param pickID :: A pick ID of an instrument component. */ void DetectorPlotController::setPlotData(size_t pickID) { - m_currentDetID = -1; + m_currentPickID = std::numeric_limits<size_t>::max(); if (m_plotType == DetectorSum) { m_plotType = Single; } - const int detid = m_instrWidget->getInstrumentActor().getDetID(pickID); - if (!m_enabled) { m_plot->clearCurve(); return; } - if (detid >= 0) { + const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); + if (componentInfo.isDetector(pickID)) { if (m_plotType == Single) { - m_currentDetID = detid; - plotSingle(detid); + m_currentPickID = pickID; + plotSingle(pickID); } else if (m_plotType == TubeSum || m_plotType == TubeIntegral) { - plotTube(detid); + plotTube(pickID); } else { throw std::logic_error("setPlotData: Unexpected plot type."); } @@ -1163,15 +1118,16 @@ void DetectorPlotController::setPlotData(size_t pickID) { /** * Set curev data from multiple detectors: sum their spectra. -* @param detIDs :: A list of detector IDs. +* @param detIndices :: A list of detector Indices. */ -void DetectorPlotController::setPlotData(QList<int> detIDs) { +void DetectorPlotController::setPlotData( + const std::vector<size_t> &detIndices) { setPlotType(DetectorSum); clear(); std::vector<double> x, y; QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); const auto &actor = m_instrWidget->getInstrumentActor(); - actor.sumDetectors(detIDs, x, y, static_cast<size_t>(m_plot->width())); + actor.sumDetectors(detIndices, x, y, static_cast<size_t>(m_plot->width())); QApplication::restoreOverrideCursor(); if (!x.empty()) { m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()), @@ -1198,23 +1154,20 @@ void DetectorPlotController::clear() { /** * Plot data for a detector. -* @param detid :: ID of the detector to be plotted. +* @param detindex :: Index of the detector to be plotted. */ -void DetectorPlotController::plotSingle(int detid) { - +void DetectorPlotController::plotSingle(size_t detindex) { clear(); std::vector<double> x, y; - prepareDataForSinglePlot(detid, x, y); + prepareDataForSinglePlot(detindex, x, y); if (x.empty() || y.empty()) return; + const auto &actor = m_instrWidget->getInstrumentActor(); // set the data m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()), - m_instrWidget->getInstrumentActor() - .getWorkspace() - ->getAxis(0) - ->unit() - ->unitID()); + actor.getWorkspace()->getAxis(0)->unit()->unitID()); + auto detid = actor.getDetID(detindex); m_plot->setLabel("Detector " + QString::number(detid)); // find any markers @@ -1237,50 +1190,53 @@ void DetectorPlotController::plotSingle(int detid) { * LENGTH * PHI * The units can be set with setTubeXUnits(...) method. -* @param detid :: A detector id. The miniplot will display data for a component +* @param detindex :: A detector index. The miniplot will display data for a +* component * containing the detector * with this id. */ -void DetectorPlotController::plotTube(int detid) { +void DetectorPlotController::plotTube(size_t detindex) { const auto &actor = m_instrWidget->getInstrumentActor(); - auto &det = actor.getDetectorByDetID(detid); - boost::shared_ptr<const Mantid::Geometry::IComponent> parent = - det.getParent(); - Mantid::Geometry::ICompAssembly_const_sptr ass = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - parent); - if (parent && ass) { + const auto &componentInfo = actor.componentInfo(); + + if (!componentInfo.hasParent(detindex)) { + m_plot->clearCurve(); + return; + } + + auto parent = componentInfo.parent(detindex); + if (componentInfo.detectorsInSubtree(parent).size() > 0) { if (m_plotType == TubeSum) // plot sums over detectors vs time bins { - plotTubeSums(detid); + plotTubeSums(detindex); } else // plot detector integrals vs detID or a function of detector // position in the tube { assert(m_plotType == TubeIntegral); - plotTubeIntegrals(detid); + plotTubeIntegrals(detindex); } - } else { - m_plot->clearCurve(); } } /** * Plot the accumulated data in a tube against time of flight. -* @param detid :: A detector id. The miniplot will display data for a component +* @param detindex :: A detector id. The miniplot will display data for a +* component * containing the detector * with this id. */ -void DetectorPlotController::plotTubeSums(int detid) { +void DetectorPlotController::plotTubeSums(size_t detindex) { std::vector<double> x, y; - prepareDataForSumsPlot(detid, x, y); + prepareDataForSumsPlot(detindex, x, y); if (x.empty() || y.empty()) { clear(); return; } const auto &actor = m_instrWidget->getInstrumentActor(); - auto &det = actor.getDetectorByDetID(detid); - auto parent = det.getParent(); - QString label = QString::fromStdString(parent->getName()) + " (" + + const auto &componentInfo = actor.componentInfo(); + auto parent = componentInfo.parent(detindex); + auto detid = actor.getDetID(detindex); + QString label = QString::fromStdString(componentInfo.name(parent)) + " (" + QString::number(detid) + ") Sum"; m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()), actor.getWorkspace()->getAxis(0)->unit()->unitID()); @@ -1295,14 +1251,16 @@ void DetectorPlotController::plotTubeSums(int detid) { * LENGTH * PHI * The units can be set with setTubeXUnits(...) method. -* @param detid :: A detector id. The miniplot will display data for a component +* @param detindex :: A detector index. The miniplot will display data for a +* component * containing the detector * with this id. */ -void DetectorPlotController::plotTubeIntegrals(int detid) { - auto &det = m_instrWidget->getInstrumentActor().getDetectorByDetID(detid); +void DetectorPlotController::plotTubeIntegrals(size_t detindex) { + const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); std::vector<double> x, y; - prepareDataForIntegralsPlot(detid, x, y); + prepareDataForIntegralsPlot(detindex, x, y); if (x.empty() || y.empty()) { clear(); return; @@ -1314,32 +1272,30 @@ void DetectorPlotController::plotTubeIntegrals(int detid) { } m_plot->setData(&x[0], &y[0], static_cast<int>(y.size()), xAxisCaption.toStdString()); - auto parent = det.getParent(); + auto parent = componentInfo.parent(detindex); // curve label: "tube_name (detid) Integrals" // detid is included to distiguish tubes with the same name - QString label = QString::fromStdString(parent->getName()) + " (" + - QString::number(detid) + ") Integrals/" + getTubeXUnitsName(); + QString label = QString::fromStdString(componentInfo.name(parent)) + " (" + + QString::number(actor.getDetID(detindex)) + ") Integrals/" + + getTubeXUnitsName(); m_plot->setLabel(label); } /** * Prepare data for plotting a spectrum of a single detector. -* @param detid :: ID of the detector to be plotted. +* @param detindex :: Index of the detector to be plotted. * @param x :: Vector of x coordinates (output) * @param y :: Vector of y coordinates (output) * @param err :: Optional pointer to a vector of errors (output) */ void DetectorPlotController::prepareDataForSinglePlot( - int detid, std::vector<double> &x, std::vector<double> &y, + size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err) { const auto &actor = m_instrWidget->getInstrumentActor(); Mantid::API::MatrixWorkspace_const_sptr ws = actor.getWorkspace(); - size_t wi; - try { - wi = actor.getWorkspaceIndex(detid); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - return; // Detector doesn't have a workspace index relating to it - } + auto wi = actor.getWorkspaceIndex(detindex); + if (wi == InstrumentActor::INVALID_INDEX) + return; // get the data const auto &XPoints = ws->points(wi); const auto &Y = ws->y(wi); @@ -1358,29 +1314,28 @@ void DetectorPlotController::prepareDataForSinglePlot( /** * Prepare data for plotting accumulated data in a tube against time of flight. -* @param detid :: A detector id. The miniplot will display data for a component -* containing the detector -* with this id. +* @param detindex :: A detector index. The miniplot will display data for a +* component +* containing the detector with this index. * @param x :: Vector of x coordinates (output) * @param y :: Vector of y coordinates (output) * @param err :: Optional pointer to a vector of errors (output) */ -void DetectorPlotController::prepareDataForSumsPlot(int detid, +void DetectorPlotController::prepareDataForSumsPlot(size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err) { const auto &actor = m_instrWidget->getInstrumentActor(); auto ws = actor.getWorkspace(); - auto &det = actor.getDetectorByDetID(detid); - auto parent = det.getParent(); - auto ass = boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - parent); - size_t wi; - try { - wi = actor.getWorkspaceIndex(detid); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - return; // Detector doesn't have a workspace index relating to it - } + const auto &componentInfo = actor.componentInfo(); + auto parent = componentInfo.parent(detindex); + auto ass = componentInfo.detectorsInSubtree(parent); + + auto wi = actor.getWorkspaceIndex(detindex); + + if (wi == InstrumentActor::INVALID_INDEX) + return; + size_t imin, imax; actor.getBinMinMaxIndex(wi, imin, imax); @@ -1390,33 +1345,29 @@ void DetectorPlotController::prepareDataForSumsPlot(int detid, if (err) err->resize(x.size(), 0); - const int n = ass->nelements(); - for (int i = 0; i < n; ++i) { - Mantid::Geometry::IDetector_sptr idet = - boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); - if (idet) { - try { - size_t index = actor.getWorkspaceIndex(idet->getID()); - const auto &Y = ws->y(index); - std::transform(y.begin(), y.end(), Y.begin() + imin, y.begin(), + for (auto det : ass) { + if (componentInfo.isDetector(det)) { + auto index = actor.getWorkspaceIndex(det); + if (index == InstrumentActor::INVALID_INDEX) + continue; + const auto &Y = ws->y(index); + std::transform(y.begin(), y.end(), Y.begin() + imin, y.begin(), + std::plus<double>()); + if (err) { + const auto &E = ws->e(index); + std::vector<double> tmp; + tmp.assign(E.begin() + imin, E.begin() + imax); + std::transform(tmp.begin(), tmp.end(), tmp.begin(), tmp.begin(), + std::multiplies<double>()); + std::transform(err->begin(), err->end(), tmp.begin(), err->begin(), std::plus<double>()); - if (err) { - const auto &E = ws->e(index); - std::vector<double> tmp; - tmp.assign(E.begin() + imin, E.begin() + imax); - std::transform(tmp.begin(), tmp.end(), tmp.begin(), tmp.begin(), - std::multiplies<double>()); - std::transform(err->begin(), err->end(), tmp.begin(), err->begin(), - std::plus<double>()); - } - } catch (Mantid::Kernel::Exception::NotFoundError &) { - continue; // Detector doesn't have a workspace index relating to it } } } if (err) - std::transform(err->begin(), err->end(), err->begin(), Sqrt()); + std::transform(err->begin(), err->end(), err->begin(), + [](double val) { return sqrt(val); }); } /** @@ -1430,14 +1381,13 @@ void DetectorPlotController::prepareDataForSumsPlot(int detid, * OUT_OF_PLANE_ANGLE * The units can be set with setTubeXUnits(...) method. * @param detid :: A detector id. The miniplot will display data for a component -* containing the detector -* with this id. +* containing the detector with this index. * @param x :: Vector of x coordinates (output) * @param y :: Vector of y coordinates (output) * @param err :: Optional pointer to a vector of errors (output) */ void DetectorPlotController::prepareDataForIntegralsPlot( - int detid, std::vector<double> &x, std::vector<double> &y, + size_t detindex, std::vector<double> &x, std::vector<double> &y, std::vector<double> *err) { #define PREPAREDATAFORINTEGRALSPLOT_RETURN_FAILED \ @@ -1448,32 +1398,26 @@ void DetectorPlotController::prepareDataForIntegralsPlot( return; const auto &actor = m_instrWidget->getInstrumentActor(); + const auto &componentInfo = actor.componentInfo(); Mantid::API::MatrixWorkspace_const_sptr ws = actor.getWorkspace(); // Does the instrument definition specify that psi should be offset. - std::vector<std::string> parameters = - ws->getInstrument()->getStringParameter("offset-phi"); + std::vector<std::string> parameters = actor.getStringParameter("offset-phi"); const bool bOffsetPsi = (!parameters.empty()) && std::find(parameters.begin(), parameters.end(), "Always") != parameters.end(); - - auto &det = actor.getDetectorByDetID(detid); - auto parent = det.getParent(); - auto ass = boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - parent); - size_t wi; - try { - wi = actor.getWorkspaceIndex(detid); - } catch (Mantid::Kernel::Exception::NotFoundError &) { - return; // Detector doesn't have a workspace index relating to it - } + auto parent = componentInfo.parent(detindex); + auto ass = componentInfo.detectorsInSubtree(parent); + auto wi = actor.getWorkspaceIndex(detindex); + if (wi == InstrumentActor::INVALID_INDEX) + return; // imin and imax give the bin integration range size_t imin, imax; actor.getBinMinMaxIndex(wi, imin, imax); - Mantid::Kernel::V3D samplePos = actor.getInstrument()->getSample()->getPos(); + auto samplePos = actor.componentInfo().samplePosition(); - const int n = ass->nelements(); + auto n = ass.size(); if (n == 0) { // don't think it's ever possible but... throw std::runtime_error("PickTab miniplot: empty instrument assembly"); @@ -1485,56 +1429,52 @@ void DetectorPlotController::prepareDataForIntegralsPlot( // collect and sort xy pairs in xymap std::map<double, double> xymap, errmap; // get the first detector in the tube for lenth calculation - Mantid::Geometry::IDetector_sptr idet0 = - boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[0]); - if (!idet0) { + if (!componentInfo.isDetector(ass[0])) { // it's not an assembly of detectors, // could be a mixture of monitors and other components PREPAREDATAFORINTEGRALSPLOT_RETURN_FAILED } - Mantid::Kernel::V3D normal = (*ass)[1]->getPos() - idet0->getPos(); + + auto normal = componentInfo.position(ass[1]) - componentInfo.position(ass[0]); normal.normalize(); - for (int i = 0; i < n; ++i) { - Mantid::Geometry::IDetector_sptr idet = - boost::dynamic_pointer_cast<Mantid::Geometry::IDetector>((*ass)[i]); - if (idet) { - try { - const int id = idet->getID(); - // get the x-value for detector idet - double xvalue = 0; - switch (m_tubeXUnits) { - case LENGTH: - xvalue = idet->getDistance(*idet0); - break; - case PHI: - xvalue = bOffsetPsi ? idet->getPhiOffset(M_PI) : idet->getPhi(); - break; - case OUT_OF_PLANE_ANGLE: { - Mantid::Kernel::V3D pos = idet->getPos(); - xvalue = getOutOfPlaneAngle(pos, samplePos, normal); - break; - } - default: - xvalue = static_cast<double>(id); - } - size_t index = actor.getWorkspaceIndex(id); - // get the y-value for detector idet - const auto &Y = ws->y(index); - double sum = std::accumulate(Y.begin() + imin, Y.begin() + imax, 0); - xymap[xvalue] = sum; - if (err) { - const auto &E = ws->e(index); - std::vector<double> tmp(imax - imin); - // take squares of the errors - std::transform(E.begin() + imin, E.begin() + imax, E.begin() + imin, - tmp.begin(), std::multiplies<double>()); - // sum them - double sum = std::accumulate(tmp.begin(), tmp.end(), 0); - // take sqrt - errmap[xvalue] = sqrt(sum); - } - } catch (Mantid::Kernel::Exception::NotFoundError &) { - continue; // Detector doesn't have a workspace index relating to it + const auto &detectorInfo = actor.detectorInfo(); + for (auto det : ass) { + if (componentInfo.isDetector(det)) { + auto id = detectorInfo.detectorIDs()[det]; + // get the x-value for detector idet + double xvalue = 0; + auto pos = detectorInfo.position(det); + switch (m_tubeXUnits) { + case LENGTH: + xvalue = pos.distance(detectorInfo.position(ass[0])); + break; + case PHI: + xvalue = bOffsetPsi ? getPhiOffset(pos, M_PI) : getPhi(pos); + break; + case OUT_OF_PLANE_ANGLE: { + xvalue = getOutOfPlaneAngle(pos, samplePos, normal); + break; + } + default: + xvalue = static_cast<double>(id); + } + auto index = actor.getWorkspaceIndex(det); + if (index == InstrumentActor::INVALID_INDEX) + continue; + // get the y-value for detector idet + const auto &Y = ws->y(index); + double sum = std::accumulate(Y.begin() + imin, Y.begin() + imax, 0); + xymap[xvalue] = sum; + if (err) { + const auto &E = ws->e(index); + std::vector<double> tmp(imax - imin); + // take squares of the errors + std::transform(E.begin() + imin, E.begin() + imax, E.begin() + imin, + tmp.begin(), std::multiplies<double>()); + // sum them + double sum = std::accumulate(tmp.begin(), tmp.end(), 0); + // take sqrt + errmap[xvalue] = sqrt(sum); } } } @@ -1590,7 +1530,7 @@ void DetectorPlotController::savePlotToWorkspace() { if (X.empty()) { // label doesn't have any info on how to reproduce the curve: // only the current curve can be saved - QList<int> dets; + std::vector<size_t> dets; m_tab->getSurface()->getMaskedDetectors(dets); actor.sumDetectors(dets, x, y); unitX = parentWorkspace->getAxis(0)->unit()->unitID(); @@ -1747,7 +1687,7 @@ QString DetectorPlotController::getPlotCaption() const { * @param y :: Peak height (counts) */ void DetectorPlotController::addPeak(double x, double y) { - if (m_currentDetID < 0) + if (m_currentPickID == std::numeric_limits<size_t>::max()) return; try { @@ -1798,11 +1738,13 @@ void DetectorPlotController::addPeak(double x, double y) { // Run the AddPeak algorithm auto alg = Mantid::API::FrameworkManager::Instance().createAlgorithm("AddPeak"); + const auto &detIDs = + m_instrWidget->getInstrumentActor().detectorInfo().detectorIDs(); alg->setPropertyValue("RunWorkspace", ws->getName()); alg->setPropertyValue("PeaksWorkspace", peakTableName); - alg->setProperty("DetectorID", m_currentDetID); + alg->setProperty("DetectorID", detIDs[m_currentPickID]); alg->setProperty("TOF", x); - alg->setProperty("Height", actor.getIntegratedCounts(m_currentDetID)); + alg->setProperty("Height", actor.getIntegratedCounts(m_currentPickID)); alg->setProperty("BinCount", y); alg->execute(); diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp index 6b33c5fe23b420a57029fd5a2ce1762670a113bf..f491739ba5f22db1130ef844d221fa729395603e 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetRenderTab.cpp @@ -287,7 +287,7 @@ void InstrumentWidgetRenderTab::enable3DSurface(bool on) { */ void InstrumentWidgetRenderTab::initSurface() { setAxis(QString::fromStdString( - m_instrWidget->getInstrumentActor().getInstrument()->getDefaultAxis())); + m_instrWidget->getInstrumentActor().getDefaultAxis())); auto surface = getSurface(); // 3D axes switch needs to be shown for the 3D surface @@ -474,9 +474,7 @@ void InstrumentWidgetRenderTab::showEvent(QShowEvent *) { if (surface) { surface->setInteractionMode(ProjectionSurface::MoveMode); } - auto &actor = m_instrWidget->getInstrumentActor(); - auto visitor = SetAllVisibleVisitor(actor.areGuidesShown()); - actor.accept(visitor); + getSurface()->updateView(); getSurface()->requestRedraw(); } diff --git a/qt/widgets/instrumentview/src/InstrumentWidgetTreeTab.cpp b/qt/widgets/instrumentview/src/InstrumentWidgetTreeTab.cpp index c703547ff0b7fa8a98c4bf2a988528b88fb2f079..a1c43a6ae19afaf8c4ccda088ede1b2b351791b3 100644 --- a/qt/widgets/instrumentview/src/InstrumentWidgetTreeTab.cpp +++ b/qt/widgets/instrumentview/src/InstrumentWidgetTreeTab.cpp @@ -1,6 +1,5 @@ #include "MantidQtWidgets/InstrumentView/InstrumentWidgetTreeTab.h" #include "MantidQtWidgets/Common/TSVSerialiser.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" #include "MantidQtWidgets/InstrumentView/InstrumentActor.h" #include "MantidQtWidgets/InstrumentView/InstrumentTreeWidget.h" #include "MantidQtWidgets/InstrumentView/InstrumentWidget.h" @@ -18,10 +17,8 @@ InstrumentWidgetTreeTab::InstrumentWidgetTreeTab(InstrumentWidget *instrWidget) // Tree Controls m_instrumentTree = new InstrumentTreeWidget(nullptr); layout->addWidget(m_instrumentTree); - connect(m_instrumentTree, - SIGNAL(componentSelected(Mantid::Geometry::ComponentID)), - m_instrWidget, - SLOT(componentSelected(Mantid::Geometry::ComponentID))); + connect(m_instrumentTree, SIGNAL(componentSelected(size_t)), m_instrWidget, + SLOT(componentSelected(size_t))); connect(m_instrWidget, SIGNAL(requestSelectComponent(QString)), this, SLOT(selectComponentByName(QString))); } diff --git a/qt/widgets/instrumentview/src/MantidGLWidget.cpp b/qt/widgets/instrumentview/src/MantidGLWidget.cpp index a4ecdee8ce2592f396364c97c17b6ecc301e1d57..2c9a39339847575243683ccf36d1a1c1714c4f72 100644 --- a/qt/widgets/instrumentview/src/MantidGLWidget.cpp +++ b/qt/widgets/instrumentview/src/MantidGLWidget.cpp @@ -283,9 +283,9 @@ void MantidGLWidget::draw() { OpenGLError::check("MantidGLWidget::drawUnwrapped()"); } -void MantidGLWidget::componentSelected(Mantid::Geometry::ComponentID id) { +void MantidGLWidget::componentSelected(size_t componentIndex) { if (m_surface) { - m_surface->componentSelected(id); + m_surface->componentSelected(componentIndex); m_surface->updateView(); update(); } diff --git a/qt/widgets/instrumentview/src/MaskBinsData.cpp b/qt/widgets/instrumentview/src/MaskBinsData.cpp index 5369b49164e2262e85298cec7b9dadc498396211..5c49f576ed9c5aa1940de1d24a1390c9b842b767 100644 --- a/qt/widgets/instrumentview/src/MaskBinsData.cpp +++ b/qt/widgets/instrumentview/src/MaskBinsData.cpp @@ -10,7 +10,7 @@ namespace MantidWidgets { /// Add a range of x values for bin masking. void MaskBinsData::addXRange(double start, double end, - const QList<int> &indices) { + const std::vector<size_t> &indices) { BinMask range(start, end); range.spectra = indices; m_masks.append(range); @@ -21,7 +21,10 @@ void MaskBinsData::addXRange(double start, double end, void MaskBinsData::mask(const std::string &wsName) const { for (auto mask = m_masks.begin(); mask != m_masks.end(); ++mask) { auto &spectra = mask->spectra; - std::vector<int> spectraList(spectra.begin(), spectra.end()); + std::vector<int> spectraList(spectra.size()); + std::transform(spectra.cbegin(), spectra.cend(), spectraList.begin(), + [](const size_t spec) + -> int { return static_cast<int>(spec); }); auto alg = Mantid::API::AlgorithmManager::Instance().create("MaskBins", -1); alg->setPropertyValue("InputWorkspace", wsName); alg->setPropertyValue("OutputWorkspace", wsName); @@ -69,12 +72,12 @@ void MaskBinsData::loadFromProject(const std::string &lines) { double start, end; mask >> start >> end; - QList<int> spectra; + std::vector<size_t> spectra; const size_t numSpectra = mask.values("Spectra").size(); for (size_t i = 0; i < numSpectra; ++i) { - int spectrum; + size_t spectrum; mask >> spectrum; - spectra.append(spectrum); + spectra.push_back(spectrum); } addXRange(start, end, spectra); @@ -90,7 +93,7 @@ std::string MaskBinsData::saveToProject() const { API::TSVSerialiser mask; mask.writeLine("Range") << binMask.start << binMask.end; mask.writeLine("Spectra"); - for (const int spectrum : binMask.spectra) { + for (auto spectrum : binMask.spectra) { mask << spectrum; } tsv.writeSection("Mask", mask.outputLines()); diff --git a/qt/widgets/instrumentview/src/ObjCompAssemblyActor.cpp b/qt/widgets/instrumentview/src/ObjCompAssemblyActor.cpp deleted file mode 100644 index 3c5da76700f8583e9bf27461e4337d935e8cf0dc..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/ObjCompAssemblyActor.cpp +++ /dev/null @@ -1,195 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/OpenGLError.h" - -#include "MantidKernel/V3D.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/ICompAssembly.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidGeometry/Instrument/ObjCompAssembly.h" -#include "MantidKernel/Exception.h" -#include <cfloat> -using namespace Mantid; -using namespace Geometry; - -namespace MantidQt { -namespace MantidWidgets { - -ObjCompAssemblyActor::ObjCompAssemblyActor(const InstrumentActor &instrActor, - Mantid::Geometry::ComponentID compID) - : ICompAssemblyActor(instrActor, compID), m_idData(0), m_idPick(0), - m_n(getObjCompAssembly()->nelements()), m_pick_data(), - m_texturesGenerated(false) { - - ObjCompAssembly_const_sptr objAss = getObjCompAssembly(); - mNumberOfDetectors = objAss->nelements(); - assert(static_cast<size_t>(m_n) == mNumberOfDetectors); - m_data = new unsigned char[m_n * 3]; - m_pick_data = new unsigned char[m_n * 3]; - for (size_t i = 0; i < getNumberOfDetectors(); ++i) { - IDetector_const_sptr det = boost::dynamic_pointer_cast<const IDetector>( - objAss->getChild(static_cast<int>(i))); - assert(det); - detid_t id = det->getID(); - m_detIDs.push_back(id); - size_t pickID = instrActor.pushBackDetid(id); - setDetectorColor(m_pick_data, i, GLActor::makePickColor(pickID)); - } - Mantid::Geometry::BoundingBox boundBox; - objAss->getBoundingBox(boundBox); - minBoundBox[0] = boundBox.xMin(); - minBoundBox[1] = boundBox.yMin(); - minBoundBox[2] = boundBox.zMin(); - maxBoundBox[0] = boundBox.xMax(); - maxBoundBox[1] = boundBox.yMax(); - maxBoundBox[2] = boundBox.zMax(); -} - -/** -* Destructor which removes the actors created by this object -*/ -ObjCompAssemblyActor::~ObjCompAssemblyActor() { - if (m_data) { - delete[] m_data; - delete[] m_pick_data; - } - if (m_texturesGenerated) { - glDeleteTextures(1, &m_idData); - glDeleteTextures(1, &m_idPick); - } -} - -/** -* This function is concrete implementation that renders the Child ObjComponents -* and Child CompAssembly's -*/ -void ObjCompAssemblyActor::draw(bool picking) const { - OpenGLError::check("ObjCompAssemblyActor::draw(0)"); - - if (!m_texturesGenerated) { - setDataColors(); - setPickColors(); - m_texturesGenerated = true; - } - - ObjCompAssembly_const_sptr objAss = getObjCompAssembly(); - glPushMatrix(); - - unsigned int texID = picking ? m_idPick : m_idData; - // Because texture colours are combined with the geometry colour - // make sure the current colour is white - glColor3f(1.0f, 1.0f, 1.0f); - glEnable(GL_TEXTURE_2D); - glBindTexture(GL_TEXTURE_2D, texID); - objAss->draw(); - glBindTexture(GL_TEXTURE_2D, 0); - OpenGLError::check("ObjCompAssemblyActor::draw()"); - - glPopMatrix(); -} - -void ObjCompAssemblyActor::generateTexture(unsigned char *data, - unsigned int &id) const { - if (id > 0) { - glDeleteTextures(1, &id); - OpenGLError::check("TexObject::generateTexture()[delete texture] "); - } - - int width = 1; - int height = m_n; - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - glGenTextures(1, &id); // Create The Texture - OpenGLError::check("TexObject::generateTexture()[generate] "); - glBindTexture(GL_TEXTURE_2D, id); - OpenGLError::check("TexObject::generateTexture()[bind] "); - - GLint texParam = GL_NEAREST; - glTexImage2D(GL_TEXTURE_2D, 0, 3, width, height, 0, GL_RGB, GL_UNSIGNED_BYTE, - data); - OpenGLError::check("TexObject::generateTexture()[set data] "); - /* If the above call to glTexImage2D has generated an error, it is likely as a - * result - * of outline="yes" being set in the IDF. If this is enabled then the texture - * above - * is generated with a width being equal to the number of points that make up - * the - * outline. However, some OpenGL implementations only support textures with a - * 2^n size. - * On the machines tested (Ubuntu 14.04, Windows 7, and RHEL6), this was not an - * issue, - * but we can't guarantee that a user wont try this on a system that doesn't - * support - * non power of 2 textures. In that case, the best thing to do would be to - * create a - * texture with a width of the next 2^n up, and adjust the texture coordinates - * accordingly. However, this is not a trivial change to make, and as far as we - * can tell - * no one has ever run into this issue, so it's being left for now. If this - * does prove - * problematic in the future, hopefully this note will save you some time - * figuring out - * the problem. - */ - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, texParam); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, texParam); - OpenGLError::check("TexObject::generateTexture()[parameters] "); -} - -/** -* Set colour to a detector. -* @param data :: pointer to color array -* @param i :: Index of the detector in ObjCompAssembly -* @param c :: The colour -*/ -void ObjCompAssemblyActor::setDetectorColor(unsigned char *data, size_t i, - GLColor c) const { - size_t pos = 3 * i; - float r, g, b, a; - c.get(r, g, b, a); - data[pos] = (unsigned char)(r * 255); - data[pos + 1] = (unsigned char)(g * 255); - data[pos + 2] = (unsigned char)(b * 255); -} - -void ObjCompAssemblyActor::swap() { - if (!m_pick_data) { - m_pick_data = new unsigned char[m_n * 3]; - } - unsigned char *tmp = m_data; - m_data = m_pick_data; - m_pick_data = tmp; -} - -const unsigned char *ObjCompAssemblyActor::getColor(int i) const { - return &m_data[3 * i]; -} - -void ObjCompAssemblyActor::setColors() { setDataColors(); } - -void ObjCompAssemblyActor::setDataColors() const { - for (size_t i = 0; i < size_t(m_n); ++i) { - GLColor c = m_instrActor.getColor(m_detIDs[i]); - setDetectorColor(m_data, i, c); - } - generateTexture(m_data, m_idData); -} - -void ObjCompAssemblyActor::setPickColors() const { - generateTexture(m_pick_data, m_idPick); -} - -bool ObjCompAssemblyActor::accept(GLActorVisitor &visitor, - GLActor::VisitorAcceptRule) { - return visitor.visit(this); -} - -bool ObjCompAssemblyActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule) const { - return visitor.visit(this); -} - -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/ObjComponentActor.cpp b/qt/widgets/instrumentview/src/ObjComponentActor.cpp deleted file mode 100644 index dd1c140ffc9f0513009f2aadc761e50617ceafb7..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/ObjComponentActor.cpp +++ /dev/null @@ -1,127 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/OpenGLError.h" - -#include "MantidKernel/V3D.h" -#include "MantidKernel/Quat.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/IComponent.h" -#include "MantidKernel/Exception.h" -#include "MantidGeometry/IDetector.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Objects/BoundingBox.h" - -using namespace Mantid; -using namespace Geometry; - -namespace { -// Anonymous namespace - -/** - * Returns if the current component is finite or - * has 'infinite' length based on all axis found - * within the bounding box - * - * @param compID:: The component to check - * @return :: True if the component has finite size else False - */ -bool isComponentFinite(const Mantid::Geometry::ComponentID &compID) { - Geometry::BoundingBox boundedBox; - compID->getBoundingBox(boundedBox); - const auto width = boundedBox.width(); - const double x = width[0]; - const double y = width[1]; - const double z = width[2]; - - // Currently an 'infinite' component will have length 1000 - // on one of its axis. Check all to make sure it is not greater - // than 1000 units in length. - const double maximumSize = 999; - if (x > maximumSize || y > maximumSize || z > maximumSize) { - return false; - } else { - return true; - } -} -} - -namespace MantidQt { -namespace MantidWidgets { - -ObjComponentActor::ObjComponentActor(const InstrumentActor &instrActor, - Mantid::Geometry::ComponentID compID) - : ComponentActor(instrActor, compID) { - // set the displayed colour - setColors(); - - if (!isComponentFinite(compID)) { - // If the component does not have finite length we set it always - // hidden so scale is not messed up and it is not displayed. - setAlwaysHidden(); - } - - // register the component with InstrumentActor and set the pick colour - IDetector_const_sptr det = getDetector(); - if (det) { - size_t pickID = instrActor.pushBackDetid(det->getID()); - m_pickColor = makePickColor(pickID); - } else { - instrActor.pushBackNonDetid(this, compID); - } -} - -ObjComponentActor::~ObjComponentActor() {} - -//------------------------------------------------------------------------------------------------- -/** -* Concrete implementation of rendering ObjComponent. -*/ -void ObjComponentActor::draw(bool picking) const { - OpenGLError::check("ObjComponentActor::draw(0)"); - glPushMatrix(); - if (picking) { - m_pickColor.paint(); - } else { - m_dataColor.paint(); - } - getObjComponent()->draw(); - glPopMatrix(); - OpenGLError::check("ObjComponentActor::draw()"); -} - -/** -* Set displayed component colour. If it's a detector the colour maps to the -* integrated counts in it. -*/ -void ObjComponentActor::setColors() { - IDetector_const_sptr det = getDetector(); - if (det) { - setColor(m_instrActor.getColor(det->getID())); - } else { - setColor(defaultDetectorColor()); - } -} - -/** -* Return the bounding box of visible components. -* If this is not visible an empty V3D object will -* be returned. -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void ObjComponentActor::getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const { - if (!isVisible()) { - // If this is not visible we should not consider this component - minBound = Kernel::V3D(); - maxBound = Kernel::V3D(); - } else { - Mantid::Geometry::BoundingBox boundBox; - getComponent()->getBoundingBox(boundBox); - minBound = boundBox.minPoint(); - maxBound = boundBox.maxPoint(); - } -} - -} // MantidWidgets -} // MantidQt \ No newline at end of file diff --git a/qt/widgets/instrumentview/src/PanelsSurface.cpp b/qt/widgets/instrumentview/src/PanelsSurface.cpp index 345257f1be1b74d97eb93f5619e34a590970a4df..1542bf49d61ef55b008ba3a9d537bf03d4d7c946 100644 --- a/qt/widgets/instrumentview/src/PanelsSurface.cpp +++ b/qt/widgets/instrumentview/src/PanelsSurface.cpp @@ -1,13 +1,9 @@ -#include "MantidQtWidgets/InstrumentView/CompAssemblyActor.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" -#include "MantidQtWidgets/InstrumentView/ObjCompAssemblyActor.h" #include "MantidQtWidgets/InstrumentView/PanelsSurface.h" -#include "MantidQtWidgets/InstrumentView/RectangularDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/StructuredDetectorActor.h" +#include "MantidQtWidgets/InstrumentView/UnwrappedDetector.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidGeometry/Instrument/DetectorInfo.h" -#include "MantidGeometry/Instrument/ObjCompAssembly.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidKernel/Logger.h" #include "MantidKernel/Tolerance.h" #include "MantidKernel/V3D.h" @@ -18,12 +14,124 @@ #include <QtDebug> using namespace Mantid::Geometry; +using Mantid::Beamline::ComponentType; namespace { + /// static logger Mantid::Kernel::Logger g_log("PanelsSurface"); + +/** + * Given the z axis, define the x and y ones. + * @param zaxis :: A given vector in 3d space to become the z axis of a + * coordinate system. + * @param xaxis :: An output arbitrary vector perpendicular to zaxis. + * @param yaxis :: An output arbitrary vector perpendicular to both zaxis and + * xaxis. + */ +void setupBasisAxes(const Mantid::Kernel::V3D &zaxis, + Mantid::Kernel::V3D &xaxis, Mantid::Kernel::V3D &yaxis) { + double R, theta, phi; + zaxis.getSpherical(R, theta, phi); + if (theta <= 45.0) { + xaxis = Mantid::Kernel::V3D(1, 0, 0); + } else if (phi <= 45.0) { + xaxis = Mantid::Kernel::V3D(0, 1, 0); + } else { + xaxis = Mantid::Kernel::V3D(0, 0, 1); + } + yaxis = zaxis.cross_prod(xaxis); + yaxis.normalize(); + xaxis = yaxis.cross_prod(zaxis); +} + +std::vector<Mantid::Kernel::V3D> +retrievePanelCorners(const Mantid::Geometry::ComponentInfo &componentInfo, + size_t rootIndex) { + auto panel = componentInfo.quadrilateralComponent(rootIndex); + return {componentInfo.position(panel.bottomLeft), + componentInfo.position(panel.bottomRight), + componentInfo.position(panel.topRight), + componentInfo.position(panel.topLeft)}; +} + +Mantid::Kernel::V3D +calculatePanelNormal(const std::vector<Mantid::Kernel::V3D> &panelCorners) { + // find the normal + auto xaxis = panelCorners[1] - panelCorners[0]; + auto yaxis = panelCorners[3] - panelCorners[0]; + auto normal = xaxis.cross_prod(yaxis); + normal.normalize(); + return normal; +} + +size_t findParentBank(const ComponentInfo &componentInfo, size_t rootIndex) { + // Search for parent component which contains tubes + auto parent = componentInfo.parent(rootIndex); + while (componentInfo.children(parent).size() <= 1) + parent = componentInfo.parent(parent); + + return parent; } +std::vector<size_t> findBankTubes(const ComponentInfo &componentInfo, + size_t rootIndex) { + auto comps = componentInfo.componentsInSubtree(rootIndex); + std::vector<size_t> tubes; + + for (auto comp : comps) { + if (componentInfo.componentType(comp) == ComponentType::OutlineComposite) + tubes.push_back(comp); + } + + return tubes; +} + +bool isBankFlat(const ComponentInfo &componentInfo, size_t bankIndex, + const std::vector<size_t> &tubes, + const Mantid::Kernel::V3D &normal) { + for (auto tube : tubes) { + const auto &children = componentInfo.children(tube); + auto vector = componentInfo.position(children[0]) - + componentInfo.position(children[1]); + vector.normalize(); + if (fabs(vector.scalar_prod(normal)) > Mantid::Kernel::Tolerance) { + g_log.warning() << "Assembly " << componentInfo.name(bankIndex) + << " isn't flat.\n"; + return false; + } + } + return true; +} + +Mantid::Kernel::V3D calculateBankNormal(const ComponentInfo &componentInfo, + const std::vector<size_t> &tubes) { + // calculate normal from first two tubes in bank as before + const auto &tube0 = componentInfo.children(tubes[0]); + const auto &tube1 = componentInfo.children(tubes[1]); + auto pos = componentInfo.position(tube0[0]); + auto x = componentInfo.position(tube0[1]) - pos; + x.normalize(); + + auto y = componentInfo.position(tube1[0]) - pos; + y.normalize(); + auto normal = x.cross_prod(y); + + if (normal.nullVector()) { + y = componentInfo.position(tube1[1]) - componentInfo.position(tube1[0]); + y.normalize(); + normal = x.cross_prod(y); + } + + normal.normalize(); + + if (normal.nullVector()) + g_log.warning() << "Colinear Assembly.\n"; + + return normal; +} +} // namespace + namespace MantidQt { namespace MantidWidgets { @@ -31,8 +139,8 @@ namespace MantidWidgets { * @param s The surface of the panel */ FlatBankInfo::FlatBankInfo(PanelsSurface *s) - : id(nullptr), rotation(), startDetectorIndex(0), endDetectorIndex(0), - polygon(), surface(s) {} + : rotation(), startDetectorIndex(0), endDetectorIndex(0), polygon(), + surface(s) {} /** * Translate the bank by a vector. @@ -42,7 +150,7 @@ void FlatBankInfo::translate(const QPointF &shift) { double du = shift.x(); double dv = shift.y(); polygon.translate(shift); - for (size_t i = startDetectorIndex; i < endDetectorIndex; ++i) { + for (size_t i = startDetectorIndex; i <= endDetectorIndex; ++i) { UnwrappedDetector &udet = surface->m_unwrappedDetectors[i]; udet.u += du; udet.v += dv; @@ -64,17 +172,13 @@ PanelsSurface::~PanelsSurface() { clearBanks(); } */ void PanelsSurface::init() { m_unwrappedDetectors.clear(); - m_assemblies.clear(); size_t ndet = m_instrActor->ndetectors(); + m_unwrappedDetectors.resize(ndet); if (ndet == 0) return; - // Pre-calculate all the detector positions (serial because - // I suspect the IComponent->getPos() method to not be properly thread safe) - m_instrActor->cacheDetPos(); - - findFlatBanks(); + constructFromComponentInfo(); spreadBanks(); RectF surfaceRect; @@ -105,9 +209,10 @@ void PanelsSurface::project(const Mantid::Kernel::V3D &, double &, double &, void PanelsSurface::rotate(const UnwrappedDetector &udet, Mantid::Kernel::Quat &R) const { - int index = m_detector2bankMap[udet.detID]; + const auto &detectorInfo = m_instrActor->detectorInfo(); + int index = m_detector2bankMap[udet.detIndex]; FlatBankInfo &info = *m_flatBanks[index]; - R = info.rotation * udet.rotation; + R = info.rotation * detectorInfo.rotation(udet.detIndex); } /** @@ -119,316 +224,161 @@ void PanelsSurface::setupAxes() { m_origin.ry() = m_yaxis.scalar_prod(m_pos); } -/** -* Given the z axis, define the x and y ones. -* @param zaxis :: A given vector in 3d space to become the z axis of a -* coordinate system. -* @param xaxis :: An output arbitrary vector perpendicular to zaxis. -* @param yaxis :: An output arbitrary vector perpendicular to both zaxis and -* xaxis. -*/ -void PanelsSurface::setupBasisAxes(const Mantid::Kernel::V3D &zaxis, - Mantid::Kernel::V3D &xaxis, - Mantid::Kernel::V3D &yaxis) const { - double R, theta, phi; - zaxis.getSpherical(R, theta, phi); - if (theta <= 45.0) { - xaxis = Mantid::Kernel::V3D(1, 0, 0); - } else if (phi <= 45.0) { - xaxis = Mantid::Kernel::V3D(0, 1, 0); - } else { - xaxis = Mantid::Kernel::V3D(0, 0, 1); - } - yaxis = zaxis.cross_prod(xaxis); - yaxis.normalize(); - xaxis = yaxis.cross_prod(zaxis); -} - //-----------------------------------------------------------------------------------------------// -class FlatBankFinder : public GLActorConstVisitor { - PanelsSurface &m_surface; - -public: - explicit FlatBankFinder(PanelsSurface &surface) : m_surface(surface) {} - - bool visit(const GLActor *) override { return false; } - bool visit(const GLActorCollection *) override { return false; } - bool visit(const ComponentActor *) override { return false; } - bool visit(const InstrumentActor *) override { return false; } - bool visit(const ObjCompAssemblyActor *) override { return false; } - - bool visit(const CompAssemblyActor *actor) override { - m_surface.addObjCompAssemblies(actor->getComponent()->getComponentID()); - return false; - } - - bool visit(const RectangularDetectorActor *actor) override { - m_surface.addRectangularDetector(actor->getComponent()->getComponentID()); - return false; - } - - bool visit(const StructuredDetectorActor *actor) override { - m_surface.addStructuredDetector(actor->getComponent()->getComponentID()); - return false; - } -}; - /** -* Traverse the instrument tree and find the banks which detectors lie in the -* same plane. -* -*/ -void PanelsSurface::findFlatBanks() { - clearBanks(); - FlatBankFinder finder(*this); - m_instrActor->accept(finder); -} - -//-----------------------------------------------------------------------------------------------// - -/** -* Add a flat bank from an assembly of ObjCompAssemblies. +* Add a flat bank from an assembly of detectors. * @param bankId :: Component ID of the bank. * @param normal :: Normal vector to the bank's plane. -* @param objCompAssemblies :: List of component IDs. Each component must cast to -* ObjCompAssembly. +* @param detectors :: List of detectorIndices. */ -void PanelsSurface::addFlatBank(ComponentID bankId, - const Mantid::Kernel::V3D &normal, - QList<ComponentID> objCompAssemblies) { +void PanelsSurface::addFlatBankOfDetectors( + const Mantid::Kernel::V3D &normal, const std::vector<size_t> &detectors) { int index = m_flatBanks.size(); // save bank info FlatBankInfo *info = new FlatBankInfo(this); m_flatBanks << info; - info->id = bankId; // record the first detector index of the bank - info->startDetectorIndex = m_unwrappedDetectors.size(); - bool doneRotation = false; + info->startDetectorIndex = detectors.front(); + info->endDetectorIndex = detectors.back(); + // keep reference position on the bank's plane - Mantid::Kernel::V3D pos0; - QPointF p0, p1; - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - // loop over the assemblies and process the detectors - foreach (ComponentID id, objCompAssemblies) { - Mantid::Geometry::ICompAssembly_const_sptr assembly = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>( - instr->getComponentByID(id)); - assert(assembly); - int nelem = assembly->nelements(); - m_unwrappedDetectors.reserve(m_unwrappedDetectors.size() + nelem); - for (int i = 0; i < nelem; ++i) { - // setup detector info - auto det = boost::dynamic_pointer_cast<const Mantid::Geometry::IDetector>( - assembly->getChild(i)); - if (!doneRotation) { - pos0 = det->getPos(); - // find the rotation to put the bank on the plane - info->rotation = calcBankRotation(pos0, normal); - Mantid::Kernel::V3D pos1 = assembly->getChild(nelem - 1)->getPos(); - pos1 -= pos0; - info->rotation.rotate(pos1); - pos1 += pos0; - // start forming the outline polygon - p0.rx() = m_xaxis.scalar_prod(pos0); - p0.ry() = m_yaxis.scalar_prod(pos0); - p1.rx() = m_xaxis.scalar_prod(pos1); - p1.ry() = m_yaxis.scalar_prod(pos1); - QVector<QPointF> vert; - vert << p1 << p0; - info->polygon = QPolygonF(vert); - doneRotation = true; - } - // add the detector - addDetector(*det, pos0, index, info->rotation); - } + const auto &detectorInfo = m_instrActor->detectorInfo(); + auto pos0 = detectorInfo.position(detectors[0]); + auto pos1 = detectorInfo.position(detectors[1]) - pos0; + + info->rotation = calcBankRotation(pos0, normal); + info->rotation.rotate(pos1); + pos1 += pos0; + QPointF p0(m_xaxis.scalar_prod(pos0), m_yaxis.scalar_prod(pos0)); + QPointF p1(m_xaxis.scalar_prod(pos1), m_yaxis.scalar_prod(pos1)); + QVector<QPointF> vert; + vert << p1 << p0; + info->polygon = QPolygonF(vert); + + for (auto detector : detectors) { + addDetector(detector, pos0, index, info->rotation); // update the outline polygon - UnwrappedDetector &udet0 = *(m_unwrappedDetectors.end() - nelem); - UnwrappedDetector &udet1 = m_unwrappedDetectors.back(); - // get the tube end points - QPointF p3 = QPointF(udet0.u, udet0.v); - QPointF p4 = QPointF(udet1.u, udet1.v); - QVector<QPointF> vert; - // add a quadrilateral formed by end points of two nearest tubes - // assumption is made here that any two adjacent tubes in an assembly's - // children's list - // are close to each other - vert << p0 << p1 << p4 << p3; + UnwrappedDetector &udet = m_unwrappedDetectors[detector]; + auto p2 = QPointF(udet.u, udet.v); + vert.clear(); + vert << p0 << p1 << p2; info->polygon = info->polygon.united(QPolygonF(vert)); - p0 = p3; - p1 = p4; } - // record the end detector index of the bank - info->endDetectorIndex = m_unwrappedDetectors.size(); } -/** -* Add a flat bank from an assembly of detectors. -* @param bankId :: Component ID of the bank. -* @param normal :: Normal vector to the bank's plane. -* @param detectors :: List of component IDs. Each component must cast to -* Detector. -*/ -void PanelsSurface::addFlatBankOfDetectors(ComponentID bankId, - const Mantid::Kernel::V3D &normal, - QList<ComponentID> detectors) { +void PanelsSurface::processStructured(const std::vector<size_t> &children, + size_t rootIndex) { int index = m_flatBanks.size(); + const auto &componentInfo = m_instrActor->componentInfo(); + auto corners = retrievePanelCorners(componentInfo, rootIndex); + auto normal = calculatePanelNormal(corners); // save bank info FlatBankInfo *info = new FlatBankInfo(this); m_flatBanks << info; - info->id = bankId; + // find the rotation to put the bank on the plane + info->rotation = calcBankRotation(corners[0], normal); // record the first detector index of the bank - info->startDetectorIndex = m_unwrappedDetectors.size(); - int nelem = detectors.size(); - m_unwrappedDetectors.reserve(m_unwrappedDetectors.size() + nelem); - - // keep reference position on the bank's plane - Mantid::Kernel::V3D pos0, pos1; - QPointF p0, p1; - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - // loop over the detectors - for (int i = 0; i < detectors.size(); ++i) { - ComponentID id = detectors[i]; - auto det = boost::dynamic_pointer_cast<const Mantid::Geometry::IDetector>( - instr->getComponentByID(id)); - - if (i == 0) { - pos0 = det->getPos(); - } else if (i == 1) { - // find the rotation to put the bank on the plane - info->rotation = calcBankRotation(pos0, normal); - pos1 = det->getPos(); - pos1 -= pos0; - info->rotation.rotate(pos1); - pos1 += pos0; - // start forming the outline polygon - p0.rx() = m_xaxis.scalar_prod(pos0); - p0.ry() = m_yaxis.scalar_prod(pos0); - p1.rx() = m_xaxis.scalar_prod(pos1); - p1.ry() = m_yaxis.scalar_prod(pos1); - QVector<QPointF> vert; - vert << p1 << p0; - info->polygon = QPolygonF(vert); - } - // add the detector - addDetector(*det, pos0, index, info->rotation); - // update the outline polygon - UnwrappedDetector &udet = *(m_unwrappedDetectors.end() - 1); - QPointF p2 = QPointF(udet.u, udet.v); - QVector<QPointF> vert; - vert << p0 << p1 << p2; - info->polygon = info->polygon.united(QPolygonF(vert)); + info->startDetectorIndex = children.front(); + info->endDetectorIndex = children.back(); + // set the outline + QVector<QPointF> verts; + for (auto &corner : corners) { + auto pos = corner - corners[0]; + info->rotation.rotate(pos); + pos += corners[0]; + verts << QPointF(pos.X(), pos.Y()); } - // record the end detector index of the bank - info->endDetectorIndex = m_unwrappedDetectors.size(); + info->polygon = QPolygonF(verts); + + for (auto child : children) + addDetector(child, corners[0], index, info->rotation); } -/** -* Add a component assembly containing a flat array of ObjCompAssemblies. -* @param bankId :: Component id of an assembly. -*/ -void PanelsSurface::addObjCompAssemblies(ComponentID bankId) { - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - boost::shared_ptr<const Mantid::Geometry::CompAssembly> assembly = - boost::dynamic_pointer_cast<const Mantid::Geometry::CompAssembly>( - instr->getComponentByID(bankId)); - - size_t nelem = static_cast<size_t>(assembly->nelements()); - // assemblies with one element cannot be flat (but its element can be) - if (nelem == 1) { +void PanelsSurface::processTubes(size_t rootIndex, std::vector<bool> &visited) { + const auto &componentInfo = m_instrActor->componentInfo(); + auto bankIndex = findParentBank(componentInfo, rootIndex); + auto name = componentInfo.name(bankIndex); + auto tubes = findBankTubes(componentInfo, bankIndex); + auto normal = calculateBankNormal(componentInfo, tubes); + + if (normal.nullVector() || + !isBankFlat(componentInfo, bankIndex, tubes, normal)) return; - } - QList<ComponentID> objCompAssemblies; - // normal to the plane, undefined at first - Mantid::Kernel::V3D normal(0, 0, 0); - Mantid::Kernel::V3D x, y, pos; - for (size_t i = 0; i < nelem; ++i) { - auto elem = assembly->getChild((int)i); - ObjCompAssembly *objCompAssembly = - dynamic_cast<ObjCompAssembly *>(elem.get()); - if (!objCompAssembly) { - CompAssembly *compAssembly = dynamic_cast<CompAssembly *>(elem.get()); - if (!compAssembly || compAssembly->nelements() != 1) { - // m_surface.g_log.warning() << "Not a CompAssembly\n"; - addCompAssembly(bankId); - return; - } - elem = compAssembly->getChild(0); - objCompAssembly = dynamic_cast<ObjCompAssembly *>(elem.get()); - if (!objCompAssembly) { - // m_surface.g_log.warning() << "Not a ObjCompAssembly\n"; - return; - } - } - if (i == 0) { - pos = objCompAssembly->getChild(0)->getPos(); - x = objCompAssembly->getChild(1)->getPos() - pos; - x.normalize(); - } else if (i == 1) { - y = objCompAssembly->getChild(0)->getPos() - pos; - y.normalize(); - normal = x.cross_prod(y); - if (normal.nullVector()) { - y = objCompAssembly->getChild(1)->getPos() - - objCompAssembly->getChild(0)->getPos(); - y.normalize(); - normal = x.cross_prod(y); - } - if (normal.nullVector()) { - g_log.warning() << "Colinear ObjCompAssemblies\n"; - return; - } - normal.normalize(); - } else { - Mantid::Kernel::V3D vector = objCompAssembly->getChild(0)->getPos() - - objCompAssembly->getChild(1)->getPos(); - vector.normalize(); - if (fabs(vector.scalar_prod(normal)) > Mantid::Kernel::Tolerance) { - g_log.warning() << "Assembly " << assembly->getName() - << " isn't flat.\n"; - return; - } + // save bank info + auto index = m_flatBanks.size(); + FlatBankInfo *info = new FlatBankInfo(this); + m_flatBanks << info; + // record the first detector index of the bank + info->startDetectorIndex = componentInfo.children(tubes.front()).front(); + info->endDetectorIndex = componentInfo.children(tubes.back()).back(); + + auto pos0 = + componentInfo.position(componentInfo.children(tubes.front()).front()); + auto pos1 = + componentInfo.position(componentInfo.children(tubes.front()).back()); + + info->rotation = calcBankRotation(pos0, normal); + pos1 -= pos0; + info->rotation.rotate(pos1); + pos1 += pos0; + + QPointF p0(m_xaxis.scalar_prod(pos0), m_yaxis.scalar_prod(pos0)); + QPointF p1(m_xaxis.scalar_prod(pos1), m_yaxis.scalar_prod(pos1)); + QVector<QPointF> vert; + vert << p0 << p1; + info->polygon = QPolygonF(vert); + + for (auto tube : tubes) { + const auto &children = componentInfo.children(tube); + visited[tube] = true; + for (auto child : children) { + if (visited[child]) + continue; + visited[child] = true; + addDetector(child, pos0, index, info->rotation); } - objCompAssemblies << objCompAssembly->getComponentID(); - } - if (!objCompAssemblies.isEmpty()) { - addFlatBank(assembly->getComponentID(), normal, objCompAssemblies); + + auto &udet0 = m_unwrappedDetectors[children.front()]; + auto &udet1 = m_unwrappedDetectors[children.back()]; + QPointF p2(udet0.u, udet0.v); + QPointF p3(udet1.u, udet1.v); + // add a quadrilateral formed by end points of two nearest tubes + // assumption is made here that any two adjacent tubes in an assembly's + // children's list + // are close to each other + vert << p0 << p1 << p3 << p2; + info->polygon = info->polygon.united(QPolygonF(vert)); + p0 = p2; + p1 = p3; } } -/** -* Add an assembly if its detectors are in the same plane. -* @param bankId :: Component id of an assembly. -*/ -void PanelsSurface::addCompAssembly(ComponentID bankId) { - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - boost::shared_ptr<const Mantid::Geometry::CompAssembly> assembly = - boost::dynamic_pointer_cast<const Mantid::Geometry::CompAssembly>( - instr->getComponentByID(bankId)); - - size_t nelem = static_cast<size_t>(assembly->nelements()); - // normal to the plane, undefined at first - Mantid::Kernel::V3D normal, x, y; +std::pair<std::vector<size_t>, Mantid::Kernel::V3D> +PanelsSurface::processUnstructured(const std::vector<size_t> &children, + size_t rootIndex, + std::vector<bool> &visited) { + Mantid::Kernel::V3D normal; + const auto &detectorInfo = m_instrActor->detectorInfo(); Mantid::Kernel::V3D pos0; + Mantid::Kernel::V3D x, y; bool normalFound = false; - QList<ComponentID> detectors; - const auto &detectorInfo = m_instrActor->getWorkspace()->detectorInfo(); - for (size_t i = 0; i < nelem; ++i) { - auto elem = assembly->getChild((int)i); - Mantid::Geometry::IDetector_const_sptr det = - boost::dynamic_pointer_cast<const Mantid::Geometry::IDetector>(elem); - if (!det) { - return; - } - size_t detIndex = detectorInfo.indexOf(det->getID()); - if (detectorInfo.isMonitor(detIndex)) + const auto &componentInfo = m_instrActor->componentInfo(); + std::vector<size_t> detectors; + detectors.reserve(children.size()); + for (auto child : children) { + if (visited[child]) + continue; + visited[child] = true; + + if (detectorInfo.isMonitor(child)) continue; - Mantid::Kernel::V3D pos = detectorInfo.position(detIndex); - if (i == 0) { + auto pos = detectorInfo.position(child); + if (child == children[0]) pos0 = pos; - } else if (i == 1) { + else if (child == children[1]) { // at first set the normal to an argbitrary vector orthogonal to // the line between the first two detectors y = pos - pos0; @@ -445,157 +395,70 @@ void PanelsSurface::addCompAssembly(ComponentID bankId) { x = y.cross_prod(normal); normalFound = true; } else { - g_log.warning() << "Assembly " << assembly->getName() + g_log.warning() << "Assembly " << componentInfo.name(rootIndex) << " isn't flat.\n"; - return; + break; } } - detectors << det->getComponentID(); - } - - // normalFound doesn't have to be true at this point - // if it is false then the normal was found by the first guess - - // add the detectors - if (!detectors.isEmpty()) { - addFlatBankOfDetectors(bankId, normal, detectors); + detectors.push_back(child); } + return std::make_pair(detectors, normal); } -/** -* Add a rectangular detector which is flat. -* @param bankId :: Component id of a rectangular detector. -*/ -void PanelsSurface::addRectangularDetector(ComponentID bankId) { - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - Mantid::Geometry::RectangularDetector_const_sptr rectDetector = - boost::dynamic_pointer_cast<const Mantid::Geometry::RectangularDetector>( - instr->getComponentByID(bankId)); - - int nx = rectDetector->xpixels(); - int ny = rectDetector->ypixels(); - Mantid::Kernel::V3D pos0 = rectDetector->getAtXY(0, 0)->getPos(); - Mantid::Kernel::V3D pos1 = rectDetector->getAtXY(nx - 1, 0)->getPos(); - Mantid::Kernel::V3D pos2 = rectDetector->getAtXY(nx - 1, ny - 1)->getPos(); - Mantid::Kernel::V3D pos3 = rectDetector->getAtXY(0, ny - 1)->getPos(); - - // find the normal - Mantid::Kernel::V3D xaxis = pos1 - pos0; - Mantid::Kernel::V3D yaxis = pos3 - pos0; - Mantid::Kernel::V3D normal = xaxis.cross_prod(yaxis); - normal.normalize(); - - int index = m_flatBanks.size(); - // save bank info - FlatBankInfo *info = new FlatBankInfo(this); - m_flatBanks << info; - info->id = bankId; - // find the rotation to put the bank on the plane - info->rotation = calcBankRotation(pos0, normal); - // record the first detector index of the bank - info->startDetectorIndex = m_unwrappedDetectors.size(); - // set the outline - QVector<QPointF> verts; - Mantid::Kernel::V3D pos = pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos1 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos2 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos3 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - info->polygon = QPolygonF(verts); +boost::optional<std::pair<std::vector<size_t>, Mantid::Kernel::V3D>> +PanelsSurface::findFlatPanels(size_t rootIndex, + const std::vector<size_t> &children, + std::vector<bool> &visited) { + const auto &componentInfo = m_instrActor->componentInfo(); + auto parentIndex = componentInfo.parent(rootIndex); + auto componentType = componentInfo.componentType(parentIndex); + if (componentType == ComponentType::Rectangular || + componentType == ComponentType::Structured) { + /* Do nothing until the root index of the structured bank. */ + return boost::none; + } - int nelem = rectDetector->nelements(); - m_unwrappedDetectors.reserve(m_unwrappedDetectors.size() + nelem); + componentType = componentInfo.componentType(rootIndex); + if (componentType == ComponentType::Rectangular || + componentType == ComponentType::Structured) { + processStructured(children, rootIndex); + for (auto child : children) + visited[child] = true; + return boost::none; + } - for (int i = 0; i < nx; ++i) - for (int j = 0; j < ny; ++j) { - Mantid::Geometry::IDetector_const_sptr det = rectDetector->getAtXY(i, j); - addDetector(*det, pos0, index, info->rotation); - } + if (componentType == ComponentType::OutlineComposite) { + processTubes(rootIndex, visited); + for (auto child : children) + visited[child] = true; + return boost::none; + } - // record the end detector index of the bank - info->endDetectorIndex = m_unwrappedDetectors.size(); + return processUnstructured(children, rootIndex, visited); } -/** -* Add a structured detector which is flat. -* @param bankId :: Component id of a structured detector. -*/ -void PanelsSurface::addStructuredDetector( - Mantid::Geometry::ComponentID bankId) { - Mantid::Geometry::Instrument_const_sptr instr = m_instrActor->getInstrument(); - Mantid::Geometry::StructuredDetector_const_sptr structDetector = - boost::dynamic_pointer_cast<const Mantid::Geometry::StructuredDetector>( - instr->getComponentByID(bankId)); - - auto nx = structDetector->xPixels(); - auto ny = structDetector->yPixels(); - Mantid::Kernel::V3D pos0 = structDetector->getAtXY(0, 0)->getPos(); - Mantid::Kernel::V3D pos1 = structDetector->getAtXY(nx - 1, 0)->getPos(); - Mantid::Kernel::V3D pos2 = structDetector->getAtXY(nx - 1, ny - 1)->getPos(); - Mantid::Kernel::V3D pos3 = structDetector->getAtXY(0, ny - 1)->getPos(); - - // find the normal - Mantid::Kernel::V3D xaxis = pos1 - pos0; - Mantid::Kernel::V3D yaxis = pos3 - pos0; - Mantid::Kernel::V3D normal = xaxis.cross_prod(yaxis); - normal.normalize(); - - int index = m_flatBanks.size(); - // save bank info - FlatBankInfo *info = new FlatBankInfo(this); - m_flatBanks << info; - info->id = bankId; - // find the rotation to put the bank on the plane - info->rotation = calcBankRotation(pos0, normal); - // record the first detector index of the bank - info->startDetectorIndex = m_unwrappedDetectors.size(); - // set the outline - QVector<QPointF> verts; - Mantid::Kernel::V3D pos = pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos1 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos2 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - pos = pos3 - pos0; - info->rotation.rotate(pos); - pos += pos0; - verts << QPointF(pos.X(), pos.Y()); - - info->polygon = QPolygonF(verts); - - int nelem = structDetector->nelements(); - m_unwrappedDetectors.reserve(m_unwrappedDetectors.size() + nelem); - - for (size_t i = 0; i < nx; ++i) - for (size_t j = 0; j < ny; ++j) { - Mantid::Geometry::IDetector_const_sptr det = - structDetector->getAtXY(i, j); - addDetector(*det, pos0, index, info->rotation); +void PanelsSurface::constructFromComponentInfo() { + const auto &componentInfo = m_instrActor->componentInfo(); + std::vector<bool> visited(componentInfo.size(), false); + + for (size_t i = 0; i < componentInfo.size() - 1; ++i) { + auto children = componentInfo.detectorsInSubtree(i); + + if (children.size() > 1 && !visited[i]) { + auto res = findFlatPanels(i, children, visited); + if (res != boost::none) { + std::vector<size_t> detectors; + Mantid::Kernel::V3D normal; + std::tie(detectors, normal) = res.get(); + if (!detectors.empty()) + addFlatBankOfDetectors(normal, detectors); + } + } else if (children.size() > 0 && + componentInfo.parent(children[0]) == componentInfo.root()) { + auto child = children[0]; + visited[child] = true; } - - // record the end detector index of the bank - info->endDetectorIndex = m_unwrappedDetectors.size(); + } } /** @@ -624,17 +487,15 @@ PanelsSurface::calcBankRotation(const Mantid::Kernel::V3D &detPos, return Mantid::Kernel::Quat(normal, m_zaxis); } -void PanelsSurface::addDetector(const Mantid::Geometry::IDetector &det, +void PanelsSurface::addDetector(size_t detIndex, const Mantid::Kernel::V3D &refPos, int index, Mantid::Kernel::Quat &rotation) { - // setup detector info - Mantid::Kernel::V3D pos = det.getPos(); - Mantid::detid_t detid = det.getID(); - m_detector2bankMap[detid] = index; + const auto &detectorInfo = m_instrActor->detectorInfo(); + + Mantid::Kernel::V3D pos = detectorInfo.position(detIndex); + m_detector2bankMap[detIndex] = index; // get the colour - unsigned char color[3]; - m_instrActor->getColor(detid).getUB3(&color[0]); - UnwrappedDetector udet(color, det); + UnwrappedDetector udet(m_instrActor->getColor(detIndex), detIndex); // apply bank's rotation pos -= refPos; rotation.rotate(pos); @@ -643,7 +504,7 @@ void PanelsSurface::addDetector(const Mantid::Geometry::IDetector &det, udet.v = m_yaxis.scalar_prod(pos); udet.uscale = udet.vscale = 1.0; this->calcSize(udet); - m_unwrappedDetectors.push_back(udet); + m_unwrappedDetectors[detIndex] = udet; } /** diff --git a/qt/widgets/instrumentview/src/Projection3D.cpp b/qt/widgets/instrumentview/src/Projection3D.cpp index 14d17c86f993b8d21c6d3cd98935c0e02c8a5176..d0bb629aa767e1e0430e352e2c3b827a7f38dc66 100644 --- a/qt/widgets/instrumentview/src/Projection3D.cpp +++ b/qt/widgets/instrumentview/src/Projection3D.cpp @@ -2,13 +2,12 @@ #include <windows.h> #endif #include "MantidQtWidgets/InstrumentView/Projection3D.h" -#include "MantidQtWidgets/InstrumentView/GLActor.h" #include "MantidQtWidgets/InstrumentView/GLColor.h" #include "MantidQtWidgets/InstrumentView/UnwrappedCylinder.h" #include "MantidQtWidgets/InstrumentView/UnwrappedSphere.h" #include "MantidQtWidgets/InstrumentView/OpenGLError.h" -#include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Objects/CSGObject.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidQtWidgets/Common/InputController.h" @@ -42,9 +41,6 @@ Projection3D::Projection3D(const InstrumentActor *rootActor, int winWidth, int winHeight) : ProjectionSurface(rootActor), m_drawAxes(true), m_wireframe(false), m_viewport(0, 0) { - - Instrument_const_sptr instr = rootActor->getInstrument(); - m_viewport.resize(winWidth, winHeight); V3D minBounds, maxBounds; m_instrActor->getBoundingBox(minBounds, maxBounds); @@ -52,7 +48,6 @@ Projection3D::Projection3D(const InstrumentActor *rootActor, int winWidth, m_viewport.setProjection(minBounds, maxBounds); changeColorMap(); - rootActor->invalidateDisplayLists(); // create and connect the move input controller InputController3DMove *moveController = new InputController3DMove(this); @@ -200,10 +195,10 @@ void Projection3D::setWireframe(bool on) { m_wireframe = on; } /** This seems to be called when the user has selected a rectangle * using the mouse. * -* @param dets :: returns a list of detector IDs selected. +* @param detIndices :: returns a list of detector Indices selected. */ -void Projection3D::getSelectedDetectors(QList<int> &dets) { - dets.clear(); +void Projection3D::getSelectedDetectors(std::vector<size_t> &detIndices) { + detIndices.clear(); if (!hasSelection()) return; double xmin, xmax, ymin, ymax, zmin, zmax; @@ -218,16 +213,12 @@ void Projection3D::getSelectedDetectors(QList<int> &dets) { double yTop = ymin + (ymax - ymin) * (h - rect.top()) / h; size_t ndet = m_instrActor->ndetectors(); - // Cache all the detector positions if needed. This is slow, but just once. - m_instrActor->cacheDetPos(); - for (size_t i = 0; i < ndet; ++i) { - detid_t detId = m_instrActor->getDetID(i); V3D pos = m_instrActor->getDetPos(i); m_viewport.transform(pos); if (pos.X() >= xLeft && pos.X() <= xRight && pos.Y() >= yBottom && pos.Y() <= yTop) { - dets.push_back(detId); + detIndices.push_back(i); } } } @@ -236,12 +227,9 @@ void Projection3D::getSelectedDetectors(QList<int> &dets) { /** Select detectors to mask, using the mouse. * From the Instrument Window's mask tab. * -* @param dets :: returns a list of detector IDs to mask. +* @param dets :: returns a list of detector Indices to mask. */ -void Projection3D::getMaskedDetectors(QList<int> &dets) const { - // Cache all the detector positions if needed. This is slow, but just once. - m_instrActor->cacheDetPos(); - +void Projection3D::getMaskedDetectors(std::vector<size_t> &detIndices) const { // find the layer of visible detectors QList<QPoint> pixels = m_maskShapes.getMaskedPixels(); double zmin = 1.0; @@ -266,7 +254,7 @@ void Projection3D::getMaskedDetectors(QList<int> &dets) const { } // find masked detector in that layer - dets.clear(); + detIndices.clear(); if (m_maskShapes.isEmpty()) return; size_t ndet = m_instrActor->ndetectors(); @@ -274,13 +262,12 @@ void Projection3D::getMaskedDetectors(QList<int> &dets) const { // Find the cached ID and position. This is much faster than getting the // detector. V3D pos = m_instrActor->getDetPos(i); - detid_t id = m_instrActor->getDetID(i); // project pos onto the screen plane m_viewport.transform(pos); if (pos.Z() < zmin || pos.Z() > zmax) continue; if (m_maskShapes.isMasked(pos.X(), pos.Y())) { - dets.push_back(int(id)); + detIndices.push_back(i); } } } @@ -289,19 +276,18 @@ void Projection3D::getMaskedDetectors(QList<int> &dets) const { * Orient the viewport to look at a selected component. * @param id :: The ID of a selected component. */ -void Projection3D::componentSelected(Mantid::Geometry::ComponentID id) { +void Projection3D::componentSelected(size_t componentIndex) { - Instrument_const_sptr instr = m_instrActor->getInstrument(); + const auto &componentInfo = m_instrActor->componentInfo(); - if (id == NULL || id == instr->getComponentID()) { + if (componentIndex == componentInfo.root()) { m_viewport.reset(); return; } - IComponent_const_sptr comp = instr->getComponentByID(id); - V3D pos = comp->getPos(); + auto pos = componentInfo.position(componentIndex); - V3D compDir = comp->getPos() - instr->getSample()->getPos(); + auto compDir = pos - componentInfo.samplePosition(); compDir.normalize(); V3D up(0, 0, 1); V3D x = up.cross_prod(compDir); diff --git a/qt/widgets/instrumentview/src/ProjectionSurface.cpp b/qt/widgets/instrumentview/src/ProjectionSurface.cpp index c8991e796c30f2bb22c570cc0f2fc16e8c56ba38..3d1b1eb45b31390c8029d0b0f783e68b3c6360f2 100644 --- a/qt/widgets/instrumentview/src/ProjectionSurface.cpp +++ b/qt/widgets/instrumentview/src/ProjectionSurface.cpp @@ -1,9 +1,10 @@ #include "MantidQtWidgets/InstrumentView/ProjectionSurface.h" #include "MantidQtWidgets/Common/InputController.h" +#include "MantidQtWidgets/Common/TSVSerialiser.h" #include "MantidQtWidgets/InstrumentView/GLColor.h" +#include "MantidQtWidgets/InstrumentView/InstrumentRenderer.h" #include "MantidQtWidgets/InstrumentView/MantidGLWidget.h" #include "MantidQtWidgets/InstrumentView/OpenGLError.h" -#include "MantidQtWidgets/Common/TSVSerialiser.h" #include "MantidAPI/Axis.h" #include "MantidAPI/IPeaksWorkspace.h" @@ -441,10 +442,8 @@ int ProjectionSurface::getDetectorID(int x, int y) const { } //------------------------------------------------------------------------------ -const Mantid::Geometry::IDetector &ProjectionSurface::getDetector(int x, - int y) const { - size_t pickID = getPickID(x, y); - return m_instrActor->getDetectorByPickID(pickID); +size_t ProjectionSurface::getDetector(int x, int y) const { + return getPickID(x, y); } /** @@ -500,7 +499,7 @@ size_t ProjectionSurface::getPickID(int x, int y) const { if (!m_pickImage || !m_pickImage->valid(x, y)) return -1; QRgb pixel = m_pickImage->pixel(x, y); - return GLActor::decodePickColor(pixel); + return InstrumentRenderer::decodePickColor(pixel); } /** @@ -769,7 +768,7 @@ void ProjectionSurface::clearComparisonPeaks() { */ void ProjectionSurface::setPeakLabelPrecision(int n) { if (n < 1) { - QMessageBox::critical(NULL, "MantidPlot - Error", + QMessageBox::critical(nullptr, "MantidPlot - Error", "Precision must be a positive number"); return; } diff --git a/qt/widgets/instrumentview/src/RectangularDetectorActor.cpp b/qt/widgets/instrumentview/src/RectangularDetectorActor.cpp deleted file mode 100644 index 3f4bc833162df9048735dbda105c0ac088ac187f..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/RectangularDetectorActor.cpp +++ /dev/null @@ -1,332 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/RectangularDetectorActor.h" -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" - -#include "MantidKernel/V3D.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidGeometry/Objects/BoundingBox.h" -#include "MantidGeometry/ICompAssembly.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidGeometry/Instrument/RectangularDetector.h" -#include "MantidGeometry/Instrument.h" -#include "MantidKernel/Exception.h" -#include <cfloat> -#include "MantidGeometry/IComponent.h" -using namespace Mantid; -using namespace Geometry; -using Mantid::Kernel::V3D; -using Mantid::Kernel::Quat; - -namespace MantidQt { -namespace MantidWidgets { - -static const bool VERBOSE = false; - -/** -* Constructor. -* -* @param instrActor :: the instrument actor -* @param compID :: the component ID -*/ -RectangularDetectorActor::RectangularDetectorActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID) - : ICompAssemblyActor(instrActor, compID), mTextureID(0), - image_data(nullptr), pick_data(nullptr) { - mNumberOfDetectors = 0; - mDet = boost::dynamic_pointer_cast<const RectangularDetector>(getComponent()); - - if (!mDet) - return; - - BoundingBox compBox; - mDet->getBoundingBox(compBox); - mNumberOfDetectors = mDet->xpixels() * mDet->ypixels(); - this->AppendBoundingBox(compBox.minPoint(), compBox.maxPoint()); - - std::vector<GLColor> clist; - for (int y = 0; y < mDet->ypixels(); y++) { - for (int x = 0; x < mDet->xpixels(); x++) { - // Getting the detector is slow. Get the ID directly - detid_t id = mDet->getDetectorIDAtXY(x, y); - size_t pickID = instrActor.pushBackDetid(id); - m_pickIDs.push_back(pickID); - clist.push_back(instrActor.getColor(id)); - } - } - - genTexture(image_data, clist, false); - genTexture(pick_data, clist, true); - uploadTexture(image_data); -} - -//------------------------------------------------------------------------------------------------- -/** -* Destructor which removes the actors created by this object -*/ -RectangularDetectorActor::~RectangularDetectorActor() { - delete[] image_data; - delete[] pick_data; -} - -//------------------------------------------------------------------------------------------------- -/** -* This function is concrete implementation that renders the Child ObjComponents -* and Child CompAssembly's -*/ -void RectangularDetectorActor::draw(bool picking) const { - if (VERBOSE) - std::cout << "RectangularDetectorActor::define() called for " - << mDet->getName() << "\n"; - - glPushMatrix(); - // Translation first - V3D pos = mDet->getPos(); - if (!(pos.nullVector())) { - glTranslated(pos[0], pos[1], pos[2]); - } - // Rotation - Quat rot = mDet->getRotation(); - if (!(rot.isNull())) { - double deg, ax0, ax1, ax2; - rot.getAngleAxis(deg, ax0, ax1, ax2); - glRotated(deg, ax0, ax1, ax2); - } - // Scale - V3D scaleFactor = mDet->getScaleFactor(); - if (!(scaleFactor == V3D(1, 1, 1))) { - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - } - - // glBindTexture(GL_TEXTURE_2D, mTextureID); - if (picking) { - this->uploadTexture(pick_data); - } else { - this->uploadTexture(image_data); - } - // RectangularDetector will use. - mDet->draw(); - glBindTexture(GL_TEXTURE_2D, 0); - - glPopMatrix(); -} - -//------------------------------------------------------------------------------------------------ -/** -* Accept a visitor. This sets the matching component's visibility to True. -* It looks if the given component is a child (pixel) of the parent rectangular -* detector, and sets the visibility of the whole panel to true if so. -* -* @param visitor :: A visitor. -* @param rule :: A rule defining visitor acceptance by assembly actors. Unused. -* -*/ -bool RectangularDetectorActor::accept(GLActorVisitor &visitor, - VisitorAcceptRule) { - return visitor.visit(this); -} - -bool RectangularDetectorActor::accept(GLActorConstVisitor &visitor, - GLActor::VisitorAcceptRule) const { - return visitor.visit(this); -} - -bool RectangularDetectorActor::isChildDetector(const ComponentID &id) const { - // ID of the parent RectangularDetector - Mantid::Geometry::ComponentID thisID = this->m_id; - - // Get the component object - IComponent_const_sptr comp = - m_instrActor.getInstrument()->getComponentByID(id); - if (comp) { - // Get the parent (e.g. the column) - IComponent_const_sptr parent1 = comp->getParent(); - if (parent1) { - if (parent1->getComponentID() == thisID) { - return true; - } - // Go to grandparent - IComponent_const_sptr parent2 = parent1->getParent(); - if (parent2) { - if (parent2->getComponentID() == thisID) { - return true; - } - } // valid grandparent - } // valid parent - } // valid component - return false; -} - -//------------------------------------------------------------------------------------------------ -/** -* Generate a texture for the RectangularDetector -* -* @param image_data :: pointer to where the image data will be filled in. -* @param list :: Color list iterator. Only used if useDetectorIDs is false. -* @param useDetectorIDs :: set to true to make a fake texture using the detector -*IDs. If false, the iterator is used. -* -*/ -int RectangularDetectorActor::genTexture(char *&image_data, - std::vector<GLColor> &list, - bool useDetectorIDs) { - int num = mDet->xpixels() * mDet->ypixels(); - - // The texture size must be 2^n power. - int text_x_size, text_y_size; - mDet->getTextureSize(text_x_size, text_y_size); - - // std::cerr << "Texture size: " << text_x_size << ',' << text_y_size - // <<'\n'; - - //------ Create the image data buffer ------- - if (!image_data) { - // Delete the old memory - delete[] image_data; - image_data = new char[3 * text_x_size * text_y_size]; - } - // Pointer to where we are in it. - char *image_data_ptr = image_data; - - // Fill with 0 (black) everywhere - std::fill(image_data, image_data + 3 * text_x_size * text_y_size, 0); - - // For using color IDs - int rgb = 0; - std::vector<GLColor>::iterator list_it = list.begin(); - - for (int y = 0; y < mDet->ypixels(); y++) { - for (int x = 0; x < mDet->xpixels(); x++) { - // Use black as the default color (for going off the edges) - unsigned char r, g, b; - - if (useDetectorIDs) { - GLColor c = GLActor::makePickColor(m_pickIDs[rgb]); - c.get(r, g, b); - rgb++; - } else { - // Get the current color - list_it->get(r, g, b); - // Go to the next color - ++list_it; - } - - // //TEMP: way to show the colors - // r=x; - // g=y; - // b=x; - - // Save the color data to the buffer - *image_data_ptr = r; - image_data_ptr++; - *image_data_ptr = g; - image_data_ptr++; - *image_data_ptr = b; - image_data_ptr++; - } - - // Skip any padding in x. 3 bytes per pixel - image_data_ptr += 3 * (text_x_size - mDet->xpixels()); - } - - if (VERBOSE) - std::cout << "RectangularDetectorActor::genTexture() called for " - << mDet->getName() << " with " << num << " entries set\n"; - - return num; -} - -//------------------------------------------------------------------------------------------------ -/** Upload the texture to the video card. */ -void RectangularDetectorActor::uploadTexture(char *&image_data) const { - if (!image_data) - throw std::runtime_error( - "Empty pointer passed to RectangularDetectorActor::uploadTexture()!"); - - // The texture size must be 2^n power. - int text_x_size, text_y_size; - mDet->getTextureSize(text_x_size, text_y_size); - - // Set up before uploading a texture - if (mTextureID > 0) - glDeleteTextures(1, &mTextureID); - glGenTextures(1, &mTextureID); // Create The Texture - if (VERBOSE) - std::cout << mDet->getName() << " is drawing with texture id " << mTextureID - << "\n"; - // mDet->setTextureID(mTextureID); - - glBindTexture(GL_TEXTURE_2D, mTextureID); - - if (glGetError() > 0) - std::cout << "OpenGL error in glBindTexture \n"; - - glPixelStorei(GL_UNPACK_ALIGNMENT, 1); - - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - - glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, - GL_MODULATE); // This one allows lighting effects - // glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); //This one - // doesn't - - // Upload the texture to video card - if (glGetError() > 0) - std::cout << "OpenGL error BEFORE glTexImage2D \n"; - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, text_x_size, text_y_size, 0, GL_RGB, - GL_UNSIGNED_BYTE, image_data); - if (glGetError() > 0) - std::cout << "OpenGL error in glTexImage2D \n"; -} - -//------------------------------------------------------------------------------------------------- -/** -* Return the bounding box, from the one calculated in the cache previously. -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void RectangularDetectorActor::getBoundingBox( - Mantid::Kernel::V3D &minBound, Mantid::Kernel::V3D &maxBound) const { - minBound = minBoundBox; - maxBound = maxBoundBox; -} - -/** -* Append the bounding box CompAssembly bounding box -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void RectangularDetectorActor::AppendBoundingBox( - const Mantid::Kernel::V3D &minBound, const Mantid::Kernel::V3D &maxBound) { - if (minBoundBox[0] > minBound[0]) - minBoundBox[0] = minBound[0]; - if (minBoundBox[1] > minBound[1]) - minBoundBox[1] = minBound[1]; - if (minBoundBox[2] > minBound[2]) - minBoundBox[2] = minBound[2]; - if (maxBoundBox[0] < maxBound[0]) - maxBoundBox[0] = maxBound[0]; - if (maxBoundBox[1] < maxBound[1]) - maxBoundBox[1] = maxBound[1]; - if (maxBoundBox[2] < maxBound[2]) - maxBoundBox[2] = maxBound[2]; -} - -void RectangularDetectorActor::setColors() { - std::vector<GLColor> clist; - for (int y = 0; y < mDet->ypixels(); y++) { - for (int x = 0; x < mDet->xpixels(); x++) { - detid_t id = mDet->getDetectorIDAtXY(x, y); - clist.push_back(m_instrActor.getColor(id)); - } - } - genTexture(image_data, clist, false); - uploadTexture(image_data); -} -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/RotationSurface.cpp b/qt/widgets/instrumentview/src/RotationSurface.cpp index 0f3bea59cdd292bc6b920915c1ebb33538af9357..a9288fabceb2e7110972539c8d0010d6e9ae6ad3 100644 --- a/qt/widgets/instrumentview/src/RotationSurface.cpp +++ b/qt/widgets/instrumentview/src/RotationSurface.cpp @@ -1,7 +1,9 @@ #include "MantidQtWidgets/InstrumentView/RotationSurface.h" +#include "MantidQtWidgets/InstrumentView/UnwrappedDetector.h" #include "MantidKernel/Logger.h" #include "MantidAPI/MatrixWorkspace.h" #include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include <QCursor> #include <QMessageBox> @@ -29,7 +31,6 @@ RotationSurface::RotationSurface(const InstrumentActor *rootActor, void RotationSurface::init() { // the actor calls this->callback for each detector m_unwrappedDetectors.clear(); - m_assemblies.clear(); // if u-correction is applied manually then m_u_min and m_u_max // have valid values and have to be saved @@ -41,12 +42,6 @@ void RotationSurface::init() { if (ndet == 0) return; - // Pre-calculate all the detector positions (serial because - // I suspect the IComponent->getPos() method to not be properly thread safe) - m_instrActor->cacheDetPos(); - - Instrument_const_sptr inst = m_instrActor->getInstrument(); - // First detector defines the surface's x axis if (m_xaxis.nullVector()) { Mantid::Kernel::V3D pos = m_instrActor->getDetPos(0) - m_pos; @@ -78,8 +73,8 @@ void RotationSurface::init() { m_u_min = -DBL_MAX; m_u_max = DBL_MAX; - const auto &detectorInfo = m_instrActor->getWorkspace()->detectorInfo(); - + const auto &detectorInfo = m_instrActor->detectorInfo(); + const auto &detIds = detectorInfo.detectorIDs(); // Set if one of the threads in the following loop // throws an exception bool exceptionThrown = false; @@ -91,36 +86,20 @@ void RotationSurface::init() { if (!exceptionThrown) try { size_t i = size_t(ii); - - unsigned char color[3]; - Mantid::detid_t id = m_instrActor->getDetID(i); - try { - auto &det = - m_instrActor->getDetectorByDetID(id); - - if (detectorInfo.isMonitor( - detectorInfo.indexOf(id)) || - (id < 0)) { - // Not a detector or a monitor - // Make some blank, empty thing that won't - // draw + if (detectorInfo.isMonitor(i) || + detIds[i] < 0) { m_unwrappedDetectors[i] = UnwrappedDetector(); } else { // A real detector. - m_instrActor->getColor(id).getUB3(&color[0]); - // Position, relative to origin - // Mantid::Kernel::V3D pos = det->getPos() - - // m_pos; - Mantid::Kernel::V3D pos = - m_instrActor->getDetPos(i) - m_pos; - + auto rpos = detectorInfo.position(i) - m_pos; // Create the unwrapped shape - UnwrappedDetector udet(&color[0], det); + UnwrappedDetector udet( + m_instrActor->getColor(i), i); // Calculate its position/size in UV // coordinates - this->calcUV(udet, pos); + this->calcUV(udet, rpos); m_unwrappedDetectors[i] = udet; } // is a real detector @@ -209,7 +188,8 @@ void RotationSurface::findUVBounds() { m_v_max = -DBL_MAX; for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) { const UnwrappedDetector &udet = m_unwrappedDetectors[i]; - if (!udet.isValid()) + if (udet.empty() || + !m_instrActor->componentInfo().hasValidShape(udet.detIndex)) continue; if (udet.u < m_u_min) m_u_min = udet.u; @@ -239,12 +219,11 @@ void RotationSurface::findAndCorrectUGap() { return; } - std::vector<UnwrappedDetector>::const_iterator ud = - m_unwrappedDetectors.begin(); - for (; ud != m_unwrappedDetectors.end(); ++ud) { - if (!ud->isValid()) + for (const auto &udet : m_unwrappedDetectors) { + if (udet.empty() || + !m_instrActor->componentInfo().hasValidShape(udet.detIndex)) continue; - double u = ud->u; + double u = udet.u; int i = int((u - m_u_min) / bin_width); ubins[i] = true; } @@ -278,11 +257,11 @@ void RotationSurface::findAndCorrectUGap() { m_u_max += period; } - std::vector<UnwrappedDetector>::iterator ud = m_unwrappedDetectors.begin(); - for (; ud != m_unwrappedDetectors.end(); ++ud) { - if (!ud->isValid()) + for (auto &udet : m_unwrappedDetectors) { + if (udet.empty() || + !m_instrActor->componentInfo().hasValidShape(udet.detIndex)) continue; - double &u = ud->u; + double &u = udet.u; u = applyUCorrection(u); } } diff --git a/qt/widgets/instrumentview/src/SampleActor.cpp b/qt/widgets/instrumentview/src/SampleActor.cpp deleted file mode 100644 index a2fc83fe23be649801ac7519e0e83cd5e686b3e2..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/SampleActor.cpp +++ /dev/null @@ -1,51 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/SampleActor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/OpenGLError.h" - -#include "MantidAPI/Sample.h" -#include "MantidGeometry/IObjComponent.h" - -using namespace Mantid; -using namespace Geometry; - -namespace MantidQt { -namespace MantidWidgets { - -SampleActor::SampleActor(const InstrumentActor &instrActor, - const Mantid::API::Sample &sample, - const ObjComponentActor *samplePosActor) - : GLActor(), m_instrActor(instrActor), m_sample(sample), - m_samplePosActor(samplePosActor), - m_samplePos(samplePosActor->getObjComponent()), m_color(255, 255, 255) {} - -/** -* Implementation of rendering Sample. -*/ -void SampleActor::draw(bool picking) const { - if (!picking && isVisible()) { - OpenGLError::check("SampleActor::draw()"); - glPushAttrib(GL_ENABLE_BIT); - GLboolean hasLight0; - glGetBooleanv(GL_LIGHT0, &hasLight0); - if (hasLight0) { - glEnable(GL_LIGHTING); - } - glPushMatrix(); - m_color.paint(); - Mantid::Kernel::V3D pos = m_samplePos->getPos(); - glTranslated(pos.X(), pos.Y(), pos.Z()); - m_sample.getShape().draw(); - glPopMatrix(); - glPopAttrib(); - OpenGLError::check("SampleActor::draw()"); - } -} - -void SampleActor::getBoundingBox(Mantid::Kernel::V3D &minBound, - Mantid::Kernel::V3D &maxBound) const { - Mantid::Geometry::BoundingBox boundBox = m_sample.getShape().getBoundingBox(); - minBound = boundBox.minPoint(); - maxBound = boundBox.maxPoint(); -} -} // MantidWidgets -} // MantidQt diff --git a/qt/widgets/instrumentview/src/StructuredDetectorActor.cpp b/qt/widgets/instrumentview/src/StructuredDetectorActor.cpp deleted file mode 100644 index 5e539f666986cd5ba7b76532a29399218b0967d2..0000000000000000000000000000000000000000 --- a/qt/widgets/instrumentview/src/StructuredDetectorActor.cpp +++ /dev/null @@ -1,193 +0,0 @@ -#include "MantidQtWidgets/InstrumentView/GLActorVisitor.h" -#include "MantidQtWidgets/InstrumentView/InstrumentActor.h" -#include "MantidQtWidgets/InstrumentView/ObjComponentActor.h" -#include "MantidQtWidgets/InstrumentView/StructuredDetectorActor.h" - -#include "MantidGeometry/ICompAssembly.h" -#include "MantidGeometry/IComponent.h" -#include "MantidGeometry/IDetector.h" -#include "MantidGeometry/IObjComponent.h" -#include "MantidGeometry/Instrument.h" -#include "MantidGeometry/Instrument/StructuredDetector.h" -#include "MantidGeometry/Objects/BoundingBox.h" -#include "MantidGeometry/Objects/CSGObject.h" -#include "MantidKernel/Exception.h" -#include "MantidKernel/V3D.h" -#include <cfloat> -using namespace Mantid; -using namespace Geometry; -using Mantid::Kernel::V3D; -using Mantid::Kernel::Quat; - -namespace MantidQt { -namespace MantidWidgets { - -/** -* Constructor. -* -* @param instrActor :: the instrument actor -* @param compID :: the component ID -*/ -StructuredDetectorActor::StructuredDetectorActor( - const InstrumentActor &instrActor, - const Mantid::Geometry::ComponentID &compID) - : ICompAssemblyActor(instrActor, compID) { - - mNumberOfDetectors = 0; - m_det = boost::dynamic_pointer_cast<const StructuredDetector>(getComponent()); - - if (!m_det) - return; - - BoundingBox compBox; - m_det->getBoundingBox(compBox); - mNumberOfDetectors = m_det->xPixels() * m_det->yPixels(); - this->AppendBoundingBox(compBox.minPoint(), compBox.maxPoint()); - - for (size_t y = 0; y < m_det->yPixels(); y++) { - for (size_t x = 0; x < m_det->xPixels(); x++) { - // Getting the detector is slow. Get the ID directly - detid_t id = m_det->getDetectorIDAtXY(x, y); - size_t pickID = instrActor.pushBackDetid(id); - m_pickIds.push_back(pickID); - m_pickColors.push_back(GLActor::makePickColor(pickID)); - m_clist.push_back(instrActor.getColor(id)); - } - } -} - -/** -* Destructor which removes the actors created by this object -*/ -StructuredDetectorActor::~StructuredDetectorActor() {} - -void StructuredDetectorActor::draw(bool picking) const { - glPushMatrix(); - // Translation first - V3D pos = m_det->getPos(); - if (!(pos.nullVector())) { - glTranslated(pos[0], pos[1], pos[2]); - } - // Rotation - Quat rot = m_det->getRotation(); - if (!(rot.isNull())) { - double deg, ax0, ax1, ax2; - rot.getAngleAxis(deg, ax0, ax1, ax2); - glRotated(deg, ax0, ax1, ax2); - } - // Scale - V3D scaleFactor = m_det->getScaleFactor(); - if (!(scaleFactor == V3D(1, 1, 1))) { - glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - } - - // StructuredDetector will use. - std::vector<int> r, g, b; - - if (picking) { - for (std::vector<GLColor>::const_iterator i = m_pickColors.cbegin(); - i != m_pickColors.cend(); ++i) { - r.push_back((*i).red()); - g.push_back((*i).green()); - b.push_back((*i).blue()); - } - } else { - for (std::vector<GLColor>::const_iterator i = m_clist.cbegin(); - i != m_clist.cend(); ++i) { - r.push_back((*i).red()); - g.push_back((*i).green()); - b.push_back((*i).blue()); - } - } - - m_det->setColors(r, g, b); - m_det->draw(); - - glPopMatrix(); -} - -/** -* Accept a visitor. This sets the matching component's visibility to True. -* It looks if the given component is a child (pixel) of the parent rectangular -* detector, and sets the visibility of the whole panel to true if so. -* -* @param visitor :: A visitor. -* @param rule :: A rule defining visitor acceptance by assembly actors. Unused. -* -*/ -bool StructuredDetectorActor::accept(GLActorVisitor &visitor, - VisitorAcceptRule) { - return visitor.visit(this); -} - -bool StructuredDetectorActor::accept(GLActorConstVisitor &visitor, - VisitorAcceptRule) const { - return visitor.visit(this); -} - -bool StructuredDetectorActor::isChildDetector( - const Mantid::Geometry::ComponentID &id) const { - // ID of the parent RectangularDetector - Mantid::Geometry::ComponentID thisID = this->m_id; - - // Get the component object - IComponent_const_sptr comp = - m_instrActor.getInstrument()->getComponentByID(id); - if (comp) { - // Get the parent (e.g. the column) - IComponent_const_sptr parent1 = comp->getParent(); - if (parent1) { - if (parent1->getComponentID() == thisID) { - return true; - } - // Go to grandparent - IComponent_const_sptr parent2 = parent1->getParent(); - if (parent2) { - if (parent2->getComponentID() == thisID) { - return true; - } - } // valid grandparent - } // valid parent - } // valid component - return false; -} - -//------------------------------------------------------------------------------------------------- -/** -* Return the bounding box, from the one calculated in the cache previously. -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void StructuredDetectorActor::getBoundingBox( - Mantid::Kernel::V3D &minBound, Mantid::Kernel::V3D &maxBound) const { - minBound = minBoundBox; - maxBound = maxBoundBox; -} - -/** -* Append the bounding box CompAssembly bounding box -* @param minBound :: min point of the bounding box -* @param maxBound :: max point of the bounding box -*/ -void StructuredDetectorActor::AppendBoundingBox( - const Mantid::Kernel::V3D &minBound, const Mantid::Kernel::V3D &maxBound) { - if (minBoundBox[0] > minBound[0]) - minBoundBox[0] = minBound[0]; - if (minBoundBox[1] > minBound[1]) - minBoundBox[1] = minBound[1]; - if (minBoundBox[2] > minBound[2]) - minBoundBox[2] = minBound[2]; - if (maxBoundBox[0] < maxBound[0]) - maxBoundBox[0] = maxBound[0]; - if (maxBoundBox[1] < maxBound[1]) - maxBoundBox[1] = maxBound[1]; - if (maxBoundBox[2] < maxBound[2]) - maxBoundBox[2] = maxBound[2]; -} - -void StructuredDetectorActor::setColors() { - // do nothing -} - -} // namespace MantidWidgets -} // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/instrumentview/src/UnwrappedCylinder.cpp b/qt/widgets/instrumentview/src/UnwrappedCylinder.cpp index ce2f3e4277af1a3bfeaf6697feedfa9a7416d84d..c7c8e5cacd04d30ec644c396119ed411aff42e5d 100644 --- a/qt/widgets/instrumentview/src/UnwrappedCylinder.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedCylinder.cpp @@ -1,6 +1,7 @@ #include "MantidQtWidgets/InstrumentView/UnwrappedCylinder.h" +#include "MantidQtWidgets/InstrumentView/UnwrappedDetector.h" -#include "MantidGeometry/IDetector.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" namespace MantidQt { namespace MantidWidgets { @@ -38,10 +39,11 @@ void UnwrappedCylinder::rotate(const UnwrappedDetector &udet, Mantid::Kernel::Quat &R) const { // direction in which to look Mantid::Kernel::V3D eye; + const auto &componentInfo = m_instrActor->componentInfo(); // rotation from the global axes to those where // the z axis points to the detector Mantid::Kernel::Quat R1; - eye = m_pos - udet.position; + eye = m_pos - componentInfo.position(udet.detIndex); if (!eye.nullVector()) { // eye must point towards the detector and be perpendicular to the // cylinder's axis @@ -54,7 +56,7 @@ void UnwrappedCylinder::rotate(const UnwrappedDetector &udet, } } // add detector's own rotation - R = R1 * udet.rotation; + R = R1 * componentInfo.rotation(udet.detIndex); } } // MantidWidgets diff --git a/qt/widgets/instrumentview/src/UnwrappedDetector.cpp b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp new file mode 100644 index 0000000000000000000000000000000000000000..d3ad0c7281581027e2e9e651d5dd8a201213c7aa --- /dev/null +++ b/qt/widgets/instrumentview/src/UnwrappedDetector.cpp @@ -0,0 +1,45 @@ +#include "MantidQtWidgets/InstrumentView/UnwrappedDetector.h" +#include "MantidGeometry/IDetector.h" +#include "MantidGeometry/Objects/CSGObject.h" + +using namespace Mantid::Geometry; + +namespace MantidQt { +namespace MantidWidgets { + +UnwrappedDetector::UnwrappedDetector() + : u(0), v(0), width(0), height(0), uscale(0), vscale(0) { + color = GLColor(0, 0, 0); +} + +UnwrappedDetector::UnwrappedDetector(GLColor color, size_t detIndex) + : u(0), v(0), width(0), height(0), uscale(0), vscale(0), + detIndex(detIndex) { + this->color = color; +} + +/** Copy constructor */ +UnwrappedDetector::UnwrappedDetector(const UnwrappedDetector &other) { + this->operator=(other); +} + +/** Assignment operator */ +UnwrappedDetector &UnwrappedDetector:: +operator=(const UnwrappedDetector &other) { + color = other.color; + u = other.u; + v = other.v; + width = other.width; + height = other.height; + uscale = other.uscale; + vscale = other.vscale; + detIndex = other.detIndex; + return *this; +} + +bool UnwrappedDetector::empty() const { + return detIndex == std::numeric_limits<size_t>::max(); +} + +} // namespace MantidWidgets +} // namespace MantidQt \ No newline at end of file diff --git a/qt/widgets/instrumentview/src/UnwrappedSphere.cpp b/qt/widgets/instrumentview/src/UnwrappedSphere.cpp index 71ad108ce3c72c027c9debeec868592b97e8dac8..9f142e6577b76a665448975912cddf38838b3c3c 100644 --- a/qt/widgets/instrumentview/src/UnwrappedSphere.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedSphere.cpp @@ -1,5 +1,6 @@ #include "MantidQtWidgets/InstrumentView/UnwrappedSphere.h" -#include "MantidGeometry/IDetector.h" +#include "MantidQtWidgets/InstrumentView/UnwrappedDetector.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include <cmath> namespace MantidQt { @@ -43,12 +44,13 @@ void UnwrappedSphere::rotate(const UnwrappedDetector &udet, Mantid::Kernel::Quat R1; // direction in which to look: from sample to detector Mantid::Kernel::V3D eye; - eye = m_pos - udet.position; + const auto &componentInfo = m_instrActor->componentInfo(); + eye = m_pos - componentInfo.position(udet.detIndex); if (!eye.nullVector()) { InstrumentActor::rotateToLookAt(eye, m_zaxis, R1); } // add detector's own rotation - R = R1 * udet.rotation; + R = R1 * componentInfo.rotation(udet.detIndex); } } // MantidWidgets diff --git a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp index 5bf94a32d8d1c05a43f9173523a37cac22567c76..2e4efc1da7030aaea1c8879c5a91be90dc3bf91e 100644 --- a/qt/widgets/instrumentview/src/UnwrappedSurface.cpp +++ b/qt/widgets/instrumentview/src/UnwrappedSurface.cpp @@ -1,82 +1,47 @@ #include "MantidQtWidgets/InstrumentView/UnwrappedSurface.h" #include "MantidQtWidgets/InstrumentView/GLColor.h" +#include "MantidQtWidgets/InstrumentView/InstrumentRenderer.h" #include "MantidQtWidgets/InstrumentView/MantidGLWidget.h" #include "MantidQtWidgets/InstrumentView/OpenGLError.h" #include "MantidQtWidgets/InstrumentView/PeakMarker2D.h" #include "MantidAPI/IPeaksWorkspace.h" #include "MantidGeometry/IDetector.h" -#include "MantidGeometry/Instrument.h" +#include "MantidGeometry/Instrument/DetectorInfo.h" +#include "MantidGeometry/Instrument/ComponentInfo.h" #include "MantidGeometry/Objects/CSGObject.h" #include "MantidQtWidgets/Common/InputController.h" -#include <QRgb> -#include <QSet> #include <QMenu> #include <QMouseEvent> #include <QApplication> -#include <QMessageBox> #include <QTransform> #include <cfloat> #include <limits> #include <cmath> -#include "MantidKernel/Exception.h" using namespace Mantid::Geometry; namespace MantidQt { namespace MantidWidgets { - -UnwrappedDetector::UnwrappedDetector() - : u(0), v(0), width(0), height(0), uscale(0), vscale(0), detID(0) { - color[0] = 0; - color[1] = 0; - color[2] = 0; -} - -UnwrappedDetector::UnwrappedDetector(const unsigned char *c, - const IDetector &det) - : u(0), v(0), width(0), height(0), uscale(0), vscale(0), detID(det.getID()), - position(det.getPos()), rotation(det.getRotation()), shape(det.shape()), - scaleFactor(det.getScaleFactor()) { - color[0] = *c; - color[1] = *(c + 1); - color[2] = *(c + 2); -} - -/** Copy constructor */ -UnwrappedDetector::UnwrappedDetector(const UnwrappedDetector &other) { - this->operator=(other); -} - -/** Assignment operator */ -UnwrappedDetector &UnwrappedDetector:: -operator=(const UnwrappedDetector &other) { - color[0] = other.color[0]; - color[1] = other.color[1]; - color[2] = other.color[2]; - u = other.u; - v = other.v; - width = other.width; - height = other.height; - uscale = other.uscale; - vscale = other.vscale; - detID = other.detID; - position = other.position; - rotation = other.rotation; - shape = other.shape; - scaleFactor = other.scaleFactor; - return *this; +namespace { + +QRectF getArea(const UnwrappedDetector &udet, double maxWidth, + double maxHeight) { + auto w = udet.width; + if (w > maxWidth) + w = maxWidth; + auto h = udet.height; + if (h > maxHeight) + h = maxHeight; + return QRectF(udet.u - w, udet.v - h, w * 2, h * 2); } - -/** Check if the object is valid*/ -bool UnwrappedDetector::isValid() const { return static_cast<bool>(shape); } - -/** -* Constructor. -* @param rootActor :: The instrument actor. -*/ +} // namespace + /** + * Constructor. + * @param rootActor :: The instrument actor. + */ UnwrappedSurface::UnwrappedSurface(const InstrumentActor *rootActor) : ProjectionSurface(rootActor), m_u_min(DBL_MAX), m_u_max(-DBL_MAX), m_v_min(DBL_MAX), m_v_max(-DBL_MAX), m_height_max(0), m_width_max(0), @@ -103,52 +68,6 @@ QString UnwrappedSurface::getDimInfo() const { .arg(m_viewRect.y1()); } -//------------------------------------------------------------------------------ -/** Calculate the rectangular region in uv coordinates occupied by an assembly. -* -* @param comp :: A member of the assembly. The total area of the assembly is a -*sum of areas of its members -* @param compRect :: A rect. area occupied by comp in uv space -*/ -void UnwrappedSurface::calcAssemblies(const Mantid::Geometry::IComponent *comp, - const QRectF &compRect) { - // We don't need the parametrized version = use the bare parent for speed - const Mantid::Geometry::IComponent *parent = comp->getBareParent(); - if (parent) { - QRectF &r = m_assemblies[parent->getComponentID()]; - r |= compRect; - calcAssemblies(parent, r); - } -} - -//------------------------------------------------------------------------------ -/** If needed, recalculate the cached bounding rectangles of all assemblies. */ -void UnwrappedSurface::cacheAllAssemblies() { - if (!m_assemblies.empty()) - return; - - for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) { - const UnwrappedDetector &udet = m_unwrappedDetectors[i]; - if (!udet.isValid()) - continue; - // Get the BARE parent (not parametrized) to speed things up. - auto &detector = m_instrActor->getDetectorByDetID(udet.detID); - const Mantid::Geometry::IComponent *bareDet = detector.getComponentID(); - const Mantid::Geometry::IComponent *parent = bareDet->getBareParent(); - if (parent) { - QRectF detRect; - detRect.setLeft(udet.u - udet.width); - detRect.setRight(udet.u + udet.width); - detRect.setBottom(udet.v - udet.height); - detRect.setTop(udet.v + udet.height); - Mantid::Geometry::ComponentID id = parent->getComponentID(); - QRectF &r = m_assemblies[id]; - r |= detRect; - calcAssemblies(parent, r); - } - } -} - //------------------------------------------------------------------------------ /** * Draw the unwrapped instrument onto the screen @@ -220,10 +139,9 @@ void UnwrappedSurface::drawSurface(MantidGLWidget *widget, bool picking) const { glShadeModel(GL_FLAT); } - for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) { - const UnwrappedDetector &udet = m_unwrappedDetectors[i]; - - if (!udet.isValid()) + const auto &componentInfo = m_instrActor->componentInfo(); + for (const auto &udet : m_unwrappedDetectors) { + if (udet.empty() || !componentInfo.hasValidShape(udet.detIndex)) continue; int iw = int(udet.width / dw); @@ -237,7 +155,7 @@ void UnwrappedSurface::drawSurface(MantidGLWidget *widget, bool picking) const { continue; // apply the detector's colour - setColor(int(i), picking); + setColor(udet.detIndex, picking); // if the detector is too small to see its shape draw a rectangle if (iw < 6 || ih < 6) { @@ -261,10 +179,11 @@ void UnwrappedSurface::drawSurface(MantidGLWidget *widget, bool picking) const { rot.getAngleAxis(deg, ax0, ax1, ax2); glRotated(deg, ax0, ax1, ax2); - Mantid::Kernel::V3D scaleFactor = udet.scaleFactor; + Mantid::Kernel::V3D scaleFactor = + componentInfo.scaleFactor(udet.detIndex); glScaled(scaleFactor[0], scaleFactor[1], scaleFactor[2]); - udet.shape->draw(); + m_instrActor->componentInfo().shape(udet.detIndex).draw(); glPopMatrix(); } @@ -285,14 +204,16 @@ void UnwrappedSurface::drawSurface(MantidGLWidget *widget, bool picking) const { * @param picking :: True if detector is being drawn in the picking mode. * In this case index is transformed into color */ -void UnwrappedSurface::setColor(int index, bool picking) const { +void UnwrappedSurface::setColor(size_t index, bool picking) const { if (picking) { - GLColor c = GLActor::makePickColor(index); + auto c = InstrumentRenderer::makePickColor(index); unsigned char r, g, b; c.get(r, g, b); glColor3ub(r, g, b); } else { - glColor3ubv(&m_unwrappedDetectors[index].color[0]); + unsigned char col[3]; + m_unwrappedDetectors[index].color.getUB3(&col[0]); + glColor3ub(col[0], col[1], col[2]); } } @@ -314,51 +235,28 @@ bool hasParent(boost::shared_ptr<const Mantid::Geometry::IComponent> comp, * * @param id :: ComponentID to zoom to. */ -void UnwrappedSurface::componentSelected(Mantid::Geometry::ComponentID id) { - boost::shared_ptr<const Mantid::Geometry::Instrument> instr = - m_instrActor->getInstrument(); - if (id == nullptr) { - id = instr->getComponentID(); - } - boost::shared_ptr<const Mantid::Geometry::IComponent> comp = - instr->getComponentByID(id); - boost::shared_ptr<const Mantid::Geometry::ICompAssembly> ass = - boost::dynamic_pointer_cast<const Mantid::Geometry::ICompAssembly>(comp); - boost::shared_ptr<const Mantid::Geometry::IDetector> det = - boost::dynamic_pointer_cast<const Mantid::Geometry::IDetector>(comp); - if (det) { - int detID = det->getID(); - - std::vector<UnwrappedDetector>::const_iterator it; - for (it = m_unwrappedDetectors.begin(); it != m_unwrappedDetectors.end(); - ++it) { - const UnwrappedDetector &udet = *it; - if (udet.detID == detID) { - double w = udet.width; - if (w > m_width_max) - w = m_width_max; - double h = udet.height; - if (h > m_height_max) - h = m_height_max; - QRectF area(udet.u - w, udet.v - h, w * 2, h * 2); - zoom(area); - break; - } - } - } - if (ass) { - this->cacheAllAssemblies(); - QMap<Mantid::Geometry::ComponentID, QRectF>::iterator assRect = - m_assemblies.find(ass->getComponentID()); - if (assRect != m_assemblies.end()) - zoom(*assRect); - else { - // std::cout << "Assembly not found \n"; +void UnwrappedSurface::componentSelected(size_t componentIndex) { + const auto &componentInfo = m_instrActor->componentInfo(); + if (componentInfo.isDetector(componentIndex)) { + const auto &udet = m_unwrappedDetectors[componentIndex]; + zoom(getArea(udet, m_width_max, m_height_max)); + } else { + auto detectors = componentInfo.detectorsInSubtree(componentIndex); + QRectF area; + for (auto det : detectors) { + QRectF detRect; + const auto &udet = m_unwrappedDetectors[det]; + detRect.setLeft(udet.u - udet.width); + detRect.setRight(udet.u + udet.width); + detRect.setBottom(udet.v - udet.height); + detRect.setTop(udet.v + udet.height); + area |= detRect; } + zoom(area); } } -void UnwrappedSurface::getSelectedDetectors(QList<int> &dets) { +void UnwrappedSurface::getSelectedDetectors(std::vector<size_t> &detIndices) { if (m_selectRect.isNull()) { return; } @@ -417,19 +315,20 @@ void UnwrappedSurface::getSelectedDetectors(QList<int> &dets) { UnwrappedDetector &udet = m_unwrappedDetectors[i]; if (udet.u >= uleft && udet.u <= uright && udet.v >= vbottom && udet.v <= vtop) { - dets.push_back(udet.detID); + detIndices.push_back(udet.detIndex); } } } -void UnwrappedSurface::getMaskedDetectors(QList<int> &dets) const { - dets.clear(); +void UnwrappedSurface::getMaskedDetectors( + std::vector<size_t> &detIndices) const { + detIndices.clear(); if (m_maskShapes.isEmpty()) return; for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) { const UnwrappedDetector &udet = m_unwrappedDetectors[i]; if (m_maskShapes.isMasked(udet.u, udet.v)) { - dets.append(udet.detID); + detIndices.push_back(udet.detIndex); } } } @@ -437,11 +336,7 @@ void UnwrappedSurface::getMaskedDetectors(QList<int> &dets) const { void UnwrappedSurface::changeColorMap() { for (size_t i = 0; i < m_unwrappedDetectors.size(); ++i) { UnwrappedDetector &udet = m_unwrappedDetectors[i]; - unsigned char color[3]; - m_instrActor->getColor(udet.detID).getUB3(&color[0]); - udet.color[0] = color[0]; - udet.color[1] = color[1]; - udet.color[2] = color[2]; + udet.color = m_instrActor->getColor(udet.detIndex); } } @@ -565,13 +460,13 @@ void UnwrappedSurface::drawSimpleToImage(QImage *image, bool picking) const { QColor color; int index = int(i); if (picking) { - GLColor c = GLActor::makePickColor(index); + GLColor c = InstrumentRenderer::makePickColor(index); unsigned char r, g, b; c.get(r, g, b); color = QColor(r, g, b); } else { - auto c = &m_unwrappedDetectors[index].color[0]; - color = QColor(c[0], c[1], c[2]); + auto c = m_unwrappedDetectors[index].color; + color = QColor(c.red(), c.green(), c.blue()); } paint.fillRect(u - iw / 2, v - ih / 2, iw, ih, color); @@ -701,8 +596,9 @@ void UnwrappedSurface::calcSize(UnwrappedDetector &udet) { Mantid::Kernel::Quat R; this->rotate(udet, R); - Mantid::Geometry::BoundingBox bbox = udet.shape->getBoundingBox(); - Mantid::Kernel::V3D scale = udet.scaleFactor; + const auto &componentInfo = m_instrActor->componentInfo(); + const auto &bbox = componentInfo.shape(udet.detIndex).getBoundingBox(); + auto scale = componentInfo.scaleFactor(udet.detIndex); // sizes of the detector along each 3D axis Mantid::Kernel::V3D size = bbox.maxPoint() - bbox.minPoint(); diff --git a/qt/widgets/legacyqwt/inc/MantidQtWidgets/LegacyQwt/SignalRange.h b/qt/widgets/legacyqwt/inc/MantidQtWidgets/LegacyQwt/SignalRange.h index a505acc0a8638b5676210ca8c54c6e05f9b81a6e..79cd4629b557e6ef469cbc26f8512ac36c9f7a83 100644 --- a/qt/widgets/legacyqwt/inc/MantidQtWidgets/LegacyQwt/SignalRange.h +++ b/qt/widgets/legacyqwt/inc/MantidQtWidgets/LegacyQwt/SignalRange.h @@ -54,8 +54,8 @@ private: Mantid::Geometry::MDImplicitFunction *function); /// Get the range of signal, in parallel, given an iterator - QwtDoubleInterval - getRange(const std::vector<Mantid::API::IMDIterator *> &iterators); + QwtDoubleInterval getRange( + const std::vector<std::unique_ptr<Mantid::API::IMDIterator>> &iterators); /// Get the range of signal given an iterator QwtDoubleInterval getRange(Mantid::API::IMDIterator *it); diff --git a/qt/widgets/legacyqwt/src/MWView.cpp b/qt/widgets/legacyqwt/src/MWView.cpp index aaacf5d3ea691862d13b5ba8244c8c48f219427e..bc76328e8b65ff73b54b1e919f6c66f1fe8fce99 100644 --- a/qt/widgets/legacyqwt/src/MWView.cpp +++ b/qt/widgets/legacyqwt/src/MWView.cpp @@ -185,7 +185,7 @@ void MWView::loadSettings() { // used. // If the user selected a unified color map for the SliceViewer and the VSI, // then this is loaded. - if (m_mdSettings != NULL && m_mdSettings->getUsageGeneralMdColorMap()) { + if (m_mdSettings != nullptr && m_mdSettings->getUsageGeneralMdColorMap()) { m_currentColorMapFile = m_mdSettings->getGeneralMdColorMapFile(); } else { m_currentColorMapFile = settings.value("ColormapFile", "").toString(); diff --git a/qt/widgets/legacyqwt/src/MantidQwtIMDWorkspaceData.cpp b/qt/widgets/legacyqwt/src/MantidQwtIMDWorkspaceData.cpp index e6a3d3abaa00e12b61d00828da11b270d60e8184..855b10cfa9d0f806e2272d212c2a4a1b12789fd5 100644 --- a/qt/widgets/legacyqwt/src/MantidQwtIMDWorkspaceData.cpp +++ b/qt/widgets/legacyqwt/src/MantidQwtIMDWorkspaceData.cpp @@ -316,7 +316,7 @@ void MantidQwtIMDWorkspaceData::choosePlotAxis() { regularBinnedMDWorkspace = atLeastOneDimNotIntegrated; } - if (NULL != + if (nullptr != boost::dynamic_pointer_cast<const Mantid::API::IMDHistoWorkspace>( originalWS) || regularBinnedMDWorkspace) { diff --git a/qt/widgets/legacyqwt/src/SignalRange.cpp b/qt/widgets/legacyqwt/src/SignalRange.cpp index 62dc07304855e024b652d6cfa461d6a26741b88e..b1e9d8c4c254ba956ce825f2a71369f928ff76a1 100644 --- a/qt/widgets/legacyqwt/src/SignalRange.cpp +++ b/qt/widgets/legacyqwt/src/SignalRange.cpp @@ -65,12 +65,12 @@ void SignalRange::findFullRange( * @return the min/max range, or 0-1.0 if not found */ QwtDoubleInterval SignalRange::getRange( - const std::vector<Mantid::API::IMDIterator *> &iterators) { + const std::vector<std::unique_ptr<Mantid::API::IMDIterator>> &iterators) { std::vector<QwtDoubleInterval> intervals(iterators.size()); // cppcheck-suppress syntaxError PRAGMA_OMP( parallel for schedule(dynamic, 1)) for (int i = 0; i < int(iterators.size()); i++) { - Mantid::API::IMDIterator *it = iterators[i]; + auto it = iterators[i].get(); intervals[i] = this->getRange(it); // don't delete iterator in parallel. MSVC doesn't like it // when the iterator points to a mock object. @@ -80,8 +80,6 @@ QwtDoubleInterval SignalRange::getRange( double minSignal = DBL_MAX; double maxSignal = -DBL_MAX; for (size_t i = 0; i < iterators.size(); i++) { - delete iterators[i]; - double signal; signal = intervals[i].minValue(); if (!std::isfinite(signal)) diff --git a/qt/widgets/plugins/algorithm_dialogs/src/LoadDialog.cpp b/qt/widgets/plugins/algorithm_dialogs/src/LoadDialog.cpp index 0d091f7cd13d49192b0e0195061c95f119482e38..b0dff8bcc61535df9ae5d1fd9beb6926351ac92c 100644 --- a/qt/widgets/plugins/algorithm_dialogs/src/LoadDialog.cpp +++ b/qt/widgets/plugins/algorithm_dialogs/src/LoadDialog.cpp @@ -216,7 +216,7 @@ void LoadDialog::tieStaticWidgets(const bool readHistory) { } tie(m_form.workspaceEdit, "OutputWorkspace", m_form.workspaceLayout, readHistory); - tie(m_form.fileWidget, "Filename", NULL, readHistory); + tie(m_form.fileWidget, "Filename", nullptr, readHistory); } /** @@ -386,7 +386,7 @@ int LoadDialog::createWidgetsForProperty(const Mantid::Kernel::Property *prop, if (addValidator) tie(inputWidget, propName, widgetLayout); else - tie(inputWidget, propName, NULL); + tie(inputWidget, propName, nullptr); return inputWidget->geometry().height(); } diff --git a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QPeaksTableModel.h b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QPeaksTableModel.h index d294d2cb3681d0c45ca70ca509d78090737c339c..4d41a695fbd2c52a1d466437711b8657241d6ecf 100644 --- a/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QPeaksTableModel.h +++ b/qt/widgets/sliceviewer/inc/MantidQtWidgets/SliceViewer/QPeaksTableModel.h @@ -116,6 +116,8 @@ public: static const QString QLAB; /// Label for Q-vector in the sample column static const QString QSAMPLE; + /// Label for Q-vector in the peak number column + static const QString PEAKNUM; private: /// Find the correct column name for this column index @@ -161,6 +163,8 @@ private: static const int COL_QLAB; /// Index for Q-vector in the sample column static const int COL_QSAMPLE; + /// Unique peak number + static const int COL_PEAKNUM; /// The number of digits past the decimal to display in the table int m_hklPrec; /// Map from column index to raw peak data diff --git a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp index 2b80d68addfe8f8d99114e01e93ecd164713d75a..9bd23870c0f7045031f0e7818a341915f2babbff 100644 --- a/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp +++ b/qt/widgets/sliceviewer/src/ConcretePeaksPresenter.cpp @@ -286,7 +286,7 @@ bool ConcretePeaksPresenter::isDimensionNameOfFreeAxis( Request that each owned view makes its self visible. */ void ConcretePeaksPresenter::showAll() { - if (m_viewPeaks != NULL) + if (m_viewPeaks != nullptr) m_viewPeaks->showView(); } @@ -295,7 +295,7 @@ void ConcretePeaksPresenter::showAll() { */ void ConcretePeaksPresenter::hideAll() { // Hide all views. - if (m_viewPeaks != NULL) + if (m_viewPeaks != nullptr) m_viewPeaks->hideView(); } @@ -319,7 +319,7 @@ PeakViewColor ConcretePeaksPresenter::getForegroundPeakViewColor() const { void ConcretePeaksPresenter::setForegroundColor(const PeakViewColor color) { // Change foreground colors - if (m_viewPeaks != NULL) { + if (m_viewPeaks != nullptr) { m_viewPeaks->changeForegroundColour(color); m_viewPeaks->updateView(); } @@ -329,7 +329,7 @@ void ConcretePeaksPresenter::setForegroundColor(const PeakViewColor color) { void ConcretePeaksPresenter::setBackgroundColor(const PeakViewColor color) { // Change background colours - if (m_viewPeaks != NULL) { + if (m_viewPeaks != nullptr) { m_viewPeaks->changeBackgroundColour(color); m_viewPeaks->updateView(); } @@ -343,7 +343,7 @@ std::string ConcretePeaksPresenter::getTransformName() const { void ConcretePeaksPresenter::showBackgroundRadius(const bool show) { // Change background colours - if (m_viewPeaks != NULL) { + if (m_viewPeaks != nullptr) { m_viewPeaks->showBackgroundRadius(show); doFindPeaksInRegion(); } @@ -353,7 +353,7 @@ void ConcretePeaksPresenter::showBackgroundRadius(const bool show) { void ConcretePeaksPresenter::setShown(const bool shown) { m_isHidden = !shown; - if (m_viewPeaks != NULL) { + if (m_viewPeaks != nullptr) { if (shown) { m_viewPeaks->showView(); } else { @@ -417,7 +417,7 @@ void ConcretePeaksPresenter::setPeakSizeIntoProjection(const double fraction) { double ConcretePeaksPresenter::getPeakSizeOnProjection() const { double result = 0; - if (m_viewPeaks != NULL && m_peaksWS->getNumberPeaks() > 0) { + if (m_viewPeaks != nullptr && m_peaksWS->getNumberPeaks() > 0) { result = m_viewPeaks->getOccupancyInView(); } return result; @@ -425,7 +425,7 @@ double ConcretePeaksPresenter::getPeakSizeOnProjection() const { double ConcretePeaksPresenter::getPeakSizeIntoProjection() const { double result = 0; - if (m_viewPeaks != NULL && m_peaksWS->getNumberPeaks() > 0) { + if (m_viewPeaks != nullptr && m_peaksWS->getNumberPeaks() > 0) { result = m_viewPeaks->getOccupancyIntoView(); } return result; diff --git a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp index 966a4b29409326af1b7770b36b9c7d1e901767e2..9ca18beb52fdf6d2e45c14837a24e52828974145 100644 --- a/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp +++ b/qt/widgets/sliceviewer/src/QPeaksTableModel.cpp @@ -62,6 +62,7 @@ const QString QPeaksTableModel::ROW("Row"); const QString QPeaksTableModel::COL("Col"); const QString QPeaksTableModel::QLAB = "QLab"; const QString QPeaksTableModel::QSAMPLE = "QSample"; +const QString QPeaksTableModel::PEAKNUM = "PeakNumber"; const int QPeaksTableModel::COL_RUNNUMBER(0); const int QPeaksTableModel::COL_DETID(1); @@ -83,6 +84,7 @@ const int QPeaksTableModel::COL_ROW(16); const int QPeaksTableModel::COL_COL(17); const int QPeaksTableModel::COL_QLAB(18); const int QPeaksTableModel::COL_QSAMPLE(19); +const int QPeaksTableModel::COL_PEAKNUM(20); /** * @param column The column to get the number of characters @@ -132,6 +134,8 @@ int QPeaksTableModel::numCharacters(const int column) const { return 3 * 6; else if (column == COL_QSAMPLE) return 3 * 6; + else if (column == COL_PEAKNUM) + return 6; else return 3; } @@ -162,7 +166,8 @@ QPeaksTableModel::QPeaksTableModel( {16, ROW}, {17, COL}, {18, QLAB}, - {19, QSAMPLE}}; + {19, QSAMPLE}, + {20, PEAKNUM}}; m_hklPrec = getHKLPrecision(); @@ -193,6 +198,7 @@ QPeaksTableModel::QPeaksTableModel( [](const IPeak &peak) { return QVariant(peak.getCol()); }, [](const IPeak &peak) { return QVariant(peak.getQLabFrame().norm()); }, [](const IPeak &peak) { return QVariant(peak.getQSampleFrame().norm()); }, + [](const IPeak &peak) { return QVariant(int(peak.getPeakNumber())); }, }; // Mapping member functions of the Peak object to a column index with @@ -244,6 +250,7 @@ QPeaksTableModel::QPeaksTableModel( [](const IPeak &peak) { return QString::number(peak.getCol()); }, [](const IPeak &peak) { return v3dAsString(peak.getQLabFrame()); }, [](const IPeak &peak) { return v3dAsString(peak.getQSampleFrame()); }, + [](const IPeak &peak) { return QString::number(peak.getPeakNumber()); }, }; } diff --git a/qt/widgets/sliceviewer/src/SliceViewer.cpp b/qt/widgets/sliceviewer/src/SliceViewer.cpp index 4f2763b5f0e7ff73046a984c00f69837efbf9d7b..7f8e690049add0c4618ec9a979408bb1ec92729f 100644 --- a/qt/widgets/sliceviewer/src/SliceViewer.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewer.cpp @@ -261,7 +261,7 @@ void SliceViewer::loadSettings() { // used. // If the user selected a unified color map for the SliceViewer and the VSI, // then this is loaded. - if (m_mdSettings != NULL && m_mdSettings->getUsageGeneralMdColorMap()) { + if (m_mdSettings != nullptr && m_mdSettings->getUsageGeneralMdColorMap()) { m_currentColorMapFile = m_mdSettings->getGeneralMdColorMapFile(); } else { m_currentColorMapFile = settings.value("ColormapFile", "").toString(); diff --git a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp index f0c25fcde89e9588b5353163189a428d5318da4f..0083113256ec4a3c782d5e0df63104897eaebc31 100644 --- a/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp +++ b/qt/widgets/sliceviewer/src/SliceViewerWindow.cpp @@ -32,7 +32,7 @@ namespace SliceViewer { */ SliceViewerWindow::SliceViewerWindow(const QString &wsName, const QString &label, Qt::WindowFlags f) - : QMainWindow(NULL, f), WorkspaceObserver(), m_lastLinerWidth(0), + : QMainWindow(nullptr, f), WorkspaceObserver(), m_lastLinerWidth(0), m_lastPeaksViewerWidth(0) { #ifdef Q_OS_MAC diff --git a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp index 2c7e702ac69cc4ba6a869a5e94e28f69f3781632..7d438bb60c7379c5be9f2efbb483f16e6785d171 100644 --- a/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp +++ b/qt/widgets/spectrumviewer/src/MatrixWSDataSource.cpp @@ -242,7 +242,7 @@ std::vector<std::string> MatrixWSDataSource::getInfoList(double x, double y) { std::string x_label = ""; Unit_sptr &old_unit = m_matWs->getAxis(0)->unit(); - if (old_unit != 0) { + if (old_unit) { x_label = old_unit->caption(); SVUtils::PushNameValue(x_label, 8, 3, x, list); } @@ -262,7 +262,7 @@ std::vector<std::string> MatrixWSDataSource::getInfoList(double x, double y) { try { - if (old_unit == 0) { + if (!old_unit) { g_log.debug("No UNITS on MatrixWorkspace X-axis"); return list; } diff --git a/scripts/ExternalInterfaces/CMakeLists.txt b/scripts/ExternalInterfaces/CMakeLists.txt index 49b608f4bbdba06b61faa3250c6cd41a005b395d..9f8cee956a296afe9b5841a474804783bd1e4e5c 100644 --- a/scripts/ExternalInterfaces/CMakeLists.txt +++ b/scripts/ExternalInterfaces/CMakeLists.txt @@ -6,7 +6,7 @@ set ( _mslice_external_root ${CMAKE_CURRENT_BINARY_DIR}/mslice ) ExternalProject_Add ( mslice PREFIX ${_mslice_external_root} GIT_REPOSITORY "https://github.com/mantidproject/mslice.git" - GIT_TAG 560cc9351596b0078b201b9e1785e3c5a745f375 + GIT_TAG 01292c88ccc508acb16735aa5f96450e076161bb EXCLUDE_FROM_ALL 1 CONFIGURE_COMMAND "" diff --git a/scripts/Inelastic/CrystalField/fitting.py b/scripts/Inelastic/CrystalField/fitting.py index f07526d4cfd5b9ca3a1a6fed0a54e474269757c4..91f1a34f1a7e4c6430f4f529acd32d4211021503 100644 --- a/scripts/Inelastic/CrystalField/fitting.py +++ b/scripts/Inelastic/CrystalField/fitting.py @@ -327,7 +327,10 @@ class CrystalField(object): return out def makeMultiSpectrumFunction(self): - return re.sub(r'FWHM[X|Y]\d+=\(\),', '', str(self.function)) + fun = re.sub(r'FWHM[X|Y]\d+=\(\),', '', str(self.function)) + fun = re.sub(r'(name=.*?,)(.*?)(Temperatures=\(.*?\),)',r'\1\3\2', fun) + fun = re.sub(r'(name=.*?,)(.*?)(PhysicalProperties=\(.*?\),)',r'\1\3\2', fun) + return fun @property def Ion(self): @@ -1319,8 +1322,6 @@ class CrystalFieldFit(object): """ from mantid.api import AlgorithmManager fun = self.model.makeMultiSpectrumFunction() - if 'CrystalFieldMultiSpectrum' in fun: - fun = re.sub(r'(name=.*?,)(.*?)(PhysicalProperties=\(.*?\),)',r'\1\3\2', fun) alg = AlgorithmManager.createUnmanaged('EstimateFitParameters') alg.initialize() alg.setProperty('Function', fun) @@ -1375,8 +1376,6 @@ class CrystalFieldFit(object): fun = str(self.model.function) else: fun = self.model.makeMultiSpectrumFunction() - if 'CrystalFieldMultiSpectrum' in fun: - fun = re.sub(r'(name=.*?,)(.*?)(PhysicalProperties=\(.*?\),)',r'\1\3\2', fun) alg = AlgorithmManager.createUnmanaged('Fit') alg.initialize() alg.setProperty('Function', fun) diff --git a/scripts/Inelastic/CrystalField/function.py b/scripts/Inelastic/CrystalField/function.py index c92547e806ad2d4cbd3b5a842cb8fe38368c2121..38813e9d020fb18d5b38a50496dcecb60f42e5f2 100644 --- a/scripts/Inelastic/CrystalField/function.py +++ b/scripts/Inelastic/CrystalField/function.py @@ -364,6 +364,10 @@ class ResolutionModel: self.model = [self._makeModel(m, xstart, xend, accuracy) for m in model] self.multi = True return + elif hasattr(model[0], 'model'): + self.model = [m.model for m in model] + self.multi = True + return elif isinstance(model[0], tuple): for m in model: self._checkModel(m) diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py index ea3a39182351d02acfae4c7ba38b63f875b4b143..38e32a99e771be116de5944369773ac4cbe31947 100644 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py +++ b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_script.py @@ -1,8 +1,6 @@ -#pylint: disable=R0902, W0221, W0621 """ - Classes for each reduction step. Those are kept separately - from the the interface class so that the HFIRReduction class could - be used independently of the interface implementation + Legacy class that old LR reduction options. + This is still in use for backward compatibility. """ from __future__ import (absolute_import, division, print_function) import xml.dom.minidom @@ -77,62 +75,13 @@ class DataSets(BaseScriptElement): super(DataSets, self).__init__() self.reset() +#pylint: disable = unused-argument, arguments-differ def to_script(self, for_automated_reduction=False): """ Generate reduction script @param execute: if true, the script will be executed """ - -# if for_automated_reduction: -# script = "RefLReduction(RunNumbers=[%s],\n" % ','.join([str(i) for i in self.data_files]) -# else: -# script = "RefLReduction(RunNumbers=[int(%s)],\n" % str(self.data_files[0]) - script = "RefLReduction(RunNumbers=[%s],\n" % ','.join([str(i) for i in self.data_files]) - script += " NormalizationRunNumber=%d,\n" % self.norm_file - script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels) - script += " SubtractSignalBackground=%s,\n" % str(self.DataBackgroundFlag) - script += " SignalBackgroundPixelRange=%s,\n" % str(self.DataBackgroundRoi[:2]) - script += " NormFlag=%s,\n" % str(self.NormFlag) - script += " NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels) - script += " NormBackgroundPixelRange=%s,\n" % str(self.NormBackgroundRoi) - script += " SubtractNormBackground=%s,\n" % str(self.NormBackgroundFlag) - script += " LowResDataAxisPixelRangeFlag=%s,\n" % str(self.data_x_range_flag) - script += " LowResDataAxisPixelRange=%s,\n" % str(self.data_x_range) - script += " LowResNormAxisPixelRangeFlag=%s,\n" % str(self.norm_x_range_flag) - script += " LowResNormAxisPixelRange=%s,\n" % str(self.norm_x_range) - script += " TOFRange=%s,\n" % str(self.DataTofRange) - - _incident_medium_str = str(self.incident_medium_list[0]) - _list = _incident_medium_str.split(',') - - script += " IncidentMediumSelected='%s',\n" % str(_list[self.incident_medium_index_selected]) - script += " GeometryCorrectionFlag=%s,\n" % str(self.geometry_correction_switch) - script += " QMin=%s,\n" % str(self.q_min) - script += " QStep=%s,\n" % str(self.q_step) - - # Angle offset - if self.angle_offset != 0.0: - script += " AngleOffset=%s,\n" % str(self.angle_offset) - script += " AngleOffsetError=%s,\n" % str(self.angle_offset_error) - - # sf configuration file -# if self.scaling_factor_file != '': - if self.scaling_factor_file_flag: - script += "ScalingFactorFile='%s',\n" % str(self.scaling_factor_file) - else: - script += "ScalingFactorFile='',\n" - - script += "SlitsWidthFlag=%s,\n" % str(self.slits_width_flag) - - # The output should be slightly different if we are generating - # a script for the automated reduction - if for_automated_reduction: - script += " OutputWorkspace='reflectivity_'+%s)" % str(self.data_files[0]) - else: - script += " OutputWorkspace='reflectivity_%s')" % str(self.data_files[0]) - script += "\n" - - return script + raise RuntimeError("refl_data_script.DataSets.to_script is deprecated") def update(self): """ @@ -144,75 +93,75 @@ class DataSets(BaseScriptElement): """ Create XML from the current data. """ - xml = "<RefLData>\n" - xml += "<peak_selection_type>%s</peak_selection_type>\n" % self.DataPeakSelectionType - xml += "<from_peak_pixels>%s</from_peak_pixels>\n" % str(self.DataPeakPixels[0]) - xml += "<to_peak_pixels>%s</to_peak_pixels>\n" % str(self.DataPeakPixels[1]) - xml += "<peak_discrete_selection>%s</peak_discrete_selection>\n" % self.DataPeakDiscreteSelection - xml += "<background_flag>%s</background_flag>\n" % str(self.DataBackgroundFlag) - xml += "<back_roi1_from>%s</back_roi1_from>\n" % str(self.DataBackgroundRoi[0]) - xml += "<back_roi1_to>%s</back_roi1_to>\n" % str(self.DataBackgroundRoi[1]) - xml += "<back_roi2_from>%s</back_roi2_from>\n" % str(self.DataBackgroundRoi[2]) - xml += "<back_roi2_to>%s</back_roi2_to>\n" % str(self.DataBackgroundRoi[3]) - xml += "<tof_range_flag>%s</tof_range_flag>\n" % str(self.TofRangeFlag) - xml += "<from_tof_range>%s</from_tof_range>\n" % str(self.DataTofRange[0]) - xml += "<to_tof_range>%s</to_tof_range>\n" % str(self.DataTofRange[1]) - xml += "<data_sets>%s</data_sets>\n" % ','.join([str(i) for i in self.data_files]) - xml += "<x_min_pixel>%s</x_min_pixel>\n" % str(self.data_x_range[0]) - xml += "<x_max_pixel>%s</x_max_pixel>\n" % str(self.data_x_range[1]) - xml += "<x_range_flag>%s</x_range_flag>\n" % str(self.data_x_range_flag) - - xml += "<tthd_value>%s</tthd_value>\n" % str(self.tthd_value) - xml += "<ths_value>%s</ths_value>\n" % str(self.ths_value) - - xml += "<norm_flag>%s</norm_flag>\n" % str(self.NormFlag) - xml += "<norm_x_range_flag>%s</norm_x_range_flag>\n" % str(self.norm_x_range_flag) - xml += "<norm_x_max>%s</norm_x_max>\n" % str(self.norm_x_range[1]) - xml += "<norm_x_min>%s</norm_x_min>\n" % str(self.norm_x_range[0]) - - xml += "<norm_from_peak_pixels>%s</norm_from_peak_pixels>\n" % str(self.NormPeakPixels[0]) - xml += "<norm_to_peak_pixels>%s</norm_to_peak_pixels>\n" % str(self.NormPeakPixels[1]) - xml += "<norm_background_flag>%s</norm_background_flag>\n" % str(self.NormBackgroundFlag) - xml += "<norm_from_back_pixels>%s</norm_from_back_pixels>\n" % str(self.NormBackgroundRoi[0]) - xml += "<norm_to_back_pixels>%s</norm_to_back_pixels>\n" % str(self.NormBackgroundRoi[1]) - xml += "<norm_dataset>%s</norm_dataset>\n" % str(self.norm_file) + _xml = "<RefLData>\n" + _xml += "<peak_selection_type>%s</peak_selection_type>\n" % self.DataPeakSelectionType + _xml += "<from_peak_pixels>%s</from_peak_pixels>\n" % str(self.DataPeakPixels[0]) + _xml += "<to_peak_pixels>%s</to_peak_pixels>\n" % str(self.DataPeakPixels[1]) + _xml += "<peak_discrete_selection>%s</peak_discrete_selection>\n" % self.DataPeakDiscreteSelection + _xml += "<background_flag>%s</background_flag>\n" % str(self.DataBackgroundFlag) + _xml += "<back_roi1_from>%s</back_roi1_from>\n" % str(self.DataBackgroundRoi[0]) + _xml += "<back_roi1_to>%s</back_roi1_to>\n" % str(self.DataBackgroundRoi[1]) + _xml += "<back_roi2_from>%s</back_roi2_from>\n" % str(self.DataBackgroundRoi[2]) + _xml += "<back_roi2_to>%s</back_roi2_to>\n" % str(self.DataBackgroundRoi[3]) + _xml += "<tof_range_flag>%s</tof_range_flag>\n" % str(self.TofRangeFlag) + _xml += "<from_tof_range>%s</from_tof_range>\n" % str(self.DataTofRange[0]) + _xml += "<to_tof_range>%s</to_tof_range>\n" % str(self.DataTofRange[1]) + _xml += "<data_sets>%s</data_sets>\n" % ','.join([str(i) for i in self.data_files]) + _xml += "<x_min_pixel>%s</x_min_pixel>\n" % str(self.data_x_range[0]) + _xml += "<x_max_pixel>%s</x_max_pixel>\n" % str(self.data_x_range[1]) + _xml += "<x_range_flag>%s</x_range_flag>\n" % str(self.data_x_range_flag) + + _xml += "<tthd_value>%s</tthd_value>\n" % str(self.tthd_value) + _xml += "<ths_value>%s</ths_value>\n" % str(self.ths_value) + + _xml += "<norm_flag>%s</norm_flag>\n" % str(self.NormFlag) + _xml += "<norm_x_range_flag>%s</norm_x_range_flag>\n" % str(self.norm_x_range_flag) + _xml += "<norm_x_max>%s</norm_x_max>\n" % str(self.norm_x_range[1]) + _xml += "<norm_x_min>%s</norm_x_min>\n" % str(self.norm_x_range[0]) + + _xml += "<norm_from_peak_pixels>%s</norm_from_peak_pixels>\n" % str(self.NormPeakPixels[0]) + _xml += "<norm_to_peak_pixels>%s</norm_to_peak_pixels>\n" % str(self.NormPeakPixels[1]) + _xml += "<norm_background_flag>%s</norm_background_flag>\n" % str(self.NormBackgroundFlag) + _xml += "<norm_from_back_pixels>%s</norm_from_back_pixels>\n" % str(self.NormBackgroundRoi[0]) + _xml += "<norm_to_back_pixels>%s</norm_to_back_pixels>\n" % str(self.NormBackgroundRoi[1]) + _xml += "<norm_dataset>%s</norm_dataset>\n" % str(self.norm_file) # Q cut - xml += "<q_min>%s</q_min>\n" % str(self.q_min) - xml += "<q_step>%s</q_step>\n" % str(self.q_step) - xml += "<auto_q_binning>%s</auto_q_binning>\n" % str(self.auto_q_binning) - xml += "<overlap_lowest_error>%s</overlap_lowest_error>\n" % str(self.overlap_lowest_error) - xml += "<overlap_mean_value>%s</overlap_mean_value>\n" % str(self.overlap_mean_value) + _xml += "<q_min>%s</q_min>\n" % str(self.q_min) + _xml += "<q_step>%s</q_step>\n" % str(self.q_step) + _xml += "<auto_q_binning>%s</auto_q_binning>\n" % str(self.auto_q_binning) + _xml += "<overlap_lowest_error>%s</overlap_lowest_error>\n" % str(self.overlap_lowest_error) + _xml += "<overlap_mean_value>%s</overlap_mean_value>\n" % str(self.overlap_mean_value) # Angle offset - xml += "<angle_offset>%s</angle_offset>\n" % str(self.angle_offset) - xml += "<angle_offset_error>%s</angle_offset_error>\n" % str(self.angle_offset_error) + _xml += "<angle_offset>%s</angle_offset>\n" % str(self.angle_offset) + _xml += "<angle_offset_error>%s</angle_offset_error>\n" % str(self.angle_offset_error) # scaling factor file name - xml += "<scaling_factor_flag>%s</scaling_factor_flag>\n" % str(self.scaling_factor_file_flag) - xml += "<scaling_factor_file>%s</scaling_factor_file>\n" % str(self.scaling_factor_file) - xml += "<slits_width_flag>%s</slits_width_flag>\n" % str(self.slits_width_flag) + _xml += "<scaling_factor_flag>%s</scaling_factor_flag>\n" % str(self.scaling_factor_file_flag) + _xml += "<scaling_factor_file>%s</scaling_factor_file>\n" % str(self.scaling_factor_file) + _xml += "<slits_width_flag>%s</slits_width_flag>\n" % str(self.slits_width_flag) # geometry correction - xml += "<geometry_correction_switch>%s</geometry_correction_switch>\n" % str(self.geometry_correction_switch) + _xml += "<geometry_correction_switch>%s</geometry_correction_switch>\n" % str(self.geometry_correction_switch) #incident medium - xml += "<incident_medium_list>%s</incident_medium_list>\n" % str(self.incident_medium_list[0]) - xml += "<incident_medium_index_selected>%s</incident_medium_index_selected>\n" % str(self.incident_medium_index_selected) + _xml += "<incident_medium_list>%s</incident_medium_list>\n" % str(self.incident_medium_list[0]) + _xml += "<incident_medium_index_selected>%s</incident_medium_index_selected>\n" % str(self.incident_medium_index_selected) #fourth column precision - xml += "<fourth_column_flag>%s</fourth_column_flag>\n" % str(self.fourth_column_flag) - xml += "<fourth_column_dq0>%s</fourth_column_dq0>\n" % str(self.fourth_column_dq0) - xml += "<fourth_column_dq_over_q>%s</fourth_column_dq_over_q>\n" % str(self.fourth_column_dq_over_q) + _xml += "<fourth_column_flag>%s</fourth_column_flag>\n" % str(self.fourth_column_flag) + _xml += "<fourth_column_dq0>%s</fourth_column_dq0>\n" % str(self.fourth_column_dq0) + _xml += "<fourth_column_dq_over_q>%s</fourth_column_dq_over_q>\n" % str(self.fourth_column_dq_over_q) # Primary fraction if self.clocking_from is not None and self.clocking_to is not None: - xml += "<clocking_from>%s</clocking_from>\n" % str(self.clocking_from) - xml += "<clocking_to>%s</clocking_to>\n" % str(self.clocking_to) + _xml += "<clocking_from>%s</clocking_from>\n" % str(self.clocking_from) + _xml += "<clocking_to>%s</clocking_to>\n" % str(self.clocking_to) - xml += "</RefLData>\n" + _xml += "</RefLData>\n" - return xml + return _xml def from_xml(self, xml_str): self.reset() diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py index 7061a8ec7e6b1a084646f95ecd7ca754551a865d..224d72ce088fd5d154121348302f47092661db78 100644 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py +++ b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_data_series.py @@ -7,7 +7,6 @@ from __future__ import (absolute_import, division, print_function) import xml.dom.minidom from reduction_gui.reduction.scripter import BaseScriptElement from reduction_gui.reduction.reflectometer.refl_data_script import DataSets as REFLDataSets -from reduction_gui.reduction.reflectometer.refm_data_script import DataSets as REFMDataSets class DataSeries(BaseScriptElement): @@ -24,18 +23,7 @@ class DataSeries(BaseScriptElement): Generate reduction script @param execute: if true, the script will be executed """ - script = "import os\n" - script += "import time\n" - script += "t0=time.time()\n" - script += "from reduction.command_interface import ReductionSingleton\n" - script += "ReductionSingleton.clean()\n" - - for item in self.data_sets: - script += item.to_script() - script += "\n" - script += "print \"Reduction time: %g\\n\" % (time.time()-t0)\n" - - return script + raise RuntimeError("refl_data_series.DataSeries.to_script is deprecated") def update(self): """ @@ -47,12 +35,12 @@ class DataSeries(BaseScriptElement): """ Create XML from the current data. """ - xml = "<DataSeries>\n" + _xml = "<DataSeries>\n" for item in self.data_sets: - xml += item.to_xml() - xml += "</DataSeries>\n" + _xml += item.to_xml() + _xml += "</DataSeries>\n" - return xml + return _xml def from_xml(self, xml_str): """ @@ -70,9 +58,6 @@ class DataSeries(BaseScriptElement): element_list = dom.getElementsByTagName("Data") if len(element_list)==0: element_list = dom.getElementsByTagName("RefLData") - if len(element_list)==0: - self._data_class = REFMDataSets - element_list = dom.getElementsByTagName("RefMData") if len(element_list)>0: for item in element_list: diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py deleted file mode 100644 index 83201441fcc3ac43e31d34103fec0b7a6b4b2f6e..0000000000000000000000000000000000000000 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_reduction.py +++ /dev/null @@ -1,51 +0,0 @@ -#pylint: disable = invalid-name -""" - This class holds all the necessary information to create a reduction script. -""" -from __future__ import (absolute_import, division, print_function) -import time -from reduction_gui.reduction.scripter import BaseReductionScripter - - -class REFLReductionScripter(BaseReductionScripter): - """ - Reduction scripter for REFL - """ - - def __init__(self, name="REFL"): - super(REFLReductionScripter, self).__init__(name=name) - - def to_script(self, file_name=None): - """ - Spits out the text of a reduction script with the current state. - @param file_name: name of the file to write the script to - """ - """ - Spits out the text of a reduction script with the current state. - @param file_name: name of the file to write the script to - """ - script = "# %s reduction script\n" % self.instrument_name - script += "# Script automatically generated on %s\n\n" % time.ctime(time.time()) - - script += "import mantid\n" - script += "from mantid.simpleapi import *\n" - script += "\n" - script += "#remove all previous workspaces\n" - script += "list_mt = AnalysisDataService.getObjectNames()\n" - script += "for _mt in list_mt:\n" - script += " if _mt.find('_scaled') != -1:\n" - script += " AnalysisDataService.remove(_mt)\n" - script += " if _mt.find('reflectivity') != -1:\n" - script += " AnalysisDataService.remove(_mt)\n" - script += "\n" - - for item in self._observers: - if item.state() is not None: - script += str(item.state()) - - if file_name is not None: - f = open(file_name, 'w') - f.write(script) - f.close() - - return script diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator.py deleted file mode 100644 index e7edad83b8f2e462351c94fd9caa3f715ac7ba35..0000000000000000000000000000000000000000 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator.py +++ /dev/null @@ -1,179 +0,0 @@ -from __future__ import (absolute_import, division, print_function) - -# pylint: disable=invalid-name -""" - This class holds all the necessary information to create a reduction script. - This is a fake version of the Reducer for testing purposes. -""" -import time -from reduction_gui.reduction.scripter import BaseReductionScripter -import sys - -# Check whether Mantid is available -try: - import mantidplot # noqa - - HAS_MANTID = True -except: - HAS_MANTID = False - - -class REFLSFCalculatorScripter(BaseReductionScripter): - """ - Organizes the set of reduction parameters that will be used to - create a reduction script. Parameters are organized by groups that - will each have their own UI representation. - """ - - def __init__(self, name="REFL"): - super(REFLSFCalculatorScripter, self).__init__(name=name) - - def create_script(self, script_part2): - """ - This creates the special script for the sfCalculator algorithm - """ - algo = 'sfCalculator.calculate' - - script_split = script_part2.split('\n') - - run_number = [] - attenuator = [] - - peak_from = [] - peak_to = [] - back_from = [] - back_to = [] - - tof_range = [0.0, 200000.0] - incident_medium = '' - incident_medium_index = -1 - - scaling_factor_file = '' - - for _line in script_split: - if _line != '': - _line_split = _line.split(':') - _arg = _line_split[0] - _val = _line_split[1] - - if _arg == 'Scaling factor file' and scaling_factor_file == '': - scaling_factor_file = _val.strip() - - elif _arg == 'Run number': - run_number.append(_val) - - elif _arg == 'TOF from' and tof_range[0] == 0.0: - tof_range[0] = float(_val) - - elif _arg == 'TOF to' and tof_range[1] == 200000.0: - tof_range[1] = float(_val) - - elif _arg == 'Incident medium' and incident_medium.strip() == '': - incident_medium = _val[4:-3] - - elif _arg == 'Incident medium index' and incident_medium_index == -1: - incident_medium_index = int(_val) - - elif _arg == 'Number of attenuator': - attenuator.append(_val) - - elif _arg == 'Peak from pixel': - peak_from.append(_val) - - elif _arg == 'Peak to pixel': - peak_to.append(_val) - - elif _arg == 'Back from pixel': - back_from.append(_val) - - elif _arg == 'Back to pixel': - back_to.append(_val) - - run_attenuator = [run.strip() + ":" + att.strip() for (run, att) in zip(run_number, attenuator)] - join_string = ',' - script_run_attenuator = join_string.join(run_attenuator) - - list_peak_back = [[int(pixel) for pixel in line] for line in zip(peak_from, peak_to, back_from, back_to)] - - new_script = algo + '(string_runs="' + script_run_attenuator + '"' - new_script += ',list_peak_back=' + str(list_peak_back) - - # retrieve right incident medium - - incident_medium_list = incident_medium.split(',') - incident_medium = incident_medium_list[incident_medium_index] - new_script += ',incident_medium="' + incident_medium.strip() + '"' - - new_script += ',output_file_name="' + scaling_factor_file + '"' - - new_script += ',tof_range=' + str(tof_range) + ')' - - if scaling_factor_file == '': - return '' - - return new_script - - def to_script(self, file_name=None): - """ - Spits out the text of a reduction script with the current state. - @param file_name: name of the file to write the script to - """ - script = "# %s scaling factor calculation script\n" % self.instrument_name - script += "# Script automatically generated on %s\n\n" % time.ctime(time.time()) - - script += "import os\n" - script += "import mantid\n" - script += "from mantid.simpleapi import *\n" - script += "import sfCalculator\n" - - script += "REF_RED_OUTPUT_MESSAGE = ''\n\n" - - script_part2 = '' - for item in self._observers: - if item.state() is not None: - script_part2 += str(item.state()) - - _script = self.create_script(script_part2) - if _script == '': - print('Please define a Scaling Factor File Name') - raise RuntimeError - - script += _script - - if file_name is not None: - f = open(file_name, 'w') - f.write(script) - f.close() - - return script - - def apply(self): - """ - Apply the reduction process - """ - if HAS_MANTID: - script = self.to_script(None) - - print(script) - - try: - t0 = time.time() - exec (script) - delta_t = time.time() - t0 - print("SF calculation time: %5.2g sec" % delta_t) - # Update scripter - for item in self._observers: - if item.state() is not None: - item.state().update() - except: - # Update scripter [Duplicated code because we can't use 'finally' on python 2.4] - for item in self._observers: - if item.state() is not None: - # Things might be broken, so update what we can - try: - item.state().update() - except: - pass - raise RuntimeError(sys.exc_info()[1]) - else: - raise RuntimeError("SF calculation could not be executed: Mantid could not be imported") diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_script.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_script.py deleted file mode 100644 index 5f617c4811143e36541f9404eb68e4922687d1fb..0000000000000000000000000000000000000000 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_script.py +++ /dev/null @@ -1,150 +0,0 @@ -""" - Classes for each reduction step. Those are kept separately - from the the interface class so that the HFIRReduction class could - be used independently of the interface implementation -""" -from __future__ import (absolute_import, division, print_function) -import xml.dom.minidom -from reduction_gui.reduction.scripter import BaseScriptElement - - -class DataSets(BaseScriptElement): - - data_file = 0 - incident_medium_list = ['H2O'] - incident_medium_index_selected = 0 - number_attenuator = 0 - peak_selection = [0, 0] - back_selection = [0, 0] - lambda_requested = 'N/A' - s1h = 'N/A' - s2h = 'N/A' - s1w = 'N/A' - s2w = 'N/A' - scaling_factor_file = '' - tof_min = 0. - tof_max = 200000. - - def __init__(self): - super(DataSets, self).__init__() - self.reset() - - def to_script(self): - """ - Generate reduction script - @param execute: if true, the script will be executed - """ - script = 'Run number: %s \n' % str(self.data_file) - -# _u_list = self.incident_medium_list -# _list = str(_u_list[0]).split(',') - - script += 'Incident medium: %s \n' % str(self.incident_medium_list) -# script += 'Incident medium: %s \n' % str(self.incident_medium_list[self.incident_medium_index_selected]) -# script += 'Incident medium: %s \n' % str(_list[self.incident_medium_index_selected]) - script += 'Incident medium index: %s \n' % str(self.incident_medium_index_selected) - script += 'TOF from: %s \n' % str(self.tof_min) - script += 'TOF to: %s \n' % str(self.tof_max) - script += 'Scaling factor file: %s \n' % str(self.scaling_factor_file) - script += 'Number of attenuator: %s \n' % str(self.number_attenuator) - script += 'Peak from pixel: %s \n' % str(self.peak_selection[0]) - script += 'Peak to pixel: %s \n' % str(self.peak_selection[1]) - script += 'Back from pixel: %s \n' % str(self.back_selection[0]) - script += 'Back to pixel: %s \n' % str(self.back_selection[1]) - - return script - - def update(self): - """ - Update transmission from reduction output - """ - pass - - def to_xml(self): - """ - Create XML from the current data. - """ - xml = "<RefLSFCalculator>\n" -# xml += "<incident_medium_list>%s</incident_medium_list>\n" % ','.join([str(i) for i in self.incident_medium_list]) - xml += "<incident_medium_list>%s</incident_medium_list>\n" % str(self.incident_medium_list[0]) - xml += "<tof_min>%s</tof_min>\n" % str(self.tof_min) - xml += "<tof_max>%s</tof_max>\n" % str(self.tof_max) - xml += "<incident_medium_index_selected>%s</incident_medium_index_selected>\n" % str(self.incident_medium_index_selected) - xml += "<data_file>%s</data_file>\n" % str(self.data_file) - xml += "<number_attenuator>%s</number_attenuator>\n" % str(self.number_attenuator) - xml += "<peak_selection_from_pixel>%s</peak_selection_from_pixel>\n" % str(self.peak_selection[0]) - xml += "<peak_selection_to_pixel>%s</peak_selection_to_pixel>\n" % str(self.peak_selection[1]) - xml += "<back_selection_from_pixel>%s</back_selection_from_pixel>\n" % str(self.back_selection[0]) - xml += "<back_selection_to_pixel>%s</back_selection_to_pixel>\n" % str(self.back_selection[1]) - xml += "<lambda_requested>%s</lambda_requested>\n" % str(self.lambda_requested) - xml += "<s1h>%s</s1h>\n" % str(self.s1h) - xml += "<s2h>%s</s2h>\n" % str(self.s2h) - xml += "<s1w>%s</s1w>\n" % str(self.s1w) - xml += "<s2w>%s</s2w>\n" % str(self.s2w) - xml += "<scaling_factor_file>%s</scaling_factor_file>\n" % str(self.scaling_factor_file) - xml += "</RefLSFCalculator>\n" - - return xml - - def from_xml(self, xml_str): - self.reset() - dom = xml.dom.minidom.parseString(xml_str) - self.from_xml_element(dom) - dom.getElementsByTagName("RefLSFCalculator") - - def from_xml_element(self, instrument_dom): - """ - Read in data from XML - @param xml_str: text to read the data from - """ - # incident medium - self.incident_medium_list = BaseScriptElement.getStringList(instrument_dom, "incident_medium_list") - self.incident_medium_index_selected = BaseScriptElement.getIntElement(instrument_dom, "incident_medium_index_selected") - - self.tof_min = BaseScriptElement.getFloatElement(instrument_dom, "tof_min") - self.tof_max = BaseScriptElement.getFloatElement(instrument_dom, "tof_max") - - # run number - self.data_file = BaseScriptElement.getIntElement(instrument_dom, "data_file") - - # number of attenuator - self.number_attenuator = BaseScriptElement.getIntElement(instrument_dom, "number_attenuator") - - # peak selection from and to - self.peak_selection = [BaseScriptElement.getIntElement(instrument_dom, "peak_selection_from_pixel"), - BaseScriptElement.getIntElement(instrument_dom, "peak_selection_to_pixel")] - - # background flag and selection from and to - self.back_selection = [BaseScriptElement.getIntElement(instrument_dom, "back_selection_from_pixel"), - BaseScriptElement.getIntElement(instrument_dom, "back_selection_to_pixel")] - - # lambda requested - self.lambda_requested = BaseScriptElement.getStringElement(instrument_dom, "lambda_requested") - - # s1h, s2h, s1w, s2w - self.s1h = BaseScriptElement.getStringElement(instrument_dom, "s1h") - self.s2h = BaseScriptElement.getStringElement(instrument_dom, "s2h") - self.s1w = BaseScriptElement.getStringElement(instrument_dom, "s1w") - self.s2w = BaseScriptElement.getStringElement(instrument_dom, "s2w") - - # scaling factor file - self.scaling_factor_file = BaseScriptElement.getStringElement(instrument_dom, "scaling_factor_file") - - def reset(self): - """ - Reset state - """ - self.data_file = DataSets.data_file - self.incident_medium_list = DataSets.incident_medium_list - self.incident_medium_index_selected = DataSets.incident_medium_index_selected - self.number_attenuator = DataSets.number_attenuator - self.peak_selection = DataSets.peak_selection - self.back_selection = DataSets.back_selection - self.lambda_requested = DataSets.lambda_requested - self.s1h = DataSets.s1h - self.s2h = DataSets.s2h - self.s1w = DataSets.s1w - self.s2w = DataSets.s2w - self.tof_min = DataSets.tof_min - self.tof_max = DataSets.tof_max - self.scaling_factor_file = DataSets.scaling_factor_file diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_series.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_series.py deleted file mode 100644 index 170889b7b4e4b25135ade0a8c6c6f76053e0dab9..0000000000000000000000000000000000000000 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refl_sf_calculator_data_series.py +++ /dev/null @@ -1,82 +0,0 @@ -""" - Classes for each reduction step. Those are kept separately - from the the interface class so that the HFIRReduction class could - be used independently of the interface implementation -""" -from __future__ import (absolute_import, division, print_function) -import xml.dom.minidom -from reduction_gui.reduction.scripter import BaseScriptElement -from reduction_gui.reduction.reflectometer.refl_sf_calculator_data_script import DataSets as REFLDataSets - - -class DataSeries(BaseScriptElement): - - data_sets = [] - - def __init__(self, data_class=REFLDataSets): - super(DataSeries, self).__init__() - self._data_class = data_class - self.reset() - - def to_script(self): - """ - Generate reduction script - @param execute: if true, the script will be executed - """ - script = "" - for item in self.data_sets: - script += item.to_script() - script += "\n" - - return script - - def update(self): - """ - Update transmission from reduction output - """ - pass - - def to_xml(self): - """ - Create XML from the current data. - """ - - xml = "<DataSeries>\n" - for item in self.data_sets: - xml += item.to_xml() - xml += "</DataSeries>\n" - - return xml - - def from_xml(self, xml_str): - """ - Read in data from XML - @param xml_str: text to read the data from - """ - self.reset() - self.data_sets = [] - dom = xml.dom.minidom.parseString(xml_str) - -# # Get Mantid version -# mtd_version = BaseScriptElement.getMantidBuildVersion(dom) - - self._data_class = REFLDataSets - element_list = dom.getElementsByTagName("Data") - if len(element_list)==0: - element_list = dom.getElementsByTagName("RefLSFCalculator") - - if len(element_list)>0: - for item in element_list: - if item is not None: - data_set = self._data_class() - data_set.from_xml_element(item) - self.data_sets.append(data_set) - - if len(self.data_sets)==0: - self.data_sets = [self._data_class()] - - def reset(self): - """ - Reset state - """ - self.data_sets = [self._data_class()] diff --git a/scripts/Interface/reduction_gui/reduction/reflectometer/refm_data_script.py b/scripts/Interface/reduction_gui/reduction/reflectometer/refm_data_script.py deleted file mode 100644 index 4918bb4002216c473e3d168c7f66aa0a96f0796c..0000000000000000000000000000000000000000 --- a/scripts/Interface/reduction_gui/reduction/reflectometer/refm_data_script.py +++ /dev/null @@ -1,381 +0,0 @@ -""" - Reduction script for REFM -""" -from __future__ import (absolute_import, division, print_function) -import xml.dom.minidom -import os -from reduction_gui.reduction.scripter import BaseScriptElement - - -class DataSets(BaseScriptElement): - - DataPeakPixels = [215, 225] - DataBackgroundFlag = False - DataBackgroundRoi = [115, 137, 123, 137] - DataTofRange = [10700., 24500.] - crop_TOF_range = True - TOFstep = 400.0 - - data_x_range_flag = False - data_x_range = [115, 210] - - norm_x_range_flag = False - norm_x_range = [90, 160] - - NormFlag = True - NormPeakPixels = [120, 130] - NormBackgroundFlag = False - NormBackgroundRoi = [115, 137] - - # Data files - data_files = [0] - norm_file = 0 - - # Q range - q_min = 0.0025 - q_step = -0.01 - q_bins = 40 - q_log = True - - # scattering angle - theta = 0.0 - use_center_pixel = True - - # Sample log overwrites - set_detector_angle = False - detector_angle = 0.0 - set_detector_angle_offset = False - detector_angle_offset = 0.0 - set_direct_pixel = False - direct_pixel = 0.0 - - output_dir = '' - - def __init__(self): - super(DataSets, self).__init__() - self.reset() - - def to_script(self, for_automated_reduction=False): - """ - Generate reduction script - @param execute: if true, the script will be executed - """ - if for_automated_reduction: - return self._automated_reduction() - - script = "import mantid\n" - script += "from mantid.api import *\n" - script += "from mantid.kernel import *\n" - script += "from mantid.simpleapi import *\n" - - script = "a = RefReduction(DataRun='%s',\n" % ','.join([str(i) for i in self.data_files]) - script += " NormalizationRun='%s',\n" % str(self.norm_file) - script += " Instrument='REF_M',\n" - script += " PolarizedData=True,\n" - - script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels) - script += " SubtractSignalBackground=%s,\n" % str(self.DataBackgroundFlag) - script += " SignalBackgroundPixelRange=%s,\n" % str(self.DataBackgroundRoi[:2]) - script += " PerformNormalization=%s,\n" % str(self.NormFlag) - script += " NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels) - script += " NormBackgroundPixelRange=%s,\n" % str(self.NormBackgroundRoi) - script += " SubtractNormBackground=%s,\n" % str(self.NormBackgroundFlag) - - script += " CropLowResDataAxis=%s,\n" % str(self.data_x_range_flag) - if self.data_x_range_flag: - script += " LowResDataAxisPixelRange=%s,\n" % str(self.data_x_range) - - script += " CropLowResNormAxis=%s,\n" % str(self.norm_x_range_flag) - if self.norm_x_range_flag: - script += " LowResNormAxisPixelRange=%s,\n" % str(self.norm_x_range) - - if self.crop_TOF_range: - script += " TOFMin=%s,\n" % str(self.DataTofRange[0]) - script += " TOFMax=%s,\n" % str(self.DataTofRange[1]) - script += " TOFStep=%s,\n" % str(self.TOFstep) - else: - script += " NBins=%s,\n" % str(self.q_bins) - - # Scattering angle options - if self.use_center_pixel: - if self.set_detector_angle: - script += " DetectorAngle=%s,\n" % str(self.detector_angle) - if self.set_detector_angle_offset: - script += " DetectorAngle0=%s,\n" % str(self.detector_angle_offset) - if self.set_direct_pixel: - script += " DirectPixel=%s,\n" % str(self.direct_pixel) - - else: - script += " Theta=%s,\n" % str(self.theta) - - # The output should be slightly different if we are generating - # a script for the automated reduction - basename = os.path.basename(str(self.data_files[0])) - script += " OutputWorkspacePrefix='reflectivity_%s')\n" % basename - script += "\n" - - # Store the log output so it can be shown in the UI - script += "from reduction_workflow.command_interface import ReductionSingleton\n" - script += "reducer_log = ReductionSingleton()\n" - script += "output_log = 'Please make sure the new-style Python API is turned ON by default\\n'\n" - script += "output_log += 'In MantiPlot, go in View > Preferences > Mantid > Options '\n" - script += "output_log += 'and check the appropriate box at the bottom.'\n" - script += "for item in a:\n" - script += " if type(item)==str: output_log = item\n" - script += "reducer_log.log_text += output_log\n\n" - - # Save the reduced data - script += "ws_list = ['reflectivity_%s-Off_Off',\n" % basename - script += " 'reflectivity_%s-On_Off',\n" % basename - script += " 'reflectivity_%s-Off_On',\n" % basename - script += " 'reflectivity_%s-On_On']\n" % basename - - script += "outdir = '%s'\n" % self.output_dir - script += "if not os.path.isdir(outdir):\n" - script += " outdir = os.path.expanduser('~')\n\n" - - script += "for ws in ws_list:\n" - script += " if AnalysisDataService.doesExist(ws):\n" - script += " outpath = os.path.join(outdir, ws+'.txt')\n" - script += " SaveAscii(Filename=outpath, InputWorkspace=ws, Separator='Space')\n\n" - - return script - - def _automated_reduction(self): - script = "# REF_M automated reduction\n" - script += "RefReduction(DataRun='%s',\n" % ','.join([str(i) for i in self.data_files]) - script += " NormalizationRun='%s',\n" % str(self.norm_file) - script += " Instrument='REF_M',\n" - script += " PolarizedData=True,\n" - script += " SignalPeakPixelRange=%s,\n" % str(self.DataPeakPixels) - script += " SubtractSignalBackground=False,\n" - script += " PerformNormalization=%s,\n" % str(self.NormFlag) - script += " NormPeakPixelRange=%s,\n" % str(self.NormPeakPixels) - script += " SubtractNormBackground=False,\n" - - script += " CropLowResDataAxis=%s,\n" % str(self.data_x_range_flag) - if self.data_x_range_flag: - script += " LowResDataAxisPixelRange=%s,\n" % str(self.data_x_range) - - script += " CropLowResNormAxis=%s,\n" % str(self.norm_x_range_flag) - if self.norm_x_range_flag: - script += " LowResNormAxisPixelRange=%s,\n" % str(self.norm_x_range) - - # The output should be slightly different if we are generating - # a script for the automated reduction - basename = os.path.basename(str(self.data_files[0])) - script += " OutputWorkspacePrefix='reflectivity_'+%s)\n" % basename - - return script - - def update(self): - """ - Update transmission from reduction output - """ - pass - - def to_xml(self): - """ - Create XML from the current data. - """ - xml = "<RefMData>\n" - xml += "<from_peak_pixels>%s</from_peak_pixels>\n" % str(self.DataPeakPixels[0]) - xml += "<to_peak_pixels>%s</to_peak_pixels>\n" % str(self.DataPeakPixels[1]) - xml += "<background_flag>%s</background_flag>\n" % str(self.DataBackgroundFlag) - xml += "<back_roi1_from>%s</back_roi1_from>\n" % str(self.DataBackgroundRoi[0]) - xml += "<back_roi1_to>%s</back_roi1_to>\n" % str(self.DataBackgroundRoi[1]) - xml += "<back_roi2_from>%s</back_roi2_from>\n" % str(self.DataBackgroundRoi[2]) - xml += "<back_roi2_to>%s</back_roi2_to>\n" % str(self.DataBackgroundRoi[3]) - xml += "<crop_tof>%s</crop_tof>\n" % str(self.crop_TOF_range) - xml += "<from_tof_range>%s</from_tof_range>\n" % str(self.DataTofRange[0]) - xml += "<to_tof_range>%s</to_tof_range>\n" % str(self.DataTofRange[1]) - xml += "<tof_step>%s</tof_step>\n" % str(self.TOFstep) - xml += "<data_sets>%s</data_sets>\n" % ','.join([str(i) for i in self.data_files]) - xml += "<x_min_pixel>%s</x_min_pixel>\n" % str(self.data_x_range[0]) - xml += "<x_max_pixel>%s</x_max_pixel>\n" % str(self.data_x_range[1]) - xml += "<x_range_flag>%s</x_range_flag>\n" % str(self.data_x_range_flag) - - xml += "<norm_flag>%s</norm_flag>\n" % str(self.NormFlag) - xml += "<norm_x_range_flag>%s</norm_x_range_flag>\n" % str(self.norm_x_range_flag) - xml += "<norm_x_max>%s</norm_x_max>\n" % str(self.norm_x_range[1]) - xml += "<norm_x_min>%s</norm_x_min>\n" % str(self.norm_x_range[0]) - - xml += "<norm_from_peak_pixels>%s</norm_from_peak_pixels>\n" % str(self.NormPeakPixels[0]) - xml += "<norm_to_peak_pixels>%s</norm_to_peak_pixels>\n" % str(self.NormPeakPixels[1]) - xml += "<norm_background_flag>%s</norm_background_flag>\n" % str(self.NormBackgroundFlag) - xml += "<norm_from_back_pixels>%s</norm_from_back_pixels>\n" % str(self.NormBackgroundRoi[0]) - xml += "<norm_to_back_pixels>%s</norm_to_back_pixels>\n" % str(self.NormBackgroundRoi[1]) - xml += "<norm_dataset>%s</norm_dataset>\n" % str(self.norm_file) - - # Q cut - xml += "<q_min>%s</q_min>\n" % str(self.q_min) - xml += "<q_step>%s</q_step>\n" % str(self.q_step) - xml += "<q_bins>%s</q_bins>\n" % str(self.q_bins) - xml += "<q_log>%s</q_log>\n" % str(self.q_log) - - # Scattering angle - xml += "<theta>%s</theta>\n" % str(self.theta) - xml += "<use_center_pixel>%s</use_center_pixel>\n" % str(self.use_center_pixel) - - # Sample log overwrites - xml += "<set_detector_angle>%s</set_detector_angle>\n" % str(self.set_detector_angle) - xml += "<detector_angle>%s</detector_angle>\n" % str(self.detector_angle) - xml += "<set_detector_angle_offset>%s</set_detector_angle_offset>\n" % str(self.set_detector_angle_offset) - xml += "<detector_angle_offset>%s</detector_angle_offset>\n" % str(self.detector_angle_offset) - xml += "<set_direct_pixel>%s</set_direct_pixel>\n" % str(self.set_direct_pixel) - xml += "<direct_pixel>%s</direct_pixel>\n" % str(self.direct_pixel) - - xml += "<output_dir>%s</output_dir>\n" % str(self.output_dir) - - xml += "</RefMData>\n" - - return xml - - def from_xml(self, xml_str): - self.reset() - dom = xml.dom.minidom.parseString(xml_str) - self.from_xml_element(dom) - dom.getElementsByTagName("RefMData") - - def from_xml_element(self, instrument_dom): - """ - Read in data from XML - @param xml_str: text to read the data from - """ - # Peak from/to pixels - self.DataPeakPixels = [BaseScriptElement.getIntElement(instrument_dom, "from_peak_pixels"), - BaseScriptElement.getIntElement(instrument_dom, "to_peak_pixels")] - - # low resolution range - self.data_x_range_flag = BaseScriptElement.getBoolElement(instrument_dom, "x_range_flag", - default=DataSets.data_x_range_flag) - - self.data_x_range = [BaseScriptElement.getIntElement(instrument_dom, "x_min_pixel"), - BaseScriptElement.getIntElement(instrument_dom, "x_max_pixel")] - - self.norm_x_range_flag = BaseScriptElement.getBoolElement(instrument_dom, "norm_x_range_flag", - default=DataSets.norm_x_range_flag) - - self.norm_x_range = [BaseScriptElement.getIntElement(instrument_dom, "norm_x_min"), - BaseScriptElement.getIntElement(instrument_dom, "norm_x_max")] - - # discrete selection string - self.DataPeakDiscreteSelection = BaseScriptElement.getStringElement(instrument_dom, "peak_discrete_selection") - - # background flag - self.DataBackgroundFlag = BaseScriptElement.getBoolElement(instrument_dom, - "background_flag", - default=DataSets.DataBackgroundFlag) - - # background from/to pixels - self.DataBackgroundRoi = [BaseScriptElement.getIntElement(instrument_dom, "back_roi1_from"), - BaseScriptElement.getIntElement(instrument_dom, "back_roi1_to"), - BaseScriptElement.getIntElement(instrument_dom, "back_roi2_from"), - BaseScriptElement.getIntElement(instrument_dom, "back_roi2_to")] - - # from TOF and to TOF - # self.crop_TOF_range = BaseScriptElement.getBoolElement(instrument_dom, "crop_tof", - # default=DataSets.crop_TOF_range) - self.DataTofRange = [BaseScriptElement.getFloatElement(instrument_dom, "from_tof_range"), - BaseScriptElement.getFloatElement(instrument_dom, "to_tof_range")] - self.TOFstep = BaseScriptElement.getFloatElement(instrument_dom, "tof_step", - default=DataSets.TOFstep) - - self.data_files = BaseScriptElement.getStringList(instrument_dom, "data_sets") - - # with or without norm - self.NormFlag = BaseScriptElement.getBoolElement(instrument_dom, "norm_flag", - default=DataSets.NormFlag) - - # Peak from/to pixels - self.NormPeakPixels = [BaseScriptElement.getIntElement(instrument_dom, "norm_from_peak_pixels"), - BaseScriptElement.getIntElement(instrument_dom, "norm_to_peak_pixels")] - - # background flag - self.NormBackgroundFlag = BaseScriptElement.getBoolElement(instrument_dom, - "norm_background_flag", - default=DataSets.NormBackgroundFlag) - - # background from/to pixels - self.NormBackgroundRoi = [BaseScriptElement.getIntElement(instrument_dom, "norm_from_back_pixels"), - BaseScriptElement.getIntElement(instrument_dom, "norm_to_back_pixels")] - - self.norm_file = BaseScriptElement.getStringElement(instrument_dom, "norm_dataset") - - # Q cut - self.q_min = BaseScriptElement.getFloatElement(instrument_dom, "q_min", default=DataSets.q_min) - self.q_step = BaseScriptElement.getFloatElement(instrument_dom, "q_step", default=DataSets.q_step) - self.q_bins = BaseScriptElement.getIntElement(instrument_dom, "q_bins", default=DataSets.q_bins) - self.q_log = BaseScriptElement.getBoolElement(instrument_dom, "q_log", default=DataSets.q_log) - - # scattering angle - self.theta = BaseScriptElement.getFloatElement(instrument_dom, "theta", default=DataSets.theta) - # self.use_center_pixel = BaseScriptElement.getBoolElement(instrument_dom, - # "use_center_pixel", - # default=DataSets.use_center_pixel) - - # Sample log overwrites - self.set_detector_angle = BaseScriptElement.getBoolElement(instrument_dom, - "set_detector_angle", - default=DataSets.set_detector_angle) - self.detector_angle = BaseScriptElement.getFloatElement(instrument_dom, - "detector_angle", - default=DataSets.detector_angle) - self.set_detector_angle_offset = BaseScriptElement.getBoolElement(instrument_dom, - "set_detector_angle_offset", - default=DataSets.set_detector_angle_offset) - self.detector_angle_offset = BaseScriptElement.getFloatElement(instrument_dom, - "detector_angle_offset", - default=DataSets.detector_angle_offset) - self.set_direct_pixel = BaseScriptElement.getBoolElement(instrument_dom, - "set_direct_pixel", - default=DataSets.set_direct_pixel) - self.direct_pixel = BaseScriptElement.getFloatElement(instrument_dom, - "direct_pixel", - default=DataSets.direct_pixel) - - self.output_dir = BaseScriptElement.getStringElement(instrument_dom, - "output_dir", - default=DataSets.output_dir) - - def reset(self): - """ - Reset state - """ - self.DataBackgroundFlag = DataSets.DataBackgroundFlag - self.DataBackgroundRoi = DataSets.DataBackgroundRoi - self.DataPeakPixels = DataSets.DataPeakPixels - self.DataTofRange = DataSets.DataTofRange - self.TOFstep = DataSets.TOFstep - self.crop_TOF_range = DataSets.crop_TOF_range - self.data_files = DataSets.data_files - - self.NormFlag = DataSets.NormFlag - self.NormBackgroundFlag = DataSets.NormBackgroundFlag - self.NormBackgroundRoi = DataSets.NormBackgroundRoi - self.NormPeakPixels = DataSets.NormPeakPixels - self.norm_file = DataSets.norm_file - self.data_x_range_flag = DataSets.data_x_range_flag - self.data_x_range = DataSets.data_x_range - self.norm_x_range_flag = DataSets.norm_x_range_flag - self.norm_x_range = DataSets.norm_x_range - - # Q range - self.q_min = DataSets.q_min - self.q_step = DataSets.q_step - self.q_bins = DataSets.q_bins - self.q_log = DataSets.q_log - - # Scattering angle - self.theta = DataSets.theta - self.use_center_pixel = DataSets.use_center_pixel - - # Sample log overwrites - self.set_detector_angle = DataSets.set_detector_angle - self.detector_angle = DataSets.detector_angle - self.set_detector_angle_offset = DataSets.set_detector_angle_offset - self.detector_angle_offset = DataSets.detector_angle_offset - self.set_direct_pixel = DataSets.set_direct_pixel - self.direct_pixel = DataSets.direct_pixel - - self.output_dir = DataSets.output_dir diff --git a/scripts/Interface/ui/reflectometer/refl_gui.py b/scripts/Interface/ui/reflectometer/refl_gui.py index 3c9adc6f190d7a8546aa838fd0dc1b526c04976b..5f37b1a2cfc0492a4b4d6bb6a588737860977b9c 100644 --- a/scripts/Interface/ui/reflectometer/refl_gui.py +++ b/scripts/Interface/ui/reflectometer/refl_gui.py @@ -21,6 +21,7 @@ from isis_reflectometry.combineMulti import * import mantidqtpython from mantid.api import Workspace, WorkspaceGroup, CatalogManager, AlgorithmManager from mantid import UsageService +from mantid import logger from ui.reflectometer.ui_refl_window import Ui_windowRefl from ui.reflectometer.refl_save import Ui_SaveWindow @@ -43,12 +44,19 @@ class ReflGui(QtGui.QMainWindow, Ui_windowRefl): labelStatus = None accMethod = None + def show_deprecation_warning(self): + logger.warning(""" +The ISIS Reflectometry (Old) interface has been deprecated and will be removed from Mantid in March 2019 +We recommend you use ISIS Reflectometry instead, If this is not possible contact the development team using the "Help->Ask For Help" menu. +""") + def __init__(self): """ Initialise the interface """ super(QtGui.QMainWindow, self).__init__() self.setupUi(self) + self.show_deprecation_warning() self.loading = False self.clip = QtGui.QApplication.clipboard() self.shown_cols = {} diff --git a/scripts/Interface/ui/reflectometer/refl_window.ui b/scripts/Interface/ui/reflectometer/refl_window.ui index 861fbff42c8cdc5a24a3ada6c408e915720fb589..a0709949d0fbfdd883b4aee9e2d16083c24331be 100644 --- a/scripts/Interface/ui/reflectometer/refl_window.ui +++ b/scripts/Interface/ui/reflectometer/refl_window.ui @@ -14,7 +14,7 @@ <bool>true</bool> </property> <property name="windowTitle"> - <string>ISIS Reflectometry (Old)</string> + <string>ISIS Reflectometry (Old) - DEPRECATED</string> </property> <widget class="QWidget" name="widgetMainRow"> <layout class="QVBoxLayout" name="layoutBase"> diff --git a/scripts/LargeScaleStructures/ScalingFactorCalculation/sfCalculator.py b/scripts/LargeScaleStructures/ScalingFactorCalculation/sfCalculator.py deleted file mode 100644 index c40a9b791a8293156090a7a031c231293d6c978e..0000000000000000000000000000000000000000 --- a/scripts/LargeScaleStructures/ScalingFactorCalculation/sfCalculator.py +++ /dev/null @@ -1,952 +0,0 @@ -from __future__ import (absolute_import, division, print_function) -from mantid import * -from mantid.simpleapi import * -from numpy import zeros -from pylab import * -import os.path - -PRECISION = 0.010 - - -class sfCalculator(): - - tof_min = None #microS - tof_max = None #microS - - #range of x pixel to use in the X integration (we found out that there - #is a frame effect that introduces noise) - x_pixel_min = 90 - x_pixel_max = 190 - - #from,width,to in microS - rebin_parameters = '0,200,200000' - - #turn on or off the plots - bPlot = False - bFittingPlot = False - - #size of detector - alpha_pixel_nbr = 256 - beta_pixel_nbr = 304 #will be integrated over this dimension - - #name of numerators and denominators - numerator = None #ex: AiD0 - denominator = None #ex: AiD1 - - y_axis_numerator = None - y_axis_error_numerator = None - y_axis_denominator = None - y_axis_error_denominator = None - x_axis = None - - #define the peak region - n_peak_pixel_min = 130 - n_peak_pixel_max = 135 - d_peak_pixel_min = 130 - d_peak_pixel_max = 135 - - peak_pixel_min = None - peak_pixel_max = None - back_pixel_min = None - back_pixel_max = None - - #define the background range used in the background subtraction - n_back_pixel_min = 125 - n_back_pixel_max = 140 - d_back_pixel_min = 125 - d_back_pixel_max = 140 - - y_axis_ratio = None - y_axis_error_ratio = None - x_axis_ratio = None - - def __init__(self, numerator=None, denominator=None, - tof_range=None): - - print('---> initialize calculation') - - if (tof_range is None): - self.tof_min = 10000 - self.tof_max = 21600 - else: - self.tof_min = tof_range[0] - self.tof_max = tof_range[1] - - self.numerator = numerator - self.denominator = denominator - - self.x_axis_ratio = None - self.y_axis_error_ratio = None - self.y_axis_ratio = None - - def setNumerator(self, minPeak, maxPeak, minBack, maxBack): - - print('---> set numerator (' + self.numerator + ')') - - if minPeak != 0: - self.n_peak_pixel_min = minPeak - if maxPeak != 0 : - self.n_peak_pixel_max = maxPeak - if minBack != 0: - self.n_back_pixel_min = minBack - if maxBack != 0: - self.n_back_pixel_max = maxBack - - def setDenominator(self, minPeak, maxPeak, minBack, maxBack): - - print('---> set denominator (' + self.denominator + ')') - - if minPeak != 0: - self.d_peak_pixel_min = minPeak - if maxPeak != 0: - self.d_peak_pixel_max = maxPeak - if minBack != 0: - self.d_back_pixel_min = minBack - if maxBack != 0: - self.d_back_pixel_max = maxBack - - def run(self): - """ - Perform the calculation - - """ - - #perform calculation for numerator - self._calculateFinalYAxis(bNumerator=True) - - #perform calculation for denominator - self._calculateFinalYAxis(bNumerator=False) - - #calculate y_axis of numerator/denominator -# self._x_axis_ratio = self._x_axis - self.y_axis_ratio = self.y_axis_numerator / self.y_axis_denominator - - self.y_axis_error_ratio = ((self.y_axis_error_numerator / - self.y_axis_numerator) ** 2 + - (self.y_axis_error_denominator / - self.y_axis_denominator) ** 2) - self.y_axis_error_ratio = sqrt(self.y_axis_error_ratio) - self.y_axis_error_ratio *= self.y_axis_ratio - - def _calculateFinalYAxis(self, bNumerator=True): - """ - run full calculation for numerator or denominator - """ - if bNumerator is True: - file = self.numerator -# _id = self.id_numerator - self.peak_pixel_min = self.n_peak_pixel_min - self.peak_pixel_max = self.n_peak_pixel_max - self.back_pixel_min = self.n_back_pixel_min - self.back_pixel_max = self.n_back_pixel_max - else: - file = self.denominator -# _id = self.id_denominator - self.peak_pixel_min = self.d_peak_pixel_min - self.peak_pixel_max = self.d_peak_pixel_max - self.back_pixel_min = self.d_back_pixel_min - self.back_pixel_max = self.d_back_pixel_max - - nexus_file_numerator = file - ws_event_data = LoadEventNexus(Filename=nexus_file_numerator, - OutputWorkspace='EventDataWks') - mt1 = mtd['EventDataWks'] - - is_nexus_detector_rotated_flag = wks_utility.isNexusTakeAfterRefDate(ws_event_data.getRun().getProperty('run_start').value) - if is_nexus_detector_rotated_flag: - self.alpha_pixel_nbr = 304 - self.beta_pixel_nbr = 256 - else: - self.alpha_pixel_nbr = 256 - self.beta_pixel_nbr = 304 - - proton_charge = self._getProtonCharge(mt1) - rebin(InputWorkspace='EventDataWks', - OutputWorkspace='HistoDataWks', - Params=self.rebin_parameters) - - mt2 = mtd['HistoDataWks'] - x_axis = mt2.readX(0)[:] - self.x_axis = x_axis - - self._createIntegratedWorkspace(InputWorkspace=mt2, - OutputWorkspace='IntegratedDataWks', - proton_charge=proton_charge, - from_pixel=self.x_pixel_min, - to_pixel=self.x_pixel_max) - ConvertToHistogram(InputWorkspace='IntegratedDataWks', - OutputWorkspace='IntegratedDataWks') - - Transpose(InputWorkspace='IntegratedDataWks', - OutputWorkspace='TransposeIntegratedDataWks') - - ConvertToHistogram(InputWorkspace='TransposeIntegratedDataWks', - OutputWorkspace='TransposeIntegratedDataWks_t') - - FlatBackground(InputWorkspace='TransposeIntegratedDataWks_t', - OutputWorkspace='TransposeHistoFlatDataWks_1', - StartX=self.back_pixel_min, - EndX=self.peak_pixel_min, - Mode='Mean', - OutputMode="Return Background") - - FlatBackground(InputWorkspace='TransposeIntegratedDataWks_t', - OutputWorkspace='TransposeHistoFlatDataWks_2', - StartX=self.peak_pixel_max, - EndX=self.back_pixel_max, - Mode='Mean', - OutputMode="Return Background") - - Transpose(InputWorkspace='TransposeHistoFlatDataWks_1', - OutputWorkspace='DataWks_1') - - Transpose(InputWorkspace='TransposeHistoFlatDataWks_2', - OutputWorkspace='DataWks_2') - - ConvertToHistogram(InputWorkspace='DataWks_1', - OutputWorkspace='DataWks_1') - - ConvertToHistogram(InputWorkspace='DataWks_2', - OutputWorkspace='DataWks_2') - - RebinToWorkspace(WorkspaceToRebin='DataWks_1', - WorkspacetoMatch='IntegratedDataWks', - OutputWorkspace='DataWks_1') - - RebinToWorkspace(WorkspaceToRebin='DataWks_2', - WorkspacetoMatch='IntegratedDataWks', - OutputWorkspace='DataWks_2') - - WeightedMean(InputWorkspace1='DataWks_1', - InputWorkspace2='DataWks_2', - OutputWorkspace='DataWks') - - Minus(LHSWorkspace='IntegratedDataWks', - RHSWorkspace='DataWks', - OutputWorkspace='DataWks') - - mt3 = mtd['DataWks'] - self._calculateFinalAxis(Workspace=mt3, - bNumerator=bNumerator) - - #cleanup workspaces - mtd.remove('EventDataWks') - mtd.remove('HistoDataWks') - mtd.remove('IntegratedDataWks') - mtd.remove('TransposeIntegratedDataWks') - mtd.remove('TransposeIntegratedDataWks_t') - mtd.remove('TransposeHistoFlatDataWks') - mtd.remove('DataWks') - - def _calculateFinalAxis(self, Workspace=None, bNumerator=None): - """ - this calculates the final y_axis and y_axis_error of numerator - and denominator - """ - mt = Workspace - x_axis = mt.readX(0)[:] - self.x_axis = x_axis - - counts_vs_tof = zeros(len(x_axis)-1) - counts_vs_tof_error = zeros(len(x_axis)-1) - - for x in range(self.alpha_pixel_nbr): - counts_vs_tof += mt.readY(x)[:] - counts_vs_tof_error += mt.readE(x)[:] ** 2 - counts_vs_tof_error = sqrt(counts_vs_tof_error) - index_tof_min = self._getIndex(self.tof_min, x_axis) - index_tof_max = self._getIndex(self.tof_max, x_axis) - - if (bNumerator is True): - self.y_axis_numerator = counts_vs_tof[index_tof_min:index_tof_max] - self.y_axis_error_numerator = counts_vs_tof_error[index_tof_min:index_tof_max] - self.x_axis_ratio = self.x_axis[index_tof_min:index_tof_max] - else: - self.y_axis_denominator = counts_vs_tof[index_tof_min:index_tof_max] - self.y_axis_error_denominator = counts_vs_tof_error[index_tof_min:index_tof_max] - self.x_axis_ratio = self.x_axis[index_tof_min:index_tof_max] - - def _createIntegratedWorkspace(self, - InputWorkspace=None, - OutputWorkspace=None, - proton_charge=None, - from_pixel=0, - to_pixel=303): - """ - This creates the integrated workspace over the second pixel range - (beta_pixel_nbr here) and - returns the new workspace handle - """ - - x_axis = InputWorkspace.readX(0)[:] - x_size = to_pixel - from_pixel + 1 - y_axis = zeros((self.alpha_pixel_nbr, len(x_axis) - 1)) - y_error_axis = zeros((self.alpha_pixel_nbr, len(x_axis) - 1)) - y_range = arange(x_size) + from_pixel - - for x in range(self.beta_pixel_nbr): - for y in y_range: - index = int(self.alpha_pixel_nbr * x + y) - y_axis[y, :] += InputWorkspace.readY(index)[:] - y_error_axis[y, :] += ((InputWorkspace.readE(index)[:]) * - (InputWorkspace.readE(index)[:])) - - y_axis = y_axis.flatten() - y_error_axis = sqrt(y_error_axis) - #plot_y_error_axis = _y_error_axis #for output testing only - #-> plt.imshow(plot_y_error_axis, aspect='auto', origin='lower') - y_error_axis = y_error_axis.flatten() - - #normalization by proton charge - y_axis /= (proton_charge * 1e-12) - - CreateWorkspace(OutputWorkspace=OutputWorkspace, - DataX=x_axis, - DataY=y_axis, - DataE=y_error_axis, - Nspec=self.alpha_pixel_nbr) -# mt3 = mtd[OutputWorkspace] -# return mt3 - - def _getIndex(self, value, array): - """ - returns the index where the value has been found - """ - return array.searchsorted(value) - - def _getProtonCharge(self, st=None): - """ - Returns the proton charge of the given workspace in picoCoulomb - """ - if st is not None: - mt_run = st.getRun() - proton_charge_mtd_unit = mt_run.getProperty('gd_prtn_chrg').value - proton_charge = proton_charge_mtd_unit / 2.77777778e-10 - return proton_charge - return None - - def __mul__(self, other): - """ - operator * between two instances of the class - """ - - product = sfCalculator() - - product.numerator = self.numerator + '*' + other.numerator - product.denominator = self.denominator + '*' + other.denominator - - product.x_axis_ratio = self.x_axis_ratio - product.y_axis_ratio = self.y_axis_ratio * other.y_axis_ratio - product.y_axis_error_ratio = sqrt((other.y_axis_ratio * self.y_axis_error_ratio) ** 2 + - (other.y_axis_error_ratio * self.y_axis_ratio) ** 2) - return product - - def fit(self): - """ - This is going to fit the counts_vs_tof with a linear expression and return the a and - b coefficients (y=a+bx) - """ - CreateWorkspace(OutputWorkspace='DataToFit', - DataX=self.x_axis_ratio, - DataY=self.y_axis_ratio, - DataE=self.y_axis_error_ratio, - Nspec=1) - - Fit(InputWorkspace='DataToFit', - Function="name=UserFunction, Formula=a+b*x, a=1, b=2", - Output='Res') - res = mtd['Res_Parameters'] - - self.a = res.getDouble("Value", 0) - self.b = res.getDouble("Value", 1) - self.error_a = res.getDouble("Error", 0) - self.error_b = res.getDouble("Error", 1) - - -def plotObject(instance): - -# return - -# print 'a: ' + str(instance.a[-1]) -# print 'b: ' + str(instance.b[-1]) - - figure() - errorbar(instance.x_axis_ratio, - instance.y_axis_ratio, - instance.y_axis_error_ratio, - marker='s', - mfc='red', - linestyle='', - label='Exp. data') - - if instance.a is not None: - x = linspace(10000, 22000, 100) - _label = "%.3f + x*%.2e" % (instance.a, instance.b) - plot(x, instance.a + instance.b * x, label=_label) - - xlabel("TOF (microsS)") - ylabel("Ratio") - - title(instance.numerator + '/' + instance.denominator) - show() - legend() - - -def recordSettings(a, b, error_a, error_b, name, instance): - """ - This function will record the various fitting parameters and the - name of the ratio - """ - a.append(instance.a) - b.append(instance.b) - error_a.append(instance.error_a) - error_b.append(instance.error_b) - name.append(instance.numerator + '/' + instance.denominator) - - -def variable_value_splitter(variable_value): - """ - This function split the variable that looks like "LambdaRequested:3.75" - and returns a dictionnary of the variable name and value - """ - - _split = variable_value.split('=') - variable = _split[0] - value = float(_split[1]) - return {'variable':variable, 'value':value} - - -def isWithinRange(value1, value2): - """ - This function checks if the two values and return true if their - difference is <= PRECISION - """ - print('value1: ' + str(value1)) - print('value2: ' + str(value2)) - - diff = abs(float(value1)) - abs(float(value2)) - if abs(diff) <= PRECISION: - return True - else: - return False - - -def outputFittingParameters(a, b, error_a, error_b, - lambda_requested, - incident_medium, - S1H, S2H, - S1W, S2W, - output_file_name): - """ - Create an ascii file of the various fittings parameters - y=a+bx - 1st column: incident medium - 2nd column: lambda requested - 3rd column: S1H value - 4th column: S2H value - 5th column: S1W value - 6th column: S2W value - 7th column: a - 7th column: b - 8th column: error_a - 9th column: error_b - """ - - bFileExist = False - #First we need to check if the file already exist - if os.path.isfile(output_file_name): - bFileExist = True - - #then if it does, parse the file and check if following infos are - #already defined: - # lambda_requested, S1H, S2H, S1W, S2W - if (bFileExist): - f = open(output_file_name, 'r') - text = f.readlines() -# split_lines = text.split('\n') - split_lines = text - - entry_list_to_add = [] - - sz = len(a) - for i in range(sz): - - _match = False - - for _line in split_lines: - if _line[0] == '#': - continue - - _line_split = _line.split(' ') - _incident_medium = _line_split[0] - if (_incident_medium == incident_medium): - _lambdaRequested = variable_value_splitter(_line_split[1]) - if (isWithinRange(_lambdaRequested['value'], lambda_requested)): - _s1h = variable_value_splitter(_line_split[2]) - if (isWithinRange(_s1h['value'], S1H[i])): - _s2h = variable_value_splitter(_line_split[3]) - if (isWithinRange(_s2h['value'],S2H[i])): - _s1w = variable_value_splitter(_line_split[4]) - if (isWithinRange(_s1w['value'],S1W[i])): - _s2w = variable_value_splitter(_line_split[5]) - if (isWithinRange(_s2w['value'],S2W[i])): - _match = True - break - - if not _match: - entry_list_to_add.append(i) - - _content = [] - for j in entry_list_to_add: - - _line = 'IncidentMedium=' + incident_medium + ' ' - _line += 'LambdaRequested=' + str(lambda_requested) + ' ' - - _S1H = "{0:.8f}".format(abs(S1H[j])) - _S2H = "{0:.8f}".format(abs(S2H[j])) - _S1W = "{0:.8f}".format(abs(S1W[j])) - _S2W = "{0:.8f}".format(abs(S2W[j])) - _a = "{0:.8f}".format(a[j]) - _b = "{0:.8f}".format(b[j]) - _error_a = "{0:.8f}".format(float(error_a[j])) - _error_b = "{0:.8f}".format(float(error_b[j])) - - _line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' ' - _line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' ' - _line += 'a=' + _a + ' ' - _line += 'b=' + _b + ' ' - _line += 'error_a=' + _error_a + ' ' - _line += 'error_b=' + _error_b + '\n' - _content.append(_line) - - f = open(output_file_name, 'a') - f.writelines(_content) - f.close() - - else: - - _content = ['#y=a+bx\n', '#\n', - '#lambdaRequested[Angstroms] S1H[mm] S2H[mm] S1W[mm] S2W[mm] a b error_a error_b\n', '#\n'] - sz = len(a) - for i in range(sz): - - _line = 'IncidentMedium=' + incident_medium.strip() + ' ' - _line += 'LambdaRequested=' + str(lambda_requested) + ' ' - - _S1H = "{0:.8f}".format(abs(S1H[i])) - _S2H = "{0:.8f}".format(abs(S2H[i])) - _S1W = "{0:.8f}".format(abs(S1W[i])) - _S2W = "{0:.8f}".format(abs(S2W[i])) - _a = "{0:.8f}".format(a[i]) - _b = "{0:.8f}".format(b[i]) - _error_a = "{0:.8f}".format(float(error_a[i])) - _error_b = "{0:.8f}".format(float(error_b[i])) - - _line += 'S1H=' + _S1H + ' ' + 'S2H=' + _S2H + ' ' - _line += 'S1W=' + _S1W + ' ' + 'S2W=' + _S2W + ' ' - _line += 'a=' + _a + ' ' - _line += 'b=' + _b + ' ' - _line += 'error_a=' + _error_a + ' ' - _line += 'error_b=' + _error_b + '\n' - _content.append(_line) - - f = open(output_file_name, 'w') - f.writelines(_content) - f.close() - - -def createIndividualList(string_list_files): - """ - Using the list_files, will produce a dictionary of the run - number and number of attenuator - ex: - list_files = "1000:0, 1001:1, 1002:1, 1003:2" - return {1000:0, 1001:1, 1002:2, 1003:2} - """ - if (string_list_files == ''): - return None - first_split = string_list_files.split(',') - - list_runs = [] - list_attenuator= [] - - _nbr_files = len(first_split) - for i in range(_nbr_files): - _second_split = first_split[i].split(':') - list_runs.append(_second_split[0].strip()) - list_attenuator.append(int(_second_split[1].strip())) - - return {'list_runs':list_runs, - 'list_attenuator':list_attenuator} - - -def getLambdaValue(mt): - """ - return the lambdaRequest value - """ - mt_run = mt.getRun() - _lambda = mt_run.getProperty('LambdaRequest').value - return _lambda - - -def getSh(mt, top_tag, bottom_tag): - """ - returns the height and units of the given slits - """ - mt_run = mt.getRun() - st = mt_run.getProperty(top_tag).value - sb = mt_run.getProperty(bottom_tag).value - sh = float(sb[0]) - float(st[0]) - units = mt_run.getProperty(top_tag).units - return sh, units - - -def getS1h(mt=None): - """ - returns the height and units of the slit #1 - """ - if mt is not None: - _h, units = getSh(mt, 's1t', 's1b') - return _h, units - return None, '' - - -def getS2h(mt=None): - """ - returns the height and units of the slit #2 - """ - if mt is not None: - _h, units = getSh(mt, 's2t', 's2b') - return _h, units - return None, None - - -def getSw(mt, left_tag, right_tag): - """ - returns the width and units of the given slits - """ - mt_run = mt.getRun() - sl = mt_run.getProperty(left_tag).value - sr = mt_run.getProperty(right_tag).value - sw = float(sl[0]) - float(sr[0]) - units = mt_run.getProperty(left_tag).units - return sw, units - - -def getS1w(mt=None): - """ - returns the width and units of the slit #1 - """ - if mt is not None: - _w, units = getSw(mt, 's1l', 's1r') - return _w, units - return None, '' - - -def getS2w(mt=None): - """ - returns the width and units of the slit #2 - """ - if mt is not None: - _w, units = getSh(mt, 's2l', 's2r') - return _w, units - return None, None - - -def getSlitsValueAndLambda(full_list_runs, - S1H, S2H, - S1W, S2W, lambdaRequest): - """ - Retrieve the S1H (slit 1 height), - S2H (slit 2 height), - S1W (slit 1 width), - S2W (slit 2 width) and - lambda requested values - """ - _nbr_files = len(full_list_runs) - print('> Retrieving Slits and Lambda Requested for each file:') - for i in range(_nbr_files): - _full_file_name = full_list_runs[i] - print('-> ' + _full_file_name) - LoadEventNexus(Filename=_full_file_name, - OutputWorkspace='tmpWks', - MetaDataOnly='1') - mt1 = mtd['tmpWks'] - _s1h_value, _s1h_units = getS1h(mt1) - _s2h_value, _s2h_units = getS2h(mt1) - S1H[i] = _s1h_value - S2H[i] = _s2h_value - - _s1w_value, _s1w_units = getS1w(mt1) - _s2w_value, _s2w_units = getS2w(mt1) - S1W[i] = _s1w_value - S2W[i] = _s2w_value - - _lambda_value = getLambdaValue(mt1) - lambdaRequest[i] = _lambda_value - - -def isRunsSorted(list_runs, S1H, S2H): - """ - Make sure the files have been sorted - """ - sz = len(S1H) - sTotal = zeros(sz) - for i in range(sz): - sTotal[i] = S1H[i] + S2H[i] - - sorted_sTotal = sorted(sTotal) - - for i in range(len(sTotal)): - _left = list(sTotal)[i] - _right = sorted_sTotal[i] - - _left_formated = "%2.1f" % _left - _right_formated = "%2.1f" % _right - if (_left_formated != _right_formated): - return False - - return True - - -def calculateAndFit(numerator='', - denominator='', - list_peak_back_numerator=None, - list_peak_back_denominator=None, - list_objects=[], - tof_range=None): - - print('--> running calculate and fit algorithm') - - cal1 = sfCalculator(numerator=numerator, - denominator=denominator, - tof_range=tof_range) - - cal1.setNumerator(minPeak=list_peak_back_numerator[0], - maxPeak=list_peak_back_numerator[1], - minBack=list_peak_back_numerator[2], - maxBack=list_peak_back_numerator[3]) - - cal1.setDenominator(minPeak=list_peak_back_denominator[0], - maxPeak=list_peak_back_denominator[1], - minBack=list_peak_back_denominator[2], - maxBack=list_peak_back_denominator[3]) - - cal1.run() - - if (list_objects != [] and list_objects[-1] is not None): - new_cal1 = cal1 * list_objects[-1] - new_cal1.fit() - return new_cal1 - else: - cal1.fit() - return cal1 - - -def help(): - """ - Here the user will have information about how the command line - works - """ - print('sfCalculator help:') - print() - print('example:') - print(' > sfCalculator.calculate(string_runs="55889:0, 55890:1, 55891:1, 55892:2",') - print(' list_') - - -#if __name__ == '__main__': -def calculate(string_runs=None, - # list_attenuator=None, - list_peak_back=None, - output_file_name=None, - incident_medium=None, - tof_range=None): - """ - In this current version, the program will automatically calculates - the scaling function for up to, and included, 6 attenuators. - A output file will then be produced with the following format: - S1H S2H a b error_a error_b - .... - where y=a+bx - x axis is in microS - - The string runs has to be specified this way: - string_runs = "run#1:nbr_attenuator, run#2:nbr_attenuator...." - - the list_peak_back is specified this way: - list_peak_back = - [[peak_min_run1, peak_max_run1, back_min_run1, back_max_run1], - [peak_min_run2, peak_max_run2, back_min_run2, back_max_run2], - [...]] - - output_path = where the scaling factor files will be written - tof_range - - """ - - list_attenuator = None - - #use default string files if not provided - if (string_runs is None): - #Input from user -# list_runs = ['55889', '55890', '55891', '55892', '55893', '55894', -# '55895', '55896', '55897', '55898', '55899', '55900', -# '55901', '55902'] - list_runs = ['55889', '55890', '55891', '55892', '55893', '55894'] - nexus_path = '/mnt/hgfs/j35/results/' - pre = 'REF_L_' - nexus_path_pre = nexus_path + pre - post = '_event.nxs' - - for (offset, item) in enumerate(list_runs): - list_runs[offset] = nexus_path_pre + item + post - - else: - dico = createIndividualList(string_runs) - list_runs = dico['list_runs'] - - for (offset, item) in enumerate(list_runs): - try: - _File = FileFinder.findRuns("REF_L%d" %int(item))[0] - list_runs[offset] = _File - except: - msg = "RefLReduction: could not find run %s\n" %item - msg += "Add your data folder to your User Data Directories in the File menu" - raise RuntimeError(msg) - - list_attenuator = dico['list_attenuator'] - - if (incident_medium is None): - incident_medium = "H20" #default value - - if (list_attenuator is None): -# list_attenuator = [0, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 4, 4] - list_attenuator = [0, 1, 1, 1, 1, 1] - - if (list_peak_back is None): - list_peak_back = zeros((len(list_runs), 4)) #[peak_min, peak_max, back_min, back_max] -# list_peak_back[9, ] = [128, 136, 120, 145] -# list_peak_back[11, ] = [125, 140, 115, 150] -# list_peak_back[10, ] = [128, 136, 120, 145] -# list_peak_back[13, ] = [120, 145, 105, 155] -# list_peak_back[12, ] = [125, 140, 115, 150] - - ##### - #Input file should be as it is here ! - ##### - - #retrieve the S1H and S2H val/units for each NeXus - #retrieve the lambdaRequest value (Angstrom) - S1H = {} - S2H = {} - S1W = {} - S2W = {} - lambdaRequest = {} - getSlitsValueAndLambda(list_runs, S1H, S2H, S1W, S2W, lambdaRequest) - - #Make sure all the lambdaRequested are identical within a given range - lambdaRequestPrecision = 0.01 #1% - for i in lambdaRequest: - _localValue = float(lambdaRequest[i][0]) - _localValueRate = lambdaRequestPrecision * _localValue - _leftValue = _localValue - _localValueRate - _rightValue = _localValue + _localValueRate - - if (_localValue < _leftValue) or (_localValue > _rightValue): - raise Exception("lambda requested do not match !") - - #make sure the file are sorted from smaller to bigger openning - if isRunsSorted(list_runs, S1H, S2H): - - #initialize record fitting parameters arrays - a = [] - b = [] - error_a = [] - error_b = [] - name = [] - - finalS1H = [] - finalS2H = [] - - finalS1W = [] - finalS2W = [] - - #array of True/False flags that will allow us - #to rescale the calculation on the first attenuator - _first_A = [] - for j in range(len(unique(list_attenuator))): - _first_A.append(True) - - #array of index of first attenuator - _index_first_A = [] - for j in range(len(unique(list_attenuator))): - _index_first_A.append(-1) - - index_numerator = -1 - index_denominator = -1 - - list_objects = [] - - for i in range(len(list_runs)): - - print('> Working with index: ' + str(i)) - _attenuator = list_attenuator[i] - - if _attenuator == 0: - continue - else: - if _first_A[_attenuator] is True: - _first_A[_attenuator] = False - _index_first_A[_attenuator] = i - continue - else: - index_numerator = i - index_denominator = _index_first_A[_attenuator] - - print('-> numerator : ' + str(list_runs[index_numerator])) - print('-> denominator: ' + str(list_runs[index_denominator])) - cal = calculateAndFit(numerator=list_runs[index_numerator], - denominator=list_runs[index_denominator], - list_peak_back_numerator=list_peak_back[index_numerator], - list_peak_back_denominator=list_peak_back[index_denominator], - list_objects=list_objects, - tof_range=tof_range) - - recordSettings(a, b, error_a, error_b, name, cal) - - if (i < (len(list_runs) - 1) and list_attenuator[i + 1] == (_attenuator+1)): - list_objects.append(cal) - - #record S1H and S2H - finalS1H.append(S1H[index_numerator]) - finalS2H.append(S2H[index_numerator]) - - #record S1W and S2W - finalS1W.append(S1W[index_numerator]) - finalS2W.append(S2W[index_numerator]) - - #output the fitting parameters in an ascii - _lambdaRequest = "{0:.2f}".format(lambdaRequest[0][0]) - -# output_pre = 'SFcalculator_lr' + str(_lambdaRequest) -# output_ext = '.txt' -# output_file = output_path + '/' + output_pre + output_ext - - if output_file_name is None: - output_file_name = "/home/j35/Desktop/RefLsf.cfg" - - outputFittingParameters(a, b, error_a, error_b, - _lambdaRequest, - incident_medium, - finalS1H, finalS2H, - finalS1W, finalS2W, - output_file_name) - - print('Done !') - - else: - """ - sort the files - """ - pass diff --git a/scripts/REFL_Reduction.py b/scripts/REFL_Reduction.py deleted file mode 100644 index 2c45991060373a51dca2881faee4b6d39f95bee0..0000000000000000000000000000000000000000 --- a/scripts/REFL_Reduction.py +++ /dev/null @@ -1,10 +0,0 @@ -#pylint: disable=invalid-name -""" - Script used to start the REFL reduction gui from Mantidplot -""" -from __future__ import (absolute_import, division, print_function) -from reduction_application import ReductionGUI - -reducer = ReductionGUI(instrument="REFL", instrument_list=["REFL"]) -if reducer.setup_layout(load_last=True): - reducer.show() diff --git a/scripts/REFL_SF_Calculator.py b/scripts/REFL_SF_Calculator.py deleted file mode 100644 index a6ce27641874470d7591de8c938d8f3ef418e0ae..0000000000000000000000000000000000000000 --- a/scripts/REFL_SF_Calculator.py +++ /dev/null @@ -1,10 +0,0 @@ -#pylint: disable=invalid-name -""" - Script used to start the REFL SF calculator gui from Mantidplot -""" -from __future__ import (absolute_import, division, print_function) -from reduction_application import ReductionGUI - -reducer = ReductionGUI(instrument="REFLSF", instrument_list=["REFLSF"]) -if reducer.setup_layout(load_last=True): - reducer.show() diff --git a/scripts/REFM_Reduction.py b/scripts/REFM_Reduction.py deleted file mode 100644 index f755196eb030347b141a0fed9bebf032f30e7182..0000000000000000000000000000000000000000 --- a/scripts/REFM_Reduction.py +++ /dev/null @@ -1,10 +0,0 @@ -#pylint: disable=invalid-name -""" - Script used to start the REFL reduction gui from Mantidplot -""" -from __future__ import (absolute_import, division, print_function) -from reduction_application import ReductionGUI - -reducer = ReductionGUI(instrument="REFM", instrument_list=["REFM"]) -if reducer.setup_layout(load_last=True): - reducer.show() diff --git a/scripts/Reflectometry/isis_reflectometry/l2q.py b/scripts/Reflectometry/isis_reflectometry/l2q.py index b192b4ef490ef2907ce414746d4e6e5245884126..79aba311d21bcd29a93cdcc6339062287f1310ed 100644 --- a/scripts/Reflectometry/isis_reflectometry/l2q.py +++ b/scripts/Reflectometry/isis_reflectometry/l2q.py @@ -1,11 +1,11 @@ -#pylint: disable=invalid-name +# pylint: disable=invalid-name from __future__ import (absolute_import, division, print_function) import math from mantid.simpleapi import * # New API -def l2q(ws,whichDet,theta, sample_component_name): +def l2q(ws, whichDet, theta, sample_component_name): ''' call signature::call signature:: @@ -33,30 +33,41 @@ def l2q(ws,whichDet,theta, sample_component_name): else: inst = ws.getInstrument() - sampleLocation=inst.getComponentByName(sample_component_name).getPos() - detLocation=inst.getComponentByName(whichDet).getPos() - sample2detector=detLocation-sampleLocation # meters + sampleLocation = inst.getComponentByName(sample_component_name).getPos() + detLocation = inst.getComponentByName(whichDet).getPos() + sample2detector = detLocation - sampleLocation # meters - theta=theta*math.pi/180.0 # convert to radians + theta = theta * math.pi / 180.0 # convert to radians # Fetch the reference frame to determine the instrument orientation. reference_frame = inst.getReferenceFrame() - sample_to_detector_along_beam = sample2detector.scalar_prod( reference_frame.vecPointingAlongBeam() ) + sample_to_detector_along_beam = sample2detector.scalar_prod( + reference_frame.vecPointingAlongBeam()) # calculate new detector position based on angle theta in degrees: - across_offset = 0.0 # Across the beam (side to side) - up_offset = sample_to_detector_along_beam * math.sin(2.0 * theta) # Normal to the beam (up) - beam_offset = detLocation.scalar_prod( reference_frame.vecPointingAlongBeam() ) + # Across the beam (side to side) + across_offset = 0.0 + up_offset = sample_to_detector_along_beam * \ + math.sin(2.0 * theta) # Normal to the beam (up) + beam_offset = detLocation.scalar_prod( + reference_frame.vecPointingAlongBeam()) coord_args = dict() - coord_args[ reference_frame.pointingAlongBeamAxis() ] = beam_offset - coord_args[ reference_frame.pointingUpAxis() ] = up_offset - coord_args[ reference_frame.pointingHorizontalAxis() ] = across_offset + coord_args[reference_frame.pointingAlongBeamAxis()] = beam_offset + coord_args[reference_frame.pointingUpAxis()] = up_offset + coord_args[reference_frame.pointingHorizontalAxis()] = across_offset logger.information('Correcting detector location') - MoveInstrumentComponent(ws, ComponentName=whichDet, RelativePosition=False, **coord_args ) + MoveInstrumentComponent( + ws, + ComponentName=whichDet, + RelativePosition=False, + **coord_args) # Now convert to momentum transfer - IvsQ = ConvertUnits(InputWorkspace=ws,OutputWorkspace="IvsQ",Target="MomentumTransfer") + IvsQ = ConvertUnits( + InputWorkspace=ws, + OutputWorkspace="IvsQ", + Target="MomentumTransfer") return IvsQ diff --git a/scripts/SANS/sans/command_interface/command_interface_state_director.py b/scripts/SANS/sans/command_interface/command_interface_state_director.py index cdcb6780b5f574fe2c64cc8116b8a1fb5193761b..44062441b4a7d08a0e132d2c4b05ce3f30c94bc9 100644 --- a/scripts/SANS/sans/command_interface/command_interface_state_director.py +++ b/scripts/SANS/sans/command_interface/command_interface_state_director.py @@ -8,6 +8,7 @@ from sans.user_file.settings_tags import (MonId, monitor_spectrum, OtherId, Samp fit_general, FitId, monitor_file, mask_angle_entry, LimitsId, range_entry, simple_range, DetectorId, event_binning_string_values, det_fit_range, single_entry_with_detector) +from sans.common.file_information import SANSFileInformationFactory # ---------------------------------------------------------------------------------------------------------------------- # Commands @@ -140,9 +141,14 @@ class CommandInterfaceStateDirector(object): def _get_data_state(self): # Get the data commands data_commands = self._get_data_commands() + data_elements = self._get_elements_with_key(DataCommandId.sample_scatter, data_commands) + data_element = data_elements[-1] + file_name = data_element.file_name + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information(file_name) # Build the state data - data_builder = get_data_builder(self._facility) + data_builder = get_data_builder(self._facility, file_information) self._set_data_element(data_builder.set_sample_scatter, data_builder.set_sample_scatter_period, DataCommandId.sample_scatter, data_commands) self._set_data_element(data_builder.set_sample_transmission, data_builder.set_sample_transmission_period, @@ -215,7 +221,11 @@ class CommandInterfaceStateDirector(object): @param data_state: the data state. @return: a SANSState object. """ - self._state_director = StateDirectorISIS(data_state) + file_name = data_state.sample_scatter + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information(file_name) + + self._state_director = StateDirectorISIS(data_state, file_information) # If we have a clean instruction in there, then we should apply it to all commands self._apply_clean_if_required() diff --git a/scripts/SANS/sans/common/file_information.py b/scripts/SANS/sans/common/file_information.py index 0de6cb8b637b6bad23f9ad460b5aea3341a01a35..5675ac3a29381d1d942abf40d0dcfc92d08abcd9 100644 --- a/scripts/SANS/sans/common/file_information.py +++ b/scripts/SANS/sans/common/file_information.py @@ -1022,8 +1022,11 @@ class SANSFileInformationFactory(object): super(SANSFileInformationFactory, self).__init__() def create_sans_file_information(self, file_name): + if not file_name: + raise ValueError("The filename given to FileInformation is empty") full_file_name = find_sans_file(file_name) + if is_isis_nexus_single_period(full_file_name) or is_isis_nexus_multi_period(full_file_name): file_information = SANSFileInformationISISNexus(full_file_name) elif is_raw_single_period(full_file_name) or is_raw_multi_period(full_file_name): diff --git a/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py b/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py index 2cc513fa8923d5bdf860fd0f6b9c06b05ded92d2..6a46e54b906fa881a6cd8f7738ee12b5c87a51a9 100644 --- a/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py +++ b/scripts/SANS/sans/gui_logic/presenter/gui_state_director.py @@ -10,6 +10,7 @@ import copy from sans.state.data import get_data_builder from sans.user_file.state_director import StateDirectorISIS +from sans.common.file_information import SANSFileInformationFactory class GuiStateDirector(object): @@ -22,7 +23,10 @@ class GuiStateDirector(object): def create_state(self, row): # 1. Get the data settings, such as sample_scatter, etc... and create the data state. table_index_model = self._table_model.get_table_entry(row) - data_builder = get_data_builder(self._facility) + file_name = table_index_model.sample_scatter + file_information_factory = SANSFileInformationFactory() + file_information = file_information_factory.create_sans_file_information(file_name) + data_builder = get_data_builder(self._facility, file_information) self._set_data_entry(data_builder.set_sample_scatter, table_index_model.sample_scatter) self._set_data_period_entry(data_builder.set_sample_scatter_period, table_index_model.sample_scatter_period) @@ -50,7 +54,7 @@ class GuiStateDirector(object): state_gui_model.output_name = output_name # 4. Create the rest of the state based on the builder. - user_file_state_director = StateDirectorISIS(data) + user_file_state_director = StateDirectorISIS(data, file_information) settings = copy.deepcopy(state_gui_model.settings) user_file_state_director.add_state_settings(settings) diff --git a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py index 315bad89e2a15d3fee20ed9234698957c0a9eb84..a08f481129587c6960daffd007301fd7998d4cba 100644 --- a/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py +++ b/scripts/SANS/sans/gui_logic/presenter/run_tab_presenter.py @@ -927,6 +927,7 @@ class RunTabPresenter(object): else: rows = range(number_of_rows) states = {} + gui_state_director = GuiStateDirector(table_model, state_model, self._facility) for row in rows: self.sans_logger.information("Generating state for row {}".format(row)) diff --git a/scripts/SANS/sans/state/data.py b/scripts/SANS/sans/state/data.py index 93e2835f8d71edb5594fef40eadad9ea35d8df1a..59ab291246644ef6a9535330e065f806c1fe96ce 100644 --- a/scripts/SANS/sans/state/data.py +++ b/scripts/SANS/sans/state/data.py @@ -10,7 +10,6 @@ from sans.state.state_base import (StateBase, StringParameter, PositiveIntegerPa from sans.common.enums import (SANSInstrument, SANSFacility) import sans.common.constants from sans.state.state_functions import (is_pure_none_or_not_none, validation_message) -from sans.common.file_information import SANSFileInformationFactory from sans.state.automatic_setters import automatic_setters @@ -106,10 +105,7 @@ class StateData(StateBase): # ---------------------------------------------------------------------------------------------------------------------- # Builder # ---------------------------------------------------------------------------------------------------------------------- -def set_information_from_file(data_info): - file_name = data_info.sample_scatter - file_information_factory = SANSFileInformationFactory() - file_information = file_information_factory.create_sans_file_information(file_name) +def set_information_from_file(data_info, file_information): instrument = file_information.get_instrument() facility = file_information.get_facility() run_number = file_information.get_run_number() @@ -123,18 +119,20 @@ def set_information_from_file(data_info): class StateDataBuilder(object): @automatic_setters(StateData) - def __init__(self): + def __init__(self, file_information): super(StateDataBuilder, self).__init__() self.state = StateData() + self._file_information = file_information def build(self): # Make sure that the product is in a valid state, ie not incomplete self.state.validate() - # There are some elements which need to be read from the file. This is currently: + # There are some elements which need to be read from the file information object. + # This is currently: # 1. instrument # 2. sample_scatter_run_number - set_information_from_file(self.state) + set_information_from_file(self.state, self._file_information) return copy.copy(self.state) @@ -142,9 +140,9 @@ class StateDataBuilder(object): # ------------------------------------------ # Factory method for StateDataBuilder # ------------------------------------------ -def get_data_builder(facility): +def get_data_builder(facility, file_information=None): if facility is SANSFacility.ISIS: - return StateDataBuilder() + return StateDataBuilder(file_information) else: raise NotImplementedError("StateDataBuilder: The selected facility {0} does not seem" " to exist".format(str(facility))) diff --git a/scripts/SANS/sans/state/scale.py b/scripts/SANS/sans/state/scale.py index 43fb51bbeebdd20d36a3235c683fb3039588459f..47189ec6f1008297c90e42e71b936e4bdf200d68 100644 --- a/scripts/SANS/sans/state/scale.py +++ b/scripts/SANS/sans/state/scale.py @@ -4,7 +4,6 @@ from __future__ import (absolute_import, division, print_function) import copy from sans.state.state_base import (StateBase, rename_descriptor_names, PositiveFloatParameter, ClassTypeParameter) from sans.common.enums import (SampleShape, SANSFacility) -from sans.common.file_information import (SANSFileInformationFactory) from sans.state.automatic_setters import (automatic_setters) @@ -43,11 +42,7 @@ class StateScale(StateBase): # ---------------------------------------------------------------------------------------------------------------------- # Builder # ---------------------------------------------------------------------------------------------------------------------- -def set_geometry_from_file(state, date_info): - sample_scatter = date_info.sample_scatter - file_information_factory = SANSFileInformationFactory() - file_information = file_information_factory.create_sans_file_information(sample_scatter) - +def set_geometry_from_file(state, date_info, file_information): # Get the geometry state.height_from_file = file_information.get_height() state.width_from_file = file_information.get_width() @@ -57,10 +52,10 @@ def set_geometry_from_file(state, date_info): class StateScaleBuilder(object): @automatic_setters(StateScale, exclusions=[]) - def __init__(self, data_info): + def __init__(self, data_info, file_information): super(StateScaleBuilder, self).__init__() self.state = StateScale() - set_geometry_from_file(self.state, data_info) + set_geometry_from_file(self.state, data_info, file_information) def build(self): self.state.validate() @@ -70,12 +65,12 @@ class StateScaleBuilder(object): # --------------------------------------- # Factory method for SANStateScaleBuilder # --------------------------------------- -def get_scale_builder(data_info): +def get_scale_builder(data_info, file_information=None): # The data state has most of the information that we require to define the scaling. For the factory method, only # the facility/instrument is of relevance. facility = data_info.facility if facility is SANSFacility.ISIS: - return StateScaleBuilder(data_info) + return StateScaleBuilder(data_info, file_information) else: raise NotImplementedError("StateScaleBuilder: Could not find any valid scale builder for the " "specified StateData object {0}".format(str(data_info))) diff --git a/scripts/SANS/sans/test_helper/file_information_mock.py b/scripts/SANS/sans/test_helper/file_information_mock.py new file mode 100644 index 0000000000000000000000000000000000000000..0bdf001aa78ed85eb02eaebce226790d33cd73cc --- /dev/null +++ b/scripts/SANS/sans/test_helper/file_information_mock.py @@ -0,0 +1,61 @@ +from sans.common.file_information import SANSFileInformation +from mantid.kernel import DateAndTime +from sans.common.enums import (SANSFacility, SANSInstrument, FileType, SampleShape) + + +class SANSFileInformationMock(SANSFileInformation): + def __init__(self, instrument=SANSInstrument.LOQ, facility=SANSFacility.ISIS, run_number=00000, file_name='file_name', + height=8.0, width=8.0, thickness=1.0, shape=SampleShape.Cuboid, date='2012-10-22T22:41:27', periods=1, + event_mode=True, added_data=False): + super(SANSFileInformationMock, self).__init__(file_name) + self._instrument = instrument + self._facility = facility + self._run_number = run_number + self._height = height + self._width = width + self._thickness = thickness + self._shape = shape + self._date = date + self._file_name = file_name + self._periods = periods + self._event_mode = event_mode + self._added_data = added_data + + def get_file_name(self): + return self._file_name + + def get_instrument(self): + return self._instrument + + def get_facility(self): + return self._facility + + def get_date(self): + return DateAndTime(self._date) + + def get_number_of_periods(self): + return self._periods + + def get_run_number(self): + return self._run_number + + def get_type(self): + return FileType.ISISNexus + + def is_event_mode(self): + return self._event_mode + + def is_added_data(self): + return self._added_data + + def get_height(self): + return self._height + + def get_width(self): + return self._width + + def get_thickness(self): + return self._thickness + + def get_shape(self): + return self._shape diff --git a/scripts/SANS/sans/test_helper/test_director.py b/scripts/SANS/sans/test_helper/test_director.py index 2ddb9f48b4be36f6904d3b0c13de9fb85eff05d6..0f2b7fda8d7c8142bca6aabf314616692a38b969 100644 --- a/scripts/SANS/sans/test_helper/test_director.py +++ b/scripts/SANS/sans/test_helper/test_director.py @@ -16,7 +16,8 @@ from sans.state.adjustment import get_adjustment_builder from sans.state.convert_to_q import get_convert_to_q_builder from sans.common.enums import (SANSFacility, ISISReductionMode, ReductionDimensionality, - FitModeForMerge, RebinType, RangeStepType, SaveType, FitType, SampleShape) + FitModeForMerge, RebinType, RangeStepType, SaveType, FitType, SampleShape, SANSInstrument) +from sans.test_helper.file_information_mock import SANSFileInformationMock class TestDirector(object): @@ -51,10 +52,11 @@ class TestDirector(object): def construct(self): facility = SANSFacility.ISIS + file_information = SANSFileInformationMock(run_number=22024, instrument=SANSInstrument.SANS2D) # Build the SANSStateData if self.data_state is None: - data_builder = get_data_builder(facility) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("SANS2D00022024") data_builder.set_can_scatter("SANS2D00022024") self.data_state = data_builder.build() @@ -110,7 +112,7 @@ class TestDirector(object): # Build the SANSStateScale if self.scale_state is None: - scale_builder = get_scale_builder(self.data_state) + scale_builder = get_scale_builder(self.data_state, file_information) scale_builder.set_shape(SampleShape.Cuboid) scale_builder.set_width(1.0) scale_builder.set_height(2.0) diff --git a/scripts/SANS/sans/user_file/state_director.py b/scripts/SANS/sans/user_file/state_director.py index 224ea588e1cd7ff339b129084dc8351ef7feeff5..606b58507669c9d0e59e1f7c1683c7a08f88c9a2 100644 --- a/scripts/SANS/sans/user_file/state_director.py +++ b/scripts/SANS/sans/user_file/state_director.py @@ -160,7 +160,7 @@ def set_single_entry(builder, method_name, tag, all_entries, apply_to_value=None class StateDirectorISIS(object): - def __init__(self, data_info): + def __init__(self, data_info, file_information): super(StateDirectorISIS, self).__init__() data_info.validate() self._data = data_info @@ -174,7 +174,7 @@ class StateDirectorISIS(object): self._slice_event_builder = get_slice_event_builder(self._data) self._wavelength_builder = get_wavelength_builder(self._data) self._save_builder = get_save_builder(self._data) - self._scale_builder = get_scale_builder(self._data) + self._scale_builder = get_scale_builder(self._data, file_information) self._adjustment_builder = get_adjustment_builder(self._data) self._normalize_to_monitor_builder = get_normalize_to_monitor_builder(self._data) diff --git a/scripts/SANS/sans/user_file/user_file_parser.py b/scripts/SANS/sans/user_file/user_file_parser.py index 492d58b6083f4ef028b12fb38a7352d67a668b8a..0dafbe2c88eb78571b32ef9449ff9ea6e2b1d4ec 100644 --- a/scripts/SANS/sans/user_file/user_file_parser.py +++ b/scripts/SANS/sans/user_file/user_file_parser.py @@ -443,7 +443,7 @@ class DetParser(UserFileComponentParser): merge_range = extract_float_range(merge_range_string) value = det_fit_range(start=merge_range[0], stop=merge_range[1], use_fit=True) else: - value = det_fit_range(start=None, stop=None, use_fit=True) + raise RuntimeError("DetParser: Could not extract line: {0}".format(line)) return {DetectorId.merge_range: value} else: raise RuntimeError("DetParser: Could not extract line: {0}".format(line)) diff --git a/scripts/directtools/__init__.py b/scripts/directtools/__init__.py index 6aea8a736947533a55793b7dccd3310b84b34e1d..bc91cfe55510da98e534397566ee564ac17794e9 100644 --- a/scripts/directtools/__init__.py +++ b/scripts/directtools/__init__.py @@ -33,6 +33,11 @@ def _clearlatex(s): return s +def _configurematplotlib(params): + """Set matplotlib rc parameters from the params dictionary.""" + matplotlib.rcParams.update(params) + + def _finalizeprofileE(axes): """Set axes for const E axes.""" axes.set_xlim(xmin=0.) @@ -111,6 +116,11 @@ def _binCentres(edges): return (edges[:-1] + edges[1:]) / 2 +def _mantidsubplotsetup(): + """Return the Mantid projection setup.""" + return {'projection': 'mantid'} + + def _profiletitle(workspaces, scan, units, cuts, widths, figure): """Add title to line profile figure.""" workspaces = _normwslist(workspaces) @@ -180,7 +190,22 @@ def _SofQWtitle(workspace, figure): def box2D(xs, vertAxis, horMin=-numpy.inf, horMax=numpy.inf, vertMin=-numpy.inf, vertMax=numpy.inf): - """Return slicing for a 2D numpy array limited by given min and max values.""" + """Return slicing for a 2D numpy array limited by given min and max values. + + :param xs: the 2D X data of a workspace from :func:`mantid.api.MatrixWorkspace.extractX` + :type xs: a 2D :class:`numpy.ndarray` + :param vertAxis: the vertical axis values of a workspace + :type vertAxis: a 1D :class:`numpy.ndarray` + :param horMin: the left edge of the box + :type horMin: float + :param horMax: the right edge of the box + :type horMax: float + :param vertMin: the bottom edge of the box + :type vertMin: float + :param vertMax: the top edge of the box + :type vertMax: float + :returns: a tuple of two :class:`slice` objects, the first one for vertical dimension, the second for horizontal. + """ if len(vertAxis) > xs.shape[0]: vertAxis = _binCentres(vertAxis) horBegin = numpy.argwhere(xs[0, :] >= horMin)[0][0] @@ -190,13 +215,11 @@ def box2D(xs, vertAxis, horMin=-numpy.inf, horMax=numpy.inf, vertMin=-numpy.inf, return slice(vertBegin, vertEnd), slice(horBegin, horEnd) -def configurematplotlib(params): - """Set matplotlib rc parameters from the params dictionary.""" - matplotlib.rcParams.update(params) - - def defaultrcParams(): - """Return a dictionary of directtools default matplotlib rc parameters.""" + """Return a dictionary of directtools default matplotlib rc parameters. + + :returns: a :class:`dict` of default :mod:`matplotlib` rc parameters needed by :mod:`directtools` + """ params = { 'legend.numpoints': 1, 'text.usetex': True, @@ -205,7 +228,23 @@ def defaultrcParams(): def dynamicsusceptibility(workspace, temperature, outputName=None, zeroEnergyEpsilon=1e-6): - """Convert :math:`S(Q,E)` to susceptibility :math:`\chi''(Q,E)`.""" + """Convert :math:`S(Q,E)` to susceptibility :math:`\chi''(Q,E)`. + + #. If the X units are not in DeltaE, the workspace is transposed + #. The Y data in *workspace* is multiplied by :math:`1 - e^{\Delta E / (kT)}` + #. Y data in the bin closest to 0 meV and within -*zeroEnergyEpsilon* < :math:`\Delta E` < *zeroEnergyEpsilon* is set to 0 + #. If the input was transposed, transpose the output as well + + :param workspace: a :math:`S(Q,E)` workspace to convert + :type workspace: :class:`mantid.api.MatrixWorkspace` + :param temperature: temperature in Kelvin + :type temperature: float + :param outputName: name of the output workspace. If :class:`None`, the output will be given some generated name. + :type outputName: str or None + :param zeroEnergyEpsilon: if a bin center is within this value from 0, the bin's value is set to zero. + :type zeroEnergyEpsilon: float + :returns: a :class:`mantid.api.MatrixWorkspace` containing :math:`\chi''(Q,E)` + """ workspace = _normws(workspace) horAxis = workspace.getAxis(0) horUnit = horAxis.getUnit().unitID() @@ -224,13 +263,24 @@ def dynamicsusceptibility(workspace, temperature, outputName=None, zeroEnergyEps return outWS -def mantidsubplotsetup(): - """Return a dict for the matplotlib.pyplot.subplots().""" - return {'projection': 'mantid'} - - def nanminmax(workspace, horMin=-numpy.inf, horMax=numpy.inf, vertMin=-numpy.inf, vertMax=numpy.inf): - """Return min and max intensities of a workspace.""" + """Return min and max intensities of a workspace ignoring NaNs. + + The search region can be limited by *horMin*, *horMax*, *vertMin* and *vertMax*. + + :param workspace: a workspace + :type workspace: :class:`mantid.api.MatrixWorkspace` + :param horMin: the left edge of the search region + :type horMin: float + :param horMax: the right edge of the search region + :type horMax: float + :param vertMin: the bottom edge of the search region + :type vertMin: float + :param vertMax: the top edge of the search region + :type vertMax: float + + :returns: a tuple containing the minimum and maximum + """ workspace = _normws(workspace) xs = workspace.extractX() ys = workspace.extractY() @@ -245,7 +295,26 @@ def nanminmax(workspace, horMin=-numpy.inf, horMax=numpy.inf, vertMin=-numpy.inf def plotconstE(workspaces, E, dE, style='l', keepCutWorkspaces=True): - """Plot line profiles at constant energy.""" + """Plot line profiles at constant energy transfer from :math:`S(Q,E)` workspace. + + Creates cut workspaces using :ref:`algm-LineProfile`, then plots the cuts. A list of workspaces, + constant energy transfers, or cut widths, or any combination thereof can be given as parameters. + + The last entry in the returned tuple is a list of cut workspace names. This will be an empty list + is *keeCutWorkspaces* is set to `False` as the workspaces will not appear in the ADS. + + :param workspaces: a single :math:`S(Q,E)` workspace or list of workspaces to cut + :type workspaces: str, :class:`mantid.api.MatrixWorkspace` or a list thereof + :param E: a constant energy transfer or a :class:`list` thereof + :type E: float or :class:`list` of floats + :param dE: width of the cut or a list of widths + :type dE: float or :class:`list` of floats + :param style: plot style: 'l' for lines, 'm' for markers, 'lm' for both + :type style: str + :param keepCutWorkspaces: whether or not keep the cut workspaces in the ADS + :type keepCutWorkspaces: bool + :returns: A tuple of (:class:`matplotlib.Figure`, :class:`matplotlib.Axes`, a :class:`list` of names) + """ figure, axes, cutWSList = plotcuts('Horizontal', workspaces, E, dE, '$E$', 'meV', style, keepCutWorkspaces) _profiletitle(workspaces, '$E$', 'meV', E, dE, figure) axes.legend() @@ -258,7 +327,26 @@ def plotconstE(workspaces, E, dE, style='l', keepCutWorkspaces=True): def plotconstQ(workspaces, Q, dQ, style='l', keepCutWorkspaces=True): - """Plot line profiles at constant momentum transfer.""" + """Plot line profiles at constant momentum transfer from :math:`S(Q,E)` workspace. + + Creates cut workspaces using :ref:`algm-LineProfile`, then plots the cuts. A list of workspaces, + constant momentum transfers, or cut widths, or any combination thereof can be given as parameters. + + The last entry in the returned tuple is a list of cut workspace names. This will be an empty list + is *keeCutWorkspaces* is set to `False` as the workspaces will not appear in the ADS. + + :param workspaces: a single :math:`S(Q,E)` workspace or list of workspaces to cut + :type workspaces: str, :class:`mantid.api.MatrixWorkspace` or a list thereof + :param Q: a constant momentum transfer or a :class:`list` thereof + :type Q: float or :class:`list` of floats + :param dQ: width of the cut or a list of widths + :type dQ: float or :class:`list` of floats + :param style: plot style: 'l' for lines, 'm' for markers, 'lm' for both + :type style: str + :param keepCutWorkspaces: whether or not keep the cut workspaces in the ADS + :type keepCutWorkspaces: bool + :returns: A tuple of (:class:`matplotlib.Figure`, :class:`matplotlib.Axes`, a :class:`list` of names) + """ figure, axes, cutWSList = plotcuts('Vertical', workspaces, Q, dQ, '$Q$', '\\AA$^{-1}$', style, keepCutWorkspaces) _profiletitle(workspaces, '$Q$', '\\AA$^{-1}$', Q, dQ, figure) axes.legend() @@ -272,7 +360,32 @@ def plotconstQ(workspaces, Q, dQ, style='l', keepCutWorkspaces=True): def plotcuts(direction, workspaces, cuts, widths, quantity, unit, style='l', keepCutWorkspaces=True): - """Cut and plot multiple line profiles.""" + """Cut and plot multiple line profiles. + + Creates cut workspaces using :ref:`algm-LineProfile`, then plots the cuts. A list of workspaces, + cut centres, or cut widths, or any combination thereof can be given as parameters. + + The last entry in the returned tuple is a list of cut workspace names. This will be an empty list + is *keeCutWorkspaces* is set to `False` as the workspaces will not appear in the ADS. + + :param direction: Cut direction. Only ``'Horizontal'`` and ``'Vertical'`` are accepted + :type direction: str + :param workspaces: a single workspace or a list thereof + :type workspaces: str, :class:`mantid.api.MatrixWorkspace` or a :class:`list` thereof + :param cuts: the center of the cut or a list of centers + :type cuts: float or a :class:`list` thereof + :param widths: the width of the cut or a list of widths + :type widths: float or a :class:`list` thereof + :param quantity: name of the physical quantity along which the cut is made, used for legend label + :type quantity: str + :param unit: unit of *quantity* + :type unit: str + :param style: plot style: 'l' for lines, 'm' for markers, 'lm' for both + :type style: str + :param keepCutWorkspaces: whether or not keep the cut workspaces in the ADS + :type keepCutWorkspaces: bool + :returns: A tuple of (:class:`matplotlib.Figure`, :class:`matplotlib.Axes`, a :class:`list` of names) + """ workspaces = _normwslist(workspaces) if not isinstance(cuts, collections.Iterable): cuts = [cuts] @@ -308,7 +421,18 @@ def plotcuts(direction, workspaces, cuts, widths, quantity, unit, style='l', kee def plotprofiles(workspaces, labels=None, style='l'): - """Plot given line profile workspaces.""" + """Plot line profile workspaces. + + Plots the first histograms from given workspaces. + + :param workspaces: a single workspace or a list thereof + :type workspaces: str, :class:`mantid.api.MatrixWorkspace` or a :class:`list` thereof + :param labels: a list of cut labels for the plot legend + :type labels: str, a :class:`list` of strings or None + :param style: plot style: 'l' for lines, 'm' for markers, 'lm' for both + :type style: str + :returns: a tuple of (:mod:`matplotlib.Figure`, :mod:`matplotlib.Axes`) + """ workspaces = _normwslist(workspaces) if not isinstance(labels, collections.Iterable) or isinstance(labels, str): if labels is None: @@ -336,7 +460,26 @@ def plotprofiles(workspaces, labels=None, style='l'): def plotSofQW(workspace, QMin=0., QMax=None, EMin=None, EMax=None, VMin=0., VMax=None, colormap='jet'): - """Plot a 2D plot with given axis limits and return the plotting layer.""" + """Plot a 2D :math:`S(Q,E)` workspace. + + :param workspace: a workspace to plot + :type workspace: str or :class:`mantid.api.MatrixWorkspace` + :param QMin: minimum :math:`Q` to include in the plot + :type QMin: float or None + :param QMax: maximum :math:`Q` to include in the plot + :type QMax: float or None + :param EMin: minimum energy transfer to include in the plot + :type EMin: float or None + :param EMax: maximum energy transfer to include in the plot + :type EMax: float or None + :param VMin: minimum intensity to show on the color bar + :type VMin: float or None + :param VMax: maximum intensity to show on the color bar + :type VMax: float or None + :param colormap: name of the colormap + :type colormap: str + :returns: a tuple of (:mod:`matplotlib.Figure`, :mod:`matplotlib.Axes`) + """ # Accept both workspace names and actual workspaces. workspace = _normws(workspace) isSusceptibility = workspace.YUnit() == 'Dynamic susceptibility' @@ -378,12 +521,28 @@ def plotSofQW(workspace, QMin=0., QMax=None, EMin=None, EMax=None, VMin=0., VMax def subplots(**kwargs): - """Return matplotlib figure and axes.""" - return pyplot.subplots(subplot_kw=mantidsubplotsetup(), **kwargs) + """Return matplotlib figure and axes with Mantid projection. + + The returned figure and axes have the proper projection to plot Mantid workspaces directly. + + :param kwargs: keyword arguments that are directly passed to :func:`matplotlib.pyplot.subplots`. + :type kwargs: dict + :returns: a tuple of (:class:`matplotlib.Figure`, :class:`matplotlib.Axes`) + """ + return pyplot.subplots(subplot_kw=_mantidsubplotsetup(), **kwargs) def validQ(workspace, E=0.0): - """Return a :math:`Q` range at given energy transfer where :math:`S(Q,E)` is defined.""" + """Return a :math:`Q` range at given energy transfer where :math:`S(Q,E)` is defined. + + :math:`S(Q,E)` is undefined when Y = NaN + + :param workspace: A :math:`S(Q,E)` workspace to investigate + :type workspace: str or :class:`mantid.api.MatrixWorkspace` + :param E: energy transfer at which to evaluate the range + :type E: float + :returns: a tuple of (:math:`Q_{min}`, :math:`Q_{max}`) + """ workspace = _normws(workspace) vertBins = workspace.getAxis(1).extractValues() if len(vertBins) > workspace.getNumberHistograms(): @@ -401,7 +560,14 @@ def validQ(workspace, E=0.0): def wsreport(workspace): - """Print some useful information from sample logs.""" + """Print some useful information from sample logs. + + The logs are expected to contain some ILL specific fields. + + :param workspace: a workspace from which to extract the logs + :type workspace: str or :class:`mantid.api.MatrixWorkspace` + :returns: None + """ workspace = _normws(workspace) print(str(workspace)) logs = SampleLogs(workspace) @@ -420,8 +586,27 @@ def wsreport(workspace): class SampleLogs: + """A convenience class to access the sample logs of :class:`mantid.api.MatrixWorkspace`. + + Upon initialization, this class adds the sample logs as data attributes to itself. The + attributes get their names from the logs. Log names containing dots result in nested + log objects. Thus, if a workspace contains logs ``'a'`` and ``'b.c'``: + + .. code:: + + logs = SampleLogs(workspace) + # This is equivalent of calling workspace.run().getProperty('a').value + logs.a + # This is equivalent of calling workspace.run().getProperty('b.c').value + logs.b.c + """ def __init__(self, workspace): - """Transform sample log entries from workspace into attributes of this object.""" + """Initialize a `SampleLogs` object. + Transform sample log entries from workspace into attributes of this object. + + :param workspace: the workspace from which to extract the sample logs + :type workspace: :class:`mantid.api.MatrixWorkspace` + """ class Log: pass workspace = _normws(workspace) @@ -442,4 +627,4 @@ class SampleLogs: # Set default matplotlib rc parameters. -configurematplotlib(defaultrcParams()) +_configurematplotlib(defaultrcParams()) diff --git a/scripts/reduction/instruments/reflectometer/__init__.py b/scripts/reduction/instruments/reflectometer/__init__.py deleted file mode 100644 index e69de29bb2d1d6434b8b29ae775ad8c2e48c5391..0000000000000000000000000000000000000000 diff --git a/scripts/reduction/instruments/reflectometer/data_manipulation.py b/scripts/reduction/instruments/reflectometer/data_manipulation.py deleted file mode 100644 index eac12d1bba57df4c5b05b6976749ca2385996da5..0000000000000000000000000000000000000000 --- a/scripts/reduction/instruments/reflectometer/data_manipulation.py +++ /dev/null @@ -1,226 +0,0 @@ -# pylint: disable=invalid-name -from __future__ import (absolute_import, division, print_function) -import os -from mantid.simpleapi import * - - -def tof_distribution(file_path, callback=None, - range_min=None, range_max=None): - """ - Plot counts as a function of TOF for a given REF_L data file - """ - - print('entering tof_distribution') - - basename = os.path.basename(file_path) - ws_raw = "__%s" % basename - ws = "__TOF_distribution" - - # if not mtd.workspaceExists(ws_raw): - LoadEventNexus(Filename=file_path, OutputWorkspace=ws_raw) - - Rebin(InputWorkspace=ws_raw, OutputWorkspace=ws, Params="0,200,200000") - SumSpectra(InputWorkspace=ws, OutputWorkspace=ws) - - # Get range of TOF where we have data - x = mtd[ws].readX(0) - y = mtd[ws].readY(0) - xmin = x[0] - xmax = None - for i in range(len(y)): - if y[i] == 0.0 and xmax is None: - xmin = x[i] - if y[i] > 0: - xmax = x[i] - - if callback is not None: - from LargeScaleStructures import data_stitching - data_stitching.RangeSelector.connect([ws], callback, - xmin=xmin, xmax=xmax, - range_min=range_min, - range_max=range_max) - - -def _load_entry(entry, ws_output_base, file_path, is_pixel_y, ws_list, tof_min, tof_max, title=""): - # 1D plot - ws_output = "%s %s" % (ws_output_base, title) - - ws = LoadEventNexus(Filename=file_path, NXentryName=entry) - - if ws.getNumberEvents() == 0: - print('No data in entry %s' % entry) - return - - instr_dir = config.getInstrumentDirectory() - - # check date of input file - date = mtd['ws'].getRun().getProperty('run_start').value - nexus_acquisition = date.split('T')[0] - if nexus_acquisition > '2014-10-01': - geo_base_file_x = "REFL_Detector_Grouping_Sum_X_rot.xml" - geo_base_file_y = "REFL_Detector_Grouping_Sum_Y_rot.xml" - else: - geo_base_file_x = "REFL_Detector_Grouping_Sum_X.xml" - geo_base_file_y = "REFL_Detector_Grouping_Sum_Y.xml" - - if is_pixel_y: - grouping_file = os.path.join(instr_dir, "Grouping", geo_base_file_x) - else: - grouping_file = os.path.join(instr_dir, "Grouping", geo_base_file_y) - - GroupDetectors(InputWorkspace=ws, OutputWorkspace=ws_output, MapFile=grouping_file) - ws_output = Transpose(InputWorkspace=ws_output) - - # Copy over the units - ws_list.append(ws_output) - - # 2D plot - output_2d = Rebin(InputWorkspace=ws, Params="%d,200,%d" % (tof_min, tof_max)) - - if is_pixel_y: - grouping_file = os.path.join(instr_dir, "Grouping", "REFL_Detector_Grouping_Sum_X.xml") - output_2d = GroupDetectors(InputWorkspace=output_2d, MapFile=grouping_file) - else: - grouping_file = os.path.join(instr_dir, "Grouping", "REFL_Detector_Grouping_Sum_Y.xml") - output_2d = GroupDetectors(InputWorkspace=output_2d, MapFile=grouping_file) - - return ws_list - - -def counts_vs_pixel_distribution(file_path, is_pixel_y=True, callback=None, - range_min=None, range_max=None, - high_res=True, instrument="REFL", - isPeak=True, - tof_min=None, tof_max=None): - """ - Display counts vs pixel of data or normalization data - - @param isPeak: are we working with peak or with background - - """ - basename = os.path.basename(file_path) - ws_base = "__%s" % basename - - ws_output_base = '' - if instrument == 'REFL': - if isPeak: - type = 'Peak' - else: - type = 'Background' - if is_pixel_y is False: - x_title = "X pixel" - else: - x_title = "Y pixel" - ws_output_base = type + " - " + basename + " - " + x_title - else: - ws_output_base = "Counts vs Y pixel - %s" % basename - x_title = "Y pixel" - if is_pixel_y is False: - ws_output_base = "Counts vs X pixel - %s" % basename - x_title = "X pixel" - - ws_list = [] - - if tof_min is None: - tof_min = 0 - if tof_max is None: - tof_max = 200000 - - if instrument == "REFM": - for p in ['Off_Off', 'On_Off', 'Off_On', 'On_On']: - ws_list = _load_entry(entry="entry-{0}".format(p), ws_output_base=ws_output_base, title=p, - file_path=file_path, is_pixel_y=is_pixel_y, ws_list=ws_list, tof_min=tof_min, - tof_max=tof_max) - else: - ws_list = _load_entry(entry="entry", ws_output_base=ws_output_base, title=p, file_path=file_path, - is_pixel_y=is_pixel_y, ws_list=ws_list, tof_min=tof_min, tof_max=tof_max) - - if callback is not None: - from LargeScaleStructures import data_stitching - data_stitching.RangeSelector.connect(ws_list, callback, - range_min=range_min, - range_max=range_max, - x_title=x_title, - log_scale=True, - ws_output_base=ws_output_base) - - # Estimate peak limits - ws_output = ws_base + '_all' - CloneWorkspace(InputWorkspace=ws_list[0], OutputWorkspace=ws_output) - for i in range(1, len(ws_list)): - Plus(LHSWorkspace=ws_output, RHSWorkspace=ws_list[i], - OutputWorkspace=ws_output) - - x = mtd[ws_output].readX(0) - if not high_res: - Rebin(InputWorkspace=ws_output, OutputWorkspace='__' + ws_output, - Params="0,10,%d" % len(x)) - ws_output = '__' + ws_output - x = mtd[ws_output].readX(0) - y = mtd[ws_output].readY(0) - - n = [] - slope_data = [] - sum = 0.0 - min_id = 0 - max_id = 0 - max_slope = 0 - min_slope = 0 - for i in range(len(y)): - sum += y[i] - n.append(sum) - if i > 0: - slope_data.append(y[i] - y[i - 1]) - if slope_data[i - 1] < min_slope: - min_slope = slope_data[i - 1] - min_id = x[i - 1] - if slope_data[i - 1] > max_slope: - max_slope = slope_data[i - 1] - max_id = x[i - 1] - - sigma = (min_id - max_id) / 2.0 - mean = (min_id + max_id) / 2.0 - return mean - 2 * sigma, mean + 2 * sigma - - -def get_logs(instrument, run): - sangle = 0 - dangle = 0 - dangle0 = 0 - direct_beam_pix = 0 - det_distance = 2.562 - - ws = "__%s_metadata" % run - if instrument == "REFM": - ws = '%s_%s' % (ws, 'Off_Off') - - if not mtd.workspaceExists(ws): - try: - f = FileFinder.findRuns("%s%s" % (instrument, run))[0] - - LoadEventNexus(Filename=f, OutputWorkspace=ws, - NXentryName='entry-Off_Off', MetaDataOnly=True) - except: - pass - - if mtd.workspaceExists(ws): - if mtd[ws].getRun().hasProperty("SANGLE"): - sangle = mtd[ws].getRun().getProperty("SANGLE").value[0] - - if mtd[ws].getRun().hasProperty("DANGLE"): - dangle = mtd[ws].getRun().getProperty("DANGLE").value[0] - - if mtd[ws].getRun().hasProperty("DANGLE0"): - dangle0 = mtd[ws].getRun().getProperty("DANGLE0").value[0] - - if mtd[ws].getRun().hasProperty("DIRPIX"): - direct_beam_pix = mtd[ws].getRun().getProperty("DIRPIX").value[0] - - if mtd[ws].getRun().hasProperty("SampleDetDis"): - det_distance = mtd[ws].getRun().getProperty("SampleDetDis").value[0] / 1000.0 - - return {"SANGLE": sangle, - "DANGLE": dangle, - "DANGLE0": dangle0, - "DIRPIX": direct_beam_pix, - "DET_DISTANCE": det_distance} diff --git a/scripts/reduction/instruments/reflectometer/wks_utility.py b/scripts/reduction/instruments/reflectometer/wks_utility.py deleted file mode 100644 index c1ec57fb120ec996484ceafd75077812bb3bd583..0000000000000000000000000000000000000000 --- a/scripts/reduction/instruments/reflectometer/wks_utility.py +++ /dev/null @@ -1,1999 +0,0 @@ -#pylint: disable=too-many-lines,invalid-name,too-many-arguments, too-many-locals, unused-argument -from __future__ import (absolute_import, division, print_function) -from numpy import zeros, arctan2, arange, shape, sqrt, fliplr, asfarray, mean, sum, NAN -from mantid.simpleapi import * -import math -import os.path -from six.moves import range - -h = 6.626e-34 #m^2 kg s^-1 -m = 1.675e-27 #kg -ref_date = '2014-10-01' #when the detector has been rotated - - -def getSequenceRuns(run_numbers): - """ - This will return the sequence of runs - ex: - input: 10,11,12 - output: 10,11,12 - - input: 10,13-15 - output: 10,13,14,15 - """ - final_list = [] - for _run in run_numbers: - _run = str(_run) - _result = _run.find('-') - if _result == -1: - final_list.append(_run) - else: - _split = _run.split('-') - start = int(_split[0]) - end = int(_split[1]) - _range = arange(end-start+1)+start - for _r in _range: - final_list.append(_r) - return final_list - - -def getProtonCharge(st=None): - """ - Returns the proton charge of the given workspace in picoCoulomb - """ - if st is not None: - mt_run = st.getRun() - proton_charge_mtd_unit = mt_run.getProperty('gd_prtn_chrg').value -# proton_charge = proton_charge_mtd_unit / 2.77777778e-10 - return proton_charge_mtd_unit - return None - - -def getIndex(value, array): - """ - returns the index where the value has been found - """ -# sz = len(array) -# for i in range(sz): -# if value == array[i]: -# return i -# return -1 - return array.searchsorted(value) - - -def getSh(mt, top_tag, bottom_tag): - """ - returns the height and units of the given slit# - """ - mt_run = mt.getRun() - st = mt_run.getProperty(top_tag).value - sb = mt_run.getProperty(bottom_tag).value - sh = math.fabs(float(sb[0]) - float(st[0])) - units = mt_run.getProperty(top_tag).units - return sh, units - - -def getSheight(mt, index): - """ - return the DAS hardware slits height of slits # index - """ - mt_run = mt.getRun() - if index == 2: - isSi = False - try: - tag = 'SiVHeight' - value = mt_run.getProperty(tag).value - isSi = True - except: - tag = 'S2VHeight' - value = mt_run.getProperty(tag).value - return [isSi, value[0]] - else: - tag = 'S1VHeight' - value = mt_run.getProperty(tag).value - - return value[0] - - -def getS1h(mt=None): - """ - returns the height and units of the slit #1 - """ - if mt is not None: -# _h, units = getSh(mt, 's1t', 's1b') - _h = getSheight(mt, 1) - return _h - return None - - -def getS2h(mt=None): - """ - returns the height and units of the slit #2 - """ - if mt is not None: - [isSi, _h] = getSheight(mt, 2) - return [isSi,_h] - return [False, None] - - -def getSwidth(mt, index): - """ - returns the width and units of the given index slits - defined by the DAS hardware - """ - mt_run = mt.getRun() - if index==2: - isSi = False - try: - tag = 'SiHWidth' - value = mt_run.getProperty(tag).value - isSi = True - except: - tag = 'S2HWidth' - value = mt_run.getProperty(tag).value - return [isSi, value[0]] - else: - tag = 'S1HWidth' - value = mt_run.getProperty(tag).value - return value[0] - - -def getSw(mt, left_tag, right_tag): - """ - returns the width and units of the given slits - """ - mt_run = mt.getRun() - sl = mt_run.getProperty(left_tag).value - sr = mt_run.getProperty(right_tag).value - sw = math.fabs(float(sl[0]) - float(sr[0])) - units = mt_run.getProperty(left_tag).units - return sw, units - - -def getS1w(mt=None): - """ - returns the width and units of the slit #1 - """ - if mt is not None: -# _w, units = getSw(mt, 's1l', 's1r') - _w = getSwidth(mt, 1) - return _w - return None - - -def getS2w(mt=None): - """ - returns the width and units of the slit #2 - """ - if mt is not None: - [isSi, _w] = getSwidth(mt, 2) - return [isSi,_w] - return [False,None] - - -def getLambdaValue(mt_name): - """ - return the lambdaRequest value - """ - mt_run = mtd[mt_name].getRun() - _lambda = mt_run.getProperty('LambdaRequest').value - return _lambda - - -def getPixelXPixelY(mt1, maxX=304, maxY=256): - """ - returns the PixelX_vs_PixelY array of the workspace data specified - """ - pixelX_vs_pixelY = zeros((maxY, maxX)) - for x in range(maxX): - for y in range(maxY): - _index = maxY * x + y - _sum = sum(mt1.readY(_index)[:]) - pixelX_vs_pixelY[y, x] = _sum - return pixelX_vs_pixelY - - -def getPixelXPixelYError(mt1): - """ - returns the PixelX_vs_PixelY_error array of the workspace data specified - """ - pixel_error = zeros((256, 304)) - for x in range(304): - for y in range(256): - _index = 256 * x + y - _sum = sum(mt1.readE(_index)[:]) - pixel_error[y, x] = _sum - return pixel_error - - -def getPixelXTOF(mt1, maxX=304, maxY=256): - """ - returns the PixelX_vs_TOF array of the workspace data specified - """ - _init = mt1.readY(0)[:] - pixelX_vs_tof = zeros((maxY, len(_init))) - for x in range(maxX): - for y in range(maxY): - _index = maxY * x + y - _array = mt1.readY(_index)[:] - pixelX_vs_tof[y, :] += _array - return pixelX_vs_tof - - -def findQaxisMinMax(q_axis): - """ - Find the position of the common Qmin and Qmax in - each q array - """ - - nbr_row = shape(q_axis)[0] - nbr_col = shape(q_axis)[1] - q_min = min(q_axis[0]) - q_max = max(q_axis[0]) - - for i in arange(nbr_row - 1) + 1: - _q_min = q_axis[i][-1] - _q_max = q_axis[i][0] - if _q_min > q_min: - q_min = _q_min - if _q_max < q_max: - q_max = _q_max - - #find now the index of those min and max in each row - _q_axis_min_max_index = zeros((nbr_row, 2)) - for i in arange(nbr_row): - for j in arange(nbr_col - 1): - _q = q_axis[i, j] - _q_next = q_axis[i, j + 1] - if (_q >= q_max) and (_q_next <= q_max): - _q_axis_min_max_index[i, 0] = j - if (_q >= q_min) and (_q_next <= q_min): - _q_axis_min_max_index[i, 1] = j - - return _q_axis_min_max_index - - -def cleanup_data(InputWorkspace=None, - OutputWorkspace=None, - maxY=256): - mti = mtd[InputWorkspace] - _tof_axis = mti.readX(0)[:] - nbr_tof = shape(_tof_axis)[0]-1 - - _new_y = zeros((maxY, nbr_tof)) - _new_e = zeros((maxY, nbr_tof)) - for px in range(maxY): - for tof in range(nbr_tof-1): - _y = mti.readY(px)[tof] - if _y != 0: - _e = mti.readE(px)[tof] -# if _y < _e: - if _y < 0 or _y < _e: - _y = 0. - _e = 0. - _new_y[px,tof] = float(_y) - _new_e[px,tof] = float(_e) - - _y_error_axis = _new_e.flatten() - _y_axis = _new_y.flatten() - - CreateWorkspace(OutputWorkspace=OutputWorkspace, - DataX=_tof_axis, - DataY=_y_axis, - DataE=_y_error_axis, - Nspec=maxY, - UnitX="TOF", - ParentWorkspace=mti) - - -def createIntegratedWorkspace(mt1, - fromXpixel, toXpixel, - fromYpixel, toYpixel, - maxX=304, maxY=256, - bCleaning=False): - """ - This creates the integrated workspace over the second pixel range (304 here) and - returns the new workspace handle - """ - - _tof_axis = mt1.readX(0)[:] - - _fromXpixel = min([fromXpixel, toXpixel]) - _toXpixel = max([fromXpixel, toXpixel]) - fromXpixel = _fromXpixel - toXpixel = _toXpixel - - _fromYpixel = min([fromYpixel, toYpixel]) - _toYpixel = max([fromYpixel, toYpixel]) - fromYpixel = _fromYpixel - toYpixel = _toYpixel - - _y_axis = zeros((maxY, len(_tof_axis) - 1)) - _y_error_axis = zeros((maxY, len(_tof_axis) - 1)) - - x_size = toXpixel - fromXpixel + 1 - x_range = arange(x_size) + fromXpixel - - y_size = toYpixel - fromYpixel + 1 - y_range = arange(y_size) + fromYpixel - - for x in x_range: - for y in y_range: - _index = int((maxY) * x + y) - _y_axis[y, :] += mt1.readY(_index)[:] - _y_error_axis[y, :] += ((mt1.readE(_index)[:]) * (mt1.readE(_index)[:])) - - _y_axis = _y_axis.flatten() - _y_error_axis = sqrt(_y_error_axis) - _y_error_axis = _y_error_axis.flatten() - - outputWorkspace = CreateWorkspace(DataX=_tof_axis, - DataY=_y_axis, - DataE=_y_error_axis, - Nspec=maxY, - UnitX="TOF", - ParentWorkspace=mt1.name()) - - return outputWorkspace - - -def convertWorkspaceToQ(ws_data, - fromYpixel, toYpixel, - maxX=304, maxY=256, - cpix=None, - source_to_detector=None, - sample_to_detector=None, - theta=None, - geo_correction=False, - q_binning=None): - """ - This creates the integrated workspace over the second pixel range (304 here) and - returns the new workspace handle - """ - - mt1 = ws_data - _tof_axis = mt1.readX(0)[:] - _fromYpixel = min([fromYpixel, toYpixel]) - _toYpixel = max([fromYpixel, toYpixel]) - fromYpixel = _fromYpixel - toYpixel = _toYpixel - - if geo_correction: - - yrange = arange(toYpixel - fromYpixel + 1) + fromYpixel - _q_axis = convertToRvsQWithCorrection(mt1, - dMD=source_to_detector, - theta=theta, - tof=_tof_axis, - yrange=yrange, - cpix=cpix) - - #find the common Qmin and Qmax values and their index (position) - #in each _q_axis row - _q_axis_min_max_index = findQaxisMinMax(_q_axis) - - #replace the _q_axis of the yrange of interest by the new - #individual _q_axis - y_size = toYpixel - fromYpixel + 1 - y_range = arange(y_size) + fromYpixel - - _y_axis = zeros((y_size, len(_tof_axis) - 1)) - _y_error_axis = zeros((y_size, len(_tof_axis) - 1)) - - #now determine the y_axis - for _q_index in range(y_size): - - _tmp_q_axis = _q_axis[_q_index] - q_axis = _tmp_q_axis[::-1] #reverse the axis (now increasing order) - - _a = yrange[_q_index] - _y_axis_tmp = list(mt1.readY(int(_a))[:]) - _y_error_axis_tmp = list(mt1.readE(int(_a))[:]) - - #keep only the overlap region of Qs - _q_min = _q_axis_min_max_index[_q_index, 0] - if _q_min != 0: - _y_axis_tmp[0:_q_min] = 0 - _y_error_axis_tmp[0:_q_min] = 0 - - _q_max = int(_q_axis_min_max_index[_q_index, 1]) - sz = shape(_y_axis_tmp)[0] - if _q_max != sz: - _index_q_max_range = arange(sz - _q_max) + _q_max - for i in _index_q_max_range: - _y_axis_tmp[i] = 0 - _y_error_axis_tmp[i] = 0 - - _y_axis[_q_index, :] = _y_axis_tmp[::-1] - _y_error_axis[_q_index, :] = _y_error_axis_tmp[::-1] - - x_axis = q_axis.flatten() - y_axis = _y_axis.flatten() - y_error_axis = _y_error_axis.flatten() - - outputWorkspace = CreateWorkspace(DataX=x_axis, - DataY=y_axis, - DataE=y_error_axis, - Nspec=int(y_size), - UnitX="MomentumTransfer", - ParentWorkspace=mt1.name()) - - outputWorkspace.setDistribution(True) - - outputWorkspace = Rebin(InputWorkspace=outputWorkspace, - Params=q_binning) - - else: - - if source_to_detector is not None and theta is not None: - _const = float(4) * math.pi * m * source_to_detector / h - _q_axis = 1e-10 * _const * math.sin(theta) / (_tof_axis * 1e-6) - else: - _q_axis = _tof_axis - print('should not reach this condition !') - - y_size = toYpixel - fromYpixel + 1 - y_range = arange(y_size) + fromYpixel - - _y_axis = zeros((y_size, len(_q_axis) -1 )) - _y_error_axis = zeros((y_size, len(_q_axis) - 1)) - - for y in range(y_size): - - a = y_range[y] - - _tmp_y_axis = mt1.readY(int(a))[:] - _y_axis[int(y), :] = _tmp_y_axis - _tmp_y_error_axis = mt1.readE(int(a))[:] - _y_error_axis[int(y),:] = _tmp_y_error_axis - - _x_axis = _q_axis.flatten() - _y_axis = _y_axis.flatten() - _y_error_axis = _y_error_axis.flatten() - - # reverse order - _x_axis = _x_axis[::-1] - _y_axis = _y_axis[::-1] - _y_error_axis = _y_error_axis[::-1] - - outputWorkspace = CreateWorkspace(DataX=_x_axis, - DataY=_y_axis, - DataE=_y_error_axis, - Nspec=int(y_size), - UnitX="MomentumTransfer", - ParentWorkspace=mt1.name()) - - outputWorkspace.setDistribution(True) - - outputWorkspace = Rebin(InputWorkspace=outputWorkspace, - Params=q_binning) - - return outputWorkspace - - -def create_grouping(workspace=None, xmin=0, xmax=None, filename=".refl_grouping.xml"): - # This should be read from the - npix_x = 304 - npix_y = 256 - if workspace is not None: - if mtd[workspace].getInstrument().hasParameter("number-of-x-pixels"): - npix_x = int(mtd[workspace].getInstrument().getNumberParameter("number-of-x-pixels")[0]) - if mtd[workspace].getInstrument().hasParameter("number-of-y-pixels"): - npix_y = int(mtd[workspace].getInstrument().getNumberParameter("number-of-y-pixels")[0]) - - f = open(filename, 'w') - f.write("<detector-grouping description=\"Integrated over X\">\n") - - if xmax is None: - xmax = npix_x - - for y in range(npix_y): - # index = max_y * x + y - indices = [] - for x in range(xmin, xmax + 1): - indices.append(str(npix_y * x + y)) - - # Detector IDs start at zero, but spectrum numbers start at 1 - # Grouping works on spectrum numbers - indices_str = ','.join(indices) - f.write(" <group name='%d'>\n" % y) - f.write(" <ids val='%s'/>\n" % indices_str) - f.write(" </group>\n") - - f.write("</detector-grouping>\n") - f.close() - - -def angleUnitConversion(value, from_units='degree', to_units='rad'): - """ - This function converts the angle units - """ - - if from_units == to_units: - return value - - from_factor = 1.0 - #convert everything into rad - if from_units == 'degree': - from_factor = 1.745329252e-2 - value_rad = from_factor * value - - if to_units == 'rad': - return value_rad - else: - to_factor = 57.2957795 - return to_factor * value_rad - - -def convertToThetaVsLambda(_tof_axis, - _pixel_axis, - central_pixel, - pixel_size=0.0007, - theta= -1, - dSD= -1, - dMD= -1): - """ - This function converts the pixel/tof array - to theta/lambda - """ - # h = 6.626e-34 #m^2 kg s^-1 - # m = 1.675e-27 #kg - - #convert tof_axis into seconds - _tof_axis = _tof_axis * 1e-6 - - vel_array = dMD / _tof_axis #mm/ms = m/s - _lambda = h / (m * vel_array) #m - _lambda = _lambda * 1e10 #angstroms - - d_vec = (_pixel_axis - central_pixel) * pixel_size - theta_vec = arctan2(d_vec, dSD) + theta - - dico = {'lambda_vec': _lambda, 'theta_vec': theta_vec} - - return dico - - -def convertToRvsQWithCorrection(mt, dMD= -1, theta= -1.0, tof=None, yrange=None, cpix=None): - """ - This function converts the pixel/TOF array to the R(Q) array - using Q = (4.Pi.Mn)/h * L.sin(theta/2)/TOF - with L: distance central_pixel->source - TOF: TOF of pixel - theta: angle of detector - """ - - # h = 6.626e-34 #m^2 kg s^-1 - # m = 1.675e-27 #kg - - sample = mt.getInstrument().getSample() - - maxY = 256 - - dPS_array = zeros(maxY) - for y in range(maxY): - detector = mt.getDetector(y) - dPS_array[y] = sample.getDistance(detector) - - #distance sample->center of detector - dSD = dPS_array[maxY / 2] - - _const = float(4) * math.pi * m * dMD / h - sz_tof = len(tof) - q_array = zeros((len(yrange), sz_tof - 1)) - - for _px in range(len(yrange)): - dangle = ref_beamdiv_correct(cpix, mt, dSD, _px) - - if dangle is not None: - _theta = theta + dangle - else: - _theta = theta - - for t in range(sz_tof - 1): - tof1 = tof[t] - tof2 = tof[t+1] - tofm = (tof1+tof2)/2. - _Q = _const * math.sin(_theta) / (tofm*1e-6) - q_array[_px, t] = _Q * 1e-10 - - return q_array - - -def getQHisto(source_to_detector, theta, tof_array): - _const = float(4) * math.pi * m * source_to_detector / h - sz_tof = len(tof_array) - q_array = zeros(sz_tof) - for t in range(sz_tof): - _Q = _const * math.sin(theta) / (tof_array[t] * 1e-6) - q_array[t] = _Q * 1e-10 - - return q_array - - -def ref_beamdiv_correct(cpix, det_secondary, - pixel_index, - pixel_width = 0.0007, - first_slit_size = None, - last_slit_size = None): - """ - This function calculates the acceptance diagram, determines pixel overlap - and computes the offset to the scattering angle. - """ - - # This is currently set to the same number for both REF_L and REF_M - epsilon = 0.5 * 1.3 * 1.0e-3 - - # Set the center pixel - if cpix is None: - cpix = 133.5 - -# first_slit_size = getSheight(mt, '1') -# last_slit_size = getSheight(mt,'2') - - last_slit_dist = 0.654 #m - slit_dist = 0.885000050068 #m - - first_slit_size = float(first_slit_size) * 0.001 - last_slit_size = float(last_slit_size) * 0.001 - - _y = 0.5 * (first_slit_size + last_slit_size) - _x = slit_dist - gamma_plus = math.atan2(_y, _x) - - _y = 0.5 * (first_slit_size - last_slit_size) - _x = slit_dist - gamma_minus = math.atan2(_y, _x) - - half_last_aperture = 0.5 * last_slit_size - neg_half_last_aperture = -1.0 * half_last_aperture - - last_slit_to_det = last_slit_dist + det_secondary - dist_last_aper_det_sin_gamma_plus = last_slit_to_det * math.sin(gamma_plus) - dist_last_aper_det_sin_gamma_minus = last_slit_to_det * math.sin(gamma_minus) - - #set the delta theta coordinates of the acceptance polygon - accept_poly_x = [] - accept_poly_x.append(-1.0 * gamma_minus) - accept_poly_x.append(gamma_plus) - accept_poly_x.append(gamma_plus) - accept_poly_x.append(gamma_minus) - accept_poly_x.append(-1.0 * gamma_plus) - accept_poly_x.append(-1.0 * gamma_plus) - accept_poly_x.append(accept_poly_x[0]) - - #set the z coordinates of the acceptance polygon - accept_poly_y = [] - accept_poly_y.append(half_last_aperture - dist_last_aper_det_sin_gamma_minus + epsilon) - accept_poly_y.append(half_last_aperture + dist_last_aper_det_sin_gamma_plus + epsilon) - accept_poly_y.append(half_last_aperture + dist_last_aper_det_sin_gamma_plus - epsilon) - accept_poly_y.append(neg_half_last_aperture + dist_last_aper_det_sin_gamma_minus - epsilon) - accept_poly_y.append(neg_half_last_aperture - dist_last_aper_det_sin_gamma_plus - epsilon) - accept_poly_y.append(neg_half_last_aperture - dist_last_aper_det_sin_gamma_plus + epsilon) - accept_poly_y.append(accept_poly_y[0]) - - cur_index = pixel_index - - #set the z band for the pixel - xMinus = (cur_index - cpix - 0.5) * pixel_width - xPlus = (cur_index - cpix + 0.5) * pixel_width - - #calculate the intersection - yLeftCross = -1 - yRightCross = -1 - - xI = accept_poly_x[0] - yI = accept_poly_y[0] - - int_poly_x = [] - int_poly_y = [] - - for i in range(len(accept_poly_x)): - - xF = accept_poly_y[i] - yF = accept_poly_x[i] - - if xI < xF: - - if xI < xMinus and xF > xMinus: - yLeftCross = yI + (yF - yI) * (xMinus - xI) / (xF - xI) - int_poly_x.append(yLeftCross) - int_poly_y.append(xMinus) - - if xI < xPlus and xF >= xPlus: - yRightCross = yI + (yF - yI) * (xPlus - xI) / (xF - xI) - int_poly_x.append(yRightCross) - int_poly_y.append(xPlus) - - else: - - if xF < xPlus and xI >= xPlus: - yRightCross = yI + (yF - yI) * (xPlus - xI) / (xF - xI) - int_poly_x.append(yRightCross) - int_poly_y.append(xPlus) - - if xF < xMinus and xI >= xMinus: - yLeftCross = yI + (yF - yI) * (xMinus - xI) / (xF - xI) - int_poly_x.append(yLeftCross) - int_poly_y.append(xMinus) - - #This catches points on the polygon inside the range of interest - if xF >= xMinus and xF < xPlus: - int_poly_x.append(yF) - int_poly_y.append(xF) - - xI = xF - yI = yF - - if len(int_poly_x) > 2: - int_poly_x.append(int_poly_x[0]) - int_poly_y.append(int_poly_y[0]) - int_poly_x.append(int_poly_x[1]) - int_poly_y.append(int_poly_y[1]) - else: - #Intersection polygon is null, point or line, so has no area - #therefore there is no angle corrction - return None - - #Calculate intersection polygon area - area = calc_area_2D_polygon(int_poly_x, - int_poly_y, - len(int_poly_x) - 2) - - center_of_mass = calc_center_of_mass(int_poly_x, - int_poly_y, - area) - - return center_of_mass - - -def calc_area_2D_polygon(x_coord, y_coord, size_poly): - """ - Calculation of the area defined by the 2D polygon - """ - _range = arange(size_poly) + 1 - area = 0 - for i in _range: - area += (x_coord[i] * (y_coord[i + 1] - y_coord[i - 1])) - return area / 2. - - -def calc_center_of_mass(arr_x, arr_y, A): - """ - Function that calculates the center-of-mass for the given polygon - - @param arr_x: The array of polygon x coordinates - @param arr_y: The array of polygon y coordinates - @param A: The signed area of the polygon - - @return: The polygon center-of-mass - """ - - center_of_mass = 0.0 - SIXTH = 1. / 6. - for j in arange(len(arr_x) - 2): - center_of_mass += (arr_x[j] + arr_x[j + 1]) \ - * ((arr_x[j] * arr_y[j + 1]) - - (arr_x[j + 1] * arr_y[j])) - - if A != 0.0: - return (SIXTH * center_of_mass) / A - else: - return 0.0 - - -def getFieldValue(table, row, column): - _tag_value = table[row][column] - _tag_value_split = _tag_value.split('=') - return _tag_value_split[1] - - -def isWithinPrecisionRange(value_file, value_run, precision): - diff = abs(float(value_file)) - abs(float(value_run)) - if abs(diff) <= precision: - return True - else: - return False - - -def _applySFtoArray(workspace, a, b, a_error, b_error): - """ - This function will create for each x-axis value the corresponding - scaling factor using the formula y=a+bx and - """ - - mt = mtd[workspace] - x_axis = mt.readX(0)[:] - sz = len(x_axis) - x_axis_factors = zeros(sz) - x_axis_factors_error = zeros(sz) - for i in range(sz): - _x_value = float(x_axis[i]) - _factor = _x_value * b + a - x_axis_factors[i] = _factor - _factor_error = _x_value * b_error + a_error - x_axis_factors_error[i] = _factor_error - - #create workspace - CreateWorkspace(OutputWorkspace='sfWorkspace', - DataX=x_axis, - DataY=x_axis_factors, - DataE=x_axis_factors_error, - Nspec=1, - UnitX="TOF") - - Divide(workspace, 'sfWorkspace', workspace) - - return workspace - - -def loadNeXus(runNumbers, type): - """ - will retrieve the data from the runNumbers specify and will - add them or just return the workspace created - """ - - wks_name = '' - if type == 'data': - wks_name = 'ws_event_data' - else: - wks_name = 'ws_event_norm' - - print('-> loading ', type) - if (type == 'data') and len(runNumbers) > 1: - - _list = [] - for _run in runNumbers: - _list.append(str(_run)) - list_run = ','.join(_list) - print('--> working with runs:', str(list_run)) - - _index = 0 - for _run in runNumbers: - - # Find full path to event NeXus data file - try: - data_file = FileFinder.findRuns("REF_L%d" %_run)[0] - except RuntimeError: - msg = "RefLReduction: could not find run %d\n" % _run - msg += "Add your data folder to your User Data Directories in the File menu" - raise RuntimeError(msg) - - if _index == 0: - ws_event_data = LoadEventNexus(Filename=data_file,OutputWorskpace=wks_name) - _index += 1 - else: - tmp = LoadEventNexus(Filename=data_file) - Plus(LHSWorkspace=ws_event_data, - RHSWorkspace=tmp, - OutputWorkspace=wks_name) - DeleteWorkspace(tmp) - else: - - print('--> Working with run: ' + str(runNumbers)) - - try: - data_file = FileFinder.findRuns("REF_L%d" %runNumbers)[0] - except RuntimeError: - msg = "RefLReduction: could not find run %d\n" %runNumbers[0] - msg += "Add your data folder to your User Data Directories in the File menu" - raise RuntimeError(msg) - - ws_event_data = LoadEventNexus(Filename=data_file, OutputWorkspace=wks_name) - - return ws_event_data - - -def rebinNeXus(inputWorkspace, params, type): - """ - will rebin the event workspace according to the params - params[0]: min value - params[1]: bin size - params[2]: max value - """ - print('--> rebin ', type) - ws_histo_data = Rebin(InputWorkspace=inputWorkspace, - Params=params, - PreserveEvents=True) - return ws_histo_data - - -def cropTOF(inputWorkspace, min, max, type): - """ - will crop the nexus (workspace) using min and max value - used here to crop the TOF range - """ - print('--> crop ' , type , ' workspace in TOF') - ws_histo_data = CropWorkspace(InputWorkspace = inputWorkspace, - XMin = min, - XMax = max) - return ws_histo_data - - -def normalizeNeXus(inputWorkspace, type): - """ - normalize nexus by proton charge - """ - print('--> normalize ', type) - ws_histo_data = NormaliseByCurrent(InputWorkspace=inputWorkspace) - return ws_histo_data - - -def integrateOverLowResRange(mt1, - dataLowResRange, - type, - is_nexus_detector_rotated_flag): - """ - This creates the integrated workspace over the low resolution range leaving - us with a [256,nbr TOF] workspace - returns the new workspace handle - BUT this algorithm also makes sure that the error value is 1 when counts - is 0 ! - """ - - print('--> integrated over low res range of ', type) - _tof_axis = mt1.readX(0)[:].copy() -# t_range = arange(nbr_tof-1) - - # -1 to work with index directly - fromXpixel = min(dataLowResRange) - 1 - toXpixel = max(dataLowResRange) - 1 - - if is_nexus_detector_rotated_flag: - sz_y_axis = 304 - else: - sz_y_axis = 256 - - _y_axis = zeros((sz_y_axis, len(_tof_axis) - 1)) - _y_error_axis = zeros((sz_y_axis, len(_tof_axis) - 1)) - - x_size = toXpixel - fromXpixel + 1 - x_range = arange(x_size) + fromXpixel - - y_range = arange(sz_y_axis) - - for x in x_range: - for y in y_range: - _index = int((sz_y_axis) * x + y) - _y_axis[y, :] += mt1.readY(_index)[:].copy() - _tmp_error_axis = mt1.readE(_index)[:].copy() - # 0 -> 1 -# index_where_0 = where(_tmp_error_axis == 0) -# _tmp_error_axis[index_where_0] = 1 - - _y_error_axis[y, :] += _tmp_error_axis * _tmp_error_axis -# _y_error_axis[y, :] += ((mt1.readE(_index)[:]) * (mt1.readE(_index)[:])) - - _y_error_axis = sqrt(_y_error_axis) - - return [_tof_axis, _y_axis, _y_error_axis] - - -def substractBackground(tof_axis, y_axis, y_error_axis, - peakRange, backFlag, backRange, - error_0, type): - """ - shape of y_axis : [sz_y_axis, nbr_tof] - This routine will calculate the background, remove it from the peak - and will return only the range of peak -> [peak_size, nbr_tof] - - """ - - # give a friendly name to peak and back ranges - # -1 because we are working with 0 index arrays - peakMin = peakRange[0]-1 - peakMax = peakRange[1]-1 - backMin = backRange[0]-1 - backMax = backRange[1]-1 - - if not backFlag: - print('---> no ', type, ' background requested!') - return [y_axis[peakMin:peakMax+1,:], y_error_axis[peakMin:peakMax+1,:]] - - print('--> background subtraction of ', type) - - # retrieve data - _tofAxis = tof_axis - nbrTof = len(_tofAxis) - - # size peak - szPeak = peakMax - peakMin + 1 - - # init arrays - final_y_axis = zeros((szPeak, nbrTof)) - final_y_error_axis = zeros((szPeak, nbrTof)) - -# final_y_axis = empty((szPeak, nbrTof)) -# final_y_error_axis = empty((szPeak, nbrTof)) -# final_y_axis[:] = NAN -# final_y_error_axis[:] = NAN - - for t in range(nbrTof): - - # by default, no space for background subtraction below and above peak - bMinBack = False - bMaxBack = False - - if backMin < (peakMin): - bMinBack = True - _backMinArray = y_axis[backMin:peakMin, t] - _backMinErrorArray = y_error_axis[backMin:peakMin, t] - [_backMin, _backMinError] = weightedMean(_backMinArray, - _backMinErrorArray, error_0) - - if (peakMax) < backMax: - bMaxBack = True - _backMaxArray = y_axis[peakMax+1:backMax+1, t] - _backMaxErrorArray = y_error_axis[peakMax+1:backMax+1, t] - [_backMax, _backMaxError] = weightedMean(_backMaxArray, _backMaxErrorArray, error_0) - - # if no max background use min background - if not bMaxBack: - background = _backMin - background_error = _backMinError - - # if no min background use max background - if not bMinBack: - background = _backMax - background_error = _backMaxError - - if bMinBack and bMaxBack: - [background, background_error] = weightedMean([_backMin, _backMax], [_backMinError, _backMaxError], error_0) - - # remove background for each pixel of the peak - for x in range(szPeak): - final_y_axis[x,t] = float(y_axis[peakMin + x,t]) - float(background) - final_y_error_axis[x,t] = float(math.sqrt(pow(y_error_axis[peakMin+x,t],2) + pow(background_error,2))) - -# if t == nbrTof-2: -# print(float(y_axis[peakMin + x,t]) - float(background)) - - return [final_y_axis, final_y_error_axis] - - -def weightedMean(data_array, error_array, error_0): - - sz = len(data_array) - - # calculate the numerator of mean - dataNum = 0 - for i in range(sz): - if error_array[i] == 0: - error_array[i] = error_0 - - tmpFactor = float(data_array[i]) / float((pow(error_array[i],2))) - dataNum += tmpFactor - - # calculate denominator - dataDen = 0 - for i in range(sz): - if error_array[i] == 0: - error_array[i] = error_0 - tmpFactor = 1./float((pow(error_array[i],2))) - dataDen += tmpFactor - - if dataDen == 0: - data_mean = NAN - mean_error = NAN - else: - data_mean = float(dataNum) / float(dataDen) - mean_error = math.sqrt(1/dataDen) - - return [data_mean, mean_error] - - -def weightedMeanOfRange(norm_y_axis, norm_y_error_axis): - """ - will calculate the weighted Mean of the region given - """ - - # get nbr tof - dim = norm_y_axis.shape - nbr_tof = dim[1] - - final_array = zeros(nbr_tof) - final_array_error = zeros(nbr_tof) - - for t in range(nbr_tof): - _tmp_range = norm_y_axis[:, t] - _tmp_range_error = norm_y_error_axis[:,t] - [_mean,_mean_error] = weightedMean(_tmp_range, _tmp_range_error) - final_array[t] = _mean - final_array_error[t] = _mean_error - - return [final_array, final_array_error] - - -def meanOfRange(norm_y_axis, norm_y_error_axis): - """ - will calculate the mean of range - """ - - # get nbr tof - dim = norm_y_axis.shape - nbr_tof = dim[1] - - final_array = zeros(nbr_tof) - final_array_error = zeros(nbr_tof) - - for t in range(nbr_tof): - _tmp_range = norm_y_axis[:,t] - _tmp_range_error = norm_y_error_axis[:,t] - [_mean,_mean_error] = myMean(_tmp_range, _tmp_range_error) - final_array[t] = _mean - final_array_error[t] = _mean_error - - return [final_array, final_array_error] - - -def myMean(data_array, error_array): - - sz=size(data_array) - - _mean = mean(data_array) - _mean_error = sqrt(sum(_mean*_mean))/float(sz[0]) - - return [_mean, _mean_error] - - -def divideDataByNormalization(data_y_axis, - data_y_error_axis, - av_norm, - av_norm_error): - - print('-> divide data by normalization') - - data_size = data_y_axis.shape - nbr_pixel = data_size[0] - nbr_tof = data_size[1] - - new_data_y_axis = zeros((nbr_pixel, nbr_tof)) - new_data_y_error_axis = zeros((nbr_pixel, nbr_tof)) - - for t in range(nbr_tof): - for x in range(nbr_pixel): - - if (av_norm[t] != 0) and (data_y_axis[x, t] != 0): - - tmp_value = float(data_y_axis[x,t]) / float(av_norm[t]) - - tmp_error_1 = pow(float(data_y_error_axis[x,t]) / float(data_y_axis[x,t]),2) - tmp_error_2 = pow(float(av_norm_error[t]) / float(av_norm[t]),2) - tmp_error = sqrt(tmp_error_1 + tmp_error_2) * abs(float(data_y_axis[x,t]) / float(av_norm[t])) - - new_data_y_axis[x,t] = tmp_value - new_data_y_error_axis[x,t] = tmp_error - - return [new_data_y_axis, new_data_y_error_axis] - - -def sumWithError(value, error): - """ will sume the array of values and will return the sum and the - error that goes with it - """ - - sum_value = sum(value) - - tmp_sum_error = 0 - for i in range(len(value)): - tmp_value = pow(error[i],2) - tmp_sum_error += tmp_value - - sum_error = math.sqrt(tmp_sum_error) - - return [sum_value, sum_error] - - -def integratedOverPixelDim(data_y_axis, data_y_error_axis): - - size = data_y_axis.shape - nbr_tof = size[1] - - final_data = zeros(nbr_tof) - final_data_error = zeros(nbr_tof) - for t in range(nbr_tof): - [data, error] = sumWithError(data_y_axis[:,t], data_y_error_axis[:,t]) - final_data[t] = data - final_data_error[t] = error - - return [final_data, final_data_error] - - -def fullSumWithError(data_y_axis, data_y_error_axis): - size = data_y_axis.shape - nbr_tof = size[1] - - final_data = zeros(nbr_tof) - final_data_error = zeros(nbr_tof) -# final_data = empty(nbr_tof) -# final_data_error = empty(nbr_tof) -# final_data[:] = NAN -# final_data_error[:] = NAN - for t in range(nbr_tof): - [data, error] = sumWithError(data_y_axis[:,t], data_y_error_axis[:,t]) - final_data[t] = data - final_data_error[t] = error - - return [final_data, final_data_error] - - -def ouput_ascii_file(file_name, - x_axis, - y_axis, - y_error_axis): - - f=open(file_name,'w') - - sz_x_axis = len(x_axis) - for i in range(sz_x_axis-1): - f.write(str(x_axis[i]) + "," + str(y_axis[i]) + "," + str(y_error_axis[i]) + "\n") - - f.close() - - -def ouput_big_ascii_file(file_name, - x_axis, - y_axis, - y_error_axis): - - f=open(file_name,'w') - - sz = y_axis.shape # (nbr_pixel, nbr_tof) - nbr_tof = sz[1] - nbr_pixel = sz[0] - - for t in range(nbr_tof): - _tmp_str = str(x_axis[t]) - for x in range(nbr_pixel): - _tmp_str += ' ,' + str(y_axis[x,t]) + " ," + str(y_error_axis[x,t]) - - _tmp_str += '\n' - f.write(_tmp_str) - - f.close() - - -def ouput_big_Q_ascii_file(file_name, - x_axis, - y_axis, - y_error_axis): - - f=open(file_name,'w') - - sz = y_axis.shape # (nbr_pixel, nbr_tof) - nbr_tof = sz[1] - nbr_pixel = sz[0] - - for t in range(nbr_tof): - _tmp_str = '' - for x in range(nbr_pixel): - _tmp_str += str(x_axis[x,t]) + ',' + str(y_axis[x,t]) + " ," + str(y_error_axis[x,t]) + ',,' - _tmp_str += '\n' - f.write(_tmp_str) - - f.close() - - -def divideData1DbyNormalization(inte_data_y_axis, - inte_data_y_error_axis, - av_norm, - av_norm_error): - - print('-> divide data by normalization') - - nbrPixel = inte_data_y_axis.shape - - final_data = zeros(nbrPixel) - final_data_error = zeros(nbrPixel) - - for x in range(nbrPixel[0]): - if av_norm[x] != 0: - - final_data[x] = inte_data_y_axis[x] / av_norm[x] - - tmp1 = pow(float(inte_data_y_error_axis[x]) / float(inte_data_y_axis[x]),2) - tmp2 = pow(float(av_norm_error[x]) / float(av_norm[x]),2) - tmp_error = sqrt(tmp1 + tmp2) * (float(inte_data_y_axis[x] / av_norm[x])) - - final_data_error[x] = tmp_error - - return [final_data, final_data_error] - - -def applyScalingFactor(tof_axis, - y_data, - y_data_error, - incident_medium, - sf_file, - valuePrecision, - slitsWidthFlag): - """" - function that apply scaling factor to data using sfCalculator.txt - file created by the sfCalculator procedure - """ - isSFfound = False - - #sf_file = 'NaN' - if os.path.isfile(sf_file): - - print('-> scaling factor file FOUND! (', sf_file, ')') - - #parse file and put info into array - f = open(sf_file, 'r') - sfFactorTable = [] - for line in f.read().split('\n'): - if len(line) > 0 and line[0] != '#': - sfFactorTable.append(line.split(' ')) - f.close() - - sz_table = shape(sfFactorTable) - nbr_row = sz_table[0] - - _incidentMedium = incident_medium.strip() - - _lr = getLambdaValue('ws_event_data') - _lr_value = _lr[0] - _lr_value = float("{0:.2f}".format(_lr_value)) - - #retrieve s1h and s2h or sih values - s1h = getS1h(mtd['ws_event_data']) - [isSih, s2h] = getS2h(mtd['ws_event_data']) - - s1h_value = abs(s1h) - s2h_value = abs(s2h) - - #retrieve s1w and s2w values - s1w = getS1w(mtd['ws_event_data']) - [isSiw, s2w] = getS2w(mtd['ws_event_data']) - - s1w_value = abs(s1w) - s2w_value = abs(s2w) - - print('--> Data Lambda Requested: {0:2f}'.format(_lr_value)) - print('--> Data S1H: {0:2f}'.format(s1h_value)) - if isSih: - print('--> Data SiH: {0:2f}'.format(s2h_value)) - else: - print('--> Data S2H: {0:2f}'.format(s2h_value)) - print('--> Data S1W: {0:2f}'.format(s1w_value)) - if isSiw: - print('--> Data SiW: {0:2f}'.format(s2w_value)) - else: - print('--> Data S2W: {0:2f}'.format(s2w_value)) - - for i in range(nbr_row): - - _file_incidentMedium = getFieldValue(sfFactorTable,i,0) - if _file_incidentMedium.strip() == _incidentMedium.strip(): - print('*** incident medium match ***') - _file_lambdaRequested = getFieldValue(sfFactorTable,i,1) - if (isWithinPrecisionRange(_file_lambdaRequested, - _lr_value, - valuePrecision)): - print('*** lambda requested match ***') - _file_s1h = getFieldValue(sfFactorTable,i,2) - if(isWithinPrecisionRange(_file_s1h, - s1h_value, - valuePrecision)): - print('*** s1h match ***') - _file_s2h = getFieldValue(sfFactorTable,i,3) - if(isWithinPrecisionRange(_file_s2h, - s2h_value, - valuePrecision)): - print('*** s2h match ***') - if slitsWidthFlag: - print('*** (with slits width flag) ***') - _file_s1w = getFieldValue(sfFactorTable,i,4) - if(isWithinPrecisionRange(_file_s1w, - s1w_value, - valuePrecision)): - print('*** s1w match ***') - _file_s2w = getFieldValue(sfFactorTable,i,5) - if(isWithinPrecisionRange(_file_s2w, - s2w_value, - valuePrecision)): - print('*** s2w match ***') - - print('--> Found a perfect match') - a = float(getFieldValue(sfFactorTable,i,6)) - b = float(getFieldValue(sfFactorTable,i,7)) - a_error = float(getFieldValue(sfFactorTable,i,8)) - b_error = float(getFieldValue(sfFactorTable,i,9)) - - [y_data, y_data_error] = applyScalingFactorToArray(tof_axis, - y_data, - y_data_error, - a, b, - a_error, b_error) - - return [tof_axis, y_data, y_data_error, True] - - else: - - print('--> Found a perfect match') - a = float(getFieldValue(sfFactorTable,i,6)) - b = float(getFieldValue(sfFactorTable,i,7)) - a_error = float(getFieldValue(sfFactorTable,i,8)) - b_error = float(getFieldValue(sfFactorTable,i,9)) - - [y_data, y_data_error] = applyScalingFactorToArray(tof_axis, - y_data, - y_data_error, - a, b, - a_error, b_error) - isSFfound = True - - return [tof_axis, y_data, y_data_error, isSFfound] - - else: - - print('-> scaling factor file for requested lambda NOT FOUND!') - return [tof_axis, y_data, y_data_error] - - -def applyScalingFactorToArray(tof_axis, y_data, y_data_error, a, b, a_error, b_error): - """ - This function will create for each x-axis value the corresponding - scaling factor using the formula y=a+bx and - """ - - x_axis = tof_axis - nbr_tof = len(x_axis)-1 - x_axis_factors = zeros(nbr_tof) - x_axis_factors_error = zeros(nbr_tof) -# x_axis_factors = empty(nbr_tof) -# x_axis_factors_error = empty(nbr_tof) -# x_axis_factors[:] = NAN -# x_axis_factors_error[:] = NAN - for i in range(nbr_tof): - _x_value = float(x_axis[i]) - _factor = _x_value * b + a - x_axis_factors[i] = _factor - _factor_error = _x_value * b_error + a_error - x_axis_factors_error[i] = _factor_error - - sz = y_data.shape - nbr_pixel = sz[0] - - final_y_data = zeros((nbr_pixel, nbr_tof)) - final_y_data_error = zeros((nbr_pixel, nbr_tof)) -# final_y_data = empty((nbr_pixel, nbr_tof)) -# final_y_data_error = empty((nbr_pixel, nbr_tof)) -# final_y_data[:] = NAN -# final_y_data_error[:] = NAN - for x in range(nbr_pixel): - - [ratio_array, ratio_array_error] = divideArrays(y_data[x,:], - y_data_error[x,:], - x_axis_factors, - x_axis_factors_error) - - final_y_data[x,:] = ratio_array[:] - final_y_data_error[x,:] = ratio_array_error - - return [final_y_data, final_y_data_error] - - -def divideArrays(num_array, num_error_array, den_array, den_error_array): - """ - This function calculates the ratio of two arrays and calculate the - respective error values - """ - - sz = num_array.shape - nbr_elements = sz[0] - - # calculate the ratio array - ratio_array = zeros(nbr_elements) - for i in range(nbr_elements): - if den_array[i] is 0: - _tmp_ratio = 0 - else: - _tmp_ratio = num_array[i] / den_array[i] - ratio_array[i] = _tmp_ratio - - # calculate the error of the ratio array - ratio_error_array = zeros(nbr_elements) - for i in range(nbr_elements): - - if (num_array[i] == 0) or (den_array[i] == 0): - ratio_error_array[i] = 0 - else: - tmp1 = pow(num_error_array[i] / num_array[i],2) - tmp2 = pow(den_error_array[i] / den_array[i],2) - ratio_error_array[i] = sqrt(tmp1+tmp2)*(num_array[i]/den_array[i]) - - return [ratio_array, ratio_error_array] - - -def getCentralPixel(ws_event_data, dataPeakRange, is_new_geometry): - """ - This function will calculate the central pixel position - """ - - if is_new_geometry: - _maxX = 256 - _maxY = 304 - else: - _maxX = 304 - _maxY = 256 - - pixelXtof_data = getPixelXTOF(ws_event_data, maxX=_maxX, maxY=_maxY) - pixelXtof_1d = pixelXtof_data.sum(axis=1) - # Keep only range of pixels - pixelXtof_roi = pixelXtof_1d[dataPeakRange[0]:dataPeakRange[1]] - sz = pixelXtof_roi.size - _num = 0 - _den = 0 - start_pixel = dataPeakRange[0] - for i in range(sz): - _num += (start_pixel * pixelXtof_roi[i]) - start_pixel = start_pixel + 1 - _den += pixelXtof_roi[i] - data_cpix = _num / _den - print('--> central pixel is {0:.1f}'.format(data_cpix)) - - return data_cpix - - -def getDistances(ws_event_data): - """ - calculates the distance between the moderator and the detector (dMD) - and the distance between the sample and the detector - """ - - print('--> calculating dMD (moderator-detector) and dSD (sample-detector)') - sample = ws_event_data.getInstrument().getSample() - source = ws_event_data.getInstrument().getSource() - dSM = sample.getDistance(source) - - # Create array of distances pixel->sample - dPS_array = zeros((256, 304)) - for x in range(304): - for y in range(256): - _index = 256 * x + y - detector = ws_event_data.getDetector(_index) - dPS_array[y, x] = sample.getDistance(detector) - - # Distance sample->center of detector - dSD = dPS_array[256//2,304//2] - # Distance source->center of detector - dMD = dSD + dSM - - return [dMD, dSD] - - -def getTheta(ws_event_data, angleOffsetDeg): - """ - will calculate the theta angle offset - """ - print('--> retrieving thi and tthd') - mt_run = ws_event_data.getRun() - thi_value = mt_run.getProperty('thi').value[0] - thi_units = mt_run.getProperty('thi').units - tthd_value = mt_run.getProperty('tthd').value[0] - tthd_units = mt_run.getProperty('tthd').units - thi_rad = angleUnitConversion(value=thi_value, - from_units=thi_units, - to_units='rad') - print('---> thi (rad): ', thi_rad) - tthd_rad = angleUnitConversion(value=tthd_value, - from_units=tthd_units, - to_units='rad') - print('---> tthd (rad): ', tthd_rad) - - theta = math.fabs(tthd_rad - thi_rad)/2. - angleOffsetRad = (angleOffsetDeg * math.pi) / 180. - theta += angleOffsetRad - print('---> theta (rad): ', theta) - - return theta - - -def getSlitsSize(mt): - print('---> retrieving slits size') - first_slit_size = getSheight(mt, '1') - last_slit_size = getSheight(mt,'2') - print('----> first_slit_size: ' , first_slit_size) - print('----> last_slit_size: ' , last_slit_size) - return [first_slit_size, last_slit_size] - - -def getQrange(ws_histo_data, theta, dMD, q_min, q_step): - """ - will determine the true q axis according to the qMin and qStep specified - and the geometry of the instrument - """ - print('---> calculating Qrange') - _tof_axis = ws_histo_data.readX(0) - _const = float(4) * math.pi * m * dMD / h - sz_tof = shape(_tof_axis)[0] - _q_axis = zeros(sz_tof-1) - for t in range(sz_tof-1): - tof1 = _tof_axis[t] - tof2 = _tof_axis[t+1] - tofm = (tof1+tof2)/2. - _Q = _const * math.sin(theta) / (tofm*1e-6) - _q_axis[t] = _Q*1e-10 - q_max = max(_q_axis) - if q_min >= q_max: - q_min = min(_q_axis) - print('----> q_min: ', q_min) - print('----> q_step: ', q_step) - print('----> q_max: ', q_max) - - return [q_min, q_step, q_max] - - -def convertToQ(tof_axis, - y_axis, - y_error_axis, - peak_range = None, - central_pixel = None, - source_to_detector_distance = None, - sample_to_detector_distance = None, - theta = None, - first_slit_size = None, - last_slit_size = None): - """ - will convert the tof_axis into q_axis according to q range specified - """ - - y_size = (peak_range[1] - peak_range[0] + 1) - y_range = arange(y_size) + peak_range[0] - _q_axis = getQaxis(source_to_detector_distance, - sample_to_detector_distance, - theta, - tof_axis, - y_range, - central_pixel, - first_slit_size, - last_slit_size) - - _q_axis_min_max_index = findQaxisMinMax(_q_axis) - - # now we need to put the various counts from y_axis into the right - # boxes - _y_axis = zeros((y_size, len(tof_axis)-1)) - _y_error_axis = zeros((y_size, len(tof_axis)-1)) -# _y_axis = empty((y_size, len(tof_axis)-1)) -# _y_error_axis = empty((y_size, len(tof_axis)-1)) -# _y_axis[:] = NAN -# _y_error_axis[:] = NAN - - # now determine the _y_axis and _y_error_axis - for _y_index in range(y_size): - - # get the q_axis of the given peak pixel - _tmp_q_axis = _q_axis[_y_index] - _q_axis = _tmp_q_axis[::-1] #reverse the axis (now in increasing order) - - _y_axis_tmp = y_axis[_y_index,:] - _y_error_axis_tmp = y_error_axis[_y_index,:] - - # keep only the overlap region of Qs - _q_min = _q_axis_min_max_index[_y_index, 0] - if _q_min != 0: - _y_axis_tmp[0:_q_min] = 0 - _y_error_axis_tmp[0:_q_min] = 0 - - _q_max = int(_q_axis_min_max_index[_y_index, 1]) - sz = shape(_y_axis_tmp)[0] - if _q_max != sz: - _index_q_max_range = arange(sz - _q_max) + _q_max - for i in _index_q_max_range: - _y_axis_tmp[i] = 0 - _y_error_axis_tmp[i] = 0 - - _y_axis[_y_index, :] = _y_axis_tmp[::-1] - _y_error_axis[_y_index, :] = _y_error_axis_tmp[::-1] - - # reverse the _q_axis here as well - q_axis_reverse = reverseQAxis(_q_axis) - - return [q_axis_reverse, _y_axis, _y_error_axis] - - -def convertToQWithoutCorrection(tof_axis, - y_axis, - y_error_axis, - peak_range = None, - source_to_detector_distance = None, - sample_to_detector_distance = None, - theta = None, - first_slit_size = None, - last_slit_size = None): - """ - will convert the tof_axis into q_axis according to q range specified - but without using any geometry correction - """ - - _const = float(4) * math.pi * m * source_to_detector_distance / h - _q_axis = 1e-10 * _const * math.sin(theta) / (tof_axis[0:-1] * 1e-6) - - sz = y_axis.shape - nbr_pixel = sz[0] - - sz_q_axis = _q_axis.shape - nbr_q = sz_q_axis[0] - - q_axis_2d = zeros((nbr_pixel, nbr_q)) - for p in range(nbr_pixel): - q_axis_2d[p,:] = _q_axis - - q_axis_reverse = reverseQAxis(q_axis_2d) - y_axis_reverse = fliplr(y_axis) - y_error_axis_reverse = fliplr(y_error_axis) - - return [q_axis_reverse, y_axis_reverse, y_error_axis_reverse] - - -def reverseQAxis(q_axis): - """ - will reverse each q_axis for the respective pixels - """ - new_q_axis = fliplr(q_axis) - return new_q_axis - - -def getQaxis(dMD, dSD, theta, - tof_axis, y_range, central_pixel, - first_slit_size, - last_slit_size): - """ - This function converts the pixel/TOF array to the R(Q) array - using Q = (4.Pi.Mn)/h * L.sin(theta/2)/TOF - with L: distance central_pixel->source - TOF: TOF of pixel - theta: angle of detector - """ - - _const = float(4) * math.pi * m * dMD / h - sz_tof = len(tof_axis) - q_array = zeros((len(y_range), sz_tof)) - - for y in range(len(y_range)): - _px = y_range[y] - dangle = ref_beamdiv_correct(central_pixel, - dSD, - _px, - 0.0007, - first_slit_size, - last_slit_size) - - if dangle is not None: - _theta = theta + dangle - else: - _theta = theta - - for t in range(sz_tof): -# tof1 = tof_axis[t] -# tof2 = tof_axis[t+1] -# tofm = (tof1+tof2)/2. - tof = tof_axis[t] -# _Q = _const * math.sin(_theta) / (tofm*1e-6) - _Q = _const * math.sin(_theta) / (tof*1e-6) - q_array[y, t] = _Q * 1e-10 - - return q_array - - -def integrateOverPeakRange(wks, dataPeakRange): - """ - getting just the mean of the peak - """ - - final_x_axis = wks.readX(0)[:] - sz = final_x_axis.shape - nbr_q = sz[0] - - # make temp big array - nbrPixel = dataPeakRange[1] - dataPeakRange[0] + 1 - bigY = zeros((nbrPixel, nbr_q)) - bigE = zeros((nbrPixel, nbr_q)) -# bigY = empty((nbrPixel, nbr_q)) -# bigE = empty((nbrPixel, nbr_q)) -# bigY[:]= NAN -# bigE[:]= NAN - for x in range(nbrPixel): - _tmp_y = wks.readY(x)[:] - bigY[x,:] = _tmp_y - _tmp_e = wks.readE(x)[:] - bigE[x,:] = _tmp_e - - final_y_axis = zeros(nbr_q) - final_y_error_axis = zeros(nbr_q) -# -# final_y_axis = empty(nbr_q) -# final_y_error_axis = empty(nbr_q) -# final_y_axis[:] = NAN -# final_y_error_axis[:] = NAN - - # range(nbr_q -2) + 1 to get rid of first and last q values (edge effect) - rangeOfQ = arange(nbr_q-1) -# for q in rangeOfQ[1:-1]: - for q in rangeOfQ: - - _tmp_y = bigY[:,q] - _tmp_y_error = bigE[:,q] - -# [_y, _y_error] = myMean(_tmp_y, _tmp_y_error) - [_y, _y_error] = sumWithError(_tmp_y, _tmp_y_error) - - final_y_axis[q] = _y - final_y_error_axis[q] = _y_error - - return [final_x_axis, final_y_axis, final_y_error_axis] - - -def createQworkspace(q_axis, y_axis, y_error_axis): - - sz = q_axis.shape - nbr_pixel = sz[0] - - q_axis_1d = q_axis.flatten() - y_axis_1d = y_axis.flatten() - y_error_axis_1d = y_error_axis.flatten() - - q_workspace = CreateWorkspace(DataX=q_axis_1d, - DataY=y_axis_1d, - DataE=y_error_axis_1d, - Nspec=nbr_pixel, - UnitX="Wavelength") - q_workspace.setDistribution(True) - - return q_workspace - - -def createFinalWorkspace(q_axis, final_y_axis, final_error_axis, name_output_ws, parent_workspace): - - final_workspace = CreateWorkspace(OutputWorkspace=name_output_ws, - DataX=q_axis, - DataY=final_y_axis, - DataE=final_error_axis, - Nspec=1, - UnitX="Wavelength", - ParentWorkspace=parent_workspace) - final_workspace.setDistribution(True) - - return final_workspace - - -def cropAxisToOnlyNonzeroElements(q_rebin, dataPeakRange): - """ - This function will only keep the range of Q that have only nonzero counts - """ - nbrPixel = dataPeakRange[1] - dataPeakRange[0] + 1 - - x_axis = q_rebin.readX(0)[:] - sz = x_axis.shape[0]-1 - - index_first_non_zero_value = sz - index_last_non_zero_value = 0 - - for x in range(nbrPixel): - _pixel_axis = q_rebin.readY(x)[:] - - for t in range(sz): - _value = _pixel_axis[t] - if _value != float(0): - if index_first_non_zero_value > t: - index_first_non_zero_value = t - break - - for t in range(sz-1,-1,-1): - _value = _pixel_axis[t] - if _value != float(0): - if index_last_non_zero_value < t: - index_last_non_zero_value = t - break - - # crop data - new_x_axis = x_axis[index_first_non_zero_value:index_last_non_zero_value+1] - new_xrange = index_last_non_zero_value - index_first_non_zero_value + 1 - - new_y_axis = zeros((nbrPixel, new_xrange)) - new_y_error_axis = zeros((nbrPixel, new_xrange)) -# new_y_axis = empty((nbrPixel, new_xrange)) -# new_y_error_axis = empty((nbrPixel, new_xrange)) -# new_y_axis[:] = NAN -# new_y_error_axis[:] = NAN - - for x in range(nbrPixel): - _tmp = q_rebin.readY(x)[:] - _tmp_E = q_rebin.readE(x)[:] - new_y_axis[x,:] = _tmp[index_first_non_zero_value:index_last_non_zero_value+1] - new_y_error_axis[x,:] = _tmp_E[index_first_non_zero_value:index_last_non_zero_value+1] - - new_y_axis = new_y_axis.flatten() - new_y_error_axis = new_y_error_axis.flatten() - - new_x_axis = asfarray(new_x_axis) - new_y_axis = asfarray(new_y_axis) - new_y_error_axis = asfarray(new_y_error_axis) - - nonzero_q_rebin_wks = CreateWorkspace(DataX=new_x_axis, - DataY=new_y_axis, - DataE=new_y_error_axis, - Nspec=int(nbrPixel), - UnitX="Wavelength") - - return nonzero_q_rebin_wks - - -def cleanupData(final_data_y_axis, final_data_y_error_axis): - - sz = final_data_y_axis.shape - nbrPixel = sz[0] - nbrQ = sz[1] - - for x in range(nbrPixel): - for q in range(nbrQ): - - _data = final_data_y_axis[x,q] - _error = final_data_y_error_axis[x,q] - - # if error is > value, remove point - if _error >= _data: - _data = 0 - _error = 1 - - # if value is below 10^-12 - if _data < 1e-12: - _data = 0 - _error = 1 - - final_data_y_axis[x,q] = _data - final_data_y_error_axis[x,q] = _error - - return [final_data_y_axis, final_data_y_error_axis] - - -def cleanupData1D(final_data_y_axis, final_data_y_error_axis): - - sz = final_data_y_axis.shape - nbrTof = sz[0] - - notYetRemoved = True - - for t in range(nbrTof): - - _data = final_data_y_axis[t] - _error = final_data_y_error_axis[t] - - if _data > 0 and notYetRemoved: - notYetRemoved = False - final_data_y_axis[t] = 0 - final_data_y_error_axis[t] = 1 - continue - - # if error is > value, remove point - if abs(_error) >= abs(_data): - _data_tmp = 0 - _error_tmp = 1 - elif _data< 1e-12: - # if value is below 10^-12 - _data_tmp = 0 - _error_tmp = 1 - else: - _data_tmp = _data - _error_tmp = _error - - final_data_y_axis[t] = _data_tmp - final_data_y_error_axis[t] = _error_tmp - -# print('final_data_y_axis[t]: ' , _data_tmp , ' final_data_y_error_axis[t]: ' , _error_tmp) - - return [final_data_y_axis, final_data_y_error_axis] - - -def isNexusTakeAfterRefDate(nexus_date): - ''' - This function parses the output.date and returns true if this date is after the ref date - ''' - nexus_date_acquistion = nexus_date.split('T')[0] - - if nexus_date_acquistion > ref_date: - return True - else: - return False diff --git a/scripts/test/SANS/algorithm_detail/scale_helper_test.py b/scripts/test/SANS/algorithm_detail/scale_helper_test.py index b69ffc1cc7165aa436e2c5f59dc04ced72b42a40..a12e3902005db32cbec0d94cb698761169fa0141 100644 --- a/scripts/test/SANS/algorithm_detail/scale_helper_test.py +++ b/scripts/test/SANS/algorithm_detail/scale_helper_test.py @@ -7,9 +7,10 @@ from sans.algorithm_detail.scale_helpers import (DivideByVolumeFactory, DivideBy MultiplyByAbsoluteScaleFactory, MultiplyByAbsoluteScaleLOQ, MultiplyByAbsoluteScaleISIS) from sans.common.general_functions import create_unmanaged_algorithm -from sans.common.enums import (SampleShape, SANSFacility, DataType) +from sans.common.enums import (SampleShape, SANSFacility, DataType, SANSInstrument) from sans.state.scale import get_scale_builder from sans.state.data import get_data_builder +from sans.test_helper.file_information_mock import SANSFileInformationMock class ScaleHelperTest(unittest.TestCase): @@ -44,11 +45,13 @@ class ScaleHelperTest(unittest.TestCase): def test_that_divide_uses_settings_from_workspace(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22024, height=8.0, + width=8.0, thickness=1.0, shape=SampleShape.CylinderAxisAlong) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("SANS2D00022024") data_state = data_builder.build() - scale_builder = get_scale_builder(data_state) + scale_builder = get_scale_builder(data_state, file_information) scale_state = scale_builder.build() test_director = TestDirector() @@ -78,11 +81,12 @@ class ScaleHelperTest(unittest.TestCase): def test_that_divide_uses_settings_from_state_if_they_are_set(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("SANS2D00022024") data_state = data_builder.build() - scale_builder = get_scale_builder(data_state) + scale_builder = get_scale_builder(data_state, file_information) width = 10. height = 5. thickness = 2. @@ -123,11 +127,12 @@ class ScaleHelperTest(unittest.TestCase): def test_that_correct_scale_strategy_is_selected_for_loq(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_state = data_builder.build() - scale_builder = get_scale_builder(data_state) + scale_builder = get_scale_builder(data_state, file_information) scale_state = scale_builder.build() test_director = TestDirector() @@ -144,11 +149,12 @@ class ScaleHelperTest(unittest.TestCase): def test_that_correct_scale_strategy_is_selected_for_loq_2(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_state = data_builder.build() - scale_builder = get_scale_builder(data_state) + scale_builder = get_scale_builder(data_state, file_information) scale_builder.set_scale(2.4) scale_state = scale_builder.build() diff --git a/scripts/test/SANS/gui_logic/property_manager_service_test.py b/scripts/test/SANS/gui_logic/property_manager_service_test.py index 97852827cfd8f105b5c8a2bc8ed0c407fd197f8f..1d16ee7bb8075bec02f534cbe644bfb2e888914b 100644 --- a/scripts/test/SANS/gui_logic/property_manager_service_test.py +++ b/scripts/test/SANS/gui_logic/property_manager_service_test.py @@ -9,7 +9,8 @@ from mantid.api import Algorithm from sans.gui_logic.presenter.property_manager_service import PropertyManagerService from sans.state.data import get_data_builder from sans.test_helper.test_director import TestDirector -from sans.common.enums import SANSFacility +from sans.common.enums import SANSFacility, SANSInstrument +from sans.test_helper.file_information_mock import SANSFileInformationMock class FakeAlgorithm(Algorithm): @@ -22,7 +23,8 @@ class FakeAlgorithm(Algorithm): def get_example_state(): ws_name_sample = "SANS2D00022024" - data_builder = get_data_builder(SANSFacility.ISIS) + file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22024) + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter(ws_name_sample) data = data_builder.build() diff --git a/scripts/test/SANS/gui_logic/state_gui_model_test.py b/scripts/test/SANS/gui_logic/state_gui_model_test.py index 4383af9f10d8525a7bf7867b1ba6768ac1698a2e..671cb525f105c9f8c0da7e5f6081e10433f637fd 100644 --- a/scripts/test/SANS/gui_logic/state_gui_model_test.py +++ b/scripts/test/SANS/gui_logic/state_gui_model_test.py @@ -4,6 +4,7 @@ from sans.gui_logic.models.state_gui_model import StateGuiModel from sans.user_file.settings_tags import (OtherId, event_binning_string_values, DetectorId, det_fit_range) from sans.common.enums import (ReductionDimensionality, ISISReductionMode, RangeStepType, SampleShape, SaveType, FitType) +from sans.user_file.settings_tags import (det_fit_range) class StateGuiModelTest(unittest.TestCase): @@ -129,7 +130,7 @@ class StateGuiModelTest(unittest.TestCase): self.assertTrue(state_gui_model.reduction_mode is ISISReductionMode.All) # ------------------------------------------------------------------------------------------------------------------ - # Reduction range + # Merge range # ------------------------------------------------------------------------------------------------------------------ def test_that_merge_mask_is_false_by_default(self): state_gui_model = StateGuiModel({"test": [1]}) @@ -153,6 +154,12 @@ class StateGuiModelTest(unittest.TestCase): state_gui_model.merge_min = 78.9 self.assertTrue(state_gui_model.merge_min == 78.9) + def test_that_merge_range_set_correctly(self): + state_gui_model = StateGuiModel({DetectorId.merge_range: [det_fit_range(use_fit=True, start=0.13, stop=0.15)]}) + self.assertEqual(state_gui_model.merge_min, 0.13) + self.assertEqual(state_gui_model.merge_max, 0.15) + self.assertTrue(state_gui_model.merge_mask) + # ------------------------------------------------------------------------------------------------------------------ # Reduction dimensionality # ------------------------------------------------------------------------------------------------------------------ diff --git a/scripts/test/SANS/state/adjustment_test.py b/scripts/test/SANS/state/adjustment_test.py index 1566c7df76af5d80bd2ba0f548141ef0c7aafd84..28810a487ec83121a4551687edeb4b18bb46452c 100644 --- a/scripts/test/SANS/state/adjustment_test.py +++ b/scripts/test/SANS/state/adjustment_test.py @@ -8,6 +8,7 @@ from sans.state.calculate_transmission import StateCalculateTransmission from sans.state.normalize_to_monitor import StateNormalizeToMonitor from sans.state.wavelength_and_pixel_adjustment import StateWavelengthAndPixelAdjustment from sans.common.enums import (SANSFacility, SANSInstrument, FitType) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -70,7 +71,8 @@ class StateAdjustmentBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/calculate_transmission_test.py b/scripts/test/SANS/state/calculate_transmission_test.py index fdaa2353d9ca575cb5c3e80139e43e6d062b0483..d1a47225e71ad133b2aa41ba548f0316d802fc85 100644 --- a/scripts/test/SANS/state/calculate_transmission_test.py +++ b/scripts/test/SANS/state/calculate_transmission_test.py @@ -5,8 +5,9 @@ import mantid from sans.state.calculate_transmission import (StateCalculateTransmission, StateCalculateTransmissionLOQ, get_calculate_transmission_builder) from sans.state.data import get_data_builder -from sans.common.enums import (RebinType, RangeStepType, FitType, DataType, SANSFacility) +from sans.common.enums import (RebinType, RangeStepType, FitType, DataType, SANSFacility, SANSInstrument) from state_test_helper import assert_validate_error, assert_raises_nothing +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -194,7 +195,8 @@ class StateCalculateTransmissionBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/convert_to_q_test.py b/scripts/test/SANS/state/convert_to_q_test.py index e48c6356ff6d078a04c79859b8091cb298163230..760e90cc93f87c3cb818381d8cb1d543f9608495 100644 --- a/scripts/test/SANS/state/convert_to_q_test.py +++ b/scripts/test/SANS/state/convert_to_q_test.py @@ -4,8 +4,9 @@ import mantid from sans.state.convert_to_q import (StateConvertToQ, get_convert_to_q_builder) from sans.state.data import get_data_builder -from sans.common.enums import (RangeStepType, ReductionDimensionality, SANSFacility) +from sans.common.enums import (RangeStepType, ReductionDimensionality, SANSFacility, SANSInstrument) from state_test_helper import (assert_validate_error, assert_raises_nothing) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -96,7 +97,8 @@ class StateConvertToQBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/data_test.py b/scripts/test/SANS/state/data_test.py index efd45a105e15223a28a0d520f55a7c3125262e56..fcfe9f83d813e8c7f8f3641e4117b605cc1f272d 100644 --- a/scripts/test/SANS/state/data_test.py +++ b/scripts/test/SANS/state/data_test.py @@ -5,6 +5,7 @@ import mantid from sans.state.data import (StateData, get_data_builder) from state_test_helper import (assert_validate_error, assert_raises_nothing) from sans.common.enums import (SANSFacility, SANSInstrument) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -71,9 +72,9 @@ class StateDataBuilderTest(unittest.TestCase): def test_that_data_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - + file_information = SANSFileInformationMock(run_number=74044) # Act - data_builder = get_data_builder(facility) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_builder.set_sample_scatter_period(3) diff --git a/scripts/test/SANS/state/mask_test.py b/scripts/test/SANS/state/mask_test.py index f6ab89fe9330e9c9dc15518cf323512925d1acac..66e0eeb5809c4e0b394fe22b7ad671a30f54ed4f 100644 --- a/scripts/test/SANS/state/mask_test.py +++ b/scripts/test/SANS/state/mask_test.py @@ -6,6 +6,8 @@ from sans.state.mask import (StateMaskSANS2D, get_mask_builder) from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, SANSInstrument, DetectorType) from state_test_helper import (assert_validate_error, assert_raises_nothing) +from sans.test_helper.file_information_mock import SANSFileInformationMock + # ---------------------------------------------------------------------------------------------------------------------- @@ -192,7 +194,8 @@ class StateMaskBuilderTest(unittest.TestCase): def test_that_mask_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_builder.set_sample_scatter_period(3) data_info = data_builder.build() diff --git a/scripts/test/SANS/state/move_test.py b/scripts/test/SANS/state/move_test.py index 3ad2eb2f6e9614ddc26146924c910ea131d51218..1e0d83f55678b8adf7204a7e153c777fb30a0993 100644 --- a/scripts/test/SANS/state/move_test.py +++ b/scripts/test/SANS/state/move_test.py @@ -5,8 +5,9 @@ import mantid from sans.state.move import (StateMoveLOQ, StateMoveSANS2D, StateMoveLARMOR, StateMoveZOOM, StateMove, StateMoveDetector, get_move_builder) from sans.state.data import get_data_builder -from sans.common.enums import (CanonicalCoordinates, SANSFacility, DetectorType) +from sans.common.enums import (CanonicalCoordinates, SANSFacility, DetectorType, SANSInstrument) from state_test_helper import assert_validate_error, assert_raises_nothing +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -115,7 +116,8 @@ class StateMoveBuilderTest(unittest.TestCase): def test_that_state_for_loq_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_builder.set_sample_scatter_period(3) data_info = data_builder.build() @@ -141,7 +143,8 @@ class StateMoveBuilderTest(unittest.TestCase): def test_that_state_for_sans2d_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22048) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("SANS2D00022048") data_info = data_builder.build() @@ -162,7 +165,8 @@ class StateMoveBuilderTest(unittest.TestCase): def test_that_state_for_larmor_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LARMOR, run_number=2260) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LARMOR00002260") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/normalize_to_monitor_test.py b/scripts/test/SANS/state/normalize_to_monitor_test.py index c469e0889056e21fd67b82068d088ee1dea08684..5179ee093fc7ed29c12ad4e9950b23fe16c57b8e 100644 --- a/scripts/test/SANS/state/normalize_to_monitor_test.py +++ b/scripts/test/SANS/state/normalize_to_monitor_test.py @@ -5,8 +5,9 @@ import mantid from sans.state.normalize_to_monitor import (StateNormalizeToMonitor, StateNormalizeToMonitorLOQ, get_normalize_to_monitor_builder) from sans.state.data import get_data_builder -from sans.common.enums import (RebinType, RangeStepType, SANSFacility) +from sans.common.enums import (RebinType, RangeStepType, SANSFacility, SANSInstrument) from state_test_helper import assert_validate_error, assert_raises_nothing +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -87,7 +88,8 @@ class StateReductionBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/reduction_mode_test.py b/scripts/test/SANS/state/reduction_mode_test.py index 02a9fa850214f242b15432cb405ec7ee8bef4501..b353d80f6191a22523c4f3b0f72395f92557b6b5 100644 --- a/scripts/test/SANS/state/reduction_mode_test.py +++ b/scripts/test/SANS/state/reduction_mode_test.py @@ -6,6 +6,7 @@ from sans.state.reduction_mode import (StateReductionMode, get_reduction_mode_bu from sans.state.data import get_data_builder from sans.common.enums import (ISISReductionMode, ReductionDimensionality, FitModeForMerge, SANSFacility, SANSInstrument, DetectorType) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -55,7 +56,8 @@ class StateReductionModeBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/save_test.py b/scripts/test/SANS/state/save_test.py index 00c43c2d7204578196e07ef22369731897a94197..6600fccb61eded891d546e6aeb4e0fac06c5dc1d 100644 --- a/scripts/test/SANS/state/save_test.py +++ b/scripts/test/SANS/state/save_test.py @@ -4,7 +4,8 @@ import mantid from sans.state.save import (get_save_builder) from sans.state.data import (get_data_builder) -from sans.common.enums import (SANSFacility, SaveType) +from sans.common.enums import (SANSFacility, SaveType, SANSInstrument) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -20,7 +21,8 @@ class StateReductionBuilderTest(unittest.TestCase): def test_that_reduction_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/scale_test.py b/scripts/test/SANS/state/scale_test.py index 6fe837552dabe0addb24164e0625220c516f5887..6d259a9dc3326325a9f1b3304a66fea51ed5c6a3 100644 --- a/scripts/test/SANS/state/scale_test.py +++ b/scripts/test/SANS/state/scale_test.py @@ -5,6 +5,8 @@ import mantid from sans.state.scale import get_scale_builder from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, SANSInstrument, SampleShape) +from sans.test_helper.file_information_mock import SANSFileInformationMock + # ---------------------------------------------------------------------------------------------------------------------- @@ -19,12 +21,14 @@ class StateSliceEventBuilderTest(unittest.TestCase): def test_that_slice_event_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() + # Act - builder = get_scale_builder(data_info) + builder = get_scale_builder(data_info, file_information) self.assertTrue(builder) builder.set_scale(1.0) diff --git a/scripts/test/SANS/state/slice_event_test.py b/scripts/test/SANS/state/slice_event_test.py index ef3f3b505df4a6950a07b8cc823978bc99c2b5b1..acda6d552629be91c5307dcf94cb7cefab8f0819 100644 --- a/scripts/test/SANS/state/slice_event_test.py +++ b/scripts/test/SANS/state/slice_event_test.py @@ -6,6 +6,7 @@ from sans.state.slice_event import (StateSliceEvent, get_slice_event_builder) from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, SANSInstrument) from state_test_helper import (assert_validate_error) +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -44,7 +45,8 @@ class StateSliceEventBuilderTest(unittest.TestCase): def test_that_slice_event_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py b/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py index fdcf5508cd7539af32c9b7bdfe8324028ec0ea2f..0d919d34e7cebfab34eddbb8373a4c739081eea4 100644 --- a/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py +++ b/scripts/test/SANS/state/wavelength_and_pixel_adjustment_test.py @@ -7,6 +7,7 @@ from sans.state.wavelength_and_pixel_adjustment import (StateWavelengthAndPixelA from sans.state.data import get_data_builder from sans.common.enums import (RebinType, RangeStepType, DetectorType, SANSFacility, SANSInstrument) from state_test_helper import assert_validate_error, assert_raises_nothing +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -42,7 +43,8 @@ class StateWavelengthAndPixelAdjustmentBuilderTest(unittest.TestCase): def test_that_wavelength_and_pixel_adjustment_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/state/wavelength_test.py b/scripts/test/SANS/state/wavelength_test.py index d38ef564095f9c9734a3c7c948806dc3cb8a02d4..b3a1c2c8769a4c32a48d2bc2aa684695e21b6888 100644 --- a/scripts/test/SANS/state/wavelength_test.py +++ b/scripts/test/SANS/state/wavelength_test.py @@ -6,6 +6,7 @@ from sans.state.wavelength import (StateWavelength, get_wavelength_builder) from sans.state.data import get_data_builder from sans.common.enums import (SANSFacility, SANSInstrument, RebinType, RangeStepType) from state_test_helper import assert_validate_error, assert_raises_nothing +from sans.test_helper.file_information_mock import SANSFileInformationMock # ---------------------------------------------------------------------------------------------------------------------- @@ -44,7 +45,8 @@ class StateSliceEventBuilderTest(unittest.TestCase): def test_that_slice_event_state_can_be_built(self): # Arrange facility = SANSFacility.ISIS - data_builder = get_data_builder(facility) + file_information = SANSFileInformationMock(instrument=SANSInstrument.LOQ, run_number=74044) + data_builder = get_data_builder(facility, file_information) data_builder.set_sample_scatter("LOQ74044") data_info = data_builder.build() diff --git a/scripts/test/SANS/user_file/state_director_test.py b/scripts/test/SANS/user_file/state_director_test.py index ea36086c97394c8947d61c0b92a42f56938a27a7..acfad053ad28bf487ad4260bc9e2ff7cadce3fb9 100644 --- a/scripts/test/SANS/user_file/state_director_test.py +++ b/scripts/test/SANS/user_file/state_director_test.py @@ -6,11 +6,12 @@ import mantid from sans.user_file.state_director import StateDirectorISIS from sans.common.enums import (SANSFacility, ISISReductionMode, RangeStepType, RebinType, DataType, FitType, - DetectorType, SampleShape) + DetectorType, SampleShape, SANSInstrument) from sans.common.configurations import Configurations from sans.state.data import get_data_builder from sans.test_helper.user_file_test_helper import create_user_file, sample_user_file +from sans.test_helper.file_information_mock import SANSFileInformationMock # ----------------------------------------------------------------- @@ -170,12 +171,13 @@ class UserFileStateDirectorISISTest(unittest.TestCase): def test_state_can_be_created_from_valid_user_file_with_data_information(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22024) + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00022024") data_builder.set_sample_scatter_period(3) data_state = data_builder.build() - director = StateDirectorISIS(data_state) + director = StateDirectorISIS(data_state, file_information) user_file_path = create_user_file(sample_user_file) director.set_user_file(user_file_path) @@ -197,12 +199,13 @@ class UserFileStateDirectorISISTest(unittest.TestCase): def test_stat_can_be_crated_from_valid_user_file_and_later_on_reset(self): # Arrange - data_builder = get_data_builder(SANSFacility.ISIS) + file_information = SANSFileInformationMock(instrument=SANSInstrument.SANS2D, run_number=22024) + data_builder = get_data_builder(SANSFacility.ISIS, file_information) data_builder.set_sample_scatter("SANS2D00022024") data_builder.set_sample_scatter_period(3) data_state = data_builder.build() - director = StateDirectorISIS(data_state) + director = StateDirectorISIS(data_state, file_information) user_file_path = create_user_file(sample_user_file) director.set_user_file(user_file_path) diff --git a/scripts/test/SANS/user_file/user_file_parser_test.py b/scripts/test/SANS/user_file/user_file_parser_test.py index 155d9c711af224d7bcab894b66c43a1b8ecfb722..918eec84912c2b7f6bc369638304f4678af530a2 100644 --- a/scripts/test/SANS/user_file/user_file_parser_test.py +++ b/scripts/test/SANS/user_file/user_file_parser_test.py @@ -131,6 +131,20 @@ class DetParserTest(unittest.TestCase): "DeT/ CORR /reAR/SIDE D 12.3": RuntimeError, " DET/CoRR/FRONT/ SidE -i3": RuntimeError} + det_parser = DetParser() + + do_test(det_parser, valid_settings, invalid_settings, self.assertTrue, self.assertRaises) + + def test_that_DET_OVERLAP_option_is_parsed_correctly(self): + valid_settings = {"DET/OVERLAP 0.13 0.15": {DetectorId.merge_range: det_fit_range(start=0.13, stop=0.15, use_fit=True)}, + "DeT/OverLAP 0.13 0.15": {DetectorId.merge_range: det_fit_range(start=0.13, stop=0.15, use_fit=True)} + } + + invalid_settings = {"DET/OVERLAP 0.13 0.15 0.17": RuntimeError, + "DET/OVERLAP 0.13": RuntimeError, + "DET/OVERLAP": RuntimeError, + "DET/OVERLAP 0.13 five": RuntimeError} + det_parser = DetParser() do_test(det_parser, valid_settings, invalid_settings, self.assertTrue, self.assertRaises) diff --git a/scripts/test/SANSReductionStepsUserFileTest.py b/scripts/test/SANSReductionStepsUserFileTest.py index eeb3d709beec5499ad20090cc439986200259fba..b253a6f9c344f6b0dd4cbad9c2b0277337c41d90 100644 --- a/scripts/test/SANSReductionStepsUserFileTest.py +++ b/scripts/test/SANSReductionStepsUserFileTest.py @@ -41,6 +41,70 @@ class SANSReductionStepsUserFileTest(unittest.TestCase): self.assertEqual(None, start_TOF_ROI, 'The start time should not have been set') self.assertEqual(None, end_TOF_ROI, 'The end time should not have been set') + def test_can_parse_DET_OVERLAP_line(self): + # Arrange + line = 'DET/OVERLAP 0.13 0.15' + command_iface.Clean() + command_iface.LOQ() + user_file = reduction_steps.UserFile() + + # Act + user_file.read_line(line = line, reducer = ReductionSingleton()) + merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange + + # Assert + self.assertEqual(merge_Range.q_min, 0.13, 'The q_min should have been read in') + self.assertEqual(merge_Range.q_max, 0.15, 'The q_max should have been read in') + self.assertEqual(merge_Range.q_merge_range, True, 'q_merge_range should be true') + + def test_that_will_not_parse_DET_OVERLAP_with_no_subsequent_commands(self): + # Arrange + line = 'DET/OVERLAP' + command_iface.Clean() + command_iface.LOQ() + user_file = reduction_steps.UserFile() + + # Act + user_file.read_line(line = line, reducer = ReductionSingleton()) + merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange + + # Assert + self.assertEqual(merge_Range.q_min, None, 'The q_min should have been read in') + self.assertEqual(merge_Range.q_max, None, 'The q_max should have been read in') + self.assertEqual(merge_Range.q_merge_range, False, 'q_merge_range should be true') + + def test_that_will_not_parse_DET_OVERLAP_with_one_subsequent_commands(self): + # Arrange + line = 'DET/OVERLAP 0.13' + command_iface.Clean() + command_iface.LOQ() + user_file = reduction_steps.UserFile() + + # Act + user_file.read_line(line = line, reducer = ReductionSingleton()) + merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange + + # Assert + self.assertEqual(merge_Range.q_min, None, 'The q_min should have been read in') + self.assertEqual(merge_Range.q_max, None, 'The q_max should have been read in') + self.assertEqual(merge_Range.q_merge_range, False, 'q_merge_range should be true') + + def test_that_will_not_parse_DET_OVERLAP_with_three_subsequent_commands(self): + # Arrange + line = 'DET/OVERLAP 0.13 0.15 0.17' + command_iface.Clean() + command_iface.LOQ() + user_file = reduction_steps.UserFile() + + # Act + user_file.read_line(line=line, reducer=ReductionSingleton()) + merge_Range = ReductionSingleton().instrument.getDetector('FRONT').mergeRange + + # Assert + self.assertEqual(merge_Range.q_min, None, 'The q_min should have been read in') + self.assertEqual(merge_Range.q_max, None, 'The q_max should have been read in') + self.assertEqual(merge_Range.q_merge_range, False, 'q_merge_range should be true') + class MockConvertTOQISISQResolution(object): def __init__(self): super(MockConvertTOQISISQResolution, self).__init__() diff --git a/scripts/test/directtools/DirectToolsTest.py b/scripts/test/directtools/DirectToolsTest.py index 82b22d58bd8813f4e2ab5c4f6f68ceb6ad932c7b..a1877a98dcc3f476ce0b0ccd153783290a6c093d 100644 --- a/scripts/test/directtools/DirectToolsTest.py +++ b/scripts/test/directtools/DirectToolsTest.py @@ -56,7 +56,7 @@ class DirectTest(unittest.TestCase): def test_configurematplotlib(self): defaultParams = directtools.defaultrcParams() - directtools.configurematplotlib(defaultParams) + directtools._configurematplotlib(defaultParams) for key in defaultParams: self.assertTrue(key in matplotlib.rcParams) self.assertEqual(matplotlib.rcParams[key], defaultParams[key]) @@ -98,7 +98,7 @@ class DirectTest(unittest.TestCase): self.assertEqual(outEs[2], 0.) def test_mantidsubplotsetup(self): - result = directtools.mantidsubplotsetup() + result = directtools._mantidsubplotsetup() self.assertEqual(result, {'projection': 'mantid'}) def _nanminmaxSetup(self):