Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_scale_draw.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_scale_draw.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1313#include "qwt_math.h"
    1414#include "qwt_painter.h"
    15 #include <qpen.h>
     15#include "qwt_text.h"
     16
    1617#include <qpainter.h>
     18#include <qpaintengine.h>
    1719#include <qmath.h>
    1820
    19 #if QT_VERSION < 0x040601
    20 #define qFastSin(x) qSin(x)
    21 #define qFastCos(x) qCos(x)
     21static inline double qwtEffectivePenWidth( const QwtAbstractScaleDraw* scaleDraw )
     22{
     23    return qwtMaxF( scaleDraw->penWidthF(), 1.0 );
     24}
     25
     26namespace QwtScaleRendererReal
     27{
     28    inline qreal penWidth( const QPainter* painter, const QwtScaleDraw* scaleDraw )
     29    {
     30        qreal width = scaleDraw->penWidthF();
     31#if 1
     32        if ( width <= 0.0 )
     33            width = 1.0;
    2234#endif
    2335
     36        if ( painter->pen().isCosmetic() )
     37        {
     38            const QTransform& transform = painter->transform();
     39
     40            switch ( scaleDraw->alignment() )
     41            {
     42                case QwtScaleDraw::LeftScale:
     43                case QwtScaleDraw::RightScale:
     44                {
     45                    width /= transform.m11();
     46                    break;
     47                }
     48                case QwtScaleDraw::TopScale:
     49                case QwtScaleDraw::BottomScale:
     50                {
     51                    width /= transform.m22();
     52                    break;
     53                }
     54            }
     55        }
     56
     57        return width;
     58    }
     59
     60    inline void drawBackbone( QPainter* painter, const QwtScaleDraw* scaleDraw )
     61    {
     62        const qreal pw2 = 0.5 * penWidth( painter, scaleDraw );
     63
     64        const QPointF pos = scaleDraw->pos();
     65        const qreal length = scaleDraw->length();
     66
     67        switch ( scaleDraw->alignment() )
     68        {
     69            case QwtScaleDraw::LeftScale:
     70            {
     71                const qreal x = pos.x() + 1.0 - pw2;
     72                QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length );
     73
     74                break;
     75            }
     76            case QwtScaleDraw::RightScale:
     77            {
     78                const qreal x = pos.x() - 1.0 + pw2;
     79                QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length );
     80
     81                break;
     82            }
     83            case QwtScaleDraw::TopScale:
     84            {
     85                const qreal y = pos.y() + 1.0 - pw2;
     86                QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y );
     87
     88                break;
     89            }
     90            case QwtScaleDraw::BottomScale:
     91            {
     92                const qreal y = pos.y() - 1.0 + pw2;
     93                QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y );
     94
     95                break;
     96            }
     97        }
     98    }
     99
     100    inline void drawTick( QPainter* painter,
     101        const QwtScaleDraw* scaleDraw, qreal tickPos, qreal tickLength )
     102    {
     103        const QPointF pos = scaleDraw->pos();
     104
     105        qreal pw = 0.0;
     106
     107        if ( scaleDraw->hasComponent( QwtScaleDraw::Backbone ) )
     108            pw = penWidth( painter, scaleDraw );
     109
     110        const qreal length = tickLength + pw;
     111
     112        /*
     113            Those correction offsets have been found by try and error.
     114            They need to be understood and replaced by a calculation,
     115            that makes sense. TODO ...
     116         */
     117        const qreal off1 = 1.0;
     118        const qreal off2 = ( scaleDraw->penWidthF() <= 0.0 ) ? 0.5 : 0.0;
     119
     120        switch ( scaleDraw->alignment() )
     121        {
     122            case QwtScaleDraw::LeftScale:
     123            {
     124                const qreal x = pos.x() + off1 - off2;
     125                QwtPainter::drawLine( painter, x, tickPos, x - length, tickPos );
     126
     127                break;
     128            }
     129            case QwtScaleDraw::RightScale:
     130            {
     131                const qreal x = pos.x() - off1 + off2;
     132                QwtPainter::drawLine( painter, x, tickPos, x + length, tickPos );
     133                break;
     134            }
     135            case QwtScaleDraw::TopScale:
     136            {
     137                const qreal y = pos.y() + off1 - 2 * off2;
     138                QwtPainter::drawLine( painter, tickPos, y, tickPos, y - length );
     139
     140                break;
     141            }
     142            case QwtScaleDraw::BottomScale:
     143            {
     144                const qreal y = pos.y() - off1 + off2;
     145                QwtPainter::drawLine( painter, tickPos, y, tickPos, y + length );
     146
     147                break;
     148            }
     149        }
     150    }
     151}
     152
     153namespace QwtScaleRendererInt
     154{
     155    inline void drawBackbone( QPainter* painter, const QwtScaleDraw* scaleDraw )
     156    {
     157        const int pw = qMax( qRound( scaleDraw->penWidthF() ), 1 );
     158
     159        const qreal length = scaleDraw->length();
     160        const QPointF pos = scaleDraw->pos();
     161
     162        switch ( scaleDraw->alignment() )
     163        {
     164            case QwtScaleDraw::LeftScale:
     165            {
     166                const qreal x = qRound( pos.x() - ( pw - 1 ) / 2 );
     167                QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length );
     168
     169                break;
     170            }
     171            case QwtScaleDraw::RightScale:
     172            {
     173                const qreal x = qRound( pos.x() + pw / 2 );
     174                QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + length );
     175
     176                break;
     177            }
     178            case QwtScaleDraw::TopScale:
     179            {
     180                const qreal y = qRound( pos.y() - ( pw - 1 ) / 2 );
     181                QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y );
     182
     183                break;
     184            }
     185            case QwtScaleDraw::BottomScale:
     186            {
     187                const qreal y = qRound( pos.y() + pw / 2 );
     188                QwtPainter::drawLine( painter, pos.x(), y, pos.x() + length, y );
     189
     190                break;
     191            }
     192        }
     193    }
     194
     195    inline void drawTick( QPainter* painter,
     196        const QwtScaleDraw* scaleDraw, qreal tickPos, qreal tickLength )
     197    {
     198        const QPointF pos = scaleDraw->pos();
     199        tickPos = qRound( tickPos );
     200
     201        int pw = 0;
     202        if ( scaleDraw->hasComponent( QwtScaleDraw::Backbone ) )
     203            pw = qMax( qRound( scaleDraw->penWidthF() ), 1 );
     204
     205        int len = qMax( qRound( tickLength ), 1 );
     206
     207        // the width of ticks at the borders might extent the backbone
     208        len += pw;
     209
     210        if ( painter->pen().capStyle() == Qt::FlatCap )
     211            len++; // the end point is not rendered
     212
     213        qreal off = 0.0;
     214
     215        if ( painter->paintEngine()->type() == QPaintEngine::X11 )
     216        {
     217            if ( pw == 1 )
     218            {
     219                // In opposite to raster, X11 paints the end point
     220                off = 1.0;
     221            }
     222        }
     223
     224        switch ( scaleDraw->alignment() )
     225        {
     226            case QwtScaleDraw::LeftScale:
     227            {
     228                const qreal x1 = qRound( pos.x() ) + 1;
     229                const qreal x2 = x1 - len + 1;
     230
     231                QwtPainter::drawLine( painter, x2, tickPos, x1 - off, tickPos );
     232
     233                break;
     234            }
     235            case QwtScaleDraw::RightScale:
     236            {
     237                const qreal x1 = qRound( pos.x() );
     238                const qreal x2 = x1 + len - 1;
     239
     240                QwtPainter::drawLine( painter, x1, tickPos, x2 - off, tickPos );
     241
     242                break;
     243            }
     244            case QwtScaleDraw::BottomScale:
     245            {
     246                const qreal y1 = qRound( pos.y() );
     247                const qreal y2 = y1 + len - 1;
     248
     249                QwtPainter::drawLine( painter, tickPos, y1, tickPos, y2 - off );
     250
     251                break;
     252            }
     253            case QwtScaleDraw::TopScale:
     254            {
     255                const qreal y1 = qRound( pos.y() );
     256                const qreal y2 = y1 - len + 1;
     257
     258                QwtPainter::drawLine( painter, tickPos, y2 + 1, tickPos, y1 + 1 - off );
     259
     260                break;
     261            }
     262        }
     263    }
     264}
     265
    24266class QwtScaleDraw::PrivateData
    25267{
    26 public:
    27     PrivateData():
    28         len( 0 ),
    29         alignment( QwtScaleDraw::BottomScale ),
    30         labelAlignment( 0 ),
    31         labelRotation( 0.0 )
     268  public:
     269    PrivateData()
     270        : len( 0 )
     271        , alignment( QwtScaleDraw::BottomScale )
     272        , labelRotation( 0.0 )
    32273    {
    33274    }
    … …  
    43284
    44285/*!
    45   \brief Constructor
    46 
    47   The range of the scale is initialized to [0, 100],
    48   The position is at (0, 0) with a length of 100.
    49   The orientation is QwtAbstractScaleDraw::Bottom.
    50 */
     286   \brief Constructor
     287
     288   The range of the scale is initialized to [0, 100],
     289   The position is at (0, 0) with a length of 100.
     290   The orientation is QwtAbstractScaleDraw::Bottom.
     291 */
    51292QwtScaleDraw::QwtScaleDraw()
    52293{
    53     d_data = new QwtScaleDraw::PrivateData;
     294    m_data = new QwtScaleDraw::PrivateData;
    54295    setLength( 100 );
    55296}
    … …  
    58299QwtScaleDraw::~QwtScaleDraw()
    59300{
    60     delete d_data;
     301    delete m_data;
    61302}
    62303
    … …  
    65306   \sa setAlignment()
    66307   \return Alignment of the scale
    67 */
     308 */
    68309QwtScaleDraw::Alignment QwtScaleDraw::alignment() const
    69310{
    70     return d_data->alignment;
     311    return m_data->alignment;
    71312}
    72313
    … …  
    78319   The default alignment is QwtScaleDraw::BottomScale
    79320   \sa alignment()
    80 */
     321 */
    81322void QwtScaleDraw::setAlignment( Alignment align )
    82323{
    83     d_data->alignment = align;
    84 }
    85 
    86 /*!
    87   Return the orientation
    88 
    89   TopScale, BottomScale are horizontal (Qt::Horizontal) scales,
    90   LeftScale, RightScale are vertical (Qt::Vertical) scales.
    91 
    92   \return Orientation of the scale
    93 
    94   \sa alignment()
    95 */
     324    m_data->alignment = align;
     325}
     326
     327/*!
     328   Return the orientation
     329
     330   TopScale, BottomScale are horizontal (Qt::Horizontal) scales,
     331   LeftScale, RightScale are vertical (Qt::Vertical) scales.
     332
     333   \return Orientation of the scale
     334
     335   \sa alignment()
     336 */
    96337Qt::Orientation QwtScaleDraw::orientation() const
    97338{
    98     switch ( d_data->alignment )
     339    switch ( m_data->alignment )
    99340    {
    100341        case TopScale:
    … …  
    109350
    110351/*!
    111   \brief Determine the minimum border distance
    112 
    113   This member function returns the minimum space
    114   needed to draw the mark labels at the scale's endpoints.
    115 
    116   \param font Font
    117   \param start Start border distance
    118   \param end End border distance
    119 */
     352   \brief Determine the minimum border distance
     353
     354   This member function returns the minimum space
     355   needed to draw the mark labels at the scale's endpoints.
     356
     357   \param font Font
     358   \param start Start border distance
     359   \param end End border distance
     360 */
    120361void QwtScaleDraw::getBorderDistHint(
    121     const QFont &font, int &start, int &end ) const
     362    const QFont& font, int& start, int& end ) const
    122363{
    123364    start = 0;
    … …  
    127368        return;
    128369
    129     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
     370    const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
    130371    if ( ticks.count() == 0 )
    131372        return;
    … …  
    179420        e = 0.0;
    180421
    181     start = qCeil( s );
    182     end = qCeil( e );
    183 }
    184 
    185 /*!
    186   Determine the minimum distance between two labels, that is necessary
    187   that the texts don't overlap.
    188 
    189   \param font Font
    190   \return The maximum width of a label
    191 
    192   \sa getBorderDistHint()
    193 */
    194 
    195 int QwtScaleDraw::minLabelDist( const QFont &font ) const
     422    start = qwtCeil( s );
     423    end = qwtCeil( e );
     424}
     425
     426/*!
     427   Determine the minimum distance between two labels, that is necessary
     428   that the texts don't overlap.
     429
     430   \param font Font
     431   \return The maximum width of a label
     432
     433   \sa getBorderDistHint()
     434 */
     435
     436int QwtScaleDraw::minLabelDist( const QFont& font ) const
    196437{
    197438    if ( !hasComponent( QwtAbstractScaleDraw::Labels ) )
    198439        return 0;
    199440
    200     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
     441    const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
    201442    if ( ticks.isEmpty() )
    202443        return 0;
    … …  
    279520
    280521   \sa minLength()
    281 */
    282 double QwtScaleDraw::extent( const QFont &font ) const
     522 */
     523double QwtScaleDraw::extent( const QFont& font ) const
    283524{
    284525    double d = 0;
    … …  
    302543    if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
    303544    {
    304         const double pw = qMax( 1, penWidth() );  // pen width can be zero
    305         d += pw;
    306     }
    307 
    308     d = qMax( d, minimumExtent() );
     545        d += qwtEffectivePenWidth( this );
     546    }
     547
     548    d = qwtMaxF( d, minimumExtent() );
    309549    return d;
    310550}
    … …  
    317557
    318558   \sa extent()
    319 */
    320 int QwtScaleDraw::minLength( const QFont &font ) const
     559 */
     560int QwtScaleDraw::minLength( const QFont& font ) const
    321561{
    322562    int startDist, endDist;
    323563    getBorderDistHint( font, startDist, endDist );
    324564
    325     const QwtScaleDiv &sd = scaleDiv();
     565    const QwtScaleDiv& sd = scaleDiv();
    326566
    327567    const uint minorCount =
    … …  
    338578    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
    339579    {
    340         const double pw = qMax( 1, penWidth() );  // penwidth can be zero
     580        const double pw = qwtEffectivePenWidth( this );
    341581        lengthForTicks = qCeil( ( majorCount + minorCount ) * ( pw + 1.0 ) );
    342582    }
    … …  
    353593   \param value Value
    354594   \return Position, where to paint a label
    355 */
     595 */
    356596QPointF QwtScaleDraw::labelPosition( double value ) const
    357597{
    … …  
    359599    double dist = spacing();
    360600    if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
    361         dist += qMax( 1, penWidth() );
     601        dist += qwtEffectivePenWidth( this );
    362602
    363603    if ( hasComponent( QwtAbstractScaleDraw::Ticks ) )
    … …  
    371611        case RightScale:
    372612        {
    373             px = d_data->pos.x() + dist;
     613            px = m_data->pos.x() + dist;
    374614            py = tval;
    375615            break;
    … …  
    377617        case LeftScale:
    378618        {
    379             px = d_data->pos.x() - dist;
     619            px = m_data->pos.x() - dist;
    380620            py = tval;
    381621            break;
    … …  
    384624        {
    385625            px = tval;
    386             py = d_data->pos.y() + dist;
     626            py = m_data->pos.y() + dist;
    387627            break;
    388628        }
    … …  
    390630        {
    391631            px = tval;
    392             py = d_data->pos.y() - dist;
     632            py = m_data->pos.y() - dist;
    393633            break;
    394634        }
    … …  
    406646
    407647   \sa drawBackbone(), drawLabel()
    408 */
    409 void QwtScaleDraw::drawTick( QPainter *painter, double value, double len ) const
     648 */
     649void QwtScaleDraw::drawTick( QPainter* painter, double value, double len ) const
    410650{
    411651    if ( len <= 0 )
    412652        return;
    413653
    414     const bool roundingAlignment = QwtPainter::roundingAlignment( painter );
    415 
    416     QPointF pos = d_data->pos;
    417 
    418     double tval = scaleMap().transform( value );
    419     if ( roundingAlignment )
    420         tval = qRound( tval );
    421 
    422     const int pw = penWidth();
    423     int a = 0;
    424     if ( pw > 1 && roundingAlignment )
    425         a = 1;
    426 
    427     switch ( alignment() )
    428     {
    429         case LeftScale:
    430         {
    431             double x1 = pos.x() + a;
    432             double x2 = pos.x() + a - pw - len;
    433             if ( roundingAlignment )
    434             {
    435                 x1 = qRound( x1 );
    436                 x2 = qRound( x2 );
    437             }
    438 
    439             QwtPainter::drawLine( painter, x1, tval, x2, tval );
    440             break;
    441         }
    442 
    443         case RightScale:
    444         {
    445             double x1 = pos.x();
    446             double x2 = pos.x() + pw + len;
    447             if ( roundingAlignment )
    448             {
    449                 x1 = qRound( x1 );
    450                 x2 = qRound( x2 );
    451             }
    452 
    453             QwtPainter::drawLine( painter, x1, tval, x2, tval );
    454             break;
    455         }
    456 
    457         case BottomScale:
    458         {
    459             double y1 = pos.y();
    460             double y2 = pos.y() + pw + len;
    461             if ( roundingAlignment )
    462             {
    463                 y1 = qRound( y1 );
    464                 y2 = qRound( y2 );
    465             }
    466 
    467             QwtPainter::drawLine( painter, tval, y1, tval, y2 );
    468             break;
    469         }
    470 
    471         case TopScale:
    472         {
    473             double y1 = pos.y() + a;
    474             double y2 = pos.y() - pw - len + a;
    475             if ( roundingAlignment )
    476             {
    477                 y1 = qRound( y1 );
    478                 y2 = qRound( y2 );
    479             }
    480 
    481             QwtPainter::drawLine( painter, tval, y1, tval, y2 );
    482             break;
    483         }
    484     }
     654    const double tval = scaleMap().transform( value );
     655
     656    if ( QwtPainter::roundingAlignment( painter ) )
     657        QwtScaleRendererInt::drawTick( painter, this, tval, len );
     658    else
     659        QwtScaleRendererReal::drawTick( painter, this, tval, len );
    485660}
    486661
    … …  
    490665
    491666   \sa drawTick(), drawLabel()
    492 */
    493 void QwtScaleDraw::drawBackbone( QPainter *painter ) const
    494 {
    495     const bool doAlign = QwtPainter::roundingAlignment( painter );
    496 
    497     const QPointF &pos = d_data->pos;
    498     const double len = d_data->len;
    499     const int pw = qMax( penWidth(), 1 );
    500 
    501     // pos indicates a border not the center of the backbone line
    502     // so we need to shift its position depending on the pen width
    503     // and the alignment of the scale
    504 
    505     double off;
    506     if ( doAlign )
    507     {
    508         if ( alignment() == LeftScale || alignment() == TopScale )
    509             off = ( pw - 1 ) / 2;
    510         else
    511             off = pw / 2;
    512     }
     667 */
     668void QwtScaleDraw::drawBackbone( QPainter* painter ) const
     669{
     670    if ( QwtPainter::roundingAlignment( painter ) )
     671        QwtScaleRendererInt::drawBackbone( painter, this );
    513672    else
    514     {
    515         off = 0.5 * penWidth();
    516     }
    517 
    518     switch ( alignment() )
    519     {
    520         case LeftScale:
    521         {
    522             double x = pos.x() - off;
    523             if ( doAlign )
    524                 x = qRound( x );
    525 
    526             QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + len );
    527             break;
    528         }
    529         case RightScale:
    530         {
    531             double x = pos.x() + off;
    532             if ( doAlign )
    533                 x = qRound( x );
    534 
    535             QwtPainter::drawLine( painter, x, pos.y(), x, pos.y() + len );
    536             break;
    537         }
    538         case TopScale:
    539         {
    540             double y = pos.y() - off;
    541             if ( doAlign )
    542                 y = qRound( y );
    543 
    544             QwtPainter::drawLine( painter, pos.x(), y, pos.x() + len, y );
    545             break;
    546         }
    547         case BottomScale:
    548         {
    549             double y = pos.y() + off;
    550             if ( doAlign )
    551                 y = qRound( y );
    552 
    553             QwtPainter::drawLine( painter, pos.x(), y, pos.x() + len, y );
    554             break;
    555         }
    556     }
    557 }
    558 
    559 /*!
    560   \brief Move the position of the scale
    561 
    562   The meaning of the parameter pos depends on the alignment:
    563   <dl>
    564   <dt>QwtScaleDraw::LeftScale
    565   <dd>The origin is the topmost point of the
     673        QwtScaleRendererReal::drawBackbone( painter, this );
     674}
     675
     676/*!
     677   \brief Move the position of the scale
     678
     679   The meaning of the parameter pos depends on the alignment:
     680   <dl>
     681   <dt>QwtScaleDraw::LeftScale
     682   <dd>The origin is the topmost point of the
    566683      backbone. The backbone is a vertical line.
    567684      Scale marks and labels are drawn
    568685      at the left of the backbone.
    569   <dt>QwtScaleDraw::RightScale
    570   <dd>The origin is the topmost point of the
     686   <dt>QwtScaleDraw::RightScale
     687   <dd>The origin is the topmost point of the
    571688      backbone. The backbone is a vertical line.
    572689      Scale marks and labels are drawn
    573690      at the right of the backbone.
    574   <dt>QwtScaleDraw::TopScale
    575   <dd>The origin is the leftmost point of the
     691   <dt>QwtScaleDraw::TopScale
     692   <dd>The origin is the leftmost point of the
    576693      backbone. The backbone is a horizontal line.
    577694      Scale marks and labels are drawn
    578695      above the backbone.
    579   <dt>QwtScaleDraw::BottomScale
    580   <dd>The origin is the leftmost point of the
     696   <dt>QwtScaleDraw::BottomScale
     697   <dd>The origin is the leftmost point of the
    581698      backbone. The backbone is a horizontal line
    582699      Scale marks and labels are drawn
    583700      below the backbone.
    584   </dl>
    585 
    586   \param pos Origin of the scale
    587 
    588   \sa pos(), setLength()
    589 */
    590 void QwtScaleDraw::move( const QPointF &pos )
    591 {
    592     d_data->pos = pos;
     701   </dl>
     702
     703   \param pos Origin of the scale
     704
     705   \sa pos(), setLength()
     706 */
     707void QwtScaleDraw::move( const QPointF& pos )
     708{
     709    m_data->pos = pos;
    593710    updateMap();
    594711}
    … …  
    597714   \return Origin of the scale
    598715   \sa move(), length()
    599 */
     716 */
    600717QPointF QwtScaleDraw::pos() const
    601718{
    602     return d_data->pos;
    603 }
    604 
    605 /*!
    606   Set the length of the backbone.
    607 
    608   The length doesn't include the space needed for
    609   overlapping labels.
    610 
    611   \param length Length of the backbone
    612 
    613   \sa move(), minLabelDist()
    614 */
     719    return m_data->pos;
     720}
     721
     722/*!
     723   Set the length of the backbone.
     724
     725   The length doesn't include the space needed for
     726   overlapping labels.
     727
     728   \param length Length of the backbone
     729
     730   \sa move(), minLabelDist()
     731 */
    615732void QwtScaleDraw::setLength( double length )
    616733{
    617 #if 1
    618734    if ( length >= 0 && length < 10 )
    619735        length = 10;
    620736
    621     // why should we accept negative lengths ???
     737    // f.e the left/bottom scales of a polar plot
    622738    if ( length < 0 && length > -10 )
    623739        length = -10;
    624 #else
    625     length = qMax( length, 10 );
    626 #endif
    627 
    628     d_data->len = length;
     740
     741    m_data->len = length;
    629742    updateMap();
    630743}
    … …  
    633746   \return the length of the backbone
    634747   \sa setLength(), pos()
    635 */
     748 */
    636749double QwtScaleDraw::length() const
    637750{
    638     return d_data->len;
     751    return m_data->len;
    639752}
    640753
    … …  
    646759
    647760   \sa drawTick(), drawBackbone(), boundingLabelRect()
    648 */
    649 void QwtScaleDraw::drawLabel( QPainter *painter, double value ) const
     761 */
     762void QwtScaleDraw::drawLabel( QPainter* painter, double value ) const
    650763{
    651764    QwtText lbl = tickLabel( painter->font(), value );
    … …  
    668781
    669782/*!
    670   \brief Find the bounding rectangle for the label.
    671 
    672   The coordinates of the rectangle are absolute ( calculated from pos() ).
    673   in direction of the tick.
    674 
    675   \param font Font used for painting
    676   \param value Value
    677 
    678   \return Bounding rectangle
    679   \sa labelRect()
    680 */
    681 QRect QwtScaleDraw::boundingLabelRect( const QFont &font, double value ) const
     783   \brief Find the bounding rectangle for the label.
     784
     785   The coordinates of the rectangle are absolute ( calculated from pos() ).
     786   in direction of the tick.
     787
     788   \param font Font used for painting
     789   \param value Value
     790
     791   \return Bounding rectangle
     792   \sa labelRect()
     793 */
     794QRect QwtScaleDraw::boundingLabelRect( const QFont& font, double value ) const
    682795{
    683796    QwtText lbl = tickLabel( font, value );
    … …  
    701814   \return Transformation matrix
    702815   \sa setLabelAlignment(), setLabelRotation()
    703 */
     816 */
    704817QTransform QwtScaleDraw::labelTransformation(
    705     const QPointF &pos, const QSizeF &size ) const
     818    const QPointF& pos, const QSizeF& size ) const
    706819{
    707820    QTransform transform;
    … …  
    763876
    764877/*!
    765   Find the bounding rectangle for the label. The coordinates of
    766   the rectangle are relative to spacing + tick length from the backbone
    767   in direction of the tick.
    768 
    769   \param font Font used for painting
    770   \param value Value
     878   Find the bounding rectangle for the label. The coordinates of
     879   the rectangle are relative to spacing + tick length from the backbone
     880   in direction of the tick.
     881
     882   \param font Font used for painting
     883   \param value Value
    771884
    772885   \return Bounding rectangle that is needed to draw a label
    773 */
    774 QRectF QwtScaleDraw::labelRect( const QFont &font, double value ) const
     886 */
     887QRectF QwtScaleDraw::labelRect( const QFont& font, double value ) const
    775888{
    776889    QwtText lbl = tickLabel( font, value );
    … …  
    796909
    797910   \return Size that is needed to draw a label
    798 */
    799 QSizeF QwtScaleDraw::labelSize( const QFont &font, double value ) const
     911 */
     912QSizeF QwtScaleDraw::labelSize( const QFont& font, double value ) const
    800913{
    801914    return labelRect( font, value ).size();
    … …  
    803916
    804917/*!
    805   Rotate all labels.
    806 
    807   When changing the rotation, it might be necessary to
    808   adjust the label flags too. Finding a useful combination is
    809   often the result of try and error.
    810 
    811   \param rotation Angle in degrees. When changing the label rotation,
     918   Rotate all labels.
     919
     920   When changing the rotation, it might be necessary to
     921   adjust the label flags too. Finding a useful combination is
     922   often the result of try and error.
     923
     924   \param rotation Angle in degrees. When changing the label rotation,
    812925                  the label flags often needs to be adjusted too.
    813926
    814   \sa setLabelAlignment(), labelRotation(), labelAlignment().
    815 
    816 */
     927   \sa setLabelAlignment(), labelRotation(), labelAlignment().
     928
     929 */
    817930void QwtScaleDraw::setLabelRotation( double rotation )
    818931{
    819     d_data->labelRotation = rotation;
    820 }
    821 
    822 /*!
    823   \return the label rotation
    824   \sa setLabelRotation(), labelAlignment()
    825 */
     932    m_data->labelRotation = rotation;
     933}
     934
     935/*!
     936   \return the label rotation
     937   \sa setLabelRotation(), labelAlignment()
     938 */
    826939double QwtScaleDraw::labelRotation() const
    827940{
    828     return d_data->labelRotation;
    829 }
    830 
    831 /*!
    832   \brief Change the label flags
    833 
    834   Labels are aligned to the point tick length + spacing away from the backbone.
    835 
    836   The alignment is relative to the orientation of the label text.
    837   In case of an flags of 0 the label will be aligned
    838   depending on the orientation of the scale:
     941    return m_data->labelRotation;
     942}
     943
     944/*!
     945   \brief Change the label flags
     946
     947   Labels are aligned to the point tick length + spacing away from the backbone.
     948
     949   The alignment is relative to the orientation of the label text.
     950   In case of an flags of 0 the label will be aligned
     951   depending on the orientation of the scale:
    839952
    840953      QwtScaleDraw::TopScale: Qt::AlignHCenter | Qt::AlignTop\n
    … …  
    843956      QwtScaleDraw::RightScale: Qt::AlignRight | Qt::AlignVCenter\n
    844957
    845   Changing the alignment is often necessary for rotated labels.
    846 
    847   \param alignment Or'd Qt::AlignmentFlags see <qnamespace.h>
    848 
    849   \sa setLabelRotation(), labelRotation(), labelAlignment()
    850   \warning The various alignments might be confusing.
     958   Changing the alignment is often necessary for rotated labels.
     959
     960   \param alignment Or'd Qt::AlignmentFlags see <qnamespace.h>
     961
     962   \sa setLabelRotation(), labelRotation(), labelAlignment()
     963   \warning The various alignments might be confusing.
    851964           The alignment of the label is not the alignment
    852965           of the scale and is not the alignment of the flags
    853966           ( QwtText::flags() ) returned from QwtAbstractScaleDraw::label().
    854 */
     967 */
    855968
    856969void QwtScaleDraw::setLabelAlignment( Qt::Alignment alignment )
    857970{
    858     d_data->labelAlignment = alignment;
    859 }
    860 
    861 /*!
    862   \return the label flags
    863   \sa setLabelAlignment(), labelRotation()
    864 */
     971    m_data->labelAlignment = alignment;
     972}
     973
     974/*!
     975   \return the label flags
     976   \sa setLabelAlignment(), labelRotation()
     977 */
    865978Qt::Alignment QwtScaleDraw::labelAlignment() const
    866979{
    867     return d_data->labelAlignment;
    868 }
    869 
    870 /*!
    871   \param font Font
    872   \return the maximum width of a label
    873 */
    874 int QwtScaleDraw::maxLabelWidth( const QFont &font ) const
     980    return m_data->labelAlignment;
     981}
     982
     983/*!
     984   \param font Font
     985   \return the maximum width of a label
     986 */
     987int QwtScaleDraw::maxLabelWidth( const QFont& font ) const
    875988{
    876989    double maxWidth = 0.0;
    877990
    878     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
     991    const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
    879992    for ( int i = 0; i < ticks.count(); i++ )
    880993    {
    … …  
    8921005
    8931006/*!
    894   \param font Font
    895   \return the maximum height of a label
    896 */
    897 int QwtScaleDraw::maxLabelHeight( const QFont &font ) const
     1007   \param font Font
     1008   \return the maximum height of a label
     1009 */
     1010int QwtScaleDraw::maxLabelHeight( const QFont& font ) const
    8981011{
    8991012    double maxHeight = 0.0;
    9001013
    901     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
     1014    const QList< double >& ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
    9021015    for ( int i = 0; i < ticks.count(); i++ )
    9031016    {
    … …  
    9161029void QwtScaleDraw::updateMap()
    9171030{
    918     const QPointF pos = d_data->pos;
    919     double len = d_data->len;
    920 
    921     QwtScaleMap &sm = scaleMap();
     1031    const QPointF pos = m_data->pos;
     1032    double len = m_data->len;
     1033
     1034    QwtScaleMap& sm = scaleMap();
    9221035    if ( orientation() == Qt::Vertical )
    9231036        sm.setPaintInterval( pos.y() + len, pos.y() );
Note: See TracChangeset for help on using the changeset viewer.