Newer
Older
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
#ifndef MANTIDQTAPI_QWTWORKSPACEBINDATA_H
#define MANTIDQTAPI_QWTWORKSPACEBINDATA_H
#include "MantidAPI/MatrixWorkspace.h"
#include "MantidQtAPI/MantidQwtWorkspaceData.h"
#include "DllOption.h"
#include <boost/shared_ptr.hpp>
#include <QString>
//=================================================================================================
//=================================================================================================
/** This class implements QwtData with direct access to a spectrum in a MatrixWorkspace.
*/
class EXPORT_OPT_MANTIDQT_API QwtWorkspaceBinData : public MantidQwtMatrixWorkspaceData
{
public:
QwtWorkspaceBinData(const Mantid::API::MatrixWorkspace & workspace, int binIndex, const bool logScale);
//! @return Pointer to a copy (virtual copy constructor)
virtual QwtWorkspaceBinData *copy() const;
/// Return a new data object of the same type but with a new workspace
virtual QwtWorkspaceBinData *copyWithNewSource(const Mantid::API::MatrixWorkspace & workspace) const;
//! @return Size of the data set
virtual size_t size() const;
/**
Return the x value of data point i
@param i :: Index
@return x X value of data point i
*/
virtual double x(size_t i) const;
/**
Return the y value of data point i
@param i :: Index
@return y Y value of data point i
*/
virtual double y(size_t i) const;
/// Returns the error of the i-th data point
double e(size_t i)const;
/// Returns the x position of the error bar for the i-th data point (bin)
double ex(size_t i)const;
/// Number of error bars to plot
size_t esize()const;
double getYMin() const;
double getYMax() const;
/// Return the label to use for the X axis
QString getXAxisLabel() const;
/// Return the label to use for the Y axis
QString getYAxisLabel() const;
/// Inform the data that it is to be plotted on a log y scale
void setLogScale(bool on);
bool logScale()const{return m_logScale;}
void saveLowestPositiveValue(const double v);
protected:
// Assignment operator (virtualized). MSVC not happy with compiler generated one
QwtWorkspaceBinData& operator=(const QwtWorkspaceBinData&); // required by QwtData base class
private:
/// Initialize the object
void init(const Mantid::API::MatrixWorkspace & workspace);
/// The column index of the current data
int m_binIndex;
/// Copy of the X vector
Mantid::MantidVec m_X;
/// Copy of the Y vector
Mantid::MantidVec m_Y;
/// Copy of the E vector
Mantid::MantidVec m_E;
/// A title for the X axis
QString m_xTitle;
/// A title for the Y axis
QString m_yTitle;
/// Indicates that the data is plotted on a log y scale
bool m_logScale;
/// lowest y value
double m_minY;
/// lowest positive y value
double m_minPositive;
/// highest y value
double m_maxY;
};
#endif