Mantid
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
Mantid::API::TextAxis Class Reference

Class to represent a text axis of a workspace. More...

#include <TextAxis.h>

Inheritance diagram for Mantid::API::TextAxis:
Mantid::API::Axis

Public Member Functions

Axisclone (const MatrixWorkspace *const parentWorkspace) override
 Virtual constructor. More...
 
Axisclone (const std::size_t length, const MatrixWorkspace *const parentWorkspace) override
 Virtual constructor for axis of different length. More...
 
double getMax () const override
 returns max value defined on axis More...
 
double getMin () const override
 returns min value defined on axis More...
 
size_t indexOfValue (const double value) const override
 Returns the value that has been passed to it as a size_t. More...
 
bool isText () const override
 If this is a TextAxis, always return true for this class. More...
 
std::string label (const std::size_t &index) const override
 Get the label at the specified index. More...
 
std::size_t length () const override
 Get the length of the axis. More...
 
double operator() (const std::size_t &index, const std::size_t &verticalIndex=0) const override
 Get a value at the specified index. More...
 
bool operator== (const Axis &) const override
 Check if two axis defined as spectra or numeric axis are equivalent. More...
 
void setLabel (const std::size_t &index, const std::string &lbl)
 Set the label at the given index. More...
 
void setValue (const std::size_t &index, const double &value) override
 Set the value at the specified index. More...
 
 TextAxis (const std::size_t &length)
 Constructor. More...
 
- Public Member Functions inherited from Mantid::API::Axis
 Axis ()
 Constructor. More...
 
virtual Axisclone (const MatrixWorkspace *const parentWorkspace)=0
 Virtual constructor. More...
 
virtual Axisclone (const std::size_t length, const MatrixWorkspace *const parentWorkspace)=0
 Virtual constructor for axis of different length. More...
 
virtual double getMax () const =0
 returns max value defined on axis More...
 
virtual double getMin () const =0
 returns min value defined on axis More...
 
double getValue (const std::size_t &index, const std::size_t &verticalIndex=0) const
 Gets the value at the specified index. More...
 
virtual size_t indexOfValue (const double value) const =0
 Find the index of the given double value. More...
 
virtual bool isNumeric () const
 Returns true if the axis is numeric. More...
 
virtual bool isSpectra () const
 Returns true is the axis is a Spectra axis. More...
 
virtual bool isText () const
 Returns true if the axis is Text. More...
 
virtual std::string label (const std::size_t &index) const =0
 Returns a text label of for a value Note that the index here is not the index of a value, but the effective index of the bin. More...
 
virtual std::size_t length () const =0
 Get the length of the axis. More...
 
virtual double operator() (const std::size_t &index, const std::size_t &verticalIndex=0) const =0
 Returns the value at a specified index. More...
 
virtual bool operator== (const Axis &) const =0
 Check whether two axis are the same, i.e same length and same spectra_values for all elements in the axis. More...
 
virtual const std::shared_ptr< Kernel::Unit > & setUnit (const std::string &unitName)
 Set the unit on the Axis. More...
 
virtual void setValue (const std::size_t &index, const double &value)=0
 Sets the value at the specified index. More...
 
virtual specnum_t spectraNo (const std::size_t &index) const
 Get the spectrum number. More...
 
std::string & title ()
 Returns a reference to the user-defined title for this axis. More...
 
const std::string & title () const
 Returns the user-defined title for this axis. More...
 
std::shared_ptr< Kernel::Unit > & unit ()
 The unit object for this workspace (non const version) More...
 
const std::shared_ptr< Kernel::Unit > & unit () const
 The unit for this axis. More...
 
virtual ~Axis ()=default
 

Private Attributes

std::vector< std::string > m_values
 A vector holding the axis values for the axis. More...
 

Additional Inherited Members

- Protected Member Functions inherited from Mantid::API::Axis
 Axis (const Axis &)=default
 
Axisoperator= (const Axis &)=default
 

Detailed Description

Class to represent a text axis of a workspace.

Author
Roman Tolchenov, Tessella plc
Date
06/07/2010

Definition at line 36 of file TextAxis.h.

Constructor & Destructor Documentation

◆ TextAxis()

Mantid::API::TextAxis::TextAxis ( const std::size_t &  length)

Constructor.

Parameters
lengththe size of the text axis

Definition at line 20 of file TextAxis.cpp.

References length(), and m_values.

Member Function Documentation

◆ clone() [1/2]

Axis * Mantid::API::TextAxis::clone ( const MatrixWorkspace *const  parentWorkspace)
overridevirtual

Virtual constructor.

Parameters
parentWorkspace:: The workspace is not used in this implementation
Returns
A pointer to a copy of the TextAxis on which the method is called

Implements Mantid::API::Axis.

Definition at line 26 of file TextAxis.cpp.

References UNUSED_ARG.

◆ clone() [2/2]

Axis * Mantid::API::TextAxis::clone ( const std::size_t  length,
const MatrixWorkspace *const  parentWorkspace 
)
overridevirtual

Virtual constructor for axis of different length.

Implements Mantid::API::Axis.

Definition at line 31 of file TextAxis.cpp.

References length(), and UNUSED_ARG.

◆ getMax()

double Mantid::API::TextAxis::getMax ( ) const
overridevirtual

returns max value defined on axis

Implements Mantid::API::Axis.

Definition at line 122 of file TextAxis.cpp.

References getMin(), and m_values.

◆ getMin()

double Mantid::API::TextAxis::getMin ( ) const
overridevirtual

returns min value defined on axis

Implements Mantid::API::Axis.

Definition at line 113 of file TextAxis.cpp.

References m_values.

Referenced by getMax().

◆ indexOfValue()

size_t Mantid::API::TextAxis::indexOfValue ( const double  value) const
overridevirtual

Returns the value that has been passed to it as a size_t.

Implements Mantid::API::Axis.

Definition at line 68 of file TextAxis.cpp.

References Mantid::Kernel::VectorHelper::indexOfValueFromCenters(), length(), spectraNumbers, and value.

◆ isText()

bool Mantid::API::TextAxis::isText ( ) const
inlineoverridevirtual

If this is a TextAxis, always return true for this class.

Reimplemented from Mantid::API::Axis.

Definition at line 43 of file TextAxis.h.

◆ label()

std::string Mantid::API::TextAxis::label ( const std::size_t &  index) const
overridevirtual

Get the label at the specified index.

Returns a text label which shows the value at index and identifies the type of the axis.

Parameters
index:: The index of an axis value
Returns
The label

Implements Mantid::API::Axis.

Definition at line 97 of file TextAxis.cpp.

References index, and m_values.

Referenced by export_TextAxis(), and Mantid::Algorithms::AppendSpectra::fixSpectrumNumbers().

◆ length()

std::size_t Mantid::API::TextAxis::length ( ) const
inlineoverridevirtual

Get the length of the axis.

Implements Mantid::API::Axis.

Definition at line 41 of file TextAxis.h.

Referenced by clone(), indexOfValue(), operator()(), operator==(), setLabel(), and TextAxis().

◆ operator()()

double Mantid::API::TextAxis::operator() ( const std::size_t &  index,
const std::size_t &  verticalIndex = 0 
) const
overridevirtual

Get a value at the specified index.

Get the axis value at the position given.

Parameters
indexThe position along the axis for which the value is required
verticalIndexNeeded for the subclass (RefAxis) method, but ignored (and defaulted) here
Returns
The value of the axis as a double
Exceptions
IndexErrorIf the index requested is not in the range of this axis

Implements Mantid::API::Axis.

Definition at line 46 of file TextAxis.cpp.

References Mantid::EMPTY_DBL(), index, length(), and UNUSED_ARG.

◆ operator==()

bool Mantid::API::TextAxis::operator== ( const Axis axis2) const
overridevirtual

Check if two axis defined as spectra or numeric axis are equivalent.

Parameters
axis2:: Reference to the axis to compare to
Returns
true if self and other axis are equal

Implements Mantid::API::Axis.

Definition at line 81 of file TextAxis.cpp.

References Mantid::API::Axis::length(), length(), and m_values.

◆ setLabel()

void Mantid::API::TextAxis::setLabel ( const std::size_t &  index,
const std::string &  lbl 
)

◆ setValue()

void Mantid::API::TextAxis::setValue ( const std::size_t &  index,
const double &  value 
)
overridevirtual

Set the value at the specified index.

Sets the axis value at a given position.

Parameters
index:: The position along the axis for which to set the value
value:: The new value
Exceptions
IndexErrorIf the index requested is not in the range of this axis

Implements Mantid::API::Axis.

Definition at line 60 of file TextAxis.cpp.

References index, UNUSED_ARG, and value.

Member Data Documentation

◆ m_values

std::vector<std::string> Mantid::API::TextAxis::m_values
private

A vector holding the axis values for the axis.

Definition at line 62 of file TextAxis.h.

Referenced by getMax(), getMin(), label(), operator==(), setLabel(), and TextAxis().


The documentation for this class was generated from the following files: