Newer
Older
// Mantid Repository : https://github.com/mantidproject/mantid
//
// Copyright © 2018 ISIS Rutherford Appleton Laboratory UKRI,
// NScD Oak Ridge National Laboratory, European Spallation Source
// & Institut Laue - Langevin
// SPDX - License - Identifier: GPL - 3.0 +
Russell Taylor
committed
#include "MantidAPI/Axis.h"
#include "MantidKernel/Exception.h"
#include "MantidKernel/Unit.h"
Russell Taylor
committed
namespace Mantid {
namespace API {
Russell Taylor
committed
Russell Taylor
committed
/// Constructor
Axis::Axis()
: m_title(),
m_unit(Mantid::Kernel::UnitFactory::Instance().create("Empty")) {}
Russell Taylor
committed
/// Returns the user-defined title for this axis
const std::string &Axis::title() const { return m_title; }
Russell Taylor
committed
/// Returns a reference to the user-defined title for this axis
std::string &Axis::title() { return m_title; }
Russell Taylor
committed
/** The unit for this axis
* @return A shared pointer to the unit object
*/
const Kernel::Unit_sptr &Axis::unit() const { return m_unit; }
Russell Taylor
committed
/** The unit object for this workspace (non const version)
* @return A shared pointer to the unit object
*/
Kernel::Unit_sptr &Axis::unit() { return m_unit; }
Michael Whitty
committed
/**
* Sets the Unit that is in use on this axis.
* @param unitName :: name of the unit as known to the UnitFactory
* @returns The new unit instance
*/
const Kernel::Unit_sptr &Axis::setUnit(const std::string &unitName) {
m_unit = Mantid::Kernel::UnitFactory::Instance().create(unitName);
return unit();
Michael Whitty
committed
}
Russell Taylor
committed
* Gets the value at the specified index. Easier to use with pointers than the
* operator()
* @param index :: The index along the axis direction
* @param verticalIndex :: The verticalIndex (used in RefAxis)
* @returns The double value at the given index
*/
double Axis::getValue(const std::size_t &index,
const std::size_t &verticalIndex) const {
return (*this)(index, verticalIndex);
}
Russell Taylor
committed
/** Returns the spectrum number at the position given (Spectra axis only)
* @param index The position for which the value is required
* @return The spectrum number as an int
* @throw domain_error If this method is called on a numeric axis
*/
specnum_t Axis::spectraNo(const std::size_t &index) const {
throw std::domain_error("Cannot call spectraNo() on a non-spectra axis.");
Russell Taylor
committed
}
} // namespace API
} // namespace Mantid