Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_scale_widget.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_scale_widget.cpp
r4271 r8127 15 15 #include "qwt_scale_div.h" 16 16 #include "qwt_text.h" 17 #include "qwt_scale_engine.h" 17 18 #include <qpainter.h> 18 19 #include <qevent.h> … … 107 108 d_data->scaleDraw->setLength( 10 ); 108 109 110 d_data->scaleDraw->setScaleDiv( 111 QwtLinearScaleEngine().divideScale( 0.0, 100.0, 10, 5 ) ); 112 109 113 d_data->colorBar.colorMap = new QwtLinearColorMap(); 110 114 d_data->colorBar.isEnabled = false; … … 202 206 void QwtScaleWidget::setAlignment( QwtScaleDraw::Alignment alignment ) 203 207 { 208 if ( d_data->scaleDraw ) 209 d_data->scaleDraw->setAlignment( alignment ); 210 204 211 if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) ) 205 212 { … … 208 215 if ( d_data->scaleDraw->orientation() == Qt::Vertical ) 209 216 policy.transpose(); 217 210 218 setSizePolicy( policy ); 211 219 … … 213 221 } 214 222 215 if ( d_data->scaleDraw )216 d_data->scaleDraw->setAlignment( alignment );217 223 layoutScale(); 218 224 } … … 305 311 /*! 306 312 Set a scale draw 307 sd has to be created with new and will be deleted in 313 314 scaleDraw has to be created with new and will be deleted in 308 315 ~QwtScaleWidget() or the next call of setScaleDraw(). 309 310 \param sd ScaleDraw object 316 scaleDraw will be initialized with the attributes of 317 the previous scaleDraw object. 318 319 \param scaleDraw ScaleDraw object 311 320 \sa scaleDraw() 312 321 */ 313 void QwtScaleWidget::setScaleDraw( QwtScaleDraw *s d)314 { 315 if ( sd == NULL || sd == d_data->scaleDraw)322 void QwtScaleWidget::setScaleDraw( QwtScaleDraw *scaleDraw ) 323 { 324 if ( ( scaleDraw == NULL ) || ( scaleDraw == d_data->scaleDraw ) ) 316 325 return; 317 326 318 if ( d_data->scaleDraw ) 319 sd->setAlignment( d_data->scaleDraw->alignment() ); 327 const QwtScaleDraw* sd = d_data->scaleDraw; 328 if ( sd ) 329 { 330 scaleDraw->setAlignment( sd->alignment() ); 331 scaleDraw->setScaleDiv( sd->scaleDiv() ); 332 333 QwtTransform *transform = NULL; 334 if ( sd->scaleMap().transformation() ) 335 transform = sd->scaleMap().transformation()->copy(); 336 337 scaleDraw->setTransformation( transform ); 338 } 320 339 321 340 delete d_data->scaleDraw; 322 d_data->scaleDraw = s d;341 d_data->scaleDraw = scaleDraw; 323 342 324 343 layoutScale(); … … 326 345 327 346 /*! 328 scaleDraw of this scale347 \return scaleDraw of this scale 329 348 \sa setScaleDraw(), QwtScaleDraw::setScaleDraw() 330 349 */ … … 335 354 336 355 /*! 337 scaleDraw of this scale356 \return scaleDraw of this scale 338 357 \sa QwtScaleDraw::setScaleDraw() 339 358 */ … … 436 455 437 456 \param rect Bounding rectangle for all components of the scale 438 \return Recta bgle for the color bar457 \return Rectangle for the color bar 439 458 */ 440 459 QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const … … 490 509 491 510 /*! 492 Event handler for resize event 511 Event handler for resize events 493 512 \param event Resize event 494 513 */ … … 501 520 /*! 502 521 Recalculate the scale's geometry and layout based on 503 the current rectand fonts.522 the current geometry and fonts. 504 523 505 524 \param update_geometry Notify the layout system and call update … … 646 665 QwtText title = d_data->title; 647 666 title.setRenderFlags( flags ); 648 title.draw( painter, QRect ( 0,0, r.width(), r.height() ) );667 title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) ); 649 668 650 669 painter->restore(); … … 713 732 int QwtScaleWidget::titleHeightForWidth( int width ) const 714 733 { 715 return d_data->title.heightForWidth( width, font() );734 return qCeil( d_data->title.heightForWidth( width, font() ) ); 716 735 } 717 736 … … 749 768 is returned. 750 769 770 \param start Return parameter for the border width at 771 the beginning of the scale 772 \param end Return parameter for the border width at the 773 end of the scale 774 751 775 \warning 752 776 <ul> <li>The minimum border distance depends on the font.</ul> … … 784 808 the widget borders. 785 809 810 \param start Return parameter for the border width at 811 the beginning of the scale 812 \param end Return parameter for the border width at the 813 end of the scale 814 786 815 \sa setMinBorderDist(), getBorderDistHint() 787 816 */ … … 797 826 The scale division determines where to set the tick marks. 798 827 799 \param transformation Transformation, needed to translate between800 scale and pixal values801 828 \param scaleDiv Scale Division 802 829 \sa For more information about scale divisions, see QwtScaleDiv. 803 830 */ 804 void QwtScaleWidget::setScaleDiv( 805 QwtScaleTransformation *transformation, 806 const QwtScaleDiv &scaleDiv ) 831 void QwtScaleWidget::setScaleDiv( const QwtScaleDiv &scaleDiv ) 807 832 { 808 833 QwtScaleDraw *sd = d_data->scaleDraw; 809 if ( sd->scaleDiv() != scaleDiv || 810 sd->scaleMap().transformation()->type() != transformation->type() ) 811 { 812 sd->setTransformation( transformation ); 834 if ( sd->scaleDiv() != scaleDiv ) 835 { 813 836 sd->setScaleDiv( scaleDiv ); 814 837 layoutScale(); … … 816 839 Q_EMIT scaleDivChanged(); 817 840 } 818 else 819 { 820 /* 821 The transformation doesn't anything different as the 822 previous one. So we better throw it silently away instead of 823 initiating heavy updates 824 */ 825 826 delete transformation; 827 } 841 } 842 843 /*! 844 Set the transformation 845 846 \param transformation Transformation 847 \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap 848 */ 849 void QwtScaleWidget::setTransformation( QwtTransform *transformation ) 850 { 851 d_data->scaleDraw->setTransformation( transformation ); 852 layoutScale(); 828 853 } 829 854
Note:
See TracChangeset
for help on using the changeset viewer.