Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (2 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot_multi_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"
    14 #include <qpainter.h>
    15 #include <qpalette.h>
     13#include "qwt_text.h"
     14#include "qwt_graphic.h"
     15#include "qwt_legend_data.h"
     16#include "qwt_math.h"
     17
    1618#include <qmap.h>
    1719
    1820inline static bool qwtIsIncreasing(
    19     const QwtScaleMap &map, const QVector<double> &values )
     21    const QwtScaleMap& map, const QVector< double >& values )
    2022{
    2123    bool isInverting = map.isInverting();
    … …  
    3335class QwtPlotMultiBarChart::PrivateData
    3436{
    35 public:
    36     PrivateData():
    37         style( QwtPlotMultiBarChart::Grouped )
     37  public:
     38    PrivateData()
     39        : style( QwtPlotMultiBarChart::Grouped )
    3840    {
    3941    }
    4042
    4143    QwtPlotMultiBarChart::ChartStyle style;
    42     QList<QwtText> barTitles;
    43     QMap<int, QwtColumnSymbol *> symbolMap;
     44    QList< QwtText > barTitles;
     45    QMap< int, QwtColumnSymbol* > symbolMap;
    4446};
    4547
    4648/*!
    47   Constructor
    48   \param title Title of the chart
    49 */
    50 QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QwtText &title ):
    51     QwtPlotAbstractBarChart( title )
     49   Constructor
     50   \param title Title of the chart
     51 */
     52QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QwtText& title )
     53    : QwtPlotAbstractBarChart( title )
    5254{
    5355    init();
    … …  
    5557
    5658/*!
    57   Constructor
    58   \param title Title of the chart
    59 */
    60 QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QString &title ):
    61     QwtPlotAbstractBarChart( QwtText( title ) )
     59   Constructor
     60   \param title Title of the chart
     61 */
     62QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QString& title )
     63    : QwtPlotAbstractBarChart( QwtText( title ) )
    6264{
    6365    init();
    … …  
    6870{
    6971    resetSymbolMap();
    70     delete d_data;
     72    delete m_data;
    7173}
    7274
    7375void QwtPlotMultiBarChart::init()
    7476{
    75     d_data = new PrivateData;
     77    m_data = new PrivateData;
    7678    setData( new QwtSetSeriesData() );
    7779}
    … …  
    8486
    8587/*!
    86   Initialize data with an array of samples.
    87   \param samples Vector of points
    88 */
     88   Initialize data with an array of samples.
     89   \param samples Vector of points
     90 */
    8991void QwtPlotMultiBarChart::setSamples(
    90     const QVector<QwtSetSample> &samples )
     92    const QVector< QwtSetSample >& samples )
    9193{
    9294    setData( new QwtSetSeriesData( samples ) );
    … …  
    9496
    9597/*!
    96   Initialize data with an array of samples.
    97   \param samples Vector of points
    98 */
     98   Initialize data with an array of samples.
     99   \param samples Vector of points
     100 */
    99101void QwtPlotMultiBarChart::setSamples(
    100     const QVector< QVector<double> > &samples )
    101 {
    102     QVector<QwtSetSample> s;
     102    const QVector< QVector< double > >& samples )
     103{
     104    QVector< QwtSetSample > s;
     105    s.reserve( samples.size() );
     106
    103107    for ( int i = 0; i < samples.size(); i++ )
    104108        s += QwtSetSample( i, samples[ i ] );
    … …  
    108112
    109113/*!
    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
     114   Assign a series of samples
     115
     116   setSamples() is just a wrapper for setData() without any additional
     117   value - beside that it is easier to find for the developer.
     118
     119   \param data Data
     120   \warning The item takes ownership of the data object, deleting
    117121           it when its not used anymore.
    118 */
     122 */
    119123void QwtPlotMultiBarChart::setSamples(
    120     QwtSeriesData<QwtSetSample> *data )
     124    QwtSeriesData< QwtSetSample >* data )
    121125{
    122126    setData( data );
    … …  
    124128
    125129/*!
    126   \brief Set the titles for the bars
    127 
    128   The titles are used for the legend.
    129 
    130   \param titles Bar titles
    131 
    132   \sa barTitles(), legendData()
    133  */
    134 void QwtPlotMultiBarChart::setBarTitles( const QList<QwtText> &titles )
    135 {
    136     d_data->barTitles = titles;
     130   \brief Set the titles for the bars
     131
     132   The titles are used for the legend.
     133
     134   \param titles Bar titles
     135
     136   \sa barTitles(), legendData()
     137 */
     138void QwtPlotMultiBarChart::setBarTitles( const QList< QwtText >& titles )
     139{
     140    m_data->barTitles = titles;
    137141    itemChanged();
    138142}
    139143
    140144/*!
    141   \return Bar titles
    142   \sa setBarTitles(), legendData()
    143  */
    144 QList<QwtText> QwtPlotMultiBarChart::barTitles() const
    145 {
    146     return d_data->barTitles;
    147 }
    148 
    149 /*!
    150   \brief Add a symbol to the symbol map
    151 
    152   Assign a default symbol for drawing the bar representing all values
    153   with the same index in a set.
    154 
    155   \param valueIndex Index of a value in a set
    156   \param symbol Symbol used for drawing a bar
    157 
    158   \sa symbol(), resetSymbolMap(), specialSymbol()
    159 */
    160 void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol )
     145   \return Bar titles
     146   \sa setBarTitles(), legendData()
     147 */
     148QList< QwtText > QwtPlotMultiBarChart::barTitles() const
     149{
     150    return m_data->barTitles;
     151}
     152
     153/*!
     154   \brief Add a symbol to the symbol map
     155
     156   Assign a default symbol for drawing the bar representing all values
     157   with the same index in a set.
     158
     159   \param valueIndex Index of a value in a set
     160   \param symbol Symbol used for drawing a bar
     161
     162   \sa symbol(), resetSymbolMap(), specialSymbol()
     163 */
     164void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol* symbol )
    161165{
    162166    if ( valueIndex < 0 )
    163167        return;
    164168
    165     QMap<int, QwtColumnSymbol *>::iterator it =
    166         d_data->symbolMap.find(valueIndex);
    167     if ( it == d_data->symbolMap.end() )
     169    QMap< int, QwtColumnSymbol* >::iterator it =
     170        m_data->symbolMap.find(valueIndex);
     171    if ( it == m_data->symbolMap.end() )
    168172    {
    169173        if ( symbol != NULL )
    170174        {
    171             d_data->symbolMap.insert( valueIndex, symbol );
     175            m_data->symbolMap.insert( valueIndex, symbol );
    172176
    173177            legendChanged();
    … …  
    183187            if ( symbol == NULL )
    184188            {
    185                 d_data->symbolMap.remove( valueIndex );
     189                m_data->symbolMap.remove( valueIndex );
    186190            }
    187191            else
    … …  
    197201
    198202/*!
    199   Find a symbol in the symbol map
    200 
    201   \param valueIndex Index of a value in a set
    202   \return The symbol, that had been set by setSymbol() or NULL.
    203 
    204   \sa setSymbol(), specialSymbol(), drawBar()
    205 */
    206 const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
    207 {
    208     QMap<int, QwtColumnSymbol *>::const_iterator it =
    209         d_data->symbolMap.constFind( valueIndex );
    210 
    211     return ( it == d_data->symbolMap.constEnd() ) ? NULL : it.value();
    212 }
    213 
    214 /*!
    215   Find a symbol in the symbol map
    216 
    217   \param valueIndex Index of a value in a set
    218   \return The symbol, that had been set by setSymbol() or NULL.
    219 
    220   \sa setSymbol(), specialSymbol(), drawBar()
    221 */
    222 QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex )
    223 {
    224     QMap<int, QwtColumnSymbol *>::const_iterator it =
    225         d_data->symbolMap.constFind( valueIndex );
    226 
    227     return ( it == d_data->symbolMap.constEnd() ) ? NULL : it.value();
    228 }
    229 
    230 /*!
    231   Remove all symbols from the symbol map
     203   Find a symbol in the symbol map
     204
     205   \param valueIndex Index of a value in a set
     206   \return The symbol, that had been set by setSymbol() or NULL.
     207
     208   \sa setSymbol(), specialSymbol(), drawBar()
     209 */
     210const QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex ) const
     211{
     212    QMap< int, QwtColumnSymbol* >::const_iterator it =
     213        m_data->symbolMap.constFind( valueIndex );
     214
     215    return ( it == m_data->symbolMap.constEnd() ) ? NULL : it.value();
     216}
     217
     218/*!
     219   Find a symbol in the symbol map
     220
     221   \param valueIndex Index of a value in a set
     222   \return The symbol, that had been set by setSymbol() or NULL.
     223
     224   \sa setSymbol(), specialSymbol(), drawBar()
     225 */
     226QwtColumnSymbol* QwtPlotMultiBarChart::symbol( int valueIndex )
     227{
     228    QMap< int, QwtColumnSymbol* >::const_iterator it =
     229        m_data->symbolMap.constFind( valueIndex );
     230
     231    return ( it == m_data->symbolMap.constEnd() ) ? NULL : it.value();
     232}
     233
     234/*!
     235   Remove all symbols from the symbol map
    232236 */
    233237void QwtPlotMultiBarChart::resetSymbolMap()
    234238{
    235     qDeleteAll( d_data->symbolMap );
    236     d_data->symbolMap.clear();
    237 }
    238 
    239 /*!
    240   \brief Create a symbol for special values
    241 
    242   Usually the symbols for displaying a bar are set by setSymbols() and
    243   common for all sets. By overloading specialSymbol() it is possible to
    244   create a temporary symbol() for displaying a special value.
    245 
    246   The symbol has to be created by new each time specialSymbol() is
    247   called. As soon as the symbol is painted this symbol gets deleted.
    248 
    249   When no symbol ( NULL ) is returned, the value will be displayed
    250   with the standard symbol that is used for all symbols with the same
    251   valueIndex.
    252 
    253   \param sampleIndex Index of the sample
    254   \param valueIndex Index of the value in the set
    255 
    256   \return NULL, meaning that the value is not special
    257 
    258  */
    259 QwtColumnSymbol *QwtPlotMultiBarChart::specialSymbol(
     239    qDeleteAll( m_data->symbolMap );
     240    m_data->symbolMap.clear();
     241}
     242
     243/*!
     244   \brief Create a symbol for special values
     245
     246   Usually the symbols for displaying a bar are set by setSymbols() and
     247   common for all sets. By overloading specialSymbol() it is possible to
     248   create a temporary symbol() for displaying a special value.
     249
     250   The symbol has to be created by new each time specialSymbol() is
     251   called. As soon as the symbol is painted this symbol gets deleted.
     252
     253   When no symbol ( NULL ) is returned, the value will be displayed
     254   with the standard symbol that is used for all symbols with the same
     255   valueIndex.
     256
     257   \param sampleIndex Index of the sample
     258   \param valueIndex Index of the value in the set
     259
     260   \return NULL, meaning that the value is not special
     261
     262 */
     263QwtColumnSymbol* QwtPlotMultiBarChart::specialSymbol(
    260264    int sampleIndex, int valueIndex ) const
    261265{
    … …  
    267271
    268272/*!
    269   Set the style of the chart
    270 
    271   \param style Chart style
    272   \sa style()
     273   Set the style of the chart
     274
     275   \param style Chart style
     276   \sa style()
    273277 */
    274278void QwtPlotMultiBarChart::setStyle( ChartStyle style )
    275279{
    276     if ( style != d_data->style )
    277     {
    278         d_data->style = style;
     280    if ( style != m_data->style )
     281    {
     282        m_data->style = style;
    279283
    280284        legendChanged();
    … …  
    284288
    285289/*!
    286   \return Style of the chart
    287   \sa setStyle()
     290   \return Style of the chart
     291   \sa setStyle()
    288292 */
    289293QwtPlotMultiBarChart::ChartStyle QwtPlotMultiBarChart::style() const
    290294{
    291     return d_data->style;
    292 }
    293 
    294 /*!
    295   \return Bounding rectangle of all samples.
    296   For an empty series the rectangle is invalid.
    297 */
     295    return m_data->style;
     296}
     297
     298/*!
     299   \return Bounding rectangle of all samples.
     300   For an empty series the rectangle is invalid.
     301 */
    298302QRectF QwtPlotMultiBarChart::boundingRect() const
    299303{
    … …  
    307311    QRectF rect;
    308312
    309     if ( d_data->style != QwtPlotMultiBarChart::Stacked )
     313    if ( m_data->style != QwtPlotMultiBarChart::Stacked )
    310314    {
    311315        rect = QwtPlotSeriesItem::boundingRect();
    … …  
    326330        yMin = yMax = baseLine;
    327331
    328         const QwtSeriesData<QwtSetSample> *series = data();
     332        const QwtSeriesData< QwtSetSample >* series = data();
    329333
    330334        for ( size_t i = 0; i < numSamples; i++ )
    … …  
    337341            else
    338342            {
    339                 xMin = qMin( xMin, sample.value );
    340                 xMax = qMax( xMax, sample.value );
     343                xMin = qwtMinF( xMin, sample.value );
     344                xMax = qwtMaxF( xMax, sample.value );
    341345            }
    342346
    343347            const double y = baseLine + sample.added();
    344348
    345             yMin = qMin( yMin, y );
    346             yMax = qMax( yMax, y );
     349            yMin = qwtMinF( yMin, y );
     350            yMax = qwtMaxF( yMax, y );
    347351        }
    348352        rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin );
    … …  
    356360
    357361/*!
    358   Draw an interval of the bar chart
    359 
    360   \param painter Painter
    361   \param xMap Maps x-values into pixel coordinates.
    362   \param yMap Maps y-values into pixel coordinates.
    363   \param canvasRect Contents rectangle of the canvas
    364   \param from Index of the first point to be painted
    365   \param to Index of the last point to be painted. If to < 0 the
     362   Draw an interval of the bar chart
     363
     364   \param painter Painter
     365   \param xMap Maps x-values into pixel coordinates.
     366   \param yMap Maps y-values into pixel coordinates.
     367   \param canvasRect Contents rectangle of the canvas
     368   \param from Index of the first point to be painted
     369   \param to Index of the last point to be painted. If to < 0 the
    366370         curve will be painted to its last point.
    367371
    368   \sa drawSymbols()
    369 */
    370 void QwtPlotMultiBarChart::drawSeries( QPainter *painter,
    371     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    372     const QRectF &canvasRect, int from, int to ) const
     372   \sa drawSymbols()
     373 */
     374void QwtPlotMultiBarChart::drawSeries( QPainter* painter,
     375    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     376    const QRectF& canvasRect, int from, int to ) const
    373377{
    374378    if ( to < 0 )
    … …  
    397401
    398402/*!
    399   Draw a sample
    400 
    401   \param painter Painter
    402   \param xMap x map
    403   \param yMap y map
    404   \param canvasRect Contents rectangle of the canvas
    405   \param boundingInterval Bounding interval of sample values
    406   \param index Index of the sample to be painted
    407   \param sample Sample value
    408 
    409   \sa drawSeries()
    410 */
    411 void QwtPlotMultiBarChart::drawSample( QPainter *painter,
    412     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    413     const QRectF &canvasRect, const QwtInterval &boundingInterval,
     403   Draw a sample
     404
     405   \param painter Painter
     406   \param xMap x map
     407   \param yMap y map
     408   \param canvasRect Contents rectangle of the canvas
     409   \param boundingInterval Bounding interval of sample values
     410   \param index Index of the sample to be painted
     411   \param sample Sample value
     412
     413   \sa drawSeries()
     414 */
     415void QwtPlotMultiBarChart::drawSample( QPainter* painter,
     416    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     417    const QRectF& canvasRect, const QwtInterval& boundingInterval,
    414418    int index, const QwtSetSample& sample ) const
    415419{
    … …  
    430434    }
    431435
    432     if ( d_data->style == Stacked )
     436    if ( m_data->style == Stacked )
    433437    {
    434438        drawStackedBars( painter, xMap, yMap,
    … …  
    443447
    444448/*!
    445   Draw a grouped sample
    446 
    447   \param painter Painter
    448   \param xMap x map
    449   \param yMap y map
    450   \param canvasRect Contents rectangle of the canvas
    451   \param index Index of the sample to be painted
    452   \param sampleWidth Boundng width for all bars of the smaple
    453   \param sample Sample
    454 
    455   \sa drawSeries(), sampleWidth()
    456 */
    457 void QwtPlotMultiBarChart::drawGroupedBars( QPainter *painter,
    458     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    459     const QRectF &canvasRect, int index, double sampleWidth,
     449   Draw a grouped sample
     450
     451   \param painter Painter
     452   \param xMap x map
     453   \param yMap y map
     454   \param canvasRect Contents rectangle of the canvas
     455   \param index Index of the sample to be painted
     456   \param sampleWidth Bounding width for all bars of the sample
     457   \param sample Sample
     458
     459   \sa drawSeries(), sampleWidth()
     460 */
     461void QwtPlotMultiBarChart::drawGroupedBars( QPainter* painter,
     462    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     463    const QRectF& canvasRect, int index, double sampleWidth,
    460464    const QwtSetSample& sample ) const
    461465{
    … …  
    523527
    524528/*!
    525   Draw a stacked sample
    526 
    527   \param painter Painter
    528   \param xMap x map
    529   \param yMap y map
    530   \param canvasRect Contents rectangle of the canvas
    531   \param index Index of the sample to be painted
    532   \param sampleWidth Width of the bars
    533   \param sample Sample
    534 
    535   \sa drawSeries(), sampleWidth()
    536 */
    537 void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
    538     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    539     const QRectF &canvasRect, int index,
     529   Draw a stacked sample
     530
     531   \param painter Painter
     532   \param xMap x map
     533   \param yMap y map
     534   \param canvasRect Contents rectangle of the canvas
     535   \param index Index of the sample to be painted
     536   \param sampleWidth Width of the bars
     537   \param sample Sample
     538
     539   \sa drawSeries(), sampleWidth()
     540 */
     541void QwtPlotMultiBarChart::drawStackedBars( QPainter* painter,
     542    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     543    const QRectF& canvasRect, int index,
    540544    double sampleWidth, const QwtSetSample& sample ) const
    541545{
    … …  
    636640
    637641/*!
    638   Draw a bar
    639 
    640   \param painter Painter
    641   \param sampleIndex Index of the sample - might be -1 when the
     642   Draw a bar
     643
     644   \param painter Painter
     645   \param sampleIndex Index of the sample - might be -1 when the
    642646                     bar is painted for the legend
    643   \param valueIndex Index of a value in a set
    644   \param rect Directed target rectangle for the bar
    645 
    646   \sa drawSeries()
    647 */
    648 void QwtPlotMultiBarChart::drawBar( QPainter *painter,
    649     int sampleIndex, int valueIndex, const QwtColumnRect &rect ) const
    650 {
    651     const QwtColumnSymbol *specialSym = NULL;
     647   \param valueIndex Index of a value in a set
     648   \param rect Directed target rectangle for the bar
     649
     650   \sa drawSeries()
     651 */
     652void QwtPlotMultiBarChart::drawBar( QPainter* painter,
     653    int sampleIndex, int valueIndex, const QwtColumnRect& rect ) const
     654{
     655    const QwtColumnSymbol* specialSym = NULL;
    652656    if ( sampleIndex >= 0 )
    653657        specialSym = specialSymbol( sampleIndex, valueIndex );
    654658
    655     const QwtColumnSymbol *sym = specialSym;
     659    const QwtColumnSymbol* sym = specialSym;
    656660    if ( sym == NULL )
    657661        sym = symbol( valueIndex );
    … …  
    674678
    675679/*!
    676   \return Information to be displayed on the legend
    677 
    678   The chart is represented by a list of entries - one for each bar title.
    679   Each element contains a bar title and an icon showing its corresponding bar.
    680 
    681   \sa barTitles(), legendIcon(), legendIconSize()
    682 */
    683 QList<QwtLegendData> QwtPlotMultiBarChart::legendData() const
    684 {
    685     QList<QwtLegendData> list;
    686 
    687     for ( int i = 0; i < d_data->barTitles.size(); i++ )
     680   \return Information to be displayed on the legend
     681
     682   The chart is represented by a list of entries - one for each bar title.
     683   Each element contains a bar title and an icon showing its corresponding bar.
     684
     685   \sa barTitles(), legendIcon(), legendIconSize()
     686 */
     687QList< QwtLegendData > QwtPlotMultiBarChart::legendData() const
     688{
     689    QList< QwtLegendData > list;
     690    list.reserve( m_data->barTitles.size() );
     691
     692    for ( int i = 0; i < m_data->barTitles.size(); i++ )
    688693    {
    689694        QwtLegendData data;
    690695
    691         QVariant titleValue;
    692         qVariantSetValue( titleValue, d_data->barTitles[i] );
    693         data.setValue( QwtLegendData::TitleRole, titleValue );
     696        data.setValue( QwtLegendData::TitleRole,
     697            QVariant::fromValue( m_data->barTitles[i] ) );
    694698
    695699        if ( !legendIconSize().isEmpty() )
    696700        {
    697             QVariant iconValue;
    698             qVariantSetValue( iconValue,
    699                 legendIcon( i, legendIconSize() ) );
    700 
    701             data.setValue( QwtLegendData::IconRole, iconValue );
     701            data.setValue( QwtLegendData::IconRole,
     702                QVariant::fromValue( legendIcon( i, legendIconSize() ) ) );
    702703        }
    703704
    … …  
    709710
    710711/*!
    711   \return Icon for representing a bar on the legend
    712 
    713   \param index Index of the bar
    714   \param size Icon size
    715 
    716   \return An icon showing a bar
    717   \sa drawBar(), legendData()
     712   \return Icon for representing a bar on the legend
     713
     714   \param index Index of the bar
     715   \param size Icon size
     716
     717   \return An icon showing a bar
     718   \sa drawBar(), legendData()
    718719 */
    719720QwtGraphic QwtPlotMultiBarChart::legendIcon( int index,
    720     const QSizeF &size ) const
     721    const QSizeF& size ) const
    721722{
    722723    QwtColumnRect column;
Note: See TracChangeset for help on using the changeset viewer.