Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_painter.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_painter.cpp

    r8127 r9383  
    2020#include <qpalette.h>
    2121#include <qpaintdevice.h>
     22#include <qpainterpath.h>
    2223#include <qpixmap.h>
    2324#include <qstyle.h>
     
    3334#endif
    3435
    35 #if QT_VERSION < 0x050000 
     36#if QT_VERSION < 0x050000
    3637
    3738#ifdef Q_WS_X11
     
    4445bool QwtPainter::d_roundingAlignment = true;
    4546
    46 static inline bool qwtIsClippingNeeded( 
     47static inline bool qwtIsClippingNeeded(
    4748    const QPainter *painter, QRectF &clipRect )
    4849{
     
    142143bool QwtPainter::isX11GraphicsSystem()
    143144{
     145    /*
     146        The X11 paint engine has been removed with Qt 5.0, but
     147        reintroduced with Qt 5.10. It can be enabled with
     148        "export QT_XCB_NATIVE_PAINTING=1".
     149     */
     150
    144151    static int onX11 = -1;
    145152    if ( onX11 < 0 )
     
    181188        }
    182189
    183         const QTransform tr = painter->transform();
     190        const QTransform &tr = painter->transform();
    184191        if ( tr.isRotating() || tr.isScaling() )
    185192        {
     
    196203  to a paint engine that floors to integer values. For other paint engines
    197204  ( PDF, SVG ) this flag has no effect.
    198   QwtPainter stores this flag only, the rounding itself is done in 
     205  QwtPainter stores this flag only, the rounding itself is done in
    199206  the painting code ( f.e the plot items ).
    200207
    201   The default setting is true. 
     208  The default setting is true.
    202209
    203210  \sa roundingAlignment(), isAligning()
     
    214221  much faster when they are split in smaller chunks: f.e all supported Qt versions
    215222  >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.
     223
     224  Also the raster paint engine has a nasty bug in many versions ( Qt 4.8 - ... )
     225  for short lines ( https://codereview.qt-project.org/#/c/99456 ), that is worked
     226  around in this mode.
    216227
    217228  The default setting is true.
     
    397408            unscaledRect = transform.inverted().mapRect(rect);
    398409        }
    399     } 
     410    }
    400411
    401412    txt->setDefaultFont( painter->font() );
     
    452463    QPolygonF cpa = polygon;
    453464    if ( deviceClipping )
    454         cpa = QwtClipper::clipPolygonF( clipRect, polygon );
     465        cpa = QwtClipper::clipPolygonF( clipRect, polygon, true );
    455466
    456467    painter->drawPolygon( cpa );
     
    501512    QPolygon cpa = polygon;
    502513    if ( deviceClipping )
    503         cpa = QwtClipper::clipPolygon( clipRect, polygon );
     514        cpa = QwtClipper::clipPolygon( clipRect, polygon, true );
    504515
    505516    painter->drawPolygon( cpa );
     
    537548    }
    538549    else
     550    {
    539551        qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting );
     552    }
    540553}
    541554
     
    565578        const int maxY = qFloor( clipRect.bottom() );
    566579
    567         if ( pos.x() < minX || pos.x() > maxX 
     580        if ( pos.x() < minX || pos.x() > maxX
    568581            || pos.y() < minY || pos.y() > maxY )
    569582        {
     
    576589
    577590//! Wrapper for QPainter::drawPoints()
    578 void QwtPainter::drawPoints( QPainter *painter, 
     591void QwtPainter::drawPoints( QPainter *painter,
    579592    const QPoint *points, int pointCount )
    580593{
     
    609622
    610623//! Wrapper for QPainter::drawPoints()
    611 void QwtPainter::drawPoints( QPainter *painter, 
     624void QwtPainter::drawPoints( QPainter *painter,
    612625    const QPointF *points, int pointCount )
    613626{
     
    697710
    698711/*!
    699   Draw a round frame 
     712  Draw a round frame
    700713
    701714  \param painter Painter
     
    708721*/
    709722void QwtPainter::drawRoundFrame( QPainter *painter,
    710     const QRectF &rect, const QPalette &palette, 
     723    const QRectF &rect, const QPalette &palette,
    711724    int lineWidth, int frameStyle )
    712725{
     
    787800    {
    788801        const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
    789         const QRectF innerRect = outerRect.adjusted( 
     802        const QRectF innerRect = outerRect.adjusted(
    790803            frameWidth, frameWidth, -frameWidth, -frameWidth );
    791804
     
    806819        {
    807820            const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
    808             const QRectF midRect1 = outerRect.adjusted( 
     821            const QRectF midRect1 = outerRect.adjusted(
    809822                frameWidth, frameWidth, -frameWidth, -frameWidth );
    810             const QRectF midRect2 = midRect1.adjusted( 
     823            const QRectF midRect2 = midRect1.adjusted(
    811824                midLineWidth, midLineWidth, -midLineWidth, -midLineWidth );
    812825
    813             const QRectF innerRect = midRect2.adjusted( 
     826            const QRectF innerRect = midRect2.adjusted(
    814827                frameWidth, frameWidth, -frameWidth, -frameWidth );
    815828
     
    887900        {
    888901            const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
    889             const QRectF innerRect = outerRect.adjusted( 
    890                 frameWidth - 1.0, frameWidth - 1.0, 
     902            const QRectF innerRect = outerRect.adjusted(
     903                frameWidth - 1.0, frameWidth - 1.0,
    891904                -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) );
    892905
     
    942955*/
    943956
    944 void QwtPainter::drawRoundedFrame( QPainter *painter, 
    945     const QRectF &rect, double xRadius, double yRadius, 
     957void QwtPainter::drawRoundedFrame( QPainter *painter,
     958    const QRectF &rect, double xRadius, double yRadius,
    946959    const QPalette &palette, int lineWidth, int frameStyle )
    947960{
     
    951964
    952965    double lw2 = lineWidth * 0.5;
    953     QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 );
     966    QRectF innerRect = rect.adjusted( lw2, lw2, -lw2, -lw2 );
    954967
    955968    QPainterPath path;
    956     path.addRoundedRect( r, xRadius, yRadius );
     969    path.addRoundedRect( innerRect, xRadius, yRadius );
    957970
    958971    enum Style
     
    973986        // move + 4 * ( cubicTo + lineTo )
    974987        QPainterPath pathList[8];
    975        
     988
    976989        for ( int i = 0; i < 4; i++ )
    977990        {
    978991            const int j = i * 4 + 1;
    979            
     992
    980993            pathList[ 2 * i ].moveTo(
    981994                path.elementAt(j - 1).x, path.elementAt( j - 1 ).y
    982             ); 
    983            
     995            );
     996
    984997            pathList[ 2 * i ].cubicTo(
    985998                path.elementAt(j + 0).x, path.elementAt(j + 0).y,
    986999                path.elementAt(j + 1).x, path.elementAt(j + 1).y,
    9871000                path.elementAt(j + 2).x, path.elementAt(j + 2).y );
    988                
     1001
    9891002            pathList[ 2 * i + 1 ].moveTo(
    9901003                path.elementAt(j + 2).x, path.elementAt(j + 2).y
    991             ); 
     1004            );
    9921005            pathList[ 2 * i + 1 ].lineTo(
    9931006                path.elementAt(j + 3).x, path.elementAt(j + 3).y
    994             ); 
    995         }   
     1007            );
     1008        }
    9961009
    9971010        QColor c1( palette.color( QPalette::Dark ) );
     
    10031016        for ( int i = 0; i < 4; i++ )
    10041017        {
    1005             QRectF r = pathList[2 * i].controlPointRect();
     1018            const QRectF r = pathList[2 * i].controlPointRect();
    10061019
    10071020            QPen arcPen;
     
    11471160}
    11481161
    1149 static inline void qwtFillRect( const QWidget *widget, QPainter *painter, 
     1162static inline void qwtFillRect( const QWidget *widget, QPainter *painter,
    11501163    const QRect &rect, const QBrush &brush)
    11511164{
    1152     if ( brush.style() == Qt::TexturePattern ) 
     1165    if ( brush.style() == Qt::TexturePattern )
    11531166    {
    11541167        painter->save();
     
    11581171
    11591172        painter->restore();
    1160     } 
     1173    }
    11611174    else if ( brush.gradient() )
    11621175    {
     
    11641177
    11651178        painter->setClipRect( rect );
    1166         painter->fillRect(0, 0, widget->width(), 
     1179        painter->fillRect(0, 0, widget->width(),
    11671180            widget->height(), brush);
    11681181
    11691182        painter->restore();
    1170     } 
    1171     else 
     1183    }
     1184    else
    11721185    {
    11731186        painter->fillRect(rect, brush);
     
    11791192
    11801193  In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy
    1181   for backgrounds with gradients. Thus fillPixmap() offers 
     1194  for backgrounds with gradients. Thus fillPixmap() offers
    11821195  an alternative implementation.
    11831196
    11841197  \param widget Widget
    11851198  \param pixmap Pixmap to be filled
    1186   \param offset Offset 
     1199  \param offset Offset
    11871200
    11881201  \sa QPixmap::fill()
    11891202 */
    1190 void QwtPainter::fillPixmap( const QWidget *widget, 
     1203void QwtPainter::fillPixmap( const QWidget *widget,
    11911204    QPixmap &pixmap, const QPoint &offset )
    11921205{
     
    11961209    painter.translate( -offset );
    11971210
    1198     const QBrush autoFillBrush = 
     1211    const QBrush autoFillBrush =
    11991212        widget->palette().brush( widget->backgroundRole() );
    12001213
    1201     if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) 
     1214    if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) )
    12021215    {
    12031216        const QBrush bg = widget->palette().brush( QPalette::Window );
     
    12081221        qwtFillRect( widget, &painter, rect, autoFillBrush);
    12091222
    1210     if ( widget->testAttribute(Qt::WA_StyledBackground) ) 
     1223    if ( widget->testAttribute(Qt::WA_StyledBackground) )
    12111224    {
    12121225        painter.setClipRegion( rect );
     
    12141227        QStyleOption opt;
    12151228        opt.initFrom( widget );
    1216         widget->style()->drawPrimitive( QStyle::PE_Widget, 
     1229        widget->style()->drawPrimitive( QStyle::PE_Widget,
    12171230            &opt, &painter, widget );
    12181231    }
     
    12851298#endif
    12861299
    1287 #if QT_VERSION < 0x050000 
     1300#if QT_VERSION < 0x050000
    12881301#ifdef Q_WS_X11
    12891302    if ( widget && isX11GraphicsSystem() )
Note: See TracChangeset for help on using the changeset viewer.