1 | /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
|
---|
2 | * Qwt Widget Library
|
---|
3 | * Copyright (C) 1997 Josef Wilgen
|
---|
4 | * Copyright (C) 2002 Uwe Rathmann
|
---|
5 | *
|
---|
6 | * This library is free software; you can redistribute it and/or
|
---|
7 | * modify it under the terms of the Qwt License, Version 1.0
|
---|
8 | *****************************************************************************/
|
---|
9 |
|
---|
10 | #ifndef QWT_INTERVAL_DATA_H
|
---|
11 | #define QWT_INTERVAL_DATA_H 1
|
---|
12 |
|
---|
13 | #include "qwt_global.h"
|
---|
14 | #include "qwt_math.h"
|
---|
15 | #include "qwt_array.h"
|
---|
16 | #include "qwt_double_interval.h"
|
---|
17 | #include "qwt_double_rect.h"
|
---|
18 |
|
---|
19 | #if defined(_MSC_VER) && (_MSC_VER > 1310)
|
---|
20 | #include <string.h>
|
---|
21 | #endif
|
---|
22 |
|
---|
23 | #if defined(QWT_TEMPLATEDLL)
|
---|
24 | // MOC_SKIP_BEGIN
|
---|
25 | template class QWT_EXPORT QwtArray<QwtDoubleInterval>;
|
---|
26 | template class QWT_EXPORT QwtArray<double>;
|
---|
27 | // MOC_SKIP_END
|
---|
28 | #endif
|
---|
29 |
|
---|
30 | /*!
|
---|
31 | \brief Series of samples of a value and an interval
|
---|
32 |
|
---|
33 | QwtIntervalData is a series of samples of a value and an interval.
|
---|
34 | F.e. error bars are built from samples [x, y1-y2], while a
|
---|
35 | histogram might consist of [x1-x2, y] samples.
|
---|
36 | */
|
---|
37 | class QWT_EXPORT QwtIntervalData
|
---|
38 | {
|
---|
39 | public:
|
---|
40 | QwtIntervalData();
|
---|
41 | QwtIntervalData(const QwtArray<QwtDoubleInterval> &,
|
---|
42 | const QwtArray<double> &);
|
---|
43 |
|
---|
44 | ~QwtIntervalData();
|
---|
45 |
|
---|
46 | void setData(const QwtArray<QwtDoubleInterval> &,
|
---|
47 | const QwtArray<double> &);
|
---|
48 |
|
---|
49 | size_t size() const;
|
---|
50 | const QwtDoubleInterval &interval(size_t i) const;
|
---|
51 | double value(size_t i) const;
|
---|
52 |
|
---|
53 | QwtDoubleRect boundingRect() const;
|
---|
54 |
|
---|
55 | private:
|
---|
56 | QwtArray<QwtDoubleInterval> d_intervals;
|
---|
57 | QwtArray<double> d_values;
|
---|
58 | };
|
---|
59 |
|
---|
60 | //! \return Number of samples
|
---|
61 | inline size_t QwtIntervalData::size() const
|
---|
62 | {
|
---|
63 | return qwtMin(d_intervals.size(), d_values.size());
|
---|
64 | }
|
---|
65 |
|
---|
66 | /*!
|
---|
67 | Interval of a sample
|
---|
68 |
|
---|
69 | \param i Sample index
|
---|
70 | \return Interval
|
---|
71 | \sa value(), size()
|
---|
72 | */
|
---|
73 | inline const QwtDoubleInterval &QwtIntervalData::interval(size_t i) const
|
---|
74 | {
|
---|
75 | return d_intervals[int(i)];
|
---|
76 | }
|
---|
77 |
|
---|
78 | /*!
|
---|
79 | Value of a sample
|
---|
80 |
|
---|
81 | \param i Sample index
|
---|
82 | \return Value
|
---|
83 | \sa interval(), size()
|
---|
84 | */
|
---|
85 | inline double QwtIntervalData::value(size_t i) const
|
---|
86 | {
|
---|
87 | return d_values[int(i)];
|
---|
88 | }
|
---|
89 |
|
---|
90 | #endif
|
---|