qwt_series_store.h
Go to the documentation of this file.
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:
28  virtual ~QwtAbstractSeriesStore() {}
29 
30  protected:
31 #ifndef QWT_PYTHON_WRAPPER
32  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 
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 
128 
129  private:
131 };
132 
133 template< typename T >
135  : m_series( NULL )
136 {
137 }
138 
139 template< typename T >
141 {
142  delete m_series;
143 }
144 
145 template< typename T >
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 >
165 {
166  if ( m_series != series )
167  {
168  delete m_series;
169  m_series = series;
170  dataChanged();
171  }
172 }
173 
174 template< typename T >
176 {
177  if ( m_series == NULL )
178  return 0;
179 
180  return m_series->size();
181 }
182 
183 template< 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 
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 >
201 {
202  QwtSeriesData< T >* swappedSeries = m_series;
203  m_series = series;
204 
205  return swappedSeries;
206 }
207 
208 #endif
QwtAbstractSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &)=0
QwtAbstractSeriesStore::~QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:35
QwtSeriesStore::sample
T sample(int index) const
Definition: qwt_series_store.h:158
qwt_global.h
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:164
QwtSeriesStore::dataRect
virtual QRectF dataRect() const QWT_OVERRIDE
Definition: qwt_series_store.h:184
QwtAbstractSeriesStore::dataRect
virtual QRectF dataRect() const =0
QwtSeriesStore::~QwtSeriesStore
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:140
QwtSeriesStore::m_series
QwtSeriesData< T > * m_series
Definition: qwt_series_store.h:130
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_plot_barchart.h:18
QwtSeriesStore::data
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:146
QwtSeriesStore::dataSize
virtual size_t dataSize() const QWT_OVERRIDE
Definition: qwt_series_store.h:175
QwtAbstractSeriesStore::dataChanged
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtSeriesStore::swapData
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:200
QwtSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect) QWT_OVERRIDE
Definition: qwt_series_store.h:193
QWT_OVERRIDE
#define QWT_OVERRIDE
Definition: qwt_global.h:53
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:66
QwtAbstractSeriesStore::dataSize
virtual size_t dataSize() const =0
qwt_series_data.h
QwtSeriesStore::QwtSeriesStore
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:134
QwtAbstractSeriesStore
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:24


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:46