Changeset 9383 in ntrip for trunk/BNC/qwt/qwt_series_data.h
- Timestamp:
- Mar 19, 2021, 9:15:03 AM (3 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_series_data.h
r8127 r9383 26 26 to implement an individual data access. 27 27 28 A subclass of QwtSeriesData<QPointF> must implement: 29 30 - size()\n 28 A subclass of QwtSeriesData<QPointF> must implement: 29 30 - size()\n 31 31 Should return number of data points. 32 32 … … 35 35 as QPointF object. 36 36 37 - boundingRect()\n 37 - boundingRect()\n 38 38 Should return the bounding rectangle of the data series. 39 39 It is used for autoscaling and might help certain algorithms for displaying 40 40 the data. You can use qwtBoundingRect() for an implementation 41 but often it is possible to implement a more efficient algorithm 41 but often it is possible to implement a more efficient algorithm 42 42 depending on the characteristics of the series. 43 43 The member d_boundingRect is intended for caching the calculated rectangle. 44 44 45 45 */ 46 46 template <typename T> … … 53 53 //! Destructor 54 54 virtual ~QwtSeriesData(); 55 56 #ifndef QWT_PYTHON_WRAPPER 55 57 56 58 //! \return Number of samples … … 78 80 virtual QRectF boundingRect() const = 0; 79 81 82 #else 83 // Needed for generating the python bindings, but not for using them ! 84 virtual size_t size() const { return 0; } 85 virtual T sample( size_t i ) const { return T(); } 86 virtual QRectF boundingRect() const { return d_boundingRect; } 87 #endif 88 80 89 /*! 81 90 Set a the "rect of interest" … … 86 95 87 96 The default implementation does nothing. 88 97 89 98 \param rect Rectangle of interest 90 99 */ … … 275 284 The following example shows finds a point of curve from an x 276 285 coordinate 277 278 \verbatim 279 #include <qwt_series_data.h> 280 #include <qwt_plot_curve.h> 281 282 struct compareX 283 { 284 inline bool operator()( const double x, const QPointF &pos ) const 285 { 286 return ( x < pos.x() ); 287 } 288 }; 289 290 QLineF curveLineAt( const QwtPlotCurve *curve, double x ) 291 { 292 int index = qwtUpperSampleIndex<QPointF>( 293 *curve->data(), x, compareX() ); 294 295 if ( index == -1 && 296 x == curve->sample( curve->dataSize() - 1 ).x() ) 297 { 298 // the last sample is excluded from qwtUpperSampleIndex 299 index = curve->dataSize() - 1; 300 } 301 302 QLineF line; // invalid 303 if ( index > 0 ) 304 { 305 line.setP1( curve->sample( index - 1 ) ); 306 line.setP2( curve->sample( index ) ); 307 } 308 309 return line; 310 } 311 312 \endverbatim 313 314 315 \param series Series of samples 316 \param value Value 317 \param lessThan Compare operation 318 319 \note The samples must be sorted according to the order specified 320 by the lessThan object 321 322 of the range [begin, end) and returns the position of the one-past-the-last occurrence of value. If no such item is found, returns the position where the item should be inserted. 286 \code 287 #include <qwt_series_data.h> 288 #include <qwt_plot_curve.h> 289 290 struct compareX 291 { 292 inline bool operator()( const double x, const QPointF &pos ) const 293 { 294 return ( x < pos.x() ); 295 } 296 }; 297 298 QLineF curveLineAt( const QwtPlotCurve *curve, double x ) 299 { 300 int index = qwtUpperSampleIndex<QPointF>( 301 *curve->data(), x, compareX() ); 302 303 if ( index == -1 && 304 x == curve->sample( curve->dataSize() - 1 ).x() ) 305 { 306 // the last sample is excluded from qwtUpperSampleIndex 307 index = curve->dataSize() - 1; 308 } 309 310 QLineF line; // invalid 311 if ( index > 0 ) 312 { 313 line.setP1( curve->sample( index - 1 ) ); 314 line.setP2( curve->sample( index ) ); 315 } 316 317 return line; 318 } 319 320 \endcode 321 \endpar 322 323 \param series Series of samples 324 \param value Value 325 \param lessThan Compare operation 326 327 \note The samples must be sorted according to the order specified 328 by the lessThan object 323 329 */ 324 330 template <typename T, typename LessThan> 325 331 inline int qwtUpperSampleIndex( const QwtSeriesData<T> &series, 326 double value, LessThan lessThan ) 332 double value, LessThan lessThan ) 327 333 { 328 334 const int indexMax = series.size() - 1;
Note:
See TracChangeset
for help on using the changeset viewer.