Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_point_mapper.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_mapper.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1111#include "qwt_scale_map.h"
    1212#include "qwt_pixel_matrix.h"
     13#include "qwt_series_data.h"
     14#include "qwt_math.h"
     15
    1316#include <qpolygon.h>
    1417#include <qimage.h>
    … …  
    1619#include <qpainter.h>
    1720
    18 #if QT_VERSION >= 0x040400
    19 
    2021#include <qthread.h>
    2122#include <qfuture.h>
    2223#include <qtconcurrentrun.h>
    2324
    24 #if !defined(QT_NO_QFUTURE)
     25#if !defined( QT_NO_QFUTURE )
    2526#define QWT_USE_THREADS 1
    2627#endif
    2728
     29static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 );
     30
     31static inline int qwtRoundValue( double value )
     32{
     33    return qRound( value );
     34}
     35
     36static inline double qwtRoundValueF( double value )
     37{
     38#if 1
     39    // MS Windows and at least IRIX does not have C99's nearbyint() function
     40    return ( value >= 0.0 ) ? std::floor( value + 0.5 ) : std::ceil( value - 0.5 );
     41#else
     42    return nearbyint( value );
    2843#endif
    29 
    30 static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 );
     44}
     45
     46static Qt::Orientation qwtProbeOrientation(
     47    const QwtSeriesData< QPointF >* series, int from, int to )
     48{
     49    if ( to - from < 20 )
     50    {
     51        // not enough points to "have an orientation"
     52        return Qt::Horizontal;
     53    }
     54
     55    const double x0 = series->sample( from ).x();
     56    const double xn = series->sample( to ).x();
     57
     58    if ( x0 == xn )
     59        return Qt::Vertical;
     60
     61    const int step = ( to - from ) / 10;
     62    const bool isIncreasing = xn > x0;
     63
     64    double x1 = x0;
     65    for ( int i = from + step; i < to; i += step )
     66    {
     67        const double x2 = series->sample( i ).x();
     68        if ( x2 != x1 )
     69        {
     70            if ( ( x2 > x1 ) != isIncreasing )
     71                return Qt::Vertical;
     72        }
     73
     74        x1 = x2;
     75    }
     76
     77    return Qt::Horizontal;
     78}
     79
     80namespace
     81{
     82    template< class Polygon, class Point >
     83    class QwtPolygonQuadrupelX
     84    {
     85      public:
     86        inline void start( int x, int y )
     87        {
     88            m_x0 = x;
     89            m_y1 = m_yMin = m_yMax = m_y2 = y;
     90        }
     91
     92        inline bool append( int x, int y )
     93        {
     94            if ( m_x0 != x )
     95                return false;
     96
     97            if ( y < m_yMin )
     98                m_yMin = y;
     99            else if ( y > m_yMax )
     100                m_yMax = y;
     101
     102            m_y2 = y;
     103
     104            return true;
     105        }
     106
     107        inline void flush( Polygon& polyline )
     108        {
     109            appendTo( m_y1, polyline );
     110
     111            if ( m_y2 > m_y1 )
     112                qSwap( m_yMin, m_yMax );
     113
     114            if ( m_yMax != m_y1 )
     115                appendTo( m_yMax, polyline );
     116
     117            if ( m_yMin != m_yMax )
     118                appendTo( m_yMin, polyline );
     119
     120            if ( m_y2 != m_yMin )
     121                appendTo( m_y2, polyline );
     122        }
     123
     124      private:
     125        inline void appendTo( int y, Polygon& polyline )
     126        {
     127            polyline += Point( m_x0, y );
     128        }
     129
     130      private:
     131        int m_x0, m_y1, m_yMin, m_yMax, m_y2;
     132    };
     133
     134    template< class Polygon, class Point >
     135    class QwtPolygonQuadrupelY
     136    {
     137      public:
     138        inline void start( int x, int y )
     139        {
     140            m_y0 = y;
     141            m_x1 = m_xMin = m_xMax = m_x2 = x;
     142        }
     143
     144        inline bool append( int x, int y )
     145        {
     146            if ( m_y0 != y )
     147                return false;
     148
     149            if ( x < m_xMin )
     150                m_xMin = x;
     151            else if ( x > m_xMax )
     152                m_xMax = x;
     153
     154            m_x2 = x;
     155
     156            return true;
     157        }
     158
     159        inline void flush( Polygon& polyline )
     160        {
     161            appendTo( m_x1, polyline );
     162
     163            if ( m_x2 > m_x1 )
     164                qSwap( m_xMin, m_xMax );
     165
     166            if ( m_xMax != m_x1 )
     167                appendTo( m_xMax, polyline );
     168
     169            if ( m_xMin != m_xMax )
     170                appendTo( m_xMin, polyline );
     171
     172            if ( m_x2 != m_xMin )
     173                appendTo( m_x2, polyline );
     174        }
     175
     176      private:
     177        inline void appendTo( int x, Polygon& polyline )
     178        {
     179            polyline += Point( x, m_y0 );
     180        }
     181
     182        int m_y0, m_x1, m_xMin, m_xMax, m_x2;
     183    };
     184}
     185
     186template< class Polygon, class Point, class PolygonQuadrupel >
     187static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     188    const QwtSeriesData< QPointF >* series, int from, int to )
     189{
     190    const QPointF sample0 = series->sample( from );
     191
     192    PolygonQuadrupel q;
     193    q.start( qwtRoundValue( xMap.transform( sample0.x() ) ),
     194        qwtRoundValue( yMap.transform( sample0.y() ) ) );
     195
     196    Polygon polyline;
     197    for ( int i = from; i <= to; i++ )
     198    {
     199        const QPointF sample = series->sample( i );
     200
     201        const int x = qwtRoundValue( xMap.transform( sample.x() ) );
     202        const int y = qwtRoundValue( yMap.transform( sample.y() ) );
     203
     204        if ( !q.append( x, y ) )
     205        {
     206            q.flush( polyline );
     207            q.start( x, y );
     208        }
     209    }
     210    q.flush( polyline );
     211
     212    return polyline;
     213}
     214
     215template< class Polygon, class Point, class PolygonQuadrupel >
     216static Polygon qwtMapPointsQuad( const Polygon& polyline )
     217{
     218    const int numPoints = polyline.size();
     219
     220    if ( numPoints < 3 )
     221        return polyline;
     222
     223    const Point* points = polyline.constData();
     224
     225    Polygon polylineXY;
     226
     227    PolygonQuadrupel q;
     228    q.start( points[0].x(), points[0].y() );
     229
     230    for ( int i = 0; i < numPoints; i++ )
     231    {
     232        const int x = points[i].x();
     233        const int y = points[i].y();
     234
     235        if ( !q.append( x, y ) )
     236        {
     237            q.flush( polylineXY );
     238            q.start( x, y );
     239        }
     240    }
     241    q.flush( polylineXY );
     242
     243    return polylineXY;
     244}
     245
     246
     247template< class Polygon, class Point >
     248static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     249    const QwtSeriesData< QPointF >* series, int from, int to )
     250{
     251    Polygon polyline;
     252    if ( from > to )
     253        return polyline;
     254
     255    /*
     256        probing some values, to decide if it is better
     257        to start with x or y coordinates
     258     */
     259    const Qt::Orientation orientation = qwtProbeOrientation( series, from, to );
     260
     261    if ( orientation == Qt::Horizontal )
     262    {
     263        polyline = qwtMapPointsQuad< Polygon, Point,
     264            QwtPolygonQuadrupelY< Polygon, Point > >( xMap, yMap, series, from, to );
     265
     266        polyline = qwtMapPointsQuad< Polygon, Point,
     267            QwtPolygonQuadrupelX< Polygon, Point > >( polyline );
     268    }
     269    else
     270    {
     271        polyline = qwtMapPointsQuad< Polygon, Point,
     272            QwtPolygonQuadrupelX< Polygon, Point > >( xMap, yMap, series, from, to );
     273
     274        polyline = qwtMapPointsQuad< Polygon, Point,
     275            QwtPolygonQuadrupelY< Polygon, Point > >( polyline );
     276    }
     277
     278    return polyline;
     279}
    31280
    32281// Helper class to work around the 5 parameters
    … …  
    34283class QwtDotsCommand
    35284{
    36 public:
    37     const QwtSeriesData<QPointF> *series;
     285  public:
     286    const QwtSeriesData< QPointF >* series;
    38287    int from;
    39288    int to;
    … …  
    42291
    43292static void qwtRenderDots(
    44     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    45     const QwtDotsCommand command, const QPoint &pos, QImage *image )
     293    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     294    const QwtDotsCommand& command, const QPoint& pos, QImage* image )
    46295{
    47296    const QRgb rgb = command.rgb;
    48     QRgb *bits = reinterpret_cast<QRgb *>( image->bits() );
     297    QRgb* bits = reinterpret_cast< QRgb* >( image->bits() );
    49298
    50299    const int w = image->width();
    … …  
    58307        const QPointF sample = command.series->sample( i );
    59308
    60         const int x = static_cast<int>( xMap.transform( sample.x() ) + 0.5 ) - x0;
    61         const int y = static_cast<int>( yMap.transform( sample.y() ) + 0.5 ) - y0;
     309        const int x = static_cast< int >( xMap.transform( sample.x() ) + 0.5 ) - x0;
     310        const int y = static_cast< int >( yMap.transform( sample.y() ) + 0.5 ) - y0;
    62311
    63312        if ( x >= 0 && x < w && y >= 0 && y < h )
    … …  
    66315}
    67316
    68 static inline int qwtRoundValue( double value )
    69 {
    70     return qRound( value );
    71 }
    72 
    73317// some functors, so that the compile can inline
    74318struct QwtRoundI
    75319{
    76     inline int operator()( double value )
     320    inline int operator()( double value ) const
    77321    {
    78322        return qwtRoundValue( value );
    … …  
    82326struct QwtRoundF
    83327{
    84     inline double operator()( double value )
    85     {
    86 #if 1
    87         // MS Windows and at least IRIX does not have C99's nearbyint() function
    88         return ( value >= 0.0 ) ? ::floor( value + 0.5 ) : ::ceil( value - 0.5 );
    89 #else
    90         // slightly faster than the code above
    91         return nearbyint( value );
    92 #endif
     328    inline double operator()( double value ) const
     329    {
     330        return qwtRoundValueF( value );
    93331    }
    94332};
    … …  
    96334struct QwtNoRoundF
    97335{
    98     inline double operator()( double value )
     336    inline double operator()( double value ) const
    99337    {
    100338        return value;
    … …  
    105343// the bounding rectangle
    106344
    107 template<class Polygon, class Point, class Round>
     345template< class Polygon, class Point, class Round >
    108346static inline Polygon qwtToPoints(
    109     const QRectF &boundingRect,
    110     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    111     const QwtSeriesData<QPointF> *series,
     347    const QRectF& boundingRect,
     348    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     349    const QwtSeriesData< QPointF >* series,
    112350    int from, int to, Round round )
    113351{
    114352    Polygon polyline( to - from + 1 );
    115     Point *points = polyline.data();
     353    Point* points = polyline.data();
    116354
    117355    int numPoints = 0;
    … …  
    164402
    165403static inline QPolygon qwtToPointsI(
    166     const QRectF &boundingRect,
    167     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    168     const QwtSeriesData<QPointF> *series,
     404    const QRectF& boundingRect,
     405    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     406    const QwtSeriesData< QPointF >* series,
    169407    int from, int to )
    170408{
    171     return qwtToPoints<QPolygon, QPoint>(
     409    return qwtToPoints< QPolygon, QPoint >(
    172410        boundingRect, xMap, yMap, series, from, to, QwtRoundI() );
    173411}
    174412
    175 template<class Round>
     413template< class Round >
    176414static inline QPolygonF qwtToPointsF(
    177     const QRectF &boundingRect,
    178     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    179     const QwtSeriesData<QPointF> *series,
     415    const QRectF& boundingRect,
     416    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     417    const QwtSeriesData< QPointF >* series,
    180418    int from, int to, Round round )
    181419{
    182     return qwtToPoints<QPolygonF, QPointF>(
     420    return qwtToPoints< QPolygonF, QPointF >(
    183421        boundingRect, xMap, yMap, series, from, to, round );
    184422}
    … …  
    187425// points mapped to the same position
    188426
    189 template<class Polygon, class Point, class Round>
     427template< class Polygon, class Point, class Round >
    190428static inline Polygon qwtToPolylineFiltered(
    191     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    192     const QwtSeriesData<QPointF> *series,
     429    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     430    const QwtSeriesData< QPointF >* series,
    193431    int from, int to, Round round )
    194432{
    … …  
    199437
    200438    Polygon polyline( to - from + 1 );
    201     Point *points = polyline.data();
     439    Point* points = polyline.data();
    202440
    203441    const QPointF sample0 = series->sample( from );
    … …  
    223461
    224462static inline QPolygon qwtToPolylineFilteredI(
    225     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    226     const QwtSeriesData<QPointF> *series,
     463    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     464    const QwtSeriesData< QPointF >* series,
    227465    int from, int to )
    228466{
    229     return qwtToPolylineFiltered<QPolygon, QPoint>(
     467    return qwtToPolylineFiltered< QPolygon, QPoint >(
    230468        xMap, yMap, series, from, to, QwtRoundI() );
    231469}
    232470
    233 template<class Round>
     471template< class Round >
    234472static inline QPolygonF qwtToPolylineFilteredF(
    235     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    236     const QwtSeriesData<QPointF> *series,
     473    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     474    const QwtSeriesData< QPointF >* series,
    237475    int from, int to, Round round )
    238476{
    239     return qwtToPolylineFiltered<QPolygonF, QPointF>(
     477    return qwtToPolylineFiltered< QPolygonF, QPointF >(
    240478        xMap, yMap, series, from, to, round );
    241479}
    242480
    243 template<class Polygon, class Point>
     481template< class Polygon, class Point >
    244482static inline Polygon qwtToPointsFiltered(
    245     const QRectF &boundingRect,
    246     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    247     const QwtSeriesData<QPointF> *series, int from, int to )
     483    const QRectF& boundingRect,
     484    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     485    const QwtSeriesData< QPointF >* series, int from, int to )
    248486{
    249487    // F.e. in scatter plots ( no connecting lines ) we
    … …  
    251489
    252490    Polygon polygon( to - from + 1 );
    253     Point *points = polygon.data();
     491    Point* points = polygon.data();
    254492
    255493    QwtPixelMatrix pixelMatrix( boundingRect.toAlignedRect() );
    … …  
    277515
    278516static inline QPolygon qwtToPointsFilteredI(
    279     const QRectF &boundingRect,
    280     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    281     const QwtSeriesData<QPointF> *series, int from, int to )
    282 {
    283     return qwtToPointsFiltered<QPolygon, QPoint>(
     517    const QRectF& boundingRect,
     518    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     519    const QwtSeriesData< QPointF >* series, int from, int to )
     520{
     521    return qwtToPointsFiltered< QPolygon, QPoint >(
    284522        boundingRect, xMap, yMap, series, from, to );
    285523}
    286524
    287525static inline QPolygonF qwtToPointsFilteredF(
    288     const QRectF &boundingRect,
    289     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    290     const QwtSeriesData<QPointF> *series, int from, int to )
    291 {
    292     return qwtToPointsFiltered<QPolygonF, QPointF>(
     526    const QRectF& boundingRect,
     527    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     528    const QwtSeriesData< QPointF >* series, int from, int to )
     529{
     530    return qwtToPointsFiltered< QPolygonF, QPointF >(
    293531        boundingRect, xMap, yMap, series, from, to );
    294532}
    … …  
    296534class QwtPointMapper::PrivateData
    297535{
    298 public:
    299     PrivateData():
    300         boundingRect( qwtInvalidRect )
     536  public:
     537    PrivateData()
     538        : boundingRect( qwtInvalidRect )
    301539    {
    302540    }
    … …  
    309547QwtPointMapper::QwtPointMapper()
    310548{
    311     d_data = new PrivateData();
     549    m_data = new PrivateData();
    312550}
    313551
    … …  
    315553QwtPointMapper::~QwtPointMapper()
    316554{
    317     delete d_data;
    318 }
    319 
    320 /*!
    321   Set the flags affecting the transformation process
    322 
    323   \param flags Flags
    324   \sa flags(), setFlag()
     555    delete m_data;
     556}
     557
     558/*!
     559   Set the flags affecting the transformation process
     560
     561   \param flags Flags
     562   \sa flags(), setFlag()
    325563 */
    326564void QwtPointMapper::setFlags( TransformationFlags flags )
    327565{
    328     d_data->flags = flags;
    329 }
    330 
    331 /*!
    332   \return Flags affecting the transformation process
    333   \sa setFlags(), setFlag()
     566    m_data->flags = flags;
     567}
     568
     569/*!
     570   \return Flags affecting the transformation process
     571   \sa setFlags(), setFlag()
    334572 */
    335573QwtPointMapper::TransformationFlags QwtPointMapper::flags() const
    336574{
    337     return d_data->flags;
    338 }
    339 
    340 /*!
    341   Modify a flag affecting the transformation process
    342 
    343   \param flag Flag type
    344   \param on Value
    345 
    346   \sa flag(), setFlags()
     575    return m_data->flags;
     576}
     577
     578/*!
     579   Modify a flag affecting the transformation process
     580
     581   \param flag Flag type
     582   \param on Value
     583
     584   \sa flag(), setFlags()
    347585 */
    348586void QwtPointMapper::setFlag( TransformationFlag flag, bool on )
    349587{
    350588    if ( on )
    351         d_data->flags |= flag;
     589        m_data->flags |= flag;
    352590    else
    353         d_data->flags &= ~flag;
    354 }
    355 
    356 /*!
    357   \return True, when the flag is set
    358   \param flag Flag type
    359   \sa setFlag(), setFlags()
     591        m_data->flags &= ~flag;
     592}
     593
     594/*!
     595   \return True, when the flag is set
     596   \param flag Flag type
     597   \sa setFlag(), setFlags()
    360598 */
    361599bool QwtPointMapper::testFlag( TransformationFlag flag ) const
    362600{
    363     return d_data->flags & flag;
    364 }
    365 
    366 /*!
    367   Set a bounding rectangle for the point mapping algorithm
    368 
    369   A valid bounding rectangle can be used for optimizations
    370 
    371   \param rect Bounding rectangle
    372   \sa boundingRect()
    373  */
    374 void QwtPointMapper::setBoundingRect( const QRectF &rect )
    375 {
    376     d_data->boundingRect = rect;
    377 }
    378 
    379 /*!
    380   \return Bounding rectangle
    381   \sa setBoundingRect()
     601    return m_data->flags & flag;
     602}
     603
     604/*!
     605   Set a bounding rectangle for the point mapping algorithm
     606
     607   A valid bounding rectangle can be used for optimizations
     608
     609   \param rect Bounding rectangle
     610   \sa boundingRect()
     611 */
     612void QwtPointMapper::setBoundingRect( const QRectF& rect )
     613{
     614    m_data->boundingRect = rect;
     615}
     616
     617/*!
     618   \return Bounding rectangle
     619   \sa setBoundingRect()
    382620 */
    383621QRectF QwtPointMapper::boundingRect() const
    384622{
    385     return d_data->boundingRect;
    386 }
    387 
    388 /*!
    389   \brief Translate a series of points into a QPolygonF
    390 
    391   When the WeedOutPoints flag is enabled consecutive points,
    392   that are mapped to the same position will be one point.
    393 
    394   When RoundPoints is set all points are rounded to integers
    395   but returned as PolygonF - what only makes sense
    396   when the further processing of the values need a QPolygonF.
    397 
    398   \param xMap x map
    399   \param yMap y map
    400   \param series Series of points to be mapped
    401   \param from Index of the first point to be painted
    402   \param to Index of the last point to be painted
    403 
    404   \return Translated polygon
    405 */
     623    return m_data->boundingRect;
     624}
     625
     626/*!
     627   \brief Translate a series of points into a QPolygonF
     628
     629   When the WeedOutPoints flag is enabled consecutive points,
     630   that are mapped to the same position will be one point.
     631
     632   When RoundPoints is set all points are rounded to integers
     633   but returned as PolygonF - what only makes sense
     634   when the further processing of the values need a QPolygonF.
     635
     636   When RoundPoints & WeedOutIntermediatePoints is enabled an even more
     637   aggressive weeding algorithm is enabled.
     638
     639   \param xMap x map
     640   \param yMap y map
     641   \param series Series of points to be mapped
     642   \param from Index of the first point to be painted
     643   \param to Index of the last point to be painted
     644
     645   \return Translated polygon
     646 */
    406647QPolygonF QwtPointMapper::toPolygonF(
    407     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    408     const QwtSeriesData<QPointF> *series, int from, int to ) const
     648    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     649    const QwtSeriesData< QPointF >* series, int from, int to ) const
    409650{
    410651    QPolygonF polyline;
    411652
    412     if ( d_data->flags & WeedOutPoints )
    413     {
    414         if ( d_data->flags & RoundPoints )
     653    if ( m_data->flags & RoundPoints )
     654    {
     655        if ( m_data->flags & WeedOutIntermediatePoints )
     656        {
     657            polyline = qwtMapPointsQuad< QPolygonF, QPointF >(
     658                xMap, yMap, series, from, to );
     659        }
     660        else if ( m_data->flags & WeedOutPoints )
    415661        {
    416662            polyline = qwtToPolylineFilteredF(
    … …  
    419665        else
    420666        {
     667            polyline = qwtToPointsF( qwtInvalidRect,
     668                xMap, yMap, series, from, to, QwtRoundF() );
     669        }
     670    }
     671    else
     672    {
     673        if ( m_data->flags & WeedOutPoints )
     674        {
    421675            polyline = qwtToPolylineFilteredF(
    422676                xMap, yMap, series, from, to, QwtNoRoundF() );
    423677        }
    424     }
    425     else
    426     {
    427         if ( d_data->flags & RoundPoints )
    428         {
    429             polyline = qwtToPointsF( qwtInvalidRect,
    430                 xMap, yMap, series, from, to, QwtRoundF() );
    431         }
    432678        else
    433679        {
    … …  
    441687
    442688/*!
    443   \brief Translate a series of points into a QPolygon
    444 
    445   When the WeedOutPoints flag is enabled consecutive points,
    446   that are mapped to the same position will be one point.
    447 
    448   \param xMap x map
    449   \param yMap y map
    450   \param series Series of points to be mapped
    451   \param from Index of the first point to be painted
    452   \param to Index of the last point to be painted
    453 
    454   \return Translated polygon
    455 */
     689   \brief Translate a series of points into a QPolygon
     690
     691   When the WeedOutPoints flag is enabled consecutive points,
     692   that are mapped to the same position will be one point.
     693
     694   \param xMap x map
     695   \param yMap y map
     696   \param series Series of points to be mapped
     697   \param from Index of the first point to be painted
     698   \param to Index of the last point to be painted
     699
     700   \return Translated polygon
     701 */
    456702QPolygon QwtPointMapper::toPolygon(
    457     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    458     const QwtSeriesData<QPointF> *series, int from, int to ) const
     703    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     704    const QwtSeriesData< QPointF >* series, int from, int to ) const
    459705{
    460706    QPolygon polyline;
    461707
    462     if ( d_data->flags & WeedOutPoints )
     708    if ( m_data->flags & WeedOutIntermediatePoints )
     709    {
     710        // TODO WeedOutIntermediatePointsY ...
     711        polyline = qwtMapPointsQuad< QPolygon, QPoint >(
     712            xMap, yMap, series, from, to );
     713    }
     714    else if ( m_data->flags & WeedOutPoints )
    463715    {
    464716        polyline = qwtToPolylineFilteredI(
    … …  
    475727
    476728/*!
    477   \brief Translate a series into a QPolygonF
    478 
    479   - WeedOutPoints & RoundPoints & boundingRect().isValid()
     729   \brief Translate a series into a QPolygonF
     730
     731   - WeedOutPoints & RoundPoints & boundingRect().isValid()
    480732    All points that are mapped to the same position
    481733    will be one point. Points outside of the bounding
    482734    rectangle are ignored.
    483735
    484   - WeedOutPoints & RoundPoints & !boundingRect().isValid()
     736   - WeedOutPoints & RoundPoints & !boundingRect().isValid()
    485737    All consecutive points that are mapped to the same position
    486738    will one point
    487739
    488   - WeedOutPoints & !RoundPoints
     740   - WeedOutPoints & !RoundPoints
    489741    All consecutive points that are mapped to the same position
    490742    will one point
    491743
    492   - !WeedOutPoints & boundingRect().isValid()
     744   - !WeedOutPoints & boundingRect().isValid()
    493745    Points outside of the bounding rectangle are ignored.
    494746
    495   When RoundPoints is set all points are rounded to integers
    496   but returned as PolygonF - what only makes sense
    497   when the further processing of the values need a QPolygonF.
    498 
    499   \param xMap x map
    500   \param yMap y map
    501   \param series Series of points to be mapped
    502   \param from Index of the first point to be painted
    503   \param to Index of the last point to be painted
    504 
    505   \return Translated polygon
    506 */
     747   When RoundPoints is set all points are rounded to integers
     748   but returned as PolygonF - what only makes sense
     749   when the further processing of the values need a QPolygonF.
     750
     751   \param xMap x map
     752   \param yMap y map
     753   \param series Series of points to be mapped
     754   \param from Index of the first point to be painted
     755   \param to Index of the last point to be painted
     756
     757   \return Translated polygon
     758 */
    507759QPolygonF QwtPointMapper::toPointsF(
    508     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    509     const QwtSeriesData<QPointF> *series, int from, int to ) const
     760    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     761    const QwtSeriesData< QPointF >* series, int from, int to ) const
    510762{
    511763    QPolygonF points;
    512764
    513     if ( d_data->flags & WeedOutPoints )
    514     {
    515         if ( d_data->flags & RoundPoints )
    516         {
    517             if ( d_data->boundingRect.isValid() )
     765    if ( m_data->flags & WeedOutPoints )
     766    {
     767        if ( m_data->flags & RoundPoints )
     768        {
     769            if ( m_data->boundingRect.isValid() )
    518770            {
    519                 points = qwtToPointsFilteredF( d_data->boundingRect,
     771                points = qwtToPointsFilteredF( m_data->boundingRect,
    520772                    xMap, yMap, series, from, to );
    521773            }
    … …  
    541793    else
    542794    {
    543         if ( d_data->flags & RoundPoints )
    544         {
    545             points = qwtToPointsF( d_data->boundingRect,
     795        if ( m_data->flags & RoundPoints )
     796        {
     797            points = qwtToPointsF( m_data->boundingRect,
    546798                xMap, yMap, series, from, to, QwtRoundF() );
    547799        }
    548800        else
    549801        {
    550             points = qwtToPointsF( d_data->boundingRect,
     802            points = qwtToPointsF( m_data->boundingRect,
    551803                xMap, yMap, series, from, to, QwtNoRoundF() );
    552804        }
    … …  
    557809
    558810/*!
    559   \brief Translate a series of points into a QPolygon
    560 
    561   - WeedOutPoints & boundingRect().isValid()
     811   \brief Translate a series of points into a QPolygon
     812
     813   - WeedOutPoints & boundingRect().isValid()
    562814    All points that are mapped to the same position
    563815    will be one point. Points outside of the bounding
    564816    rectangle are ignored.
    565817
    566   - WeedOutPoints & !boundingRect().isValid()
     818   - WeedOutPoints & !boundingRect().isValid()
    567819    All consecutive points that are mapped to the same position
    568820    will one point
    569821
    570   - !WeedOutPoints & boundingRect().isValid()
     822   - !WeedOutPoints & boundingRect().isValid()
    571823    Points outside of the bounding rectangle are ignored.
    572824
    573   \param xMap x map
    574   \param yMap y map
    575   \param series Series of points to be mapped
    576   \param from Index of the first point to be painted
    577   \param to Index of the last point to be painted
    578 
    579   \return Translated polygon
    580 */
     825   \param xMap x map
     826   \param yMap y map
     827   \param series Series of points to be mapped
     828   \param from Index of the first point to be painted
     829   \param to Index of the last point to be painted
     830
     831   \return Translated polygon
     832 */
    581833QPolygon QwtPointMapper::toPoints(
    582     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    583     const QwtSeriesData<QPointF> *series, int from, int to ) const
     834    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     835    const QwtSeriesData< QPointF >* series, int from, int to ) const
    584836{
    585837    QPolygon points;
    586838
    587     if ( d_data->flags & WeedOutPoints )
    588     {
    589         if ( d_data->boundingRect.isValid() )
    590         {
    591             points = qwtToPointsFilteredI( d_data->boundingRect,
     839    if ( m_data->flags & WeedOutPoints )
     840    {
     841        if ( m_data->boundingRect.isValid() )
     842        {
     843            points = qwtToPointsFilteredI( m_data->boundingRect,
    592844                xMap, yMap, series, from, to );
    593845        }
    … …  
    604856    {
    605857        points = qwtToPointsI(
    606             d_data->boundingRect, xMap, yMap, series, from, to );
     858            m_data->boundingRect, xMap, yMap, series, from, to );
    607859    }
    608860
    … …  
    612864
    613865/*!
    614   \brief Translate a series into a QImage
    615 
    616   \param xMap x map
    617   \param yMap y map
    618   \param series Series of points to be mapped
    619   \param from Index of the first point to be painted
    620   \param to Index of the last point to be painted
    621   \param pen Pen used for drawing a point
     866   \brief Translate a series into a QImage
     867
     868   \param xMap x map
     869   \param yMap y map
     870   \param series Series of points to be mapped
     871   \param from Index of the first point to be painted
     872   \param to Index of the last point to be painted
     873   \param pen Pen used for drawing a point
    622874             of the image, where a point is mapped to
    623   \param antialiased True, when the dots should be displayed
     875   \param antialiased True, when the dots should be displayed
    624876                     antialiased
    625   \param numThreads Number of threads to be used for rendering.
     877   \param numThreads Number of threads to be used for rendering.
    626878                   If numThreads is set to 0, the system specific
    627879                   ideal thread count is used.
    628880
    629   \return Image displaying the series
    630 */
     881   \return Image displaying the series
     882 */
    631883QImage QwtPointMapper::toImage(
    632     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    633     const QwtSeriesData<QPointF> *series, int from, int to,
    634     const QPen &pen, bool antialiased, uint numThreads ) const
     884    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     885    const QwtSeriesData< QPointF >* series, int from, int to,
     886    const QPen& pen, bool antialiased, uint numThreads ) const
    635887{
    636888    Q_UNUSED( antialiased )
    … …  
    649901    // where every sample is mapped to one pixel only.
    650902
    651     const QRect rect = d_data->boundingRect.toAlignedRect();
     903    const QRect rect = m_data->boundingRect.toAlignedRect();
    652904
    653905    QImage image( rect.size(), QImage::Format_ARGB32 );
    … …  
    663915        const int numPoints = ( to - from + 1 ) / numThreads;
    664916
    665         QList< QFuture<void> > futures;
     917        QList< QFuture< void > > futures;
    666918        for ( uint i = 0; i < numThreads; i++ )
    667919        {
Note: See TracChangeset for help on using the changeset viewer.