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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1515#include "qwt_interval.h"
    1616
     17#include <qcoreevent.h>
     18
    1719class QwtAbstractScale::PrivateData
    1820{
    19 public:
     21  public:
    2022    PrivateData():
    2123        maxMajor( 5 ),
    … …  
    3335    }
    3436
    35     QwtScaleEngine *scaleEngine;
    36     QwtAbstractScaleDraw *scaleDraw;
     37    QwtScaleEngine* scaleEngine;
     38    QwtAbstractScaleDraw* scaleDraw;
    3739
    3840    int maxMajor;
    … …  
    4244
    4345/*!
    44   Constructor
    45 
    46   \param parent Parent widget
    47 
    48   Creates a default QwtScaleDraw and a QwtLinearScaleEngine.
    49   The initial scale boundaries are set to [ 0.0, 100.0 ]
    50 
    51   The scaleStepSize() is initialized to 0.0, scaleMaxMajor() to 5
    52   and scaleMaxMajor to 3.
    53 */
    54 
    55 QwtAbstractScale::QwtAbstractScale( QWidget *parent ):
    56     QWidget( parent )
    57 {
    58     d_data = new PrivateData;
    59     rescale( 0.0, 100.0, d_data->stepSize );
     46   Constructor
     47
     48   \param parent Parent widget
     49
     50   Creates a default QwtScaleDraw and a QwtLinearScaleEngine.
     51   The initial scale boundaries are set to [ 0.0, 100.0 ]
     52
     53   The scaleStepSize() is initialized to 0.0, scaleMaxMajor() to 5
     54   and scaleMaxMajor to 3.
     55 */
     56
     57QwtAbstractScale::QwtAbstractScale( QWidget* parent )
     58    : QWidget( parent )
     59{
     60    m_data = new PrivateData;
     61    rescale( 0.0, 100.0, m_data->stepSize );
    6062}
    6163
    … …  
    6365QwtAbstractScale::~QwtAbstractScale()
    6466{
    65     delete d_data;
    66 }
    67 
    68 /*!
    69   Set the lower bound of the scale
    70 
    71   \param value Lower bound
    72 
    73   \sa lowerBound(), setScale(), setUpperBound()
    74   \note For inverted scales the lower bound
     67    delete m_data;
     68}
     69
     70/*!
     71   Set the lower bound of the scale
     72
     73   \param value Lower bound
     74
     75   \sa lowerBound(), setScale(), setUpperBound()
     76   \note For inverted scales the lower bound
    7577        is greater than the upper bound
    76 */
     78 */
    7779void QwtAbstractScale::setLowerBound( double value )
    7880{
    … …  
    8183
    8284/*!
    83   \return Lower bound of the scale
    84   \sa setLowerBound(), setScale(), upperBound()
    85 */
     85   \return Lower bound of the scale
     86   \sa setLowerBound(), setScale(), upperBound()
     87 */
    8688double QwtAbstractScale::lowerBound() const
    8789{
    88     return d_data->scaleDraw->scaleDiv().lowerBound();
    89 }
    90 
    91 /*!
    92   Set the upper bound of the scale
    93 
    94   \param value Upper bound
    95 
    96   \sa upperBound(), setScale(), setLowerBound()
    97   \note For inverted scales the lower bound
     90    return m_data->scaleDraw->scaleDiv().lowerBound();
     91}
     92
     93/*!
     94   Set the upper bound of the scale
     95
     96   \param value Upper bound
     97
     98   \sa upperBound(), setScale(), setLowerBound()
     99   \note For inverted scales the lower bound
    98100        is greater than the upper bound
    99 */
     101 */
    100102void QwtAbstractScale::setUpperBound( double value )
    101103{
    … …  
    104106
    105107/*!
    106   \return Upper bound of the scale
    107   \sa setUpperBound(), setScale(), lowerBound()
    108 */
     108   \return Upper bound of the scale
     109   \sa setUpperBound(), setScale(), lowerBound()
     110 */
    109111double QwtAbstractScale::upperBound() const
    110112{
    111     return d_data->scaleDraw->scaleDiv().upperBound();
    112 }
    113 
    114 /*!
    115   \brief Specify a scale.
    116 
    117   Define a scale by an interval
    118 
    119   The ticks are calculated using scaleMaxMinor(),
    120   scaleMaxMajor() and scaleStepSize().
    121 
    122   \param lowerBound lower limit of the scale interval
    123   \param upperBound upper limit of the scale interval
    124 
    125   \note For inverted scales the lower bound
     113    return m_data->scaleDraw->scaleDiv().upperBound();
     114}
     115
     116/*!
     117   \brief Specify a scale.
     118
     119   Define a scale by an interval
     120
     121   The ticks are calculated using scaleMaxMinor(),
     122   scaleMaxMajor() and scaleStepSize().
     123
     124   \param lowerBound lower limit of the scale interval
     125   \param upperBound upper limit of the scale interval
     126
     127   \note For inverted scales the lower bound
    126128        is greater than the upper bound
    127 */
     129 */
    128130void QwtAbstractScale::setScale( double lowerBound, double upperBound )
    129131{
    130     rescale( lowerBound, upperBound, d_data->stepSize );
    131 }
    132 
    133 /*!
    134   \brief Specify a scale.
    135 
    136   Define a scale by an interval
    137 
    138   The ticks are calculated using scaleMaxMinor(),
    139   scaleMaxMajor() and scaleStepSize().
    140 
    141   \param interval Interval
    142 */
    143 void QwtAbstractScale::setScale( const QwtInterval &interval )
     132    rescale( lowerBound, upperBound, m_data->stepSize );
     133}
     134
     135/*!
     136   \brief Specify a scale.
     137
     138   Define a scale by an interval
     139
     140   The ticks are calculated using scaleMaxMinor(),
     141   scaleMaxMajor() and scaleStepSize().
     142
     143   \param interval Interval
     144 */
     145void QwtAbstractScale::setScale( const QwtInterval& interval )
    144146{
    145147    setScale( interval.minValue(), interval.maxValue() );
    … …  
    147149
    148150/*!
    149   \brief Specify a scale.
    150 
    151   scaleMaxMinor(), scaleMaxMajor() and scaleStepSize() and have no effect.
    152 
    153   \param scaleDiv Scale division
    154   \sa setAutoScale()
    155 */
    156 void QwtAbstractScale::setScale( const QwtScaleDiv &scaleDiv )
    157 {
    158     if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
     151   \brief Specify a scale.
     152
     153   scaleMaxMinor(), scaleMaxMajor() and scaleStepSize() and have no effect.
     154
     155   \param scaleDiv Scale division
     156   \sa setAutoScale()
     157 */
     158void QwtAbstractScale::setScale( const QwtScaleDiv& scaleDiv )
     159{
     160    if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
    159161    {
    160162#if 1
    161         if ( d_data->scaleEngine )
     163        if ( m_data->scaleEngine )
    162164        {
    163             d_data->scaleDraw->setTransformation(
    164                 d_data->scaleEngine->transformation() );
     165            m_data->scaleDraw->setTransformation(
     166                m_data->scaleEngine->transformation() );
    165167        }
    166168#endif
    167169
    168         d_data->scaleDraw->setScaleDiv( scaleDiv );
     170        m_data->scaleDraw->setScaleDiv( scaleDiv );
    169171
    170172        scaleChange();
    … …  
    173175
    174176/*!
    175   \brief Set the maximum number of major tick intervals.
    176 
    177   The scale's major ticks are calculated automatically such that
    178   the number of major intervals does not exceed ticks.
    179 
    180   The default value is 5.
    181 
    182   \param ticks Maximal number of major ticks.
    183 
    184   \sa scaleMaxMajor(), setScaleMaxMinor(),
     177   \brief Set the maximum number of major tick intervals.
     178
     179   The scale's major ticks are calculated automatically such that
     180   the number of major intervals does not exceed ticks.
     181
     182   The default value is 5.
     183
     184   \param ticks Maximal number of major ticks.
     185
     186   \sa scaleMaxMajor(), setScaleMaxMinor(),
    185187      setScaleStepSize(), QwtScaleEngine::divideInterval()
    186 */
     188 */
    187189void QwtAbstractScale::setScaleMaxMajor( int ticks )
    188190{
    189     if ( ticks != d_data->maxMajor )
    190     {
    191         d_data->maxMajor = ticks;
     191    if ( ticks != m_data->maxMajor )
     192    {
     193        m_data->maxMajor = ticks;
    192194        updateScaleDraw();
    193195    }
    … …  
    195197
    196198/*!
    197   \return Maximal number of major tick intervals
    198   \sa setScaleMaxMajor(), scaleMaxMinor()
    199 */
     199   \return Maximal number of major tick intervals
     200   \sa setScaleMaxMajor(), scaleMaxMinor()
     201 */
    200202int QwtAbstractScale::scaleMaxMajor() const
    201203{
    202     return d_data->maxMajor;
    203 }
    204 
    205 /*!
    206   \brief Set the maximum number of minor tick intervals
    207 
    208   The scale's minor ticks are calculated automatically such that
    209   the number of minor intervals does not exceed ticks.
    210   The default value is 3.
    211 
    212   \param ticks Maximal number of minor ticks.
    213 
    214   \sa scaleMaxMajor(), setScaleMaxMinor(),
     204    return m_data->maxMajor;
     205}
     206
     207/*!
     208   \brief Set the maximum number of minor tick intervals
     209
     210   The scale's minor ticks are calculated automatically such that
     211   the number of minor intervals does not exceed ticks.
     212   The default value is 3.
     213
     214   \param ticks Maximal number of minor ticks.
     215
     216   \sa scaleMaxMajor(), setScaleMaxMinor(),
    215217      setScaleStepSize(), QwtScaleEngine::divideInterval()
    216 */
     218 */
    217219void QwtAbstractScale::setScaleMaxMinor( int ticks )
    218220{
    219     if ( ticks != d_data->maxMinor )
    220     {
    221         d_data->maxMinor = ticks;
     221    if ( ticks != m_data->maxMinor )
     222    {
     223        m_data->maxMinor = ticks;
    222224        updateScaleDraw();
    223225    }
    … …  
    225227
    226228/*!
    227   \return Maximal number of minor tick intervals
    228   \sa setScaleMaxMinor(), scaleMaxMajor()
    229 */
     229   \return Maximal number of minor tick intervals
     230   \sa setScaleMaxMinor(), scaleMaxMajor()
     231 */
    230232int QwtAbstractScale::scaleMaxMinor() const
    231233{
    232     return d_data->maxMinor;
     234    return m_data->maxMinor;
    233235}
    234236
    … …  
    246248   \note Position and distance between the major ticks also
    247249         depends on scaleMaxMajor().
    248 */
     250 */
    249251void QwtAbstractScale::setScaleStepSize( double stepSize )
    250252{
    251     if ( stepSize != d_data->stepSize )
    252     {
    253         d_data->stepSize = stepSize;
     253    if ( stepSize != m_data->stepSize )
     254    {
     255        m_data->stepSize = stepSize;
    254256        updateScaleDraw();
    255257    }
    … …  
    257259
    258260/*!
    259   \return Hint for the step size of the scale
    260   \sa setScaleStepSize(), QwtScaleEngine::divideScale()
    261 */
     261   \return Hint for the step size of the scale
     262   \sa setScaleStepSize(), QwtScaleEngine::divideScale()
     263 */
    262264double QwtAbstractScale::scaleStepSize() const
    263265{
    264     return d_data->stepSize;
    265 }
    266 
    267 /*!
    268   \brief Set a scale draw
    269 
    270   scaleDraw has to be created with new and will be deleted in
    271   the destructor or the next call of setAbstractScaleDraw().
    272 
    273   \sa abstractScaleDraw()
    274 */
    275 void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw *scaleDraw )
    276 {
    277     if ( scaleDraw == NULL || scaleDraw == d_data->scaleDraw )
     266    return m_data->stepSize;
     267}
     268
     269/*!
     270   \brief Set a scale draw
     271
     272   scaleDraw has to be created with new and will be deleted in
     273   the destructor or the next call of setAbstractScaleDraw().
     274
     275   \sa abstractScaleDraw()
     276 */
     277void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw* scaleDraw )
     278{
     279    if ( scaleDraw == NULL || scaleDraw == m_data->scaleDraw )
    278280        return;
    279281
    280     if ( d_data->scaleDraw != NULL )
    281         scaleDraw->setScaleDiv( d_data->scaleDraw->scaleDiv() );
    282 
    283     delete d_data->scaleDraw;
    284     d_data->scaleDraw = scaleDraw;
     282    if ( m_data->scaleDraw != NULL )
     283        scaleDraw->setScaleDiv( m_data->scaleDraw->scaleDiv() );
     284
     285    delete m_data->scaleDraw;
     286    m_data->scaleDraw = scaleDraw;
    285287}
    286288
    … …  
    288290    \return Scale draw
    289291    \sa setAbstractScaleDraw()
    290 */
    291 QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw()
    292 {
    293     return d_data->scaleDraw;
     292 */
     293QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw()
     294{
     295    return m_data->scaleDraw;
    294296}
    295297
    … …  
    297299    \return Scale draw
    298300    \sa setAbstractScaleDraw()
    299 */
    300 const QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() const
    301 {
    302     return d_data->scaleDraw;
    303 }
    304 
    305 /*!
    306   \brief Set a scale engine
    307 
    308   The scale engine is responsible for calculating the scale division
    309   and provides a transformation between scale and widget coordinates.
    310 
    311   scaleEngine has to be created with new and will be deleted in
    312   the destructor or the next call of setScaleEngine.
    313 */
    314 void QwtAbstractScale::setScaleEngine( QwtScaleEngine *scaleEngine )
    315 {
    316     if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine )
    317     {
    318         delete d_data->scaleEngine;
    319         d_data->scaleEngine = scaleEngine;
    320     }
    321 }
    322 
    323 /*!
    324   \return Scale engine
    325   \sa setScaleEngine()
    326 */
    327 const QwtScaleEngine *QwtAbstractScale::scaleEngine() const
    328 {
    329     return d_data->scaleEngine;
    330 }
    331 
    332 /*!
    333   \return Scale engine
    334   \sa setScaleEngine()
    335 */
    336 QwtScaleEngine *QwtAbstractScale::scaleEngine()
    337 {
    338     return d_data->scaleEngine;
    339 }
    340 
    341 /*!
    342   \return Scale boundaries and positions of the ticks
    343 
    344   The scale division might have been assigned explicitly
    345   or calculated implicitly by rescale().
    346  */
    347 const QwtScaleDiv &QwtAbstractScale::scaleDiv() const
    348 {
    349     return d_data->scaleDraw->scaleDiv();
    350 }
    351 
    352 /*!
    353   \return Map to translate between scale and widget coordinates
    354  */
    355 const QwtScaleMap &QwtAbstractScale::scaleMap() const
    356 {
    357     return d_data->scaleDraw->scaleMap();
    358 }
    359 
    360 /*!
    361   Translate a scale value into a widget coordinate
    362 
    363   \param value Scale value
    364   \return Corresponding widget coordinate for value
    365   \sa scaleMap(), invTransform()
     301 */
     302const QwtAbstractScaleDraw* QwtAbstractScale::abstractScaleDraw() const
     303{
     304    return m_data->scaleDraw;
     305}
     306
     307/*!
     308   \brief Set a scale engine
     309
     310   The scale engine is responsible for calculating the scale division
     311   and provides a transformation between scale and widget coordinates.
     312
     313   scaleEngine has to be created with new and will be deleted in
     314   the destructor or the next call of setScaleEngine.
     315 */
     316void QwtAbstractScale::setScaleEngine( QwtScaleEngine* scaleEngine )
     317{
     318    if ( scaleEngine != NULL && scaleEngine != m_data->scaleEngine )
     319    {
     320        delete m_data->scaleEngine;
     321        m_data->scaleEngine = scaleEngine;
     322    }
     323}
     324
     325/*!
     326   \return Scale engine
     327   \sa setScaleEngine()
     328 */
     329const QwtScaleEngine* QwtAbstractScale::scaleEngine() const
     330{
     331    return m_data->scaleEngine;
     332}
     333
     334/*!
     335   \return Scale engine
     336   \sa setScaleEngine()
     337 */
     338QwtScaleEngine* QwtAbstractScale::scaleEngine()
     339{
     340    return m_data->scaleEngine;
     341}
     342
     343/*!
     344   \return Scale boundaries and positions of the ticks
     345
     346   The scale division might have been assigned explicitly
     347   or calculated implicitly by rescale().
     348 */
     349const QwtScaleDiv& QwtAbstractScale::scaleDiv() const
     350{
     351    return m_data->scaleDraw->scaleDiv();
     352}
     353
     354/*!
     355   \return Map to translate between scale and widget coordinates
     356 */
     357const QwtScaleMap& QwtAbstractScale::scaleMap() const
     358{
     359    return m_data->scaleDraw->scaleMap();
     360}
     361
     362/*!
     363   Translate a scale value into a widget coordinate
     364
     365   \param value Scale value
     366   \return Corresponding widget coordinate for value
     367   \sa scaleMap(), invTransform()
    366368 */
    367369int QwtAbstractScale::transform( double value ) const
    368370{
    369     return qRound( d_data->scaleDraw->scaleMap().transform( value ) );
    370 }
    371 
    372 /*!
    373   Translate a widget coordinate into a scale value
    374 
    375   \param value Widget coordinate
    376   \return Corresponding scale coordinate for value
    377   \sa scaleMap(), transform()
     371    return qRound( m_data->scaleDraw->scaleMap().transform( value ) );
     372}
     373
     374/*!
     375   Translate a widget coordinate into a scale value
     376
     377   \param value Widget coordinate
     378   \return Corresponding scale coordinate for value
     379   \sa scaleMap(), transform()
    378380 */
    379381double QwtAbstractScale::invTransform( int value ) const
    380382{
    381     return d_data->scaleDraw->scaleMap().invTransform( value );
    382 }
    383 
    384 /*!
    385   \return True, when the scale is increasing in opposite direction
     383    return m_data->scaleDraw->scaleMap().invTransform( value );
     384}
     385
     386/*!
     387   \return True, when the scale is increasing in opposite direction
    386388          to the widget coordinates
    387389 */
    388390bool QwtAbstractScale::isInverted() const
    389391{
    390     return d_data->scaleDraw->scaleMap().isInverting();
    391 }
    392 
    393 /*!
    394   \return The boundary with the smaller value
    395   \sa maximum(), lowerBound(), upperBound()
     392    return m_data->scaleDraw->scaleMap().isInverting();
     393}
     394
     395/*!
     396   \return The boundary with the smaller value
     397   \sa maximum(), lowerBound(), upperBound()
    396398 */
    397399double QwtAbstractScale::minimum() const
    398400{
    399     return qMin( d_data->scaleDraw->scaleDiv().lowerBound(),
    400         d_data->scaleDraw->scaleDiv().upperBound() );
    401 }
    402 
    403 /*!
    404   \return The boundary with the larger value
    405   \sa minimum(), lowerBound(), upperBound()
     401    return qMin( m_data->scaleDraw->scaleDiv().lowerBound(),
     402        m_data->scaleDraw->scaleDiv().upperBound() );
     403}
     404
     405/*!
     406   \return The boundary with the larger value
     407   \sa minimum(), lowerBound(), upperBound()
    406408 */
    407409double QwtAbstractScale::maximum() const
    408410{
    409     return qMax( d_data->scaleDraw->scaleDiv().lowerBound(),
    410         d_data->scaleDraw->scaleDiv().upperBound() );
     411    return qMax( m_data->scaleDraw->scaleDiv().lowerBound(),
     412        m_data->scaleDraw->scaleDiv().upperBound() );
    411413}
    412414
    … …  
    417419
    418420/*!
    419   Recalculate the scale division and update the scale.
    420 
    421   \param lowerBound Lower limit of the scale interval
    422   \param upperBound Upper limit of the scale interval
    423   \param stepSize Major step size
    424 
    425   \sa scaleChange()
    426 */
     421   Recalculate the scale division and update the scale.
     422
     423   \param lowerBound Lower limit of the scale interval
     424   \param upperBound Upper limit of the scale interval
     425   \param stepSize Major step size
     426
     427   \sa scaleChange()
     428 */
    427429void QwtAbstractScale::rescale(
    428430    double lowerBound, double upperBound, double stepSize )
    429431{
    430     const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale(
    431         lowerBound, upperBound, d_data->maxMajor, d_data->maxMinor, stepSize );
    432 
    433     if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
     432    const QwtScaleDiv scaleDiv = m_data->scaleEngine->divideScale(
     433        lowerBound, upperBound, m_data->maxMajor, m_data->maxMinor, stepSize );
     434
     435    if ( scaleDiv != m_data->scaleDraw->scaleDiv() )
    434436    {
    435437#if 1
    436         d_data->scaleDraw->setTransformation(
    437             d_data->scaleEngine->transformation() );
     438        m_data->scaleDraw->setTransformation(
     439            m_data->scaleEngine->transformation() );
    438440#endif
    439441
    440         d_data->scaleDraw->setScaleDiv( scaleDiv );
     442        m_data->scaleDraw->setScaleDiv( scaleDiv );
    441443        scaleChange();
    442444    }
    443445}
    444446
     447/*!
     448   Change Event handler
     449   \param event Change event
     450
     451   Invalidates internal caches if necessary
     452 */
     453void QwtAbstractScale::changeEvent( QEvent* event )
     454{
     455    if ( event->type() == QEvent::LocaleChange )
     456    {
     457        m_data->scaleDraw->invalidateCache();
     458    }
     459
     460    QWidget::changeEvent( event );
     461}
     462
     463/*!
     464   Recalculate ticks and scale boundaries.
     465 */
    445466void QwtAbstractScale::updateScaleDraw()
    446467{
    447     rescale( d_data->scaleDraw->scaleDiv().lowerBound(),
    448         d_data->scaleDraw->scaleDiv().upperBound(), d_data->stepSize );
    449 }
     468    rescale( m_data->scaleDraw->scaleDiv().lowerBound(),
     469        m_data->scaleDraw->scaleDiv().upperBound(), m_data->stepSize );
     470}
     471
     472#include "moc_qwt_abstract_scale.cpp"
Note: See TracChangeset for help on using the changeset viewer.