Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_picker.cpp


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

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

    r4271 r8127  
    2828*/
    2929
    30 QwtPlotPicker::QwtPlotPicker( QwtPlotCanvas *canvas ):
     30QwtPlotPicker::QwtPlotPicker( QWidget *canvas ):
    3131    QwtPicker( canvas ),
    3232    d_xAxis( -1 ),
     
    6666  \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
    6767*/
    68 QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QwtPlotCanvas *canvas ):
     68QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QWidget *canvas ):
    6969    QwtPicker( canvas ),
    7070    d_xAxis( xAxis ),
     
    7878  \param xAxis X axis of the picker
    7979  \param yAxis Y axis of the picker
    80   \param rubberBand Rubberband style
     80  \param rubberBand Rubber band style
    8181  \param trackerMode Tracker mode
    8282  \param canvas Plot canvas to observe, also the parent object
     
    8989QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis,
    9090        RubberBand rubberBand, DisplayMode trackerMode,
    91         QwtPlotCanvas *canvas ):
     91        QWidget *canvas ):
    9292    QwtPicker( rubberBand, trackerMode, canvas ),
    9393    d_xAxis( xAxis ),
     
    101101}
    102102
    103 //! Return observed plot canvas
    104 QwtPlotCanvas *QwtPlotPicker::canvas()
    105 {
    106     return qobject_cast<QwtPlotCanvas *>( parentWidget() );
    107 }
    108 
    109 //! Return Observed plot canvas
    110 const QwtPlotCanvas *QwtPlotPicker::canvas() const
    111 {
    112     return qobject_cast<const QwtPlotCanvas *>( parentWidget() );
    113 }
    114 
    115 //! Return plot widget, containing the observed plot canvas
     103//! \return Observed plot canvas
     104QWidget *QwtPlotPicker::canvas()
     105{
     106    return parentWidget();
     107}
     108
     109//! \return Observed plot canvas
     110const QWidget *QwtPlotPicker::canvas() const
     111{
     112    return parentWidget();
     113}
     114
     115//! \return Plot widget, containing the observed plot canvas
    116116QwtPlot *QwtPlotPicker::plot()
    117117{
    118     QwtPlotCanvas *w = canvas();
     118    QWidget *w = canvas();
    119119    if ( w )
    120         return w->plot();
    121 
    122     return NULL;
    123 }
    124 
    125 //! Return plot widget, containing the observed plot canvas
     120        w = w->parentWidget();
     121
     122    return qobject_cast<QwtPlot *>( w );
     123}
     124
     125//! \return Plot widget, containing the observed plot canvas
    126126const QwtPlot *QwtPlotPicker::plot() const
    127127{
    128     const QwtPlotCanvas *w = canvas();
     128    const QWidget *w = canvas();
    129129    if ( w )
    130         return w->plot();
    131 
    132     return NULL;
    133 }
    134 
    135 /*!
    136   Return normalized bounding rect of the axes
    137 
     130        w = w->parentWidget();
     131
     132    return qobject_cast<const QwtPlot *>( w );
     133}
     134
     135/*!
     136  \return Normalized bounding rectangle of the axes
    138137  \sa QwtPlot::autoReplot(), QwtPlot::replot().
    139138*/
     
    144143    if ( plot() )
    145144    {
    146         const QwtScaleDiv *xs = plot()->axisScaleDiv( xAxis() );
    147         const QwtScaleDiv *ys = plot()->axisScaleDiv( yAxis() );
    148 
    149         if ( xs && ys )
    150         {
    151             rect = QRectF( xs->lowerBound(), ys->lowerBound(),
    152                 xs->range(), ys->range() );
    153             rect = rect.normalized();
    154         }
     145        const QwtScaleDiv &xs = plot()->axisScaleDiv( xAxis() );
     146        const QwtScaleDiv &ys = plot()->axisScaleDiv( yAxis() );
     147
     148        rect = QRectF( xs.lowerBound(), ys.lowerBound(),
     149            xs.range(), ys.range() );
     150        rect = rect.normalized();
    155151    }
    156152
     
    231227
    232228/*!
    233   Append a point to the selection and update rubberband and tracker.
     229  Append a point to the selection and update rubber band and tracker.
    234230
    235231  \param pos Additional point
     
    265261  \param ok If true, complete the selection and emit selected signals
    266262            otherwise discard the selection.
    267   \return true if the selection is accepted, false otherwise
     263  \return True if the selection has been accepted, false otherwise
    268264*/
    269265
     
    278274        return false;
    279275
    280     const QPolygon pa = selection();
    281     if ( pa.count() == 0 )
     276    const QPolygon points = selection();
     277    if ( points.count() == 0 )
    282278        return false;
    283279
     
    292288        case QwtPickerMachine::PointSelection:
    293289        {
    294             const QPointF pos = invTransform( pa[0] );
     290            const QPointF pos = invTransform( points.first() );
    295291            Q_EMIT selected( pos );
    296292            break;
     
    298294        case QwtPickerMachine::RectSelection:
    299295        {
    300             if ( pa.count() >= 2 )
     296            if ( points.count() >= 2 )
    301297            {
    302                 const QPoint p1 = pa[0];
    303                 const QPoint p2 = pa[int( pa.count() - 1 )];
     298                const QPoint p1 = points.first();
     299                const QPoint p2 = points.last();
    304300
    305301                const QRect rect = QRect( p1, p2 ).normalized();
     
    310306        case QwtPickerMachine::PolygonSelection:
    311307        {
    312             QVector<QPointF> dpa( pa.count() );
    313             for ( int i = 0; i < int( pa.count() ); i++ )
    314                 dpa[i] = invTransform( pa[i] );
     308            QVector<QPointF> dpa( points.count() );
     309            for ( int i = 0; i < points.count(); i++ )
     310                dpa[i] = invTransform( points[i] );
    315311
    316312            Q_EMIT selected( dpa );
Note: See TracChangeset for help on using the changeset viewer.