15#include <Poco/NObserver.h>
62 : m_dimensions(), m_originalWorkspaces(), m_origin(), m_transforms_FromOriginal(), m_transforms_ToOriginal(),
72 m_dimensions = std::vector<std::shared_ptr<IMDDimension>>{};
82 std::vector<Mantid::Geometry::IMDDimension_sptr> dimensions;
83 for (
size_t d = 0;
d < other.getNumDims();
d++) {
85 auto dim = std::make_shared<MDHistoDimension>(other.getDimension(
d).get());
86 dimensions.emplace_back(dim);
91 std::vector<CoordTransform_const_sptr>::const_iterator it;
92 for (it = other.m_transforms_FromOriginal.begin(); it != other.m_transforms_FromOriginal.end(); ++it) {
99 for (it = other.m_transforms_ToOriginal.begin(); it != other.m_transforms_ToOriginal.end(); ++it) {
109 for (
size_t i = 0; i < other.m_originalWorkspaces.size(); i++)
153 [](
const auto &dimension) { return !dimension->getIsIntegrated(); });
163 throw std::runtime_error(
"Workspace does not have a dimension at that index.");
173 auto dimension = std::find_if(
175 [&
id](
const std::shared_ptr<const Mantid::Geometry::IMDDimension> &dim) { return dim->getDimensionId() == id; });
179 throw std::invalid_argument(
"Dimension tagged " +
id +
" was not found in the Workspace");
190 [](
const auto &dimension) { return !dimension->getIsIntegrated(); });
191 return vecCollapsedDimensions;
197 std::vector<coord_t> out;
199 out.emplace_back(this->getDimension(
d)->getBinWidth());
214 throw std::runtime_error(
"Dimension named '" + name +
"' was not found in the IMDWorkspace.");
228 throw std::runtime_error(
"Dimension with id '" +
id +
"' was not found in the IMDWorkspace.");
242 m_dimensions.emplace_back(std::shared_ptr<Mantid::Geometry::IMDDimension>(dim));
249 throw std::runtime_error(
"Workspace does not have any dimensions!");
256 throw std::runtime_error(
"Workspace does not have a Y dimension.");
263 throw std::runtime_error(
"Workspace does not have a Z dimension.");
270 throw std::runtime_error(
"Workspace does not have a T dimension.");
282 throw std::invalid_argument(
"getBasisVector(): invalid index");
293 throw std::invalid_argument(
"getBasisVector(): invalid index");
304 throw std::invalid_argument(
"getBasisVector(): invalid index");
342 throw std::runtime_error(
"MDGeometry::getOriginalWorkspace() invalid index.");
379 throw std::invalid_argument(
"MDGeometry::transformDimensions(): "
380 "scaling.size() must be equal to number of "
383 throw std::invalid_argument(
"MDGeometry::transformDimensions(): "
384 "offset.size() must be equal to number of "
391 dim->setRange(dim->getNBins(), min, max);
393 dim->setRange(dim->getNBins(), max, min);
414 if (original == deleted) {
435 throw std::runtime_error(
"MDGeometry::getTransformFromOriginal(): invalid index.");
471 throw std::runtime_error(
"MDGeometry::getTransformFromOriginal(): invalid index.");
501 const size_t nDimensions = this->
getNumDims();
502 for (
size_t i = 0; i < nDimensions; i++) {
506 if (nDimensions > 0) {
509 if (nDimensions > 1) {
512 if (nDimensions > 2) {
515 if (nDimensions > 3) {
519 return xmlBuilder.
create();
std::map< DeltaEMode::Type, std::string > index
std::string getName(const IMDDimension &self)
MDGeometryNotificationHelper(MDGeometry &parent)
~MDGeometryNotificationHelper()
Poco::NObserver< MDGeometryNotificationHelper, WorkspacePreDeleteNotification > m_delete_observer
Poco delete notification observer object.
void deleteNotificationReceived(Mantid::API::WorkspacePreDeleteNotification_ptr notice)
bool m_observingDelete
Set to True when the m_delete_observer is observing workspace deletions.
void watchForWorkspaceDeletions()
Describes the geometry (i.e.
Kernel::DblMatrix m_Wtransf
the matrix which transforms momentums from orthogonal Q-system to Orthogonal HKL or non-orthogonal HK...
Mantid::API::CoordTransform const * getTransformFromOriginal(size_t index=0) const
Get the Coordinate Transformation that goes from the original workspace to this workspace's coordinat...
void initGeometry(const std::vector< std::shared_ptr< Geometry::IMDDimension > > &dimensions)
Initialize the geometry.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getTDimension() const
Get the t-dimension mapping.
std::vector< Mantid::Kernel::VMD > m_basisVectors
Vector of the basis vector (in the original workspace) for each dimension of this workspace.
virtual ~MDGeometry()
Destructor.
size_t getNumberTransformsToOriginal() const
Get the number of transforms defined to the original coordinate system.
std::vector< std::shared_ptr< const Mantid::API::CoordTransform > > m_transforms_FromOriginal
Coordinate Transformation that goes from the original workspace to this workspace's coordinates.
Mantid::Kernel::VMD m_origin
Vector of the origin (in the original workspace) that corresponds to 0,0,0... in this workspace.
bool allBasisNormalized() const
virtual std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimension(size_t index) const
Get a dimension.
void addDimension(const std::shared_ptr< Mantid::Geometry::IMDDimension > &dim)
Add a dimension.
void transformDimensions(std::vector< double > &scaling, std::vector< double > &offset)
Transform the dimensions contained in this geometry x' = x*scaling + offset.
std::vector< std::shared_ptr< const Geometry::IMDDimension > > getNonIntegratedDimensions() const
Get non-collapsed dimensions.
void clearTransforms()
Clear transforms.
void setOriginalWorkspace(std::shared_ptr< Workspace > ws, size_t index=0)
Set the "original" workspace (the workspace that was the source for a binned MDWorkspace).
size_t getDimensionIndexById(const std::string &id) const
Get the index of the dimension that matches the ID given.
virtual std::shared_ptr< const Mantid::Geometry::IMDDimension > getDimensionWithId(std::string id) const
Get a dimension.
size_t numOriginalWorkspaces() const
void setBasisVector(size_t index, const Mantid::Kernel::VMD &vec)
Set the basis vector (in the original workspace) for a dimension of this workspace.
std::vector< std::shared_ptr< Geometry::IMDDimension > > m_dimensions
Vector of the dimensions used, in the order X Y Z t, etc.
virtual size_t getNumDims() const
void clearOriginalWorkspaces()
Clear original workspaces.
virtual size_t getNumNonIntegratedDims() const
std::vector< std::shared_ptr< const Mantid::API::CoordTransform > > m_transforms_ToOriginal
Coordinate Transformation that goes from this workspace's coordinates to the original workspace coord...
Mantid::API::CoordTransform const * getTransformToOriginal(size_t index=0) const
Get the Coordinate Transformation that goes from THIS workspace's coordinates to the ORIGINAL workspa...
bool hasOriginalWorkspace(size_t index=0) const
void setTransformFromOriginal(Mantid::API::CoordTransform *transform, size_t index=0)
Sets the Coordinate Transformation that goes from the original workspace to this workspace's coordina...
virtual std::vector< coord_t > estimateResolution() const
void setTransformToOriginal(Mantid::API::CoordTransform *transform, size_t index=0)
Sets the Coordinate Transformation that goes from THIS workspace's coordinates to the ORIGINAL worksp...
std::string getGeometryXML() const
std::shared_ptr< Workspace > getOriginalWorkspace(size_t index=0) const
Get the "original" workspace (the workspace that was the source for a binned MDWorkspace).
void deleteNotificationReceived(const std::shared_ptr< const Workspace > &deleted)
Function called when observer objects recieves a notification.
Mantid::Kernel::VMD & getBasisVector(size_t index)
Get the basis vector (in the original workspace) for a dimension of this workspace.
MDGeometry & operator=(const MDGeometry &other)
size_t getDimensionIndexByName(const std::string &name) const
Get the index of the dimension that matches the name given.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getXDimension() const
Get the x-dimension mapping.
std::vector< std::shared_ptr< Workspace > > m_originalWorkspaces
Pointer to the original workspace(s), if this workspace is a coordinate transformation from an origin...
size_t getNumberTransformsFromOriginal() const
Get the number of transforms defined from the original coordinate system.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getYDimension() const
Get the y-dimension mapping.
std::shared_ptr< const Mantid::Geometry::IMDDimension > getZDimension() const
Get the z-dimension mapping.
std::unique_ptr< MDGeometryNotificationHelper > m_notificationHelper
Helper that deals with notifications and observing the ADS.
The class describes one dimension of multidimensional dataset representing an orthogonal dimension an...
bool addXDimension(const IMDDimension_const_sptr &dimension) const
Add x dimension.
bool addZDimension(const IMDDimension_const_sptr &dimension) const
Add z dimension.
bool addYDimension(const IMDDimension_const_sptr &dimension) const
Add y dimension.
bool addTDimension(const IMDDimension_const_sptr &dimension) const
Add t dimension.
const std::string & create() const
Create the xml.
bool addOrdinaryDimension(IMDDimension_const_sptr dimensionToAdd) const
Add a dimension that is neither considered x, y, z or t.
static T & Instance()
Return a reference to the Singleton instance, creating it if it does not already exist Creation is do...
const Poco::AutoPtr< Mantid::Kernel::DataService< Mantid::API::Workspace >::PreDeleteNotification > & WorkspacePreDeleteNotification_ptr
std::shared_ptr< const CoordTransform > CoordTransform_const_sptr
std::shared_ptr< IMDDimension > IMDDimension_sptr
Shared Pointer for IMDDimension. Frequently used type in framework.
std::vector< IMDDimension_const_sptr > VecIMDDimension_const_sptr
Vector of constant shared pointers to IMDDimensions.
float coord_t
Typedef for the data type to use for coordinate axes in MD objects such as MDBox, MDEventWorkspace,...