Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_point_data.h


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_point_data.h

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#ifndef QWT_POINT_DATA_H
    11 #define QWT_POINT_DATA_H 1
     11#define QWT_POINT_DATA_H
    1212
    1313#include "qwt_global.h"
    1414#include "qwt_series_data.h"
    1515
    16 /*!
    17   \brief Interface for iterating over two QVector<double> objects.
    18 */
    19 class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
    20 {
    21 public:
    22     QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
    23     QwtPointArrayData( const double *x, const double *y, size_t size );
    24 
    25     virtual QRectF boundingRect() const;
    26 
    27     virtual size_t size() const;
    28     virtual QPointF sample( size_t index ) const;
    29 
    30     const QVector<double> &xData() const;
    31     const QVector<double> &yData() const;
    32 
    33 private:
    34     QVector<double> d_x;
    35     QVector<double> d_y;
     16#include <cstring>
     17
     18/*!
     19   \brief Interface for iterating over two QVector<T> objects.
     20 */
     21template< typename T >
     22class QwtPointArrayData : public QwtSeriesData< QPointF >
     23{
     24  public:
     25    QwtPointArrayData( const QVector< T >& x, const QVector< T >& y );
     26    QwtPointArrayData( const T* x, const T* y, size_t size );
     27
     28    virtual size_t size() const QWT_OVERRIDE;
     29    virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
     30
     31    const QVector< T >& xData() const;
     32    const QVector< T >& yData() const;
     33
     34  private:
     35    QVector< T > m_x;
     36    QVector< T > m_y;
    3637};
    3738
    3839/*!
    39   \brief Data class containing two pointers to memory blocks of doubles.
    40  */
    41 class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
    42 {
    43 public:
    44     QwtCPointerData( const double *x, const double *y, size_t size );
    45 
    46     virtual QRectF boundingRect() const;
    47     virtual size_t size() const;
    48     virtual QPointF sample( size_t index ) const;
    49 
    50     const double *xData() const;
    51     const double *yData() const;
    52 
    53 private:
    54     const double *d_x;
    55     const double *d_y;
    56     size_t d_size;
     40   \brief Data class containing two pointers to memory blocks of T.
     41 */
     42template< typename T >
     43class QwtCPointerData : public QwtSeriesData< QPointF >
     44{
     45  public:
     46    QwtCPointerData( const T* x, const T* y, size_t size );
     47
     48    virtual size_t size() const QWT_OVERRIDE;
     49    virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
     50
     51    const T* xData() const;
     52    const T* yData() const;
     53
     54  private:
     55    const T* m_x;
     56    const T* m_y;
     57    size_t m_size;
    5758};
    5859
    5960/*!
    60   \brief Synthetic point data
    61 
    62   QwtSyntheticPointData provides a fixed number of points for an interval.
    63   The points are calculated in equidistant steps in x-direction.
    64 
    65   If the interval is invalid, the points are calculated for
    66   the "rectangle of interest", what normally is the displayed area on the
    67   plot canvas. In this mode you get different levels of detail, when
    68   zooming in/out.
    69 
    70   \par Example
    71 
    72   The following example shows how to implement a sinus curve.
    73 
    74   \code
    75 #include <cmath>
    76 #include <qwt_series_data.h>
    77 #include <qwt_plot_curve.h>
    78 #include <qwt_plot.h>
    79 #include <qapplication.h>
    80 
    81 class SinusData: public QwtSyntheticPointData
    82 {
    83 public:
     61   \brief Interface for iterating over a QVector<T>.
     62
     63   The memory contains the y coordinates, while the index is
     64   interpreted as x coordinate.
     65 */
     66template< typename T >
     67class QwtValuePointData : public QwtSeriesData< QPointF >
     68{
     69  public:
     70    QwtValuePointData( const QVector< T >& y );
     71    QwtValuePointData( const T* y, size_t size );
     72
     73    virtual size_t size() const QWT_OVERRIDE;
     74    virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
     75
     76    const QVector< T >& yData() const;
     77
     78  private:
     79    QVector< T > m_y;
     80};
     81
     82/*!
     83   \brief Data class containing a pointer to memory of y coordinates
     84
     85   The memory contains the y coordinates, while the index is
     86   interpreted as x coordinate.
     87 */
     88template< typename T >
     89class QwtCPointerValueData : public QwtSeriesData< QPointF >
     90{
     91  public:
     92    QwtCPointerValueData( const T* y, size_t size );
     93
     94    virtual size_t size() const QWT_OVERRIDE;
     95    virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
     96
     97    const T* yData() const;
     98
     99  private:
     100    const T* m_y;
     101    size_t m_size;
     102};
     103
     104/*!
     105   \brief Synthetic point data
     106
     107   QwtSyntheticPointData provides a fixed number of points for an interval.
     108   The points are calculated in equidistant steps in x-direction.
     109
     110   If the interval is invalid, the points are calculated for
     111   the "rectangle of interest", what normally is the displayed area on the
     112   plot canvas. In this mode you get different levels of detail, when
     113   zooming in/out.
     114
     115   \par Example
     116
     117   The following example shows how to implement a sinus curve.
     118
     119   \code
     120 #include <cmath>
     121 #include <qwt_series_data.h>
     122 #include <qwt_plot_curve.h>
     123 #include <qwt_plot.h>
     124 #include <qapplication.h>
     125
     126   class SinusData: public QwtSyntheticPointData
     127   {
     128   public:
    84129    SinusData():
    85130        QwtSyntheticPointData( 100 )
    … …  
    91136        return qSin( x );
    92137    }
    93 };
    94 
    95 int main(int argc, char **argv)
    96 {
     138   };
     139
     140   int main(int argc, char **argv)
     141   {
    97142    QApplication a( argc, argv );
    98143
    99144    QwtPlot plot;
    100     plot.setAxisScale( QwtPlot::xBottom, 0.0, 10.0 );
    101     plot.setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );
     145    plot.setAxisScale( QwtAxis::XBottom, 0.0, 10.0 );
     146    plot.setAxisScale( QwtAxis::YLeft, -1.0, 1.0 );
    102147
    103148    QwtPlotCurve *curve = new QwtPlotCurve( "y = sin(x)" );
    … …  
    107152    plot.show();
    108153    return a.exec();
    109 }
     154   }
    110155   \endcode
    111 */
    112 class QWT_EXPORT QwtSyntheticPointData: public QwtSeriesData<QPointF>
    113 {
    114 public:
     156 */
     157class QWT_EXPORT QwtSyntheticPointData : public QwtSeriesData< QPointF >
     158{
     159  public:
    115160    QwtSyntheticPointData( size_t size,
    116         const QwtInterval & = QwtInterval() );
     161        const QwtInterval& = QwtInterval() );
    117162
    118163    void setSize( size_t size );
    119     virtual size_t size() const;
     164    virtual size_t size() const QWT_OVERRIDE;
    120165
    121166    void setInterval( const QwtInterval& );
    122167    QwtInterval interval() const;
    123168
    124     virtual QRectF boundingRect() const;
    125     virtual QPointF sample( size_t index ) const;
     169    virtual QRectF boundingRect() const QWT_OVERRIDE;
     170    virtual QPointF sample( size_t index ) const QWT_OVERRIDE;
    126171
    127172    /*!
    … …  
    134179    virtual double x( uint index ) const;
    135180
    136     virtual void setRectOfInterest( const QRectF & );
     181    virtual void setRectOfInterest( const QRectF& ) QWT_OVERRIDE;
    137182    QRectF rectOfInterest() const;
    138183
    139 private:
    140     size_t d_size;
    141     QwtInterval d_interval;
    142     QRectF d_rectOfInterest;
    143     QwtInterval d_intervalOfInterest;
     184  private:
     185    size_t m_size;
     186    QwtInterval m_interval;
     187    QRectF m_rectOfInterest;
     188    QwtInterval m_intervalOfInterest;
    144189};
    145190
     191/*!
     192   Constructor
     193
     194   \param x Array of x values
     195   \param y Array of y values
     196
     197   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
     198 */
     199template< typename T >
     200QwtPointArrayData< T >::QwtPointArrayData(
     201        const QVector< T >& x, const QVector< T >& y )
     202    : m_x( x )
     203    , m_y( y )
     204{
     205}
     206
     207/*!
     208   Constructor
     209
     210   \param x Array of x values
     211   \param y Array of y values
     212   \param size Size of the x and y arrays
     213   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
     214 */
     215template< typename T >
     216QwtPointArrayData< T >::QwtPointArrayData( const T* x, const T* y, size_t size )
     217{
     218    m_x.resize( size );
     219    std::memcpy( m_x.data(), x, size * sizeof( T ) );
     220
     221    m_y.resize( size );
     222    std::memcpy( m_y.data(), y, size * sizeof( T ) );
     223}
     224
     225//! \return Size of the data set
     226template< typename T >
     227size_t QwtPointArrayData< T >::size() const
     228{
     229    return qMin( m_x.size(), m_y.size() );
     230}
     231
     232/*!
     233   Return the sample at position i
     234
     235   \param index Index
     236   \return Sample at position i
     237 */
     238template< typename T >
     239QPointF QwtPointArrayData< T >::sample( size_t index ) const
     240{
     241    return QPointF( m_x[int( index )], m_y[int( index )] );
     242}
     243
     244//! \return Array of the x-values
     245template< typename T >
     246const QVector< T >& QwtPointArrayData< T >::xData() const
     247{
     248    return m_x;
     249}
     250
     251//! \return Array of the y-values
     252template< typename T >
     253const QVector< T >& QwtPointArrayData< T >::yData() const
     254{
     255    return m_y;
     256}
     257
     258/*!
     259   Constructor
     260
     261   \param y Array of y values
     262
     263   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
     264 */
     265template< typename T >
     266QwtValuePointData< T >::QwtValuePointData( const QVector< T >& y )
     267    : m_y( y )
     268{
     269}
     270
     271/*!
     272   Constructor
     273
     274   \param y Array of y values
     275   \param size Size of the x and y arrays
     276   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
     277 */
     278template< typename T >
     279QwtValuePointData< T >::QwtValuePointData( const T* y, size_t size )
     280{
     281    m_y.resize( size );
     282    std::memcpy( m_y.data(), y, size * sizeof( T ) );
     283}
     284
     285//! \return Size of the data set
     286template< typename T >
     287size_t QwtValuePointData< T >::size() const
     288{
     289    return m_y.size();
     290}
     291
     292/*!
     293   Return the sample at position i
     294
     295   \param index Index
     296   \return Sample at position i
     297 */
     298template< typename T >
     299QPointF QwtValuePointData< T >::sample( size_t index ) const
     300{
     301    return QPointF( index, m_y[int( index )] );
     302}
     303
     304//! \return Array of the y-values
     305template< typename T >
     306const QVector< T >& QwtValuePointData< T >::yData() const
     307{
     308    return m_y;
     309}
     310
     311/*!
     312   Constructor
     313
     314   \param x Array of x values
     315   \param y Array of y values
     316   \param size Size of the x and y arrays
     317
     318   \warning The programmer must assure that the memory blocks referenced
     319           by the pointers remain valid during the lifetime of the
     320           QwtPlotCPointer object.
     321
     322   \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
     323 */
     324
     325template< typename T >
     326QwtCPointerData< T >::QwtCPointerData( const T* x, const T* y, size_t size )
     327    : m_x( x )
     328    , m_y( y )
     329    , m_size( size )
     330{
     331}
     332
     333//! \return Size of the data set
     334template< typename T >
     335size_t QwtCPointerData< T >::size() const
     336{
     337    return m_size;
     338}
     339
     340/*!
     341   Return the sample at position i
     342
     343   \param index Index
     344   \return Sample at position i
     345 */
     346template< typename T >
     347QPointF QwtCPointerData< T >::sample( size_t index ) const
     348{
     349    return QPointF( m_x[int( index )], m_y[int( index )] );
     350}
     351
     352//! \return Array of the x-values
     353template< typename T >
     354const T* QwtCPointerData< T >::xData() const
     355{
     356    return m_x;
     357}
     358
     359//! \return Array of the y-values
     360template< typename T >
     361const T* QwtCPointerData< T >::yData() const
     362{
     363    return m_y;
     364}
     365
     366/*!
     367   Constructor
     368
     369   \param y Array of y values
     370   \param size Size of the x and y arrays
     371
     372   \warning The programmer must assure that the memory blocks referenced
     373           by the pointers remain valid during the lifetime of the
     374           QwtCPointerValueData object.
     375
     376   \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
     377 */
     378
     379template< typename T >
     380QwtCPointerValueData< T >::QwtCPointerValueData( const T* y, size_t size )
     381    : m_y( y )
     382    , m_size( size )
     383{
     384}
     385
     386//! \return Size of the data set
     387template< typename T >
     388size_t QwtCPointerValueData< T >::size() const
     389{
     390    return m_size;
     391}
     392
     393/*!
     394   Return the sample at position i
     395
     396   \param index Index
     397   \return Sample at position i
     398 */
     399template< typename T >
     400QPointF QwtCPointerValueData< T >::sample( size_t index ) const
     401{
     402    return QPointF( index, m_y[ int( index ) ] );
     403}
     404
     405//! \return Array of the y-values
     406template< typename T >
     407const T* QwtCPointerValueData< T >::yData() const
     408{
     409    return m_y;
     410}
     411
    146412#endif
Note: See TracChangeset for help on using the changeset viewer.