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


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.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_point_data.h"
    11 #include "qwt_math.h"
    12 #include <string.h>
    13 
    14 /*!
    15   Constructor
    16 
    17   \param x Array of x values
    18   \param y Array of y values
    19 
    20   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
    21 */
    22 QwtPointArrayData::QwtPointArrayData(
    23         const QVector<double> &x, const QVector<double> &y ):
    24     d_x( x ),
    25     d_y( y )
    26 {
    27 }
    28 
    29 /*!
    30   Constructor
    31 
    32   \param x Array of x values
    33   \param y Array of y values
    34   \param size Size of the x and y arrays
    35   \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
    36 */
    37 QwtPointArrayData::QwtPointArrayData( const double *x,
    38         const double *y, size_t size )
    39 {
    40     d_x.resize( size );
    41     ::memcpy( d_x.data(), x, size * sizeof( double ) );
    42 
    43     d_y.resize( size );
    44     ::memcpy( d_y.data(), y, size * sizeof( double ) );
    45 }
    46 
    47 /*!
    48   \brief Calculate the bounding rectangle
    49 
    50   The bounding rectangle is calculated once by iterating over all
    51   points and is stored for all following requests.
    52 
    53   \return Bounding rectangle
    54 */
    55 QRectF QwtPointArrayData::boundingRect() const
    56 {
    57     if ( d_boundingRect.width() < 0 )
    58         d_boundingRect = qwtBoundingRect( *this );
    59 
    60     return d_boundingRect;
    61 }
    62 
    63 //! \return Size of the data set
    64 size_t QwtPointArrayData::size() const
    65 {
    66     return qMin( d_x.size(), d_y.size() );
    67 }
    68 
    69 /*!
    70   Return the sample at position i
    71 
    72   \param index Index
    73   \return Sample at position i
    74 */
    75 QPointF QwtPointArrayData::sample( size_t index ) const
    76 {
    77     return QPointF( d_x[int( index )], d_y[int( index )] );
    78 }
    79 
    80 //! \return Array of the x-values
    81 const QVector<double> &QwtPointArrayData::xData() const
    82 {
    83     return d_x;
    84 }
    85 
    86 //! \return Array of the y-values
    87 const QVector<double> &QwtPointArrayData::yData() const
    88 {
    89     return d_y;
    90 }
    91 
    92 /*!
    93   Constructor
    94 
    95   \param x Array of x values
    96   \param y Array of y values
    97   \param size Size of the x and y arrays
    98 
    99   \warning The programmer must assure that the memory blocks referenced
    100            by the pointers remain valid during the lifetime of the
    101            QwtPlotCPointer object.
    102 
    103   \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
    104 */
    105 QwtCPointerData::QwtCPointerData(
    106         const double *x, const double *y, size_t size ):
    107     d_x( x ),
    108     d_y( y ),
    109     d_size( size )
    110 {
    111 }
    112 
    113 /*!
    114   \brief Calculate the bounding rectangle
    115 
    116   The bounding rectangle is calculated once by iterating over all
    117   points and is stored for all following requests.
    118 
    119   \return Bounding rectangle
    120 */
    121 QRectF QwtCPointerData::boundingRect() const
    122 {
    123     if ( d_boundingRect.width() < 0 )
    124         d_boundingRect = qwtBoundingRect( *this );
    125 
    126     return d_boundingRect;
    127 }
    128 
    129 //! \return Size of the data set
    130 size_t QwtCPointerData::size() const
    131 {
    132     return d_size;
    133 }
    134 
    135 /*!
    136   Return the sample at position i
    137 
    138   \param index Index
    139   \return Sample at position i
    140 */
    141 QPointF QwtCPointerData::sample( size_t index ) const
    142 {
    143     return QPointF( d_x[int( index )], d_y[int( index )] );
    144 }
    145 
    146 //! \return Array of the x-values
    147 const double *QwtCPointerData::xData() const
    148 {
    149     return d_x;
    150 }
    151 
    152 //! \return Array of the y-values
    153 const double *QwtCPointerData::yData() const
    154 {
    155     return d_y;
    156 }
    15711
    15812/*!
    … …  
    16317
    16418   \sa setInterval(), setSize()
    165 */
     19 */
    16620QwtSyntheticPointData::QwtSyntheticPointData(
    167         size_t size, const QwtInterval &interval ):
    168     d_size( size ),
    169     d_interval( interval )
     21        size_t size, const QwtInterval& interval )
     22    : m_size( size )
     23    , m_interval( interval )
    17024{
    17125}
    17226
    17327/*!
    174   Change the number of points
     28   Change the number of points
    17529
    176   \param size Number of points
    177   \sa size(), setInterval()
    178 */
     30   \param size Number of points
     31   \sa size(), setInterval()
     32 */
    17933void QwtSyntheticPointData::setSize( size_t size )
    18034{
    181     d_size = size;
     35    m_size = size;
    18236}
    18337
    18438/*!
    185   \return Number of points
    186   \sa setSize(), interval()
    187 */
     39   \return Number of points
     40   \sa setSize(), interval()
     41 */
    18842size_t QwtSyntheticPointData::size() const
    18943{
    190     return d_size;
     44    return m_size;
    19145}
    19246
    … …  
    19650   \param interval Interval
    19751   \sa interval(), setSize()
    198 */
    199 void QwtSyntheticPointData::setInterval( const QwtInterval &interval )
     52 */
     53void QwtSyntheticPointData::setInterval( const QwtInterval& interval )
    20054{
    201     d_interval = interval.normalized();
     55    m_interval = interval.normalized();
    20256}
    20357
    … …  
    20559   \return Bounding interval
    20660   \sa setInterval(), size()
    207 */
     61 */
    20862QwtInterval QwtSyntheticPointData::interval() const
    20963{
    210     return d_interval;
     64    return m_interval;
    21165}
    21266
    … …  
    22175
    22276   \sa rectOfInterest()
    223 */
    224 void QwtSyntheticPointData::setRectOfInterest( const QRectF &rect )
     77 */
     78void QwtSyntheticPointData::setRectOfInterest( const QRectF& rect )
    22579{
    226     d_rectOfInterest = rect;
    227     d_intervalOfInterest = QwtInterval(
     80    m_rectOfInterest = rect;
     81    m_intervalOfInterest = QwtInterval(
    22882        rect.left(), rect.right() ).normalized();
    22983}
    … …  
    23286   \return "rectangle of interest"
    23387   \sa setRectOfInterest()
    234 */
     88 */
    23589QRectF QwtSyntheticPointData::rectOfInterest() const
    23690{
    237     return d_rectOfInterest;
     91    return m_rectOfInterest;
    23892}
    23993
    24094/*!
    241   \brief Calculate the bounding rectangle
     95   \brief Calculate the bounding rectangle
    24296
    243   This implementation iterates over all points, what could often
    244   be implemented much faster using the characteristics of the series.
    245   When there are many points it is recommended to overload and
    246   reimplement this method using the characteristics of the series
    247   ( if possible ).
     97   This implementation iterates over all points, what could often
     98   be implemented much faster using the characteristics of the series.
     99   When there are many points it is recommended to overload and
     100   reimplement this method using the characteristics of the series
     101   ( if possible ).
    248102
    249   \return Bounding rectangle
    250 */
     103   \return Bounding rectangle
     104 */
    251105QRectF QwtSyntheticPointData::boundingRect() const
    252106{
    253     if ( d_size == 0 ||
    254         !( d_interval.isValid() || d_intervalOfInterest.isValid() ) )
     107    if ( m_size == 0 ||
     108        !( m_interval.isValid() || m_intervalOfInterest.isValid() ) )
    255109    {
    256110        return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
    … …  
    268122   \warning For invalid indices ( index < 0 || index >= size() )
    269123            (0, 0) is returned.
    270 */
     124 */
    271125QPointF QwtSyntheticPointData::sample( size_t index ) const
    272126{
    273     if ( index >= d_size )
     127    if ( index >= m_size )
    274128        return QPointF( 0, 0 );
    275129
    … …  
    291145
    292146   \sa interval(), rectOfInterest(), y()
    293 */
     147 */
    294148double QwtSyntheticPointData::x( uint index ) const
    295149{
    296     const QwtInterval &interval = d_interval.isValid() ?
    297         d_interval : d_intervalOfInterest;
     150    const QwtInterval& interval = m_interval.isValid() ?
     151        m_interval : m_intervalOfInterest;
    298152
    299153    if ( !interval.isValid() )
    300154        return 0.0;
    301155
    302     if ( d_size <= 1 )
     156    if ( m_size <= 1 )
    303157        return interval.minValue();
    304158
    305     const double dx = interval.width() / ( d_size - 1 );
     159    const double dx = interval.width() / ( m_size - 1 );
    306160    return interval.minValue() + index * dx;
    307161}
Note: See TracChangeset for help on using the changeset viewer.