Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_plot_canvas.cpp


Ignore:
Timestamp:
Mar 19, 2021, 9:15:03 AM (3 years ago)
Author:
stoecker
Message:

update to qwt verion 6.1.1 to fix build with newer Qt5

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot_canvas.cpp

    r8127 r9383  
    4949    }
    5050
     51    virtual void drawRects(const QRect *rects, int count )
     52    {
     53        // to silence -Woverloaded-virtual
     54        QwtNullPaintDevice::drawRects( rects, count );
     55    }
     56
    5157    virtual void drawPath( const QPainterPath &path )
    5258    {
     
    7379        for ( int i = 0; i < path.elementCount(); i++ )
    7480        {
    75             QPainterPath::Element el = path.elementAt(i); 
     81            QPainterPath::Element el = path.elementAt(i);
    7682            switch( el.type )
    7783            {
     
    98104                    {
    99105                        QRectF r = clipRects.last();
    100                         r.setCoords( 
     106                        r.setCoords(
    101107                            qMin( r.left(), el.x ),
    102108                            qMin( r.top(), el.y ),
     
    170176        painter->setClipPath( borderClip, Qt::IntersectClip );
    171177
    172     const QBrush &brush = 
     178    const QBrush &brush =
    173179        canvas->palette().brush( canvas->backgroundRole() );
    174180
     
    186192        {
    187193            rects += canvas->rect();
    188         } 
    189         else 
     194        }
     195        else
    190196        {
    191197            rects = painter->clipRegion().rects();
     
    197203        if ( painter->paintEngine()->type() == QPaintEngine::X11 )
    198204        {
    199             // Qt 4.7.1: gradients on X11 are broken ( subrects + 
     205            // Qt 4.7.1: gradients on X11 are broken ( subrects +
    200206            // QGradient::StretchToDeviceMode ) and horrible slow.
    201207            // As workaround we have to use the raster paintengine.
     
    223229                }
    224230            }
    225            
     231
    226232            QImage image( canvas->size(), format );
    227233
     
    268274}
    269275
    270 static QPainterPath qwtCombinePathList( const QRectF &rect, 
     276static QPainterPath qwtCombinePathList( const QRectF &rect,
    271277    const QList<QPainterPath> &pathList )
    272278{
     
    286292            if ( br.center().y() < rect.center().y() )
    287293            {
    288                 if ( qAbs( br.top() - rect.top() ) < 
     294                if ( qAbs( br.top() - rect.top() ) <
    289295                    qAbs( br.left() - rect.left() ) )
    290296                {
     
    298304            else
    299305            {
    300                 if ( qAbs( br.bottom() - rect.bottom() ) < 
     306                if ( qAbs( br.bottom() - rect.bottom() ) <
    301307                    qAbs( br.left() - rect.left() ) )
    302308                {
     
    316322            if ( br.center().y() < rect.center().y() )
    317323            {
    318                 if ( qAbs( br.top() - rect.top() ) < 
     324                if ( qAbs( br.top() - rect.top() ) <
    319325                    qAbs( br.right() - rect.right() ) )
    320326                {
     
    328334            else
    329335            {
    330                 if ( qAbs( br.bottom() - rect.bottom() ) < 
     336                if ( qAbs( br.bottom() - rect.bottom() ) <
    331337                    qAbs( br.right() - rect.right() ) )
    332338                {
     
    340346            if ( subPath.currentPosition().y() < br.center().y() )
    341347                qwtRevertPath( subPath );
    342         }   
     348        }
    343349        ordered[index] = subPath;
    344350    }
     
    381387}
    382388
    383 static inline void qwtDrawStyledBackground( 
     389static inline void qwtDrawStyledBackground(
    384390    QWidget *w, QPainter *painter )
    385391{
     
    418424}
    419425
    420 static void qwtFillBackground( QPainter *painter, 
     426static void qwtFillBackground( QPainter *painter,
    421427    QWidget *widget, const QVector<QRectF> &fillRects )
    422428{
     
    521527};
    522528
    523 /*! 
     529/*!
    524530  \brief Constructor
    525531
     
    595601                    *d_data->backingStore = grab( rect() );
    596602#else
    597                     *d_data->backingStore = 
     603                    *d_data->backingStore =
    598604                        QPixmap::grabWidget( this, rect() );
    599605#endif
     
    695701bool QwtPlotCanvas::event( QEvent *event )
    696702{
    697     if ( event->type() == QEvent::PolishRequest ) 
     703    if ( event->type() == QEvent::PolishRequest )
    698704    {
    699705        if ( testPaintAttribute( QwtPlotCanvas::Opaque ) )
    700706        {
    701             // Setting a style sheet changes the 
     707            // Setting a style sheet changes the
    702708            // Qt::WA_OpaquePaintEvent attribute, but we insist
    703709            // on painting the background.
    704            
     710
    705711            setAttribute( Qt::WA_OpaquePaintEvent, true );
    706712        }
    707713    }
    708714
    709     if ( event->type() == QEvent::PolishRequest || 
     715    if ( event->type() == QEvent::PolishRequest ||
    710716        event->type() == QEvent::StyleChange )
    711717    {
     
    729735    {
    730736        QPixmap &bs = *d_data->backingStore;
    731         if ( bs.size() != size() )
     737
     738        qreal pixelRatio = 1.0;
     739
     740#if QT_VERSION >= 0x050000
     741        pixelRatio = bs.devicePixelRatio();
     742#endif
     743
     744        if ( bs.size() != size() * pixelRatio )
    732745        {
    733746            bs = QwtPainter::backingStore( this, size() );
     
    806819            drawCanvas( &painter, false );
    807820
    808             if ( frameWidth() > 0 ) 
     821            if ( frameWidth() > 0 )
    809822                drawBorder( &painter );
    810823        }
     
    815828}
    816829
    817 void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground ) 
     830void QwtPlotCanvas::drawCanvas( QPainter *painter, bool withBackground )
    818831{
    819832    bool hackStyledBackground = false;
    820833
    821     if ( withBackground && testAttribute( Qt::WA_StyledBackground ) 
     834    if ( withBackground && testAttribute( Qt::WA_StyledBackground )
    822835        && testPaintAttribute( HackStyledBackground ) )
    823836    {
    824837        // Antialiasing rounded borders is done by
    825         // inserting pixels with colors between the 
     838        // inserting pixels with colors between the
    826839        // border color and the color on the canvas,
    827840        // When the border is painted before the plot items
     
    853866
    854867                painter->setPen( Qt::NoPen );
    855                 painter->setBrush( d_data->styleSheet.background.brush ); 
     868                painter->setBrush( d_data->styleSheet.background.brush );
    856869                painter->setBrushOrigin( d_data->styleSheet.background.origin );
    857870                painter->setClipPath( d_data->styleSheet.borderPath );
     
    894907    if ( !d_data->styleSheet.borderPath.isEmpty() )
    895908    {
    896         painter->setClipPath( 
     909        painter->setClipPath(
    897910            d_data->styleSheet.borderPath, Qt::IntersectClip );
    898911    }
     
    930943        if ( frameWidth() > 0 )
    931944        {
    932             QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 
     945            QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ),
    933946                d_data->borderRadius, d_data->borderRadius,
    934947                palette(), frameWidth(), frameStyle() );
     
    953966#endif
    954967
    955         switch (frameShape) 
     968        switch (frameShape)
    956969        {
    957970            case QFrame::Box:
     
    963976                opt.lineWidth = lineWidth();
    964977                opt.midLineWidth = midLineWidth();
    965                 break; 
    966             }
    967             default: 
     978                break;
     979            }
     980            default:
    968981            {
    969982                opt.lineWidth = frameWidth();
     
    971984            }
    972985        }
    973    
     986
    974987        if ( frameShadow == Sunken )
    975988            opt.state |= QStyle::State_Sunken;
     
    10301043
    10311044    QwtStyleSheetRecorder recorder( size() );
    1032    
     1045
    10331046    QPainter painter( &recorder );
    1034    
     1047
    10351048    QStyleOption opt;
    10361049    opt.initFrom(this);
    10371050    style()->drawPrimitive( QStyle::PE_Widget, &opt, &painter, this);
    1038    
     1051
    10391052    painter.end();
    10401053
     
    10461059        if ( !recorder.border.rectList.isEmpty() )
    10471060        {
    1048             d_data->styleSheet.borderPath = 
     1061            d_data->styleSheet.borderPath =
    10491062                qwtCombinePathList( rect(), recorder.border.pathList );
    10501063        }
     
    10971110        return path;
    10981111    }
    1099    
     1112
    11001113    return QPainterPath();
    11011114}
Note: See TracChangeset for help on using the changeset viewer.