Skip to content

Commit

Permalink
Merge remote branch 'origin/master' into iteration33. Refs #4472.
Browse files Browse the repository at this point in the history
Conflicts:
	Code/Mantid/Framework/API/CMakeLists.txt
	Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
  • Loading branch information
peterfpeterson committed Feb 3, 2012
2 parents fbe4ba0 + 81897a0 commit a6e911a
Show file tree
Hide file tree
Showing 104 changed files with 3,851 additions and 1,113 deletions.
4 changes: 2 additions & 2 deletions Code/Mantid/Build/CMake/VersionNumber.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Set the version number here for MantidVersion and the package filenames

set ( VERSION_MAJOR 1 )
set ( VERSION_MAJOR 2 )

# The minor version number is the iteration number
set ( VERSION_MINOR 32 )
set ( VERSION_MINOR 0 )
4 changes: 4 additions & 0 deletions Code/Mantid/Framework/API/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ set ( SRC_FILES
src/MultipleExperimentInfos.cpp
src/MultipleFileProperty.cpp
src/NumericAxis.cpp
src/NullCoordTransform.cpp
src/PairedGroupAlgorithm.cpp
src/ParamFunction.cpp
src/ParameterReference.cpp
src/ParameterTie.cpp
Expand Down Expand Up @@ -171,6 +173,8 @@ set ( INC_FILES
inc/MantidAPI/MultipleExperimentInfos.h
inc/MantidAPI/MultipleFileProperty.h
inc/MantidAPI/NumericAxis.h
inc/MantidAPI/NullCoordTransform.h
inc/MantidAPI/PairedGroupAlgorithm.h
inc/MantidAPI/ParamFunction.h
inc/MantidAPI/ParameterReference.h
inc/MantidAPI/ParameterTie.h
Expand Down
11 changes: 8 additions & 3 deletions Code/Mantid/Framework/API/inc/MantidAPI/CoordTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace API
/// Pure abstract methods to be implemented
virtual std::string toXMLString() const = 0;
virtual void apply(const coord_t * inputVector, coord_t * outVector) const = 0;
virtual CoordTransform * clone() const = 0;

/// Wrapper for VMD
Mantid::Kernel::VMD applyVMD(const Mantid::Kernel::VMD & inputVector) const;
Expand All @@ -44,9 +45,13 @@ namespace API
/// @return the number of output dimensions
size_t getOutD() const
{ return outD; };
//
// /// Compound the transformation by appending another one after this one.
// virtual void compound(CoordTransform * other) = 0;

/// @return the affine matrix equivalent to this transformation, if possible
/// @throw std::runtime_error if there is no possible affine matrix
virtual Mantid::Kernel::Matrix<coord_t> makeAffineMatrix() const
{
throw std::runtime_error("This coordinate transformation does not have an equivalent affine matrix.");
}

protected:
/// Input number of dimensions
Expand Down
21 changes: 20 additions & 1 deletion Code/Mantid/Framework/API/inc/MantidAPI/IMDWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ namespace Mantid

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
};


/** Basic MD Workspace Abstract Class.
*
* This defines the interface that allows one to iterate through several types of workspaces:
Expand Down Expand Up @@ -79,13 +93,18 @@ namespace Mantid
}

//-------------------------------------------------------------------------------------------
/// Returns the (normalized) signal at a given coordinates
/// Returns the signal (normalized by volume) at a given coordinates
/// @param coords :: coordinate as a VMD vector
signal_t getSignalAtCoord(const Mantid::Kernel::VMD & coords) const
{
return this->getSignalAtCoord(coords.getBareArray());
}

/// Method to generate a line plot through a MD-workspace
virtual void getLinePlot(const Mantid::Kernel::VMD & start, const Mantid::Kernel::VMD & end,
Mantid::API::MDNormalization normalize, std::vector<coord_t> & x, std::vector<signal_t> & y, std::vector<signal_t> & e) const = 0;

virtual ~IMDWorkspace();
};

/// Shared pointer to the IMDWorkspace base class
Expand Down
23 changes: 12 additions & 11 deletions Code/Mantid/Framework/API/inc/MantidAPI/MDGeometry.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,13 +80,14 @@ namespace API
void setBasisVector(size_t index, const Mantid::Kernel::VMD & vec);

// --------------------------------------------------------------------------------------------
bool hasOriginalWorkspace() const;
boost::shared_ptr<Workspace> getOriginalWorkspace() const;
void setOriginalWorkspace(boost::shared_ptr<Workspace> ws);
Mantid::API::CoordTransform * getTransformFromOriginal() const;
void setTransformFromOriginal(Mantid::API::CoordTransform * transform);
Mantid::API::CoordTransform * getTransformToOriginal() const;
void setTransformToOriginal(Mantid::API::CoordTransform * transform);
bool hasOriginalWorkspace(size_t index=0) const;
size_t numOriginalWorkspaces() const;
boost::shared_ptr<Workspace> getOriginalWorkspace(size_t index=0) const;
void setOriginalWorkspace(boost::shared_ptr<Workspace> ws, size_t index=0);
Mantid::API::CoordTransform * getTransformFromOriginal(size_t index=0) const;
void setTransformFromOriginal(Mantid::API::CoordTransform * transform, size_t index=0);
Mantid::API::CoordTransform * getTransformToOriginal(size_t index=0) const;
void setTransformToOriginal(Mantid::API::CoordTransform * transform, size_t index=0);

void transformDimensions(std::vector<double> & scaling, std::vector<double> & offset);

Expand All @@ -113,8 +114,8 @@ namespace API
/// Vector of the dimensions used, in the order X Y Z t, etc.
std::vector<Mantid::Geometry::IMDDimension_sptr> m_dimensions;

/// Pointer to the original workspace, if this workspace is a coordinate transformation from an original workspace.
boost::shared_ptr<Workspace> m_originalWorkspace;
/// Pointer to the original workspace(s), if this workspace is a coordinate transformation from an original workspace.
std::vector<boost::shared_ptr<Workspace> > m_originalWorkspaces;

/// Vector of the basis vector (in the original workspace) for each dimension of this workspace.
std::vector<Mantid::Kernel::VMD> m_basisVectors;
Expand All @@ -123,10 +124,10 @@ namespace API
Mantid::Kernel::VMD m_origin;

/// Coordinate Transformation that goes from the original workspace to this workspace's coordinates.
Mantid::API::CoordTransform * m_transformFromOriginal;
std::vector<Mantid::API::CoordTransform *> m_transforms_FromOriginal;

/// Coordinate Transformation that goes from this workspace's coordinates to the original workspace coordinates.
Mantid::API::CoordTransform * m_transformToOriginal;
std::vector<Mantid::API::CoordTransform *> m_transforms_ToOriginal;

/// Poco delete notification observer object
Poco::NObserver<MDGeometry, Mantid::API::WorkspacePreDeleteNotification> m_delete_observer;
Expand Down
5 changes: 5 additions & 0 deletions Code/Mantid/Framework/API/inc/MantidAPI/MatrixWorkspace.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "MantidNexusCPP/NeXusFile.hpp"
#include <boost/scoped_ptr.hpp>

using Mantid::API::MDNormalization;

namespace Mantid
{
//----------------------------------------------------------------------------
Expand Down Expand Up @@ -278,6 +280,9 @@ namespace Mantid
/// Dimensin id for y-dimension.
static const std::string yDimensionId;

virtual void getLinePlot(const Mantid::Kernel::VMD & start, const Mantid::Kernel::VMD & end,
Mantid::API::MDNormalization normalize, std::vector<coord_t> & x, std::vector<signal_t> & y, std::vector<signal_t> & e) const;

void saveSpectraMapNexus(::NeXus::File * file, const std::vector<int>& spec,
const ::NeXus::NXcompression compression = ::NeXus::LZW) const;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
#ifndef MANTID_VATES_API_NULL_COORD_TRANSFORM_H
#define MANTID_VATES_API_NULL_COORD_TRANSFORM_H
#ifndef MANTIDAPI_NULLCOORDTRANSFORM_H
#define MANTIDAPI_NULLCOORDTRANSFORM_H

#include "MantidAPI/CoordTransform.h"

namespace Mantid
{
namespace VATES
namespace API
{

/** NullCoordTransform : A transform that sets the outVector to have the same values as the inputVector.
Expand All @@ -21,6 +21,7 @@ namespace Mantid
virtual ~NullCoordTransform();
std::string toXMLString() const;
void apply(const Mantid::coord_t * inputVector, Mantid::coord_t * outVector) const;
virtual CoordTransform * clone() const;

private:
/// Number of dimensions.
Expand All @@ -30,4 +31,4 @@ namespace Mantid
}
}

#endif
#endif
102 changes: 68 additions & 34 deletions Code/Mantid/Framework/API/src/MDGeometry.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ namespace API
/** Constructor
*/
MDGeometry::MDGeometry() :
m_originalWorkspace(),
m_transformFromOriginal(NULL), m_transformToOriginal(NULL),
m_originalWorkspaces(),
m_transforms_FromOriginal(), m_transforms_ToOriginal(),
m_delete_observer(*this, &MDGeometry::deleteNotificationReceived),
m_observingDelete(false)
{
Expand Down Expand Up @@ -52,10 +52,10 @@ namespace API
*/
MDGeometry::~MDGeometry()
{
if (m_transformFromOriginal)
delete m_transformFromOriginal;
if (m_transformToOriginal)
delete m_transformToOriginal;
for (size_t i=0; i<m_transforms_FromOriginal.size(); i++)
delete m_transforms_FromOriginal[i];
for (size_t i=0; i<m_transforms_ToOriginal.size(); i++)
delete m_transforms_ToOriginal[i];
if (m_observingDelete)
{
// Stop watching once object is deleted
Expand Down Expand Up @@ -250,21 +250,39 @@ namespace API

//---------------------------------------------------------------------------------------------------
/// @return true if the geometry is defined relative to another workspace.
bool MDGeometry::hasOriginalWorkspace() const
/// @param index :: index into the vector of original workspaces
bool MDGeometry::hasOriginalWorkspace(size_t index) const
{
if (index >= m_originalWorkspaces.size())
return false;
return bool(m_originalWorkspaces[index]);
}

/// @return the number of original workspaces attached to this one
size_t MDGeometry::numOriginalWorkspaces() const
{
return bool(m_originalWorkspace);
return m_originalWorkspaces.size();
}


//---------------------------------------------------------------------------------------------------
/// @return the original workspace to which the basis vectors relate
boost::shared_ptr<Workspace> MDGeometry::getOriginalWorkspace() const
/// @param index :: index into the vector of original workspaces
boost::shared_ptr<Workspace> MDGeometry::getOriginalWorkspace(size_t index) const
{
return m_originalWorkspace;
if (index >= m_originalWorkspaces.size())
throw std::runtime_error("MDGeometry::getOriginalWorkspace() invalid index.");
return m_originalWorkspaces[index];
}

/// Set the original workspace to which the basis vectors relate
void MDGeometry::setOriginalWorkspace(boost::shared_ptr<Workspace> ws)
/// @param ws :: original workspace shared pointer
/// @param index :: index into the vector of original workspaces
void MDGeometry::setOriginalWorkspace(boost::shared_ptr<Workspace> ws, size_t index)
{
m_originalWorkspace = ws;
if (index >= m_originalWorkspaces.size())
m_originalWorkspaces.resize(index+1);
m_originalWorkspaces[index] = ws;
// Watch for workspace deletions
if (!m_observingDelete)
{
Expand Down Expand Up @@ -319,48 +337,64 @@ namespace API
*/
void MDGeometry::deleteNotificationReceived(Mantid::API::WorkspacePreDeleteNotification_ptr notice)
{
if (bool(m_originalWorkspace))
for (size_t i=0; i<m_originalWorkspaces.size(); i++)
{
// Compare the pointer being deleted to the one stored as the original.
Workspace_sptr deleted = notice->object();
if (this->m_originalWorkspace == deleted)
Workspace_sptr original = m_originalWorkspaces[i];
if (original)
{
// Clear the reference
m_originalWorkspace.reset();
// Compare the pointer being deleted to the one stored as the original.
Workspace_sptr deleted = notice->object();
if (original == deleted)
{
// Clear the reference
m_originalWorkspaces[i].reset();
}
}
}
}

//---------------------------------------------------------------------------------------------------
/// @return Coordinate Transformation that goes from the original workspace to this workspace's coordinates.
Mantid::API::CoordTransform * MDGeometry::getTransformFromOriginal() const
/** @return Coordinate Transformation that goes from the original workspace to this workspace's coordinates.
* @param index :: index into the array of original workspaces */
Mantid::API::CoordTransform * MDGeometry::getTransformFromOriginal(size_t index) const
{
return m_transformFromOriginal;
if (index >= m_transforms_FromOriginal.size())
throw std::runtime_error("MDGeometry::getTransformFromOriginal(): invalid index.");
return m_transforms_FromOriginal[index];
}

/** Set Coordinate Transformation that goes from the original workspace to this workspace's coordinates.
* @param transform :: CoordTransform pointer (this assumes pointer ownership) */
void MDGeometry::setTransformFromOriginal(Mantid::API::CoordTransform * transform)
* @param transform :: CoordTransform pointer (this assumes pointer ownership)
* @param index :: index into the array of original workspaces */
void MDGeometry::setTransformFromOriginal(Mantid::API::CoordTransform * transform, size_t index)
{
if (m_transformFromOriginal)
delete m_transformFromOriginal;
m_transformFromOriginal = transform;
if (index >= m_transforms_FromOriginal.size())
m_transforms_FromOriginal.resize(index+1);
if (m_transforms_FromOriginal[index])
delete m_transforms_FromOriginal[index];
m_transforms_FromOriginal[index] = transform;
}

//---------------------------------------------------------------------------------------------------
/// @return Coordinate Transformation that goes from this workspace's coordinates to the original workspace coordinates.
Mantid::API::CoordTransform * MDGeometry::getTransformToOriginal() const
/** @return Coordinate Transformation that goes from this workspace's coordinates to the original workspace coordinates.
* @param index :: index into the array of original workspaces */
Mantid::API::CoordTransform * MDGeometry::getTransformToOriginal(size_t index) const
{
return m_transformToOriginal;
if (index >= m_transforms_ToOriginal.size())
throw std::runtime_error("MDGeometry::getTransformFromOriginal(): invalid index.");
return m_transforms_ToOriginal[index];
}

/** Set Coordinate Transformation that goes from this workspace's coordinates to the original workspace coordinates.
* @param transform :: CoordTransform pointer (this assumes pointer ownership) */
void MDGeometry::setTransformToOriginal(Mantid::API::CoordTransform * transform)
* @param transform :: CoordTransform pointer (this assumes pointer ownership)
* @param index :: index into the array of original workspaces */
void MDGeometry::setTransformToOriginal(Mantid::API::CoordTransform * transform, size_t index)
{
if (m_transformToOriginal)
delete m_transformToOriginal;
m_transformToOriginal = transform;
if (index >= m_transforms_ToOriginal.size())
m_transforms_ToOriginal.resize(index+1);
if (m_transforms_ToOriginal[index])
delete m_transforms_ToOriginal[index];
m_transforms_ToOriginal[index] = transform;
}

//---------------------------------------------------------------------------------------------------
Expand Down
16 changes: 16 additions & 0 deletions Code/Mantid/Framework/API/src/MatrixWorkspace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1492,6 +1492,22 @@ namespace Mantid
file->closeGroup();
}

/** Obtain coordinates for a line plot through a MDWorkspace.
* Cross the workspace from start to end points, recording the signal along the line.
* Sets the x,y vectors to the histogram bin boundaries and counts
*
* @param start :: coordinates of the start point of the line
* @param end :: coordinates of the end point of the line
* @param normalize :: how to normalize the signal
* @param x :: is set to the boundaries of the bins, relative to start of the line.
* @param y :: is set to the normalized signal for each bin. Length = length(x) - 1
*/
void MatrixWorkspace::getLinePlot(const Mantid::Kernel::VMD & start, const Mantid::Kernel::VMD & end,
Mantid::API::MDNormalization normalize, std::vector<coord_t> & x, std::vector<signal_t> & y, std::vector<signal_t> & e) const
{
UNUSED_ARG(start);UNUSED_ARG(end);UNUSED_ARG(normalize);UNUSED_ARG(x);UNUSED_ARG(y);UNUSED_ARG(e);
throw std::runtime_error("MatrixWorkspace::getLinePlot() not yet implemented.");
}


} // namespace API
Expand Down

0 comments on commit a6e911a

Please sign in to comment.