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

deprecated functions exchanged libs updated

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot_histogram.cpp

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_plot_histogram.h"
    11 #include "qwt_plot.h"
    1211#include "qwt_painter.h"
    1312#include "qwt_column_symbol.h"
    1413#include "qwt_scale_map.h"
     14#include "qwt_graphic.h"
     15
    1516#include <qstring.h>
    1617#include <qpainter.h>
    1718
    18 static inline bool qwtIsCombinable( const QwtInterval &d1,
    19     const QwtInterval &d2 )
     19static inline bool qwtIsCombinable( const QwtInterval& d1,
     20    const QwtInterval& d2 )
    2021{
    2122    if ( d1.isValid() && d2.isValid() )
    … …  
    3637class QwtPlotHistogram::PrivateData
    3738{
    38 public:
    39     PrivateData():
    40         baseline( 0.0 ),
    41         style( Columns ),
    42         symbol( NULL )
     39  public:
     40    PrivateData()
     41        : baseline( 0.0 )
     42        , style( Columns )
     43        , symbol( NULL )
    4344    {
    4445    }
    … …  
    5455    QBrush brush;
    5556    QwtPlotHistogram::HistogramStyle style;
    56     const QwtColumnSymbol *symbol;
     57    const QwtColumnSymbol* symbol;
    5758};
    5859
    5960/*!
    60   Constructor
    61   \param title Title of the histogram.
    62 */
    63 QwtPlotHistogram::QwtPlotHistogram( const QwtText &title ):
    64     QwtPlotSeriesItem( title )
     61   Constructor
     62   \param title Title of the histogram.
     63 */
     64QwtPlotHistogram::QwtPlotHistogram( const QwtText& title )
     65    : QwtPlotSeriesItem( title )
    6566{
    6667    init();
    … …  
    6869
    6970/*!
    70   Constructor
    71   \param title Title of the histogram.
    72 */
    73 QwtPlotHistogram::QwtPlotHistogram( const QString &title ):
    74     QwtPlotSeriesItem( title )
     71   Constructor
     72   \param title Title of the histogram.
     73 */
     74QwtPlotHistogram::QwtPlotHistogram( const QString& title )
     75    : QwtPlotSeriesItem( title )
    7576{
    7677    init();
    … …  
    8081QwtPlotHistogram::~QwtPlotHistogram()
    8182{
    82     delete d_data;
     83    delete m_data;
    8384}
    8485
    … …  
    8687void QwtPlotHistogram::init()
    8788{
    88     d_data = new PrivateData();
     89    m_data = new PrivateData();
    8990    setData( new QwtIntervalSeriesData() );
    9091
    … …  
    9697
    9798/*!
    98   Set the histogram's drawing style
    99 
    100   \param style Histogram style
    101   \sa HistogramStyle, style()
    102 */
     99   Set the histogram's drawing style
     100
     101   \param style Histogram style
     102   \sa HistogramStyle, style()
     103 */
    103104void QwtPlotHistogram::setStyle( HistogramStyle style )
    104105{
    105     if ( style != d_data->style )
    106     {
    107         d_data->style = style;
     106    if ( style != m_data->style )
     107    {
     108        m_data->style = style;
    108109
    109110        legendChanged();
    … …  
    115116    \return Style of the histogram
    116117    \sa HistogramStyle, setStyle()
    117 */
     118 */
    118119QwtPlotHistogram::HistogramStyle QwtPlotHistogram::style() const
    119120{
    120     return d_data->style;
    121 }
    122 
    123 /*!
    124   Build and assign a pen
    125 
    126   In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
    127   non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
    128   to hide this incompatibility.
    129 
    130   \param color Pen color
    131   \param width Pen width
    132   \param style Pen style
    133 
    134   \sa pen(), brush()
    135  */
    136 void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style )
     121    return m_data->style;
     122}
     123
     124/*!
     125   Build and assign a pen
     126
     127   In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
     128   non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
     129   to hide this incompatibility.
     130
     131   \param color Pen color
     132   \param width Pen width
     133   \param style Pen style
     134
     135   \sa pen(), brush()
     136 */
     137void QwtPlotHistogram::setPen( const QColor& color, qreal width, Qt::PenStyle style )
    137138{
    138139    setPen( QPen( color, width, style ) );
    … …  
    140141
    141142/*!
    142   Assign a pen, that is used in a style() depending way.
    143 
    144   \param pen New pen
    145   \sa pen(), brush()
    146 */
    147 void QwtPlotHistogram::setPen( const QPen &pen )
    148 {
    149     if ( pen != d_data->pen )
    150     {
    151         d_data->pen = pen;
     143   Assign a pen, that is used in a style() depending way.
     144
     145   \param pen New pen
     146   \sa pen(), brush()
     147 */
     148void QwtPlotHistogram::setPen( const QPen& pen )
     149{
     150    if ( pen != m_data->pen )
     151    {
     152        m_data->pen = pen;
    152153
    153154        legendChanged();
    … …  
    157158
    158159/*!
    159   \return Pen used in a style() depending way.
    160   \sa setPen(), brush()
    161 */
    162 const QPen &QwtPlotHistogram::pen() const
    163 {
    164     return d_data->pen;
    165 }
    166 
    167 /*!
    168   Assign a brush, that is used in a style() depending way.
    169 
    170   \param brush New brush
    171   \sa pen(), brush()
    172 */
    173 void QwtPlotHistogram::setBrush( const QBrush &brush )
    174 {
    175     if ( brush != d_data->brush )
    176     {
    177         d_data->brush = brush;
     160   \return Pen used in a style() depending way.
     161   \sa setPen(), brush()
     162 */
     163const QPen& QwtPlotHistogram::pen() const
     164{
     165    return m_data->pen;
     166}
     167
     168/*!
     169   Assign a brush, that is used in a style() depending way.
     170
     171   \param brush New brush
     172   \sa pen(), brush()
     173 */
     174void QwtPlotHistogram::setBrush( const QBrush& brush )
     175{
     176    if ( brush != m_data->brush )
     177    {
     178        m_data->brush = brush;
    178179
    179180        legendChanged();
    … …  
    183184
    184185/*!
    185   \return Brush used in a style() depending way.
    186   \sa setPen(), brush()
    187 */
    188 const QBrush &QwtPlotHistogram::brush() const
    189 {
    190     return d_data->brush;
    191 }
    192 
    193 /*!
    194   \brief Assign a symbol
    195 
    196   In Column style an optional symbol can be assigned, that is responsible
    197   for displaying the rectangle that is defined by the interval and
    198   the distance between baseline() and value. When no symbol has been
    199   defined the area is displayed as plain rectangle using pen() and brush().
    200 
    201   \sa style(), symbol(), drawColumn(), pen(), brush()
    202 
    203   \note In applications, where different intervals need to be displayed
     186   \return Brush used in a style() depending way.
     187   \sa setPen(), brush()
     188 */
     189const QBrush& QwtPlotHistogram::brush() const
     190{
     191    return m_data->brush;
     192}
     193
     194/*!
     195   \brief Assign a symbol
     196
     197   In Column style an optional symbol can be assigned, that is responsible
     198   for displaying the rectangle that is defined by the interval and
     199   the distance between baseline() and value. When no symbol has been
     200   defined the area is displayed as plain rectangle using pen() and brush().
     201
     202   \sa style(), symbol(), drawColumn(), pen(), brush()
     203
     204   \note In applications, where different intervals need to be displayed
    204205        in a different way ( f.e different colors or even using different symbols)
    205206        it is recommended to overload drawColumn().
    206 */
    207 void QwtPlotHistogram::setSymbol( const QwtColumnSymbol *symbol )
    208 {
    209     if ( symbol != d_data->symbol )
    210     {
    211         delete d_data->symbol;
    212         d_data->symbol = symbol;
     207 */
     208void QwtPlotHistogram::setSymbol( const QwtColumnSymbol* symbol )
     209{
     210    if ( symbol != m_data->symbol )
     211    {
     212        delete m_data->symbol;
     213        m_data->symbol = symbol;
    213214
    214215        legendChanged();
    … …  
    218219
    219220/*!
    220   \return Current symbol or NULL, when no symbol has been assigned
    221   \sa setSymbol()
    222 */
    223 const QwtColumnSymbol *QwtPlotHistogram::symbol() const
    224 {
    225     return d_data->symbol;
    226 }
    227 
    228 /*!
    229   \brief Set the value of the baseline
    230 
    231   Each column representing an QwtIntervalSample is defined by its
    232   interval and the interval between baseline and the value of the sample.
    233 
    234   The default value of the baseline is 0.0.
    235 
    236   \param value Value of the baseline
    237   \sa baseline()
    238 */
     221   \return Current symbol or NULL, when no symbol has been assigned
     222   \sa setSymbol()
     223 */
     224const QwtColumnSymbol* QwtPlotHistogram::symbol() const
     225{
     226    return m_data->symbol;
     227}
     228
     229/*!
     230   \brief Set the value of the baseline
     231
     232   Each column representing an QwtIntervalSample is defined by its
     233   interval and the interval between baseline and the value of the sample.
     234
     235   The default value of the baseline is 0.0.
     236
     237   \param value Value of the baseline
     238   \sa baseline()
     239 */
    239240void QwtPlotHistogram::setBaseline( double value )
    240241{
    241     if ( d_data->baseline != value )
    242     {
    243         d_data->baseline = value;
     242    if ( m_data->baseline != value )
     243    {
     244        m_data->baseline = value;
    244245        itemChanged();
    245246    }
    … …  
    247248
    248249/*!
    249   \return Value of the baseline
    250   \sa setBaseline()
    251 */
     250   \return Value of the baseline
     251   \sa setBaseline()
     252 */
    252253double QwtPlotHistogram::baseline() const
    253254{
    254     return d_data->baseline;
    255 }
    256 
    257 /*!
    258   \return Bounding rectangle of all samples.
    259   For an empty series the rectangle is invalid.
    260 */
     255    return m_data->baseline;
     256}
     257
     258/*!
     259   \return Bounding rectangle of all samples.
     260   For an empty series the rectangle is invalid.
     261 */
    261262QRectF QwtPlotHistogram::boundingRect() const
    262263{
    … …  
    270271            rect.height(), rect.width() );
    271272
    272         if ( rect.left() > d_data->baseline )
    273             rect.setLeft( d_data->baseline );
    274         else if ( rect.right() < d_data->baseline )
    275             rect.setRight( d_data->baseline );
     273        if ( rect.left() > m_data->baseline )
     274            rect.setLeft( m_data->baseline );
     275        else if ( rect.right() < m_data->baseline )
     276            rect.setRight( m_data->baseline );
    276277    }
    277278    else
    278279    {
    279         if ( rect.bottom() < d_data->baseline )
    280             rect.setBottom( d_data->baseline );
    281         else if ( rect.top() > d_data->baseline )
    282             rect.setTop( d_data->baseline );
     280        if ( rect.bottom() < m_data->baseline )
     281            rect.setBottom( m_data->baseline );
     282        else if ( rect.top() > m_data->baseline )
     283            rect.setTop( m_data->baseline );
    283284    }
    284285
    … …  
    293294
    294295/*!
    295   Initialize data with an array of samples.
    296   \param samples Vector of points
    297 */
     296   Initialize data with an array of samples.
     297   \param samples Vector of points
     298 */
    298299void QwtPlotHistogram::setSamples(
    299     const QVector<QwtIntervalSample> &samples )
     300    const QVector< QwtIntervalSample >& samples )
    300301{
    301302    setData( new QwtIntervalSeriesData( samples ) );
    … …  
    303304
    304305/*!
    305   Assign a series of samples
    306 
    307   setSamples() is just a wrapper for setData() without any additional
    308   value - beside that it is easier to find for the developer.
    309 
    310   \param data Data
    311   \warning The item takes ownership of the data object, deleting
     306   Assign a series of samples
     307
     308   setSamples() is just a wrapper for setData() without any additional
     309   value - beside that it is easier to find for the developer.
     310
     311   \param data Data
     312   \warning The item takes ownership of the data object, deleting
    312313           it when its not used anymore.
    313 */
     314 */
    314315void QwtPlotHistogram::setSamples(
    315     QwtSeriesData<QwtIntervalSample> *data )
     316    QwtSeriesData< QwtIntervalSample >* data )
    316317{
    317318    setData( data );
    … …  
    319320
    320321/*!
    321   Draw a subset of the histogram samples
    322 
    323   \param painter Painter
    324   \param xMap Maps x-values into pixel coordinates.
    325   \param yMap Maps y-values into pixel coordinates.
    326   \param canvasRect Contents rectangle of the canvas
    327   \param from Index of the first sample to be painted
    328   \param to Index of the last sample to be painted. If to < 0 the
     322   Draw a subset of the histogram samples
     323
     324   \param painter Painter
     325   \param xMap Maps x-values into pixel coordinates.
     326   \param yMap Maps y-values into pixel coordinates.
     327   \param canvasRect Contents rectangle of the canvas
     328   \param from Index of the first sample to be painted
     329   \param to Index of the last sample to be painted. If to < 0 the
    329330         series will be painted to its last sample.
    330331
    331   \sa drawOutline(), drawLines(), drawColumns
    332 */
    333 void QwtPlotHistogram::drawSeries( QPainter *painter,
    334     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
    335     const QRectF &canvasRect, int from, int to ) const
     332   \sa drawOutline(), drawLines(), drawColumns
     333 */
     334void QwtPlotHistogram::drawSeries( QPainter* painter,
     335    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
     336    const QRectF& canvasRect, int from, int to ) const
    336337{
    337338    Q_UNUSED( canvasRect )
    … …  
    343344        to = dataSize() - 1;
    344345
    345     switch ( d_data->style )
     346    switch ( m_data->style )
    346347    {
    347348        case Outline:
    … …  
    360361
    361362/*!
    362   Draw a histogram in Outline style()
    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 from Index of the first sample to be painted
    368   \param to Index of the last sample to be painted. If to < 0 the
     363   Draw a histogram in Outline style()
     364
     365   \param painter Painter
     366   \param xMap Maps x-values into pixel coordinates.
     367   \param yMap Maps y-values into pixel coordinates.
     368   \param from Index of the first sample to be painted
     369   \param to Index of the last sample to be painted. If to < 0 the
    369370         histogram will be painted to its last point.
    370371
    371   \sa setStyle(), style()
    372   \warning The outline style requires, that the intervals are in increasing
     372   \sa setStyle(), style()
     373   \warning The outline style requires, that the intervals are in increasing
    373374           order and not overlapping.
    374 */
    375 void QwtPlotHistogram::drawOutline( QPainter *painter,
    376     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
     375 */
     376void QwtPlotHistogram::drawOutline( QPainter* painter,
     377    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
    377378    int from, int to ) const
    378379{
    … …  
    447448
    448449/*!
    449   Draw a histogram in Columns style()
    450 
    451   \param painter Painter
    452   \param xMap Maps x-values into pixel coordinates.
    453   \param yMap Maps y-values into pixel coordinates.
    454   \param from Index of the first sample to be painted
    455   \param to Index of the last sample to be painted. If to < 0 the
     450   Draw a histogram in Columns style()
     451
     452   \param painter Painter
     453   \param xMap Maps x-values into pixel coordinates.
     454   \param yMap Maps y-values into pixel coordinates.
     455   \param from Index of the first sample to be painted
     456   \param to Index of the last sample to be painted. If to < 0 the
    456457         histogram will be painted to its last point.
    457458
    458   \sa setStyle(), style(), setSymbol(), drawColumn()
    459 */
    460 void QwtPlotHistogram::drawColumns( QPainter *painter,
    461     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
     459   \sa setStyle(), style(), setSymbol(), drawColumn()
     460 */
     461void QwtPlotHistogram::drawColumns( QPainter* painter,
     462    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
    462463    int from, int to ) const
    463464{
    464     painter->setPen( d_data->pen );
    465     painter->setBrush( d_data->brush );
    466 
    467     const QwtSeriesData<QwtIntervalSample> *series = data();
     465    painter->setPen( m_data->pen );
     466    painter->setBrush( m_data->brush );
     467
     468    const QwtSeriesData< QwtIntervalSample >* series = data();
    468469
    469470    for ( int i = from; i <= to; i++ )
    … …  
    479480
    480481/*!
    481   Draw a histogram in Lines style()
    482 
    483   \param painter Painter
    484   \param xMap Maps x-values into pixel coordinates.
    485   \param yMap Maps y-values into pixel coordinates.
    486   \param from Index of the first sample to be painted
    487   \param to Index of the last sample to be painted. If to < 0 the
     482   Draw a histogram in Lines style()
     483
     484   \param painter Painter
     485   \param xMap Maps x-values into pixel coordinates.
     486   \param yMap Maps y-values into pixel coordinates.
     487   \param from Index of the first sample to be painted
     488   \param to Index of the last sample to be painted. If to < 0 the
    488489         histogram will be painted to its last point.
    489490
    490   \sa setStyle(), style(), setPen()
    491 */
    492 void QwtPlotHistogram::drawLines( QPainter *painter,
    493     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
     491   \sa setStyle(), style(), setPen()
     492 */
     493void QwtPlotHistogram::drawLines( QPainter* painter,
     494    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
    494495    int from, int to ) const
    495496{
    496497    const bool doAlign = QwtPainter::roundingAlignment( painter );
    497498
    498     painter->setPen( d_data->pen );
     499    painter->setPen( m_data->pen );
    499500    painter->setBrush( Qt::NoBrush );
    500501
    501     const QwtSeriesData<QwtIntervalSample> *series = data();
     502    const QwtSeriesData< QwtIntervalSample >* series = data();
    502503
    503504    for ( int i = from; i <= to; i++ )
    … …  
    549550
    550551//! Internal, used by the Outline style.
    551 void QwtPlotHistogram::flushPolygon( QPainter *painter,
    552     double baseLine, QPolygonF &polygon ) const
     552void QwtPlotHistogram::flushPolygon( QPainter* painter,
     553    double baseLine, QPolygonF& polygon ) const
    553554{
    554555    if ( polygon.size() == 0 )
    … …  
    560561        polygon += QPointF( polygon.last().x(), baseLine );
    561562
    562     if ( d_data->brush.style() != Qt::NoBrush )
     563    if ( m_data->brush.style() != Qt::NoBrush )
    563564    {
    564565        painter->setPen( Qt::NoPen );
    565         painter->setBrush( d_data->brush );
     566        painter->setBrush( m_data->brush );
    566567
    567568        if ( orientation() == Qt::Horizontal )
    … …  
    581582        polygon.pop_back();
    582583    }
    583     if ( d_data->pen.style() != Qt::NoPen )
     584    if ( m_data->pen.style() != Qt::NoPen )
    584585    {
    585586        painter->setBrush( Qt::NoBrush );
    586         painter->setPen( d_data->pen );
     587        painter->setPen( m_data->pen );
    587588        QwtPainter::drawPolyline( painter, polygon );
    588589    }
    … …  
    591592
    592593/*!
    593   Calculate the area that is covered by a sample
    594 
    595   \param sample Sample
    596   \param xMap Maps x-values into pixel coordinates.
    597   \param yMap Maps y-values into pixel coordinates.
    598 
    599   \return Rectangle, that is covered by a sample
    600 */
    601 QwtColumnRect QwtPlotHistogram::columnRect( const QwtIntervalSample &sample,
    602     const QwtScaleMap &xMap, const QwtScaleMap &yMap ) const
     594   Calculate the area that is covered by a sample
     595
     596   \param sample Sample
     597   \param xMap Maps x-values into pixel coordinates.
     598   \param yMap Maps y-values into pixel coordinates.
     599
     600   \return Rectangle, that is covered by a sample
     601 */
     602QwtColumnRect QwtPlotHistogram::columnRect( const QwtIntervalSample& sample,
     603    const QwtScaleMap& xMap, const QwtScaleMap& yMap ) const
    603604{
    604605    QwtColumnRect rect;
    605606
    606     const QwtInterval &iv = sample.interval;
     607    const QwtInterval& iv = sample.interval;
    607608    if ( !iv.isValid() )
    608609        return rect;
    … …  
    611612    {
    612613        const double x0 = xMap.transform( baseline() );
    613         const double x  = xMap.transform( sample.value );
     614        const double x = xMap.transform( sample.value );
    614615        const double y1 = yMap.transform( iv.minValue() );
    615616        const double y2 = yMap.transform( iv.maxValue() );
    … …  
    618619        rect.vInterval.setInterval( y1, y2, iv.borderFlags() );
    619620        rect.direction = ( x < x0 ) ? QwtColumnRect::RightToLeft :
    620                          QwtColumnRect::LeftToRight;
     621            QwtColumnRect::LeftToRight;
    621622    }
    622623    else
    … …  
    637638
    638639/*!
    639   Draw a column for a sample in Columns style().
    640 
    641   When a symbol() has been set the symbol is used otherwise the
    642   column is displayed as plain rectangle using pen() and brush().
    643 
    644   \param painter Painter
    645   \param rect Rectangle where to paint the column in paint device coordinates
    646   \param sample Sample to be displayed
    647 
    648   \note In applications, where different intervals need to be displayed
     640   Draw a column for a sample in Columns style().
     641
     642   When a symbol() has been set the symbol is used otherwise the
     643   column is displayed as plain rectangle using pen() and brush().
     644
     645   \param painter Painter
     646   \param rect Rectangle where to paint the column in paint device coordinates
     647   \param sample Sample to be displayed
     648
     649   \note In applications, where different intervals need to be displayed
    649650        in a different way ( f.e different colors or even using different symbols)
    650651        it is recommended to overload drawColumn().
    651 */
    652 void QwtPlotHistogram::drawColumn( QPainter *painter,
    653     const QwtColumnRect &rect, const QwtIntervalSample &sample ) const
     652 */
     653void QwtPlotHistogram::drawColumn( QPainter* painter,
     654    const QwtColumnRect& rect, const QwtIntervalSample& sample ) const
    654655{
    655656    Q_UNUSED( sample );
    656657
    657     if ( d_data->symbol &&
    658         ( d_data->symbol->style() != QwtColumnSymbol::NoStyle ) )
    659     {
    660         d_data->symbol->draw( painter, rect );
     658    if ( m_data->symbol &&
     659        ( m_data->symbol->style() != QwtColumnSymbol::NoStyle ) )
     660    {
     661        m_data->symbol->draw( painter, rect );
    661662    }
    662663    else
    … …  
    676677
    677678/*!
    678   A plain rectangle without pen using the brush()
    679 
    680   \param index Index of the legend entry
     679   A plain rectangle without pen using the brush()
     680
     681   \param index Index of the legend entry
    681682                ( ignored as there is only one )
    682   \param size Icon size
    683   \return A graphic displaying the icon
    684 
    685   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
    686 */
    687 QwtGraphic QwtPlotHistogram::legendIcon( int index,
    688     const QSizeF &size ) const
     683   \param size Icon size
     684   \return A graphic displaying the icon
     685
     686   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
     687 */
     688QwtGraphic QwtPlotHistogram::legendIcon( int index, const QSizeF& size ) const
    689689{
    690690    Q_UNUSED( index );
    691     return defaultIcon( d_data->brush, size );
    692 }
     691    return defaultIcon( m_data->brush, size );
     692}
Note: See TracChangeset for help on using the changeset viewer.