Qwt User's Guide  5.2.3
qwt_interval_data.h
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 
37 class QWT_EXPORT QwtIntervalData
38 {
39 public:
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 
61 inline size_t QwtIntervalData::size() const
62 {
63  return qwtMin(d_intervals.size(), d_values.size());
64 }
65 
73 inline const QwtDoubleInterval &QwtIntervalData::interval(size_t i) const
74 {
75  return d_intervals[int(i)];
76 }
77 
85 inline double QwtIntervalData::value(size_t i) const
86 {
87  return d_values[int(i)];
88 }
89 
90 #endif