Qwt User's Guide 6.1.1

- Main Page
- Related Pages
- Classes

All Classes Functions Variables Typedefs Enumerations Enumerator Pages
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
31 virtual void dataChanged() = 0;
32
37 virtual void setRectOfInterest( const QRectF & ) = 0;
38
40 virtual QRectF dataRect() const = 0;
41
43 virtual size_t dataSize() const = 0;
44 };
45
56 template <typename T>
57 class QwtSeriesStore: public virtual QwtAbstractSeriesStore
58 {
59 public:
64 explicit QwtSeriesStore<T>();
65
67 ~QwtSeriesStore<T>();
68
76 void setData( QwtSeriesData<T> *series );
77
79 QwtSeriesData<T> *data();
80
82 const QwtSeriesData<T> *data() const;
83
88 T sample( int index ) const;
89
94 virtual size_t dataSize() const;
95
102 virtual QRectF dataRect() const;
103
110 virtual void setRectOfInterest( const QRectF &rect );
111
118 QwtSeriesData<T> *swapData( QwtSeriesData<T> *series );
119
120 private:
121 QwtSeriesData<T> *d_series;
122 };
123
124 template <typename T>
125 QwtSeriesStore<T>::QwtSeriesStore():
126 d_series( NULL )
127 {
128 }
129
130 template <typename T>
131 QwtSeriesStore<T>::~QwtSeriesStore()
132 {
133 delete d_series;
134 }
135
136 template <typename T>
137 inline QwtSeriesData<T> *QwtSeriesStore<T>::data()
138 {
139 return d_series;
140 }
141
142 template <typename T>
143 inline const QwtSeriesData<T> *QwtSeriesStore<T>::data() const
144 {
145 return d_series;
146 }
147
148 template <typename T>
149 inline T QwtSeriesStore<T>::sample( int index ) const
150 {
151 return d_series ? d_series->sample( index ) : T();
152 }
153
154 template <typename T>
155 void QwtSeriesStore<T>::setData( QwtSeriesData<T> *series )
156 {
157 if ( d_series != series )
158 {
159 delete d_series;
160 d_series = series;
161 dataChanged();
162 }
163 }
164
165 template <typename T>
166 size_t QwtSeriesStore<T>::dataSize() const
167 {
168 if ( d_series == NULL )
169 return 0;
170
171 return d_series->size();
172 }
173
174 template <typename T>
175 QRectF QwtSeriesStore<T>::dataRect() const
176 {
177 if ( d_series == NULL )
178 return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
179
180 return d_series->boundingRect();
181 }
182
183 template <typename T>
184 void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
185 {
186 if ( d_series )
187 d_series->setRectOfInterest( rect );
188 }
189
190 template <typename T>
191 QwtSeriesData<T>* QwtSeriesStore<T>::swapData( QwtSeriesData<T> *series )
192 {
193 QwtSeriesData<T> * swappedSeries = d_series;
194 d_series = series;
195
196 return swappedSeries;
197 }
198
199 #endif
QwtSeriesStore::data
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:137
QwtAbstractSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &)=0
QwtAbstractSeriesStore
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:24
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:155
QwtSeriesStore::sample
T sample(int index) const
Definition: qwt_series_store.h:149
QwtSeriesStore::swapData
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:191
QwtAbstractSeriesStore::dataChanged
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtSeriesStore::QwtSeriesStore
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:125
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_series_data.h:47
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:57
QwtSeriesStore::~QwtSeriesStore
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:131
QwtSeriesStore::dataRect
virtual QRectF dataRect() const
Definition: qwt_series_store.h:175
QwtSeriesStore::dataSize
virtual size_t dataSize() const
Definition: qwt_series_store.h:166
QwtSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_store.h:184
QwtAbstractSeriesStore::dataSize
virtual size_t dataSize() const =0
QwtAbstractSeriesStore::dataRect
virtual QRectF dataRect() const =0
QwtAbstractSeriesStore::~QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:28