Index: trunk/BNC/qwt/qwt_plot_picker.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_picker.cpp	(revision 9383)
+++ trunk/BNC/qwt/qwt_plot_picker.cpp	(revision 11158)
@@ -1,3 +1,3 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+/******************************************************************************
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
@@ -10,88 +10,97 @@
 #include "qwt_plot_picker.h"
 #include "qwt_plot.h"
+#include "qwt_text.h"
 #include "qwt_scale_div.h"
-#include "qwt_painter.h"
 #include "qwt_scale_map.h"
 #include "qwt_picker_machine.h"
 
-/*!
-  \brief Create a plot picker
-
-  The picker is set to those x- and y-axis of the plot
-  that are enabled. If both or no x-axis are enabled, the picker
-  is set to QwtPlot::xBottom. If both or no y-axis are
-  enabled, it is set to QwtPlot::yLeft.
-
-  \param canvas Plot canvas to observe, also the parent object
-
-  \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
-*/
-
-QwtPlotPicker::QwtPlotPicker( QWidget *canvas ):
-    QwtPicker( canvas ),
-    d_xAxis( -1 ),
-    d_yAxis( -1 )
-{
+class QwtPlotPicker::PrivateData
+{
+  public:
+    PrivateData():
+        xAxisId( -1 ),
+        yAxisId( -1 )
+    {
+    }
+
+    QwtAxisId xAxisId;
+    QwtAxisId yAxisId;
+};
+
+/*!
+   \brief Create a plot picker
+
+   The picker is set to those x- and y-axis of the plot
+   that are enabled. If both or no x-axis are enabled, the picker
+   is set to QwtAxis::XBottom. If both or no y-axis are
+   enabled, it is set to QwtAxis::YLeft.
+
+   \param canvas Plot canvas to observe, also the parent object
+
+   \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
+ */
+
+QwtPlotPicker::QwtPlotPicker( QWidget* canvas )
+    : QwtPicker( canvas )
+{
+    m_data = new PrivateData;
+
     if ( !canvas )
         return;
 
+    const QwtPlot* plot = QwtPlotPicker::plot();
     // attach axes
 
-    int xAxis = QwtPlot::xBottom;
-
-    const QwtPlot *plot = QwtPlotPicker::plot();
-    if ( !plot->axisEnabled( QwtPlot::xBottom ) &&
-        plot->axisEnabled( QwtPlot::xTop ) )
-    {
-        xAxis = QwtPlot::xTop;
-    }
-
-    int yAxis = QwtPlot::yLeft;
-    if ( !plot->axisEnabled( QwtPlot::yLeft ) &&
-        plot->axisEnabled( QwtPlot::yRight ) )
-    {
-        yAxis = QwtPlot::yRight;
-    }
-
-    setAxis( xAxis, yAxis );
-}
-
-/*!
-  Create a plot picker
-
-  \param xAxis Set the x axis of the picker
-  \param yAxis Set the y axis of the picker
-  \param canvas Plot canvas to observe, also the parent object
-
-  \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
-*/
-QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QWidget *canvas ):
-    QwtPicker( canvas ),
-    d_xAxis( xAxis ),
-    d_yAxis( yAxis )
-{
-}
-
-/*!
-  Create a plot picker
-
-  \param xAxis X axis of the picker
-  \param yAxis Y axis of the picker
-  \param rubberBand Rubber band style
-  \param trackerMode Tracker mode
-  \param canvas Plot canvas to observe, also the parent object
-
-  \sa QwtPicker, QwtPicker::setSelectionFlags(), QwtPicker::setRubberBand(),
+    using namespace QwtAxis;
+
+    int xAxis = XBottom;
+    if ( !plot->isAxisVisible( XBottom ) && plot->isAxisVisible( XTop ) )
+        xAxis = XTop;
+
+    int yAxis = YLeft;
+    if ( !plot->isAxisVisible( YLeft ) && plot->isAxisVisible( YRight ) )
+        yAxis = YRight;
+
+    setAxes( xAxis, yAxis );
+}
+
+/*!
+   Create a plot picker
+
+   \param xAxisId X axis of the picker
+   \param yAxisId Y axis of the picker
+   \param canvas Plot canvas to observe, also the parent object
+
+   \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
+ */
+QwtPlotPicker::QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId, QWidget* canvas )
+    : QwtPicker( canvas )
+{
+    m_data = new PrivateData;
+    m_data->xAxisId = xAxisId;
+    m_data->yAxisId = yAxisId;
+}
+
+/*!
+   Create a plot picker
+
+   \param xAxisId X axis of the picker
+   \param yAxisId Y axis of the picker
+   \param rubberBand Rubber band style
+   \param trackerMode Tracker mode
+   \param canvas Plot canvas to observe, also the parent object
+
+   \sa QwtPicker, QwtPicker::setSelectionFlags(), QwtPicker::setRubberBand(),
       QwtPicker::setTrackerMode
 
-  \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
-*/
-QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis,
-        RubberBand rubberBand, DisplayMode trackerMode,
-        QWidget *canvas ):
-    QwtPicker( rubberBand, trackerMode, canvas ),
-    d_xAxis( xAxis ),
-    d_yAxis( yAxis )
-{
+   \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
+ */
+QwtPlotPicker::QwtPlotPicker( QwtAxisId xAxisId, QwtAxisId yAxisId,
+        RubberBand rubberBand, DisplayMode trackerMode, QWidget* canvas )
+    : QwtPicker( rubberBand, trackerMode, canvas )
+{
+    m_data = new PrivateData;
+    m_data->xAxisId = xAxisId;
+    m_data->yAxisId = yAxisId;
 }
 
@@ -99,8 +108,9 @@
 QwtPlotPicker::~QwtPlotPicker()
 {
+    delete m_data;
 }
 
 //! \return Observed plot canvas
-QWidget *QwtPlotPicker::canvas()
+QWidget* QwtPlotPicker::canvas()
 {
     return parentWidget();
@@ -108,5 +118,5 @@
 
 //! \return Observed plot canvas
-const QWidget *QwtPlotPicker::canvas() const
+const QWidget* QwtPlotPicker::canvas() const
 {
     return parentWidget();
@@ -114,27 +124,27 @@
 
 //! \return Plot widget, containing the observed plot canvas
-QwtPlot *QwtPlotPicker::plot()
-{
-    QWidget *w = canvas();
+QwtPlot* QwtPlotPicker::plot()
+{
+    QWidget* w = canvas();
     if ( w )
         w = w->parentWidget();
 
-    return qobject_cast<QwtPlot *>( w );
+    return qobject_cast< QwtPlot* >( w );
 }
 
 //! \return Plot widget, containing the observed plot canvas
-const QwtPlot *QwtPlotPicker::plot() const
-{
-    const QWidget *w = canvas();
+const QwtPlot* QwtPlotPicker::plot() const
+{
+    const QWidget* w = canvas();
     if ( w )
         w = w->parentWidget();
 
-    return qobject_cast<const QwtPlot *>( w );
-}
-
-/*!
-  \return Normalized bounding rectangle of the axes
-  \sa QwtPlot::autoReplot(), QwtPlot::replot().
-*/
+    return qobject_cast< const QwtPlot* >( w );
+}
+
+/*!
+   \return Normalized bounding rectangle of the axes
+   \sa QwtPlot::autoReplot(), QwtPlot::replot().
+ */
 QRectF QwtPlotPicker::scaleRect() const
 {
@@ -143,6 +153,6 @@
     if ( plot() )
     {
-        const QwtScaleDiv &xs = plot()->axisScaleDiv( xAxis() );
-        const QwtScaleDiv &ys = plot()->axisScaleDiv( yAxis() );
+        const QwtScaleDiv& xs = plot()->axisScaleDiv( xAxis() );
+        const QwtScaleDiv& ys = plot()->axisScaleDiv( yAxis() );
 
         rect = QRectF( xs.lowerBound(), ys.lowerBound(),
@@ -155,41 +165,41 @@
 
 /*!
-  Set the x and y axes of the picker
-
-  \param xAxis X axis
-  \param yAxis Y axis
-*/
-void QwtPlotPicker::setAxis( int xAxis, int yAxis )
-{
-    const QwtPlot *plt = plot();
+   Set the x and y axes of the picker
+
+   \param xAxisId X axis
+   \param yAxisId Y axis
+ */
+void QwtPlotPicker::setAxes( QwtAxisId xAxisId, QwtAxisId yAxisId )
+{
+    const QwtPlot* plt = plot();
     if ( !plt )
         return;
 
-    if ( xAxis != d_xAxis || yAxis != d_yAxis )
-    {
-        d_xAxis = xAxis;
-        d_yAxis = yAxis;
+    if ( xAxisId != m_data->xAxisId || yAxisId != m_data->yAxisId )
+    {
+        m_data->xAxisId = xAxisId;
+        m_data->yAxisId = yAxisId;
     }
 }
 
 //! Return x axis
-int QwtPlotPicker::xAxis() const
-{
-    return d_xAxis;
+QwtAxisId QwtPlotPicker::xAxis() const
+{
+    return m_data->xAxisId;
 }
 
 //! Return y axis
-int QwtPlotPicker::yAxis() const
-{
-    return d_yAxis;
-}
-
-/*!
-  Translate a pixel position into a position string
-
-  \param pos Position in pixel coordinates
-  \return Position string
-*/
-QwtText QwtPlotPicker::trackerText( const QPoint &pos ) const
+QwtAxisId QwtPlotPicker::yAxis() const
+{
+    return m_data->yAxisId;
+}
+
+/*!
+   Translate a pixel position into a position string
+
+   \param pos Position in pixel coordinates
+   \return Position string
+ */
+QwtText QwtPlotPicker::trackerText( const QPoint& pos ) const
 {
     if ( plot() == NULL )
@@ -200,16 +210,16 @@
 
 /*!
-  \brief Translate a position into a position string
-
-  In case of HLineRubberBand the label is the value of the
-  y position, in case of VLineRubberBand the value of the x position.
-  Otherwise the label contains x and y position separated by a ',' .
-
-  The format for the double to string conversion is "%.4f".
-
-  \param pos Position
-  \return Position string
-*/
-QwtText QwtPlotPicker::trackerTextF( const QPointF &pos ) const
+   \brief Translate a position into a position string
+
+   In case of HLineRubberBand the label is the value of the
+   y position, in case of VLineRubberBand the value of the x position.
+   Otherwise the label contains x and y position separated by a ',' .
+
+   The format for the double to string conversion is "%.4f".
+
+   \param pos Position
+   \return Position string
+ */
+QwtText QwtPlotPicker::trackerTextF( const QPointF& pos ) const
 {
     QString text;
@@ -218,11 +228,12 @@
     {
         case HLineRubberBand:
-            text.sprintf( "%.4f", pos.y() );
+            text = QString::number( pos.y(), 'f', 4 );
             break;
         case VLineRubberBand:
-            text.sprintf( "%.4f", pos.x() );
+            text = QString::number( pos.x(), 'f', 4 );
             break;
         default:
-            text.sprintf( "%.4f, %.4f", pos.x(), pos.y() );
+            text = QString::number( pos.x(), 'f', 4 )
+                + ", " + QString::number( pos.y(), 'f', 4 );
     }
     return QwtText( text );
@@ -230,13 +241,13 @@
 
 /*!
-  Append a point to the selection and update rubber band and tracker.
-
-  \param pos Additional point
-  \sa isActive, begin(), end(), move(), appended()
-
-  \note The appended(const QPoint &), appended(const QDoublePoint &)
+   Append a point to the selection and update rubber band and tracker.
+
+   \param pos Additional point
+   \sa isActive, begin(), end(), move(), appended()
+
+   \note The appended(const QPoint &), appended(const QDoublePoint &)
         signals are emitted.
-*/
-void QwtPlotPicker::append( const QPoint &pos )
+ */
+void QwtPlotPicker::append( const QPoint& pos )
 {
     QwtPicker::append( pos );
@@ -245,13 +256,13 @@
 
 /*!
-  Move the last point of the selection
-
-  \param pos New position
-  \sa isActive, begin(), end(), append()
-
-  \note The moved(const QPoint &), moved(const QDoublePoint &)
+   Move the last point of the selection
+
+   \param pos New position
+   \sa isActive, begin(), end(), append()
+
+   \note The moved(const QPoint &), moved(const QDoublePoint &)
         signals are emitted.
-*/
-void QwtPlotPicker::move( const QPoint &pos )
+ */
+void QwtPlotPicker::move( const QPoint& pos )
 {
     QwtPicker::move( pos );
@@ -260,10 +271,10 @@
 
 /*!
-  Close a selection setting the state to inactive.
-
-  \param ok If true, complete the selection and emit selected signals
+   Close a selection setting the state to inactive.
+
+   \param ok If true, complete the selection and emit selected signals
             otherwise discard the selection.
-  \return True if the selection has been accepted, false otherwise
-*/
+   \return True if the selection has been accepted, false otherwise
+ */
 
 bool QwtPlotPicker::end( bool ok )
@@ -273,5 +284,5 @@
         return false;
 
-    QwtPlot *plot = QwtPlotPicker::plot();
+    QwtPlot* plot = QwtPlotPicker::plot();
     if ( !plot )
         return false;
@@ -309,5 +320,5 @@
         case QwtPickerMachine::PolygonSelection:
         {
-            QVector<QPointF> dpa( points.count() );
+            QVector< QPointF > dpa( points.count() );
             for ( int i = 0; i < points.count(); i++ )
                 dpa[i] = invTransform( points[i] );
@@ -327,9 +338,9 @@
     \return Rectangle in plot coordinates
     \sa transform()
-*/
-QRectF QwtPlotPicker::invTransform( const QRect &rect ) const
-{
-    const QwtScaleMap xMap = plot()->canvasMap( d_xAxis );
-    const QwtScaleMap yMap = plot()->canvasMap( d_yAxis );
+ */
+QRectF QwtPlotPicker::invTransform( const QRect& rect ) const
+{
+    const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
+    const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
 
     return QwtScaleMap::invTransform( xMap, yMap, rect );
@@ -340,9 +351,9 @@
     \return Rectangle in pixel coordinates
     \sa invTransform()
-*/
-QRect QwtPlotPicker::transform( const QRectF &rect ) const
-{
-    const QwtScaleMap xMap = plot()->canvasMap( d_xAxis );
-    const QwtScaleMap yMap = plot()->canvasMap( d_yAxis );
+ */
+QRect QwtPlotPicker::transform( const QRectF& rect ) const
+{
+    const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
+    const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
 
     return QwtScaleMap::transform( xMap, yMap, rect ).toRect();
@@ -353,14 +364,14 @@
     \return Point in plot coordinates
     \sa transform()
-*/
-QPointF QwtPlotPicker::invTransform( const QPoint &pos ) const
-{
-    QwtScaleMap xMap = plot()->canvasMap( d_xAxis );
-    QwtScaleMap yMap = plot()->canvasMap( d_yAxis );
+ */
+QPointF QwtPlotPicker::invTransform( const QPoint& pos ) const
+{
+    const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
+    const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
 
     return QPointF(
         xMap.invTransform( pos.x() ),
         yMap.invTransform( pos.y() )
-    );
+        );
 }
 
@@ -369,13 +380,14 @@
     \return Point in pixel coordinates
     \sa invTransform()
-*/
-QPoint QwtPlotPicker::transform( const QPointF &pos ) const
-{
-    QwtScaleMap xMap = plot()->canvasMap( d_xAxis );
-    QwtScaleMap yMap = plot()->canvasMap( d_yAxis );
-
-    const QPointF p( xMap.transform( pos.x() ),
-        yMap.transform( pos.y() ) );
+ */
+QPoint QwtPlotPicker::transform( const QPointF& pos ) const
+{
+    const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
+    const QwtScaleMap yMap = plot()->canvasMap( yAxis() );
+
+    const QPointF p( xMap.transform( pos.x() ), yMap.transform( pos.y() ) );
 
     return p.toPoint();
 }
+
+#include "moc_qwt_plot_picker.cpp"
