Qwt User's Guide 6.2.0

qwt_point_data.h
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_POINT_DATA_H
11 #define QWT_POINT_DATA_H
12
13 #include "qwt_global.h"
14 #include "qwt_series_data.h"
15
16 #include <cstring>
17
21 template< typename T >
22 class QwtPointArrayData : public QwtPointSeriesData
23 {
24 public:
25 QwtPointArrayData( const QVector< T >& x, const QVector< T >& y );
26 QwtPointArrayData( const T* x, const T* y, size_t size );
27
28 virtual size_t size() const QWT_OVERRIDE;
29 virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
30
31 const QVector< T >& xData() const;
32 const QVector< T >& yData() const;
33
34 private:
35 QVector< T > m_x;
36 QVector< T > m_y;
37 };
38
42 template< typename T >
43 class QwtCPointerData : public QwtPointSeriesData
44 {
45 public:
46 QwtCPointerData( const T* x, const T* y, size_t size );
47
48 virtual size_t size() const QWT_OVERRIDE;
49 virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
50
51 const T* xData() const;
52 const T* yData() const;
53
54 private:
55 const T* m_x;
56 const T* m_y;
57 size_t m_size;
58 };
59
66 template< typename T >
67 class QwtValuePointData : public QwtPointSeriesData
68 {
69 public:
70 QwtValuePointData( const QVector< T >& y );
71 QwtValuePointData( const T* y, size_t size );
72
73 virtual size_t size() const QWT_OVERRIDE;
74 virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
75
76 const QVector< T >& yData() const;
77
78 private:
79 QVector< T > m_y;
80 };
81
88 template< typename T >
89 class QwtCPointerValueData : public QwtPointSeriesData
90 {
91 public:
92 QwtCPointerValueData( const T* y, size_t size );
93
94 virtual size_t size() const QWT_OVERRIDE;
95 virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
96
97 const T* yData() const;
98
99 private:
100 const T* m_y;
101 size_t m_size;
102 };
103
157 class QWT_EXPORT QwtSyntheticPointData : public QwtPointSeriesData
158 {
159 public:
160 QwtSyntheticPointData( size_t size,
161 const QwtInterval& = QwtInterval() );
162
163 void setSize( size_t size );
164 virtual size_t size() const QWT_OVERRIDE;
165
166 void setInterval( const QwtInterval& );
167 QwtInterval interval() const;
168
169 virtual QRectF boundingRect() const QWT_OVERRIDE;
170 virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
171
178 virtual double y( double x ) const = 0;
179 virtual double x( uint index ) const;
180
181 virtual void setRectOfInterest( const QRectF& ) QWT_OVERRIDE;
182 QRectF rectOfInterest() const;
183
184 private:
185 size_t m_size;
186 QwtInterval m_interval;
187 QRectF m_rectOfInterest;
188 QwtInterval m_intervalOfInterest;
189 };
190
199 template< typename T >
200 QwtPointArrayData< T >::QwtPointArrayData(
201 const QVector< T >& x, const QVector< T >& y )
202 : m_x( x )
203 , m_y( y )
204 {
205 }
206
215 template< typename T >
216 QwtPointArrayData< T >::QwtPointArrayData( const T* x, const T* y, size_t size )
217 {
218 m_x.resize( size );
219 std::memcpy( m_x.data(), x, size * sizeof( T ) );
220
221 m_y.resize( size );
222 std::memcpy( m_y.data(), y, size * sizeof( T ) );
223 }
224
226 template< typename T >
227 size_t QwtPointArrayData< T >::size() const
228 {
229 return qMin( m_x.size(), m_y.size() );
230 }
231
238 template< typename T >
239 QPointF QwtPointArrayData< T >::sample( size_t index ) const
240 {
241 return QPointF( m_x[int( index )], m_y[int( index )] );
242 }
243
245 template< typename T >
246 const QVector< T >& QwtPointArrayData< T >::xData() const
247 {
248 return m_x;
249 }
250
252 template< typename T >
253 const QVector< T >& QwtPointArrayData< T >::yData() const
254 {
255 return m_y;
256 }
257
265 template< typename T >
266 QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y )
267 : m_y( y )
268 {
269 }
270
278 template< typename T >
279 QwtValuePointData< T >::QwtValuePointData( const T* y, size_t size )
280 {
281 m_y.resize( size );
282 std::memcpy( m_y.data(), y, size * sizeof( T ) );
283 }
284
286 template< typename T >
287 size_t QwtValuePointData< T >::size() const
288 {
289 return m_y.size();
290 }
291
298 template< typename T >
299 QPointF QwtValuePointData< T >::sample( size_t index ) const
300 {
301 return QPointF( index, m_y[int( index )] );
302 }
303
305 template< typename T >
306 const QVector< T >& QwtValuePointData< T >::yData() const
307 {
308 return m_y;
309 }
310
325 template< typename T >
326 QwtCPointerData< T >::QwtCPointerData( const T* x, const T* y, size_t size )
327 : m_x( x )
328 , m_y( y )
329 , m_size( size )
330 {
331 }
332
334 template< typename T >
335 size_t QwtCPointerData< T >::size() const
336 {
337 return m_size;
338 }
339
346 template< typename T >
347 QPointF QwtCPointerData< T >::sample( size_t index ) const
348 {
349 return QPointF( m_x[int( index )], m_y[int( index )] );
350 }
351
353 template< typename T >
354 const T* QwtCPointerData< T >::xData() const
355 {
356 return m_x;
357 }
358
360 template< typename T >
361 const T* QwtCPointerData< T >::yData() const
362 {
363 return m_y;
364 }
365
379 template< typename T >
380 QwtCPointerValueData< T >::QwtCPointerValueData( const T* y, size_t size )
381 : m_y( y )
382 , m_size( size )
383 {
384 }
385
387 template< typename T >
388 size_t QwtCPointerValueData< T >::size() const
389 {
390 return m_size;
391 }
392
399 template< typename T >
400 QPointF QwtCPointerValueData< T >::sample( size_t index ) const
401 {
402 return QPointF( index, m_y[ int( index ) ] );
403 }
404
406 template< typename T >
407 const T* QwtCPointerValueData< T >::yData() const
408 {
409 return m_y;
410 }
411
412 #endif
QVector
Definition: qwt_clipper.h:23
QwtArraySeriesData< QPointF >::sample
virtual QPointF sample(size_t index) const override
Definition: qwt_series_data.h:203
QwtArraySeriesData< QPointF >::size
virtual size_t size() const override
Definition: qwt_series_data.h:197
QwtCPointerData
Data class containing two pointers to memory blocks of T.
Definition: qwt_point_data.h:44
QwtCPointerData::xData
const T * xData() const
Definition: qwt_point_data.h:354
QwtCPointerData::yData
const T * yData() const
Definition: qwt_point_data.h:361
QwtCPointerData::size
virtual size_t size() const override
Definition: qwt_point_data.h:335
QwtCPointerData::sample
virtual QPointF sample(size_t index) const override
Definition: qwt_point_data.h:347
QwtCPointerData::QwtCPointerData
QwtCPointerData(const T *x, const T *y, size_t size)
Definition: qwt_point_data.h:326
QwtCPointerValueData
Data class containing a pointer to memory of y coordinates.
Definition: qwt_point_data.h:90
QwtCPointerValueData::QwtCPointerValueData
QwtCPointerValueData(const T *y, size_t size)
Definition: qwt_point_data.h:380
QwtCPointerValueData::size
virtual size_t size() const override
Definition: qwt_point_data.h:388
QwtCPointerValueData::yData
const T * yData() const
Definition: qwt_point_data.h:407
QwtCPointerValueData::sample
virtual QPointF sample(size_t index) const override
Definition: qwt_point_data.h:400
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:23
QwtPointArrayData
Interface for iterating over two QVector<T> objects.
Definition: qwt_point_data.h:23
QwtPointArrayData::sample
virtual QPointF sample(size_t index) const override
Definition: qwt_point_data.h:239
QwtPointArrayData::xData
const QVector< T > & xData() const
Definition: qwt_point_data.h:246
QwtPointArrayData::yData
const QVector< T > & yData() const
Definition: qwt_point_data.h:253
QwtPointArrayData::QwtPointArrayData
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
Definition: qwt_point_data.h:200
QwtPointArrayData::size
virtual size_t size() const override
Definition: qwt_point_data.h:227
QwtPointSeriesData
Interface for iterating over an array of points.
Definition: qwt_series_data.h:210
QwtPointSeriesData::boundingRect
virtual QRectF boundingRect() const override
Calculate the bounding rectangle.
Definition: qwt_series_data.cpp:263
QwtSeriesData< QPointF >::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_data.h:124
QwtSyntheticPointData
Synthetic point data.
Definition: qwt_point_data.h:158
QwtSyntheticPointData::y
virtual double y(double x) const =0
QwtValuePointData
Interface for iterating over a QVector<T>.
Definition: qwt_point_data.h:68
QwtValuePointData::QwtValuePointData
QwtValuePointData(const QVector< T > &y)
Definition: qwt_point_data.h:266
QwtValuePointData::size
virtual size_t size() const override
Definition: qwt_point_data.h:287
QwtValuePointData::sample
virtual QPointF sample(size_t index) const override
Definition: qwt_point_data.h:299
QwtValuePointData::yData
const QVector< T > & yData() const
Definition: qwt_point_data.h:306