Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_picker.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_picker.cpp
r4271 r8127 28 28 */ 29 29 30 QwtPlotPicker::QwtPlotPicker( Q wtPlotCanvas*canvas ):30 QwtPlotPicker::QwtPlotPicker( QWidget *canvas ): 31 31 QwtPicker( canvas ), 32 32 d_xAxis( -1 ), … … 66 66 \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect() 67 67 */ 68 QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, Q wtPlotCanvas*canvas ):68 QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QWidget *canvas ): 69 69 QwtPicker( canvas ), 70 70 d_xAxis( xAxis ), … … 78 78 \param xAxis X axis of the picker 79 79 \param yAxis Y axis of the picker 80 \param rubberBand Rubber band style80 \param rubberBand Rubber band style 81 81 \param trackerMode Tracker mode 82 82 \param canvas Plot canvas to observe, also the parent object … … 89 89 QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, 90 90 RubberBand rubberBand, DisplayMode trackerMode, 91 Q wtPlotCanvas*canvas ):91 QWidget *canvas ): 92 92 QwtPicker( rubberBand, trackerMode, canvas ), 93 93 d_xAxis( xAxis ), … … 101 101 } 102 102 103 //! Return observed plot canvas104 Q wtPlotCanvas*QwtPlotPicker::canvas()105 { 106 return qobject_cast<QwtPlotCanvas *>( parentWidget());107 } 108 109 //! Return Observed plot canvas110 const Q wtPlotCanvas*QwtPlotPicker::canvas() const111 { 112 return qobject_cast<const QwtPlotCanvas *>( parentWidget());113 } 114 115 //! Return plot widget, containing the observed plot canvas103 //! \return Observed plot canvas 104 QWidget *QwtPlotPicker::canvas() 105 { 106 return parentWidget(); 107 } 108 109 //! \return Observed plot canvas 110 const QWidget *QwtPlotPicker::canvas() const 111 { 112 return parentWidget(); 113 } 114 115 //! \return Plot widget, containing the observed plot canvas 116 116 QwtPlot *QwtPlotPicker::plot() 117 117 { 118 Q wtPlotCanvas*w = canvas();118 QWidget *w = canvas(); 119 119 if ( w ) 120 return w->plot();121 122 return NULL;123 } 124 125 //! Return plot widget, containing the observed plot canvas120 w = w->parentWidget(); 121 122 return qobject_cast<QwtPlot *>( w ); 123 } 124 125 //! \return Plot widget, containing the observed plot canvas 126 126 const QwtPlot *QwtPlotPicker::plot() const 127 127 { 128 const Q wtPlotCanvas*w = canvas();128 const QWidget *w = canvas(); 129 129 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 138 137 \sa QwtPlot::autoReplot(), QwtPlot::replot(). 139 138 */ … … 144 143 if ( plot() ) 145 144 { 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(); 155 151 } 156 152 … … 231 227 232 228 /*! 233 Append a point to the selection and update rubber band and tracker.229 Append a point to the selection and update rubber band and tracker. 234 230 235 231 \param pos Additional point … … 265 261 \param ok If true, complete the selection and emit selected signals 266 262 otherwise discard the selection. 267 \return true if the selection isaccepted, false otherwise263 \return True if the selection has been accepted, false otherwise 268 264 */ 269 265 … … 278 274 return false; 279 275 280 const QPolygon p a= selection();281 if ( p a.count() == 0 )276 const QPolygon points = selection(); 277 if ( points.count() == 0 ) 282 278 return false; 283 279 … … 292 288 case QwtPickerMachine::PointSelection: 293 289 { 294 const QPointF pos = invTransform( p a[0]);290 const QPointF pos = invTransform( points.first() ); 295 291 Q_EMIT selected( pos ); 296 292 break; … … 298 294 case QwtPickerMachine::RectSelection: 299 295 { 300 if ( p a.count() >= 2 )296 if ( points.count() >= 2 ) 301 297 { 302 const QPoint p1 = p a[0];303 const QPoint p2 = p a[int( pa.count() - 1 )];298 const QPoint p1 = points.first(); 299 const QPoint p2 = points.last(); 304 300 305 301 const QRect rect = QRect( p1, p2 ).normalized(); … … 310 306 case QwtPickerMachine::PolygonSelection: 311 307 { 312 QVector<QPointF> dpa( p a.count() );313 for ( int i = 0; i < int( pa.count()); i++ )314 dpa[i] = invTransform( p a[i] );308 QVector<QPointF> dpa( points.count() ); 309 for ( int i = 0; i < points.count(); i++ ) 310 dpa[i] = invTransform( points[i] ); 315 311 316 312 Q_EMIT selected( dpa );
Note:
See TracChangeset
for help on using the changeset viewer.