Qwt User's Guide  6.1.3
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 
25 {
26 protected:
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>
58 {
59 public:
64  explicit QwtSeriesStore<T>();
65 
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>
126  d_series( NULL )
127 {
128 }
129 
130 template <typename T>
132 {
133  delete d_series;
134 }
135 
136 template <typename T>
138 {
139  return d_series;
140 }
141 
142 template <typename T>
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>
156 {
157  if ( d_series != series )
158  {
159  delete d_series;
160  d_series = series;
161  dataChanged();
162  }
163 }
164 
165 template <typename T>
167 {
168  if ( d_series == NULL )
169  return 0;
170 
171  return d_series->size();
172 }
173 
174 template <typename T>
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>
192 {
193  QwtSeriesData<T> * swappedSeries = d_series;
194  d_series = series;
195 
196  return swappedSeries;
197 }
198 
199 #endif
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:137
virtual void setRectOfInterest(const QRectF &)=0
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:24
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:155
T sample(int index) const
Definition: qwt_series_store.h:149
virtual QRectF dataRect() const =0
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:191
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:125
Abstract interface for iterating over samples.
Definition: qwt_series_data.h:47
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:57
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:131
virtual QRectF dataRect() const
Definition: qwt_series_store.h:175
virtual size_t dataSize() const =0
virtual size_t dataSize() const
Definition: qwt_series_store.h:166
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_store.h:184
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:28