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

    r8127 r9383  
    3232}
    3333
    34 static QwtGraphic qwtPathGraphic( const QPainterPath &path, 
     34static QwtGraphic qwtPathGraphic( const QPainterPath &path,
    3535    const QPen &pen, const QBrush& brush )
    3636{
     
    4747}
    4848
    49 static inline QRectF qwtScaledBoundingRect( 
     49static inline QRectF qwtScaledBoundingRect(
    5050    const QwtGraphic &graphic, const QSizeF size )
    5151{
     
    5353    if ( scaledSize.isEmpty() )
    5454        scaledSize = graphic.defaultSize();
    55        
     55
    5656    const QSizeF sz = graphic.controlPointRect().size();
    5757
     
    5959    if ( sz.width() > 0.0 )
    6060        sx = scaledSize.width() / sz.width();
    61    
     61
    6262    double sy = 1.0;
    6363    if ( sz.height() > 0.0 )
     
    8484    if ( pm.size() != size )
    8585        pm = pm.scaled( size );
    86    
     86
    8787    QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() );
    8888    if ( symbol.isPinPointEnabled() )
     
    9595        const QPointF pos = transform.map( points[i] ) - pinPoint;
    9696
    97         QwtPainter::drawPixmap( painter, 
     97        QwtPainter::drawPixmap( painter,
    9898            QRect( pos.toPoint(), pm.size() ), pm );
    9999    }
     
    102102#ifndef QWT_NO_SVG
    103103
    104 static inline void qwtDrawSvgSymbols( QPainter *painter, 
    105     const QPointF *points, int numPoints, 
     104static inline void qwtDrawSvgSymbols( QPainter *painter,
     105    const QPointF *points, int numPoints,
    106106    QSvgRenderer *renderer, const QwtSymbol &symbol )
    107107{
     
    132132        const double y = points[i].y() - dy;
    133133
    134         renderer->render( painter, 
     134        renderer->render( painter,
    135135            QRectF( x, y, sz.width(), sz.height() ) );
    136136    }
     
    139139#endif
    140140
    141 static inline void qwtDrawGraphicSymbols( QPainter *painter, 
     141static inline void qwtDrawGraphicSymbols( QPainter *painter,
    142142    const QPointF *points, int numPoints, const QwtGraphic &graphic,
    143143    const QwtSymbol &symbol )
     
    876876*/
    877877
    878 QwtSymbol::QwtSymbol( const QPainterPath &path, 
     878QwtSymbol::QwtSymbol( const QPainterPath &path,
    879879    const QBrush &brush, const QPen &pen )
    880880{
     
    919919  \brief Set a painter path as symbol
    920920
    921   The symbol is represented by a painter path, where the 
     921  The symbol is represented by a painter path, where the
    922922  origin ( 0, 0 ) of the path coordinate system is mapped to
    923923  the position of the symbol.
     
    927927  the bounding rectangle of the path.
    928928
    929   The following code defines a symbol drawing an arrow:
    930 
    931   \verbatim
    932 #include <qwt_symbol.h>
    933 
    934 QwtSymbol *symbol = new QwtSymbol();
    935 
    936 QPen pen( Qt::black, 2 );
    937 pen.setJoinStyle( Qt::MiterJoin );
    938 
    939 symbol->setPen( pen );
    940 symbol->setBrush( Qt::red );
    941 
    942 QPainterPath path;
    943 path.moveTo( 0, 8 );
    944 path.lineTo( 0, 5 );
    945 path.lineTo( -3, 5 );
    946 path.lineTo( 0, 0 );
    947 path.lineTo( 3, 5 );
    948 path.lineTo( 0, 5 );
    949 
    950 QTransform transform;
    951 transform.rotate( -30.0 );
    952 path = transform.map( path );
    953 
    954 symbol->setPath( path );
    955 symbol->setPinPoint( QPointF( 0.0, 0.0 ) );
    956 
    957 setSize( 10, 14 );
    958 \endverbatim
     929  \par Example
     930    The following code defines a symbol drawing an arrow:
     931
     932    \code
     933      #include <qwt_symbol.h>
     934
     935      QwtSymbol *symbol = new QwtSymbol();
     936
     937      QPen pen( Qt::black, 2 );
     938      pen.setJoinStyle( Qt::MiterJoin );
     939
     940      symbol->setPen( pen );
     941      symbol->setBrush( Qt::red );
     942
     943      QPainterPath path;
     944      path.moveTo( 0, 8 );
     945      path.lineTo( 0, 5 );
     946      path.lineTo( -3, 5 );
     947      path.lineTo( 0, 0 );
     948      path.lineTo( 3, 5 );
     949      path.lineTo( 0, 5 );
     950
     951      QTransform transform;
     952      transform.rotate( -30.0 );
     953      path = transform.map( path );
     954
     955      symbol->setPath( path );
     956      symbol->setPinPoint( QPointF( 0.0, 0.0 ) );
     957
     958      setSize( 10, 14 );
     959    \endcode
     960  \endpar
    959961
    960962  \param path Painter path
     
    12371239  The position of a complex symbol is not always aligned to its center
    12381240  ( f.e an arrow, where the peak points to a position ). The pin point
    1239   defines the position inside of a Pixmap, Graphic, SvgDocument 
     1241  defines the position inside of a Pixmap, Graphic, SvgDocument
    12401242  or PainterPath symbol where the represented point has to
    12411243  be aligned to.
    1242  
     1244
    12431245  \param pos Position
    12441246  \param enable En/Disable the pin point alignment
     
    13411343                    {
    13421344                        if ( !d_data->size.isEmpty() &&
    1343                             d_data->size != d_data->pixmap.pixmap.size() ) 
     1345                            d_data->size != d_data->pixmap.pixmap.size() )
    13441346                        {
    13451347                            useCache = true;
    13461348                        }
    13471349                        break;
    1348                     }                       
     1350                    }
    13491351                    default:
    13501352                        useCache = true;
     
    13581360        const QRect br = boundingRect();
    13591361
    1360         const QRect rect( 0, 0, br.width(), br.height() );
    1361        
    13621362        if ( d_data->cache.pixmap.isNull() )
    13631363        {
     
    14021402
    14031403  \param painter Painter
    1404   \param rect Target rectangle for the symbol 
     1404  \param rect Target rectangle for the symbol
    14051405*/
    14061406void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const
     
    14111411    if ( d_data->style == QwtSymbol::Graphic )
    14121412    {
    1413         d_data->graphic.graphic.render( 
     1413        d_data->graphic.graphic.render(
    14141414            painter, rect, Qt::KeepAspectRatio );
    14151415    }
     
    14181418        if ( d_data->path.graphic.isNull() )
    14191419        {
    1420             d_data->path.graphic = qwtPathGraphic( 
     1420            d_data->path.graphic = qwtPathGraphic(
    14211421                d_data->path.path, d_data->pen, d_data->brush );
    14221422        }
    14231423
    1424         d_data->path.graphic.render( 
     1424        d_data->path.graphic.render(
    14251425            painter, rect, Qt::KeepAspectRatio );
    14261426        return;
     
    14451445            }
    14461446
    1447             d_data->svg.renderer->render( 
     1447            d_data->svg.renderer->render(
    14481448                painter, scaledRect );
    14491449        }
     
    14561456        // scale the symbol size to fit into rect.
    14571457
    1458         const double ratio = qMin( rect.width() / br.width(), 
     1458        const double ratio = qMin( rect.width() / br.width(),
    14591459            rect.height() / br.height() );
    14601460
     
    14691469        const QPointF pos;
    14701470        renderSymbols( painter, &pos, 1 );
    1471    
     1471
    14721472        d_data->isPinPointEnabled = isPinPointEnabled;
    14731473
     
    15701570            if ( d_data->path.graphic.isNull() )
    15711571            {
    1572                 d_data->path.graphic = qwtPathGraphic( d_data->path.path, 
     1572                d_data->path.graphic = qwtPathGraphic( d_data->path.path,
    15731573                    d_data->pen, d_data->brush );
    15741574            }
    15751575
    1576             qwtDrawGraphicSymbols( painter, points, numPoints, 
     1576            qwtDrawGraphicSymbols( painter, points, numPoints,
    15771577                d_data->path.graphic, *this );
    15781578            break;
     
    15851585        case QwtSymbol::Graphic:
    15861586        {
    1587             qwtDrawGraphicSymbols( painter, points, numPoints, 
     1587            qwtDrawGraphicSymbols( painter, points, numPoints,
    15881588                d_data->graphic.graphic, *this );
    15891589            break;
     
    15921592        {
    15931593#ifndef QWT_NO_SVG
    1594             qwtDrawSvgSymbols( painter, points, numPoints, 
     1594            qwtDrawSvgSymbols( painter, points, numPoints,
    15951595                d_data->svg.renderer, *this );
    15961596#endif
     
    16541654            }
    16551655
    1656             rect = qwtScaledBoundingRect( 
     1656            rect = qwtScaledBoundingRect(
    16571657                d_data->path.graphic, d_data->size );
    16581658            pinPointTranslation = true;
     
    16661666            else
    16671667                rect.setSize( d_data->size );
    1668            
     1668
    16691669            pinPointTranslation = true;
    16701670
     
    16731673        case QwtSymbol::Graphic:
    16741674        {
    1675             rect = qwtScaledBoundingRect( 
     1675            rect = qwtScaledBoundingRect(
    16761676                d_data->graphic.graphic, d_data->size );
    16771677            pinPointTranslation = true;
Note: See TracChangeset for help on using the changeset viewer.