qwt_series_data.h
Go to the documentation of this file.
1 /******************************************************************************
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 
70 #else
71  // Needed for generating the python bindings, but not for using them !
72  virtual size_t size() const { return 0; }
73  virtual T sample( size_t i ) const { return T(); }
74 #endif
75 
88  virtual QRectF boundingRect() const
89  {
90  if ( cachedBoundingRect.width() < 0.0 )
92 
93  return cachedBoundingRect;
94  }
95 
107  virtual void setRectOfInterest( const QRectF& rect );
108 
109  protected:
111  mutable QRectF cachedBoundingRect;
112 
113  private:
115 };
116 
117 template< typename T >
119  : cachedBoundingRect( 0.0, 0.0, -1.0, -1.0 )
120 {
121 }
122 
123 template< typename T >
125 {
126 }
127 
128 template< typename T >
130 {
131 }
132 
139 template< typename T >
141 {
142  public:
145 
150  explicit QwtArraySeriesData( const QVector< T >& samples );
151 
156  void setSamples( const QVector< T >& samples );
157 
159  const QVector< T > samples() const;
160 
162  virtual size_t size() const QWT_OVERRIDE;
163 
170  virtual T sample( size_t index ) const QWT_OVERRIDE;
171 
172  protected:
175 };
176 
177 template< typename T >
179 {
180 }
181 
182 template< typename T >
184  : m_samples( samples )
185 {
186 }
187 
188 template< typename T >
190 {
191  QwtSeriesData< T >::cachedBoundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
192  m_samples = samples;
193 }
194 
195 template< typename T >
197 {
198  return m_samples;
199 }
200 
201 template< typename T >
203 {
204  return m_samples.size();
205 }
206 
207 template< typename T >
209 {
210  return m_samples[ static_cast< int >( i ) ];
211 }
212 
215 
218 
221 
224 
227 
230 
232  const QwtSeriesData< QPointF >&, int from = 0, int to = -1 );
233 
235  const QwtSeriesData< QwtPoint3D >&, int from = 0, int to = -1 );
236 
238  const QwtSeriesData< QwtPointPolar >&, int from = 0, int to = -1 );
239 
241  const QwtSeriesData< QwtIntervalSample >&, int from = 0, int to = -1 );
242 
244  const QwtSeriesData< QwtSetSample >&, int from = 0, int to = -1 );
245 
247  const QwtSeriesData< QwtOHLCSample >&, int from = 0, int to = -1 );
248 
250  const QwtSeriesData< QwtVectorFieldSample >&, int from = 0, int to = -1 );
251 
307 template< typename T, typename LessThan >
308 inline int qwtUpperSampleIndex( const QwtSeriesData< T >& series,
309  double value, LessThan lessThan )
310 {
311  const int indexMax = series.size() - 1;
312 
313  if ( indexMax < 0 || !lessThan( value, series.sample( indexMax ) ) )
314  return -1;
315 
316  int indexMin = 0;
317  int n = indexMax;
318 
319  while ( n > 0 )
320  {
321  const int half = n >> 1;
322  const int indexMid = indexMin + half;
323 
324  if ( lessThan( value, series.sample( indexMid ) ) )
325  {
326  n = half;
327  }
328  else
329  {
330  indexMin = indexMid + 1;
331  n -= half + 1;
332  }
333  }
334 
335  return indexMin;
336 }
337 
338 #endif
QwtArraySeriesData::m_samples
QVector< T > m_samples
Vector of samples.
Definition: qwt_series_data.h:174
QwtVectorFieldData
QwtArraySeriesData< QwtVectorFieldSample > QwtVectorFieldData
Interface for iterating over an array of vector field samples.
Definition: qwt_series_data.h:226
QwtIntervalSeriesData
QwtArraySeriesData< QwtIntervalSample > QwtIntervalSeriesData
Interface for iterating over an array of intervals.
Definition: qwt_series_data.h:220
QwtArraySeriesData::QwtArraySeriesData
QwtArraySeriesData()
Constructor.
Definition: qwt_series_data.h:178
QVector
Definition: qwt_clipper.h:23
QwtSetSeriesData
QwtArraySeriesData< QwtSetSample > QwtSetSeriesData
Interface for iterating over an array of samples.
Definition: qwt_series_data.h:223
qwt_global.h
QwtTradingChartData
QwtArraySeriesData< QwtOHLCSample > QwtTradingChartData
Interface for iterating over an array of OHLC samples.
Definition: qwt_series_data.h:229
QwtArraySeriesData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_series_data.h:202
QwtPointPolar
A point in polar coordinates.
Definition: qwt_point_polar.h:28
qwt_samples.h
QwtArraySeriesData::sample
virtual T sample(size_t index) const QWT_OVERRIDE
Definition: qwt_series_data.h:208
QwtArraySeriesData::setSamples
void setSamples(const QVector< T > &samples)
Definition: qwt_series_data.h:189
QwtSeriesData::QwtSeriesData
QwtSeriesData()
Constructor.
Definition: qwt_series_data.h:118
QwtArraySeriesData::samples
const QVector< T > samples() const
Definition: qwt_series_data.h:196
QwtSeriesData::boundingRect
virtual QRectF boundingRect() const
Definition: qwt_series_data.h:88
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_plot_barchart.h:18
QwtSeriesData::sample
virtual T sample(size_t i) const =0
QwtSeriesData::operator=
QwtSeriesData< T > & operator=(const QwtSeriesData< T > &)
qwtUpperSampleIndex
int qwtUpperSampleIndex(const QwtSeriesData< T > &series, double value, LessThan lessThan)
Definition: qwt_series_data.h:308
QwtSeriesData::cachedBoundingRect
QRectF cachedBoundingRect
Can be used to cache a calculated bounding rectangle.
Definition: qwt_series_data.h:111
QwtArraySeriesData
Template class for data, that is organized as QVector.
Definition: qwt_series_data.h:140
QwtSeriesData::~QwtSeriesData
virtual ~QwtSeriesData()
Destructor.
Definition: qwt_series_data.h:124
QWT_OVERRIDE
#define QWT_OVERRIDE
Definition: qwt_global.h:53
QWT_EXPORT
#define QWT_EXPORT
Definition: qwt_global.h:38
qwt_point_3d.h
QwtPoint3DSeriesData
QwtArraySeriesData< QwtPoint3D > QwtPoint3DSeriesData
Interface for iterating over an array of 3D points.
Definition: qwt_series_data.h:217
QwtSeriesData::size
virtual size_t size() const =0
QwtSeriesData::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_data.h:129
qwtBoundingRect
QWT_EXPORT QRectF qwtBoundingRect(const QwtSeriesData< QPointF > &, int from=0, int to=-1)
Calculate the bounding rectangle of a series subset.
Definition: qwt_series_data.cpp:136
QwtPointSeriesData
QwtArraySeriesData< QPointF > QwtPointSeriesData
Interface for iterating over an array of points.
Definition: qwt_series_data.h:214


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46