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
25{
26 public:
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
65template< typename T >
67{
68 public:
73 explicit QwtSeriesStore();
74
77
85 void setData( QwtSeriesData< T >* series );
86
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 >
135 : m_series( NULL )
136{
137}
138
139template< typename T >
141{
142 delete m_series;
143}
144
145template< typename T >
147{
148 return m_series;
149}
150
151template< typename T >
153{
154 return m_series;
155}
156
157template< typename T >
158inline T QwtSeriesStore< T >::sample( int index ) const
159{
160 return m_series ? m_series->sample( index ) : T();
161}
162
163template< typename T >
165{
166 if ( m_series != series )
167 {
168 delete m_series;
169 m_series = series;
170 dataChanged();
171 }
172}
173
174template< typename T >
176{
177 if ( m_series == NULL )
178 return 0;
179
180 return m_series->size();
181}
182
183template< typename T >
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
192template< typename T >
194{
195 if ( m_series )
196 m_series->setRectOfInterest( rect );
197}
198
199template< typename T >
201{
202 QwtSeriesData< T >* swappedSeries = m_series;
203 m_series = series;
204
205 return swappedSeries;
206}
207
208#endif
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
virtual QRectF dataRect() const =0
virtual ~QwtAbstractSeriesStore()
Destructor.
virtual void setRectOfInterest(const QRectF &)=0
virtual size_t dataSize() const =0
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
Abstract interface for iterating over samples.
Class storing a QwtSeriesData object.
T sample(int index) const
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
virtual size_t dataSize() const override
const QwtSeriesData< T > * data() const
QwtSeriesStore()
Constructor The store contains no series.
QwtSeriesData< T > * data()
void setData(QwtSeriesData< T > *series)
~QwtSeriesStore()
Destructor.
virtual QRectF dataRect() const override
virtual void setRectOfInterest(const QRectF &rect) override