qwt_point_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_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 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:
37 };
38 
42 template< typename T >
43 class 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 
66 template< typename T >
67 class 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:
80 };
81 
88 template< typename T >
89 class 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 
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;
189 };
190 
199 template< typename T >
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 >
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 >
247 {
248  return m_x;
249 }
250 
252 template< typename T >
254 {
255  return m_y;
256 }
257 
265 template< typename T >
267  : m_y( y )
268 {
269 }
270 
278 template< typename T >
280 {
281  m_y.resize( size );
282  std::memcpy( m_y.data(), y, size * sizeof( T ) );
283 }
284 
286 template< typename T >
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 >
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 >
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 >
355 {
356  return m_x;
357 }
358 
360 template< typename T >
362 {
363  return m_y;
364 }
365 
379 template< typename T >
381  : m_y( y )
382  , m_size( size )
383 {
384 }
385 
387 template< typename T >
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 >
408 {
409  return m_y;
410 }
411 
412 #endif
QwtPointArrayData
Interface for iterating over two QVector<T> objects.
Definition: qwt_point_data.h:22
QwtValuePointData::QwtValuePointData
QwtValuePointData(const QVector< T > &y)
Definition: qwt_point_data.h:266
QwtValuePointData::yData
const QVector< T > & yData() const
Definition: qwt_point_data.h:306
QwtCPointerValueData
Data class containing a pointer to memory of y coordinates.
Definition: qwt_point_data.h:89
QwtCPointerValueData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_point_data.h:388
QwtValuePointData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_point_data.h:287
QwtCPointerData::yData
const T * yData() const
Definition: qwt_point_data.h:361
QwtCPointerValueData::sample
virtual QPointF sample(size_t index) const QWT_OVERRIDE
Definition: qwt_point_data.h:400
QwtPointArrayData::m_x
QVector< T > m_x
Definition: qwt_point_data.h:42
QVector
Definition: qwt_clipper.h:23
qwt_global.h
QwtSyntheticPointData::m_intervalOfInterest
QwtInterval m_intervalOfInterest
Definition: qwt_point_data.h:188
mqtt_test_proto.x
x
Definition: mqtt_test_proto.py:34
QwtSyntheticPointData::m_rectOfInterest
QRectF m_rectOfInterest
Definition: qwt_point_data.h:187
QwtCPointerData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_point_data.h:335
QwtValuePointData::m_y
QVector< T > m_y
Definition: qwt_point_data.h:79
mqtt_test_proto.y
y
Definition: mqtt_test_proto.py:35
QwtCPointerData::m_x
const T * m_x
Definition: qwt_point_data.h:55
QwtPointArrayData::xData
const QVector< T > & xData() const
Definition: qwt_point_data.h:246
QwtPointArrayData::QwtPointArrayData
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
Definition: qwt_point_data.h:200
nonstd::span_lite::size
span_constexpr std::size_t size(span< T, Extent > const &spn)
Definition: span.hpp:1554
QwtCPointerData
Data class containing two pointers to memory blocks of T.
Definition: qwt_point_data.h:43
QwtInterval
A class representing an interval.
Definition: qwt_interval.h:22
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
QwtSyntheticPointData
Synthetic point data.
Definition: qwt_point_data.h:157
QwtSyntheticPointData::m_interval
QwtInterval m_interval
Definition: qwt_point_data.h:186
QwtCPointerData::QwtCPointerData
QwtCPointerData(const T *x, const T *y, size_t size)
Definition: qwt_point_data.h:326
QwtSeriesData::sample
virtual T sample(size_t i) const =0
QwtCPointerData::xData
const T * xData() const
Definition: qwt_point_data.h:354
QwtValuePointData::sample
virtual QPointF sample(size_t index) const QWT_OVERRIDE
Definition: qwt_point_data.h:299
QwtCPointerValueData::yData
const T * yData() const
Definition: qwt_point_data.h:407
QwtPointArrayData::sample
virtual QPointF sample(size_t index) const QWT_OVERRIDE
Definition: qwt_point_data.h:239
QwtSyntheticPointData::m_size
size_t m_size
Definition: qwt_point_data.h:185
QwtValuePointData
Interface for iterating over a QVector<T>.
Definition: qwt_point_data.h:67
QwtPointArrayData::m_y
QVector< T > m_y
Definition: qwt_point_data.h:43
QwtCPointerData::m_size
size_t m_size
Definition: qwt_point_data.h:57
QwtCPointerData::m_y
const T * m_y
Definition: qwt_point_data.h:56
QWT_OVERRIDE
#define QWT_OVERRIDE
Definition: qwt_global.h:53
QWT_EXPORT
#define QWT_EXPORT
Definition: qwt_global.h:38
QwtCPointerValueData::m_y
const T * m_y
Definition: qwt_point_data.h:100
QwtSeriesData::size
virtual size_t size() const =0
QwtSeriesData::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_data.h:129
QwtPointArrayData::yData
const QVector< T > & yData() const
Definition: qwt_point_data.h:253
QwtPointArrayData::size
virtual size_t size() const QWT_OVERRIDE
Definition: qwt_point_data.h:227
QwtCPointerValueData::QwtCPointerValueData
QwtCPointerValueData(const T *y, size_t size)
Definition: qwt_point_data.h:380
QwtCPointerData::sample
virtual QPointF sample(size_t index) const QWT_OVERRIDE
Definition: qwt_point_data.h:347
qwt_series_data.h
QwtCPointerValueData::m_size
size_t m_size
Definition: qwt_point_data.h:101


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