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

    r8127 r9383  
    5353    if ( l.x1() == l.x2() )
    5454    {
    55         region += QRect( l.x1() - pw2, l.y1(), 
     55        region += QRect( l.x1() - pw2, l.y1(),
    5656            pw, l.y2() ).normalized();
    5757    }
    5858    else if ( l.y1() == l.y2() )
    5959    {
    60         region += QRect( l.x1(), l.y1() - pw2, 
     60        region += QRect( l.x1(), l.y1() - pw2,
    6161            l.x2(), pw ).normalized();
    6262    }
     
    7878
    7979class QwtPickerTracker: public QwtWidgetOverlay
    80 {                                 
     80{
    8181public:
    8282    QwtPickerTracker( QwtPicker *, QWidget * );
    83    
     83
    8484protected:
    8585    virtual void drawOverlay( QPainter * ) const;
    8686    virtual QRegion maskHint() const;
    87    
     87
    8888    QwtPicker *d_picker;
    89 }; 
     89};
    9090
    9191
     
    105105    {
    106106    }
    107        
     107
    108108    bool enabled;
    109109
     
    558558                case VLineRubberBand:
    559559                {
    560                     mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), 
     560                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
    561561                        pos.x(), pRect.bottom() ), pw );
    562562                    break;
     
    564564                case HLineRubberBand:
    565565                {
    566                     mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), 
     566                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
    567567                        pRect.right(), pos.y() ), pw );
    568568                    break;
     
    570570                case CrossRubberBand:
    571571                {
    572                     mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), 
     572                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(),
    573573                        pos.x(), pRect.bottom() ), pw );
    574                     mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), 
     574                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(),
    575575                        pRect.right(), pos.y() ), pw );
    576576                    break;
     
    752752   depends on the application requirements. F.e. :
    753753
    754    - A rectangular selection might need to have a specific aspect ratio only.\n
    755    - A selection could accept non intersecting polygons only.\n
    756    - ...\n
     754     - A rectangular selection might need to have a specific aspect ratio only.
     755     - A selection could accept non intersecting polygons only.
     756     - ...
    757757
    758758   The example below is for a rectangular selection, where the first
    759759   point is the center of the selected rectangle.
     760
    760761  \par Example
    761   \verbatim QPolygon MyPicker::adjustedPoints(const QPolygon &points) const
    762 {
    763     QPolygon adjusted;
    764     if ( points.size() == 2 )
    765     {
    766         const int width = qAbs(points[1].x() - points[0].x());
    767         const int height = qAbs(points[1].y() - points[0].y());
    768 
    769         QRect rect(0, 0, 2 * width, 2 * height);
    770         rect.moveCenter(points[0]);
    771 
    772         adjusted += rect.topLeft();
    773         adjusted += rect.bottomRight();
    774     }
    775     return adjusted;
    776 }\endverbatim\n
     762  \code
     763    QPolygon MyPicker::adjustedPoints( const QPolygon &points ) const
     764    {
     765        QPolygon adjusted;
     766        if ( points.size() == 2 )
     767        {
     768            const int width = qAbs( points[1].x() - points[0].x() );
     769            const int height = qAbs( points[1].y() - points[0].y() );
     770
     771            QRect rect( 0, 0, 2 * width, 2 * height );
     772            rect.moveCenter( points[0] );
     773
     774            adjusted += rect.topLeft();
     775            adjusted += rect.bottomRight();
     776        }
     777        return adjusted;
     778    }
     779  \endcode
     780  \endpar
    777781
    778782  \param points Selected points
     
    833837    {
    834838        const QPoint last =
    835             d_data->pickedPoints[int( d_data->pickedPoints.count() ) - 2];
     839            d_data->pickedPoints[ d_data->pickedPoints.count() - 2 ];
    836840
    837841        alignment |= ( pos.x() >= last.x() ) ? Qt::AlignRight : Qt::AlignLeft;
     
    11831187        case QEvent::MouseMove:
    11841188        {
    1185             const QMouseEvent *me = 
     1189            const QMouseEvent *me =
    11861190                static_cast< const QMouseEvent * >( event );
    11871191            pos = me->pos();
     
    12351239        return;
    12361240
    1237     d_data->pickedPoints.resize( 0 );
     1241    d_data->pickedPoints.clear();
    12381242    d_data->isActive = true;
    12391243    Q_EMIT activated( true );
     
    12811285            Q_EMIT selected( d_data->pickedPoints );
    12821286        else
    1283             d_data->pickedPoints.resize( 0 );
     1287            d_data->pickedPoints.clear();
    12841288
    12851289        updateDisplay();
     
    13151319    if ( d_data->isActive )
    13161320    {
    1317         const int idx = d_data->pickedPoints.count();
    1318         d_data->pickedPoints.resize( idx + 1 );
    1319         d_data->pickedPoints[idx] = pos;
     1321        d_data->pickedPoints += pos;
    13201322
    13211323        updateDisplay();
     
    13331335void QwtPicker::move( const QPoint &pos )
    13341336{
    1335     if ( d_data->isActive )
    1336     {
    1337         const int idx = d_data->pickedPoints.count() - 1;
    1338         if ( idx >= 0 )
    1339         {
    1340             if ( d_data->pickedPoints[idx] != pos )
    1341             {
    1342                 d_data->pickedPoints[idx] = pos;
    1343 
    1344                 updateDisplay();
    1345                 Q_EMIT moved( pos );
    1346             }
     1337    if ( d_data->isActive && !d_data->pickedPoints.isEmpty() )
     1338    {
     1339        QPoint &point = d_data->pickedPoints.last();
     1340        if ( point != pos )
     1341        {
     1342            point = pos;
     1343
     1344            updateDisplay();
     1345            Q_EMIT moved( pos );
    13471346        }
    13481347    }
     
    13571356void QwtPicker::remove()
    13581357{
    1359     if ( d_data->isActive )
    1360     {
    1361         const int idx = d_data->pickedPoints.count() - 1;
    1362         if ( idx > 0 )
    1363         {
    1364             const int idx = d_data->pickedPoints.count();
    1365 
    1366             const QPoint pos = d_data->pickedPoints[idx - 1];
    1367             d_data->pickedPoints.resize( idx - 1 );
    1368 
    1369             updateDisplay();
    1370             Q_EMIT removed( pos );
    1371         }
     1358    if ( d_data->isActive && !d_data->pickedPoints.isEmpty() )
     1359    {
     1360#if QT_VERSION >= 0x050100
     1361        const QPoint pos = d_data->pickedPoints.takeLast();
     1362#else
     1363        const QPoint pos = d_data->pickedPoints.last();
     1364        d_data->pickedPoints.resize( d_data->pickedPoints.count() - 1 );
     1365#endif
     1366
     1367        updateDisplay();
     1368        Q_EMIT removed( pos );
    13721369    }
    13731370}
     
    14241421    }
    14251422
    1426     const double xRatio =
    1427         double( newSize.width() ) / double( oldSize.width() );
    1428     const double yRatio =
    1429         double( newSize.height() ) / double( oldSize.height() );
    1430 
    1431     for ( int i = 0; i < int( d_data->pickedPoints.count() ); i++ )
     1423    const double xRatio = double( newSize.width() ) / double( oldSize.width() );
     1424    const double yRatio = double( newSize.height() ) / double( oldSize.height() );
     1425
     1426    for ( int i = 0; i < d_data->pickedPoints.count(); i++ )
    14321427    {
    14331428        QPoint &p = d_data->pickedPoints[i];
     
    14721467  Find the area of the observed widget, where selection might happen.
    14731468
    1474   \return parentWidget()->contentsRect() 
     1469  \return parentWidget()->contentsRect()
    14751470*/
    14761471QPainterPath QwtPicker::pickArea() const
     
    15041499            ( trackerMode() == ActiveOnly && isActive() ) )
    15051500        {
    1506             if ( trackerPen() != Qt::NoPen 
     1501            if ( trackerPen() != Qt::NoPen
    15071502                && !trackerRect( QFont() ).isEmpty() )
    15081503            {
Note: See TracChangeset for help on using the changeset viewer.