Qwt User's Guide 6.0.1

- Main Page
- Related Pages
- Classes
- Files

- File List

# qwt_series_data.h

    00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
    00002  * Qwt Widget Library
    00003  * Copyright (C) 1997   Josef Wilgen
    00004  * Copyright (C) 2002   Uwe Rathmann
    00005  *
    00006  * This library is free software; you can redistribute it and/or
    00007  * modify it under the terms of the Qwt License, Version 1.0
    00008  *****************************************************************************/
    00009
    00010 #ifndef QWT_SERIES_DATA_H
    00011 #define QWT_SERIES_DATA_H 1
    00012
    00013 #include "qwt_global.h"
    00014 #include "qwt_interval.h"
    00015 #include "qwt_point_3d.h"
    00016 #include "qwt_point_polar.h"
    00017 #include <qvector.h>
    00018 #include <qrect.h>
    00019
    00021 class QWT_EXPORT QwtIntervalSample
    00022 {
    00023 public:
    00024     QwtIntervalSample();
    00025     QwtIntervalSample( double, const QwtInterval & );
    00026     QwtIntervalSample( double value, double min, double max );
    00027
    00028     bool operator==( const QwtIntervalSample & ) const;
    00029     bool operator!=( const QwtIntervalSample & ) const;
    00030
    00032     double value;
    00033
    00035     QwtInterval interval;
    00036 };
    00037
    00042 inline QwtIntervalSample::QwtIntervalSample():
    00043     value( 0.0 )
    00044 {
    00045 }
    00046
    00048 inline QwtIntervalSample::QwtIntervalSample(
    00049         double v, const QwtInterval &intv ):
    00050     value( v ),
    00051     interval( intv )
    00052 {
    00053 }
    00054
    00056 inline QwtIntervalSample::QwtIntervalSample(
    00057         double v, double min, double max ):
    00058     value( v ),
    00059     interval( min, max )
    00060 {
    00061 }
    00062
    00064 inline bool QwtIntervalSample::operator==(
    00065     const QwtIntervalSample &other ) const
    00066 {
    00067     return value == other.value && interval == other.interval;
    00068 }
    00069
    00071 inline bool QwtIntervalSample::operator!=(
    00072     const QwtIntervalSample &other ) const
    00073 {
    00074     return !( *this == other );
    00075 }
    00076
    00078 class QWT_EXPORT QwtSetSample
    00079 {
    00080 public:
    00081     QwtSetSample();
    00082     bool operator==( const QwtSetSample &other ) const;
    00083     bool operator!=( const QwtSetSample &other ) const;
    00084
    00086     double value;
    00087
    00089     QVector<double> set;
    00090 };
    00091
    00096 inline QwtSetSample::QwtSetSample():
    00097     value( 0.0 )
    00098 {
    00099 }
    00100
    00102 inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
    00103 {
    00104     return value == other.value && set == other.set;
    00105 }
    00106
    00108 inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
    00109 {
    00110     return !( *this == other );
    00111 }
    00112
    00121 template <typename T>
    00122 class QwtSeriesData
    00123 {
    00124 public:
    00125     QwtSeriesData();
    00126     virtual ~QwtSeriesData();
    00127
    00129     virtual size_t size() const = 0;
    00130
    00136     virtual T sample( size_t i ) const = 0;
    00137
    00148     virtual QRectF boundingRect() const = 0;
    00149
    00150     virtual void setRectOfInterest( const QRectF & );
    00151
    00152 protected:
    00154     mutable QRectF d_boundingRect;
    00155
    00156 private:
    00157     QwtSeriesData<T> &operator=( const QwtSeriesData<T> & );
    00158 };
    00159
    00161 template <typename T>
    00162 QwtSeriesData<T>::QwtSeriesData():
    00163     d_boundingRect( 0.0, 0.0, -1.0, -1.0 )
    00164 {
    00165 }
    00166
    00168 template <typename T>
    00169 QwtSeriesData<T>::~QwtSeriesData()
    00170 {
    00171 }
    00172
    00182 template <typename T>
    00183 void QwtSeriesData<T>::setRectOfInterest( const QRectF & )
    00184 {
    00185 }
    00186
    00193 template <typename T>
    00194 class QwtArraySeriesData: public QwtSeriesData<T>
    00195 {
    00196 public:
    00197     QwtArraySeriesData();
    00198     QwtArraySeriesData( const QVector<T> & );
    00199
    00200     void setSamples( const QVector<T> & );
    00201     const QVector<T> samples() const;
    00202
    00203     virtual size_t size() const;
    00204     virtual T sample( size_t ) const;
    00205
    00206 protected:
    00208     QVector<T> d_samples;
    00209 };
    00210
    00212 template <typename T>
    00213 QwtArraySeriesData<T>::QwtArraySeriesData()
    00214 {
    00215 }
    00216
    00221 template <typename T>
    00222 QwtArraySeriesData<T>::QwtArraySeriesData( const QVector<T> &samples ):
    00223     d_samples( samples )
    00224 {
    00225 }
    00226
    00231 template <typename T>
    00232 void QwtArraySeriesData<T>::setSamples( const QVector<T> &samples )
    00233 {
    00234     QwtSeriesData<T>::d_boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
    00235     d_samples = samples;
    00236 }
    00237
    00239 template <typename T>
    00240 const QVector<T> QwtArraySeriesData<T>::samples() const
    00241 {
    00242     return d_samples;
    00243 }
    00244
    00246 template <typename T>
    00247 size_t QwtArraySeriesData<T>::size() const
    00248 {
    00249     return d_samples.size();
    00250 }
    00251
    00257 template <typename T>
    00258 T QwtArraySeriesData<T>::sample( size_t i ) const
    00259 {
    00260     return d_samples[i];
    00261 }
    00262
    00264 class QWT_EXPORT QwtPointSeriesData: public QwtArraySeriesData<QPointF>
    00265 {
    00266 public:
    00267     QwtPointSeriesData(
    00268         const QVector<QPointF> & = QVector<QPointF>() );
    00269
    00270     virtual QRectF boundingRect() const;
    00271 };
    00272
    00274 class QWT_EXPORT QwtPoint3DSeriesData: public QwtArraySeriesData<QwtPoint3D>
    00275 {
    00276 public:
    00277     QwtPoint3DSeriesData(
    00278         const QVector<QwtPoint3D> & = QVector<QwtPoint3D>() );
    00279     virtual QRectF boundingRect() const;
    00280 };
    00281
    00283 class QWT_EXPORT QwtIntervalSeriesData: public QwtArraySeriesData<QwtIntervalSample>
    00284 {
    00285 public:
    00286     QwtIntervalSeriesData(
    00287         const QVector<QwtIntervalSample> & = QVector<QwtIntervalSample>() );
    00288
    00289     virtual QRectF boundingRect() const;
    00290 };
    00291
    00293 class QWT_EXPORT QwtSetSeriesData: public QwtArraySeriesData<QwtSetSample>
    00294 {
    00295 public:
    00296     QwtSetSeriesData(
    00297         const QVector<QwtSetSample> & = QVector<QwtSetSample>() );
    00298
    00299     virtual QRectF boundingRect() const;
    00300 };
    00301
    00305 class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
    00306 {
    00307 public:
    00308     QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
    00309     QwtPointArrayData( const double *x, const double *y, size_t size );
    00310
    00311     virtual QRectF boundingRect() const;
    00312
    00313     virtual size_t size() const;
    00314     virtual QPointF sample( size_t i ) const;
    00315
    00316     const QVector<double> &xData() const;
    00317     const QVector<double> &yData() const;
    00318
    00319 private:
    00320     QVector<double> d_x;
    00321     QVector<double> d_y;
    00322 };
    00323
    00327 class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
    00328 {
    00329 public:
    00330     QwtCPointerData( const double *x, const double *y, size_t size );
    00331
    00332     virtual QRectF boundingRect() const;
    00333     virtual size_t size() const;
    00334     virtual QPointF sample( size_t i ) const;
    00335
    00336     const double *xData() const;
    00337     const double *yData() const;
    00338
    00339 private:
    00340     const double *d_x;
    00341     const double *d_y;
    00342     size_t d_size;
    00343 };
    00344
    00397 class QWT_EXPORT QwtSyntheticPointData: public QwtSeriesData<QPointF>
    00398 {
    00399 public:
    00400     QwtSyntheticPointData( size_t size,
    00401         const QwtInterval & = QwtInterval() );
    00402
    00403     void setSize( size_t size );
    00404     size_t size() const;
    00405
    00406     void setInterval( const QwtInterval& );
    00407     QwtInterval interval() const;
    00408
    00409     virtual QRectF boundingRect() const;
    00410     virtual QPointF sample( size_t i ) const;
    00411
    00418     virtual double y( double x ) const = 0;
    00419     virtual double x( uint index ) const;
    00420
    00421     virtual void setRectOfInterest( const QRectF & );
    00422     QRectF rectOfInterest() const;
    00423
    00424 private:
    00425     size_t d_size;
    00426     QwtInterval d_interval;
    00427     QRectF d_rectOfInterest;
    00428     QwtInterval d_intervalOfInterest;
    00429 };
    00430
    00431 QWT_EXPORT QRectF qwtBoundingRect(
    00432     const QwtSeriesData<QPointF> &, int from = 0, int to = -1 );
    00433 QWT_EXPORT QRectF qwtBoundingRect(
    00434     const QwtSeriesData<QwtPoint3D> &, int from = 0, int to = -1 );
    00435 QWT_EXPORT QRectF qwtBoundingRect(
    00436     const QwtSeriesData<QwtPointPolar> &, int from = 0, int to = -1 );
    00437 QWT_EXPORT QRectF qwtBoundingRect(
    00438     const QwtSeriesData<QwtIntervalSample> &, int from = 0, int to = -1 );
    00439 QWT_EXPORT QRectF qwtBoundingRect(
    00440     const QwtSeriesData<QwtSetSample> &, int from = 0, int to = -1 );
    00441
    00442 #endif