Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_dial.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (7 days ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_dial.cpp (modified) (42 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_dial.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 11 11 #include "qwt_dial_needle.h" 12 12 #include "qwt_math.h" 13 #include "qwt_scale_engine.h"14 13 #include "qwt_scale_map.h" 15 14 #include "qwt_round_scale_draw.h" 16 15 #include "qwt_painter.h" 16 #include "qwt.h" 17 17 18 #include <qpainter.h> 18 19 #include <qpalette.h> 19 20 #include <qpixmap.h> 20 21 #include <qevent.h> 21 #include <qalgorithms.h>22 #include <qmath.h>23 22 #include <qstyle.h> 24 23 #include <qstyleoption.h> 25 #include <qapplication.h>26 24 27 25 static inline double qwtAngleDist( double a1, double a2 ) … … 77 75 class QwtDial::PrivateData 78 76 { 79 public: 80 PrivateData() :81 frameShadow( Sunken ) ,82 lineWidth( 0 ) ,83 mode( RotateNeedle ) ,84 origin( 90.0 ) ,85 minScaleArc( 0.0 ) ,86 maxScaleArc( 0.0 ) ,87 needle( NULL ) ,88 arcOffset( 0.0 ) ,89 mouseOffset( 0.0 ) 77 public: 78 PrivateData() 79 : frameShadow( Sunken ) 80 , lineWidth( 0 ) 81 , mode( RotateNeedle ) 82 , origin( 90.0 ) 83 , minScaleArc( 0.0 ) 84 , maxScaleArc( 0.0 ) 85 , needle( NULL ) 86 , arcOffset( 0.0 ) 87 , mouseOffset( 0.0 ) 90 88 { 91 89 } … … 104 102 double maxScaleArc; 105 103 106 QwtDialNeedle *needle;104 QwtDialNeedle* needle; 107 105 108 106 double arcOffset; … … 113 111 114 112 /*! 115 \brief Constructor 116 \param parent Parent widget 117 118 Create a dial widget with no needle. The scale is initialized 119 to [ 0.0, 360.0 ] and 360 steps ( QwtAbstractSlider::setTotalSteps() ). 120 The origin of the scale is at 90°, 121 122 The value is set to 0.0. 123 124 The default mode is QwtDial::RotateNeedle. 125 */ 126 QwtDial::QwtDial( QWidget* parent ) :127 QwtAbstractSlider( parent ) 128 { 129 d_data = new PrivateData;113 \brief Constructor 114 \param parent Parent widget 115 116 Create a dial widget with no needle. The scale is initialized 117 to [ 0.0, 360.0 ] and 360 steps ( QwtAbstractSlider::setTotalSteps() ). 118 The origin of the scale is at 90°, 119 120 The value is set to 0.0. 121 122 The default mode is QwtDial::RotateNeedle. 123 */ 124 QwtDial::QwtDial( QWidget* parent ) 125 : QwtAbstractSlider( parent ) 126 { 127 m_data = new PrivateData; 130 128 131 129 setFocusPolicy( Qt::TabFocus ); … … 135 133 { 136 134 const QPalette::ColorGroup colorGroup = 137 static_cast<QPalette::ColorGroup>( i ); 135 static_cast< QPalette::ColorGroup >( i ); 138 136 139 137 // Base: background color of the circle inside the frame. … … 161 159 QwtDial::~QwtDial() 162 160 { 163 delete d_data;164 } 165 166 /*! 167 Sets the frame shadow value from the frame style. 168 169 \param shadow Frame shadow 170 \sa setLineWidth(), QFrame::setFrameShadow() 171 */ 161 delete m_data; 162 } 163 164 /*! 165 Sets the frame shadow value from the frame style. 166 167 \param shadow Frame shadow 168 \sa setLineWidth(), QFrame::setFrameShadow() 169 */ 172 170 void QwtDial::setFrameShadow( Shadow shadow ) 173 171 { 174 if ( shadow != d_data->frameShadow )172 if ( shadow != m_data->frameShadow ) 175 173 { 176 174 invalidateCache(); 177 175 178 d_data->frameShadow = shadow;176 m_data->frameShadow = shadow; 179 177 if ( lineWidth() > 0 ) 180 178 update(); … … 183 181 184 182 /*! 185 \return Frame shadow 186 /sa setFrameShadow(), lineWidth(), QFrame::frameShadow() 187 */ 183 \return Frame shadow 184 /sa setFrameShadow(), lineWidth(), QFrame::frameShadow() 185 */ 188 186 QwtDial::Shadow QwtDial::frameShadow() const 189 187 { 190 return d_data->frameShadow;191 } 192 193 /*! 194 Sets the line width of the frame 195 196 \param lineWidth Line width 197 \sa setFrameShadow() 198 */ 188 return m_data->frameShadow; 189 } 190 191 /*! 192 Sets the line width of the frame 193 194 \param lineWidth Line width 195 \sa setFrameShadow() 196 */ 199 197 void QwtDial::setLineWidth( int lineWidth ) 200 198 { … … 202 200 lineWidth = 0; 203 201 204 if ( d_data->lineWidth != lineWidth )202 if ( m_data->lineWidth != lineWidth ) 205 203 { 206 204 invalidateCache(); 207 205 208 d_data->lineWidth = lineWidth;206 m_data->lineWidth = lineWidth; 209 207 update(); 210 208 } … … 212 210 213 211 /*! 214 \return Line width of the frame 215 \sa setLineWidth(), frameShadow(), lineWidth() 216 */ 212 \return Line width of the frame 213 \sa setLineWidth(), frameShadow(), lineWidth() 214 */ 217 215 int QwtDial::lineWidth() const 218 216 { 219 return d_data->lineWidth;220 } 221 222 /*! 223 \return bounding rectangle of the circle inside the frame 224 \sa setLineWidth(), scaleInnerRect(), boundingRect() 225 */ 217 return m_data->lineWidth; 218 } 219 220 /*! 221 \return bounding rectangle of the circle inside the frame 222 \sa setLineWidth(), scaleInnerRect(), boundingRect() 223 */ 226 224 QRect QwtDial::innerRect() const 227 225 { … … 231 229 232 230 /*! 233 \return bounding rectangle of the dial including the frame 234 \sa setLineWidth(), scaleInnerRect(), innerRect() 235 */ 231 \return bounding rectangle of the dial including the frame 232 \sa setLineWidth(), scaleInnerRect(), innerRect() 233 */ 236 234 QRect QwtDial::boundingRect() const 237 235 { … … 247 245 248 246 /*! 249 \return rectangle inside the scale 250 \sa setLineWidth(), boundingRect(), innerRect() 251 */ 247 \return rectangle inside the scale 248 \sa setLineWidth(), boundingRect(), innerRect() 249 */ 252 250 QRect QwtDial::scaleInnerRect() const 253 251 { 254 252 QRect rect = innerRect(); 255 253 256 const QwtAbstractScaleDraw *sd = scaleDraw();254 const QwtAbstractScaleDraw* sd = scaleDraw(); 257 255 if ( sd ) 258 256 { 259 int scaleDist = qCeil( sd->extent( font() ) ); 257 int scaleDist = qwtCeil( sd->extent( font() ) ); 260 258 scaleDist++; // margin 261 259 … … 267 265 268 266 /*! 269 \brief Change the mode of the dial. 270 \param mode New mode 271 272 In case of QwtDial::RotateNeedle the needle is rotating, in case of 273 QwtDial::RotateScale, the needle points to origin() 274 and the scale is rotating. 275 276 The default mode is QwtDial::RotateNeedle. 277 278 \sa mode(), setValue(), setOrigin() 279 */ 267 \brief Change the mode of the dial. 268 \param mode New mode 269 270 In case of QwtDial::RotateNeedle the needle is rotating, in case of 271 QwtDial::RotateScale, the needle points to origin() 272 and the scale is rotating. 273 274 The default mode is QwtDial::RotateNeedle. 275 276 \sa mode(), setValue(), setOrigin() 277 */ 280 278 void QwtDial::setMode( Mode mode ) 281 279 { 282 if ( mode != d_data->mode )280 if ( mode != m_data->mode ) 283 281 { 284 282 invalidateCache(); 285 283 286 d_data->mode = mode;284 m_data->mode = mode; 287 285 sliderChange(); 288 286 } … … 290 288 291 289 /*! 292 \return Mode of the dial. 293 \sa setMode(), origin(), setScaleArc(), value() 294 */ 290 \return Mode of the dial. 291 \sa setMode(), origin(), setScaleArc(), value() 292 */ 295 293 QwtDial::Mode QwtDial::mode() const 296 294 { 297 return d_data->mode;298 } 299 300 /*! 301 Invalidate the internal caches used to speed up repainting 295 return m_data->mode; 296 } 297 298 /*! 299 Invalidate the internal caches used to speed up repainting 302 300 */ 303 301 void QwtDial::invalidateCache() 304 302 { 305 d_data->pixmapCache = QPixmap();303 m_data->pixmapCache = QPixmap(); 306 304 } 307 305 … … 309 307 Paint the dial 310 308 \param event Paint event 311 */ 312 void QwtDial::paintEvent( QPaintEvent *event )309 */ 310 void QwtDial::paintEvent( QPaintEvent* event ) 313 311 { 314 312 QPainter painter( this ); … … 316 314 317 315 QStyleOption opt; 318 opt.init(this); 316 opt.initFrom(this); 319 317 style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); 320 318 321 if ( d_data->mode == QwtDial::RotateScale )319 if ( m_data->mode == QwtDial::RotateScale ) 322 320 { 323 321 painter.save(); … … 330 328 331 329 const QRect r = contentsRect(); 332 if ( r.size() != d_data->pixmapCache.size() )333 { 334 d_data->pixmapCache = QwtPainter::backingStore( this, r.size() );335 d_data->pixmapCache.fill( Qt::transparent );336 337 QPainter p( & d_data->pixmapCache );330 if ( r.size() != m_data->pixmapCache.size() ) 331 { 332 m_data->pixmapCache = QwtPainter::backingStore( this, r.size() ); 333 m_data->pixmapCache.fill( Qt::transparent ); 334 335 QPainter p( &m_data->pixmapCache ); 338 336 p.setRenderHint( QPainter::Antialiasing, true ); 339 337 p.translate( -r.topLeft() ); 340 338 341 if ( d_data->mode != QwtDial::RotateScale )339 if ( m_data->mode != QwtDial::RotateScale ) 342 340 drawContents( &p ); 343 341 … … 345 343 drawFrame( &p ); 346 344 347 if ( d_data->mode != QwtDial::RotateNeedle )345 if ( m_data->mode != QwtDial::RotateNeedle ) 348 346 drawNeedle( &p ); 349 347 } 350 348 351 painter.drawPixmap( r.topLeft(), d_data->pixmapCache );352 353 if ( d_data->mode == QwtDial::RotateNeedle )349 painter.drawPixmap( r.topLeft(), m_data->pixmapCache ); 350 351 if ( m_data->mode == QwtDial::RotateNeedle ) 354 352 drawNeedle( &painter ); 355 353 … … 359 357 360 358 /*! 361 Draw the focus indicator 362 \param painter Painter 363 */ 364 void QwtDial::drawFocusIndicator( QPainter *painter ) const359 Draw the focus indicator 360 \param painter Painter 361 */ 362 void QwtDial::drawFocusIndicator( QPainter* painter ) const 365 363 { 366 364 QwtPainter::drawFocusRect( painter, this, boundingRect() ); … … 368 366 369 367 /*! 370 Draw the frame around the dial 371 372 \param painter Painter 373 \sa lineWidth(), frameShadow() 374 */ 375 void QwtDial::drawFrame( QPainter *painter )368 Draw the frame around the dial 369 370 \param painter Painter 371 \sa lineWidth(), frameShadow() 372 */ 373 void QwtDial::drawFrame( QPainter* painter ) 376 374 { 377 375 QwtPainter::drawRoundFrame( painter, boundingRect(), 378 palette(), lineWidth(), d_data->frameShadow );379 } 380 381 /*! 382 \brief Draw the contents inside the frame 383 384 QPalette::Window is the background color outside of the frame. 385 QPalette::Base is the background color inside the frame. 386 QPalette::WindowText is the background color inside the scale. 387 388 \param painter Painter 389 390 \sa boundingRect(), innerRect(), 376 palette(), lineWidth(), m_data->frameShadow ); 377 } 378 379 /*! 380 \brief Draw the contents inside the frame 381 382 QPalette::Window is the background color outside of the frame. 383 QPalette::Base is the background color inside the frame. 384 QPalette::WindowText is the background color inside the scale. 385 386 \param painter Painter 387 388 \sa boundingRect(), innerRect(), 391 389 scaleInnerRect(), QWidget::setPalette() 392 */ 393 void QwtDial::drawContents( QPainter *painter ) const390 */ 391 void QwtDial::drawContents( QPainter* painter ) const 394 392 { 395 393 if ( testAttribute( Qt::WA_NoSystemBackground ) || 396 394 palette().brush( QPalette::Base ) != 397 palette().brush( QPalette::Window ) )395 palette().brush( QPalette::Window ) ) 398 396 { 399 397 const QRectF br = boundingRect(); … … 408 406 const QRectF insideScaleRect = scaleInnerRect(); 409 407 if ( palette().brush( QPalette::WindowText ) != 410 palette().brush( QPalette::Base ) )408 palette().brush( QPalette::Base ) ) 411 409 { 412 410 painter->save(); … … 430 428 431 429 /*! 432 Draw the needle 433 434 \param painter Painter 435 \param center Center of the dial 436 \param radius Length for the needle 437 \param direction Direction of the needle in degrees, counter clockwise 438 \param colorGroup ColorGroup 439 */ 440 void QwtDial::drawNeedle( QPainter *painter, const QPointF¢er,430 Draw the needle 431 432 \param painter Painter 433 \param center Center of the dial 434 \param radius Length for the needle 435 \param direction Direction of the needle in degrees, counter clockwise 436 \param colorGroup ColorGroup 437 */ 438 void QwtDial::drawNeedle( QPainter* painter, const QPointF& center, 441 439 double radius, double direction, QPalette::ColorGroup colorGroup ) const 442 440 { 443 if ( d_data->needle )441 if ( m_data->needle ) 444 442 { 445 443 direction = 360.0 - direction; // counter clockwise 446 d_data->needle->draw( painter, center, radius, direction, colorGroup );447 } 448 } 449 450 void QwtDial::drawNeedle( QPainter *painter ) const444 m_data->needle->draw( painter, center, radius, direction, colorGroup ); 445 } 446 } 447 448 void QwtDial::drawNeedle( QPainter* painter ) const 451 449 { 452 450 if ( !isValid() ) … … 469 467 470 468 /*! 471 Draw the scale 472 473 \param painter Painter 474 \param center Center of the dial 475 \param radius Radius of the scale 476 */ 477 void QwtDial::drawScale( QPainter *painter,478 const QPointF ¢er, double radius ) const479 { 480 QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw*>( scaleDraw() );469 Draw the scale 470 471 \param painter Painter 472 \param center Center of the dial 473 \param radius Radius of the scale 474 */ 475 void QwtDial::drawScale( QPainter* painter, 476 const QPointF& center, double radius ) const 477 { 478 QwtRoundScaleDraw* sd = const_cast< QwtRoundScaleDraw* >( scaleDraw() ); 481 479 if ( sd == NULL ) 482 480 return; … … 491 489 492 490 painter->setFont( font() ); 493 painter->setPen( QPen( textColor, sd->penWidth() ) ); 491 painter->setPen( QPen( textColor, sd->penWidthF() ) ); 494 492 495 493 painter->setBrush( Qt::red ); … … 498 496 499 497 /*! 500 Draw the contents inside the scale 501 502 Paints nothing. 503 504 \param painter Painter 505 \param center Center of the contents circle 506 \param radius Radius of the contents circle 507 */ 508 void QwtDial::drawScaleContents( QPainter *painter,509 const QPointF ¢er, double radius ) const498 Draw the contents inside the scale 499 500 Paints nothing. 501 502 \param painter Painter 503 \param center Center of the contents circle 504 \param radius Radius of the contents circle 505 */ 506 void QwtDial::drawScaleContents( QPainter* painter, 507 const QPointF& center, double radius ) const 510 508 { 511 509 Q_UNUSED(painter); … … 515 513 516 514 /*! 517 Set a needle for the dial 518 519 \param needle Needle 520 521 \warning The needle will be deleted, when a different needle is 515 Set a needle for the dial 516 517 \param needle Needle 518 519 \warning The needle will be deleted, when a different needle is 522 520 set or in ~QwtDial() 523 */ 524 void QwtDial::setNeedle( QwtDialNeedle *needle )525 { 526 if ( needle != d_data->needle )527 { 528 if ( d_data->needle )529 delete d_data->needle;530 531 d_data->needle = needle;521 */ 522 void QwtDial::setNeedle( QwtDialNeedle* needle ) 523 { 524 if ( needle != m_data->needle ) 525 { 526 if ( m_data->needle ) 527 delete m_data->needle; 528 529 m_data->needle = needle; 532 530 update(); 533 531 } … … 535 533 536 534 /*! 537 \return needle 538 \sa setNeedle() 539 */ 540 const QwtDialNeedle *QwtDial::needle() const541 { 542 return d_data->needle;543 } 544 545 /*! 546 \return needle 547 \sa setNeedle() 548 */ 549 QwtDialNeedle *QwtDial::needle()550 { 551 return d_data->needle;535 \return needle 536 \sa setNeedle() 537 */ 538 const QwtDialNeedle* QwtDial::needle() const 539 { 540 return m_data->needle; 541 } 542 543 /*! 544 \return needle 545 \sa setNeedle() 546 */ 547 QwtDialNeedle* QwtDial::needle() 548 { 549 return m_data->needle; 552 550 } 553 551 554 552 //! \return the scale draw 555 QwtRoundScaleDraw *QwtDial::scaleDraw()556 { 557 return static_cast<QwtRoundScaleDraw *>( abstractScaleDraw() );553 QwtRoundScaleDraw* QwtDial::scaleDraw() 554 { 555 return static_cast< QwtRoundScaleDraw* >( abstractScaleDraw() ); 558 556 } 559 557 560 558 //! \return the scale draw 561 const QwtRoundScaleDraw *QwtDial::scaleDraw() const562 { 563 return static_cast<const QwtRoundScaleDraw *>( abstractScaleDraw() );564 } 565 566 /*! 567 Set an individual scale draw 568 569 The motivation for setting a scale draw is often 570 to overload QwtRoundScaleDraw::label() to return 571 individual tick labels. 572 573 \param scaleDraw Scale draw 574 \warning The previous scale draw is deleted 575 */ 576 void QwtDial::setScaleDraw( QwtRoundScaleDraw *scaleDraw )559 const QwtRoundScaleDraw* QwtDial::scaleDraw() const 560 { 561 return static_cast< const QwtRoundScaleDraw* >( abstractScaleDraw() ); 562 } 563 564 /*! 565 Set an individual scale draw 566 567 The motivation for setting a scale draw is often 568 to overload QwtRoundScaleDraw::label() to return 569 individual tick labels. 570 571 \param scaleDraw Scale draw 572 \warning The previous scale draw is deleted 573 */ 574 void QwtDial::setScaleDraw( QwtRoundScaleDraw* scaleDraw ) 577 575 { 578 576 setAbstractScaleDraw( scaleDraw ); … … 581 579 582 580 /*! 583 Change the arc of the scale 584 585 \param minArc Lower limit 586 \param maxArc Upper limit 587 588 \sa minScaleArc(), maxScaleArc() 589 */ 581 Change the arc of the scale 582 583 \param minArc Lower limit 584 \param maxArc Upper limit 585 586 \sa minScaleArc(), maxScaleArc() 587 */ 590 588 void QwtDial::setScaleArc( double minArc, double maxArc ) 591 589 { 592 590 if ( minArc != 360.0 && minArc != -360.0 ) 593 minArc = ::fmod( minArc, 360.0 ); 591 minArc = std::fmod( minArc, 360.0 ); 594 592 if ( maxArc != 360.0 && maxArc != -360.0 ) 595 maxArc = ::fmod( maxArc, 360.0 ); 596 597 double minScaleArc = q Min( minArc, maxArc );598 double maxScaleArc = q Max( minArc, maxArc );593 maxArc = std::fmod( maxArc, 360.0 ); 594 595 double minScaleArc = qwtMinF( minArc, maxArc ); 596 double maxScaleArc = qwtMaxF( minArc, maxArc ); 599 597 600 598 if ( maxScaleArc - minScaleArc > 360.0 ) 601 599 maxScaleArc = minScaleArc + 360.0; 602 600 603 if ( ( minScaleArc != d_data->minScaleArc ) ||604 ( maxScaleArc != d_data->maxScaleArc ) )605 { 606 d_data->minScaleArc = minScaleArc;607 d_data->maxScaleArc = maxScaleArc;601 if ( ( minScaleArc != m_data->minScaleArc ) || 602 ( maxScaleArc != m_data->maxScaleArc ) ) 603 { 604 m_data->minScaleArc = minScaleArc; 605 m_data->maxScaleArc = maxScaleArc; 608 606 609 607 invalidateCache(); … … 613 611 614 612 /*! 615 Set the lower limit for the scale arc 616 617 \param min Lower limit of the scale arc 618 \sa setScaleArc(), setMaxScaleArc() 613 Set the lower limit for the scale arc 614 615 \param min Lower limit of the scale arc 616 \sa setScaleArc(), setMaxScaleArc() 619 617 */ 620 618 void QwtDial::setMinScaleArc( double min ) 621 619 { 622 setScaleArc( min, d_data->maxScaleArc );623 } 624 625 /*! 626 \return Lower limit of the scale arc 627 \sa setScaleArc() 628 */ 620 setScaleArc( min, m_data->maxScaleArc ); 621 } 622 623 /*! 624 \return Lower limit of the scale arc 625 \sa setScaleArc() 626 */ 629 627 double QwtDial::minScaleArc() const 630 628 { 631 return d_data->minScaleArc;632 } 633 634 /*! 635 Set the upper limit for the scale arc 636 637 \param max Upper limit of the scale arc 638 \sa setScaleArc(), setMinScaleArc() 629 return m_data->minScaleArc; 630 } 631 632 /*! 633 Set the upper limit for the scale arc 634 635 \param max Upper limit of the scale arc 636 \sa setScaleArc(), setMinScaleArc() 639 637 */ 640 638 void QwtDial::setMaxScaleArc( double max ) 641 639 { 642 setScaleArc( d_data->minScaleArc, max );643 } 644 645 /*! 646 \return Upper limit of the scale arc 647 \sa setScaleArc() 648 */ 640 setScaleArc( m_data->minScaleArc, max ); 641 } 642 643 /*! 644 \return Upper limit of the scale arc 645 \sa setScaleArc() 646 */ 649 647 double QwtDial::maxScaleArc() const 650 648 { 651 return d_data->maxScaleArc;652 } 653 654 /*! 655 \brief Change the origin 656 657 The origin is the angle where scale and needle is relative to. 658 659 \param origin New origin 660 \sa origin() 661 */ 649 return m_data->maxScaleArc; 650 } 651 652 /*! 653 \brief Change the origin 654 655 The origin is the angle where scale and needle is relative to. 656 657 \param origin New origin 658 \sa origin() 659 */ 662 660 void QwtDial::setOrigin( double origin ) 663 661 { 664 662 invalidateCache(); 665 663 666 d_data->origin = origin;664 m_data->origin = origin; 667 665 sliderChange(); 668 666 } 669 667 670 668 /*! 671 The origin is the angle where scale and needle is relative to. 672 673 \return Origin of the dial 674 \sa setOrigin() 675 */ 669 The origin is the angle where scale and needle is relative to. 670 671 \return Origin of the dial 672 \sa setOrigin() 673 */ 676 674 double QwtDial::origin() const 677 675 { 678 return d_data->origin;679 } 680 681 /*! 682 \return Size hint 683 \sa minimumSizeHint() 684 */ 676 return m_data->origin; 677 } 678 679 /*! 680 \return Size hint 681 \sa minimumSizeHint() 682 */ 685 683 QSize QwtDial::sizeHint() const 686 684 { 687 685 int sh = 0; 688 686 if ( scaleDraw() ) 689 sh = qCeil( scaleDraw()->extent( font() ) ); 687 sh = qwtCeil( scaleDraw()->extent( font() ) ); 690 688 691 689 const int d = 6 * sh + 2 * lineWidth(); … … 693 691 QSize hint( d, d ); 694 692 if ( !isReadOnly() ) 695 hint = hint.expandedTo( QApplication::globalStrut());693 hint = qwtExpandedToGlobalStrut( hint ); 696 694 697 695 return hint; … … 699 697 700 698 /*! 701 \return Minimum size hint 702 \sa sizeHint() 703 */ 699 \return Minimum size hint 700 \sa sizeHint() 701 */ 704 702 QSize QwtDial::minimumSizeHint() const 705 703 { 706 704 int sh = 0; 707 705 if ( scaleDraw() ) 708 sh = qCeil( scaleDraw()->extent( font() ) ); 706 sh = qwtCeil( scaleDraw()->extent( font() ) ); 709 707 710 708 const int d = 3 * sh + 2 * lineWidth(); … … 714 712 715 713 /*! 716 \brief Determine what to do when the user presses a mouse button. 717 718 \param pos Mouse position 719 720 \retval True, when the inner circle contains pos 721 \sa scrolledTo() 722 */ 723 bool QwtDial::isScrollPosition( const QPoint &pos ) const714 \brief Determine what to do when the user presses a mouse button. 715 716 \param pos Mouse position 717 718 \retval True, when the inner circle contains pos 719 \sa scrolledTo() 720 */ 721 bool QwtDial::isScrollPosition( const QPoint& pos ) const 724 722 { 725 723 const QRegion region( innerRect(), QRegion::Ellipse ); … … 727 725 { 728 726 double angle = QLineF( rect().center(), pos ).angle(); 729 if ( d_data->mode == QwtDial::RotateScale )727 if ( m_data->mode == QwtDial::RotateScale ) 730 728 angle = 360.0 - angle; 731 729 … … 733 731 qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) ); 734 732 735 d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle );736 d_data->arcOffset = scaleMap().p1();733 m_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle ); 734 m_data->arcOffset = scaleMap().p1(); 737 735 738 736 return true; … … 743 741 744 742 /*! 745 \brief Determine the value for a new position of the 743 \brief Determine the value for a new position of the 746 744 slider handle. 747 745 748 \param pos Mouse position 749 750 \return Value for the mouse position 751 \sa isScrollPosition() 752 */ 753 double QwtDial::scrolledTo( const QPoint &pos ) const746 \param pos Mouse position 747 748 \return Value for the mouse position 749 \sa isScrollPosition() 750 */ 751 double QwtDial::scrolledTo( const QPoint& pos ) const 754 752 { 755 753 double angle = QLineF( rect().center(), pos ).angle(); 756 if ( d_data->mode == QwtDial::RotateScale )757 { 758 angle += scaleMap().p1() - d_data->arcOffset;754 if ( m_data->mode == QwtDial::RotateScale ) 755 { 756 angle += scaleMap().p1() - m_data->arcOffset; 759 757 angle = 360.0 - angle; 760 758 } 761 759 762 angle = qwtNormalizeDegrees( angle - d_data->mouseOffset );760 angle = qwtNormalizeDegrees( angle - m_data->mouseOffset ); 763 761 angle = qwtNormalizeDegrees( 90.0 - angle ); 764 762 … … 779 777 } 780 778 781 d_data->mouseOffset += ( boundedAngle - angle );779 m_data->mouseOffset += ( boundedAngle - angle ); 782 780 783 781 angle = boundedAngle; … … 790 788 791 789 if ( !wrapping() ) 792 d_data->mouseOffset += ( boundedAngle - angle );790 m_data->mouseOffset += ( boundedAngle - angle ); 793 791 794 792 angle = boundedAngle; … … 799 797 800 798 /*! 801 Change Event handler 802 \param event Change event 803 804 Invalidates internal paint caches if necessary 805 */ 806 void QwtDial::changeEvent( QEvent *event )799 Change Event handler 800 \param event Change event 801 802 Invalidates internal paint caches if necessary 803 */ 804 void QwtDial::changeEvent( QEvent* event ) 807 805 { 808 806 switch( event->type() ) … … 826 824 827 825 /*! 828 Wheel Event handler 829 \param event Wheel event 830 */ 831 void QwtDial::wheelEvent( QWheelEvent *event ) 832 { 826 Wheel Event handler 827 \param event Wheel event 828 */ 829 void QwtDial::wheelEvent( QWheelEvent* event ) 830 { 831 #if QT_VERSION < 0x050e00 832 const QPoint wheelPos = event->pos(); 833 #else 834 const QPoint wheelPos = event->position().toPoint(); 835 #endif 836 833 837 const QRegion region( innerRect(), QRegion::Ellipse ); 834 if ( region.contains( event->pos()) )838 if ( region.contains( wheelPos ) ) 835 839 QwtAbstractSlider::wheelEvent( event ); 836 840 } … … 838 842 void QwtDial::setAngleRange( double angle, double span ) 839 843 { 840 QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() ); 841 if ( sd ) 844 if ( QwtRoundScaleDraw* sd = scaleDraw() ) 842 845 { 843 846 angle = qwtNormalizeDegrees( angle - 270.0 ); … … 847 850 848 851 /*! 849 Invalidate the internal caches and call 850 QwtAbstractSlider::scaleChange() 852 Invalidate the internal caches and call 853 QwtAbstractSlider::scaleChange() 851 854 */ 852 855 void QwtDial::scaleChange() … … 858 861 void QwtDial::sliderChange() 859 862 { 860 setAngleRange( d_data->origin +d_data->minScaleArc,861 d_data->maxScaleArc -d_data->minScaleArc );863 setAngleRange( m_data->origin + m_data->minScaleArc, 864 m_data->maxScaleArc - m_data->minScaleArc ); 862 865 863 866 if ( mode() == RotateScale ) 864 867 { 865 868 const double arc = scaleMap().transform( value() ) - scaleMap().p1(); 866 setAngleRange( d_data->origin - arc,867 d_data->maxScaleArc -d_data->minScaleArc );869 setAngleRange( m_data->origin - arc, 870 m_data->maxScaleArc - m_data->minScaleArc ); 868 871 } 869 872 870 873 QwtAbstractSlider::sliderChange(); 871 874 } 875 876 #include "moc_qwt_dial.cpp"
Note:
See TracChangeset
for help on using the changeset viewer.
