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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1515#include "qwt_scale_map.h"
    1616#include "qwt_plot.h"
    17 #include "qwt_curve_fitter.h"
     17#include "qwt_spline_curve_fitter.h"
    1818#include "qwt_symbol.h"
    1919#include "qwt_point_mapper.h"
     20#include "qwt_text.h"
     21#include "qwt_graphic.h"
     22
    2023#include <qpainter.h>
    21 #include <qpixmap.h>
    22 #include <qalgorithms.h>
    23 #include <qmath.h>
    24 
    25 static void qwtUpdateLegendIconSize( QwtPlotCurve *curve )
     24#include <qpainterpath.h>
     25#include <qnumeric.h>
     26
     27#include <climits>
     28
     29static inline QRectF qwtIntersectedClipRect( const QRectF& rect, QPainter* painter )
     30{
     31    QRectF clipRect = rect;
     32    if ( painter->hasClipping() )
     33        clipRect &= painter->clipBoundingRect();
     34
     35    return clipRect;
     36}
     37
     38static void qwtUpdateLegendIconSize( QwtPlotCurve* curve )
    2639{
    2740    if ( curve->symbol() &&
    … …  
    3548            // Avoid, that the line is completely covered by the symbol
    3649
    37             int w = qCeil( 1.5 * sz.width() );
     50            int w = qwtCeil( 1.5 * sz.width() );
    3851            if ( w % 2 )
    3952                w++;
    … …  
    4659}
    4760
    48 static int qwtVerifyRange( int size, int &i1, int &i2 )
     61static int qwtVerifyRange( int size, int& i1, int& i2 )
    4962{
    5063    if ( size < 1 )
    … …  
    6275class QwtPlotCurve::PrivateData
    6376{
    64 public:
    65     PrivateData():
    66         style( QwtPlotCurve::Lines ),
    67         baseline( 0.0 ),
    68         symbol( NULL ),
    69         attributes( 0 ),
    70         paintAttributes(
    71             QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ),
    72         legendAttributes( 0 )
    73     {
    74         pen = QPen( Qt::black );
     77  public:
     78    PrivateData()
     79        : style( QwtPlotCurve::Lines )
     80        , baseline( 0.0 )
     81        , symbol( NULL )
     82        , pen( Qt::black )
     83        , paintAttributes( QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints )
     84    {
    7585        curveFitter = new QwtSplineCurveFitter;
    7686    }
    … …  
    8595    double baseline;
    8696
    87     const QwtSymbol *symbol;
    88     QwtCurveFitter *curveFitter;
     97    const QwtSymbol* symbol;
     98    QwtCurveFitter* curveFitter;
    8999
    90100    QPen pen;
    … …  
    98108
    99109/*!
    100   Constructor
    101   \param title Title of the curve
    102 */
    103 QwtPlotCurve::QwtPlotCurve( const QwtText &title ):
    104     QwtPlotSeriesItem( title )
     110   Constructor
     111   \param title Title of the curve
     112 */
     113QwtPlotCurve::QwtPlotCurve( const QwtText& title )
     114    : QwtPlotSeriesItem( title )
    105115{
    106116    init();
    … …  
    108118
    109119/*!
    110   Constructor
    111   \param title Title of the curve
    112 */
    113 QwtPlotCurve::QwtPlotCurve( const QString &title ):
    114     QwtPlotSeriesItem( QwtText( title ) )
     120   Constructor
     121   \param title Title of the curve
     122 */
     123QwtPlotCurve::QwtPlotCurve( const QString& title )
     124    : QwtPlotSeriesItem( QwtText( title ) )
    115125{
    116126    init();
    … …  
    120130QwtPlotCurve::~QwtPlotCurve()
    121131{
    122     delete d_data;
     132    delete m_data;
    123133}
    124134
    … …  
    129139    setItemAttribute( QwtPlotItem::AutoScale );
    130140
    131     d_data = new PrivateData;
     141    m_data = new PrivateData;
    132142    setData( new QwtPointSeriesData() );
    133143
    … …  
    142152
    143153/*!
    144   Specify an attribute how to draw the curve
    145 
    146   \param attribute Paint attribute
    147   \param on On/Off
    148   \sa testPaintAttribute()
    149 */
     154   Specify an attribute how to draw the curve
     155
     156   \param attribute Paint attribute
     157   \param on On/Off
     158   \sa testPaintAttribute()
     159 */
    150160void QwtPlotCurve::setPaintAttribute( PaintAttribute attribute, bool on )
    151161{
    152162    if ( on )
    153         d_data->paintAttributes |= attribute;
     163        m_data->paintAttributes |= attribute;
    154164    else
    155         d_data->paintAttributes &= ~attribute;
     165        m_data->paintAttributes &= ~attribute;
    156166}
    157167
    … …  
    159169    \return True, when attribute is enabled
    160170    \sa setPaintAttribute()
    161 */
     171 */
    162172bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const
    163173{
    164     return ( d_data->paintAttributes & attribute );
    165 }
    166 
    167 /*!
    168   Specify an attribute how to draw the legend icon
    169 
    170   \param attribute Attribute
    171   \param on On/Off
    172   /sa testLegendAttribute(). legendIcon()
    173 */
     174    return ( m_data->paintAttributes & attribute );
     175}
     176
     177/*!
     178   Specify an attribute how to draw the legend icon
     179
     180   \param attribute Attribute
     181   \param on On/Off
     182   /sa testLegendAttribute(). legendIcon()
     183 */
    174184void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on )
    175185{
    … …  
    177187    {
    178188        if ( on )
    179             d_data->legendAttributes |= attribute;
     189            m_data->legendAttributes |= attribute;
    180190        else
    181             d_data->legendAttributes &= ~attribute;
     191            m_data->legendAttributes &= ~attribute;
    182192
    183193        qwtUpdateLegendIconSize( this );
    … …  
    187197
    188198/*!
    189   \return True, when attribute is enabled
    190   \sa setLegendAttribute()
    191 */
     199   \return True, when attribute is enabled
     200   \sa setLegendAttribute()
     201 */
    192202bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const
    193203{
    194     return ( d_data->legendAttributes & attribute );
    195 }
    196 
    197 /*!
    198   Set the curve's drawing style
    199 
    200   \param style Curve style
    201   \sa style()
    202 */
     204    return ( m_data->legendAttributes & attribute );
     205}
     206
     207/*!
     208   Specify the attributes how to draw the legend icon
     209
     210   \param attributes Attributes
     211   /sa setLegendAttribute(). legendIcon()
     212 */
     213void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes )
     214{
     215    if ( attributes != m_data->legendAttributes )
     216    {
     217        m_data->legendAttributes = attributes;
     218
     219        qwtUpdateLegendIconSize( this );
     220        legendChanged();
     221    }
     222}
     223
     224/*!
     225   \return Attributes how to draw the legend icon
     226   \sa setLegendAttributes(), testLegendAttribute()
     227 */
     228QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const
     229{
     230    return m_data->legendAttributes;
     231}
     232
     233/*!
     234   Set the curve's drawing style
     235
     236   \param style Curve style
     237   \sa style()
     238 */
    203239void QwtPlotCurve::setStyle( CurveStyle style )
    204240{
    205     if ( style != d_data->style )
    206     {
    207         d_data->style = style;
     241    if ( style != m_data->style )
     242    {
     243        m_data->style = style;
    208244
    209245        legendChanged();
    … …  
    213249
    214250/*!
    215   \return Style of the curve
    216   \sa setStyle()
    217 */
     251   \return Style of the curve
     252   \sa setStyle()
     253 */
    218254QwtPlotCurve::CurveStyle QwtPlotCurve::style() const
    219255{
    220     return d_data->style;
    221 }
    222 
    223 /*!
    224   \brief Assign a symbol
    225 
    226   The curve will take the ownership of the symbol, hence the previously
    227   set symbol will be delete by setting a new one. If \p symbol is
    228   \c NULL no symbol will be drawn.
    229 
    230   \param symbol Symbol
    231   \sa symbol()
    232 */
    233 void QwtPlotCurve::setSymbol( QwtSymbol *symbol )
    234 {
    235     if ( symbol != d_data->symbol )
    236     {
    237         delete d_data->symbol;
    238         d_data->symbol = symbol;
     256    return m_data->style;
     257}
     258
     259/*!
     260   \brief Assign a symbol
     261
     262   The curve will take the ownership of the symbol, hence the previously
     263   set symbol will be delete by setting a new one. If \p symbol is
     264   \c NULL no symbol will be drawn.
     265
     266   \param symbol Symbol
     267   \sa symbol()
     268 */
     269void QwtPlotCurve::setSymbol( QwtSymbol* symbol )
     270{
     271    if ( symbol != m_data->symbol )
     272    {
     273        delete m_data->symbol;
     274        m_data->symbol = symbol;
    239275
    240276        qwtUpdateLegendIconSize( this );
    … …  
    246282
    247283/*!
    248   \return Current symbol or NULL, when no symbol has been assigned
    249   \sa setSymbol()
    250 */
    251 const QwtSymbol *QwtPlotCurve::symbol() const
    252 {
    253     return d_data->symbol;
    254 }
    255 
    256 /*!
    257   Build and assign a pen
    258 
    259   In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
    260   non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
    261   to hide this incompatibility.
    262 
    263   \param color Pen color
    264   \param width Pen width
    265   \param style Pen style
    266 
    267   \sa pen(), brush()
    268  */
    269 void QwtPlotCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
     284   \return Current symbol or NULL, when no symbol has been assigned
     285   \sa setSymbol()
     286 */
     287const QwtSymbol* QwtPlotCurve::symbol() const
     288{
     289    return m_data->symbol;
     290}
     291
     292/*!
     293   Build and assign a pen
     294
     295   In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
     296   non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
     297   to hide this incompatibility.
     298
     299   \param color Pen color
     300   \param width Pen width
     301   \param style Pen style
     302
     303   \sa pen(), brush()
     304 */
     305void QwtPlotCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style )
    270306{
    271307    setPen( QPen( color, width, style ) );
    … …  
    273309
    274310/*!
    275   Assign a pen
    276 
    277   \param pen New pen
    278   \sa pen(), brush()
    279 */
    280 void QwtPlotCurve::setPen( const QPen &pen )
    281 {
    282     if ( pen != d_data->pen )
    283     {
    284         d_data->pen = pen;
     311   Assign a pen
     312
     313   \param pen New pen
     314   \sa pen(), brush()
     315 */
     316void QwtPlotCurve::setPen( const QPen& pen )
     317{
     318    if ( pen != m_data->pen )
     319    {
     320        m_data->pen = pen;
    285321
    286322        legendChanged();
    … …  
    290326
    291327/*!
    292   \return Pen used to draw the lines
    293   \sa setPen(), brush()
    294 */
     328   \return Pen used to draw the lines
     329   \sa setPen(), brush()
     330 */
    295331const QPen& QwtPlotCurve::pen() const
    296332{
    297     return d_data->pen;
    298 }
    299 
    300 /*!
    301   \brief Assign a brush.
     333    return m_data->pen;
     334}
     335
     336/*!
     337   \brief Assign a brush.
    302338
    303339   In case of brush.style() != QBrush::NoBrush
    … …  
    310346   (ascending or descending).
    311347
    312   \param brush New brush
    313   \sa brush(), setBaseline(), baseline()
    314 */
    315 void QwtPlotCurve::setBrush( const QBrush &brush )
    316 {
    317     if ( brush != d_data->brush )
    318     {
    319         d_data->brush = brush;
     348   \param brush New brush
     349   \sa brush(), setBaseline(), baseline()
     350 */
     351void QwtPlotCurve::setBrush( const QBrush& brush )
     352{
     353    if ( brush != m_data->brush )
     354    {
     355        m_data->brush = brush;
    320356
    321357        legendChanged();
    … …  
    325361
    326362/*!
    327   \return Brush used to fill the area between lines and the baseline
    328   \sa setBrush(), setBaseline(), baseline()
    329 */
     363   \return Brush used to fill the area between lines and the baseline
     364   \sa setBrush(), setBaseline(), baseline()
     365 */
    330366const QBrush& QwtPlotCurve::brush() const
    331367{
    332     return d_data->brush;
    333 }
    334 
    335 /*!
    336   Draw an interval of the curve
    337 
    338   \param painter Painter
    339   \param xMap Maps x-values into pixel coordinates.
    340   \param yMap Maps y-values into pixel coordinates.
    341   \param canvasRect Contents rectangle of the canvas
    342   \param from Index of the first point to be painted
    343   \param to Index of the last point to be painted. If to < 0 the
     368    return m_data->brush;
     369}
     370
     371/*!
     372   Draw an interval of the curve
     373
     374   \param painter Painter
     375   \param xMap Maps x-values into pixel coordinates.
     376   \param yMap Maps y-values into pixel coordinates.
     377   \param canvasRect Contents rectangle of the canvas
     378   \param from Index of the first point to be painted
     379   \param to Index of the last point to be painted. If to < 0 the
    344380         curve will be painted to its last point.
    345381
    346   \sa drawCurve(), drawSymbols(),
    347 */
    348 void QwtPlotCurve::drawSeries( QPainter *painter,
    349     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    350     const QRectF &canvasRect, int from, int to ) const
     382   \sa drawCurve(), drawSymbols(),
     383 */
     384void QwtPlotCurve::drawSeries( QPainter* painter,
     385    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     386    const QRectF& canvasRect, int from, int to ) const
    351387{
    352388    const size_t numSamples = dataSize();
    … …  
    361397    {
    362398        painter->save();
    363         painter->setPen( d_data->pen );
     399        painter->setPen( m_data->pen );
    364400
    365401        /*
    366           Qt 4.0.0 is slow when drawing lines, but it's even
    367           slower when the painter has a brush. So we don't
    368           set the brush before we really need it.
     402           Qt 4.0.0 is slow when drawing lines, but it's even
     403           slower when the painter has a brush. So we don't
     404           set the brush before we really need it.
    369405         */
    370406
    371         drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to );
     407        drawCurve( painter, m_data->style, xMap, yMap, canvasRect, from, to );
    372408        painter->restore();
    373409
    374         if ( d_data->symbol &&
    375             ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
     410        if ( m_data->symbol &&
     411            ( m_data->symbol->style() != QwtSymbol::NoSymbol ) )
    376412        {
    377413            painter->save();
    378             drawSymbols( painter, *d_data->symbol,
     414            drawSymbols( painter, *m_data->symbol,
    379415                xMap, yMap, canvasRect, from, to );
    380416            painter->restore();
    … …  
    384420
    385421/*!
    386   \brief Draw the line part (without symbols) of a curve interval.
    387   \param painter Painter
    388   \param style curve style, see QwtPlotCurve::CurveStyle
    389   \param xMap x map
    390   \param yMap y map
    391   \param canvasRect Contents rectangle of the canvas
    392   \param from index of the first point to be painted
    393   \param to index of the last point to be painted
    394   \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks()
    395 */
    396 void QwtPlotCurve::drawCurve( QPainter *painter, int style,
    397     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    398     const QRectF &canvasRect, int from, int to ) const
     422   \brief Draw the line part (without symbols) of a curve interval.
     423   \param painter Painter
     424   \param style curve style, see QwtPlotCurve::CurveStyle
     425   \param xMap x map
     426   \param yMap y map
     427   \param canvasRect Contents rectangle of the canvas
     428   \param from index of the first point to be painted
     429   \param to index of the last point to be painted
     430   \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks()
     431 */
     432void QwtPlotCurve::drawCurve( QPainter* painter, int style,
     433    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     434    const QRectF& canvasRect, int from, int to ) const
    399435{
    400436    switch ( style )
    … …  
    426462
    427463/*!
    428   \brief Draw lines
    429 
    430   If the CurveAttribute Fitted is enabled a QwtCurveFitter tries
    431   to interpolate/smooth the curve, before it is painted.
    432 
    433   \param painter Painter
    434   \param xMap x map
    435   \param yMap y map
    436   \param canvasRect Contents rectangle of the canvas
    437   \param from index of the first point to be painted
    438   \param to index of the last point to be painted
    439 
    440   \sa setCurveAttribute(), setCurveFitter(), draw(),
     464   \brief Draw lines
     465
     466   If the CurveAttribute Fitted is enabled a QwtCurveFitter tries
     467   to interpolate/smooth the curve, before it is painted.
     468
     469   \param painter Painter
     470   \param xMap x map
     471   \param yMap y map
     472   \param canvasRect Contents rectangle of the canvas
     473   \param from index of the first point to be painted
     474   \param to index of the last point to be painted
     475
     476   \sa setCurveAttribute(), setCurveFitter(), draw(),
    441477      drawLines(), drawDots(), drawSteps(), drawSticks()
    442 */
    443 void QwtPlotCurve::drawLines( QPainter *painter,
    444     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    445     const QRectF &canvasRect, int from, int to ) const
     478 */
     479void QwtPlotCurve::drawLines( QPainter* painter,
     480    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     481    const QRectF& canvasRect, int from, int to ) const
    446482{
    447483    if ( from > to )
    448484        return;
    449485
    450     const bool doAlign = QwtPainter::roundingAlignment( painter );
    451     const bool doFit = ( d_data->attributes & Fitted ) && d_data->curveFitter;
    452     const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
    453             && ( d_data->brush.color().alpha() > 0 );
     486    const bool doFit = ( m_data->attributes & Fitted ) && m_data->curveFitter;
     487    const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter );
     488    const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
     489        && ( m_data->brush.color().alpha() > 0 );
    454490
    455491    QRectF clipRect;
    456     if ( d_data->paintAttributes & ClipPolygons )
    457     {
    458         qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
    459         clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
    460     }
    461 
    462     bool doIntegers = false;
    463 
    464 #if QT_VERSION < 0x040800
    465 
    466     // For Qt <= 4.7 the raster paint engine is significantly faster
    467     // for rendering QPolygon than for QPolygonF. So let's
    468     // see if we can use it.
    469 
    470     if ( painter->paintEngine()->type() == QPaintEngine::Raster )
    471     {
    472         // In case of filling or fitting performance doesn't count
    473         // because both operations are much more expensive
    474         // then drawing the polyline itself
    475 
    476         if ( !doFit && !doFill )
    477             doIntegers = true;
    478     }
    479 #endif
    480 
    481     const bool noDuplicates = d_data->paintAttributes & FilterPoints;
     492    if ( m_data->paintAttributes & ClipPolygons )
     493    {
     494        clipRect = qwtIntersectedClipRect( canvasRect, painter );
     495
     496        const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
     497        clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
     498    }
    482499
    483500    QwtPointMapper mapper;
    484     mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
    485     mapper.setFlag( QwtPointMapper::WeedOutPoints, noDuplicates );
     501
     502    if ( doAlign )
     503    {
     504        mapper.setFlag( QwtPointMapper::RoundPoints, true );
     505        mapper.setFlag( QwtPointMapper::WeedOutIntermediatePoints,
     506            testPaintAttribute( FilterPointsAggressive ) );
     507    }
     508
     509    mapper.setFlag( QwtPointMapper::WeedOutPoints,
     510        testPaintAttribute( FilterPoints ) ||
     511        testPaintAttribute( FilterPointsAggressive ) );
     512
    486513    mapper.setBoundingRect( canvasRect );
    487514
    488     if ( doIntegers )
    489     {
    490         QPolygon polyline = mapper.toPolygon(
    491             xMap, yMap, data(), from, to );
    492 
    493         if ( d_data->paintAttributes & ClipPolygons )
    494         {
    495             polyline = QwtClipper::clipPolygon(
    496                 clipRect.toAlignedRect(), polyline, false );
    497         }
    498 
    499         QwtPainter::drawPolyline( painter, polyline );
     515    QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
     516
     517    if ( doFill )
     518    {
     519        if ( doFit )
     520        {
     521            // it might be better to extend and draw the curvePath, but for
     522            // the moment we keep an implementation, where we translate the
     523            // path back to a polyline.
     524
     525            polyline = m_data->curveFitter->fitCurve( polyline );
     526        }
     527
     528        if ( painter->pen().style() != Qt::NoPen )
     529        {
     530            // here we are wasting memory for the filled copy,
     531            // do polygon clipping twice etc .. TODO
     532
     533            QPolygonF filled = polyline;
     534            fillCurve( painter, xMap, yMap, canvasRect, filled );
     535            filled.clear();
     536
     537            if ( m_data->paintAttributes & ClipPolygons )
     538                QwtClipper::clipPolygonF( clipRect, polyline, false );
     539
     540            QwtPainter::drawPolyline( painter, polyline );
     541        }
     542        else
     543        {
     544            fillCurve( painter, xMap, yMap, canvasRect, polyline );
     545        }
    500546    }
    501547    else
    502548    {
    503         QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
     549        if ( testPaintAttribute( ClipPolygons ) )
     550        {
     551            QwtClipper::clipPolygonF( clipRect, polyline, false );
     552        }
    504553
    505554        if ( doFit )
    506             polyline = d_data->curveFitter->fitCurve( polyline );
    507 
    508         if ( doFill )
    509         {
    510             if ( painter->pen().style() != Qt::NoPen )
     555        {
     556            if ( m_data->curveFitter->mode() == QwtCurveFitter::Path )
    511557            {
    512                 // here we are wasting memory for the filled copy,
    513                 // do polygon clipping twice etc .. TODO
    514 
    515                 QPolygonF filled = polyline;
    516                 fillCurve( painter, xMap, yMap, canvasRect, filled );
    517                 filled.clear();
    518 
    519                 if ( d_data->paintAttributes & ClipPolygons )
    520                 {
    521                     polyline = QwtClipper::clipPolygonF(
    522                         clipRect, polyline, false );
    523                 }
    524 
    525                 QwtPainter::drawPolyline( painter, polyline );
     558                const QPainterPath curvePath =
     559                    m_data->curveFitter->fitCurvePath( polyline );
     560
     561                painter->drawPath( curvePath );
    526562            }
    527563            else
    528564            {
    529                 fillCurve( painter, xMap, yMap, canvasRect, polyline );
     565                polyline = m_data->curveFitter->fitCurve( polyline );
     566                QwtPainter::drawPolyline( painter, polyline );
    530567            }
    531568        }
    532569        else
    533570        {
    534             if ( d_data->paintAttributes & ClipPolygons )
    535             {
    536                 polyline = QwtClipper::clipPolygonF(
    537                     clipRect, polyline, false );
    538             }
    539 
    540571            QwtPainter::drawPolyline( painter, polyline );
    541572        }
    … …  
    544575
    545576/*!
    546   Draw sticks
    547 
    548   \param painter Painter
    549   \param xMap x map
    550   \param yMap y map
    551   \param canvasRect Contents rectangle of the canvas
    552   \param from index of the first point to be painted
    553   \param to index of the last point to be painted
    554 
    555   \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps()
    556 */
    557 void QwtPlotCurve::drawSticks( QPainter *painter,
    558     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    559     const QRectF &canvasRect, int from, int to ) const
     577   Draw sticks
     578
     579   \param painter Painter
     580   \param xMap x map
     581   \param yMap y map
     582   \param canvasRect Contents rectangle of the canvas
     583   \param from index of the first point to be painted
     584   \param to index of the last point to be painted
     585
     586   \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps()
     587 */
     588void QwtPlotCurve::drawSticks( QPainter* painter,
     589    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     590    const QRectF& canvasRect, int from, int to ) const
    560591{
    561592    Q_UNUSED( canvasRect )
    … …  
    566597    const bool doAlign = QwtPainter::roundingAlignment( painter );
    567598
    568     double x0 = xMap.transform( d_data->baseline );
    569     double y0 = yMap.transform( d_data->baseline );
     599    double x0 = xMap.transform( m_data->baseline );
     600    double y0 = yMap.transform( m_data->baseline );
    570601    if ( doAlign )
    571602    {
    … …  
    576607    const Qt::Orientation o = orientation();
    577608
    578     const QwtSeriesData<QPointF> *series = data();
     609    const QwtSeriesData< QPointF >* series = data();
    579610
    580611    for ( int i = from; i <= to; i++ )
    … …  
    599630
    600631/*!
    601   Draw dots
    602 
    603   \param painter Painter
    604   \param xMap x map
    605   \param yMap y map
    606   \param canvasRect Contents rectangle of the canvas
    607   \param from index of the first point to be painted
    608   \param to index of the last point to be painted
    609 
    610   \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()
    611 */
    612 void QwtPlotCurve::drawDots( QPainter *painter,
    613     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    614     const QRectF &canvasRect, int from, int to ) const
     632   Draw dots
     633
     634   \param painter Painter
     635   \param xMap x map
     636   \param yMap y map
     637   \param canvasRect Contents rectangle of the canvas
     638   \param from index of the first point to be painted
     639   \param to index of the last point to be painted
     640
     641   \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps()
     642 */
     643void QwtPlotCurve::drawDots( QPainter* painter,
     644    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     645    const QRectF& canvasRect, int from, int to ) const
    615646{
    616647    const QColor color = painter->pen().color();
    … …  
    621652    }
    622653
    623     const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
    624             && ( d_data->brush.color().alpha() > 0 );
     654    const bool doFill = ( m_data->brush.style() != Qt::NoBrush )
     655        && ( m_data->brush.color().alpha() > 0 );
    625656    const bool doAlign = QwtPainter::roundingAlignment( painter );
    626657
    … …  
    629660    mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
    630661
    631     if ( d_data->paintAttributes & FilterPoints )
     662    if ( m_data->paintAttributes & FilterPoints )
    632663    {
    633664        if ( ( color.alpha() == 255 )
    … …  
    642673        mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
    643674
    644         QPolygonF points = mapper.toPointsF(
     675        QPolygonF points = mapper.toPolygonF(
    645676            xMap, yMap, data(), from, to );
    646677
    … …  
    648679        fillCurve( painter, xMap, yMap, canvasRect, points );
    649680    }
    650     else if ( d_data->paintAttributes & ImageBuffer )
     681    else if ( m_data->paintAttributes & ImageBuffer )
    651682    {
    652683        const QImage image = mapper.toImage( xMap, yMap,
    653             data(), from, to, d_data->pen,
     684            data(), from, to, m_data->pen,
    654685            painter->testRenderHint( QPainter::Antialiasing ),
    655686            renderThreadCount() );
    … …  
    657688        painter->drawImage( canvasRect.toAlignedRect(), image );
    658689    }
    659     else if ( d_data->paintAttributes & MinimizeMemory )
    660     {
    661         const QwtSeriesData<QPointF> *series = data();
     690    else if ( m_data->paintAttributes & MinimizeMemory )
     691    {
     692        const QwtSeriesData< QPointF >* series = data();
    662693
    663694        for ( int i = from; i <= to; i++ )
    … …  
    697728
    698729/*!
    699   Draw step function
    700 
    701   The direction of the steps depends on Inverted attribute.
    702 
    703   \param painter Painter
    704   \param xMap x map
    705   \param yMap y map
    706   \param canvasRect Contents rectangle of the canvas
    707   \param from index of the first point to be painted
    708   \param to index of the last point to be painted
    709 
    710   \sa CurveAttribute, setCurveAttribute(),
     730   Draw step function
     731
     732   The direction of the steps depends on Inverted attribute.
     733
     734   \param painter Painter
     735   \param xMap x map
     736   \param yMap y map
     737   \param canvasRect Contents rectangle of the canvas
     738   \param from index of the first point to be painted
     739   \param to index of the last point to be painted
     740
     741   \sa CurveAttribute, setCurveAttribute(),
    711742      draw(), drawCurve(), drawDots(), drawLines(), drawSticks()
    712 */
    713 void QwtPlotCurve::drawSteps( QPainter *painter,
    714     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    715     const QRectF &canvasRect, int from, int to ) const
     743 */
     744void QwtPlotCurve::drawSteps( QPainter* painter,
     745    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     746    const QRectF& canvasRect, int from, int to ) const
    716747{
    717748    const bool doAlign = QwtPainter::roundingAlignment( painter );
    718749
    719750    QPolygonF polygon( 2 * ( to - from ) + 1 );
    720     QPointF *points = polygon.data();
     751    QPointF* points = polygon.data();
    721752
    722753    bool inverted = orientation() == Qt::Vertical;
    723     if ( d_data->attributes & Inverted )
     754    if ( m_data->attributes & Inverted )
    724755        inverted = !inverted;
    725756
    726     const QwtSeriesData<QPointF> *series = data();
     757    const QwtSeriesData< QPointF >* series = data();
    727758
    728759    int i, ip;
    … …  
    740771        if ( ip > 0 )
    741772        {
    742             const QPointF &p0 = points[ip - 2];
    743             QPointF &p = points[ip - 1];
     773            const QPointF& p0 = points[ip - 2];
     774            QPointF& p = points[ip - 1];
    744775
    745776            if ( inverted )
    … …  
    759790    }
    760791
    761     if ( d_data->paintAttributes & ClipPolygons )
    762     {
    763         qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
    764         const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
    765 
    766         const QPolygonF clipped = QwtClipper::clipPolygonF(
     792    if ( m_data->paintAttributes & ClipPolygons )
     793    {
     794        QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
     795
     796        const qreal pw = QwtPainter::effectivePenWidth( painter->pen() );
     797        clipRect = clipRect.adjusted(-pw, -pw, pw, pw);
     798
     799        const QPolygonF clipped = QwtClipper::clippedPolygonF(
    767800            clipRect, polygon, false );
    768801
    … …  
    774807    }
    775808
    776     if ( d_data->brush.style() != Qt::NoBrush )
     809    if ( m_data->brush.style() != Qt::NoBrush )
    777810        fillCurve( painter, xMap, yMap, canvasRect, polygon );
    778811}
    … …  
    780813
    781814/*!
    782   Specify an attribute for drawing the curve
    783 
    784   \param attribute Curve attribute
    785   \param on On/Off
    786 
    787   /sa testCurveAttribute(), setCurveFitter()
    788 */
     815   Specify an attribute for drawing the curve
     816
     817   \param attribute Curve attribute
     818   \param on On/Off
     819
     820   /sa testCurveAttribute(), setCurveFitter()
     821 */
    789822void QwtPlotCurve::setCurveAttribute( CurveAttribute attribute, bool on )
    790823{
    791     if ( bool( d_data->attributes & attribute ) == on )
     824    if ( bool( m_data->attributes & attribute ) == on )
    792825        return;
    793826
    794827    if ( on )
    795         d_data->attributes |= attribute;
     828        m_data->attributes |= attribute;
    796829    else
    797         d_data->attributes &= ~attribute;
     830        m_data->attributes &= ~attribute;
    798831
    799832    itemChanged();
    … …  
    803836    \return true, if attribute is enabled
    804837    \sa setCurveAttribute()
    805 */
     838 */
    806839bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const
    807840{
    808     return d_data->attributes & attribute;
    809 }
    810 
    811 /*!
    812   Assign a curve fitter
    813 
    814   The curve fitter "smooths" the curve points, when the Fitted
    815   CurveAttribute is set. setCurveFitter(NULL) also disables curve fitting.
    816 
    817   The curve fitter operates on the translated points ( = widget coordinates)
    818   to be functional for logarithmic scales. Obviously this is less performant
    819   for fitting algorithms, that reduce the number of points.
    820 
    821   For situations, where curve fitting is used to improve the performance
    822   of painting huge series of points it might be better to execute the fitter
    823   on the curve points once and to cache the result in the QwtSeriesData object.
    824 
    825   \param curveFitter() Curve fitter
    826   \sa Fitted
    827 */
    828 void QwtPlotCurve::setCurveFitter( QwtCurveFitter *curveFitter )
    829 {
    830     delete d_data->curveFitter;
    831     d_data->curveFitter = curveFitter;
     841    return m_data->attributes & attribute;
     842}
     843
     844/*!
     845   Assign a curve fitter
     846
     847   The curve fitter "smooths" the curve points, when the Fitted
     848   CurveAttribute is set. setCurveFitter(NULL) also disables curve fitting.
     849
     850   The curve fitter operates on the translated points ( = widget coordinates)
     851   to be functional for logarithmic scales. Obviously this is less performant
     852   for fitting algorithms, that reduce the number of points.
     853
     854   For situations, where curve fitting is used to improve the performance
     855   of painting huge series of points it might be better to execute the fitter
     856   on the curve points once and to cache the result in the QwtSeriesData object.
     857
     858   \param curveFitter() Curve fitter
     859   \sa Fitted
     860 */
     861void QwtPlotCurve::setCurveFitter( QwtCurveFitter* curveFitter )
     862{
     863    delete m_data->curveFitter;
     864    m_data->curveFitter = curveFitter;
    832865
    833866    itemChanged();
    … …  
    835868
    836869/*!
    837   Get the curve fitter. If curve fitting is disabled NULL is returned.
    838 
    839   \return Curve fitter
    840   \sa setCurveFitter(), Fitted
    841 */
    842 QwtCurveFitter *QwtPlotCurve::curveFitter() const
    843 {
    844     return d_data->curveFitter;
    845 }
    846 
    847 /*!
    848   Fill the area between the curve and the baseline with
    849   the curve brush
    850 
    851   \param painter Painter
    852   \param xMap x map
    853   \param yMap y map
    854   \param canvasRect Contents rectangle of the canvas
    855   \param polygon Polygon - will be modified !
    856 
    857   \sa setBrush(), setBaseline(), setStyle()
    858 */
    859 void QwtPlotCurve::fillCurve( QPainter *painter,
    860     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    861     const QRectF &canvasRect, QPolygonF &polygon ) const
    862 {
    863     if ( d_data->brush.style() == Qt::NoBrush )
     870   Get the curve fitter. If curve fitting is disabled NULL is returned.
     871
     872   \return Curve fitter
     873   \sa setCurveFitter(), Fitted
     874 */
     875QwtCurveFitter* QwtPlotCurve::curveFitter() const
     876{
     877    return m_data->curveFitter;
     878}
     879
     880/*!
     881   Fill the area between the curve and the baseline with
     882   the curve brush
     883
     884   \param painter Painter
     885   \param xMap x map
     886   \param yMap y map
     887   \param canvasRect Contents rectangle of the canvas
     888   \param polygon Polygon - will be modified !
     889
     890   \sa setBrush(), setBaseline(), setStyle()
     891 */
     892void QwtPlotCurve::fillCurve( QPainter* painter,
     893    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     894    const QRectF& canvasRect, QPolygonF& polygon ) const
     895{
     896    if ( m_data->brush.style() == Qt::NoBrush )
    864897        return;
    865898
    … …  
    868901        return;
    869902
    870     QBrush brush = d_data->brush;
     903    QBrush brush = m_data->brush;
    871904    if ( !brush.color().isValid() )
    872         brush.setColor( d_data->pen.color() );
    873 
    874     if ( d_data->paintAttributes & ClipPolygons )
    875         polygon = QwtClipper::clipPolygonF( canvasRect, polygon, true );
     905        brush.setColor( m_data->pen.color() );
     906
     907    if ( m_data->paintAttributes & ClipPolygons )
     908    {
     909        const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
     910        QwtClipper::clipPolygonF( clipRect, polygon, true );
     911    }
    876912
    877913    painter->save();
    … …  
    886922
    887923/*!
    888   \brief Complete a polygon to be a closed polygon including the
     924   \brief Complete a polygon to be a closed polygon including the
    889925         area between the original polygon and the baseline.
    890926
    891   \param painter Painter
    892   \param xMap X map
    893   \param yMap Y map
    894   \param polygon Polygon to be completed
    895 */
    896 void QwtPlotCurve::closePolyline( QPainter *painter,
    897     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    898     QPolygonF &polygon ) const
     927   \param painter Painter
     928   \param xMap X map
     929   \param yMap Y map
     930   \param polygon Polygon to be completed
     931 */
     932void QwtPlotCurve::closePolyline( QPainter* painter,
     933    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     934    QPolygonF& polygon ) const
    899935{
    900936    if ( polygon.size() < 2 )
    … …  
    903939    const bool doAlign = QwtPainter::roundingAlignment( painter );
    904940
    905     double baseline = d_data->baseline;
     941    double baseline = m_data->baseline;
    906942
    907943    if ( orientation() == Qt::Vertical )
    … …  
    911947
    912948        double refY = yMap.transform( baseline );
    913         if ( doAlign )
     949        if ( doAlign && qAbs( refY ) < std::numeric_limits< int >::max() )
    914950            refY = qRound( refY );
    915951
    … …  
    923959
    924960        double refX = xMap.transform( baseline );
    925         if ( doAlign )
     961        if ( doAlign && qAbs( refX ) < std::numeric_limits< int >::max() )
    926962            refX = qRound( refX );
    927963
    … …  
    932968
    933969/*!
    934   Draw symbols
    935 
    936   \param painter Painter
    937   \param symbol Curve symbol
    938   \param xMap x map
    939   \param yMap y map
    940   \param canvasRect Contents rectangle of the canvas
    941   \param from Index of the first point to be painted
    942   \param to Index of the last point to be painted
    943 
    944   \sa setSymbol(), drawSeries(), drawCurve()
    945 */
    946 void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
    947     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    948     const QRectF &canvasRect, int from, int to ) const
     970   Draw symbols
     971
     972   \param painter Painter
     973   \param symbol Curve symbol
     974   \param xMap x map
     975   \param yMap y map
     976   \param canvasRect Contents rectangle of the canvas
     977   \param from Index of the first point to be painted
     978   \param to Index of the last point to be painted
     979
     980   \sa setSymbol(), drawSeries(), drawCurve()
     981 */
     982void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol,
     983    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     984    const QRectF& canvasRect, int from, int to ) const
    949985{
    950986    QwtPointMapper mapper;
    … …  
    953989    mapper.setFlag( QwtPointMapper::WeedOutPoints,
    954990        testPaintAttribute( QwtPlotCurve::FilterPoints ) );
    955     mapper.setBoundingRect( canvasRect );
     991
     992    const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter );
     993    mapper.setBoundingRect( clipRect );
    956994
    957995    const int chunkSize = 500;
    … …  
    9701008
    9711009/*!
    972   \brief Set the value of the baseline
    973 
    974   The baseline is needed for filling the curve with a brush or
    975   the Sticks drawing style.
    976 
    977   The interpretation of the baseline depends on the orientation().
    978   With Qt::Vertical, the baseline is interpreted as a horizontal line
    979   at y = baseline(), with Qt::Horizontal, it is interpreted as a vertical
    980   line at x = baseline().
    981 
    982   The default value is 0.0.
    983 
    984   \param value Value of the baseline
    985   \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation()
    986 */
     1010   \brief Set the value of the baseline
     1011
     1012   The baseline is needed for filling the curve with a brush or
     1013   the Sticks drawing style.
     1014
     1015   The interpretation of the baseline depends on the orientation().
     1016   With Qt::Vertical, the baseline is interpreted as a horizontal line
     1017   at y = baseline(), with Qt::Horizontal, it is interpreted as a vertical
     1018   line at x = baseline().
     1019
     1020   The default value is 0.0.
     1021
     1022   \param value Value of the baseline
     1023   \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation()
     1024 */
    9871025void QwtPlotCurve::setBaseline( double value )
    9881026{
    989     if ( d_data->baseline != value )
    990     {
    991         d_data->baseline = value;
     1027    if ( m_data->baseline != value )
     1028    {
     1029        m_data->baseline = value;
    9921030        itemChanged();
    9931031    }
    … …  
    9951033
    9961034/*!
    997   \return Value of the baseline
    998   \sa setBaseline()
    999 */
     1035   \return Value of the baseline
     1036   \sa setBaseline()
     1037 */
    10001038double QwtPlotCurve::baseline() const
    10011039{
    1002     return d_data->baseline;
    1003 }
    1004 
    1005 /*!
    1006   Find the closest curve point for a specific position
    1007 
    1008   \param pos Position, where to look for the closest curve point
    1009   \param dist If dist != NULL, closestPoint() returns the distance between
    1010               the position and the closest curve point
    1011   \return Index of the closest curve point, or -1 if none can be found
     1040    return m_data->baseline;
     1041}
     1042
     1043/*!
     1044   Find the closest curve point for a specific position
     1045
     1046   \param pos Position, where to look for the closest curve point
     1047   \param dist If dist != NULL, closestPoint() returns the distance between
     1048              the position and the closest curve point in paint device coordinates
     1049   \return Index of the closest curve point, or -1 if none can be found
    10121050          ( f.e when the curve has no points )
    1013   \note closestPoint() implements a dumb algorithm, that iterates
     1051   \note closestPoint() implements a dumb algorithm, that iterates
    10141052        over all points
    1015 */
    1016 int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const
    1017 {
     1053 */
     1054int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const
     1055{
     1056    const QwtPlot* plot = this->plot();
     1057
     1058    if ( ( plot == NULL ) || !plot->isAxisValid( xAxis() ) || !plot->isAxisValid( yAxis() ) )
     1059        return -1;
     1060
    10181061    const size_t numSamples = dataSize();
    1019 
    1020     if ( plot() == NULL || numSamples <= 0 )
     1062    if ( numSamples <= 0 )
    10211063        return -1;
    10221064
    1023     const QwtSeriesData<QPointF> *series = data();
    1024 
    1025     const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
    1026     const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
     1065    const QwtSeriesData< QPointF >* series = data();
     1066
     1067    const QwtScaleMap xMap = plot->canvasMap( xAxis() );
     1068    const QwtScaleMap yMap = plot->canvasMap( yAxis() );
    10271069
    10281070    int index = -1;
    … …  
    10441086    }
    10451087    if ( dist )
    1046         *dist = qSqrt( dmin );
     1088        *dist = std::sqrt( dmin );
    10471089
    10481090    return index;
     1091}
     1092
     1093/*!
     1094   Find the curve point with the smallest coordinate larger than a specific value
     1095   The coordinates have to be monotonic in direction of the orientation.
     1096   
     1097   \param orientation Qt::Horizontal corresponds to x, Qt::Vertical to y coordinates
     1098   \param value x or y coordinate, depending on the orientation
     1099
     1100   \return Index of the curve point with the smalles coordinate above value
     1101           or -1 if there is none.
     1102
     1103   \note The implementation uses a binary search algorithm and requires the
     1104         points being ordered in direction of the orientation.
     1105
     1106   \sa qwtUpperSampleIndex()
     1107 */
     1108int QwtPlotCurve::adjacentPoint( Qt::Orientation orientation, qreal value ) const
     1109{
     1110    const QwtSeriesData< QPointF >* data = this->data();
     1111    if ( data == NULL )
     1112        return -1;
     1113
     1114    if ( orientation == Qt::Horizontal )
     1115    {
     1116        struct compareX
     1117        {
     1118            inline bool operator()( const double x, const QPointF& pos ) const
     1119            {
     1120                return ( x < pos.x() );
     1121            }
     1122        };
     1123
     1124        return qwtUpperSampleIndex< QPointF >( *data, value, compareX() );
     1125    }
     1126    else
     1127    {
     1128        struct compareY
     1129        {
     1130            inline bool operator()( const double y, const QPointF& pos ) const
     1131            {
     1132                return ( y < pos.y() );
     1133            }
     1134        };
     1135
     1136        return qwtUpperSampleIndex< QPointF >( *data, value, compareY() );
     1137    }
     1138
     1139    return -1;
     1140}
     1141
     1142/*!
     1143   Calculate a fictive curve point by interpolating between the adjacent
     1144   points. The curve points have to be monotonic in direction of the orientation.
     1145   
     1146   \param orientation For Qt::Horizontal value is a x coordinate and a y coordinate
     1147                      is returned. For Qt::Vertical value is a x coordinate
     1148   \param value x or y coordinate, depending on the orientation
     1149
     1150   \return Interpolated coordinate or qQNaN() if value is outside the bounding
     1151           rectangle of the curve
     1152
     1153   \note The implementation uses a binary search algorithm and requires the
     1154         points being ordered in direction of the orientation.
     1155
     1156   \sa adjacentPoint()
     1157 */
     1158qreal QwtPlotCurve::interpolatedValueAt( Qt::Orientation orientation, double value ) const
     1159{
     1160    const QRectF br = boundingRect();
     1161    if ( br.width() <= 0.0 )
     1162        return qQNaN();
     1163
     1164    double v;
     1165
     1166    if ( orientation == Qt::Horizontal )
     1167    {
     1168        if ( value < br.left() || value > br.right() )
     1169            return qQNaN();
     1170
     1171        const int index = adjacentPoint( orientation, value );
     1172
     1173        if ( index == -1 )
     1174        {
     1175            const QPointF last = sample( dataSize() - 1 );
     1176
     1177            if ( value != last.x() )
     1178                return qQNaN();
     1179
     1180            v = last.y();
     1181        }
     1182        else
     1183        {
     1184            const QLineF line( sample( index - 1 ), sample( index ) );
     1185            v = line.pointAt( ( value - line.p1().x() ) / line.dx() ).y();
     1186        }
     1187    }
     1188    else
     1189    {
     1190        if ( value < br.top() || value > br.bottom() )
     1191            return qQNaN();
     1192
     1193        const int index = adjacentPoint( orientation, value );
     1194
     1195        if ( index == -1 )
     1196        {
     1197            const QPointF last = sample( dataSize() - 1 );
     1198
     1199            if ( value != last.y() )
     1200                return qQNaN();
     1201
     1202            v = last.x();
     1203        }
     1204        else
     1205        {
     1206            const QLineF line( sample( index - 1 ), sample( index ) );
     1207            v = line.pointAt( ( value - line.p1().y() ) / line.dy() ).x();
     1208        }
     1209    }
     1210
     1211    return v;
    10491212}
    10501213
    … …  
    10581221   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
    10591222 */
    1060 QwtGraphic QwtPlotCurve::legendIcon( int index,
    1061     const QSizeF &size ) const
     1223QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const
    10621224{
    10631225    Q_UNUSED( index );
    … …  
    10741236        testRenderHint( QwtPlotItem::RenderAntialiased ) );
    10751237
    1076     if ( d_data->legendAttributes == 0 ||
    1077         d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
    1078     {
    1079         QBrush brush = d_data->brush;
     1238    if ( m_data->legendAttributes == 0 ||
     1239        m_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
     1240    {
     1241        QBrush brush = m_data->brush;
    10801242
    10811243        if ( brush.style() == Qt::NoBrush &&
    1082             d_data->legendAttributes == 0 )
     1244            m_data->legendAttributes == 0 )
    10831245        {
    10841246            if ( style() != QwtPlotCurve::NoCurve )
    … …  
    10861248                brush = QBrush( pen().color() );
    10871249            }
    1088             else if ( d_data->symbol &&
    1089                 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
     1250            else if ( m_data->symbol &&
     1251                ( m_data->symbol->style() != QwtSymbol::NoSymbol ) )
    10901252            {
    1091                 brush = QBrush( d_data->symbol->pen().color() );
     1253                brush = QBrush( m_data->symbol->pen().color() );
    10921254            }
    10931255        }
    … …  
    11001262    }
    11011263
    1102     if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
     1264    if ( m_data->legendAttributes & QwtPlotCurve::LegendShowLine )
    11031265    {
    11041266        if ( pen() != Qt::NoPen )
    … …  
    11141276    }
    11151277
    1116     if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
    1117     {
    1118         if ( d_data->symbol )
     1278    if ( m_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
     1279    {
     1280        if ( m_data->symbol )
    11191281        {
    11201282            QRectF r( 0, 0, size.width(), size.height() );
    1121             d_data->symbol->drawSymbol( &painter, r );
     1283            m_data->symbol->drawSymbol( &painter, r );
    11221284        }
    11231285    }
    … …  
    11271289
    11281290/*!
    1129   Initialize data with an array of points.
    1130 
    1131   \param samples Vector of points
    1132   \note QVector is implicitly shared
    1133   \note QPolygonF is derived from QVector<QPointF>
    1134 */
    1135 void QwtPlotCurve::setSamples( const QVector<QPointF> &samples )
     1291   Assign a series of points
     1292
     1293   setSamples() is just a wrapper for setData() without any additional
     1294   value - beside that it is easier to find for the developer.
     1295
     1296   \param data Data
     1297   \warning The item takes ownership of the data object, deleting
     1298           it when its not used anymore.
     1299 */
     1300void QwtPlotCurve::setSamples( QwtSeriesData< QPointF >* data )
     1301{
     1302    setData( data );
     1303}
     1304
     1305/*!
     1306   Initialize data with an array of points.
     1307
     1308   \param samples Vector of points
     1309   \note QVector is implicitly shared
     1310   \note QPolygonF is derived from QVector<QPointF>
     1311 */
     1312void QwtPlotCurve::setSamples( const QVector< QPointF >& samples )
    11361313{
    11371314    setData( new QwtPointSeriesData( samples ) );
    … …  
    11391316
    11401317/*!
    1141   Assign a series of points
    1142 
    1143   setSamples() is just a wrapper for setData() without any additional
    1144   value - beside that it is easier to find for the developer.
    1145 
    1146   \param data Data
    1147   \warning The item takes ownership of the data object, deleting
    1148            it when its not used anymore.
    1149 */
    1150 void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
    1151 {
    1152     setData( data );
    1153 }
    1154 
    1155 #ifndef QWT_NO_COMPAT
    1156 
    1157 /*!
    1158   \brief Initialize the data by pointing to memory blocks which
     1318   \brief Initialize the data by pointing to memory blocks which
    11591319         are not managed by QwtPlotCurve.
    11601320
    1161   setRawSamples is provided for efficiency.
    1162   It is important to keep the pointers
    1163   during the lifetime of the underlying QwtCPointerData class.
    1164 
    1165   \param xData pointer to x data
    1166   \param yData pointer to y data
    1167   \param size size of x and y
    1168 
    1169   \sa QwtCPointerData
    1170 */
     1321   setRawSamples is provided for efficiency.
     1322   It is important to keep the pointers
     1323   during the lifetime of the underlying QwtCPointerData class.
     1324
     1325   \param xData pointer to x data
     1326   \param yData pointer to y data
     1327   \param size size of x and y
     1328
     1329   \sa QwtCPointerData
     1330 */
    11711331void QwtPlotCurve::setRawSamples(
    1172     const double *xData, const double *yData, int size )
    1173 {
    1174     setData( new QwtCPointerData( xData, yData, size ) );
    1175 }
    1176 
    1177 /*!
    1178   Set data by copying x- and y-values from specified memory blocks.
    1179   Contrary to setRawSamples(), this function makes a 'deep copy' of
    1180   the data.
    1181 
    1182   \param xData pointer to x values
    1183   \param yData pointer to y values
    1184   \param size size of xData and yData
    1185 
    1186   \sa QwtPointArrayData
    1187 */
     1332    const double* xData, const double* yData, int size )
     1333{
     1334    setData( new QwtCPointerData< double >( xData, yData, size ) );
     1335}
     1336
     1337/*!
     1338   \brief Initialize the data by pointing to memory blocks which
     1339         are not managed by QwtPlotCurve.
     1340
     1341   setRawSamples is provided for efficiency.
     1342   It is important to keep the pointers
     1343   during the lifetime of the underlying QwtCPointerData class.
     1344
     1345   \param xData pointer to x data
     1346   \param yData pointer to y data
     1347   \param size size of x and y
     1348
     1349   \sa QwtCPointerData
     1350 */
     1351void QwtPlotCurve::setRawSamples(
     1352    const float* xData, const float* yData, int size )
     1353{
     1354    setData( new QwtCPointerData< float >( xData, yData, size ) );
     1355}
     1356
     1357/*!
     1358   \brief Initialize the data by pointing to a memory block which
     1359         is not managed by QwtPlotCurve.
     1360
     1361   The memory contains the y coordinates, while the index is
     1362   interpreted as x coordinate.
     1363
     1364   setRawSamples() is provided for efficiency. It is important to
     1365   keep the pointers during the lifetime of the underlying
     1366   QwtCPointerValueData class.
     1367
     1368   \param yData pointer to y data
     1369   \param size size of x and y
     1370
     1371   \sa QwtCPointerData
     1372 */
     1373void QwtPlotCurve::setRawSamples( const double* yData, int size )
     1374{
     1375    setData( new QwtCPointerValueData< double >( yData, size ) );
     1376}
     1377
     1378/*!
     1379   \brief Initialize the data by pointing to memory blocks which
     1380         are not managed by QwtPlotCurve.
     1381
     1382   The memory contains the y coordinates, while the index is
     1383   interpreted as x coordinate.
     1384
     1385   setRawSamples() is provided for efficiency. It is important to
     1386   keep the pointers during the lifetime of the underlying
     1387   QwtCPointerValueData class.
     1388
     1389   \param yData pointer to y data
     1390   \param size size of x and y
     1391
     1392   \sa QwtCPointerData
     1393 */
     1394void QwtPlotCurve::setRawSamples( const float* yData, int size )
     1395{
     1396    setData( new QwtCPointerValueData< float >( yData, size ) );
     1397}
     1398
     1399/*!
     1400   Set data by copying x- and y-values from specified memory blocks.
     1401   Contrary to setRawSamples(), this function makes a 'deep copy' of
     1402   the data.
     1403
     1404   \param xData pointer to x values
     1405   \param yData pointer to y values
     1406   \param size size of xData and yData
     1407
     1408   \sa QwtPointArrayData
     1409 */
    11881410void QwtPlotCurve::setSamples(
    1189     const double *xData, const double *yData, int size )
    1190 {
    1191     setData( new QwtPointArrayData( xData, yData, size ) );
    1192 }
    1193 
    1194 /*!
    1195   \brief Initialize data with x- and y-arrays (explicitly shared)
    1196 
    1197   \param xData x data
    1198   \param yData y data
    1199 
    1200   \sa QwtPointArrayData
    1201 */
    1202 void QwtPlotCurve::setSamples( const QVector<double> &xData,
    1203     const QVector<double> &yData )
    1204 {
    1205     setData( new QwtPointArrayData( xData, yData ) );
    1206 }
    1207 
    1208 #endif // !QWT_NO_COMPAT
    1209 
     1411    const double* xData, const double* yData, int size )
     1412{
     1413    setData( new QwtPointArrayData< double >( xData, yData, size ) );
     1414}
     1415
     1416/*!
     1417   Set data by copying x- and y-values from specified memory blocks.
     1418   Contrary to setRawSamples(), this function makes a 'deep copy' of
     1419   the data.
     1420
     1421   \param xData pointer to x values
     1422   \param yData pointer to y values
     1423   \param size size of xData and yData
     1424
     1425   \sa QwtPointArrayData
     1426 */
     1427void QwtPlotCurve::setSamples(
     1428    const float* xData, const float* yData, int size )
     1429{
     1430    setData( new QwtPointArrayData< float >( xData, yData, size ) );
     1431}
     1432
     1433/*!
     1434   \brief Initialize data with x- and y-arrays (explicitly shared)
     1435
     1436   \param xData x data
     1437   \param yData y data
     1438
     1439   \sa QwtPointArrayData
     1440 */
     1441void QwtPlotCurve::setSamples( const QVector< double >& xData,
     1442    const QVector< double >& yData )
     1443{
     1444    setData( new QwtPointArrayData< double >( xData, yData ) );
     1445}
     1446
     1447/*!
     1448   \brief Initialize data with x- and y-arrays (explicitly shared)
     1449
     1450   \param xData x data
     1451   \param yData y data
     1452
     1453   \sa QwtPointArrayData
     1454 */
     1455void QwtPlotCurve::setSamples( const QVector< float >& xData,
     1456    const QVector< float >& yData )
     1457{
     1458    setData( new QwtPointArrayData< float >( xData, yData ) );
     1459}
     1460
     1461/*!
     1462   Set data by copying y-values from a specified memory block.
     1463
     1464   The memory contains the y coordinates, while the index is
     1465   interpreted as x coordinate.
     1466
     1467   \param yData y data
     1468   \param size size of yData
     1469
     1470   \sa QwtValuePointData
     1471 */
     1472void QwtPlotCurve::setSamples( const double* yData, int size )
     1473{
     1474    setData( new QwtValuePointData< double >( yData, size ) );
     1475}
     1476
     1477/*!
     1478   Set data by copying y-values from a specified memory block.
     1479
     1480   The vector contains the y coordinates, while the index is
     1481   interpreted as x coordinate.
     1482
     1483   \param yData y data
     1484   \param size size of yData
     1485
     1486   \sa QwtValuePointData
     1487 */
     1488void QwtPlotCurve::setSamples( const float* yData, int size )
     1489{
     1490    setData( new QwtValuePointData< float >( yData, size ) );
     1491}
     1492
     1493/*!
     1494   Initialize data with an array of y values (explicitly shared)
     1495
     1496   The vector contains the y coordinates, while the index is
     1497   the x coordinate.
     1498
     1499   \param yData y data
     1500
     1501   \sa QwtValuePointData
     1502 */
     1503void QwtPlotCurve::setSamples( const QVector< double >& yData )
     1504{
     1505    setData( new QwtValuePointData< double >( yData ) );
     1506}
     1507
     1508/*!
     1509   Initialize data with an array of y values (explicitly shared)
     1510
     1511   The vector contains the y coordinates, while the index is
     1512   the x coordinate.
     1513
     1514   \param yData y data
     1515
     1516   \sa QwtValuePointData
     1517 */
     1518void QwtPlotCurve::setSamples( const QVector< float >& yData )
     1519{
     1520    setData( new QwtValuePointData< float >( yData ) );
     1521}
Note: See TracChangeset for help on using the changeset viewer.