Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_item.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_plot_item.cpp (modified) (41 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_item.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 12 12 #include "qwt_plot.h" 13 13 #include "qwt_legend_data.h" 14 #include "qwt_scale_ div.h"14 #include "qwt_scale_map.h" 15 15 #include "qwt_graphic.h" 16 16 17 #include <qpainter.h> 17 18 18 19 class QwtPlotItem::PrivateData 19 20 { 20 public: 21 PrivateData(): 22 plot( NULL ), 23 isVisible( true ), 24 attributes( 0 ), 25 interests( 0 ), 26 renderHints( 0 ), 27 renderThreadCount( 1 ), 28 z( 0.0 ), 29 xAxis( QwtPlot::xBottom ), 30 yAxis( QwtPlot::yLeft ), 31 legendIconSize( 8, 8 ) 32 { 33 } 34 35 mutable QwtPlot *plot; 21 public: 22 PrivateData() 23 : plot( NULL ) 24 , isVisible( true ) 25 , renderThreadCount( 1 ) 26 , z( 0.0 ) 27 , xAxisId( QwtAxis::XBottom ) 28 , yAxisId( QwtAxis::YLeft ) 29 , legendIconSize( 8, 8 ) 30 { 31 } 32 33 mutable QwtPlot* plot; 36 34 37 35 bool isVisible; … … 45 43 double z; 46 44 47 int xAxis;48 int yAxis;45 QwtAxisId xAxisId; 46 QwtAxisId yAxisId; 49 47 50 48 QwtText title; … … 54 52 /*! 55 53 Constructor 54 */ 55 QwtPlotItem::QwtPlotItem() 56 { 57 m_data = new PrivateData; 58 } 59 60 /*! 61 Constructor 56 62 \param title Title of the item 57 */ 58 QwtPlotItem::QwtPlotItem( const QwtText &title ) 59 { 60 d_data = new PrivateData; 61 d_data->title = title; 63 */ 64 QwtPlotItem::QwtPlotItem( const QString& title ) 65 { 66 m_data = new PrivateData; 67 m_data->title = title; 68 } 69 70 /*! 71 Constructor 72 \param title Title of the item 73 */ 74 QwtPlotItem::QwtPlotItem( const QwtText& title ) 75 { 76 m_data = new PrivateData; 77 m_data->title = title; 62 78 } 63 79 … … 66 82 { 67 83 attach( NULL ); 68 delete d_data;69 } 70 71 /*! 72 \brief Attach the item to a plot. 73 74 This method will attach a QwtPlotItem to the QwtPlot argument. It will first 75 detach the QwtPlotItem from any plot from a previous call to attach (if 76 necessary). If a NULL argument is passed, it will detach from any QwtPlot it 77 was attached to. 78 79 \param plot Plot widget 80 \sa detach() 81 */ 82 void QwtPlotItem::attach( QwtPlot *plot )83 { 84 if ( plot == d_data->plot )84 delete m_data; 85 } 86 87 /*! 88 \brief Attach the item to a plot. 89 90 This method will attach a QwtPlotItem to the QwtPlot argument. It will first 91 detach the QwtPlotItem from any plot from a previous call to attach (if 92 necessary). If a NULL argument is passed, it will detach from any QwtPlot it 93 was attached to. 94 95 \param plot Plot widget 96 \sa detach() 97 */ 98 void QwtPlotItem::attach( QwtPlot* plot ) 99 { 100 if ( plot == m_data->plot ) 85 101 return; 86 102 87 if ( d_data->plot )88 d_data->plot->attachItem( this, false );89 90 d_data->plot = plot;91 92 if ( d_data->plot )93 d_data->plot->attachItem( this, true );103 if ( m_data->plot ) 104 m_data->plot->attachItem( this, false ); 105 106 m_data->plot = plot; 107 108 if ( m_data->plot ) 109 m_data->plot->attachItem( this, true ); 94 110 } 95 111 … … 100 116 detach() is equivalent to calling attach( NULL ) 101 117 \sa attach() 102 */ 118 */ 103 119 void QwtPlotItem::detach() 104 120 { … … 117 133 \return rtti value 118 134 \sa RttiValues 119 */ 135 */ 120 136 int QwtPlotItem::rtti() const 121 137 { … … 124 140 125 141 //! Return attached plot 126 QwtPlot *QwtPlotItem::plot() const127 { 128 return d_data->plot;142 QwtPlot* QwtPlotItem::plot() const 143 { 144 return m_data->plot; 129 145 } 130 146 … … 133 149 134 150 \return setZ(), QwtPlotDict::itemList() 135 */ 151 */ 136 152 double QwtPlotItem::z() const 137 153 { 138 return d_data->z;154 return m_data->z; 139 155 } 140 156 … … 146 162 \param z Z-value 147 163 \sa z(), QwtPlotDict::itemList() 148 */ 164 */ 149 165 void QwtPlotItem::setZ( double z ) 150 166 { 151 if ( d_data->z != z )152 { 153 if ( d_data->plot ) // update the z order154 d_data->plot->attachItem( this, false );155 156 d_data->z = z;157 158 if ( d_data->plot )159 d_data->plot->attachItem( this, true );167 if ( m_data->z != z ) 168 { 169 if ( m_data->plot ) // update the z order 170 m_data->plot->attachItem( this, false ); 171 172 m_data->z = z; 173 174 if ( m_data->plot ) 175 m_data->plot->attachItem( this, true ); 160 176 161 177 itemChanged(); … … 168 184 \param title Title 169 185 \sa title() 170 */ 171 void QwtPlotItem::setTitle( const QString &title )186 */ 187 void QwtPlotItem::setTitle( const QString& title ) 172 188 { 173 189 setTitle( QwtText( title ) ); … … 179 195 \param title Title 180 196 \sa title() 181 */ 182 void QwtPlotItem::setTitle( const QwtText &title )183 { 184 if ( d_data->title != title )185 { 186 d_data->title = title;197 */ 198 void QwtPlotItem::setTitle( const QwtText& title ) 199 { 200 if ( m_data->title != title ) 201 { 202 m_data->title = title; 187 203 188 204 legendChanged(); … … 196 212 \return Title of the item 197 213 \sa setTitle() 198 */ 199 const QwtText &QwtPlotItem::title() const200 { 201 return d_data->title;214 */ 215 const QwtText& QwtPlotItem::title() const 216 { 217 return m_data->title; 202 218 } 203 219 … … 209 225 210 226 \sa testItemAttribute(), ItemInterest 211 */ 227 */ 212 228 void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on ) 213 229 { 214 if ( d_data->attributes.testFlag( attribute ) != on )230 if ( m_data->attributes.testFlag( attribute ) != on ) 215 231 { 216 232 if ( on ) 217 d_data->attributes |= attribute;233 m_data->attributes |= attribute; 218 234 else 219 d_data->attributes &= ~attribute;235 m_data->attributes &= ~attribute; 220 236 221 237 if ( attribute == QwtPlotItem::Legend ) 222 legendChanged(); 238 { 239 if ( on ) 240 { 241 legendChanged(); 242 } 243 else 244 { 245 /* 246 In the special case of taking an item from 247 the legend we can't use legendChanged() as 248 it depends on QwtPlotItem::Legend being enabled 249 */ 250 if ( m_data->plot ) 251 m_data->plot->updateLegend( this ); 252 } 253 } 223 254 224 255 itemChanged(); … … 232 263 \return true/false 233 264 \sa setItemAttribute(), ItemInterest 234 */ 265 */ 235 266 bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const 236 267 { 237 return d_data->attributes.testFlag( attribute );268 return m_data->attributes.testFlag( attribute ); 238 269 } 239 270 … … 245 276 246 277 \sa testItemInterest(), ItemAttribute 247 */ 278 */ 248 279 void QwtPlotItem::setItemInterest( ItemInterest interest, bool on ) 249 280 { 250 if ( d_data->interests.testFlag( interest ) != on )281 if ( m_data->interests.testFlag( interest ) != on ) 251 282 { 252 283 if ( on ) 253 d_data->interests |= interest;284 m_data->interests |= interest; 254 285 else 255 d_data->interests &= ~interest;286 m_data->interests &= ~interest; 256 287 257 288 itemChanged(); … … 265 296 \return true/false 266 297 \sa setItemInterest(), ItemAttribute 267 */ 298 */ 268 299 bool QwtPlotItem::testItemInterest( ItemInterest interest ) const 269 300 { 270 return d_data->interests.testFlag( interest );301 return m_data->interests.testFlag( interest ); 271 302 } 272 303 … … 278 309 279 310 \sa testRenderHint(), RenderHint 280 */ 311 */ 281 312 void QwtPlotItem::setRenderHint( RenderHint hint, bool on ) 282 313 { 283 if ( d_data->renderHints.testFlag( hint ) != on )314 if ( m_data->renderHints.testFlag( hint ) != on ) 284 315 { 285 316 if ( on ) 286 d_data->renderHints |= hint;317 m_data->renderHints |= hint; 287 318 else 288 d_data->renderHints &= ~hint;319 m_data->renderHints &= ~hint; 289 320 290 321 itemChanged(); … … 298 329 \return true/false 299 330 \sa setRenderHint(), RenderHint 300 */ 331 */ 301 332 bool QwtPlotItem::testRenderHint( RenderHint hint ) const 302 333 { 303 return d_data->renderHints.testFlag( hint );334 return m_data->renderHints.testFlag( hint ); 304 335 } 305 336 … … 316 347 317 348 The default thread count is 1 ( = no additional threads ) 318 */ 349 */ 319 350 void QwtPlotItem::setRenderThreadCount( uint numThreads ) 320 351 { 321 d_data->renderThreadCount = numThreads;352 m_data->renderThreadCount = numThreads; 322 353 } 323 354 … … 326 357 If numThreads() is set to 0, the system specific 327 358 ideal thread count is used. 328 */ 359 */ 329 360 uint QwtPlotItem::renderThreadCount() const 330 361 { 331 return d_data->renderThreadCount;362 return m_data->renderThreadCount; 332 363 } 333 364 … … 339 370 \param size Size 340 371 \sa legendIconSize(), legendIcon() 341 */ 342 void QwtPlotItem::setLegendIconSize( const QSize &size )343 { 344 if ( d_data->legendIconSize != size )345 { 346 d_data->legendIconSize = size;372 */ 373 void QwtPlotItem::setLegendIconSize( const QSize& size ) 374 { 375 if ( m_data->legendIconSize != size ) 376 { 377 m_data->legendIconSize = size; 347 378 legendChanged(); 348 379 } … … 352 383 \return Legend icon size 353 384 \sa setLegendIconSize(), legendIcon() 354 */ 385 */ 355 386 QSize QwtPlotItem::legendIconSize() const 356 387 { 357 return d_data->legendIconSize;388 return m_data->legendIconSize; 358 389 } 359 390 … … 370 401 */ 371 402 QwtGraphic QwtPlotItem::legendIcon( 372 int index, const QSizeF &size ) const403 int index, const QSizeF& size ) const 373 404 { 374 405 Q_UNUSED( index ) … … 390 421 */ 391 422 QwtGraphic QwtPlotItem::defaultIcon( 392 const QBrush &brush, const QSizeF&size ) const423 const QBrush& brush, const QSizeF& size ) const 393 424 { 394 425 QwtGraphic icon; … … 423 454 \param on Show if true, otherwise hide 424 455 \sa isVisible(), show(), hide() 425 */ 456 */ 426 457 void QwtPlotItem::setVisible( bool on ) 427 458 { 428 if ( on != d_data->isVisible )429 { 430 d_data->isVisible = on;459 if ( on != m_data->isVisible ) 460 { 461 m_data->isVisible = on; 431 462 itemChanged(); 432 463 } … … 436 467 \return true if visible 437 468 \sa setVisible(), show(), hide() 438 */ 469 */ 439 470 bool QwtPlotItem::isVisible() const 440 471 { 441 return d_data->isVisible;472 return m_data->isVisible; 442 473 } 443 474 … … 447 478 448 479 \sa QwtPlot::legendChanged(), QwtPlot::autoRefresh() 449 */ 480 */ 450 481 void QwtPlotItem::itemChanged() 451 482 { 452 if ( d_data->plot )453 d_data->plot->autoRefresh();483 if ( m_data->plot ) 484 m_data->plot->autoRefresh(); 454 485 } 455 486 … … 457 488 Update the legend of the parent plot. 458 489 \sa QwtPlot::updateLegend(), itemChanged() 459 */ 490 */ 460 491 void QwtPlotItem::legendChanged() 461 492 { 462 if ( testItemAttribute( QwtPlotItem::Legend ) && d_data->plot )463 d_data->plot->updateLegend( this );493 if ( testItemAttribute( QwtPlotItem::Legend ) && m_data->plot ) 494 m_data->plot->updateLegend( this ); 464 495 } 465 496 … … 469 500 The item will painted according to the coordinates of its Axes. 470 501 471 \param xAxis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )472 \param yAxis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )473 474 \sa setXAxis(), setYAxis(), xAxis(), yAxis() , QwtPlot::Axis475 */ 476 void QwtPlotItem::setAxes( int xAxis, int yAxis)477 { 478 if ( xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop)479 d_data->xAxis= xAxis;480 481 if ( yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight)482 d_data->yAxis= yAxis;502 \param xAxisId X Axis 503 \param yAxisId Y Axis 504 505 \sa setXAxis(), setYAxis(), xAxis(), yAxis() 506 */ 507 void QwtPlotItem::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId ) 508 { 509 if ( QwtAxis::isXAxis( xAxisId ) ) 510 m_data->xAxisId = xAxisId; 511 512 if ( QwtAxis::isYAxis( yAxisId ) ) 513 m_data->yAxisId = yAxisId; 483 514 484 515 itemChanged(); … … 490 521 The item will painted according to the coordinates its Axes. 491 522 492 \param axis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )493 \sa setAxes(), setYAxis(), xAxis() , QwtPlot::Axis494 */ 495 void QwtPlotItem::setXAxis( int axis)496 { 497 if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop)498 { 499 d_data->xAxis= axis;523 \param axisId X Axis 524 \sa setAxes(), setYAxis(), xAxis() 525 */ 526 void QwtPlotItem::setXAxis( QwtAxisId axisId ) 527 { 528 if ( QwtAxis::isXAxis( axisId ) ) 529 { 530 m_data->xAxisId = axisId; 500 531 itemChanged(); 501 532 } … … 507 538 The item will painted according to the coordinates its Axes. 508 539 509 \param axis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )510 \sa setAxes(), setXAxis(), yAxis() , QwtPlot::Axis511 */ 512 void QwtPlotItem::setYAxis( int axis)513 { 514 if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight)515 { 516 d_data->yAxis= axis;540 \param axisId Y Axis 541 \sa setAxes(), setXAxis(), yAxis() 542 */ 543 void QwtPlotItem::setYAxis( QwtAxisId axisId ) 544 { 545 if ( QwtAxis::isYAxis( axisId ) ) 546 { 547 m_data->yAxisId = axisId; 517 548 itemChanged(); 518 549 } … … 520 551 521 552 //! Return xAxis 522 intQwtPlotItem::xAxis() const523 { 524 return d_data->xAxis;553 QwtAxisId QwtPlotItem::xAxis() const 554 { 555 return m_data->xAxisId; 525 556 } 526 557 527 558 //! Return yAxis 528 intQwtPlotItem::yAxis() const529 { 530 return d_data->yAxis;559 QwtAxisId QwtPlotItem::yAxis() const 560 { 561 return m_data->yAxisId; 531 562 } 532 563 … … 534 565 \return An invalid bounding rect: QRectF(1.0, 1.0, -2.0, -2.0) 535 566 \note A width or height < 0.0 is ignored by the autoscaler 536 */ 567 */ 537 568 QRectF QwtPlotItem::boundingRect() const 538 569 { … … 562 593 \sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins() 563 594 */ 564 void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,565 const QwtScaleMap &yMap, const QRectF&canvasRect,566 double &left, double&top, double&right, double&bottom ) const595 void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap& xMap, 596 const QwtScaleMap& yMap, const QRectF& canvasRect, 597 double& left, double& top, double& right, double& bottom ) const 567 598 { 568 599 Q_UNUSED( xMap ); … … 593 624 \sa title(), legendIcon(), QwtLegend, QwtPlotLegendItem 594 625 */ 595 QList<QwtLegendData> QwtPlotItem::legendData() const 626 QList< QwtLegendData > QwtPlotItem::legendData() const 596 627 { 597 628 QwtLegendData data; … … 600 631 label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); 601 632 602 QVariant titleValue; 603 qVariantSetValue( titleValue, label ); 604 data.setValue( QwtLegendData::TitleRole, titleValue ); 633 data.setValue( QwtLegendData::TitleRole, 634 QVariant::fromValue( label ) ); 605 635 606 636 const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); 607 637 if ( !graphic.isNull() ) 608 638 { 609 QVariant iconValue; 610 qVariantSetValue( iconValue, graphic ); 611 data.setValue( QwtLegendData::IconRole, iconValue ); 612 } 613 614 QList<QwtLegendData> list; 639 data.setValue( QwtLegendData::IconRole, 640 QVariant::fromValue( graphic ) ); 641 } 642 643 QList< QwtLegendData > list; 615 644 list += data; 616 645 … … 633 662 634 663 \sa QwtPlot::updateAxes(), ScaleInterest 635 */ 636 void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,637 const QwtScaleDiv &yScaleDiv )664 */ 665 void QwtPlotItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv, 666 const QwtScaleDiv& yScaleDiv ) 638 667 { 639 668 Q_UNUSED( xScaleDiv ); … … 659 688 legendData() and legendIcon() 660 689 */ 661 void QwtPlotItem::updateLegend( const QwtPlotItem *item,662 const QList<QwtLegendData > &data )690 void QwtPlotItem::updateLegend( const QwtPlotItem* item, 691 const QList< QwtLegendData >& data ) 663 692 { 664 693 Q_UNUSED( item ); … … 673 702 674 703 \return Bounding scale rect of the scale maps, not normalized 675 */ 676 QRectF QwtPlotItem::scaleRect( const QwtScaleMap &xMap,677 const QwtScaleMap &yMap ) const704 */ 705 QRectF QwtPlotItem::scaleRect( const QwtScaleMap& xMap, 706 const QwtScaleMap& yMap ) const 678 707 { 679 708 return QRectF( xMap.s1(), yMap.s1(), … … 688 717 689 718 \return Bounding paint rectangle of the scale maps, not normalized 690 */ 691 QRectF QwtPlotItem::paintRect( const QwtScaleMap &xMap,692 const QwtScaleMap &yMap ) const719 */ 720 QRectF QwtPlotItem::paintRect( const QwtScaleMap& xMap, 721 const QwtScaleMap& yMap ) const 693 722 { 694 723 const QRectF rect( xMap.p1(), yMap.p1(),
Note:
See TracChangeset
for help on using the changeset viewer.
