qwt_series_store.h
/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
* Qwt Widget Library
* Copyright (C) 1997 Josef Wilgen
* Copyright (C) 2002 Uwe Rathmann
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the Qwt License, Version 1.0
*****************************************************************************/
#ifndef QWT_SERIES_STORE_H
#define QWT_SERIES_STORE_H
#include "qwt_global.h"
#include "qwt_series_data.h"
class QwtAbstractSeriesStore
{
protected:
virtual ~QwtAbstractSeriesStore() {}
#ifndef QWT_PYTHON_WRAPPER
virtual void dataChanged() = 0;
virtual void setRectOfInterest( const QRectF & ) = 0;
virtual QRectF dataRect() const = 0;
virtual size_t dataSize() const = 0;
#else
// Needed for generating the python bindings, but not for using them !
virtual void dataChanged() {}
virtual void setRectOfInterest( const QRectF & ) {}
virtual QRectF dataRect() const { return QRectF( 0.0, 0.0, -1.0, -1.0 ); }
virtual size_t dataSize() const { return 0; }
#endif
};
template <typename T>
class QwtSeriesStore: public virtual QwtAbstractSeriesStore
{
public:
explicit QwtSeriesStore<T>();
~QwtSeriesStore<T>();
void setData( QwtSeriesData<T> *series );
QwtSeriesData<T> *data();
const QwtSeriesData<T> *data() const;
T sample( int index ) const;
virtual size_t dataSize() const;
virtual QRectF dataRect() const;
virtual void setRectOfInterest( const QRectF &rect );
QwtSeriesData<T> *swapData( QwtSeriesData<T> *series );
private:
QwtSeriesData<T> *d_series;
};
template <typename T>
QwtSeriesStore<T>::QwtSeriesStore():
d_series( NULL )
{
}
template <typename T>
QwtSeriesStore<T>::~QwtSeriesStore()
{
delete d_series;
}
template <typename T>
inline QwtSeriesData<T> *QwtSeriesStore<T>::data()
{
return d_series;
}
template <typename T>
inline const QwtSeriesData<T> *QwtSeriesStore<T>::data() const
{
return d_series;
}
template <typename T>
inline T QwtSeriesStore<T>::sample( int index ) const
{
return d_series ? d_series->sample( index ) : T();
}
template <typename T>
void QwtSeriesStore<T>::setData( QwtSeriesData<T> *series )
{
if ( d_series != series )
{
delete d_series;
d_series = series;
dataChanged();
}
}
template <typename T>
size_t QwtSeriesStore<T>::dataSize() const
{
if ( d_series == NULL )
return 0;
return d_series->size();
}
template <typename T>
QRectF QwtSeriesStore<T>::dataRect() const
{
if ( d_series == NULL )
return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
return d_series->boundingRect();
}
template <typename T>
void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
{
if ( d_series )
d_series->setRectOfInterest( rect );
}
template <typename T>
QwtSeriesData<T>* QwtSeriesStore<T>::swapData( QwtSeriesData<T> *series )
{
QwtSeriesData<T> * swappedSeries = d_series;
d_series = series;
return swappedSeries;
}
#endif
QwtSeriesStore::data
const QwtSeriesData< T > * data() const
Definition: qwt_series_store.h:151
QwtAbstractSeriesStore::~QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:28
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:66
QwtSeriesStore::data
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:145
QwtAbstractSeriesStore::dataRect
virtual QRectF dataRect() const =0
QwtSeriesStore::swapData
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:199
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_series_data.h:48
QwtSeriesStore::dataSize
virtual size_t dataSize() const
Definition: qwt_series_store.h:174
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:163
QwtSeriesStore::dataRect
virtual QRectF dataRect() const
Definition: qwt_series_store.h:183
QwtSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_store.h:192
QwtSeriesStore::QwtSeriesStore
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:133
QwtSeriesStore::~QwtSeriesStore
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:139
QwtAbstractSeriesStore
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:25
QwtSeriesStore::sample
T sample(int index) const
Definition: qwt_series_store.h:157
QwtAbstractSeriesStore::dataChanged
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtAbstractSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &)=0
QwtAbstractSeriesStore::dataSize
virtual size_t dataSize() const =0