Qwt User's Guide 6.3.0
Loading...
Searching...
No Matches
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
21template< typename T >
22class QwtPointArrayData : public QwtSeriesData< QPointF >
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
42template< typename T >
43class QwtCPointerData : public QwtSeriesData< QPointF >
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
66template< typename T >
67class QwtValuePointData : public QwtSeriesData< QPointF >
68{
69 public:
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
88template< typename T >
89class QwtCPointerValueData : public QwtSeriesData< QPointF >
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
157class QWT_EXPORT QwtSyntheticPointData : public QwtSeriesData< QPointF >
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
199template< typename T >
201 const QVector< T >& x, const QVector< T >& y )
202 : m_x( x )
203 , m_y( y )
204{
205}
206
215template< typename T >
216QwtPointArrayData< 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
226template< typename T >
228{
229 return qMin( m_x.size(), m_y.size() );
230}
231
238template< typename T >
239QPointF QwtPointArrayData< T >::sample( size_t index ) const
240{
241 return QPointF( m_x[int( index )], m_y[int( index )] );
242}
243
245template< typename T >
247{
248 return m_x;
249}
250
252template< typename T >
254{
255 return m_y;
256}
257
265template< typename T >
267 : m_y( y )
268{
269}
270
278template< typename T >
280{
281 m_y.resize( size );
282 std::memcpy( m_y.data(), y, size * sizeof( T ) );
283}
284
286template< typename T >
288{
289 return m_y.size();
290}
291
298template< typename T >
299QPointF QwtValuePointData< T >::sample( size_t index ) const
300{
301 return QPointF( index, m_y[int( index )] );
302}
303
305template< typename T >
307{
308 return m_y;
309}
310
325template< typename T >
326QwtCPointerData< 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
334template< typename T >
336{
337 return m_size;
338}
339
346template< typename T >
347QPointF QwtCPointerData< T >::sample( size_t index ) const
348{
349 return QPointF( m_x[int( index )], m_y[int( index )] );
350}
351
353template< typename T >
355{
356 return m_x;
357}
358
360template< typename T >
362{
363 return m_y;
364}
365
379template< typename T >
381 : m_y( y )
382 , m_size( size )
383{
384}
385
387template< typename T >
389{
390 return m_size;
391}
392
399template< typename T >
400QPointF QwtCPointerValueData< T >::sample( size_t index ) const
401{
402 return QPointF( index, m_y[ int( index ) ] );
403}
404
406template< typename T >
408{
409 return m_y;
410}
411
412#endif
Data class containing two pointers to memory blocks of T.
const T * xData() const
const T * yData() const
virtual size_t size() const override
virtual QPointF sample(size_t index) const override
QwtCPointerData(const T *x, const T *y, size_t size)
Data class containing a pointer to memory of y coordinates.
QwtCPointerValueData(const T *y, size_t size)
virtual size_t size() const override
const T * yData() const
virtual QPointF sample(size_t index) const override
A class representing an interval.
Interface for iterating over two QVector<T> objects.
virtual QPointF sample(size_t index) const override
const QVector< T > & xData() const
const QVector< T > & yData() const
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
virtual size_t size() const override
Abstract interface for iterating over samples.
virtual void setRectOfInterest(const QRectF &rect)
virtual size_t size() const =0
virtual QRectF boundingRect() const
virtual T sample(size_t i) const =0
Synthetic point data.
virtual double y(double x) const =0
Interface for iterating over a QVector<T>.
QwtValuePointData(const QVector< T > &y)
virtual size_t size() const override
virtual QPointF sample(size_t index) const override
const QVector< T > & yData() const