Index: trunk/BNC/qwt/qwt_plot_barchart.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_barchart.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_plot_barchart.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -11,13 +11,16 @@
 #include "qwt_scale_map.h"
 #include "qwt_column_symbol.h"
-#include "qwt_painter.h"
+#include "qwt_text.h"
+#include "qwt_graphic.h"
+#include "qwt_legend_data.h"
+
 #include <qpainter.h>
 
 class QwtPlotBarChart::PrivateData
 {
-public:
-    PrivateData():
-        symbol( NULL ),
-        legendMode( QwtPlotBarChart::LegendChartTitle )
+  public:
+    PrivateData()
+        : symbol( NULL )
+        , legendMode( QwtPlotBarChart::LegendChartTitle )
     {
     }
@@ -28,14 +31,14 @@
     }
 
-    QwtColumnSymbol *symbol;
+    QwtColumnSymbol* symbol;
     QwtPlotBarChart::LegendMode legendMode;
 };
 
 /*!
-  Constructor
-  \param title Title of the curve
-*/
-QwtPlotBarChart::QwtPlotBarChart( const QwtText &title ):
-    QwtPlotAbstractBarChart( title )
+   Constructor
+   \param title Title of the curve
+ */
+QwtPlotBarChart::QwtPlotBarChart( const QwtText& title )
+    : QwtPlotAbstractBarChart( title )
 {
     init();
@@ -43,9 +46,9 @@
 
 /*!
-  Constructor
-  \param title Title of the curve
-*/
-QwtPlotBarChart::QwtPlotBarChart( const QString &title ):
-    QwtPlotAbstractBarChart( QwtText( title ) )
+   Constructor
+   \param title Title of the curve
+ */
+QwtPlotBarChart::QwtPlotBarChart( const QString& title )
+    : QwtPlotAbstractBarChart( QwtText( title ) )
 {
     init();
@@ -55,10 +58,10 @@
 QwtPlotBarChart::~QwtPlotBarChart()
 {
-    delete d_data;
+    delete m_data;
 }
 
 void QwtPlotBarChart::init()
 {
-    d_data = new PrivateData;
+    m_data = new PrivateData;
     setData( new QwtPointSeriesData() );
 }
@@ -71,12 +74,12 @@
 
 /*!
-  Initialize data with an array of points
-
-  \param samples Vector of points
-  \note QVector is implicitly shared
-  \note QPolygonF is derived from QVector<QPointF>
-*/
+   Initialize data with an array of points
+
+   \param samples Vector of points
+   \note QVector is implicitly shared
+   \note QPolygonF is derived from QVector<QPointF>
+ */
 void QwtPlotBarChart::setSamples(
-    const QVector<QPointF> &samples )
+    const QVector< QPointF >& samples )
 {
     setData( new QwtPointSeriesData( samples ) );
@@ -84,16 +87,18 @@
 
 /*!
-  Initialize data with an array of doubles
-
-  The indices in the array are taken as x coordinate,
-  while the doubles are interpreted as y values.
-
-  \param samples Vector of y coordinates
-  \note QVector is implicitly shared
-*/
+   Initialize data with an array of doubles
+
+   The indices in the array are taken as x coordinate,
+   while the doubles are interpreted as y values.
+
+   \param samples Vector of y coordinates
+   \note QVector is implicitly shared
+ */
 void QwtPlotBarChart::setSamples(
-    const QVector<double> &samples )
-{
-    QVector<QPointF> points;
+    const QVector< double >& samples )
+{
+    QVector< QPointF > points;
+    points.reserve( samples.size() );
+
     for ( int i = 0; i < samples.size(); i++ )
         points += QPointF( i, samples[ i ] );
@@ -103,14 +108,14 @@
 
 /*!
-  Assign a series of samples
-
-  setSamples() is just a wrapper for setData() without any additional
-  value - beside that it is easier to find for the developer.
-
-  \param data Data
-  \warning The item takes ownership of the data object, deleting
+   Assign a series of samples
+
+   setSamples() is just a wrapper for setData() without any additional
+   value - beside that it is easier to find for the developer.
+
+   \param data Data
+   \warning The item takes ownership of the data object, deleting
            it when its not used anymore.
-*/
-void QwtPlotBarChart::setSamples( QwtSeriesData<QPointF> *data )
+ */
+void QwtPlotBarChart::setSamples( QwtSeriesData< QPointF >* data )
 {
     setData( data );
@@ -118,19 +123,19 @@
 
 /*!
-  \brief Assign a symbol
-
-  The bar chart will take the ownership of the symbol, hence the previously
-  set symbol will be delete by setting a new one. If \p symbol is
-  \c NULL no symbol will be drawn.
-
-  \param symbol Symbol
-  \sa symbol()
-*/
-void QwtPlotBarChart::setSymbol( QwtColumnSymbol *symbol )
-{
-    if ( symbol != d_data->symbol )
-    {
-        delete d_data->symbol;
-        d_data->symbol = symbol;
+   \brief Assign a symbol
+
+   The bar chart will take the ownership of the symbol, hence the previously
+   set symbol will be delete by setting a new one. If \p symbol is
+   \c NULL no symbol will be drawn.
+
+   \param symbol Symbol
+   \sa symbol()
+ */
+void QwtPlotBarChart::setSymbol( QwtColumnSymbol* symbol )
+{
+    if ( symbol != m_data->symbol )
+    {
+        delete m_data->symbol;
+        m_data->symbol = symbol;
 
         legendChanged();
@@ -140,26 +145,26 @@
 
 /*!
-  \return Current symbol or NULL, when no symbol has been assigned
-  \sa setSymbol()
-*/
-const QwtColumnSymbol *QwtPlotBarChart::symbol() const
-{
-    return d_data->symbol;
-}
-
-/*!
-  Set the mode that decides what to display on the legend
-
-  In case of LegendBarTitles barTitle() needs to be overloaded
-  to return individual titles for each bar.
-
-  \param mode New mode
-  \sa legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute
+   \return Current symbol or NULL, when no symbol has been assigned
+   \sa setSymbol()
+ */
+const QwtColumnSymbol* QwtPlotBarChart::symbol() const
+{
+    return m_data->symbol;
+}
+
+/*!
+   Set the mode that decides what to display on the legend
+
+   In case of LegendBarTitles barTitle() needs to be overloaded
+   to return individual titles for each bar.
+
+   \param mode New mode
+   \sa legendMode(), legendData(), barTitle(), QwtPlotItem::ItemAttribute
  */
 void QwtPlotBarChart::setLegendMode( LegendMode mode )
 {
-    if ( mode != d_data->legendMode )
-    {
-        d_data->legendMode = mode;
+    if ( mode != m_data->legendMode )
+    {
+        m_data->legendMode = mode;
         legendChanged();
     }
@@ -167,16 +172,16 @@
 
 /*!
-  \return Legend mode
-  \sa setLegendMode()
+   \return Legend mode
+   \sa setLegendMode()
  */
 QwtPlotBarChart::LegendMode QwtPlotBarChart::legendMode() const
 {
-    return d_data->legendMode;
-}
-
-/*!
-  \return Bounding rectangle of all samples.
-  For an empty series the rectangle is invalid.
-*/
+    return m_data->legendMode;
+}
+
+/*!
+   \return Bounding rectangle of all samples.
+   For an empty series the rectangle is invalid.
+ */
 QRectF QwtPlotBarChart::boundingRect() const
 {
@@ -204,19 +209,19 @@
 
 /*!
-  Draw an interval of the bar chart
-
-  \param painter Painter
-  \param xMap Maps x-values into pixel coordinates.
-  \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
-  \param from Index of the first point to be painted
-  \param to Index of the last point to be painted. If to < 0 the
+   Draw an interval of the bar chart
+
+   \param painter Painter
+   \param xMap Maps x-values into pixel coordinates.
+   \param yMap Maps y-values into pixel coordinates.
+   \param canvasRect Contents rect of the canvas
+   \param from Index of the first point to be painted
+   \param to Index of the last point to be painted. If to < 0 the
          curve will be painted to its last point.
 
-  \sa drawSymbols()
-*/
-void QwtPlotBarChart::drawSeries( QPainter *painter,
-    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-    const QRectF &canvasRect, int from, int to ) const
+   \sa drawSymbols()
+ */
+void QwtPlotBarChart::drawSeries( QPainter* painter,
+    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
+    const QRectF& canvasRect, int from, int to ) const
 {
     if ( to < 0 )
@@ -238,5 +243,5 @@
     {
         drawSample( painter, xMap, yMap,
-                    canvasRect, interval, i, sample( i ) );
+            canvasRect, interval, i, sample( i ) );
     }
 
@@ -245,20 +250,18 @@
 
 /*!
-  Draw a sample
-
-  \param painter Painter
-  \param xMap x map
-  \param yMap y map
-  \param canvasRect Contents rect of the canvas
-  \param boundingInterval Bounding interval of sample values
-  \param index Index of the sample
-  \param sample Value of the sample
-
-  \sa drawSeries()
-*/
-void QwtPlotBarChart::drawSample( QPainter *painter,
-    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-    const QRectF &canvasRect, const QwtInterval &boundingInterval,
-    int index, const QPointF &sample ) const
+   Calculate the geometry of a bar in widget coordinates
+
+   \param xMap x map
+   \param yMap y map
+   \param canvasRect Contents rect of the canvas
+   \param boundingInterval Bounding interval of sample values
+   \param sample Value of the sample
+
+   \return Geometry of the column
+ */
+QwtColumnRect QwtPlotBarChart::columnRect(
+    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
+    const QRectF& canvasRect, const QwtInterval& boundingInterval,
+    const QPointF& sample ) const
 {
     QwtColumnRect barRect;
@@ -301,25 +304,49 @@
     }
 
+    return barRect;
+}
+
+/*!
+   Draw a sample
+
+   \param painter Painter
+   \param xMap x map
+   \param yMap y map
+   \param canvasRect Contents rect of the canvas
+   \param boundingInterval Bounding interval of sample values
+   \param index Index of the sample
+   \param sample Value of the sample
+
+   \sa drawSeries()
+ */
+void QwtPlotBarChart::drawSample( QPainter* painter,
+    const QwtScaleMap& xMap, const QwtScaleMap& yMap,
+    const QRectF& canvasRect, const QwtInterval& boundingInterval,
+    int index, const QPointF& sample ) const
+{
+    const QwtColumnRect barRect = columnRect( xMap, yMap,
+        canvasRect, boundingInterval, sample );
+
     drawBar( painter, index, sample, barRect );
 }
 
 /*!
-  Draw a bar
-
-  \param painter Painter
-  \param sampleIndex Index of the sample represented by the bar
-  \param sample Value of the sample
-  \param rect Bounding rectangle of the bar
- */
-void QwtPlotBarChart::drawBar( QPainter *painter,
-    int sampleIndex, const QPointF &sample,
-    const QwtColumnRect &rect ) const
-{
-    const QwtColumnSymbol *specialSym =
+   Draw a bar
+
+   \param painter Painter
+   \param sampleIndex Index of the sample represented by the bar
+   \param sample Value of the sample
+   \param rect Bounding rectangle of the bar
+ */
+void QwtPlotBarChart::drawBar( QPainter* painter,
+    int sampleIndex, const QPointF& sample,
+    const QwtColumnRect& rect ) const
+{
+    const QwtColumnSymbol* specialSym =
         specialSymbol( sampleIndex, sample );
 
-    const QwtColumnSymbol *sym = specialSym;
+    const QwtColumnSymbol* sym = specialSym;
     if ( sym == NULL )
-        sym = d_data->symbol;
+        sym = m_data->symbol;
 
     if ( sym )
@@ -340,14 +367,14 @@
 
 /*!
-  Needs to be overloaded to return a
-  non default symbol for a specific sample
-
-  \param sampleIndex Index of the sample represented by the bar
-  \param sample Value of the sample
-
-  \return NULL, indicating to use the default symbol
- */
-QwtColumnSymbol *QwtPlotBarChart::specialSymbol(
-    int sampleIndex, const QPointF &sample ) const
+   Needs to be overloaded to return a
+   non default symbol for a specific sample
+
+   \param sampleIndex Index of the sample represented by the bar
+   \param sample Value of the sample
+
+   \return NULL, indicating to use the default symbol
+ */
+QwtColumnSymbol* QwtPlotBarChart::specialSymbol(
+    int sampleIndex, const QPointF& sample ) const
 {
     Q_UNUSED( sampleIndex );
@@ -358,15 +385,15 @@
 
 /*!
-  \brief Return the title of a bar
-
-  In LegendBarTitles mode the title is displayed on
-  the legend entry corresponding to a bar.
-
-  The default implementation is a dummy, that is intended
-  to be overloaded.
-
-  \param sampleIndex Index of the bar
-  \return An empty text
-  \sa LegendBarTitles
+   \brief Return the title of a bar
+
+   In LegendBarTitles mode the title is displayed on
+   the legend entry corresponding to a bar.
+
+   The default implementation is a dummy, that is intended
+   to be overloaded.
+
+   \param sampleIndex Index of the bar
+   \return An empty text
+   \sa LegendBarTitles
  */
 QwtText QwtPlotBarChart::barTitle( int sampleIndex ) const
@@ -387,26 +414,24 @@
    \sa title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem
  */
-QList<QwtLegendData> QwtPlotBarChart::legendData() const
-{
-    QList<QwtLegendData> list;
-
-    if ( d_data->legendMode == LegendBarTitles )
+QList< QwtLegendData > QwtPlotBarChart::legendData() const
+{
+    QList< QwtLegendData > list;
+
+    if ( m_data->legendMode == LegendBarTitles )
     {
         const size_t numSamples = dataSize();
+        list.reserve( numSamples );
+
         for ( size_t i = 0; i < numSamples; i++ )
         {
             QwtLegendData data;
 
-            QVariant titleValue;
-            qVariantSetValue( titleValue, barTitle( i ) );
-            data.setValue( QwtLegendData::TitleRole, titleValue );
+            data.setValue( QwtLegendData::TitleRole,
+                QVariant::fromValue( barTitle( i ) ) );
 
             if ( !legendIconSize().isEmpty() )
             {
-                QVariant iconValue;
-                qVariantSetValue( iconValue,
-                    legendIcon( i, legendIconSize() ) );
-
-                data.setValue( QwtLegendData::IconRole, iconValue );
+                data.setValue( QwtLegendData::IconRole,
+                    QVariant::fromValue( legendIcon( i, legendIconSize() ) ) );
             }
 
@@ -436,5 +461,5 @@
  */
 QwtGraphic QwtPlotBarChart::legendIcon(
-    int index, const QSizeF &size ) const
+    int index, const QSizeF& size ) const
 {
     QwtColumnRect column;
@@ -451,5 +476,5 @@
 
     int barIndex = -1;
-    if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
+    if ( m_data->legendMode == QwtPlotBarChart::LegendBarTitles )
         barIndex = index;
 
