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_abstract_scale_draw.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_abstract_scale_draw.h"
    11 #include "qwt_math.h"
    1211#include "qwt_text.h"
    1312#include "qwt_painter.h"
    1413#include "qwt_scale_map.h"
     14#include "qwt_math.h"
     15
    1516#include <qpainter.h>
    1617#include <qpalette.h>
    1718#include <qmap.h>
     19#include <qlist.h>
    1820#include <qlocale.h>
    1921
    2022class QwtAbstractScaleDraw::PrivateData
    2123{
    22 public:
     24  public:
    2325    PrivateData():
    2426        spacing( 4.0 ),
    25         penWidth( 0 ),
     27        penWidthF( 0.0 ),
    2628        minExtent( 0.0 )
    2729    {
    … …  
    4244    double spacing;
    4345    double tickLength[QwtScaleDiv::NTickTypes];
    44     int penWidth;
     46    qreal penWidthF;
    4547
    4648    double minExtent;
    4749
    48     QMap<double, QwtText> labelCache;
     50    QMap< double, QwtText > labelCache;
    4951};
    5052
    5153/*!
    52   \brief Constructor
    53 
    54   The range of the scale is initialized to [0, 100],
    55   The spacing (distance between ticks and labels) is
    56   set to 4, the tick lengths are set to 4,6 and 8 pixels
    57 */
     54   \brief Constructor
     55
     56   The range of the scale is initialized to [0, 100],
     57   The spacing (distance between ticks and labels) is
     58   set to 4, the tick lengths are set to 4,6 and 8 pixels
     59 */
    5860QwtAbstractScaleDraw::QwtAbstractScaleDraw()
    5961{
    60     d_data = new QwtAbstractScaleDraw::PrivateData;
     62    m_data = new QwtAbstractScaleDraw::PrivateData;
    6163}
    6264
    … …  
    6466QwtAbstractScaleDraw::~QwtAbstractScaleDraw()
    6567{
    66     delete d_data;
    67 }
    68 
    69 /*!
    70   En/Disable a component of the scale
    71 
    72   \param component Scale component
    73   \param enable On/Off
    74 
    75   \sa hasComponent()
    76 */
     68    delete m_data;
     69}
     70
     71/*!
     72   En/Disable a component of the scale
     73
     74   \param component Scale component
     75   \param enable On/Off
     76
     77   \sa hasComponent()
     78 */
    7779void QwtAbstractScaleDraw::enableComponent(
    7880    ScaleComponent component, bool enable )
    7981{
    8082    if ( enable )
    81         d_data->components |= component;
     83        m_data->components |= component;
    8284    else
    83         d_data->components &= ~component;
    84 }
    85 
    86 /*!
    87   Check if a component is enabled
    88 
    89   \param component Component type
    90   \return true, when component is enabled
    91   \sa enableComponent()
    92 */
     85        m_data->components &= ~component;
     86}
     87
     88/*!
     89   Check if a component is enabled
     90
     91   \param component Component type
     92   \return true, when component is enabled
     93   \sa enableComponent()
     94 */
    9395bool QwtAbstractScaleDraw::hasComponent( ScaleComponent component ) const
    9496{
    95     return ( d_data->components & component );
    96 }
    97 
    98 /*!
    99   Change the scale division
    100   \param scaleDiv New scale division
    101 */
    102 void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv &scaleDiv )
    103 {
    104     d_data->scaleDiv = scaleDiv;
    105     d_data->map.setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound() );
    106     d_data->labelCache.clear();
    107 }
    108 
    109 /*!
    110   Change the transformation of the scale
    111   \param transformation New scale transformation
    112 */
    113 void QwtAbstractScaleDraw::setTransformation(
    114     QwtTransform *transformation )
    115 {
    116     d_data->map.setTransformation( transformation );
     97    return ( m_data->components & component );
     98}
     99
     100/*!
     101   Change the scale division
     102   \param scaleDiv New scale division
     103 */
     104void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv& scaleDiv )
     105{
     106    m_data->scaleDiv = scaleDiv;
     107    m_data->map.setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound() );
     108    m_data->labelCache.clear();
     109}
     110
     111/*!
     112   Change the transformation of the scale
     113   \param transformation New scale transformation
     114 */
     115void QwtAbstractScaleDraw::setTransformation( QwtTransform* transformation )
     116{
     117    m_data->map.setTransformation( transformation );
    117118}
    118119
    119120//! \return Map how to translate between scale and pixel values
    120 const QwtScaleMap &QwtAbstractScaleDraw::scaleMap() const
    121 {
    122     return d_data->map;
     121const QwtScaleMap& QwtAbstractScaleDraw::scaleMap() const
     122{
     123    return m_data->map;
    123124}
    124125
    125126//! \return Map how to translate between scale and pixel values
    126 QwtScaleMap &QwtAbstractScaleDraw::scaleMap()
    127 {
    128     return d_data->map;
     127QwtScaleMap& QwtAbstractScaleDraw::scaleMap()
     128{
     129    return m_data->map;
    129130}
    130131
    … …  
    132133const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const
    133134{
    134     return d_data->scaleDiv;
    135 }
    136 
    137 /*!
    138   \brief Specify the width of the scale pen
    139   \param width Pen width
    140   \sa penWidth()
    141 */
    142 void QwtAbstractScaleDraw::setPenWidth( int width )
    143 {
    144     if ( width < 0 )
    145         width = 0;
    146 
    147     if ( width != d_data->penWidth )
    148         d_data->penWidth = width;
     135    return m_data->scaleDiv;
     136}
     137
     138/*!
     139   \brief Specify the width of the scale pen
     140   \param width Pen width
     141
     142   \sa penWidth()
     143 */
     144void QwtAbstractScaleDraw::setPenWidthF( qreal width )
     145{
     146    if ( width < 0.0 )
     147        width = 0.0;
     148
     149    m_data->penWidthF = width;
    149150}
    150151
    … …  
    152153    \return Scale pen width
    153154    \sa setPenWidth()
    154 */
    155 int QwtAbstractScaleDraw::penWidth() const
    156 {
    157     return d_data->penWidth;
    158 }
    159 
    160 /*!
    161   \brief Draw the scale
    162 
    163   \param painter    The painter
    164 
    165   \param palette    Palette, text color is used for the labels,
     155 */
     156qreal QwtAbstractScaleDraw::penWidthF() const
     157{
     158    return m_data->penWidthF;
     159}
     160
     161/*!
     162   \brief Draw the scale
     163
     164   \param painter    The painter
     165
     166   \param palette    Palette, text color is used for the labels,
    166167                    foreground color for ticks and backbone
    167 */
    168 void QwtAbstractScaleDraw::draw( QPainter *painter,
     168 */
     169void QwtAbstractScaleDraw::draw( QPainter* painter,
    169170    const QPalette& palette ) const
    170171{
    … …  
    172173
    173174    QPen pen = painter->pen();
    174     pen.setWidth( d_data->penWidth );
    175     pen.setCosmetic( false );
     175    pen.setWidthF( m_data->penWidthF );
     176
    176177    painter->setPen( pen );
    177178
    … …  
    181182        painter->setPen( palette.color( QPalette::Text ) ); // ignore pen style
    182183
    183         const QList<double> &majorTicks =
    184             d_data->scaleDiv.ticks( QwtScaleDiv::MajorTick );
     184        const QList< double >& majorTicks =
     185            m_data->scaleDiv.ticks( QwtScaleDiv::MajorTick );
    185186
    186187        for ( int i = 0; i < majorTicks.count(); i++ )
    187188        {
    188189            const double v = majorTicks[i];
    189             if ( d_data->scaleDiv.contains( v ) )
     190            if ( m_data->scaleDiv.contains( v ) )
    190191                drawLabel( painter, v );
    191192        }
    … …  
    207208            tickType < QwtScaleDiv::NTickTypes; tickType++ )
    208209        {
    209             const double tickLen = d_data->tickLength[tickType];
     210            const double tickLen = m_data->tickLength[tickType];
    210211            if ( tickLen <= 0.0 )
    211212                continue;
    212213
    213             const QList<double> &ticks = d_data->scaleDiv.ticks( tickType );
     214            const QList< double >& ticks = m_data->scaleDiv.ticks( tickType );
    214215            for ( int i = 0; i < ticks.count(); i++ )
    215216            {
    216217                const double v = ticks[i];
    217                 if ( d_data->scaleDiv.contains( v ) )
     218                if ( m_data->scaleDiv.contains( v ) )
    218219                    drawTick( painter, v, tickLen );
    219220            }
    … …  
    242243
    243244/*!
    244   \brief Set the spacing between tick and labels
    245 
    246   The spacing is the distance between ticks and labels.
    247   The default spacing is 4 pixels.
    248 
    249   \param spacing Spacing
    250 
    251   \sa spacing()
    252 */
     245   \brief Set the spacing between tick and labels
     246
     247   The spacing is the distance between ticks and labels.
     248   The default spacing is 4 pixels.
     249
     250   \param spacing Spacing
     251
     252   \sa spacing()
     253 */
    253254void QwtAbstractScaleDraw::setSpacing( double spacing )
    254255{
    … …  
    256257        spacing = 0;
    257258
    258     d_data->spacing = spacing;
    259 }
    260 
    261 /*!
    262   \brief Get the spacing
    263 
    264   The spacing is the distance between ticks and labels.
    265   The default spacing is 4 pixels.
    266 
    267   \return Spacing
    268   \sa setSpacing()
    269 */
     259    m_data->spacing = spacing;
     260}
     261
     262/*!
     263   \brief Get the spacing
     264
     265   The spacing is the distance between ticks and labels.
     266   The default spacing is 4 pixels.
     267
     268   \return Spacing
     269   \sa setSpacing()
     270 */
    270271double QwtAbstractScaleDraw::spacing() const
    271272{
    272     return d_data->spacing;
    273 }
    274 
    275 /*!
    276   \brief Set a minimum for the extent
    277 
    278   The extent is calculated from the components of the
    279   scale draw. In situations, where the labels are
    280   changing and the layout depends on the extent (f.e scrolling
    281   a scale), setting an upper limit as minimum extent will
    282   avoid jumps of the layout.
    283 
    284   \param minExtent Minimum extent
    285 
    286   \sa extent(), minimumExtent()
    287 */
     273    return m_data->spacing;
     274}
     275
     276/*!
     277   \brief Set a minimum for the extent
     278
     279   The extent is calculated from the components of the
     280   scale draw. In situations, where the labels are
     281   changing and the layout depends on the extent (f.e scrolling
     282   a scale), setting an upper limit as minimum extent will
     283   avoid jumps of the layout.
     284
     285   \param minExtent Minimum extent
     286
     287   \sa extent(), minimumExtent()
     288 */
    288289void QwtAbstractScaleDraw::setMinimumExtent( double minExtent )
    289290{
    … …  
    291292        minExtent = 0.0;
    292293
    293     d_data->minExtent = minExtent;
    294 }
    295 
    296 /*!
    297   Get the minimum extent
    298   \return Minimum extent
    299   \sa extent(), setMinimumExtent()
    300 */
     294    m_data->minExtent = minExtent;
     295}
     296
     297/*!
     298   Get the minimum extent
     299   \return Minimum extent
     300   \sa extent(), setMinimumExtent()
     301 */
    301302double QwtAbstractScaleDraw::minimumExtent() const
    302303{
    303     return d_data->minExtent;
    304 }
    305 
    306 /*!
    307   Set the length of the ticks
    308 
    309   \param tickType Tick type
    310   \param length New length
    311 
    312   \warning the length is limited to [0..1000]
    313 */
     304    return m_data->minExtent;
     305}
     306
     307/*!
     308   Set the length of the ticks
     309
     310   \param tickType Tick type
     311   \param length New length
     312
     313   \warning the length is limited to [0..1000]
     314 */
    314315void QwtAbstractScaleDraw::setTickLength(
    315316    QwtScaleDiv::TickType tickType, double length )
    … …  
    328329        length = maxTickLen;
    329330
    330     d_data->tickLength[tickType] = length;
     331    m_data->tickLength[tickType] = length;
    331332}
    332333
    … …  
    334335    \return Length of the ticks
    335336    \sa setTickLength(), maxTickLength()
    336 */
     337 */
    337338double QwtAbstractScaleDraw::tickLength( QwtScaleDiv::TickType tickType ) const
    338339{
    … …  
    343344    }
    344345
    345     return d_data->tickLength[tickType];
     346    return m_data->tickLength[tickType];
    346347}
    347348
    … …  
    351352   Useful for layout calculations
    352353   \sa tickLength(), setTickLength()
    353 */
     354 */
    354355double QwtAbstractScaleDraw::maxTickLength() const
    355356{
    356357    double length = 0.0;
    357358    for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
    358         length = qMax( length, d_data->tickLength[i] );
     359        length = qwtMaxF( length, m_data->tickLength[i] );
    359360
    360361    return length;
    … …  
    362363
    363364/*!
    364   \brief Convert a value into its representing label
    365 
    366   The value is converted to a plain text using
    367   QLocale().toString(value).
    368   This method is often overloaded by applications to have individual
    369   labels.
    370 
    371   \param value Value
    372   \return Label string.
    373 */
     365   \brief Convert a value into its representing label
     366
     367   The value is converted to a plain text using
     368   QLocale().toString(value).
     369   This method is often overloaded by applications to have individual
     370   labels.
     371
     372   \param value Value
     373   \return Label string.
     374 */
    374375QwtText QwtAbstractScaleDraw::label( double value ) const
    375376{
    … …  
    389390
    390391   \return Tick label
    391 */
    392 const QwtText &QwtAbstractScaleDraw::tickLabel(
    393     const QFont &font, double value ) const
    394 {
    395     QMap<double, QwtText>::const_iterator it1 = d_data->labelCache.constFind( value );
    396     if ( it1 != d_data->labelCache.constEnd() )
     392 */
     393const QwtText& QwtAbstractScaleDraw::tickLabel(
     394    const QFont& font, double value ) const
     395{
     396    QMap< double, QwtText >::const_iterator it1 = m_data->labelCache.constFind( value );
     397    if ( it1 != m_data->labelCache.constEnd() )
    397398        return *it1;
    398399
    … …  
    403404    ( void )lbl.textSize( font ); // initialize the internal cache
    404405
    405     QMap<double, QwtText>::iterator it2 = d_data->labelCache.insert( value, lbl );
     406    QMap< double, QwtText >::iterator it2 = m_data->labelCache.insert( value, lbl );
    406407    return *it2;
    407408}
    … …  
    413414   the labels need to be changed. while the same QwtScaleDiv is set,
    414415   invalidateCache() needs to be called manually.
    415 */
     416 */
    416417void QwtAbstractScaleDraw::invalidateCache()
    417418{
    418     d_data->labelCache.clear();
    419 }
     419    m_data->labelCache.clear();
     420}
Note: See TracChangeset for help on using the changeset viewer.