QWT 7.0.1
Loading...
Searching...
No Matches
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
42{
43public:
46 {
47 }
48
49protected:
50#ifndef QWT_PYTHON_WRAPPER
52 virtual void dataChanged() = 0;
53
58 virtual void setRectOfInterest(const QRectF&) = 0;
59
61 virtual QRectF dataRect() const = 0;
62
64 virtual size_t dataSize() const = 0;
65#else
66 // Needed for generating the python bindings, but not for using them !
67 virtual void dataChanged()
68 {
69 }
70 virtual void setRectOfInterest(const QRectF&)
71 {
72 }
73 virtual QRectF dataRect() const
74 {
75 return QRectF(0.0, 0.0, -1.0, -1.0);
76 }
77 virtual size_t dataSize() const
78 {
79 return 0;
80 }
81#endif
82};
83
94template< typename T >
96{
97public:
102 explicit QwtSeriesStore();
103
106
115
118
120 const QwtSeriesData< T >* data() const;
121
126 T sample(size_t index) const;
127
132 virtual size_t dataSize() const QWT_OVERRIDE;
133
140 virtual QRectF dataRect() const QWT_OVERRIDE;
141
148 virtual void setRectOfInterest(const QRectF& rect) QWT_OVERRIDE;
149
157
158private:
159 QwtSeriesData< T >* m_series;
160};
161
162template< typename T >
163QwtSeriesStore< T >::QwtSeriesStore() : m_series(NULL)
164{
165}
166
167template< typename T >
169{
170 delete m_series;
171}
172
173template< typename T >
175{
176 return m_series;
177}
178
179template< typename T >
181{
182 return m_series;
183}
184
185template< typename T >
186inline T QwtSeriesStore< T >::sample(size_t index) const
187{
188 return m_series ? m_series->sample(index) : T();
189}
190
191template< typename T >
193{
194 if (m_series != series) {
195 delete m_series;
196 m_series = series;
197 dataChanged();
198 }
199}
200
201template< typename T >
203{
204 if (m_series == NULL)
205 return 0;
206
207 return m_series->size();
208}
209
210template< typename T >
212{
213 if (m_series == NULL)
214 return QRectF(1.0, 1.0, -2.0, -2.0); // invalid
215
216 return m_series->boundingRect();
217}
218
219template< typename T >
221{
222 if (m_series)
223 m_series->setRectOfInterest(rect);
224}
225
226template< typename T >
228{
229 QwtSeriesData< T >* swappedSeries = m_series;
230 m_series = series;
231
232 return swappedSeries;
233}
234
235#endif
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition qwt_series_store.h:42
virtual QRectF dataRect() const =0
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition qwt_series_store.h:45
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:67
Class storing a QwtSeriesData object.
Definition qwt_series_store.h:96
virtual size_t dataSize() const QWT_OVERRIDE
Definition qwt_series_store.h:202
virtual QRectF dataRect() const QWT_OVERRIDE
Definition qwt_series_store.h:211
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Replace a series without deleting the previous one.
Definition qwt_series_store.h:227
const QwtSeriesData< T > * data() const
Definition qwt_series_store.h:180
T sample(size_t index) const
Definition qwt_series_store.h:186
QwtSeriesStore()
Constructor The store contains no series.
Definition qwt_series_store.h:163
QwtSeriesData< T > * data()
Definition qwt_series_store.h:174
virtual void setRectOfInterest(const QRectF &rect) QWT_OVERRIDE
Set a the "rect of interest" for the series.
Definition qwt_series_store.h:220
void setData(QwtSeriesData< T > *series)
Assign a series of samples.
Definition qwt_series_store.h:192
~QwtSeriesStore()
Destructor.
Definition qwt_series_store.h:168