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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1010#include "qwt_plot_textlabel.h"
    1111#include "qwt_painter.h"
    12 #include "qwt_scale_map.h"
     12#include "qwt_text.h"
     13#include "qwt_math.h"
     14
    1315#include <qpainter.h>
     16#include <qpaintengine.h>
    1417#include <qpixmap.h>
    15 #include <qmath.h>
    1618
    1719static QRect qwtItemRect( int renderFlags,
    18     const QRectF &rect, const QSizeF &itemSize )
     20    const QRectF& rect, const QSizeF& itemSize )
    1921{
    2022    int x;
    … …  
    5153class QwtPlotTextLabel::PrivateData
    5254{
    53 public:
    54     PrivateData():
    55         margin( 5 )
     55  public:
     56    PrivateData()
     57        : margin( 5 )
    5658    {
    5759    }
    … …  
    7678
    7779   \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
    78 */
    79 
    80 QwtPlotTextLabel::QwtPlotTextLabel():
    81     QwtPlotItem( QwtText( "Label" ) )
    82 {
    83     d_data = new PrivateData;
     80 */
     81
     82QwtPlotTextLabel::QwtPlotTextLabel()
     83    : QwtPlotItem( QwtText( "Label" ) )
     84{
     85    m_data = new PrivateData;
    8486
    8587    setItemAttribute( QwtPlotItem::AutoScale, false );
    … …  
    9294QwtPlotTextLabel::~QwtPlotTextLabel()
    9395{
    94     delete d_data;
     96    delete m_data;
    9597}
    9698
    … …  
    102104
    103105/*!
    104   Set the text
    105 
    106   The label will be aligned to the plot canvas according to
    107   the alignment flags of text.
    108 
    109   \param text Text to be displayed
    110 
    111   \sa text(), QwtText::renderFlags()
    112 */
    113 void QwtPlotTextLabel::setText( const QwtText &text )
    114 {
    115     if ( d_data->text != text )
    116     {
    117         d_data->text = text;
     106   Set the text
     107
     108   The label will be aligned to the plot canvas according to
     109   the alignment flags of text.
     110
     111   \param text Text to be displayed
     112
     113   \sa text(), QwtText::renderFlags()
     114 */
     115void QwtPlotTextLabel::setText( const QwtText& text )
     116{
     117    if ( m_data->text != text )
     118    {
     119        m_data->text = text;
    118120
    119121        invalidateCache();
    … …  
    123125
    124126/*!
    125   \return Text to be displayed
    126   \sa setText()
    127 */
     127   \return Text to be displayed
     128   \sa setText()
     129 */
    128130QwtText QwtPlotTextLabel::text() const
    129131{
    130     return d_data->text;
    131 }
    132 
    133 /*!
    134   Set the margin
    135 
    136   The margin is the distance between the contentsRect()
    137   of the plot canvas and the rectangle where the label can
    138   be displayed.
    139 
    140   \param margin Margin
    141 
    142   \sa margin(), textRect()
     132    return m_data->text;
     133}
     134
     135/*!
     136   Set the margin
     137
     138   The margin is the distance between the contentsRect()
     139   of the plot canvas and the rectangle where the label can
     140   be displayed.
     141
     142   \param margin Margin
     143
     144   \sa margin(), textRect()
    143145 */
    144146void QwtPlotTextLabel::setMargin( int margin )
    145147{
    146148    margin = qMax( margin, 0 );
    147     if ( d_data->margin != margin )
    148     {
    149         d_data->margin = margin;
     149    if ( m_data->margin != margin )
     150    {
     151        m_data->margin = margin;
    150152        itemChanged();
    151153    }
    … …  
    153155
    154156/*!
    155   \return Margin added to the contentsMargins() of the canvas
    156   \sa setMargin()
    157 */
     157   \return Margin added to the contentsMargins() of the canvas
     158   \sa setMargin()
     159 */
    158160int QwtPlotTextLabel::margin() const
    159161{
    160     return d_data->margin;
    161 }
    162 
    163 /*!
    164   Draw the text label
    165 
    166   \param painter Painter
    167   \param xMap x Scale Map
    168   \param yMap y Scale Map
    169   \param canvasRect Contents rectangle of the canvas in painter coordinates
    170 
    171   \sa textRect()
    172 */
    173 
    174 void QwtPlotTextLabel::draw( QPainter *painter,
    175     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    176     const QRectF &canvasRect ) const
     162    return m_data->margin;
     163}
     164
     165/*!
     166   Draw the text label
     167
     168   \param painter Painter
     169   \param xMap x Scale Map
     170   \param yMap y Scale Map
     171   \param canvasRect Contents rectangle of the canvas in painter coordinates
     172
     173   \sa textRect()
     174 */
     175
     176void QwtPlotTextLabel::draw( QPainter* painter,
     177    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     178    const QRectF& canvasRect ) const
    177179{
    178180    Q_UNUSED( xMap );
    179181    Q_UNUSED( yMap );
    180182
    181     const int m = d_data->margin;
     183    const int m = m_data->margin;
    182184
    183185    const QRectF rect = textRect( canvasRect.adjusted( m, m, -m, -m ),
    184         d_data->text.textSize( painter->font() ) );
     186        m_data->text.textSize( painter->font() ) );
    185187
    186188    bool doCache = QwtPainter::roundingAlignment( painter );
    … …  
    208210
    209211        int pw = 0;
    210         if ( d_data->text.borderPen().style() != Qt::NoPen )
    211             pw = qMax( d_data->text.borderPen().width(), 1 );
     212        if ( m_data->text.borderPen().style() != Qt::NoPen )
     213            pw = qMax( m_data->text.borderPen().width(), 1 );
    212214
    213215        QRect pixmapRect;
    214         pixmapRect.setLeft( qFloor( rect.left() ) - pw );
    215         pixmapRect.setTop( qFloor( rect.top() ) - pw );
    216         pixmapRect.setRight( qCeil( rect.right() ) + pw );
    217         pixmapRect.setBottom( qCeil( rect.bottom() ) + pw );
    218 
    219 #define QWT_HIGH_DPI 1
    220 
    221 #if QT_VERSION >= 0x050100 && QWT_HIGH_DPI
    222         const qreal pixelRatio = painter->device()->devicePixelRatio();
     216        pixmapRect.setLeft( qwtFloor( rect.left() ) - pw );
     217        pixmapRect.setTop( qwtFloor( rect.top() ) - pw );
     218        pixmapRect.setRight( qwtCeil( rect.right() ) + pw );
     219        pixmapRect.setBottom( qwtCeil( rect.bottom() ) + pw );
     220
     221#if QT_VERSION >= 0x050000
     222        const qreal pixelRatio = QwtPainter::devicePixelRatio( painter->device() );
    223223        const QSize scaledSize = pixmapRect.size() * pixelRatio;
    224224#else
    225225        const QSize scaledSize = pixmapRect.size();
    226226#endif
    227         if ( d_data->pixmap.isNull() ||
    228             ( scaledSize != d_data->pixmap.size() )  )
     227
     228        if ( m_data->pixmap.isNull() ||
     229            ( scaledSize != m_data->pixmap.size() ) )
    229230        {
    230             d_data->pixmap = QPixmap( scaledSize );
    231 #if QT_VERSION >= 0x050100 && QWT_HIGH_DPI
    232             d_data->pixmap.setDevicePixelRatio( pixelRatio );
     231            m_data->pixmap = QPixmap( scaledSize );
     232#if QT_VERSION >= 0x050000
     233            m_data->pixmap.setDevicePixelRatio( pixelRatio );
    233234#endif
    234             d_data->pixmap.fill( Qt::transparent );
     235            m_data->pixmap.fill( Qt::transparent );
    235236
    236237            const QRect r( pw, pw,
    237238                pixmapRect.width() - 2 * pw, pixmapRect.height() - 2 * pw );
    238239
    239             QPainter pmPainter( &d_data->pixmap );
    240             d_data->text.draw( &pmPainter, r );
     240            QPainter pmPainter( &m_data->pixmap );
     241            m_data->text.draw( &pmPainter, r );
    241242        }
    242243
    243         painter->drawPixmap( pixmapRect, d_data->pixmap );
     244        painter->drawPixmap( pixmapRect, m_data->pixmap );
    244245    }
    245246    else
    246247    {
    247         d_data->text.draw( painter, rect );
     248        m_data->text.draw( painter, rect );
    248249    }
    249250}
    … …  
    261262 */
    262263QRectF QwtPlotTextLabel::textRect(
    263     const QRectF &rect, const QSizeF &textSize ) const
    264 {
    265     return qwtItemRect( d_data->text.renderFlags(), rect, textSize );
     264    const QRectF& rect, const QSizeF& textSize ) const
     265{
     266    return qwtItemRect( m_data->text.renderFlags(), rect, textSize );
    266267}
    267268
    … …  
    269270void QwtPlotTextLabel::invalidateCache()
    270271{
    271     d_data->pixmap = QPixmap();
    272 }
     272    m_data->pixmap = QPixmap();
     273}
Note: See TracChangeset for help on using the changeset viewer.