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_round_scale_draw.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1212#include "qwt_scale_div.h"
    1313#include "qwt_scale_map.h"
     14#include "qwt_text.h"
    1415#include "qwt_math.h"
    15 #include <qpen.h>
     16
    1617#include <qpainter.h>
    17 #include <qfontmetrics.h>
    18 #include <qmath.h>
    1918
    2019class QwtRoundScaleDraw::PrivateData
    2120{
    22 public:
    23     PrivateData():
    24         center( 50.0, 50.0 ),
    25         radius( 50.0 ),
    26         startAngle( -135.0 ),
    27         endAngle( 135.0 )
     21  public:
     22    PrivateData()
     23        : center( 50.0, 50.0 )
     24        , radius( 50.0 )
     25        , startAngle( -135.0 )
     26        , endAngle( 135.0 )
    2827    {
    2928    }
    … …  
    3736
    3837/*!
    39   \brief Constructor
    40 
    41   The range of the scale is initialized to [0, 100],
    42   The center is set to (50, 50) with a radius of 50.
    43   The angle range is set to [-135, 135].
    44 */
     38   \brief Constructor
     39
     40   The range of the scale is initialized to [0, 100],
     41   The center is set to (50, 50) with a radius of 50.
     42   The angle range is set to [-135, 135].
     43 */
    4544QwtRoundScaleDraw::QwtRoundScaleDraw()
    4645{
    47     d_data = new QwtRoundScaleDraw::PrivateData;
     46    m_data = new QwtRoundScaleDraw::PrivateData;
    4847
    4948    setRadius( 50 );
    50     scaleMap().setPaintInterval( d_data->startAngle, d_data->endAngle );
     49    scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle );
    5150}
    5251
    … …  
    5453QwtRoundScaleDraw::~QwtRoundScaleDraw()
    5554{
    56     delete d_data;
    57 }
    58 
    59 /*!
    60   Change of radius the scale
    61 
    62   Radius is the radius of the backbone without ticks and labels.
    63 
    64   \param radius New Radius
    65   \sa moveCenter()
    66 */
     55    delete m_data;
     56}
     57
     58/*!
     59   Change of radius the scale
     60
     61   Radius is the radius of the backbone without ticks and labels.
     62
     63   \param radius New Radius
     64   \sa moveCenter()
     65 */
    6766void QwtRoundScaleDraw::setRadius( double radius )
    6867{
    69     d_data->radius = radius;
    70 }
    71 
    72 /*!
    73   Get the radius
    74 
    75   Radius is the radius of the backbone without ticks and labels.
    76 
    77   \return Radius of the scale
    78   \sa setRadius(), extent()
    79 */
     68    m_data->radius = radius;
     69}
     70
     71/*!
     72   Get the radius
     73
     74   Radius is the radius of the backbone without ticks and labels.
     75
     76   \return Radius of the scale
     77   \sa setRadius(), extent()
     78 */
    8079double QwtRoundScaleDraw::radius() const
    8180{
    82     return d_data->radius;
     81    return m_data->radius;
    8382}
    8483
    … …  
    8887   \param center New center
    8988   \sa setRadius()
    90 */
    91 void QwtRoundScaleDraw::moveCenter( const QPointF &center )
    92 {
    93     d_data->center = center;
     89 */
     90void QwtRoundScaleDraw::moveCenter( const QPointF& center )
     91{
     92    m_data->center = center;
    9493}
    9594
    … …  
    9796QPointF QwtRoundScaleDraw::center() const
    9897{
    99     return d_data->center;
    100 }
    101 
    102 /*!
    103   \brief Adjust the baseline circle segment for round scales.
    104 
    105   The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2).
    106   The default setting is [ -135, 135 ].
    107   An angle of 0 degrees corresponds to the 12 o'clock position,
    108   and positive angles count in a clockwise direction.
    109   \param angle1
    110   \param angle2 boundaries of the angle interval in degrees.
    111   \warning <ul>
    112   <li>The angle range is limited to [-360, 360] degrees. Angles exceeding
     98    return m_data->center;
     99}
     100
     101/*!
     102   \brief Adjust the baseline circle segment for round scales.
     103
     104   The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2).
     105   The default setting is [ -135, 135 ].
     106   An angle of 0 degrees corresponds to the 12 o'clock position,
     107   and positive angles count in a clockwise direction.
     108   \param angle1
     109   \param angle2 boundaries of the angle interval in degrees.
     110   \warning <ul>
     111   <li>The angle range is limited to [-360, 360] degrees. Angles exceeding
    113112      this range will be clipped.
    114   <li>For angles more or equal than 360 degrees above or below min(angle1, angle2),
     113   <li>For angles more or equal than 360 degrees above or below min(angle1, angle2),
    115114      scale marks will not be drawn.
    116   <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval()
    117   </ul>
    118 */
     115   <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval()
     116   </ul>
     117 */
    119118void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 )
    120119{
    … …  
    124123#endif
    125124
    126     d_data->startAngle = angle1;
    127     d_data->endAngle = angle2;
    128 
    129     if ( d_data->startAngle == d_data->endAngle )
    130     {
    131         d_data->startAngle -= 1;
    132         d_data->endAngle += 1;
    133     }
    134 
    135     scaleMap().setPaintInterval( d_data->startAngle, d_data->endAngle );
     125    m_data->startAngle = angle1;
     126    m_data->endAngle = angle2;
     127
     128    if ( m_data->startAngle == m_data->endAngle )
     129    {
     130        m_data->startAngle -= 1;
     131        m_data->endAngle += 1;
     132    }
     133
     134    scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle );
    136135}
    137136
    … …  
    143142
    144143   \sa drawTick(), drawBackbone()
    145 */
    146 void QwtRoundScaleDraw::drawLabel( QPainter *painter, double value ) const
     144 */
     145void QwtRoundScaleDraw::drawLabel( QPainter* painter, double value ) const
    147146{
    148147    const double tval = scaleMap().transform( value );
    149     if ( ( tval >= d_data->startAngle + 360.0 )
    150         || ( tval <= d_data->startAngle - 360.0 ) )
     148    if ( ( tval >= m_data->startAngle + 360.0 )
     149        || ( tval <= m_data->startAngle - 360.0 ) )
    151150    {
    152151        return;
    … …  
    157156        return;
    158157
    159     double radius = d_data->radius;
     158    double radius = m_data->radius;
    160159    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
    161160        hasComponent( QwtAbstractScaleDraw::Backbone ) )
    … …  
    170169    const double arc = qwtRadians( tval );
    171170
    172     const double x = d_data->center.x() +
    173         ( radius + sz.width() / 2.0 ) * qSin( arc );
    174     const double y = d_data->center.y() -
    175         ( radius + sz.height() / 2.0 ) * qCos( arc );
     171    const double x = m_data->center.x() +
     172        ( radius + sz.width() / 2.0 ) * std::sin( arc );
     173    const double y = m_data->center.y() -
     174        ( radius + sz.height() / 2.0 ) * std::cos( arc );
    176175
    177176    const QRectF r( x - sz.width() / 2, y - sz.height() / 2,
    … …  
    188187
    189188   \sa drawBackbone(), drawLabel()
    190 */
    191 void QwtRoundScaleDraw::drawTick( QPainter *painter, double value, double len ) const
     189 */
     190void QwtRoundScaleDraw::drawTick( QPainter* painter, double value, double len ) const
    192191{
    193192    if ( len <= 0 )
    … …  
    196195    const double tval = scaleMap().transform( value );
    197196
    198     const double cx = d_data->center.x();
    199     const double cy = d_data->center.y();
    200     const double radius = d_data->radius;
    201 
    202     if ( ( tval < d_data->startAngle + 360.0 )
    203         && ( tval > d_data->startAngle - 360.0 ) )
     197    const double cx = m_data->center.x();
     198    const double cy = m_data->center.y();
     199    const double radius = m_data->radius;
     200
     201    if ( ( tval < m_data->startAngle + 360.0 )
     202        && ( tval > m_data->startAngle - 360.0 ) )
    204203    {
    205204        const double arc = qwtRadians( tval );
    206205
    207         const double sinArc = qSin( arc );
    208         const double cosArc = qCos( arc );
     206        const double sinArc = std::sin( arc );
     207        const double cosArc = std::cos( arc );
    209208
    210209        const double x1 = cx + radius * sinArc;
    … …  
    222221
    223222   \sa drawTick(), drawLabel()
    224 */
    225 void QwtRoundScaleDraw::drawBackbone( QPainter *painter ) const
     223 */
     224void QwtRoundScaleDraw::drawBackbone( QPainter* painter ) const
    226225{
    227226    const double deg1 = scaleMap().p1();
    228227    const double deg2 = scaleMap().p2();
    229228
    230     const int a1 = qRound( qMin( deg1, deg2 ) - 90 );
    231     const int a2 = qRound( qMax( deg1, deg2 ) - 90 );
    232 
    233     const double radius = d_data->radius;
    234     const double x = d_data->center.x() - radius;
    235     const double y = d_data->center.y() - radius;
     229    const int a1 = qRound( qwtMinF( deg1, deg2 ) - 90 );
     230    const int a2 = qRound( qwtMaxF( deg1, deg2 ) - 90 );
     231
     232    const double radius = m_data->radius;
     233    const double x = m_data->center.x() - radius;
     234    const double y = m_data->center.y() - radius;
    236235
    237236    painter->drawArc( QRectF( x, y, 2 * radius, 2 * radius ),
    … …  
    253252            calculates only an upper limit, that might be a
    254253            few pixels too large
    255 */
    256 double QwtRoundScaleDraw::extent( const QFont &font ) const
     254 */
     255double QwtRoundScaleDraw::extent( const QFont& font ) const
    257256{
    258257    double d = 0.0;
    … …  
    260259    if ( hasComponent( QwtAbstractScaleDraw::Labels ) )
    261260    {
    262         const QwtScaleDiv &sd = scaleDiv();
    263         const QList<double> &ticks = sd.ticks( QwtScaleDiv::MajorTick );
     261        const QwtScaleDiv& sd = scaleDiv();
     262        const QList< double >& ticks = sd.ticks( QwtScaleDiv::MajorTick );
    264263        for ( int i = 0; i < ticks.count(); i++ )
    265264        {
    … …  
    269268
    270269            const double tval = scaleMap().transform( value );
    271             if ( ( tval < d_data->startAngle + 360 )
    272                 && ( tval > d_data->startAngle - 360 ) )
     270            if ( ( tval < m_data->startAngle + 360 )
     271                && ( tval > m_data->startAngle - 360 ) )
    273272            {
    274273                const QwtText label = tickLabel( font, value );
    … …  
    281280                const double off = qMax( sz.width(), sz.height() );
    282281
    283                 double x = off * qSin( arc );
    284                 double y = off * qCos( arc );
    285 
    286                 const double dist = qSqrt( x * x + y * y );
     282                double x = off * std::sin( arc );
     283                double y = off * std::cos( arc );
     284
     285                const double dist = std::sqrt( x * x + y * y );
    287286                if ( dist > d )
    288287                    d = dist;
    … …  
    298297    if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
    299298    {
    300         const double pw = qMax( 1, penWidth() );  // pen width can be zero
    301         d += pw;
     299        d += qwtMaxF( penWidthF(), 1.0 );
    302300    }
    303301
    304302    if ( hasComponent( QwtAbstractScaleDraw::Labels ) &&
    305303        ( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
    306             hasComponent( QwtAbstractScaleDraw::Backbone ) ) )
     304        hasComponent( QwtAbstractScaleDraw::Backbone ) ) )
    307305    {
    308306        d += spacing();
    309307    }
    310308
    311     d = qMax( d, minimumExtent() );
     309    d = qwtMaxF( d, minimumExtent() );
    312310
    313311    return d;
Note: See TracChangeset for help on using the changeset viewer.