Mantid
Loading...
Searching...
No Matches
Histogram1D.h
Go to the documentation of this file.
1// Mantid Repository : https://github.com/mantidproject/mantid
2//
3// Copyright © 2007 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
10#include "MantidDataObjects/DllConfig.h"
13
14namespace Mantid {
15namespace DataObjects {
19class MANTID_DATAOBJECTS_DLL Histogram1D : public Mantid::API::ISpectrum {
20private:
22 HistogramData::Histogram m_histogram;
23
24public:
25 Histogram1D(HistogramData::Histogram::XMode xmode, HistogramData::Histogram::YMode ymode);
26
27 Histogram1D(const Histogram1D &) = default;
28 Histogram1D(Histogram1D &&) = default;
29 Histogram1D(const ISpectrum &other);
30
31 Histogram1D &operator=(const Histogram1D &) = default;
33 Histogram1D &operator=(const ISpectrum &rhs);
34
35 void copyDataFrom(const ISpectrum &source) override;
36
37 [[deprecated("use setSharedX() instead")]]
38 void setX(const Kernel::cow_ptr<HistogramData::HistogramX> &X) override;
39 [[deprecated("use mutableX() instead")]]
40 MantidVec &dataX() override;
41 [[deprecated("use x() instead")]]
42 const MantidVec &dataX() const override;
43 [[deprecated("use x() instead")]]
44 const MantidVec &readX() const override;
45 [[deprecated("use sharedX() instead")]]
47
48 [[deprecated("use mutableDx() instead")]]
49 MantidVec &dataDx() override;
50 [[deprecated("use dx() instead")]]
51 const MantidVec &dataDx() const override;
52 [[deprecated("use dx() instead")]]
53 const MantidVec &readDx() const override;
54
56 void clearData() override;
57
59 [[deprecated("use y() instead")]]
60 const MantidVec &dataY() const override {
61 return m_histogram.y().rawData();
62 }
64 [[deprecated("use e() instead")]]
65 const MantidVec &dataE() const override {
66 return m_histogram.e().rawData();
67 }
68
69 // The mutable legacy accessors below can only be expressed in terms of Histogram's own legacy
70 // interface: handing out a mutable MantidVec would allow the length to be changed, so
71 // FixedLengthVector::mutableRawData() is protected and Histogram is its only friend.
72 GNU_DIAG_OFF("deprecated-declarations")
73 MSVC_DIAG_OFF(4996)
75 [[deprecated("use mutableY() instead")]]
76 MantidVec &dataY() override {
77 return m_histogram.dataY();
78 }
80 [[deprecated("use mutableE() instead")]]
81 MantidVec &dataE() override {
82 return m_histogram.dataE();
83 }
84 MSVC_DIAG_ON(4996)
85 GNU_DIAG_ON("deprecated-declarations")
86
87 virtual std::size_t size() const { return m_histogram.y().size(); }
88
90 bool isError() const { return e().empty(); }
91
93 size_t getMemorySize() const override { return ((x().size() + y().size() + e().size()) * sizeof(double)); }
94
95private:
96 using ISpectrum::copyDataInto;
97 void copyDataInto(Histogram1D &sink) const override;
98
99 void checkAndSanitizeHistogram(HistogramData::Histogram &histogram) override;
100 const HistogramData::Histogram &histogramRef() const override { return m_histogram; }
101 HistogramData::Histogram &mutableHistogramRef() override { return m_histogram; }
102};
103
104} // namespace DataObjects
105} // Namespace Mantid
const std::vector< double > & rhs
#define MSVC_DIAG_ON(x)
#define MSVC_DIAG_OFF(x)
#define GNU_DIAG_ON(x)
#define GNU_DIAG_OFF(x)
This is a collection of macros for turning compiler warnings off in a controlled manner.
A "spectrum" is an object that holds the data for a particular spectrum, in particular:
Definition ISpectrum.h:38
1D histogram implementation.
Definition Histogram1D.h:19
Histogram1D & operator=(Histogram1D &&)=default
HistogramData::Histogram m_histogram
Histogram object holding the histogram data.
Definition Histogram1D.h:22
const MantidVec & dataE() const override
Deprecated, use e() instead. Returns the error data const.
Definition Histogram1D.h:65
const MantidVec & dataY() const override
Deprecated, use y() instead. Returns the y data const.
Definition Histogram1D.h:60
Histogram1D(const Histogram1D &)=default
Histogram1D & operator=(const Histogram1D &)=default
Histogram1D(Histogram1D &&)=default
const HistogramData::Histogram & histogramRef() const override
bool isError() const
Checks for errors.
Definition Histogram1D.h:90
MantidVec & dataE() override
Deprecated, use mutableE() instead. Returns the error data.
Definition Histogram1D.h:81
size_t getMemorySize() const override
Gets the memory size of the histogram.
Definition Histogram1D.h:93
HistogramData::Histogram & mutableHistogramRef() override
Implements a copy on write data template.
Definition cow_ptr.h:41
Helper class which provides the Collimation Length for SANS instruments.
std::vector< double > MantidVec
typedef for the data storage used in Mantid matrix workspaces
Definition cow_ptr.h:172
STL namespace.