-
Notifications
You must be signed in to change notification settings - Fork 122
/
NumericAxis.h
99 lines (80 loc) · 3.61 KB
/
NumericAxis.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#ifndef MANTID_API_NUMERICAXIS_H_
#define MANTID_API_NUMERICAXIS_H_
//----------------------------------------------------------------------
// Includes
//----------------------------------------------------------------------
#include "MantidAPI/Axis.h"
#include <string>
#include <vector>
namespace Mantid {
namespace API {
//----------------------------------------------------------------------
// Forward declaration
//----------------------------------------------------------------------
class MatrixWorkspace;
/** Class to represent a numeric axis of a workspace.
@author Roman Tolchenov, Tessella plc
@date 05/07/2010
Copyright © 2008 ISIS Rutherford Appleton Laboratory, NScD Oak Ridge
National Laboratory & European Spallation Source
This file is part of Mantid.
Mantid is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
Mantid is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
File change history is stored at: <https://github.com/mantidproject/mantid>.
Code Documentation is available at: <http://doxygen.mantidproject.org>
*/
class MANTID_API_DLL NumericAxis : public Axis {
public:
/// Find the index of the value in the given set of edges
static size_t indexOfValue(const double value,
const std::vector<double> &edges);
NumericAxis(const std::size_t &length);
NumericAxis(const std::vector<double> ¢res);
virtual ~NumericAxis() {}
virtual Axis *clone(const MatrixWorkspace *const parentWorkspace);
virtual Axis *clone(const std::size_t length,
const MatrixWorkspace *const parentWorkspace);
/// Is the axis numeric - always true for this class
virtual bool isNumeric() const { return true; }
virtual std::size_t length() const { return m_values.size(); }
/// Get a value at the specified index
virtual double operator()(const std::size_t &index,
const std::size_t &verticalIndex = 0) const;
/// Set the value at a specific index
virtual void setValue(const std::size_t &index, const double &value);
size_t indexOfValue(const double value) const;
virtual bool operator==(const Axis &) const;
virtual bool equalWithinTolerance(const Axis &axis2,
const double tolerance) const;
std::string label(const std::size_t &index) const;
/// Create bin boundaries from the point values
virtual std::vector<double> createBinBoundaries() const;
/// Return a const reference to the values
const std::vector<double> &getValues() const;
/// returns min value defined on axis
double getMin() const { return m_values.front(); }
/// returns max value defined on axis
double getMax() const { return m_values.back(); }
protected:
/// Default constructor
NumericAxis();
/// A vector holding the centre values.
std::vector<double> m_values;
private:
/// Private, undefined copy assignment operator
const NumericAxis &operator=(const NumericAxis &);
/// A vector holding the edge values, computed from the distance between
/// values
std::vector<double> m_edges;
};
} // namespace API
} // namespace Mantid
#endif /* MANTID_API_NUMERICAXIS_H_ */