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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1212#include "qwt_plot.h"
    1313#include "qwt_legend_data.h"
    14 #include "qwt_scale_div.h"
     14#include "qwt_scale_map.h"
    1515#include "qwt_graphic.h"
     16
    1617#include <qpainter.h>
    1718
    1819class QwtPlotItem::PrivateData
    1920{
    20 public:
    21     PrivateData():
    22         plot( NULL ),
    23         isVisible( true ),
    24         attributes( 0 ),
    25         interests( 0 ),
    26         renderHints( 0 ),
    27         renderThreadCount( 1 ),
    28         z( 0.0 ),
    29         xAxis( QwtPlot::xBottom ),
    30         yAxis( QwtPlot::yLeft ),
    31         legendIconSize( 8, 8 )
    32     {
    33     }
    34 
    35     mutable QwtPlot *plot;
     21  public:
     22    PrivateData()
     23        : plot( NULL )
     24        , isVisible( true )
     25        , renderThreadCount( 1 )
     26        , z( 0.0 )
     27        , xAxisId( QwtAxis::XBottom )
     28        , yAxisId( QwtAxis::YLeft )
     29        , legendIconSize( 8, 8 )
     30    {
     31    }
     32
     33    mutable QwtPlot* plot;
    3634
    3735    bool isVisible;
    … …  
    4543    double z;
    4644
    47     int xAxis;
    48     int yAxis;
     45    QwtAxisId xAxisId;
     46    QwtAxisId yAxisId;
    4947
    5048    QwtText title;
    … …  
    5452/*!
    5553   Constructor
     54 */
     55QwtPlotItem::QwtPlotItem()
     56{
     57    m_data = new PrivateData;
     58}
     59
     60/*!
     61   Constructor
    5662   \param title Title of the item
    57 */
    58 QwtPlotItem::QwtPlotItem( const QwtText &title )
    59 {
    60     d_data = new PrivateData;
    61     d_data->title = title;
     63 */
     64QwtPlotItem::QwtPlotItem( const QString& title )
     65{
     66    m_data = new PrivateData;
     67    m_data->title = title;
     68}
     69
     70/*!
     71   Constructor
     72   \param title Title of the item
     73 */
     74QwtPlotItem::QwtPlotItem( const QwtText& title )
     75{
     76    m_data = new PrivateData;
     77    m_data->title = title;
    6278}
    6379
    … …  
    6682{
    6783    attach( NULL );
    68     delete d_data;
    69 }
    70 
    71 /*!
    72   \brief Attach the item to a plot.
    73 
    74   This method will attach a QwtPlotItem to the QwtPlot argument. It will first
    75   detach the QwtPlotItem from any plot from a previous call to attach (if
    76   necessary). If a NULL argument is passed, it will detach from any QwtPlot it
    77   was attached to.
    78 
    79   \param plot Plot widget
    80   \sa detach()
    81 */
    82 void QwtPlotItem::attach( QwtPlot *plot )
    83 {
    84     if ( plot == d_data->plot )
     84    delete m_data;
     85}
     86
     87/*!
     88   \brief Attach the item to a plot.
     89
     90   This method will attach a QwtPlotItem to the QwtPlot argument. It will first
     91   detach the QwtPlotItem from any plot from a previous call to attach (if
     92   necessary). If a NULL argument is passed, it will detach from any QwtPlot it
     93   was attached to.
     94
     95   \param plot Plot widget
     96   \sa detach()
     97 */
     98void QwtPlotItem::attach( QwtPlot* plot )
     99{
     100    if ( plot == m_data->plot )
    85101        return;
    86102
    87     if ( d_data->plot )
    88         d_data->plot->attachItem( this, false );
    89 
    90     d_data->plot = plot;
    91 
    92     if ( d_data->plot )
    93         d_data->plot->attachItem( this, true );
     103    if ( m_data->plot )
     104        m_data->plot->attachItem( this, false );
     105
     106    m_data->plot = plot;
     107
     108    if ( m_data->plot )
     109        m_data->plot->attachItem( this, true );
    94110}
    95111
    … …  
    100116   detach() is equivalent to calling attach( NULL )
    101117   \sa attach()
    102 */
     118 */
    103119void QwtPlotItem::detach()
    104120{
    … …  
    117133   \return rtti value
    118134   \sa RttiValues
    119 */
     135 */
    120136int QwtPlotItem::rtti() const
    121137{
    … …  
    124140
    125141//! Return attached plot
    126 QwtPlot *QwtPlotItem::plot() const
    127 {
    128     return d_data->plot;
     142QwtPlot* QwtPlotItem::plot() const
     143{
     144    return m_data->plot;
    129145}
    130146
    … …  
    133149
    134150   \return setZ(), QwtPlotDict::itemList()
    135 */
     151 */
    136152double QwtPlotItem::z() const
    137153{
    138     return d_data->z;
     154    return m_data->z;
    139155}
    140156
    … …  
    146162   \param z Z-value
    147163   \sa z(), QwtPlotDict::itemList()
    148 */
     164 */
    149165void QwtPlotItem::setZ( double z )
    150166{
    151     if ( d_data->z != z )
    152     {
    153         if ( d_data->plot ) // update the z order
    154             d_data->plot->attachItem( this, false );
    155 
    156         d_data->z = z;
    157 
    158         if ( d_data->plot )
    159             d_data->plot->attachItem( this, true );
     167    if ( m_data->z != z )
     168    {
     169        if ( m_data->plot ) // update the z order
     170            m_data->plot->attachItem( this, false );
     171
     172        m_data->z = z;
     173
     174        if ( m_data->plot )
     175            m_data->plot->attachItem( this, true );
    160176
    161177        itemChanged();
    … …  
    168184   \param title Title
    169185   \sa title()
    170 */
    171 void QwtPlotItem::setTitle( const QString &title )
     186 */
     187void QwtPlotItem::setTitle( const QString& title )
    172188{
    173189    setTitle( QwtText( title ) );
    … …  
    179195   \param title Title
    180196   \sa title()
    181 */
    182 void QwtPlotItem::setTitle( const QwtText &title )
    183 {
    184     if ( d_data->title != title )
    185     {
    186         d_data->title = title;
     197 */
     198void QwtPlotItem::setTitle( const QwtText& title )
     199{
     200    if ( m_data->title != title )
     201    {
     202        m_data->title = title;
    187203
    188204        legendChanged();
    … …  
    196212   \return Title of the item
    197213   \sa setTitle()
    198 */
    199 const QwtText &QwtPlotItem::title() const
    200 {
    201     return d_data->title;
     214 */
     215const QwtText& QwtPlotItem::title() const
     216{
     217    return m_data->title;
    202218}
    203219
    … …  
    209225
    210226   \sa testItemAttribute(), ItemInterest
    211 */
     227 */
    212228void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on )
    213229{
    214     if ( d_data->attributes.testFlag( attribute ) != on )
     230    if ( m_data->attributes.testFlag( attribute ) != on )
    215231    {
    216232        if ( on )
    217             d_data->attributes |= attribute;
     233            m_data->attributes |= attribute;
    218234        else
    219             d_data->attributes &= ~attribute;
     235            m_data->attributes &= ~attribute;
    220236
    221237        if ( attribute == QwtPlotItem::Legend )
    222             legendChanged();
     238        {
     239            if ( on )
     240            {
     241                legendChanged();
     242            }
     243            else
     244            {
     245                /*
     246                    In the special case of taking an item from
     247                    the legend we can't use legendChanged() as
     248                    it depends on QwtPlotItem::Legend being enabled
     249                 */
     250                if ( m_data->plot )
     251                    m_data->plot->updateLegend( this );
     252            }
     253        }
    223254
    224255        itemChanged();
    … …  
    232263   \return true/false
    233264   \sa setItemAttribute(), ItemInterest
    234 */
     265 */
    235266bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const
    236267{
    237     return d_data->attributes.testFlag( attribute );
     268    return m_data->attributes.testFlag( attribute );
    238269}
    239270
    … …  
    245276
    246277   \sa testItemInterest(), ItemAttribute
    247 */
     278 */
    248279void QwtPlotItem::setItemInterest( ItemInterest interest, bool on )
    249280{
    250     if ( d_data->interests.testFlag( interest ) != on )
     281    if ( m_data->interests.testFlag( interest ) != on )
    251282    {
    252283        if ( on )
    253             d_data->interests |= interest;
     284            m_data->interests |= interest;
    254285        else
    255             d_data->interests &= ~interest;
     286            m_data->interests &= ~interest;
    256287
    257288        itemChanged();
    … …  
    265296   \return true/false
    266297   \sa setItemInterest(), ItemAttribute
    267 */
     298 */
    268299bool QwtPlotItem::testItemInterest( ItemInterest interest ) const
    269300{
    270     return d_data->interests.testFlag( interest );
     301    return m_data->interests.testFlag( interest );
    271302}
    272303
    … …  
    278309
    279310   \sa testRenderHint(), RenderHint
    280 */
     311 */
    281312void QwtPlotItem::setRenderHint( RenderHint hint, bool on )
    282313{
    283     if ( d_data->renderHints.testFlag( hint ) != on )
     314    if ( m_data->renderHints.testFlag( hint ) != on )
    284315    {
    285316        if ( on )
    286             d_data->renderHints |= hint;
     317            m_data->renderHints |= hint;
    287318        else
    288             d_data->renderHints &= ~hint;
     319            m_data->renderHints &= ~hint;
    289320
    290321        itemChanged();
    … …  
    298329   \return true/false
    299330   \sa setRenderHint(), RenderHint
    300 */
     331 */
    301332bool QwtPlotItem::testRenderHint( RenderHint hint ) const
    302333{
    303     return d_data->renderHints.testFlag( hint );
     334    return m_data->renderHints.testFlag( hint );
    304335}
    305336
    … …  
    316347
    317348   The default thread count is 1 ( = no additional threads )
    318 */
     349 */
    319350void QwtPlotItem::setRenderThreadCount( uint numThreads )
    320351{
    321     d_data->renderThreadCount = numThreads;
     352    m_data->renderThreadCount = numThreads;
    322353}
    323354
    … …  
    326357           If numThreads() is set to 0, the system specific
    327358           ideal thread count is used.
    328 */
     359 */
    329360uint QwtPlotItem::renderThreadCount() const
    330361{
    331     return d_data->renderThreadCount;
     362    return m_data->renderThreadCount;
    332363}
    333364
    … …  
    339370   \param size Size
    340371   \sa legendIconSize(), legendIcon()
    341 */
    342 void QwtPlotItem::setLegendIconSize( const QSize &size )
    343 {
    344     if ( d_data->legendIconSize != size )
    345     {
    346         d_data->legendIconSize = size;
     372 */
     373void QwtPlotItem::setLegendIconSize( const QSize& size )
     374{
     375    if ( m_data->legendIconSize != size )
     376    {
     377        m_data->legendIconSize = size;
    347378        legendChanged();
    348379    }
    … …  
    352383   \return Legend icon size
    353384   \sa setLegendIconSize(), legendIcon()
    354 */
     385 */
    355386QSize QwtPlotItem::legendIconSize() const
    356387{
    357     return d_data->legendIconSize;
     388    return m_data->legendIconSize;
    358389}
    359390
    … …  
    370401 */
    371402QwtGraphic QwtPlotItem::legendIcon(
    372     int index, const QSizeF &size ) const
     403    int index, const QSizeF& size ) const
    373404{
    374405    Q_UNUSED( index )
    … …  
    390421 */
    391422QwtGraphic QwtPlotItem::defaultIcon(
    392     const QBrush &brush, const QSizeF &size ) const
     423    const QBrush& brush, const QSizeF& size ) const
    393424{
    394425    QwtGraphic icon;
    … …  
    423454    \param on Show if true, otherwise hide
    424455    \sa isVisible(), show(), hide()
    425 */
     456 */
    426457void QwtPlotItem::setVisible( bool on )
    427458{
    428     if ( on != d_data->isVisible )
    429     {
    430         d_data->isVisible = on;
     459    if ( on != m_data->isVisible )
     460    {
     461        m_data->isVisible = on;
    431462        itemChanged();
    432463    }
    … …  
    436467    \return true if visible
    437468    \sa setVisible(), show(), hide()
    438 */
     469 */
    439470bool QwtPlotItem::isVisible() const
    440471{
    441     return d_data->isVisible;
     472    return m_data->isVisible;
    442473}
    443474
    … …  
    447478
    448479   \sa QwtPlot::legendChanged(), QwtPlot::autoRefresh()
    449 */
     480 */
    450481void QwtPlotItem::itemChanged()
    451482{
    452     if ( d_data->plot )
    453         d_data->plot->autoRefresh();
     483    if ( m_data->plot )
     484        m_data->plot->autoRefresh();
    454485}
    455486
    … …  
    457488   Update the legend of the parent plot.
    458489   \sa QwtPlot::updateLegend(), itemChanged()
    459 */
     490 */
    460491void QwtPlotItem::legendChanged()
    461492{
    462     if ( testItemAttribute( QwtPlotItem::Legend ) && d_data->plot )
    463         d_data->plot->updateLegend( this );
     493    if ( testItemAttribute( QwtPlotItem::Legend ) && m_data->plot )
     494        m_data->plot->updateLegend( this );
    464495}
    465496
    … …  
    469500   The item will painted according to the coordinates of its Axes.
    470501
    471    \param xAxis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )
    472    \param yAxis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )
    473 
    474    \sa setXAxis(), setYAxis(), xAxis(), yAxis(), QwtPlot::Axis
    475 */
    476 void QwtPlotItem::setAxes( int xAxis, int yAxis )
    477 {
    478     if ( xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop )
    479         d_data->xAxis = xAxis;
    480 
    481     if ( yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight )
    482         d_data->yAxis = yAxis;
     502   \param xAxisId X Axis
     503   \param yAxisId Y Axis
     504
     505   \sa setXAxis(), setYAxis(), xAxis(), yAxis()
     506 */
     507void QwtPlotItem::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId )
     508{
     509    if ( QwtAxis::isXAxis( xAxisId ) )
     510        m_data->xAxisId = xAxisId;
     511
     512    if ( QwtAxis::isYAxis( yAxisId ) )
     513        m_data->yAxisId = yAxisId;
    483514
    484515    itemChanged();
    … …  
    490521   The item will painted according to the coordinates its Axes.
    491522
    492    \param axis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )
    493    \sa setAxes(), setYAxis(), xAxis(), QwtPlot::Axis
    494 */
    495 void QwtPlotItem::setXAxis( int axis )
    496 {
    497     if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
    498     {
    499         d_data->xAxis = axis;
     523   \param axisId X Axis
     524   \sa setAxes(), setYAxis(), xAxis()
     525 */
     526void QwtPlotItem::setXAxis( QwtAxisId axisId )
     527{
     528    if ( QwtAxis::isXAxis( axisId ) )
     529    {
     530        m_data->xAxisId = axisId;
    500531        itemChanged();
    501532    }
    … …  
    507538   The item will painted according to the coordinates its Axes.
    508539
    509    \param axis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )
    510    \sa setAxes(), setXAxis(), yAxis(), QwtPlot::Axis
    511 */
    512 void QwtPlotItem::setYAxis( int axis )
    513 {
    514     if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
    515     {
    516         d_data->yAxis = axis;
     540   \param axisId Y Axis
     541   \sa setAxes(), setXAxis(), yAxis()
     542 */
     543void QwtPlotItem::setYAxis( QwtAxisId axisId )
     544{
     545    if ( QwtAxis::isYAxis( axisId ) )
     546    {
     547        m_data->yAxisId = axisId;
    517548        itemChanged();
    518549    }
    … …  
    520551
    521552//! Return xAxis
    522 int QwtPlotItem::xAxis() const
    523 {
    524     return d_data->xAxis;
     553QwtAxisId QwtPlotItem::xAxis() const
     554{
     555    return m_data->xAxisId;
    525556}
    526557
    527558//! Return yAxis
    528 int QwtPlotItem::yAxis() const
    529 {
    530     return d_data->yAxis;
     559QwtAxisId QwtPlotItem::yAxis() const
     560{
     561    return m_data->yAxisId;
    531562}
    532563
    … …  
    534565   \return An invalid bounding rect: QRectF(1.0, 1.0, -2.0, -2.0)
    535566   \note A width or height < 0.0 is ignored by the autoscaler
    536 */
     567 */
    537568QRectF QwtPlotItem::boundingRect() const
    538569{
    … …  
    562593   \sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
    563594 */
    564 void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
    565     const QwtScaleMap &yMap, const QRectF &canvasRect,
    566     double &left, double &top, double &right, double &bottom ) const
     595void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap& xMap,
     596    const QwtScaleMap& yMap, const QRectF& canvasRect,
     597    double& left, double& top, double& right, double& bottom ) const
    567598{
    568599    Q_UNUSED( xMap );
    … …  
    593624   \sa title(), legendIcon(), QwtLegend, QwtPlotLegendItem
    594625 */
    595 QList<QwtLegendData> QwtPlotItem::legendData() const
     626QList< QwtLegendData > QwtPlotItem::legendData() const
    596627{
    597628    QwtLegendData data;
    … …  
    600631    label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
    601632
    602     QVariant titleValue;
    603     qVariantSetValue( titleValue, label );
    604     data.setValue( QwtLegendData::TitleRole, titleValue );
     633    data.setValue( QwtLegendData::TitleRole,
     634        QVariant::fromValue( label ) );
    605635
    606636    const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
    607637    if ( !graphic.isNull() )
    608638    {
    609         QVariant iconValue;
    610         qVariantSetValue( iconValue, graphic );
    611         data.setValue( QwtLegendData::IconRole, iconValue );
    612     }
    613 
    614     QList<QwtLegendData> list;
     639        data.setValue( QwtLegendData::IconRole,
     640            QVariant::fromValue( graphic ) );
     641    }
     642
     643    QList< QwtLegendData > list;
    615644    list += data;
    616645
    … …  
    633662
    634663   \sa QwtPlot::updateAxes(), ScaleInterest
    635 */
    636 void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,
    637     const QwtScaleDiv &yScaleDiv )
     664 */
     665void QwtPlotItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv,
     666    const QwtScaleDiv& yScaleDiv )
    638667{
    639668    Q_UNUSED( xScaleDiv );
    … …  
    659688         legendData() and legendIcon()
    660689 */
    661 void QwtPlotItem::updateLegend( const QwtPlotItem *item,
    662     const QList<QwtLegendData> &data )
     690void QwtPlotItem::updateLegend( const QwtPlotItem* item,
     691    const QList< QwtLegendData >& data )
    663692{
    664693    Q_UNUSED( item );
    … …  
    673702
    674703   \return Bounding scale rect of the scale maps, not normalized
    675 */
    676 QRectF QwtPlotItem::scaleRect( const QwtScaleMap &xMap,
    677     const QwtScaleMap &yMap ) const
     704 */
     705QRectF QwtPlotItem::scaleRect( const QwtScaleMap& xMap,
     706    const QwtScaleMap& yMap ) const
    678707{
    679708    return QRectF( xMap.s1(), yMap.s1(),
    … …  
    688717
    689718   \return Bounding paint rectangle of the scale maps, not normalized
    690 */
    691 QRectF QwtPlotItem::paintRect( const QwtScaleMap &xMap,
    692     const QwtScaleMap &yMap ) const
     719 */
     720QRectF QwtPlotItem::paintRect( const QwtScaleMap& xMap,
     721    const QwtScaleMap& yMap ) const
    693722{
    694723    const QRectF rect( xMap.p1(), yMap.p1(),
Note: See TracChangeset for help on using the changeset viewer.