Commit f6697520 authored by Dimitar Tasev's avatar Dimitar Tasev
Browse files

Merge master

parent 1edabd41
[flake8]
ignore = E114,E115,E116,E12,E13,E2,E3,F403,F405,F999
ignore = E114,E115,E116,E121,E123,E126,E133,E2,E704,W503,F403,F405,F999
exclude =
buildconfig,
docs,
......
......@@ -34,6 +34,23 @@ set_property(CACHE CPACK_PACKAGE_SUFFIX PROPERTY STRINGS nightly unstable "") #e
#Set package name here
set ( CPACK_PACKAGE_NAME "mantid${CPACK_PACKAGE_SUFFIX}" )
###########################################################################
# Set ParaView information since later items depend on it
###########################################################################
# VATES flag. Requires ParaView
set ( MAKE_VATES OFF CACHE BOOL "Switch for compiling the Vates project")
if ( ENABLE_MANTIDPLOT AND MAKE_VATES )
find_package( ParaView )
if( ParaView_FOUND )
add_definitions ( -DMAKE_VATES )
# Poco::File throws an exception when a backslash is used.
string ( REPLACE "\\" "/" ParaView_DIR ${ParaView_DIR} )
endif ()
endif ()
if ( ENABLE_MANTIDPLOT )
include ( ParaViewSetup )
endif ()
###########################################################################
# Bootstrap any dependencies
###########################################################################
......@@ -69,13 +86,6 @@ endif ()
find_package(TBB REQUIRED)
###########################################################################
# Set ParaView information since later items depend on it
###########################################################################
if (ENABLE_MANTIDPLOT)
include ( ParaViewSetup )
endif ()
# We probably don't want this to run on every build.
option(COVERALLS "Generate coveralls data" OFF)
......@@ -129,16 +139,6 @@ set( DOCS_BUILDDIR ${CMAKE_BINARY_DIR}/docs )
set ( CXXTEST_SINGLE_LOGFILE CACHE BOOL "Switch to have the tests for each package run together")
set ( CXXTEST_ADD_PERFORMANCE OFF CACHE BOOL "Switch to add Performance tests to the list of tests run by ctest?")
# VATES flag. Requires ParaView
set ( MAKE_VATES OFF CACHE BOOL "Switch for compiling the Vates project")
if (ENABLE_MANTIDPLOT AND MAKE_VATES )
find_package(ParaView)
if(ParaView_FOUND)
add_definitions ( -DMAKE_VATES )
endif()
endif()
add_subdirectory ( Framework )
include_directories ( Framework/Kernel/inc )
......@@ -323,7 +323,7 @@ if ( ENABLE_CPACK )
"python-pycifrw (>= 4.2.1)" )
set ( PERFTOOLS_DEB_PACKAGE "libgoogle-perftools4 (>= 1.7)" )
if( "${UNIX_CODENAME}" STREQUAL "xenial")
list ( APPEND DEPENDS_LIST ", libnexus0v5 (>= 4.3),libjsoncpp1,libqscintilla2-12v5, libmuparser2v5,libqwtplot3d-qt4-0v5,libgsl2,liboce-foundation10,liboce-modeling10")
list ( APPEND DEPENDS_LIST ", libhdf5-cpp-11,libnexus0v5 (>= 4.3),libjsoncpp1,libqscintilla2-12v5, libmuparser2v5,libqwtplot3d-qt4-0v5,libgsl2,liboce-foundation10,liboce-modeling10")
list (REMOVE_ITEM DEPENDS_LIST "libjsoncpp0 (>=0.7.0)," "libqscintilla2-11," "libmuparser2," "libnexus0 (>= 4.3)," "libqwtplot3d-qt4-0," "libgsl0ldbl," "liboce-foundation8,liboce-modeling8,")
endif()
# parse list to string required for deb package
......
......@@ -27,6 +27,7 @@ set ( SRC_FILES
src/CostFunctionFactory.cpp
src/DataProcessorAlgorithm.cpp
src/DeprecatedAlgorithm.cpp
src/DetectorInfo.cpp
src/DomainCreatorFactory.cpp
src/EnabledWhenWorkspaceIsType.cpp
src/EqualBinSizesValidator.cpp
......@@ -98,6 +99,7 @@ set ( SRC_FILES
src/MultiPeriodGroupWorker.cpp
src/MultipleExperimentInfos.cpp
src/MultipleFileProperty.cpp
src/NearestNeighbourInfo.cpp
src/NotebookBuilder.cpp
src/NotebookWriter.cpp
src/NullCoordTransform.cpp
......@@ -178,6 +180,7 @@ set ( INC_FILES
inc/MantidAPI/DataProcessorAlgorithm.h
inc/MantidAPI/DeclareUserAlg.h
inc/MantidAPI/DeprecatedAlgorithm.h
inc/MantidAPI/DetectorInfo.h
inc/MantidAPI/DllConfig.h
inc/MantidAPI/DomainCreatorFactory.h
inc/MantidAPI/EnabledWhenWorkspaceIsType.h
......@@ -280,6 +283,7 @@ set ( INC_FILES
inc/MantidAPI/MultiPeriodGroupWorker.h
inc/MantidAPI/MultipleExperimentInfos.h
inc/MantidAPI/MultipleFileProperty.h
inc/MantidAPI/NearestNeighbourInfo.h
inc/MantidAPI/NotebookBuilder.h
inc/MantidAPI/NotebookWriter.h
inc/MantidAPI/NullCoordTransform.h
......@@ -343,6 +347,7 @@ set ( TEST_FILES
CoordTransformTest.h
CostFunctionFactoryTest.h
DataProcessorAlgorithmTest.h
DetectorInfoTest.h
EnabledWhenWorkspaceIsTypeTest.h
EqualBinSizesValidatorTest.h
ExperimentInfoTest.h
......@@ -391,6 +396,7 @@ set ( TEST_FILES
MultiPeriodGroupWorkerTest.h
MultipleExperimentInfosTest.h
MultipleFilePropertyTest.h
NearestNeighbourInfoTest.h
NotebookBuilderTest.h
NotebookWriterTest.h
NumericAxisTest.h
......
#ifndef MANTID_API_ALGORITHMHASPROPERTY_H_
#define MANTID_API_ALGORITHMHASPROPERTY_H_
//------------------------------------------------------------------------------
// Includes
//------------------------------------------------------------------------------
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/TypedValidator.h"
namespace Mantid {
namespace API {
//------------------------------------------------------------------------------
// Forward declaration
//------------------------------------------------------------------------------
class IAlgorithm;
/**
......@@ -46,25 +40,11 @@ class IAlgorithm;
class MANTID_API_DLL AlgorithmHasProperty
: public Kernel::TypedValidator<boost::shared_ptr<IAlgorithm>> {
public:
/// Constructor
AlgorithmHasProperty(const std::string &propName);
/**
* Get a string representation of the type
* @returns A string containing the validator type
*/
inline std::string getType() const { return "AlgorithmHasProperty"; }
/// Make a copy of the present type of validator
inline Kernel::IValidator_sptr clone() const override {
return boost::make_shared<AlgorithmHasProperty>(*this);
}
std::string getType() const;
Kernel::IValidator_sptr clone() const override;
protected:
/**
* Checks the value based on the validator's rules
* @param value :: The input algorithm to check
* @returns An error message to display to users or an empty string on no
* error
*/
std::string
checkValidity(const boost::shared_ptr<IAlgorithm> &value) const override;
......
......@@ -2,12 +2,15 @@
#define MANTID_API_AXIS_H_
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/Unit.h"
#include "MantidGeometry/IDTypes.h"
#include <boost/shared_ptr.hpp>
#include <string>
namespace Mantid {
namespace Kernel {
class Unit;
}
namespace API {
//----------------------------------------------------------------------
// Forward declaration
......@@ -54,11 +57,12 @@ public:
const std::string &title() const;
std::string &title();
const Kernel::Unit_sptr &unit() const;
Kernel::Unit_sptr &unit();
const boost::shared_ptr<Kernel::Unit> &unit() const;
boost::shared_ptr<Kernel::Unit> &unit();
/// Set the unit on the Axis
virtual const Kernel::Unit_sptr &setUnit(const std::string &unitName);
virtual const boost::shared_ptr<Kernel::Unit> &
setUnit(const std::string &unitName);
/// Returns true is the axis is a Spectra axis
virtual bool isSpectra() const { return false; }
......@@ -110,7 +114,7 @@ private:
/// The user-defined title for this axis
std::string m_title;
/// The unit for this axis
Kernel::Unit_sptr m_unit;
boost::shared_ptr<Kernel::Unit> m_unit;
};
} // namespace API
......
#ifndef MANTID_API_DETECTORINFO_H_
#define MANTID_API_DETECTORINFO_H_
#include "MantidAPI/DllConfig.h"
#include "MantidKernel/Quat.h"
#include "MantidKernel/V3D.h"
#include <boost/shared_ptr.hpp>
#include <mutex>
#include <unordered_map>
#include <vector>
namespace Mantid {
using detid_t = int32_t;
namespace Geometry {
class IComponent;
class IDetector;
class Instrument;
class ParameterMap;
}
namespace API {
class SpectrumInfo;
/** API::DetectorInfo is an intermediate step towards a DetectorInfo that is
part of Instrument-2.0. The aim is to provide a nearly identical interface
such that we can start refactoring existing code before the full-blown
implementation of Instrument-2.0 is available.
DetectorInfo provides easy access to commonly used parameters of individual
detectors, such as mask and monitor flags, L1, L2, and 2-theta.
This class is thread safe with OpenMP BUT NOT WITH ANY OTHER THREADING LIBRARY
such as Poco threads or Intel TBB.
@author Simon Heybrock
@date 2016
Copyright &copy; 2016 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_API_DLL DetectorInfo {
public:
DetectorInfo(boost::shared_ptr<const Geometry::Instrument> instrument,
Geometry::ParameterMap *pmap = nullptr);
bool isMonitor(const size_t index) const;
bool isMasked(const size_t index) const;
double l2(const size_t index) const;
double twoTheta(const size_t index) const;
double signedTwoTheta(const size_t index) const;
Kernel::V3D position(const size_t index) const;
Kernel::Quat rotation(const size_t index) const;
void setPosition(const size_t index, const Kernel::V3D &position);
void setRotation(const size_t index, const Kernel::Quat &rotation);
void setPosition(const Geometry::IComponent &comp, const Kernel::V3D &pos);
void setRotation(const Geometry::IComponent &comp, const Kernel::Quat &rot);
// This does not really belong into DetectorInfo, but it seems to be useful
// while Instrument-2.0 does not exist.
Kernel::V3D sourcePosition() const;
Kernel::V3D samplePosition() const;
double l1() const;
const std::vector<detid_t> &detectorIDs() const;
/// Returns the index of the detector with the given detector ID.
size_t indexOf(const detid_t id) const { return m_detIDToIndex.at(id); }
friend class SpectrumInfo;
private:
const Geometry::IDetector &getDetector(const size_t index) const;
boost::shared_ptr<const Geometry::IDetector>
getDetectorPtr(const size_t index) const;
void setCachedDetector(
size_t index,
boost::shared_ptr<const Geometry::IDetector> detector) const;
const Geometry::IComponent &getSource() const;
const Geometry::IComponent &getSample() const;
void cacheSource() const;
void cacheSample() const;
// These cache init functions are not thread-safe! Use only in combination
// with std::call_once!
void doCacheSource() const;
void doCacheSample() const;
void cacheL1() const;
Geometry::ParameterMap *m_pmap;
boost::shared_ptr<const Geometry::Instrument> m_instrument;
std::vector<detid_t> m_detectorIDs;
std::unordered_map<detid_t, size_t> m_detIDToIndex;
// The following variables are mutable, since they are initialized (cached)
// only on demand, by const getters.
mutable boost::shared_ptr<const Geometry::IComponent> m_source;
mutable boost::shared_ptr<const Geometry::IComponent> m_sample;
mutable bool m_sourceGood{false};
mutable bool m_sampleGood{false};
mutable Kernel::V3D m_sourcePos;
mutable Kernel::V3D m_samplePos;
mutable double m_L1;
mutable std::once_flag m_sourceCached;
mutable std::once_flag m_sampleCached;
mutable std::once_flag m_L1Cached;
mutable std::vector<boost::shared_ptr<const Geometry::IDetector>>
m_lastDetector;
mutable std::vector<size_t> m_lastIndex;
};
} // namespace API
} // namespace Mantid
#endif /* MANTID_API_DETECTORINFO_H_ */
......@@ -2,8 +2,6 @@
#define MANTID_API_EXPERIMENTINFO_H_
#include "MantidAPI/DllConfig.h"
#include "MantidAPI/Run.h"
#include "MantidAPI/Sample.h"
#include "MantidAPI/SpectraDetectorTypes.h"
#include "MantidGeometry/IDetector.h"
......@@ -15,20 +13,20 @@
#include <mutex>
namespace Mantid {
//---------------------------------------------------------------------------
// Forward declaration
//---------------------------------------------------------------------------
namespace Kernel {
class Property;
}
namespace Geometry {
class ParameterMap;
class XMLInstrumentParameter;
}
namespace API {
//---------------------------------------------------------------------------
// Forward declaration
//---------------------------------------------------------------------------
class ChopperModel;
class DetectorInfo;
class ModeratorModel;
class Run;
class Sample;
/** This class is shared by a few Workspace types
* and holds information related to a particular experiment/run:
......@@ -43,7 +41,7 @@ public:
/// Default constructor
ExperimentInfo();
/// Virtual destructor
virtual ~ExperimentInfo() = default;
virtual ~ExperimentInfo();
/// Copy constructor
ExperimentInfo(const ExperimentInfo &);
/// Copy everything from the given experiment object
......@@ -55,7 +53,7 @@ public:
virtual const std::string toString() const;
/// Instrument accessors
virtual void setInstrument(const Geometry::Instrument_const_sptr &instr);
void setInstrument(const Geometry::Instrument_const_sptr &instr);
/// Returns the parameterized instrument
virtual Geometry::Instrument_const_sptr getInstrument() const;
......@@ -161,7 +159,13 @@ public:
static std::string getInstrumentFilename(const std::string &instrumentName,
const std::string &date = "");
const DetectorInfo &detectorInfo() const;
DetectorInfo &mutableDetectorInfo();
protected:
/// Called when instrument or parameter map is reset to notify child classes.
virtual void invalidateInstrumentReferences() const {}
/// Description of the source object
boost::shared_ptr<ModeratorModel> m_moderatorModel;
/// Description of the choppers for this experiment.
......@@ -200,6 +204,9 @@ private:
det2group_map m_detgroups;
/// Mutex to protect against cow_ptr copying
mutable std::recursive_mutex m_mutex;
mutable std::unique_ptr<DetectorInfo> m_detectorInfo;
mutable std::mutex m_detectorInfoMutex;
};
/// Shared pointer to ExperimentInfo
......
......@@ -50,6 +50,13 @@ Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL Expression {
public:
/// Specialised exception for parsing errors
class ParsingError : public std::runtime_error {
public:
ParsingError(const std::string &msg, const std::string &expr, size_t i);
ParsingError(const std::string &msg);
};
/// Default contructor
Expression();
/// contructor
......
#ifndef MANTID_API_IMDWORKSPACE_H_
#define MANTID_API_IMDWORKSPACE_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/IMDWorkspace.h"
#include "MantidAPI/ITableWorkspace_fwd.h"
#include "MantidAPI/MDGeometry.h"
#include "MantidAPI/Workspace.h"
#include "MantidGeometry/MDGeometry/IMDDimension.h"
#include "MantidGeometry/MDGeometry/MDImplicitFunction.h"
#include "MantidKernel/SpecialCoordinateSystem.h"
#include <cstdarg>
#include <cstdint>
#include <vector>
namespace Mantid {
namespace Geometry {
class MDImplicitFunction;
}
namespace API {
class IMDIterator;
......
#ifndef MANTID_API_MATRIXWORKSPACE_H_
#define MANTID_API_MATRIXWORKSPACE_H_
#ifndef Q_MOC_RUN
#include <boost/scoped_ptr.hpp>
#endif
#include <mutex>
#include "MantidAPI/DllConfig.h"
#include "MantidAPI/ExperimentInfo.h"
......@@ -17,8 +15,6 @@ namespace Mantid {
//----------------------------------------------------------------------------
namespace Geometry {
class ParameterMap;
class INearestNeighbours;
class INearestNeighboursFactory;
}
namespace API {
......@@ -33,9 +29,6 @@ typedef boost::shared_ptr<MantidImage> MantidImage_sptr;
/// shared pointer to const MantidImage
typedef boost::shared_ptr<const MantidImage> MantidImage_const_sptr;
/// Helper for MatrixWorkspace::spectrumInfo()
enum class ThreadedContextCheck { Check, Skip };
//----------------------------------------------------------------------
/** Base MatrixWorkspace Abstract Class.
......@@ -89,8 +82,8 @@ public:
/// String description of state
const std::string toString() const override;
const SpectrumInfo &spectrumInfo(
ThreadedContextCheck contextCheck = ThreadedContextCheck::Check) const;
const SpectrumInfo &spectrumInfo() const;
SpectrumInfo &mutableSpectrumInfo();
/**@name Instrument queries */
//@{
......@@ -100,29 +93,6 @@ public:
//@}
void populateInstrumentParameters() override;
/** @name Nearest neighbours */
/// Build and populate the NearestNeighbours object
void buildNearestNeighbours(const bool ignoreMaskedDetectors = false) const;
/// Causes the nearest neighbours map to be rebuilt
void rebuildNearestNeighbours();
/// Query the NearestNeighbours object for a detector
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(const Geometry::IDetector *comp, const double radius = 0.0,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum number using a
/// search radius
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighbours(specnum_t spec, const double radius,
const bool ignoreMaskedDetectors = false) const;
/// Query the NearestNeighbours object for a given spectrum number using the
/// direct number of nearest neighbours
std::map<specnum_t, Mantid::Kernel::V3D>
getNeighboursExact(specnum_t spec, const int nNeighbours,
const bool ignoreMaskedDetectors = false) const;
//@}
virtual void updateSpectraUsing(const SpectrumDetectorMapping &map);
/// Build the default spectra mapping, most likely wanted after an instrument
/// update
......@@ -562,8 +532,7 @@ protected:
/// Protected copy constructor. May be used by childs for cloning.
MatrixWorkspace(const MatrixWorkspace &other);
MatrixWorkspace(
Mantid::Geometry::INearestNeighboursFactory *nnFactory = nullptr);
MatrixWorkspace();
/// Initialises the workspace. Sets the size and lengths of the arrays. Must
/// be overloaded.
......@@ -574,6 +543,8 @@ protected:
/// could allow the X values to be changed.
void invalidateCommonBinsFlag() { m_isCommonBinsFlagSet = false; }
void invalidateInstrumentReferences() const override;
/// A vector of pointers to the axes for this workspace
std::vector<Axis *> m_axes;
......@@ -590,7 +561,7 @@ private:
const MantidImage &image, size_t start, bool parallelExecution);
/// Has this workspace been initialised?
bool m_isInitialized;
bool m_isInitialized{false};
/// The unit for the data values (e.g. Counts)
std::string m_YUnit;
......@@ -599,9 +570,9 @@ private:
/// Flag indicating whether the m_isCommonBinsFlag has been set. False by
/// default
mutable bool m_isCommonBinsFlagSet;
mutable bool m_isCommonBinsFlagSet{false};
/// Flag indicating whether the data has common bins. False by default
mutable bool m_isCommonBinsFlag;
mutable bool m_isCommonBinsFlag{false};
/// The set of masked bins in a map keyed on workspace index
std::map<int64_t, MaskList> m_masks;
......@@ -611,16 +582,9 @@ private:
boost::shared_ptr<MatrixWorkspace> m_monitorWorkspace;
mutable std::unique_ptr<SpectrumInfo> m_spectrumInfo;
mutable std::mutex m_spectrumInfoMutex;
protected:
/// Scoped pointer to NearestNeighbours factory
boost::scoped_ptr<Mantid::Geometry::INearestNeighboursFactory>
m_nearestNeighboursFactory;
/// Shared pointer to NearestNeighbours object
mutable boost::shared_ptr<Mantid::Geometry::INearestNeighbours>
m_nearestNeighbours;
/// Getter for the dimension id based on the axis.
std::string getDimensionIdFromAxis(const int &axisIndex) const;
};
......
#ifndef MANTID_GEOMETRY_NEARESTNEIGHBOURSFACTORY_H_
#define MANTID_GEOMETRY_NEARESTNEIGHBOURSFACTORY_H_
#ifndef MANTID_API_NEARESTNEIGHBOURINFO_H_
#define MANTID_API_NEARESTNEIGHBOURINFO_H_
#include "MantidGeometry/Instrument/INearestNeighboursFactory.h"
#include "MantidAPI/DllConfig.h"
#include "MantidGeometry/Instrument/NearestNeighbours.h"
namespace Mantid {
namespace Geometry {
namespace API {
/** NearestNeighboursFactory : Implementation of INearestNeighbours factory
returning a NearestNeighbours object upon create.
class MatrixWorkspace;
@date 2011-11-24
/** NearestNeighbourInfo provides easy access to nearest-neighbour information
for a workspace.
Copyright &copy; 2011 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
Copyright &copy; 2016 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
......@@ -33,21 +33,25 @@ namespace Geometry {
File change history is stored at: <https://github.com/mantidproject/mantid>
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_GEOMETRY_DLL NearestNeighboursFactory
: public INearestNeighboursFactory {
class MANTID_API_DLL NearestNeighbourInfo {
public:
/// Factory Method
NearestNeighbours *create(boost::shared_ptr<const Instrument> instrument,