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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1111#include "qwt_scale_map.h"
    1212#include "qwt_column_symbol.h"
    13 #include "qwt_painter.h"
     13#include "qwt_text.h"
     14#include "qwt_graphic.h"
     15#include "qwt_legend_data.h"
     16
    1417#include <qpainter.h>
    1518
    1619class QwtPlotBarChart::PrivateData
    1720{
    18 public:
    19     PrivateData():
    20         symbol( NULL ),
    21         legendMode( QwtPlotBarChart::LegendChartTitle )
     21  public:
     22    PrivateData()
     23        : symbol( NULL )
     24        , legendMode( QwtPlotBarChart::LegendChartTitle )
    2225    {
    2326    }
    … …  
    2831    }
    2932
    30     QwtColumnSymbol *symbol;
     33    QwtColumnSymbol* symbol;
    3134    QwtPlotBarChart::LegendMode legendMode;
    3235};
    3336
    3437/*!
    35   Constructor
    36   \param title Title of the curve
    37 */
    38 QwtPlotBarChart::QwtPlotBarChart( const QwtText &title ):
    39     QwtPlotAbstractBarChart( title )
     38   Constructor
     39   \param title Title of the curve
     40 */
     41QwtPlotBarChart::QwtPlotBarChart( const QwtText& title )
     42    : QwtPlotAbstractBarChart( title )
    4043{
    4144    init();
    … …  
    4346
    4447/*!
    45   Constructor
    46   \param title Title of the curve
    47 */
    48 QwtPlotBarChart::QwtPlotBarChart( const QString &title ):
    49     QwtPlotAbstractBarChart( QwtText( title ) )
     48   Constructor
     49   \param title Title of the curve
     50 */
     51QwtPlotBarChart::QwtPlotBarChart( const QString& title )
     52    : QwtPlotAbstractBarChart( QwtText( title ) )
    5053{
    5154    init();
    … …  
    5558QwtPlotBarChart::~QwtPlotBarChart()
    5659{
    57     delete d_data;
     60    delete m_data;
    5861}
    5962
    6063void QwtPlotBarChart::init()
    6164{
    62     d_data = new PrivateData;
     65    m_data = new PrivateData;
    6366    setData( new QwtPointSeriesData() );
    6467}
    … …  
    7174
    7275/*!
    73   Initialize data with an array of points
    74 
    75   \param samples Vector of points
    76   \note QVector is implicitly shared
    77   \note QPolygonF is derived from QVector<QPointF>
    78 */
     76   Initialize data with an array of points
     77
     78   \param samples Vector of points
     79   \note QVector is implicitly shared
     80   \note QPolygonF is derived from QVector<QPointF>
     81 */
    7982void QwtPlotBarChart::setSamples(
    80     const QVector<QPointF> &samples )
     83    const QVector< QPointF >& samples )
    8184{
    8285    setData( new QwtPointSeriesData( samples ) );
    … …  
    8487
    8588/*!
    86   Initialize data with an array of doubles
    87 
    88   The indices in the array are taken as x coordinate,
    89   while the doubles are interpreted as y values.
    90 
    91   \param samples Vector of y coordinates
    92   \note QVector is implicitly shared
    93 */
     89   Initialize data with an array of doubles
     90
     91   The indices in the array are taken as x coordinate,
     92   while the doubles are interpreted as y values.
     93
     94   \param samples Vector of y coordinates
     95   \note QVector is implicitly shared
     96 */
    9497void QwtPlotBarChart::setSamples(
    95     const QVector<double> &samples )
    96 {
    97     QVector<QPointF> points;
     98    const QVector< double >& samples )
     99{
     100    QVector< QPointF > points;
     101    points.reserve( samples.size() );
     102
    98103    for ( int i = 0; i < samples.size(); i++ )
    99104        points += QPointF( i, samples[ i ] );
    … …  
    103108
    104109/*!
    105   Assign a series of samples
    106 
    107   setSamples() is just a wrapper for setData() without any additional
    108   value - beside that it is easier to find for the developer.
    109 
    110   \param data Data
    111   \warning The item takes ownership of the data object, deleting
     110   Assign a series of samples
     111
     112   setSamples() is just a wrapper for setData() without any additional
     113   value - beside that it is easier to find for the developer.
     114
     115   \param data Data
     116   \warning The item takes ownership of the data object, deleting
    112117           it when its not used anymore.
    113 */
    114 void QwtPlotBarChart::setSamples( QwtSeriesData<QPointF> *data )
     118 */
     119void QwtPlotBarChart::setSamples( QwtSeriesData< QPointF >* data )
    115120{
    116121    setData( data );
    … …  
    118123
    119124/*!
    120   \brief Assign a symbol
    121 
    122   The bar chart will take the ownership of the symbol, hence the previously
    123   set symbol will be delete by setting a new one. If \p symbol is
    124   \c NULL no symbol will be drawn.
    125 
    126   \param symbol Symbol
    127   \sa symbol()
    128 */
    129 void QwtPlotBarChart::setSymbol( QwtColumnSymbol *symbol )
    130 {
    131     if ( symbol != d_data->symbol )
    132     {
    133         delete d_data->symbol;
    134         d_data->symbol = symbol;
     125   \brief Assign a symbol
     126
     127   The bar chart will take the ownership of the symbol, hence the previously
     128   set symbol will be delete by setting a new one. If \p symbol is
     129   \c NULL no symbol will be drawn.
     130
     131   \param symbol Symbol
     132   \sa symbol()
     133 */
     134void QwtPlotBarChart::setSymbol( QwtColumnSymbol* symbol )
     135{
     136    if ( symbol != m_data->symbol )
     137    {
     138        delete m_data->symbol;
     139        m_data->symbol = symbol;
    135140
    136141        legendChanged();
    … …  
    140145
    141146/*!
    142   \return Current symbol or NULL, when no symbol has been assigned
    143   \sa setSymbol()
    144 */
    145 const QwtColumnSymbol *QwtPlotBarChart::symbol() const
    146 {
    147     return d_data->symbol;
    148 }
    149 
    150 /*!
    151   Set the mode that decides what to display on the legend
    152 
    153   In case of LegendBarTitles barTitle() needs to be overloaded
    154   to return individual titles for each bar.
    155 
    156   \param mode New mode
    157   \sa legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute
     147   \return Current symbol or NULL, when no symbol has been assigned
     148   \sa setSymbol()
     149 */
     150const QwtColumnSymbol* QwtPlotBarChart::symbol() const
     151{
     152    return m_data->symbol;
     153}
     154
     155/*!
     156   Set the mode that decides what to display on the legend
     157
     158   In case of LegendBarTitles barTitle() needs to be overloaded
     159   to return individual titles for each bar.
     160
     161   \param mode New mode
     162   \sa legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute
    158163 */
    159164void QwtPlotBarChart::setLegendMode( LegendMode mode )
    160165{
    161     if ( mode != d_data->legendMode )
    162     {
    163         d_data->legendMode = mode;
     166    if ( mode != m_data->legendMode )
     167    {
     168        m_data->legendMode = mode;
    164169        legendChanged();
    165170    }
    … …  
    167172
    168173/*!
    169   \return Legend mode
    170   \sa setLegendMode()
     174   \return Legend mode
     175   \sa setLegendMode()
    171176 */
    172177QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode() const
    173178{
    174     return d_data->legendMode;
    175 }
    176 
    177 /*!
    178   \return Bounding rectangle of all samples.
    179   For an empty series the rectangle is invalid.
    180 */
     179    return m_data->legendMode;
     180}
     181
     182/*!
     183   \return Bounding rectangle of all samples.
     184   For an empty series the rectangle is invalid.
     185 */
    181186QRectF QwtPlotBarChart::boundingRect() const
    182187{
    … …  
    204209
    205210/*!
    206   Draw an interval of the bar chart
    207 
    208   \param painter Painter
    209   \param xMap Maps x-values into pixel coordinates.
    210   \param yMap Maps y-values into pixel coordinates.
    211   \param canvasRect Contents rect of the canvas
    212   \param from Index of the first point to be painted
    213   \param to Index of the last point to be painted. If to < 0 the
     211   Draw an interval of the bar chart
     212
     213   \param painter Painter
     214   \param xMap Maps x-values into pixel coordinates.
     215   \param yMap Maps y-values into pixel coordinates.
     216   \param canvasRect Contents rect of the canvas
     217   \param from Index of the first point to be painted
     218   \param to Index of the last point to be painted. If to < 0 the
    214219         curve will be painted to its last point.
    215220
    216   \sa drawSymbols()
    217 */
    218 void QwtPlotBarChart::drawSeries( QPainter *painter,
    219     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    220     const QRectF &canvasRect, int from, int to ) const
     221   \sa drawSymbols()
     222 */
     223void QwtPlotBarChart::drawSeries( QPainter* painter,
     224    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     225    const QRectF& canvasRect, int from, int to ) const
    221226{
    222227    if ( to < 0 )
    … …  
    238243    {
    239244        drawSample( painter, xMap, yMap,
    240                     canvasRect, interval, i, sample( i ) );
     245            canvasRect, interval, i, sample( i ) );
    241246    }
    242247
    … …  
    245250
    246251/*!
    247   Draw a sample
    248 
    249   \param painter Painter
    250   \param xMap x map
    251   \param yMap y map
    252   \param canvasRect Contents rect of the canvas
    253   \param boundingInterval Bounding interval of sample values
    254   \param index Index of the sample
    255   \param sample Value of the sample
    256 
    257   \sa drawSeries()
    258 */
    259 void QwtPlotBarChart::drawSample( QPainter *painter,
    260     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    261     const QRectF &canvasRect, const QwtInterval &boundingInterval,
    262     int index, const QPointF &sample ) const
     252   Calculate the geometry of a bar in widget coordinates
     253
     254   \param xMap x map
     255   \param yMap y map
     256   \param canvasRect Contents rect of the canvas
     257   \param boundingInterval Bounding interval of sample values
     258   \param sample Value of the sample
     259
     260   \return Geometry of the column
     261 */
     262QwtColumnRect QwtPlotBarChart::columnRect(
     263    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     264    const QRectF& canvasRect, const QwtInterval& boundingInterval,
     265    const QPointF& sample ) const
    263266{
    264267    QwtColumnRect barRect;
    … …  
    301304    }
    302305
     306    return barRect;
     307}
     308
     309/*!
     310   Draw a sample
     311
     312   \param painter Painter
     313   \param xMap x map
     314   \param yMap y map
     315   \param canvasRect Contents rect of the canvas
     316   \param boundingInterval Bounding interval of sample values
     317   \param index Index of the sample
     318   \param sample Value of the sample
     319
     320   \sa drawSeries()
     321 */
     322void QwtPlotBarChart::drawSample( QPainter* painter,
     323    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     324    const QRectF& canvasRect, const QwtInterval& boundingInterval,
     325    int index, const QPointF& sample ) const
     326{
     327    const QwtColumnRect barRect = columnRect( xMap, yMap,
     328        canvasRect, boundingInterval, sample );
     329
    303330    drawBar( painter, index, sample, barRect );
    304331}
    305332
    306333/*!
    307   Draw a bar
    308 
    309   \param painter Painter
    310   \param sampleIndex Index of the sample represented by the bar
    311   \param sample Value of the sample
    312   \param rect Bounding rectangle of the bar
    313  */
    314 void QwtPlotBarChart::drawBar( QPainter *painter,
    315     int sampleIndex, const QPointF &sample,
    316     const QwtColumnRect &rect ) const
    317 {
    318     const QwtColumnSymbol *specialSym =
     334   Draw a bar
     335
     336   \param painter Painter
     337   \param sampleIndex Index of the sample represented by the bar
     338   \param sample Value of the sample
     339   \param rect Bounding rectangle of the bar
     340 */
     341void QwtPlotBarChart::drawBar( QPainter* painter,
     342    int sampleIndex, const QPointF& sample,
     343    const QwtColumnRect& rect ) const
     344{
     345    const QwtColumnSymbol* specialSym =
    319346        specialSymbol( sampleIndex, sample );
    320347
    321     const QwtColumnSymbol *sym = specialSym;
     348    const QwtColumnSymbol* sym = specialSym;
    322349    if ( sym == NULL )
    323         sym = d_data->symbol;
     350        sym = m_data->symbol;
    324351
    325352    if ( sym )
    … …  
    340367
    341368/*!
    342   Needs to be overloaded to return a
    343   non default symbol for a specific sample
    344 
    345   \param sampleIndex Index of the sample represented by the bar
    346   \param sample Value of the sample
    347 
    348   \return NULL, indicating to use the default symbol
    349  */
    350 QwtColumnSymbol *QwtPlotBarChart::specialSymbol(
    351     int sampleIndex, const QPointF &sample ) const
     369   Needs to be overloaded to return a
     370   non default symbol for a specific sample
     371
     372   \param sampleIndex Index of the sample represented by the bar
     373   \param sample Value of the sample
     374
     375   \return NULL, indicating to use the default symbol
     376 */
     377QwtColumnSymbol* QwtPlotBarChart::specialSymbol(
     378    int sampleIndex, const QPointF& sample ) const
    352379{
    353380    Q_UNUSED( sampleIndex );
    … …  
    358385
    359386/*!
    360   \brief Return the title of a bar
    361 
    362   In LegendBarTitles mode the title is displayed on
    363   the legend entry corresponding to a bar.
    364 
    365   The default implementation is a dummy, that is intended
    366   to be overloaded.
    367 
    368   \param sampleIndex Index of the bar
    369   \return An empty text
    370   \sa LegendBarTitles
     387   \brief Return the title of a bar
     388
     389   In LegendBarTitles mode the title is displayed on
     390   the legend entry corresponding to a bar.
     391
     392   The default implementation is a dummy, that is intended
     393   to be overloaded.
     394
     395   \param sampleIndex Index of the bar
     396   \return An empty text
     397   \sa LegendBarTitles
    371398 */
    372399QwtText QwtPlotBarChart::barTitle( int sampleIndex ) const
    … …  
    387414   \sa title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem
    388415 */
    389 QList<QwtLegendData> QwtPlotBarChart::legendData() const
    390 {
    391     QList<QwtLegendData> list;
    392 
    393     if ( d_data->legendMode == LegendBarTitles )
     416QList< QwtLegendData > QwtPlotBarChart::legendData() const
     417{
     418    QList< QwtLegendData > list;
     419
     420    if ( m_data->legendMode == LegendBarTitles )
    394421    {
    395422        const size_t numSamples = dataSize();
     423        list.reserve( numSamples );
     424
    396425        for ( size_t i = 0; i < numSamples; i++ )
    397426        {
    398427            QwtLegendData data;
    399428
    400             QVariant titleValue;
    401             qVariantSetValue( titleValue, barTitle( i ) );
    402             data.setValue( QwtLegendData::TitleRole, titleValue );
     429            data.setValue( QwtLegendData::TitleRole,
     430                QVariant::fromValue( barTitle( i ) ) );
    403431
    404432            if ( !legendIconSize().isEmpty() )
    405433            {
    406                 QVariant iconValue;
    407                 qVariantSetValue( iconValue,
    408                     legendIcon( i, legendIconSize() ) );
    409 
    410                 data.setValue( QwtLegendData::IconRole, iconValue );
     434                data.setValue( QwtLegendData::IconRole,
     435                    QVariant::fromValue( legendIcon( i, legendIconSize() ) ) );
    411436            }
    412437
    … …  
    436461 */
    437462QwtGraphic QwtPlotBarChart::legendIcon(
    438     int index, const QSizeF &size ) const
     463    int index, const QSizeF& size ) const
    439464{
    440465    QwtColumnRect column;
    … …  
    451476
    452477    int barIndex = -1;
    453     if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
     478    if ( m_data->legendMode == QwtPlotBarChart::LegendBarTitles )
    454479        barIndex = index;
    455480
Note: See TracChangeset for help on using the changeset viewer.