Index: trunk/BNC/qwt/qwt_plot_item.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_item.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_plot_item.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -12,26 +12,24 @@
 #include "qwt_plot.h"
 #include "qwt_legend_data.h"
-#include "qwt_scale_div.h"
+#include "qwt_scale_map.h"
 #include "qwt_graphic.h"
+
 #include <qpainter.h>
 
 class QwtPlotItem::PrivateData
 {
-public:
-    PrivateData():
-        plot( NULL ),
-        isVisible( true ),
-        attributes( 0 ),
-        interests( 0 ),
-        renderHints( 0 ),
-        renderThreadCount( 1 ),
-        z( 0.0 ),
-        xAxis( QwtPlot::xBottom ),
-        yAxis( QwtPlot::yLeft ),
-        legendIconSize( 8, 8 )
-    {
-    }
-
-    mutable QwtPlot *plot;
+  public:
+    PrivateData()
+        : plot( NULL )
+        , isVisible( true )
+        , renderThreadCount( 1 )
+        , z( 0.0 )
+        , xAxisId( QwtAxis::XBottom )
+        , yAxisId( QwtAxis::YLeft )
+        , legendIconSize( 8, 8 )
+    {
+    }
+
+    mutable QwtPlot* plot;
 
     bool isVisible;
@@ -45,6 +43,6 @@
     double z;
 
-    int xAxis;
-    int yAxis;
+    QwtAxisId xAxisId;
+    QwtAxisId yAxisId;
 
     QwtText title;
@@ -54,10 +52,28 @@
 /*!
    Constructor
+ */
+QwtPlotItem::QwtPlotItem()
+{
+    m_data = new PrivateData;
+}
+
+/*!
+   Constructor
    \param title Title of the item
-*/
-QwtPlotItem::QwtPlotItem( const QwtText &title )
-{
-    d_data = new PrivateData;
-    d_data->title = title;
+ */
+QwtPlotItem::QwtPlotItem( const QString& title )
+{
+    m_data = new PrivateData;
+    m_data->title = title;
+}
+
+/*!
+   Constructor
+   \param title Title of the item
+ */
+QwtPlotItem::QwtPlotItem( const QwtText& title )
+{
+    m_data = new PrivateData;
+    m_data->title = title;
 }
 
@@ -66,30 +82,30 @@
 {
     attach( NULL );
-    delete d_data;
-}
-
-/*!
-  \brief Attach the item to a plot.
-
-  This method will attach a QwtPlotItem to the QwtPlot argument. It will first
-  detach the QwtPlotItem from any plot from a previous call to attach (if
-  necessary). If a NULL argument is passed, it will detach from any QwtPlot it
-  was attached to.
-
-  \param plot Plot widget
-  \sa detach()
-*/
-void QwtPlotItem::attach( QwtPlot *plot )
-{
-    if ( plot == d_data->plot )
+    delete m_data;
+}
+
+/*!
+   \brief Attach the item to a plot.
+
+   This method will attach a QwtPlotItem to the QwtPlot argument. It will first
+   detach the QwtPlotItem from any plot from a previous call to attach (if
+   necessary). If a NULL argument is passed, it will detach from any QwtPlot it
+   was attached to.
+
+   \param plot Plot widget
+   \sa detach()
+ */
+void QwtPlotItem::attach( QwtPlot* plot )
+{
+    if ( plot == m_data->plot )
         return;
 
-    if ( d_data->plot )
-        d_data->plot->attachItem( this, false );
-
-    d_data->plot = plot;
-
-    if ( d_data->plot )
-        d_data->plot->attachItem( this, true );
+    if ( m_data->plot )
+        m_data->plot->attachItem( this, false );
+
+    m_data->plot = plot;
+
+    if ( m_data->plot )
+        m_data->plot->attachItem( this, true );
 }
 
@@ -100,5 +116,5 @@
    detach() is equivalent to calling attach( NULL )
    \sa attach()
-*/
+ */
 void QwtPlotItem::detach()
 {
@@ -117,5 +133,5 @@
    \return rtti value
    \sa RttiValues
-*/
+ */
 int QwtPlotItem::rtti() const
 {
@@ -124,7 +140,7 @@
 
 //! Return attached plot
-QwtPlot *QwtPlotItem::plot() const
-{
-    return d_data->plot;
+QwtPlot* QwtPlotItem::plot() const
+{
+    return m_data->plot;
 }
 
@@ -133,8 +149,8 @@
 
    \return setZ(), QwtPlotDict::itemList()
-*/
+ */
 double QwtPlotItem::z() const
 {
-    return d_data->z;
+    return m_data->z;
 }
 
@@ -146,16 +162,16 @@
    \param z Z-value
    \sa z(), QwtPlotDict::itemList()
-*/
+ */
 void QwtPlotItem::setZ( double z )
 {
-    if ( d_data->z != z )
-    {
-        if ( d_data->plot ) // update the z order
-            d_data->plot->attachItem( this, false );
-
-        d_data->z = z;
-
-        if ( d_data->plot )
-            d_data->plot->attachItem( this, true );
+    if ( m_data->z != z )
+    {
+        if ( m_data->plot ) // update the z order
+            m_data->plot->attachItem( this, false );
+
+        m_data->z = z;
+
+        if ( m_data->plot )
+            m_data->plot->attachItem( this, true );
 
         itemChanged();
@@ -168,6 +184,6 @@
    \param title Title
    \sa title()
-*/
-void QwtPlotItem::setTitle( const QString &title )
+ */
+void QwtPlotItem::setTitle( const QString& title )
 {
     setTitle( QwtText( title ) );
@@ -179,10 +195,10 @@
    \param title Title
    \sa title()
-*/
-void QwtPlotItem::setTitle( const QwtText &title )
-{
-    if ( d_data->title != title )
-    {
-        d_data->title = title;
+ */
+void QwtPlotItem::setTitle( const QwtText& title )
+{
+    if ( m_data->title != title )
+    {
+        m_data->title = title;
 
         legendChanged();
@@ -196,8 +212,8 @@
    \return Title of the item
    \sa setTitle()
-*/
-const QwtText &QwtPlotItem::title() const
-{
-    return d_data->title;
+ */
+const QwtText& QwtPlotItem::title() const
+{
+    return m_data->title;
 }
 
@@ -209,16 +225,31 @@
 
    \sa testItemAttribute(), ItemInterest
-*/
+ */
 void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on )
 {
-    if ( d_data->attributes.testFlag( attribute ) != on )
+    if ( m_data->attributes.testFlag( attribute ) != on )
     {
         if ( on )
-            d_data->attributes |= attribute;
+            m_data->attributes |= attribute;
         else
-            d_data->attributes &= ~attribute;
+            m_data->attributes &= ~attribute;
 
         if ( attribute == QwtPlotItem::Legend )
-            legendChanged();
+        {
+            if ( on )
+            {
+                legendChanged();
+            }
+            else
+            {
+                /*
+                    In the special case of taking an item from
+                    the legend we can't use legendChanged() as
+                    it depends on QwtPlotItem::Legend being enabled
+                 */
+                if ( m_data->plot )
+                    m_data->plot->updateLegend( this );
+            }
+        }
 
         itemChanged();
@@ -232,8 +263,8 @@
    \return true/false
    \sa setItemAttribute(), ItemInterest
-*/
+ */
 bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const
 {
-    return d_data->attributes.testFlag( attribute );
+    return m_data->attributes.testFlag( attribute );
 }
 
@@ -245,13 +276,13 @@
 
    \sa testItemInterest(), ItemAttribute
-*/
+ */
 void QwtPlotItem::setItemInterest( ItemInterest interest, bool on )
 {
-    if ( d_data->interests.testFlag( interest ) != on )
+    if ( m_data->interests.testFlag( interest ) != on )
     {
         if ( on )
-            d_data->interests |= interest;
+            m_data->interests |= interest;
         else
-            d_data->interests &= ~interest;
+            m_data->interests &= ~interest;
 
         itemChanged();
@@ -265,8 +296,8 @@
    \return true/false
    \sa setItemInterest(), ItemAttribute
-*/
+ */
 bool QwtPlotItem::testItemInterest( ItemInterest interest ) const
 {
-    return d_data->interests.testFlag( interest );
+    return m_data->interests.testFlag( interest );
 }
 
@@ -278,13 +309,13 @@
 
    \sa testRenderHint(), RenderHint
-*/
+ */
 void QwtPlotItem::setRenderHint( RenderHint hint, bool on )
 {
-    if ( d_data->renderHints.testFlag( hint ) != on )
+    if ( m_data->renderHints.testFlag( hint ) != on )
     {
         if ( on )
-            d_data->renderHints |= hint;
+            m_data->renderHints |= hint;
         else
-            d_data->renderHints &= ~hint;
+            m_data->renderHints &= ~hint;
 
         itemChanged();
@@ -298,8 +329,8 @@
    \return true/false
    \sa setRenderHint(), RenderHint
-*/
+ */
 bool QwtPlotItem::testRenderHint( RenderHint hint ) const
 {
-    return d_data->renderHints.testFlag( hint );
+    return m_data->renderHints.testFlag( hint );
 }
 
@@ -316,8 +347,8 @@
 
    The default thread count is 1 ( = no additional threads )
-*/
+ */
 void QwtPlotItem::setRenderThreadCount( uint numThreads )
 {
-    d_data->renderThreadCount = numThreads;
+    m_data->renderThreadCount = numThreads;
 }
 
@@ -326,8 +357,8 @@
            If numThreads() is set to 0, the system specific
            ideal thread count is used.
-*/
+ */
 uint QwtPlotItem::renderThreadCount() const
 {
-    return d_data->renderThreadCount;
+    return m_data->renderThreadCount;
 }
 
@@ -339,10 +370,10 @@
    \param size Size
    \sa legendIconSize(), legendIcon()
-*/
-void QwtPlotItem::setLegendIconSize( const QSize &size )
-{
-    if ( d_data->legendIconSize != size )
-    {
-        d_data->legendIconSize = size;
+ */
+void QwtPlotItem::setLegendIconSize( const QSize& size )
+{
+    if ( m_data->legendIconSize != size )
+    {
+        m_data->legendIconSize = size;
         legendChanged();
     }
@@ -352,8 +383,8 @@
    \return Legend icon size
    \sa setLegendIconSize(), legendIcon()
-*/
+ */
 QSize QwtPlotItem::legendIconSize() const
 {
-    return d_data->legendIconSize;
+    return m_data->legendIconSize;
 }
 
@@ -370,5 +401,5 @@
  */
 QwtGraphic QwtPlotItem::legendIcon(
-    int index, const QSizeF &size ) const
+    int index, const QSizeF& size ) const
 {
     Q_UNUSED( index )
@@ -390,5 +421,5 @@
  */
 QwtGraphic QwtPlotItem::defaultIcon(
-    const QBrush &brush, const QSizeF &size ) const
+    const QBrush& brush, const QSizeF& size ) const
 {
     QwtGraphic icon;
@@ -423,10 +454,10 @@
     \param on Show if true, otherwise hide
     \sa isVisible(), show(), hide()
-*/
+ */
 void QwtPlotItem::setVisible( bool on )
 {
-    if ( on != d_data->isVisible )
-    {
-        d_data->isVisible = on;
+    if ( on != m_data->isVisible )
+    {
+        m_data->isVisible = on;
         itemChanged();
     }
@@ -436,8 +467,8 @@
     \return true if visible
     \sa setVisible(), show(), hide()
-*/
+ */
 bool QwtPlotItem::isVisible() const
 {
-    return d_data->isVisible;
+    return m_data->isVisible;
 }
 
@@ -447,9 +478,9 @@
 
    \sa QwtPlot::legendChanged(), QwtPlot::autoRefresh()
-*/
+ */
 void QwtPlotItem::itemChanged()
 {
-    if ( d_data->plot )
-        d_data->plot->autoRefresh();
+    if ( m_data->plot )
+        m_data->plot->autoRefresh();
 }
 
@@ -457,9 +488,9 @@
    Update the legend of the parent plot.
    \sa QwtPlot::updateLegend(), itemChanged()
-*/
+ */
 void QwtPlotItem::legendChanged()
 {
-    if ( testItemAttribute( QwtPlotItem::Legend ) && d_data->plot )
-        d_data->plot->updateLegend( this );
+    if ( testItemAttribute( QwtPlotItem::Legend ) && m_data->plot )
+        m_data->plot->updateLegend( this );
 }
 
@@ -469,16 +500,16 @@
    The item will painted according to the coordinates of its Axes.
 
-   \param xAxis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )
-   \param yAxis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )
-
-   \sa setXAxis(), setYAxis(), xAxis(), yAxis(), QwtPlot::Axis
-*/
-void QwtPlotItem::setAxes( int xAxis, int yAxis )
-{
-    if ( xAxis == QwtPlot::xBottom || xAxis == QwtPlot::xTop )
-        d_data->xAxis = xAxis;
-
-    if ( yAxis == QwtPlot::yLeft || yAxis == QwtPlot::yRight )
-        d_data->yAxis = yAxis;
+   \param xAxisId X Axis
+   \param yAxisId Y Axis
+
+   \sa setXAxis(), setYAxis(), xAxis(), yAxis()
+ */
+void QwtPlotItem::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId )
+{
+    if ( QwtAxis::isXAxis( xAxisId ) )
+        m_data->xAxisId = xAxisId;
+
+    if ( QwtAxis::isYAxis( yAxisId ) )
+        m_data->yAxisId = yAxisId;
 
     itemChanged();
@@ -490,12 +521,12 @@
    The item will painted according to the coordinates its Axes.
 
-   \param axis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )
-   \sa setAxes(), setYAxis(), xAxis(), QwtPlot::Axis
-*/
-void QwtPlotItem::setXAxis( int axis )
-{
-    if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
-    {
-        d_data->xAxis = axis;
+   \param axisId X Axis
+   \sa setAxes(), setYAxis(), xAxis()
+ */
+void QwtPlotItem::setXAxis( QwtAxisId axisId )
+{
+    if ( QwtAxis::isXAxis( axisId ) )
+    {
+        m_data->xAxisId = axisId;
         itemChanged();
     }
@@ -507,12 +538,12 @@
    The item will painted according to the coordinates its Axes.
 
-   \param axis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )
-   \sa setAxes(), setXAxis(), yAxis(), QwtPlot::Axis
-*/
-void QwtPlotItem::setYAxis( int axis )
-{
-    if ( axis == QwtPlot::yLeft || axis == QwtPlot::yRight )
-    {
-        d_data->yAxis = axis;
+   \param axisId Y Axis
+   \sa setAxes(), setXAxis(), yAxis()
+ */
+void QwtPlotItem::setYAxis( QwtAxisId axisId )
+{
+    if ( QwtAxis::isYAxis( axisId ) )
+    {
+        m_data->yAxisId = axisId;
         itemChanged();
     }
@@ -520,13 +551,13 @@
 
 //! Return xAxis
-int QwtPlotItem::xAxis() const
-{
-    return d_data->xAxis;
+QwtAxisId QwtPlotItem::xAxis() const
+{
+    return m_data->xAxisId;
 }
 
 //! Return yAxis
-int QwtPlotItem::yAxis() const
-{
-    return d_data->yAxis;
+QwtAxisId QwtPlotItem::yAxis() const
+{
+    return m_data->yAxisId;
 }
 
@@ -534,5 +565,5 @@
    \return An invalid bounding rect: QRectF(1.0, 1.0, -2.0, -2.0)
    \note A width or height < 0.0 is ignored by the autoscaler
-*/
+ */
 QRectF QwtPlotItem::boundingRect() const
 {
@@ -562,7 +593,7 @@
    \sa QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
  */
-void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap &xMap,
-    const QwtScaleMap &yMap, const QRectF &canvasRect,
-    double &left, double &top, double &right, double &bottom ) const
+void QwtPlotItem::getCanvasMarginHint( const QwtScaleMap& xMap,
+    const QwtScaleMap& yMap, const QRectF& canvasRect,
+    double& left, double& top, double& right, double& bottom ) const
 {
     Q_UNUSED( xMap );
@@ -593,5 +624,5 @@
    \sa title(), legendIcon(), QwtLegend, QwtPlotLegendItem
  */
-QList<QwtLegendData> QwtPlotItem::legendData() const
+QList< QwtLegendData > QwtPlotItem::legendData() const
 {
     QwtLegendData data;
@@ -600,17 +631,15 @@
     label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
 
-    QVariant titleValue;
-    qVariantSetValue( titleValue, label );
-    data.setValue( QwtLegendData::TitleRole, titleValue );
+    data.setValue( QwtLegendData::TitleRole,
+        QVariant::fromValue( label ) );
 
     const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
     if ( !graphic.isNull() )
     {
-        QVariant iconValue;
-        qVariantSetValue( iconValue, graphic );
-        data.setValue( QwtLegendData::IconRole, iconValue );
-    }
-
-    QList<QwtLegendData> list;
+        data.setValue( QwtLegendData::IconRole,
+            QVariant::fromValue( graphic ) );
+    }
+
+    QList< QwtLegendData > list;
     list += data;
 
@@ -633,7 +662,7 @@
 
    \sa QwtPlot::updateAxes(), ScaleInterest
-*/
-void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,
-    const QwtScaleDiv &yScaleDiv )
+ */
+void QwtPlotItem::updateScaleDiv( const QwtScaleDiv& xScaleDiv,
+    const QwtScaleDiv& yScaleDiv )
 {
     Q_UNUSED( xScaleDiv );
@@ -659,6 +688,6 @@
          legendData() and legendIcon()
  */
-void QwtPlotItem::updateLegend( const QwtPlotItem *item,
-    const QList<QwtLegendData> &data )
+void QwtPlotItem::updateLegend( const QwtPlotItem* item,
+    const QList< QwtLegendData >& data )
 {
     Q_UNUSED( item );
@@ -673,7 +702,7 @@
 
    \return Bounding scale rect of the scale maps, not normalized
-*/
-QRectF QwtPlotItem::scaleRect( const QwtScaleMap &xMap,
-    const QwtScaleMap &yMap ) const
+ */
+QRectF QwtPlotItem::scaleRect( const QwtScaleMap& xMap,
+    const QwtScaleMap& yMap ) const
 {
     return QRectF( xMap.s1(), yMap.s1(),
@@ -688,7 +717,7 @@
 
    \return Bounding paint rectangle of the scale maps, not normalized
-*/
-QRectF QwtPlotItem::paintRect( const QwtScaleMap &xMap,
-    const QwtScaleMap &yMap ) const
+ */
+QRectF QwtPlotItem::paintRect( const QwtScaleMap& xMap,
+    const QwtScaleMap& yMap ) const
 {
     const QRectF rect( xMap.p1(), yMap.p1(),
