Loading...
Searching...
No Matches
qwt_point_data.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_POINT_DATA_H
#define QWT_POINT_DATA_H
#include "qwt_global.h"
#include "qwt_series_data.h"
#include <cstring>
template< typename T >
class QwtPointArrayData : public QwtSeriesData< QPointF >
{
public:
QwtPointArrayData( const QVector< T >& x, const QVector< T >& y );
QwtPointArrayData( const T* x, const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const QVector< T >& xData() const;
const QVector< T >& yData() const;
private:
QVector< T > m_x;
QVector< T > m_y;
};
template< typename T >
class QwtCPointerData : public QwtSeriesData< QPointF >
{
public:
QwtCPointerData( const T* x, const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const T* xData() const;
const T* yData() const;
private:
const T* m_x;
const T* m_y;
size_t m_size;
};
template< typename T >
class QwtValuePointData : public QwtSeriesData< QPointF >
{
public:
QwtValuePointData( const QVector< T >& y );
QwtValuePointData( const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const QVector< T >& yData() const;
private:
QVector< T > m_y;
};
template< typename T >
class QwtCPointerValueData : public QwtSeriesData< QPointF >
{
public:
QwtCPointerValueData( const T* y, size_t size );
virtual size_t size() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
const T* yData() const;
private:
const T* m_y;
size_t m_size;
};
class QWT_EXPORT QwtSyntheticPointData : public QwtSeriesData< QPointF >
{
public:
QwtSyntheticPointData( size_t size,
const QwtInterval& = QwtInterval() );
void setSize( size_t size );
virtual size_t size() const QWT_OVERRIDE;
void setInterval( const QwtInterval& );
QwtInterval interval() const;
virtual QRectF boundingRect() const QWT_OVERRIDE;
virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
virtual double y( double x ) const = 0;
virtual double x( uint index ) const;
virtual void setRectOfInterest( const QRectF& ) QWT_OVERRIDE;
QRectF rectOfInterest() const;
private:
size_t m_size;
QwtInterval m_interval;
QRectF m_rectOfInterest;
QwtInterval m_intervalOfInterest;
};
template< typename T >
QwtPointArrayData< T >::QwtPointArrayData(
const QVector< T >& x, const QVector< T >& y )
: m_x( x )
, m_y( y )
{
}
template< typename T >
QwtPointArrayData< T >::QwtPointArrayData( const T* x, const T* y, size_t size )
{
m_x.resize( size );
std::memcpy( m_x.data(), x, size * sizeof( T ) );
m_y.resize( size );
std::memcpy( m_y.data(), y, size * sizeof( T ) );
}
template< typename T >
size_t QwtPointArrayData< T >::size() const
{
return qMin( m_x.size(), m_y.size() );
}
template< typename T >
QPointF QwtPointArrayData< T >::sample( size_t index ) const
{
return QPointF( m_x[int( index )], m_y[int( index )] );
}
template< typename T >
const QVector< T >& QwtPointArrayData< T >::xData() const
{
return m_x;
}
template< typename T >
const QVector< T >& QwtPointArrayData< T >::yData() const
{
return m_y;
}
template< typename T >
QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y )
: m_y( y )
{
}
template< typename T >
QwtValuePointData< T >::QwtValuePointData( const T* y, size_t size )
{
m_y.resize( size );
std::memcpy( m_y.data(), y, size * sizeof( T ) );
}
template< typename T >
size_t QwtValuePointData< T >::size() const
{
return m_y.size();
}
template< typename T >
QPointF QwtValuePointData< T >::sample( size_t index ) const
{
return QPointF( index, m_y[int( index )] );
}
template< typename T >
const QVector< T >& QwtValuePointData< T >::yData() const
{
return m_y;
}
template< typename T >
QwtCPointerData< T >::QwtCPointerData( const T* x, const T* y, size_t size )
: m_x( x )
, m_y( y )
, m_size( size )
{
}
template< typename T >
size_t QwtCPointerData< T >::size() const
{
return m_size;
}
template< typename T >
QPointF QwtCPointerData< T >::sample( size_t index ) const
{
return QPointF( m_x[int( index )], m_y[int( index )] );
}
template< typename T >
const T* QwtCPointerData< T >::xData() const
{
return m_x;
}
template< typename T >
const T* QwtCPointerData< T >::yData() const
{
return m_y;
}
template< typename T >
QwtCPointerValueData< T >::QwtCPointerValueData( const T* y, size_t size )
: m_y( y )
, m_size( size )
{
}
template< typename T >
size_t QwtCPointerValueData< T >::size() const
{
return m_size;
}
template< typename T >
QPointF QwtCPointerValueData< T >::sample( size_t index ) const
{
return QPointF( index, m_y[ int( index ) ] );
}
template< typename T >
const T* QwtCPointerValueData< T >::yData() const
{
return m_y;
}
#endif
QVector
Definition qwt_clipper.h:23
QwtCPointerData
Data class containing two pointers to memory blocks of T.
Definition qwt_point_data.h:44
QwtCPointerData::xData
const T * xData() const
Definition qwt_point_data.h:354
QwtCPointerData::yData
const T * yData() const
Definition qwt_point_data.h:361
QwtCPointerData::size
virtual size_t size() const override
Definition qwt_point_data.h:335
QwtCPointerData::sample
virtual QPointF sample(size_t index) const override
Definition qwt_point_data.h:347
QwtCPointerData::QwtCPointerData
QwtCPointerData(const T *x, const T *y, size_t size)
Definition qwt_point_data.h:326
QwtCPointerValueData
Data class containing a pointer to memory of y coordinates.
Definition qwt_point_data.h:90
QwtCPointerValueData::QwtCPointerValueData
QwtCPointerValueData(const T *y, size_t size)
Definition qwt_point_data.h:380
QwtCPointerValueData::size
virtual size_t size() const override
Definition qwt_point_data.h:388
QwtCPointerValueData::yData
const T * yData() const
Definition qwt_point_data.h:407
QwtCPointerValueData::sample
virtual QPointF sample(size_t index) const override
Definition qwt_point_data.h:400
QwtInterval
A class representing an interval.
Definition qwt_interval.h:23
QwtPointArrayData
Interface for iterating over two QVector<T> objects.
Definition qwt_point_data.h:23
QwtPointArrayData::sample
virtual QPointF sample(size_t index) const override
Definition qwt_point_data.h:239
QwtPointArrayData::xData
const QVector< T > & xData() const
Definition qwt_point_data.h:246
QwtPointArrayData::yData
const QVector< T > & yData() const
Definition qwt_point_data.h:253
QwtPointArrayData::QwtPointArrayData
QwtPointArrayData(const QVector< T > &x, const QVector< T > &y)
Definition qwt_point_data.h:200
QwtPointArrayData::size
virtual size_t size() const override
Definition qwt_point_data.h:227
QwtSeriesData
Abstract interface for iterating over samples.
Definition qwt_series_data.h:50
QwtSeriesData::setRectOfInterest
virtual void setRectOfInterest(const QRectF &rect)
Definition qwt_series_data.h:141
QwtSeriesData::size
virtual size_t size() const =0
QwtSeriesData::boundingRect
virtual QRectF boundingRect() const
Definition qwt_series_data.h:100
QwtSeriesData::sample
virtual T sample(size_t i) const =0
QwtSyntheticPointData
Synthetic point data.
Definition qwt_point_data.h:158
QwtSyntheticPointData::y
virtual double y(double x) const =0
QwtValuePointData
Interface for iterating over a QVector<T>.
Definition qwt_point_data.h:68
QwtValuePointData::QwtValuePointData
QwtValuePointData(const QVector< T > &y)
Definition qwt_point_data.h:266
QwtValuePointData::size
virtual size_t size() const override
Definition qwt_point_data.h:287
QwtValuePointData::sample
virtual QPointF sample(size_t index) const override
Definition qwt_point_data.h:299
QwtValuePointData::yData
const QVector< T > & yData() const
Definition qwt_point_data.h:306