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


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

deprecated functions exchanged libs updated

File:
1 edited

Legend:

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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_analog_clock.h"
     11#include "qwt_dial_needle.h"
    1112#include "qwt_round_scale_draw.h"
    12 #include <qmath.h>
     13#include "qwt_text.h"
     14#include "qwt_math.h"
     15
    1316#include <qlocale.h>
    14 
    15 class QwtAnalogClockScaleDraw: public QwtRoundScaleDraw
    16 {
    17 public:
    18     QwtAnalogClockScaleDraw()
    19     {
    20         setSpacing( 8 );
    21 
    22         enableComponent( QwtAbstractScaleDraw::Backbone, false );
    23 
    24         setTickLength( QwtScaleDiv::MinorTick, 2 );
    25         setTickLength( QwtScaleDiv::MediumTick, 4 );
    26         setTickLength( QwtScaleDiv::MajorTick, 8 );
    27 
    28         setPenWidth( 1 );
    29     }
    30 
    31     virtual QwtText label( double value ) const
    32     {
    33         if ( qFuzzyCompare( value + 1.0, 1.0 ) )
    34             value = 60.0 * 60.0 * 12.0;
    35 
    36         return QLocale().toString( qRound( value / ( 60.0 * 60.0 ) ) );
    37     }
    38 };
    39 
    40 /*!
    41   Constructor
    42   \param parent Parent widget
    43 */
    44 QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
    45     QwtDial( parent )
     17#include <qdatetime.h>
     18
     19namespace
     20{
     21    class QwtAnalogClockScaleDraw QWT_FINAL : public QwtRoundScaleDraw
     22    {
     23      public:
     24        QwtAnalogClockScaleDraw()
     25        {
     26            setSpacing( 8 );
     27
     28            enableComponent( QwtAbstractScaleDraw::Backbone, false );
     29
     30            setTickLength( QwtScaleDiv::MinorTick, 2 );
     31            setTickLength( QwtScaleDiv::MediumTick, 4 );
     32            setTickLength( QwtScaleDiv::MajorTick, 8 );
     33
     34            setPenWidthF( 1.0 );
     35        }
     36
     37        virtual QwtText label( double value ) const QWT_OVERRIDE
     38        {
     39            if ( qFuzzyCompare( value + 1.0, 1.0 ) )
     40                value = 60.0 * 60.0 * 12.0;
     41
     42            return QLocale().toString( qRound( value / ( 60.0 * 60.0 ) ) );
     43        }
     44    };
     45}
     46
     47/*!
     48   Constructor
     49   \param parent Parent widget
     50 */
     51QwtAnalogClock::QwtAnalogClock( QWidget* parent )
     52    : QwtDial( parent )
    4653{
    4754    setWrapping( true );
    … …  
    5562    const int secondsPerHour = 60.0 * 60.0;
    5663
    57     QList<double> majorTicks;
    58     QList<double> minorTicks;
     64    QList< double > majorTicks;
     65    QList< double > minorTicks;
    5966
    6067    for ( int i = 0; i < 12; i++ )
    … …  
    9198        }
    9299
    93         QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
     100        QwtDialSimpleNeedle* hand = new QwtDialSimpleNeedle(
    94101            QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
    95102        hand->setWidth( width );
    96103
    97         d_hand[i] = NULL;
    98         setHand( static_cast<Hand>( i ), hand );
     104        m_hand[i] = NULL;
     105        setHand( static_cast< Hand >( i ), hand );
    99106    }
    100107}
    … …  
    104111{
    105112    for ( int i = 0; i < NHands; i++ )
    106         delete d_hand[i];
    107 }
    108 
    109 /*!
    110   Nop method, use setHand() instead
    111   \sa setHand()
    112 */
    113 void QwtAnalogClock::setNeedle( QwtDialNeedle * )
     113        delete m_hand[i];
     114}
     115
     116/*!
     117   Nop method, use setHand() instead
     118   \sa setHand()
     119 */
     120void QwtAnalogClock::setNeedle( QwtDialNeedle* )
    114121{
    115122    // no op
    … …  
    122129   \param needle Hand
    123130   \sa hand()
    124 */
    125 void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle *needle )
     131 */
     132void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle* needle )
    126133{
    127134    if ( hand >= 0 && hand < NHands )
    128135    {
    129         delete d_hand[hand];
    130         d_hand[hand] = needle;
    131     }
    132 }
    133 
    134 /*!
    135   \return Clock hand
    136   \param hd Specifies the type of hand
    137   \sa setHand()
    138 */
    139 QwtDialNeedle *QwtAnalogClock::hand( Hand hd )
     136        delete m_hand[hand];
     137        m_hand[hand] = needle;
     138    }
     139}
     140
     141/*!
     142   \return Clock hand
     143   \param hd Specifies the type of hand
     144   \sa setHand()
     145 */
     146QwtDialNeedle* QwtAnalogClock::hand( Hand hd )
    140147{
    141148    if ( hd < 0 || hd >= NHands )
    142149        return NULL;
    143150
    144     return d_hand[hd];
    145 }
    146 
    147 /*!
    148   \return Clock hand
    149   \param hd Specifies the type of hand
    150   \sa setHand()
    151 */
    152 const QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) const
    153 {
    154     return const_cast<QwtAnalogClock *>( this )->hand( hd );
    155 }
    156 
    157 /*!
    158   \brief Set the current time
    159 */
     151    return m_hand[hd];
     152}
     153
     154/*!
     155   \return Clock hand
     156   \param hd Specifies the type of hand
     157   \sa setHand()
     158 */
     159const QwtDialNeedle* QwtAnalogClock::hand( Hand hd ) const
     160{
     161    return const_cast< QwtAnalogClock* >( this )->hand( hd );
     162}
     163
     164/*!
     165   \brief Set the current time
     166 */
    160167void QwtAnalogClock::setCurrentTime()
    161168{
    … …  
    164171
    165172/*!
    166   Set a time
    167   \param time Time to display
    168 */
    169 void QwtAnalogClock::setTime( const QTime &time )
     173   Set a time
     174   \param time Time to display
     175 */
     176void QwtAnalogClock::setTime( const QTime& time )
    170177{
    171178    if ( time.isValid() )
    … …  
    179186
    180187/*!
    181   \brief Draw the needle
    182 
    183   A clock has no single needle but three hands instead. drawNeedle()
    184   translates value() into directions for the hands and calls
    185   drawHand().
    186 
    187   \param painter Painter
    188   \param center Center of the clock
    189   \param radius Maximum length for the hands
    190   \param dir Dummy, not used.
    191   \param colorGroup ColorGroup
    192 
    193   \sa drawHand()
    194 */
    195 void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
    196     double radius, double dir, QPalette::ColorGroup colorGroup ) const
    197 {
    198     Q_UNUSED( dir );
     188   \brief Draw the needle
     189
     190   A clock has no single needle but three hands instead. drawNeedle()
     191   translates value() into directions for the hands and calls
     192   drawHand().
     193
     194   \param painter Painter
     195   \param center Center of the clock
     196   \param radius Maximum length for the hands
     197   \param direction Dummy, not used.
     198   \param colorGroup ColorGroup
     199
     200   \sa drawHand()
     201 */
     202void QwtAnalogClock::drawNeedle( QPainter* painter, const QPointF& center,
     203    double radius, double direction, QPalette::ColorGroup colorGroup ) const
     204{
     205    Q_UNUSED( direction );
    199206
    200207    if ( isValid() )
    … …  
    202209        const double hours = value() / ( 60.0 * 60.0 );
    203210        const double minutes =
    204             ( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
    205         const double seconds = value() - qFloor(hours) * 60.0 * 60.0
    206             - qFloor(minutes) * 60.0;
     211            ( value() - std::floor(hours) * 60.0 * 60.0 ) / 60.0;
     212        const double seconds = value() - std::floor(hours) * 60.0 * 60.0
     213            - std::floor(minutes) * 60.0;
    207214
    208215        double angle[NHands];
    … …  
    214221        {
    215222            const double d = 360.0 - angle[hand] - origin();
    216             drawHand( painter, static_cast<Hand>( hand ),
     223            drawHand( painter, static_cast< Hand >( hand ),
    217224                center, radius, d, colorGroup );
    218225        }
    … …  
    221228
    222229/*!
    223   Draw a clock hand
    224 
    225   \param painter Painter
    226   \param hd Specify the type of hand
    227   \param center Center of the clock
    228   \param radius Maximum length for the hands
    229   \param direction Direction of the hand in degrees, counter clockwise
    230   \param cg ColorGroup
    231 */
    232 void QwtAnalogClock::drawHand( QPainter *painter, Hand hd,
    233     const QPointF &center, double radius, double direction,
     230   Draw a clock hand
     231
     232   \param painter Painter
     233   \param hd Specify the type of hand
     234   \param center Center of the clock
     235   \param radius Maximum length for the hands
     236   \param direction Direction of the hand in degrees, counter clockwise
     237   \param cg ColorGroup
     238 */
     239void QwtAnalogClock::drawHand( QPainter* painter, Hand hd,
     240    const QPointF& center, double radius, double direction,
    234241    QPalette::ColorGroup cg ) const
    235242{
    236     const QwtDialNeedle *needle = hand( hd );
     243    const QwtDialNeedle* needle = hand( hd );
    237244    if ( needle )
    238245    {
    … …  
    243250    }
    244251}
     252
     253#include "moc_qwt_analog_clock.cpp"
Note: See TracChangeset for help on using the changeset viewer.