Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_dial.cpp


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (7 days ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_dial.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1111#include "qwt_dial_needle.h"
    1212#include "qwt_math.h"
    13 #include "qwt_scale_engine.h"
    1413#include "qwt_scale_map.h"
    1514#include "qwt_round_scale_draw.h"
    1615#include "qwt_painter.h"
     16#include "qwt.h"
     17
    1718#include <qpainter.h>
    1819#include <qpalette.h>
    1920#include <qpixmap.h>
    2021#include <qevent.h>
    21 #include <qalgorithms.h>
    22 #include <qmath.h>
    2322#include <qstyle.h>
    2423#include <qstyleoption.h>
    25 #include <qapplication.h>
    2624
    2725static inline double qwtAngleDist( double a1, double a2 )
    … …  
    7775class QwtDial::PrivateData
    7876{
    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 )
    9088    {
    9189    }
    … …  
    104102    double maxScaleArc;
    105103
    106     QwtDialNeedle *needle;
     104    QwtDialNeedle* needle;
    107105
    108106    double arcOffset;
    … …  
    113111
    114112/*!
    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 */
     124QwtDial::QwtDial( QWidget* parent )
     125    : QwtAbstractSlider( parent )
     126{
     127    m_data = new PrivateData;
    130128
    131129    setFocusPolicy( Qt::TabFocus );
    … …  
    135133    {
    136134        const QPalette::ColorGroup colorGroup =
    137             static_cast<QPalette::ColorGroup>( i );
     135            static_cast< QPalette::ColorGroup >( i );
    138136
    139137        // Base: background color of the circle inside the frame.
    … …  
    161159QwtDial::~QwtDial()
    162160{
    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 */
    172170void QwtDial::setFrameShadow( Shadow shadow )
    173171{
    174     if ( shadow != d_data->frameShadow )
     172    if ( shadow != m_data->frameShadow )
    175173    {
    176174        invalidateCache();
    177175
    178         d_data->frameShadow = shadow;
     176        m_data->frameShadow = shadow;
    179177        if ( lineWidth() > 0 )
    180178            update();
    … …  
    183181
    184182/*!
    185   \return Frame shadow
    186   /sa setFrameShadow(), lineWidth(), QFrame::frameShadow()
    187 */
     183   \return Frame shadow
     184   /sa setFrameShadow(), lineWidth(), QFrame::frameShadow()
     185 */
    188186QwtDial::Shadow QwtDial::frameShadow() const
    189187{
    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 */
    199197void QwtDial::setLineWidth( int lineWidth )
    200198{
    … …  
    202200        lineWidth = 0;
    203201
    204     if ( d_data->lineWidth != lineWidth )
     202    if ( m_data->lineWidth != lineWidth )
    205203    {
    206204        invalidateCache();
    207205
    208         d_data->lineWidth = lineWidth;
     206        m_data->lineWidth = lineWidth;
    209207        update();
    210208    }
    … …  
    212210
    213211/*!
    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 */
    217215int QwtDial::lineWidth() const
    218216{
    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 */
    226224QRect QwtDial::innerRect() const
    227225{
    … …  
    231229
    232230/*!
    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 */
    236234QRect QwtDial::boundingRect() const
    237235{
    … …  
    247245
    248246/*!
    249   \return rectangle inside the scale
    250   \sa setLineWidth(), boundingRect(), innerRect()
    251 */
     247   \return rectangle inside the scale
     248   \sa setLineWidth(), boundingRect(), innerRect()
     249 */
    252250QRect QwtDial::scaleInnerRect() const
    253251{
    254252    QRect rect = innerRect();
    255253
    256     const QwtAbstractScaleDraw *sd = scaleDraw();
     254    const QwtAbstractScaleDraw* sd = scaleDraw();
    257255    if ( sd )
    258256    {
    259         int scaleDist = qCeil( sd->extent( font() ) );
     257        int scaleDist = qwtCeil( sd->extent( font() ) );
    260258        scaleDist++; // margin
    261259
    … …  
    267265
    268266/*!
    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 */
    280278void QwtDial::setMode( Mode mode )
    281279{
    282     if ( mode != d_data->mode )
     280    if ( mode != m_data->mode )
    283281    {
    284282        invalidateCache();
    285283
    286         d_data->mode = mode;
     284        m_data->mode = mode;
    287285        sliderChange();
    288286    }
    … …  
    290288
    291289/*!
    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 */
    295293QwtDial::Mode QwtDial::mode() const
    296294{
    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
    302300 */
    303301void QwtDial::invalidateCache()
    304302{
    305     d_data->pixmapCache = QPixmap();
     303    m_data->pixmapCache = QPixmap();
    306304}
    307305
    … …  
    309307   Paint the dial
    310308   \param event Paint event
    311 */
    312 void QwtDial::paintEvent( QPaintEvent *event )
     309 */
     310void QwtDial::paintEvent( QPaintEvent* event )
    313311{
    314312    QPainter painter( this );
    … …  
    316314
    317315    QStyleOption opt;
    318     opt.init(this);
     316    opt.initFrom(this);
    319317    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
    320318
    321     if ( d_data->mode == QwtDial::RotateScale )
     319    if ( m_data->mode == QwtDial::RotateScale )
    322320    {
    323321        painter.save();
    … …  
    330328
    331329    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 );
    338336        p.setRenderHint( QPainter::Antialiasing, true );
    339337        p.translate( -r.topLeft() );
    340338
    341         if ( d_data->mode != QwtDial::RotateScale )
     339        if ( m_data->mode != QwtDial::RotateScale )
    342340            drawContents( &p );
    343341
    … …  
    345343            drawFrame( &p );
    346344
    347         if ( d_data->mode != QwtDial::RotateNeedle )
     345        if ( m_data->mode != QwtDial::RotateNeedle )
    348346            drawNeedle( &p );
    349347    }
    350348
    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 )
    354352        drawNeedle( &painter );
    355353
    … …  
    359357
    360358/*!
    361   Draw the focus indicator
    362   \param painter Painter
    363 */
    364 void QwtDial::drawFocusIndicator( QPainter *painter ) const
     359   Draw the focus indicator
     360   \param painter Painter
     361 */
     362void QwtDial::drawFocusIndicator( QPainter* painter ) const
    365363{
    366364    QwtPainter::drawFocusRect( painter, this, boundingRect() );
    … …  
    368366
    369367/*!
    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 */
     373void QwtDial::drawFrame( QPainter* painter )
    376374{
    377375    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(),
    391389    scaleInnerRect(), QWidget::setPalette()
    392 */
    393 void QwtDial::drawContents( QPainter *painter ) const
     390 */
     391void QwtDial::drawContents( QPainter* painter ) const
    394392{
    395393    if ( testAttribute( Qt::WA_NoSystemBackground ) ||
    396394        palette().brush( QPalette::Base ) !=
    397             palette().brush( QPalette::Window ) )
     395        palette().brush( QPalette::Window ) )
    398396    {
    399397        const QRectF br = boundingRect();
    … …  
    408406    const QRectF insideScaleRect = scaleInnerRect();
    409407    if ( palette().brush( QPalette::WindowText ) !=
    410             palette().brush( QPalette::Base ) )
     408        palette().brush( QPalette::Base ) )
    411409    {
    412410        painter->save();
    … …  
    430428
    431429/*!
    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 &center,
     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 */
     438void QwtDial::drawNeedle( QPainter* painter, const QPointF& center,
    441439    double radius, double direction, QPalette::ColorGroup colorGroup ) const
    442440{
    443     if ( d_data->needle )
     441    if ( m_data->needle )
    444442    {
    445443        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 ) const
     444        m_data->needle->draw( painter, center, radius, direction, colorGroup );
     445    }
     446}
     447
     448void QwtDial::drawNeedle( QPainter* painter ) const
    451449{
    452450    if ( !isValid() )
    … …  
    469467
    470468/*!
    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 &center, double radius ) const
    479 {
    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 */
     475void QwtDial::drawScale( QPainter* painter,
     476    const QPointF& center, double radius ) const
     477{
     478    QwtRoundScaleDraw* sd = const_cast< QwtRoundScaleDraw* >( scaleDraw() );
    481479    if ( sd == NULL )
    482480        return;
    … …  
    491489
    492490    painter->setFont( font() );
    493     painter->setPen( QPen( textColor, sd->penWidth() ) );
     491    painter->setPen( QPen( textColor, sd->penWidthF() ) );
    494492
    495493    painter->setBrush( Qt::red );
    … …  
    498496
    499497/*!
    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 &center, double radius ) const
     498   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 */
     506void QwtDial::drawScaleContents( QPainter* painter,
     507    const QPointF& center, double radius ) const
    510508{
    511509    Q_UNUSED(painter);
    … …  
    515513
    516514/*!
    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
    522520           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 */
     522void 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;
    532530        update();
    533531    }
    … …  
    535533
    536534/*!
    537   \return needle
    538   \sa setNeedle()
    539 */
    540 const QwtDialNeedle *QwtDial::needle() const
    541 {
    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 */
     538const QwtDialNeedle* QwtDial::needle() const
     539{
     540    return m_data->needle;
     541}
     542
     543/*!
     544   \return needle
     545   \sa setNeedle()
     546 */
     547QwtDialNeedle* QwtDial::needle()
     548{
     549    return m_data->needle;
    552550}
    553551
    554552//! \return the scale draw
    555 QwtRoundScaleDraw *QwtDial::scaleDraw()
    556 {
    557     return static_cast<QwtRoundScaleDraw *>( abstractScaleDraw() );
     553QwtRoundScaleDraw* QwtDial::scaleDraw()
     554{
     555    return static_cast< QwtRoundScaleDraw* >( abstractScaleDraw() );
    558556}
    559557
    560558//! \return the scale draw
    561 const QwtRoundScaleDraw *QwtDial::scaleDraw() const
    562 {
    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 )
     559const 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 */
     574void QwtDial::setScaleDraw( QwtRoundScaleDraw* scaleDraw )
    577575{
    578576    setAbstractScaleDraw( scaleDraw );
    … …  
    581579
    582580/*!
    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 */
    590588void QwtDial::setScaleArc( double minArc, double maxArc )
    591589{
    592590    if ( minArc != 360.0 && minArc != -360.0 )
    593         minArc = ::fmod( minArc, 360.0 );
     591        minArc = std::fmod( minArc, 360.0 );
    594592    if ( maxArc != 360.0 && maxArc != -360.0 )
    595         maxArc = ::fmod( maxArc, 360.0 );
    596 
    597     double minScaleArc = qMin( minArc, maxArc );
    598     double maxScaleArc = qMax( minArc, maxArc );
     593        maxArc = std::fmod( maxArc, 360.0 );
     594
     595    double minScaleArc = qwtMinF( minArc, maxArc );
     596    double maxScaleArc = qwtMaxF( minArc, maxArc );
    599597
    600598    if ( maxScaleArc - minScaleArc > 360.0 )
    601599        maxScaleArc = minScaleArc + 360.0;
    602600
    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;
    608606
    609607        invalidateCache();
    … …  
    613611
    614612/*!
    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()
    619617 */
    620618void QwtDial::setMinScaleArc( double min )
    621619{
    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 */
    629627double QwtDial::minScaleArc() const
    630628{
    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()
    639637 */
    640638void QwtDial::setMaxScaleArc( double max )
    641639{
    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 */
    649647double QwtDial::maxScaleArc() const
    650648{
    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 */
    662660void QwtDial::setOrigin( double origin )
    663661{
    664662    invalidateCache();
    665663
    666     d_data->origin = origin;
     664    m_data->origin = origin;
    667665    sliderChange();
    668666}
    669667
    670668/*!
    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 */
    676674double QwtDial::origin() const
    677675{
    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 */
    685683QSize QwtDial::sizeHint() const
    686684{
    687685    int sh = 0;
    688686    if ( scaleDraw() )
    689         sh = qCeil( scaleDraw()->extent( font() ) );
     687        sh = qwtCeil( scaleDraw()->extent( font() ) );
    690688
    691689    const int d = 6 * sh + 2 * lineWidth();
    … …  
    693691    QSize hint( d, d );
    694692    if ( !isReadOnly() )
    695         hint = hint.expandedTo( QApplication::globalStrut() );
     693        hint = qwtExpandedToGlobalStrut( hint );
    696694
    697695    return hint;
    … …  
    699697
    700698/*!
    701   \return Minimum size hint
    702   \sa sizeHint()
    703 */
     699   \return Minimum size hint
     700   \sa sizeHint()
     701 */
    704702QSize QwtDial::minimumSizeHint() const
    705703{
    706704    int sh = 0;
    707705    if ( scaleDraw() )
    708         sh = qCeil( scaleDraw()->extent( font() ) );
     706        sh = qwtCeil( scaleDraw()->extent( font() ) );
    709707
    710708    const int d = 3 * sh + 2 * lineWidth();
    … …  
    714712
    715713/*!
    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 ) const
     714   \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 */
     721bool QwtDial::isScrollPosition( const QPoint& pos ) const
    724722{
    725723    const QRegion region( innerRect(), QRegion::Ellipse );
    … …  
    727725    {
    728726        double angle = QLineF( rect().center(), pos ).angle();
    729         if ( d_data->mode == QwtDial::RotateScale )
     727        if ( m_data->mode == QwtDial::RotateScale )
    730728            angle = 360.0 - angle;
    731729
    … …  
    733731            qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) );
    734732
    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();
    737735
    738736        return true;
    … …  
    743741
    744742/*!
    745   \brief Determine the value for a new position of the
     743   \brief Determine the value for a new position of the
    746744         slider handle.
    747745
    748   \param pos Mouse position
    749 
    750   \return Value for the mouse position
    751   \sa isScrollPosition()
    752 */
    753 double QwtDial::scrolledTo( const QPoint &pos ) const
     746   \param pos Mouse position
     747
     748   \return Value for the mouse position
     749   \sa isScrollPosition()
     750 */
     751double QwtDial::scrolledTo( const QPoint& pos ) const
    754752{
    755753    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;
    759757        angle = 360.0 - angle;
    760758    }
    761759
    762     angle = qwtNormalizeDegrees( angle - d_data->mouseOffset );
     760    angle = qwtNormalizeDegrees( angle - m_data->mouseOffset );
    763761    angle = qwtNormalizeDegrees( 90.0 - angle );
    764762
    … …  
    779777            }
    780778
    781             d_data->mouseOffset += ( boundedAngle - angle );
     779            m_data->mouseOffset += ( boundedAngle - angle );
    782780
    783781            angle = boundedAngle;
    … …  
    790788
    791789        if ( !wrapping() )
    792             d_data->mouseOffset += ( boundedAngle - angle );
     790            m_data->mouseOffset += ( boundedAngle - angle );
    793791
    794792        angle = boundedAngle;
    … …  
    799797
    800798/*!
    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 */
     804void QwtDial::changeEvent( QEvent* event )
    807805{
    808806    switch( event->type() )
    … …  
    826824
    827825/*!
    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 */
     829void 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
    833837    const QRegion region( innerRect(), QRegion::Ellipse );
    834     if ( region.contains( event->pos() ) )
     838    if ( region.contains( wheelPos ) )
    835839        QwtAbstractSlider::wheelEvent( event );
    836840}
    … …  
    838842void QwtDial::setAngleRange( double angle, double span )
    839843{
    840     QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() );
    841     if ( sd  )
     844    if ( QwtRoundScaleDraw* sd = scaleDraw() )
    842845    {
    843846        angle = qwtNormalizeDegrees( angle - 270.0 );
    … …  
    847850
    848851/*!
    849   Invalidate the internal caches and call
    850   QwtAbstractSlider::scaleChange()
     852   Invalidate the internal caches and call
     853   QwtAbstractSlider::scaleChange()
    851854 */
    852855void QwtDial::scaleChange()
    … …  
    858861void QwtDial::sliderChange()
    859862{
    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 );
    862865
    863866    if ( mode() == RotateScale )
    864867    {
    865868        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 );
    868871    }
    869872
    870873    QwtAbstractSlider::sliderChange();
    871874}
     875
     876#include "moc_qwt_dial.cpp"
Note: See TracChangeset for help on using the changeset viewer.