Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_curve.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_curve.cpp (modified) (56 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_curve.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 15 15 #include "qwt_scale_map.h" 16 16 #include "qwt_plot.h" 17 #include "qwt_curve_fitter.h" 17 #include "qwt_spline_curve_fitter.h" 18 18 #include "qwt_symbol.h" 19 19 #include "qwt_point_mapper.h" 20 #include "qwt_text.h" 21 #include "qwt_graphic.h" 22 20 23 #include <qpainter.h> 21 #include <qpixmap.h> 22 #include <qalgorithms.h> 23 #include <qmath.h> 24 25 static void qwtUpdateLegendIconSize( QwtPlotCurve *curve ) 24 #include <qpainterpath.h> 25 #include <qnumeric.h> 26 27 #include <climits> 28 29 static inline QRectF qwtIntersectedClipRect( const QRectF& rect, QPainter* painter ) 30 { 31 QRectF clipRect = rect; 32 if ( painter->hasClipping() ) 33 clipRect &= painter->clipBoundingRect(); 34 35 return clipRect; 36 } 37 38 static void qwtUpdateLegendIconSize( QwtPlotCurve* curve ) 26 39 { 27 40 if ( curve->symbol() && … … 35 48 // Avoid, that the line is completely covered by the symbol 36 49 37 int w = qCeil( 1.5 * sz.width() ); 50 int w = qwtCeil( 1.5 * sz.width() ); 38 51 if ( w % 2 ) 39 52 w++; … … 46 59 } 47 60 48 static int qwtVerifyRange( int size, int &i1, int&i2 )61 static int qwtVerifyRange( int size, int& i1, int& i2 ) 49 62 { 50 63 if ( size < 1 ) … … 62 75 class QwtPlotCurve::PrivateData 63 76 { 64 public: 65 PrivateData(): 66 style( QwtPlotCurve::Lines ), 67 baseline( 0.0 ), 68 symbol( NULL ), 69 attributes( 0 ), 70 paintAttributes( 71 QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ), 72 legendAttributes( 0 ) 73 { 74 pen = QPen( Qt::black ); 77 public: 78 PrivateData() 79 : style( QwtPlotCurve::Lines ) 80 , baseline( 0.0 ) 81 , symbol( NULL ) 82 , pen( Qt::black ) 83 , paintAttributes( QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ) 84 { 75 85 curveFitter = new QwtSplineCurveFitter; 76 86 } … … 85 95 double baseline; 86 96 87 const QwtSymbol *symbol;88 QwtCurveFitter *curveFitter;97 const QwtSymbol* symbol; 98 QwtCurveFitter* curveFitter; 89 99 90 100 QPen pen; … … 98 108 99 109 /*! 100 Constructor 101 \param title Title of the curve 102 */ 103 QwtPlotCurve::QwtPlotCurve( const QwtText &title ):104 QwtPlotSeriesItem( title ) 110 Constructor 111 \param title Title of the curve 112 */ 113 QwtPlotCurve::QwtPlotCurve( const QwtText& title ) 114 : QwtPlotSeriesItem( title ) 105 115 { 106 116 init(); … … 108 118 109 119 /*! 110 Constructor 111 \param title Title of the curve 112 */ 113 QwtPlotCurve::QwtPlotCurve( const QString &title ):114 QwtPlotSeriesItem( QwtText( title ) ) 120 Constructor 121 \param title Title of the curve 122 */ 123 QwtPlotCurve::QwtPlotCurve( const QString& title ) 124 : QwtPlotSeriesItem( QwtText( title ) ) 115 125 { 116 126 init(); … … 120 130 QwtPlotCurve::~QwtPlotCurve() 121 131 { 122 delete d_data;132 delete m_data; 123 133 } 124 134 … … 129 139 setItemAttribute( QwtPlotItem::AutoScale ); 130 140 131 d_data = new PrivateData;141 m_data = new PrivateData; 132 142 setData( new QwtPointSeriesData() ); 133 143 … … 142 152 143 153 /*! 144 Specify an attribute how to draw the curve 145 146 \param attribute Paint attribute 147 \param on On/Off 148 \sa testPaintAttribute() 149 */ 154 Specify an attribute how to draw the curve 155 156 \param attribute Paint attribute 157 \param on On/Off 158 \sa testPaintAttribute() 159 */ 150 160 void QwtPlotCurve::setPaintAttribute( PaintAttribute attribute, bool on ) 151 161 { 152 162 if ( on ) 153 d_data->paintAttributes |= attribute;163 m_data->paintAttributes |= attribute; 154 164 else 155 d_data->paintAttributes &= ~attribute;165 m_data->paintAttributes &= ~attribute; 156 166 } 157 167 … … 159 169 \return True, when attribute is enabled 160 170 \sa setPaintAttribute() 161 */ 171 */ 162 172 bool QwtPlotCurve::testPaintAttribute( PaintAttribute attribute ) const 163 173 { 164 return ( d_data->paintAttributes & attribute );165 } 166 167 /*! 168 Specify an attribute how to draw the legend icon 169 170 \param attribute Attribute 171 \param on On/Off 172 /sa testLegendAttribute(). legendIcon() 173 */ 174 return ( m_data->paintAttributes & attribute ); 175 } 176 177 /*! 178 Specify an attribute how to draw the legend icon 179 180 \param attribute Attribute 181 \param on On/Off 182 /sa testLegendAttribute(). legendIcon() 183 */ 174 184 void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on ) 175 185 { … … 177 187 { 178 188 if ( on ) 179 d_data->legendAttributes |= attribute;189 m_data->legendAttributes |= attribute; 180 190 else 181 d_data->legendAttributes &= ~attribute;191 m_data->legendAttributes &= ~attribute; 182 192 183 193 qwtUpdateLegendIconSize( this ); … … 187 197 188 198 /*! 189 \return True, when attribute is enabled 190 \sa setLegendAttribute() 191 */ 199 \return True, when attribute is enabled 200 \sa setLegendAttribute() 201 */ 192 202 bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const 193 203 { 194 return ( d_data->legendAttributes & attribute ); 195 } 196 197 /*! 198 Set the curve's drawing style 199 200 \param style Curve style 201 \sa style() 202 */ 204 return ( m_data->legendAttributes & attribute ); 205 } 206 207 /*! 208 Specify the attributes how to draw the legend icon 209 210 \param attributes Attributes 211 /sa setLegendAttribute(). legendIcon() 212 */ 213 void QwtPlotCurve::setLegendAttributes( LegendAttributes attributes ) 214 { 215 if ( attributes != m_data->legendAttributes ) 216 { 217 m_data->legendAttributes = attributes; 218 219 qwtUpdateLegendIconSize( this ); 220 legendChanged(); 221 } 222 } 223 224 /*! 225 \return Attributes how to draw the legend icon 226 \sa setLegendAttributes(), testLegendAttribute() 227 */ 228 QwtPlotCurve::LegendAttributes QwtPlotCurve::legendAttributes() const 229 { 230 return m_data->legendAttributes; 231 } 232 233 /*! 234 Set the curve's drawing style 235 236 \param style Curve style 237 \sa style() 238 */ 203 239 void QwtPlotCurve::setStyle( CurveStyle style ) 204 240 { 205 if ( style != d_data->style )206 { 207 d_data->style = style;241 if ( style != m_data->style ) 242 { 243 m_data->style = style; 208 244 209 245 legendChanged(); … … 213 249 214 250 /*! 215 \return Style of the curve 216 \sa setStyle() 217 */ 251 \return Style of the curve 252 \sa setStyle() 253 */ 218 254 QwtPlotCurve::CurveStyle QwtPlotCurve::style() const 219 255 { 220 return d_data->style;221 } 222 223 /*! 224 \brief Assign a symbol 225 226 The curve will take the ownership of the symbol, hence the previously 227 set symbol will be delete by setting a new one. If \p symbol is 228 \c NULL no symbol will be drawn. 229 230 \param symbol Symbol 231 \sa symbol() 232 */ 233 void QwtPlotCurve::setSymbol( QwtSymbol *symbol )234 { 235 if ( symbol != d_data->symbol )236 { 237 delete d_data->symbol;238 d_data->symbol = symbol;256 return m_data->style; 257 } 258 259 /*! 260 \brief Assign a symbol 261 262 The curve will take the ownership of the symbol, hence the previously 263 set symbol will be delete by setting a new one. If \p symbol is 264 \c NULL no symbol will be drawn. 265 266 \param symbol Symbol 267 \sa symbol() 268 */ 269 void QwtPlotCurve::setSymbol( QwtSymbol* symbol ) 270 { 271 if ( symbol != m_data->symbol ) 272 { 273 delete m_data->symbol; 274 m_data->symbol = symbol; 239 275 240 276 qwtUpdateLegendIconSize( this ); … … 246 282 247 283 /*! 248 \return Current symbol or NULL, when no symbol has been assigned 249 \sa setSymbol() 250 */ 251 const QwtSymbol *QwtPlotCurve::symbol() const252 { 253 return d_data->symbol;254 } 255 256 /*! 257 Build and assign a pen 258 259 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 260 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 261 to hide this incompatibility. 262 263 \param color Pen color 264 \param width Pen width 265 \param style Pen style 266 267 \sa pen(), brush() 268 */ 269 void QwtPlotCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )284 \return Current symbol or NULL, when no symbol has been assigned 285 \sa setSymbol() 286 */ 287 const QwtSymbol* QwtPlotCurve::symbol() const 288 { 289 return m_data->symbol; 290 } 291 292 /*! 293 Build and assign a pen 294 295 In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it 296 non cosmetic ( see QPen::isCosmetic() ). This method has been introduced 297 to hide this incompatibility. 298 299 \param color Pen color 300 \param width Pen width 301 \param style Pen style 302 303 \sa pen(), brush() 304 */ 305 void QwtPlotCurve::setPen( const QColor& color, qreal width, Qt::PenStyle style ) 270 306 { 271 307 setPen( QPen( color, width, style ) ); … … 273 309 274 310 /*! 275 Assign a pen 276 277 \param pen New pen 278 \sa pen(), brush() 279 */ 280 void QwtPlotCurve::setPen( const QPen &pen )281 { 282 if ( pen != d_data->pen )283 { 284 d_data->pen = pen;311 Assign a pen 312 313 \param pen New pen 314 \sa pen(), brush() 315 */ 316 void QwtPlotCurve::setPen( const QPen& pen ) 317 { 318 if ( pen != m_data->pen ) 319 { 320 m_data->pen = pen; 285 321 286 322 legendChanged(); … … 290 326 291 327 /*! 292 \return Pen used to draw the lines 293 \sa setPen(), brush() 294 */ 328 \return Pen used to draw the lines 329 \sa setPen(), brush() 330 */ 295 331 const QPen& QwtPlotCurve::pen() const 296 332 { 297 return d_data->pen;298 } 299 300 /*! 301 \brief Assign a brush. 333 return m_data->pen; 334 } 335 336 /*! 337 \brief Assign a brush. 302 338 303 339 In case of brush.style() != QBrush::NoBrush … … 310 346 (ascending or descending). 311 347 312 \param brush New brush 313 \sa brush(), setBaseline(), baseline() 314 */ 315 void QwtPlotCurve::setBrush( const QBrush &brush )316 { 317 if ( brush != d_data->brush )318 { 319 d_data->brush = brush;348 \param brush New brush 349 \sa brush(), setBaseline(), baseline() 350 */ 351 void QwtPlotCurve::setBrush( const QBrush& brush ) 352 { 353 if ( brush != m_data->brush ) 354 { 355 m_data->brush = brush; 320 356 321 357 legendChanged(); … … 325 361 326 362 /*! 327 \return Brush used to fill the area between lines and the baseline 328 \sa setBrush(), setBaseline(), baseline() 329 */ 363 \return Brush used to fill the area between lines and the baseline 364 \sa setBrush(), setBaseline(), baseline() 365 */ 330 366 const QBrush& QwtPlotCurve::brush() const 331 367 { 332 return d_data->brush;333 } 334 335 /*! 336 Draw an interval of the curve 337 338 \param painter Painter 339 \param xMap Maps x-values into pixel coordinates. 340 \param yMap Maps y-values into pixel coordinates. 341 \param canvasRect Contents rectangle of the canvas 342 \param from Index of the first point to be painted 343 \param to Index of the last point to be painted. If to < 0 the 368 return m_data->brush; 369 } 370 371 /*! 372 Draw an interval of the curve 373 374 \param painter Painter 375 \param xMap Maps x-values into pixel coordinates. 376 \param yMap Maps y-values into pixel coordinates. 377 \param canvasRect Contents rectangle of the canvas 378 \param from Index of the first point to be painted 379 \param to Index of the last point to be painted. If to < 0 the 344 380 curve will be painted to its last point. 345 381 346 \sa drawCurve(), drawSymbols(), 347 */ 348 void QwtPlotCurve::drawSeries( QPainter *painter,349 const QwtScaleMap &xMap, const QwtScaleMap&yMap,350 const QRectF &canvasRect, int from, int to ) const382 \sa drawCurve(), drawSymbols(), 383 */ 384 void QwtPlotCurve::drawSeries( QPainter* painter, 385 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 386 const QRectF& canvasRect, int from, int to ) const 351 387 { 352 388 const size_t numSamples = dataSize(); … … 361 397 { 362 398 painter->save(); 363 painter->setPen( d_data->pen );399 painter->setPen( m_data->pen ); 364 400 365 401 /* 366 Qt 4.0.0 is slow when drawing lines, but it's even 367 slower when the painter has a brush. So we don't 368 set the brush before we really need it. 402 Qt 4.0.0 is slow when drawing lines, but it's even 403 slower when the painter has a brush. So we don't 404 set the brush before we really need it. 369 405 */ 370 406 371 drawCurve( painter, d_data->style, xMap, yMap, canvasRect, from, to );407 drawCurve( painter, m_data->style, xMap, yMap, canvasRect, from, to ); 372 408 painter->restore(); 373 409 374 if ( d_data->symbol &&375 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )410 if ( m_data->symbol && 411 ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) 376 412 { 377 413 painter->save(); 378 drawSymbols( painter, * d_data->symbol,414 drawSymbols( painter, *m_data->symbol, 379 415 xMap, yMap, canvasRect, from, to ); 380 416 painter->restore(); … … 384 420 385 421 /*! 386 \brief Draw the line part (without symbols) of a curve interval. 387 \param painter Painter 388 \param style curve style, see QwtPlotCurve::CurveStyle 389 \param xMap x map 390 \param yMap y map 391 \param canvasRect Contents rectangle of the canvas 392 \param from index of the first point to be painted 393 \param to index of the last point to be painted 394 \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks() 395 */ 396 void QwtPlotCurve::drawCurve( QPainter *painter, int style,397 const QwtScaleMap &xMap, const QwtScaleMap&yMap,398 const QRectF &canvasRect, int from, int to ) const422 \brief Draw the line part (without symbols) of a curve interval. 423 \param painter Painter 424 \param style curve style, see QwtPlotCurve::CurveStyle 425 \param xMap x map 426 \param yMap y map 427 \param canvasRect Contents rectangle of the canvas 428 \param from index of the first point to be painted 429 \param to index of the last point to be painted 430 \sa draw(), drawDots(), drawLines(), drawSteps(), drawSticks() 431 */ 432 void QwtPlotCurve::drawCurve( QPainter* painter, int style, 433 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 434 const QRectF& canvasRect, int from, int to ) const 399 435 { 400 436 switch ( style ) … … 426 462 427 463 /*! 428 \brief Draw lines 429 430 If the CurveAttribute Fitted is enabled a QwtCurveFitter tries 431 to interpolate/smooth the curve, before it is painted. 432 433 \param painter Painter 434 \param xMap x map 435 \param yMap y map 436 \param canvasRect Contents rectangle of the canvas 437 \param from index of the first point to be painted 438 \param to index of the last point to be painted 439 440 \sa setCurveAttribute(), setCurveFitter(), draw(), 464 \brief Draw lines 465 466 If the CurveAttribute Fitted is enabled a QwtCurveFitter tries 467 to interpolate/smooth the curve, before it is painted. 468 469 \param painter Painter 470 \param xMap x map 471 \param yMap y map 472 \param canvasRect Contents rectangle of the canvas 473 \param from index of the first point to be painted 474 \param to index of the last point to be painted 475 476 \sa setCurveAttribute(), setCurveFitter(), draw(), 441 477 drawLines(), drawDots(), drawSteps(), drawSticks() 442 */ 443 void QwtPlotCurve::drawLines( QPainter *painter,444 const QwtScaleMap &xMap, const QwtScaleMap&yMap,445 const QRectF &canvasRect, int from, int to ) const478 */ 479 void QwtPlotCurve::drawLines( QPainter* painter, 480 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 481 const QRectF& canvasRect, int from, int to ) const 446 482 { 447 483 if ( from > to ) 448 484 return; 449 485 450 const bool do Align = QwtPainter::roundingAlignment( painter );451 const bool do Fit = ( d_data->attributes & Fitted ) && d_data->curveFitter;452 const bool doFill = ( d_data->brush.style() != Qt::NoBrush )453 && ( d_data->brush.color().alpha() > 0 );486 const bool doFit = ( m_data->attributes & Fitted ) && m_data->curveFitter; 487 const bool doAlign = !doFit && QwtPainter::roundingAlignment( painter ); 488 const bool doFill = ( m_data->brush.style() != Qt::NoBrush ) 489 && ( m_data->brush.color().alpha() > 0 ); 454 490 455 491 QRectF clipRect; 456 if ( d_data->paintAttributes & ClipPolygons ) 457 { 458 qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF()); 459 clipRect = canvasRect.adjusted(-pw, -pw, pw, pw); 460 } 461 462 bool doIntegers = false; 463 464 #if QT_VERSION < 0x040800 465 466 // For Qt <= 4.7 the raster paint engine is significantly faster 467 // for rendering QPolygon than for QPolygonF. So let's 468 // see if we can use it. 469 470 if ( painter->paintEngine()->type() == QPaintEngine::Raster ) 471 { 472 // In case of filling or fitting performance doesn't count 473 // because both operations are much more expensive 474 // then drawing the polyline itself 475 476 if ( !doFit && !doFill ) 477 doIntegers = true; 478 } 479 #endif 480 481 const bool noDuplicates = d_data->paintAttributes & FilterPoints; 492 if ( m_data->paintAttributes & ClipPolygons ) 493 { 494 clipRect = qwtIntersectedClipRect( canvasRect, painter ); 495 496 const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); 497 clipRect = clipRect.adjusted(-pw, -pw, pw, pw); 498 } 482 499 483 500 QwtPointMapper mapper; 484 mapper.setFlag( QwtPointMapper::RoundPoints, doAlign ); 485 mapper.setFlag( QwtPointMapper::WeedOutPoints, noDuplicates ); 501 502 if ( doAlign ) 503 { 504 mapper.setFlag( QwtPointMapper::RoundPoints, true ); 505 mapper.setFlag( QwtPointMapper::WeedOutIntermediatePoints, 506 testPaintAttribute( FilterPointsAggressive ) ); 507 } 508 509 mapper.setFlag( QwtPointMapper::WeedOutPoints, 510 testPaintAttribute( FilterPoints ) || 511 testPaintAttribute( FilterPointsAggressive ) ); 512 486 513 mapper.setBoundingRect( canvasRect ); 487 514 488 if ( doIntegers ) 489 { 490 QPolygon polyline = mapper.toPolygon( 491 xMap, yMap, data(), from, to ); 492 493 if ( d_data->paintAttributes & ClipPolygons ) 494 { 495 polyline = QwtClipper::clipPolygon( 496 clipRect.toAlignedRect(), polyline, false ); 497 } 498 499 QwtPainter::drawPolyline( painter, polyline ); 515 QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to ); 516 517 if ( doFill ) 518 { 519 if ( doFit ) 520 { 521 // it might be better to extend and draw the curvePath, but for 522 // the moment we keep an implementation, where we translate the 523 // path back to a polyline. 524 525 polyline = m_data->curveFitter->fitCurve( polyline ); 526 } 527 528 if ( painter->pen().style() != Qt::NoPen ) 529 { 530 // here we are wasting memory for the filled copy, 531 // do polygon clipping twice etc .. TODO 532 533 QPolygonF filled = polyline; 534 fillCurve( painter, xMap, yMap, canvasRect, filled ); 535 filled.clear(); 536 537 if ( m_data->paintAttributes & ClipPolygons ) 538 QwtClipper::clipPolygonF( clipRect, polyline, false ); 539 540 QwtPainter::drawPolyline( painter, polyline ); 541 } 542 else 543 { 544 fillCurve( painter, xMap, yMap, canvasRect, polyline ); 545 } 500 546 } 501 547 else 502 548 { 503 QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to ); 549 if ( testPaintAttribute( ClipPolygons ) ) 550 { 551 QwtClipper::clipPolygonF( clipRect, polyline, false ); 552 } 504 553 505 554 if ( doFit ) 506 polyline = d_data->curveFitter->fitCurve( polyline ); 507 508 if ( doFill ) 509 { 510 if ( painter->pen().style() != Qt::NoPen ) 555 { 556 if ( m_data->curveFitter->mode() == QwtCurveFitter::Path ) 511 557 { 512 // here we are wasting memory for the filled copy, 513 // do polygon clipping twice etc .. TODO 514 515 QPolygonF filled = polyline; 516 fillCurve( painter, xMap, yMap, canvasRect, filled ); 517 filled.clear(); 518 519 if ( d_data->paintAttributes & ClipPolygons ) 520 { 521 polyline = QwtClipper::clipPolygonF( 522 clipRect, polyline, false ); 523 } 524 525 QwtPainter::drawPolyline( painter, polyline ); 558 const QPainterPath curvePath = 559 m_data->curveFitter->fitCurvePath( polyline ); 560 561 painter->drawPath( curvePath ); 526 562 } 527 563 else 528 564 { 529 fillCurve( painter, xMap, yMap, canvasRect, polyline ); 565 polyline = m_data->curveFitter->fitCurve( polyline ); 566 QwtPainter::drawPolyline( painter, polyline ); 530 567 } 531 568 } 532 569 else 533 570 { 534 if ( d_data->paintAttributes & ClipPolygons )535 {536 polyline = QwtClipper::clipPolygonF(537 clipRect, polyline, false );538 }539 540 571 QwtPainter::drawPolyline( painter, polyline ); 541 572 } … … 544 575 545 576 /*! 546 Draw sticks 547 548 \param painter Painter 549 \param xMap x map 550 \param yMap y map 551 \param canvasRect Contents rectangle of the canvas 552 \param from index of the first point to be painted 553 \param to index of the last point to be painted 554 555 \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps() 556 */ 557 void QwtPlotCurve::drawSticks( QPainter *painter,558 const QwtScaleMap &xMap, const QwtScaleMap&yMap,559 const QRectF &canvasRect, int from, int to ) const577 Draw sticks 578 579 \param painter Painter 580 \param xMap x map 581 \param yMap y map 582 \param canvasRect Contents rectangle of the canvas 583 \param from index of the first point to be painted 584 \param to index of the last point to be painted 585 586 \sa draw(), drawCurve(), drawDots(), drawLines(), drawSteps() 587 */ 588 void QwtPlotCurve::drawSticks( QPainter* painter, 589 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 590 const QRectF& canvasRect, int from, int to ) const 560 591 { 561 592 Q_UNUSED( canvasRect ) … … 566 597 const bool doAlign = QwtPainter::roundingAlignment( painter ); 567 598 568 double x0 = xMap.transform( d_data->baseline );569 double y0 = yMap.transform( d_data->baseline );599 double x0 = xMap.transform( m_data->baseline ); 600 double y0 = yMap.transform( m_data->baseline ); 570 601 if ( doAlign ) 571 602 { … … 576 607 const Qt::Orientation o = orientation(); 577 608 578 const QwtSeriesData<QPointF > *series = data();609 const QwtSeriesData< QPointF >* series = data(); 579 610 580 611 for ( int i = from; i <= to; i++ ) … … 599 630 600 631 /*! 601 Draw dots 602 603 \param painter Painter 604 \param xMap x map 605 \param yMap y map 606 \param canvasRect Contents rectangle of the canvas 607 \param from index of the first point to be painted 608 \param to index of the last point to be painted 609 610 \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps() 611 */ 612 void QwtPlotCurve::drawDots( QPainter *painter,613 const QwtScaleMap &xMap, const QwtScaleMap&yMap,614 const QRectF &canvasRect, int from, int to ) const632 Draw dots 633 634 \param painter Painter 635 \param xMap x map 636 \param yMap y map 637 \param canvasRect Contents rectangle of the canvas 638 \param from index of the first point to be painted 639 \param to index of the last point to be painted 640 641 \sa draw(), drawCurve(), drawSticks(), drawLines(), drawSteps() 642 */ 643 void QwtPlotCurve::drawDots( QPainter* painter, 644 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 645 const QRectF& canvasRect, int from, int to ) const 615 646 { 616 647 const QColor color = painter->pen().color(); … … 621 652 } 622 653 623 const bool doFill = ( d_data->brush.style() != Qt::NoBrush )624 && ( d_data->brush.color().alpha() > 0 );654 const bool doFill = ( m_data->brush.style() != Qt::NoBrush ) 655 && ( m_data->brush.color().alpha() > 0 ); 625 656 const bool doAlign = QwtPainter::roundingAlignment( painter ); 626 657 … … 629 660 mapper.setFlag( QwtPointMapper::RoundPoints, doAlign ); 630 661 631 if ( d_data->paintAttributes & FilterPoints )662 if ( m_data->paintAttributes & FilterPoints ) 632 663 { 633 664 if ( ( color.alpha() == 255 ) … … 642 673 mapper.setFlag( QwtPointMapper::WeedOutPoints, false ); 643 674 644 QPolygonF points = mapper.toPo intsF(675 QPolygonF points = mapper.toPolygonF( 645 676 xMap, yMap, data(), from, to ); 646 677 … … 648 679 fillCurve( painter, xMap, yMap, canvasRect, points ); 649 680 } 650 else if ( d_data->paintAttributes & ImageBuffer )681 else if ( m_data->paintAttributes & ImageBuffer ) 651 682 { 652 683 const QImage image = mapper.toImage( xMap, yMap, 653 data(), from, to, d_data->pen,684 data(), from, to, m_data->pen, 654 685 painter->testRenderHint( QPainter::Antialiasing ), 655 686 renderThreadCount() ); … … 657 688 painter->drawImage( canvasRect.toAlignedRect(), image ); 658 689 } 659 else if ( d_data->paintAttributes & MinimizeMemory )660 { 661 const QwtSeriesData<QPointF > *series = data();690 else if ( m_data->paintAttributes & MinimizeMemory ) 691 { 692 const QwtSeriesData< QPointF >* series = data(); 662 693 663 694 for ( int i = from; i <= to; i++ ) … … 697 728 698 729 /*! 699 Draw step function 700 701 The direction of the steps depends on Inverted attribute. 702 703 \param painter Painter 704 \param xMap x map 705 \param yMap y map 706 \param canvasRect Contents rectangle of the canvas 707 \param from index of the first point to be painted 708 \param to index of the last point to be painted 709 710 \sa CurveAttribute, setCurveAttribute(), 730 Draw step function 731 732 The direction of the steps depends on Inverted attribute. 733 734 \param painter Painter 735 \param xMap x map 736 \param yMap y map 737 \param canvasRect Contents rectangle of the canvas 738 \param from index of the first point to be painted 739 \param to index of the last point to be painted 740 741 \sa CurveAttribute, setCurveAttribute(), 711 742 draw(), drawCurve(), drawDots(), drawLines(), drawSticks() 712 */ 713 void QwtPlotCurve::drawSteps( QPainter *painter,714 const QwtScaleMap &xMap, const QwtScaleMap&yMap,715 const QRectF &canvasRect, int from, int to ) const743 */ 744 void QwtPlotCurve::drawSteps( QPainter* painter, 745 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 746 const QRectF& canvasRect, int from, int to ) const 716 747 { 717 748 const bool doAlign = QwtPainter::roundingAlignment( painter ); 718 749 719 750 QPolygonF polygon( 2 * ( to - from ) + 1 ); 720 QPointF *points = polygon.data();751 QPointF* points = polygon.data(); 721 752 722 753 bool inverted = orientation() == Qt::Vertical; 723 if ( d_data->attributes & Inverted )754 if ( m_data->attributes & Inverted ) 724 755 inverted = !inverted; 725 756 726 const QwtSeriesData<QPointF > *series = data();757 const QwtSeriesData< QPointF >* series = data(); 727 758 728 759 int i, ip; … … 740 771 if ( ip > 0 ) 741 772 { 742 const QPointF &p0 = points[ip - 2];743 QPointF &p = points[ip - 1];773 const QPointF& p0 = points[ip - 2]; 774 QPointF& p = points[ip - 1]; 744 775 745 776 if ( inverted ) … … 759 790 } 760 791 761 if ( d_data->paintAttributes & ClipPolygons ) 762 { 763 qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF()); 764 const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw); 765 766 const QPolygonF clipped = QwtClipper::clipPolygonF( 792 if ( m_data->paintAttributes & ClipPolygons ) 793 { 794 QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); 795 796 const qreal pw = QwtPainter::effectivePenWidth( painter->pen() ); 797 clipRect = clipRect.adjusted(-pw, -pw, pw, pw); 798 799 const QPolygonF clipped = QwtClipper::clippedPolygonF( 767 800 clipRect, polygon, false ); 768 801 … … 774 807 } 775 808 776 if ( d_data->brush.style() != Qt::NoBrush )809 if ( m_data->brush.style() != Qt::NoBrush ) 777 810 fillCurve( painter, xMap, yMap, canvasRect, polygon ); 778 811 } … … 780 813 781 814 /*! 782 Specify an attribute for drawing the curve 783 784 \param attribute Curve attribute 785 \param on On/Off 786 787 /sa testCurveAttribute(), setCurveFitter() 788 */ 815 Specify an attribute for drawing the curve 816 817 \param attribute Curve attribute 818 \param on On/Off 819 820 /sa testCurveAttribute(), setCurveFitter() 821 */ 789 822 void QwtPlotCurve::setCurveAttribute( CurveAttribute attribute, bool on ) 790 823 { 791 if ( bool( d_data->attributes & attribute ) == on )824 if ( bool( m_data->attributes & attribute ) == on ) 792 825 return; 793 826 794 827 if ( on ) 795 d_data->attributes |= attribute;828 m_data->attributes |= attribute; 796 829 else 797 d_data->attributes &= ~attribute;830 m_data->attributes &= ~attribute; 798 831 799 832 itemChanged(); … … 803 836 \return true, if attribute is enabled 804 837 \sa setCurveAttribute() 805 */ 838 */ 806 839 bool QwtPlotCurve::testCurveAttribute( CurveAttribute attribute ) const 807 840 { 808 return d_data->attributes & attribute;809 } 810 811 /*! 812 Assign a curve fitter 813 814 The curve fitter "smooths" the curve points, when the Fitted 815 CurveAttribute is set. setCurveFitter(NULL) also disables curve fitting. 816 817 The curve fitter operates on the translated points ( = widget coordinates) 818 to be functional for logarithmic scales. Obviously this is less performant 819 for fitting algorithms, that reduce the number of points. 820 821 For situations, where curve fitting is used to improve the performance 822 of painting huge series of points it might be better to execute the fitter 823 on the curve points once and to cache the result in the QwtSeriesData object. 824 825 \param curveFitter() Curve fitter 826 \sa Fitted 827 */ 828 void QwtPlotCurve::setCurveFitter( QwtCurveFitter *curveFitter )829 { 830 delete d_data->curveFitter;831 d_data->curveFitter = curveFitter;841 return m_data->attributes & attribute; 842 } 843 844 /*! 845 Assign a curve fitter 846 847 The curve fitter "smooths" the curve points, when the Fitted 848 CurveAttribute is set. setCurveFitter(NULL) also disables curve fitting. 849 850 The curve fitter operates on the translated points ( = widget coordinates) 851 to be functional for logarithmic scales. Obviously this is less performant 852 for fitting algorithms, that reduce the number of points. 853 854 For situations, where curve fitting is used to improve the performance 855 of painting huge series of points it might be better to execute the fitter 856 on the curve points once and to cache the result in the QwtSeriesData object. 857 858 \param curveFitter() Curve fitter 859 \sa Fitted 860 */ 861 void QwtPlotCurve::setCurveFitter( QwtCurveFitter* curveFitter ) 862 { 863 delete m_data->curveFitter; 864 m_data->curveFitter = curveFitter; 832 865 833 866 itemChanged(); … … 835 868 836 869 /*! 837 Get the curve fitter. If curve fitting is disabled NULL is returned. 838 839 \return Curve fitter 840 \sa setCurveFitter(), Fitted 841 */ 842 QwtCurveFitter *QwtPlotCurve::curveFitter() const843 { 844 return d_data->curveFitter;845 } 846 847 /*! 848 Fill the area between the curve and the baseline with 849 the curve brush 850 851 \param painter Painter 852 \param xMap x map 853 \param yMap y map 854 \param canvasRect Contents rectangle of the canvas 855 \param polygon Polygon - will be modified ! 856 857 \sa setBrush(), setBaseline(), setStyle() 858 */ 859 void QwtPlotCurve::fillCurve( QPainter *painter,860 const QwtScaleMap &xMap, const QwtScaleMap&yMap,861 const QRectF &canvasRect, QPolygonF&polygon ) const862 { 863 if ( d_data->brush.style() == Qt::NoBrush )870 Get the curve fitter. If curve fitting is disabled NULL is returned. 871 872 \return Curve fitter 873 \sa setCurveFitter(), Fitted 874 */ 875 QwtCurveFitter* QwtPlotCurve::curveFitter() const 876 { 877 return m_data->curveFitter; 878 } 879 880 /*! 881 Fill the area between the curve and the baseline with 882 the curve brush 883 884 \param painter Painter 885 \param xMap x map 886 \param yMap y map 887 \param canvasRect Contents rectangle of the canvas 888 \param polygon Polygon - will be modified ! 889 890 \sa setBrush(), setBaseline(), setStyle() 891 */ 892 void QwtPlotCurve::fillCurve( QPainter* painter, 893 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 894 const QRectF& canvasRect, QPolygonF& polygon ) const 895 { 896 if ( m_data->brush.style() == Qt::NoBrush ) 864 897 return; 865 898 … … 868 901 return; 869 902 870 QBrush brush = d_data->brush;903 QBrush brush = m_data->brush; 871 904 if ( !brush.color().isValid() ) 872 brush.setColor( d_data->pen.color() ); 873 874 if ( d_data->paintAttributes & ClipPolygons ) 875 polygon = QwtClipper::clipPolygonF( canvasRect, polygon, true ); 905 brush.setColor( m_data->pen.color() ); 906 907 if ( m_data->paintAttributes & ClipPolygons ) 908 { 909 const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); 910 QwtClipper::clipPolygonF( clipRect, polygon, true ); 911 } 876 912 877 913 painter->save(); … … 886 922 887 923 /*! 888 \brief Complete a polygon to be a closed polygon including the 924 \brief Complete a polygon to be a closed polygon including the 889 925 area between the original polygon and the baseline. 890 926 891 \param painter Painter 892 \param xMap X map 893 \param yMap Y map 894 \param polygon Polygon to be completed 895 */ 896 void QwtPlotCurve::closePolyline( QPainter *painter,897 const QwtScaleMap &xMap, const QwtScaleMap&yMap,898 QPolygonF &polygon ) const927 \param painter Painter 928 \param xMap X map 929 \param yMap Y map 930 \param polygon Polygon to be completed 931 */ 932 void QwtPlotCurve::closePolyline( QPainter* painter, 933 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 934 QPolygonF& polygon ) const 899 935 { 900 936 if ( polygon.size() < 2 ) … … 903 939 const bool doAlign = QwtPainter::roundingAlignment( painter ); 904 940 905 double baseline = d_data->baseline;941 double baseline = m_data->baseline; 906 942 907 943 if ( orientation() == Qt::Vertical ) … … 911 947 912 948 double refY = yMap.transform( baseline ); 913 if ( doAlign ) 949 if ( doAlign && qAbs( refY ) < std::numeric_limits< int >::max() ) 914 950 refY = qRound( refY ); 915 951 … … 923 959 924 960 double refX = xMap.transform( baseline ); 925 if ( doAlign ) 961 if ( doAlign && qAbs( refX ) < std::numeric_limits< int >::max() ) 926 962 refX = qRound( refX ); 927 963 … … 932 968 933 969 /*! 934 Draw symbols 935 936 \param painter Painter 937 \param symbol Curve symbol 938 \param xMap x map 939 \param yMap y map 940 \param canvasRect Contents rectangle of the canvas 941 \param from Index of the first point to be painted 942 \param to Index of the last point to be painted 943 944 \sa setSymbol(), drawSeries(), drawCurve() 945 */ 946 void QwtPlotCurve::drawSymbols( QPainter *painter, const QwtSymbol&symbol,947 const QwtScaleMap &xMap, const QwtScaleMap&yMap,948 const QRectF &canvasRect, int from, int to ) const970 Draw symbols 971 972 \param painter Painter 973 \param symbol Curve symbol 974 \param xMap x map 975 \param yMap y map 976 \param canvasRect Contents rectangle of the canvas 977 \param from Index of the first point to be painted 978 \param to Index of the last point to be painted 979 980 \sa setSymbol(), drawSeries(), drawCurve() 981 */ 982 void QwtPlotCurve::drawSymbols( QPainter* painter, const QwtSymbol& symbol, 983 const QwtScaleMap& xMap, const QwtScaleMap& yMap, 984 const QRectF& canvasRect, int from, int to ) const 949 985 { 950 986 QwtPointMapper mapper; … … 953 989 mapper.setFlag( QwtPointMapper::WeedOutPoints, 954 990 testPaintAttribute( QwtPlotCurve::FilterPoints ) ); 955 mapper.setBoundingRect( canvasRect ); 991 992 const QRectF clipRect = qwtIntersectedClipRect( canvasRect, painter ); 993 mapper.setBoundingRect( clipRect ); 956 994 957 995 const int chunkSize = 500; … … 970 1008 971 1009 /*! 972 \brief Set the value of the baseline 973 974 The baseline is needed for filling the curve with a brush or 975 the Sticks drawing style. 976 977 The interpretation of the baseline depends on the orientation(). 978 With Qt::Vertical, the baseline is interpreted as a horizontal line 979 at y = baseline(), with Qt::Horizontal, it is interpreted as a vertical 980 line at x = baseline(). 981 982 The default value is 0.0. 983 984 \param value Value of the baseline 985 \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation() 986 */ 1010 \brief Set the value of the baseline 1011 1012 The baseline is needed for filling the curve with a brush or 1013 the Sticks drawing style. 1014 1015 The interpretation of the baseline depends on the orientation(). 1016 With Qt::Vertical, the baseline is interpreted as a horizontal line 1017 at y = baseline(), with Qt::Horizontal, it is interpreted as a vertical 1018 line at x = baseline(). 1019 1020 The default value is 0.0. 1021 1022 \param value Value of the baseline 1023 \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation() 1024 */ 987 1025 void QwtPlotCurve::setBaseline( double value ) 988 1026 { 989 if ( d_data->baseline != value )990 { 991 d_data->baseline = value;1027 if ( m_data->baseline != value ) 1028 { 1029 m_data->baseline = value; 992 1030 itemChanged(); 993 1031 } … … 995 1033 996 1034 /*! 997 \return Value of the baseline 998 \sa setBaseline() 999 */ 1035 \return Value of the baseline 1036 \sa setBaseline() 1037 */ 1000 1038 double QwtPlotCurve::baseline() const 1001 1039 { 1002 return d_data->baseline;1003 } 1004 1005 /*! 1006 Find the closest curve point for a specific position 1007 1008 \param pos Position, where to look for the closest curve point 1009 \param dist If dist != NULL, closestPoint() returns the distance between 1010 the position and the closest curve point 1011 \return Index of the closest curve point, or -1 if none can be found 1040 return m_data->baseline; 1041 } 1042 1043 /*! 1044 Find the closest curve point for a specific position 1045 1046 \param pos Position, where to look for the closest curve point 1047 \param dist If dist != NULL, closestPoint() returns the distance between 1048 the position and the closest curve point in paint device coordinates 1049 \return Index of the closest curve point, or -1 if none can be found 1012 1050 ( f.e when the curve has no points ) 1013 \note closestPoint() implements a dumb algorithm, that iterates 1051 \note closestPoint() implements a dumb algorithm, that iterates 1014 1052 over all points 1015 */ 1016 int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const 1017 { 1053 */ 1054 int QwtPlotCurve::closestPoint( const QPointF& pos, double* dist ) const 1055 { 1056 const QwtPlot* plot = this->plot(); 1057 1058 if ( ( plot == NULL ) || !plot->isAxisValid( xAxis() ) || !plot->isAxisValid( yAxis() ) ) 1059 return -1; 1060 1018 1061 const size_t numSamples = dataSize(); 1019 1020 if ( plot() == NULL || numSamples <= 0 ) 1062 if ( numSamples <= 0 ) 1021 1063 return -1; 1022 1064 1023 const QwtSeriesData<QPointF > *series = data();1024 1025 const QwtScaleMap xMap = plot ()->canvasMap( xAxis() );1026 const QwtScaleMap yMap = plot ()->canvasMap( yAxis() );1065 const QwtSeriesData< QPointF >* series = data(); 1066 1067 const QwtScaleMap xMap = plot->canvasMap( xAxis() ); 1068 const QwtScaleMap yMap = plot->canvasMap( yAxis() ); 1027 1069 1028 1070 int index = -1; … … 1044 1086 } 1045 1087 if ( dist ) 1046 *dist = qSqrt( dmin );1088 *dist = std::sqrt( dmin ); 1047 1089 1048 1090 return index; 1091 } 1092 1093 /*! 1094 Find the curve point with the smallest coordinate larger than a specific value 1095 The coordinates have to be monotonic in direction of the orientation. 1096 1097 \param orientation Qt::Horizontal corresponds to x, Qt::Vertical to y coordinates 1098 \param value x or y coordinate, depending on the orientation 1099 1100 \return Index of the curve point with the smalles coordinate above value 1101 or -1 if there is none. 1102 1103 \note The implementation uses a binary search algorithm and requires the 1104 points being ordered in direction of the orientation. 1105 1106 \sa qwtUpperSampleIndex() 1107 */ 1108 int QwtPlotCurve::adjacentPoint( Qt::Orientation orientation, qreal value ) const 1109 { 1110 const QwtSeriesData< QPointF >* data = this->data(); 1111 if ( data == NULL ) 1112 return -1; 1113 1114 if ( orientation == Qt::Horizontal ) 1115 { 1116 struct compareX 1117 { 1118 inline bool operator()( const double x, const QPointF& pos ) const 1119 { 1120 return ( x < pos.x() ); 1121 } 1122 }; 1123 1124 return qwtUpperSampleIndex< QPointF >( *data, value, compareX() ); 1125 } 1126 else 1127 { 1128 struct compareY 1129 { 1130 inline bool operator()( const double y, const QPointF& pos ) const 1131 { 1132 return ( y < pos.y() ); 1133 } 1134 }; 1135 1136 return qwtUpperSampleIndex< QPointF >( *data, value, compareY() ); 1137 } 1138 1139 return -1; 1140 } 1141 1142 /*! 1143 Calculate a fictive curve point by interpolating between the adjacent 1144 points. The curve points have to be monotonic in direction of the orientation. 1145 1146 \param orientation For Qt::Horizontal value is a x coordinate and a y coordinate 1147 is returned. For Qt::Vertical value is a x coordinate 1148 \param value x or y coordinate, depending on the orientation 1149 1150 \return Interpolated coordinate or qQNaN() if value is outside the bounding 1151 rectangle of the curve 1152 1153 \note The implementation uses a binary search algorithm and requires the 1154 points being ordered in direction of the orientation. 1155 1156 \sa adjacentPoint() 1157 */ 1158 qreal QwtPlotCurve::interpolatedValueAt( Qt::Orientation orientation, double value ) const 1159 { 1160 const QRectF br = boundingRect(); 1161 if ( br.width() <= 0.0 ) 1162 return qQNaN(); 1163 1164 double v; 1165 1166 if ( orientation == Qt::Horizontal ) 1167 { 1168 if ( value < br.left() || value > br.right() ) 1169 return qQNaN(); 1170 1171 const int index = adjacentPoint( orientation, value ); 1172 1173 if ( index == -1 ) 1174 { 1175 const QPointF last = sample( dataSize() - 1 ); 1176 1177 if ( value != last.x() ) 1178 return qQNaN(); 1179 1180 v = last.y(); 1181 } 1182 else 1183 { 1184 const QLineF line( sample( index - 1 ), sample( index ) ); 1185 v = line.pointAt( ( value - line.p1().x() ) / line.dx() ).y(); 1186 } 1187 } 1188 else 1189 { 1190 if ( value < br.top() || value > br.bottom() ) 1191 return qQNaN(); 1192 1193 const int index = adjacentPoint( orientation, value ); 1194 1195 if ( index == -1 ) 1196 { 1197 const QPointF last = sample( dataSize() - 1 ); 1198 1199 if ( value != last.y() ) 1200 return qQNaN(); 1201 1202 v = last.x(); 1203 } 1204 else 1205 { 1206 const QLineF line( sample( index - 1 ), sample( index ) ); 1207 v = line.pointAt( ( value - line.p1().y() ) / line.dy() ).x(); 1208 } 1209 } 1210 1211 return v; 1049 1212 } 1050 1213 … … 1058 1221 \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData() 1059 1222 */ 1060 QwtGraphic QwtPlotCurve::legendIcon( int index, 1061 const QSizeF &size ) const 1223 QwtGraphic QwtPlotCurve::legendIcon( int index, const QSizeF& size ) const 1062 1224 { 1063 1225 Q_UNUSED( index ); … … 1074 1236 testRenderHint( QwtPlotItem::RenderAntialiased ) ); 1075 1237 1076 if ( d_data->legendAttributes == 0 ||1077 d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )1078 { 1079 QBrush brush = d_data->brush;1238 if ( m_data->legendAttributes == 0 || 1239 m_data->legendAttributes & QwtPlotCurve::LegendShowBrush ) 1240 { 1241 QBrush brush = m_data->brush; 1080 1242 1081 1243 if ( brush.style() == Qt::NoBrush && 1082 d_data->legendAttributes == 0 )1244 m_data->legendAttributes == 0 ) 1083 1245 { 1084 1246 if ( style() != QwtPlotCurve::NoCurve ) … … 1086 1248 brush = QBrush( pen().color() ); 1087 1249 } 1088 else if ( d_data->symbol &&1089 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )1250 else if ( m_data->symbol && 1251 ( m_data->symbol->style() != QwtSymbol::NoSymbol ) ) 1090 1252 { 1091 brush = QBrush( d_data->symbol->pen().color() );1253 brush = QBrush( m_data->symbol->pen().color() ); 1092 1254 } 1093 1255 } … … 1100 1262 } 1101 1263 1102 if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )1264 if ( m_data->legendAttributes & QwtPlotCurve::LegendShowLine ) 1103 1265 { 1104 1266 if ( pen() != Qt::NoPen ) … … 1114 1276 } 1115 1277 1116 if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )1117 { 1118 if ( d_data->symbol )1278 if ( m_data->legendAttributes & QwtPlotCurve::LegendShowSymbol ) 1279 { 1280 if ( m_data->symbol ) 1119 1281 { 1120 1282 QRectF r( 0, 0, size.width(), size.height() ); 1121 d_data->symbol->drawSymbol( &painter, r );1283 m_data->symbol->drawSymbol( &painter, r ); 1122 1284 } 1123 1285 } … … 1127 1289 1128 1290 /*! 1129 Initialize data with an array of points. 1130 1131 \param samples Vector of points 1132 \note QVector is implicitly shared 1133 \note QPolygonF is derived from QVector<QPointF> 1134 */ 1135 void QwtPlotCurve::setSamples( const QVector<QPointF> &samples ) 1291 Assign a series of points 1292 1293 setSamples() is just a wrapper for setData() without any additional 1294 value - beside that it is easier to find for the developer. 1295 1296 \param data Data 1297 \warning The item takes ownership of the data object, deleting 1298 it when its not used anymore. 1299 */ 1300 void QwtPlotCurve::setSamples( QwtSeriesData< QPointF >* data ) 1301 { 1302 setData( data ); 1303 } 1304 1305 /*! 1306 Initialize data with an array of points. 1307 1308 \param samples Vector of points 1309 \note QVector is implicitly shared 1310 \note QPolygonF is derived from QVector<QPointF> 1311 */ 1312 void QwtPlotCurve::setSamples( const QVector< QPointF >& samples ) 1136 1313 { 1137 1314 setData( new QwtPointSeriesData( samples ) ); … … 1139 1316 1140 1317 /*! 1141 Assign a series of points 1142 1143 setSamples() is just a wrapper for setData() without any additional 1144 value - beside that it is easier to find for the developer. 1145 1146 \param data Data 1147 \warning The item takes ownership of the data object, deleting 1148 it when its not used anymore. 1149 */ 1150 void QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data ) 1151 { 1152 setData( data ); 1153 } 1154 1155 #ifndef QWT_NO_COMPAT 1156 1157 /*! 1158 \brief Initialize the data by pointing to memory blocks which 1318 \brief Initialize the data by pointing to memory blocks which 1159 1319 are not managed by QwtPlotCurve. 1160 1320 1161 setRawSamples is provided for efficiency. 1162 It is important to keep the pointers 1163 during the lifetime of the underlying QwtCPointerData class. 1164 1165 \param xData pointer to x data 1166 \param yData pointer to y data 1167 \param size size of x and y 1168 1169 \sa QwtCPointerData 1170 */ 1321 setRawSamples is provided for efficiency. 1322 It is important to keep the pointers 1323 during the lifetime of the underlying QwtCPointerData class. 1324 1325 \param xData pointer to x data 1326 \param yData pointer to y data 1327 \param size size of x and y 1328 1329 \sa QwtCPointerData 1330 */ 1171 1331 void QwtPlotCurve::setRawSamples( 1172 const double *xData, const double *yData, int size ) 1173 { 1174 setData( new QwtCPointerData( xData, yData, size ) ); 1175 } 1176 1177 /*! 1178 Set data by copying x- and y-values from specified memory blocks. 1179 Contrary to setRawSamples(), this function makes a 'deep copy' of 1180 the data. 1181 1182 \param xData pointer to x values 1183 \param yData pointer to y values 1184 \param size size of xData and yData 1185 1186 \sa QwtPointArrayData 1187 */ 1332 const double* xData, const double* yData, int size ) 1333 { 1334 setData( new QwtCPointerData< double >( xData, yData, size ) ); 1335 } 1336 1337 /*! 1338 \brief Initialize the data by pointing to memory blocks which 1339 are not managed by QwtPlotCurve. 1340 1341 setRawSamples is provided for efficiency. 1342 It is important to keep the pointers 1343 during the lifetime of the underlying QwtCPointerData class. 1344 1345 \param xData pointer to x data 1346 \param yData pointer to y data 1347 \param size size of x and y 1348 1349 \sa QwtCPointerData 1350 */ 1351 void QwtPlotCurve::setRawSamples( 1352 const float* xData, const float* yData, int size ) 1353 { 1354 setData( new QwtCPointerData< float >( xData, yData, size ) ); 1355 } 1356 1357 /*! 1358 \brief Initialize the data by pointing to a memory block which 1359 is not managed by QwtPlotCurve. 1360 1361 The memory contains the y coordinates, while the index is 1362 interpreted as x coordinate. 1363 1364 setRawSamples() is provided for efficiency. It is important to 1365 keep the pointers during the lifetime of the underlying 1366 QwtCPointerValueData class. 1367 1368 \param yData pointer to y data 1369 \param size size of x and y 1370 1371 \sa QwtCPointerData 1372 */ 1373 void QwtPlotCurve::setRawSamples( const double* yData, int size ) 1374 { 1375 setData( new QwtCPointerValueData< double >( yData, size ) ); 1376 } 1377 1378 /*! 1379 \brief Initialize the data by pointing to memory blocks which 1380 are not managed by QwtPlotCurve. 1381 1382 The memory contains the y coordinates, while the index is 1383 interpreted as x coordinate. 1384 1385 setRawSamples() is provided for efficiency. It is important to 1386 keep the pointers during the lifetime of the underlying 1387 QwtCPointerValueData class. 1388 1389 \param yData pointer to y data 1390 \param size size of x and y 1391 1392 \sa QwtCPointerData 1393 */ 1394 void QwtPlotCurve::setRawSamples( const float* yData, int size ) 1395 { 1396 setData( new QwtCPointerValueData< float >( yData, size ) ); 1397 } 1398 1399 /*! 1400 Set data by copying x- and y-values from specified memory blocks. 1401 Contrary to setRawSamples(), this function makes a 'deep copy' of 1402 the data. 1403 1404 \param xData pointer to x values 1405 \param yData pointer to y values 1406 \param size size of xData and yData 1407 1408 \sa QwtPointArrayData 1409 */ 1188 1410 void QwtPlotCurve::setSamples( 1189 const double *xData, const double *yData, int size ) 1190 { 1191 setData( new QwtPointArrayData( xData, yData, size ) ); 1192 } 1193 1194 /*! 1195 \brief Initialize data with x- and y-arrays (explicitly shared) 1196 1197 \param xData x data 1198 \param yData y data 1199 1200 \sa QwtPointArrayData 1201 */ 1202 void QwtPlotCurve::setSamples( const QVector<double> &xData, 1203 const QVector<double> &yData ) 1204 { 1205 setData( new QwtPointArrayData( xData, yData ) ); 1206 } 1207 1208 #endif // !QWT_NO_COMPAT 1209 1411 const double* xData, const double* yData, int size ) 1412 { 1413 setData( new QwtPointArrayData< double >( xData, yData, size ) ); 1414 } 1415 1416 /*! 1417 Set data by copying x- and y-values from specified memory blocks. 1418 Contrary to setRawSamples(), this function makes a 'deep copy' of 1419 the data. 1420 1421 \param xData pointer to x values 1422 \param yData pointer to y values 1423 \param size size of xData and yData 1424 1425 \sa QwtPointArrayData 1426 */ 1427 void QwtPlotCurve::setSamples( 1428 const float* xData, const float* yData, int size ) 1429 { 1430 setData( new QwtPointArrayData< float >( xData, yData, size ) ); 1431 } 1432 1433 /*! 1434 \brief Initialize data with x- and y-arrays (explicitly shared) 1435 1436 \param xData x data 1437 \param yData y data 1438 1439 \sa QwtPointArrayData 1440 */ 1441 void QwtPlotCurve::setSamples( const QVector< double >& xData, 1442 const QVector< double >& yData ) 1443 { 1444 setData( new QwtPointArrayData< double >( xData, yData ) ); 1445 } 1446 1447 /*! 1448 \brief Initialize data with x- and y-arrays (explicitly shared) 1449 1450 \param xData x data 1451 \param yData y data 1452 1453 \sa QwtPointArrayData 1454 */ 1455 void QwtPlotCurve::setSamples( const QVector< float >& xData, 1456 const QVector< float >& yData ) 1457 { 1458 setData( new QwtPointArrayData< float >( xData, yData ) ); 1459 } 1460 1461 /*! 1462 Set data by copying y-values from a specified memory block. 1463 1464 The memory contains the y coordinates, while the index is 1465 interpreted as x coordinate. 1466 1467 \param yData y data 1468 \param size size of yData 1469 1470 \sa QwtValuePointData 1471 */ 1472 void QwtPlotCurve::setSamples( const double* yData, int size ) 1473 { 1474 setData( new QwtValuePointData< double >( yData, size ) ); 1475 } 1476 1477 /*! 1478 Set data by copying y-values from a specified memory block. 1479 1480 The vector contains the y coordinates, while the index is 1481 interpreted as x coordinate. 1482 1483 \param yData y data 1484 \param size size of yData 1485 1486 \sa QwtValuePointData 1487 */ 1488 void QwtPlotCurve::setSamples( const float* yData, int size ) 1489 { 1490 setData( new QwtValuePointData< float >( yData, size ) ); 1491 } 1492 1493 /*! 1494 Initialize data with an array of y values (explicitly shared) 1495 1496 The vector contains the y coordinates, while the index is 1497 the x coordinate. 1498 1499 \param yData y data 1500 1501 \sa QwtValuePointData 1502 */ 1503 void QwtPlotCurve::setSamples( const QVector< double >& yData ) 1504 { 1505 setData( new QwtValuePointData< double >( yData ) ); 1506 } 1507 1508 /*! 1509 Initialize data with an array of y values (explicitly shared) 1510 1511 The vector contains the y coordinates, while the index is 1512 the x coordinate. 1513 1514 \param yData y data 1515 1516 \sa QwtValuePointData 1517 */ 1518 void QwtPlotCurve::setSamples( const QVector< float >& yData ) 1519 { 1520 setData( new QwtValuePointData< float >( yData ) ); 1521 }
Note:
See TracChangeset
for help on using the changeset viewer.
