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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1313#include "qwt_plot_canvas.h"
    1414#include "qwt_plot_seriesitem.h"
     15
    1516#include <qpainter.h>
    1617#include <qevent.h>
    17 #include <qapplication.h>
    1818#include <qpixmap.h>
    1919
    2020static inline void qwtRenderItem(
    21     QPainter *painter, const QRect &canvasRect,
    22     QwtPlotSeriesItem *seriesItem, int from, int to )
     21    QPainter* painter, const QRect& canvasRect,
     22    QwtPlotSeriesItem* seriesItem, int from, int to )
    2323{
    2424    // A minor performance improvement is possible
    2525    // with caching the maps. TODO ...
    2626
    27     QwtPlot *plot = seriesItem->plot();
     27    QwtPlot* plot = seriesItem->plot();
    2828    const QwtScaleMap xMap = plot->canvasMap( seriesItem->xAxis() );
    2929    const QwtScaleMap yMap = plot->canvasMap( seriesItem->yAxis() );
    … …  
    3434}
    3535
    36 static inline bool qwtHasBackingStore( const QwtPlotCanvas *canvas )
     36static inline bool qwtHasBackingStore( const QwtPlotCanvas* canvas )
    3737{
    3838    return canvas->testPaintAttribute( QwtPlotCanvas::BackingStore )
    39         && canvas->backingStore() && !canvas->backingStore()->isNull();
     39           && canvas->backingStore() && !canvas->backingStore()->isNull();
    4040}
    4141
    4242class QwtPlotDirectPainter::PrivateData
    4343{
    44 public:
    45     PrivateData():
    46         attributes( 0 ),
    47         hasClipping(false),
    48         seriesItem( NULL ),
    49         from( 0 ),
    50         to( 0 )
     44  public:
     45    PrivateData()
     46        : hasClipping( false )
     47        , seriesItem( NULL )
     48        , from( 0 )
     49        , to( 0 )
    5150    {
    5251    }
    … …  
    5958    QPainter painter;
    6059
    61     QwtPlotSeriesItem *seriesItem;
     60    QwtPlotSeriesItem* seriesItem;
    6261    int from;
    6362    int to;
    … …  
    6564
    6665//! Constructor
    67 QwtPlotDirectPainter::QwtPlotDirectPainter( QObject *parent ):
    68     QObject( parent )
    69 {
    70     d_data = new PrivateData;
     66QwtPlotDirectPainter::QwtPlotDirectPainter( QObject* parent )
     67    : QObject( parent )
     68{
     69    m_data = new PrivateData;
    7170}
    7271
    … …  
    7473QwtPlotDirectPainter::~QwtPlotDirectPainter()
    7574{
    76     delete d_data;
    77 }
    78 
    79 /*!
    80   Change an attribute
    81 
    82   \param attribute Attribute to change
    83   \param on On/Off
    84 
    85   \sa Attribute, testAttribute()
    86 */
     75    delete m_data;
     76}
     77
     78/*!
     79   Change an attribute
     80
     81   \param attribute Attribute to change
     82   \param on On/Off
     83
     84   \sa Attribute, testAttribute()
     85 */
    8786void QwtPlotDirectPainter::setAttribute( Attribute attribute, bool on )
    8887{
    89     if ( bool( d_data->attributes & attribute ) != on )
     88    if ( bool( m_data->attributes & attribute ) != on )
    9089    {
    9190        if ( on )
    92             d_data->attributes |= attribute;
     91            m_data->attributes |= attribute;
    9392        else
    94             d_data->attributes &= ~attribute;
     93            m_data->attributes &= ~attribute;
    9594
    9695        if ( ( attribute == AtomicPainter ) && on )
    … …  
    10099
    101100/*!
    102   \return True, when attribute is enabled
    103   \param attribute Attribute to be tested
    104   \sa Attribute, setAttribute()
    105 */
     101   \return True, when attribute is enabled
     102   \param attribute Attribute to be tested
     103   \sa Attribute, setAttribute()
     104 */
    106105bool QwtPlotDirectPainter::testAttribute( Attribute attribute ) const
    107106{
    108     return d_data->attributes & attribute;
    109 }
    110 
    111 /*!
    112   En/Disables clipping
    113 
    114   \param enable Enables clipping is true, disable it otherwise
    115   \sa hasClipping(), clipRegion(), setClipRegion()
    116 */
     107    return m_data->attributes & attribute;
     108}
     109
     110/*!
     111   En/Disables clipping
     112
     113   \param enable Enables clipping is true, disable it otherwise
     114   \sa hasClipping(), clipRegion(), setClipRegion()
     115 */
    117116void QwtPlotDirectPainter::setClipping( bool enable )
    118117{
    119     d_data->hasClipping = enable;
    120 }
    121 
    122 /*!
    123   \return true, when clipping is enabled
    124   \sa setClipping(), clipRegion(), setClipRegion()
    125 */
     118    m_data->hasClipping = enable;
     119}
     120
     121/*!
     122   \return true, when clipping is enabled
     123   \sa setClipping(), clipRegion(), setClipRegion()
     124 */
    126125bool QwtPlotDirectPainter::hasClipping() const
    127126{
    128     return d_data->hasClipping;
     127    return m_data->hasClipping;
    129128}
    130129
    … …  
    139138   \param region Clip region
    140139   \sa clipRegion(), hasClipping(), setClipping()
    141 */
    142 void QwtPlotDirectPainter::setClipRegion( const QRegion &region )
    143 {
    144     d_data->clipRegion = region;
    145     d_data->hasClipping = true;
     140 */
     141void QwtPlotDirectPainter::setClipRegion( const QRegion& region )
     142{
     143    m_data->clipRegion = region;
     144    m_data->hasClipping = true;
    146145}
    147146
    … …  
    149148   \return Currently set clip region.
    150149   \sa setClipRegion(), setClipping(), hasClipping()
    151 */
     150 */
    152151QRegion QwtPlotDirectPainter::clipRegion() const
    153152{
    154     return d_data->clipRegion;
    155 }
    156 
    157 /*!
    158   \brief Draw a set of points of a seriesItem.
    159 
    160   When observing an measurement while it is running, new points have to be
    161   added to an existing seriesItem. drawSeries() can be used to display them avoiding
    162   a complete redraw of the canvas.
    163 
    164   Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
    165   will result in faster painting, if the paint engine of the canvas widget
    166   supports this feature.
    167 
    168   \param seriesItem Item to be painted
    169   \param from Index of the first point to be painted
    170   \param to Index of the last point to be painted. If to < 0 the
     153    return m_data->clipRegion;
     154}
     155
     156/*!
     157   \brief Draw a set of points of a seriesItem.
     158
     159   When observing an measurement while it is running, new points have to be
     160   added to an existing seriesItem. drawSeries() can be used to display them avoiding
     161   a complete redraw of the canvas.
     162
     163   Setting plot()->canvas()->setAttribute(Qt::WA_PaintOutsidePaintEvent, true);
     164   will result in faster painting, if the paint engine of the canvas widget
     165   supports this feature.
     166
     167   \param seriesItem Item to be painted
     168   \param from Index of the first point to be painted
     169   \param to Index of the last point to be painted. If to < 0 the
    171170         series will be painted to its last point.
    172 */
     171 */
    173172void QwtPlotDirectPainter::drawSeries(
    174     QwtPlotSeriesItem *seriesItem, int from, int to )
     173    QwtPlotSeriesItem* seriesItem, int from, int to )
    175174{
    176175    if ( seriesItem == NULL || seriesItem->plot() == NULL )
    177176        return;
    178177
    179     QWidget *canvas = seriesItem->plot()->canvas();
     178    QWidget* canvas = seriesItem->plot()->canvas();
    180179    const QRect canvasRect = canvas->contentsRect();
    181180
    182     QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas );
     181    QwtPlotCanvas* plotCanvas = qobject_cast< QwtPlotCanvas* >( canvas );
    183182
    184183    if ( plotCanvas && qwtHasBackingStore( plotCanvas ) )
    185184    {
    186         QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) );
    187 
    188         if ( d_data->hasClipping )
    189             painter.setClipRegion( d_data->clipRegion );
     185        QPainter painter( const_cast< QPixmap* >( plotCanvas->backingStore() ) );
     186
     187        if ( m_data->hasClipping )
     188            painter.setClipRegion( m_data->clipRegion );
    190189
    191190        qwtRenderItem( &painter, canvasRect, seriesItem, from, to );
    … …  
    206205        if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
    207206#endif
    208             immediatePaint = false;
     207        immediatePaint = false;
    209208    }
    210209
    211210    if ( immediatePaint )
    212211    {
    213         if ( !d_data->painter.isActive() )
     212        if ( !m_data->painter.isActive() )
    214213        {
    215214            reset();
    216215
    217             d_data->painter.begin( canvas );
     216            m_data->painter.begin( canvas );
    218217            canvas->installEventFilter( this );
    219218        }
    220219
    221         if ( d_data->hasClipping )
    222         {
    223             d_data->painter.setClipRegion(
    224                 QRegion( canvasRect ) & d_data->clipRegion );
     220        if ( m_data->hasClipping )
     221        {
     222            m_data->painter.setClipRegion(
     223                QRegion( canvasRect ) & m_data->clipRegion );
    225224        }
    226225        else
    227226        {
    228             if ( !d_data->painter.hasClipping() )
    229                 d_data->painter.setClipRect( canvasRect );
    230         }
    231 
    232         qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to );
    233 
    234         if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
     227            if ( !m_data->painter.hasClipping() )
     228                m_data->painter.setClipRect( canvasRect );
     229        }
     230
     231        qwtRenderItem( &m_data->painter, canvasRect, seriesItem, from, to );
     232
     233        if ( m_data->attributes & QwtPlotDirectPainter::AtomicPainter )
    235234        {
    236235            reset();
    … …  
    238237        else
    239238        {
    240             if ( d_data->hasClipping )
    241                 d_data->painter.setClipping( false );
     239            if ( m_data->hasClipping )
     240                m_data->painter.setClipping( false );
    242241        }
    243242    }
    … …  
    246245        reset();
    247246
    248         d_data->seriesItem = seriesItem;
    249         d_data->from = from;
    250         d_data->to = to;
     247        m_data->seriesItem = seriesItem;
     248        m_data->from = from;
     249        m_data->to = to;
    251250
    252251        QRegion clipRegion = canvasRect;
    253         if ( d_data->hasClipping )
    254             clipRegion &= d_data->clipRegion;
     252        if ( m_data->hasClipping )
     253            clipRegion &= m_data->clipRegion;
    255254
    256255        canvas->installEventFilter( this );
    … …  
    258257        canvas->removeEventFilter( this );
    259258
    260         d_data->seriesItem = NULL;
     259        m_data->seriesItem = NULL;
    261260    }
    262261}
    … …  
    265264void QwtPlotDirectPainter::reset()
    266265{
    267     if ( d_data->painter.isActive() )
    268     {
    269         QWidget *w = static_cast<QWidget *>( d_data->painter.device() );
     266    if ( m_data->painter.isActive() )
     267    {
     268        QWidget* w = static_cast< QWidget* >( m_data->painter.device() );
    270269        if ( w )
    271270            w->removeEventFilter( this );
    272271
    273         d_data->painter.end();
     272        m_data->painter.end();
    274273    }
    275274}
    276275
    277276//! Event filter
    278 bool QwtPlotDirectPainter::eventFilter( QObject *, QEvent *event )
     277bool QwtPlotDirectPainter::eventFilter( QObject*, QEvent* event )
    279278{
    280279    if ( event->type() == QEvent::Paint )
    … …  
    282281        reset();
    283282
    284         if ( d_data->seriesItem )
    285         {
    286             const QPaintEvent *pe = static_cast< QPaintEvent *>( event );
    287 
    288             QWidget *canvas = d_data->seriesItem->plot()->canvas();
     283        if ( m_data->seriesItem )
     284        {
     285            const QPaintEvent* pe = static_cast< QPaintEvent* >( event );
     286
     287            QWidget* canvas = m_data->seriesItem->plot()->canvas();
    289288
    290289            QPainter painter( canvas );
    … …  
    295294            if ( doCopyCache )
    296295            {
    297                 QwtPlotCanvas *plotCanvas =
    298                     qobject_cast<QwtPlotCanvas *>( canvas );
     296                QwtPlotCanvas* plotCanvas =
     297                    qobject_cast< QwtPlotCanvas* >( canvas );
    299298                if ( plotCanvas )
    300299                {
    … …  
    311310            {
    312311                qwtRenderItem( &painter, canvas->contentsRect(),
    313                     d_data->seriesItem, d_data->from, d_data->to );
     312                    m_data->seriesItem, m_data->from, m_data->to );
    314313            }
    315314
Note: See TracChangeset for help on using the changeset viewer.