Mantid
Loading...
Searching...
No Matches
Axis.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2008 ISIS Rutherford Appleton Laboratory UKRI,
4// NScD Oak Ridge National Laboratory, European Spallation Source,
5// Institut Laue - Langevin & CSNS, Institute of High Energy Physics, CAS
6// SPDX - License - Identifier: GPL - 3.0 +
7#pragma once
8
9#include "MantidAPI/DllConfig.h"
11
12#include <memory>
13#include <string>
14
15namespace Mantid {
16namespace Kernel {
17class Unit;
18}
19namespace API {
20//----------------------------------------------------------------------
21// Forward declaration
22//----------------------------------------------------------------------
23class MatrixWorkspace;
24
30class MANTID_API_DLL Axis {
31public:
32 Axis();
33 virtual ~Axis() = default;
34
36 virtual Axis *clone(const MatrixWorkspace *const parentWorkspace) = 0;
38 virtual Axis *clone(const std::size_t length, const MatrixWorkspace *const parentWorkspace) = 0;
39
40 const std::string &title() const;
41 std::string &title();
42
43 const std::shared_ptr<Kernel::Unit> &unit() const;
44 std::shared_ptr<Kernel::Unit> &unit();
45
47 virtual const std::shared_ptr<Kernel::Unit> &setUnit(const std::string &unitName);
48
50 virtual bool isSpectra() const { return false; }
52 virtual bool isNumeric() const { return false; }
54 virtual bool isText() const { return false; }
55
59 virtual double operator()(const std::size_t &index, const std::size_t &verticalIndex = 0) const = 0;
62 double getValue(const std::size_t &index, const std::size_t &verticalIndex = 0) const;
64 virtual double getMin() const = 0;
66 virtual double getMax() const = 0;
70 virtual void setValue(const std::size_t &index, const double &value) = 0;
72 virtual size_t indexOfValue(const double value) const = 0;
73
75 virtual specnum_t spectraNo(const std::size_t &index) const;
76
78 virtual std::size_t length() const = 0;
79
82 virtual bool operator==(const Axis &) const = 0;
83
87 virtual std::string label(const std::size_t &index) const = 0;
88
89protected:
90 Axis(const Axis &) = default;
91 Axis &operator=(const Axis &) = default;
92
93private:
95 std::string m_title;
97 std::shared_ptr<Kernel::Unit> m_unit;
98};
99
100} // namespace API
101} // namespace Mantid
double value
The value of the point.
Definition: FitMW.cpp:51
std::map< DeltaEMode::Type, std::string > index
Definition: DeltaEMode.cpp:19
Class to represent the axis of a workspace.
Definition: Axis.h:30
virtual double getMin() const =0
returns min value defined on axis
virtual double getMax() const =0
returns max value defined on axis
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,...
Axis(const Axis &)=default
std::shared_ptr< Kernel::Unit > m_unit
The unit for this axis.
Definition: Axis.h:97
virtual double operator()(const std::size_t &index, const std::size_t &verticalIndex=0) const =0
Returns the value at a specified index.
virtual bool isText() const
Returns true if the axis is Text.
Definition: Axis.h:54
virtual size_t indexOfValue(const double value) const =0
Find the index of the given double value.
virtual std::size_t length() const =0
Get the length of the axis.
virtual ~Axis()=default
virtual Axis * clone(const MatrixWorkspace *const parentWorkspace)=0
Virtual constructor.
Axis & operator=(const Axis &)=default
virtual Axis * clone(const std::size_t length, const MatrixWorkspace *const parentWorkspace)=0
Virtual constructor for axis of different length.
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 ...
virtual void setValue(const std::size_t &index, const double &value)=0
Sets the value at the specified index.
std::string m_title
The user-defined title for this axis.
Definition: Axis.h:95
virtual bool isNumeric() const
Returns true if the axis is numeric.
Definition: Axis.h:52
virtual bool isSpectra() const
Returns true is the axis is a Spectra axis.
Definition: Axis.h:50
Base MatrixWorkspace Abstract Class.
Helper class which provides the Collimation Length for SANS instruments.
int32_t specnum_t
Typedef for a spectrum Number.
Definition: IDTypes.h:16