QWT API (中文) 7.3.0
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 "qwtcore_global.h"
31#include "qwt_series_data.h"
32
41{
42public:
43 // Destructor
45 {
46 }
47
48protected:
49#ifndef QWT_PYTHON_WRAPPER
51 virtual void dataChanged() = 0;
52
54 virtual void setRectOfInterest(const QRectF&) = 0;
55
57 virtual QRectF dataRect() const = 0;
58
60 virtual size_t dataSize() const = 0;
61#else
62 // Needed for generating the python bindings, but not for using them !
63 virtual void dataChanged()
64 {
65 }
66 virtual void setRectOfInterest(const QRectF&)
67 {
68 }
69 virtual QRectF dataRect() const
70 {
71 return QRectF(0.0, 0.0, -1.0, -1.0);
72 }
73 virtual size_t dataSize() const
74 {
75 return 0;
76 }
77#endif
78};
79
89template< typename T >
91{
92public:
93 // Constructor - The store contains no series
94 explicit QwtSeriesStore();
95
96 // Destructor
98
99 // Assign a series of samples
100 void setData(QwtSeriesData< T >* series);
101
102 // Get the series data
103 QwtSeriesData< T >* data();
104
105 // Get the series data (const version)
106 const QwtSeriesData< T >* data() const;
107
108 // Get sample at position index
109 T sample(size_t index) const;
110
111 // Get number of samples of the series
112 virtual size_t dataSize() const override;
113
114 // Get bounding rectangle of the series or an invalid rectangle, when no series is stored
115 virtual QRectF dataRect() const override;
116
117 // Set a the "rect of interest" for the series
118 virtual void setRectOfInterest(const QRectF& rect) override;
119
120 // Replace a series without deleting the previous one
121 QwtSeriesData< T >* swapData(QwtSeriesData< T >* series);
122
123private:
124 QwtSeriesData< T >* m_series;
125};
126
127template< typename T >
128QwtSeriesStore< T >::QwtSeriesStore() : m_series(nullptr)
129{
130}
131
132template< typename T >
134{
135 delete m_series;
136}
137
138template< typename T >
140{
141 return m_series;
142}
143
144template< typename T >
146{
147 return m_series;
148}
149
150template< typename T >
151inline T QwtSeriesStore< T >::sample(size_t index) const
152{
153 return m_series ? m_series->sample(index) : T();
154}
155
156template< typename T >
158{
159 if (m_series != series) {
160 delete m_series;
161 m_series = series;
162 dataChanged();
163 }
164}
165
166template< typename T >
168{
169 if (m_series == nullptr)
170 return 0;
171
172 return m_series->size();
173}
174
175template< typename T >
177{
178 if (m_series == nullptr)
179 return QRectF(1.0, 1.0, -2.0, -2.0); // invalid
180
181 return m_series->boundingRect();
182}
183
184template< typename T >
186{
187 if (m_series)
188 m_series->setRectOfInterest(rect);
189}
190
191template< typename T >
193{
194 QwtSeriesData< T >* swappedSeries = m_series;
195 m_series = series;
196
197 return swappedSeries;
198}
199
200#endif
Bridge between QwtSeriesStore and QwtPlotSeriesItem
Definition qwt_series_store.h:41
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.
Abstract interface for iterating over samples
Definition qwt_series_data.h:88
Class storing a QwtSeriesData object
Definition qwt_series_store.h:91
virtual size_t dataSize() const override
Definition qwt_series_store.h:167
virtual QRectF dataRect() const override
Definition qwt_series_store.h:176
virtual void setRectOfInterest(const QRectF &rect) override
Set a the "rectangle of interest" for the stored series
Definition qwt_series_store.h:185