QWT API (中文) 7.0.1
Qt绘图库 - 中文API文档
载入中...
搜索中...
未找到
qwt_series_store.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_SERIES_STORE_H
28#define QWT_SERIES_STORE_H
29
30#include "qwt_global.h"
31#include "qwt_series_data.h"
32
49{
50public:
51 // Destructor
53 {
54 }
55
56protected:
57#ifndef QWT_PYTHON_WRAPPER
59 virtual void dataChanged() = 0;
60
62 virtual void setRectOfInterest(const QRectF&) = 0;
63
65 virtual QRectF dataRect() const = 0;
66
68 virtual size_t dataSize() const = 0;
69#else
70 // Needed for generating the python bindings, but not for using them !
71 virtual void dataChanged()
72 {
73 }
74 virtual void setRectOfInterest(const QRectF&)
75 {
76 }
77 virtual QRectF dataRect() const
78 {
79 return QRectF(0.0, 0.0, -1.0, -1.0);
80 }
81 virtual size_t dataSize() const
82 {
83 return 0;
84 }
85#endif
86};
87
107template< typename T >
109{
110public:
111 // Constructor - The store contains no series
112 explicit QwtSeriesStore();
113
114 // Destructor
116
117 // Assign a series of samples
118 void setData(QwtSeriesData< T >* series);
119
120 // Get the series data
121 QwtSeriesData< T >* data();
122
123 // Get the series data (const version)
124 const QwtSeriesData< T >* data() const;
125
126 // Get sample at position index
127 T sample(size_t index) const;
128
129 // Get number of samples of the series
130 virtual size_t dataSize() const override;
131
132 // Get bounding rectangle of the series or an invalid rectangle, when no series is stored
133 virtual QRectF dataRect() const override;
134
135 // Set a the "rect of interest" for the series
136 virtual void setRectOfInterest(const QRectF& rect) override;
137
138 // Replace a series without deleting the previous one
139 QwtSeriesData< T >* swapData(QwtSeriesData< T >* series);
140
141private:
142 QwtSeriesData< T >* m_series;
143};
144
145template< typename T >
146QwtSeriesStore< T >::QwtSeriesStore() : m_series(nullptr)
147{
148}
149
150template< typename T >
152{
153 delete m_series;
154}
155
156template< typename T >
158{
159 return m_series;
160}
161
162template< typename T >
164{
165 return m_series;
166}
167
168template< typename T >
169inline T QwtSeriesStore< T >::sample(size_t index) const
170{
171 return m_series ? m_series->sample(index) : T();
172}
173
174template< typename T >
176{
177 if (m_series != series) {
178 delete m_series;
179 m_series = series;
180 dataChanged();
181 }
182}
183
184template< typename T >
186{
187 if (m_series == nullptr)
188 return 0;
189
190 return m_series->size();
191}
192
193template< typename T >
195{
196 if (m_series == nullptr)
197 return QRectF(1.0, 1.0, -2.0, -2.0); // invalid
198
199 return m_series->boundingRect();
200}
201
202template< typename T >
204{
205 if (m_series)
206 m_series->setRectOfInterest(rect);
207}
208
209template< typename T >
211{
212 QwtSeriesData< T >* swappedSeries = m_series;
213 m_series = series;
214
215 return swappedSeries;
216}
217
218#endif
QwtSeriesStore 和 QwtPlotSeriesItem 之间的桥梁
Definition qwt_series_store.h:49
virtual QRectF dataRect() const =0
virtual void setRectOfInterest(const QRectF &)=0
Set a the "rectangle of interest" for the stored series
virtual size_t dataSize() const =0
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
遍历样本的抽象接口
Definition qwt_series_data.h:72
存储 QwtSeriesData 对象的类
Definition qwt_series_store.h:109
virtual size_t dataSize() const override
Definition qwt_series_store.h:185
virtual QRectF dataRect() const override
Definition qwt_series_store.h:194
virtual void setRectOfInterest(const QRectF &rect) override
Set a the "rectangle of interest" for the stored series
Definition qwt_series_store.h:203