Qwt User's Guide: qwt_series_store.h Source File

Qwt User's Guide 6.1.5

qwt_series_store.h
1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
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
10 #ifndef QWT_SERIES_STORE_H
11 #define QWT_SERIES_STORE_H
12
13 #include "qwt_global.h"
14 #include "qwt_series_data.h"
15
24 class QwtAbstractSeriesStore
25 {
26 protected:
28 virtual ~QwtAbstractSeriesStore() {}
29
30 #ifndef QWT_PYTHON_WRAPPER
31 virtual void dataChanged() = 0;
33
38 virtual void setRectOfInterest( const QRectF & ) = 0;
39
41 virtual QRectF dataRect() const = 0;
42
44 virtual size_t dataSize() const = 0;
45 #else
46 // Needed for generating the python bindings, but not for using them !
47 virtual void dataChanged() {}
48 virtual void setRectOfInterest( const QRectF & ) {}
49 virtual QRectF dataRect() const { return QRectF( 0.0, 0.0, -1.0, -1.0 ); }
50 virtual size_t dataSize() const { return 0; }
51 #endif
52 };
53
64 template <typename T>
65 class QwtSeriesStore: public virtual QwtAbstractSeriesStore
66 {
67 public:
72 explicit QwtSeriesStore<T>();
73
75 ~QwtSeriesStore<T>();
76
84 void setData( QwtSeriesData<T> *series );
85
87 QwtSeriesData<T> *data();
88
90 const QwtSeriesData<T> *data() const;
91
96 T sample( int index ) const;
97
102 virtual size_t dataSize() const;
103
110 virtual QRectF dataRect() const;
111
118 virtual void setRectOfInterest( const QRectF &rect );
119
126 QwtSeriesData<T> *swapData( QwtSeriesData<T> *series );
127
128 private:
129 QwtSeriesData<T> *d_series;
130 };
131
132 template <typename T>
133 QwtSeriesStore<T>::QwtSeriesStore():
134 d_series( NULL )
135 {
136 }
137
138 template <typename T>
139 QwtSeriesStore<T>::~QwtSeriesStore()
140 {
141 delete d_series;
142 }
143
144 template <typename T>
145 inline QwtSeriesData<T> *QwtSeriesStore<T>::data()
146 {
147 return d_series;
148 }
149
150 template <typename T>
151 inline const QwtSeriesData<T> *QwtSeriesStore<T>::data() const
152 {
153 return d_series;
154 }
155
156 template <typename T>
157 inline T QwtSeriesStore<T>::sample( int index ) const
158 {
159 return d_series ? d_series->sample( index ) : T();
160 }
161
162 template <typename T>
163 void QwtSeriesStore<T>::setData( QwtSeriesData<T> *series )
164 {
165 if ( d_series != series )
166 {
167 delete d_series;
168 d_series = series;
169 dataChanged();
170 }
171 }
172
173 template <typename T>
174 size_t QwtSeriesStore<T>::dataSize() const
175 {
176 if ( d_series == NULL )
177 return 0;
178
179 return d_series->size();
180 }
181
182 template <typename T>
183 QRectF QwtSeriesStore<T>::dataRect() const
184 {
185 if ( d_series == NULL )
186 return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
187
188 return d_series->boundingRect();
189 }
190
191 template <typename T>
192 void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
193 {
194 if ( d_series )
195 d_series->setRectOfInterest( rect );
196 }
197
198 template <typename T>
199 QwtSeriesData<T>* QwtSeriesStore<T>::swapData( QwtSeriesData<T> *series )
200 {
201 QwtSeriesData<T> * swappedSeries = d_series;
202 d_series = series;
203
204 return swappedSeries;
205 }
206
207 #endif
QwtAbstractSeriesStore::~QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:28
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:65
QwtSeriesStore::data
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:145
QwtAbstractSeriesStore::dataRect
virtual QRectF dataRect() const =0
QwtSeriesStore::swapData
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:199
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_series_data.h:47
QwtSeriesStore::dataSize
virtual size_t dataSize() const
Definition: qwt_series_store.h:174
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:163
QwtSeriesStore::dataRect
virtual QRectF dataRect() const
Definition: qwt_series_store.h:183
QwtSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_store.h:192
QwtSeriesStore::QwtSeriesStore
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:133
QwtSeriesStore::~QwtSeriesStore
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:139
QwtAbstractSeriesStore
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:24
QwtSeriesStore::sample
T sample(int index) const
Definition: qwt_series_store.h:157
QwtAbstractSeriesStore::dataChanged
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtAbstractSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &)=0
QwtAbstractSeriesStore::dataSize
virtual size_t dataSize() const =0