QWT API (中文) 7.3.0
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 "qwtcore_global.h"
31#include "qwt_series_data.h"
32
33#include <cstring>
34
38template< typename T >
40{
41public:
47 QwtPointArrayData(const T* x, const T* y, size_t size);
48
50 virtual size_t size() const override;
52 virtual QPointF sample(size_t index) const override;
53
55 const QVector< T >& xData() const;
57 const QVector< T >& yData() const;
58
59private:
60 QVector< T > m_x;
61 QVector< T > m_y;
62};
63
67template< typename T >
69{
70public:
72 QwtCPointerData(const T* x, const T* y, size_t size);
73
75 virtual size_t size() const override;
77 virtual QPointF sample(size_t index) const override;
78
80 const T* xData() const;
82 const T* yData() const;
83
84private:
85 const T* m_x;
86 const T* m_y;
87 size_t m_size;
88};
89
96template< typename T >
98{
99public:
103 QwtValuePointData(const T* y, size_t size);
104
106 virtual size_t size() const override;
108 virtual QPointF sample(size_t index) const override;
109
111 const QVector< T >& yData() const;
112
113private:
114 QVector< T > m_y;
115};
116
123template< typename T >
125{
126public:
128 QwtCPointerValueData(const T* y, size_t size);
129
131 virtual size_t size() const override;
133 virtual QPointF sample(size_t index) const override;
134
136 const T* yData() const;
137
138private:
139 const T* m_y;
140 size_t m_size;
141};
142
196class QWTCORE_EXPORT QwtSyntheticPointData : public QwtPointSeriesData
197{
198public:
199 // Constructor
200 QwtSyntheticPointData(size_t size, const QwtInterval& = QwtInterval());
201
202 // Set the number of points
203 void setSize(size_t size);
204 // Get the number of points
205 virtual size_t size() const override;
206
207 // Set the interval
208 void setInterval(const QwtInterval&);
209 // Get the interval
210 QwtInterval interval() const;
211
212 // Get the bounding rectangle
213 virtual QRectF boundingRect() const override;
214 // Get the sample at a specific index
215 virtual QPointF sample(size_t index) const override;
216
217 // Calculate a y value for a x value
218 virtual double y(double x) const = 0;
219 // Calculate the x value for a given index
220 virtual double x(size_t index) const;
221
222 // Set the rectangle of interest
223 virtual void setRectOfInterest(const QRectF&) override;
224 // Get the rectangle of interest
225 QRectF rectOfInterest() const;
226
227private:
228 size_t m_size;
229 QwtInterval m_interval;
230 QRectF m_rectOfInterest;
231 QwtInterval m_intervalOfInterest;
232};
233
235template< typename T >
237{
238}
239
241template< typename T >
243{
244 m_x = std::move(x);
245 m_y = std::move(y);
246}
247
249template< typename T >
250QwtPointArrayData< T >::QwtPointArrayData(const T* x, const T* y, size_t size)
251{
252 m_x.resize(size);
253 std::memcpy(m_x.data(), x, size * sizeof(T));
254
255 m_y.resize(size);
256 std::memcpy(m_y.data(), y, size * sizeof(T));
257}
258
260template< typename T >
262{
263 return qMin(m_x.size(), m_y.size());
264}
265
267template< typename T >
268QPointF QwtPointArrayData< T >::sample(size_t index) const
269{
270 return QPointF(m_x[ int(index) ], m_y[ int(index) ]);
271}
272
274template< typename T >
276{
277 return m_x;
278}
279
281template< typename T >
283{
284 return m_y;
285}
286
288template< typename T >
292
294template< typename T >
296{
297 m_y.resize(size);
298 std::memcpy(m_y.data(), y, size * sizeof(T));
299}
300
302template< typename T >
304{
305 return m_y.size();
306}
307
309template< typename T >
310QPointF QwtValuePointData< T >::sample(size_t index) const
311{
312 return QPointF(index, m_y[ int(index) ]);
313}
314
316template< typename T >
318{
319 return m_y;
320}
321
323template< typename T >
324QwtCPointerData< T >::QwtCPointerData(const T* x, const T* y, size_t size) : m_x(x), m_y(y), m_size(size)
325{
326}
327
329template< typename T >
331{
332 return m_size;
333}
334
336template< typename T >
337QPointF QwtCPointerData< T >::sample(size_t index) const
338{
339 return QPointF(m_x[ int(index) ], m_y[ int(index) ]);
340}
341
343template< typename T >
345{
346 return m_x;
347}
348
350template< typename T >
352{
353 return m_y;
354}
355
357template< typename T >
358QwtCPointerValueData< T >::QwtCPointerValueData(const T* y, size_t size) : m_y(y), m_size(size)
359{
360}
361
363template< typename T >
365{
366 return m_size;
367}
368
370template< typename T >
371QPointF QwtCPointerValueData< T >::sample(size_t index) const
372{
373 return QPointF(index, m_y[ int(index) ]);
374}
375
377template< typename T >
379{
380 return m_y;
381}
382
383#endif
Definition qwt_clipper.h:41
virtual QPointF sample(size_t index) const override
Definition qwt_series_data.h:225
virtual size_t size() const override
Definition qwt_series_data.h:219
Data class containing two pointers to memory blocks of T.
Definition qwt_point_data.h:69
const T * xData() const
Get the x-data pointer
Definition qwt_point_data.h:344
const T * yData() const
Get the y-data pointer
Definition qwt_point_data.h:351
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:330
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:337
QwtCPointerData(const T *x, const T *y, size_t size)
Constructor with C-style arrays
Definition qwt_point_data.h:324
Data class containing a pointer to memory of y coordinates
Definition qwt_point_data.h:125
QwtCPointerValueData(const T *y, size_t size)
Constructor with C-style array
Definition qwt_point_data.h:358
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:364
const T * yData() const
Get the y-data pointer
Definition qwt_point_data.h:378
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:371
A class representing an interval
Definition qwt_interval.h:39
Interface for iterating over two QVector<T> objects.
Definition qwt_point_data.h:40
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:268
const QVector< T > & xData() const
Get the x-data vector
Definition qwt_point_data.h:275
const QVector< T > & yData() const
Get the y-data vector
Definition qwt_point_data.h:282
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
Constructor with QVector references
Definition qwt_point_data.h:236
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:261
Interface for iterating over an array of points
Definition qwt_series_data.h:235
virtual QRectF boundingRect() const override
Calculate the bounding rectangle
Definition qwt_series_data.cpp:415
virtual void setRectOfInterest(const QRectF &rect)
Set a the "rect of interest"
Definition qwt_series_data.h:145
Synthetic point data
Definition qwt_point_data.h:197
Interface for iterating over a QVector<T>.
Definition qwt_point_data.h:98
QwtValuePointData(const QVector< T > &y)
Constructor with QVector reference
Definition qwt_point_data.h:289
virtual size_t size() const override
Get the size of the data set
Definition qwt_point_data.h:303
virtual QPointF sample(size_t index) const override
Get the sample at a specific index
Definition qwt_point_data.h:310
const QVector< T > & yData() const
Get the y-data vector
Definition qwt_point_data.h:317