qwt_series_data.h
Go to the documentation of this file.
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_SERIES_DATA_H
11 #define QWT_SERIES_DATA_H
12 
13 #include "qwt_global.h"
14 #include "qwt_samples.h"
15 #include "qwt_point_3d.h"
16 
17 #include <qvector.h>
18 #include <qrect.h>
19 
20 class QwtPointPolar;
21 
48 template <typename T>
49 class QwtSeriesData
50 {
51 public:
53  QwtSeriesData();
54 
56  virtual ~QwtSeriesData();
57 
58 #ifndef QWT_PYTHON_WRAPPER
59 
61  virtual size_t size() const = 0;
62 
68  virtual T sample( size_t i ) const = 0;
69 
82  virtual QRectF boundingRect() const = 0;
83 
84 #else
85  // Needed for generating the python bindings, but not for using them !
86  virtual size_t size() const { return 0; }
87  virtual T sample( size_t i ) const { return T(); }
88  virtual QRectF boundingRect() const { return d_boundingRect; }
89 #endif
90 
102  virtual void setRectOfInterest( const QRectF &rect );
103 
104 protected:
106  mutable QRectF d_boundingRect;
107 
108 private:
110 };
111 
112 template <typename T>
114  d_boundingRect( 0.0, 0.0, -1.0, -1.0 )
115 {
116 }
117 
118 template <typename T>
120 {
121 }
122 
123 template <typename T>
125 {
126 }
127 
134 template <typename T>
136 {
137 public:
140 
145  explicit QwtArraySeriesData( const QVector<T> &samples );
146 
151  void setSamples( const QVector<T> &samples );
152 
154  const QVector<T> samples() const;
155 
157  virtual size_t size() const QWT_OVERRIDE;
158 
165  virtual T sample( size_t index ) const QWT_OVERRIDE;
166 
167 protected:
170 };
171 
172 template <typename T>
174 {
175 }
176 
177 template <typename T>
179  d_samples( samples )
180 {
181 }
182 
183 template <typename T>
185 {
186  QwtSeriesData<T>::d_boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
187  d_samples = samples;
188 }
189 
190 template <typename T>
192 {
193  return d_samples;
194 }
195 
196 template <typename T>
198 {
199  return d_samples.size();
200 }
201 
202 template <typename T>
203 T QwtArraySeriesData<T>::sample( size_t i ) const
204 {
205  return d_samples[ static_cast<int>( i ) ];
206 }
207 
210 {
211 public:
213  const QVector<QPointF> & = QVector<QPointF>() );
214 
215  virtual QRectF boundingRect() const QWT_OVERRIDE;
216 };
217 
220 {
221 public:
224 
225  virtual QRectF boundingRect() const QWT_OVERRIDE;
226 };
227 
229 class QWT_EXPORT QwtIntervalSeriesData: public QwtArraySeriesData<QwtIntervalSample>
230 {
231 public:
234 
235  virtual QRectF boundingRect() const QWT_OVERRIDE;
236 };
237 
239 class QWT_EXPORT QwtSetSeriesData: public QwtArraySeriesData<QwtSetSample>
240 {
241 public:
244 
245  virtual QRectF boundingRect() const QWT_OVERRIDE;
246 };
247 
248 class QWT_EXPORT QwtVectorFieldData: public QwtArraySeriesData<QwtVectorFieldSample>
249 {
250 public:
253 
254  virtual QRectF boundingRect() const QWT_OVERRIDE;
255  virtual double maxMagnitude() const;
256 
257 protected:
258  mutable double d_maxMagnitude;
259 };
260 
265 {
266 public:
269 
270  virtual QRectF boundingRect() const QWT_OVERRIDE;
271 };
272 
274  const QwtSeriesData<QPointF> &, int from = 0, int to = -1 );
275 
277  const QwtSeriesData<QwtPoint3D> &, int from = 0, int to = -1 );
278 
280  const QwtSeriesData<QwtPointPolar> &, int from = 0, int to = -1 );
281 
283  const QwtSeriesData<QwtIntervalSample> &, int from = 0, int to = -1 );
284 
286  const QwtSeriesData<QwtSetSample> &, int from = 0, int to = -1 );
287 
289  const QwtSeriesData<QwtOHLCSample> &, int from = 0, int to = -1 );
290 
292  const QwtSeriesData<QwtVectorFieldSample> &, int from = 0, int to = -1 );
293 
349 template <typename T, typename LessThan>
350 inline int qwtUpperSampleIndex( const QwtSeriesData<T> &series,
351  double value, LessThan lessThan )
352 {
353  const int indexMax = series.size() - 1;
354 
355  if ( indexMax < 0 || !lessThan( value, series.sample( indexMax ) ) )
356  return -1;
357 
358  int indexMin = 0;
359  int n = indexMax;
360 
361  while ( n > 0 )
362  {
363  const int half = n >> 1;
364  const int indexMid = indexMin + half;
365 
366  if ( lessThan( value, series.sample( indexMid ) ) )
367  {
368  n = half;
369  }
370  else
371  {
372  indexMin = indexMid + 1;
373  n -= half + 1;
374  }
375  }
376 
377  return indexMin;
378 }
379 
380 #endif
virtual void setRectOfInterest(const QRectF &rect)
enum MQTTPropertyCodes value
A point in polar coordinates.
QwtSeriesData()
Constructor.
QRectF d_boundingRect
Can be used to cache a calculated bounding rectangle.
QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData< QPointF > &, int from=0, int to=-1)
Calculate the bounding rectangle of a series subset.
Interface for iterating over an array of samples.
virtual QRectF boundingRect() const =0
QVector< T > d_samples
Vector of samples.
#define QWT_EXPORT
Definition: qwt_global.h:38
const QVector< T > samples() const
Abstract interface for iterating over samples.
Interface for iterating over an array of 3D points.
virtual size_t size() const QWT_OVERRIDE
QwtArraySeriesData()
Constructor.
QwtSeriesData< T > & operator=(const QwtSeriesData< T > &)
virtual ~QwtSeriesData()
Destructor.
virtual T sample(size_t index) const QWT_OVERRIDE
Template class for data, that is organized as QVector.
void setSamples(const QVector< T > &samples)
Interface for iterating over an array of intervals.
virtual size_t size() const =0
virtual T sample(size_t i) const =0
Interface for iterating over an array of points.
#define QWT_OVERRIDE
Definition: qwt_global.h:53
int qwtUpperSampleIndex(const QwtSeriesData< T > &series, double value, LessThan lessThan)


plotjuggler
Author(s): Davide Faconti
autogenerated on Sun Dec 6 2020 03:48:10