Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_thermo.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_thermo.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_thermo.h"
    11 #include "qwt_scale_engine.h"
    1211#include "qwt_scale_draw.h"
    1312#include "qwt_scale_map.h"
    1413#include "qwt_color_map.h"
     14#include "qwt_math.h"
     15
    1516#include <qpainter.h>
    1617#include <qevent.h>
    … …  
    1819#include <qstyle.h>
    1920#include <qstyleoption.h>
    20 #include <qmath.h>
    21 
    22 static inline void qwtDrawLine( QPainter *painter, int pos,
    23     const QColor &color, const QRect &pipeRect, const QRect &liquidRect,
     21#include <qmargins.h>
     22
     23#include <algorithm>
     24#include <functional>
     25
     26static inline void qwtDrawLine( QPainter* painter, int pos,
     27    const QColor& color, const QRect& pipeRect, const QRect& liquidRect,
    2428    Qt::Orientation orientation )
    2529{
    … …  
    3741}
    3842
    39 QVector<double> qwtTickList( const QwtScaleDiv &scaleDiv )
    40 {
    41     QVector<double> values;
     43static QVector< double > qwtTickList( const QwtScaleDiv& scaleDiv )
     44{
     45    QVector< double > values;
    4246
    4347    double lowerLimit = scaleDiv.interval().minValue();
    … …  
    5256        tickType < QwtScaleDiv::NTickTypes; tickType++ )
    5357    {
    54         const QList<double> ticks = scaleDiv.ticks( tickType );
     58        const QList< double > ticks = scaleDiv.ticks( tickType );
    5559
    5660        for ( int i = 0; i < ticks.count(); i++ )
    … …  
    6973class QwtThermo::PrivateData
    7074{
    71 public:
    72     PrivateData():
    73         orientation( Qt::Vertical ),
    74         scalePosition( QwtThermo::TrailingScale ),
    75         spacing( 3 ),
    76         borderWidth( 2 ),
    77         pipeWidth( 10 ),
    78         alarmLevel( 0.0 ),
    79         alarmEnabled( false ),
    80         autoFillPipe( true ),
    81         originMode( QwtThermo::OriginMinimum ),
    82         origin( 0.0 ),
    83         colorMap( NULL ),
    84         value( 0.0 )
     75  public:
     76    PrivateData()
     77        : orientation( Qt::Vertical )
     78        , scalePosition( QwtThermo::TrailingScale )
     79        , spacing( 3 )
     80        , borderWidth( 2 )
     81        , pipeWidth( 10 )
     82        , alarmLevel( 0.0 )
     83        , alarmEnabled( false )
     84        , autoFillPipe( true )
     85        , originMode( QwtThermo::OriginMinimum )
     86        , origin( 0.0 )
     87        , colorMap( NULL )
     88        , value( 0.0 )
    8589    {
    8690        rangeFlags = QwtInterval::IncludeBorders;
    … …  
    106110    double origin;
    107111
    108     QwtColorMap *colorMap;
     112    QwtColorMap* colorMap;
    109113
    110114    double value;
    … …  
    112116
    113117/*!
    114   Constructor
    115   \param parent Parent widget
    116 */
    117 QwtThermo::QwtThermo( QWidget *parent ):
    118     QwtAbstractScale( parent )
    119 {
    120     d_data = new PrivateData;
     118   Constructor
     119   \param parent Parent widget
     120 */
     121QwtThermo::QwtThermo( QWidget* parent )
     122    : QwtAbstractScale( parent )
     123{
     124    m_data = new PrivateData;
    121125
    122126    QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
    123     if ( d_data->orientation == Qt::Vertical )
     127    if ( m_data->orientation == Qt::Vertical )
    124128        policy.transpose();
    125129
    … …  
    133137QwtThermo::~QwtThermo()
    134138{
    135     delete d_data;
    136 }
    137 
    138 /*!
    139   \brief Exclude/Include min/max values
    140 
    141   According to the flags minValue() and maxValue()
    142   are included/excluded from the pipe. In case of an
    143   excluded value the corresponding tick is painted
    144   1 pixel off of the pipeRect().
    145 
    146   F.e. when a minimum
    147   of 0.0 has to be displayed as an empty pipe the minValue()
    148   needs to be excluded.
    149 
    150   \param flags Range flags
    151   \sa rangeFlags()
    152 */
     139    delete m_data;
     140}
     141
     142/*!
     143   \brief Exclude/Include min/max values
     144
     145   According to the flags minValue() and maxValue()
     146   are included/excluded from the pipe. In case of an
     147   excluded value the corresponding tick is painted
     148   1 pixel off of the pipeRect().
     149
     150   F.e. when a minimum
     151   of 0.0 has to be displayed as an empty pipe the minValue()
     152   needs to be excluded.
     153
     154   \param flags Range flags
     155   \sa rangeFlags()
     156 */
    153157void QwtThermo::setRangeFlags( QwtInterval::BorderFlags flags )
    154158{
    155     if ( d_data->rangeFlags != flags )
    156     {
    157         d_data->rangeFlags = flags;
     159    if ( m_data->rangeFlags != flags )
     160    {
     161        m_data->rangeFlags = flags;
    158162        update();
    159163    }
    … …  
    161165
    162166/*!
    163   \return Range flags
    164   \sa setRangeFlags()
    165 */
     167   \return Range flags
     168   \sa setRangeFlags()
     169 */
    166170QwtInterval::BorderFlags QwtThermo::rangeFlags() const
    167171{
    168     return d_data->rangeFlags;
    169 }
    170 
    171 /*!
    172   Set the current value.
    173 
    174   \param value New Value
    175   \sa value()
    176 */
     172    return m_data->rangeFlags;
     173}
     174
     175/*!
     176   Set the current value.
     177
     178   \param value New Value
     179   \sa value()
     180 */
    177181void QwtThermo::setValue( double value )
    178182{
    179     if ( d_data->value != value )
    180     {
    181         d_data->value = value;
     183    if ( m_data->value != value )
     184    {
     185        m_data->value = value;
    182186        update();
    183187    }
    … …  
    187191double QwtThermo::value() const
    188192{
    189     return d_data->value;
    190 }
    191 
    192 /*!
    193   \brief Set a scale draw
    194 
    195   For changing the labels of the scales, it
    196   is necessary to derive from QwtScaleDraw and
    197   overload QwtScaleDraw::label().
    198 
    199   \param scaleDraw ScaleDraw object, that has to be created with
     193    return m_data->value;
     194}
     195
     196/*!
     197   \brief Set a scale draw
     198
     199   For changing the labels of the scales, it
     200   is necessary to derive from QwtScaleDraw and
     201   overload QwtScaleDraw::label().
     202
     203   \param scaleDraw ScaleDraw object, that has to be created with
    200204                   new and will be deleted in ~QwtThermo() or the next
    201205                   call of setScaleDraw().
    202 */
    203 void QwtThermo::setScaleDraw( QwtScaleDraw *scaleDraw )
     206 */
     207void QwtThermo::setScaleDraw( QwtScaleDraw* scaleDraw )
    204208{
    205209    setAbstractScaleDraw( scaleDraw );
    … …  
    210214   \return the scale draw of the thermo
    211215   \sa setScaleDraw()
    212 */
    213 const QwtScaleDraw *QwtThermo::scaleDraw() const
    214 {
    215     return static_cast<const QwtScaleDraw *>( abstractScaleDraw() );
     216 */
     217const QwtScaleDraw* QwtThermo::scaleDraw() const
     218{
     219    return static_cast< const QwtScaleDraw* >( abstractScaleDraw() );
    216220}
    217221
    … …  
    219223   \return the scale draw of the thermo
    220224   \sa setScaleDraw()
    221 */
    222 QwtScaleDraw *QwtThermo::scaleDraw()
    223 {
    224     return static_cast<QwtScaleDraw *>( abstractScaleDraw() );
    225 }
    226 
    227 /*!
    228   Paint event handler
    229   \param event Paint event
    230 */
    231 void QwtThermo::paintEvent( QPaintEvent *event )
     225 */
     226QwtScaleDraw* QwtThermo::scaleDraw()
     227{
     228    return static_cast< QwtScaleDraw* >( abstractScaleDraw() );
     229}
     230
     231/*!
     232   Paint event handler
     233   \param event Paint event
     234 */
     235void QwtThermo::paintEvent( QPaintEvent* event )
    232236{
    233237    QPainter painter( this );
    … …  
    235239
    236240    QStyleOption opt;
    237     opt.init(this);
     241    opt.initFrom(this);
    238242    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
    239243
    … …  
    242246    if ( !tRect.contains( event->rect() ) )
    243247    {
    244         if ( d_data->scalePosition != QwtThermo::NoScale )
     248        if ( m_data->scalePosition != QwtThermo::NoScale )
    245249            scaleDraw()->draw( &painter, palette() );
    246250    }
    247251
    248     const int bw = d_data->borderWidth;
     252    const int bw = m_data->borderWidth;
    249253
    250254    const QBrush brush = palette().brush( QPalette::Base );
    … …  
    252256        tRect.adjusted( -bw, -bw, bw, bw ),
    253257        palette(), true, bw,
    254         d_data->autoFillPipe ? &brush : NULL );
     258        m_data->autoFillPipe ? &brush : NULL );
    255259
    256260    drawLiquid( &painter, tRect );
    … …  
    258262
    259263/*!
    260   Resize event handler
    261   \param event Resize event
    262 */
    263 void QwtThermo::resizeEvent( QResizeEvent *event )
     264   Resize event handler
     265   \param event Resize event
     266 */
     267void QwtThermo::resizeEvent( QResizeEvent* event )
    264268{
    265269    Q_UNUSED( event );
    … …  
    268272
    269273/*!
    270   Qt change event handler
    271   \param event Event
    272 */
    273 void QwtThermo::changeEvent( QEvent *event )
     274   Qt change event handler
     275   \param event Event
     276 */
     277void QwtThermo::changeEvent( QEvent* event )
    274278{
    275279    switch( event->type() )
    … …  
    287291
    288292/*!
    289   Recalculate the QwtThermo geometry and layout based on
    290   pipeRect() and the fonts.
    291 
    292   \param update_geometry notify the layout system and call update
     293   Recalculate the QwtThermo geometry and layout based on
     294   pipeRect() and the fonts.
     295
     296   \param update_geometry notify the layout system and call update
    293297         to redraw the scale
    294 */
     298 */
    295299void QwtThermo::layoutThermo( bool update_geometry )
    296300{
    297301    const QRect tRect = pipeRect();
    298     const int bw = d_data->borderWidth + d_data->spacing;
     302    const int bw = m_data->borderWidth + m_data->spacing;
    299303    const bool inverted = ( upperBound() < lowerBound() );
    300304
    301305    int from, to;
    302306
    303     if ( d_data->orientation == Qt::Horizontal )
     307    if ( m_data->orientation == Qt::Horizontal )
    304308    {
    305309        from = tRect.left();
    306310        to = tRect.right();
    307311
    308         if ( d_data->rangeFlags & QwtInterval::ExcludeMinimum )
     312        if ( m_data->rangeFlags & QwtInterval::ExcludeMinimum )
    309313        {
    310314            if ( inverted )
    … …  
    313317                from--;
    314318        }
    315         if ( d_data->rangeFlags & QwtInterval::ExcludeMaximum )
     319        if ( m_data->rangeFlags & QwtInterval::ExcludeMaximum )
    316320        {
    317321            if ( inverted )
    … …  
    321325        }
    322326
    323         if ( d_data->scalePosition == QwtThermo::TrailingScale )
     327        if ( m_data->scalePosition == QwtThermo::TrailingScale )
    324328        {
    325329            scaleDraw()->setAlignment( QwtScaleDraw::TopScale );
    … …  
    339343        to = tRect.bottom();
    340344
    341         if ( d_data->rangeFlags & QwtInterval::ExcludeMinimum )
     345        if ( m_data->rangeFlags & QwtInterval::ExcludeMinimum )
    342346        {
    343347            if ( inverted )
    … …  
    346350                to++;
    347351        }
    348         if ( d_data->rangeFlags & QwtInterval::ExcludeMaximum )
     352        if ( m_data->rangeFlags & QwtInterval::ExcludeMaximum )
    349353        {
    350354            if ( inverted )
    … …  
    354358        }
    355359
    356         if ( d_data->scalePosition == QwtThermo::LeadingScale )
     360        if ( m_data->scalePosition == QwtThermo::LeadingScale )
    357361        {
    358362            scaleDraw()->setAlignment( QwtScaleDraw::RightScale );
    … …  
    376380
    377381/*!
    378   \return Bounding rectangle of the pipe ( without borders )
     382   \return Bounding rectangle of the pipe ( without borders )
    379383          in widget coordinates
    380 */
     384 */
    381385QRect QwtThermo::pipeRect() const
    382386{
    383387    int mbd = 0;
    384     if ( d_data->scalePosition != QwtThermo::NoScale )
     388    if ( m_data->scalePosition != QwtThermo::NoScale )
    385389    {
    386390        int d1, d2;
    … …  
    388392        mbd = qMax( d1, d2 );
    389393    }
    390     const int bw = d_data->borderWidth;
     394    const int bw = m_data->borderWidth;
    391395    const int scaleOff = bw + mbd;
    392396
    … …  
    394398
    395399    QRect pipeRect = cr;
    396     if ( d_data->orientation == Qt::Horizontal )
     400    if ( m_data->orientation == Qt::Horizontal )
    397401    {
    398402        pipeRect.adjust( scaleOff, 0, -scaleOff, 0 );
    399403
    400         if ( d_data->scalePosition == QwtThermo::TrailingScale )
    401             pipeRect.setTop( cr.top() + cr.height() - bw - d_data->pipeWidth );
     404        if ( m_data->scalePosition == QwtThermo::TrailingScale )
     405            pipeRect.setTop( cr.top() + cr.height() - bw - m_data->pipeWidth );
    402406        else
    403407            pipeRect.setTop( bw );
    404408
    405         pipeRect.setHeight( d_data->pipeWidth );
     409        pipeRect.setHeight( m_data->pipeWidth );
    406410    }
    407411    else // Qt::Vertical
    … …  
    409413        pipeRect.adjust( 0, scaleOff, 0, -scaleOff );
    410414
    411         if ( d_data->scalePosition == QwtThermo::LeadingScale )
     415        if ( m_data->scalePosition == QwtThermo::LeadingScale )
    412416            pipeRect.setLeft( bw );
    413417        else
    414             pipeRect.setLeft( cr.left() + cr.width() - bw - d_data->pipeWidth );
    415 
    416         pipeRect.setWidth( d_data->pipeWidth );
     418            pipeRect.setLeft( cr.left() + cr.width() - bw - m_data->pipeWidth );
     419
     420        pipeRect.setWidth( m_data->pipeWidth );
    417421    }
    418422
    … …  
    421425
    422426/*!
    423   \brief Set the orientation.
    424   \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
    425 
    426   \sa orientation(), scalePosition()
    427 */
     427   \brief Set the orientation.
     428   \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
     429
     430   \sa orientation(), scalePosition()
     431 */
    428432void QwtThermo::setOrientation( Qt::Orientation orientation )
    429433{
    430     if ( orientation == d_data->orientation )
     434    if ( orientation == m_data->orientation )
    431435        return;
    432436
    433     d_data->orientation = orientation;
     437    m_data->orientation = orientation;
    434438
    435439    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
    … …  
    446450
    447451/*!
    448   \return Orientation
    449   \sa setOrientation()
    450 */
     452   \return Orientation
     453   \sa setOrientation()
     454 */
    451455Qt::Orientation QwtThermo::orientation() const
    452456{
    453     return d_data->orientation;
    454 }
    455 
    456 /*!
    457   \brief Change how the origin is determined.
    458   \sa originMode(), serOrigin(), origin()
     457    return m_data->orientation;
     458}
     459
     460/*!
     461   \brief Change how the origin is determined.
     462   \sa originMode(), serOrigin(), origin()
    459463 */
    460464void QwtThermo::setOriginMode( OriginMode m )
    461465{
    462     if ( m == d_data->originMode )
     466    if ( m == m_data->originMode )
    463467        return;
    464468
    465     d_data->originMode = m;
     469    m_data->originMode = m;
    466470    update();
    467471}
    468472
    469473/*!
    470   \return Mode, how the origin is determined.
    471   \sa setOriginMode(), serOrigin(), origin()
     474   \return Mode, how the origin is determined.
     475   \sa setOriginMode(), serOrigin(), origin()
    472476 */
    473477QwtThermo::OriginMode QwtThermo::originMode() const
    474478{
    475     return d_data->originMode;
    476 }
    477 
    478 /*!
    479   \brief Specifies the custom origin.
    480 
    481   If originMode is set to OriginCustom this property controls where the
    482   liquid starts.
    483 
    484   \param origin New origin level
    485   \sa setOriginMode(), originMode(), origin()
     479    return m_data->originMode;
     480}
     481
     482/*!
     483   \brief Specifies the custom origin.
     484
     485   If originMode is set to OriginCustom this property controls where the
     486   liquid starts.
     487
     488   \param origin New origin level
     489   \sa setOriginMode(), originMode(), origin()
    486490 */
    487491void QwtThermo::setOrigin( double origin )
    488492{
    489     if ( origin == d_data->origin )
     493    if ( origin == m_data->origin )
    490494        return;
    491495
    492     d_data->origin = origin;
     496    m_data->origin = origin;
    493497    update();
    494498}
    495499
    496500/*!
    497   \return Origin of the thermo, when OriginCustom is enabled
    498   \sa setOrigin(), setOriginMode(), originMode()
     501   \return Origin of the thermo, when OriginCustom is enabled
     502   \sa setOrigin(), setOriginMode(), originMode()
    499503 */
    500504double QwtThermo::origin() const
    501505{
    502     return d_data->origin;
    503 }
    504 
    505 /*!
    506   \brief Change the position of the scale
    507   \param scalePosition Position of the scale.
    508 
    509   \sa ScalePosition, scalePosition()
    510 */
     506    return m_data->origin;
     507}
     508
     509/*!
     510   \brief Change the position of the scale
     511   \param scalePosition Position of the scale.
     512
     513   \sa ScalePosition, scalePosition()
     514 */
    511515void QwtThermo::setScalePosition( ScalePosition scalePosition )
    512516{
    513     if ( d_data->scalePosition == scalePosition )
     517    if ( m_data->scalePosition == scalePosition )
    514518        return;
    515519
    516     d_data->scalePosition = scalePosition;
     520    m_data->scalePosition = scalePosition;
    517521
    518522    if ( testAttribute( Qt::WA_WState_Polished ) )
    … …  
    523527   \return Scale position.
    524528   \sa setScalePosition()
    525 */
     529 */
    526530QwtThermo::ScalePosition QwtThermo::scalePosition() const
    527531{
    528     return d_data->scalePosition;
     532    return m_data->scalePosition;
    529533}
    530534
    … …  
    539543   \param painter Painter
    540544   \param pipeRect Bounding rectangle of the pipe without borders
    541 */
     545 */
    542546void QwtThermo::drawLiquid(
    543     QPainter *painter, const QRect &pipeRect ) const
     547    QPainter* painter, const QRect& pipeRect ) const
    544548{
    545549    painter->save();
    … …  
    551555    QRect liquidRect = fillRect( pipeRect );
    552556
    553     if ( d_data->colorMap != NULL )
     557    if ( m_data->colorMap != NULL )
    554558    {
    555559        const QwtInterval interval = scaleDiv().interval().normalized();
    … …  
    558562        // we calculate the colors for the rounded tick values
    559563
    560         QVector<double> values = qwtTickList( scaleDraw()->scaleDiv() );
     564        QVector< double > values = qwtTickList( scaleDraw()->scaleDiv() );
    561565
    562566        if ( scaleMap.isInverting() )
    563             qSort( values.begin(), values.end(), qGreater<double>() );
     567            std::sort( values.begin(), values.end(), std::greater< double >() );
    564568        else
    565             qSort( values.begin(), values.end(), qLess<double>() );
     569            std::sort( values.begin(), values.end(), std::less< double >() );
    566570
    567571        int from;
    … …  
    570574            from = qRound( scaleMap.transform( values[0] ) );
    571575            qwtDrawLine( painter, from,
    572                 d_data->colorMap->color( interval, values[0] ),
    573                 pipeRect, liquidRect, d_data->orientation );
     576                m_data->colorMap->color( interval, values[0] ),
     577                pipeRect, liquidRect, m_data->orientation );
    574578        }
    575579
    … …  
    583587
    584588                qwtDrawLine( painter, pos,
    585                     d_data->colorMap->color( interval, v ),
    586                     pipeRect, liquidRect, d_data->orientation );
     589                    m_data->colorMap->color( interval, v ),
     590                    pipeRect, liquidRect, m_data->orientation );
    587591            }
    588592
    589593            qwtDrawLine( painter, to,
    590                 d_data->colorMap->color( interval, values[i] ),
    591                 pipeRect, liquidRect, d_data->orientation );
     594                m_data->colorMap->color( interval, values[i] ),
     595                pipeRect, liquidRect, m_data->orientation );
    592596
    593597            from = to;
    … …  
    596600    else
    597601    {
    598         if ( !liquidRect.isEmpty() && d_data->alarmEnabled )
     602        if ( !liquidRect.isEmpty() && m_data->alarmEnabled )
    599603        {
    600604            const QRect r = alarmRect( liquidRect );
    … …  
    613617
    614618/*!
    615   \brief Change the spacing between pipe and scale
    616 
    617   A spacing of 0 means, that the backbone of the scale is below
    618   the pipe.
    619 
    620   The default setting is 3 pixels.
    621 
    622   \param spacing Number of pixels
    623   \sa spacing();
    624 */
     619   \brief Change the spacing between pipe and scale
     620
     621   A spacing of 0 means, that the backbone of the scale is below
     622   the pipe.
     623
     624   The default setting is 3 pixels.
     625
     626   \param spacing Number of pixels
     627   \sa spacing();
     628 */
    625629void QwtThermo::setSpacing( int spacing )
    626630{
    … …  
    628632        spacing = 0;
    629633
    630     if ( spacing != d_data->spacing  )
    631     {
    632         d_data->spacing = spacing;
     634    if ( spacing != m_data->spacing  )
     635    {
     636        m_data->spacing = spacing;
    633637        layoutThermo( true );
    634638    }
    … …  
    636640
    637641/*!
    638   \return Number of pixels between pipe and scale
    639   \sa setSpacing()
    640 */
     642   \return Number of pixels between pipe and scale
     643   \sa setSpacing()
     644 */
    641645int QwtThermo::spacing() const
    642646{
    643     return d_data->spacing;
     647    return m_data->spacing;
    644648}
    645649
    … …  
    648652   \param width Border width
    649653   \sa borderWidth()
    650 */
     654 */
    651655void QwtThermo::setBorderWidth( int width )
    652656{
    … …  
    654658        width = 0;
    655659
    656     if ( width != d_data->borderWidth  )
    657     {
    658         d_data->borderWidth = width;
     660    if ( width != m_data->borderWidth  )
     661    {
     662        m_data->borderWidth = width;
    659663        layoutThermo( true );
    660664    }
    … …  
    664668   \return Border width of the thermometer pipe.
    665669   \sa setBorderWidth()
    666 */
     670 */
    667671int QwtThermo::borderWidth() const
    668672{
    669     return d_data->borderWidth;
    670 }
    671 
    672 /*!
    673   \brief Assign a color map for the fill color
    674 
    675   \param colorMap Color map
    676   \warning The alarm threshold has no effect, when
     673    return m_data->borderWidth;
     674}
     675
     676/*!
     677   \brief Assign a color map for the fill color
     678
     679   \param colorMap Color map
     680   \warning The alarm threshold has no effect, when
    677681           a color map has been assigned
    678 */
    679 void QwtThermo::setColorMap( QwtColorMap *colorMap )
    680 {
    681     if ( colorMap != d_data->colorMap )
    682     {
    683         delete d_data->colorMap;
    684         d_data->colorMap = colorMap;
    685     }
    686 }
    687 
    688 /*!
    689   \return Color map for the fill color
    690   \warning The alarm threshold has no effect, when
     682 */
     683void QwtThermo::setColorMap( QwtColorMap* colorMap )
     684{
     685    if ( colorMap != m_data->colorMap )
     686    {
     687        delete m_data->colorMap;
     688        m_data->colorMap = colorMap;
     689    }
     690}
     691
     692/*!
     693   \return Color map for the fill color
     694   \warning The alarm threshold has no effect, when
    691695           a color map has been assigned
    692 */
    693 QwtColorMap *QwtThermo::colorMap()
    694 {
    695     return d_data->colorMap;
    696 }
    697 
    698 /*!
    699   \return Color map for the fill color
    700   \warning The alarm threshold has no effect, when
     696 */
     697QwtColorMap* QwtThermo::colorMap()
     698{
     699    return m_data->colorMap;
     700}
     701
     702/*!
     703   \return Color map for the fill color
     704   \warning The alarm threshold has no effect, when
    701705           a color map has been assigned
    702 */
    703 const QwtColorMap *QwtThermo::colorMap() const
    704 {
    705     return d_data->colorMap;
    706 }
    707 
    708 /*!
    709   \brief Change the brush of the liquid.
    710 
    711   Changes the QPalette::ButtonText brush of the palette.
    712 
    713   \param brush New brush.
    714   \sa fillBrush(), QWidget::setPalette()
    715 */
     706 */
     707const QwtColorMap* QwtThermo::colorMap() const
     708{
     709    return m_data->colorMap;
     710}
     711
     712/*!
     713   \brief Change the brush of the liquid.
     714
     715   Changes the QPalette::ButtonText brush of the palette.
     716
     717   \param brush New brush.
     718   \sa fillBrush(), QWidget::setPalette()
     719 */
    716720void QwtThermo::setFillBrush( const QBrush& brush )
    717721{
    … …  
    722726
    723727/*!
    724   \return Liquid ( QPalette::ButtonText ) brush.
    725   \sa setFillBrush(), QWidget::palette()
    726 */
     728   \return Liquid ( QPalette::ButtonText ) brush.
     729   \sa setFillBrush(), QWidget::palette()
     730 */
    727731QBrush QwtThermo::fillBrush() const
    728732{
    … …  
    731735
    732736/*!
    733   \brief Specify the liquid brush above the alarm threshold
    734 
    735   Changes the QPalette::Highlight brush of the palette.
    736 
    737   \param brush New brush.
    738   \sa alarmBrush(), QWidget::setPalette()
    739 
    740   \warning The alarm threshold has no effect, when
     737   \brief Specify the liquid brush above the alarm threshold
     738
     739   Changes the QPalette::Highlight brush of the palette.
     740
     741   \param brush New brush.
     742   \sa alarmBrush(), QWidget::setPalette()
     743
     744   \warning The alarm threshold has no effect, when
    741745           a color map has been assigned
    742 */
     746 */
    743747void QwtThermo::setAlarmBrush( const QBrush& brush )
    744748{
    … …  
    749753
    750754/*!
    751   \return Liquid brush ( QPalette::Highlight ) above the alarm threshold.
    752   \sa setAlarmBrush(), QWidget::palette()
    753 
    754   \warning The alarm threshold has no effect, when
     755   \return Liquid brush ( QPalette::Highlight ) above the alarm threshold.
     756   \sa setAlarmBrush(), QWidget::palette()
     757
     758   \warning The alarm threshold has no effect, when
    755759           a color map has been assigned
    756 */
     760 */
    757761QBrush QwtThermo::alarmBrush() const
    758762{
    … …  
    761765
    762766/*!
    763   Specify the alarm threshold.
    764 
    765   \param level Alarm threshold
    766   \sa alarmLevel()
    767 
    768   \warning The alarm threshold has no effect, when
     767   Specify the alarm threshold.
     768
     769   \param level Alarm threshold
     770   \sa alarmLevel()
     771
     772   \warning The alarm threshold has no effect, when
    769773           a color map has been assigned
    770 */
     774 */
    771775void QwtThermo::setAlarmLevel( double level )
    772776{
    773     d_data->alarmLevel = level;
    774     d_data->alarmEnabled = 1;
     777    m_data->alarmLevel = level;
     778    m_data->alarmEnabled = 1;
    775779    update();
    776780}
    777781
    778782/*!
    779   \return Alarm threshold.
    780   \sa setAlarmLevel()
    781 
    782   \warning The alarm threshold has no effect, when
     783   \return Alarm threshold.
     784   \sa setAlarmLevel()
     785
     786   \warning The alarm threshold has no effect, when
    783787           a color map has been assigned
    784 */
     788 */
    785789double QwtThermo::alarmLevel() const
    786790{
    787     return d_data->alarmLevel;
    788 }
    789 
    790 /*!
    791   Change the width of the pipe.
    792 
    793   \param width Width of the pipe
    794   \sa pipeWidth()
    795 */
     791    return m_data->alarmLevel;
     792}
     793
     794/*!
     795   Change the width of the pipe.
     796
     797   \param width Width of the pipe
     798   \sa pipeWidth()
     799 */
    796800void QwtThermo::setPipeWidth( int width )
    797801{
    798802    if ( width > 0 )
    799803    {
    800         d_data->pipeWidth = width;
     804        m_data->pipeWidth = width;
    801805        layoutThermo( true );
    802806    }
    … …  
    804808
    805809/*!
    806   \return Width of the pipe.
    807   \sa setPipeWidth()
    808 */
     810   \return Width of the pipe.
     811   \sa setPipeWidth()
     812 */
    809813int QwtThermo::pipeWidth() const
    810814{
    811     return d_data->pipeWidth;
    812 }
    813 
    814 /*!
    815   \brief Enable or disable the alarm threshold
    816   \param on true (disabled) or false (enabled)
    817 
    818   \warning The alarm threshold has no effect, when
     815    return m_data->pipeWidth;
     816}
     817
     818/*!
     819   \brief Enable or disable the alarm threshold
     820   \param on true (disabled) or false (enabled)
     821
     822   \warning The alarm threshold has no effect, when
    819823           a color map has been assigned
    820 */
     824 */
    821825void QwtThermo::setAlarmEnabled( bool on )
    822826{
    823     d_data->alarmEnabled = on;
     827    m_data->alarmEnabled = on;
    824828    update();
    825829}
    826830
    827831/*!
    828   \return True, when the alarm threshold is enabled.
    829 
    830   \warning The alarm threshold has no effect, when
     832   \return True, when the alarm threshold is enabled.
     833
     834   \warning The alarm threshold has no effect, when
    831835           a color map has been assigned
    832 */
     836 */
    833837bool QwtThermo::alarmEnabled() const
    834838{
    835     return d_data->alarmEnabled;
    836 }
    837 
    838 /*!
    839   \return the minimum size hint
    840   \sa minimumSizeHint()
    841 */
     839    return m_data->alarmEnabled;
     840}
     841
     842/*!
     843   \return the minimum size hint
     844   \sa minimumSizeHint()
     845 */
    842846QSize QwtThermo::sizeHint() const
    843847{
    … …  
    846850
    847851/*!
    848   \return Minimum size hint
    849   \warning The return value depends on the font and the scale.
    850   \sa sizeHint()
    851 */
     852   \return Minimum size hint
     853   \warning The return value depends on the font and the scale.
     854   \sa sizeHint()
     855 */
    852856QSize QwtThermo::minimumSizeHint() const
    853857{
    854858    int w = 0, h = 0;
    855859
    856     if ( d_data->scalePosition != NoScale )
    857     {
    858         const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
     860    if ( m_data->scalePosition != NoScale )
     861    {
     862        const int sdExtent = qwtCeil( scaleDraw()->extent( font() ) );
    859863        const int sdLength = scaleDraw()->minLength( font() );
    860864
    861865        w = sdLength;
    862         h = d_data->pipeWidth + sdExtent + d_data->spacing;
     866        h = m_data->pipeWidth + sdExtent + m_data->spacing;
    863867
    864868    }
    … …  
    866870    {
    867871        w = 200;
    868         h = d_data->pipeWidth;
    869     }
    870 
    871     if ( d_data->orientation == Qt::Vertical )
     872        h = m_data->pipeWidth;
     873    }
     874
     875    if ( m_data->orientation == Qt::Vertical )
    872876        qSwap( w, h );
    873877
    874     w += 2 * d_data->borderWidth;
    875     h += 2 * d_data->borderWidth;
     878    w += 2 * m_data->borderWidth;
     879    h += 2 * m_data->borderWidth;
    876880
    877881    // finally add the margins
    878     int left, right, top, bottom;
    879     getContentsMargins( &left, &top, &right, &bottom );
    880     w += left + right;
    881     h += top + bottom;
     882    const QMargins m = contentsMargins();
     883    w += m.left() + m.right();
     884    h += m.top() + m.bottom();
    882885
    883886    return QSize( w, h );
    … …  
    885888
    886889/*!
    887   \brief Calculate the filled rectangle of the pipe
    888 
    889   \param pipeRect Rectangle of the pipe
    890   \return Rectangle to be filled ( fill and alarm brush )
    891 
    892   \sa pipeRect(), alarmRect()
    893  */
    894 QRect QwtThermo::fillRect( const QRect &pipeRect ) const
     890   \brief Calculate the filled rectangle of the pipe
     891
     892   \param pipeRect Rectangle of the pipe
     893   \return Rectangle to be filled ( fill and alarm brush )
     894
     895   \sa pipeRect(), alarmRect()
     896 */
     897QRect QwtThermo::fillRect( const QRect& pipeRect ) const
    895898{
    896899    double origin;
    897     if ( d_data->originMode == OriginMinimum )
     900    if ( m_data->originMode == OriginMinimum )
    898901    {
    899902        origin = qMin( lowerBound(), upperBound() );
    900903    }
    901     else if ( d_data->originMode == OriginMaximum )
     904    else if ( m_data->originMode == OriginMaximum )
    902905    {
    903906        origin = qMax( lowerBound(), upperBound() );
    … …  
    905908    else // OriginCustom
    906909    {
    907         origin = d_data->origin;
     910        origin = m_data->origin;
    908911    }
    909912
    910913    const QwtScaleMap scaleMap = scaleDraw()->scaleMap();
    911914
    912     int from = qRound( scaleMap.transform( d_data->value ) );
     915    int from = qRound( scaleMap.transform( m_data->value ) );
    913916    int to = qRound( scaleMap.transform( origin ) );
    914917
    … …  
    917920
    918921    QRect fillRect = pipeRect;
    919     if ( d_data->orientation == Qt::Horizontal )
     922    if ( m_data->orientation == Qt::Horizontal )
    920923    {
    921924        fillRect.setLeft( from );
    … …  
    932935
    933936/*!
    934   \brief Calculate the alarm rectangle of the pipe
    935 
    936   \param fillRect Filled rectangle in the pipe
    937   \return Rectangle to be filled with the alarm brush
    938 
    939   \sa pipeRect(), fillRect(), alarmLevel(), alarmBrush()
    940  */
    941 QRect QwtThermo::alarmRect( const QRect &fillRect ) const
     937   \brief Calculate the alarm rectangle of the pipe
     938
     939   \param fillRect Filled rectangle in the pipe
     940   \return Rectangle to be filled with the alarm brush
     941
     942   \sa pipeRect(), fillRect(), alarmLevel(), alarmBrush()
     943 */
     944QRect QwtThermo::alarmRect( const QRect& fillRect ) const
    942945{
    943946    QRect alarmRect( 0, 0, -1, -1); // something invalid
    944947
    945     if ( !d_data->alarmEnabled )
     948    if ( !m_data->alarmEnabled )
    946949        return alarmRect;
    947950
    … …  
    949952
    950953    bool increasing;
    951     if ( d_data->originMode == OriginCustom )
    952     {
    953         increasing = d_data->value > d_data->origin;
     954    if ( m_data->originMode == OriginCustom )
     955    {
     956        increasing = m_data->value > m_data->origin;
    954957    }
    955958    else
    956959    {
    957         increasing = d_data->originMode == OriginMinimum;
     960        increasing = m_data->originMode == OriginMinimum;
    958961    }
    959962
    960963    const QwtScaleMap map = scaleDraw()->scaleMap();
    961     const int alarmPos = qRound( map.transform( d_data->alarmLevel ) );
    962     const int valuePos = qRound( map.transform( d_data->value ) );
    963 
    964     if ( d_data->orientation == Qt::Horizontal )
     964    const int alarmPos = qRound( map.transform( m_data->alarmLevel ) );
     965    const int valuePos = qRound( map.transform( m_data->value ) );
     966
     967    if ( m_data->orientation == Qt::Horizontal )
    965968    {
    966969        int v1, v2;
    … …  
    10041007    return alarmRect;
    10051008}
     1009
     1010#include "moc_qwt_thermo.cpp"
Note: See TracChangeset for help on using the changeset viewer.