Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_point_mapper.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_point_mapper.cpp (modified) (28 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_point_mapper.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 11 11 #include "qwt_scale_map.h" 12 12 #include "qwt_pixel_matrix.h" 13 #include "qwt_series_data.h" 14 #include "qwt_math.h" 15 13 16 #include <qpolygon.h> 14 17 #include <qimage.h> … … 16 19 #include <qpainter.h> 17 20 18 #if QT_VERSION >= 0x04040019 20 21 #include <qthread.h> 21 22 #include <qfuture.h> 22 23 #include <qtconcurrentrun.h> 23 24 24 #if !defined(QT_NO_QFUTURE) 25 #if !defined( QT_NO_QFUTURE ) 25 26 #define QWT_USE_THREADS 1 26 27 #endif 27 28 29 static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 ); 30 31 static inline int qwtRoundValue( double value ) 32 { 33 return qRound( value ); 34 } 35 36 static inline double qwtRoundValueF( double value ) 37 { 38 #if 1 39 // MS Windows and at least IRIX does not have C99's nearbyint() function 40 return ( value >= 0.0 ) ? std::floor( value + 0.5 ) : std::ceil( value - 0.5 ); 41 #else 42 return nearbyint( value ); 28 43 #endif 29 30 static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 ); 44 } 45 46 static Qt::Orientation qwtProbeOrientation( 47 const QwtSeriesData< QPointF >* series, int from, int to ) 48 { 49 if ( to - from < 20 ) 50 { 51 // not enough points to "have an orientation" 52 return Qt::Horizontal; 53 } 54 55 const double x0 = series->sample( from ).x(); 56 const double xn = series->sample( to ).x(); 57 58 if ( x0 == xn ) 59 return Qt::Vertical; 60 61 const int step = ( to - from ) / 10; 62 const bool isIncreasing = xn > x0; 63 64 double x1 = x0; 65 for ( int i = from + step; i < to; i += step ) 66 { 67 const double x2 = series->sample( i ).x(); 68 if ( x2 != x1 ) 69 { 70 if ( ( x2 > x1 ) != isIncreasing ) 71 return Qt::Vertical; 72 } 73 74 x1 = x2; 75 } 76 77 return Qt::Horizontal; 78 } 79 80 namespace 81 { 82 template< class Polygon, class Point > 83 class QwtPolygonQuadrupelX 84 { 85 public: 86 inline void start( int x, int y ) 87 { 88 m_x0 = x; 89 m_y1 = m_yMin = m_yMax = m_y2 = y; 90 } 91 92 inline bool append( int x, int y ) 93 { 94 if ( m_x0 != x ) 95 return false; 96 97 if ( y < m_yMin ) 98 m_yMin = y; 99 else if ( y > m_yMax ) 100 m_yMax = y; 101 102 m_y2 = y; 103 104 return true; 105 } 106 107 inline void flush( Polygon& polyline ) 108 { 109 appendTo( m_y1, polyline ); 110 111 if ( m_y2 > m_y1 ) 112 qSwap( m_yMin, m_yMax ); 113 114 if ( m_yMax != m_y1 ) 115 appendTo( m_yMax, polyline ); 116 117 if ( m_yMin != m_yMax ) 118 appendTo( m_yMin, polyline ); 119 120 if ( m_y2 != m_yMin ) 121 appendTo( m_y2, polyline ); 122 } 123 124 private: 125 inline void appendTo( int y, Polygon& polyline ) 126 { 127 polyline += Point( m_x0, y ); 128 } 129 130 private: 131 int m_x0, m_y1, m_yMin, m_yMax, m_y2; 132 }; 133 134 template< class Polygon, class Point > 135 class QwtPolygonQuadrupelY 136 { 137 public: 138 inline void start( int x, int y ) 139 { 140 m_y0 = y; 141 m_x1 = m_xMin = m_xMax = m_x2 = x; 142 } 143 144 inline bool append( int x, int y ) 145 { 146 if ( m_y0 != y ) 147 return false; 148 149 if ( x < m_xMin ) 150 m_xMin = x; 151 else if ( x > m_xMax ) 152 m_xMax = x; 153 154 m_x2 = x; 155 156 return true; 157 } 158 159 inline void flush( Polygon& polyline ) 160 { 161 appendTo( m_x1, polyline ); 162 163 if ( m_x2 > m_x1 ) 164 qSwap( m_xMin, m_xMax ); 165 166 if ( m_xMax != m_x1 ) 167 appendTo( m_xMax, polyline ); 168 169 if ( m_xMin != m_xMax ) 170 appendTo( m_xMin, polyline ); 171 172 if ( m_x2 != m_xMin ) 173 appendTo( m_x2, polyline ); 174 } 175 176 private: 177 inline void appendTo( int x, Polygon& polyline ) 178 { 179 polyline += Point( x, m_y0 ); 180 } 181 182 int m_y0, m_x1, m_xMin, m_xMax, m_x2; 183 }; 184 } 185 186 template< class Polygon, class Point, class PolygonQuadrupel > 187 static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap, 188 const QwtSeriesData< QPointF >* series, int from, int to ) 189 { 190 const QPointF sample0 = series->sample( from ); 191 192 PolygonQuadrupel q; 193 q.start( qwtRoundValue( xMap.transform( sample0.x() ) ), 194 qwtRoundValue( yMap.transform( sample0.y() ) ) ); 195 196 Polygon polyline; 197 for ( int i = from; i <= to; i++ ) 198 { 199 const QPointF sample = series->sample( i ); 200 201 const int x = qwtRoundValue( xMap.transform( sample.x() ) ); 202 const int y = qwtRoundValue( yMap.transform( sample.y() ) ); 203 204 if ( !q.append( x, y ) ) 205 { 206 q.flush( polyline ); 207 q.start( x, y ); 208 } 209 } 210 q.flush( polyline ); 211 212 return polyline; 213 } 214 215 template< class Polygon, class Point, class PolygonQuadrupel > 216 static Polygon qwtMapPointsQuad( const Polygon& polyline ) 217 { 218 const int numPoints = polyline.size(); 219 220 if ( numPoints < 3 ) 221 return polyline; 222 223 const Point* points = polyline.constData(); 224 225 Polygon polylineXY; 226 227 PolygonQuadrupel q; 228 q.start( points[0].x(), points[0].y() ); 229 230 for ( int i = 0; i < numPoints; i++ ) 231 { 232 const int x = points[i].x(); 233 const int y = points[i].y(); 234 235 if ( !q.append( x, y ) ) 236 { 237 q.flush( polylineXY ); 238 q.start( x, y ); 239 } 240 } 241 q.flush( polylineXY ); 242 243 return polylineXY; 244 } 245 246 247 template< class Polygon, class Point > 248 static Polygon qwtMapPointsQuad( const QwtScaleMap& xMap, const QwtScaleMap& yMap, 249 const QwtSeriesData< QPointF >* series, int from, int to ) 250 { 251 Polygon polyline; 252 if ( from > to ) 253 return polyline; 254 255 /* 256 probing some values, to decide if it is better 257 to start with x or y coordinates 258 */ 259 const Qt::Orientation orientation = qwtProbeOrientation( series, from, to ); 260 261 if ( orientation == Qt::Horizontal ) 262 { 263 polyline = qwtMapPointsQuad< Polygon, Point, 264 QwtPolygonQuadrupelY< Polygon, Point > >( xMap, yMap, series, from, to ); 265 266 polyline = qwtMapPointsQuad< Polygon, Point, 267 QwtPolygonQuadrupelX< Polygon, Point > >( polyline ); 268 } 269 else 270 { 271 polyline = qwtMapPointsQuad< Polygon, Point, 272 QwtPolygonQuadrupelX< Polygon, Point > >( xMap, yMap, series, from, to ); 273 274 polyline = qwtMapPointsQuad< Polygon, Point, 275 QwtPolygonQuadrupelY< Polygon, Point > >( polyline ); 276 } 277 278 return polyline; 279 } 31 280 32 281 // Helper class to work around the 5 parameters … … 34 283 class QwtDotsCommand 35 284 { 36 public: 37 const QwtSeriesData<QPointF > *series;285 public: 286 const QwtSeriesData< QPointF >* series; 38 287 int from; 39 288 int to; … … 42 291 43 292 static void qwtRenderDots( 44 const QwtScaleMap &xMap, const QwtScaleMap&yMap,45 const QwtDotsCommand command, const QPoint &pos, QImage*image )293 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 294 const QwtDotsCommand& command, const QPoint& pos, QImage* image ) 46 295 { 47 296 const QRgb rgb = command.rgb; 48 QRgb *bits = reinterpret_cast<QRgb *>( image->bits() );297 QRgb* bits = reinterpret_cast< QRgb* >( image->bits() ); 49 298 50 299 const int w = image->width(); … … 58 307 const QPointF sample = command.series->sample( i ); 59 308 60 const int x = static_cast< int>( xMap.transform( sample.x() ) + 0.5 ) - x0;61 const int y = static_cast< int>( yMap.transform( sample.y() ) + 0.5 ) - y0;309 const int x = static_cast< int >( xMap.transform( sample.x() ) + 0.5 ) - x0; 310 const int y = static_cast< int >( yMap.transform( sample.y() ) + 0.5 ) - y0; 62 311 63 312 if ( x >= 0 && x < w && y >= 0 && y < h ) … … 66 315 } 67 316 68 static inline int qwtRoundValue( double value )69 {70 return qRound( value );71 }72 73 317 // some functors, so that the compile can inline 74 318 struct QwtRoundI 75 319 { 76 inline int operator()( double value ) 320 inline int operator()( double value ) const 77 321 { 78 322 return qwtRoundValue( value ); … … 82 326 struct QwtRoundF 83 327 { 84 inline double operator()( double value ) 85 { 86 #if 1 87 // MS Windows and at least IRIX does not have C99's nearbyint() function 88 return ( value >= 0.0 ) ? ::floor( value + 0.5 ) : ::ceil( value - 0.5 ); 89 #else 90 // slightly faster than the code above 91 return nearbyint( value ); 92 #endif 328 inline double operator()( double value ) const 329 { 330 return qwtRoundValueF( value ); 93 331 } 94 332 }; … … 96 334 struct QwtNoRoundF 97 335 { 98 inline double operator()( double value ) 336 inline double operator()( double value ) const 99 337 { 100 338 return value; … … 105 343 // the bounding rectangle 106 344 107 template<class Polygon, class Point, class Round> 345 template< class Polygon, class Point, class Round > 108 346 static inline Polygon qwtToPoints( 109 const QRectF &boundingRect,110 const QwtScaleMap &xMap, const QwtScaleMap&yMap,111 const QwtSeriesData<QPointF > *series,347 const QRectF& boundingRect, 348 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 349 const QwtSeriesData< QPointF >* series, 112 350 int from, int to, Round round ) 113 351 { 114 352 Polygon polyline( to - from + 1 ); 115 Point *points = polyline.data();353 Point* points = polyline.data(); 116 354 117 355 int numPoints = 0; … … 164 402 165 403 static inline QPolygon qwtToPointsI( 166 const QRectF &boundingRect,167 const QwtScaleMap &xMap, const QwtScaleMap&yMap,168 const QwtSeriesData<QPointF > *series,404 const QRectF& boundingRect, 405 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 406 const QwtSeriesData< QPointF >* series, 169 407 int from, int to ) 170 408 { 171 return qwtToPoints<QPolygon, QPoint>( 409 return qwtToPoints< QPolygon, QPoint >( 172 410 boundingRect, xMap, yMap, series, from, to, QwtRoundI() ); 173 411 } 174 412 175 template<class Round> 413 template< class Round > 176 414 static inline QPolygonF qwtToPointsF( 177 const QRectF &boundingRect,178 const QwtScaleMap &xMap, const QwtScaleMap&yMap,179 const QwtSeriesData<QPointF > *series,415 const QRectF& boundingRect, 416 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 417 const QwtSeriesData< QPointF >* series, 180 418 int from, int to, Round round ) 181 419 { 182 return qwtToPoints<QPolygonF, QPointF>( 420 return qwtToPoints< QPolygonF, QPointF >( 183 421 boundingRect, xMap, yMap, series, from, to, round ); 184 422 } … … 187 425 // points mapped to the same position 188 426 189 template<class Polygon, class Point, class Round> 427 template< class Polygon, class Point, class Round > 190 428 static inline Polygon qwtToPolylineFiltered( 191 const QwtScaleMap &xMap, const QwtScaleMap&yMap,192 const QwtSeriesData<QPointF > *series,429 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 430 const QwtSeriesData< QPointF >* series, 193 431 int from, int to, Round round ) 194 432 { … … 199 437 200 438 Polygon polyline( to - from + 1 ); 201 Point *points = polyline.data();439 Point* points = polyline.data(); 202 440 203 441 const QPointF sample0 = series->sample( from ); … … 223 461 224 462 static inline QPolygon qwtToPolylineFilteredI( 225 const QwtScaleMap &xMap, const QwtScaleMap&yMap,226 const QwtSeriesData<QPointF > *series,463 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 464 const QwtSeriesData< QPointF >* series, 227 465 int from, int to ) 228 466 { 229 return qwtToPolylineFiltered<QPolygon, QPoint>( 467 return qwtToPolylineFiltered< QPolygon, QPoint >( 230 468 xMap, yMap, series, from, to, QwtRoundI() ); 231 469 } 232 470 233 template<class Round> 471 template< class Round > 234 472 static inline QPolygonF qwtToPolylineFilteredF( 235 const QwtScaleMap &xMap, const QwtScaleMap&yMap,236 const QwtSeriesData<QPointF > *series,473 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 474 const QwtSeriesData< QPointF >* series, 237 475 int from, int to, Round round ) 238 476 { 239 return qwtToPolylineFiltered<QPolygonF, QPointF>( 477 return qwtToPolylineFiltered< QPolygonF, QPointF >( 240 478 xMap, yMap, series, from, to, round ); 241 479 } 242 480 243 template<class Polygon, class Point> 481 template< class Polygon, class Point > 244 482 static inline Polygon qwtToPointsFiltered( 245 const QRectF &boundingRect,246 const QwtScaleMap &xMap, const QwtScaleMap&yMap,247 const QwtSeriesData<QPointF > *series, int from, int to )483 const QRectF& boundingRect, 484 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 485 const QwtSeriesData< QPointF >* series, int from, int to ) 248 486 { 249 487 // F.e. in scatter plots ( no connecting lines ) we … … 251 489 252 490 Polygon polygon( to - from + 1 ); 253 Point *points = polygon.data();491 Point* points = polygon.data(); 254 492 255 493 QwtPixelMatrix pixelMatrix( boundingRect.toAlignedRect() ); … … 277 515 278 516 static inline QPolygon qwtToPointsFilteredI( 279 const QRectF &boundingRect,280 const QwtScaleMap &xMap, const QwtScaleMap&yMap,281 const QwtSeriesData<QPointF > *series, int from, int to )282 { 283 return qwtToPointsFiltered<QPolygon, QPoint>( 517 const QRectF& boundingRect, 518 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 519 const QwtSeriesData< QPointF >* series, int from, int to ) 520 { 521 return qwtToPointsFiltered< QPolygon, QPoint >( 284 522 boundingRect, xMap, yMap, series, from, to ); 285 523 } 286 524 287 525 static inline QPolygonF qwtToPointsFilteredF( 288 const QRectF &boundingRect,289 const QwtScaleMap &xMap, const QwtScaleMap&yMap,290 const QwtSeriesData<QPointF > *series, int from, int to )291 { 292 return qwtToPointsFiltered<QPolygonF, QPointF>( 526 const QRectF& boundingRect, 527 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 528 const QwtSeriesData< QPointF >* series, int from, int to ) 529 { 530 return qwtToPointsFiltered< QPolygonF, QPointF >( 293 531 boundingRect, xMap, yMap, series, from, to ); 294 532 } … … 296 534 class QwtPointMapper::PrivateData 297 535 { 298 public: 299 PrivateData() :300 boundingRect( qwtInvalidRect ) 536 public: 537 PrivateData() 538 : boundingRect( qwtInvalidRect ) 301 539 { 302 540 } … … 309 547 QwtPointMapper::QwtPointMapper() 310 548 { 311 d_data = new PrivateData();549 m_data = new PrivateData(); 312 550 } 313 551 … … 315 553 QwtPointMapper::~QwtPointMapper() 316 554 { 317 delete d_data;318 } 319 320 /*! 321 Set the flags affecting the transformation process 322 323 \param flags Flags 324 \sa flags(), setFlag() 555 delete m_data; 556 } 557 558 /*! 559 Set the flags affecting the transformation process 560 561 \param flags Flags 562 \sa flags(), setFlag() 325 563 */ 326 564 void QwtPointMapper::setFlags( TransformationFlags flags ) 327 565 { 328 d_data->flags = flags;329 } 330 331 /*! 332 \return Flags affecting the transformation process 333 \sa setFlags(), setFlag() 566 m_data->flags = flags; 567 } 568 569 /*! 570 \return Flags affecting the transformation process 571 \sa setFlags(), setFlag() 334 572 */ 335 573 QwtPointMapper::TransformationFlags QwtPointMapper::flags() const 336 574 { 337 return d_data->flags;338 } 339 340 /*! 341 Modify a flag affecting the transformation process 342 343 \param flag Flag type 344 \param on Value 345 346 \sa flag(), setFlags() 575 return m_data->flags; 576 } 577 578 /*! 579 Modify a flag affecting the transformation process 580 581 \param flag Flag type 582 \param on Value 583 584 \sa flag(), setFlags() 347 585 */ 348 586 void QwtPointMapper::setFlag( TransformationFlag flag, bool on ) 349 587 { 350 588 if ( on ) 351 d_data->flags |= flag;589 m_data->flags |= flag; 352 590 else 353 d_data->flags &= ~flag;354 } 355 356 /*! 357 \return True, when the flag is set 358 \param flag Flag type 359 \sa setFlag(), setFlags() 591 m_data->flags &= ~flag; 592 } 593 594 /*! 595 \return True, when the flag is set 596 \param flag Flag type 597 \sa setFlag(), setFlags() 360 598 */ 361 599 bool QwtPointMapper::testFlag( TransformationFlag flag ) const 362 600 { 363 return d_data->flags & flag;364 } 365 366 /*! 367 Set a bounding rectangle for the point mapping algorithm 368 369 A valid bounding rectangle can be used for optimizations 370 371 \param rect Bounding rectangle 372 \sa boundingRect() 373 */ 374 void QwtPointMapper::setBoundingRect( const QRectF &rect )375 { 376 d_data->boundingRect = rect;377 } 378 379 /*! 380 \return Bounding rectangle 381 \sa setBoundingRect() 601 return m_data->flags & flag; 602 } 603 604 /*! 605 Set a bounding rectangle for the point mapping algorithm 606 607 A valid bounding rectangle can be used for optimizations 608 609 \param rect Bounding rectangle 610 \sa boundingRect() 611 */ 612 void QwtPointMapper::setBoundingRect( const QRectF& rect ) 613 { 614 m_data->boundingRect = rect; 615 } 616 617 /*! 618 \return Bounding rectangle 619 \sa setBoundingRect() 382 620 */ 383 621 QRectF QwtPointMapper::boundingRect() const 384 622 { 385 return d_data->boundingRect; 386 } 387 388 /*! 389 \brief Translate a series of points into a QPolygonF 390 391 When the WeedOutPoints flag is enabled consecutive points, 392 that are mapped to the same position will be one point. 393 394 When RoundPoints is set all points are rounded to integers 395 but returned as PolygonF - what only makes sense 396 when the further processing of the values need a QPolygonF. 397 398 \param xMap x map 399 \param yMap y map 400 \param series Series of points to be mapped 401 \param from Index of the first point to be painted 402 \param to Index of the last point to be painted 403 404 \return Translated polygon 405 */ 623 return m_data->boundingRect; 624 } 625 626 /*! 627 \brief Translate a series of points into a QPolygonF 628 629 When the WeedOutPoints flag is enabled consecutive points, 630 that are mapped to the same position will be one point. 631 632 When RoundPoints is set all points are rounded to integers 633 but returned as PolygonF - what only makes sense 634 when the further processing of the values need a QPolygonF. 635 636 When RoundPoints & WeedOutIntermediatePoints is enabled an even more 637 aggressive weeding algorithm is enabled. 638 639 \param xMap x map 640 \param yMap y map 641 \param series Series of points to be mapped 642 \param from Index of the first point to be painted 643 \param to Index of the last point to be painted 644 645 \return Translated polygon 646 */ 406 647 QPolygonF QwtPointMapper::toPolygonF( 407 const QwtScaleMap &xMap, const QwtScaleMap&yMap,408 const QwtSeriesData<QPointF > *series, int from, int to ) const648 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 649 const QwtSeriesData< QPointF >* series, int from, int to ) const 409 650 { 410 651 QPolygonF polyline; 411 652 412 if ( d_data->flags & WeedOutPoints ) 413 { 414 if ( d_data->flags & RoundPoints ) 653 if ( m_data->flags & RoundPoints ) 654 { 655 if ( m_data->flags & WeedOutIntermediatePoints ) 656 { 657 polyline = qwtMapPointsQuad< QPolygonF, QPointF >( 658 xMap, yMap, series, from, to ); 659 } 660 else if ( m_data->flags & WeedOutPoints ) 415 661 { 416 662 polyline = qwtToPolylineFilteredF( … … 419 665 else 420 666 { 667 polyline = qwtToPointsF( qwtInvalidRect, 668 xMap, yMap, series, from, to, QwtRoundF() ); 669 } 670 } 671 else 672 { 673 if ( m_data->flags & WeedOutPoints ) 674 { 421 675 polyline = qwtToPolylineFilteredF( 422 676 xMap, yMap, series, from, to, QwtNoRoundF() ); 423 677 } 424 }425 else426 {427 if ( d_data->flags & RoundPoints )428 {429 polyline = qwtToPointsF( qwtInvalidRect,430 xMap, yMap, series, from, to, QwtRoundF() );431 }432 678 else 433 679 { … … 441 687 442 688 /*! 443 \brief Translate a series of points into a QPolygon 444 445 When the WeedOutPoints flag is enabled consecutive points, 446 that are mapped to the same position will be one point. 447 448 \param xMap x map 449 \param yMap y map 450 \param series Series of points to be mapped 451 \param from Index of the first point to be painted 452 \param to Index of the last point to be painted 453 454 \return Translated polygon 455 */ 689 \brief Translate a series of points into a QPolygon 690 691 When the WeedOutPoints flag is enabled consecutive points, 692 that are mapped to the same position will be one point. 693 694 \param xMap x map 695 \param yMap y map 696 \param series Series of points to be mapped 697 \param from Index of the first point to be painted 698 \param to Index of the last point to be painted 699 700 \return Translated polygon 701 */ 456 702 QPolygon QwtPointMapper::toPolygon( 457 const QwtScaleMap &xMap, const QwtScaleMap&yMap,458 const QwtSeriesData<QPointF > *series, int from, int to ) const703 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 704 const QwtSeriesData< QPointF >* series, int from, int to ) const 459 705 { 460 706 QPolygon polyline; 461 707 462 if ( d_data->flags & WeedOutPoints ) 708 if ( m_data->flags & WeedOutIntermediatePoints ) 709 { 710 // TODO WeedOutIntermediatePointsY ... 711 polyline = qwtMapPointsQuad< QPolygon, QPoint >( 712 xMap, yMap, series, from, to ); 713 } 714 else if ( m_data->flags & WeedOutPoints ) 463 715 { 464 716 polyline = qwtToPolylineFilteredI( … … 475 727 476 728 /*! 477 \brief Translate a series into a QPolygonF 478 479 - WeedOutPoints & RoundPoints & boundingRect().isValid() 729 \brief Translate a series into a QPolygonF 730 731 - WeedOutPoints & RoundPoints & boundingRect().isValid() 480 732 All points that are mapped to the same position 481 733 will be one point. Points outside of the bounding 482 734 rectangle are ignored. 483 735 484 - WeedOutPoints & RoundPoints & !boundingRect().isValid() 736 - WeedOutPoints & RoundPoints & !boundingRect().isValid() 485 737 All consecutive points that are mapped to the same position 486 738 will one point 487 739 488 - WeedOutPoints & !RoundPoints 740 - WeedOutPoints & !RoundPoints 489 741 All consecutive points that are mapped to the same position 490 742 will one point 491 743 492 - !WeedOutPoints & boundingRect().isValid() 744 - !WeedOutPoints & boundingRect().isValid() 493 745 Points outside of the bounding rectangle are ignored. 494 746 495 When RoundPoints is set all points are rounded to integers 496 but returned as PolygonF - what only makes sense 497 when the further processing of the values need a QPolygonF. 498 499 \param xMap x map 500 \param yMap y map 501 \param series Series of points to be mapped 502 \param from Index of the first point to be painted 503 \param to Index of the last point to be painted 504 505 \return Translated polygon 506 */ 747 When RoundPoints is set all points are rounded to integers 748 but returned as PolygonF - what only makes sense 749 when the further processing of the values need a QPolygonF. 750 751 \param xMap x map 752 \param yMap y map 753 \param series Series of points to be mapped 754 \param from Index of the first point to be painted 755 \param to Index of the last point to be painted 756 757 \return Translated polygon 758 */ 507 759 QPolygonF QwtPointMapper::toPointsF( 508 const QwtScaleMap &xMap, const QwtScaleMap&yMap,509 const QwtSeriesData<QPointF > *series, int from, int to ) const760 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 761 const QwtSeriesData< QPointF >* series, int from, int to ) const 510 762 { 511 763 QPolygonF points; 512 764 513 if ( d_data->flags & WeedOutPoints )514 { 515 if ( d_data->flags & RoundPoints )516 { 517 if ( d_data->boundingRect.isValid() )765 if ( m_data->flags & WeedOutPoints ) 766 { 767 if ( m_data->flags & RoundPoints ) 768 { 769 if ( m_data->boundingRect.isValid() ) 518 770 { 519 points = qwtToPointsFilteredF( d_data->boundingRect,771 points = qwtToPointsFilteredF( m_data->boundingRect, 520 772 xMap, yMap, series, from, to ); 521 773 } … … 541 793 else 542 794 { 543 if ( d_data->flags & RoundPoints )544 { 545 points = qwtToPointsF( d_data->boundingRect,795 if ( m_data->flags & RoundPoints ) 796 { 797 points = qwtToPointsF( m_data->boundingRect, 546 798 xMap, yMap, series, from, to, QwtRoundF() ); 547 799 } 548 800 else 549 801 { 550 points = qwtToPointsF( d_data->boundingRect,802 points = qwtToPointsF( m_data->boundingRect, 551 803 xMap, yMap, series, from, to, QwtNoRoundF() ); 552 804 } … … 557 809 558 810 /*! 559 \brief Translate a series of points into a QPolygon 560 561 - WeedOutPoints & boundingRect().isValid() 811 \brief Translate a series of points into a QPolygon 812 813 - WeedOutPoints & boundingRect().isValid() 562 814 All points that are mapped to the same position 563 815 will be one point. Points outside of the bounding 564 816 rectangle are ignored. 565 817 566 - WeedOutPoints & !boundingRect().isValid() 818 - WeedOutPoints & !boundingRect().isValid() 567 819 All consecutive points that are mapped to the same position 568 820 will one point 569 821 570 - !WeedOutPoints & boundingRect().isValid() 822 - !WeedOutPoints & boundingRect().isValid() 571 823 Points outside of the bounding rectangle are ignored. 572 824 573 \param xMap x map 574 \param yMap y map 575 \param series Series of points to be mapped 576 \param from Index of the first point to be painted 577 \param to Index of the last point to be painted 578 579 \return Translated polygon 580 */ 825 \param xMap x map 826 \param yMap y map 827 \param series Series of points to be mapped 828 \param from Index of the first point to be painted 829 \param to Index of the last point to be painted 830 831 \return Translated polygon 832 */ 581 833 QPolygon QwtPointMapper::toPoints( 582 const QwtScaleMap &xMap, const QwtScaleMap&yMap,583 const QwtSeriesData<QPointF > *series, int from, int to ) const834 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 835 const QwtSeriesData< QPointF >* series, int from, int to ) const 584 836 { 585 837 QPolygon points; 586 838 587 if ( d_data->flags & WeedOutPoints )588 { 589 if ( d_data->boundingRect.isValid() )590 { 591 points = qwtToPointsFilteredI( d_data->boundingRect,839 if ( m_data->flags & WeedOutPoints ) 840 { 841 if ( m_data->boundingRect.isValid() ) 842 { 843 points = qwtToPointsFilteredI( m_data->boundingRect, 592 844 xMap, yMap, series, from, to ); 593 845 } … … 604 856 { 605 857 points = qwtToPointsI( 606 d_data->boundingRect, xMap, yMap, series, from, to );858 m_data->boundingRect, xMap, yMap, series, from, to ); 607 859 } 608 860 … … 612 864 613 865 /*! 614 \brief Translate a series into a QImage 615 616 \param xMap x map 617 \param yMap y map 618 \param series Series of points to be mapped 619 \param from Index of the first point to be painted 620 \param to Index of the last point to be painted 621 \param pen Pen used for drawing a point 866 \brief Translate a series into a QImage 867 868 \param xMap x map 869 \param yMap y map 870 \param series Series of points to be mapped 871 \param from Index of the first point to be painted 872 \param to Index of the last point to be painted 873 \param pen Pen used for drawing a point 622 874 of the image, where a point is mapped to 623 \param antialiased True, when the dots should be displayed 875 \param antialiased True, when the dots should be displayed 624 876 antialiased 625 \param numThreads Number of threads to be used for rendering. 877 \param numThreads Number of threads to be used for rendering. 626 878 If numThreads is set to 0, the system specific 627 879 ideal thread count is used. 628 880 629 \return Image displaying the series 630 */ 881 \return Image displaying the series 882 */ 631 883 QImage QwtPointMapper::toImage( 632 const QwtScaleMap &xMap, const QwtScaleMap&yMap,633 const QwtSeriesData<QPointF > *series, int from, int to,634 const QPen &pen, bool antialiased, uint numThreads ) const884 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 885 const QwtSeriesData< QPointF >* series, int from, int to, 886 const QPen& pen, bool antialiased, uint numThreads ) const 635 887 { 636 888 Q_UNUSED( antialiased ) … … 649 901 // where every sample is mapped to one pixel only. 650 902 651 const QRect rect = d_data->boundingRect.toAlignedRect();903 const QRect rect = m_data->boundingRect.toAlignedRect(); 652 904 653 905 QImage image( rect.size(), QImage::Format_ARGB32 ); … … 663 915 const int numPoints = ( to - from + 1 ) / numThreads; 664 916 665 QList< QFuture< void> > futures;917 QList< QFuture< void > > futures; 666 918 for ( uint i = 0; i < numThreads; i++ ) 667 919 {
Note:
See TracChangeset
for help on using the changeset viewer.
