Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source,
// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
// SPDX - License - Identifier: GPL - 3.0 +
Russell Taylor
committed
Gigg, Martyn Anthony
committed
#include "MantidAPI/DllConfig.h"
Gigg, Martyn Anthony
committed
#include "MantidGeometry/IDTypes.h"
#include <boost/shared_ptr.hpp>
Russell Taylor
committed
#include <string>
namespace Kernel {
class Unit;
}
Russell Taylor
committed
//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
Roman Tolchenov
committed
class MatrixWorkspace;
Russell Taylor
committed
/** Class to represent the axis of a workspace.
@author Russell Taylor, Tessella Support Services plc
@date 16/05/2008
*/
Russell Taylor
committed
public:
virtual ~Axis() = default;
Russell Taylor
committed
/// Virtual constructor
virtual Axis *clone(const MatrixWorkspace *const parentWorkspace) = 0;
Russell Taylor
committed
/// Virtual constructor for axis of different length
virtual Axis *clone(const std::size_t length,
const MatrixWorkspace *const parentWorkspace) = 0;
Russell Taylor
committed
const std::string &title() const;
std::string &title();
Russell Taylor
committed
const boost::shared_ptr<Kernel::Unit> &unit() const;
boost::shared_ptr<Kernel::Unit> &unit();
Russell Taylor
committed
Michael Whitty
committed
/// Set the unit on the Axis
virtual const boost::shared_ptr<Kernel::Unit> &
setUnit(const std::string &unitName);
Michael Whitty
committed
virtual bool isSpectra() const { return false; }
virtual bool isNumeric() const { return false; }
/// Returns true if the axis is Text
virtual bool isText() const { return false; }
Russell Taylor
committed
Janik Zikovsky
committed
/// @param index :: the index
/// @param verticalIndex :: The verticalIndex
virtual double operator()(const std::size_t &index,
const std::size_t &verticalIndex = 0) const = 0;
/// Gets the value at the specified index. Just calls operator() but is easier
/// to use with Axis pointers
double getValue(const std::size_t &index,
const std::size_t &verticalIndex = 0) const;
/// returns min value defined on axis
virtual double getMin() const = 0;
/// returns max value defined on axis
virtual double getMax() const = 0;
Janik Zikovsky
committed
/// @param index :: The index
/// @param value :: The new value
virtual void setValue(const std::size_t &index, const double &value) = 0;
/// Find the index of the given double value
virtual size_t indexOfValue(const double value) const = 0;
/// Get the spectrum number
virtual specnum_t spectraNo(const std::size_t &index) const;
Russell Taylor
committed
/// Get the length of the axis
/// Check whether two axis are the same, i.e same length and same
/// spectra_values for all elements in the axis
virtual bool operator==(const Axis &) const = 0;
virtual std::string label(const std::size_t &index) const = 0;
Russell Taylor
committed
protected:
Russell Taylor
committed
private:
/// Private, undefined copy assignment operator
const Axis &operator=(const Axis &) = delete;
Russell Taylor
committed
Russell Taylor
committed
/// The user-defined title for this axis
std::string m_title;
/// The unit for this axis
boost::shared_ptr<Kernel::Unit> m_unit;
Russell Taylor
committed
};
} // namespace API
} // namespace Mantid