Qwt User's Guide 6.3.0

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