Changeset 8127 in ntrip for trunk/BNC/qwtpolar
- Timestamp:
- May 10, 2017, 3:20:54 PM (8 years ago)
- Location:
- trunk/BNC/qwtpolar
- Files:
-
- 17 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwtpolar/qwt_polar_canvas.cpp
r4272 r8127 9 9 #include "qwt_polar_canvas.h" 10 10 #include "qwt_polar_plot.h" 11 #include <qwt_painter.h> 11 12 #include <qpainter.h> 12 13 #include <qevent.h> … … 213 214 { 214 215 QWidget *bgWidget = qwtBackgroundWidget( plot() ); 215 bs.fill( bgWidget, mapTo( bgWidget, rect().topLeft() ) ); 216 217 QwtPainter::fillPixmap( bgWidget, bs, 218 mapTo( bgWidget, rect().topLeft() ) ); 219 216 220 p.begin( &bs ); 217 221 } -
trunk/BNC/qwtpolar/qwt_polar_curve.cpp
r7990 r8127 14 14 #include <qwt_symbol.h> 15 15 #include <qwt_legend.h> 16 #include <qwt_legend_item.h>17 16 #include <qwt_curve_fitter.h> 18 17 #include <qwt_clipper.h> … … 174 173 \sa symbol() 175 174 */ 176 void QwtPolarCurve::setSymbol( constQwtSymbol *symbol )175 void QwtPolarCurve::setSymbol( QwtSymbol *symbol ) 177 176 { 178 177 if ( symbol != d_data->symbol ) … … 434 433 if ( !clipRect.isEmpty() ) 435 434 { 436 double off = qCeil( qMax( qreal(1.0), painter->pen().widthF() ) );435 double off = qCeil( qMax( qreal( 1.0 ), painter->pen().widthF() ) ); 437 436 clipRect = clipRect.toRect().adjusted( -off, -off, off, off ); 438 437 polyline = QwtClipper::clipPolygonF( clipRect, polyline ); … … 501 500 } 502 501 503 //! Update the widget that represents the curve on the legend 504 void QwtPolarCurve::updateLegend( QwtLegend *legend ) const 505 { 506 if ( legend && testItemAttribute( QwtPolarCurve::Legend ) 507 && ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol ) 508 && d_data->symbol 509 && d_data->symbol->style() != QwtSymbol::NoSymbol ) 510 { 511 QWidget *lgdItem = legend->find( this ); 512 if ( lgdItem == NULL ) 513 { 514 lgdItem = legendItem(); 515 if ( lgdItem ) 516 legend->insert( this, lgdItem ); 517 } 518 519 QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem ); 520 if ( l ) 521 { 522 QSize sz = d_data->symbol->boundingSize(); 523 sz += QSize( 2, 2 ); // margin 524 525 if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine ) 526 { 527 // Avoid, that the line is completely covered by the symbol 528 529 int w = qCeil( 1.5 * sz.width() ); 530 if ( w % 2 ) 531 w++; 532 533 sz.setWidth( qMax( 8, w ) ); 534 } 535 536 l->setIdentifierSize( sz ); 537 } 538 } 539 540 QwtPolarItem::updateLegend( legend ); 541 } 542 543 /*! 544 \brief Draw the identifier representing the curve on the legend 545 546 \param painter Qt Painter 547 \param rect Bounding rectangle for the identifier 548 549 \sa setLegendAttribute 550 */ 551 void QwtPolarCurve::drawLegendIdentifier( 552 QPainter *painter, const QRectF &rect ) const 553 { 554 if ( rect.isEmpty() ) 555 return; 556 557 const double dim = qMin( rect.width(), rect.height() ); 558 559 QSizeF size( dim, dim ); 560 561 QRectF r( 0, 0, size.width(), size.height() ); 562 r.moveCenter( rect.center() ); 502 /*! 503 \return Icon representing the curve on the legend 504 505 \param index Index of the legend entry 506 ( ignored as there is only one ) 507 \param size Icon size 508 509 \sa QwtPolarItem::setLegendIconSize(), QwtPolarItem::legendData() 510 */ 511 QwtGraphic QwtPolarCurve::legendIcon( int index, 512 const QSizeF &size ) const 513 { 514 Q_UNUSED( index ); 515 516 if ( size.isEmpty() ) 517 return QwtGraphic(); 518 519 QwtGraphic graphic; 520 graphic.setDefaultSize( size ); 521 graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true ); 522 523 QPainter painter( &graphic ); 524 painter.setRenderHint( QPainter::Antialiasing, 525 testRenderHint( QwtPolarItem::RenderAntialiased ) ); 563 526 564 527 if ( d_data->legendAttributes == 0 ) 565 528 { 566 529 QBrush brush; 530 567 531 if ( style() != QwtPolarCurve::NoCurve ) 532 { 568 533 brush = QBrush( pen().color() ); 534 } 569 535 else if ( d_data->symbol && 570 536 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) … … 572 538 brush = QBrush( d_data->symbol->pen().color() ); 573 539 } 540 574 541 if ( brush.style() != Qt::NoBrush ) 575 painter->fillRect( r, brush ); 576 } 542 { 543 QRectF r( 0, 0, size.width(), size.height() ); 544 painter.fillRect( r, brush ); 545 } 546 } 547 577 548 if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine ) 578 549 { 579 550 if ( pen() != Qt::NoPen ) 580 551 { 581 painter->setPen( pen() ); 582 QwtPainter::drawLine( painter, rect.left(), rect.center().y(), 583 rect.right() - 1.0, rect.center().y() ); 584 } 585 } 552 QPen pn = pen(); 553 pn.setCapStyle( Qt::FlatCap ); 554 555 painter.setPen( pn ); 556 557 const double y = 0.5 * size.height(); 558 QwtPainter::drawLine( &painter, 0.0, y, size.width(), y ); 559 } 560 } 561 586 562 if ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol ) 587 563 { 588 if ( d_data->symbol && 589 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) ) 590 { 591 QSize symbolSize = d_data->symbol->boundingSize(); 592 symbolSize -= QSize( 2, 2 ); 593 594 // scale the symbol size down if it doesn't fit into rect. 595 596 double xRatio = 1.0; 597 if ( rect.width() < symbolSize.width() ) 598 xRatio = rect.width() / symbolSize.width(); 599 double yRatio = 1.0; 600 if ( rect.height() < symbolSize.height() ) 601 yRatio = rect.height() / symbolSize.height(); 602 603 const double ratio = qMin( xRatio, yRatio ); 604 605 painter->save(); 606 painter->scale( ratio, ratio ); 607 608 d_data->symbol->drawSymbol( painter, rect.center() / ratio ); 609 610 painter->restore(); 611 } 612 } 564 if ( d_data->symbol ) 565 { 566 QRectF r( 0, 0, size.width(), size.height() ); 567 d_data->symbol->drawSymbol( &painter, r ); 568 } 569 } 570 571 return graphic; 613 572 } 614 573 … … 634 593 return QwtInterval(); 635 594 } 595 596 -
trunk/BNC/qwtpolar/qwt_polar_curve.h
r4272 r8127 58 58 In the default setting all attributes are off. 59 59 60 \sa setLegendAttribute(), testLegendAttribute(), 61 drawLegendIdentifier() 60 \sa setLegendAttribute(), testLegendAttribute() 62 61 */ 63 62 … … 101 100 CurveStyle style() const; 102 101 103 void setSymbol( constQwtSymbol * );102 void setSymbol( QwtSymbol * ); 104 103 const QwtSymbol *symbol() const; 105 104 … … 116 115 const QPointF &pole, int from, int to ) const; 117 116 118 virtual void updateLegend( QwtLegend * ) const;119 117 virtual QwtInterval boundingInterval( int scaleId ) const; 120 118 121 virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;119 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; 122 120 123 121 protected: -
trunk/BNC/qwtpolar/qwt_polar_global.h
r4272 r8127 14 14 // QWT_POLAR_VERSION is (major << 16) + (minor << 8) + patch. 15 15 16 #define QWT_POLAR_VERSION 0x010000 17 #define QWT_POLAR_VERSION_STR "1.0.0" 18 19 #if defined(Q_WS_WIN) || defined(Q_WS_S60) 16 #define QWT_POLAR_VERSION 0x010101 17 #define QWT_POLAR_VERSION_STR "1.1.1" 20 18 21 19 #if defined(_MSC_VER) /* MSVC Compiler */ … … 26 24 #ifdef QWT_POLAR_DLL 27 25 28 #if defined(QWT_POLAR_MAKEDLL) // create a QwtDLL library29 #define QWT_POLAR_EXPORT __declspec(dllexport)26 #if defined(QWT_POLAR_MAKEDLL) // create DLL library 27 #define QWT_POLAR_EXPORT Q_DECL_EXPORT 30 28 #define QWT_POLAR_TEMPLATEDLL 31 #else // use a QwtDLL library32 #define QWT_POLAR_EXPORT __declspec(dllimport)29 #else // use DLL library 30 #define QWT_POLAR_EXPORT Q_DECL_IMPORT 33 31 #endif 34 32 35 #endif // QWT_POLAR_MAKEDLL 36 37 #endif // Q_WS_WIN 33 #endif // QWT_POLAR_DLL 38 34 39 35 #ifndef QWT_POLAR_EXPORT -
trunk/BNC/qwtpolar/qwt_polar_grid.cpp
r4272 r8127 877 877 878 878 scaleDraw->setAngleRange( from, from - 360.0 ); 879 scaleDraw->setTransformation( azimuthMap.transformation()->copy() ); 879 880 const QwtTransform *transform = azimuthMap.transformation(); 881 if ( transform ) 882 scaleDraw->setTransformation( transform->copy() ); 883 else 884 scaleDraw->setTransformation( NULL ); 880 885 } 881 886 else … … 911 916 } 912 917 } 913 scaleDraw->setTransformation( radialMap.transformation()->copy() ); 918 const QwtTransform *transform = radialMap.transformation(); 919 if ( transform ) 920 scaleDraw->setTransformation( transform->copy() ); 921 else 922 scaleDraw->setTransformation( NULL ); 914 923 } 915 924 } … … 976 985 QwtScaleDiv sd = radialGrid.scaleDiv; 977 986 978 QList<double> &ticks = 979 const_cast<QList<double> &>( sd.ticks( QwtScaleDiv::MajorTick ) ); 987 QList<double> ticks = sd.ticks( QwtScaleDiv::MajorTick ); 980 988 981 989 if ( testDisplayFlag( SmartOriginLabel ) ) … … 1011 1019 } 1012 1020 1021 sd.setTicks( QwtScaleDiv::MajorTick, ticks ); 1013 1022 axis.scaleDraw->setScaleDiv( sd ); 1014 1023 … … 1049 1058 const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const 1050 1059 { 1051 if ( axisId >= QwtPolar::AxisLeft ||axisId <= QwtPolar::AxisBottom )1060 if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom ) 1052 1061 return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw ); 1053 1062 … … 1064 1073 QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) 1065 1074 { 1066 if ( axisId >= QwtPolar::AxisLeft ||axisId <= QwtPolar::AxisBottom )1075 if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom ) 1067 1076 return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw ); 1068 1077 -
trunk/BNC/qwtpolar/qwt_polar_item.cpp
r4272 r8127 10 10 #include "qwt_polar_item.h" 11 11 #include <qwt_legend.h> 12 #include <qwt_legend_item.h>13 12 #include <qwt_scale_div.h> 14 13 #include <qpainter.h> … … 22 21 attributes( 0 ), 23 22 renderHints( 0 ), 24 z( 0.0 ) 23 renderThreadCount( 1 ), 24 z( 0.0 ), 25 legendIconSize( 8, 8 ) 25 26 { 26 27 } … … 31 32 QwtPolarItem::ItemAttributes attributes; 32 33 QwtPolarItem::RenderHints renderHints; 34 uint renderThreadCount; 35 33 36 double z; 34 37 35 38 QwtText title; 39 QSize legendIconSize; 36 40 }; 37 41 … … 74 78 return; 75 79 76 // remove the item from the previous plot77 78 80 if ( d_data->plot ) 79 {80 if ( d_data->plot->legend() )81 d_data->plot->legend()->remove( this );82 83 81 d_data->plot->attachItem( this, false ); 84 82 85 if ( d_data->plot->autoReplot() )86 d_data->plot->update();87 }88 89 83 d_data->plot = plot; 90 84 91 85 if ( d_data->plot ) 92 {93 // insert the item into the current plot94 95 86 d_data->plot->attachItem( this, true ); 96 itemChanged(); 97 } 87 } 88 89 /*! 90 \brief This method detaches a QwtPolarItem from the QwtPolarPlot it 91 has been associated with. 92 93 detach() is equivalent to calling attach( NULL ) 94 \sa attach() 95 */ 96 void QwtPolarItem::detach() 97 { 98 attach( NULL ); 98 99 } 99 100 … … 257 258 } 258 259 260 /*! 261 On multi core systems rendering of certain plot item 262 ( f.e QwtPolarSpectrogram ) can be done in parallel in 263 several threads. 264 265 The default setting is set to 1. 266 267 \param numThreads Number of threads to be used for rendering. 268 If numThreads is set to 0, the system specific 269 ideal thread count is used. 270 271 The default thread count is 1 ( = no additional threads ) 272 */ 273 void QwtPolarItem::setRenderThreadCount( uint numThreads ) 274 { 275 d_data->renderThreadCount = numThreads; 276 } 277 278 /*! 279 \return Number of threads to be used for rendering. 280 If numThreads() is set to 0, the system specific 281 ideal thread count is used. 282 */ 283 uint QwtPolarItem::renderThreadCount() const 284 { 285 return d_data->renderThreadCount; 286 } 287 288 /*! 289 Set the size of the legend icon 290 291 The default setting is 8x8 pixels 292 293 \param size Size 294 \sa legendIconSize(), legendIcon() 295 */ 296 void QwtPolarItem::setLegendIconSize( const QSize &size ) 297 { 298 if ( d_data->legendIconSize != size ) 299 { 300 d_data->legendIconSize = size; 301 legendChanged(); 302 } 303 } 304 305 /*! 306 \return Legend icon size 307 \sa setLegendIconSize(), legendIcon() 308 */ 309 QSize QwtPolarItem::legendIconSize() const 310 { 311 return d_data->legendIconSize; 312 } 313 259 314 //! Show the item 260 315 void QwtPolarItem::show() … … 302 357 { 303 358 if ( d_data->plot ) 304 {305 if ( d_data->plot->legend() )306 updateLegend( d_data->plot->legend() );307 308 359 d_data->plot->autoRefresh(); 309 } 360 } 361 362 /*! 363 Update the legend of the parent plot. 364 \sa QwtPolarPlot::updateLegend(), itemChanged() 365 */ 366 void QwtPolarItem::legendChanged() 367 { 368 if ( testItemAttribute( QwtPolarItem::Legend ) && d_data->plot ) 369 d_data->plot->updateLegend( this ); 310 370 } 311 371 … … 351 411 352 412 /*! 353 \brief Update the widget that represents the item on the legend 354 355 updateLegend() is called from itemChanged() to adopt the widget 356 representing the item on the legend to its new configuration. 357 358 The default implementation is made for QwtPolarCurve and updates a 359 QwtLegendItem(), but an item could be represented by any type of widget, 360 by overloading legendItem() and updateLegend(). 361 362 \sa legendItem(), itemChanged(), QwtLegend() 363 */ 364 void QwtPolarItem::updateLegend( QwtLegend *legend ) const 365 { 366 if ( legend == NULL ) 367 return; 368 369 QWidget *lgdItem = legend->find( this ); 370 if ( testItemAttribute( QwtPolarItem::Legend ) ) 371 { 372 if ( lgdItem == NULL ) 373 { 374 lgdItem = legendItem(); 375 if ( lgdItem ) 376 legend->insert( this, lgdItem ); 377 } 378 379 QwtLegendItem* label = qobject_cast<QwtLegendItem *>( lgdItem ); 380 if ( label ) 381 { 382 // paint the identifier 383 const QSize sz = label->identifierSize(); 384 385 QPixmap identifier( sz.width(), sz.height() ); 386 identifier.fill( Qt::transparent ); 387 388 QPainter painter( &identifier ); 389 painter.setRenderHint( QPainter::Antialiasing, 390 testRenderHint( QwtPolarItem::RenderAntialiased ) ); 391 392 drawLegendIdentifier( &painter, 393 QRect( 0, 0, sz.width(), sz.height() ) ); 394 395 painter.end(); 396 397 const bool doUpdate = label->updatesEnabled(); 398 if ( doUpdate ) 399 label->setUpdatesEnabled( false ); 400 401 label->setText( title() ); 402 label->setIdentifier( identifier ); 403 label->setItemMode( legend->itemMode() ); 404 405 if ( doUpdate ) 406 label->setUpdatesEnabled( true ); 407 408 label->update(); 409 } 410 } 411 else 412 { 413 if ( lgdItem ) 414 { 415 lgdItem->hide(); 416 lgdItem->deleteLater(); 417 } 418 } 419 } 420 /*! 421 \brief Allocate the widget that represents the item on the legend 422 423 The default implementation is made for QwtPolarCurve and returns a 424 QwtLegendItem(), but an item could be represented by any type of widget, 425 by overloading legendItem() and updateLegend(). 426 427 \return QwtLegendItem() 428 \sa updateLegend() QwtLegend() 429 */ 430 QWidget *QwtPolarItem::legendItem() const 431 { 432 QwtLegendItem *item = new QwtLegendItem; 433 if ( d_data->plot ) 434 { 435 QObject::connect( item, SIGNAL( clicked() ), 436 d_data->plot, SLOT( legendItemClicked() ) ); 437 QObject::connect( item, SIGNAL( checked( bool ) ), 438 d_data->plot, SLOT( legendItemChecked( bool ) ) ); 439 } 440 return item; 413 \brief Return all information, that is needed to represent 414 the item on the legend 415 416 Most items are represented by one entry on the legend 417 showing an icon and a text. 418 419 QwtLegendData is basically a list of QVariants that makes it 420 possible to overload and reimplement legendData() to 421 return almost any type of information, that is understood 422 by the receiver that acts as the legend. 423 424 The default implementation returns one entry with 425 the title() of the item and the legendIcon(). 426 427 \sa title(), legendIcon(), QwtLegend 428 */ 429 QList<QwtLegendData> QwtPolarItem::legendData() const 430 { 431 QwtLegendData data; 432 433 QwtText label = title(); 434 label.setRenderFlags( label.renderFlags() & Qt::AlignLeft ); 435 436 QVariant titleValue; 437 qVariantSetValue( titleValue, label ); 438 data.setValue( QwtLegendData::TitleRole, titleValue ); 439 440 const QwtGraphic graphic = legendIcon( 0, legendIconSize() ); 441 if ( !graphic.isNull() ) 442 { 443 QVariant iconValue; 444 qVariantSetValue( iconValue, graphic ); 445 data.setValue( QwtLegendData::IconRole, iconValue ); 446 } 447 448 QList<QwtLegendData> list; 449 list += data; 450 451 return list; 452 } 453 454 /*! 455 \return Icon representing the item on the legend 456 457 The default implementation returns an invalid icon 458 459 \param index Index of the legend entry 460 ( usually there is only one ) 461 \param size Icon size 462 463 \sa setLegendIconSize(), legendData() 464 */ 465 QwtGraphic QwtPolarItem::legendIcon( 466 int index, const QSizeF &size ) const 467 { 468 Q_UNUSED( index ) 469 Q_UNUSED( size ) 470 471 return QwtGraphic(); 441 472 } 442 473 -
trunk/BNC/qwtpolar/qwt_polar_item.h
r4272 r8127 12 12 #include "qwt_polar_global.h" 13 13 #include <qwt_text.h> 14 #include <qwt_legend_itemmanager.h> 14 #include <qwt_legend_data.h> 15 #include <qwt_graphic.h> 15 16 #include <qwt_interval.h> 16 17 … … 34 35 types of items. 35 36 */ 36 class QWT_POLAR_EXPORT QwtPolarItem : public QwtLegendItemManager37 class QWT_POLAR_EXPORT QwtPolarItem 37 38 { 38 39 public: … … 103 104 104 105 void attach( QwtPolarPlot *plot ); 105 106 /*! 107 \brief This method detaches a QwtPolarItem from any QwtPolarPlot it 108 has been associated with. 109 110 detach() is equivalent to calling attach( NULL ) 111 \sa attach( QwtPolarPlot* plot ) 112 */ 113 void detach() { attach( NULL ); } 106 void detach(); 114 107 115 108 QwtPolarPlot *plot() const; … … 127 120 bool testRenderHint( RenderHint ) const; 128 121 122 void setRenderThreadCount( uint numThreads ); 123 uint renderThreadCount() const; 124 129 125 double z() const; 130 126 void setZ( double z ); … … 136 132 137 133 virtual void itemChanged(); 134 virtual void legendChanged(); 138 135 139 136 /*! … … 154 151 virtual QwtInterval boundingInterval( int scaleId ) const; 155 152 156 virtual QWidget *legendItem() const;157 158 virtual void updateLegend( QwtLegend * ) const;159 153 virtual void updateScaleDiv( const QwtScaleDiv &, 160 154 const QwtScaleDiv &, const QwtInterval & ); 161 155 162 156 virtual int marginHint() const; 157 158 void setLegendIconSize( const QSize & ); 159 QSize legendIconSize() const; 160 161 virtual QList<QwtLegendData> legendData() const; 162 virtual QwtGraphic legendIcon( int index, const QSizeF & ) const; 163 163 164 164 private: … … 174 174 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints ) 175 175 176 Q_DECLARE_METATYPE( QwtPolarItem * ) 177 176 178 #endif -
trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp
r4272 r8127 110 110 111 111 /*! 112 Attach/Detacha plot item112 Insert a plot item 113 113 114 Attached items will be deleted in the destructor, 115 if auto deletion is enabled (default). Manually detached 116 items are not deleted. 114 \param item PlotItem 115 \sa removeItem() 116 */ 117 void QwtPolarItemDict::insertItem( QwtPolarItem *item ) 118 { 119 d_data->itemList.insertItem( item ); 120 } 117 121 118 \param item Plot item to attach/detach 119 \ on If true attach, else detach theitem122 /*! 123 Remove a plot item 120 124 121 \sa setAutoDelete, ~QwtPolarItemDict 122 */ 123 void QwtPolarItemDict::attachItem( QwtPolarItem *item, bool on ) 125 \param item PlotItem 126 \sa insertItem() 127 */ 128 void QwtPolarItemDict::removeItem( QwtPolarItem *item ) 124 129 { 125 if ( on ) 126 d_data->itemList.insertItem( item ); 127 else 128 d_data->itemList.removeItem( item ); 130 d_data->itemList.removeItem( item ); 129 131 } 130 132 -
trunk/BNC/qwtpolar/qwt_polar_itemdict.h
r4272 r8127 44 44 bool autoDelete = true ); 45 45 46 protected: 47 void insertItem( QwtPolarItem * ); 48 void removeItem( QwtPolarItem * ); 49 46 50 private: 47 friend class QwtPolarItem;48 49 void attachItem( QwtPolarItem *, bool );50 51 51 class PrivateData; 52 52 PrivateData *d_data; -
trunk/BNC/qwtpolar/qwt_polar_layout.cpp
r7990 r8127 23 23 { 24 24 int frameWidth; 25 int vScrollBarWidth;26 int hScrollBarHeight;25 int hScrollExtent; 26 int vScrollExtent; 27 27 QSizeF hint; 28 28 } legend; … … 49 49 { 50 50 legend.frameWidth = plot->legend()->frameWidth(); 51 legend. vScrollBarWidth=52 plot->legend()-> verticalScrollBar()->sizeHint().width();53 legend. hScrollBarHeight =54 plot->legend()-> horizontalScrollBar()->sizeHint().height();51 legend.hScrollExtent = 52 plot->legend()->scrollExtent( Qt::Horizontal ); 53 legend.vScrollExtent = 54 plot->legend()->scrollExtent( Qt::Vertical ); 55 55 56 56 const QSizeF hint = plot->legend()->sizeHint(); … … 62 62 63 63 if ( h > rect.height() ) 64 w += legend. vScrollBarWidth;64 w += legend.hScrollExtent; 65 65 66 66 legend.hint = QSizeF( w, h ); … … 279 279 // half of the available space. 280 280 281 dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio));281 dim = qMin( double( hint.width() ), rect.width() * d_data->legendRatio ); 282 282 283 283 if ( !( options & IgnoreScrollbars ) ) … … 288 288 // space for the vertical scrollbar. 289 289 290 dim += d_data->layoutData.legend. vScrollBarWidth;290 dim += d_data->layoutData.legend.hScrollExtent; 291 291 } 292 292 } … … 294 294 else 295 295 { 296 dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio));297 dim = qMax( dim, d_data->layoutData.legend. hScrollBarHeight );296 dim = qMin( double( hint.height() ), rect.height() * d_data->legendRatio ); 297 dim = qMax( dim, d_data->layoutData.legend.vScrollExtent ); 298 298 } 299 299 -
trunk/BNC/qwtpolar/qwt_polar_plot.cpp
r4272 r8127 16 16 #include <qwt_round_scale_draw.h> 17 17 #include <qwt_legend.h> 18 #include <qwt_legend_item.h>19 18 #include <qwt_dyngrid_layout.h> 20 19 #include <qpointer.h> … … 35 34 public: 36 35 ScaleData(): 36 isValid( false ), 37 37 scaleEngine( NULL ) 38 38 { … … 53 53 int maxMinor; 54 54 55 bool isValid; 56 55 57 QwtScaleDiv scaleDiv; 56 58 QwtScaleEngine *scaleEngine; … … 70 72 QPointer<QwtTextLabel> titleLabel; 71 73 QPointer<QwtPolarCanvas> canvas; 72 QPointer<Qwt Legend> legend;74 QPointer<QwtAbstractLegend> legend; 73 75 double azimuthOrigin; 74 76 … … 183 185 QwtPolarLayout::setLegendPosition() 184 186 */ 185 void QwtPolarPlot::insertLegend( Qwt Legend *legend,187 void QwtPolarPlot::insertLegend( QwtAbstractLegend *legend, 186 188 QwtPolarPlot::LegendPosition pos, double ratio ) 187 189 { 188 190 d_data->layout->setLegendPosition( pos, ratio ); 191 189 192 if ( legend != d_data->legend ) 190 193 { … … 196 199 if ( d_data->legend ) 197 200 { 198 if ( pos != ExternalLegend ) 201 connect( this, 202 SIGNAL( legendDataChanged( 203 const QVariant &, const QList<QwtLegendData> & ) ), 204 d_data->legend, 205 SLOT( updateLegend( 206 const QVariant &, const QList<QwtLegendData> & ) ) 207 ); 208 209 if ( d_data->legend->parent() != this ) 210 d_data->legend->setParent( this ); 211 212 updateLegend(); 213 214 QwtLegend *lgd = qobject_cast<QwtLegend *>( legend ); 215 if ( lgd ) 199 216 { 200 if ( d_data->legend->parent() != this ) 201 d_data->legend->setParent( this ); 202 } 203 204 const QwtPolarItemList& itmList = itemList(); 205 for ( QwtPolarItemIterator it = itmList.begin(); 206 it != itmList.end(); ++it ) 207 { 208 ( *it )->updateLegend( d_data->legend ); 209 } 210 211 QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>( 212 d_data->legend->contentsWidget()->layout() ); 213 214 if ( tl ) 215 { 216 switch( d_data->layout->legendPosition() ) 217 switch ( d_data->layout->legendPosition() ) 217 218 { 218 219 case LeftLegend: 219 220 case RightLegend: 220 tl->setMaxCols( 1 ); // 1 column: align vertical 221 { 222 if ( lgd->maxColumns() == 0 ) 223 lgd->setMaxColumns( 1 ); // 1 column: align vertical 221 224 break; 222 225 } 223 226 case TopLegend: 224 227 case BottomLegend: 225 tl->setMaxCols( 0 ); // unlimited 228 { 229 lgd->setMaxColumns( 0 ); // unlimited 226 230 break; 227 228 case ExternalLegend:231 } 232 default: 229 233 break; 230 234 } 231 235 } 232 } 233 } 236 237 } 238 } 239 234 240 updateLayout(); 241 } 242 243 /*! 244 Emit legendDataChanged() for all plot item 245 246 \sa QwtPlotItem::legendData(), legendDataChanged() 247 */ 248 void QwtPolarPlot::updateLegend() 249 { 250 const QwtPolarItemList& itmList = itemList(); 251 for ( QwtPolarItemIterator it = itmList.begin(); 252 it != itmList.end(); ++it ) 253 { 254 updateLegend( *it ); 255 } 256 } 257 258 /*! 259 Emit legendDataChanged() for a plot item 260 261 \param plotItem Plot item 262 \sa QwtPlotItem::legendData(), legendDataChanged() 263 */ 264 void QwtPolarPlot::updateLegend( const QwtPolarItem *plotItem ) 265 { 266 if ( plotItem == NULL ) 267 return; 268 269 QList<QwtLegendData> legendData; 270 271 if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) ) 272 legendData = plotItem->legendData(); 273 274 const QVariant itemInfo = itemToInfo( const_cast< QwtPolarItem *>( plotItem) ); 275 Q_EMIT legendDataChanged( itemInfo, legendData ); 235 276 } 236 277 … … 239 280 \sa insertLegend() 240 281 */ 241 Qwt Legend *QwtPolarPlot::legend()282 QwtAbstractLegend *QwtPolarPlot::legend() 242 283 { 243 284 return d_data->legend; … … 248 289 \sa insertLegend() 249 290 */ 250 const Qwt Legend *QwtPolarPlot::legend() const291 const QwtAbstractLegend *QwtPolarPlot::legend() const 251 292 { 252 293 return d_data->legend; 253 }254 255 /*!256 Called internally when the legend has been clicked on.257 Emits a legendClicked() signal.258 */259 void QwtPolarPlot::legendItemClicked()260 {261 if ( d_data->legend && sender()->isWidgetType() )262 {263 QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(264 d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );265 if ( plotItem )266 Q_EMIT legendClicked( plotItem );267 }268 }269 270 /*!271 Called internally when the legend has been checked272 Emits a legendClicked() signal.273 */274 void QwtPolarPlot::legendItemChecked( bool on )275 {276 if ( d_data->legend && sender()->isWidgetType() )277 {278 QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(279 d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );280 if ( plotItem )281 Q_EMIT legendChecked( plotItem, on );282 }283 294 } 284 295 … … 389 400 return; 390 401 391 if ( maxMinor < 0 ) 392 maxMinor = 0; 393 if ( maxMinor > 100 ) 394 maxMinor = 100; 402 maxMinor = qBound( 0, maxMinor, 100 ); 395 403 396 404 ScaleData &scaleData = d_data->scaleData[scaleId]; … … 399 407 { 400 408 scaleData.maxMinor = maxMinor; 401 scaleData. scaleDiv.invalidate();409 scaleData.isValid = false; 402 410 autoRefresh(); 403 411 } … … 429 437 return; 430 438 431 if ( maxMajor < 1 ) 432 maxMajor = 1; 433 if ( maxMajor > 1000 ) 434 maxMajor = 10000; 439 maxMajor = qBound( 1, maxMajor, 10000 ); 435 440 436 441 ScaleData &scaleData = d_data->scaleData[scaleId]; … … 438 443 { 439 444 scaleData.maxMajor = maxMajor; 440 scaleData. scaleDiv.invalidate();445 scaleData.isValid = false; 441 446 autoRefresh(); 442 447 } … … 477 482 scaleData.scaleEngine = scaleEngine; 478 483 479 scaleData. scaleDiv.invalidate();484 scaleData.isValid = false; 480 485 481 486 autoRefresh(); … … 527 532 ScaleData &scaleData = d_data->scaleData[scaleId]; 528 533 529 scaleData. scaleDiv.invalidate();534 scaleData.isValid = false; 530 535 531 536 scaleData.minValue = min; … … 551 556 552 557 scaleData.scaleDiv = scaleDiv; 558 scaleData.isValid = true; 553 559 scaleData.doAutoScale = false; 554 560 … … 732 738 { 733 739 map.setPaintInterval( d_data->azimuthOrigin, 734 d_data->azimuthOrigin + M_2PI );740 d_data->azimuthOrigin + 2 * M_PI ); 735 741 } 736 742 else … … 820 826 scaleData.maxMajor = 8; 821 827 828 scaleData.isValid = false; 829 822 830 scaleData.scaleEngine = new QwtLinearScaleEngine; 823 scaleData.scaleDiv.invalidate();824 831 } 825 832 d_data->zoomFactor = 1.0; … … 858 865 } 859 866 860 if ( d_data->legend && 861 d_data->layout->legendPosition() != ExternalLegend ) 862 { 863 if ( d_data->legend->itemCount() > 0 ) 864 { 865 d_data->legend->setGeometry( d_data->layout->legendRect().toRect() ); 867 if ( d_data->legend ) 868 { 869 if ( d_data->legend->isEmpty() ) 870 { 871 d_data->legend->hide(); 872 } 873 else 874 { 875 const QRectF legendRect = d_data->layout->legendRect(); 876 d_data->legend->setGeometry( legendRect.toRect() ); 866 877 d_data->legend->show(); 867 878 } 868 else869 d_data->legend->hide();870 879 } 871 880 … … 1054 1063 d.scaleEngine->autoScale( d.maxMajor, 1055 1064 minValue, maxValue, stepSize ); 1056 d. scaleDiv.invalidate();1057 } 1058 1059 if ( !d. scaleDiv.isValid())1065 d.isValid = false; 1066 } 1067 1068 if ( !d.isValid ) 1060 1069 { 1061 1070 d.scaleDiv = d.scaleEngine->divideScale( 1062 1071 minValue, maxValue, d.maxMajor, d.maxMinor, stepSize ); 1072 d.isValid = true; 1063 1073 } 1064 1074 … … 1270 1280 return d_data->layout; 1271 1281 } 1282 1283 /*! 1284 \brief Attach/Detach a plot item 1285 1286 \param plotItem Plot item 1287 \param on When true attach the item, otherwise detach it 1288 */ 1289 void QwtPolarPlot::attachItem( QwtPolarItem *plotItem, bool on ) 1290 { 1291 if ( on ) 1292 insertItem( plotItem ); 1293 else 1294 removeItem( plotItem ); 1295 1296 Q_EMIT itemAttached( plotItem, on ); 1297 1298 if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) ) 1299 { 1300 // the item wants to be represented on the legend 1301 1302 if ( on ) 1303 { 1304 updateLegend( plotItem ); 1305 } 1306 else 1307 { 1308 const QVariant itemInfo = itemToInfo( plotItem ); 1309 Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() ); 1310 } 1311 } 1312 1313 if ( autoReplot() ) 1314 update(); 1315 } 1316 1317 /*! 1318 \brief Build an information, that can be used to identify 1319 a plot item on the legend. 1320 1321 The default implementation simply wraps the plot item 1322 into a QVariant object. When overloading itemToInfo() 1323 usually infoToItem() needs to reimplemeted too. 1324 1325 \code 1326 QVariant itemInfo; 1327 qVariantSetValue( itemInfo, plotItem ); 1328 \endcode 1329 1330 \param plotItem Plot item 1331 \sa infoToItem() 1332 */ 1333 QVariant QwtPolarPlot::itemToInfo( QwtPolarItem *plotItem ) const 1334 { 1335 QVariant itemInfo; 1336 qVariantSetValue( itemInfo, plotItem ); 1337 1338 return itemInfo; 1339 } 1340 1341 /*! 1342 \brief Identify the plot item according to an item info object, 1343 that has bee generated from itemToInfo(). 1344 1345 The default implementation simply tries to unwrap a QwtPlotItem 1346 pointer: 1347 1348 \code 1349 if ( itemInfo.canConvert<QwtPlotItem *>() ) 1350 return qvariant_cast<QwtPlotItem *>( itemInfo ); 1351 \endcode 1352 \param itemInfo Plot item 1353 \return A plot item, when successful, otherwise a NULL pointer. 1354 \sa itemToInfo() 1355 */ 1356 QwtPolarItem *QwtPolarPlot::infoToItem( const QVariant &itemInfo ) const 1357 { 1358 if ( itemInfo.canConvert<QwtPolarItem *>() ) 1359 return qvariant_cast<QwtPolarItem *>( itemInfo ); 1360 1361 return NULL; 1362 } -
trunk/BNC/qwtpolar/qwt_polar_plot.h
r4272 r8127 24 24 class QwtPolarCanvas; 25 25 class QwtPolarLayout; 26 class QwtAbstractLegend; 26 27 27 28 /*! … … 141 142 // Legend 142 143 143 void insertLegend( Qwt Legend *,144 void insertLegend( QwtAbstractLegend *, 144 145 LegendPosition = RightLegend, double ratio = -1.0 ); 145 146 146 QwtLegend *legend(); 147 const QwtLegend *legend() const; 147 QwtAbstractLegend *legend(); 148 const QwtAbstractLegend *legend() const; 149 150 void updateLegend(); 151 void updateLegend( const QwtPolarItem * ); 148 152 149 153 // Layout … … 157 161 int plotMarginHint() const; 158 162 163 virtual QVariant itemToInfo( QwtPolarItem * ) const; 164 virtual QwtPolarItem *infoToItem( const QVariant & ) const; 165 159 166 Q_SIGNALS: 160 167 /*! 161 A signal which is emitted when the user has clicked on 162 a legend item, which is in QwtLegend::ClickableItem mode. 163 164 \param plotItem Corresponding plot item of the 165 selected legend item 166 167 \note clicks are disabled as default 168 \sa QwtLegend::setItemMode, QwtLegend::itemMode 169 */ 170 void legendClicked( QwtPolarItem *plotItem ); 171 172 /*! 173 A signal which is emitted when the user has clicked on 174 a legend item, which is in QwtLegend::CheckableItem mode 175 176 \param plotItem Corresponding plot item of the 177 selected legend item 178 \param on True when the legen item is checked 179 180 \note clicks are disabled as default 181 \sa QwtLegend::setItemMode, QwtLegend::itemMode 182 */ 183 void legendChecked( QwtPolarItem *plotItem, bool on ); 168 A signal indicating, that an item has been attached/detached 169 170 \param plotItem Plot item 171 \param on Attached/Detached 172 */ 173 void itemAttached( QwtPolarItem *plotItem, bool on ); 174 175 /*! 176 A signal with the attributes how to update 177 the legend entries for a plot item. 178 179 \param itemInfo Info about a plot, build from itemToInfo() 180 181 \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend() 182 */ 183 void legendDataChanged( const QVariant &itemInfo, 184 const QList<QwtLegendData> &data ); 184 185 185 186 /*! … … 194 195 void setAzimuthOrigin( double ); 195 196 196 protected Q_SLOTS:197 virtual void legendItemClicked();198 virtual void legendItemChecked( bool );199 200 197 protected: 201 198 virtual bool event( QEvent * ); … … 210 207 211 208 private: 209 friend class QwtPolarItem; 210 void attachItem( QwtPolarItem *, bool ); 211 212 212 void initPlot( const QwtText & ); 213 213 -
trunk/BNC/qwtpolar/qwt_polar_renderer.cpp
r4272 r8127 11 11 #include "qwt_polar_layout.h" 12 12 #include <qwt_legend.h> 13 #include <qwt_legend_item.h>14 13 #include <qwt_dyngrid_layout.h> 15 14 #include <qwt_text_label.h> … … 17 16 #include <qpainter.h> 18 17 #include <qprinter.h> 18 #include <qprintdialog.h> 19 #include <qfiledialog.h> 19 20 #include <qimagewriter.h> 20 21 #include <qfileinfo.h> … … 115 116 116 117 const QString fmt = format.toLower(); 117 if ( format == "pdf" || format == "ps" ) 118 { 118 if ( format == "pdf" ) 119 { 120 #ifndef QT_NO_PRINTER 119 121 QPrinter printer; 122 printer.setColorMode( QPrinter::Color ); 120 123 printer.setFullPage( true ); 121 124 printer.setPaperSize( sizeMM, QPrinter::Millimeter ); 122 125 printer.setDocName( title ); 123 126 printer.setOutputFileName( fileName ); 124 printer.setOutputFormat( ( format == "pdf" ) 125 ? QPrinter::PdfFormat : QPrinter::PostScriptFormat ); 127 printer.setOutputFormat( QPrinter::PdfFormat ); 126 128 printer.setResolution( resolution ); 127 129 128 130 QPainter painter( &printer ); 129 131 render( plot, &painter, documentRect ); 132 #endif 133 } 134 else if ( format == "ps" ) 135 { 136 #if QT_VERSION < 0x050000 137 #ifndef QT_NO_PRINTER 138 QPrinter printer; 139 printer.setColorMode( QPrinter::Color ); 140 printer.setFullPage( true ); 141 printer.setPaperSize( sizeMM, QPrinter::Millimeter ); 142 printer.setDocName( title ); 143 printer.setOutputFileName( fileName ); 144 printer.setOutputFormat( QPrinter::PostScriptFormat ); 145 printer.setResolution( resolution ); 146 147 QPainter painter( &printer ); 148 render( plot, &painter, documentRect ); 149 #endif 150 #endif 130 151 } 131 152 #ifndef QWT_NO_POLAR_SVG … … 300 321 301 322 painter->save(); 302 renderLegend( p ainter, layout->legendRect() );323 renderLegend( plot, painter, layout->legendRect() ); 303 324 painter->restore(); 304 325 … … 340 361 Render the legend into a given rectangle. 341 362 363 \param plot Plot widget 342 364 \param painter Painter 343 365 \param rect Bounding rectangle 344 366 */ 345 346 void QwtPolarRenderer::renderLegend( 367 void QwtPolarRenderer::renderLegend( const QwtPolarPlot *plot, 347 368 QPainter *painter, const QRectF &rect ) const 348 369 { 349 QwtLegend *legend = d_data->plot->legend(); 350 if ( legend == NULL || legend->isEmpty() ) 351 return; 352 353 const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>( 354 legend->contentsWidget()->layout() ); 355 if ( legendLayout == NULL ) 356 return; 357 358 uint numCols = legendLayout->columnsForWidth( rect.width() ); 359 const QList<QRect> itemRects = 360 legendLayout->layoutItems( rect.toRect(), numCols ); 361 362 int index = 0; 363 364 for ( int i = 0; i < legendLayout->count(); i++ ) 365 { 366 QLayoutItem *item = legendLayout->itemAt( i ); 367 QWidget *w = item->widget(); 368 if ( w ) 370 if ( plot->legend() ) 371 plot->legend()->renderLegend( painter, rect, true ); 372 } 373 374 /*! 375 \brief Execute a file dialog and render the plot to the selected file 376 377 The document will be rendered in 85 dpi for a size 30x30 cm 378 379 \param plot Plot widget 380 \param documentName Default document name 381 \param sizeMM Size for the document in millimeters. 382 \param resolution Resolution in dots per Inch (dpi) 383 384 \sa renderDocument() 385 */ 386 bool QwtPolarRenderer::exportTo( QwtPolarPlot *plot, 387 const QString &documentName, const QSizeF &sizeMM, int resolution ) 388 { 389 if ( plot == NULL ) 390 return false; 391 392 QString fileName = documentName; 393 394 // What about translation 395 396 #ifndef QT_NO_FILEDIALOG 397 const QList<QByteArray> imageFormats = 398 QImageWriter::supportedImageFormats(); 399 400 QStringList filter; 401 #ifndef QT_NO_PRINTER 402 filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)"; 403 #endif 404 #ifndef QWT_NO_SVG 405 filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)"; 406 #endif 407 #ifndef QT_NO_PRINTER 408 filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)"; 409 #endif 410 411 if ( imageFormats.size() > 0 ) 412 { 413 QString imageFilter( tr( "Images" ) ); 414 imageFilter += " ("; 415 for ( int i = 0; i < imageFormats.size(); i++ ) 369 416 { 370 painter->save(); 371 372 painter->setClipRect( itemRects[index] ); 373 renderLegendItem( painter, w, itemRects[index] ); 374 375 index++; 376 painter->restore(); 417 if ( i > 0 ) 418 imageFilter += " "; 419 imageFilter += "*."; 420 imageFilter += imageFormats[i]; 377 421 } 378 } 379 380 } 381 382 /*! 383 Print the legend item into a given rectangle. 384 385 \param painter Painter 386 \param widget Widget representing a legend item 387 \param rect Bounding rectangle 388 389 \note When widget is not derived from QwtLegendItem renderLegendItem 390 does nothing and needs to be overloaded 391 */ 392 void QwtPolarRenderer::renderLegendItem( QPainter *painter, 393 const QWidget *widget, const QRectF &rect ) const 394 { 395 const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget ); 396 if ( item ) 397 { 398 const QSize sz = item->identifierSize(); 399 400 const QRectF identifierRect( rect.x() + item->margin(), 401 rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() ); 402 403 QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item ); 404 if ( itemManger ) 405 { 406 painter->save(); 407 painter->setClipRect( identifierRect, Qt::IntersectClip ); 408 itemManger->drawLegendIdentifier( painter, identifierRect ); 409 painter->restore(); 410 } 411 412 // Label 413 414 QRectF titleRect = rect; 415 titleRect.setX( identifierRect.right() + 2 * item->spacing() ); 416 417 painter->setFont( item->font() ); 418 item->text().draw( painter, titleRect ); 419 } 420 } 421 422 imageFilter += ")"; 423 424 filter += imageFilter; 425 } 426 427 fileName = QFileDialog::getSaveFileName( 428 NULL, tr( "Export File Name" ), fileName, 429 filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite ); 430 #endif 431 if ( fileName.isEmpty() ) 432 return false; 433 434 renderDocument( plot, fileName, sizeMM, resolution ); 435 436 return true; 437 } -
trunk/BNC/qwtpolar/qwt_polar_renderer.h
r4272 r8127 12 12 #include "qwt_polar_global.h" 13 13 #include <qobject.h> 14 #include <qsize.h> 14 15 15 16 class QwtPolarPlot; 16 class QSizeF;17 17 class QRectF; 18 18 class QPainter; … … 52 52 #endif 53 53 void renderTo( QwtPolarPlot *, QPrinter & ) const; 54 void renderTo( QwtPolarPlot *, QPaintDevice & p) const;54 void renderTo( QwtPolarPlot *, QPaintDevice & ) const; 55 55 56 56 virtual void render( QwtPolarPlot *, 57 57 QPainter *, const QRectF &rect ) const; 58 58 59 protected: 59 bool exportTo( QwtPolarPlot *, const QString &documentName, 60 const QSizeF &sizeMM = QSizeF( 200, 200 ), int resolution = 85 ); 61 60 62 virtual void renderTitle( QPainter *, const QRectF & ) const; 61 virtual void renderLegend( QPainter *, const QRectF & ) const;62 63 63 virtual void renderLegend Item( QPainter *,64 const Q Widget*, const QRectF & ) const;64 virtual void renderLegend( 65 const QwtPolarPlot *, QPainter *, const QRectF & ) const; 65 66 66 67 private: -
trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp
r4272 r8127 95 95 public: 96 96 PrivateData(): 97 data( NULL ), 98 renderThreadCount( 1 ) 97 data( NULL ) 99 98 { 100 99 colorMap = new QwtLinearColorMap(); … … 109 108 QwtRasterData *data; 110 109 QwtColorMap *colorMap; 111 112 uint renderThreadCount;113 110 114 111 QwtPolarSpectrogram::PaintAttributes paintAttributes; … … 223 220 { 224 221 return ( d_data->paintAttributes & attribute ); 225 }226 227 /*!228 Rendering an image from the raster data can often be done229 parallel on a multicore system.230 231 \param numThreads Number of threads to be used for rendering.232 If numThreads is set to 0, the system specific233 ideal thread count is used.234 235 The default thread count is 1 ( = no additional threads )236 237 \warning Rendering in multiple threads is only supported for Qt >= 4.4238 \sa renderThreadCount(), renderImage(), renderTile()239 */240 void QwtPolarSpectrogram::setRenderThreadCount( uint numThreads )241 {242 d_data->renderThreadCount = numThreads;243 }244 245 /*!246 \return Number of threads to be used for rendering.247 If numThreads is set to 0, the system specific248 ideal thread count is used.249 250 \warning Rendering in multiple threads is only supported for Qt >= 4.4251 \sa setRenderThreadCount(), renderImage(), renderTile()252 */253 uint QwtPolarSpectrogram::renderThreadCount() const254 {255 return d_data->renderThreadCount;256 222 } 257 223 … … 357 323 358 324 #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE) 359 uint numThreads = d_data->renderThreadCount;325 uint numThreads = renderThreadCount(); 360 326 361 327 if ( numThreads <= 0 ) -
trunk/BNC/qwtpolar/qwt_polar_spectrogram.h
r4272 r8127 60 60 bool testPaintAttribute( PaintAttribute ) const; 61 61 62 void setRenderThreadCount( uint numThreads );63 uint renderThreadCount() const;64 65 62 virtual int rtti() const; 66 63 -
trunk/BNC/qwtpolar/qwtpolar.pro
r5182 r8127 6 6 CONFIG += release 7 7 DEFINES += QWT_POLAR_NO_SVG 8 greaterThan(QT_MAJOR_VERSION, 4) { 9 QT += printsupport 10 QT += concurrent 11 } 8 12 9 13 INCLUDEPATH += ../qwt … … 45 49 qwt_polar_renderer.cpp \ 46 50 qwt_polar_plot.cpp 47
Note:
See TracChangeset
for help on using the changeset viewer.