qwt_series_store.h
/******************************************************************************
* 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
{
public:
virtual ~QwtAbstractSeriesStore() {}
protected:
#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();
~QwtSeriesStore();
void setData( QwtSeriesData< T >* series );
QwtSeriesData< T >* data();
const QwtSeriesData< T >* data() const;
T sample( int index ) const;
virtual size_t dataSize() const QWT_OVERRIDE;
virtual QRectF dataRect() const QWT_OVERRIDE;
virtual void setRectOfInterest( const QRectF& rect ) QWT_OVERRIDE;
QwtSeriesData< T >* swapData( QwtSeriesData< T >* series );
private:
QwtSeriesData< T >* m_series;
};
template< typename T >
QwtSeriesStore< T >::QwtSeriesStore()
: m_series( NULL )
{
}
template< typename T >
QwtSeriesStore< T >::~QwtSeriesStore()
{
delete m_series;
}
template< typename T >
inline QwtSeriesData< T >* QwtSeriesStore< T >::data()
{
return m_series;
}
template< typename T >
inline const QwtSeriesData< T >* QwtSeriesStore< T >::data() const
{
return m_series;
}
template< typename T >
inline T QwtSeriesStore< T >::sample( int index ) const
{
return m_series ? m_series->sample( index ) : T();
}
template< typename T >
void QwtSeriesStore< T >::setData( QwtSeriesData< T >* series )
{
if ( m_series != series )
{
delete m_series;
m_series = series;
dataChanged();
}
}
template< typename T >
size_t QwtSeriesStore< T >::dataSize() const
{
if ( m_series == NULL )
return 0;
return m_series->size();
}
template< typename T >
QRectF QwtSeriesStore< T >::dataRect() const
{
if ( m_series == NULL )
return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
return m_series->boundingRect();
}
template< typename T >
void QwtSeriesStore< T >::setRectOfInterest( const QRectF& rect )
{
if ( m_series )
m_series->setRectOfInterest( rect );
}
template< typename T >
QwtSeriesData< T >* QwtSeriesStore< T >::swapData( QwtSeriesData< T >* series )
{
QwtSeriesData< T >* swappedSeries = m_series;
m_series = series;
return swappedSeries;
}
#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