QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
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 * Modified by ChenZongYan in 2024 <czy.t@163.com>
10 * Summary of major modifications (see ChangeLog.md for full history):
11 * 1. CMake build system & C++11 throughout.
12 * 2. Core panner/ zoomer refactored:
13 * - QwtPanner → QwtCachePanner (pixmap-cache version)
14 * - New real-time QwtPlotPanner derived from QwtPicker.
15 * 3. Zoomer supports multi-axis.
16 * 4. Parasite-plot framework:
17 * - QwtFigure, QwtPlotParasiteLayout, QwtPlotTransparentCanvas,
18 * - QwtPlotScaleEventDispatcher, built-in pan/zoom on axis.
19 * 5. New picker: QwtPlotSeriesDataPicker (works with date axis).
20 * 6. Raster & color-map extensions:
21 * - QwtGridRasterData (2-D table + interpolation)
22 * - QwtLinearColorMap::stopColors(), stopPos() API rename.
23 * 7. Bar-chart: expose pen/brush control.
24 * 8. Amalgamated build: single QwtPlot.h / QwtPlot.cpp pair in src-amalgamate.
25 *****************************************************************************/
26
27#ifndef QWT_POINT_DATA_H
28#define QWT_POINT_DATA_H
29
30#include "qwt_global.h"
31#include "qwt_series_data.h"
32
33#include <cstring>
34
44template< typename T >
46{
47public:
53 QwtPointArrayData(const T* x, const T* y, size_t size);
54
56 virtual size_t size() const override;
58 virtual QPointF sample(size_t index) const override;
59
61 const QVector< T >& xData() const;
63 const QVector< T >& yData() const;
64
65private:
66 QVector< T > m_x;
67 QVector< T > m_y;
68};
69
79template< typename T >
81{
82public:
84 QwtCPointerData(const T* x, const T* y, size_t size);
85
87 virtual size_t size() const override;
89 virtual QPointF sample(size_t index) const override;
90
92 const T* xData() const;
94 const T* yData() const;
95
96private:
97 const T* m_x;
98 const T* m_y;
99 size_t m_size;
100};
101
116template< typename T >
118{
119public:
123 QwtValuePointData(const T* y, size_t size);
124
126 virtual size_t size() const override;
128 virtual QPointF sample(size_t index) const override;
129
131 const QVector< T >& yData() const;
132
133private:
134 QVector< T > m_y;
135};
136
151template< typename T >
153{
154public:
156 QwtCPointerValueData(const T* y, size_t size);
157
159 virtual size_t size() const override;
161 virtual QPointF sample(size_t index) const override;
162
164 const T* yData() const;
165
166private:
167 const T* m_y;
168 size_t m_size;
169};
170
279{
280public:
281 // Constructor
282 QwtSyntheticPointData(size_t size, const QwtInterval& = QwtInterval());
283
284 // Set the number of points
285 void setSize(size_t size);
286 // Get the number of points
287 virtual size_t size() const override;
288
289 // Set the interval
290 void setInterval(const QwtInterval&);
291 // Get the interval
292 QwtInterval interval() const;
293
294 // Get the bounding rectangle
295 virtual QRectF boundingRect() const override;
296 // Get the sample at a specific index
297 virtual QPointF sample(size_t index) const override;
298
314 virtual double y(double x) const = 0;
315 // Calculate the x value for a given index
316 virtual double x(size_t index) const;
317
318 // Set the rectangle of interest
319 virtual void setRectOfInterest(const QRectF&) override;
320 // Get the rectangle of interest
321 QRectF rectOfInterest() const;
322
323private:
324 size_t m_size;
325 QwtInterval m_interval;
326 QRectF m_rectOfInterest;
327 QwtInterval m_intervalOfInterest;
328};
329
331template< typename T >
333{
334}
335
337template< typename T >
339{
340 m_x = std::move(x);
341 m_y = std::move(y);
342}
343
345template< typename T >
346QwtPointArrayData< T >::QwtPointArrayData(const T* x, const T* y, size_t size)
347{
348 m_x.resize(size);
349 std::memcpy(m_x.data(), x, size * sizeof(T));
350
351 m_y.resize(size);
352 std::memcpy(m_y.data(), y, size * sizeof(T));
353}
354
356template< typename T >
358{
359 return qMin(m_x.size(), m_y.size());
360}
361
363template< typename T >
364QPointF QwtPointArrayData< T >::sample(size_t index) const
365{
366 return QPointF(m_x[ int(index) ], m_y[ int(index) ]);
367}
368
370template< typename T >
372{
373 return m_x;
374}
375
377template< typename T >
379{
380 return m_y;
381}
382
384template< typename T >
388
390template< typename T >
392{
393 m_y.resize(size);
394 std::memcpy(m_y.data(), y, size * sizeof(T));
395}
396
398template< typename T >
400{
401 return m_y.size();
402}
403
405template< typename T >
406QPointF QwtValuePointData< T >::sample(size_t index) const
407{
408 return QPointF(index, m_y[ int(index) ]);
409}
410
412template< typename T >
414{
415 return m_y;
416}
417
419template< typename T >
420QwtCPointerData< T >::QwtCPointerData(const T* x, const T* y, size_t size) : m_x(x), m_y(y), m_size(size)
421{
422}
423
425template< typename T >
427{
428 return m_size;
429}
430
432template< typename T >
433QPointF QwtCPointerData< T >::sample(size_t index) const
434{
435 return QPointF(m_x[ int(index) ], m_y[ int(index) ]);
436}
437
439template< typename T >
441{
442 return m_x;
443}
444
446template< typename T >
448{
449 return m_y;
450}
451
453template< typename T >
454QwtCPointerValueData< T >::QwtCPointerValueData(const T* y, size_t size) : m_y(y), m_size(size)
455{
456}
457
459template< typename T >
461{
462 return m_size;
463}
464
466template< typename T >
467QPointF QwtCPointerValueData< T >::sample(size_t index) const
468{
469 return QPointF(index, m_y[ int(index) ]);
470}
471
473template< typename T >
475{
476 return m_y;
477}
478
479#endif
Definition qwt_clipper.h:40
virtual QPointF sample(size_t index) const override
Definition qwt_series_data.h:215
virtual size_t size() const override
Definition qwt_series_data.h:209
包含两个指向 T 类型内存块的指针的数据类
Definition qwt_point_data.h:81
const T * xData() const
Get the x-data pointer
Definition qwt_point_data.h:440
const T * yData() const
Get the y-data pointer
Definition qwt_point_data.h:447
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:426
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:433
QwtCPointerData(const T *x, const T *y, size_t size)
Constructor with C-style arrays
Definition qwt_point_data.h:420
包含指向 y 坐标内存的指针的数据类
Definition qwt_point_data.h:153
QwtCPointerValueData(const T *y, size_t size)
Constructor with C-style array
Definition qwt_point_data.h:454
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:460
const T * yData() const
Get the y-data pointer
Definition qwt_point_data.h:474
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:467
表示区间的类
Definition qwt_interval.h:45
用于遍历两个 QVector<T> 对象的接口
Definition qwt_point_data.h:46
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:364
const QVector< T > & xData() const
Get the x-data vector
Definition qwt_point_data.h:371
const QVector< T > & yData() const
Get the y-data vector
Definition qwt_point_data.h:378
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
Constructor with QVector references
Definition qwt_point_data.h:332
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:357
点数组迭代接口
Definition qwt_series_data.h:231
virtual QRectF boundingRect() const override
Calculate the bounding rectangle
Definition qwt_series_data.cpp:530
virtual void setRectOfInterest(const QRectF &rect)
Set a the "rect of interest"
Definition qwt_series_data.h:129
合成点数据
Definition qwt_point_data.h:279
virtual double y(double x) const =0
计算 x 值对应的 y 值
用于遍历 QVector<T> 的接口
Definition qwt_point_data.h:118
QwtValuePointData(const QVector< T > &y)
Constructor with QVector reference
Definition qwt_point_data.h:385
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:399
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:406
const QVector< T > & yData() const
Get the y-data vector
Definition qwt_point_data.h:413