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() {}
virtual void dataChanged() = 0;
virtual void setRectOfInterest( const QRectF & ) = 0;
virtual QRectF dataRect() const = 0;
virtual size_t dataSize() const = 0;
};
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
QwtSeriesData< T > * data()
Definition: qwt_series_store.h:137
QwtAbstractSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &)=0
QwtAbstractSeriesStore
Bridge between QwtSeriesStore and QwtPlotSeriesItem.
Definition: qwt_series_store.h:24
QwtSeriesStore::setData
void setData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:155
QwtSeriesStore::sample
T sample(int index) const
Definition: qwt_series_store.h:149
QwtAbstractSeriesStore::dataRect
virtual QRectF dataRect() const =0
QwtSeriesStore::swapData
QwtSeriesData< T > * swapData(QwtSeriesData< T > *series)
Definition: qwt_series_store.h:191
QwtAbstractSeriesStore::dataChanged
virtual void dataChanged()=0
dataChanged() indicates, that the series has been changed.
QwtSeriesStore::QwtSeriesStore
QwtSeriesStore()
Constructor The store contains no series.
Definition: qwt_series_store.h:125
QwtSeriesData
Abstract interface for iterating over samples.
Definition: qwt_series_data.h:47
QwtSeriesStore
Class storing a QwtSeriesData object.
Definition: qwt_series_store.h:57
QwtSeriesStore::~QwtSeriesStore
~QwtSeriesStore()
Destructor.
Definition: qwt_series_store.h:131
QwtSeriesStore::dataRect
virtual QRectF dataRect() const
Definition: qwt_series_store.h:175
QwtAbstractSeriesStore::dataSize
virtual size_t dataSize() const =0
QwtSeriesStore::dataSize
virtual size_t dataSize() const
Definition: qwt_series_store.h:166
QwtSeriesStore::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition: qwt_series_store.h:184
QwtAbstractSeriesStore::~QwtAbstractSeriesStore
virtual ~QwtAbstractSeriesStore()
Destructor.
Definition: qwt_series_store.h:28