Index: trunk/BNC/qwt/qwt.h
===================================================================
--- trunk/BNC/qwt/qwt.h	(revision 8125)
+++ trunk/BNC/qwt/qwt.h	(revision 8127)
@@ -18,5 +18,5 @@
 namespace Qwt
 {
-};
+}
 
 #endif
Index: trunk/BNC/qwt/qwt.pro
===================================================================
--- trunk/BNC/qwt/qwt.pro	(revision 8125)
+++ trunk/BNC/qwt/qwt.pro	(revision 8127)
@@ -7,136 +7,8 @@
 CONFIG -= debug
 CONFIG += release
-
-###DEFINES += QWT_NO_SVG
-QT += svg
+QWT_CONFIG = QwtPlot QwtWidgets QwtSvg
 
 OBJECTS_DIR = .obj
 MOC_DIR     = .moc
 
-HEADERS += \
-    qwt.h \
-    qwt_abstract_scale_draw.h \
-    qwt_interval_symbol.h \
-    qwt_clipper.h \
-    qwt_color_map.h \
-    qwt_compat.h \
-    qwt_column_symbol.h \
-    qwt_interval.h \
-    qwt_dyngrid_layout.h \
-    qwt_global.h \
-    qwt_math.h \
-    qwt_magnifier.h \
-    qwt_null_paintdevice.h \
-    qwt_painter.h \
-    qwt_panner.h \
-    qwt_picker.h \
-    qwt_picker_machine.h \
-    qwt_point_3d.h \
-    qwt_point_polar.h \
-    qwt_round_scale_draw.h \
-    qwt_scale_div.h \
-    qwt_scale_draw.h \
-    qwt_scale_engine.h \
-    qwt_scale_map.h \
-    qwt_spline.h \
-    qwt_symbol.h \
-    qwt_system_clock.h \
-    qwt_text_engine.h \
-    qwt_text_label.h \
-    qwt_text.h \
-    qwt_curve_fitter.h \
-    qwt_event_pattern.h \
-    qwt_legend.h \
-    qwt_legend_item.h \
-    qwt_legend_itemmanager.h \
-    qwt_plot.h \
-    qwt_plot_renderer.h \
-    qwt_plot_curve.h \
-    qwt_plot_dict.h \
-    qwt_plot_directpainter.h \
-    qwt_plot_grid.h \
-    qwt_plot_histogram.h \
-    qwt_plot_item.h \
-    qwt_plot_intervalcurve.h \
-    qwt_plot_layout.h \
-    qwt_plot_marker.h \
-    qwt_plot_rasteritem.h \
-    qwt_plot_spectrogram.h \
-    qwt_plot_spectrocurve.h \
-    qwt_plot_scaleitem.h \
-    qwt_plot_seriesitem.h \
-    qwt_plot_canvas.h \
-    qwt_plot_panner.h \
-    qwt_plot_picker.h \
-    qwt_plot_zoomer.h \
-    qwt_plot_magnifier.h \
-    qwt_plot_rescaler.h \
-    qwt_raster_data.h \
-    qwt_matrix_raster_data.h \
-    qwt_sampling_thread.h \
-    qwt_series_data.h \
-    qwt_scale_widget.h \
-    qwt_plot_svgitem.h
-
-SOURCES += \
-    qwt_abstract_scale_draw.cpp \
-    qwt_interval_symbol.cpp \
-    qwt_clipper.cpp \
-    qwt_color_map.cpp \
-    qwt_column_symbol.cpp \
-    qwt_interval.cpp \
-    qwt_dyngrid_layout.cpp \
-    qwt_math.cpp \
-    qwt_magnifier.cpp \
-    qwt_panner.cpp \
-    qwt_null_paintdevice.cpp \
-    qwt_painter.cpp \
-    qwt_picker.cpp \
-    qwt_round_scale_draw.cpp \
-    qwt_scale_div.cpp \
-    qwt_scale_draw.cpp \
-    qwt_scale_map.cpp \
-    qwt_spline.cpp \
-    qwt_text_engine.cpp \
-    qwt_text_label.cpp \
-    qwt_text.cpp \
-    qwt_event_pattern.cpp \
-    qwt_picker_machine.cpp \
-    qwt_point_3d.cpp \
-    qwt_point_polar.cpp \
-    qwt_scale_engine.cpp \
-    qwt_symbol.cpp \
-    qwt_system_clock.cpp \
-    qwt_curve_fitter.cpp \
-    qwt_legend.cpp \
-    qwt_legend_item.cpp \
-    qwt_plot.cpp \
-    qwt_plot_renderer.cpp \
-    qwt_plot_xml.cpp \
-    qwt_plot_axis.cpp \
-    qwt_plot_curve.cpp \
-    qwt_plot_dict.cpp \
-    qwt_plot_directpainter.cpp \
-    qwt_plot_grid.cpp \
-    qwt_plot_histogram.cpp \
-    qwt_plot_item.cpp \
-    qwt_plot_intervalcurve.cpp \
-    qwt_plot_spectrogram.cpp \
-    qwt_plot_spectrocurve.cpp \
-    qwt_plot_scaleitem.cpp \
-    qwt_plot_seriesitem.cpp \
-    qwt_plot_marker.cpp \
-    qwt_plot_layout.cpp \
-    qwt_plot_canvas.cpp \
-    qwt_plot_panner.cpp \
-    qwt_plot_rasteritem.cpp \
-    qwt_plot_picker.cpp \
-    qwt_plot_zoomer.cpp \
-    qwt_plot_magnifier.cpp \
-    qwt_plot_rescaler.cpp \
-    qwt_raster_data.cpp \
-    qwt_matrix_raster_data.cpp \
-    qwt_sampling_thread.cpp \
-    qwt_series_data.cpp \
-    qwt_scale_widget.cpp \
-    qwt_plot_svgitem.cpp
+include ( src.pri )
Index: trunk/BNC/qwt/qwt_abstract_legend.cpp
===================================================================
--- trunk/BNC/qwt/qwt_abstract_legend.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_legend.cpp	(revision 8127)
@@ -0,0 +1,38 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_abstract_legend.h"
+
+/*!
+  Constructor
+
+  \param parent Parent widget
+*/
+QwtAbstractLegend::QwtAbstractLegend( QWidget *parent ):
+    QFrame( parent )
+{
+}
+
+//! Destructor
+QwtAbstractLegend::~QwtAbstractLegend()
+{
+}
+
+/*!
+   Return the extent, that is needed for elements to scroll
+   the legend ( usually scrollbars ),
+
+   \param orientation Orientation
+   \return Extent of the corresponding scroll element
+*/
+int QwtAbstractLegend::scrollExtent( Qt::Orientation orientation ) const
+{
+    Q_UNUSED( orientation );
+    return 0;
+}
Index: trunk/BNC/qwt/qwt_abstract_legend.h
===================================================================
--- trunk/BNC/qwt/qwt_abstract_legend.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_legend.h	(revision 8127)
@@ -0,0 +1,71 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_ABSTRACT_LEGEND_H
+#define QWT_ABSTRACT_LEGEND_H
+
+#include "qwt_global.h"
+#include "qwt_legend_data.h"
+#include <qframe.h>
+#include <qlist.h>
+
+class QVariant;
+
+/*!
+  \brief Abstract base class for legend widgets
+
+  Legends, that need to be under control of the QwtPlot layout system
+  need to be derived from QwtAbstractLegend. 
+
+  \note Other type of legends can be implemented by connecting to
+        the QwtPlot::legendDataChanged() signal. But as these legends
+        are unknown to the plot layout system the layout code
+        ( on screen and for QwtPlotRenderer ) need to be organized
+        in application code.
+
+  \sa QwtLegend
+ */
+class QWT_EXPORT QwtAbstractLegend : public QFrame
+{
+    Q_OBJECT
+
+public:
+    explicit QwtAbstractLegend( QWidget *parent = NULL );
+    virtual ~QwtAbstractLegend();
+
+    /*!
+      Render the legend into a given rectangle.
+
+      \param painter Painter
+      \param rect Bounding rectangle
+      \param fillBackground When true, fill rect with the widget background 
+
+      \sa renderLegend() is used by QwtPlotRenderer
+    */
+    virtual void renderLegend( QPainter *painter, 
+        const QRectF &rect, bool fillBackground ) const = 0;
+
+    //! \return True, when no plot item is inserted
+    virtual bool isEmpty() const = 0;
+
+    virtual int scrollExtent( Qt::Orientation ) const;
+
+public Q_SLOTS:
+
+    /*!
+      \brief Update the entries for a plot item
+
+      \param itemInfo Info about an item
+      \param data List of legend entry attributes for the  item
+     */
+    virtual void updateLegend( const QVariant &itemInfo, 
+        const QList<QwtLegendData> &data ) = 0;
+};
+
+#endif 
Index: trunk/BNC/qwt/qwt_abstract_scale.cpp
===================================================================
--- trunk/BNC/qwt/qwt_abstract_scale.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_scale.cpp	(revision 8127)
@@ -0,0 +1,449 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_abstract_scale.h"
+#include "qwt_scale_engine.h"
+#include "qwt_scale_draw.h"
+#include "qwt_scale_div.h"
+#include "qwt_scale_map.h"
+#include "qwt_interval.h"
+
+class QwtAbstractScale::PrivateData
+{
+public:
+    PrivateData():
+        maxMajor( 5 ),
+        maxMinor( 3 ),
+        stepSize( 0.0 )
+    {
+        scaleEngine = new QwtLinearScaleEngine();
+        scaleDraw = new QwtScaleDraw();
+    }
+
+    ~PrivateData()
+    {
+        delete scaleEngine;
+        delete scaleDraw;
+    }
+
+    QwtScaleEngine *scaleEngine;
+    QwtAbstractScaleDraw *scaleDraw;
+
+    int maxMajor;
+    int maxMinor;
+    double stepSize;
+};
+
+/*!
+  Constructor
+
+  \param parent Parent widget
+
+  Creates a default QwtScaleDraw and a QwtLinearScaleEngine.
+  The initial scale boundaries are set to [ 0.0, 100.0 ]
+
+  The scaleStepSize() is initialized to 0.0, scaleMaxMajor() to 5
+  and scaleMaxMajor to 3.
+*/
+
+QwtAbstractScale::QwtAbstractScale( QWidget *parent ):
+    QWidget( parent )
+{
+    d_data = new PrivateData;
+    rescale( 0.0, 100.0, d_data->stepSize );
+}
+
+//! Destructor
+QwtAbstractScale::~QwtAbstractScale()
+{
+    delete d_data;
+}
+
+/*!
+  Set the lower bound of the scale
+
+  \param value Lower bound
+
+  \sa lowerBound(), setScale(), setUpperBound()
+  \note For inverted scales the lower bound 
+        is greater than the upper bound
+*/
+void QwtAbstractScale::setLowerBound( double value )
+{
+    setScale( value, upperBound() );
+}
+
+/*!
+  \return Lower bound of the scale
+  \sa setLowerBound(), setScale(), upperBound()
+*/
+double QwtAbstractScale::lowerBound() const
+{
+    return d_data->scaleDraw->scaleDiv().lowerBound();
+}
+
+/*!
+  Set the upper bound of the scale
+
+  \param value Upper bound
+
+  \sa upperBound(), setScale(), setLowerBound()
+  \note For inverted scales the lower bound 
+        is greater than the upper bound
+*/
+void QwtAbstractScale::setUpperBound( double value )
+{
+    setScale( lowerBound(), value );
+}
+
+/*!
+  \return Upper bound of the scale
+  \sa setUpperBound(), setScale(), lowerBound()
+*/
+double QwtAbstractScale::upperBound() const
+{
+    return d_data->scaleDraw->scaleDiv().upperBound();
+}
+
+/*!
+  \brief Specify a scale.
+
+  Define a scale by an interval 
+
+  The ticks are calculated using scaleMaxMinor(), 
+  scaleMaxMajor() and scaleStepSize().
+
+  \param lowerBound lower limit of the scale interval
+  \param upperBound upper limit of the scale interval
+
+  \note For inverted scales the lower bound 
+        is greater than the upper bound
+*/
+void QwtAbstractScale::setScale( double lowerBound, double upperBound )
+{
+    rescale( lowerBound, upperBound, d_data->stepSize );
+}
+
+/*!
+  \brief Specify a scale.
+
+  Define a scale by an interval
+
+  The ticks are calculated using scaleMaxMinor(), 
+  scaleMaxMajor() and scaleStepSize().
+
+  \param interval Interval
+*/
+void QwtAbstractScale::setScale( const QwtInterval &interval )
+{
+    setScale( interval.minValue(), interval.maxValue() );
+}
+
+/*!
+  \brief Specify a scale.
+
+  scaleMaxMinor(), scaleMaxMajor() and scaleStepSize() and have no effect.
+
+  \param scaleDiv Scale division
+  \sa setAutoScale()
+*/
+void QwtAbstractScale::setScale( const QwtScaleDiv &scaleDiv )
+{
+    if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
+    {
+#if 1
+        if ( d_data->scaleEngine )
+        {
+            d_data->scaleDraw->setTransformation(
+                d_data->scaleEngine->transformation() );
+        }
+#endif
+
+        d_data->scaleDraw->setScaleDiv( scaleDiv );
+
+        scaleChange();
+    }
+}
+
+/*!
+  \brief Set the maximum number of major tick intervals.
+
+  The scale's major ticks are calculated automatically such that
+  the number of major intervals does not exceed ticks.
+
+  The default value is 5.
+
+  \param ticks Maximal number of major ticks.
+
+  \sa scaleMaxMajor(), setScaleMaxMinor(),
+      setScaleStepSize(), QwtScaleEngine::divideInterval()
+*/
+void QwtAbstractScale::setScaleMaxMajor( int ticks )
+{
+    if ( ticks != d_data->maxMajor )
+    {
+        d_data->maxMajor = ticks;
+        updateScaleDraw();
+    }
+}
+
+/*!
+  \return Maximal number of major tick intervals
+  \sa setScaleMaxMajor(), scaleMaxMinor()
+*/
+int QwtAbstractScale::scaleMaxMajor() const
+{
+    return d_data->maxMajor;
+}
+
+/*!
+  \brief Set the maximum number of minor tick intervals
+
+  The scale's minor ticks are calculated automatically such that
+  the number of minor intervals does not exceed ticks.
+  The default value is 3.
+
+  \param ticks Maximal number of minor ticks.
+
+  \sa scaleMaxMajor(), setScaleMaxMinor(),
+      setScaleStepSize(), QwtScaleEngine::divideInterval()
+*/
+void QwtAbstractScale::setScaleMaxMinor( int ticks )
+{
+    if ( ticks != d_data->maxMinor )
+    {
+        d_data->maxMinor = ticks;
+        updateScaleDraw();
+    }
+}
+
+/*!
+  \return Maximal number of minor tick intervals
+  \sa setScaleMaxMinor(), scaleMaxMajor()
+*/
+int QwtAbstractScale::scaleMaxMinor() const
+{
+    return d_data->maxMinor;
+}
+
+/*!
+   \brief Set the step size used for calculating a scale division
+
+   The step size is hint for calculating the intervals for
+   the major ticks of the scale. A value of 0.0 is interpreted
+   as no hint.
+
+   \param stepSize Hint for the step size of the scale
+
+   \sa scaleStepSize(), QwtScaleEngine::divideScale()
+
+   \note Position and distance between the major ticks also
+         depends on scaleMaxMajor().
+*/
+void QwtAbstractScale::setScaleStepSize( double stepSize )
+{
+    if ( stepSize != d_data->stepSize )
+    {
+        d_data->stepSize = stepSize;
+        updateScaleDraw();
+    }
+}
+
+/*!
+  \return Hint for the step size of the scale
+  \sa setScaleStepSize(), QwtScaleEngine::divideScale()
+*/
+double QwtAbstractScale::scaleStepSize() const
+{
+    return d_data->stepSize;
+}
+
+/*!
+  \brief Set a scale draw
+
+  scaleDraw has to be created with new and will be deleted in
+  the destructor or the next call of setAbstractScaleDraw().
+
+  \sa abstractScaleDraw()
+*/
+void QwtAbstractScale::setAbstractScaleDraw( QwtAbstractScaleDraw *scaleDraw )
+{
+    if ( scaleDraw == NULL || scaleDraw == d_data->scaleDraw )
+        return;
+
+    if ( d_data->scaleDraw != NULL )
+        scaleDraw->setScaleDiv( d_data->scaleDraw->scaleDiv() );
+
+    delete d_data->scaleDraw;
+    d_data->scaleDraw = scaleDraw;
+}
+
+/*!
+    \return Scale draw
+    \sa setAbstractScaleDraw()
+*/
+QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw()
+{
+    return d_data->scaleDraw;
+}
+
+/*!
+    \return Scale draw
+    \sa setAbstractScaleDraw()
+*/
+const QwtAbstractScaleDraw *QwtAbstractScale::abstractScaleDraw() const
+{
+    return d_data->scaleDraw;
+}
+
+/*!
+  \brief Set a scale engine
+
+  The scale engine is responsible for calculating the scale division
+  and provides a transformation between scale and widget coordinates.
+
+  scaleEngine has to be created with new and will be deleted in
+  the destructor or the next call of setScaleEngine.
+*/
+void QwtAbstractScale::setScaleEngine( QwtScaleEngine *scaleEngine )
+{
+    if ( scaleEngine != NULL && scaleEngine != d_data->scaleEngine )
+    {
+        delete d_data->scaleEngine;
+        d_data->scaleEngine = scaleEngine;
+    }
+}
+
+/*!
+  \return Scale engine
+  \sa setScaleEngine()
+*/
+const QwtScaleEngine *QwtAbstractScale::scaleEngine() const
+{
+    return d_data->scaleEngine;
+}
+
+/*!
+  \return Scale engine
+  \sa setScaleEngine()
+*/
+QwtScaleEngine *QwtAbstractScale::scaleEngine()
+{
+    return d_data->scaleEngine;
+}
+
+/*!
+  \return Scale boundaries and positions of the ticks
+
+  The scale division might have been assigned explicitly
+  or calculated implicitly by rescale(). 
+ */
+const QwtScaleDiv &QwtAbstractScale::scaleDiv() const
+{
+    return d_data->scaleDraw->scaleDiv();
+}
+
+/*!
+  \return Map to translate between scale and widget coordinates
+ */
+const QwtScaleMap &QwtAbstractScale::scaleMap() const
+{
+    return d_data->scaleDraw->scaleMap();
+}
+
+/*!
+  Translate a scale value into a widget coordinate
+
+  \param value Scale value 
+  \return Corresponding widget coordinate for value
+  \sa scaleMap(), invTransform()
+ */
+int QwtAbstractScale::transform( double value ) const
+{
+    return qRound( d_data->scaleDraw->scaleMap().transform( value ) );
+}
+
+/*!
+  Translate a widget coordinate into a scale value
+
+  \param value Widget coordinate
+  \return Corresponding scale coordinate for value
+  \sa scaleMap(), transform()
+ */
+double QwtAbstractScale::invTransform( int value ) const
+{
+    return d_data->scaleDraw->scaleMap().invTransform( value );
+}
+
+/*!
+  \return True, when the scale is increasing in opposite direction
+          to the widget coordinates
+ */
+bool QwtAbstractScale::isInverted() const
+{
+    return d_data->scaleDraw->scaleMap().isInverting();
+}
+
+/*!
+  \return The boundary with the smaller value
+  \sa maximum(), lowerBound(), upperBound()
+ */
+double QwtAbstractScale::minimum() const
+{
+    return qMin( d_data->scaleDraw->scaleDiv().lowerBound(),
+        d_data->scaleDraw->scaleDiv().upperBound() );
+}
+
+/*!
+  \return The boundary with the larger value
+  \sa minimum(), lowerBound(), upperBound()
+ */
+double QwtAbstractScale::maximum() const
+{
+    return qMax( d_data->scaleDraw->scaleDiv().lowerBound(),
+        d_data->scaleDraw->scaleDiv().upperBound() );
+}
+
+//! Notify changed scale
+void QwtAbstractScale::scaleChange()
+{
+}
+
+/*!
+  Recalculate the scale division and update the scale.
+
+  \param lowerBound Lower limit of the scale interval
+  \param upperBound Upper limit of the scale interval
+  \param stepSize Major step size
+
+  \sa scaleChange()
+*/
+void QwtAbstractScale::rescale( 
+    double lowerBound, double upperBound, double stepSize )
+{
+    const QwtScaleDiv scaleDiv = d_data->scaleEngine->divideScale(
+        lowerBound, upperBound, d_data->maxMajor, d_data->maxMinor, stepSize );
+
+    if ( scaleDiv != d_data->scaleDraw->scaleDiv() )
+    {
+#if 1
+        d_data->scaleDraw->setTransformation(
+            d_data->scaleEngine->transformation() );
+#endif
+
+        d_data->scaleDraw->setScaleDiv( scaleDiv );
+        scaleChange();
+    }
+}
+
+void QwtAbstractScale::updateScaleDraw()
+{
+    rescale( d_data->scaleDraw->scaleDiv().lowerBound(),
+        d_data->scaleDraw->scaleDiv().upperBound(), d_data->stepSize );
+}
Index: trunk/BNC/qwt/qwt_abstract_scale.h
===================================================================
--- trunk/BNC/qwt/qwt_abstract_scale.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_scale.h	(revision 8127)
@@ -0,0 +1,105 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_ABSTRACT_SCALE_H
+#define QWT_ABSTRACT_SCALE_H
+
+#include "qwt_global.h"
+#include <qwidget.h>
+
+class QwtScaleEngine;
+class QwtAbstractScaleDraw;
+class QwtScaleDiv;
+class QwtScaleMap;
+class QwtInterval;
+
+/*!
+  \brief An abstract base class for widgets having a scale
+
+  The scale of an QwtAbstractScale is determined by a QwtScaleDiv
+  definition, that contains the boundaries and the ticks of the scale.
+  The scale is painted using a QwtScaleDraw object.
+
+  The scale division might be assigned explicitly - but usually
+  it is calculated from the boundaries using a QwtScaleEngine. 
+
+  The scale engine also decides the type of transformation of the scale 
+  ( linear, logarithmic ... ).
+*/
+
+class QWT_EXPORT QwtAbstractScale: public QWidget
+{
+    Q_OBJECT
+
+    Q_PROPERTY( double lowerBound READ lowerBound WRITE setLowerBound )
+    Q_PROPERTY( double upperBound READ upperBound WRITE setUpperBound )
+
+    Q_PROPERTY( int scaleMaxMajor READ scaleMaxMajor WRITE setScaleMaxMajor )
+    Q_PROPERTY( int scaleMaxMinor READ scaleMaxMinor WRITE setScaleMaxMinor )
+
+    Q_PROPERTY( double scaleStepSize READ scaleStepSize WRITE setScaleStepSize )
+
+public:
+    QwtAbstractScale( QWidget *parent = NULL );
+    virtual ~QwtAbstractScale();
+
+    void setScale( double lowerBound, double upperBound );
+    void setScale( const QwtInterval & );
+    void setScale( const QwtScaleDiv & );
+
+    const QwtScaleDiv& scaleDiv() const;
+
+    void setLowerBound( double value );
+    double lowerBound() const;
+
+    void setUpperBound( double value );
+    double upperBound() const;
+
+    void setScaleStepSize( double stepSize );
+    double scaleStepSize() const;
+
+    void setScaleMaxMajor( int ticks );
+    int scaleMaxMinor() const;
+
+    void setScaleMaxMinor( int ticks );
+    int scaleMaxMajor() const;
+
+    void setScaleEngine( QwtScaleEngine * );
+    const QwtScaleEngine *scaleEngine() const;
+    QwtScaleEngine *scaleEngine();
+
+    int transform( double ) const;
+    double invTransform( int ) const;
+
+    bool isInverted() const;
+
+    double minimum() const;
+    double maximum() const;
+
+    const QwtScaleMap &scaleMap() const;
+
+protected:
+    void rescale( double lowerBound, 
+        double upperBound, double stepSize );
+
+    void setAbstractScaleDraw( QwtAbstractScaleDraw * );
+
+    const QwtAbstractScaleDraw *abstractScaleDraw() const;
+    QwtAbstractScaleDraw *abstractScaleDraw();
+
+    virtual void scaleChange();
+
+private:
+    void updateScaleDraw();
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_abstract_scale_draw.cpp
===================================================================
--- trunk/BNC/qwt/qwt_abstract_scale_draw.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_abstract_scale_draw.cpp	(revision 8127)
@@ -38,5 +38,5 @@
 
     QwtScaleMap map;
-    QwtScaleDiv scldiv;
+    QwtScaleDiv scaleDiv;
 
     double spacing;
@@ -86,4 +86,7 @@
 /*!
   Check if a component is enabled
+
+  \param component Component type
+  \return true, when component is enabled
   \sa enableComponent()
 */
@@ -95,10 +98,10 @@
 /*!
   Change the scale division
-  \param sd New scale division
-*/
-void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv &sd )
-{
-    d_data->scldiv = sd;
-    d_data->map.setScaleInterval( sd.lowerBound(), sd.upperBound() );
+  \param scaleDiv New scale division
+*/
+void QwtAbstractScaleDraw::setScaleDiv( const QwtScaleDiv &scaleDiv )
+{
+    d_data->scaleDiv = scaleDiv;
+    d_data->map.setScaleInterval( scaleDiv.lowerBound(), scaleDiv.upperBound() );
     d_data->labelCache.clear();
 }
@@ -109,5 +112,5 @@
 */
 void QwtAbstractScaleDraw::setTransformation(
-    QwtScaleTransformation *transformation )
+    QwtTransform *transformation )
 {
     d_data->map.setTransformation( transformation );
@@ -129,5 +132,5 @@
 const QwtScaleDiv& QwtAbstractScaleDraw::scaleDiv() const
 {
-    return d_data->scldiv;
+    return d_data->scaleDiv;
 }
 
@@ -179,11 +182,11 @@
 
         const QList<double> &majorTicks =
-            d_data->scldiv.ticks( QwtScaleDiv::MajorTick );
+            d_data->scaleDiv.ticks( QwtScaleDiv::MajorTick );
 
         for ( int i = 0; i < majorTicks.count(); i++ )
         {
             const double v = majorTicks[i];
-            if ( d_data->scldiv.contains( v ) )
-                drawLabel( painter, majorTicks[i] );
+            if ( d_data->scaleDiv.contains( v ) )
+                drawLabel( painter, v );
         }
 
@@ -204,10 +207,14 @@
             tickType < QwtScaleDiv::NTickTypes; tickType++ )
         {
-            const QList<double> &ticks = d_data->scldiv.ticks( tickType );
+            const double tickLen = d_data->tickLength[tickType];
+            if ( tickLen <= 0.0 )
+                continue;
+
+            const QList<double> &ticks = d_data->scaleDiv.ticks( tickType );
             for ( int i = 0; i < ticks.count(); i++ )
             {
                 const double v = ticks[i];
-                if ( d_data->scldiv.contains( v ) )
-                    drawTick( painter, v, d_data->tickLength[tickType] );
+                if ( d_data->scaleDiv.contains( v ) )
+                    drawTick( painter, v, tickLen );
             }
         }
@@ -258,4 +265,5 @@
   The default spacing is 4 pixels.
 
+  \return Spacing
   \sa setSpacing()
 */
@@ -268,5 +276,5 @@
   \brief Set a minimum for the extent
 
-  The extent is calculated from the coomponents of the
+  The extent is calculated from the components of the
   scale draw. In situations, where the labels are
   changing and the layout depends on the extent (f.e scrolling
@@ -288,4 +296,5 @@
 /*!
   Get the minimum extent
+  \return Minimum extent
   \sa extent(), setMinimumExtent()
 */
@@ -323,6 +332,5 @@
 
 /*!
-    Return the length of the ticks
-
+    \return Length of the ticks
     \sa setTickLength(), maxTickLength()
 */
@@ -357,5 +365,5 @@
 
   The value is converted to a plain text using
-  QLocale::system().toString(value).
+  QLocale().toString(value).
   This method is often overloaded by applications to have individual
   labels.
@@ -401,5 +409,5 @@
 
 /*!
-   Invalidate the cache used by QwtAbstractScaleDraw::tickLabel
+   Invalidate the cache used by tickLabel()
 
    The cache is invalidated, when a new QwtScaleDiv is set. If
Index: trunk/BNC/qwt/qwt_abstract_scale_draw.h
===================================================================
--- trunk/BNC/qwt/qwt_abstract_scale_draw.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_abstract_scale_draw.h	(revision 8127)
@@ -18,5 +18,5 @@
 class QPainter;
 class QFont;
-class QwtScaleTransformation;
+class QwtTransform;
 class QwtScaleMap;
 
@@ -27,6 +27,5 @@
 
   After a scale division has been specified as a QwtScaleDiv object
-  using QwtAbstractScaleDraw::setScaleDiv(const QwtScaleDiv &s),
-  the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
+  using setScaleDiv(), the scale can be drawn with the draw() member.
 */
 class QWT_EXPORT QwtAbstractScaleDraw
@@ -59,5 +58,5 @@
     const QwtScaleDiv& scaleDiv() const;
 
-    void setTransformation( QwtScaleTransformation * );
+    void setTransformation( QwtTransform * );
     const QwtScaleMap &scaleMap() const;
     QwtScaleMap &scaleMap();
@@ -83,11 +82,14 @@
       Calculate the extent
 
-      The extent is the distcance from the baseline to the outermost
+      The extent is the distance from the baseline to the outermost
       pixel of the scale draw in opposite to its orientation.
       It is at least minimumExtent() pixels.
 
+      \param font Font used for drawing the tick labels
+      \return Number of pixels
+
       \sa setMinimumExtent(), minimumExtent()
     */
-    virtual double extent( const QFont & ) const = 0;
+    virtual double extent( const QFont &font ) const = 0;
 
     void setMinimumExtent( double );
@@ -100,5 +102,5 @@
        \param painter Painter
        \param value Value of the tick
-       \param len Lenght of the tick
+       \param len Length of the tick
 
        \sa drawBackbone(), drawLabel()
Index: trunk/BNC/qwt/qwt_abstract_slider.cpp
===================================================================
--- trunk/BNC/qwt/qwt_abstract_slider.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_slider.cpp	(revision 8127)
@@ -0,0 +1,822 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_abstract_slider.h"
+#include "qwt_abstract_scale_draw.h"
+#include "qwt_math.h"
+#include "qwt_scale_map.h"
+#include <qevent.h>
+
+#if QT_VERSION < 0x040601
+#define qFabs(x) ::fabs(x)
+#endif
+
+static double qwtAlignToScaleDiv( 
+    const QwtAbstractSlider *slider, double value )
+{
+    const QwtScaleDiv &sd = slider->scaleDiv();
+
+    const int tValue = slider->transform( value );
+
+    if ( tValue == slider->transform( sd.lowerBound() ) )
+        return sd.lowerBound();
+
+    if ( tValue == slider->transform( sd.lowerBound() ) )
+        return sd.upperBound();
+
+    for ( int i = 0; i < QwtScaleDiv::NTickTypes; i++ )
+    {
+        const QList<double> ticks = sd.ticks( i );
+        for ( int j = 0; j < ticks.size(); j++ )
+        {
+            if ( slider->transform( ticks[ j ] ) == tValue )
+                return ticks[ j ];
+        }
+    }
+
+    return value;
+}
+
+class QwtAbstractSlider::PrivateData
+{
+public:
+    PrivateData():
+        isScrolling( false ),
+        isTracking( true ),
+        pendingValueChanged( false ),
+        readOnly( false ),
+        totalSteps( 100 ),
+        singleSteps( 1 ),
+        pageSteps( 10 ),
+        stepAlignment( true ),
+        isValid( false ),
+        value( 0.0 ),
+        wrapping( false ),
+        invertedControls( false )
+    {
+    }
+
+    bool isScrolling;
+    bool isTracking;
+    bool pendingValueChanged;
+
+    bool readOnly;
+
+    uint totalSteps;
+    uint singleSteps;
+    uint pageSteps;
+    bool stepAlignment;
+
+    bool isValid;
+    double value;
+
+    bool wrapping;
+    bool invertedControls;
+};
+
+/*!
+  \brief Constructor
+
+  The scale is initialized to [0.0, 100.0], the
+  number of steps is set to 100 with 1 and 10 and single
+  an page step sizes. Step alignment is enabled.
+
+  The initial value is invalid.
+
+  \param parent Parent widget
+*/
+QwtAbstractSlider::QwtAbstractSlider( QWidget *parent ):
+    QwtAbstractScale( parent )
+{
+    d_data = new QwtAbstractSlider::PrivateData;
+
+    setScale( 0.0, 100.0 );
+    setFocusPolicy( Qt::StrongFocus );
+}
+
+//! Destructor
+QwtAbstractSlider::~QwtAbstractSlider()
+{
+    delete d_data;
+}
+
+/*! 
+  Set the value to be valid/invalid
+
+  \param on When true, the value is invalidated
+
+  \sa setValue()
+*/
+void QwtAbstractSlider::setValid( bool on )
+{
+    if ( on != d_data->isValid )
+    {
+        d_data->isValid = on;
+        sliderChange();
+
+        Q_EMIT valueChanged( d_data->value );
+    }   
+}   
+
+//! \return True, when the value is invalid
+bool QwtAbstractSlider::isValid() const
+{
+    return d_data->isValid;
+}   
+
+/*!
+  En/Disable read only mode
+
+  In read only mode the slider can't be controlled by mouse
+  or keyboard.
+
+  \param on Enables in case of true
+  \sa isReadOnly()
+
+  \warning The focus policy is set to Qt::StrongFocus or Qt::NoFocus
+*/
+void QwtAbstractSlider::setReadOnly( bool on )
+{
+    if ( d_data->readOnly != on )
+    {
+        d_data->readOnly = on;
+        setFocusPolicy( on ? Qt::StrongFocus : Qt::NoFocus );
+
+        update();
+    }
+}
+
+/*!
+  In read only mode the slider can't be controlled by mouse
+  or keyboard.
+
+  \return true if read only
+  \sa setReadOnly()
+*/
+bool QwtAbstractSlider::isReadOnly() const
+{
+    return d_data->readOnly;
+}
+
+/*!
+  \brief Enables or disables tracking.
+
+  If tracking is enabled, the slider emits the valueChanged() 
+  signal while the movable part of the slider is being dragged. 
+  If tracking is disabled, the slider emits the valueChanged() signal 
+  only when the user releases the slider.
+
+  Tracking is enabled by default.
+  \param on \c true (enable) or \c false (disable) tracking.
+
+  \sa isTracking(), sliderMoved()
+*/
+void QwtAbstractSlider::setTracking( bool on )
+{
+    d_data->isTracking = on;
+}
+
+/*!
+  \return True, when tracking has been enabled
+  \sa setTracking()
+*/
+bool QwtAbstractSlider::isTracking() const
+{
+    return d_data->isTracking;
+}
+
+/*!
+   Mouse press event handler
+   \param event Mouse event
+*/
+void QwtAbstractSlider::mousePressEvent( QMouseEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( !d_data->isValid || lowerBound() == upperBound() )
+        return;
+
+    d_data->isScrolling = isScrollPosition( event->pos() );
+
+    if ( d_data->isScrolling )
+    {
+        d_data->pendingValueChanged = false;
+
+        Q_EMIT sliderPressed();
+    }
+}
+
+/*!
+   Mouse Move Event handler
+   \param event Mouse event
+*/
+void QwtAbstractSlider::mouseMoveEvent( QMouseEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( d_data->isValid && d_data->isScrolling )
+    {
+        double value = scrolledTo( event->pos() );
+        if ( value != d_data->value )
+        {
+            value = boundedValue( value );
+
+            if ( d_data->stepAlignment )
+            {
+                value = alignedValue( value );
+            }
+            else
+            {
+                value = qwtAlignToScaleDiv( this, value );
+            }
+
+            if ( value != d_data->value )
+            {
+                d_data->value = value;
+
+                sliderChange();
+
+                Q_EMIT sliderMoved( d_data->value );
+
+                if ( d_data->isTracking )
+                    Q_EMIT valueChanged( d_data->value );
+                else
+                    d_data->pendingValueChanged = true;
+            }
+        }
+    }
+}
+
+/*!
+   Mouse Release Event handler
+   \param event Mouse event
+*/
+void QwtAbstractSlider::mouseReleaseEvent( QMouseEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( d_data->isScrolling && d_data->isValid )
+    {
+        d_data->isScrolling = false;
+
+        if ( d_data->pendingValueChanged )
+            Q_EMIT valueChanged( d_data->value );
+
+        Q_EMIT sliderReleased();
+    }
+}
+
+/*!
+   Wheel Event handler
+
+   In/decreases the value by s number of steps. The direction 
+   depends on the invertedControls() property.
+
+   When the control or shift modifier is pressed the wheel delta
+   ( divided by 120 ) is mapped to an increment according to
+   pageSteps(). Otherwise it is mapped to singleSteps().
+
+   \param event Wheel event
+*/
+void QwtAbstractSlider::wheelEvent( QWheelEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( !d_data->isValid || d_data->isScrolling )
+        return;
+
+    int numSteps = 0;
+
+    if ( ( event->modifiers() & Qt::ControlModifier) ||
+        ( event->modifiers() & Qt::ShiftModifier ) )
+    {
+        // one page regardless of delta
+        numSteps = d_data->pageSteps;
+        if ( event->delta() < 0 )
+            numSteps = -numSteps;
+    }
+    else
+    {
+        const int numTurns = ( event->delta() / 120 );
+        numSteps = numTurns * d_data->singleSteps;
+    }
+
+    if ( d_data->invertedControls )
+        numSteps = -numSteps;
+
+    const double value = incrementedValue( d_data->value, numSteps );
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        sliderChange();
+
+        Q_EMIT sliderMoved( d_data->value );
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+/*!
+  Handles key events
+
+  QwtAbstractSlider handles the following keys:
+
+  - Qt::Key_Left\n
+    Add/Subtract singleSteps() in direction to lowerBound();
+  - Qt::Key_Right\n
+    Add/Subtract singleSteps() in direction to upperBound();
+  - Qt::Key_Down\n
+    Subtract singleSteps(), when invertedControls() is false
+  - Qt::Key_Up\n
+    Add singleSteps(), when invertedControls() is false
+  - Qt::Key_PageDown\n
+    Subtract pageSteps(), when invertedControls() is false
+  - Qt::Key_PageUp\n
+    Add pageSteps(), when invertedControls() is false
+  - Qt::Key_Home\n
+    Set the value to the minimum()
+  - Qt::Key_End\n
+    Set the value to the maximum()
+
+  \param event Key event
+  \sa isReadOnly()
+*/
+void QwtAbstractSlider::keyPressEvent( QKeyEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( !d_data->isValid || d_data->isScrolling )
+        return;
+
+    int numSteps = 0;
+    double value = d_data->value;
+
+    switch ( event->key() )
+    {
+        case Qt::Key_Left:
+        {
+            numSteps = -static_cast<int>( d_data->singleSteps );
+            if ( isInverted() )
+                numSteps = -numSteps;
+
+            break;
+        }
+        case Qt::Key_Right:
+        {
+            numSteps = d_data->singleSteps;
+            if ( isInverted() )
+                numSteps = -numSteps;
+
+            break;
+        }
+        case Qt::Key_Down:
+        {
+            numSteps = -static_cast<int>( d_data->singleSteps );
+            if ( d_data->invertedControls )
+                numSteps = -numSteps;
+            break;
+        }
+        case Qt::Key_Up:
+        {
+            numSteps = d_data->singleSteps;
+            if ( d_data->invertedControls )
+                numSteps = -numSteps;
+
+            break;
+        }
+        case Qt::Key_PageUp:
+        {
+            numSteps = d_data->pageSteps;
+            if ( d_data->invertedControls )
+                numSteps = -numSteps;
+            break;
+        }
+        case Qt::Key_PageDown:
+        {
+            numSteps = -static_cast<int>( d_data->pageSteps );
+            if ( d_data->invertedControls )
+                numSteps = -numSteps;
+            break;
+        }
+        case Qt::Key_Home:
+        {
+            value = minimum();
+            break;
+        }
+        case Qt::Key_End:
+        {
+            value = maximum();
+            break;
+        }
+        default:;
+        {
+            event->ignore();
+        }
+    }
+
+    if ( numSteps != 0 )
+    {
+        value = incrementedValue( d_data->value, numSteps );
+    }
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        sliderChange();
+
+        Q_EMIT sliderMoved( d_data->value );
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+/*!
+  \brief Set the number of steps
+
+  The range of the slider is divided into a number of steps from
+  which the value increments according to user inputs depend. 
+
+  The default setting is 100.
+
+  \param stepCount Number of steps
+
+  \sa totalSteps(), setSingleSteps(), setPageSteps()
+ */
+void QwtAbstractSlider::setTotalSteps( uint stepCount )
+{
+    d_data->totalSteps = stepCount;
+}
+
+/*!
+  \return Number of steps
+  \sa setTotalSteps(), singleSteps(), pageSteps()
+ */
+uint QwtAbstractSlider::totalSteps() const
+{
+    return d_data->totalSteps;
+}
+
+/*!
+  \brief Set the number of steps for a single increment
+
+  The range of the slider is divided into a number of steps from
+  which the value increments according to user inputs depend. 
+
+  \param stepCount Number of steps
+
+  \sa singleSteps(), setTotalSteps(), setPageSteps()
+ */
+
+void QwtAbstractSlider::setSingleSteps( uint stepCount )
+{
+    d_data->singleSteps = stepCount;
+}   
+
+/*!
+  \return Number of steps
+  \sa setSingleSteps(), totalSteps(), pageSteps()
+ */
+uint QwtAbstractSlider::singleSteps() const
+{
+    return d_data->singleSteps;
+}   
+
+/*! 
+  \brief Set the number of steps for a page increment
+    
+  The range of the slider is divided into a number of steps from
+  which the value increments according to user inputs depend. 
+
+  \param stepCount Number of steps
+
+  \sa pageSteps(), setTotalSteps(), setSingleSteps()
+ */
+
+void QwtAbstractSlider::setPageSteps( uint stepCount )
+{
+    d_data->pageSteps = stepCount;
+}
+
+/*!
+  \return Number of steps
+  \sa setPageSteps(), totalSteps(), singleSteps()
+ */
+uint QwtAbstractSlider::pageSteps() const
+{
+    return d_data->pageSteps;
+}
+
+/*!
+  \brief Enable step alignment
+
+  When step alignment is enabled values resulting from slider
+  movements are aligned to the step size.
+
+  \param on Enable step alignment when true
+  \sa stepAlignment()
+*/
+void QwtAbstractSlider::setStepAlignment( bool on )
+{   
+    if ( on != d_data->stepAlignment )
+    {
+        d_data->stepAlignment = on;
+    }
+}   
+    
+/*!
+  \return True, when step alignment is enabled
+  \sa setStepAlignment()
+ */
+bool QwtAbstractSlider::stepAlignment() const
+{
+    return d_data->stepAlignment;
+}
+
+/*!
+  Set the slider to the specified value
+
+  \param value New value
+  \sa setValid(), sliderChange(), valueChanged()
+*/
+void QwtAbstractSlider::setValue( double value )
+{
+    value = qBound( minimum(), value, maximum() );
+
+    const bool changed = ( d_data->value != value ) || !d_data->isValid;
+
+    d_data->value = value;
+    d_data->isValid = true;
+
+    if ( changed )
+    {
+        sliderChange();
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+//! Returns the current value.
+double QwtAbstractSlider::value() const
+{
+    return d_data->value;
+}
+
+/*!
+  If wrapping is true stepping up from upperBound() value will 
+  take you to the minimum() value and vice versa. 
+
+  \param on En/Disable wrapping
+  \sa wrapping()
+*/
+void QwtAbstractSlider::setWrapping( bool on )
+{
+    d_data->wrapping = on;
+}   
+
+/*!
+  \return True, when wrapping is set
+  \sa setWrapping()
+ */ 
+bool QwtAbstractSlider::wrapping() const
+{
+    return d_data->wrapping;
+}
+
+/*!
+  Invert wheel and key events
+
+  Usually scrolling the mouse wheel "up" and using keys like page 
+  up will increase the slider's value towards its maximum. 
+  When invertedControls() is enabled the value is scrolled
+  towards its minimum.
+
+  Inverting the controls might be f.e. useful for a vertical slider
+  with an inverted scale ( decreasing from top to bottom ).
+
+  \param on Invert controls, when true
+
+  \sa invertedControls(), keyEvent(), wheelEvent()
+ */
+void QwtAbstractSlider::setInvertedControls( bool on )
+{
+    d_data->invertedControls = on;
+}
+
+/*!
+ \return True, when the controls are inverted
+ \sa setInvertedControls()
+ */
+bool QwtAbstractSlider::invertedControls() const
+{
+    return d_data->invertedControls;
+}
+
+/*!
+  Increment the slider
+
+  The step size depends on the number of totalSteps()
+
+  \param stepCount Number of steps
+  \sa setTotalSteps(), incrementedValue()
+ */
+void QwtAbstractSlider::incrementValue( int stepCount )
+{
+    const double value = incrementedValue( 
+        d_data->value, stepCount );
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        sliderChange();
+    }
+}
+
+/*!
+  Increment a value 
+
+  \param value Value 
+  \param stepCount Number of steps
+
+  \return Incremented value
+ */
+double QwtAbstractSlider::incrementedValue( 
+    double value, int stepCount ) const
+{
+    if ( d_data->totalSteps == 0 )
+        return value;
+
+    const QwtTransform *transformation =
+        scaleMap().transformation();
+
+    if ( transformation == NULL )
+    {
+        const double range = maximum() - minimum();
+        value += stepCount * range / d_data->totalSteps;
+    }
+    else
+    {
+        QwtScaleMap map = scaleMap();
+        map.setPaintInterval( 0, d_data->totalSteps );
+
+        // we need equidant steps according to
+        // paint device coordinates
+        const double range = transformation->transform( maximum() ) 
+            - transformation->transform( minimum() );
+
+        const double stepSize = range / d_data->totalSteps;
+
+        double v = transformation->transform( value );
+
+        v = qRound( v / stepSize ) * stepSize; 
+        v += stepCount * range / d_data->totalSteps;
+
+        value = transformation->invTransform( v );
+    }
+
+    value = boundedValue( value );
+
+    if ( d_data->stepAlignment )
+        value = alignedValue( value );
+
+    return value;
+}
+
+double QwtAbstractSlider::boundedValue( double value ) const
+{
+    const double vmin = minimum();
+    const double vmax = maximum();
+
+    if ( d_data->wrapping && vmin != vmax )
+    {
+        const int fullCircle = 360 * 16;
+
+        const double pd = scaleMap().pDist();
+        if ( int( pd / fullCircle ) * fullCircle == pd )
+        {
+            // full circle scales: min and max are the same
+            const double range = vmax - vmin;
+
+            if ( value < vmin )
+            {
+                value += ::ceil( ( vmin - value ) / range ) * range;
+            }
+            else if ( value > vmax )
+            {
+                value -= ::ceil( ( value - vmax ) / range ) * range;
+            }
+        }
+        else
+        {
+            if ( value < vmin )
+                value = vmax;
+            else if ( value > vmax )
+                value = vmin;
+        }
+    }
+    else
+    {
+        value = qBound( vmin, value, vmax );
+    }
+
+    return value;
+}
+
+double QwtAbstractSlider::alignedValue( double value ) const
+{
+    if ( d_data->totalSteps == 0 )
+        return value;
+
+    double stepSize;
+
+    if ( scaleMap().transformation() == NULL )
+    {
+        stepSize = ( maximum() - minimum() ) / d_data->totalSteps;
+        if ( stepSize > 0.0 )
+        {
+            value = lowerBound() + 
+                qRound( ( value - lowerBound() ) / stepSize ) * stepSize;
+        }
+    }
+    else
+    {
+        stepSize = ( scaleMap().p2() - scaleMap().p1() ) / d_data->totalSteps;
+
+        if ( stepSize > 0.0 )
+        {
+            double v = scaleMap().transform( value );
+
+            v = scaleMap().p1() +
+                qRound( ( v - scaleMap().p1() ) / stepSize ) * stepSize;
+
+            value = scaleMap().invTransform( v );
+        }
+    }
+
+    if ( qAbs( stepSize ) > 1e-12 )
+    {
+        if ( qFuzzyCompare( value + 1.0, 1.0 ) )
+        {
+            // correct rounding error if value = 0
+            value = 0.0;
+        }
+        else
+        {
+            // correct rounding error at the border
+            if ( qFuzzyCompare( value, upperBound() ) )
+                value = upperBound();
+            else if ( qFuzzyCompare( value, lowerBound() ) )
+                value = lowerBound();
+        }
+    }
+
+    return value;
+}
+
+/*!
+  Update the slider according to modifications of the scale
+ */
+void QwtAbstractSlider::scaleChange()
+{
+    const double value = qBound( minimum(), d_data->value, maximum() );
+
+    const bool changed = ( value != d_data->value );
+    if ( changed )
+    {
+        d_data->value = value;
+    }
+
+    if ( d_data->isValid || changed )
+        Q_EMIT valueChanged( d_data->value );
+
+    updateGeometry();
+    update();
+}
+
+//! Calling update()
+void QwtAbstractSlider::sliderChange()
+{
+    update();
+}
Index: trunk/BNC/qwt/qwt_abstract_slider.h
===================================================================
--- trunk/BNC/qwt/qwt_abstract_slider.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_abstract_slider.h	(revision 8127)
@@ -0,0 +1,167 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_ABSTRACT_SLIDER_H
+#define QWT_ABSTRACT_SLIDER_H
+
+#include "qwt_global.h"
+#include "qwt_abstract_scale.h"
+
+/*!
+  \brief An abstract base class for slider widgets with a scale
+
+  A slider widget displays a value according to a scale.
+  The class is designed as a common super class for widgets like 
+  QwtKnob, QwtDial and QwtSlider.
+
+  When the slider is nor readOnly() its value can be modified 
+  by keyboard, mouse and wheel inputs. 
+
+  The range of the slider is divided into a number of steps from
+  which the value increments according to user inputs depend. 
+  Only for linear scales the number of steps correspond with
+  a fixed step size.
+*/
+
+class QWT_EXPORT QwtAbstractSlider: public QwtAbstractScale
+{
+    Q_OBJECT
+
+    Q_PROPERTY( double value READ value WRITE setValue )
+
+    Q_PROPERTY( uint totalSteps READ totalSteps WRITE setTotalSteps )
+    Q_PROPERTY( uint singleSteps READ singleSteps WRITE setSingleSteps )
+    Q_PROPERTY( uint pageSteps READ pageSteps WRITE setPageSteps )
+    Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )
+
+    Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
+    Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
+    Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
+
+    Q_PROPERTY( bool invertedControls READ invertedControls WRITE setInvertedControls )
+
+public:
+    explicit QwtAbstractSlider( QWidget *parent = NULL );
+    virtual ~QwtAbstractSlider();
+
+    void setValid( bool );
+    bool isValid() const;
+
+    double value() const;
+
+    void setWrapping( bool );
+    bool wrapping() const;
+
+    void setTotalSteps( uint );
+    uint totalSteps() const;
+
+    void setSingleSteps( uint );
+    uint singleSteps() const;
+
+    void setPageSteps( uint );
+    uint pageSteps() const;
+
+    void setStepAlignment( bool ); 
+    bool stepAlignment() const;
+
+    void setTracking( bool );
+    bool isTracking() const;
+
+    void setReadOnly( bool );
+    bool isReadOnly() const;
+
+    void setInvertedControls( bool );
+    bool invertedControls() const;
+
+public Q_SLOTS:
+    void setValue( double val );
+
+Q_SIGNALS:
+
+    /*!
+      \brief Notify a change of value.
+
+      When tracking is enabled (default setting), 
+      this signal will be emitted every time the value changes. 
+
+      \param value New value
+
+      \sa setTracking(), sliderMoved()
+    */
+    void valueChanged( double value );
+
+    /*!
+      This signal is emitted when the user presses the
+      movable part of the slider.
+    */
+    void sliderPressed();
+
+    /*!
+      This signal is emitted when the user releases the
+      movable part of the slider.
+    */
+    void sliderReleased();
+
+    /*!
+      This signal is emitted when the user moves the
+      slider with the mouse.
+
+      \param value New value
+
+      \sa valueChanged()
+    */
+    void sliderMoved( double value );
+
+protected:
+    virtual void mousePressEvent( QMouseEvent * );
+    virtual void mouseReleaseEvent( QMouseEvent * );
+    virtual void mouseMoveEvent( QMouseEvent * );
+    virtual void keyPressEvent( QKeyEvent * );
+    virtual void wheelEvent( QWheelEvent * );
+
+    /*!
+      \brief Determine what to do when the user presses a mouse button.
+
+      \param pos Mouse position
+
+      \retval True, when pos is a valid scroll position
+      \sa scrolledTo()
+    */
+    virtual bool isScrollPosition( const QPoint &pos ) const = 0;
+
+    /*!
+      \brief Determine the value for a new position of the
+             movable part of the slider
+
+      \param pos Mouse position
+
+      \return Value for the mouse position
+      \sa isScrollPosition()
+    */
+    virtual double scrolledTo( const QPoint &pos ) const = 0;
+
+    void incrementValue( int numSteps );
+
+    virtual void scaleChange();
+
+protected:
+    virtual void sliderChange();
+
+    double incrementedValue( 
+        double value, int stepCount ) const;
+
+private:
+    double alignedValue( double ) const;
+    double boundedValue( double ) const;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_analog_clock.cpp
===================================================================
--- trunk/BNC/qwt/qwt_analog_clock.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_analog_clock.cpp	(revision 8127)
@@ -0,0 +1,244 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_analog_clock.h"
+#include "qwt_round_scale_draw.h"
+#include <qmath.h>
+#include <qlocale.h>
+
+class QwtAnalogClockScaleDraw: public QwtRoundScaleDraw
+{
+public:
+    QwtAnalogClockScaleDraw()
+    {
+        setSpacing( 8 );
+
+        enableComponent( QwtAbstractScaleDraw::Backbone, false );
+
+        setTickLength( QwtScaleDiv::MinorTick, 2 );
+        setTickLength( QwtScaleDiv::MediumTick, 4 );
+        setTickLength( QwtScaleDiv::MajorTick, 8 );
+
+        setPenWidth( 1 );
+    }
+
+    virtual QwtText label( double value ) const
+    {
+        if ( qFuzzyCompare( value + 1.0, 1.0 ) )
+            value = 60.0 * 60.0 * 12.0;
+
+        return QLocale().toString( qRound( value / ( 60.0 * 60.0 ) ) );
+    }
+};
+
+/*!
+  Constructor
+  \param parent Parent widget
+*/
+QwtAnalogClock::QwtAnalogClock( QWidget *parent ):
+    QwtDial( parent )
+{
+    setWrapping( true );
+    setReadOnly( true );
+
+    setOrigin( 270.0 );
+    setScaleDraw( new QwtAnalogClockScaleDraw() );
+
+    setTotalSteps( 60 );
+
+    const int secondsPerHour = 60.0 * 60.0; 
+
+    QList<double> majorTicks;
+    QList<double> minorTicks;
+
+    for ( int i = 0; i < 12; i++ )
+    {
+        majorTicks += i * secondsPerHour;
+
+        for ( int j = 1; j < 5; j++ )
+            minorTicks += i * secondsPerHour + j * secondsPerHour / 5.0;
+    }
+
+    QwtScaleDiv scaleDiv;
+    scaleDiv.setInterval( 0.0, 12.0 * secondsPerHour );
+    scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
+    setScale( scaleDiv );
+
+    QColor knobColor = palette().color( QPalette::Active, QPalette::Text );
+    knobColor = knobColor.dark( 120 );
+
+    QColor handColor;
+    int width;
+
+    for ( int i = 0; i < NHands; i++ )
+    {
+        if ( i == SecondHand )
+        {
+            width = 2;
+            handColor = knobColor.dark( 120 );
+        }
+        else
+        {
+            width = 8;
+            handColor = knobColor;
+        }
+
+        QwtDialSimpleNeedle *hand = new QwtDialSimpleNeedle(
+            QwtDialSimpleNeedle::Arrow, true, handColor, knobColor );
+        hand->setWidth( width );
+
+        d_hand[i] = NULL;
+        setHand( static_cast<Hand>( i ), hand );
+    }
+}
+
+//! Destructor
+QwtAnalogClock::~QwtAnalogClock()
+{
+    for ( int i = 0; i < NHands; i++ )
+        delete d_hand[i];
+}
+
+/*!
+  Nop method, use setHand() instead
+  \sa setHand()
+*/
+void QwtAnalogClock::setNeedle( QwtDialNeedle * )
+{
+    // no op
+    return;
+}
+
+/*!
+   Set a clock hand
+   \param hand Specifies the type of hand
+   \param needle Hand
+   \sa hand()
+*/
+void QwtAnalogClock::setHand( Hand hand, QwtDialNeedle *needle )
+{
+    if ( hand >= 0 && hand < NHands )
+    {
+        delete d_hand[hand];
+        d_hand[hand] = needle;
+    }
+}
+
+/*!
+  \return Clock hand
+  \param hd Specifies the type of hand
+  \sa setHand()
+*/
+QwtDialNeedle *QwtAnalogClock::hand( Hand hd )
+{
+    if ( hd < 0 || hd >= NHands )
+        return NULL;
+
+    return d_hand[hd];
+}
+
+/*!
+  \return Clock hand
+  \param hd Specifies the type of hand
+  \sa setHand()
+*/
+const QwtDialNeedle *QwtAnalogClock::hand( Hand hd ) const
+{
+    return const_cast<QwtAnalogClock *>( this )->hand( hd );
+}
+
+/*!
+  \brief Set the current time
+*/
+void QwtAnalogClock::setCurrentTime()
+{
+    setTime( QTime::currentTime() );
+}
+
+/*!
+  Set a time
+  \param time Time to display
+*/
+void QwtAnalogClock::setTime( const QTime &time )
+{
+    if ( time.isValid() )
+    {
+        setValue( ( time.hour() % 12 ) * 60.0 * 60.0
+            + time.minute() * 60.0 + time.second() );
+    }
+    else
+        setValid( false );
+}
+
+/*!
+  \brief Draw the needle
+
+  A clock has no single needle but three hands instead. drawNeedle()
+  translates value() into directions for the hands and calls
+  drawHand().
+
+  \param painter Painter
+  \param center Center of the clock
+  \param radius Maximum length for the hands
+  \param dir Dummy, not used.
+  \param colorGroup ColorGroup
+
+  \sa drawHand()
+*/
+void QwtAnalogClock::drawNeedle( QPainter *painter, const QPointF &center,
+    double radius, double dir, QPalette::ColorGroup colorGroup ) const
+{
+    Q_UNUSED( dir );
+
+    if ( isValid() )
+    {
+        const double hours = value() / ( 60.0 * 60.0 );
+        const double minutes = 
+            ( value() - qFloor(hours) * 60.0 * 60.0 ) / 60.0;
+        const double seconds = value() - qFloor(hours) * 60.0 * 60.0
+            - qFloor(minutes) * 60.0;
+
+        double angle[NHands];
+        angle[HourHand] = 360.0 * hours / 12.0;
+        angle[MinuteHand] = 360.0 * minutes / 60.0;
+        angle[SecondHand] = 360.0 * seconds / 60.0;
+
+        for ( int hand = 0; hand < NHands; hand++ )
+        {
+            const double d = 360.0 - angle[hand] - origin();
+            drawHand( painter, static_cast<Hand>( hand ), 
+                center, radius, d, colorGroup );
+        }
+    }
+}
+
+/*!
+  Draw a clock hand
+
+  \param painter Painter
+  \param hd Specify the type of hand
+  \param center Center of the clock
+  \param radius Maximum length for the hands
+  \param direction Direction of the hand in degrees, counter clockwise
+  \param cg ColorGroup
+*/
+void QwtAnalogClock::drawHand( QPainter *painter, Hand hd,
+    const QPointF &center, double radius, double direction,
+    QPalette::ColorGroup cg ) const
+{
+    const QwtDialNeedle *needle = hand( hd );
+    if ( needle )
+    {
+        if ( hd == HourHand )
+            radius = qRound( 0.8 * radius );
+
+        needle->draw( painter, center, radius, direction, cg );
+    }
+}
Index: trunk/BNC/qwt/qwt_analog_clock.h
===================================================================
--- trunk/BNC/qwt/qwt_analog_clock.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_analog_clock.h	(revision 8127)
@@ -0,0 +1,93 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_ANALOG_CLOCK_H
+#define QWT_ANALOG_CLOCK_H
+
+#include "qwt_global.h"
+#include "qwt_dial.h"
+#include "qwt_dial_needle.h"
+#include <qdatetime.h>
+
+/*!
+  \brief An analog clock
+
+  \image html analogclock.png
+
+  \par Example
+  \code 
+  #include <qwt_analog_clock.h>
+
+  QwtAnalogClock *clock = new QwtAnalogClock(...);
+  clock->scaleDraw()->setPenWidth(3);
+  clock->setLineWidth(6);
+  clock->setFrameShadow(QwtDial::Sunken);
+  clock->setTime();
+
+  // update the clock every second
+  QTimer *timer = new QTimer(clock);
+  timer->connect(timer, SIGNAL(timeout()), clock, SLOT(setCurrentTime()));
+  timer->start(1000);
+
+  \endcode
+
+  \note The examples/dials example shows how to use QwtAnalogClock.
+*/
+
+class QWT_EXPORT QwtAnalogClock: public QwtDial
+{
+    Q_OBJECT
+
+public:
+    /*!
+        Hand type
+        \sa setHand(), hand()
+    */
+    enum Hand
+    {
+        //! Needle displaying the seconds
+        SecondHand,
+
+        //! Needle displaying the minutes
+        MinuteHand,
+
+        //! Needle displaying the hours
+        HourHand,
+
+        //! Number of needles
+        NHands
+    };
+
+    explicit QwtAnalogClock( QWidget* parent = NULL );
+    virtual ~QwtAnalogClock();
+
+    void setHand( Hand, QwtDialNeedle * );
+
+    const QwtDialNeedle *hand( Hand ) const;
+    QwtDialNeedle *hand( Hand );
+
+public Q_SLOTS:
+    void setCurrentTime();
+    void setTime( const QTime & );
+
+protected:
+    virtual void drawNeedle( QPainter *, const QPointF &,
+        double radius, double direction, QPalette::ColorGroup ) const;
+
+    virtual void drawHand( QPainter *, Hand, const QPointF &,
+        double radius, double direction, QPalette::ColorGroup ) const;
+
+private:
+    // use setHand instead
+    void setNeedle( QwtDialNeedle * );
+
+    QwtDialNeedle *d_hand[NHands];
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_arrow_button.cpp
===================================================================
--- trunk/BNC/qwt/qwt_arrow_button.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_arrow_button.cpp	(revision 8127)
@@ -0,0 +1,333 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_arrow_button.h"
+#include "qwt_math.h"
+#include <qpainter.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qevent.h>
+#include <qapplication.h>
+
+static const int MaxNum = 3;
+static const int Margin = 2;
+static const int Spacing = 1;
+
+class QwtArrowButton::PrivateData
+{
+public:
+    int num;
+    Qt::ArrowType arrowType;
+};
+
+static QStyleOptionButton styleOpt( const QwtArrowButton* btn )
+{
+    QStyleOptionButton option;
+    option.init( btn );
+    option.features = QStyleOptionButton::None;
+    if ( btn->isFlat() )
+        option.features |= QStyleOptionButton::Flat;
+    if ( btn->menu() )
+        option.features |= QStyleOptionButton::HasMenu;
+    if ( btn->autoDefault() || btn->isDefault() )
+        option.features |= QStyleOptionButton::AutoDefaultButton;
+    if ( btn->isDefault() )
+        option.features |= QStyleOptionButton::DefaultButton;
+    if ( btn->isDown() )
+        option.state |= QStyle::State_Sunken;
+    if ( !btn->isFlat() && !btn->isDown() )
+        option.state |= QStyle::State_Raised;
+
+    return option;
+}
+
+/*!
+  \param num Number of arrows
+  \param arrowType see Qt::ArrowType in the Qt docs.
+  \param parent Parent widget
+*/
+QwtArrowButton::QwtArrowButton( int num,
+        Qt::ArrowType arrowType, QWidget *parent ):
+    QPushButton( parent )
+{
+    d_data = new PrivateData;
+    d_data->num = qBound( 1, num, MaxNum );
+    d_data->arrowType = arrowType;
+
+    setAutoRepeat( true );
+    setAutoDefault( false );
+
+    switch ( d_data->arrowType )
+    {
+        case Qt::LeftArrow:
+        case Qt::RightArrow:
+            setSizePolicy( QSizePolicy::Expanding,
+                QSizePolicy::Fixed );
+            break;
+        default:
+            setSizePolicy( QSizePolicy::Fixed,
+                QSizePolicy::Expanding );
+    }
+}
+
+//! Destructor
+QwtArrowButton::~QwtArrowButton()
+{
+    delete d_data;
+    d_data = NULL;
+}
+
+/*!
+  \brief The direction of the arrows
+*/
+Qt::ArrowType QwtArrowButton::arrowType() const
+{
+    return d_data->arrowType;
+}
+
+/*!
+  \brief The number of arrows
+*/
+int QwtArrowButton::num() const
+{
+    return d_data->num;
+}
+
+/*!
+  \return the bounding rectangle for the label
+*/
+QRect QwtArrowButton::labelRect() const
+{
+    const int m = Margin;
+
+    QRect r = rect();
+    r.setRect( r.x() + m, r.y() + m,
+        r.width() - 2 * m, r.height() - 2 * m );
+
+    if ( isDown() )
+    {
+        QStyleOptionButton option = styleOpt( this );
+        const int ph = style()->pixelMetric(
+            QStyle::PM_ButtonShiftHorizontal, &option, this );
+        const int pv = style()->pixelMetric(
+            QStyle::PM_ButtonShiftVertical, &option, this );
+
+        r.translate( ph, pv );
+    }
+
+    return r;
+}
+
+/*!
+   Paint event handler
+   \param event Paint event
+*/
+void QwtArrowButton::paintEvent( QPaintEvent *event )
+{
+    QPushButton::paintEvent( event );
+    QPainter painter( this );
+    drawButtonLabel( &painter );
+}
+
+/*!
+  \brief Draw the button label
+
+  \param painter Painter
+  \sa The Qt Manual for QPushButton
+*/
+void QwtArrowButton::drawButtonLabel( QPainter *painter )
+{
+    const bool isVertical = d_data->arrowType == Qt::UpArrow ||
+        d_data->arrowType == Qt::DownArrow;
+
+    const QRect r = labelRect();
+    QSize boundingSize = labelRect().size();
+    if ( isVertical )
+        boundingSize.transpose();
+
+    const int w =
+        ( boundingSize.width() - ( MaxNum - 1 ) * Spacing ) / MaxNum;
+
+    QSize arrow = arrowSize( Qt::RightArrow,
+        QSize( w, boundingSize.height() ) );
+
+    if ( isVertical )
+        arrow.transpose();
+
+    QRect contentsSize; // aligned rect where to paint all arrows
+    if ( d_data->arrowType == Qt::LeftArrow || d_data->arrowType == Qt::RightArrow )
+    {
+        contentsSize.setWidth( d_data->num * arrow.width()
+            + ( d_data->num - 1 ) * Spacing );
+        contentsSize.setHeight( arrow.height() );
+    }
+    else
+    {
+        contentsSize.setWidth( arrow.width() );
+        contentsSize.setHeight( d_data->num * arrow.height()
+            + ( d_data->num - 1 ) * Spacing );
+    }
+
+    QRect arrowRect( contentsSize );
+    arrowRect.moveCenter( r.center() );
+    arrowRect.setSize( arrow );
+
+    painter->save();
+    for ( int i = 0; i < d_data->num; i++ )
+    {
+        drawArrow( painter, arrowRect, d_data->arrowType );
+
+        int dx = 0;
+        int dy = 0;
+
+        if ( isVertical )
+            dy = arrow.height() + Spacing;
+        else
+            dx = arrow.width() + Spacing;
+
+        arrowRect.translate( dx, dy );
+    }
+    painter->restore();
+
+    if ( hasFocus() )
+    {
+        QStyleOptionFocusRect option;
+        option.init( this );
+        option.backgroundColor = palette().color( QPalette::Window );
+
+        style()->drawPrimitive( QStyle::PE_FrameFocusRect,
+            &option, painter, this );
+    }
+}
+
+/*!
+    Draw an arrow int a bounding rectangle
+
+    \param painter Painter
+    \param r Rectangle where to paint the arrow
+    \param arrowType Arrow type
+*/
+void QwtArrowButton::drawArrow( QPainter *painter,
+    const QRect &r, Qt::ArrowType arrowType ) const
+{
+    QPolygon pa( 3 );
+
+    switch ( arrowType )
+    {
+        case Qt::UpArrow:
+            pa.setPoint( 0, r.bottomLeft() );
+            pa.setPoint( 1, r.bottomRight() );
+            pa.setPoint( 2, r.center().x(), r.top() );
+            break;
+        case Qt::DownArrow:
+            pa.setPoint( 0, r.topLeft() );
+            pa.setPoint( 1, r.topRight() );
+            pa.setPoint( 2, r.center().x(), r.bottom() );
+            break;
+        case Qt::RightArrow:
+            pa.setPoint( 0, r.topLeft() );
+            pa.setPoint( 1, r.bottomLeft() );
+            pa.setPoint( 2, r.right(), r.center().y() );
+            break;
+        case Qt::LeftArrow:
+            pa.setPoint( 0, r.topRight() );
+            pa.setPoint( 1, r.bottomRight() );
+            pa.setPoint( 2, r.left(), r.center().y() );
+            break;
+        default:
+            break;
+    }
+
+    painter->save();
+
+    painter->setRenderHint( QPainter::Antialiasing, true );
+    painter->setPen( Qt::NoPen );
+    painter->setBrush( palette().brush( QPalette::ButtonText ) );
+    painter->drawPolygon( pa );
+
+    painter->restore();
+}
+
+/*!
+  \return a size hint
+*/
+QSize QwtArrowButton::sizeHint() const
+{
+    const QSize hint = minimumSizeHint();
+    return hint.expandedTo( QApplication::globalStrut() );
+}
+
+/*!
+  \brief Return a minimum size hint
+*/
+QSize QwtArrowButton::minimumSizeHint() const
+{
+    const QSize asz = arrowSize( Qt::RightArrow, QSize() );
+
+    QSize sz(
+        2 * Margin + ( MaxNum - 1 ) * Spacing + MaxNum * asz.width(),
+        2 * Margin + asz.height()
+    );
+
+    if ( d_data->arrowType == Qt::UpArrow || d_data->arrowType == Qt::DownArrow )
+        sz.transpose();
+
+    QStyleOption styleOption;
+    styleOption.init( this );
+
+    sz = style()->sizeFromContents( QStyle::CT_PushButton,
+        &styleOption, sz, this );
+
+    return sz;
+}
+
+/*!
+   Calculate the size for a arrow that fits into a rectangle of a given size
+
+   \param arrowType Arrow type
+   \param boundingSize Bounding size
+   \return Size of the arrow
+*/
+QSize QwtArrowButton::arrowSize( Qt::ArrowType arrowType,
+    const QSize &boundingSize ) const
+{
+    QSize bs = boundingSize;
+    if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
+        bs.transpose();
+
+    const int MinLen = 2;
+    const QSize sz = bs.expandedTo(
+        QSize( MinLen, 2 * MinLen - 1 ) ); // minimum
+
+    int w = sz.width();
+    int h = 2 * w - 1;
+
+    if ( h > sz.height() )
+    {
+        h = sz.height();
+        w = ( h + 1 ) / 2;
+    }
+
+    QSize arrSize( w, h );
+    if ( arrowType == Qt::UpArrow || arrowType == Qt::DownArrow )
+        arrSize.transpose();
+
+    return arrSize;
+}
+
+/*!
+  \brief autoRepeat for the space keys
+*/
+void QwtArrowButton::keyPressEvent( QKeyEvent *event )
+{
+    if ( event->isAutoRepeat() && event->key() == Qt::Key_Space )
+        Q_EMIT clicked();
+
+    QPushButton::keyPressEvent( event );
+}
Index: trunk/BNC/qwt/qwt_arrow_button.h
===================================================================
--- trunk/BNC/qwt/qwt_arrow_button.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_arrow_button.h	(revision 8127)
@@ -0,0 +1,52 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_ARROW_BUTTON_H
+#define QWT_ARROW_BUTTON_H
+
+#include "qwt_global.h"
+#include <qpushbutton.h>
+
+/*!
+  \brief Arrow Button
+
+  A push button with one or more filled triangles on its front.
+  An Arrow button can have 1 to 3 arrows in a row, pointing
+  up, down, left or right.
+*/
+class QWT_EXPORT QwtArrowButton : public QPushButton
+{
+public:
+    explicit QwtArrowButton ( int num, Qt::ArrowType, QWidget *parent = NULL );
+    virtual ~QwtArrowButton();
+
+    Qt::ArrowType arrowType() const;
+    int num() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+protected:
+    virtual void paintEvent( QPaintEvent *event );
+
+    virtual void drawButtonLabel( QPainter *p );
+    virtual void drawArrow( QPainter *,
+        const QRect &, Qt::ArrowType ) const;
+    virtual QRect labelRect() const;
+    virtual QSize arrowSize( Qt::ArrowType,
+        const QSize &boundingSize ) const;
+
+    virtual void keyPressEvent( QKeyEvent * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_clipper.cpp
===================================================================
--- trunk/BNC/qwt/qwt_clipper.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_clipper.cpp	(revision 8127)
@@ -11,4 +11,6 @@
 #include "qwt_point_polar.h"
 #include <qrect.h>
+#include <string.h>
+#include <stdlib.h>
 
 #if QT_VERSION < 0x040601
@@ -44,5 +46,5 @@
     {
         double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() );
-        return Point( d_x1, ( Value ) ( p2.y() + ( d_x1 - p2.x() ) * dy ) );
+        return Point( d_x1, static_cast< Value >( p2.y() + ( d_x1 - p2.x() ) * dy ) );
     }
 private:
@@ -67,5 +69,5 @@
     {
         double dy = ( p1.y() - p2.y() ) / double( p1.x() - p2.x() );
-        return Point( d_x2, ( Value ) ( p2.y() + ( d_x2 - p2.x() ) * dy ) );
+        return Point( d_x2, static_cast<Value>( p2.y() + ( d_x2 - p2.x() ) * dy ) );
     }
 
@@ -91,5 +93,5 @@
     {
         double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() );
-        return Point( ( Value )( p2.x() + ( d_y1 - p2.y() ) * dx ), d_y1 );
+        return Point( static_cast<Value>( p2.x() + ( d_y1 - p2.y() ) * dx ), d_y1 );
     }
 
@@ -115,5 +117,5 @@
     {
         double dx = ( p1.x() - p2.x() ) / double( p1.y() - p2.y() );
-        return Point( ( Value )( p2.x() + ( d_y2 - p2.y() ) * dx ), d_y2 );
+        return Point( static_cast<Value>( p2.x() + ( d_y2 - p2.y() ) * dx ), d_y2 );
     }
 
@@ -138,5 +140,5 @@
     {
         if ( m_buffer )
-            qFree( m_buffer );
+            ::free( m_buffer );
     }
 
@@ -146,5 +148,5 @@
 
         m_size = numPoints;
-        qMemCopy( m_buffer, points, m_size * sizeof( Point ) );
+        ::memcpy( m_buffer, points, m_size * sizeof( Point ) );
     }
 
@@ -191,6 +193,6 @@
             m_capacity *= 2;
 
-        m_buffer = ( Point * ) qRealloc( 
-            m_buffer, m_capacity * sizeof( Point ) );
+        m_buffer = static_cast<Point *>( 
+            ::realloc( m_buffer, m_capacity * sizeof( Point ) ) );
     }
 
@@ -230,5 +232,5 @@
         Polygon p;
         p.resize( points1.size() );
-        qMemCopy( p.data(), points1.data(), points1.size() * sizeof( Point ) );
+        ::memcpy( p.data(), points1.data(), points1.size() * sizeof( Point ) );
 
         return p;
@@ -335,5 +337,5 @@
     QList<QPointF> points;
     for ( int edge = 0; edge < NEdges; edge++ )
-        points += cuttingPoints( ( Edge )edge, pos, radius );
+        points += cuttingPoints( static_cast<Edge>(edge), pos, radius );
 
     QVector<QwtInterval> intv;
@@ -444,4 +446,26 @@
 */
 QPolygon QwtClipper::clipPolygon(
+    const QRectF &clipRect, const QPolygon &polygon, bool closePolygon )
+{
+    const int minX = qCeil( clipRect.left() );
+    const int maxX = qFloor( clipRect.right() );
+    const int minY = qCeil( clipRect.top() );
+    const int maxY = qFloor( clipRect.bottom() );
+
+    const QRect r( minX, minY, maxX - minX, maxY - minY );
+
+    QwtPolygonClipper<QPolygon, QRect, QPoint, int> clipper( r );
+    return clipper.clipPolygon( polygon, closePolygon );
+}
+/*!
+   Sutherland-Hodgman polygon clipping
+
+   \param clipRect Clip rectangle
+   \param polygon Polygon
+   \param closePolygon True, when the polygon is closed
+
+   \return Clipped polygon
+*/
+QPolygon QwtClipper::clipPolygon(
     const QRect &clipRect, const QPolygon &polygon, bool closePolygon )
 {
@@ -469,5 +493,5 @@
    Circle clipping
 
-   clipCircle() devides a circle into intervals of angles representing arcs
+   clipCircle() divides a circle into intervals of angles representing arcs
    of the circle. When the circle is completely inside the clip rectangle
    an interval [0.0, 2 * M_PI] is returned.
Index: trunk/BNC/qwt/qwt_clipper.h
===================================================================
--- trunk/BNC/qwt/qwt_clipper.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_clipper.h	(revision 8127)
@@ -20,5 +20,5 @@
 
 /*!
-  \brief Some clipping algos
+  \brief Some clipping algorithms
 */
 
@@ -28,4 +28,7 @@
     static QPolygon clipPolygon( const QRect &, 
         const QPolygon &, bool closePolygon = false );
+    static QPolygon clipPolygon( const QRectF &, 
+        const QPolygon &, bool closePolygon = false );
+
     static QPolygonF clipPolygonF( const QRectF &, 
         const QPolygonF &, bool closePolygon = false );
Index: trunk/BNC/qwt/qwt_color_map.cpp
===================================================================
--- trunk/BNC/qwt/qwt_color_map.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_color_map.cpp	(revision 8127)
@@ -16,7 +16,8 @@
 {
 public:
-    ColorStops()
-    {
-        _stops.reserve( 256 );
+    ColorStops():
+        d_doAlpha( false )
+    {
+        d_stops.reserve( 256 );
     }
 
@@ -39,18 +40,48 @@
         ColorStop( double p, const QColor &c ):
             pos( p ),
-            rgb( c.rgb() )
+            rgb( c.rgba() )
         {
             r = qRed( rgb );
             g = qGreen( rgb );
             b = qBlue( rgb );
+            a = qAlpha( rgb );
+
+            /* 
+                when mapping a value to rgb we will have to calcualate: 
+                   - const int v = int( ( s1.v0 + ratio * s1.vStep ) + 0.5 );
+
+                Thus adding 0.5 ( for rounding ) can be done in advance
+             */
+            r0 = r + 0.5;
+            g0 = g + 0.5;
+            b0 = b + 0.5;
+            a0 = a + 0.5;
+
+            rStep = gStep = bStep = aStep = 0.0;
+            posStep = 0.0;
+        }
+
+        void updateSteps( const ColorStop &nextStop )
+        {
+            rStep = nextStop.r - r;
+            gStep = nextStop.g - g;
+            bStep = nextStop.b - b;
+            aStep = nextStop.a - a;
+            posStep = nextStop.pos - pos;
         }
 
         double pos;
         QRgb rgb;
-        int r, g, b;
+        int r, g, b, a;
+
+        // precalculated values
+        double rStep, gStep, bStep, aStep;
+        double r0, g0, b0, a0;
+        double posStep;
     };
 
     inline int findUpper( double pos ) const;
-    QVector<ColorStop> _stops;
+    QVector<ColorStop> d_stops;
+    bool d_doAlpha;
 };
 
@@ -64,29 +95,37 @@
 
     int index;
-    if ( _stops.size() == 0 )
+    if ( d_stops.size() == 0 )
     {
         index = 0;
-        _stops.resize( 1 );
+        d_stops.resize( 1 );
     }
     else
     {
         index = findUpper( pos );
-        if ( index == _stops.size() ||
-                qAbs( _stops[index].pos - pos ) >= 0.001 )
-        {
-            _stops.resize( _stops.size() + 1 );
-            for ( int i = _stops.size() - 1; i > index; i-- )
-                _stops[i] = _stops[i-1];
-        }
-    }
-
-    _stops[index] = ColorStop( pos, color );
+        if ( index == d_stops.size() ||
+                qAbs( d_stops[index].pos - pos ) >= 0.001 )
+        {
+            d_stops.resize( d_stops.size() + 1 );
+            for ( int i = d_stops.size() - 1; i > index; i-- )
+                d_stops[i] = d_stops[i-1];
+        }
+    }
+
+    d_stops[index] = ColorStop( pos, color );
+    if ( color.alpha() != 255 )
+        d_doAlpha = true;
+
+    if ( index > 0 )
+        d_stops[index-1].updateSteps( d_stops[index] );
+
+    if ( index < d_stops.size() - 1 )
+        d_stops[index].updateSteps( d_stops[index+1] );
 }
 
 inline QVector<double> QwtLinearColorMap::ColorStops::stops() const
 {
-    QVector<double> positions( _stops.size() );
-    for ( int i = 0; i < _stops.size(); i++ )
-        positions[i] = _stops[i].pos;
+    QVector<double> positions( d_stops.size() );
+    for ( int i = 0; i < d_stops.size(); i++ )
+        positions[i] = d_stops[i].pos;
     return positions;
 }
@@ -95,7 +134,7 @@
 {
     int index = 0;
-    int n = _stops.size();
-
-    const ColorStop *stops = _stops.data();
+    int n = d_stops.size();
+
+    const ColorStop *stops = d_stops.data();
 
     while ( n > 0 )
@@ -120,25 +159,39 @@
 {
     if ( pos <= 0.0 )
-        return _stops[0].rgb;
+        return d_stops[0].rgb;
     if ( pos >= 1.0 )
-        return _stops[ _stops.size() - 1 ].rgb;
+        return d_stops[ d_stops.size() - 1 ].rgb;
 
     const int index = findUpper( pos );
     if ( mode == FixedColors )
     {
-        return _stops[index-1].rgb;
+        return d_stops[index-1].rgb;
     }
     else
     {
-        const ColorStop &s1 = _stops[index-1];
-        const ColorStop &s2 = _stops[index];
-
-        const double ratio = ( pos - s1.pos ) / ( s2.pos - s1.pos );
-
-        const int r = s1.r + qRound( ratio * ( s2.r - s1.r ) );
-        const int g = s1.g + qRound( ratio * ( s2.g - s1.g ) );
-        const int b = s1.b + qRound( ratio * ( s2.b - s1.b ) );
-
-        return qRgb( r, g, b );
+        const ColorStop &s1 = d_stops[index-1];
+
+        const double ratio = ( pos - s1.pos ) / ( s1.posStep );
+
+        const int r = int( s1.r0 + ratio * s1.rStep );
+        const int g = int( s1.g0 + ratio * s1.gStep );
+        const int b = int( s1.b0 + ratio * s1.bStep );
+
+        if ( d_doAlpha )
+        {
+            if ( s1.aStep )
+            {
+                const int a = int( s1.a0 + ratio * s1.aStep );
+                return qRgba( r, g, b, a );
+            }
+            else
+            {
+                return qRgba( r, g, b, s1.a );
+            }
+        }
+        else
+        {
+            return qRgb( r, g, b );
+        }
     }
 }
@@ -205,5 +258,5 @@
    \param color1 Color used for the minimum value of the value interval
    \param color2 Color used for the maximum value of the value interval
-   \param format Preferred format of the coor map
+   \param format Preferred format for the color map
 */
 QwtLinearColorMap::QwtLinearColorMap( const QColor &color1,
@@ -280,5 +333,5 @@
 
 /*!
-   Return all positions of color stops in increasing order
+   \return Positions of color stops in increasing order
 */
 QVector<double> QwtLinearColorMap::colorStops() const
@@ -306,8 +359,10 @@
 
 /*!
-  Map a value of a given interval into a rgb value
+  Map a value of a given interval into a RGB value
 
   \param interval Range for all values
-  \param value Value to map into a rgb value
+  \param value Value to map into a RGB value
+
+  \return RGB value for value
 */
 QRgb QwtLinearColorMap::rgb(
@@ -315,20 +370,21 @@
 {
     if ( qIsNaN(value) )
-        return qRgba(0, 0, 0, 0);
+        return 0u;
 
     const double width = interval.width();
-
-    double ratio = 0.0;
-    if ( width > 0.0 )
-        ratio = ( value - interval.minValue() ) / width;
-
+    if ( width <= 0.0 )
+        return 0u;
+
+    const double ratio = ( value - interval.minValue() ) / width;
     return d_data->colorStops.rgb( d_data->mode, ratio );
 }
 
 /*!
-  Map a value of a given interval into a color index, between 0 and 255
+  \brief Map a value of a given interval into a color index
 
   \param interval Range for all values
   \param value Value to map into a color index
+
+  \return Index, between 0 and 255
 */
 unsigned char QwtLinearColorMap::colorIndex(
@@ -341,5 +397,5 @@
 
     if ( value >= interval.maxValue() )
-        return ( unsigned char )255;
+        return 255;
 
     const double ratio = ( value - interval.minValue() ) / width;
@@ -347,7 +403,7 @@
     unsigned char index;
     if ( d_data->mode == FixedColors )
-        index = ( unsigned char )( ratio * 255 ); // always floor
+        index = static_cast<unsigned char>( ratio * 255 ); // always floor
     else
-        index = ( unsigned char )qRound( ratio * 255 );
+        index = static_cast<unsigned char>( ratio * 255 + 0.5 );
 
     return index;
@@ -359,4 +415,5 @@
     QColor color;
     QRgb rgb;
+    QRgb rgbMax;
 };
 
@@ -370,24 +427,24 @@
 {
     d_data = new PrivateData;
+    setColor( color );
+}
+
+//! Destructor
+QwtAlphaColorMap::~QwtAlphaColorMap()
+{
+    delete d_data;
+}
+
+/*!
+   Set the color
+
+   \param color Color
+   \sa color()
+*/
+void QwtAlphaColorMap::setColor( const QColor &color )
+{
     d_data->color = color;
     d_data->rgb = color.rgb() & qRgba( 255, 255, 255, 0 );
-}
-
-//! Destructor
-QwtAlphaColorMap::~QwtAlphaColorMap()
-{
-    delete d_data;
-}
-
-/*!
-   Set the color
-
-   \param color Color
-   \sa color()
-*/
-void QwtAlphaColorMap::setColor( const QColor &color )
-{
-    d_data->color = color;
-    d_data->rgb = color.rgb();
+    d_data->rgbMax = d_data->rgb | ( 255 << 24 );
 }
 
@@ -407,22 +464,24 @@
 
   \param interval Range for all values
-  \param value Value to map into a rgb value
-  \return rgb value, with an alpha value
+  \param value Value to map into a RGB value
+  \return RGB value, with an alpha value
 */
 QRgb QwtAlphaColorMap::rgb( const QwtInterval &interval, double value ) const
 {
+    if ( qIsNaN(value) )
+        return 0u;
+
     const double width = interval.width();
-    if ( !qIsNaN(value) && width >= 0.0 )
-    {
-        const double ratio = ( value - interval.minValue() ) / width;
-        int alpha = qRound( 255 * ratio );
-        if ( alpha < 0 )
-            alpha = 0;
-        if ( alpha > 255 )
-            alpha = 255;
-
-        return d_data->rgb | ( alpha << 24 );
-    }
-    return d_data->rgb;
+    if ( width <= 0.0 )
+        return 0u;
+
+    if ( value <= interval.minValue() )
+        return d_data->rgb;
+
+    if ( value >= interval.maxValue() )
+        return d_data->rgbMax;
+
+    const double ratio = ( value - interval.minValue() ) / width;
+    return d_data->rgb | ( qRound( 255 * ratio ) << 24 );
 }
 
Index: trunk/BNC/qwt/qwt_color_map.h
===================================================================
--- trunk/BNC/qwt/qwt_color_map.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_color_map.h	(revision 8127)
@@ -41,5 +41,5 @@
     enum Format
     {
-        //! The map is intended to map into QRgb values.
+        //! The map is intended to map into RGB values.
         RGB,
 
@@ -57,8 +57,9 @@
 
     /*!
-       Map a value of a given interval into a rgb value.
+       Map a value of a given interval into a RGB value.
+
        \param interval Range for the values
        \param value Value
-       \return rgb value, corresponding to value
+       \return RGB value, corresponding to value
     */
     virtual QRgb rgb( const QwtInterval &interval,
@@ -67,4 +68,5 @@
     /*!
        Map a value of a given interval into a color index
+
        \param interval Range for the values
        \param value Value
@@ -136,5 +138,5 @@
 
 /*!
-  \brief QwtAlphaColorMap variies the alpha value of a color
+  \brief QwtAlphaColorMap varies the alpha value of a color
 */
 class QWT_EXPORT QwtAlphaColorMap: public QwtColorMap
@@ -178,5 +180,5 @@
     if ( d_format == RGB )
     {
-        return QColor( rgb( interval, value ) );
+        return QColor::fromRgba( rgb( interval, value ) );
     }
     else
Index: trunk/BNC/qwt/qwt_column_symbol.cpp
===================================================================
--- trunk/BNC/qwt/qwt_column_symbol.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_column_symbol.cpp	(revision 8127)
@@ -10,10 +10,9 @@
 #include "qwt_column_symbol.h"
 #include "qwt_math.h"
-#include "qwt_text.h"
 #include "qwt_painter.h"
 #include <qpainter.h>
 #include <qpalette.h>
 
-static void drawBox( QPainter *p, const QRectF &rect,
+static void qwtDrawBox( QPainter *p, const QRectF &rect,
     const QPalette &pal, double lw )
 {
@@ -58,5 +57,5 @@
 }
 
-static void drawPanel( QPainter *painter, const QRectF &rect,
+static void qwtDrawPanel( QPainter *painter, const QRectF &rect,
     const QPalette &pal, double lw )
 {
@@ -125,6 +124,4 @@
 
     QPalette palette;
-    QwtText label;
-
     int lineWidth;
 };
@@ -281,10 +278,10 @@
         case QwtColumnSymbol::Raised:
         {
-            ::drawPanel( painter, r, d_data->palette, d_data->lineWidth );
+            qwtDrawPanel( painter, r, d_data->palette, d_data->lineWidth );
             break;
         }
         case QwtColumnSymbol::Plain:
         {
-            ::drawBox( painter, r, d_data->palette, d_data->lineWidth );
+            qwtDrawBox( painter, r, d_data->palette, d_data->lineWidth );
             break;
         }
Index: trunk/BNC/qwt/qwt_column_symbol.h
===================================================================
--- trunk/BNC/qwt/qwt_column_symbol.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_column_symbol.h	(revision 8127)
@@ -23,5 +23,5 @@
 
 /*!
-    \brief Directed rectangle representing bounding rectangle und orientation
+    \brief Directed rectangle representing bounding rectangle and orientation
     of a column.
 */
Index: trunk/BNC/qwt/qwt_compass.cpp
===================================================================
--- trunk/BNC/qwt/qwt_compass.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_compass.cpp	(revision 8127)
@@ -0,0 +1,308 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_compass.h"
+#include "qwt_compass_rose.h"
+#include "qwt_math.h"
+#include "qwt_scale_draw.h"
+#include "qwt_painter.h"
+#include "qwt_dial_needle.h"
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qevent.h>
+
+/*! 
+  \brief Constructor
+
+  Initializes a label map for multiples of 45 degrees
+ */
+QwtCompassScaleDraw::QwtCompassScaleDraw()
+{
+    enableComponent( QwtAbstractScaleDraw::Backbone, false );
+    enableComponent( QwtAbstractScaleDraw::Ticks, false );
+
+    d_labelMap.insert( 0.0, QString::fromLatin1( "N" ) );
+    d_labelMap.insert( 45.0, QString::fromLatin1( "NE" ) );
+    d_labelMap.insert( 90.0, QString::fromLatin1( "E" ) );
+    d_labelMap.insert( 135.0, QString::fromLatin1( "SE" ) );
+    d_labelMap.insert( 180.0, QString::fromLatin1( "S" ) );
+    d_labelMap.insert( 225.0, QString::fromLatin1( "SW" ) );
+    d_labelMap.insert( 270.0, QString::fromLatin1( "W" ) );
+    d_labelMap.insert( 315.0, QString::fromLatin1( "NW" ) );
+
+#if 0
+    d_labelMap.insert( 22.5, QString::fromLatin1( "NNE" ) );
+    d_labelMap.insert( 67.5, QString::fromLatin1( "NEE" ) );
+    d_labelMap.insert( 112.5, QString::fromLatin1( "SEE" ) );
+    d_labelMap.insert( 157.5, QString::fromLatin1( "SSE" ) );
+    d_labelMap.insert( 202.5, QString::fromLatin1( "SSW" ) );
+    d_labelMap.insert( 247.5, QString::fromLatin1( "SWW" ) );
+    d_labelMap.insert( 292.5, QString::fromLatin1( "NWW" ) );
+    d_labelMap.insert( 337.5, QString::fromLatin1( "NNW" ) );
+#endif
+}
+
+/*! 
+  \brief Constructor
+
+  \param map Value to label map
+ */
+QwtCompassScaleDraw::QwtCompassScaleDraw( const QMap<double, QString> &map ):
+    d_labelMap( map )
+{
+    enableComponent( QwtAbstractScaleDraw::Backbone, false );
+    enableComponent( QwtAbstractScaleDraw::Ticks, false );
+}
+
+/*!
+  \brief Set a map, mapping values to labels
+  \param map Value to label map
+
+  The values of the major ticks are found by looking into this
+  map. The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
+
+  \warning The map will have no effect for values that are no major
+           tick values. Major ticks can be changed by QwtScaleDraw::setScale
+
+  \sa labelMap(), scaleDraw(), setScale()
+*/
+void QwtCompassScaleDraw::setLabelMap( const QMap<double, QString> &map )
+{
+    d_labelMap = map;
+}
+
+
+/*!
+  \return map, mapping values to labels
+  \sa setLabelMap()
+*/
+QMap<double, QString> QwtCompassScaleDraw::labelMap() const
+{
+    return d_labelMap;
+}
+
+/*!
+  Map a value to a corresponding label
+
+  \param value Value that will be mapped
+
+  label() looks in the labelMap() for a corresponding label for value
+  or returns an null text.
+
+  \return Label, or QString::null
+  \sa labelMap(), setLabelMap()
+*/
+
+QwtText QwtCompassScaleDraw::label( double value ) const
+{
+    if ( qFuzzyCompare( value + 1.0, 1.0 ) )
+        value = 0.0;
+
+    if ( value < 0.0 )
+        value += 360.0;
+
+    if ( d_labelMap.contains( value ) )
+        return d_labelMap[value];
+
+    return QwtText();
+}
+
+class QwtCompass::PrivateData
+{
+public:
+    PrivateData():
+        rose( NULL )
+    {
+    }
+
+    ~PrivateData()
+    {
+        delete rose;
+    }
+
+    QwtCompassRose *rose;
+};
+
+/*!
+  \brief Constructor
+  \param parent Parent widget
+
+  Create a compass widget with a scale, no needle and no rose.
+  The default origin is 270.0 with no valid value. It accepts
+  mouse and keyboard inputs and has no step size. The default mode
+  is QwtDial::RotateNeedle.
+*/
+QwtCompass::QwtCompass( QWidget* parent ):
+    QwtDial( parent )
+{
+    d_data = new PrivateData;
+
+    setScaleDraw( new QwtCompassScaleDraw() );
+
+    setOrigin( 270.0 );
+    setWrapping( true );
+
+    setScaleMaxMajor( 36 );
+    setScaleMaxMinor( 10 );
+
+    setScale( 0.0, 360.0 ); // degrees as default
+    setTotalSteps( 360 );
+}
+
+//!  Destructor
+QwtCompass::~QwtCompass()
+{
+    delete d_data;
+}
+
+
+/*!
+   Draw the contents of the scale
+
+   \param painter Painter
+   \param center Center of the content circle
+   \param radius Radius of the content circle
+*/
+void QwtCompass::drawScaleContents( QPainter *painter,
+    const QPointF &center, double radius ) const
+{
+    QPalette::ColorGroup cg;
+    if ( isEnabled() )
+        cg = hasFocus() ? QPalette::Active : QPalette::Inactive;
+    else
+        cg = QPalette::Disabled;
+
+    double north = origin();
+    if ( isValid() )
+    {
+        if ( mode() == RotateScale )
+            north -= value();
+    }
+
+    const int margin = 4;
+    drawRose( painter, center, radius - margin, 360.0 - north,  cg );
+}
+
+/*!
+  Draw the compass rose
+
+  \param painter Painter
+  \param center Center of the compass
+  \param radius of the circle, where to paint the rose
+  \param north Direction pointing north, in degrees counter clockwise
+  \param cg Color group
+*/
+void QwtCompass::drawRose( QPainter *painter, const QPointF &center,
+    double radius, double north, QPalette::ColorGroup cg ) const
+{
+    if ( d_data->rose )
+        d_data->rose->draw( painter, center, radius, north,  cg );
+}
+
+/*!
+  Set a rose for the compass
+  \param rose Compass rose
+  \warning The rose will be deleted, when a different rose is
+    set or in ~QwtCompass
+  \sa rose()
+*/
+void QwtCompass::setRose( QwtCompassRose *rose )
+{
+    if ( rose != d_data->rose )
+    {
+        if ( d_data->rose )
+            delete d_data->rose;
+
+        d_data->rose = rose;
+        update();
+    }
+}
+
+/*!
+  \return rose
+  \sa setRose()
+*/
+const QwtCompassRose *QwtCompass::rose() const
+{
+    return d_data->rose;
+}
+
+/*!
+  \return rose
+  \sa setRose()
+*/
+QwtCompassRose *QwtCompass::rose()
+{
+    return d_data->rose;
+}
+
+/*!
+  Handles key events
+
+  Beside the keys described in QwtDial::keyPressEvent numbers
+  from 1-9 (without 5) set the direction according to their
+  position on the num pad.
+
+  \sa isReadOnly()
+*/
+void QwtCompass::keyPressEvent( QKeyEvent *kev )
+{
+    if ( isReadOnly() )
+        return;
+
+#if 0
+    if ( kev->key() == Key_5 )
+    {
+        invalidate(); // signal ???
+        return;
+    }
+#endif
+
+    double newValue = value();
+
+    if ( kev->key() >= Qt::Key_1 && kev->key() <= Qt::Key_9 )
+    {
+        if ( mode() != RotateNeedle || kev->key() == Qt::Key_5 )
+            return;
+
+        switch ( kev->key() )
+        {
+            case Qt::Key_6:
+                newValue = 180.0 * 0.0;
+                break;
+            case Qt::Key_3:
+                newValue = 180.0 * 0.25;
+                break;
+            case Qt::Key_2:
+                newValue = 180.0 * 0.5;
+                break;
+            case Qt::Key_1:
+                newValue = 180.0 * 0.75;
+                break;
+            case Qt::Key_4:
+                newValue = 180.0 * 1.0;
+                break;
+            case Qt::Key_7:
+                newValue = 180.0 * 1.25;
+                break;
+            case Qt::Key_8:
+                newValue = 180.0 * 1.5;
+                break;
+            case Qt::Key_9:
+                newValue = 180.0 * 1.75;
+                break;
+        }
+        newValue -= origin();
+        setValue( newValue );
+    }
+    else
+    {
+        QwtDial::keyPressEvent( kev );
+    }
+}
Index: trunk/BNC/qwt/qwt_compass.h
===================================================================
--- trunk/BNC/qwt/qwt_compass.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_compass.h	(revision 8127)
@@ -0,0 +1,83 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_COMPASS_H
+#define QWT_COMPASS_H 1
+
+#include "qwt_global.h"
+#include "qwt_dial.h"
+#include "qwt_round_scale_draw.h"
+#include <qstring.h>
+#include <qmap.h>
+
+class QwtCompassRose;
+
+/*!
+  \brief A special scale draw made for QwtCompass
+
+  QwtCompassScaleDraw maps values to strings using
+  a special map, that can be modified by the application
+
+  The default map consists of the labels N, NE, E, SE, S, SW, W, NW.
+
+  \sa QwtCompass
+*/
+class QWT_EXPORT QwtCompassScaleDraw: public QwtRoundScaleDraw
+{
+public:
+    explicit QwtCompassScaleDraw();
+    explicit QwtCompassScaleDraw( const QMap<double, QString> &map );
+
+    void setLabelMap( const QMap<double, QString> &map );
+    QMap<double, QString> labelMap() const;
+
+    virtual QwtText label( double value ) const;
+
+private:
+    QMap<double, QString> d_labelMap;
+};
+
+/*!
+  \brief A Compass Widget
+
+  QwtCompass is a widget to display and enter directions. It consists
+  of a scale, an optional needle and rose.
+
+  \image html dials1.png
+
+  \note The examples/dials example shows how to use QwtCompass.
+*/
+
+class QWT_EXPORT QwtCompass: public QwtDial
+{
+    Q_OBJECT
+
+public:
+    explicit QwtCompass( QWidget* parent = NULL );
+    virtual ~QwtCompass();
+
+    void setRose( QwtCompassRose *rose );
+    const QwtCompassRose *rose() const;
+    QwtCompassRose *rose();
+
+protected:
+    virtual void drawRose( QPainter *, const QPointF &center,
+        double radius, double north, QPalette::ColorGroup ) const;
+
+    virtual void drawScaleContents( QPainter *,
+        const QPointF &center, double radius ) const;
+
+    virtual void keyPressEvent( QKeyEvent * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_compass_rose.cpp
===================================================================
--- trunk/BNC/qwt/qwt_compass_rose.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_compass_rose.cpp	(revision 8127)
@@ -0,0 +1,269 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_compass_rose.h"
+#include "qwt_point_polar.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+
+static QPointF qwtIntersection( 
+    QPointF p11, QPointF p12, QPointF p21, QPointF p22 )
+{
+    const QLineF line1( p11, p12 );
+    const QLineF line2( p21, p22 );
+
+    QPointF pos;
+    if ( line1.intersect( line2, &pos ) == QLineF::NoIntersection )
+        return QPointF();
+
+    return pos;
+}
+
+class QwtSimpleCompassRose::PrivateData
+{
+public:
+    PrivateData():
+        width( 0.2 ),
+        numThorns( 8 ),
+        numThornLevels( -1 ),
+        shrinkFactor( 0.9 )
+    {
+    }
+
+    double width;
+    int numThorns;
+    int numThornLevels;
+    double shrinkFactor;
+};
+
+/*!
+   Constructor
+
+   \param numThorns Number of thorns
+   \param numThornLevels Number of thorn levels
+*/
+QwtSimpleCompassRose::QwtSimpleCompassRose(
+    int numThorns, int numThornLevels )
+{
+    d_data = new PrivateData();
+    d_data->numThorns = numThorns;
+    d_data->numThornLevels = numThornLevels;
+
+    const QColor dark( 128, 128, 255 );
+    const QColor light( 192, 255, 255 );
+
+    QPalette palette;
+    palette.setColor( QPalette::Dark, dark );
+    palette.setColor( QPalette::Light, light );
+
+    setPalette( palette );
+}
+
+//! Destructor
+QwtSimpleCompassRose::~QwtSimpleCompassRose()
+{
+    delete d_data;
+}
+
+/*!
+  Set the Factor how to shrink the thorns with each level
+  The default value is 0.9.
+
+  \param factor Shrink factor
+  \sa shrinkFactor()
+*/
+void QwtSimpleCompassRose::setShrinkFactor( double factor )
+{
+    d_data->shrinkFactor = factor;
+}
+
+/*!
+  \return Factor how to shrink the thorns with each level
+  \sa setShrinkFactor()
+*/
+double QwtSimpleCompassRose::shrinkFactor() const
+{
+    return d_data->shrinkFactor;
+}
+
+/*!
+   Draw the rose
+
+   \param painter Painter
+   \param center Center point
+   \param radius Radius of the rose
+   \param north Position
+   \param cg Color group
+*/
+void QwtSimpleCompassRose::draw( QPainter *painter, const QPointF &center,
+    double radius, double north, QPalette::ColorGroup cg ) const
+{
+    QPalette pal = palette();
+    pal.setCurrentColorGroup( cg );
+
+    drawRose( painter, pal, center, radius, north, d_data->width,
+        d_data->numThorns, d_data->numThornLevels, d_data->shrinkFactor );
+}
+
+/*!
+   Draw the rose
+
+   \param painter Painter
+   \param palette Palette
+   \param center Center of the rose
+   \param radius Radius of the rose
+   \param north Position pointing to north
+   \param width Width of the rose
+   \param numThorns Number of thorns
+   \param numThornLevels Number of thorn levels
+   \param shrinkFactor Factor to shrink the thorns with each level
+*/
+void QwtSimpleCompassRose::drawRose(
+    QPainter *painter,
+    const QPalette &palette,
+    const QPointF &center, double radius, double north, double width,
+    int numThorns, int numThornLevels, double shrinkFactor )
+{
+    if ( numThorns < 4 )
+        numThorns = 4;
+
+    if ( numThorns % 4 )
+        numThorns += 4 - numThorns % 4;
+
+    if ( numThornLevels <= 0 )
+        numThornLevels = numThorns / 4;
+
+    if ( shrinkFactor >= 1.0 )
+        shrinkFactor = 1.0;
+
+    if ( shrinkFactor <= 0.5 )
+        shrinkFactor = 0.5;
+
+    painter->save();
+
+    painter->setPen( Qt::NoPen );
+
+    for ( int j = 1; j <= numThornLevels; j++ )
+    {
+        double step =  qPow( 2.0, j ) * M_PI / numThorns;
+        if ( step > M_PI_2 )
+            break;
+
+        double r = radius;
+        for ( int k = 0; k < 3; k++ )
+        {
+            if ( j + k < numThornLevels )
+                r *= shrinkFactor;
+        }
+
+        double leafWidth = r * width;
+        if ( 2.0 * M_PI / step > 32 )
+            leafWidth = 16;
+
+        const double origin = qwtRadians( north );
+        for ( double angle = origin;
+            angle < 2.0 * M_PI + origin; angle += step )
+        {
+            const QPointF p = qwtPolar2Pos( center, r, angle );
+            const QPointF p1 = qwtPolar2Pos( center, leafWidth, angle + M_PI_2 );
+            const QPointF p2 = qwtPolar2Pos( center, leafWidth, angle - M_PI_2 );
+            const QPointF p3 = qwtPolar2Pos( center, r, angle + step / 2.0 );
+            const QPointF p4 = qwtPolar2Pos( center, r, angle - step / 2.0 );
+
+            QPainterPath darkPath;
+            darkPath.moveTo( center );
+            darkPath.lineTo( p );
+            darkPath.lineTo( qwtIntersection( center, p3, p1, p ) );
+
+            painter->setBrush( palette.brush( QPalette::Dark ) );
+            painter->drawPath( darkPath );
+
+            QPainterPath lightPath;
+            lightPath.moveTo( center );
+            lightPath.lineTo( p );
+            lightPath.lineTo( qwtIntersection( center, p4, p2, p ) );
+
+            painter->setBrush( palette.brush( QPalette::Light ) );
+            painter->drawPath( lightPath );
+        }
+    }
+    painter->restore();
+}
+
+/*!
+   Set the width of the rose heads. Lower value make thinner heads.
+   The range is limited from 0.03 to 0.4.
+
+   \param width Width
+*/
+void QwtSimpleCompassRose::setWidth( double width )
+{
+    d_data->width = width;
+    if ( d_data->width < 0.03 )
+        d_data->width = 0.03;
+
+    if ( d_data->width > 0.4 )
+        d_data->width = 0.4;
+}
+
+/*! 
+  \return Width of the rose
+  \sa setWidth()
+ */
+double QwtSimpleCompassRose::width() const
+{
+    return d_data->width;
+}
+
+/*!
+  Set the number of thorns on one level
+  The number is aligned to a multiple of 4, with a minimum of 4
+
+  \param numThorns Number of thorns
+  \sa numThorns(), setNumThornLevels()
+*/
+void QwtSimpleCompassRose::setNumThorns( int numThorns )
+{
+    if ( numThorns < 4 )
+        numThorns = 4;
+
+    if ( numThorns % 4 )
+        numThorns += 4 - numThorns % 4;
+
+    d_data->numThorns = numThorns;
+}
+
+/*!
+   \return Number of thorns
+   \sa setNumThorns(), setNumThornLevels()
+*/
+int QwtSimpleCompassRose::numThorns() const
+{
+    return d_data->numThorns;
+}
+
+/*!
+  Set the of thorns levels
+
+  \param numThornLevels Number of thorns levels
+  \sa setNumThorns(), numThornLevels()
+*/
+void QwtSimpleCompassRose::setNumThornLevels( int numThornLevels )
+{
+    d_data->numThornLevels = numThornLevels;
+}
+
+/*!
+   \return Number of thorn levels
+   \sa setNumThorns(), setNumThornLevels()
+*/
+int QwtSimpleCompassRose::numThornLevels() const
+{
+    return d_data->numThornLevels;
+}
Index: trunk/BNC/qwt/qwt_compass_rose.h
===================================================================
--- trunk/BNC/qwt/qwt_compass_rose.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_compass_rose.h	(revision 8127)
@@ -0,0 +1,89 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_COMPASS_ROSE_H
+#define QWT_COMPASS_ROSE_H 1
+
+#include "qwt_global.h"
+#include <qpalette.h>
+
+class QPainter;
+
+/*!
+  \brief Abstract base class for a compass rose
+*/
+class QWT_EXPORT QwtCompassRose
+{
+public:
+    //! Destructor
+    virtual ~QwtCompassRose() {};
+
+    //! Assign a palette
+    virtual void setPalette( const QPalette &p )
+    {
+        d_palette = p;
+    }
+
+    //! \return Current palette
+    const QPalette &palette() const
+    {
+        return d_palette;
+    }
+
+    /*!
+        Draw the rose
+
+        \param painter Painter
+        \param center Center point
+        \param radius Radius of the rose
+        \param north Position
+        \param colorGroup Color group
+     */
+    virtual void draw( QPainter *painter, 
+        const QPointF &center, double radius, double north,
+        QPalette::ColorGroup colorGroup = QPalette::Active ) const = 0;
+
+private:
+    QPalette d_palette;
+};
+
+/*!
+  \brief A simple rose for QwtCompass
+*/
+class QWT_EXPORT QwtSimpleCompassRose: public QwtCompassRose
+{
+public:
+    QwtSimpleCompassRose( int numThorns = 8, int numThornLevels = -1 );
+    virtual ~QwtSimpleCompassRose();
+
+    void setWidth( double w );
+    double width() const;
+
+    void setNumThorns( int count );
+    int numThorns() const;
+
+    void setNumThornLevels( int count );
+    int numThornLevels() const;
+
+    void setShrinkFactor( double factor );
+    double shrinkFactor() const;
+
+    virtual void draw( QPainter *, const QPointF &center, double radius,
+        double north, QPalette::ColorGroup = QPalette::Active ) const;
+
+    static void drawRose( QPainter *, const QPalette &,
+        const QPointF &center, double radius, double origin, double width,
+        int numThorns, int numThornLevels, double shrinkFactor );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif 
Index: trunk/BNC/qwt/qwt_compat.h
===================================================================
--- trunk/BNC/qwt/qwt_compat.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_compat.h	(revision 8127)
@@ -12,4 +12,6 @@
 
 #include "qwt_global.h"
+#include "qwt_interval.h"
+#include "qwt_point_3d.h"
 #include <qlist.h>
 #include <qvector.h>
Index: trunk/BNC/qwt/qwt_counter.cpp
===================================================================
--- trunk/BNC/qwt/qwt_counter.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_counter.cpp	(revision 8127)
@@ -0,0 +1,785 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_arrow_button.h"
+#include "qwt_math.h"
+#include "qwt_counter.h"
+#include <qlayout.h>
+#include <qlineedit.h>
+#include <qvalidator.h>
+#include <qevent.h>
+#include <qstyle.h>
+
+class QwtCounter::PrivateData
+{
+public:
+    PrivateData():
+        minimum( 0.0 ),
+        maximum( 0.0 ),
+        singleStep( 1.0 ),
+        isValid( false ),
+        value( 0.0 ),
+        wrapping( false )
+    {
+        increment[Button1] = 1;
+        increment[Button2] = 10;
+        increment[Button3] = 100;
+    }
+
+    QwtArrowButton *buttonDown[ButtonCnt];
+    QwtArrowButton *buttonUp[ButtonCnt];
+    QLineEdit *valueEdit;
+
+    int increment[ButtonCnt];
+    int numButtons;
+
+    double minimum;
+    double maximum;
+    double singleStep;
+
+    bool isValid;
+    double value;
+
+    bool wrapping;
+};
+
+/*!
+  The counter is initialized with a range is set to [0.0, 1.0] with 
+  0.01 as single step size. The value is invalid.
+
+  The default number of buttons is set to 2. The default increments are:
+  \li Button 1: 1 step
+  \li Button 2: 10 steps
+  \li Button 3: 100 steps
+
+  \param parent
+ */
+QwtCounter::QwtCounter( QWidget *parent ):
+    QWidget( parent )
+{
+    initCounter();
+}
+
+void QwtCounter::initCounter()
+{
+    d_data = new PrivateData;
+
+    QHBoxLayout *layout = new QHBoxLayout( this );
+    layout->setSpacing( 0 );
+    layout->setMargin( 0 );
+
+    for ( int i = ButtonCnt - 1; i >= 0; i-- )
+    {
+        QwtArrowButton *btn =
+            new QwtArrowButton( i + 1, Qt::DownArrow, this );
+        btn->setFocusPolicy( Qt::NoFocus );
+        btn->installEventFilter( this );
+        layout->addWidget( btn );
+
+        connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) );
+        connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) );
+
+        d_data->buttonDown[i] = btn;
+    }
+
+    d_data->valueEdit = new QLineEdit( this );
+    d_data->valueEdit->setReadOnly( false );
+    d_data->valueEdit->setValidator( new QDoubleValidator( d_data->valueEdit ) );
+    layout->addWidget( d_data->valueEdit );
+
+    connect( d_data->valueEdit, SIGNAL( editingFinished() ),
+         SLOT( textChanged() ) );
+
+    layout->setStretchFactor( d_data->valueEdit, 10 );
+
+    for ( int i = 0; i < ButtonCnt; i++ )
+    {
+        QwtArrowButton *btn =
+            new QwtArrowButton( i + 1, Qt::UpArrow, this );
+        btn->setFocusPolicy( Qt::NoFocus );
+        btn->installEventFilter( this );
+        layout->addWidget( btn );
+
+        connect( btn, SIGNAL( released() ), SLOT( btnReleased() ) );
+        connect( btn, SIGNAL( clicked() ), SLOT( btnClicked() ) );
+
+        d_data->buttonUp[i] = btn;
+    }
+
+    setNumButtons( 2 );
+    setRange( 0.0, 1.0 );
+    setSingleStep( 0.001 );
+    setValue( 0.0 );
+
+    setSizePolicy(
+        QSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed ) );
+
+    setFocusProxy( d_data->valueEdit );
+    setFocusPolicy( Qt::StrongFocus );
+}
+
+//! Destructor
+QwtCounter::~QwtCounter()
+{
+    delete d_data;
+}
+
+/*! 
+  Set the counter to be in valid/invalid state
+
+  When the counter is set to invalid, no numbers are displayed and
+  the buttons are disabled.
+
+  \param on If true the counter will be set as valid 
+
+  \sa setValue(), isValid()
+*/
+void QwtCounter::setValid( bool on )
+{
+    if ( on != d_data->isValid )
+    {
+        d_data->isValid = on;
+
+        updateButtons();
+
+        if ( d_data->isValid )
+        {
+            showNumber( value() );
+            Q_EMIT valueChanged( value() );
+        }
+        else
+        {
+            d_data->valueEdit->setText( QString::null );
+        }
+    }   
+}   
+
+/*! 
+  \return True, if the value is valid
+  \sa setValid(), setValue()
+ */
+bool QwtCounter::isValid() const
+{
+    return d_data->isValid;
+}   
+
+/*!
+  \brief Allow/disallow the user to manually edit the value
+
+  \param on True disable editing
+  \sa isReadOnly()
+*/
+void QwtCounter::setReadOnly( bool on )
+{
+    d_data->valueEdit->setReadOnly( on );
+}
+
+/*! 
+   \return True, when the line line edit is read only. (default is no)
+  \sa setReadOnly()
+ */
+bool QwtCounter::isReadOnly() const
+{
+    return d_data->valueEdit->isReadOnly();
+}
+
+/*!
+  \brief Set a new value without adjusting to the step raster
+
+  The state of the counter is set to be valid.
+
+  \param value New value
+
+  \sa isValid(), value(), valueChanged()
+  \warning The value is clipped when it lies outside the range.
+*/
+
+void QwtCounter::setValue( double value )
+{
+    const double vmin = qMin( d_data->minimum, d_data->maximum );
+    const double vmax = qMax( d_data->minimum, d_data->maximum );
+
+    value = qBound( vmin, value, vmax );
+
+    if ( !d_data->isValid || value != d_data->value )
+    {
+        d_data->isValid = true;
+        d_data->value = value;
+
+        showNumber( value );
+        updateButtons();
+
+        Q_EMIT valueChanged( value );
+    }
+}
+
+/*!
+  \return Current value of the counter
+  \sa setValue(), valueChanged()
+ */
+double QwtCounter::value() const
+{
+    return d_data->value;
+}
+
+/*!
+  \brief Set the minimum and maximum values
+
+  The maximum is adjusted if necessary to ensure that the range remains valid.
+  The value might be modified to be inside of the range.
+
+  \param min Minimum value
+  \param max Maximum value
+
+  \sa minimum(), maximum()
+ */
+void QwtCounter::setRange( double min, double max )
+{
+    max = qMax( min, max );
+
+    if ( d_data->maximum == max && d_data->minimum == min )
+        return;
+
+    d_data->minimum = min;
+    d_data->maximum = max;
+
+    setSingleStep( singleStep() );
+
+    const double value = qBound( min, d_data->value, max );
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+
+        if ( d_data->isValid )
+        {
+            showNumber( value );
+            Q_EMIT valueChanged( value );
+        }
+    }
+
+    updateButtons();
+}
+
+/*!
+  Set the minimum value of the range
+
+  \param value Minimum value
+  \sa setRange(), setMaximum(), minimum()
+
+  \note The maximum is adjusted if necessary to ensure that the range remains valid.
+*/
+void QwtCounter::setMinimum( double value )
+{
+    setRange( value, maximum() );
+}
+
+/*!
+  \return The minimum of the range
+  \sa setRange(), setMinimum(), maximum()
+*/
+double QwtCounter::minimum() const
+{
+    return d_data->minimum;
+}
+
+/*!
+  Set the maximum value of the range
+
+  \param value Maximum value
+  \sa setRange(), setMinimum(), maximum()
+*/
+void QwtCounter::setMaximum( double value )
+{
+    setRange( minimum(), value );
+}
+
+/*!
+  \return The maximum of the range
+  \sa setRange(), setMaximum(), minimum()
+*/
+double QwtCounter::maximum() const
+{
+    return d_data->maximum;
+}
+
+/*!
+  \brief Set the step size of the counter
+
+  A value <= 0.0 disables stepping
+
+  \param stepSize Single step size
+  \sa singleStep()
+*/
+void QwtCounter::setSingleStep( double stepSize )
+{
+    d_data->singleStep = qMax( stepSize, 0.0 );
+}
+
+/*!
+  \return Single step size
+  \sa setSingleStep()
+ */
+double QwtCounter::singleStep() const
+{
+    return d_data->singleStep;
+}
+
+/*!
+  \brief En/Disable wrapping
+
+  If wrapping is true stepping up from maximum() value will take 
+  you to the minimum() value and vice versa. 
+
+  \param on En/Disable wrapping
+  \sa wrapping()
+ */
+void QwtCounter::setWrapping( bool on )
+{
+    d_data->wrapping = on;
+}
+
+/*!
+  \return True, when wrapping is set
+  \sa setWrapping()
+ */
+bool QwtCounter::wrapping() const
+{
+    return d_data->wrapping;
+}
+
+/*!
+  Specify the number of buttons on each side of the label
+
+  \param numButtons Number of buttons
+  \sa numButtons()
+*/
+void QwtCounter::setNumButtons( int numButtons )
+{
+    if ( numButtons < 0 || numButtons > QwtCounter::ButtonCnt )
+        return;
+
+    for ( int i = 0; i < QwtCounter::ButtonCnt; i++ )
+    {
+        if ( i < numButtons )
+        {
+            d_data->buttonDown[i]->show();
+            d_data->buttonUp[i]->show();
+        }
+        else
+        {
+            d_data->buttonDown[i]->hide();
+            d_data->buttonUp[i]->hide();
+        }
+    }
+
+    d_data->numButtons = numButtons;
+}
+
+/*!
+  \return The number of buttons on each side of the widget.
+  \sa setNumButtons()
+*/
+int QwtCounter::numButtons() const
+{
+    return d_data->numButtons;
+}
+
+/*!
+  Specify the number of steps by which the value
+  is incremented or decremented when a specified button
+  is pushed.
+
+  \param button Button index
+  \param numSteps Number of steps
+
+  \sa incSteps()
+*/
+void QwtCounter::setIncSteps( QwtCounter::Button button, int numSteps )
+{
+    if ( button >= 0 && button < QwtCounter::ButtonCnt )
+        d_data->increment[ button ] = numSteps;
+}
+
+/*!
+  \return The number of steps by which a specified button increments the value
+          or 0 if the button is invalid.
+  \param button Button index
+
+  \sa setIncSteps()
+*/
+int QwtCounter::incSteps( QwtCounter::Button button ) const
+{
+    if ( button >= 0 && button < QwtCounter::ButtonCnt )
+        return d_data->increment[ button ];
+
+    return 0;
+}
+
+
+/*!
+  Set the number of increment steps for button 1
+  \param nSteps Number of steps
+*/
+void QwtCounter::setStepButton1( int nSteps )
+{
+    setIncSteps( QwtCounter::Button1, nSteps );
+}
+
+//! returns the number of increment steps for button 1
+int QwtCounter::stepButton1() const
+{
+    return incSteps( QwtCounter::Button1 );
+}
+
+/*!
+  Set the number of increment steps for button 2
+  \param nSteps Number of steps
+*/
+void QwtCounter::setStepButton2( int nSteps )
+{
+    setIncSteps( QwtCounter::Button2, nSteps );
+}
+
+//! returns the number of increment steps for button 2
+int QwtCounter::stepButton2() const
+{
+    return incSteps( QwtCounter::Button2 );
+}
+
+/*!
+  Set the number of increment steps for button 3
+  \param nSteps Number of steps
+*/
+void QwtCounter::setStepButton3( int nSteps )
+{
+    setIncSteps( QwtCounter::Button3, nSteps );
+}
+
+//! returns the number of increment steps for button 3
+int QwtCounter::stepButton3() const
+{
+    return incSteps( QwtCounter::Button3 );
+}
+
+//! Set from lineedit
+void QwtCounter::textChanged()
+{
+    bool converted = false;
+
+    const double value = d_data->valueEdit->text().toDouble( &converted );
+    if ( converted )
+        setValue( value );
+}
+
+/*!
+   Handle QEvent::PolishRequest events
+   \param event Event
+   \return see QWidget::event()
+*/
+bool QwtCounter::event( QEvent *event )
+{
+    if ( event->type() == QEvent::PolishRequest )
+    {
+        const int w = d_data->valueEdit->fontMetrics().width( "W" ) + 8;
+        for ( int i = 0; i < ButtonCnt; i++ )
+        {
+            d_data->buttonDown[i]->setMinimumWidth( w );
+            d_data->buttonUp[i]->setMinimumWidth( w );
+        }
+    }
+
+    return QWidget::event( event );
+}
+
+/*!
+  Handle key events
+
+  - Ctrl + Qt::Key_Home\n
+    Step to minimum()
+  - Ctrl + Qt::Key_End\n
+    Step to maximum()
+  - Qt::Key_Up\n
+    Increment by incSteps(QwtCounter::Button1)
+  - Qt::Key_Down\n
+    Decrement by incSteps(QwtCounter::Button1)
+  - Qt::Key_PageUp\n
+    Increment by incSteps(QwtCounter::Button2)
+  - Qt::Key_PageDown\n
+    Decrement by incSteps(QwtCounter::Button2)
+  - Shift + Qt::Key_PageUp\n
+    Increment by incSteps(QwtCounter::Button3)
+  - Shift + Qt::Key_PageDown\n
+    Decrement by incSteps(QwtCounter::Button3)
+
+  \param event Key event
+*/
+void QwtCounter::keyPressEvent ( QKeyEvent *event )
+{
+    bool accepted = true;
+
+    switch ( event->key() )
+    {
+        case Qt::Key_Home:
+        {
+            if ( event->modifiers() & Qt::ControlModifier )
+                setValue( minimum() );
+            else
+                accepted = false;
+            break;
+        }
+        case Qt::Key_End:
+        {
+            if ( event->modifiers() & Qt::ControlModifier )
+                setValue( maximum() );
+            else
+                accepted = false;
+            break;
+        }
+        case Qt::Key_Up:
+        {
+            incrementValue( d_data->increment[0] );
+            break;
+        }
+        case Qt::Key_Down:
+        {
+            incrementValue( -d_data->increment[0] );
+            break;
+        }
+        case Qt::Key_PageUp:
+        case Qt::Key_PageDown:
+        {
+            int increment = d_data->increment[0];
+            if ( d_data->numButtons >= 2 )
+                increment = d_data->increment[1];
+            if ( d_data->numButtons >= 3 )
+            {
+                if ( event->modifiers() & Qt::ShiftModifier )
+                    increment = d_data->increment[2];
+            }
+            if ( event->key() == Qt::Key_PageDown )
+                increment = -increment;
+            incrementValue( increment );
+            break;
+        }
+        default:
+        {
+            accepted = false;
+        }
+    }
+
+    if ( accepted )
+    {
+        event->accept();
+        return;
+    }
+
+    QWidget::keyPressEvent ( event );
+}
+
+/*!
+  Handle wheel events
+  \param event Wheel event
+*/
+void QwtCounter::wheelEvent( QWheelEvent *event )
+{
+    event->accept();
+
+    if ( d_data->numButtons <= 0 )
+        return;
+
+    int increment = d_data->increment[0];
+    if ( d_data->numButtons >= 2 )
+    {
+        if ( event->modifiers() & Qt::ControlModifier )
+            increment = d_data->increment[1];
+    }
+    if ( d_data->numButtons >= 3 )
+    {
+        if ( event->modifiers() & Qt::ShiftModifier )
+            increment = d_data->increment[2];
+    }
+
+    for ( int i = 0; i < d_data->numButtons; i++ )
+    {
+        if ( d_data->buttonDown[i]->geometry().contains( event->pos() ) ||
+            d_data->buttonUp[i]->geometry().contains( event->pos() ) )
+        {
+            increment = d_data->increment[i];
+        }
+    }
+
+    const int wheel_delta = 120;
+
+#if 1
+    int delta = event->delta();
+    if ( delta >= 2 * wheel_delta )
+        delta /= 2; // Never saw an abs(delta) < 240
+#endif
+
+    incrementValue( delta / wheel_delta * increment );
+}
+
+void QwtCounter::incrementValue( int numSteps )
+{
+    const double min = d_data->minimum;
+    const double max = d_data->maximum;
+    double stepSize = d_data->singleStep;
+
+    if ( !d_data->isValid || min >= max || stepSize <= 0.0 )
+        return;
+
+
+#if 1
+    stepSize = qMax( stepSize, 1.0e-10 * ( max - min ) );
+#endif
+
+    double value = d_data->value + numSteps * stepSize;
+
+    if ( d_data->wrapping )
+    {
+        const double range = max - min;
+
+        if ( value < min )
+        {
+            value += ::ceil( ( min - value ) / range ) * range;
+        }
+        else if ( value > max )
+        {
+            value -= ::ceil( ( value - max ) / range ) * range;
+        }
+    }
+    else
+    {
+        value = qBound( min, value, max );
+    }
+
+    value = min + qRound( ( value - min ) / stepSize ) * stepSize;
+
+    if ( stepSize > 1e-12 )
+    {
+        if ( qFuzzyCompare( value + 1.0, 1.0 ) )
+        {
+            // correct rounding error if value = 0
+            value = 0.0;
+        }
+        else if ( qFuzzyCompare( value, max ) )
+        {
+            // correct rounding error at the border
+            value = max;
+        }
+    }
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        showNumber( d_data->value );
+        updateButtons();
+
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+
+/*!
+  \brief Update buttons according to the current value
+
+  When the QwtCounter under- or over-flows, the focus is set to the smallest
+  up- or down-button and counting is disabled.
+
+  Counting is re-enabled on a button release event (mouse or space bar).
+*/
+void QwtCounter::updateButtons()
+{
+    if ( d_data->isValid )
+    {
+        // 1. save enabled state of the smallest down- and up-button
+        // 2. change enabled state on under- or over-flow
+
+        for ( int i = 0; i < QwtCounter::ButtonCnt; i++ )
+        {
+            d_data->buttonDown[i]->setEnabled( value() > minimum() );
+            d_data->buttonUp[i]->setEnabled( value() < maximum() );
+        }
+    }
+    else
+    {
+        for ( int i = 0; i < QwtCounter::ButtonCnt; i++ )
+        {
+            d_data->buttonDown[i]->setEnabled( false );
+            d_data->buttonUp[i]->setEnabled( false );
+        }
+    }
+}
+/*!
+  Display number string
+
+  \param number Number
+*/
+void QwtCounter::showNumber( double number )
+{
+    QString text;
+    text.setNum( number );
+
+    const int cursorPos = d_data->valueEdit->cursorPosition();
+    d_data->valueEdit->setText( text );
+    d_data->valueEdit->setCursorPosition( cursorPos );
+}
+
+//!  Button clicked
+void QwtCounter::btnClicked()
+{
+    for ( int i = 0; i < ButtonCnt; i++ )
+    {
+        if ( d_data->buttonUp[i] == sender() )
+            incrementValue( d_data->increment[i] );
+
+        if ( d_data->buttonDown[i] == sender() )
+            incrementValue( -d_data->increment[i] );
+    }
+}
+
+//!  Button released
+void QwtCounter::btnReleased()
+{
+    Q_EMIT buttonReleased( value() );
+}
+
+//! A size hint
+QSize QwtCounter::sizeHint() const
+{
+    QString tmp;
+
+    int w = tmp.setNum( minimum() ).length();
+    int w1 = tmp.setNum( maximum() ).length();
+    if ( w1 > w )
+        w = w1;
+    w1 = tmp.setNum( minimum() + singleStep() ).length();
+    if ( w1 > w )
+        w = w1;
+    w1 = tmp.setNum( maximum() - singleStep() ).length();
+    if ( w1 > w )
+        w = w1;
+
+    tmp.fill( '9', w );
+
+    QFontMetrics fm( d_data->valueEdit->font() );
+    w = fm.width( tmp ) + 2;
+    if ( d_data->valueEdit->hasFrame() )
+        w += 2 * style()->pixelMetric( QStyle::PM_DefaultFrameWidth );
+
+    // Now we replace default sizeHint contribution of d_data->valueEdit by
+    // what we really need.
+
+    w += QWidget::sizeHint().width() - d_data->valueEdit->sizeHint().width();
+
+    const int h = qMin( QWidget::sizeHint().height(),
+        d_data->valueEdit->minimumSizeHint().height() );
+    return QSize( w, h );
+}
Index: trunk/BNC/qwt/qwt_counter.h
===================================================================
--- trunk/BNC/qwt/qwt_counter.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_counter.h	(revision 8127)
@@ -0,0 +1,161 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_COUNTER_H
+#define QWT_COUNTER_H
+
+#include "qwt_global.h"
+#include <qwidget.h>
+
+/*!
+  \brief The Counter Widget
+
+  A Counter consists of a label displaying a number and
+  one ore more (up to three) push buttons on each side
+  of the label which can be used to increment or decrement
+  the counter's value.
+
+  A counter has a range from a minimum value to a maximum value
+  and a step size. When the wrapping property is set
+  the counter is circular.
+ 
+  The number of steps by which a button increments or decrements the value 
+  can be specified using setIncSteps(). The number of buttons can be 
+  changed with setNumButtons().
+
+  Example:
+\code
+#include <qwt_counter.h>
+
+QwtCounter *counter = new QwtCounter(parent);
+
+counter->setRange(0.0, 100.0);                  // From 0.0 to 100
+counter->setSingleStep( 1.0 );                  // Step size 1.0
+counter->setNumButtons(2);                      // Two buttons each side
+counter->setIncSteps(QwtCounter::Button1, 1);   // Button 1 increments 1 step
+counter->setIncSteps(QwtCounter::Button2, 20);  // Button 2 increments 20 steps
+
+connect(counter, SIGNAL(valueChanged(double)), myClass, SLOT(newValue(double)));
+\endcode
+ */
+
+class QWT_EXPORT QwtCounter : public QWidget
+{
+    Q_OBJECT
+
+    Q_PROPERTY( double value READ value WRITE setValue )
+    Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
+    Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
+    Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
+
+    Q_PROPERTY( int numButtons READ numButtons WRITE setNumButtons )
+    Q_PROPERTY( int stepButton1 READ stepButton1 WRITE setStepButton1 )
+    Q_PROPERTY( int stepButton2 READ stepButton2 WRITE setStepButton2 )
+    Q_PROPERTY( int stepButton3 READ stepButton3 WRITE setStepButton3 )
+
+    Q_PROPERTY( bool readOnly READ isReadOnly WRITE setReadOnly )
+    Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
+
+public:
+    //! Button index
+    enum Button
+    {
+        //! Button intended for minor steps
+        Button1,
+
+        //! Button intended for medium steps
+        Button2,
+
+        //! Button intended for large steps
+        Button3,
+
+        //! Number of buttons
+        ButtonCnt
+    };
+
+    explicit QwtCounter( QWidget *parent = NULL );
+    virtual ~QwtCounter();
+
+    void setValid( bool );
+    bool isValid() const;
+
+    void setWrapping( bool );
+    bool wrapping() const;
+
+    bool isReadOnly() const;
+    void setReadOnly( bool );
+
+    void setNumButtons( int n );
+    int numButtons() const;
+
+    void setIncSteps( QwtCounter::Button btn, int nSteps );
+    int incSteps( QwtCounter::Button btn ) const;
+
+    virtual QSize sizeHint() const;
+
+    double singleStep() const;
+    void setSingleStep( double s );
+
+    void setRange( double min, double max );
+    
+    double minimum() const;
+    void setMinimum( double min );
+
+    double maximum() const;
+    void setMaximum( double max );
+
+    void setStepButton1( int nSteps );
+    int stepButton1() const;
+
+    void setStepButton2( int nSteps );
+    int stepButton2() const;
+
+    void setStepButton3( int nSteps );
+    int stepButton3() const;
+
+    double value() const;
+
+public Q_SLOTS:
+    void setValue( double );
+
+
+Q_SIGNALS:
+    /*!
+        This signal is emitted when a button has been released
+        \param value The new value
+    */
+    void buttonReleased ( double value );
+
+    /*!
+        This signal is emitted when the counter's value has changed
+        \param value The new value
+    */
+    void valueChanged ( double value );
+
+protected:
+    virtual bool event( QEvent * );
+    virtual void wheelEvent( QWheelEvent * );
+    virtual void keyPressEvent( QKeyEvent * );
+
+private Q_SLOTS:
+    void btnReleased();
+    void btnClicked();
+    void textChanged();
+
+private:
+    void incrementValue( int numSteps );
+    void initCounter();
+    void updateButtons();
+    void showNumber( double );
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_curve_fitter.cpp
===================================================================
--- trunk/BNC/qwt/qwt_curve_fitter.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_curve_fitter.cpp	(revision 8127)
@@ -247,9 +247,11 @@
 public:
     PrivateData():
-        tolerance( 1.0 )
+        tolerance( 1.0 ),
+        chunkSize( 0 )
     {
     }
 
     double tolerance;
+    uint chunkSize;
 };
 
@@ -288,5 +290,5 @@
  Assign the tolerance
 
- The tolerance is the maximum distance, that is accaptable
+ The tolerance is the maximum distance, that is acceptable
  between the original curve and the smoothed curve.
 
@@ -313,4 +315,34 @@
 
 /*!
+ Limit the number of points passed to a run of the algorithm
+
+ The runtime of the Douglas Peucker algorithm increases non linear
+ with the number of points. For a chunk size > 0 the polygon
+ is split into pieces passed to the algorithm one by one.
+
+ \param numPoints Maximum for the number of points passed to the algorithm
+
+ \sa chunkSize()
+*/
+void QwtWeedingCurveFitter::setChunkSize( uint numPoints )
+{
+    if ( numPoints > 0 )
+        numPoints = qMax( numPoints, 3U );
+
+    d_data->chunkSize = numPoints;
+}
+
+/*!
+  
+  \return Maximum for the number of points passed to a run 
+          of the algorithm - or 0, when unlimited
+  \sa setChunkSize()
+*/
+uint QwtWeedingCurveFitter::chunkSize() const
+{
+    return d_data->chunkSize;
+}
+
+/*!
   \param points Series of data points
   \return Curve points
@@ -318,4 +350,26 @@
 QPolygonF QwtWeedingCurveFitter::fitCurve( const QPolygonF &points ) const
 {
+    QPolygonF fittedPoints;
+
+    if ( d_data->chunkSize == 0 )
+    {
+        fittedPoints = simplify( points );
+    }
+    else
+    {
+        for ( int i = 0; i < points.size(); i += d_data->chunkSize )
+        {
+            const QPolygonF p = points.mid( i, d_data->chunkSize );
+            fittedPoints += simplify( p );
+        }
+    }
+
+    return fittedPoints;
+}
+
+QPolygonF QwtWeedingCurveFitter::simplify( const QPolygonF &points ) const
+{
+    const double toleranceSqr = d_data->tolerance * d_data->tolerance;
+
     QStack<Line> stack;
     stack.reserve( 500 );
@@ -325,6 +379,4 @@
 
     QVector<bool> usePoint( nPoints, false );
-
-    double distToSegment;
 
     stack.push( Line( 0, nPoints - 1 ) );
@@ -343,5 +395,5 @@
         const double unitVecY = ( vecLength != 0.0 ) ? vecY / vecLength : 0.0;
 
-        double maxDist = 0.0;
+        double maxDistSqr = 0.0;
         int nVertexIndexMaxDistance = r.from + 1;
         for ( int i = r.from + 1; i < r.to; i++ )
@@ -350,14 +402,9 @@
             const double fromVecX = p[i].x() - p[r.from].x();
             const double fromVecY = p[i].y() - p[r.from].y();
-            const double fromVecLength =
-                qSqrt( fromVecX * fromVecX + fromVecY * fromVecY );
-
+
+            double distToSegmentSqr;
             if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 )
             {
-                distToSegment = fromVecLength;
-            }
-            if ( fromVecX * unitVecX + fromVecY * unitVecY < 0.0 )
-            {
-                distToSegment = fromVecLength;
+                distToSegmentSqr = fromVecX * fromVecX + fromVecY * fromVecY;
             }
             else
@@ -365,21 +412,24 @@
                 const double toVecX = p[i].x() - p[r.to].x();
                 const double toVecY = p[i].y() - p[r.to].y();
-                const double toVecLength = qSqrt( toVecX * toVecX + toVecY * toVecY );
+                const double toVecLength = toVecX * toVecX + toVecY * toVecY;
+
                 const double s = toVecX * ( -unitVecX ) + toVecY * ( -unitVecY );
                 if ( s < 0.0 )
-                    distToSegment = toVecLength;
+                {
+                    distToSegmentSqr = toVecLength;
+                }
                 else
                 {
-                    distToSegment = qSqrt( qFabs( toVecLength * toVecLength - s * s ) );
+                    distToSegmentSqr = qFabs( toVecLength - s * s );
                 }
             }
 
-            if ( maxDist < distToSegment )
+            if ( maxDistSqr < distToSegmentSqr )
             {
-                maxDist = distToSegment;
+                maxDistSqr = distToSegmentSqr;
                 nVertexIndexMaxDistance = i;
             }
         }
-        if ( maxDist <= d_data->tolerance )
+        if ( maxDistSqr <= toleranceSqr )
         {
             usePoint[r.from] = true;
@@ -393,13 +443,11 @@
     }
 
-    int cnt = 0;
-
-    QPolygonF stripped( nPoints );
+    QPolygonF stripped;
     for ( int i = 0; i < nPoints; i++ )
     {
         if ( usePoint[i] )
-            stripped[cnt++] = p[i];
-    }
-    stripped.resize( cnt );
+            stripped += p[i];
+    }
+
     return stripped;
 }
Index: trunk/BNC/qwt/qwt_curve_fitter.h
===================================================================
--- trunk/BNC/qwt/qwt_curve_fitter.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_curve_fitter.h	(revision 8127)
@@ -100,4 +100,10 @@
   smoothed curve.
 
+  The runtime of the algorithm increases non linear ( worst case O( n*n ) )
+  and might be very slow for huge polygons. To avoid performance issues
+  it might be useful to split the polygon ( setChunkSize() ) and to run the algorithm
+  for these smaller parts. The disadvantage of having no interpolation
+  at the borders is for most use cases irrelevant.
+
   The smoothed curve consists of a subset of the points that defined the
   original curve.
@@ -117,7 +123,12 @@
     double tolerance() const;
 
+    void setChunkSize( uint );
+    uint chunkSize() const;
+
     virtual QPolygonF fitCurve( const QPolygonF & ) const;
 
 private:
+    virtual QPolygonF simplify( const QPolygonF & ) const;
+
     class Line;
 
Index: trunk/BNC/qwt/qwt_date.cpp
===================================================================
--- trunk/BNC/qwt/qwt_date.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_date.cpp	(revision 8127)
@@ -0,0 +1,760 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_date.h"
+#include <qdebug.h>
+#include <qlocale.h>
+#include <math.h>
+#include <limits>
+#include <limits.h>
+
+#if QT_VERSION >= 0x050000
+
+typedef qint64 QwtJulianDay;
+static const QwtJulianDay minJulianDayD = Q_INT64_C( -784350574879 );
+static const QwtJulianDay maxJulianDayD = Q_INT64_C( 784354017364 );
+
+#else
+
+// QDate stores the Julian day as unsigned int, but
+// but it is QDate::fromJulianDay( int ). That's why
+// we have the range [ 1, INT_MAX ]
+typedef int QwtJulianDay;
+static const QwtJulianDay minJulianDayD = 1;
+static const QwtJulianDay maxJulianDayD = std::numeric_limits<int>::max();
+
+#endif
+
+static QString qwtExpandedFormat( const QString & format, 
+    const QDateTime &dateTime, QwtDate::Week0Type week0Type )
+{
+    const int week = QwtDate::weekNumber( dateTime.date(), week0Type );
+
+    QString weekNo;
+    weekNo.setNum( week );
+
+    QString weekNoWW;
+    if ( weekNo.length() == 1 )
+        weekNoWW += "0";
+
+    weekNoWW += weekNo;
+
+    QString fmt = format;
+    fmt.replace( "ww", weekNoWW );
+    fmt.replace( "w", weekNo );
+
+    if ( week == 1 && dateTime.date().month() != 1 )
+    {
+        // in case of week 1, we might need to increment the year
+
+        static QString s_yyyy = "yyyy";
+        static QString s_yy = "yy";
+
+        // week 1 might start in the previous year
+
+        bool doReplaceYear = fmt.contains( s_yy );
+
+        if ( doReplaceYear )
+        {
+            if ( fmt.contains( 'M' ) )
+            {
+                // in case of also having 'M' we have a conflict about
+                // which year to show
+
+                doReplaceYear = false;
+            }
+            else
+            {
+                // in case of also having 'd' or 'dd' we have a conflict about
+                // which year to show
+
+                int numD = 0;
+
+                for ( int i = 0; i < fmt.size(); i++ )
+                {
+                    if ( fmt[i] == 'd' )
+                    {
+                        numD++;
+                    }
+                    else
+                    {
+                        if ( numD > 0 && numD <= 2 )
+                            break;
+
+                        numD = 0;
+                    }
+                }
+
+                if ( numD > 0 && numD <= 2 )
+                    doReplaceYear = false;
+            }
+        }
+
+        if ( doReplaceYear )
+        {
+            const QDate dt( dateTime.date().year() + 1, 1, 1 );
+
+            if ( fmt.contains( s_yyyy ) )
+            {
+                fmt.replace( s_yyyy, dt.toString( s_yyyy ) );
+            }
+            else
+            {
+                fmt.replace( s_yy, dt.toString( s_yyyy ) );
+            }
+        }
+    }
+
+    return fmt;
+}
+
+static inline Qt::DayOfWeek qwtFirstDayOfWeek()
+{
+#if QT_VERSION >= 0x040800
+    return QLocale().firstDayOfWeek();
+#else
+
+    switch( QLocale().country() )
+    {
+        case QLocale::Maldives:
+            return Qt::Friday;
+
+        case QLocale::Afghanistan:
+        case QLocale::Algeria:
+        case QLocale::Bahrain:
+        case QLocale::Djibouti:
+        case QLocale::Egypt:
+        case QLocale::Eritrea:
+        case QLocale::Ethiopia:
+        case QLocale::Iran:
+        case QLocale::Iraq:
+        case QLocale::Jordan:
+        case QLocale::Kenya:
+        case QLocale::Kuwait:
+        case QLocale::LibyanArabJamahiriya:
+        case QLocale::Morocco:
+        case QLocale::Oman:
+        case QLocale::Qatar:
+        case QLocale::SaudiArabia:
+        case QLocale::Somalia:
+        case QLocale::Sudan:
+        case QLocale::Tunisia:
+        case QLocale::Yemen:
+            return Qt::Saturday;
+
+        case QLocale::AmericanSamoa:
+        case QLocale::Argentina:
+        case QLocale::Azerbaijan:
+        case QLocale::Botswana:
+        case QLocale::Canada:
+        case QLocale::China:
+        case QLocale::FaroeIslands:
+        case QLocale::Georgia:
+        case QLocale::Greenland:
+        case QLocale::Guam:
+        case QLocale::HongKong:
+        case QLocale::Iceland:
+        case QLocale::India:
+        case QLocale::Ireland:
+        case QLocale::Israel:
+        case QLocale::Jamaica:
+        case QLocale::Japan:
+        case QLocale::Kyrgyzstan:
+        case QLocale::Lao:
+        case QLocale::Malta:
+        case QLocale::MarshallIslands:
+        case QLocale::Macau:
+        case QLocale::Mongolia:
+        case QLocale::NewZealand:
+        case QLocale::NorthernMarianaIslands:
+        case QLocale::Pakistan:
+        case QLocale::Philippines:
+        case QLocale::RepublicOfKorea:
+        case QLocale::Singapore:
+        case QLocale::SyrianArabRepublic:
+        case QLocale::Taiwan:
+        case QLocale::Thailand:
+        case QLocale::TrinidadAndTobago:
+        case QLocale::UnitedStates:
+        case QLocale::UnitedStatesMinorOutlyingIslands:
+        case QLocale::USVirginIslands:
+        case QLocale::Uzbekistan:
+        case QLocale::Zimbabwe:
+            return Qt::Sunday;
+
+        default:
+            return Qt::Monday;
+    }
+#endif
+}
+
+static inline void qwtFloorTime( 
+    QwtDate::IntervalType intervalType, QDateTime &dt )
+{
+    // when dt is inside the special hour where DST is ending
+    // an hour is no unique. Therefore we have to
+    // use UTC time.
+
+    const Qt::TimeSpec timeSpec = dt.timeSpec();
+
+    if ( timeSpec == Qt::LocalTime )
+        dt = dt.toTimeSpec( Qt::UTC );
+
+    const QTime t = dt.time();
+    switch( intervalType )
+    {
+        case QwtDate::Second:
+        {
+            dt.setTime( QTime( t.hour(), t.minute(), t.second() ) );
+            break;
+        }
+        case QwtDate::Minute:
+        {
+            dt.setTime( QTime( t.hour(), t.minute(), 0 ) );
+            break;
+        }
+        case QwtDate::Hour:
+        {
+            dt.setTime( QTime( t.hour(), 0, 0 ) );
+            break;
+        }   
+        default:
+            break;
+    }
+
+    if ( timeSpec == Qt::LocalTime )
+        dt = dt.toTimeSpec( Qt::LocalTime );
+}
+
+static inline QDateTime qwtToTimeSpec( 
+    const QDateTime &dt, Qt::TimeSpec spec )
+{
+    if ( dt.timeSpec() == spec )
+        return dt;
+
+    const qint64 jd = dt.date().toJulianDay();
+    if ( jd < 0 || jd >= INT_MAX )
+    {
+        // the conversion between local time and UTC
+        // is internally limited. To avoid
+        // overflows we simply ignore the difference
+        // for those dates
+
+        QDateTime dt2 = dt;
+        dt2.setTimeSpec( spec );
+        return dt2;
+    }
+
+    return dt.toTimeSpec( spec );
+}
+
+static inline double qwtToJulianDay( int year, int month, int day )
+{
+    // code from QDate but using doubles to avoid overflows
+    // for large values
+
+    const int m1 = ( month - 14 ) / 12;
+    const int m2 = ( 367 * ( month - 2 - 12 * m1 ) ) / 12;
+    const double y1 = ::floor( ( 4900.0 + year + m1 ) / 100 );
+
+    return ::floor( ( 1461.0 * ( year + 4800 + m1 ) ) / 4 ) + m2
+            - ::floor( ( 3 * y1 ) / 4 ) + day - 32075;
+}
+
+static inline qint64 qwtFloorDiv64( qint64 a, int b )
+{
+    if ( a < 0 )
+        a -= b - 1;
+
+    return a / b;
+}
+
+static inline qint64 qwtFloorDiv( int a, int b )
+{
+    if ( a < 0 )
+        a -= b - 1;
+        
+    return a / b;
+}   
+
+static inline QDate qwtToDate( int year, int month = 1, int day = 1 )
+{
+#if QT_VERSION >= 0x050000
+    return QDate( year, month, day );
+#else
+    if ( year > 100000 )
+    {
+        // code from QDate but using doubles to avoid overflows
+        // for large values
+
+        const int m1 = ( month - 14 ) / 12;
+        const int m2 = ( 367 * ( month - 2 - 12 * m1 ) ) / 12;
+        const double y1 = ::floor( ( 4900.0 + year + m1 ) / 100 );
+
+        const double jd = ::floor( ( 1461.0 * ( year + 4800 + m1 ) ) / 4 ) + m2
+            - ::floor( ( 3 * y1 ) / 4 ) + day - 32075;
+
+        if ( jd > maxJulianDayD )
+        {
+            qWarning() << "qwtToDate: overflow";
+            return QDate();
+        }
+
+        return QDate::fromJulianDay( static_cast<QwtJulianDay>( jd ) );
+    }
+    else
+    {
+        return QDate( year, month, day );
+    }
+#endif
+}
+
+/*!
+  Translate from double to QDateTime
+
+  \param value Number of milliseconds since the epoch, 
+               1970-01-01T00:00:00 UTC
+  \param timeSpec Time specification
+  \return Datetime value
+
+  \sa toDouble(), QDateTime::setMSecsSinceEpoch()
+  \note The return datetime for Qt::OffsetFromUTC will be Qt::UTC
+ */
+QDateTime QwtDate::toDateTime( double value, Qt::TimeSpec timeSpec )
+{
+    const int msecsPerDay = 86400000;
+
+    const double days = static_cast<qint64>( ::floor( value / msecsPerDay ) );
+
+    const double jd = QwtDate::JulianDayForEpoch + days;
+    if ( ( jd > maxJulianDayD ) || ( jd < minJulianDayD ) )
+    {
+        qWarning() << "QwtDate::toDateTime: overflow";
+        return QDateTime();
+    }
+
+    const QDate d = QDate::fromJulianDay( static_cast<QwtJulianDay>( jd ) );
+
+    const int msecs = static_cast<int>( value - days * msecsPerDay );
+
+    static const QTime timeNull( 0, 0, 0, 0 );
+
+    QDateTime dt( d, timeNull.addMSecs( msecs ), Qt::UTC );
+
+    if ( timeSpec == Qt::LocalTime )
+        dt = qwtToTimeSpec( dt, timeSpec );
+
+    return dt;
+}
+
+/*!
+  Translate from QDateTime to double
+
+  \param dateTime Datetime value
+  \return Number of milliseconds since 1970-01-01T00:00:00 UTC has passed.
+
+  \sa toDateTime(), QDateTime::toMSecsSinceEpoch()
+  \warning For values very far below or above 1970-01-01 UTC rounding errors
+           will happen due to the limited significance of a double.
+ */
+double QwtDate::toDouble( const QDateTime &dateTime )
+{
+    const int msecsPerDay = 86400000;
+
+    const QDateTime dt = qwtToTimeSpec( dateTime, Qt::UTC );
+
+    const double days = dt.date().toJulianDay() - QwtDate::JulianDayForEpoch;
+
+    const QTime time = dt.time();
+    const double secs = 3600.0 * time.hour() + 
+        60.0 * time.minute() + time.second();
+
+    return days * msecsPerDay + time.msec() + 1000.0 * secs;
+}
+
+/*!
+  Ceil a datetime according the interval type
+
+  \param dateTime Datetime value
+  \param intervalType Interval type, how to ceil. 
+                      F.e. when intervalType = QwtDate::Months, the result
+                      will be ceiled to the next beginning of a month
+  \return Ceiled datetime
+  \sa floor()
+ */
+QDateTime QwtDate::ceil( const QDateTime &dateTime, IntervalType intervalType )
+{
+    if ( dateTime.date() >= QwtDate::maxDate() )
+        return dateTime;
+
+    QDateTime dt = dateTime;
+
+    switch ( intervalType )
+    {
+        case QwtDate::Millisecond:
+        {
+            break;
+        }
+        case QwtDate::Second:
+        {
+            qwtFloorTime( QwtDate::Second, dt );
+            if ( dt < dateTime )
+                dt = dt.addSecs( 1 );
+
+            break;
+        }
+        case QwtDate::Minute:
+        {
+            qwtFloorTime( QwtDate::Minute, dt );
+            if ( dt < dateTime )
+                dt = dt.addSecs( 60 );
+
+            break;
+        }
+        case QwtDate::Hour:
+        {
+            qwtFloorTime( QwtDate::Hour, dt );
+            if ( dt < dateTime )
+                dt = dt.addSecs( 3600 );
+
+            break;
+        }
+        case QwtDate::Day:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+            if ( dt < dateTime )
+                dt = dt.addDays( 1 );
+
+            break;
+        }
+        case QwtDate::Week:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+            if ( dt < dateTime )
+                dt = dt.addDays( 1 );
+
+            int days = qwtFirstDayOfWeek() - dt.date().dayOfWeek();
+            if ( days < 0 )
+                days += 7;
+
+            dt = dt.addDays( days );
+
+            break;
+        }
+        case QwtDate::Month:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+            dt.setDate( qwtToDate( dateTime.date().year(), 
+                dateTime.date().month() ) );
+
+            if ( dt < dateTime )
+                dt = dt.addMonths( 1 );
+
+            break;
+        }
+        case QwtDate::Year:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+
+            const QDate d = dateTime.date();
+
+            int year = d.year();
+            if ( d.month() > 1 || d.day() > 1 || !dateTime.time().isNull() )
+                year++;
+
+            if ( year == 0 )
+                year++; // there is no year 0
+
+            dt.setDate( qwtToDate( year ) );
+            break;
+        }
+    }
+
+    return dt;
+}
+
+/*!
+  Floor a datetime according the interval type
+
+  \param dateTime Datetime value
+  \param intervalType Interval type, how to ceil. 
+                      F.e. when intervalType = QwtDate::Months,
+                      the result will be ceiled to the next 
+                      beginning of a month
+  \return Floored datetime
+  \sa floor()
+ */
+QDateTime QwtDate::floor( const QDateTime &dateTime, 
+    IntervalType intervalType )
+{
+    if ( dateTime.date() <= QwtDate::minDate() )
+        return dateTime;
+
+    QDateTime dt = dateTime;
+
+    switch ( intervalType )
+    {
+        case QwtDate::Millisecond:
+        {
+            break;
+        }
+        case QwtDate::Second:
+        case QwtDate::Minute:
+        case QwtDate::Hour:
+        {
+            qwtFloorTime( intervalType, dt );
+            break;
+        }
+        case QwtDate::Day:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+            break;
+        }
+        case QwtDate::Week:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+
+            int days = dt.date().dayOfWeek() - qwtFirstDayOfWeek();
+            if ( days < 0 )
+                days += 7;
+
+            dt = dt.addDays( -days );
+
+            break;
+        }
+        case QwtDate::Month:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+
+            const QDate date = qwtToDate( dt.date().year(), 
+                dt.date().month() );
+            dt.setDate( date );
+
+            break;
+        }
+        case QwtDate::Year:
+        {
+            dt.setTime( QTime( 0, 0 ) );
+
+            const QDate date = qwtToDate( dt.date().year() );
+            dt.setDate( date );
+
+            break;
+        }
+    }
+
+    return dt;
+}
+
+/*!
+  Minimum for the supported date range
+
+  The range of valid dates depends on how QDate stores the 
+  Julian day internally.
+
+  - For Qt4 it is "Tue Jan 2 -4713"
+  - For Qt5 it is "Thu Jan 1 -2147483648"
+
+  \return minimum of the date range
+  \sa maxDate()
+ */
+QDate QwtDate::minDate()
+{
+    static QDate date;
+    if ( !date.isValid() )
+        date = QDate::fromJulianDay( minJulianDayD );
+
+    return date;
+}
+
+/*!
+  Maximum for the supported date range
+
+  The range of valid dates depends on how QDate stores the 
+  Julian day internally.
+
+  - For Qt4 it is "Tue Jun 3 5874898"
+  - For Qt5 it is "Tue Dec 31 2147483647"
+
+  \return maximum of the date range
+  \sa minDate()
+  \note The maximum differs between Qt4 and Qt5
+ */
+QDate QwtDate::maxDate()
+{
+    static QDate date;
+    if ( !date.isValid() )
+        date = QDate::fromJulianDay( maxJulianDayD );
+
+    return date;
+}
+
+/*!
+  \brief Date of the first day of the first week for a year
+
+  The first day of a week depends on the current locale
+  ( QLocale::firstDayOfWeek() ). 
+
+  \param year Year
+  \param type Option how to identify the first week
+  \return First day of week 0
+
+  \sa QLocale::firstDayOfWeek(), weekNumber()
+ */ 
+QDate QwtDate::dateOfWeek0( int year, Week0Type type )
+{
+    const Qt::DayOfWeek firstDayOfWeek = qwtFirstDayOfWeek();
+
+    QDate dt0( year, 1, 1 );
+
+    // floor to the first day of the week
+    int days = dt0.dayOfWeek() - firstDayOfWeek;
+    if ( days < 0 )
+        days += 7;
+
+    dt0 = dt0.addDays( -days );
+
+    if ( type == QwtDate::FirstThursday )
+    {
+        // according to ISO 8601 the first week is defined
+        // by the first thursday. 
+
+        int d = Qt::Thursday - firstDayOfWeek;
+        if ( d < 0 )
+            d += 7;
+
+        if ( dt0.addDays( d ).year() < year )
+            dt0 = dt0.addDays( 7 );
+    }
+
+    return dt0;
+}
+
+/*!
+  Find the week number of a date
+
+  - QwtDate::FirstThursday\n
+    Corresponding to ISO 8601 ( see QDate::weekNumber() ). 
+
+  - QwtDate::FirstDay\n
+    Number of weeks that have begun since dateOfWeek0().
+
+  \param date Date
+  \param type Option how to identify the first week
+
+  \return Week number, starting with 1
+ */
+int QwtDate::weekNumber( const QDate &date, Week0Type type )
+{
+    int weekNo;
+
+    if ( type == QwtDate::FirstDay )
+    {
+        QDate day0;
+
+        if ( date.month() == 12 && date.day() >= 24 )
+        {
+            // week 1 usually starts in the previous years.
+            // and we have to check if we are already there
+
+            day0 = dateOfWeek0( date.year() + 1, type );
+            if ( day0.daysTo( date ) < 0 )
+                day0 = dateOfWeek0( date.year(), type );
+        }
+        else
+        {
+            day0 = dateOfWeek0( date.year(), type );
+        }
+
+        weekNo = day0.daysTo( date ) / 7 + 1;
+    }
+    else
+    {
+        weekNo = date.weekNumber();
+    }
+
+    return weekNo;
+}
+
+/*!
+   Offset in seconds from Coordinated Universal Time
+
+   The offset depends on the time specification of dateTime:
+
+   - Qt::UTC
+     0, dateTime has no offset
+   - Qt::OffsetFromUTC
+     returns dateTime.utcOffset()
+   - Qt::LocalTime:
+     number of seconds from the UTC
+
+   For Qt::LocalTime the offset depends on the timezone and
+   daylight savings.
+
+   \param dateTime Datetime value
+   \return Offset in seconds
+ */
+int QwtDate::utcOffset( const QDateTime &dateTime )
+{
+    int seconds = 0;
+
+    switch( dateTime.timeSpec() )
+    {
+        case Qt::UTC:
+        {
+            break;
+        }
+        case Qt::OffsetFromUTC:
+        {
+            seconds = dateTime.utcOffset();
+            break;
+        }
+        default:
+        {
+            const QDateTime dt1( dateTime.date(), dateTime.time(), Qt::UTC );
+            seconds = dateTime.secsTo( dt1 );
+        }
+    }
+
+    return seconds;
+}
+
+/*!
+  Translate a datetime into a string
+
+  Beside the format expressions documented in QDateTime::toString()
+  the following expressions are supported:
+
+  - w\n
+    week number: ( 1 - 53 )
+  - ww\n
+    week number with a leading zero ( 01 - 53 )
+
+  As week 1 usually starts in the previous year a special rule 
+  is applied for formats, where the year is expected to match the
+  week number - even if the date belongs to the previous year.
+
+  \param dateTime Datetime value
+  \param format Format string
+  \param week0Type Specification of week 0
+
+  \return Datetime string
+  \sa QDateTime::toString(), weekNumber(), QwtDateScaleDraw
+ */
+QString QwtDate::toString( const QDateTime &dateTime,
+    const QString & format, Week0Type week0Type )
+{
+    QString fmt = format;
+    if ( fmt.contains( 'w' ) )
+    {
+        fmt = qwtExpandedFormat( fmt, dateTime, week0Type );
+    }
+
+    return dateTime.toString( fmt );
+}
Index: trunk/BNC/qwt/qwt_date.h
===================================================================
--- trunk/BNC/qwt/qwt_date.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_date.h	(revision 8127)
@@ -0,0 +1,128 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef _QWT_DATE_H_
+#define _QWT_DATE_H_
+
+#include "qwt_global.h"
+#include <qdatetime.h>
+
+/*!
+  \brief A collection of methods around date/time values
+
+  Qt offers convenient classes for dealing with date/time values,
+  but Qwt uses coordinate systems that are based on doubles.
+  QwtDate offers methods to translate from QDateTime to double and v.v.
+
+  A double is interpreted as the number of milliseconds since
+  1970-01-01T00:00:00 Universal Coordinated Time - also known
+  as "The Epoch". 
+
+  While the range of the Julian day in Qt4 is limited to [0, MAX_INT], 
+  Qt5 stores it as qint64 offering a huge range of valid dates. 
+  As the significance of a double is below this ( assuming a 
+  fraction of 52 bits ) the translation is not 
+  bijective with rounding errors for dates very far from Epoch. 
+  For a resolution of 1 ms those start to happen for dates above the 
+  year 144683. 
+
+  An axis for a date/time interval is expected to be aligned
+  and divided in time/date units like seconds, minutes, ...
+  QwtDate offers several algorithms that are needed to
+  calculate these axes.
+
+  \sa QwtDateScaleEngine, QwtDateScaleDraw, QDate, QTime
+*/
+class QWT_EXPORT QwtDate
+{
+public:
+    /*! 
+       How to identify the first week of year differs between
+       countries. 
+     */
+    enum Week0Type
+    {
+        /*!
+           According to ISO 8601 the first week of a year is defined
+           as "the week with the year's first Thursday in it".
+
+           FirstThursday corresponds to the numbering that is
+           implemented in QDate::weekNumber().
+        */
+        FirstThursday,
+
+        /*!
+            "The week with January 1.1 in it."
+           
+            In the U.S. this definition is more common than
+            FirstThursday.
+        */
+        FirstDay
+    };
+
+    /*! 
+      Classification of an time interval
+
+      Time intervals needs to be classified to decide how to
+      align and divide it.
+     */
+    enum IntervalType
+    {
+        //! The interval is related to milliseconds
+        Millisecond,
+
+        //! The interval is related to seconds
+        Second,
+
+        //! The interval is related to minutes
+        Minute,
+
+        //! The interval is related to hours
+        Hour,
+
+        //! The interval is related to days
+        Day,
+
+        //! The interval is related to weeks
+        Week,
+
+        //! The interval is related to months
+        Month,
+
+        //! The interval is related to years
+        Year
+    };
+
+    enum
+    {
+        //! The Julian day of "The Epoch"
+        JulianDayForEpoch = 2440588
+    };
+
+    static QDate minDate();
+    static QDate maxDate();
+
+    static QDateTime toDateTime( double value, 
+        Qt::TimeSpec = Qt::UTC );
+
+    static double toDouble( const QDateTime & );
+
+    static QDateTime ceil( const QDateTime &, IntervalType );
+    static QDateTime floor( const QDateTime &, IntervalType );
+
+    static QDate dateOfWeek0( int year, Week0Type );
+    static int weekNumber( const QDate &, Week0Type );
+
+    static int utcOffset( const QDateTime & );
+
+    static QString toString( const QDateTime &, 
+        const QString & format, Week0Type );
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_date_scale_draw.cpp
===================================================================
--- trunk/BNC/qwt/qwt_date_scale_draw.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_date_scale_draw.cpp	(revision 8127)
@@ -0,0 +1,278 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_date_scale_draw.h"
+
+class QwtDateScaleDraw::PrivateData
+{
+public:
+    PrivateData( Qt::TimeSpec spec ):
+        timeSpec( spec ),
+        utcOffset( 0 ),
+        week0Type( QwtDate::FirstThursday )
+    {
+        dateFormats[ QwtDate::Millisecond ] = "hh:mm:ss:zzz\nddd dd MMM yyyy";
+        dateFormats[ QwtDate::Second ] = "hh:mm:ss\nddd dd MMM yyyy";
+        dateFormats[ QwtDate::Minute ] = "hh:mm\nddd dd MMM yyyy";
+        dateFormats[ QwtDate::Hour ] = "hh:mm\nddd dd MMM yyyy";
+        dateFormats[ QwtDate::Day ] = "ddd dd MMM yyyy";
+        dateFormats[ QwtDate::Week ] = "Www yyyy";
+        dateFormats[ QwtDate::Month ] = "MMM yyyy";
+        dateFormats[ QwtDate::Year ] = "yyyy";
+    }
+
+    Qt::TimeSpec timeSpec;
+    int utcOffset;
+    QwtDate::Week0Type week0Type;
+    QString dateFormats[ QwtDate::Year + 1 ];
+};
+
+/*!
+  \brief Constructor
+
+  The default setting is to display tick labels for the 
+  given time specification. The first week of a year is defined like
+  for QwtDate::FirstThursday.
+
+  \param timeSpec Time specification
+
+  \sa setTimeSpec(), setWeek0Type()
+ */
+QwtDateScaleDraw::QwtDateScaleDraw( Qt::TimeSpec timeSpec )
+{
+    d_data = new PrivateData( timeSpec );
+}
+
+//! Destructor
+QwtDateScaleDraw::~QwtDateScaleDraw()
+{
+    delete d_data;
+}
+
+/*!
+  Set the time specification used for the tick labels
+
+  \param timeSpec Time specification
+  \sa timeSpec(), setUtcOffset(), toDateTime()
+ */
+void QwtDateScaleDraw::setTimeSpec( Qt::TimeSpec timeSpec )
+{
+    d_data->timeSpec = timeSpec;
+}
+
+/*!
+  \return Time specification used for the tick labels
+  \sa setTimeSpec(), utcOffset(), toDateTime()
+ */
+Qt::TimeSpec QwtDateScaleDraw::timeSpec() const
+{
+    return d_data->timeSpec;
+}
+
+/*!
+  Set the offset in seconds from Coordinated Universal Time
+
+  \param seconds Offset in seconds
+
+  \note The offset has no effect beside for the time specification
+        Qt::OffsetFromUTC.
+
+  \sa QDate::utcOffset(), setTimeSpec(), toDateTime()
+ */
+void QwtDateScaleDraw::setUtcOffset( int seconds )
+{
+    d_data->utcOffset = seconds;
+}
+
+/*!
+  \return Offset in seconds from Coordinated Universal Time
+  \note The offset has no effect beside for the time specification
+        Qt::OffsetFromUTC.
+
+  \sa QDate::setUtcOffset(), setTimeSpec(), toDateTime()
+ */
+int QwtDateScaleDraw::utcOffset() const
+{
+    return d_data->utcOffset;
+}
+
+/*!
+  Sets how to identify the first week of a year.
+
+  \param week0Type Mode how to identify the first week of a year
+
+  \sa week0Type().
+  \note week0Type has no effect beside for intervals classified as
+        QwtDate::Week. 
+ */
+void QwtDateScaleDraw::setWeek0Type( QwtDate::Week0Type week0Type )
+{
+    d_data->week0Type = week0Type;
+}
+
+/*!
+  \return Setting how to identify the first week of a year. 
+  \sa setWeek0Type()
+ */
+QwtDate::Week0Type QwtDateScaleDraw::week0Type() const
+{
+    return d_data->week0Type;
+}
+
+/*!
+  Set the default format string for an datetime interval type
+
+  \param intervalType Interval type
+  \param format Default format string
+
+  \sa dateFormat(), dateFormatOfDate(), QwtDate::toString()
+ */
+void QwtDateScaleDraw::setDateFormat( 
+    QwtDate::IntervalType intervalType, const QString &format )
+{
+    if ( intervalType >= QwtDate::Millisecond && 
+        intervalType <= QwtDate::Year )
+    {
+        d_data->dateFormats[ intervalType ] = format;
+    }
+}
+
+/*!
+  \param intervalType Interval type
+  \return Default format string for an datetime interval type
+  \sa setDateFormat(), dateFormatOfDate()
+ */
+QString QwtDateScaleDraw::dateFormat( 
+    QwtDate::IntervalType intervalType ) const
+{
+    if ( intervalType >= QwtDate::Millisecond && 
+        intervalType <= QwtDate::Year )
+    {
+        return d_data->dateFormats[ intervalType ];
+    }
+
+    return QString::null;
+}
+
+/*!
+  Format string for the representation of a datetime
+
+  dateFormatOfDate() is intended to be overloaded for
+  situations, where formats are individual for specific
+  datetime values.
+
+  The default setting ignores dateTime and return
+  the default format for the interval type.
+
+  \param dateTime Datetime value
+  \param intervalType Interval type
+  \return Format string
+
+  \sa setDateFormat(), QwtDate::toString()
+ */
+QString QwtDateScaleDraw::dateFormatOfDate( const QDateTime &dateTime,
+    QwtDate::IntervalType intervalType ) const
+{
+    Q_UNUSED( dateTime )
+
+    if ( intervalType >= QwtDate::Millisecond && 
+        intervalType <= QwtDate::Year )
+    {
+        return d_data->dateFormats[ intervalType ];
+    }
+
+    return d_data->dateFormats[ QwtDate::Second ];
+}
+
+/*!
+  \brief Convert a value into its representing label
+
+  The value is converted to a datetime value using toDateTime()
+  and converted to a plain text using QwtDate::toString().
+
+  \param value Value
+  \return Label string.
+
+  \sa dateFormatOfDate()
+*/
+QwtText QwtDateScaleDraw::label( double value ) const
+{
+    const QDateTime dt = toDateTime( value );
+    const QString fmt = dateFormatOfDate( 
+        dt, intervalType( scaleDiv() ) );
+
+    return QwtDate::toString( dt, fmt, d_data->week0Type );
+}
+
+/*!
+  Find the less detailed datetime unit, where no rounding
+  errors happen.
+
+  \param scaleDiv Scale division
+  \return Interval type
+
+  \sa dateFormatOfDate()
+ */
+QwtDate::IntervalType QwtDateScaleDraw::intervalType( 
+    const QwtScaleDiv &scaleDiv ) const
+{
+    int intvType = QwtDate::Year;
+
+    bool alignedToWeeks = true;
+
+    const QList<double> ticks = scaleDiv.ticks( QwtScaleDiv::MajorTick );
+    for ( int i = 0; i < ticks.size(); i++ )
+    {
+        const QDateTime dt = toDateTime( ticks[i] );
+        for ( int j = QwtDate::Second; j <= intvType; j++ )
+        {
+            const QDateTime dt0 = QwtDate::floor( dt, 
+                static_cast<QwtDate::IntervalType>( j ) );
+
+            if ( dt0 != dt )
+            {
+                if ( j == QwtDate::Week )
+                {
+                    alignedToWeeks = false;
+                }
+                else
+                {
+                    intvType = j - 1;
+                    break;
+                }
+            }
+        }
+
+        if ( intvType == QwtDate::Millisecond )
+            break;
+    }
+
+    if ( intvType == QwtDate::Week && !alignedToWeeks )
+        intvType = QwtDate::Day;
+
+    return static_cast<QwtDate::IntervalType>( intvType );
+}
+
+/*!
+  Translate a double value into a QDateTime object.
+
+  \return QDateTime object initialized with timeSpec() and utcOffset().
+  \sa timeSpec(), utcOffset(), QwtDate::toDateTime()
+ */
+QDateTime QwtDateScaleDraw::toDateTime( double value ) const
+{
+    QDateTime dt = QwtDate::toDateTime( value, d_data->timeSpec );
+    if ( d_data->timeSpec == Qt::OffsetFromUTC )
+    {
+        dt = dt.addSecs( d_data->utcOffset );
+        dt.setUtcOffset( d_data->utcOffset );
+    }
+
+    return dt;
+}
Index: trunk/BNC/qwt/qwt_date_scale_draw.h
===================================================================
--- trunk/BNC/qwt/qwt_date_scale_draw.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_date_scale_draw.h	(revision 8127)
@@ -0,0 +1,86 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef _QWT_DATE_SCALE_DRAW_H_
+#define _QWT_DATE_SCALE_DRAW_H_ 1
+
+#include "qwt_global.h"
+#include "qwt_scale_draw.h"
+#include "qwt_date.h"
+
+/*!
+  \brief A class for drawing datetime scales
+
+  QwtDateScaleDraw displays values as datetime labels.
+  The format of the labels depends on the alignment of
+  the major tick labels.
+
+  The default format strings are:
+
+  - Millisecond\n
+    "hh:mm:ss:zzz\nddd dd MMM yyyy"
+  - Second\n
+    "hh:mm:ss\nddd dd MMM yyyy"
+  - Minute\n
+    "hh:mm\nddd dd MMM yyyy"
+  - Hour\n
+    "hh:mm\nddd dd MMM yyyy"
+  - Day\n
+    "ddd dd MMM yyyy"
+  - Week\n
+    "Www yyyy"
+  - Month\n
+    "MMM yyyy"
+  - Year\n
+    "yyyy"
+
+  The format strings can be modified using setDateFormat()
+  or individually for each tick label by overloading dateFormatOfDate(),
+
+  Usually QwtDateScaleDraw is used in combination with
+  QwtDateScaleEngine, that calculates scales for datetime
+  intervals.
+
+  \sa QwtDateScaleEngine, QwtPlot::setAxisScaleDraw()
+*/
+class QWT_EXPORT QwtDateScaleDraw: public QwtScaleDraw
+{
+public:
+    QwtDateScaleDraw( Qt::TimeSpec = Qt::LocalTime );
+    virtual ~QwtDateScaleDraw();
+
+    void setDateFormat( QwtDate::IntervalType, const QString & );
+    QString dateFormat( QwtDate::IntervalType ) const;
+
+    void setTimeSpec( Qt::TimeSpec );
+    Qt::TimeSpec timeSpec() const;
+
+    void setUtcOffset( int seconds );
+    int utcOffset() const;
+
+    void setWeek0Type( QwtDate::Week0Type );
+    QwtDate::Week0Type week0Type() const;
+
+    virtual QwtText label( double ) const;
+
+    QDateTime toDateTime( double ) const;
+
+protected:
+    virtual QwtDate::IntervalType 
+        intervalType( const QwtScaleDiv & ) const;
+
+    virtual QString dateFormatOfDate( const QDateTime &,
+        QwtDate::IntervalType ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_date_scale_engine.cpp
===================================================================
--- trunk/BNC/qwt/qwt_date_scale_engine.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_date_scale_engine.cpp	(revision 8127)
@@ -0,0 +1,1309 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_date_scale_engine.h"
+#include "qwt_math.h"
+#include "qwt_transform.h"
+#include <qdatetime.h>
+#include <limits.h>
+
+static inline double qwtMsecsForType( QwtDate::IntervalType type )
+{
+    static const double msecs[] =
+    {
+        1.0,
+        1000.0,
+        60.0 * 1000.0,
+        3600.0 * 1000.0,
+        24.0 * 3600.0 * 1000.0,
+        7.0 * 24.0 * 3600.0 * 1000.0,
+        30.0 * 24.0 * 3600.0 * 1000.0,
+        365.0 * 24.0 * 3600.0 * 1000.0,
+    };
+
+    if ( type < 0 || type >= static_cast<int>( sizeof( msecs ) / sizeof( msecs[0] ) ) )
+        return 1.0;
+
+    return msecs[ type ];
+}
+
+static inline int qwtAlignValue(
+    double value, double stepSize, bool up )
+{
+    double d = value / stepSize;
+    d = up ? ::ceil( d ) : ::floor( d );
+
+    return static_cast<int>( d * stepSize );
+}
+
+static double qwtIntervalWidth( const QDateTime &minDate,
+    const QDateTime &maxDate, QwtDate::IntervalType intervalType ) 
+{
+    switch( intervalType )
+    {
+        case QwtDate::Millisecond:
+        {
+            const double secsTo = minDate.secsTo( maxDate );
+            const double msecs = maxDate.time().msec() -
+                minDate.time().msec();
+
+            return secsTo * 1000 + msecs;
+        }
+        case QwtDate::Second:
+        {
+            return minDate.secsTo( maxDate );
+        }
+        case QwtDate::Minute:
+        {
+            const double secsTo = minDate.secsTo( maxDate );
+            return ::floor( secsTo / 60 );
+        }
+        case QwtDate::Hour:
+        {
+            const double secsTo = minDate.secsTo( maxDate );
+            return ::floor( secsTo / 3600 );
+        }
+        case QwtDate::Day:
+        {
+            return minDate.daysTo( maxDate );
+        }
+        case QwtDate::Week:
+        {
+            return ::floor( minDate.daysTo( maxDate ) / 7.0 );
+        }
+        case QwtDate::Month:
+        {
+            const double years = 
+                double( maxDate.date().year() ) - minDate.date().year();
+
+            int months = maxDate.date().month() - minDate.date().month();
+            if ( maxDate.date().day() < minDate.date().day() )
+                months--;
+
+            return years * 12 + months;
+        }
+        case QwtDate::Year:
+        {
+            double years = 
+                double( maxDate.date().year() ) - minDate.date().year();
+
+            if ( maxDate.date().month() < minDate.date().month() )
+                years -= 1.0;
+
+            return years;
+        }
+    }
+
+    return 0.0;
+}
+
+static double qwtRoundedIntervalWidth( 
+    const QDateTime &minDate, const QDateTime &maxDate, 
+    QwtDate::IntervalType intervalType ) 
+{
+    const QDateTime minD = QwtDate::floor( minDate, intervalType );
+    const QDateTime maxD = QwtDate::ceil( maxDate, intervalType );
+
+    return qwtIntervalWidth( minD, maxD, intervalType );
+}
+
+static inline int qwtStepCount( int intervalSize, int maxSteps,
+    const int limits[], size_t numLimits )
+{
+    for ( uint i = 0; i < numLimits; i++ )
+    {
+        const int numSteps = intervalSize / limits[ i ];
+
+        if ( numSteps > 1 && numSteps <= maxSteps &&
+            numSteps * limits[ i ] == intervalSize )
+        {
+            return numSteps;
+        }
+    }
+
+    return 0;
+}
+
+static int qwtStepSize( int intervalSize, int maxSteps, uint base ) 
+{
+    if ( maxSteps <= 0 )
+        return 0;
+
+    if ( maxSteps > 2 )
+    {
+        for ( int numSteps = maxSteps; numSteps > 1; numSteps-- )
+        {
+            const double stepSize = double( intervalSize ) / numSteps;
+
+            const double p = ::floor( ::log( stepSize ) / ::log( double( base ) ) );
+            const double fraction = qPow( base, p );
+
+            for ( uint n = base; n >= 1; n /= 2 )
+            {
+                if ( qFuzzyCompare( stepSize, n * fraction ) )
+                    return qRound( stepSize );
+
+                if ( n == 3 && ( base % 2 ) == 0 )
+                {
+                    if ( qFuzzyCompare( stepSize, 2 * fraction ) )
+                        return qRound( stepSize );
+                }
+            }
+        }
+    }
+
+    return 0;
+}
+
+static int qwtDivideInterval( double intervalSize, int numSteps, 
+    const int limits[], size_t numLimits )
+{
+    const int v = qCeil( intervalSize / double( numSteps ) );
+
+    for ( uint i = 0; i < numLimits - 1; i++ )
+    {
+        if ( v <= limits[i] )
+            return limits[i];
+    }
+
+    return limits[ numLimits - 1 ];
+}
+
+static double qwtDivideScale( double intervalSize, int numSteps,
+    QwtDate::IntervalType intervalType )
+{
+    if ( intervalType != QwtDate::Day )
+    {
+        if ( ( intervalSize > numSteps ) && 
+            ( intervalSize <= 2 * numSteps ) )
+        {
+            return 2.0;
+        }
+    }
+
+    double stepSize;
+
+    switch( intervalType )
+    {
+        case QwtDate::Second:
+        case QwtDate::Minute:
+        {
+            static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 };
+    
+            stepSize = qwtDivideInterval( intervalSize, numSteps,
+                limits, sizeof( limits ) / sizeof( int ) );
+
+            break;
+        }
+        case QwtDate::Hour:
+        {
+            static int limits[] = { 1, 2, 3, 4, 6, 12, 24 };
+    
+            stepSize = qwtDivideInterval( intervalSize, numSteps,
+                limits, sizeof( limits ) / sizeof( int ) );
+
+            break;
+        }
+        case QwtDate::Day:
+        {
+            const double v = intervalSize / double( numSteps );
+            if ( v <= 5.0 )
+                stepSize = qCeil( v );
+            else
+                stepSize = qCeil( v / 7 ) * 7;
+
+            break;
+        }
+        case QwtDate::Week:
+        {
+            static int limits[] = { 1, 2, 4, 8, 12, 26, 52 };
+
+            stepSize = qwtDivideInterval( intervalSize, numSteps,
+                limits, sizeof( limits ) / sizeof( int ) );
+
+            break;
+        }
+        case QwtDate::Month:
+        {
+            static int limits[] = { 1, 2, 3, 4, 6, 12 };
+
+            stepSize = qwtDivideInterval( intervalSize, numSteps,
+                limits, sizeof( limits ) / sizeof( int ) );
+
+            break;
+        }
+        case QwtDate::Year:
+        case QwtDate::Millisecond:
+        default:
+        {
+            stepSize = QwtScaleArithmetic::divideInterval(
+                intervalSize, numSteps, 10 );
+        }
+    }
+
+    return stepSize;
+}
+
+static double qwtDivideMajorStep( double stepSize, int maxMinSteps,
+    QwtDate::IntervalType intervalType )
+{
+    double minStepSize = 0.0;
+
+    switch( intervalType )
+    {
+        case QwtDate::Second:
+        {
+            minStepSize = qwtStepSize( stepSize, maxMinSteps, 10 );
+            if ( minStepSize == 0.0 )
+                minStepSize = 0.5 * stepSize;
+
+            break;
+        }
+        case QwtDate::Minute:
+        {
+            static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 };
+
+            int numSteps;
+
+            if ( stepSize > maxMinSteps )
+            {
+                numSteps = qwtStepCount( stepSize, maxMinSteps, 
+                    limits, sizeof( limits ) / sizeof( int ) );
+
+            }
+            else
+            {
+                numSteps = qwtStepCount( stepSize * 60, maxMinSteps, 
+                    limits, sizeof( limits ) / sizeof( int ) );
+            }
+
+            if ( numSteps > 0 )
+                minStepSize = double( stepSize ) / numSteps;
+
+            break;
+        }
+        case QwtDate::Hour:
+        {
+            int numSteps = 0;
+
+            if ( stepSize > maxMinSteps )
+            {
+                static int limits[] = { 1, 2, 3, 4, 6, 12, 24, 48, 72 };
+
+                numSteps = qwtStepCount( stepSize, maxMinSteps,
+                    limits, sizeof( limits ) / sizeof( int ) );
+            }
+            else
+            {
+                static int limits[] = { 1, 2, 5, 10, 15, 20, 30, 60 };
+
+                numSteps = qwtStepCount( stepSize * 60, maxMinSteps,
+                    limits, sizeof( limits ) / sizeof( int ) );
+            }
+
+            if ( numSteps > 0 )
+                minStepSize = double( stepSize ) / numSteps;
+
+            break;
+        }
+        case QwtDate::Day:
+        {
+            int numSteps = 0;
+
+            if ( stepSize > maxMinSteps )
+            {
+                static int limits[] = { 1, 2, 3, 7, 14, 28 };
+
+                numSteps = qwtStepCount( stepSize, maxMinSteps,
+                    limits, sizeof( limits ) / sizeof( int ) );
+            }
+            else
+            {
+                static int limits[] = { 1, 2, 3, 4, 6, 12, 24, 48, 72 };
+
+                numSteps = qwtStepCount( stepSize * 24, maxMinSteps,
+                    limits, sizeof( limits ) / sizeof( int ) );
+            }
+
+            if ( numSteps > 0 )
+                minStepSize = double( stepSize ) / numSteps;
+
+            break;
+        }
+        case QwtDate::Week:
+        {
+            const int daysInStep = stepSize * 7;
+
+            if ( maxMinSteps >= daysInStep )
+            {
+                // we want to have one tick per day
+                minStepSize = 1.0 / 7.0;
+            }
+            else
+            {
+                // when the stepSize is more than a week we want to
+                // have a tick for each week
+
+                const int stepSizeInWeeks = stepSize;
+
+                if ( stepSizeInWeeks <= maxMinSteps )
+                {
+                    minStepSize = 1;
+                }
+                else
+                {
+                    minStepSize = QwtScaleArithmetic::divideInterval( 
+                        stepSizeInWeeks, maxMinSteps, 10 );
+                }
+            }
+            break;
+        }
+        case QwtDate::Month:
+        {
+            // fractions of months doesn't make any sense
+
+            if ( stepSize < maxMinSteps )
+                maxMinSteps = static_cast<int>( stepSize );
+
+            static int limits[] = { 1, 2, 3, 4, 6, 12 };
+
+            int numSteps = qwtStepCount( stepSize, maxMinSteps,
+                limits, sizeof( limits ) / sizeof( int ) );
+
+            if ( numSteps > 0 )
+                minStepSize = double( stepSize ) / numSteps;
+
+            break;
+        }
+        case QwtDate::Year:
+        {
+            if ( stepSize >= maxMinSteps )
+            {
+                minStepSize = QwtScaleArithmetic::divideInterval(
+                    stepSize, maxMinSteps, 10 );
+            }
+            else
+            {
+                // something in months
+
+                static int limits[] = { 1, 2, 3, 4, 6, 12 };
+
+                int numSteps = qwtStepCount( 12 * stepSize, maxMinSteps,
+                    limits, sizeof( limits ) / sizeof( int ) );
+
+                if ( numSteps > 0 )
+                    minStepSize = double( stepSize ) / numSteps;
+            }
+                
+            break;
+        }
+        default:
+            break;
+    }
+
+    if ( intervalType != QwtDate::Month
+        && minStepSize == 0.0 )
+    {
+        minStepSize = 0.5 * stepSize;
+    }
+
+    return minStepSize;
+}
+
+static QList<double> qwtDstTicks( const QDateTime &dateTime,
+    int secondsMajor, int secondsMinor )
+{
+    if ( secondsMinor <= 0 )
+        QList<double>();
+
+    QDateTime minDate = dateTime.addSecs( -secondsMajor );
+    minDate = QwtDate::floor( minDate, QwtDate::Hour );
+
+    const double utcOffset = QwtDate::utcOffset( dateTime );
+
+    // find the hours where daylight saving time happens
+
+    double dstMin = QwtDate::toDouble( minDate );
+    while ( minDate < dateTime &&
+        QwtDate::utcOffset( minDate ) != utcOffset )
+    {
+        minDate = minDate.addSecs( 3600 );
+        dstMin += 3600 * 1000.0;
+    }
+
+    QList<double> ticks;
+    for ( int i = 0; i < 3600; i += secondsMinor )
+        ticks += dstMin + i * 1000.0;
+
+    return ticks;
+}
+
+static QwtScaleDiv qwtDivideToSeconds( 
+    const QDateTime &minDate, const QDateTime &maxDate,
+    double stepSize, int maxMinSteps,
+    QwtDate::IntervalType intervalType ) 
+{
+    // calculate the min step size
+    double minStepSize = 0;
+
+    if ( maxMinSteps > 1 ) 
+    {
+        minStepSize = qwtDivideMajorStep( stepSize, 
+            maxMinSteps, intervalType );
+    }
+
+    bool daylightSaving = false;
+    if ( minDate.timeSpec() == Qt::LocalTime )
+    {
+        daylightSaving = intervalType > QwtDate::Hour;
+        if ( intervalType == QwtDate::Hour )
+        {
+            daylightSaving = stepSize > 1;
+        }
+    }
+
+    const double s = qwtMsecsForType( intervalType ) / 1000;
+    const int secondsMajor = static_cast<int>( stepSize * s );
+    const double secondsMinor = minStepSize * s;
+    
+    // UTC excludes daylight savings. So from the difference
+    // of a date and its UTC counterpart we can find out
+    // the daylight saving hours
+
+    const double utcOffset = QwtDate::utcOffset( minDate );
+    double dstOff = 0;
+
+    QList<double> majorTicks;
+    QList<double> mediumTicks;
+    QList<double> minorTicks;
+
+    for ( QDateTime dt = minDate; dt <= maxDate; 
+        dt = dt.addSecs( secondsMajor ) )
+    {
+        if ( !dt.isValid() )
+            break;
+
+        double majorValue = QwtDate::toDouble( dt );
+
+        if ( daylightSaving )
+        {
+            const double offset = utcOffset - QwtDate::utcOffset( dt );
+            majorValue += offset * 1000.0;
+
+            if ( offset > dstOff )
+            {
+                // we add some minor ticks for the DST hour,
+                // otherwise the ticks will be unaligned: 0, 2, 3, 5 ...
+                minorTicks += qwtDstTicks( 
+                    dt, secondsMajor, qRound( secondsMinor ) );
+            }
+
+            dstOff = offset;
+        }
+
+        if ( majorTicks.isEmpty() || majorTicks.last() != majorValue )
+            majorTicks += majorValue;
+
+        if ( secondsMinor > 0.0 )
+        {
+            const int numMinorSteps = qFloor( secondsMajor / secondsMinor );
+
+            for ( int i = 1; i < numMinorSteps; i++ )
+            {
+                const QDateTime mt = dt.addMSecs( 
+                    qRound64( i * secondsMinor * 1000 ) );
+
+                double minorValue = QwtDate::toDouble( mt );
+                if ( daylightSaving )
+                {
+                    const double offset = utcOffset - QwtDate::utcOffset( mt );
+                    minorValue += offset * 1000.0;
+                }
+
+                if ( minorTicks.isEmpty() || minorTicks.last() != minorValue )
+                {
+                    const bool isMedium = ( numMinorSteps % 2 == 0 ) 
+                        && ( i != 1 ) && ( i == numMinorSteps / 2 );
+
+                    if ( isMedium )
+                        mediumTicks += minorValue;
+                    else
+                        minorTicks += minorValue;
+                }
+            }
+        }
+    }
+
+    QwtScaleDiv scaleDiv;
+
+    scaleDiv.setInterval( QwtDate::toDouble( minDate ),
+        QwtDate::toDouble( maxDate ) );
+
+    scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
+
+    return scaleDiv;
+}
+
+static QwtScaleDiv qwtDivideToMonths( 
+    QDateTime &minDate, const QDateTime &maxDate,
+    double stepSize, int maxMinSteps ) 
+{
+    // months are intervals with non 
+    // equidistant ( in ms ) steps: we have to build the 
+    // scale division manually
+
+    int minStepDays = 0;
+    int minStepSize = 0.0; 
+
+    if ( maxMinSteps > 1 )
+    {
+        if ( stepSize == 1 )
+        {
+            if ( maxMinSteps >= 30 )
+                minStepDays = 1;
+            else if ( maxMinSteps >= 6 )
+                minStepDays = 5;
+            else if ( maxMinSteps >= 3 )
+                minStepDays = 10;
+            else
+                minStepDays = 15;
+        }
+        else
+        {
+            minStepSize = qwtDivideMajorStep( 
+                stepSize, maxMinSteps, QwtDate::Month );
+        }
+    }
+
+    QList<double> majorTicks;
+    QList<double> mediumTicks;
+    QList<double> minorTicks;
+
+    for ( QDateTime dt = minDate; 
+        dt <= maxDate; dt = dt.addMonths( stepSize ) )
+    {
+        if ( !dt.isValid() )
+            break;
+
+        majorTicks += QwtDate::toDouble( dt );
+
+        if ( minStepDays > 0 )
+        {
+            for ( int days = minStepDays; 
+                days < 30; days += minStepDays )
+            {
+                const double tick = QwtDate::toDouble( dt.addDays( days ) );
+
+                if ( days == 15 && minStepDays != 15 )
+                    mediumTicks += tick;
+                else
+                    minorTicks += tick;
+            }
+        }
+        else if ( minStepSize > 0.0 )
+        {
+            const int numMinorSteps = qRound( stepSize / (double) minStepSize );
+
+            for ( int i = 1; i < numMinorSteps; i++ )
+            {
+                const double minorValue =
+                    QwtDate::toDouble( dt.addMonths( i * minStepSize ) );
+
+                if ( ( numMinorSteps % 2 == 0 ) && ( i == numMinorSteps / 2 ) )
+                    mediumTicks += minorValue;
+                else
+                    minorTicks += minorValue;
+            }
+        }
+    }
+
+    QwtScaleDiv scaleDiv;
+    scaleDiv.setInterval( QwtDate::toDouble( minDate ),
+        QwtDate::toDouble( maxDate ) );
+
+    scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
+
+    return scaleDiv;
+}
+
+static QwtScaleDiv qwtDivideToYears( 
+    const QDateTime &minDate, const QDateTime &maxDate,
+    double stepSize, int maxMinSteps ) 
+{
+    QList<double> majorTicks;
+    QList<double> mediumTicks;
+    QList<double> minorTicks;
+
+    double minStepSize = 0.0;
+
+    if ( maxMinSteps > 1 )
+    {
+        minStepSize = qwtDivideMajorStep( 
+            stepSize, maxMinSteps, QwtDate::Year );
+    }
+
+    int numMinorSteps = 0;
+    if ( minStepSize > 0.0 )
+        numMinorSteps = qFloor( stepSize / minStepSize );
+
+    bool dateBC = minDate.date().year() < -1;
+
+    for ( QDateTime dt = minDate; dt <= maxDate;
+        dt = dt.addYears( stepSize ) )
+    {
+        if ( dateBC && dt.date().year() > 1 )
+        {
+            // there is no year 0 in the Julian calendar
+            dt = dt.addYears( -1 );
+            dateBC = false;
+        }
+
+        if ( !dt.isValid() )
+            break;
+
+        majorTicks += QwtDate::toDouble( dt );
+
+        for ( int i = 1; i < numMinorSteps; i++ )
+        {
+            QDateTime tickDate;
+
+            const double years = qRound( i * minStepSize );
+            if ( years >= INT_MAX / 12 )
+            {
+                tickDate = dt.addYears( years );
+            }
+            else
+            {
+                tickDate = dt.addMonths( qRound( years * 12 ) );
+            }
+
+            const bool isMedium = ( numMinorSteps > 2 ) &&
+                ( numMinorSteps % 2 == 0 ) && ( i == numMinorSteps / 2 );
+
+            const double minorValue = QwtDate::toDouble( tickDate );
+            if ( isMedium )
+                mediumTicks += minorValue;
+            else
+                minorTicks += minorValue;
+        }
+
+        if ( QwtDate::maxDate().addYears( -stepSize ) < dt.date() )
+        {
+            break;
+        }
+    }   
+
+    QwtScaleDiv scaleDiv;
+    scaleDiv.setInterval( QwtDate::toDouble( minDate ),
+        QwtDate::toDouble( maxDate ) );
+
+    scaleDiv.setTicks( QwtScaleDiv::MajorTick, majorTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MediumTick, mediumTicks );
+    scaleDiv.setTicks( QwtScaleDiv::MinorTick, minorTicks );
+
+    return scaleDiv;
+}
+
+class QwtDateScaleEngine::PrivateData
+{
+public:
+    PrivateData( Qt::TimeSpec spec ):
+        timeSpec( spec ),
+        utcOffset( 0 ),
+        week0Type( QwtDate::FirstThursday ),
+        maxWeeks( 4 )
+    {
+    }
+
+    Qt::TimeSpec timeSpec;
+    int utcOffset;
+    QwtDate::Week0Type week0Type;
+    int maxWeeks;
+};      
+
+
+/*!
+  \brief Constructor
+
+  The engine is initialized to build scales for the 
+  given time specification. It classifies intervals > 4 weeks
+  as >= Qt::Month. The first week of a year is defined like
+  for QwtDate::FirstThursday.
+
+  \param timeSpec Time specification
+
+  \sa setTimeSpec(), setMaxWeeks(), setWeek0Type()
+ */
+QwtDateScaleEngine::QwtDateScaleEngine( Qt::TimeSpec timeSpec ):
+    QwtLinearScaleEngine( 10 )
+{
+    d_data = new PrivateData( timeSpec );
+}
+
+//! Destructor
+QwtDateScaleEngine::~QwtDateScaleEngine()
+{
+    delete d_data;
+}
+
+/*!
+  Set the time specification used by the engine
+
+  \param timeSpec Time specification
+  \sa timeSpec(), setUtcOffset(), toDateTime()
+ */
+void QwtDateScaleEngine::setTimeSpec( Qt::TimeSpec timeSpec )
+{
+    d_data->timeSpec = timeSpec;
+}
+
+/*!
+  \return Time specification used by the engine
+  \sa setTimeSpec(), utcOffset(), toDateTime()
+ */
+Qt::TimeSpec QwtDateScaleEngine::timeSpec() const
+{
+    return d_data->timeSpec;
+}
+
+/*!
+  Set the offset in seconds from Coordinated Universal Time
+
+  \param seconds Offset in seconds
+
+  \note The offset has no effect beside for the time specification
+        Qt::OffsetFromUTC.
+
+  \sa QDate::utcOffset(), setTimeSpec(), toDateTime()
+ */
+void QwtDateScaleEngine::setUtcOffset( int seconds )
+{
+    d_data->utcOffset = seconds;
+}
+
+/*!
+  \return Offset in seconds from Coordinated Universal Time
+  \note The offset has no effect beside for the time specification
+        Qt::OffsetFromUTC.
+
+  \sa QDate::setUtcOffset(), setTimeSpec(), toDateTime()
+ */
+int QwtDateScaleEngine::utcOffset() const
+{
+    return d_data->utcOffset;
+}
+
+/*!
+  Sets how to identify the first week of a year.
+
+  \param week0Type Mode how to identify the first week of a year
+
+  \sa week0Type(), setMaxWeeks()
+  \note week0Type has no effect beside for intervals classified as
+        QwtDate::Week. 
+ */
+void QwtDateScaleEngine::setWeek0Type( QwtDate::Week0Type week0Type )
+{
+    d_data->week0Type = week0Type;
+}
+
+/*!
+  \return Setting how to identify the first week of a year. 
+  \sa setWeek0Type(), maxWeeks()
+ */
+QwtDate::Week0Type QwtDateScaleEngine::week0Type() const
+{
+    return d_data->week0Type;
+}
+
+/*!
+  Set a upper limit for the number of weeks, when an interval
+  can be classified as Qt::Week.
+
+  The default setting is 4 weeks.
+
+  \param weeks Upper limit for the number of weeks
+
+  \note In business charts a year is often devided
+        into weeks [1-52]
+  \sa maxWeeks(), setWeek0Type() 
+ */
+void QwtDateScaleEngine::setMaxWeeks( int weeks )
+{
+    d_data->maxWeeks = qMax( weeks, 0 );
+}
+
+/*!
+  \return Upper limit for the number of weeks, when an interval
+          can be classified as Qt::Week.
+  \sa setMaxWeeks(), week0Type()
+ */
+int QwtDateScaleEngine::maxWeeks() const
+{
+    return d_data->maxWeeks;
+}
+
+/*!
+  Classification of a date/time interval division
+
+  \param minDate Minimum ( = earlier ) of the interval
+  \param maxDate Maximum ( = later ) of the interval
+  \param maxSteps Maximum for the number of steps
+
+  \return Interval classification
+ */
+QwtDate::IntervalType QwtDateScaleEngine::intervalType( 
+    const QDateTime &minDate, const QDateTime &maxDate, 
+    int maxSteps ) const
+{
+    const double jdMin = minDate.date().toJulianDay();
+    const double jdMax = maxDate.date().toJulianDay();
+
+    if ( ( jdMax - jdMin ) / 365 > maxSteps )
+        return QwtDate::Year;
+
+    const int months = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Month );
+    if ( months > maxSteps * 6 )
+        return QwtDate::Year;
+
+    const int days = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Day );
+    const int weeks = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Week );
+
+    if ( weeks > d_data->maxWeeks )
+    {
+        if ( days > 4 * maxSteps * 7 )
+            return QwtDate::Month;
+    }
+
+    if ( days > maxSteps * 7 )
+        return QwtDate::Week;
+
+    const int hours = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Hour );
+    if ( hours > maxSteps * 24 )
+        return QwtDate::Day;
+
+    const int seconds = qwtRoundedIntervalWidth( minDate, maxDate, QwtDate::Second );
+
+    if ( seconds >= maxSteps * 3600 )
+        return QwtDate::Hour;
+
+    if ( seconds >= maxSteps * 60 )
+        return QwtDate::Minute;
+
+    if ( seconds >= maxSteps )
+        return QwtDate::Second;
+
+    return QwtDate::Millisecond;
+}
+
+/*!
+  Align and divide an interval
+
+  The algorithm aligns and divides the interval into steps. 
+
+  Datetime interval divisions are usually not equidistant and the
+  calculated stepSize can only be used as an approximation
+  for the steps calculated by divideScale(). 
+
+  \param maxNumSteps Max. number of steps
+  \param x1 First limit of the interval (In/Out)
+  \param x2 Second limit of the interval (In/Out)
+  \param stepSize Step size (Out)
+
+  \sa QwtScaleEngine::setAttribute()
+*/
+void QwtDateScaleEngine::autoScale( int maxNumSteps,
+    double &x1, double &x2, double &stepSize ) const
+{
+    stepSize = 0.0;
+
+    QwtInterval interval( x1, x2 );
+    interval = interval.normalized();
+
+    interval.setMinValue( interval.minValue() - lowerMargin() );
+    interval.setMaxValue( interval.maxValue() + upperMargin() );
+
+    if ( testAttribute( QwtScaleEngine::Symmetric ) )
+        interval = interval.symmetrize( reference() );
+
+    if ( testAttribute( QwtScaleEngine::IncludeReference ) )
+        interval = interval.extend( reference() );
+
+    if ( interval.width() == 0.0 )
+        interval = buildInterval( interval.minValue() );
+
+    const QDateTime from = toDateTime( interval.minValue() );
+    const QDateTime to = toDateTime( interval.maxValue() );
+
+    if ( from.isValid() && to.isValid() )
+    {
+        if ( maxNumSteps < 1 )
+            maxNumSteps = 1;
+
+        const QwtDate::IntervalType intvType = 
+            intervalType( from, to, maxNumSteps );
+
+        const double width = qwtIntervalWidth( from, to, intvType );
+
+        const double stepWidth = qwtDivideScale( width, maxNumSteps, intvType );
+        if ( stepWidth != 0.0 && !testAttribute( QwtScaleEngine::Floating ) )
+        {
+            const QDateTime d1 = alignDate( from, stepWidth, intvType, false );
+            const QDateTime d2 = alignDate( to, stepWidth, intvType, true );
+
+            interval.setMinValue( QwtDate::toDouble( d1 ) );
+            interval.setMaxValue( QwtDate::toDouble( d2 ) );
+        }
+
+        stepSize = stepWidth * qwtMsecsForType( intvType );
+    }
+
+    x1 = interval.minValue();
+    x2 = interval.maxValue();
+
+    if ( testAttribute( QwtScaleEngine::Inverted ) )
+    {
+        qSwap( x1, x2 );
+        stepSize = -stepSize;
+    }
+}
+
+/*!
+   \brief Calculate a scale division for a date/time interval
+
+   \param x1 First interval limit
+   \param x2 Second interval limit
+   \param maxMajorSteps Maximum for the number of major steps
+   \param maxMinorSteps Maximum number of minor steps
+   \param stepSize Step size. If stepSize == 0, the scaleEngine
+                   calculates one.
+   \return Calculated scale division
+*/
+QwtScaleDiv QwtDateScaleEngine::divideScale( double x1, double x2,
+    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
+{
+    if ( maxMajorSteps < 1 )
+        maxMajorSteps = 1;
+
+    const double min = qMin( x1, x2 );
+    const double max = qMax( x1, x2 );
+
+    const QDateTime from = toDateTime( min );
+    const QDateTime to = toDateTime( max );
+
+    if ( from == to )
+        return QwtScaleDiv();
+
+    stepSize = qAbs( stepSize );
+    if ( stepSize > 0.0 )
+    {
+        // as interval types above hours are not equidistant
+        // ( even days might have 23/25 hours because of daylight saving )
+        // the stepSize is used as a hint only
+
+        maxMajorSteps = qCeil( ( max - min ) / stepSize );
+    }
+
+    const QwtDate::IntervalType intvType = 
+        intervalType( from, to, maxMajorSteps );
+
+    QwtScaleDiv scaleDiv;
+
+    if ( intvType == QwtDate::Millisecond )
+    {
+        // for milliseconds and below we can use the decimal system
+        scaleDiv = QwtLinearScaleEngine::divideScale( min, max,
+            maxMajorSteps, maxMinorSteps, stepSize );
+    }
+    else
+    {
+        const QDateTime minDate = QwtDate::floor( from, intvType );
+        const QDateTime maxDate = QwtDate::ceil( to, intvType );
+
+        scaleDiv = buildScaleDiv( minDate, maxDate, 
+            maxMajorSteps, maxMinorSteps, intvType );
+
+        // scaleDiv has been calculated from an extended interval
+        // adjusted to the step size. We have to shrink it again.
+
+        scaleDiv = scaleDiv.bounded( min, max );
+    }
+
+    if ( x1 > x2 )
+        scaleDiv.invert();
+
+    return scaleDiv;
+}
+
+QwtScaleDiv QwtDateScaleEngine::buildScaleDiv( 
+    const QDateTime &minDate, const QDateTime &maxDate,
+    int maxMajorSteps, int maxMinorSteps,
+    QwtDate::IntervalType intervalType ) const
+{
+    // calculate the step size
+    const double stepSize = qwtDivideScale( 
+        qwtIntervalWidth( minDate, maxDate, intervalType ), 
+        maxMajorSteps, intervalType );
+
+    // align minDate to the step size
+    QDateTime dt0 = alignDate( minDate, stepSize, intervalType, false );
+    if ( !dt0.isValid() )
+    {
+        // the floored date is out of the range of a 
+        // QDateTime - we ceil instead.
+        dt0 = alignDate( minDate, stepSize, intervalType, true );
+    }
+
+    QwtScaleDiv scaleDiv;
+
+    if ( intervalType <= QwtDate::Week )
+    {
+        scaleDiv = qwtDivideToSeconds( dt0, maxDate, 
+            stepSize, maxMinorSteps, intervalType );
+    }
+    else
+    {
+        if( intervalType == QwtDate::Month )
+        {
+            scaleDiv = qwtDivideToMonths( dt0, maxDate,
+                stepSize, maxMinorSteps );
+        }
+        else if ( intervalType == QwtDate::Year )
+        {
+            scaleDiv = qwtDivideToYears( dt0, maxDate,
+                stepSize, maxMinorSteps );
+        }
+    }
+
+
+    return scaleDiv;
+}
+
+/*!
+  Align a date/time value for a step size
+
+  For Qt::Day alignments there is no "natural day 0" -
+  instead the first day of the year is used to avoid jumping 
+  major ticks positions when panning a scale. For other alignments
+  ( f.e according to the first day of the month ) alignDate()
+  has to be overloaded.
+
+  \param dateTime Date/time value
+  \param stepSize Step size
+  \param intervalType Interval type
+  \param up When true dateTime is ceiled - otherwise it is floored
+
+  \return Aligned date/time value
+ */
+QDateTime QwtDateScaleEngine::alignDate( 
+    const QDateTime &dateTime, double stepSize, 
+    QwtDate::IntervalType intervalType, bool up ) const
+{
+    // what about: (year == 1582 && month == 10 && day > 4 && day < 15) ??
+
+    QDateTime dt = dateTime;
+
+    if ( dateTime.timeSpec() == Qt::OffsetFromUTC )
+    {
+        dt.setUtcOffset( 0 );
+    }
+
+    switch( intervalType )
+    {
+        case QwtDate::Millisecond:
+        {
+            const int ms = qwtAlignValue( 
+                dt.time().msec(), stepSize, up ) ;
+
+            dt = QwtDate::floor( dateTime, QwtDate::Second );
+            dt = dt.addMSecs( ms );
+
+            break;
+        }
+        case QwtDate::Second:
+        {
+            int second = dt.time().second();
+            if ( up )
+            {
+                if ( dt.time().msec() > 0 )
+                    second++;
+            }
+
+            const int s = qwtAlignValue( second, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Minute );
+            dt = dt.addSecs( s );
+
+            break;
+        }
+        case QwtDate::Minute:
+        {
+            int minute = dt.time().minute();
+            if ( up )
+            {
+                if ( dt.time().msec() > 0 || dt.time().second() > 0 )
+                    minute++;
+            }
+
+            const int m = qwtAlignValue( minute, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Hour );
+            dt = dt.addSecs( m * 60 );
+
+            break;
+        }
+        case QwtDate::Hour:
+        {
+            int hour = dt.time().hour();
+            if ( up )
+            {
+                if ( dt.time().msec() > 0 || dt.time().second() > 0
+                    || dt.time().minute() > 0 )
+                {
+                    hour++;
+                }
+            }
+            const int h = qwtAlignValue( hour, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Day );
+            dt = dt.addSecs( h * 3600 );
+
+            break;
+        }
+        case QwtDate::Day:
+        {
+            // What date do we expect f.e. from an alignment of 5 days ??
+            // Aligning them to the beginning of the year avoids at least
+            // jumping major ticks when panning
+
+            int day = dt.date().dayOfYear();
+            if ( up )
+            {
+                if ( dt.time() > QTime( 0, 0 ) )
+                    day++;
+            }
+
+            const int d = qwtAlignValue( day, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Year );
+            dt = dt.addDays( d - 1 );
+
+            break;
+        }
+        case QwtDate::Week:
+        {
+            const QDate date = QwtDate::dateOfWeek0(
+                dt.date().year(), d_data->week0Type );
+
+            int numWeeks = date.daysTo( dt.date() ) / 7;
+            if ( up )
+            {
+                if ( dt.time() > QTime( 0, 0 ) ||
+                    date.daysTo( dt.date() ) % 7 )
+                {
+                    numWeeks++;
+                }
+            }
+
+            const int d = qwtAlignValue( numWeeks, stepSize, up ) * 7;
+
+            dt = QwtDate::floor( dt, QwtDate::Day );
+            dt.setDate( date );
+            dt = dt.addDays( d );
+
+            break;
+        }
+        case QwtDate::Month:
+        {
+            int month = dt.date().month();
+            if ( up )
+            {
+                if ( dt.date().day() > 1 ||
+                    dt.time() > QTime( 0, 0 ) )
+                {
+                    month++;
+                }
+            }
+
+            const int m = qwtAlignValue( month - 1, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Year );
+            dt = dt.addMonths( m );
+
+            break;
+        }
+        case QwtDate::Year:
+        {
+            int year = dateTime.date().year();
+            if ( up )
+            {
+                if ( dateTime.date().dayOfYear() > 1 ||
+                    dt.time() > QTime( 0, 0 ) )
+                {
+                    year++;
+                }
+            }
+
+            const int y = qwtAlignValue( year, stepSize, up );
+
+            dt = QwtDate::floor( dt, QwtDate::Day );
+            if ( y == 0 )
+            {
+                // there is no year 0 in the Julian calendar
+                dt.setDate( QDate( stepSize, 1, 1 ).addYears( -stepSize ) );
+            }
+            else
+            {
+                dt.setDate( QDate( y, 1, 1 ) );
+            }
+
+            break;
+        }
+    }
+
+    if ( dateTime.timeSpec() == Qt::OffsetFromUTC )
+    {
+        dt.setUtcOffset( dateTime.utcOffset() );
+    }
+
+    return dt;
+}
+
+/*!
+  Translate a double value into a QDateTime object.
+
+  For QDateTime result is bounded by QwtDate::minDate() and QwtDate::maxDate()
+
+  \return QDateTime object initialized with timeSpec() and utcOffset().
+  \sa timeSpec(), utcOffset(), QwtDate::toDateTime()
+ */
+QDateTime QwtDateScaleEngine::toDateTime( double value ) const
+{
+    QDateTime dt = QwtDate::toDateTime( value, d_data->timeSpec );
+    if ( !dt.isValid() )
+    {
+        const QDate date = ( value <= 0.0 ) 
+            ? QwtDate::minDate() : QwtDate::maxDate();
+
+        dt = QDateTime( date, QTime( 0, 0 ), d_data->timeSpec );
+    }
+
+    if ( d_data->timeSpec == Qt::OffsetFromUTC )
+    {
+        dt = dt.addSecs( d_data->utcOffset );
+        dt.setUtcOffset( d_data->utcOffset );
+    }
+
+    return dt;
+}
+
Index: trunk/BNC/qwt/qwt_date_scale_engine.h
===================================================================
--- trunk/BNC/qwt/qwt_date_scale_engine.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_date_scale_engine.h	(revision 8127)
@@ -0,0 +1,86 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef _QWT_DATE_SCALE_ENGINE_H_
+#define _QWT_DATE_SCALE_ENGINE_H_ 1
+
+#include "qwt_date.h"
+#include "qwt_scale_engine.h"
+
+/*!
+  \brief A scale engine for date/time values
+
+  QwtDateScaleEngine builds scales from a time intervals.
+  Together with QwtDateScaleDraw it can be used for
+  axes according to date/time values.
+
+  Years, months, weeks, days, hours and minutes are organized
+  in steps with non constant intervals. QwtDateScaleEngine
+  classifies intervals and aligns the boundaries and tick positions
+  according to this classification.
+
+  QwtDateScaleEngine supports representations depending
+  on Qt::TimeSpec specifications. The valid range for scales
+  is limited by the range of QDateTime, that differs 
+  between Qt4 and Qt5.
+  
+  Datetime values are expected as the number of milliseconds since
+  1970-01-01T00:00:00 Universal Coordinated Time - also known
+  as "The Epoch", that can be converted to QDateTime using 
+  QwtDate::toDateTime().
+
+  \sa QwtDate, QwtPlot::setAxisScaleEngine(),
+      QwtAbstractScale::setScaleEngine()
+*/
+class QWT_EXPORT QwtDateScaleEngine: public QwtLinearScaleEngine
+{
+public:
+    QwtDateScaleEngine( Qt::TimeSpec = Qt::LocalTime );
+    virtual ~QwtDateScaleEngine();
+
+    void setTimeSpec( Qt::TimeSpec );
+    Qt::TimeSpec timeSpec() const;
+
+    void setUtcOffset( int seconds );
+    int utcOffset() const;
+
+    void setWeek0Type( QwtDate::Week0Type );
+    QwtDate::Week0Type week0Type() const;
+    
+    void setMaxWeeks( int );
+    int maxWeeks() const;
+
+    virtual void autoScale( int maxNumSteps,
+        double &x1, double &x2, double &stepSize ) const;
+
+    virtual QwtScaleDiv divideScale( 
+        double x1, double x2,
+        int maxMajorSteps, int maxMinorSteps,
+        double stepSize = 0.0 ) const;
+
+    virtual QwtDate::IntervalType intervalType( 
+        const QDateTime &, const QDateTime &, int maxSteps ) const;
+
+    QDateTime toDateTime( double ) const;
+
+protected:
+    virtual QDateTime alignDate( const QDateTime &, double stepSize,
+        QwtDate::IntervalType, bool up ) const;
+
+private:
+    QwtScaleDiv buildScaleDiv( const QDateTime &, const QDateTime &,
+        int maxMajorSteps, int maxMinorSteps, 
+        QwtDate::IntervalType ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_dial.cpp
===================================================================
--- trunk/BNC/qwt/qwt_dial.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_dial.cpp	(revision 8127)
@@ -0,0 +1,871 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_dial.h"
+#include "qwt_dial_needle.h"
+#include "qwt_math.h"
+#include "qwt_scale_engine.h"
+#include "qwt_scale_map.h"
+#include "qwt_round_scale_draw.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qpixmap.h>
+#include <qevent.h>
+#include <qalgorithms.h>
+#include <qmath.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qapplication.h>
+
+static inline double qwtAngleDist( double a1, double a2 )
+{
+    double dist = qAbs( a2 - a1 );
+    if ( dist > 360.0 )
+        dist -= 360.0;
+
+    return dist;
+}
+
+static inline bool qwtIsOnArc( double angle, double min, double max )
+{
+    if ( min < max )
+    {
+        return ( angle >= min ) && ( angle <= max );
+    }
+    else
+    {
+        return ( angle >= min ) || ( angle <= max );
+    }
+}
+
+static inline double qwtBoundedAngle( double min, double angle, double max )
+{
+    double from = qwtNormalizeDegrees( min );
+    double to = qwtNormalizeDegrees( max );
+
+    double a;
+
+    if ( qwtIsOnArc( angle, from, to ) )
+    {
+        a = angle;
+        if ( a < min )
+            a += 360.0;
+    }
+    else
+    {
+        if ( qwtAngleDist( angle, from ) <
+            qwtAngleDist( angle, to ) )
+        {
+            a = min;
+        }
+        else
+        {
+            a = max;
+        }
+    }
+
+    return a;
+}
+
+class QwtDial::PrivateData
+{
+public:
+    PrivateData():
+        frameShadow( Sunken ),
+        lineWidth( 0 ),
+        mode( RotateNeedle ),
+        origin( 90.0 ),
+        minScaleArc( 0.0 ),
+        maxScaleArc( 0.0 ),
+        needle( NULL ),
+        arcOffset( 0.0 ),
+        mouseOffset( 0.0 )
+    {
+    }
+
+    ~PrivateData()
+    {
+        delete needle;
+    }
+    Shadow frameShadow;
+    int lineWidth;
+
+    QwtDial::Mode mode;
+
+    double origin;
+    double minScaleArc;
+    double maxScaleArc;
+
+    QwtDialNeedle *needle;
+
+    double arcOffset;
+    double mouseOffset;
+
+    QPixmap pixmapCache;
+};
+
+/*!
+  \brief Constructor
+  \param parent Parent widget
+
+  Create a dial widget with no needle. The scale is initialized
+  to [ 0.0, 360.0 ] and 360 steps ( QwtAbstractSlider::setTotalSteps() ).
+  The origin of the scale is at 90°,
+
+  The value is set to 0.0.
+
+  The default mode is QwtDial::RotateNeedle.
+*/
+QwtDial::QwtDial( QWidget* parent ):
+    QwtAbstractSlider( parent )
+{
+    d_data = new PrivateData;
+
+    setFocusPolicy( Qt::TabFocus );
+
+    QPalette p = palette();
+    for ( int i = 0; i < QPalette::NColorGroups; i++ )
+    {
+        const QPalette::ColorGroup colorGroup =
+            static_cast<QPalette::ColorGroup>( i );
+
+        // Base: background color of the circle inside the frame.
+        // WindowText: background color of the circle inside the scale
+
+        p.setColor( colorGroup, QPalette::WindowText,
+            p.color( colorGroup, QPalette::Base ) );
+    }
+    setPalette( p );
+
+    QwtRoundScaleDraw* scaleDraw = new QwtRoundScaleDraw();
+    scaleDraw->setRadius( 0 );
+
+    setScaleDraw( scaleDraw );
+
+    setScaleArc( 0.0, 360.0 ); // scale as a full circle
+
+    setScaleMaxMajor( 10 );
+    setScaleMaxMinor( 5 );
+
+    setValue( 0.0 );
+}
+
+//!  Destructor
+QwtDial::~QwtDial()
+{
+    delete d_data;
+}
+
+/*!
+  Sets the frame shadow value from the frame style.
+
+  \param shadow Frame shadow
+  \sa setLineWidth(), QFrame::setFrameShadow()
+*/
+void QwtDial::setFrameShadow( Shadow shadow )
+{
+    if ( shadow != d_data->frameShadow )
+    {
+        invalidateCache();
+
+        d_data->frameShadow = shadow;
+        if ( lineWidth() > 0 )
+            update();
+    }
+}
+
+/*!
+  \return Frame shadow
+  /sa setFrameShadow(), lineWidth(), QFrame::frameShadow()
+*/
+QwtDial::Shadow QwtDial::frameShadow() const
+{
+    return d_data->frameShadow;
+}
+
+/*!
+  Sets the line width of the frame
+
+  \param lineWidth Line width
+  \sa setFrameShadow()
+*/
+void QwtDial::setLineWidth( int lineWidth )
+{
+    if ( lineWidth < 0 )
+        lineWidth = 0;
+
+    if ( d_data->lineWidth != lineWidth )
+    {
+        invalidateCache();
+
+        d_data->lineWidth = lineWidth;
+        update();
+    }
+}
+
+/*!
+  \return Line width of the frame
+  \sa setLineWidth(), frameShadow(), lineWidth()
+*/
+int QwtDial::lineWidth() const
+{
+    return d_data->lineWidth;
+}
+
+/*!
+  \return bounding rectangle of the circle inside the frame
+  \sa setLineWidth(), scaleInnerRect(), boundingRect()
+*/
+QRect QwtDial::innerRect() const
+{
+    const int lw = lineWidth();
+    return boundingRect().adjusted( lw, lw, -lw, -lw );
+}
+
+/*!
+  \return bounding rectangle of the dial including the frame
+  \sa setLineWidth(), scaleInnerRect(), innerRect()
+*/
+QRect QwtDial::boundingRect() const
+{
+    const QRect cr = contentsRect();
+
+    const double dim = qMin( cr.width(), cr.height() );
+
+    QRect inner( 0, 0, dim, dim );
+    inner.moveCenter( cr.center() );
+
+    return inner;
+}
+
+/*!
+  \return rectangle inside the scale
+  \sa setLineWidth(), boundingRect(), innerRect()
+*/
+QRect QwtDial::scaleInnerRect() const
+{
+    QRect rect = innerRect();
+
+    const QwtAbstractScaleDraw *sd = scaleDraw();
+    if ( sd )
+    {
+        int scaleDist = qCeil( sd->extent( font() ) );
+        scaleDist++; // margin
+
+        rect.adjust( scaleDist, scaleDist, -scaleDist, -scaleDist );
+    }
+
+    return rect;
+}
+
+/*!
+  \brief Change the mode of the dial.
+  \param mode New mode
+
+  In case of QwtDial::RotateNeedle the needle is rotating, in case of
+  QwtDial::RotateScale, the needle points to origin()
+  and the scale is rotating.
+
+  The default mode is QwtDial::RotateNeedle.
+
+  \sa mode(), setValue(), setOrigin()
+*/
+void QwtDial::setMode( Mode mode )
+{
+    if ( mode != d_data->mode )
+    {
+        invalidateCache();
+
+        d_data->mode = mode;
+        sliderChange();
+    }
+}
+
+/*!
+  \return Mode of the dial.
+  \sa setMode(), origin(), setScaleArc(), value()
+*/
+QwtDial::Mode QwtDial::mode() const
+{
+    return d_data->mode;
+}
+
+/*!
+  Invalidate the internal caches used to speed up repainting
+ */
+void QwtDial::invalidateCache()
+{
+    d_data->pixmapCache = QPixmap();
+}
+
+/*!
+   Paint the dial
+   \param event Paint event
+*/
+void QwtDial::paintEvent( QPaintEvent *event )
+{
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    QStyleOption opt;
+    opt.init(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    if ( d_data->mode == QwtDial::RotateScale )
+    {
+        painter.save();
+        painter.setRenderHint( QPainter::Antialiasing, true );
+
+        drawContents( &painter );
+
+        painter.restore();
+    }
+
+    const QRect r = contentsRect();
+    if ( r.size() != d_data->pixmapCache.size() )
+    {
+        d_data->pixmapCache = QwtPainter::backingStore( this, r.size() );
+        d_data->pixmapCache.fill( Qt::transparent );
+
+        QPainter p( &d_data->pixmapCache );
+        p.setRenderHint( QPainter::Antialiasing, true );
+        p.translate( -r.topLeft() );
+            
+        if ( d_data->mode != QwtDial::RotateScale )
+            drawContents( &p );
+
+        if ( lineWidth() > 0 )
+            drawFrame( &p );
+
+        if ( d_data->mode != QwtDial::RotateNeedle )
+            drawNeedle( &p );
+    }
+
+    painter.drawPixmap( r.topLeft(), d_data->pixmapCache );
+
+    if ( d_data->mode == QwtDial::RotateNeedle )
+        drawNeedle( &painter );
+
+    if ( hasFocus() )
+        drawFocusIndicator( &painter );
+}
+
+/*!
+  Draw the focus indicator
+  \param painter Painter
+*/
+void QwtDial::drawFocusIndicator( QPainter *painter ) const
+{
+    QwtPainter::drawFocusRect( painter, this, boundingRect() );
+}
+
+/*!
+  Draw the frame around the dial
+
+  \param painter Painter
+  \sa lineWidth(), frameShadow()
+*/
+void QwtDial::drawFrame( QPainter *painter )
+{
+    QwtPainter::drawRoundFrame( painter, boundingRect(),
+        palette(), lineWidth(), d_data->frameShadow );
+}
+
+/*!
+  \brief Draw the contents inside the frame
+
+  QPalette::Window is the background color outside of the frame.
+  QPalette::Base is the background color inside the frame.
+  QPalette::WindowText is the background color inside the scale.
+
+  \param painter Painter
+
+  \sa boundingRect(), innerRect(),
+    scaleInnerRect(), QWidget::setPalette()
+*/
+void QwtDial::drawContents( QPainter *painter ) const
+{
+    if ( testAttribute( Qt::WA_NoSystemBackground ) ||
+        palette().brush( QPalette::Base ) !=
+            palette().brush( QPalette::Window ) )
+    {
+        const QRectF br = boundingRect();
+
+        painter->save();
+        painter->setPen( Qt::NoPen );
+        painter->setBrush( palette().brush( QPalette::Base ) );
+        painter->drawEllipse( br );
+        painter->restore();
+    }
+
+    const QRectF insideScaleRect = scaleInnerRect();
+    if ( palette().brush( QPalette::WindowText ) !=
+            palette().brush( QPalette::Base ) )
+    {
+        painter->save();
+        painter->setPen( Qt::NoPen );
+        painter->setBrush( palette().brush( QPalette::WindowText ) );
+        painter->drawEllipse( insideScaleRect );
+        painter->restore();
+    }
+
+    const QPointF center = insideScaleRect.center();
+    const double radius = 0.5 * insideScaleRect.width();
+
+    painter->save();
+    drawScale( painter, center, radius );
+    painter->restore();
+
+    painter->save();
+    drawScaleContents( painter, center, radius );
+    painter->restore();
+}
+
+/*!
+  Draw the needle
+
+  \param painter Painter
+  \param center Center of the dial
+  \param radius Length for the needle
+  \param direction Direction of the needle in degrees, counter clockwise
+  \param colorGroup ColorGroup
+*/
+void QwtDial::drawNeedle( QPainter *painter, const QPointF &center,
+    double radius, double direction, QPalette::ColorGroup colorGroup ) const
+{
+    if ( d_data->needle )
+    {
+        direction = 360.0 - direction; // counter clockwise
+        d_data->needle->draw( painter, center, radius, direction, colorGroup );
+    }
+}
+
+void QwtDial::drawNeedle( QPainter *painter ) const
+{
+    if ( !isValid() )
+        return;
+
+    QPalette::ColorGroup colorGroup;
+    if ( isEnabled() )
+        colorGroup = hasFocus() ? QPalette::Active : QPalette::Inactive;
+    else
+        colorGroup = QPalette::Disabled;
+
+    const QRectF sr = scaleInnerRect();
+
+    painter->save();
+    painter->setRenderHint( QPainter::Antialiasing, true );
+    drawNeedle( painter, sr.center(), 0.5 * sr.width(),
+        scaleMap().transform( value() ) + 270.0, colorGroup );
+    painter->restore();
+}
+
+/*!
+  Draw the scale
+
+  \param painter Painter
+  \param center Center of the dial
+  \param radius Radius of the scale
+*/
+void QwtDial::drawScale( QPainter *painter, 
+    const QPointF &center, double radius ) const
+{
+    QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() );
+    if ( sd == NULL )
+        return;
+
+    sd->setRadius( radius );
+    sd->moveCenter( center );
+
+    QPalette pal = palette();
+
+    const QColor textColor = pal.color( QPalette::Text );
+    pal.setColor( QPalette::WindowText, textColor ); // ticks, backbone
+
+    painter->setFont( font() );
+    painter->setPen( QPen( textColor, sd->penWidth() ) );
+
+    painter->setBrush( Qt::red );
+    sd->draw( painter, pal );
+}
+
+/*!
+  Draw the contents inside the scale
+
+  Paints nothing.
+
+  \param painter Painter
+  \param center Center of the contents circle
+  \param radius Radius of the contents circle
+*/
+void QwtDial::drawScaleContents( QPainter *painter,
+    const QPointF &center, double radius ) const
+{
+    Q_UNUSED(painter);
+    Q_UNUSED(center);
+    Q_UNUSED(radius);
+}
+
+/*!
+  Set a needle for the dial
+
+  \param needle Needle
+
+  \warning The needle will be deleted, when a different needle is
+           set or in ~QwtDial()
+*/
+void QwtDial::setNeedle( QwtDialNeedle *needle )
+{
+    if ( needle != d_data->needle )
+    {
+        if ( d_data->needle )
+            delete d_data->needle;
+
+        d_data->needle = needle;
+        update();
+    }
+}
+
+/*!
+  \return needle
+  \sa setNeedle()
+*/
+const QwtDialNeedle *QwtDial::needle() const
+{
+    return d_data->needle;
+}
+
+/*!
+  \return needle
+  \sa setNeedle()
+*/
+QwtDialNeedle *QwtDial::needle()
+{
+    return d_data->needle;
+}
+
+//! \return the scale draw
+QwtRoundScaleDraw *QwtDial::scaleDraw()
+{
+    return static_cast<QwtRoundScaleDraw *>( abstractScaleDraw() );
+}
+
+//! \return the scale draw
+const QwtRoundScaleDraw *QwtDial::scaleDraw() const
+{
+    return static_cast<const QwtRoundScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+  Set an individual scale draw
+
+  The motivation for setting a scale draw is often
+  to overload QwtRoundScaleDraw::label() to return 
+  individual tick labels.
+  
+  \param scaleDraw Scale draw
+  \warning The previous scale draw is deleted
+*/
+void QwtDial::setScaleDraw( QwtRoundScaleDraw *scaleDraw )
+{
+    setAbstractScaleDraw( scaleDraw );
+    sliderChange();
+}
+
+/*!
+  Change the arc of the scale
+
+  \param minArc Lower limit
+  \param maxArc Upper limit
+
+  \sa minScaleArc(), maxScaleArc()
+*/
+void QwtDial::setScaleArc( double minArc, double maxArc )
+{
+    if ( minArc != 360.0 && minArc != -360.0 )
+        minArc = ::fmod( minArc, 360.0 );
+    if ( maxArc != 360.0 && maxArc != -360.0 )
+        maxArc = ::fmod( maxArc, 360.0 );
+
+    double minScaleArc = qMin( minArc, maxArc );
+    double maxScaleArc = qMax( minArc, maxArc );
+
+    if ( maxScaleArc - minScaleArc > 360.0 )
+        maxScaleArc = minScaleArc + 360.0;
+
+    if ( ( minScaleArc != d_data->minScaleArc ) || 
+        ( maxScaleArc != d_data->maxScaleArc ) )
+    {
+        d_data->minScaleArc = minScaleArc;
+        d_data->maxScaleArc = maxScaleArc;
+
+        invalidateCache();
+        sliderChange();
+    }
+}
+
+/*! 
+  Set the lower limit for the scale arc
+
+  \param min Lower limit of the scale arc
+  \sa setScaleArc(), setMaxScaleArc()
+ */
+void QwtDial::setMinScaleArc( double min )
+{
+    setScaleArc( min, d_data->maxScaleArc );
+}
+
+/*! 
+  \return Lower limit of the scale arc
+  \sa setScaleArc()
+*/
+double QwtDial::minScaleArc() const
+{
+    return d_data->minScaleArc;
+}
+
+/*! 
+  Set the upper limit for the scale arc
+
+  \param max Upper limit of the scale arc
+  \sa setScaleArc(), setMinScaleArc()
+ */
+void QwtDial::setMaxScaleArc( double max )
+{
+    setScaleArc( d_data->minScaleArc, max );
+}
+
+/*! 
+  \return Upper limit of the scale arc
+  \sa setScaleArc()
+*/
+double QwtDial::maxScaleArc() const
+{
+    return d_data->maxScaleArc;
+}
+
+/*!
+  \brief Change the origin
+
+  The origin is the angle where scale and needle is relative to.
+
+  \param origin New origin
+  \sa origin()
+*/
+void QwtDial::setOrigin( double origin )
+{
+    invalidateCache();
+
+    d_data->origin = origin;
+    sliderChange();
+}
+
+/*!
+  The origin is the angle where scale and needle is relative to.
+
+  \return Origin of the dial
+  \sa setOrigin()
+*/
+double QwtDial::origin() const
+{
+    return d_data->origin;
+}
+
+/*!
+  \return Size hint
+  \sa minimumSizeHint()
+*/
+QSize QwtDial::sizeHint() const
+{
+    int sh = 0;
+    if ( scaleDraw() )
+        sh = qCeil( scaleDraw()->extent( font() ) );
+
+    const int d = 6 * sh + 2 * lineWidth();
+
+    QSize hint( d, d ); 
+    if ( !isReadOnly() )
+        hint = hint.expandedTo( QApplication::globalStrut() );
+
+    return hint;
+}
+
+/*!
+  \return Minimum size hint
+  \sa sizeHint()
+*/
+QSize QwtDial::minimumSizeHint() const
+{
+    int sh = 0;
+    if ( scaleDraw() )
+        sh = qCeil( scaleDraw()->extent( font() ) );
+
+    const int d = 3 * sh + 2 * lineWidth();
+
+    return QSize( d, d );
+}
+
+/*!
+  \brief Determine what to do when the user presses a mouse button.
+
+  \param pos Mouse position
+
+  \retval True, when the inner circle contains pos 
+  \sa scrolledTo()
+*/
+bool QwtDial::isScrollPosition( const QPoint &pos ) const
+{
+    const QRegion region( innerRect(), QRegion::Ellipse );
+    if ( region.contains( pos ) && ( pos != innerRect().center() ) )
+    {
+        double angle = QLineF( rect().center(), pos ).angle();
+        if ( d_data->mode == QwtDial::RotateScale )
+            angle = 360.0 - angle;
+
+        double valueAngle = 
+            qwtNormalizeDegrees( 90.0 - scaleMap().transform( value() ) );
+
+        d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle );
+        d_data->arcOffset = scaleMap().p1();
+
+        return true;
+    }
+
+    return false;
+}
+
+/*!
+  \brief Determine the value for a new position of the
+         slider handle.
+
+  \param pos Mouse position
+
+  \return Value for the mouse position
+  \sa isScrollPosition()
+*/
+double QwtDial::scrolledTo( const QPoint &pos ) const
+{
+    double angle = QLineF( rect().center(), pos ).angle();
+    if ( d_data->mode == QwtDial::RotateScale )
+    {
+        angle += scaleMap().p1() - d_data->arcOffset;
+        angle = 360.0 - angle;
+    }
+
+    angle = qwtNormalizeDegrees( angle - d_data->mouseOffset );
+    angle = qwtNormalizeDegrees( 90.0 - angle );
+
+    if ( scaleMap().pDist() >= 360.0 )
+    {
+        if ( angle < scaleMap().p1() )
+            angle += 360.0;
+
+        if ( !wrapping() )
+        {
+            double boundedAngle = angle;
+
+            const double arc = angle - scaleMap().transform( value() );
+            if ( qAbs( arc ) > 180.0 )
+            {
+                boundedAngle = ( arc > 0 ) 
+                    ? scaleMap().p1() : scaleMap().p2();
+            }
+
+            d_data->mouseOffset += ( boundedAngle - angle );
+
+            angle = boundedAngle;
+        }
+    }
+    else
+    {
+        const double boundedAngle =
+            qwtBoundedAngle( scaleMap().p1(), angle, scaleMap().p2() );
+
+        if ( !wrapping() )
+            d_data->mouseOffset += ( boundedAngle - angle );
+
+        angle = boundedAngle;
+    }
+
+    return scaleMap().invTransform( angle );
+}
+
+/*!
+  Change Event handler
+  \param event Change event
+
+  Invalidates internal paint caches if necessary
+*/
+void QwtDial::changeEvent( QEvent *event )
+{
+    switch( event->type() )
+    {
+        case QEvent::EnabledChange:
+        case QEvent::FontChange:
+        case QEvent::StyleChange:
+        case QEvent::PaletteChange:
+        case QEvent::LanguageChange:
+        case QEvent::LocaleChange:
+        {
+            invalidateCache();
+            break;
+        }
+        default:
+            break;
+    }
+    
+    QwtAbstractSlider::changeEvent( event );
+}
+
+/*!
+  Wheel Event handler
+  \param event Wheel event
+*/
+void QwtDial::wheelEvent( QWheelEvent *event )
+{
+    const QRegion region( innerRect(), QRegion::Ellipse );
+    if ( region.contains( event->pos() ) )
+        QwtAbstractSlider::wheelEvent( event );
+}
+
+void QwtDial::setAngleRange( double angle, double span )
+{
+    QwtRoundScaleDraw *sd = const_cast<QwtRoundScaleDraw *>( scaleDraw() );
+    if ( sd  )
+    {
+        angle = qwtNormalizeDegrees( angle - 270.0 );
+        sd->setAngleRange( angle, angle + span );
+    }
+}
+
+/*!
+  Invalidate the internal caches and call 
+  QwtAbstractSlider::scaleChange()
+ */
+void QwtDial::scaleChange()
+{
+    invalidateCache();
+    QwtAbstractSlider::scaleChange();
+}
+
+void QwtDial::sliderChange()
+{
+    setAngleRange( d_data->origin + d_data->minScaleArc,
+        d_data->maxScaleArc - d_data->minScaleArc );
+
+    if ( mode() == RotateScale )
+    {
+        const double arc = scaleMap().transform( value() ) - scaleMap().p1();
+        setAngleRange( d_data->origin - arc,
+            d_data->maxScaleArc - d_data->minScaleArc );
+    }
+
+    QwtAbstractSlider::sliderChange();
+}
Index: trunk/BNC/qwt/qwt_dial.h
===================================================================
--- trunk/BNC/qwt/qwt_dial.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_dial.h	(revision 8127)
@@ -0,0 +1,168 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_DIAL_H
+#define QWT_DIAL_H 1
+
+#include "qwt_global.h"
+#include "qwt_abstract_slider.h"
+#include "qwt_abstract_scale_draw.h"
+#include <qframe.h>
+#include <qpalette.h>
+
+class QwtDialNeedle;
+class QwtRoundScaleDraw;
+
+/*!
+  \brief QwtDial class provides a rounded range control.
+
+  QwtDial is intended as base class for dial widgets like
+  speedometers, compass widgets, clocks ...
+
+  \image html dials2.png
+
+  A dial contains a scale and a needle indicating the current value
+  of the dial. Depending on Mode one of them is fixed and the
+  other is rotating. If not isReadOnly() the
+  dial can be rotated by dragging the mouse or using keyboard inputs
+  (see QwtAbstractSlider::keyPressEvent()). A dial might be wrapping, what means
+  a rotation below/above one limit continues on the other limit (f.e compass).
+  The scale might cover any arc of the dial, its values are related to
+  the origin() of the dial.
+
+  Often dials have to be updated very often according to values from external
+  devices. For these high refresh rates QwtDial caches as much as possible.
+  For derived classes it might be necessary to clear these caches manually
+  according to attribute changes using invalidateCache().
+
+  \sa QwtCompass, QwtAnalogClock, QwtDialNeedle
+  \note The controls and dials examples shows different types of dials.
+  \note QDial is more similar to QwtKnob than to QwtDial
+*/
+
+class QWT_EXPORT QwtDial: public QwtAbstractSlider
+{
+    Q_OBJECT
+
+    Q_ENUMS( Shadow Mode Direction )
+
+    Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
+    Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
+    Q_PROPERTY( Mode mode READ mode WRITE setMode )
+    Q_PROPERTY( double origin READ origin WRITE setOrigin )
+    Q_PROPERTY( double minScaleArc READ minScaleArc WRITE setMinScaleArc )
+    Q_PROPERTY( double maxScaleArc READ maxScaleArc WRITE setMaxScaleArc )
+
+public:
+
+    /*!
+        \brief Frame shadow
+
+         Unfortunately it is not possible to use QFrame::Shadow
+         as a property of a widget that is not derived from QFrame.
+         The following enum is made for the designer only. It is safe
+         to use QFrame::Shadow instead.
+     */
+    enum Shadow
+    {
+        //! QFrame::Plain
+        Plain = QFrame::Plain,
+
+        //! QFrame::Raised
+        Raised = QFrame::Raised,
+
+        //! QFrame::Sunken
+        Sunken = QFrame::Sunken
+    };
+
+    //! Mode controlling whether the needle or the scale is rotating
+    enum Mode
+    {
+        //! The needle is rotating
+        RotateNeedle,
+
+        //! The needle is fixed, the scales are rotating
+        RotateScale
+    };
+
+    explicit QwtDial( QWidget *parent = NULL );
+    virtual ~QwtDial();
+
+    void setFrameShadow( Shadow );
+    Shadow frameShadow() const;
+
+    void setLineWidth( int );
+    int lineWidth() const;
+
+    void setMode( Mode );
+    Mode mode() const;
+
+    void setScaleArc( double min, double max );
+
+    void setMinScaleArc( double min );
+    double minScaleArc() const;
+
+    void setMaxScaleArc( double min );
+    double maxScaleArc() const;
+
+    virtual void setOrigin( double );
+    double origin() const;
+
+    void setNeedle( QwtDialNeedle * );
+    const QwtDialNeedle *needle() const;
+    QwtDialNeedle *needle();
+
+    QRect boundingRect() const;
+    QRect innerRect() const;
+
+    virtual QRect scaleInnerRect() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+    void setScaleDraw( QwtRoundScaleDraw * );
+
+    QwtRoundScaleDraw *scaleDraw();
+    const QwtRoundScaleDraw *scaleDraw() const;
+
+protected:
+    virtual void wheelEvent( QWheelEvent * );
+    virtual void paintEvent( QPaintEvent * );
+    virtual void changeEvent( QEvent * );
+
+    virtual void drawFrame( QPainter *p );
+    virtual void drawContents( QPainter * ) const;
+    virtual void drawFocusIndicator( QPainter * ) const;
+
+    void invalidateCache();
+
+    virtual void drawScale( QPainter *, 
+        const QPointF &center, double radius ) const;
+
+    virtual void drawScaleContents( QPainter *painter, 
+        const QPointF &center, double radius ) const;
+
+    virtual void drawNeedle( QPainter *, const QPointF &,
+        double radius, double direction, QPalette::ColorGroup ) const;
+
+    virtual double scrolledTo( const QPoint & ) const;
+    virtual bool isScrollPosition( const QPoint & ) const;
+
+    virtual void sliderChange();
+    virtual void scaleChange();
+
+private:
+    void setAngleRange( double angle, double span );
+    void drawNeedle( QPainter * ) const;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_dial_needle.cpp
===================================================================
--- trunk/BNC/qwt/qwt_dial_needle.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_dial_needle.cpp	(revision 8127)
@@ -0,0 +1,440 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_dial_needle.h"
+#include "qwt_global.h"
+#include "qwt_math.h"
+#include "qwt_painter.h"
+#include <qapplication.h>
+#include <qpainter.h>
+
+#if QT_VERSION < 0x040601
+#define qFastSin(x) qSin(x)
+#define qFastCos(x) qCos(x)
+#endif
+
+static void qwtDrawStyle1Needle( QPainter *painter,
+    const QPalette &palette, QPalette::ColorGroup colorGroup,
+    double length )
+{
+    const double r[] = { 0.4, 0.3, 1, 0.8, 1, 0.3, 0.4 };
+    const double a[] = { -45, -20, -15, 0, 15, 20, 45 };
+
+    QPainterPath path;
+    for ( int i = 0; i < 7; i++ )
+    {
+        const double angle = a[i] / 180.0 * M_PI;
+        const double radius = r[i] * length;
+
+        const double x = radius * qFastCos( angle );
+        const double y = radius * qFastSin( angle );
+
+        path.lineTo( x, -y );
+    }
+
+    painter->setPen( Qt::NoPen );
+    painter->setBrush( palette.brush( colorGroup, QPalette::Light ) );
+    painter->drawPath( path );
+}
+
+static void qwtDrawStyle2Needle( QPainter *painter,
+    const QPalette &palette, QPalette::ColorGroup colorGroup, double length )
+{
+    const double ratioX = 0.7;
+    const double ratioY = 0.3;
+
+    QPainterPath path1;
+    path1.lineTo( ratioX * length, 0.0 );
+    path1.lineTo( length, ratioY * length );
+
+    QPainterPath path2;
+    path2.lineTo( ratioX * length, 0.0 );
+    path2.lineTo( length, -ratioY * length );
+
+    painter->setPen( Qt::NoPen );
+
+    painter->setBrush( palette.brush( colorGroup, QPalette::Light ) );
+    painter->drawPath( path1 );
+
+    painter->setBrush( palette.brush( colorGroup, QPalette::Dark ) );
+    painter->drawPath( path2 );
+}
+
+static void qwtDrawShadedPointer( QPainter *painter, 
+    const QColor &lightColor, const QColor &darkColor,
+    double length, double width )
+{
+    const double peak = qMax( length / 10.0, 5.0 );
+
+    const double knobWidth = width + 8;
+    QRectF knobRect( 0, 0, knobWidth, knobWidth );
+    knobRect.moveCenter( QPointF(0, 0) );
+
+    QPainterPath path1;
+    path1.lineTo( 0.0, 0.5 * width );
+    path1.lineTo( length - peak, 0.5 * width );
+    path1.lineTo( length, 0.0 );
+    path1.lineTo( 0.0, 0.0 );
+
+    QPainterPath arcPath1;
+    arcPath1.arcTo( knobRect, 0.0, -90.0 );
+
+    path1 = path1.united( arcPath1 );
+
+    QPainterPath path2;
+    path2.lineTo( 0.0, -0.5 * width );
+    path2.lineTo( length - peak, -0.5 * width );
+    path2.lineTo( length, 0.0 );
+    path2.lineTo( 0.0, 0.0 );
+
+    QPainterPath arcPath2;
+    arcPath2.arcTo( knobRect, 0.0, 90.0 );
+
+    path2 = path2.united( arcPath2 );
+
+    painter->setPen( Qt::NoPen );
+
+    painter->setBrush( lightColor );
+    painter->drawPath( path1 );
+
+    painter->setBrush( darkColor );
+    painter->drawPath( path2 );
+}
+
+static void qwtDrawArrowNeedle( QPainter *painter,
+    const QPalette &palette, QPalette::ColorGroup colorGroup,
+    double length, double width )
+{
+    if ( width <= 0 )
+        width = qMax( length * 0.06, 9.0 );
+
+    const double peak = qMax( 2.0, 0.4 * width );
+
+    QPainterPath path;
+    path.moveTo( 0.0, 0.5 * width );
+    path.lineTo( length - peak, 0.3 * width );
+    path.lineTo( length, 0.0 );
+    path.lineTo( length - peak, -0.3 * width );
+    path.lineTo( 0.0, -0.5 * width );
+
+    QRectF br = path.boundingRect();
+
+    QPalette pal( palette.color( QPalette::Mid ) );
+    QColor c1 = pal.color( QPalette::Light );
+    QColor c2 = pal.color( QPalette::Dark );
+
+    QLinearGradient gradient( br.topLeft(), br.bottomLeft() );
+    gradient.setColorAt( 0.0, c1 );
+    gradient.setColorAt( 0.5, c1 );
+    gradient.setColorAt( 0.5001, c2 );
+    gradient.setColorAt( 1.0, c2 );
+
+    QPen pen( gradient, 1 );
+    pen.setJoinStyle( Qt::MiterJoin );
+
+    painter->setPen( pen );
+    painter->setBrush( palette.brush( colorGroup, QPalette::Mid ) );
+
+    painter->drawPath( path );
+}
+
+static void qwtDrawTriangleNeedle( QPainter *painter,
+    const QPalette &palette, QPalette::ColorGroup colorGroup,
+    double length )
+{
+    const double width = qRound( length / 3.0 );
+
+    QPainterPath path[4];
+
+    path[0].lineTo( length, 0.0 );
+    path[0].lineTo( 0.0, width / 2 );
+
+    path[1].lineTo( length, 0.0 );
+    path[1].lineTo( 0.0, -width / 2 );
+
+    path[2].lineTo( -length, 0.0 );
+    path[2].lineTo( 0.0, width / 2 );
+
+    path[3].lineTo( -length, 0.0 );
+    path[3].lineTo( 0.0, -width / 2 );
+
+
+    const int colorOffset =  10;
+    const QColor darkColor = palette.color( colorGroup, QPalette::Dark );
+    const QColor lightColor = palette.color( colorGroup, QPalette::Light );
+
+    QColor color[4];
+    color[0] = darkColor.light( 100 + colorOffset );
+    color[1] = darkColor.dark( 100 + colorOffset );
+    color[2] = lightColor.light( 100 + colorOffset );
+    color[3] = lightColor.dark( 100 + colorOffset );
+
+    painter->setPen( Qt::NoPen );
+
+    for ( int i = 0; i < 4; i++ )
+    {
+        painter->setBrush( color[i] );
+        painter->drawPath( path[i] );
+    }
+}
+
+//! Constructor
+QwtDialNeedle::QwtDialNeedle():
+    d_palette( QApplication::palette() )
+{
+}
+
+//! Destructor
+QwtDialNeedle::~QwtDialNeedle()
+{
+}
+
+/*!
+    Sets the palette for the needle.
+
+    \param palette New Palette
+*/
+void QwtDialNeedle::setPalette( const QPalette &palette )
+{
+    d_palette = palette;
+}
+
+/*!
+  \return the palette of the needle.
+*/
+const QPalette &QwtDialNeedle::palette() const
+{
+    return d_palette;
+}
+
+/*!
+  Draw the needle
+
+  \param painter Painter
+  \param center Center of the dial, start position for the needle
+  \param length Length of the needle
+  \param direction Direction of the needle, in degrees counter clockwise
+  \param colorGroup Color group, used for painting
+*/
+void QwtDialNeedle::draw( QPainter *painter, 
+    const QPointF &center, double length, double direction, 
+    QPalette::ColorGroup colorGroup ) const
+{
+    painter->save();
+
+    painter->translate( center );
+    painter->rotate( -direction );
+
+    drawNeedle( painter, length, colorGroup );
+
+    painter->restore();
+}
+
+//!  Draw the knob
+void QwtDialNeedle::drawKnob( QPainter *painter,
+    double width, const QBrush &brush, bool sunken ) const
+{
+    QPalette palette( brush.color() );
+
+    QColor c1 = palette.color( QPalette::Light );
+    QColor c2 = palette.color( QPalette::Dark );
+
+    if ( sunken )
+        qSwap( c1, c2 );
+
+    QRectF rect( 0.0, 0.0, width, width );
+    rect.moveCenter( painter->combinedTransform().map( QPointF() ) );
+
+    QLinearGradient gradient( rect.topLeft(), rect.bottomRight() );
+    gradient.setColorAt( 0.0, c1 );
+    gradient.setColorAt( 0.3, c1 );
+    gradient.setColorAt( 0.7, c2 );
+    gradient.setColorAt( 1.0, c2 );
+
+    painter->save();
+
+    painter->resetTransform();
+
+    painter->setPen( QPen( gradient, 1 ) );
+    painter->setBrush( brush );
+    painter->drawEllipse( rect );
+
+    painter->restore();
+}
+
+/*!
+  Constructor
+
+  \param style Style
+  \param hasKnob With/Without knob
+  \param mid Middle color
+  \param base Base color
+*/
+QwtDialSimpleNeedle::QwtDialSimpleNeedle( Style style, bool hasKnob,
+        const QColor &mid, const QColor &base ):
+    d_style( style ),
+    d_hasKnob( hasKnob ),
+    d_width( -1 )
+{
+    QPalette palette;
+    palette.setColor( QPalette::Mid, mid );
+    palette.setColor( QPalette::Base, base );
+
+    setPalette( palette );
+}
+
+/*!
+  Set the width of the needle
+  \param width Width
+  \sa width()
+*/
+void QwtDialSimpleNeedle::setWidth( double width )
+{
+    d_width = width;
+}
+
+/*!
+  \return the width of the needle
+  \sa setWidth()
+*/
+double QwtDialSimpleNeedle::width() const
+{
+    return d_width;
+}
+
+/*!
+ Draw the needle
+
+ \param painter Painter
+ \param length Length of the needle
+ \param colorGroup Color group, used for painting
+*/
+void QwtDialSimpleNeedle::drawNeedle( QPainter *painter, 
+    double length, QPalette::ColorGroup colorGroup ) const
+{
+    double knobWidth = 0.0;
+    double width = d_width;
+
+    if ( d_style == Arrow )
+    {
+        if ( width <= 0.0 )
+            width = qMax(length * 0.06, 6.0);
+
+        qwtDrawArrowNeedle( painter, 
+            palette(), colorGroup, length, width );
+
+        knobWidth = qMin( width * 2.0, 0.2 * length );
+    }
+    else
+    {
+        if ( width <= 0.0 )
+            width = 5.0;
+        
+        QPen pen ( palette().brush( colorGroup, QPalette::Mid ), width );
+        pen.setCapStyle( Qt::FlatCap );
+    
+        painter->setPen( pen );
+        painter->drawLine( QPointF( 0.0, 0.0 ), QPointF( length, 0.0 ) );
+
+        knobWidth = qMax( width * 3.0, 5.0 );
+    }
+
+    if ( d_hasKnob && knobWidth > 0.0 )
+    {
+        drawKnob( painter, knobWidth,
+            palette().brush( colorGroup, QPalette::Base ), false );
+    }
+}
+
+//! Constructor
+QwtCompassMagnetNeedle::QwtCompassMagnetNeedle( Style style,
+        const QColor &light, const QColor &dark ):
+    d_style( style )
+{
+    QPalette palette;
+    palette.setColor( QPalette::Light, light );
+    palette.setColor( QPalette::Dark, dark );
+    palette.setColor( QPalette::Base, Qt::gray );
+
+    setPalette( palette );
+}
+
+/*!
+    Draw the needle
+
+    \param painter Painter
+    \param length Length of the needle
+    \param colorGroup Color group, used for painting
+*/
+void QwtCompassMagnetNeedle::drawNeedle( QPainter *painter, 
+    double length, QPalette::ColorGroup colorGroup ) const
+{
+    if ( d_style == ThinStyle )
+    {
+        const double width = qMax( length / 6.0, 3.0 );
+
+        const int colorOffset = 10;
+
+        const QColor light = palette().color( colorGroup, QPalette::Light );
+        const QColor dark = palette().color( colorGroup, QPalette::Dark );
+
+        qwtDrawShadedPointer( painter,
+            dark.light( 100 + colorOffset ),
+            dark.dark( 100 + colorOffset ),
+            length, width );
+        
+        painter->rotate( 180.0 );
+    
+        qwtDrawShadedPointer( painter,
+            light.light( 100 + colorOffset ),
+            light.dark( 100 + colorOffset ),
+            length, width );
+        
+        const QBrush baseBrush = palette().brush( colorGroup, QPalette::Base );
+        drawKnob( painter, width, baseBrush, true );
+    }
+    else
+    {
+        qwtDrawTriangleNeedle( painter, palette(), colorGroup, length );
+    }
+}
+
+/*!
+   Constructor
+
+   \param style Arrow style
+   \param light Light color
+   \param dark Dark color
+*/
+QwtCompassWindArrow::QwtCompassWindArrow( Style style,
+        const QColor &light, const QColor &dark ):
+    d_style( style )
+{
+    QPalette palette;
+    palette.setColor( QPalette::Light, light );
+    palette.setColor( QPalette::Dark, dark );
+
+    setPalette( palette );
+}
+
+/*!
+ Draw the needle
+
+ \param painter Painter
+ \param length Length of the needle
+ \param colorGroup Color group, used for painting
+*/
+void QwtCompassWindArrow::drawNeedle( QPainter *painter, 
+    double length, QPalette::ColorGroup colorGroup ) const
+{
+    if ( d_style == Style1 )
+        qwtDrawStyle1Needle( painter, palette(), colorGroup, length );
+    else
+        qwtDrawStyle2Needle( painter, palette(), colorGroup, length );
+}
Index: trunk/BNC/qwt/qwt_dial_needle.h
===================================================================
--- trunk/BNC/qwt/qwt_dial_needle.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_dial_needle.h	(revision 8127)
@@ -0,0 +1,187 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_DIAL_NEEDLE_H
+#define QWT_DIAL_NEEDLE_H 1
+
+#include "qwt_global.h"
+#include <qpalette.h>
+
+class QPainter;
+class QPoint;
+
+/*!
+  \brief Base class for needles that can be used in a QwtDial.
+
+  QwtDialNeedle is a pointer that indicates a value by pointing
+  to a specific direction.
+
+  \sa QwtDial, QwtCompass
+*/
+
+class QWT_EXPORT QwtDialNeedle
+{
+public:
+    QwtDialNeedle();
+    virtual ~QwtDialNeedle();
+
+    virtual void setPalette( const QPalette & );
+    const QPalette &palette() const;
+
+    virtual void draw( QPainter *painter, const QPointF &center,
+        double length, double direction, 
+        QPalette::ColorGroup = QPalette::Active ) const;
+
+protected:
+    /*!
+      \brief Draw the needle
+
+      The origin of the needle is at position (0.0, 0.0 )
+      pointing in direction 0.0 ( = east ). 
+
+      The painter is already initialized with translation and 
+      rotation.
+
+      \param painter Painter
+      \param length Length of the needle
+      \param colorGroup Color group, used for painting
+
+      \sa setPalette(), palette()
+    */
+    virtual void drawNeedle( QPainter *painter, 
+        double length, QPalette::ColorGroup colorGroup ) const = 0;
+
+    virtual void drawKnob( QPainter *, double width, 
+        const QBrush &, bool sunken ) const;
+
+private:
+    QPalette d_palette;
+};
+
+/*!
+  \brief A needle for dial widgets
+
+  The following colors are used:
+
+  - QPalette::Mid\n
+    Pointer
+  - QPalette::Base\n
+    Knob
+
+  \sa QwtDial, QwtCompass
+*/
+
+class QWT_EXPORT QwtDialSimpleNeedle: public QwtDialNeedle
+{
+public:
+    //! Style of the needle
+    enum Style
+    {
+        //! Arrow
+        Arrow,
+
+        //! A straight line from the center
+        Ray
+    };
+
+    QwtDialSimpleNeedle( Style, bool hasKnob = true,
+        const QColor &mid = Qt::gray, const QColor &base = Qt::darkGray );
+
+    void setWidth( double width );
+    double width() const;
+
+protected:
+    virtual void drawNeedle( QPainter *, double length,
+        QPalette::ColorGroup ) const;
+
+private:
+    Style d_style;
+    bool d_hasKnob;
+    double d_width;
+};
+
+/*!
+  \brief A magnet needle for compass widgets
+
+  A magnet needle points to two opposite directions indicating
+  north and south.
+
+  The following colors are used:
+  - QPalette::Light\n
+    Used for pointing south
+  - QPalette::Dark\n
+    Used for pointing north
+  - QPalette::Base\n
+    Knob (ThinStyle only)
+
+  \sa QwtDial, QwtCompass
+*/
+
+class QWT_EXPORT QwtCompassMagnetNeedle: public QwtDialNeedle
+{
+public:
+    //! Style of the needle
+    enum Style
+    {
+        //! A needle with a triangular shape
+        TriangleStyle,
+
+        //! A thin needle 
+        ThinStyle
+    };
+
+    QwtCompassMagnetNeedle( Style = TriangleStyle,
+        const QColor &light = Qt::white, const QColor &dark = Qt::red );
+
+protected:
+    virtual void drawNeedle( QPainter *, 
+        double length, QPalette::ColorGroup ) const;
+
+private:
+    Style d_style;
+};
+
+/*!
+  \brief An indicator for the wind direction
+
+  QwtCompassWindArrow shows the direction where the wind comes from.
+
+  - QPalette::Light\n
+    Used for Style1, or the light half of Style2
+  - QPalette::Dark\n
+    Used for the dark half of Style2
+
+  \sa QwtDial, QwtCompass
+*/
+
+class QWT_EXPORT QwtCompassWindArrow: public QwtDialNeedle
+{
+public:
+    //! Style of the arrow
+    enum Style
+    {
+        //! A needle pointing to the center
+        Style1,
+
+        //! A needle pointing to the center
+        Style2
+    };
+
+    QwtCompassWindArrow( Style, const QColor &light = Qt::white,
+        const QColor &dark = Qt::gray );
+
+protected:
+    virtual void drawNeedle( QPainter *, 
+        double length, QPalette::ColorGroup ) const;
+
+private:
+    Style d_style;
+};
+
+#endif 
Index: trunk/BNC/qwt/qwt_dyngrid_layout.cpp
===================================================================
--- trunk/BNC/qwt/qwt_dyngrid_layout.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_dyngrid_layout.cpp	(revision 8127)
@@ -10,5 +10,5 @@
 #include "qwt_dyngrid_layout.h"
 #include "qwt_math.h"
-#include <qwidget.h>
+#include <qvector.h>
 #include <qlist.h>
 
@@ -25,7 +25,7 @@
     mutable QList<QLayoutItem*> itemList;
 
-    uint maxCols;
+    uint maxColumns;
     uint numRows;
-    uint numCols;
+    uint numColumns;
 
     Qt::Orientations expanding;
@@ -82,5 +82,5 @@
 {
     d_data = new QwtDynGridLayout::PrivateData;
-    d_data->maxCols = d_data->numRows = d_data->numCols = 0;
+    d_data->maxColumns = d_data->numRows = d_data->numColumns = 0;
     d_data->expanding = 0;
 }
@@ -105,25 +105,29 @@
 /*!
   Limit the number of columns.
-  \param maxCols upper limit, 0 means unlimited
-  \sa maxCols()
-*/
-void QwtDynGridLayout::setMaxCols( uint maxCols )
-{
-    d_data->maxCols = maxCols;
-}
-
-/*!
-  Return the upper limit for the number of columns.
+  \param maxColumns upper limit, 0 means unlimited
+  \sa maxColumns()
+*/
+void QwtDynGridLayout::setMaxColumns( uint maxColumns )
+{
+    d_data->maxColumns = maxColumns;
+}
+
+/*!
+  \brief Return the upper limit for the number of columns.
+
   0 means unlimited, what is the default.
-  \sa setMaxCols()
-*/
-
-uint QwtDynGridLayout::maxCols() const
-{
-    return d_data->maxCols;
-}
-
-//! Adds item to the next free position.
-
+
+  \return Upper limit for the number of columns
+  \sa setMaxColumns()
+*/
+uint QwtDynGridLayout::maxColumns() const
+{
+    return d_data->maxColumns;
+}
+
+/*! 
+  \brief Add an item to the next free position.
+  \param item Layout item
+ */
 void QwtDynGridLayout::addItem( QLayoutItem *item )
 {
@@ -135,5 +139,4 @@
   \return true if this layout is empty.
 */
-
 bool QwtDynGridLayout::isEmpty() const
 {
@@ -144,5 +147,4 @@
   \return number of layout items
 */
-
 uint QwtDynGridLayout::itemCount() const
 {
@@ -151,7 +153,8 @@
 
 /*!
-  Find the item at a spcific index
+  Find the item at a specific index
 
   \param index Index
+  \return Item at a specific index
   \sa takeAt()
 */
@@ -165,7 +168,8 @@
 
 /*!
-  Find the item at a spcific index and remove it from the layout
+  Find the item at a specific index and remove it from the layout
 
   \param index Index
+  \return Layout item, removed from the layout
   \sa itemAt()
 */
@@ -200,8 +204,11 @@
 
 /*!
-  Returns whether this layout can make use of more space than sizeHint().
+  \brief Returns whether this layout can make use of more space than sizeHint().
+
   A value of Qt::Vertical or Qt::Horizontal means that it wants to grow in only
   one dimension, while Qt::Vertical | Qt::Horizontal means that it wants
   to grow in both dimensions.
+
+  \return Orientations, where the layout expands
   \sa setExpandingDirections()
 */
@@ -212,6 +219,6 @@
 
 /*!
-  Reorganizes columns and rows and resizes managed widgets within
-  the rectangle rect.
+  Reorganizes columns and rows and resizes managed items within
+  a rectangle.
 
   \param rect Layout geometry
@@ -224,10 +231,10 @@
         return;
 
-    d_data->numCols = columnsForWidth( rect.width() );
-    d_data->numRows = itemCount() / d_data->numCols;
-    if ( itemCount() % d_data->numCols )
+    d_data->numColumns = columnsForWidth( rect.width() );
+    d_data->numRows = itemCount() / d_data->numColumns;
+    if ( itemCount() % d_data->numColumns )
         d_data->numRows++;
 
-    QList<QRect> itemGeometries = layoutItems( rect, d_data->numCols );
+    QList<QRect> itemGeometries = layoutItems( rect, d_data->numColumns );
 
     int index = 0;
@@ -235,21 +242,20 @@
         it != d_data->itemList.end(); ++it )
     {
-        QWidget *w = ( *it )->widget();
-        if ( w )
-        {
-            w->setGeometry( itemGeometries[index] );
-            index++;
-        }
-    }
-}
-
-/*!
-  Calculate the number of columns for a given width. It tries to
-  use as many columns as possible (limited by maxCols())
+        ( *it )->setGeometry( itemGeometries[index] );
+        index++;
+    }
+}
+
+/*!
+  \brief Calculate the number of columns for a given width. 
+
+  The calculation tries to use as many columns as possible 
+  ( limited by maxColumns() )
 
   \param width Available width for all columns
-  \sa maxCols(), setMaxCols()
-*/
-
+  \return Number of columns for a given width
+
+  \sa maxColumns(), setMaxColumns()
+*/
 uint QwtDynGridLayout::columnsForWidth( int width ) const
 {
@@ -257,13 +263,16 @@
         return 0;
 
-    const int maxCols = ( d_data->maxCols > 0 ) ? d_data->maxCols : itemCount();
-    if ( maxRowWidth( maxCols ) <= width )
-        return maxCols;
-
-    for ( int numCols = 2; numCols <= maxCols; numCols++ )
-    {
-        const int rowWidth = maxRowWidth( numCols );
+    uint maxColumns = itemCount();
+    if ( d_data->maxColumns > 0 ) 
+        maxColumns = qMin( d_data->maxColumns, maxColumns );
+
+    if ( maxRowWidth( maxColumns ) <= width )
+        return maxColumns;
+
+    for ( uint numColumns = 2; numColumns <= maxColumns; numColumns++ )
+    {
+        const int rowWidth = maxRowWidth( numColumns );
         if ( rowWidth > width )
-            return numCols - 1;
+            return numColumns - 1;
     }
 
@@ -275,13 +284,13 @@
   columns.
 
-  \param numCols Given number of columns
+  \param numColumns Given number of columns
   \param itemWidth Array of the width hints for all items
 */
-int QwtDynGridLayout::maxRowWidth( int numCols ) const
+int QwtDynGridLayout::maxRowWidth( int numColumns ) const
 {
     int col;
 
-    QVector<int> colWidth( numCols );
-    for ( col = 0; col < numCols; col++ )
+    QVector<int> colWidth( numColumns );
+    for ( col = 0; col < numColumns; col++ )
         colWidth[col] = 0;
 
@@ -292,11 +301,11 @@
         index < d_data->itemSizeHints.count(); index++ )
     {
-        col = index % numCols;
+        col = index % numColumns;
         colWidth[col] = qMax( colWidth[col],
             d_data->itemSizeHints[int( index )].width() );
     }
 
-    int rowWidth = 2 * margin() + ( numCols - 1 ) * spacing();
-    for ( col = 0; col < numCols; col++ )
+    int rowWidth = 2 * margin() + ( numColumns - 1 ) * spacing();
+    for ( col = 0; col < numColumns; col++ )
         rowWidth += colWidth[col];
 
@@ -328,26 +337,29 @@
 /*!
   Calculate the geometries of the layout items for a layout
-  with numCols columns and a given rect.
+  with numColumns columns and a given rectangle.
 
   \param rect Rect where to place the items
-  \param numCols Number of columns
+  \param numColumns Number of columns
   \return item geometries
 */
 
 QList<QRect> QwtDynGridLayout::layoutItems( const QRect &rect,
-    uint numCols ) const
+    uint numColumns ) const
 {
     QList<QRect> itemGeometries;
-    if ( numCols == 0 || isEmpty() )
+    if ( numColumns == 0 || isEmpty() )
         return itemGeometries;
 
-    uint numRows = itemCount() / numCols;
-    if ( numRows % itemCount() )
+    uint numRows = itemCount() / numColumns;
+    if ( numColumns % itemCount() )
         numRows++;
 
+    if ( numRows == 0 )
+        return itemGeometries;
+
     QVector<int> rowHeight( numRows );
-    QVector<int> colWidth( numCols );
-
-    layoutGrid( numCols, rowHeight, colWidth );
+    QVector<int> colWidth( numColumns );
+
+    layoutGrid( numColumns, rowHeight, colWidth );
 
     bool expandH, expandV;
@@ -356,15 +368,15 @@
 
     if ( expandH || expandV )
-        stretchGrid( rect, numCols, rowHeight, colWidth );
-
-    const int maxCols = d_data->maxCols;
-    d_data->maxCols = numCols;
+        stretchGrid( rect, numColumns, rowHeight, colWidth );
+
+    const int maxColumns = d_data->maxColumns;
+    d_data->maxColumns = numColumns;
     const QRect alignedRect = alignmentRect( rect );
-    d_data->maxCols = maxCols;
+    d_data->maxColumns = maxColumns;
 
     const int xOffset = expandH ? 0 : alignedRect.x();
     const int yOffset = expandV ? 0 : alignedRect.y();
 
-    QVector<int> colX( numCols );
+    QVector<int> colX( numColumns );
     QVector<int> rowY( numRows );
 
@@ -372,9 +384,9 @@
 
     rowY[0] = yOffset + margin();
-    for ( int r = 1; r < ( int )numRows; r++ )
+    for ( uint r = 1; r < numRows; r++ )
         rowY[r] = rowY[r-1] + rowHeight[r-1] + xySpace;
 
     colX[0] = xOffset + margin();
-    for ( int c = 1; c < ( int )numCols; c++ )
+    for ( uint c = 1; c < numColumns; c++ )
         colX[c] = colX[c-1] + colWidth[c-1] + xySpace;
 
@@ -382,6 +394,6 @@
     for ( int i = 0; i < itemCount; i++ )
     {
-        const int row = i / numCols;
-        const int col = i % numCols;
+        const int row = i / numColumns;
+        const int col = i % numColumns;
 
         QRect itemGeometry( colX[col], rowY[row],
@@ -396,15 +408,15 @@
 /*!
   Calculate the dimensions for the columns and rows for a grid
-  of numCols columns.
-
-  \param numCols Number of columns.
+  of numColumns columns.
+
+  \param numColumns Number of columns.
   \param rowHeight Array where to fill in the calculated row heights.
   \param colWidth Array where to fill in the calculated column widths.
 */
 
-void QwtDynGridLayout::layoutGrid( uint numCols,
+void QwtDynGridLayout::layoutGrid( uint numColumns,
     QVector<int>& rowHeight, QVector<int>& colWidth ) const
 {
-    if ( numCols <= 0 )
+    if ( numColumns <= 0 )
         return;
 
@@ -412,9 +424,8 @@
         d_data->updateLayoutCache();
 
-    for ( uint index = 0;
-        index < ( uint )d_data->itemSizeHints.count(); index++ )
-    {
-        const int row = index / numCols;
-        const int col = index % numCols;
+    for ( int index = 0; index < d_data->itemSizeHints.count(); index++ )
+    {
+        const int row = index / numColumns;
+        const int col = index % numColumns;
 
         const QSize &size = d_data->itemSizeHints[int( index )];
@@ -428,5 +439,5 @@
 
 /*!
-  \return true: QwtDynGridLayout implements heightForWidth.
+  \return true: QwtDynGridLayout implements heightForWidth().
   \sa heightForWidth()
 */
@@ -437,5 +448,5 @@
 
 /*!
-  \return The preferred height for this layout, given the width w.
+  \return The preferred height for this layout, given a width.
   \sa hasHeightForWidth()
 */
@@ -445,16 +456,16 @@
         return 0;
 
-    const uint numCols = columnsForWidth( width );
-    uint numRows = itemCount() / numCols;
-    if ( itemCount() % numCols )
+    const uint numColumns = columnsForWidth( width );
+    uint numRows = itemCount() / numColumns;
+    if ( itemCount() % numColumns )
         numRows++;
 
     QVector<int> rowHeight( numRows );
-    QVector<int> colWidth( numCols );
-
-    layoutGrid( numCols, rowHeight, colWidth );
+    QVector<int> colWidth( numColumns );
+
+    layoutGrid( numColumns, rowHeight, colWidth );
 
     int h = 2 * margin() + ( numRows - 1 ) * spacing();
-    for ( int row = 0; row < ( int )numRows; row++ )
+    for ( uint row = 0; row < numRows; row++ )
         h += rowHeight[row];
 
@@ -467,10 +478,15 @@
   rect. Rows and columns are stretched with the same factor.
 
+  \param rect Bounding rectangle
+  \param numColumns Number of columns
+  \param rowHeight Array to be filled with the calculated row heights
+  \param colWidth Array to be filled with the calculated column widths
+
   \sa setExpanding(), expanding()
 */
 void QwtDynGridLayout::stretchGrid( const QRect &rect,
-    uint numCols, QVector<int>& rowHeight, QVector<int>& colWidth ) const
-{
-    if ( numCols == 0 || isEmpty() )
+    uint numColumns, QVector<int>& rowHeight, QVector<int>& colWidth ) const
+{
+    if ( numColumns == 0 || isEmpty() )
         return;
 
@@ -481,13 +497,13 @@
     if ( expandH )
     {
-        int xDelta = rect.width() - 2 * margin() - ( numCols - 1 ) * spacing();
-        for ( int col = 0; col < ( int )numCols; col++ )
+        int xDelta = rect.width() - 2 * margin() - ( numColumns - 1 ) * spacing();
+        for ( uint col = 0; col < numColumns; col++ )
             xDelta -= colWidth[col];
 
         if ( xDelta > 0 )
         {
-            for ( int col = 0; col < ( int )numCols; col++ )
+            for ( uint col = 0; col < numColumns; col++ )
             {
-                const int space = xDelta / ( numCols - col );
+                const int space = xDelta / ( numColumns - col );
                 colWidth[col] += space;
                 xDelta -= space;
@@ -498,15 +514,15 @@
     if ( expandV )
     {
-        uint numRows = itemCount() / numCols;
-        if ( itemCount() % numCols )
+        uint numRows = itemCount() / numColumns;
+        if ( itemCount() % numColumns )
             numRows++;
 
         int yDelta = rect.height() - 2 * margin() - ( numRows - 1 ) * spacing();
-        for ( int row = 0; row < ( int )numRows; row++ )
+        for ( uint row = 0; row < numRows; row++ )
             yDelta -= rowHeight[row];
 
         if ( yDelta > 0 )
         {
-            for ( int row = 0; row < ( int )numRows; row++ )
+            for ( uint row = 0; row < numRows; row++ )
             {
                 const int space = yDelta / ( numRows - row );
@@ -519,9 +535,10 @@
 
 /*!
-   Return the size hint. If maxCols() > 0 it is the size for
-   a grid with maxCols() columns, otherwise it is the size for
+   Return the size hint. If maxColumns() > 0 it is the size for
+   a grid with maxColumns() columns, otherwise it is the size for
    a grid with only one row.
 
-   \sa maxCols(), setMaxCols()
+   \return Size hint
+   \sa maxColumns(), setMaxColumns()
 */
 QSize QwtDynGridLayout::sizeHint() const
@@ -530,20 +547,23 @@
         return QSize();
 
-    const uint numCols = ( d_data->maxCols > 0 ) ? d_data->maxCols : itemCount();
-    uint numRows = itemCount() / numCols;
-    if ( itemCount() % numCols )
+    uint numColumns = itemCount();
+    if ( d_data->maxColumns > 0 )
+        numColumns = qMin( d_data->maxColumns, numColumns );
+
+    uint numRows = itemCount() / numColumns;
+    if ( itemCount() % numColumns )
         numRows++;
 
     QVector<int> rowHeight( numRows );
-    QVector<int> colWidth( numCols );
-
-    layoutGrid( numCols, rowHeight, colWidth );
+    QVector<int> colWidth( numColumns );
+
+    layoutGrid( numColumns, rowHeight, colWidth );
 
     int h = 2 * margin() + ( numRows - 1 ) * spacing();
-    for ( int row = 0; row < ( int )numRows; row++ )
+    for ( uint row = 0; row < numRows; row++ )
         h += rowHeight[row];
 
-    int w = 2 * margin() + ( numCols - 1 ) * spacing();
-    for ( int col = 0; col < ( int )numCols; col++ )
+    int w = 2 * margin() + ( numColumns - 1 ) * spacing();
+    for ( uint col = 0; col < numColumns; col++ )
         w += colWidth[col];
 
@@ -553,5 +573,5 @@
 /*!
   \return Number of rows of the current layout.
-  \sa numCols()
+  \sa numColumns()
   \warning The number of rows might change whenever the geometry changes
 */
@@ -566,6 +586,6 @@
   \warning The number of columns might change whenever the geometry changes
 */
-uint QwtDynGridLayout::numCols() const
-{
-    return d_data->numCols;
-}
+uint QwtDynGridLayout::numColumns() const
+{
+    return d_data->numColumns;
+}
Index: trunk/BNC/qwt/qwt_dyngrid_layout.h
===================================================================
--- trunk/BNC/qwt/qwt_dyngrid_layout.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_dyngrid_layout.h	(revision 8127)
@@ -22,5 +22,5 @@
   QwtDynGridLayout takes the space it gets, divides it up into rows and
   columns, and puts each of the widgets it manages into the correct cell(s).
-  It lays out as many number of columns as possible (limited by maxCols()).
+  It lays out as many number of columns as possible (limited by maxColumns()).
 */
 
@@ -36,9 +36,9 @@
     virtual void invalidate();
 
-    void setMaxCols( uint maxCols );
-    uint maxCols() const;
+    void setMaxColumns( uint maxCols );
+    uint maxColumns() const;
 
     uint numRows () const;
-    uint numCols () const;
+    uint numColumns () const;
 
     virtual void addItem( QLayoutItem * );
Index: trunk/BNC/qwt/qwt_event_pattern.cpp
===================================================================
--- trunk/BNC/qwt/qwt_event_pattern.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_event_pattern.cpp	(revision 8127)
@@ -38,8 +38,4 @@
 void QwtEventPattern::initMousePattern( int numButtons )
 {
-    const int altButton = Qt::AltModifier;
-    const int controlButton = Qt::ControlModifier;
-    const int shiftButton = Qt::ShiftModifier;
-
     d_mousePattern.resize( MousePatternCount );
 
@@ -49,6 +45,6 @@
         {
             setMousePattern( MouseSelect1, Qt::LeftButton );
-            setMousePattern( MouseSelect2, Qt::LeftButton, controlButton );
-            setMousePattern( MouseSelect3, Qt::LeftButton, altButton );
+            setMousePattern( MouseSelect2, Qt::LeftButton, Qt::ControlModifier );
+            setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier );
             break;
         }
@@ -57,5 +53,5 @@
             setMousePattern( MouseSelect1, Qt::LeftButton );
             setMousePattern( MouseSelect2, Qt::RightButton );
-            setMousePattern( MouseSelect3, Qt::LeftButton, altButton );
+            setMousePattern( MouseSelect3, Qt::LeftButton, Qt::AltModifier );
             break;
         }
@@ -67,10 +63,13 @@
         }
     }
-    for ( int i = 0; i < 3; i++ )
-    {
-        setMousePattern( MouseSelect4 + i,
-                         d_mousePattern[MouseSelect1 + i].button,
-                         d_mousePattern[MouseSelect1 + i].state | shiftButton );
-    }
+
+    setMousePattern( MouseSelect4, d_mousePattern[MouseSelect1].button,
+        d_mousePattern[MouseSelect1].modifiers | Qt::ShiftModifier );
+
+    setMousePattern( MouseSelect5, d_mousePattern[MouseSelect2].button,
+        d_mousePattern[MouseSelect2].modifiers | Qt::ShiftModifier );
+
+    setMousePattern( MouseSelect6, d_mousePattern[MouseSelect3].button,
+        d_mousePattern[MouseSelect3].modifiers | Qt::ShiftModifier );
 }
 
@@ -103,14 +102,15 @@
   \param pattern Index of the pattern
   \param button Button
-  \param state State
+  \param modifiers Keyboard modifiers
 
   \sa QMouseEvent
 */
-void QwtEventPattern::setMousePattern( uint pattern, int button, int state )
-{
-    if ( pattern < ( uint )d_mousePattern.count() )
+void QwtEventPattern::setMousePattern( MousePatternCode pattern, 
+    Qt::MouseButton button, Qt::KeyboardModifiers modifiers )
+{
+    if ( pattern >= 0 && pattern < MousePatternCount )
     {
-        d_mousePattern[int( pattern )].button = button;
-        d_mousePattern[int( pattern )].state = state;
+        d_mousePattern[ pattern ].button = button;
+        d_mousePattern[ pattern ].modifiers = modifiers;
     }
 }
@@ -121,14 +121,15 @@
   \param pattern Index of the pattern
   \param key Key
-  \param state State
+  \param modifiers Keyboard modifiers
 
   \sa QKeyEvent
 */
-void QwtEventPattern::setKeyPattern( uint pattern, int key, int state )
-{
-    if ( pattern < ( uint )d_keyPattern.count() )
+void QwtEventPattern::setKeyPattern( KeyPatternCode pattern, 
+    int key, Qt::KeyboardModifiers modifiers )
+{
+    if ( pattern >= 0 && pattern < KeyPatternCount )
     {
-        d_keyPattern[int( pattern )].key = key;
-        d_keyPattern[int( pattern )].state = state;
+        d_keyPattern[ pattern ].key = key;
+        d_keyPattern[ pattern ].modifiers = modifiers;
     }
 }
@@ -146,5 +147,5 @@
 }
 
-//! Return mouse patterns
+//! \return Mouse pattern
 const QVector<QwtEventPattern::MousePattern> &
 QwtEventPattern::mousePattern() const
@@ -153,5 +154,5 @@
 }
 
-//! Return key patterns
+//! \return Key pattern
 const QVector<QwtEventPattern::KeyPattern> &
 QwtEventPattern::keyPattern() const
@@ -160,5 +161,5 @@
 }
 
-//! Return ,ouse patterns
+//! \return Mouse pattern
 QVector<QwtEventPattern::MousePattern> &QwtEventPattern::mousePattern()
 {
@@ -166,5 +167,5 @@
 }
 
-//! Return Key patterns
+//! \return Key pattern
 QVector<QwtEventPattern::KeyPattern> &QwtEventPattern::keyPattern()
 {
@@ -179,5 +180,5 @@
   are set.
 
-  \param pattern Index of the event pattern
+  \param code Index of the event pattern
   \param event Mouse event
   \return true if matches
@@ -185,13 +186,11 @@
   \sa keyMatch()
 */
-bool QwtEventPattern::mouseMatch( uint pattern, 
+bool QwtEventPattern::mouseMatch( MousePatternCode code, 
     const QMouseEvent *event ) const
 {
-    bool ok = false;
-
-    if ( event && pattern < ( uint )d_mousePattern.count() )
-        ok = mouseMatch( d_mousePattern[int( pattern )], event );
-
-    return ok;
+    if ( code >= 0 && code < MousePatternCount )
+        return mouseMatch( d_mousePattern[ code ], event );
+
+    return false;
 }
 
@@ -213,12 +212,9 @@
     const QMouseEvent *event ) const
 {
-    if ( event->button() != pattern.button )
+    if ( event == NULL )
         return false;
 
-    const bool matched =
-        ( event->modifiers() & Qt::KeyboardModifierMask ) ==
-            ( int )( pattern.state & Qt::KeyboardModifierMask );
-
-    return matched;
+    const MousePattern mousePattern( event->button(), event->modifiers() );
+    return mousePattern == pattern;
 }
 
@@ -230,5 +226,5 @@
   are set.
 
-  \param pattern Index of the event pattern
+  \param code Index of the event pattern
   \param event Key event
   \return true if matches
@@ -236,13 +232,11 @@
   \sa mouseMatch()
 */
-bool QwtEventPattern::keyMatch( uint pattern, 
+bool QwtEventPattern::keyMatch( KeyPatternCode code, 
     const QKeyEvent *event ) const
 {
-    bool ok = false;
-
-    if ( event && pattern < ( uint )d_keyPattern.count() )
-        ok = keyMatch( d_keyPattern[int( pattern )], event );
-
-    return ok;
+    if ( code >= 0 && code < KeyPatternCount )
+        return keyMatch( d_keyPattern[ code ], event );
+
+    return false;
 }
 
@@ -264,11 +258,8 @@
     const KeyPattern &pattern, const QKeyEvent *event ) const
 {
-    if ( event->key() != pattern.key )
+    if ( event == NULL )
         return false;
 
-    const bool matched =
-        ( event->modifiers() & Qt::KeyboardModifierMask ) ==
-            ( int )( pattern.state & Qt::KeyboardModifierMask );
-
-    return matched;
-}
+    const KeyPattern keyPattern( event->key(), event->modifiers() );
+    return keyPattern == pattern;
+}
Index: trunk/BNC/qwt/qwt_event_pattern.h
===================================================================
--- trunk/BNC/qwt/qwt_event_pattern.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_event_pattern.h	(revision 8127)
@@ -33,58 +33,70 @@
       \brief Symbolic mouse input codes
 
-      The default initialization for 3 button mice is:
-      - MouseSelect1\n
-        Qt::LeftButton
-      - MouseSelect2\n
-        Qt::RightButton
-      - MouseSelect3\n
-        Qt::MidButton
-      - MouseSelect4\n
-        Qt::LeftButton + Qt::ShiftButton
-      - MouseSelect5\n
-        Qt::RightButton + Qt::ShiftButton
-      - MouseSelect6\n
-        Qt::MidButton + Qt::ShiftButton
-
-      The default initialization for 2 button mice is:
-      - MouseSelect1\n
-        Qt::LeftButton
-      - MouseSelect2\n
-        Qt::RightButton
-      - MouseSelect3\n
-        Qt::LeftButton + Qt::AltButton
-      - MouseSelect4\n
-        Qt::LeftButton + Qt::ShiftButton
-      - MouseSelect5\n
-        Qt::RightButton + Qt::ShiftButton
-      - MouseSelect6\n
-        Qt::LeftButton + Qt::AltButton + Qt::ShiftButton
-
-      The default initialization for 1 button mice is:
-      - MouseSelect1\n
-        Qt::LeftButton
-      - MouseSelect2\n
-        Qt::LeftButton + Qt::ControlButton
-      - MouseSelect3\n
-        Qt::LeftButton + Qt::AltButton
-      - MouseSelect4\n
-        Qt::LeftButton + Qt::ShiftButton
-      - MouseSelect5\n
-        Qt::LeftButton + Qt::ControlButton + Qt::ShiftButton
-      - MouseSelect6\n
-        Qt::LeftButton + Qt::AltButton + Qt::ShiftButton
-
-      \sa initMousePattern()
+      QwtEventPattern implements 3 different settings for
+      mice with 1, 2, or 3 buttons that can be activated
+      using initMousePattern(). The default setting is for
+      3 button mice.
+
+      Individual settings can be configured using setMousePattern().
+
+      \sa initMousePattern(), setMousePattern(), setKeyPattern()
     */
-
     enum MousePatternCode
     {
+        /*! 
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton 
+          - Qt::LeftButton 
+          - Qt::LeftButton 
+         */
         MouseSelect1,
+
+        /*!
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton + Qt::ControlModifier
+          - Qt::RightButton
+          - Qt::RightButton
+         */
         MouseSelect2,
+
+        /*!
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton + Qt::AltModifier
+          - Qt::LeftButton + Qt::AltModifier
+          - Qt::MidButton
+         */
         MouseSelect3,
+
+        /*!
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton + Qt::ShiftModifier
+          - Qt::LeftButton + Qt::ShiftModifier
+          - Qt::LeftButton + Qt::ShiftModifier
+         */
         MouseSelect4,
+
+        /*!
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton + Qt::ControlButton | Qt::ShiftModifier
+          - Qt::RightButton + Qt::ShiftModifier
+          - Qt::RightButton + Qt::ShiftModifier
+         */
         MouseSelect5,
+
+        /*!
+          The default setting for 1, 2 and 3 button mice is:
+
+          - Qt::LeftButton + Qt::AltModifier + Qt::ShiftModifier
+          - Qt::LeftButton + Qt::AltModifier | Qt::ShiftModifier
+          - Qt::MidButton + Qt::ShiftModifier
+         */
         MouseSelect6,
 
+        //! Number of mouse patterns
         MousePatternCount
     };
@@ -93,43 +105,41 @@
       \brief Symbolic keyboard input codes
 
-      Default initialization:
-      - KeySelect1\n
-        Qt::Key_Return
-      - KeySelect2\n
-        Qt::Key_Space
-      - KeyAbort\n
-        Qt::Key_Escape
-
-      - KeyLeft\n
-        Qt::Key_Left
-      - KeyRight\n
-        Qt::Key_Right
-      - KeyUp\n
-        Qt::Key_Up
-      - KeyDown\n
-        Qt::Key_Down
-
-      - KeyUndo\n
-        Qt::Key_Minus
-      - KeyRedo\n
-        Qt::Key_Plus
-      - KeyHome\n
-        Qt::Key_Escape
+      Individual settings can be configured using setKeyPattern()
+
+      \sa setKeyPattern(), setMousePattern()
     */
     enum KeyPatternCode
     {
+        //! Qt::Key_Return
         KeySelect1,
+
+        //! Qt::Key_Space
         KeySelect2,
+
+        //! Qt::Key_Escape
         KeyAbort,
 
+        //! Qt::Key_Left
         KeyLeft,
+
+        //! Qt::Key_Right
         KeyRight,
+
+        //! Qt::Key_Up
         KeyUp,
+
+        //! Qt::Key_Down
         KeyDown,
 
+        //! Qt::Key_Plus
         KeyRedo,
+
+        //! Qt::Key_Minus
         KeyUndo,
+
+        //! Qt::Key_Escape
         KeyHome,
 
+        //! Number of key patterns
         KeyPatternCount
     };
@@ -140,15 +150,16 @@
     public:
         //! Constructor
-        MousePattern( int btn = Qt::NoButton, int st = Qt::NoButton )
+        MousePattern( Qt::MouseButton btn = Qt::NoButton, 
+                Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
+            button( btn ),
+            modifiers( modifierCodes )
         {
-            button = btn;
-            state = st;
         }
 
-        //! Button code
-        int button;
-
-        //! State
-        int state;
+        //! Button 
+        Qt::MouseButton button;
+
+        //! Keyboard modifier
+        Qt::KeyboardModifiers modifiers;
     };
 
@@ -158,8 +169,9 @@
     public:
         //! Constructor
-        KeyPattern( int k = 0, int st = Qt::NoButton )
+        KeyPattern( int keyCode = Qt::Key_unknown, 
+                Qt::KeyboardModifiers modifierCodes = Qt::NoModifier ):
+            key( keyCode ),
+            modifiers( modifierCodes )
         {
-            key = k;
-            state = st;
         }
 
@@ -167,6 +179,6 @@
         int key;
 
-        //! State
-        int state;
+        //! Modifiers
+        Qt::KeyboardModifiers modifiers;
     };
 
@@ -177,6 +189,9 @@
     void initKeyPattern();
 
-    void setMousePattern( uint pattern, int button, int state = Qt::NoButton );
-    void setKeyPattern( uint pattern, int key, int state = Qt::NoButton );
+    void setMousePattern( MousePatternCode, Qt::MouseButton button, 
+        Qt::KeyboardModifiers = Qt::NoModifier );
+
+    void setKeyPattern( KeyPatternCode, int keyCode, 
+        Qt::KeyboardModifiers modifierCodes = Qt::NoModifier );
 
     void setMousePattern( const QVector<MousePattern> & );
@@ -189,6 +204,6 @@
     QVector<KeyPattern> &keyPattern();
 
-    bool mouseMatch( uint pattern, const QMouseEvent * ) const;
-    bool keyMatch( uint pattern, const QKeyEvent * ) const;
+    bool mouseMatch( MousePatternCode, const QMouseEvent * ) const;
+    bool keyMatch( KeyPatternCode, const QKeyEvent * ) const;
 
 protected:
@@ -213,5 +228,5 @@
     QwtEventPattern::MousePattern  b2 )
 {
-    return b1.button == b2.button && b1.state == b2.state;
+    return b1.button == b2.button && b1.modifiers == b2.modifiers;
 }
 
@@ -220,5 +235,5 @@
    QwtEventPattern::KeyPattern  b2 )
 {
-    return b1.key == b2.key && b1.state == b2.state;
+    return b1.key == b2.key && b1.modifiers == b2.modifiers;
 }
 
Index: trunk/BNC/qwt/qwt_global.h
===================================================================
--- trunk/BNC/qwt/qwt_global.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_global.h	(revision 8127)
@@ -15,12 +15,12 @@
 // QWT_VERSION is (major << 16) + (minor << 8) + patch.
 
-#define QWT_VERSION       0x060001
-#define QWT_VERSION_STR   "6.0.1"
-
-#if defined(Q_WS_WIN) || defined(Q_WS_S60)
+#define QWT_VERSION       0x060104
+#define QWT_VERSION_STR   "6.1.4"
 
 #if defined(_MSC_VER) /* MSVC Compiler */
 /* template-class specialization 'identifier' is already instantiated */
 #pragma warning(disable: 4660)
+/* inherits via dominance */
+#pragma warning(disable: 4250)
 #endif // _MSC_VER
 
@@ -28,13 +28,10 @@
 
 #if defined(QWT_MAKEDLL)     // create a Qwt DLL library 
-#define QWT_EXPORT  __declspec(dllexport)
-#define QWT_TEMPLATEDLL
+#define QWT_EXPORT Q_DECL_EXPORT
 #else                        // use a Qwt DLL library
-#define QWT_EXPORT  __declspec(dllimport)
+#define QWT_EXPORT Q_DECL_IMPORT 
 #endif
 
 #endif // QWT_DLL
-
-#endif // Q_WS_WIN || Q_WS_S60
 
 #ifndef QWT_EXPORT
@@ -42,5 +39,3 @@
 #endif
 
-// #define QWT_NO_COMPAT 1 // disable withdrawn functionality
-
 #endif 
Index: trunk/BNC/qwt/qwt_graphic.cpp
===================================================================
--- trunk/BNC/qwt/qwt_graphic.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_graphic.cpp	(revision 8127)
@@ -0,0 +1,1009 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_graphic.h"
+#include "qwt_painter_command.h"
+#include <qvector.h>
+#include <qpainter.h>
+#include <qpaintengine.h>
+#include <qimage.h>
+#include <qpixmap.h>
+#include <qpainterpath.h>
+#include <qmath.h>
+
+static bool qwtHasScalablePen( const QPainter *painter )
+{
+    const QPen pen = painter->pen();
+
+    bool scalablePen = false;
+
+    if ( pen.style() != Qt::NoPen && pen.brush().style() != Qt::NoBrush )
+    {
+        scalablePen = !pen.isCosmetic();
+        if ( !scalablePen && pen.widthF() == 0.0 )
+        {
+            const QPainter::RenderHints hints = painter->renderHints();
+            if ( hints.testFlag( QPainter::NonCosmeticDefaultPen ) )
+                scalablePen = true;
+        }
+    }
+
+    return scalablePen;
+}
+
+static QRectF qwtStrokedPathRect( 
+    const QPainter *painter, const QPainterPath &path )
+{
+    QPainterPathStroker stroker;
+    stroker.setWidth( painter->pen().widthF() );
+    stroker.setCapStyle( painter->pen().capStyle() );
+    stroker.setJoinStyle( painter->pen().joinStyle() );
+    stroker.setMiterLimit( painter->pen().miterLimit() );
+
+    QRectF rect;
+    if ( qwtHasScalablePen( painter ) )
+    {
+        QPainterPath stroke = stroker.createStroke(path);
+        rect = painter->transform().map(stroke).boundingRect();
+    }
+    else
+    {
+        QPainterPath mappedPath = painter->transform().map(path);
+        mappedPath = stroker.createStroke( mappedPath );
+
+        rect = mappedPath.boundingRect();
+    }
+
+    return rect;
+}
+
+static inline void qwtExecCommand( 
+    QPainter *painter, const QwtPainterCommand &cmd, 
+    QwtGraphic::RenderHints renderHints,
+    const QTransform &transform,
+    const QTransform *initialTransform )
+{
+    switch( cmd.type() )
+    {
+        case QwtPainterCommand::Path:
+        {
+            bool doMap = false;
+
+            if ( renderHints.testFlag( QwtGraphic::RenderPensUnscaled )
+                && painter->transform().isScaling() )
+            {
+                bool isCosmetic = painter->pen().isCosmetic();
+                if ( isCosmetic && painter->pen().widthF() == 0.0 )
+                {
+                    QPainter::RenderHints hints = painter->renderHints();
+                    if ( hints.testFlag( QPainter::NonCosmeticDefaultPen ) )
+                        isCosmetic = false;
+                }
+
+                doMap = !isCosmetic;
+            }
+
+            if ( doMap )
+            {
+                const QTransform tr = painter->transform();
+
+                painter->resetTransform();
+
+                QPainterPath path = tr.map( *cmd.path() );
+                if ( initialTransform )
+                {
+                    painter->setTransform( *initialTransform );
+                    path = initialTransform->inverted().map( path );
+                }
+
+                painter->drawPath( path );
+
+                painter->setTransform( tr );
+            }
+            else
+            {
+                painter->drawPath( *cmd.path() );
+            }
+            break;
+        }
+        case QwtPainterCommand::Pixmap:
+        {
+            const QwtPainterCommand::PixmapData *data = cmd.pixmapData();
+            painter->drawPixmap( data->rect, data->pixmap, data->subRect );
+            break;
+        }
+        case QwtPainterCommand::Image:
+        {
+            const QwtPainterCommand::ImageData *data = cmd.imageData();
+            painter->drawImage( data->rect, data->image, 
+                data->subRect, data->flags );
+            break;
+        }
+        case QwtPainterCommand::State:
+        {
+            const QwtPainterCommand::StateData *data = cmd.stateData();
+
+            if ( data->flags & QPaintEngine::DirtyPen ) 
+                painter->setPen( data->pen );
+
+            if ( data->flags & QPaintEngine::DirtyBrush ) 
+                painter->setBrush( data->brush );
+
+            if ( data->flags & QPaintEngine::DirtyBrushOrigin ) 
+                painter->setBrushOrigin( data->brushOrigin );
+
+            if ( data->flags & QPaintEngine::DirtyFont ) 
+                painter->setFont( data->font );
+
+            if ( data->flags & QPaintEngine::DirtyBackground ) 
+            {
+                painter->setBackgroundMode( data->backgroundMode );
+                painter->setBackground( data->backgroundBrush );
+            }
+
+            if ( data->flags & QPaintEngine::DirtyTransform ) 
+            {
+                painter->setTransform( data->transform * transform );
+            }
+
+            if ( data->flags & QPaintEngine::DirtyClipEnabled ) 
+                painter->setClipping( data->isClipEnabled );
+
+            if ( data->flags & QPaintEngine::DirtyClipRegion) 
+            {
+                painter->setClipRegion( data->clipRegion, 
+                    data->clipOperation );
+            }
+
+            if ( data->flags & QPaintEngine::DirtyClipPath ) 
+            {
+                painter->setClipPath( data->clipPath, data->clipOperation );
+            }
+
+            if ( data->flags & QPaintEngine::DirtyHints) 
+            {
+                const QPainter::RenderHints hints = data->renderHints;
+
+                painter->setRenderHint( QPainter::Antialiasing,
+                    hints.testFlag( QPainter::Antialiasing ) );
+
+                painter->setRenderHint( QPainter::TextAntialiasing,
+                    hints.testFlag( QPainter::TextAntialiasing ) );
+
+                painter->setRenderHint( QPainter::SmoothPixmapTransform,
+                    hints.testFlag( QPainter::SmoothPixmapTransform ) );
+
+                painter->setRenderHint( QPainter::HighQualityAntialiasing,
+                    hints.testFlag( QPainter::HighQualityAntialiasing ) );
+
+                painter->setRenderHint( QPainter::NonCosmeticDefaultPen,
+                    hints.testFlag( QPainter::NonCosmeticDefaultPen ) );
+            }
+
+            if ( data->flags & QPaintEngine::DirtyCompositionMode) 
+                painter->setCompositionMode( data->compositionMode );
+
+            if ( data->flags & QPaintEngine::DirtyOpacity) 
+                painter->setOpacity( data->opacity );
+
+            break;
+        }
+        default:
+            break;
+    }
+
+}
+
+class QwtGraphic::PathInfo
+{
+public:
+    PathInfo():
+        d_scalablePen( false )
+    {
+        // QVector needs a default constructor
+    }
+
+    PathInfo( const QRectF &pointRect, 
+            const QRectF &boundingRect, bool scalablePen ):
+        d_pointRect( pointRect ),
+        d_boundingRect( boundingRect ),
+        d_scalablePen( scalablePen )
+    {
+    }
+
+    inline QRectF scaledBoundingRect( double sx, double sy,
+        bool scalePens ) const
+    {
+        if ( sx == 1.0 && sy == 1.0 )
+            return d_boundingRect;
+
+        QTransform transform;
+        transform.scale( sx, sy );
+
+        QRectF rect;
+        if ( scalePens && d_scalablePen )
+        {
+            rect = transform.mapRect( d_boundingRect );
+        }
+        else
+        {
+            rect = transform.mapRect( d_pointRect );
+
+            const double l = qAbs( d_pointRect.left() - d_boundingRect.left() );
+            const double r = qAbs( d_pointRect.right() - d_boundingRect.right() );
+            const double t = qAbs( d_pointRect.top() - d_boundingRect.top() );
+            const double b = qAbs( d_pointRect.bottom() - d_boundingRect.bottom() );
+
+            rect.adjust( -l, -t, r, b );
+        }
+
+        return rect;
+    }
+
+    inline double scaleFactorX( const QRectF& pathRect, 
+        const QRectF &targetRect, bool scalePens ) const
+    {
+        if ( pathRect.width() <= 0.0 )
+            return 0.0;
+
+        const QPointF p0 = d_pointRect.center();
+
+        const double l = qAbs( pathRect.left() - p0.x() );
+        const double r = qAbs( pathRect.right() - p0.x() );
+
+        const double w = 2.0 * qMin( l, r ) 
+            * targetRect.width() / pathRect.width();
+
+        double sx;
+        if ( scalePens && d_scalablePen )
+        {
+            sx = w / d_boundingRect.width();
+        }
+        else
+        {
+            const double pw = qMax( 
+                qAbs( d_boundingRect.left() - d_pointRect.left() ),
+                qAbs( d_boundingRect.right() - d_pointRect.right() ) );
+
+            sx = ( w - 2 * pw ) / d_pointRect.width();
+        }
+
+        return sx;
+    }
+
+    inline double scaleFactorY( const QRectF& pathRect, 
+        const QRectF &targetRect, bool scalePens ) const
+    {
+        if ( pathRect.height() <= 0.0 )
+            return 0.0;
+
+        const QPointF p0 = d_pointRect.center();
+
+        const double t = qAbs( pathRect.top() - p0.y() );
+        const double b = qAbs( pathRect.bottom() - p0.y() );
+
+        const double h = 2.0 * qMin( t, b ) 
+            * targetRect.height() / pathRect.height();
+
+        double sy;
+        if ( scalePens && d_scalablePen )
+        {
+            sy = h / d_boundingRect.height();
+        }
+        else
+        {
+            const double pw = 
+                qMax( qAbs( d_boundingRect.top() - d_pointRect.top() ),
+                qAbs( d_boundingRect.bottom() - d_pointRect.bottom() ) );
+
+            sy = ( h - 2 * pw ) / d_pointRect.height();
+        }
+
+        return sy;
+    }
+
+private:
+    QRectF d_pointRect;
+    QRectF d_boundingRect;
+    bool d_scalablePen;
+};
+
+class QwtGraphic::PrivateData
+{
+public:
+    PrivateData():
+        boundingRect( 0.0, 0.0, -1.0, -1.0 ),
+        pointRect( 0.0, 0.0, -1.0, -1.0 ),
+        initialTransform( NULL )
+    {
+    }
+
+    QSizeF defaultSize;
+    QVector<QwtPainterCommand> commands;
+    QVector<QwtGraphic::PathInfo> pathInfos;
+
+    QRectF boundingRect;
+    QRectF pointRect;
+
+    QwtGraphic::RenderHints renderHints;
+    QTransform *initialTransform;
+};
+
+/*!
+  \brief Constructor
+
+  Initializes a null graphic
+  \sa isNull()
+ */
+QwtGraphic::QwtGraphic():
+    QwtNullPaintDevice()
+{
+    setMode( QwtNullPaintDevice::PathMode );
+    d_data = new PrivateData;
+}
+
+/*!
+  \brief Copy constructor
+
+  \param other Source 
+  \sa operator=()
+ */
+QwtGraphic::QwtGraphic( const QwtGraphic &other ):
+    QwtNullPaintDevice()
+{
+    setMode( other.mode() );
+    d_data = new PrivateData( *other.d_data );
+}
+
+//! Destructor
+QwtGraphic::~QwtGraphic()
+{
+    delete d_data;
+}
+
+/*!
+  \brief Assignment operator
+
+  \param other Source 
+  \return A reference of this object
+ */
+QwtGraphic& QwtGraphic::operator=(const QwtGraphic &other)
+{
+    setMode( other.mode() );
+    *d_data = *other.d_data;
+
+    return *this;
+}
+
+/*!
+  \brief Clear all stored commands 
+  \sa isNull()
+ */
+void QwtGraphic::reset() 
+{
+    d_data->commands.clear();
+    d_data->pathInfos.clear();
+
+    d_data->boundingRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
+    d_data->pointRect = QRectF( 0.0, 0.0, -1.0, -1.0 );
+    d_data->defaultSize = QSizeF();
+
+}
+
+/*!
+  \return True, when no painter commands have been stored
+  \sa isEmpty(), commands()
+*/
+bool QwtGraphic::isNull() const
+{
+    return d_data->commands.isEmpty();
+}
+
+/*!
+  \return True, when the bounding rectangle is empty
+  \sa boundingRect(), isNull()
+*/
+bool QwtGraphic::isEmpty() const
+{
+    return d_data->boundingRect.isEmpty();
+}
+
+/*!
+  Toggle an render hint
+
+  \param hint Render hint
+  \param on true/false
+
+  \sa testRenderHint(), RenderHint
+*/
+void QwtGraphic::setRenderHint( RenderHint hint, bool on )
+{
+    if ( on )
+        d_data->renderHints |= hint;
+    else
+        d_data->renderHints &= ~hint;
+}
+
+/*!
+  Test a render hint
+
+  \param hint Render hint
+  \return true/false
+  \sa setRenderHint(), RenderHint
+*/
+bool QwtGraphic::testRenderHint( RenderHint hint ) const
+{
+    return d_data->renderHints.testFlag( hint );
+}
+
+/*!
+  The bounding rectangle is the controlPointRect()
+  extended by the areas needed for rendering the outlines
+  with unscaled pens.
+
+  \return Bounding rectangle of the graphic
+  \sa controlPointRect(), scaledBoundingRect()
+ */
+QRectF QwtGraphic::boundingRect() const
+{
+    if ( d_data->boundingRect.width() < 0 )
+        return QRectF();
+
+    return d_data->boundingRect;
+}
+
+/*!
+  The control point rectangle is the bounding rectangle 
+  of all control points of the paths and the target
+  rectangles of the images/pixmaps.
+
+  \return Control point rectangle
+  \sa boundingRect(), scaledBoundingRect()
+ */
+QRectF QwtGraphic::controlPointRect() const
+{
+    if ( d_data->pointRect.width() < 0 )
+        return QRectF();
+
+    return d_data->pointRect;
+}
+
+/*!
+  \brief Calculate the target rectangle for scaling the graphic
+
+  \param sx Horizontal scaling factor 
+  \param sy Vertical scaling factor 
+
+  \note In case of paths that are painted with a cosmetic pen 
+        ( see QPen::isCosmetic() ) the target rectangle is different to
+        multiplying the bounding rectangle.
+
+  \return Scaled bounding rectangle
+  \sa boundingRect(), controlPointRect()
+ */
+QRectF QwtGraphic::scaledBoundingRect( double sx, double sy ) const
+{
+    if ( sx == 1.0 && sy == 1.0 )
+        return d_data->boundingRect;
+
+    QTransform transform;
+    transform.scale( sx, sy );
+
+    QRectF rect = transform.mapRect( d_data->pointRect );
+
+    for ( int i = 0; i < d_data->pathInfos.size(); i++ )
+    {
+        rect |= d_data->pathInfos[i].scaledBoundingRect( sx, sy, 
+            !d_data->renderHints.testFlag( RenderPensUnscaled ) );
+    }
+
+    return rect;
+}
+
+//! \return Ceiled defaultSize()
+QSize QwtGraphic::sizeMetrics() const
+{
+    const QSizeF sz = defaultSize();
+    return QSize( qCeil( sz.width() ), qCeil( sz.height() ) );
+}
+
+/*!
+  \brief Set a default size
+
+  The default size is used in all methods rendering the graphic,
+  where no size is explicitly specified. Assigning an empty size
+  means, that the default size will be calculated from the bounding 
+  rectangle.
+
+  The default setting is an empty size.
+    
+  \param size Default size
+
+  \sa defaultSize(), boundingRect()
+ */
+void QwtGraphic::setDefaultSize( const QSizeF &size )
+{
+    const double w = qMax( qreal( 0.0 ), size.width() );
+    const double h = qMax( qreal( 0.0 ), size.height() );
+
+    d_data->defaultSize = QSizeF( w, h );
+}
+
+/*!
+  \brief Default size
+
+  When a non empty size has been assigned by setDefaultSize() this
+  size will be returned. Otherwise the default size is the size
+  of the bounding rectangle.
+
+  The default size is used in all methods rendering the graphic,
+  where no size is explicitly specified. 
+
+  \return Default size
+  \sa setDefaultSize(), boundingRect()
+ */
+QSizeF QwtGraphic::defaultSize() const
+{
+    if ( !d_data->defaultSize.isEmpty() )
+        return d_data->defaultSize;
+
+    return boundingRect().size();
+}
+
+/*!
+  \brief Replay all recorded painter commands
+  \param painter Qt painter
+ */
+void QwtGraphic::render( QPainter *painter ) const
+{
+    if ( isNull() )
+        return;
+
+    const int numCommands = d_data->commands.size();
+    const QwtPainterCommand *commands = d_data->commands.constData();
+
+    const QTransform transform = painter->transform();
+
+    painter->save();
+
+    for ( int i = 0; i < numCommands; i++ )
+    {
+        qwtExecCommand( painter, commands[i], 
+            d_data->renderHints, transform, d_data->initialTransform );
+    }
+
+    painter->restore();
+}
+
+/*!
+  \brief Replay all recorded painter commands
+
+  The graphic is scaled to fit into the rectangle
+  of the given size starting at ( 0, 0 ).
+
+  \param painter Qt painter
+  \param size Size for the scaled graphic
+  \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode
+ */
+void QwtGraphic::render( QPainter *painter, const QSizeF &size, 
+    Qt::AspectRatioMode aspectRatioMode ) const
+{
+    const QRectF r( 0.0, 0.0, size.width(), size.height() );
+    render( painter, r, aspectRatioMode );
+}
+
+/*!
+  \brief Replay all recorded painter commands
+
+  The graphic is scaled to fit into the given rectangle
+
+  \param painter Qt painter
+  \param rect Rectangle for the scaled graphic
+  \param aspectRatioMode Mode how to scale - See Qt::AspectRatioMode
+ */
+void QwtGraphic::render( QPainter *painter, const QRectF &rect, 
+    Qt::AspectRatioMode aspectRatioMode ) const
+{
+    if ( isEmpty() || rect.isEmpty() )
+        return;
+
+    double sx = 1.0; 
+    double sy = 1.0;
+
+    if ( d_data->pointRect.width() > 0.0 )
+        sx = rect.width() / d_data->pointRect.width();
+
+    if ( d_data->pointRect.height() > 0.0 )
+        sy = rect.height() / d_data->pointRect.height();
+
+    const bool scalePens = 
+        !d_data->renderHints.testFlag( RenderPensUnscaled );
+
+    for ( int i = 0; i < d_data->pathInfos.size(); i++ )
+    {
+        const PathInfo info = d_data->pathInfos[i];
+
+        const double ssx = info.scaleFactorX( 
+            d_data->pointRect, rect, scalePens );
+
+        if ( ssx > 0.0 )
+            sx = qMin( sx, ssx );
+
+        const double ssy = info.scaleFactorY( 
+            d_data->pointRect, rect, scalePens );
+
+        if ( ssy > 0.0 )
+            sy = qMin( sy, ssy );
+    }
+
+    if ( aspectRatioMode == Qt::KeepAspectRatio )
+    {
+        const double s = qMin( sx, sy );
+        sx = s;
+        sy = s;
+    }
+    else if ( aspectRatioMode == Qt::KeepAspectRatioByExpanding )
+    {
+        const double s = qMax( sx, sy );
+        sx = s;
+        sy = s;
+    }
+
+    QTransform tr;
+    tr.translate( rect.center().x() - 0.5 * sx * d_data->pointRect.width(),
+        rect.center().y() - 0.5 * sy * d_data->pointRect.height() );
+    tr.scale( sx, sy );
+    tr.translate( -d_data->pointRect.x(), -d_data->pointRect.y() );
+
+    const QTransform transform = painter->transform();
+    if ( !scalePens && transform.isScaling() )
+    {
+        // we don't want to scale pens according to sx/sy,
+        // but we want to apply the scaling from the 
+        // painter transformation later
+
+        d_data->initialTransform = new QTransform();
+        d_data->initialTransform->scale( transform.m11(), transform.m22() );
+    }
+
+    painter->setTransform( tr, true );
+    render( painter );
+
+    painter->setTransform( transform );
+
+    delete d_data->initialTransform;
+    d_data->initialTransform = NULL;
+}
+
+/*!
+  \brief Replay all recorded painter commands
+
+  The graphic is scaled to the defaultSize() and aligned
+  to a position.
+
+  \param painter Qt painter
+  \param pos Reference point, where to render
+  \param alignment Flags how to align the target rectangle 
+                   to pos.
+ */
+void QwtGraphic::render( QPainter *painter, 
+    const QPointF &pos, Qt::Alignment alignment ) const
+{
+    QRectF r( pos, defaultSize() );
+
+    if ( alignment & Qt::AlignLeft )
+    {
+        r.moveLeft( pos.x() );
+    }
+    else if ( alignment & Qt::AlignHCenter )
+    {
+        r.moveCenter( QPointF( pos.x(), r.center().y() ) );
+    }
+    else if ( alignment & Qt::AlignRight )
+    {
+        r.moveRight( pos.x() );
+    }
+
+    if ( alignment & Qt::AlignTop )
+    {
+        r.moveTop( pos.y() );
+    }
+    else if ( alignment & Qt::AlignVCenter )
+    {
+        r.moveCenter( QPointF( r.center().x(), pos.y() ) );
+    }
+    else if ( alignment & Qt::AlignBottom )
+    {
+        r.moveBottom( pos.y() );
+    }
+
+    render( painter, r );
+}
+
+/*!
+  \brief Convert the graphic to a QPixmap
+    
+  All pixels of the pixmap get initialized by Qt::transparent
+  before the graphic is scaled and rendered on it.
+    
+  The size of the pixmap is the default size ( ceiled to integers )
+  of the graphic.
+
+  \return The graphic as pixmap in default size
+  \sa defaultSize(), toImage(), render()
+ */ 
+QPixmap QwtGraphic::toPixmap() const
+{
+    if ( isNull() )
+        return QPixmap();
+
+    const QSizeF sz = defaultSize();
+
+    const int w = qCeil( sz.width() );
+    const int h = qCeil( sz.height() );
+
+    QPixmap pixmap( w, h );
+    pixmap.fill( Qt::transparent );
+
+    const QRectF r( 0.0, 0.0, sz.width(), sz.height() );
+
+    QPainter painter( &pixmap );
+    render( &painter, r, Qt::KeepAspectRatio );
+    painter.end();
+
+    return pixmap;
+}
+
+/*!
+  \brief Convert the graphic to a QPixmap
+
+  All pixels of the pixmap get initialized by Qt::transparent
+  before the graphic is scaled and rendered on it.
+
+  \param size Size of the image
+  \param aspectRatioMode Aspect ratio how to scale the graphic
+
+  \return The graphic as pixmap
+  \sa toImage(), render()
+ */
+QPixmap QwtGraphic::toPixmap( const QSize &size,
+    Qt::AspectRatioMode aspectRatioMode ) const
+{
+    QPixmap pixmap( size );
+    pixmap.fill( Qt::transparent );
+
+    const QRect r( 0, 0, size.width(), size.height() );
+
+    QPainter painter( &pixmap );
+    render( &painter, r, aspectRatioMode );
+    painter.end();
+
+    return pixmap;
+}
+
+/*!
+  \brief Convert the graphic to a QImage
+
+  All pixels of the image get initialized by 0 ( transparent )
+  before the graphic is scaled and rendered on it.
+
+  The format of the image is QImage::Format_ARGB32_Premultiplied.
+
+  \param size Size of the image
+  \param aspectRatioMode Aspect ratio how to scale the graphic
+
+  \return The graphic as image
+  \sa toPixmap(), render()
+ */
+QImage QwtGraphic::toImage( const QSize &size,
+    Qt::AspectRatioMode aspectRatioMode  ) const
+{
+    QImage image( size, QImage::Format_ARGB32_Premultiplied );
+    image.fill( 0 );
+
+    const QRect r( 0, 0, size.width(), size.height() );
+
+    QPainter painter( &image );
+    render( &painter, r, aspectRatioMode );
+    painter.end();
+
+    return image;
+}
+
+/*!
+  \brief Convert the graphic to a QImage
+    
+  All pixels of the image get initialized by 0 ( transparent )
+  before the graphic is scaled and rendered on it.
+
+  The format of the image is QImage::Format_ARGB32_Premultiplied.
+
+  The size of the image is the default size ( ceiled to integers )
+  of the graphic.
+    
+  \return The graphic as image in default size
+  \sa defaultSize(), toPixmap(), render()
+ */
+QImage QwtGraphic::toImage() const
+{
+    if ( isNull() )
+        return QImage();
+
+    const QSizeF sz = defaultSize();
+
+    const int w = qCeil( sz.width() );
+    const int h = qCeil( sz.height() );
+
+    QImage image( w, h, QImage::Format_ARGB32 );
+    image.fill( 0 );
+
+    const QRect r( 0, 0, sz.width(), sz.height() );
+
+    QPainter painter( &image );
+    render( &painter, r, Qt::KeepAspectRatio );
+    painter.end();
+
+    return image;
+}
+
+/*!
+  Store a path command in the command list
+
+  \param path Painter path
+  \sa QPaintEngine::drawPath()
+*/
+void QwtGraphic::drawPath( const QPainterPath &path )
+{
+    const QPainter *painter = paintEngine()->painter();
+    if ( painter == NULL )
+        return;
+
+    d_data->commands += QwtPainterCommand( path );
+
+    if ( !path.isEmpty() )
+    {
+        const QPainterPath scaledPath = painter->transform().map( path );
+
+        QRectF pointRect = scaledPath.boundingRect();
+        QRectF boundingRect = pointRect;
+
+        if ( painter->pen().style() != Qt::NoPen 
+            && painter->pen().brush().style() != Qt::NoBrush )
+        {
+            boundingRect = qwtStrokedPathRect( painter, path );
+        }
+
+        updateControlPointRect( pointRect );
+        updateBoundingRect( boundingRect );
+
+        d_data->pathInfos += PathInfo( pointRect, 
+            boundingRect, qwtHasScalablePen( painter ) );
+    }
+}
+
+/*!
+  \brief Store a pixmap command in the command list
+
+  \param rect target rectangle
+  \param pixmap Pixmap to be painted
+  \param subRect Reactangle of the pixmap to be painted
+
+  \sa QPaintEngine::drawPixmap()
+*/
+void QwtGraphic::drawPixmap( const QRectF &rect, 
+    const QPixmap &pixmap, const QRectF &subRect )
+{
+    const QPainter *painter = paintEngine()->painter();
+    if ( painter == NULL )
+        return;
+
+    d_data->commands += QwtPainterCommand( rect, pixmap, subRect );
+
+    const QRectF r = painter->transform().mapRect( rect );
+    updateControlPointRect( r );
+    updateBoundingRect( r );
+}
+
+/*!
+  \brief Store a image command in the command list
+
+  \param rect traget rectangle
+  \param image Image to be painted
+  \param subRect Reactangle of the pixmap to be painted
+  \param flags Image conversion flags
+
+  \sa QPaintEngine::drawImage()
+ */
+void QwtGraphic::drawImage( const QRectF &rect, const QImage &image,
+    const QRectF &subRect, Qt::ImageConversionFlags flags)
+{
+    const QPainter *painter = paintEngine()->painter();
+    if ( painter == NULL )
+        return;
+
+    d_data->commands += QwtPainterCommand( rect, image, subRect, flags );
+
+    const QRectF r = painter->transform().mapRect( rect );
+
+    updateControlPointRect( r );
+    updateBoundingRect( r );
+}
+
+/*!
+  \brief Store a state command in the command list
+
+  \param state State to be stored
+  \sa QPaintEngine::updateState()
+ */
+void QwtGraphic::updateState( const QPaintEngineState &state)
+{
+    d_data->commands += QwtPainterCommand( state );
+}
+
+void QwtGraphic::updateBoundingRect( const QRectF &rect )
+{
+    QRectF br = rect;
+
+    const QPainter *painter = paintEngine()->painter();
+    if ( painter && painter->hasClipping() )
+    {
+        QRectF cr = painter->clipRegion().boundingRect();
+        cr = painter->transform().mapRect( cr );
+
+        br &= cr;
+    }
+
+    if ( d_data->boundingRect.width() < 0 )
+        d_data->boundingRect = br;
+    else
+        d_data->boundingRect |= br;
+}
+
+void QwtGraphic::updateControlPointRect( const QRectF &rect )
+{
+    if ( d_data->pointRect.width() < 0.0 )
+        d_data->pointRect = rect;
+    else
+        d_data->pointRect |= rect;
+}
+
+/*!
+  \return List of recorded paint commands
+  \sa setCommands()
+ */
+const QVector< QwtPainterCommand > &QwtGraphic::commands() const
+{
+    return d_data->commands;
+}
+
+/*!
+  \brief Append paint commands
+
+  \param commands Paint commands
+  \sa commands()
+ */
+void QwtGraphic::setCommands( QVector< QwtPainterCommand > &commands )
+{
+    reset();
+
+    const int numCommands = commands.size();
+    if ( numCommands <= 0 )
+        return;
+
+    // to calculate a proper bounding rectangle we don't simply copy 
+    // the commands. 
+
+    const QwtPainterCommand *cmds = commands.constData();
+
+    QPainter painter( this );
+    for ( int i = 0; i < numCommands; i++ )
+        qwtExecCommand( &painter, cmds[i], RenderHints(), QTransform(), NULL );
+
+    painter.end();
+}
Index: trunk/BNC/qwt/qwt_graphic.h
===================================================================
--- trunk/BNC/qwt/qwt_graphic.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_graphic.h	(revision 8127)
@@ -0,0 +1,176 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_GRAPHIC_H
+#define QWT_GRAPHIC_H
+
+#include "qwt_global.h"
+#include "qwt_null_paintdevice.h"
+#include <qmetatype.h>
+#include <qimage.h>
+#include <qpixmap.h>
+
+class QwtPainterCommand;
+
+/*!
+    \brief A paint device for scalable graphics
+
+    QwtGraphic is the representation of a graphic that is tailored for
+    scalability. Like QPicture it will be initialized by QPainter
+    operations and can be replayed later to any target paint device.
+
+    While the usual image representations QImage and QPixmap are not
+    scalable Qt offers two paint devices, that might be candidates
+    for representing a vector graphic:
+
+    - QPicture\n
+      Unfortunately QPicture had been forgotten, when Qt4
+      introduced floating point based render engines. Its API
+      is still on integers, what make it unusable for proper scaling.
+
+    - QSvgRenderer/QSvgGenerator\n
+      Unfortunately QSvgRenderer hides to much information about
+      its nodes in internal APIs, that are necessary for proper 
+      layout calculations. Also it is derived from QObject and 
+      can't be copied like QImage/QPixmap.
+
+    QwtGraphic maps all scalable drawing primitives to a QPainterPath
+    and stores them together with the painter state changes 
+    ( pen, brush, transformation ... ) in a list of QwtPaintCommands. 
+    For being a complete QPaintDevice it also stores pixmaps or images, 
+    what is somehow against the idea of the class, because these objects 
+    can't be scaled without a loss in quality.
+
+    The main issue about scaling a QwtGraphic object are the pens used for
+    drawing the outlines of the painter paths. While non cosmetic pens 
+    ( QPen::isCosmetic() ) are scaled with the same ratio as the path, 
+    cosmetic pens have a fixed width. A graphic might have paths with 
+    different pens - cosmetic and non-cosmetic.
+
+    QwtGraphic caches 2 different rectangles:
+
+    - control point rectangle\n
+      The control point rectangle is the bounding rectangle of all
+      control point rectangles of the painter paths, or the target 
+      rectangle of the pixmaps/images.
+
+    - bounding rectangle\n
+      The bounding rectangle extends the control point rectangle by
+      what is needed for rendering the outline with an unscaled pen.
+
+    Because the offset for drawing the outline depends on the shape 
+    of the painter path ( the peak of a triangle is different than the flat side ) 
+    scaling with a fixed aspect ratio always needs to be calculated from the 
+    control point rectangle.
+
+    \sa QwtPainterCommand
+ */
+class QWT_EXPORT QwtGraphic: public QwtNullPaintDevice
+{
+public:
+    /*! 
+        Hint how to render a graphic
+        \sa setRenderHint(), testRenderHint()
+     */
+    enum RenderHint
+    {
+        /*!
+           When rendering a QwtGraphic a specific scaling between 
+           the controlPointRect() and the coordinates of the target rectangle
+           is set up internally in render().
+
+           When RenderPensUnscaled is set this specific scaling is applied
+           for the control points only, but not for the pens.
+           All other painter transformations ( set up by application code )
+           are supposed to work like usual.
+
+           \sa render();
+         */
+        RenderPensUnscaled = 0x1
+    };
+
+    /*! 
+        \brief Render hints
+
+        The default setting is to disable all hints
+     */
+    typedef QFlags<RenderHint> RenderHints;
+
+    QwtGraphic();
+    QwtGraphic( const QwtGraphic & );
+
+    virtual ~QwtGraphic();
+
+    QwtGraphic& operator=( const QwtGraphic & );
+
+    void reset();
+
+    bool isNull() const;
+    bool isEmpty() const;
+
+    void render( QPainter * ) const;
+
+    void render( QPainter *, const QSizeF &, 
+            Qt::AspectRatioMode = Qt::IgnoreAspectRatio  ) const;
+
+    void render( QPainter *, const QRectF &, 
+            Qt::AspectRatioMode = Qt::IgnoreAspectRatio  ) const;
+
+    void render( QPainter *, const QPointF &,
+        Qt::Alignment = Qt::AlignTop | Qt::AlignLeft ) const;
+
+    QPixmap toPixmap() const; 
+    QPixmap toPixmap( const QSize &, 
+        Qt::AspectRatioMode = Qt::IgnoreAspectRatio  ) const;
+
+    QImage toImage() const; 
+    QImage toImage( const QSize &, 
+        Qt::AspectRatioMode = Qt::IgnoreAspectRatio  ) const;
+
+    QRectF scaledBoundingRect( double sx, double sy ) const;
+
+    QRectF boundingRect() const;
+    QRectF controlPointRect() const;
+
+    const QVector< QwtPainterCommand > &commands() const;
+    void setCommands( QVector< QwtPainterCommand > & );
+
+    void setDefaultSize( const QSizeF & );
+    QSizeF defaultSize() const;
+    
+    void setRenderHint( RenderHint, bool on = true );
+    bool testRenderHint( RenderHint ) const;
+
+protected:
+    virtual QSize sizeMetrics() const;
+
+    virtual void drawPath( const QPainterPath & );
+
+    virtual void drawPixmap( const QRectF &,
+        const QPixmap &, const QRectF & );
+
+    virtual void drawImage( const QRectF &,
+        const QImage &, const QRectF &, Qt::ImageConversionFlags );
+
+    virtual void updateState( const QPaintEngineState &state );
+
+private:
+    void updateBoundingRect( const QRectF & );
+    void updateControlPointRect( const QRectF & );
+
+    class PathInfo;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtGraphic::RenderHints )
+Q_DECLARE_METATYPE( QwtGraphic )
+
+#endif
Index: trunk/BNC/qwt/qwt_interval.cpp
===================================================================
--- trunk/BNC/qwt/qwt_interval.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_interval.cpp	(revision 8127)
@@ -13,10 +13,10 @@
 
 /*!
-   \brief Normalize the limits of the interval
-
-   If maxValue() < minValue() the limits will be inverted.
-   \return Normalized interval
-
-   \sa isValid(), inverted()
+  \brief Normalize the limits of the interval
+
+  If maxValue() < minValue() the limits will be inverted.
+  \return Normalized interval
+
+  \sa isValid(), inverted()
 */
 QwtInterval QwtInterval::normalized() const
@@ -35,7 +35,7 @@
 
 /*!
-   Invert the limits of the interval
-   \return Inverted interval
-   \sa normalized()
+  Invert the limits of the interval
+  \return Inverted interval
+  \sa normalized()
 */
 QwtInterval QwtInterval::inverted() const
@@ -131,5 +131,10 @@
 }
 
-//! Intersect 2 intervals
+/*! 
+  \brief Intersect 2 intervals
+  
+  \param other Interval to be intersect with
+  \return Intersection
+ */
 QwtInterval QwtInterval::intersect( const QwtInterval &other ) const
 {
@@ -193,20 +198,33 @@
 }
 
-//! Unites this interval with the given interval.
-QwtInterval& QwtInterval::operator|=( const QwtInterval & interval )
-{
-    *this = *this | interval;
+/*! 
+  \brief Unite this interval with the given interval.
+
+  \param other Interval to be united with
+  \return This interval
+ */
+QwtInterval& QwtInterval::operator|=( const QwtInterval &other )
+{
+    *this = *this | other;
     return *this;
 }
 
-//! Intersects this interval with the given interval.
-QwtInterval& QwtInterval::operator&=( const QwtInterval & interval )
-{
-    *this = *this & interval;
+/*! 
+  \brief Intersect this interval with the given interval.
+
+  \param other Interval to be intersected with
+  \return This interval
+ */
+QwtInterval& QwtInterval::operator&=( const QwtInterval &other )
+{
+    *this = *this & other;
     return *this;
 }
 
 /*!
-   Test if two intervals overlap
+  \brief Test if two intervals overlap
+
+  \param other Interval
+  \return True, when the intervals are intersecting
 */
 bool QwtInterval::intersects( const QwtInterval &other ) const
@@ -244,9 +262,9 @@
 
 /*!
-   Adjust the limit that is closer to value, so that value becomes
-   the center of the interval.
-
-   \param value Center
-   \return Interval with value as center
+  Adjust the limit that is closer to value, so that value becomes
+  the center of the interval.
+
+  \param value Center
+  \return Interval with value as center
 */
 QwtInterval QwtInterval::symmetrize( double value ) const
@@ -262,10 +280,10 @@
 
 /*!
-   Limit the interval, keeping the border modes
-
-   \param lowerBound Lower limit
-   \param upperBound Upper limit
-
-   \return Limited interval
+  Limit the interval, keeping the border modes
+
+  \param lowerBound Lower limit
+  \param upperBound Upper limit
+
+  \return Limited interval
 */
 QwtInterval QwtInterval::limited( double lowerBound, double upperBound ) const
@@ -284,13 +302,15 @@
 
 /*!
-   Extend the interval
-
-   If value is below minValue, value becomes the lower limit.
-   If value is above maxValue, value becomes the upper limit.
-
-   extend has no effect for invalid intervals
-
-   \param value Value
-   \sa isValid()
+  \brief Extend the interval
+
+  If value is below minValue(), value becomes the lower limit.
+  If value is above maxValue(), value becomes the upper limit.
+
+  extend() has no effect for invalid intervals
+
+  \param value Value
+  \return extended interval
+
+  \sa isValid()
 */
 QwtInterval QwtInterval::extend( double value ) const
@@ -304,10 +324,10 @@
 
 /*!
-   Extend an interval
-
-   \param value Value
-   \return Reference of the extended interval
-
-   \sa extend()
+  Extend an interval
+
+  \param value Value
+  \return Reference of the extended interval
+
+  \sa extend()
 */
 QwtInterval& QwtInterval::operator|=( double value )
Index: trunk/BNC/qwt/qwt_interval.h
===================================================================
--- trunk/BNC/qwt/qwt_interval.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_interval.h	(revision 8127)
@@ -12,4 +12,6 @@
 
 #include "qwt_global.h"
+#include <qmetatype.h>
+
 #ifndef QT_NO_DEBUG_STREAM
 #include <qdebug.h>
@@ -200,71 +202,9 @@
 
 /*!
-   Return the width of an interval
-   The width of invalid intervals is 0.0, otherwise the result is
-   maxValue() - minValue().
-
-   \sa isValid()
-*/
-inline double QwtInterval::width() const
-{
-    return isValid() ? ( d_maxValue - d_minValue ) : 0.0;
-}
-
-/*!
-   Intersection of two intervals
-   \sa intersect()
-*/
-inline QwtInterval QwtInterval::operator&(
-    const QwtInterval &interval ) const
-{
-    return intersect( interval );
-}
-
-/*!
-   Union of two intervals
-   \sa unite()
-*/
-inline QwtInterval QwtInterval::operator|(
-    const QwtInterval &interval ) const
-{
-    return unite( interval );
-}
-
-//! Compare two intervals
-inline bool QwtInterval::operator==( const QwtInterval &other ) const
-{
-    return ( d_minValue == other.d_minValue ) &&
-           ( d_maxValue == other.d_maxValue ) &&
-           ( d_borderFlags == other.d_borderFlags );
-}
-
-//! Compare two intervals
-inline bool QwtInterval::operator!=( const QwtInterval &other ) const
-{
-    return ( !( *this == other ) );
-}
-
-/*!
-   Extend an interval
-
-   \param value Value
-   \return Extended interval
-   \sa extend()
-*/
-inline QwtInterval QwtInterval::operator|( double value ) const
-{
-    return extend( value );
-}
-
-//! \return true, if isValid() && (minValue() >= maxValue())
-inline bool QwtInterval::isNull() const
-{
-    return isValid() && d_minValue >= d_maxValue;
-}
-
-/*!
    A interval is valid when minValue() <= maxValue().
    In case of QwtInterval::ExcludeBorders it is true
    when minValue() < maxValue()
+
+   \return True, when the interval is valid
 */
 inline bool QwtInterval::isValid() const
@@ -277,4 +217,87 @@
 
 /*!
+   \brief Return the width of an interval
+
+   The width of invalid intervals is 0.0, otherwise the result is
+   maxValue() - minValue().
+
+   \return Interval width
+   \sa isValid()
+*/
+inline double QwtInterval::width() const
+{
+    return isValid() ? ( d_maxValue - d_minValue ) : 0.0;
+}
+
+/*!
+   \brief Intersection of two intervals
+ 
+   \param other Interval to intersect with
+   \return Intersection of this and other
+
+   \sa intersect()
+*/
+inline QwtInterval QwtInterval::operator&(
+    const QwtInterval &other ) const
+{
+    return intersect( other );
+}
+
+/*!
+   Union of two intervals
+
+   \param other Interval to unite with
+   \return Union of this and other
+
+   \sa unite()
+*/
+inline QwtInterval QwtInterval::operator|(
+    const QwtInterval &other ) const
+{
+    return unite( other );
+}
+
+/*! 
+   \brief Compare two intervals
+
+   \param other Interval to compare with
+   \return True, when this and other are equal
+*/
+inline bool QwtInterval::operator==( const QwtInterval &other ) const
+{
+    return ( d_minValue == other.d_minValue ) &&
+           ( d_maxValue == other.d_maxValue ) &&
+           ( d_borderFlags == other.d_borderFlags );
+}
+/*! 
+   \brief Compare two intervals
+
+   \param other Interval to compare with
+   \return True, when this and other are not equal
+*/
+inline bool QwtInterval::operator!=( const QwtInterval &other ) const
+{
+    return ( !( *this == other ) );
+}
+
+/*!
+   Extend an interval
+
+   \param value Value
+   \return Extended interval
+   \sa extend()
+*/
+inline QwtInterval QwtInterval::operator|( double value ) const
+{
+    return extend( value );
+}
+
+//! \return true, if isValid() && (minValue() >= maxValue())
+inline bool QwtInterval::isNull() const
+{
+    return isValid() && d_minValue >= d_maxValue;
+}
+
+/*!
   Invalidate the interval
 
@@ -289,4 +312,5 @@
 
 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtInterval::BorderFlags )
+Q_DECLARE_METATYPE( QwtInterval )
 
 #ifndef QT_NO_DEBUG_STREAM
Index: trunk/BNC/qwt/qwt_interval_symbol.cpp
===================================================================
--- trunk/BNC/qwt/qwt_interval_symbol.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_interval_symbol.cpp	(revision 8127)
@@ -15,4 +15,6 @@
 #if QT_VERSION < 0x040601
 #define qAtan2(y, x) ::atan2(y, x)
+#define qFastSin(x) qSin(x)
+#define qFastCos(x) qCos(x)
 #endif
 
@@ -149,4 +151,23 @@
 {
     return d_data->brush;
+}
+
+/*! 
+  Build and assign a pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtIntervalSymbol::setPen( const QColor &color, 
+    qreal width, Qt::PenStyle style )
+{   
+    setPen( QPen( color, width, style ) );
 }
 
@@ -232,6 +253,6 @@
                     double dw2 = sw / 2.0;
 
-                    const double cx = qCos( angle ) * dw2;
-                    const double sy = qSin( angle ) * dw2;
+                    const double cx = qFastCos( angle ) * dw2;
+                    const double sy = qFastSin( angle ) * dw2;
 
                     QwtPainter::drawLine( painter,
@@ -280,6 +301,6 @@
                     double dw2 = sw / 2.0;
 
-                    const int cx = qCos( angle ) * dw2;
-                    const int sy = qSin( angle ) * dw2;
+                    const double cx = qFastCos( angle ) * dw2;
+                    const double sy = qFastSin( angle ) * dw2;
 
                     QPolygonF polygon;
Index: trunk/BNC/qwt/qwt_interval_symbol.h
===================================================================
--- trunk/BNC/qwt/qwt_interval_symbol.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_interval_symbol.h	(revision 8127)
@@ -69,4 +69,5 @@
     const QBrush& brush() const;
 
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setPen( const QPen & );
     const QPen& pen() const;
Index: trunk/BNC/qwt/qwt_knob.cpp
===================================================================
--- trunk/BNC/qwt/qwt_knob.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_knob.cpp	(revision 8127)
@@ -0,0 +1,855 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_knob.h"
+#include "qwt_round_scale_draw.h"
+#include "qwt_math.h"
+#include "qwt_painter.h"
+#include "qwt_scale_map.h"
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qevent.h>
+#include <qmath.h>
+#include <qapplication.h>
+
+#if QT_VERSION < 0x040601
+#define qAtan2(y, x) ::atan2(y, x)
+#define qFabs(x) ::fabs(x)
+#define qFastCos(x) qCos(x)
+#define qFastSin(x) qSin(x)
+#endif
+
+static QSize qwtKnobSizeHint( const QwtKnob *knob, int min )
+{
+    int knobWidth = knob->knobWidth();
+    if ( knobWidth <= 0 )
+        knobWidth = qMax( 3 * knob->markerSize(), min );
+
+    // Add the scale radial thickness to the knobWidth
+    const int extent = qCeil( knob->scaleDraw()->extent( knob->font() ) );
+    const int d = 2 * ( extent + 4 ) + knobWidth;
+
+    int left, right, top, bottom;
+    knob->getContentsMargins( &left, &top, &right, &bottom );
+
+    return QSize( d + left + right, d + top + bottom );
+}
+
+static inline double qwtToScaleAngle( double angle )
+{
+    // the map is counter clockwise with the origin
+    // at 90° using angles from -180° -> 180°
+
+    double a = 90.0 - angle;
+    if ( a <= -180.0 )
+        a += 360.0;
+    else if ( a >= 180.0 )
+        a -= 360.0;
+
+    return a;
+}
+
+static double qwtToDegrees( double value )
+{
+    return qwtNormalizeDegrees( 90.0 - value );
+}
+
+class QwtKnob::PrivateData
+{
+public:
+    PrivateData():
+        knobStyle( QwtKnob::Raised ),
+        markerStyle( QwtKnob::Notch ),
+        borderWidth( 2 ),
+        borderDist( 4 ),
+        scaleDist( 4 ),
+        maxScaleTicks( 11 ),
+        knobWidth( 0 ),
+        alignment( Qt::AlignCenter ),
+        markerSize( 8 ),
+        totalAngle( 270.0 ),
+        mouseOffset( 0.0 )
+    {
+    }
+
+    QwtKnob::KnobStyle knobStyle;
+    QwtKnob::MarkerStyle markerStyle;
+
+    int borderWidth;
+    int borderDist;
+    int scaleDist;
+    int maxScaleTicks;
+    int knobWidth;
+    Qt::Alignment alignment;
+    int markerSize;
+
+    double totalAngle;
+
+    double mouseOffset;
+};
+
+/*!
+  \brief Constructor
+
+  Construct a knob with an angle of 270°. The style is
+  QwtKnob::Raised and the marker style is QwtKnob::Notch.
+  The width of the knob is set to 50 pixels.
+
+  \param parent Parent widget
+
+  \sa setTotalAngle()
+*/
+QwtKnob::QwtKnob( QWidget* parent ):
+    QwtAbstractSlider( parent )
+{
+    d_data = new PrivateData;
+
+    setScaleDraw( new QwtRoundScaleDraw() );
+
+    setTotalAngle( 270.0 );
+
+    setScale( 0.0, 10.0 );
+    setValue( 0.0 );
+
+    setSizePolicy( QSizePolicy::MinimumExpanding, 
+        QSizePolicy::MinimumExpanding );
+}
+
+//! Destructor
+QwtKnob::~QwtKnob()
+{
+    delete d_data;
+}
+
+/*!
+  \brief Set the knob type 
+
+  \param knobStyle Knob type
+  \sa knobStyle(), setBorderWidth()
+*/
+void QwtKnob::setKnobStyle( KnobStyle knobStyle )
+{
+    if ( d_data->knobStyle != knobStyle )
+    {
+        d_data->knobStyle = knobStyle;
+        update();
+    }
+}
+
+/*!
+    \return Marker type of the knob
+    \sa setKnobStyle(), setBorderWidth()
+*/
+QwtKnob::KnobStyle QwtKnob::knobStyle() const
+{
+    return d_data->knobStyle;
+}
+
+/*!
+  \brief Set the marker type of the knob
+
+  \param markerStyle Marker type
+  \sa markerStyle(), setMarkerSize()
+*/
+void QwtKnob::setMarkerStyle( MarkerStyle markerStyle )
+{
+    if ( d_data->markerStyle != markerStyle )
+    {
+        d_data->markerStyle = markerStyle;
+        update();
+    }
+}
+
+/*!
+  \return Marker type of the knob
+  \sa setMarkerStyle(), setMarkerSize()
+*/
+QwtKnob::MarkerStyle QwtKnob::markerStyle() const
+{
+    return d_data->markerStyle;
+}
+
+/*!
+  \brief Set the total angle by which the knob can be turned
+  \param angle Angle in degrees.
+
+  The angle has to be between [10, 360] degrees. Angles above
+  360 ( so that the knob can be turned several times around its axis )
+  have to be set using setNumTurns().
+
+  The default angle is 270 degrees. 
+
+  \sa totalAngle(), setNumTurns()
+*/
+void QwtKnob::setTotalAngle ( double angle )
+{
+    angle = qBound( 10.0, angle, 360.0 );
+
+    if ( angle != d_data->totalAngle )
+    {
+        d_data->totalAngle = angle;
+
+        scaleDraw()->setAngleRange( -0.5 * d_data->totalAngle,
+            0.5 * d_data->totalAngle );
+
+        updateGeometry();
+        update();
+    }
+}
+
+/*! 
+  \return the total angle
+  \sa setTotalAngle(), setNumTurns(), numTurns()
+ */
+double QwtKnob::totalAngle() const
+{
+    return d_data->totalAngle;
+}
+
+/*!
+  \brief Set the number of turns
+
+  When numTurns > 1 the knob can be turned several times around its axis
+  - otherwise the total angle is floored to 360°.
+
+  \sa numTurns(), totalAngle(), setTotalAngle()
+*/
+  
+void QwtKnob::setNumTurns( int numTurns )
+{
+    numTurns = qMax( numTurns, 1 );
+
+    if ( numTurns == 1 && d_data->totalAngle <= 360.0 )
+        return;
+
+    const double angle = numTurns * 360.0;
+    if ( angle != d_data->totalAngle )
+    {
+        d_data->totalAngle = angle;
+
+        scaleDraw()->setAngleRange( -0.5 * d_data->totalAngle,
+            0.5 * d_data->totalAngle );
+
+        updateGeometry();
+        update();
+    }
+}
+
+/*!
+  \return Number of turns. 
+
+  When the total angle is below 360° numTurns() is ceiled to 1.
+  \sa setNumTurns(), setTotalAngle(), totalAngle()
+ */
+int QwtKnob::numTurns() const
+{
+    return qCeil( d_data->totalAngle / 360.0 );
+}
+
+/*!
+   Change the scale draw of the knob
+
+   For changing the labels of the scales, it
+   is necessary to derive from QwtRoundScaleDraw and
+   overload QwtRoundScaleDraw::label().
+
+   \sa scaleDraw()
+*/
+void QwtKnob::setScaleDraw( QwtRoundScaleDraw *scaleDraw )
+{
+    setAbstractScaleDraw( scaleDraw );
+    setTotalAngle( d_data->totalAngle );
+
+    updateGeometry();
+    update();
+}
+
+/*!
+   \return the scale draw of the knob
+   \sa setScaleDraw()
+*/
+const QwtRoundScaleDraw *QwtKnob::scaleDraw() const
+{
+    return static_cast<const QwtRoundScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+   \return the scale draw of the knob
+   \sa setScaleDraw()
+*/
+QwtRoundScaleDraw *QwtKnob::scaleDraw()
+{
+    return static_cast<QwtRoundScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+  Calculate the bounding rectangle of the knob without the scale
+
+  \return Bounding rectangle of the knob
+  \sa knobWidth(), alignment(), QWidget::contentsRect()
+ */
+QRect QwtKnob::knobRect() const
+{
+    const QRect cr = contentsRect();
+
+    const int extent = qCeil( scaleDraw()->extent( font() ) );
+    const int d = extent + d_data->scaleDist;
+
+    int w = d_data->knobWidth;
+    if ( w <= 0 )
+    {
+        const int dim = qMin( cr.width(), cr.height() );
+
+        w = dim - 2 * ( d );
+        w = qMax( 0, w );
+    }
+
+    QRect r( 0, 0, w, w );
+
+    if ( d_data->alignment & Qt::AlignLeft )
+    {
+        r.moveLeft( cr.left() + d );
+    }
+    else if ( d_data->alignment & Qt::AlignRight )
+    {
+        r.moveRight( cr.right() - d );
+    }
+    else
+    {
+        r.moveCenter( QPoint( cr.center().x(), r.center().y() ) );
+    }
+
+    if ( d_data->alignment & Qt::AlignTop )
+    {
+        r.moveTop( cr.top() + d );
+    }
+    else if ( d_data->alignment & Qt::AlignBottom )
+    {
+        r.moveBottom( cr.bottom() - d );
+    }
+    else 
+    {
+        r.moveCenter( QPoint( r.center().x(), cr.center().y() ) );
+    }
+
+    return r;
+}
+
+/*!
+  \brief Determine what to do when the user presses a mouse button.
+
+  \param pos Mouse position
+
+  \retval True, when pos is inside the circle of the knob.
+  \sa scrolledTo()
+*/
+bool QwtKnob::isScrollPosition( const QPoint &pos ) const
+{
+    const QRect kr = knobRect();
+
+    const QRegion region( kr, QRegion::Ellipse );
+    if ( region.contains( pos ) && ( pos != kr.center() ) )
+    {
+        const double angle = QLineF( kr.center(), pos ).angle();
+        const double valueAngle = qwtToDegrees( scaleMap().transform( value() ) );
+
+        d_data->mouseOffset = qwtNormalizeDegrees( angle - valueAngle );
+
+        return true;
+    }
+
+    return false;
+}
+
+/*!
+  \brief Determine the value for a new position of the mouse
+
+  \param pos Mouse position
+
+  \return Value for the mouse position
+  \sa isScrollPosition()
+*/
+double QwtKnob::scrolledTo( const QPoint &pos ) const
+{
+    double angle = QLineF( rect().center(), pos ).angle();
+    angle = qwtNormalizeDegrees( angle - d_data->mouseOffset );
+
+    if ( scaleMap().pDist() > 360.0 )
+    {
+        angle = qwtToDegrees( angle );
+
+        const double v = scaleMap().transform( value() );
+
+        int numTurns = qFloor( ( v - scaleMap().p1() ) / 360.0 );
+
+        double valueAngle = qwtNormalizeDegrees( v );
+        if ( qAbs( valueAngle - angle ) > 180.0 )
+        {
+            numTurns += ( angle > valueAngle ) ? -1 : 1;
+        }
+
+        angle += scaleMap().p1() + numTurns * 360.0;
+
+        if ( !wrapping() )
+        {
+            const double boundedAngle = 
+                qBound( scaleMap().p1(), angle, scaleMap().p2() );
+
+            d_data->mouseOffset += ( boundedAngle - angle );
+            angle = boundedAngle;
+        }
+    }
+    else
+    {
+        angle = qwtToScaleAngle( angle );
+
+        double boundedAngle = qBound( scaleMap().p1(), angle, scaleMap().p2() );
+
+        if ( !wrapping() )
+        {
+            const double currentAngle = scaleMap().transform( value() );
+
+            if ( ( currentAngle > 90.0 ) && ( boundedAngle < -90.0 ) )
+                boundedAngle = scaleMap().p2();
+            else if ( ( currentAngle < -90.0 ) && ( boundedAngle > 90.0 ) )
+                boundedAngle = scaleMap().p1();
+
+            d_data->mouseOffset += ( boundedAngle - angle );
+        }
+
+        angle = boundedAngle;
+    }
+
+    return scaleMap().invTransform( angle );
+}
+
+/*! 
+  Handle QEvent::StyleChange and QEvent::FontChange;
+  \param event Change event
+*/
+void QwtKnob::changeEvent( QEvent *event )
+{
+    switch( event->type() )
+    {
+        case QEvent::StyleChange:
+        case QEvent::FontChange:
+        {
+            updateGeometry();
+            update();
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+/*!
+  Repaint the knob
+  \param event Paint event
+*/
+void QwtKnob::paintEvent( QPaintEvent *event )
+{
+    const QRectF knobRect = this->knobRect();
+
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    QStyleOption opt;
+    opt.init(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    painter.setRenderHint( QPainter::Antialiasing, true );
+
+    if ( !knobRect.contains( event->region().boundingRect() ) )
+    {
+        scaleDraw()->setRadius( 0.5 * knobRect.width() + d_data->scaleDist );
+        scaleDraw()->moveCenter( knobRect.center() );
+
+        scaleDraw()->draw( &painter, palette() );
+    }
+
+    drawKnob( &painter, knobRect );
+
+    drawMarker( &painter, knobRect, 
+        qwtNormalizeDegrees( scaleMap().transform( value() ) ) );
+
+    painter.setRenderHint( QPainter::Antialiasing, false );
+
+    if ( hasFocus() )
+        drawFocusIndicator( &painter );
+}
+
+/*!
+  \brief Draw the knob
+
+  \param painter painter
+  \param knobRect Bounding rectangle of the knob (without scale)
+*/
+void QwtKnob::drawKnob( QPainter *painter, const QRectF &knobRect ) const
+{
+    double dim = qMin( knobRect.width(), knobRect.height() );
+    dim -= d_data->borderWidth * 0.5;
+
+    QRectF aRect( 0, 0, dim, dim );
+    aRect.moveCenter( knobRect.center() );
+
+    QPen pen( Qt::NoPen );
+    if ( d_data->borderWidth > 0 )
+    {
+        QColor c1 = palette().color( QPalette::Light );
+        QColor c2 = palette().color( QPalette::Dark );
+
+        QLinearGradient gradient( aRect.topLeft(), aRect.bottomRight() );
+        gradient.setColorAt( 0.0, c1 );
+        gradient.setColorAt( 0.3, c1 );
+        gradient.setColorAt( 0.7, c2 );
+        gradient.setColorAt( 1.0, c2 );
+
+        pen = QPen( gradient, d_data->borderWidth ); 
+    }
+
+    QBrush brush;
+    switch( d_data->knobStyle )
+    {
+        case QwtKnob::Raised:
+        {
+            double off = 0.3 * knobRect.width();
+            QRadialGradient gradient( knobRect.center(),
+                knobRect.width(), knobRect.topLeft() + QPointF( off, off ) );
+            
+            gradient.setColorAt( 0.0, palette().color( QPalette::Midlight ) );
+            gradient.setColorAt( 1.0, palette().color( QPalette::Button ) );
+
+            brush = QBrush( gradient );
+
+            break;
+        }
+        case QwtKnob::Styled:
+        {
+            QRadialGradient gradient(knobRect.center().x() - knobRect.width() / 3,
+                knobRect.center().y() - knobRect.height() / 2,
+                knobRect.width() * 1.3,
+                knobRect.center().x(),
+                knobRect.center().y() - knobRect.height() / 2);
+
+            const QColor c = palette().color( QPalette::Button );
+            gradient.setColorAt(0, c.lighter(110));
+            gradient.setColorAt(qreal(0.5), c);
+            gradient.setColorAt(qreal(0.501), c.darker(102));
+            gradient.setColorAt(1, c.darker(115));
+
+            brush = QBrush( gradient );
+
+            break;
+        }
+        case QwtKnob::Sunken:
+        {
+            QLinearGradient gradient( 
+                knobRect.topLeft(), knobRect.bottomRight() );
+            gradient.setColorAt( 0.0, palette().color( QPalette::Mid ) );
+            gradient.setColorAt( 0.5, palette().color( QPalette::Button ) );
+            gradient.setColorAt( 1.0, palette().color( QPalette::Midlight ) );
+            brush = QBrush( gradient );
+
+            break;
+        }
+        case QwtKnob::Flat:
+        default:
+            brush = palette().brush( QPalette::Button );
+    }
+
+    painter->setPen( pen );
+    painter->setBrush( brush );
+    painter->drawEllipse( aRect );
+}
+
+
+/*!
+  \brief Draw the marker at the knob's front
+
+  \param painter Painter
+  \param rect Bounding rectangle of the knob without scale
+  \param angle Angle of the marker in degrees 
+               ( clockwise, 0 at the 12 o'clock position )
+*/
+void QwtKnob::drawMarker( QPainter *painter, 
+    const QRectF &rect, double angle ) const
+{
+    if ( d_data->markerStyle == NoMarker || !isValid() )
+        return;
+
+    const double radians = qwtRadians( angle );
+    const double sinA = -qFastSin( radians );
+    const double cosA = qFastCos( radians );
+
+    const double xm = rect.center().x();
+    const double ym = rect.center().y();
+    const double margin = 4.0;
+
+    double radius = 0.5 * ( rect.width() - d_data->borderWidth ) - margin;
+    if ( radius < 1.0 )
+        radius = 1.0;
+
+    int markerSize = d_data->markerSize;
+    if ( markerSize <= 0 )
+        markerSize = qRound( 0.4 * radius );
+
+    switch ( d_data->markerStyle )
+    {
+        case Notch:
+        case Nub:
+        {
+            const double dotWidth = 
+                qMin( double( markerSize ), radius);
+
+            const double dotCenterDist = radius - 0.5 * dotWidth;
+            if ( dotCenterDist > 0.0 )
+            {
+                const QPointF center( xm - sinA * dotCenterDist, 
+                    ym - cosA * dotCenterDist );
+
+                QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
+                ellipse.moveCenter( center );
+
+                QColor c1 = palette().color( QPalette::Light );
+                QColor c2 = palette().color( QPalette::Mid );
+
+                if ( d_data->markerStyle == Notch )
+                    qSwap( c1, c2 );
+
+                QLinearGradient gradient( 
+                    ellipse.topLeft(), ellipse.bottomRight() );
+                gradient.setColorAt( 0.0, c1 );
+                gradient.setColorAt( 1.0, c2 );
+
+                painter->setPen( Qt::NoPen );
+                painter->setBrush( gradient );
+
+                painter->drawEllipse( ellipse );
+            }
+            break;
+        }
+        case Dot:
+        {
+            const double dotWidth = 
+                qMin( double( markerSize ), radius);
+
+            const double dotCenterDist = radius - 0.5 * dotWidth;
+            if ( dotCenterDist > 0.0 )
+            {
+                const QPointF center( xm - sinA * dotCenterDist, 
+                    ym - cosA * dotCenterDist );
+
+                QRectF ellipse( 0.0, 0.0, dotWidth, dotWidth );
+                ellipse.moveCenter( center );
+
+                painter->setPen( Qt::NoPen );
+                painter->setBrush( palette().color( QPalette::ButtonText ) );
+                painter->drawEllipse( ellipse );
+            }
+
+            break;
+        }
+        case Tick:
+        {
+            const double rb = qMax( radius - markerSize, 1.0 );
+            const double re = radius;
+
+            const QLineF line( xm - sinA * rb, ym - cosA * rb,
+                xm - sinA * re, ym - cosA * re );
+
+            QPen pen( palette().color( QPalette::ButtonText ), 0 );
+            pen.setCapStyle( Qt::FlatCap );
+            painter->setPen( pen );
+            painter->drawLine ( line );
+
+            break;
+        }
+        case Triangle:
+        {
+            const double rb = qMax( radius - markerSize, 1.0 );
+            const double re = radius;
+
+            painter->translate( rect.center() );
+            painter->rotate( angle - 90.0 );
+            
+            QPolygonF polygon;
+            polygon += QPointF( re, 0.0 );
+            polygon += QPointF( rb, 0.5 * ( re - rb ) );
+            polygon += QPointF( rb, -0.5 * ( re - rb ) );
+
+            painter->setPen( Qt::NoPen );
+            painter->setBrush( palette().color( QPalette::ButtonText ) );
+            painter->drawPolygon( polygon );
+
+            painter->resetTransform();
+
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+/*!
+  Draw the focus indicator
+  \param painter Painter
+*/
+void QwtKnob::drawFocusIndicator( QPainter *painter ) const
+{       
+    const QRect cr = contentsRect();
+
+    int w = d_data->knobWidth;
+    if ( w <= 0 )
+    {
+        w = qMin( cr.width(), cr.height() );
+    }
+    else
+    {
+        const int extent = qCeil( scaleDraw()->extent( font() ) );
+        w += 2 * ( extent + d_data->scaleDist );
+    }
+
+    QRect focusRect( 0, 0, w, w );
+    focusRect.moveCenter( cr.center() );
+
+    QwtPainter::drawFocusRect( painter, this, focusRect );
+}  
+
+/*!
+  \brief Set the alignment of the knob
+
+  Similar to a QLabel::alignment() the flags decide how
+  to align the knob inside of contentsRect(). 
+
+  The default setting is Qt::AlignCenter
+
+  \param alignment Or'd alignment flags
+
+  \sa alignment(), setKnobWidth(), knobRect()
+ */
+void QwtKnob::setAlignment( Qt::Alignment alignment )
+{
+    if ( d_data->alignment != alignment )
+    {
+        d_data->alignment = alignment;
+        update();
+    }
+}
+
+/*!
+  \return Alignment of the knob inside of contentsRect()
+  \sa setAlignment(), knobWidth(), knobRect()
+ */
+Qt::Alignment QwtKnob::alignment() const
+{
+    return d_data->alignment;
+}
+
+/*!
+  \brief Change the knob's width.
+
+  Setting a fixed value for the diameter of the knob 
+  is helpful for aligning several knobs in a row.
+
+  \param width New width
+
+  \sa knobWidth(), setAlignment()
+  \note Modifies the sizePolicy() 
+*/
+void QwtKnob::setKnobWidth( int width )
+{
+    width = qMax( width, 0 );
+
+    if ( width != d_data->knobWidth )
+    {
+        QSizePolicy::Policy policy;
+        if ( width > 0 )
+            policy = QSizePolicy::Minimum;
+        else
+            policy = QSizePolicy::MinimumExpanding;
+
+        setSizePolicy( policy, policy );
+
+        d_data->knobWidth = width;
+
+        updateGeometry();
+        update();
+    }
+}
+
+//! Return the width of the knob
+int QwtKnob::knobWidth() const
+{
+    return d_data->knobWidth;
+}
+
+/*!
+  \brief Set the knob's border width
+  \param borderWidth new border width
+*/
+void QwtKnob::setBorderWidth( int borderWidth )
+{
+    d_data->borderWidth = qMax( borderWidth, 0 );
+
+    updateGeometry();
+    update();
+}
+
+//! Return the border width
+int QwtKnob::borderWidth() const
+{
+    return d_data->borderWidth;
+}
+
+/*!
+  \brief Set the size of the marker
+
+  When setting a size <= 0 the marker will
+  automatically scaled to 40% of the radius of the knob.
+
+  \sa markerSize(), markerStyle()
+*/
+void QwtKnob::setMarkerSize( int size )
+{
+    if ( d_data->markerSize != size )
+    {
+        d_data->markerSize = size;
+        update();
+    }
+}
+
+/*! 
+  \return Marker size
+  \sa setMarkerSize()
+ */
+int QwtKnob::markerSize() const
+{
+    return d_data->markerSize;
+}
+
+/*!
+  \return sizeHint()
+*/
+QSize QwtKnob::sizeHint() const
+{
+    const QSize hint = qwtKnobSizeHint( this, 50 );
+    return hint.expandedTo( QApplication::globalStrut() );
+}
+
+/*!
+  \return Minimum size hint
+  \sa sizeHint()
+*/
+QSize QwtKnob::minimumSizeHint() const
+{
+    return qwtKnobSizeHint( this, 20 );
+}
Index: trunk/BNC/qwt/qwt_knob.h
===================================================================
--- trunk/BNC/qwt/qwt_knob.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_knob.h	(revision 8127)
@@ -0,0 +1,178 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_KNOB_H
+#define QWT_KNOB_H
+
+#include "qwt_global.h"
+#include "qwt_abstract_slider.h"
+
+class QwtRoundScaleDraw;
+
+/*!
+  \brief The Knob Widget
+
+  The QwtKnob widget imitates look and behavior of a volume knob on a radio.
+  It looks similar to QDial - not to QwtDial.
+
+  The value range of a knob might be divided into several turns.
+
+  The layout of the knob depends on the knobWidth().
+
+  - width > 0 
+    The diameter of the knob is fixed and the knob is aligned
+    according to the alignment() flags inside of the contentsRect(). 
+
+  - width <= 0
+    The knob is extended to the minimum of width/height of the contentsRect()
+    and aligned in the other direction according to alignment().
+
+  Setting a fixed knobWidth() is helpful to align several knobs with different
+  scale labels.
+  
+  \image html knob.png
+*/
+
+class QWT_EXPORT QwtKnob: public QwtAbstractSlider
+{
+    Q_OBJECT
+
+    Q_ENUMS ( KnobStyle MarkerStyle )
+
+    Q_PROPERTY( KnobStyle knobStyle READ knobStyle WRITE setKnobStyle )
+    Q_PROPERTY( int knobWidth READ knobWidth WRITE setKnobWidth )
+    Q_PROPERTY( Qt::Alignment alignment READ alignment WRITE setAlignment )
+    Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
+    Q_PROPERTY( int numTurns READ numTurns WRITE setNumTurns )
+    Q_PROPERTY( MarkerStyle markerStyle READ markerStyle WRITE setMarkerStyle )
+    Q_PROPERTY( int markerSize READ markerSize WRITE setMarkerSize )
+    Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
+
+public:
+    /*! 
+       \brief Style of the knob surface
+
+       Depending on the KnobStyle the surface of the knob is
+       filled from the brushes of the widget palette().
+
+       \sa setKnobStyle(), knobStyle()
+     */
+    enum KnobStyle
+    {
+        //! Fill the knob with a brush from QPalette::Button.
+        Flat,
+
+        //! Build a gradient from QPalette::Midlight and QPalette::Button
+        Raised,
+
+        /*! 
+          Build a gradient from QPalette::Midlight, QPalette::Button
+          and QPalette::Midlight
+         */
+        Sunken,
+
+        /*! 
+          Build a radial gradient from QPalette::Button
+          like it is used for QDial in various Qt styles.
+         */
+        Styled
+    };
+
+    /*!
+        \brief Marker type
+ 
+        The marker indicates the current value on the knob
+        The default setting is a Notch marker.
+
+        \sa setMarkerStyle(), setMarkerSize()
+    */
+    enum MarkerStyle 
+    { 
+        //! Don't paint any marker
+        NoMarker = -1,
+
+        //! Paint a single tick in QPalette::ButtonText color
+        Tick, 
+
+        //! Paint a triangle in QPalette::ButtonText color
+        Triangle, 
+
+        //! Paint a circle in QPalette::ButtonText color
+        Dot, 
+
+        /*! 
+          Draw a raised ellipse with a gradient build from
+          QPalette::Light and QPalette::Mid
+         */ 
+        Nub, 
+
+        /*! 
+          Draw a sunken ellipse with a gradient build from
+          QPalette::Light and QPalette::Mid
+         */ 
+        Notch 
+    };
+
+    explicit QwtKnob( QWidget* parent = NULL );
+    virtual ~QwtKnob();
+
+    void setAlignment( Qt::Alignment );
+    Qt::Alignment alignment() const;
+
+    void setKnobWidth( int );
+    int knobWidth() const;
+
+    void setNumTurns( int );
+    int numTurns() const;
+
+    void setTotalAngle ( double angle );
+    double totalAngle() const;
+
+    void setKnobStyle( KnobStyle );
+    KnobStyle knobStyle() const;
+
+    void setBorderWidth( int bw );
+    int borderWidth() const;
+
+    void setMarkerStyle( MarkerStyle );
+    MarkerStyle markerStyle() const;
+
+    void setMarkerSize( int );
+    int markerSize() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+    void setScaleDraw( QwtRoundScaleDraw * );
+
+    const QwtRoundScaleDraw *scaleDraw() const;
+    QwtRoundScaleDraw *scaleDraw();
+
+    QRect knobRect() const;
+
+protected:
+    virtual void paintEvent( QPaintEvent * );
+    virtual void changeEvent( QEvent * );
+
+    virtual void drawKnob( QPainter *, const QRectF & ) const;
+
+    virtual void drawFocusIndicator( QPainter * ) const;
+
+    virtual void drawMarker( QPainter *, 
+        const QRectF &, double arc ) const;
+
+    virtual double scrolledTo( const QPoint & ) const;
+    virtual bool isScrollPosition( const QPoint & ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_legend.cpp
===================================================================
--- trunk/BNC/qwt/qwt_legend.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_legend.cpp	(revision 8127)
@@ -9,45 +9,129 @@
 
 #include "qwt_legend.h"
-#include "qwt_legend_itemmanager.h"
-#include "qwt_legend_item.h"
+#include "qwt_legend_label.h"
 #include "qwt_dyngrid_layout.h"
 #include "qwt_math.h"
+#include "qwt_plot_item.h"
+#include "qwt_painter.h"
 #include <qapplication.h>
-#include <qmap.h>
 #include <qscrollbar.h>
 #include <qscrollarea.h>
+#include <qpainter.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+
+class QwtLegendMap
+{
+public:
+    inline bool isEmpty() const { return d_entries.isEmpty(); }
+
+    void insert( const QVariant &, const QList<QWidget *> & );
+    void remove( const QVariant & );
+
+    void removeWidget( const QWidget * );
+
+    QList<QWidget *> legendWidgets( const QVariant & ) const;
+    QVariant itemInfo( const QWidget * ) const;
+
+private:
+    // we don't know anything about itemInfo and therefore don't have
+    // any key that can be used for a map or hashtab.
+    // But a simple linear list is o.k. here, as we will never have
+    // more than a few entries.
+
+    class Entry
+    {
+    public:
+        QVariant itemInfo;
+        QList<QWidget *> widgets;
+    };
+
+    QList< Entry > d_entries;
+};
+
+void QwtLegendMap::insert( const QVariant &itemInfo, 
+    const QList<QWidget *> &widgets )
+{
+    for ( int i = 0; i < d_entries.size(); i++ )
+    {
+        Entry &entry = d_entries[i];
+        if ( entry.itemInfo == itemInfo )
+        {
+            entry.widgets = widgets;
+            return;
+        }
+    }
+
+    Entry newEntry;
+    newEntry.itemInfo = itemInfo;
+    newEntry.widgets = widgets;
+
+    d_entries += newEntry;
+}
+
+void QwtLegendMap::remove( const QVariant &itemInfo )
+{
+    for ( int i = 0; i < d_entries.size(); i++ )
+    {
+        Entry &entry = d_entries[i];
+        if ( entry.itemInfo == itemInfo )
+        {
+            d_entries.removeAt( i );
+            return;
+        }
+    }
+}
+
+void QwtLegendMap::removeWidget( const QWidget *widget )
+{
+    QWidget *w = const_cast<QWidget *>( widget );
+
+    for ( int i = 0; i < d_entries.size(); i++ )
+        d_entries[ i ].widgets.removeAll( w );
+}
+
+QVariant QwtLegendMap::itemInfo( const QWidget *widget ) const
+{
+    if ( widget != NULL )
+    {
+        QWidget *w = const_cast<QWidget *>( widget );
+
+        for ( int i = 0; i < d_entries.size(); i++ )
+        {
+            const Entry &entry = d_entries[i];
+            if ( entry.widgets.indexOf( w ) >= 0 )
+                return entry.itemInfo;
+        }
+    }
+
+    return QVariant();
+}
+
+QList<QWidget *> QwtLegendMap::legendWidgets( const QVariant &itemInfo ) const
+{
+    if ( itemInfo.isValid() )
+    {
+        for ( int i = 0; i < d_entries.size(); i++ )
+        {
+            const Entry &entry = d_entries[i];
+            if ( entry.itemInfo == itemInfo )
+                return entry.widgets;
+        }
+    }
+
+    return QList<QWidget *>();
+}
 
 class QwtLegend::PrivateData
 {
 public:
-    class LegendMap
-    {
-    public:
-        void insert( const QwtLegendItemManager *, QWidget * );
-
-        void remove( const QwtLegendItemManager * );
-        void remove( QWidget * );
-
-        void clear();
-
-        uint count() const;
-
-        inline const QWidget *find( const QwtLegendItemManager * ) const;
-        inline QWidget *find( const QwtLegendItemManager * );
-
-        inline const QwtLegendItemManager *find( const QWidget * ) const;
-        inline QwtLegendItemManager *find( const QWidget * );
-
-        const QMap<QWidget *, const QwtLegendItemManager *> &widgetMap() const;
-        QMap<QWidget *, const QwtLegendItemManager *> &widgetMap();
-
-    private:
-        QMap<QWidget *, const QwtLegendItemManager *> d_widgetMap;
-        QMap<const QwtLegendItemManager *, QWidget *> d_itemMap;
-    };
-
-    QwtLegend::LegendItemMode itemMode;
-
-    LegendMap map;
+    PrivateData():
+        itemMode( QwtLegendData::ReadOnly ),
+        view( NULL )
+    {
+    }
+
+    QwtLegendData::Mode itemMode;
+    QwtLegendMap itemMap;
 
     class LegendView;
@@ -61,6 +145,4 @@
         QScrollArea( parent )
     {
-        setFocusPolicy( Qt::NoFocus );
-
         contentsWidget = new QWidget( this );
         contentsWidget->setObjectName( "QwtLegendViewContents" );
@@ -77,12 +159,39 @@
     }
 
-    virtual bool viewportEvent( QEvent *e )
-    {
-        bool ok = QScrollArea::viewportEvent( e );
-
-        if ( e->type() == QEvent::Resize )
-        {
-            QEvent event( QEvent::LayoutRequest );
-            QApplication::sendEvent( contentsWidget, &event );
+    virtual bool event( QEvent *event )
+    {
+        if ( event->type() == QEvent::PolishRequest )
+        {
+            setFocusPolicy( Qt::NoFocus );
+        }
+
+        if ( event->type() == QEvent::Resize )
+        {
+            // adjust the size to en/disable the scrollbars
+            // before QScrollArea adjusts the viewport size
+
+            const QRect cr = contentsRect();
+
+            int w = cr.width();
+            int h = contentsWidget->heightForWidth( cr.width() );
+            if ( h > w )
+            {
+                w -= verticalScrollBar()->sizeHint().width();
+                h = contentsWidget->heightForWidth( w );
+            }
+
+            contentsWidget->resize( w, h );
+        }
+
+        return QScrollArea::event( event );
+    }
+
+    virtual bool viewportEvent( QEvent *event )
+    {
+        bool ok = QScrollArea::viewportEvent( event );
+
+        if ( event->type() == QEvent::Resize )
+        {
+            layoutContents();
         }
         return ok;
@@ -112,117 +221,41 @@
     }
 
+    void layoutContents()
+    {
+        const QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
+            contentsWidget->layout() );
+        if ( tl == NULL )
+            return;
+
+        const QSize visibleSize = viewport()->contentsRect().size();
+
+        const int minW = int( tl->maxItemWidth() ) + 2 * tl->margin();
+
+        int w = qMax( visibleSize.width(), minW );
+        int h = qMax( tl->heightForWidth( w ), visibleSize.height() );
+
+        const int vpWidth = viewportSize( w, h ).width();
+        if ( w > vpWidth )
+        {
+            w = qMax( vpWidth, minW );
+            h = qMax( tl->heightForWidth( w ), visibleSize.height() );
+        }
+
+        contentsWidget->resize( w, h );
+    }
+
     QWidget *contentsWidget;
 };
 
-void QwtLegend::PrivateData::LegendMap::insert(
-    const QwtLegendItemManager *item, QWidget *widget )
-{
-    d_itemMap.insert( item, widget );
-    d_widgetMap.insert( widget, item );
-}
-
-void QwtLegend::PrivateData::LegendMap::remove( const QwtLegendItemManager *item )
-{
-    QWidget *widget = d_itemMap[item];
-    d_itemMap.remove( item );
-    d_widgetMap.remove( widget );
-}
-
-void QwtLegend::PrivateData::LegendMap::remove( QWidget *widget )
-{
-    const QwtLegendItemManager *item = d_widgetMap[widget];
-    d_itemMap.remove( item );
-    d_widgetMap.remove( widget );
-}
-
-void QwtLegend::PrivateData::LegendMap::clear()
-{
-
-    /*
-       We can't delete the widgets in the following loop, because
-       we would get ChildRemoved events, changing d_itemMap, while
-       we are iterating.
-     */
-
-    QList<const QWidget *> widgets;
-
-    QMap<const QwtLegendItemManager *, QWidget *>::const_iterator it;
-    for ( it = d_itemMap.begin(); it != d_itemMap.end(); ++it )
-        widgets.append( it.value() );
-
-    d_itemMap.clear();
-    d_widgetMap.clear();
-
-    for ( int i = 0; i < widgets.size(); i++ )
-        delete widgets[i];
-}
-
-uint QwtLegend::PrivateData::LegendMap::count() const
-{
-    return d_itemMap.count();
-}
-
-inline const QWidget *QwtLegend::PrivateData::LegendMap::find( 
-    const QwtLegendItemManager *item ) const
-{
-    if ( !d_itemMap.contains( item ) )
-        return NULL;
-
-    return d_itemMap[item];
-}
-
-inline QWidget *QwtLegend::PrivateData::LegendMap::find( 
-    const QwtLegendItemManager *item )
-{
-    if ( !d_itemMap.contains( item ) )
-        return NULL;
-
-    return d_itemMap[item];
-}
-
-inline const QwtLegendItemManager *QwtLegend::PrivateData::LegendMap::find(
-    const QWidget *widget ) const
-{
-    QWidget *w = const_cast<QWidget *>( widget );
-    if ( !d_widgetMap.contains( w ) )
-        return NULL;
-
-    return d_widgetMap[w];
-}
-
-inline QwtLegendItemManager *QwtLegend::PrivateData::LegendMap::find(
-    const QWidget *widget )
-{
-    QWidget *w = const_cast<QWidget *>( widget );
-    if ( !d_widgetMap.contains( w ) )
-        return NULL;
-
-    return const_cast<QwtLegendItemManager *>( d_widgetMap[w] );
-}
-
-inline const QMap<QWidget *, const QwtLegendItemManager *> &
-QwtLegend::PrivateData::LegendMap::widgetMap() const
-{
-    return d_widgetMap;
-}
-
-inline QMap<QWidget *, const QwtLegendItemManager *> &
-QwtLegend::PrivateData::LegendMap::widgetMap()
-{
-    return d_widgetMap;
-}
-
 /*!
   Constructor
-
   \param parent Parent widget
 */
 QwtLegend::QwtLegend( QWidget *parent ):
-    QFrame( parent )
+    QwtAbstractLegend( parent )
 {
     setFrameStyle( NoFrame );
 
     d_data = new QwtLegend::PrivateData;
-    d_data->itemMode = QwtLegend::ReadOnlyItem;
 
     d_data->view = new QwtLegend::PrivateData::LegendView( this );
@@ -247,12 +280,61 @@
 }
 
-//! \sa LegendItemMode
-void QwtLegend::setItemMode( LegendItemMode mode )
+/*!
+  \brief Set the maximum number of entries in a row
+
+  F.e when the maximum is set to 1 all items are aligned
+  vertically. 0 means unlimited
+
+  \param numColums Maximum number of entries in a row
+
+  \sa maxColumns(), QwtDynGridLayout::setMaxColumns()
+ */
+void QwtLegend::setMaxColumns( uint numColums )
+{
+    QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
+        d_data->view->contentsWidget->layout() );
+    if ( tl )
+        tl->setMaxColumns( numColums );
+}
+
+/*!
+  \return Maximum number of entries in a row
+  \sa setMaxColumns(), QwtDynGridLayout::maxColumns()
+ */
+uint QwtLegend::maxColumns() const
+{
+    uint maxCols = 0;
+
+    const QwtDynGridLayout *tl = qobject_cast<const QwtDynGridLayout *>(
+        d_data->view->contentsWidget->layout() );
+    if ( tl )
+        maxCols = tl->maxColumns();
+
+    return maxCols;
+}
+
+/*!
+  \brief Set the default mode for legend labels
+
+  Legend labels will be constructed according to the
+  attributes in a QwtLegendData object. When it doesn't
+  contain a value for the QwtLegendData::ModeRole the
+  label will be initialized with the default mode of the legend.
+
+  \param mode Default item mode
+
+  \sa itemMode(), QwtLegendData::value(), QwtPlotItem::legendData()
+  \note Changing the mode doesn't have any effect on existing labels.
+ */
+void QwtLegend::setDefaultItemMode( QwtLegendData::Mode mode )
 {
     d_data->itemMode = mode;
 }
 
-//! \sa LegendItemMode
-QwtLegend::LegendItemMode QwtLegend::itemMode() const
+/*!
+  \return Default item mode
+  \sa setDefaultItemMode()
+*/
+QwtLegendData::Mode QwtLegend::defaultItemMode() const
 {
     return d_data->itemMode;
@@ -261,5 +343,5 @@
 /*!
   The contents widget is the only child of the viewport of 
-  the internal QScrollArea  and the parent widget of all legend items.
+  the internal QScrollArea and the parent widget of all legend items.
 
   \return Container widget of the legend items
@@ -290,5 +372,5 @@
 /*!
   The contents widget is the only child of the viewport of 
-  the internal QScrollArea  and the parent widget of all legend items.
+  the internal QScrollArea and the parent widget of all legend items.
 
   \return Container widget of the legend items
@@ -301,36 +383,128 @@
 
 /*!
-  Insert a new item for a plot item
-  \param plotItem Plot item
-  \param legendItem New legend item
-  \note The parent of item will be changed to contentsWidget()
-*/
-void QwtLegend::insert( const QwtLegendItemManager *plotItem, QWidget *legendItem )
-{
-    if ( legendItem == NULL || plotItem == NULL )
-        return;
-
-    QWidget *contentsWidget = d_data->view->contentsWidget;
-
-    if ( legendItem->parent() != contentsWidget )
-        legendItem->setParent( contentsWidget );
-
-    legendItem->show();
-
-    d_data->map.insert( plotItem, legendItem );
-
-    layoutContents();
-
-    if ( contentsWidget->layout() )
-    {
-        contentsWidget->layout()->addWidget( legendItem );
-
+  \brief Update the entries for an item
+
+  \param itemInfo Info for an item
+  \param data List of legend entry attributes for the item
+ */
+void QwtLegend::updateLegend( const QVariant &itemInfo, 
+    const QList<QwtLegendData> &data )
+{
+    QList<QWidget *> widgetList = legendWidgets( itemInfo );
+
+    if ( widgetList.size() != data.size() )
+    {
+        QLayout *contentsLayout = d_data->view->contentsWidget->layout();
+
+        while ( widgetList.size() > data.size() )
+        {
+            QWidget *w = widgetList.takeLast();
+
+            contentsLayout->removeWidget( w );
+
+            // updates might be triggered by signals from the legend widget
+            // itself. So we better don't delete it here.
+
+            w->hide();
+            w->deleteLater();
+        }
+
+        for ( int i = widgetList.size(); i < data.size(); i++ )
+        {
+            QWidget *widget = createWidget( data[i] );
+
+            if ( contentsLayout )
+                contentsLayout->addWidget( widget );
+
+            if ( isVisible() )
+            {
+                // QLayout does a delayed show, with the effect, that
+                // the size hint will be wrong, when applications
+                // call replot() right after changing the list
+                // of plot items. So we better do the show now.
+
+                widget->setVisible( true );
+            }
+
+            widgetList += widget;
+        }
+
+        if ( widgetList.isEmpty() )
+        {
+            d_data->itemMap.remove( itemInfo );
+        }
+        else
+        {
+            d_data->itemMap.insert( itemInfo, widgetList );
+        }
+
+        updateTabOrder();
+    }
+    
+    for ( int i = 0; i < data.size(); i++ )
+        updateWidget( widgetList[i], data[i] );
+}
+
+/*!
+  \brief Create a widget to be inserted into the legend
+
+  The default implementation returns a QwtLegendLabel.
+
+  \param data Attributes of the legend entry
+  \return Widget representing data on the legend
+  
+  \note updateWidget() will called soon after createWidget()
+        with the same attributes.
+ */
+QWidget *QwtLegend::createWidget( const QwtLegendData &data ) const
+{
+    Q_UNUSED( data );
+
+    QwtLegendLabel *label = new QwtLegendLabel();
+    label->setItemMode( defaultItemMode() );
+
+    connect( label, SIGNAL( clicked() ), SLOT( itemClicked() ) );
+    connect( label, SIGNAL( checked( bool ) ), SLOT( itemChecked( bool ) ) );
+
+    return label;
+}
+
+/*!
+  \brief Update the widget 
+
+  \param widget Usually a QwtLegendLabel
+  \param data Attributes to be displayed
+
+  \sa createWidget()
+  \note When widget is no QwtLegendLabel updateWidget() does nothing.
+ */
+void QwtLegend::updateWidget( QWidget *widget, const QwtLegendData &data )
+{
+    QwtLegendLabel *label = qobject_cast<QwtLegendLabel *>( widget );
+    if ( label )
+    {
+        label->setData( data );
+        if ( !data.value( QwtLegendData::ModeRole ).isValid() )
+        {
+            // use the default mode, when there is no specific
+            // hint from the legend data
+
+            label->setItemMode( defaultItemMode() );
+        }
+    }
+}
+
+void QwtLegend::updateTabOrder()
+{
+    QLayout *contentsLayout = d_data->view->contentsWidget->layout();
+    if ( contentsLayout )
+    {
         // set tab focus chain
 
         QWidget *w = NULL;
 
-        for ( int i = 0; i < contentsWidget->layout()->count(); i++ )
-        {
-            QLayoutItem *item = contentsWidget->layout()->itemAt( i );
+        for ( int i = 0; i < contentsLayout->count(); i++ )
+        {
+            QLayoutItem *item = contentsLayout->itemAt( i );
             if ( w && item->widget() )
                 QWidget::setTabOrder( w, item->widget() );
@@ -339,65 +513,4 @@
         }
     }
-    if ( parentWidget() && parentWidget()->layout() == NULL )
-    {
-        /*
-           updateGeometry() doesn't post LayoutRequest in certain
-           situations, like when we are hidden. But we want the
-           parent widget notified, so it can show/hide the legend
-           depending on its items.
-         */
-        QApplication::postEvent( parentWidget(),
-            new QEvent( QEvent::LayoutRequest ) );
-    }
-}
-
-/*!
-  Find the widget that represents a plot item
-
-  \param plotItem Plot item
-  \return Widget on the legend, or NULL
-*/
-QWidget *QwtLegend::find( const QwtLegendItemManager *plotItem ) const
-{
-    return d_data->map.find( plotItem );
-}
-
-/*!
-  Find the widget that represents a plot item
-
-  \param legendItem Legend item
-  \return Widget on the legend, or NULL
-*/
-QwtLegendItemManager *QwtLegend::find( const QWidget *legendItem ) const
-{
-    return d_data->map.find( legendItem );
-}
-
-/*!
-   Find the corresponding item for a plotItem and remove it
-   from the item list.
-
-   \param plotItem Plot item
-*/
-void QwtLegend::remove( const QwtLegendItemManager *plotItem )
-{
-    QWidget *legendItem = d_data->map.find( plotItem );
-    d_data->map.remove( legendItem );
-    delete legendItem;
-}
-
-//! Remove all items.
-void QwtLegend::clear()
-{
-    bool doUpdate = updatesEnabled();
-    if ( doUpdate )
-        setUpdatesEnabled( false );
-
-    d_data->map.clear();
-
-    if ( doUpdate )
-        setUpdatesEnabled( true );
-
-    update();
 }
 
@@ -412,5 +525,5 @@
 
 /*!
-  \return The preferred height, for the width w.
+  \return The preferred height, for a width.
   \param width Width
 */
@@ -426,31 +539,4 @@
 }
 
-/*!
-  Adjust contents widget and item layout to the size of the viewport().
-*/
-void QwtLegend::layoutContents()
-{
-    const QSize visibleSize = 
-        d_data->view->viewport()->contentsRect().size();
-
-    const QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
-        d_data->view->contentsWidget->layout() );
-    if ( tl )
-    {
-        const int minW = int( tl->maxItemWidth() ) + 2 * tl->margin();
-
-        int w = qMax( visibleSize.width(), minW );
-        int h = qMax( tl->heightForWidth( w ), visibleSize.height() );
-
-        const int vpWidth = d_data->view->viewportSize( w, h ).width();
-        if ( w > vpWidth )
-        {
-            w = qMax( vpWidth, minW );
-            h = qMax( tl->heightForWidth( w ), visibleSize.height() );
-        }
-
-        d_data->view->contentsWidget->resize( w, h );
-    }
-}
 
 /*!
@@ -460,4 +546,6 @@
   \param object Object to be filtered
   \param event Event
+
+  \return Forwarded to QwtAbstractLegend::eventFilter()
 */
 bool QwtLegend::eventFilter( QObject *object, QEvent *event )
@@ -474,5 +562,5 @@
                 {
                     QWidget *w = static_cast< QWidget * >( ce->child() );
-                    d_data->map.remove( w );
+                    d_data->itemMap.removeWidget( w );
                 }
                 break;
@@ -480,5 +568,22 @@
             case QEvent::LayoutRequest:
             {
-                layoutContents();
+                d_data->view->layoutContents();
+
+                if ( parentWidget() && parentWidget()->layout() == NULL )
+                {
+                    /*
+                       We want the parent widget ( usually QwtPlot ) to recalculate
+                       its layout, when the contentsWidget has changed. But
+                       because of the scroll view we have to forward the LayoutRequest
+                       event manually.
+
+                       We don't use updateGeometry() because it doesn't post LayoutRequest
+                       events when the legend is hidden. But we want the
+                       parent widget notified, so it can show/hide the legend
+                       depending on its items.
+                     */
+                    QApplication::postEvent( parentWidget(),
+                        new QEvent( QEvent::LayoutRequest ) );
+                }                
                 break;
             }
@@ -488,32 +593,219 @@
     }
 
-    return QFrame::eventFilter( object, event );
-}
-
-
-//! Return true, if there are no legend items.
+    return QwtAbstractLegend::eventFilter( object, event );
+}
+
+/*!
+  Called internally when the legend has been clicked on.
+  Emits a clicked() signal.
+*/
+void QwtLegend::itemClicked()
+{
+    QWidget *w = qobject_cast<QWidget *>( sender() );
+    if ( w )
+    {
+        const QVariant itemInfo = d_data->itemMap.itemInfo( w );
+        if ( itemInfo.isValid() )
+        {
+            const QList<QWidget *> widgetList =
+                d_data->itemMap.legendWidgets( itemInfo );
+
+            const int index = widgetList.indexOf( w );
+            if ( index >= 0 )
+                Q_EMIT clicked( itemInfo, index );
+        }
+    }
+}
+
+/*!
+  Called internally when the legend has been checked
+  Emits a checked() signal.
+*/
+void QwtLegend::itemChecked( bool on )
+{
+    QWidget *w = qobject_cast<QWidget *>( sender() );
+    if ( w )
+    {
+        const QVariant itemInfo = d_data->itemMap.itemInfo( w );
+        if ( itemInfo.isValid() )
+        {
+            const QList<QWidget *> widgetList =
+                d_data->itemMap.legendWidgets( itemInfo );
+
+            const int index = widgetList.indexOf( w );
+            if ( index >= 0 )
+                Q_EMIT checked( itemInfo, on, index );
+        }
+    }
+}
+
+/*!
+  Render the legend into a given rectangle.
+
+  \param painter Painter
+  \param rect Bounding rectangle
+  \param fillBackground When true, fill rect with the widget background 
+
+  \sa renderLegend() is used by QwtPlotRenderer - not by QwtLegend itself
+*/
+void QwtLegend::renderLegend( QPainter *painter, 
+    const QRectF &rect, bool fillBackground ) const
+{
+    if ( d_data->itemMap.isEmpty() )
+        return;
+
+    if ( fillBackground )
+    {
+        if ( autoFillBackground() ||
+            testAttribute( Qt::WA_StyledBackground ) )
+        {
+            QwtPainter::drawBackgound( painter, rect, this );
+        }
+    }
+
+    const QwtDynGridLayout *legendLayout = 
+        qobject_cast<QwtDynGridLayout *>( contentsWidget()->layout() );
+    if ( legendLayout == NULL )
+        return;
+
+    int left, right, top, bottom;
+    getContentsMargins( &left, &top, &right, &bottom );
+
+    QRect layoutRect; 
+    layoutRect.setLeft( qCeil( rect.left() ) + left );
+    layoutRect.setTop( qCeil( rect.top() ) + top );
+    layoutRect.setRight( qFloor( rect.right() ) - right );
+    layoutRect.setBottom( qFloor( rect.bottom() ) - bottom );
+
+    uint numCols = legendLayout->columnsForWidth( layoutRect.width() );
+    QList<QRect> itemRects =
+        legendLayout->layoutItems( layoutRect, numCols );
+
+    int index = 0;
+
+    for ( int i = 0; i < legendLayout->count(); i++ )
+    {
+        QLayoutItem *item = legendLayout->itemAt( i );
+        QWidget *w = item->widget();
+        if ( w )
+        {
+            painter->save();
+
+            painter->setClipRect( itemRects[index], Qt::IntersectClip );
+            renderItem( painter, w, itemRects[index], fillBackground );
+
+            index++;
+            painter->restore();
+        }
+    }
+}
+
+/*!
+  Render a legend entry into a given rectangle.
+
+  \param painter Painter
+  \param widget Widget representing a legend entry
+  \param rect Bounding rectangle
+  \param fillBackground When true, fill rect with the widget background 
+
+  \note When widget is not derived from QwtLegendLabel renderItem
+        does nothing beside the background
+*/
+void QwtLegend::renderItem( QPainter *painter, 
+    const QWidget *widget, const QRectF &rect, bool fillBackground ) const
+{
+    if ( fillBackground )
+    {
+        if ( widget->autoFillBackground() ||
+            widget->testAttribute( Qt::WA_StyledBackground ) )
+        {
+            QwtPainter::drawBackgound( painter, rect, widget );
+        }
+    }
+
+    const QwtLegendLabel *label = qobject_cast<const QwtLegendLabel *>( widget );
+    if ( label )
+    {
+        // icon
+
+        const QwtGraphic &icon = label->data().icon();
+        const QSizeF sz = icon.defaultSize();
+
+        const QRectF iconRect( rect.x() + label->margin(),
+            rect.center().y() - 0.5 * sz.height(), 
+            sz.width(), sz.height() );
+
+        icon.render( painter, iconRect, Qt::KeepAspectRatio );
+
+        // title
+
+        QRectF titleRect = rect;
+        titleRect.setX( iconRect.right() + 2 * label->spacing() );
+
+        painter->setFont( label->font() );
+        painter->setPen( label->palette().color( QPalette::Text ) );
+        const_cast< QwtLegendLabel *>( label )->drawText( painter, titleRect );
+    }
+}
+
+/*!
+  \return List of widgets associated to a item
+  \param itemInfo Info about an item
+  \sa legendWidget(), itemInfo(), QwtPlot::itemToInfo()
+ */
+QList<QWidget *> QwtLegend::legendWidgets( const QVariant &itemInfo ) const
+{
+    return d_data->itemMap.legendWidgets( itemInfo );
+}
+
+/*!
+  \return First widget in the list of widgets associated to an item
+  \param itemInfo Info about an item
+  \sa itemInfo(), QwtPlot::itemToInfo()
+  \note Almost all types of items have only one widget
+*/
+QWidget *QwtLegend::legendWidget( const QVariant &itemInfo ) const
+{
+    const QList<QWidget *> list = d_data->itemMap.legendWidgets( itemInfo );
+    if ( list.isEmpty() )
+        return NULL;
+
+    return list[0];
+}
+
+/*!
+  Find the item that is associated to a widget
+
+  \param widget Widget on the legend
+  \return Associated item info
+  \sa legendWidget()
+ */
+QVariant QwtLegend::itemInfo( const QWidget *widget ) const
+{
+    return d_data->itemMap.itemInfo( widget );
+}
+
+//! \return True, when no item is inserted
 bool QwtLegend::isEmpty() const
 {
-    return d_data->map.count() == 0;
-}
-
-//! Return the number of legend items.
-uint QwtLegend::itemCount() const
-{
-    return d_data->map.count();
-}
-
-//! Return a list of all legend items
-QList<QWidget *> QwtLegend::legendItems() const
-{
-    const QMap<QWidget *, const QwtLegendItemManager *> &map =
-        d_data->map.widgetMap();
-
-    QList<QWidget *> list;
-
-    QMap<QWidget *, const QwtLegendItemManager *>::const_iterator it;
-    for ( it = map.begin(); it != map.end(); ++it )
-        list += it.key();
-
-    return list;
-}
+    return d_data->itemMap.isEmpty();
+}
+
+/*!
+    Return the extent, that is needed for the scrollbars
+
+    \param orientation Orientation ( 
+    \return The width of the vertical scrollbar for Qt::Horizontal and v.v.
+ */
+int QwtLegend::scrollExtent( Qt::Orientation orientation ) const
+{
+    int extent = 0;
+
+    if ( orientation == Qt::Horizontal )
+        extent = verticalScrollBar()->sizeHint().width();
+    else
+        extent = horizontalScrollBar()->sizeHint().height();
+
+    return extent;
+}
+
Index: trunk/BNC/qwt/qwt_legend.h
===================================================================
--- trunk/BNC/qwt/qwt_legend.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_legend.h	(revision 8127)
@@ -12,9 +12,8 @@
 
 #include "qwt_global.h"
-#include <qframe.h>
-#include <qlist.h>
+#include "qwt_abstract_legend.h"
+#include <qvariant.h>
 
 class QScrollBar;
-class QwtLegendItemManager;
 
 /*!
@@ -23,57 +22,30 @@
   The QwtLegend widget is a tabular arrangement of legend items. Legend
   items might be any type of widget, but in general they will be
-  a QwtLegendItem.
+  a QwtLegendLabel.
 
-  \sa QwtLegendItem, QwtLegendItemManager QwtPlot
+  \sa QwtLegendLabel, QwtPlotItem, QwtPlot
 */
 
-class QWT_EXPORT QwtLegend : public QFrame
+class QWT_EXPORT QwtLegend : public QwtAbstractLegend
 {
     Q_OBJECT
 
 public:
-    /*!
-      \brief Interaction mode for the legend items
-
-       The default is QwtLegend::ReadOnlyItem.
-
-       \sa setItemMode(), itemMode(), QwtLegendItem::IdentifierMode
-           QwtLegendItem::clicked(), QwtLegendItem::checked(),
-           QwtPlot::legendClicked(), QwtPlot::legendChecked()
-     */
-
-    enum LegendItemMode
-    {
-        //! The legend item is not interactive, like a label
-        ReadOnlyItem,
-
-        //! The legend item is clickable, like a push button
-        ClickableItem,
-
-        //! The legend item is checkable, like a checkable button
-        CheckableItem
-    };
-
     explicit QwtLegend( QWidget *parent = NULL );
     virtual ~QwtLegend();
 
-    void setItemMode( LegendItemMode );
-    LegendItemMode itemMode() const;
+    void setMaxColumns( uint numColums );
+    uint maxColumns() const;
+
+    void setDefaultItemMode( QwtLegendData::Mode );
+    QwtLegendData::Mode defaultItemMode() const;
 
     QWidget *contentsWidget();
     const QWidget *contentsWidget() const;
 
-    void insert( const QwtLegendItemManager *, QWidget * );
-    void remove( const QwtLegendItemManager * );
+    QWidget *legendWidget( const QVariant &  ) const;
+    QList<QWidget *> legendWidgets( const QVariant & ) const;
 
-    QWidget *find( const QwtLegendItemManager * ) const;
-    QwtLegendItemManager *find( const QWidget * ) const;
-
-    virtual QList<QWidget *> legendItems() const;
-
-    void clear();
-
-    bool isEmpty() const;
-    uint itemCount() const;
+    QVariant itemInfo( const QWidget * ) const;
 
     virtual bool eventFilter( QObject *, QEvent * );
@@ -85,8 +57,58 @@
     QScrollBar *verticalScrollBar() const;
 
+    virtual void renderLegend( QPainter *, 
+        const QRectF &, bool fillBackground ) const;
+
+    virtual void renderItem( QPainter *, 
+        const QWidget *, const QRectF &, bool fillBackground ) const;
+
+    virtual bool isEmpty() const;
+    virtual int scrollExtent( Qt::Orientation ) const;
+
+Q_SIGNALS:
+    /*!
+      A signal which is emitted when the user has clicked on
+      a legend label, which is in QwtLegendData::Clickable mode.
+
+      \param itemInfo Info for the item item of the
+                      selected legend item
+      \param index Index of the legend label in the list of widgets
+                   that are associated with the plot item
+
+      \note clicks are disabled as default
+      \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
+     */
+    void clicked( const QVariant &itemInfo, int index );
+
+    /*!
+      A signal which is emitted when the user has clicked on
+      a legend label, which is in QwtLegendData::Checkable mode
+
+      \param itemInfo Info for the item of the
+                      selected legend label
+      \param index Index of the legend label in the list of widgets
+                   that are associated with the plot item
+      \param on True when the legend label is checked
+
+      \note clicks are disabled as default
+      \sa setDefaultItemMode(), defaultItemMode(), QwtPlot::itemToInfo()
+     */
+    void checked( const QVariant &itemInfo, bool on, int index );
+
+public Q_SLOTS:
+    virtual void updateLegend( const QVariant &,
+        const QList<QwtLegendData> & );
+
+protected Q_SLOTS:
+    void itemClicked();
+    void itemChecked( bool );
+
 protected:
-    virtual void layoutContents();
+    virtual QWidget *createWidget( const QwtLegendData & ) const;
+    virtual void updateWidget( QWidget *widget, const QwtLegendData &data );
 
 private:
+    void updateTabOrder();
+
     class PrivateData;
     PrivateData *d_data;
Index: trunk/BNC/qwt/qwt_legend_data.cpp
===================================================================
--- trunk/BNC/qwt/qwt_legend_data.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_legend_data.cpp	(revision 8127)
@@ -0,0 +1,129 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_legend_data.h"
+
+//! Constructor
+QwtLegendData::QwtLegendData()
+{
+}
+
+//! Destructor
+QwtLegendData::~QwtLegendData()
+{
+}
+
+/*!
+  Set the legend attributes
+
+  QwtLegendData actually is a QMap<int, QVariant> with some
+  convenience interfaces
+
+  \param map Values
+  \sa values()
+ */
+void QwtLegendData::setValues( const QMap<int, QVariant> &map )
+{
+    d_map = map;
+}
+
+/*!
+  \return Legend attributes
+  \sa setValues()
+ */
+const QMap<int, QVariant> &QwtLegendData::values() const
+{
+    return d_map;
+}
+
+/*!
+  \param role Attribute role
+  \return True, when the internal map has an entry for role
+ */
+bool QwtLegendData::hasRole( int role ) const
+{
+    return d_map.contains( role );
+}
+
+/*!
+  Set an attribute value
+
+  \param role Attribute role
+  \param data Attribute value
+
+  \sa value()
+ */
+void QwtLegendData::setValue( int role, const QVariant &data )
+{
+    d_map[role] = data;
+}
+
+/*!
+  \param role Attribute role
+  \return Attribute value for a specific role
+ */
+QVariant QwtLegendData::value( int role ) const
+{
+    if ( !d_map.contains( role ) )
+        return QVariant();
+
+    return d_map[role];
+}
+
+//! \return True, when the internal map is empty
+bool QwtLegendData::isValid() const
+{
+    return !d_map.isEmpty();
+}
+
+//! \return Value of the TitleRole attribute
+QwtText QwtLegendData::title() const
+{
+    QwtText text;
+
+    const QVariant titleValue = value( QwtLegendData::TitleRole );
+    if ( titleValue.canConvert<QwtText>() )
+    {
+        text = qvariant_cast<QwtText>( titleValue );
+    }
+    else if ( titleValue.canConvert<QString>() )
+    {
+        text.setText( qvariant_cast<QString>( titleValue ) );
+    }
+
+    return text;
+}
+
+//! \return Value of the IconRole attribute
+QwtGraphic QwtLegendData::icon() const
+{
+    const QVariant iconValue = value( QwtLegendData::IconRole );
+
+    QwtGraphic graphic;
+    if ( iconValue.canConvert<QwtGraphic>() )
+    {
+        graphic = qvariant_cast<QwtGraphic>( iconValue );
+    }
+
+    return graphic;
+}
+
+//! \return Value of the ModeRole attribute
+QwtLegendData::Mode QwtLegendData::mode() const
+{
+    const QVariant modeValue = value( QwtLegendData::ModeRole );
+    if ( modeValue.canConvert<int>() )
+    {
+        const int mode = qvariant_cast<int>( modeValue );
+        return static_cast<QwtLegendData::Mode>( mode );
+    }
+    
+    return QwtLegendData::ReadOnly;
+}
+
Index: trunk/BNC/qwt/qwt_legend_data.h
===================================================================
--- trunk/BNC/qwt/qwt_legend_data.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_legend_data.h	(revision 8127)
@@ -0,0 +1,87 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_LEGEND_DATA_H
+#define QWT_LEGEND_DATA_H
+
+#include "qwt_global.h"
+#include "qwt_text.h"
+#include "qwt_graphic.h"
+#include <qvariant.h>
+#include <qpixmap.h>
+#include <qmap.h>
+
+/*!
+  \brief Attributes of an entry on a legend
+
+  QwtLegendData is an abstract container ( like QAbstractModel )
+  to exchange attributes, that are only known between to 
+  the plot item and the legend. 
+  
+  By overloading QwtPlotItem::legendData() any other set of attributes
+  could be used, that can be handled by a modified ( or completely 
+  different ) implementation of a legend.
+
+  \sa QwtLegend, QwtPlotLegendItem
+  \note The stockchart example implements a legend as a tree
+        with checkable items
+ */
+class QWT_EXPORT QwtLegendData
+{
+public:
+    //! Mode defining how a legend entry interacts
+    enum Mode
+    {
+        //! The legend item is not interactive, like a label
+        ReadOnly,
+
+        //! The legend item is clickable, like a push button
+        Clickable,
+
+        //! The legend item is checkable, like a checkable button
+        Checkable
+    };
+
+    //! Identifier how to interprete a QVariant
+    enum Role
+    {
+        // The value is a Mode
+        ModeRole, 
+
+        // The value is a title
+        TitleRole, 
+
+        // The value is an icon
+        IconRole, 
+
+        // Values < UserRole are reserved for internal use
+        UserRole  = 32
+    };
+
+    QwtLegendData();
+    ~QwtLegendData();
+
+    void setValues( const QMap<int, QVariant> & );
+    const QMap<int, QVariant> &values() const;
+
+    void setValue( int role, const QVariant & );
+    QVariant value( int role ) const;
+
+    bool hasRole( int role ) const;
+    bool isValid() const;
+
+    QwtGraphic icon() const;
+    QwtText title() const;
+    Mode mode() const;
+
+private:
+    QMap<int, QVariant> d_map;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_legend_item.cpp
===================================================================
--- trunk/BNC/qwt/qwt_legend_item.cpp	(revision 8125)
+++ 	(revision )
@@ -1,405 +1,0 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
- * Qwt Widget Library
- * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2002   Uwe Rathmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Qwt License, Version 1.0
- *****************************************************************************/
-
-#include "qwt_legend_item.h"
-#include "qwt_math.h"
-#include "qwt_painter.h"
-#include "qwt_symbol.h"
-#include <qpainter.h>
-#include <qdrawutil.h>
-#include <qstyle.h>
-#include <qpen.h>
-#include <qevent.h>
-#include <qstyleoption.h>
-#include <qapplication.h>
-
-static const int ButtonFrame = 2;
-static const int Margin = 2;
-
-static QSize buttonShift( const QwtLegendItem *w )
-{
-    QStyleOption option;
-    option.init( w );
-
-    const int ph = w->style()->pixelMetric(
-        QStyle::PM_ButtonShiftHorizontal, &option, w );
-    const int pv = w->style()->pixelMetric(
-        QStyle::PM_ButtonShiftVertical, &option, w );
-    return QSize( ph, pv );
-}
-
-class QwtLegendItem::PrivateData
-{
-public:
-    PrivateData():
-        itemMode( QwtLegend::ReadOnlyItem ),
-        isDown( false ),
-        identifierSize( 8, 8 ),
-        spacing( Margin )
-    {
-    }
-
-    QwtLegend::LegendItemMode itemMode;
-    bool isDown;
-
-    QSize identifierSize;
-    QPixmap identifier;
-
-    int spacing;
-};
-
-/*!
-  \param parent Parent widget
-*/
-QwtLegendItem::QwtLegendItem( QWidget *parent ):
-    QwtTextLabel( parent )
-{
-    d_data = new PrivateData;
-    setMargin( Margin );
-    setIndent( Margin + d_data->identifierSize.width() + 2 * d_data->spacing );
-}
-
-//! Destructor
-QwtLegendItem::~QwtLegendItem()
-{
-    delete d_data;
-    d_data = NULL;
-}
-
-/*!
-   Set the text to the legend item
-
-   \param text Text label
-    \sa QwtTextLabel::text()
-*/
-void QwtLegendItem::setText( const QwtText &text )
-{
-    const int flags = Qt::AlignLeft | Qt::AlignVCenter
-        | Qt::TextExpandTabs | Qt::TextWordWrap;
-
-    QwtText txt = text;
-    txt.setRenderFlags( flags );
-
-    QwtTextLabel::setText( txt );
-}
-
-/*!
-   Set the item mode
-   The default is QwtLegend::ReadOnlyItem
-
-   \param mode Item mode
-   \sa itemMode()
-*/
-void QwtLegendItem::setItemMode( QwtLegend::LegendItemMode mode )
-{
-    if ( mode != d_data->itemMode )
-    {
-        d_data->itemMode = mode;
-        d_data->isDown = false;
-
-        setFocusPolicy( mode != QwtLegend::ReadOnlyItem ? Qt::TabFocus : Qt::NoFocus );
-        setMargin( ButtonFrame + Margin );
-
-        updateGeometry();
-    }
-}
-
-/*!
-   Return the item mode
-
-   \sa setItemMode()
-*/
-QwtLegend::LegendItemMode QwtLegendItem::itemMode() const
-{
-    return d_data->itemMode;
-}
-
-/*!
-  Assign the identifier
-  The identifier needs to be created according to the identifierWidth()
-
-  \param identifier Pixmap representing a plot item
-
-  \sa identifier(), identifierWidth()
-*/
-void QwtLegendItem::setIdentifier( const QPixmap &identifier )
-{
-    d_data->identifier = identifier;
-    update();
-}
-
-/*!
-  \return pixmap representing a plot item
-  \sa setIdentifier()
-*/
-QPixmap QwtLegendItem::identifier() const
-{
-    return d_data->identifier;
-}
-
-/*!
-  Set the size for the identifier
-  Default is 8x8 pixels
-
-  \param size New size
-
-  \sa identifierSize()
-*/
-void QwtLegendItem::setIdentifierSize( const QSize &size )
-{
-    QSize sz = size.expandedTo( QSize( 0, 0 ) );
-    if ( sz != d_data->identifierSize )
-    {
-        d_data->identifierSize = sz;
-        setIndent( margin() + d_data->identifierSize.width()
-            + 2 * d_data->spacing );
-        updateGeometry();
-    }
-}
-/*!
-   Return the width of the identifier
-
-   \sa setIdentifierSize()
-*/
-QSize QwtLegendItem::identifierSize() const
-{
-    return d_data->identifierSize;
-}
-
-/*!
-   Change the spacing
-   \param spacing Spacing
-   \sa spacing(), identifierWidth(), QwtTextLabel::margin()
-*/
-void QwtLegendItem::setSpacing( int spacing )
-{
-    spacing = qMax( spacing, 0 );
-    if ( spacing != d_data->spacing )
-    {
-        d_data->spacing = spacing;
-        setIndent( margin() + d_data->identifierSize.width()
-            + 2 * d_data->spacing );
-    }
-}
-
-/*!
-   Return the spacing
-   \sa setSpacing(), identifierWidth(), QwtTextLabel::margin()
-*/
-int QwtLegendItem::spacing() const
-{
-    return d_data->spacing;
-}
-
-/*!
-    Check/Uncheck a the item
-
-    \param on check/uncheck
-    \sa setItemMode()
-*/
-void QwtLegendItem::setChecked( bool on )
-{
-    if ( d_data->itemMode == QwtLegend::CheckableItem )
-    {
-        const bool isBlocked = signalsBlocked();
-        blockSignals( true );
-
-        setDown( on );
-
-        blockSignals( isBlocked );
-    }
-}
-
-//! Return true, if the item is checked
-bool QwtLegendItem::isChecked() const
-{
-    return d_data->itemMode == QwtLegend::CheckableItem && isDown();
-}
-
-//! Set the item being down
-void QwtLegendItem::setDown( bool down )
-{
-    if ( down == d_data->isDown )
-        return;
-
-    d_data->isDown = down;
-    update();
-
-    if ( d_data->itemMode == QwtLegend::ClickableItem )
-    {
-        if ( d_data->isDown )
-            Q_EMIT pressed();
-        else
-        {
-            Q_EMIT released();
-            Q_EMIT clicked();
-        }
-    }
-
-    if ( d_data->itemMode == QwtLegend::CheckableItem )
-        Q_EMIT checked( d_data->isDown );
-}
-
-//! Return true, if the item is down
-bool QwtLegendItem::isDown() const
-{
-    return d_data->isDown;
-}
-
-//! Return a size hint
-QSize QwtLegendItem::sizeHint() const
-{
-    QSize sz = QwtTextLabel::sizeHint();
-    sz.setHeight( qMax( sz.height(), d_data->identifier.height() + 4 ) );
-
-    if ( d_data->itemMode != QwtLegend::ReadOnlyItem )
-    {
-        sz += buttonShift( this );
-        sz = sz.expandedTo( QApplication::globalStrut() );
-    }
-
-    return sz;
-}
-
-//! Paint event
-void QwtLegendItem::paintEvent( QPaintEvent *e )
-{
-    const QRect cr = contentsRect();
-
-    QPainter painter( this );
-    painter.setClipRegion( e->region() );
-
-    if ( d_data->isDown )
-    {
-        qDrawWinButton( &painter, 0, 0, width(), height(),
-            palette(), true );
-    }
-
-    painter.save();
-
-    if ( d_data->isDown )
-    {
-        const QSize shiftSize = buttonShift( this );
-        painter.translate( shiftSize.width(), shiftSize.height() );
-    }
-
-    painter.setClipRect( cr );
-
-    drawContents( &painter );
-
-    if ( !d_data->identifier.isNull() )
-    {
-        QRect identRect = cr;
-        identRect.setX( identRect.x() + margin() );
-        if ( d_data->itemMode != QwtLegend::ReadOnlyItem )
-            identRect.setX( identRect.x() + ButtonFrame );
-
-        identRect.setSize( d_data->identifier.size() );
-        identRect.moveCenter( QPoint( identRect.center().x(), cr.center().y() ) );
-
-        painter.drawPixmap( identRect, d_data->identifier );
-    }
-
-    painter.restore();
-}
-
-//! Handle mouse press events
-void QwtLegendItem::mousePressEvent( QMouseEvent *e )
-{
-    if ( e->button() == Qt::LeftButton )
-    {
-        switch ( d_data->itemMode )
-        {
-            case QwtLegend::ClickableItem:
-            {
-                setDown( true );
-                return;
-            }
-            case QwtLegend::CheckableItem:
-            {
-                setDown( !isDown() );
-                return;
-            }
-            default:;
-        }
-    }
-    QwtTextLabel::mousePressEvent( e );
-}
-
-//! Handle mouse release events
-void QwtLegendItem::mouseReleaseEvent( QMouseEvent *e )
-{
-    if ( e->button() == Qt::LeftButton )
-    {
-        switch ( d_data->itemMode )
-        {
-            case QwtLegend::ClickableItem:
-            {
-                setDown( false );
-                return;
-            }
-            case QwtLegend::CheckableItem:
-            {
-                return; // do nothing, but accept
-            }
-            default:;
-        }
-    }
-    QwtTextLabel::mouseReleaseEvent( e );
-}
-
-//! Handle key press events
-void QwtLegendItem::keyPressEvent( QKeyEvent *e )
-{
-    if ( e->key() == Qt::Key_Space )
-    {
-        switch ( d_data->itemMode )
-        {
-            case QwtLegend::ClickableItem:
-            {
-                if ( !e->isAutoRepeat() )
-                    setDown( true );
-                return;
-            }
-            case QwtLegend::CheckableItem:
-            {
-                if ( !e->isAutoRepeat() )
-                    setDown( !isDown() );
-                return;
-            }
-            default:;
-        }
-    }
-
-    QwtTextLabel::keyPressEvent( e );
-}
-
-//! Handle key release events
-void QwtLegendItem::keyReleaseEvent( QKeyEvent *e )
-{
-    if ( e->key() == Qt::Key_Space )
-    {
-        switch ( d_data->itemMode )
-        {
-            case QwtLegend::ClickableItem:
-            {
-                if ( !e->isAutoRepeat() )
-                    setDown( false );
-                return;
-            }
-            case QwtLegend::CheckableItem:
-            {
-                return; // do nothing, but accept
-            }
-            default:;
-        }
-    }
-
-    QwtTextLabel::keyReleaseEvent( e );
-}
Index: trunk/BNC/qwt/qwt_legend_item.h
===================================================================
--- trunk/BNC/qwt/qwt_legend_item.h	(revision 8125)
+++ 	(revision )
@@ -1,78 +1,0 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
- * Qwt Widget Library
- * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2002   Uwe Rathmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Qwt License, Version 1.0
- *****************************************************************************/
-
-#ifndef QWT_LEGEND_ITEM_H
-#define QWT_LEGEND_ITEM_H
-
-#include "qwt_global.h"
-#include "qwt_legend.h"
-#include "qwt_text.h"
-#include "qwt_text_label.h"
-#include <qpixmap.h>
-
-/*!
-  \brief A widget representing something on a QwtLegend().
-*/
-class QWT_EXPORT QwtLegendItem: public QwtTextLabel
-{
-    Q_OBJECT
-public:
-    explicit QwtLegendItem( QWidget *parent = 0 );
-    virtual ~QwtLegendItem();
-
-    void setItemMode( QwtLegend::LegendItemMode );
-    QwtLegend::LegendItemMode itemMode() const;
-
-    void setSpacing( int spacing );
-    int spacing() const;
-
-    virtual void setText( const QwtText & );
-
-    void setIdentifier( const QPixmap & );
-    QPixmap identifier() const;
-
-    void setIdentifierSize( const QSize & );
-    QSize identifierSize() const;
-
-    virtual QSize sizeHint() const;
-
-    bool isChecked() const;
-
-public Q_SLOTS:
-    void setChecked( bool on );
-
-Q_SIGNALS:
-    //! Signal, when the legend item has been clicked
-    void clicked();
-
-    //! Signal, when the legend item has been pressed
-    void pressed();
-
-    //! Signal, when the legend item has been relased
-    void released();
-
-    //! Signal, when the legend item has been toggled
-    void checked( bool );
-
-protected:
-    void setDown( bool );
-    bool isDown() const;
-
-    virtual void paintEvent( QPaintEvent * );
-    virtual void mousePressEvent( QMouseEvent * );
-    virtual void mouseReleaseEvent( QMouseEvent * );
-    virtual void keyPressEvent( QKeyEvent * );
-    virtual void keyReleaseEvent( QKeyEvent * );
-
-private:
-    class PrivateData;
-    PrivateData *d_data;
-};
-
-#endif 
Index: trunk/BNC/qwt/qwt_legend_itemmanager.h
===================================================================
--- trunk/BNC/qwt/qwt_legend_itemmanager.h	(revision 8125)
+++ 	(revision )
@@ -1,66 +1,0 @@
-/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
- * Qwt Widget Library
- * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2002   Uwe Rathmann
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the Qwt License, Version 1.0
- *****************************************************************************/
-
-#ifndef QWT_LEGEND_ITEM_MANAGER_H
-#define QWT_LEGEND_ITEM_MANAGER_H
-
-#include "qwt_global.h"
-
-class QwtLegend;
-class QWidget;
-class QRectF;
-class QPainter;
-
-/*!
-  \brief Abstract API to bind plot items to the legend
-*/
-
-class QWT_EXPORT QwtLegendItemManager
-{
-public:
-    //! Constructor
-    QwtLegendItemManager()
-    {
-    }
-
-    //! Destructor
-    virtual ~QwtLegendItemManager()
-    {
-    }
-
-    /*!
-      Update the widget that represents the item on the legend
-      \param legend Legend
-      \sa legendItem()
-     */
-    virtual void updateLegend( QwtLegend *legend ) const = 0;
-
-    /*!
-      Allocate the widget that represents the item on the legend
-      \return Allocated widget
-      \sa updateLegend() QwtLegend()
-     */
-
-    virtual QWidget *legendItem() const = 0;
-
-    /*!
-      QwtLegendItem can display an icon-identifier followed
-      by a text. The icon helps to identify a plot item on
-      the plot canvas and depends on the type of information,
-      that is displayed.
-
-      The default implementation paints nothing.
-     */
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const
-    {
-    }
-};
-
-#endif
-
Index: trunk/BNC/qwt/qwt_legend_label.cpp
===================================================================
--- trunk/BNC/qwt/qwt_legend_label.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_legend_label.cpp	(revision 8127)
@@ -0,0 +1,421 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_legend_label.h"
+#include "qwt_legend_data.h"
+#include "qwt_math.h"
+#include "qwt_painter.h"
+#include "qwt_symbol.h"
+#include "qwt_graphic.h"
+#include <qpainter.h>
+#include <qdrawutil.h>
+#include <qstyle.h>
+#include <qpen.h>
+#include <qevent.h>
+#include <qstyleoption.h>
+#include <qapplication.h>
+
+static const int ButtonFrame = 2;
+static const int Margin = 2;
+
+static QSize buttonShift( const QwtLegendLabel *w )
+{
+    QStyleOption option;
+    option.init( w );
+
+    const int ph = w->style()->pixelMetric(
+        QStyle::PM_ButtonShiftHorizontal, &option, w );
+    const int pv = w->style()->pixelMetric(
+        QStyle::PM_ButtonShiftVertical, &option, w );
+    return QSize( ph, pv );
+}
+
+class QwtLegendLabel::PrivateData
+{
+public:
+    PrivateData():
+        itemMode( QwtLegendData::ReadOnly ),
+        isDown( false ),
+        spacing( Margin )
+    {
+    }
+
+    QwtLegendData::Mode itemMode;
+    QwtLegendData legendData;
+    bool isDown;
+
+    QPixmap icon;
+
+    int spacing;
+};
+
+/*!
+  Set the attributes of the legend label
+
+  \param legendData Attributes of the label
+  \sa data()
+ */
+void QwtLegendLabel::setData( const QwtLegendData &legendData )
+{
+    d_data->legendData = legendData;
+
+    const bool doUpdate = updatesEnabled();
+    setUpdatesEnabled( false );
+
+    setText( legendData.title() );
+    setIcon( legendData.icon().toPixmap() );
+
+    if ( legendData.hasRole( QwtLegendData::ModeRole ) )
+        setItemMode( legendData.mode() );
+
+    if ( doUpdate )
+    {
+        setUpdatesEnabled( true );
+        update();
+    }
+}
+
+/*!
+  \return Attributes of the label
+  \sa setData(), QwtPlotItem::legendData()
+ */
+const QwtLegendData &QwtLegendLabel::data() const
+{
+    return d_data->legendData;
+}
+
+/*!
+  \param parent Parent widget
+*/
+QwtLegendLabel::QwtLegendLabel( QWidget *parent ):
+    QwtTextLabel( parent )
+{
+    d_data = new PrivateData;
+    setMargin( Margin );
+    setIndent( Margin );
+}
+
+//! Destructor
+QwtLegendLabel::~QwtLegendLabel()
+{
+    delete d_data;
+    d_data = NULL;
+}
+
+/*!
+   Set the text to the legend item
+
+   \param text Text label
+    \sa QwtTextLabel::text()
+*/
+void QwtLegendLabel::setText( const QwtText &text )
+{
+    const int flags = Qt::AlignLeft | Qt::AlignVCenter
+        | Qt::TextExpandTabs | Qt::TextWordWrap;
+
+    QwtText txt = text;
+    txt.setRenderFlags( flags );
+
+    QwtTextLabel::setText( txt );
+}
+
+/*!
+   Set the item mode
+   The default is QwtLegendData::ReadOnly
+
+   \param mode Item mode
+   \sa itemMode()
+*/
+void QwtLegendLabel::setItemMode( QwtLegendData::Mode mode )
+{
+    if ( mode != d_data->itemMode )
+    {
+        d_data->itemMode = mode;
+        d_data->isDown = false;
+
+        setFocusPolicy( ( mode != QwtLegendData::ReadOnly ) 
+            ? Qt::TabFocus : Qt::NoFocus );
+        setMargin( ButtonFrame + Margin );
+
+        updateGeometry();
+    }
+}
+
+/*!
+   \return Item mode
+   \sa setItemMode()
+*/
+QwtLegendData::Mode QwtLegendLabel::itemMode() const
+{
+    return d_data->itemMode;
+}
+
+/*!
+  Assign the icon
+
+  \param icon Pixmap representing a plot item
+
+  \sa icon(), QwtPlotItem::legendIcon()
+*/
+void QwtLegendLabel::setIcon( const QPixmap &icon )
+{
+    d_data->icon = icon;
+
+    int indent = margin() + d_data->spacing;
+    if ( icon.width() > 0 )
+        indent += icon.width() + d_data->spacing;
+
+    setIndent( indent );
+}
+
+/*!
+  \return Pixmap representing a plot item
+  \sa setIcon()
+*/
+QPixmap QwtLegendLabel::icon() const
+{
+    return d_data->icon;
+}
+
+/*!
+   \brief Change the spacing between icon and text
+
+   \param spacing Spacing
+   \sa spacing(), QwtTextLabel::margin()
+*/
+void QwtLegendLabel::setSpacing( int spacing )
+{
+    spacing = qMax( spacing, 0 );
+    if ( spacing != d_data->spacing )
+    {
+        d_data->spacing = spacing;
+
+        int indent = margin() + d_data->spacing;
+        if ( d_data->icon.width() > 0 )
+            indent += d_data->icon.width() + d_data->spacing;
+
+        setIndent( indent );
+    }
+}
+
+/*!
+   \return Spacing between icon and text
+   \sa setSpacing(), QwtTextLabel::margin()
+*/
+int QwtLegendLabel::spacing() const
+{
+    return d_data->spacing;
+}
+
+/*!
+    Check/Uncheck a the item
+
+    \param on check/uncheck
+    \sa setItemMode()
+*/
+void QwtLegendLabel::setChecked( bool on )
+{
+    if ( d_data->itemMode == QwtLegendData::Checkable )
+    {
+        const bool isBlocked = signalsBlocked();
+        blockSignals( true );
+
+        setDown( on );
+
+        blockSignals( isBlocked );
+    }
+}
+
+//! Return true, if the item is checked
+bool QwtLegendLabel::isChecked() const
+{
+    return d_data->itemMode == QwtLegendData::Checkable && isDown();
+}
+
+//! Set the item being down
+void QwtLegendLabel::setDown( bool down )
+{
+    if ( down == d_data->isDown )
+        return;
+
+    d_data->isDown = down;
+    update();
+
+    if ( d_data->itemMode == QwtLegendData::Clickable )
+    {
+        if ( d_data->isDown )
+            Q_EMIT pressed();
+        else
+        {
+            Q_EMIT released();
+            Q_EMIT clicked();
+        }
+    }
+
+    if ( d_data->itemMode == QwtLegendData::Checkable )
+        Q_EMIT checked( d_data->isDown );
+}
+
+//! Return true, if the item is down
+bool QwtLegendLabel::isDown() const
+{
+    return d_data->isDown;
+}
+
+//! Return a size hint
+QSize QwtLegendLabel::sizeHint() const
+{
+    QSize sz = QwtTextLabel::sizeHint();
+    sz.setHeight( qMax( sz.height(), d_data->icon.height() + 4 ) );
+
+    if ( d_data->itemMode != QwtLegendData::ReadOnly )
+    {
+        sz += buttonShift( this );
+        sz = sz.expandedTo( QApplication::globalStrut() );
+    }
+
+    return sz;
+}
+
+//! Paint event
+void QwtLegendLabel::paintEvent( QPaintEvent *e )
+{
+    const QRect cr = contentsRect();
+
+    QPainter painter( this );
+    painter.setClipRegion( e->region() );
+
+    if ( d_data->isDown )
+    {
+        qDrawWinButton( &painter, 0, 0, width(), height(),
+            palette(), true );
+    }
+
+    painter.save();
+
+    if ( d_data->isDown )
+    {
+        const QSize shiftSize = buttonShift( this );
+        painter.translate( shiftSize.width(), shiftSize.height() );
+    }
+
+    painter.setClipRect( cr );
+
+    drawContents( &painter );
+
+    if ( !d_data->icon.isNull() )
+    {
+        QRect iconRect = cr;
+        iconRect.setX( iconRect.x() + margin() );
+        if ( d_data->itemMode != QwtLegendData::ReadOnly )
+            iconRect.setX( iconRect.x() + ButtonFrame );
+
+        iconRect.setSize( d_data->icon.size() );
+        iconRect.moveCenter( QPoint( iconRect.center().x(), cr.center().y() ) );
+
+        painter.drawPixmap( iconRect, d_data->icon );
+    }
+
+    painter.restore();
+}
+
+//! Handle mouse press events
+void QwtLegendLabel::mousePressEvent( QMouseEvent *e )
+{
+    if ( e->button() == Qt::LeftButton )
+    {
+        switch ( d_data->itemMode )
+        {
+            case QwtLegendData::Clickable:
+            {
+                setDown( true );
+                return;
+            }
+            case QwtLegendData::Checkable:
+            {
+                setDown( !isDown() );
+                return;
+            }
+            default:;
+        }
+    }
+    QwtTextLabel::mousePressEvent( e );
+}
+
+//! Handle mouse release events
+void QwtLegendLabel::mouseReleaseEvent( QMouseEvent *e )
+{
+    if ( e->button() == Qt::LeftButton )
+    {
+        switch ( d_data->itemMode )
+        {
+            case QwtLegendData::Clickable:
+            {
+                setDown( false );
+                return;
+            }
+            case QwtLegendData::Checkable:
+            {
+                return; // do nothing, but accept
+            }
+            default:;
+        }
+    }
+    QwtTextLabel::mouseReleaseEvent( e );
+}
+
+//! Handle key press events
+void QwtLegendLabel::keyPressEvent( QKeyEvent *e )
+{
+    if ( e->key() == Qt::Key_Space )
+    {
+        switch ( d_data->itemMode )
+        {
+            case QwtLegendData::Clickable:
+            {
+                if ( !e->isAutoRepeat() )
+                    setDown( true );
+                return;
+            }
+            case QwtLegendData::Checkable:
+            {
+                if ( !e->isAutoRepeat() )
+                    setDown( !isDown() );
+                return;
+            }
+            default:;
+        }
+    }
+
+    QwtTextLabel::keyPressEvent( e );
+}
+
+//! Handle key release events
+void QwtLegendLabel::keyReleaseEvent( QKeyEvent *e )
+{
+    if ( e->key() == Qt::Key_Space )
+    {
+        switch ( d_data->itemMode )
+        {
+            case QwtLegendData::Clickable:
+            {
+                if ( !e->isAutoRepeat() )
+                    setDown( false );
+                return;
+            }
+            case QwtLegendData::Checkable:
+            {
+                return; // do nothing, but accept
+            }
+            default:;
+        }
+    }
+
+    QwtTextLabel::keyReleaseEvent( e );
+}
Index: trunk/BNC/qwt/qwt_legend_label.h
===================================================================
--- trunk/BNC/qwt/qwt_legend_label.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_legend_label.h	(revision 8127)
@@ -0,0 +1,80 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_LEGEND_LABEL_H
+#define QWT_LEGEND_LABEL_H
+
+#include "qwt_global.h"
+#include "qwt_legend_data.h"
+#include "qwt_text.h"
+#include "qwt_text_label.h"
+#include <qpixmap.h>
+
+class QwtLegendData;
+
+/*!
+  \brief A widget representing something on a QwtLegend.
+*/
+class QWT_EXPORT QwtLegendLabel: public QwtTextLabel
+{
+    Q_OBJECT
+public:
+    explicit QwtLegendLabel( QWidget *parent = 0 );
+    virtual ~QwtLegendLabel();
+
+    void setData( const QwtLegendData & );
+    const QwtLegendData &data() const;
+
+    void setItemMode( QwtLegendData::Mode );
+    QwtLegendData::Mode itemMode() const;
+
+    void setSpacing( int spacing );
+    int spacing() const;
+
+    virtual void setText( const QwtText & );
+
+    void setIcon( const QPixmap & );
+    QPixmap icon() const;
+
+    virtual QSize sizeHint() const;
+
+    bool isChecked() const;
+
+public Q_SLOTS:
+    void setChecked( bool on );
+
+Q_SIGNALS:
+    //! Signal, when the legend item has been clicked
+    void clicked();
+
+    //! Signal, when the legend item has been pressed
+    void pressed();
+
+    //! Signal, when the legend item has been released
+    void released();
+
+    //! Signal, when the legend item has been toggled
+    void checked( bool );
+
+protected:
+    void setDown( bool );
+    bool isDown() const;
+
+    virtual void paintEvent( QPaintEvent * );
+    virtual void mousePressEvent( QMouseEvent * );
+    virtual void mouseReleaseEvent( QMouseEvent * );
+    virtual void keyPressEvent( QKeyEvent * );
+    virtual void keyReleaseEvent( QKeyEvent * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif 
Index: trunk/BNC/qwt/qwt_magnifier.cpp
===================================================================
--- trunk/BNC/qwt/qwt_magnifier.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_magnifier.cpp	(revision 8127)
@@ -19,12 +19,12 @@
         isEnabled( false ),
         wheelFactor( 0.9 ),
-        wheelButtonState( Qt::NoButton ),
+        wheelModifiers( Qt::NoModifier ),
         mouseFactor( 0.95 ),
         mouseButton( Qt::RightButton ),
-        mouseButtonState( Qt::NoButton ),
+        mouseButtonModifiers( Qt::NoModifier ),
         keyFactor( 0.9 ),
         zoomInKey( Qt::Key_Plus ),
+        zoomInKeyModifiers( Qt::NoModifier ),
         zoomOutKey( Qt::Key_Minus ),
-        zoomInKeyModifiers( Qt::NoModifier ),
         zoomOutKeyModifiers( Qt::NoModifier ),
         mousePressed( false )
@@ -35,15 +35,18 @@
 
     double wheelFactor;
-    int wheelButtonState;
+    Qt::KeyboardModifiers wheelModifiers;
 
     double mouseFactor;
-    int mouseButton;
-    int mouseButtonState;
+
+    Qt::MouseButton mouseButton;
+    Qt::KeyboardModifiers mouseButtonModifiers;
 
     double keyFactor;
+
     int zoomInKey;
+    Qt::KeyboardModifiers zoomInKeyModifiers;
+
     int zoomOutKey;
-    int zoomInKeyModifiers;
-    int zoomOutKeyModifiers;
+    Qt::KeyboardModifiers  zoomOutKeyModifiers;
 
     bool mousePressed;
@@ -109,4 +112,9 @@
    The wheel factor defines the ratio between the current range
    on the parent widget and the zoomed range for each step of the wheel.
+
+   Use values > 1 for magnification (i.e. 2.0) and values < 1 for
+   scaling down (i.e. 1/2.0 = 0.5). You can use this feature for
+   inverting the direction of the wheel.
+
    The default value is 0.9.
 
@@ -130,22 +138,22 @@
 
 /*!
-   Assign a mandatory button state for zooming in/out using the wheel.
-   The default button state is Qt::NoButton.
-
-   \param buttonState Button state
-   \sa wheelButtonState()
-*/
-void QwtMagnifier::setWheelButtonState( int buttonState )
-{
-    d_data->wheelButtonState = buttonState;
-}
-
-/*!
-   \return Wheel button state
-   \sa setWheelButtonState()
-*/
-int QwtMagnifier::wheelButtonState() const
-{
-    return d_data->wheelButtonState;
+   Assign keyboard modifiers for zooming in/out using the wheel.
+   The default modifiers are Qt::NoModifiers.
+
+   \param modifiers Keyboard modifiers
+   \sa wheelModifiers()
+*/
+void QwtMagnifier::setWheelModifiers( Qt::KeyboardModifiers modifiers )
+{
+    d_data->wheelModifiers = modifiers;
+}
+
+/*!
+   \return Wheel modifiers
+   \sa setWheelModifiers()
+*/
+Qt::KeyboardModifiers QwtMagnifier::wheelModifiers() const
+{
+    return d_data->wheelModifiers;
 }
 
@@ -179,19 +187,21 @@
 
    \param button Button
-   \param buttonState Button state
+   \param modifiers Keyboard modifiers
+
    \sa getMouseButton()
 */
-void QwtMagnifier::setMouseButton( int button, int buttonState )
+void QwtMagnifier::setMouseButton( 
+    Qt::MouseButton button, Qt::KeyboardModifiers modifiers )
 {
     d_data->mouseButton = button;
-    d_data->mouseButtonState = buttonState;
+    d_data->mouseButtonModifiers = modifiers;
 }
 
 //! \sa setMouseButton()
 void QwtMagnifier::getMouseButton(
-    int &button, int &buttonState ) const
+    Qt::MouseButton &button, Qt::KeyboardModifiers &modifiers ) const
 {
     button = d_data->mouseButton;
-    buttonState = d_data->mouseButtonState;
+    modifiers = d_data->mouseButtonModifiers;
 }
 
@@ -229,5 +239,6 @@
    \sa getZoomInKey(), setZoomOutKey()
 */
-void QwtMagnifier::setZoomInKey( int key, int modifiers )
+void QwtMagnifier::setZoomInKey( int key, 
+    Qt::KeyboardModifiers modifiers )
 {
     d_data->zoomInKey = key;
@@ -235,6 +246,14 @@
 }
 
-//! \sa setZoomInKey()
-void QwtMagnifier::getZoomInKey( int &key, int &modifiers ) const
+/*! 
+   \brief Retrieve the settings of the zoom in key
+
+   \param key Key code, see Qt::Key
+   \param modifiers Keyboard modifiers
+
+   \sa setZoomInKey()
+*/
+void QwtMagnifier::getZoomInKey( int &key, 
+    Qt::KeyboardModifiers &modifiers ) const
 {
     key = d_data->zoomInKey;
@@ -250,5 +269,6 @@
    \sa getZoomOutKey(), setZoomOutKey()
 */
-void QwtMagnifier::setZoomOutKey( int key, int modifiers )
+void QwtMagnifier::setZoomOutKey( int key, 
+    Qt::KeyboardModifiers modifiers )
 {
     d_data->zoomOutKey = key;
@@ -256,6 +276,14 @@
 }
 
-//! \sa setZoomOutKey()
-void QwtMagnifier::getZoomOutKey( int &key, int &modifiers ) const
+/*! 
+   \brief Retrieve the settings of the zoom out key
+
+   \param key Key code, see Qt::Key
+   \param modifiers Keyboard modifiers
+
+   \sa setZoomOutKey()
+*/
+void QwtMagnifier::getZoomOutKey( int &key, 
+    Qt::KeyboardModifiers &modifiers ) const
 {
     key = d_data->zoomOutKey;
@@ -266,8 +294,11 @@
   \brief Event filter
 
-  When isEnabled() the mouse events of the observed widget are filtered.
+  When isEnabled() is true, the mouse events of the
+  observed widget are filtered.
 
   \param object Object to be filtered
   \param event Event
+
+  \return Forwarded to QObject::eventFilter()
 
   \sa widgetMousePressEvent(), widgetMouseReleaseEvent(),
@@ -283,30 +314,30 @@
             case QEvent::MouseButtonPress:
             {
-                widgetMousePressEvent( ( QMouseEvent * )event );
+                widgetMousePressEvent( static_cast<QMouseEvent *>( event ) );
                 break;
             }
             case QEvent::MouseMove:
             {
-                widgetMouseMoveEvent( ( QMouseEvent * )event );
+                widgetMouseMoveEvent( static_cast<QMouseEvent *>( event ) );
                 break;
             }
             case QEvent::MouseButtonRelease:
             {
-                widgetMouseReleaseEvent( ( QMouseEvent * )event );
+                widgetMouseReleaseEvent( static_cast<QMouseEvent *>( event ) );
                 break;
             }
             case QEvent::Wheel:
             {
-                widgetWheelEvent( ( QWheelEvent * )event );
+                widgetWheelEvent( static_cast<QWheelEvent *>( event ) );
                 break;
             }
             case QEvent::KeyPress:
             {
-                widgetKeyPressEvent( ( QKeyEvent * )event );
+                widgetKeyPressEvent( static_cast<QKeyEvent *>( event ) );
                 break;
             }
             case QEvent::KeyRelease:
             {
-                widgetKeyReleaseEvent( ( QKeyEvent * )event );
+                widgetKeyReleaseEvent( static_cast<QKeyEvent *>( event ) );
                 break;
             }
@@ -325,12 +356,9 @@
 void QwtMagnifier::widgetMousePressEvent( QMouseEvent *mouseEvent )
 {
-    if ( ( mouseEvent->button() != d_data->mouseButton) 
-        || parentWidget() == NULL )
-    {
+    if ( parentWidget() == NULL )
         return;
-    }
-
-    if ( ( mouseEvent->modifiers() & Qt::KeyboardModifierMask ) !=
-        ( int )( d_data->mouseButtonState & Qt::KeyboardModifierMask ) )
+
+    if ( ( mouseEvent->button() != d_data->mouseButton ) ||
+        ( mouseEvent->modifiers() != d_data->mouseButtonModifiers ) )
     {
         return;
@@ -338,4 +366,5 @@
 
     d_data->hasMouseTracking = parentWidget()->hasMouseTracking();
+
     parentWidget()->setMouseTracking( true );
     d_data->mousePos = mouseEvent->pos();
@@ -393,6 +422,5 @@
 void QwtMagnifier::widgetWheelEvent( QWheelEvent *wheelEvent )
 {
-    if ( ( wheelEvent->modifiers() & Qt::KeyboardModifierMask ) !=
-        ( int )( d_data->wheelButtonState & Qt::KeyboardModifierMask ) )
+    if ( wheelEvent->modifiers() != d_data->wheelModifiers )
     {
         return;
@@ -411,5 +439,5 @@
          */
         double f = qPow( d_data->wheelFactor, 
-            qAbs( wheelEvent->delta() / 120 ) );
+            qAbs( wheelEvent->delta() / 120.0 ) );
 
         if ( wheelEvent->delta() > 0 )
@@ -428,14 +456,11 @@
 void QwtMagnifier::widgetKeyPressEvent( QKeyEvent *keyEvent )
 {
-    const int key = keyEvent->key();
-    const int state = keyEvent->modifiers();
-
-    if ( key == d_data->zoomInKey &&
-        state == d_data->zoomInKeyModifiers )
+    if ( keyEvent->key() == d_data->zoomInKey &&
+        keyEvent->modifiers() == d_data->zoomInKeyModifiers )
     {
         rescale( d_data->keyFactor );
     }
-    else if ( key == d_data->zoomOutKey &&
-        state == d_data->zoomOutKeyModifiers )
+    else if ( keyEvent->key() == d_data->zoomOutKey &&
+        keyEvent->modifiers() == d_data->zoomOutKeyModifiers )
     {
         rescale( 1.0 / d_data->keyFactor );
@@ -457,8 +482,5 @@
 QWidget *QwtMagnifier::parentWidget()
 {
-    if ( parent()->inherits( "QWidget" ) )
-        return ( QWidget * )parent();
-
-    return NULL;
+    return qobject_cast<QWidget *>( parent() );
 }
 
@@ -466,8 +488,5 @@
 const QWidget *QwtMagnifier::parentWidget() const
 {
-    if ( parent()->inherits( "QWidget" ) )
-        return ( const QWidget * )parent();
-
-    return NULL;
-}
-
+    return qobject_cast<const QWidget *>( parent() );
+}
+
Index: trunk/BNC/qwt/qwt_magnifier.h
===================================================================
--- trunk/BNC/qwt/qwt_magnifier.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_magnifier.h	(revision 8127)
@@ -43,6 +43,6 @@
     double mouseFactor() const;
 
-    void setMouseButton( int button, int buttonState = Qt::NoButton );
-    void getMouseButton( int &button, int &buttonState ) const;
+    void setMouseButton( Qt::MouseButton, Qt::KeyboardModifiers = Qt::NoModifier );
+    void getMouseButton( Qt::MouseButton &, Qt::KeyboardModifiers & ) const;
 
     // mouse wheel
@@ -50,6 +50,6 @@
     double wheelFactor() const;
 
-    void setWheelButtonState( int buttonState );
-    int wheelButtonState() const;
+    void setWheelModifiers( Qt::KeyboardModifiers );
+    Qt::KeyboardModifiers wheelModifiers() const;
 
     // keyboard
@@ -57,9 +57,9 @@
     double keyFactor() const;
 
-    void setZoomInKey( int key, int modifiers );
-    void getZoomInKey( int &key, int &modifiers ) const;
+    void setZoomInKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
+    void getZoomInKey( int &key, Qt::KeyboardModifiers & ) const;
 
-    void setZoomOutKey( int key, int modifiers );
-    void getZoomOutKey( int &key, int &modifiers ) const;
+    void setZoomOutKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
+    void getZoomOutKey( int &key, Qt::KeyboardModifiers & ) const;
 
     virtual bool eventFilter( QObject *, QEvent * );
Index: trunk/BNC/qwt/qwt_math.cpp
===================================================================
--- trunk/BNC/qwt/qwt_math.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_math.cpp	(revision 8127)
@@ -44,2 +44,31 @@
     return rv;
 }
+
+/*!
+  \brief Normalize an angle to be int the range [0.0, 2 * PI[
+  \param radians Angle in radians
+  \return Normalized angle in radians
+*/
+double qwtNormalizeRadians( double radians )
+{
+    double a = ::fmod( radians, 2.0 * M_PI );
+    if ( a < 0.0 )
+        a += 2.0 * M_PI;
+
+    return a;
+
+}
+
+/*!
+  \brief Normalize an angle to be int the range [0.0, 360.0[
+  \param radians Angle in degrees
+  \return Normalized angle in degrees
+*/
+double qwtNormalizeDegrees( double degrees )
+{
+    double a = ::fmod( degrees, 360.0 );
+    if ( a < 0.0 )
+        a += 360.0;
+
+    return a;
+}
Index: trunk/BNC/qwt/qwt_math.h
===================================================================
--- trunk/BNC/qwt/qwt_math.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_math.h	(revision 8127)
@@ -24,26 +24,15 @@
 #endif
 
-#include <qpoint.h>
 #include <qmath.h>
 #include "qwt_global.h"
 
-#ifndef LOG10_2
-#define LOG10_2     0.30102999566398119802  /* log10(2) */
-#endif
-
-#ifndef LOG10_3
-#define LOG10_3     0.47712125471966243540  /* log10(3) */
-#endif
-
-#ifndef LOG10_5
-#define LOG10_5     0.69897000433601885749  /* log10(5) */
-#endif
-
-#ifndef M_2PI
-#define M_2PI       6.28318530717958623200  /* 2 pi */
+#ifndef M_PI_2
+// For Qt <= 4.8.4 M_PI_2 is not known by MinGW-w64 
+// when compiling with -std=c++11
+#define M_PI_2 (1.57079632679489661923)
 #endif
 
 #ifndef LOG_MIN
-//! Mininum value for logarithmic scales
+//! Minimum value for logarithmic scales
 #define LOG_MIN 1.0e-100
 #endif
@@ -54,58 +43,9 @@
 #endif
 
-#ifndef M_E
-#define M_E            2.7182818284590452354   /* e */
-#endif
-
-#ifndef M_LOG2E
-#define M_LOG2E 1.4426950408889634074   /* log_2 e */
-#endif
-
-#ifndef M_LOG10E
-#define M_LOG10E    0.43429448190325182765  /* log_10 e */
-#endif
-
-#ifndef M_LN2
-#define M_LN2       0.69314718055994530942  /* log_e 2 */
-#endif
-
-#ifndef M_LN10
-#define M_LN10         2.30258509299404568402  /* log_e 10 */
-#endif
-
-#ifndef M_PI
-#define M_PI        3.14159265358979323846  /* pi */
-#endif
-
-#ifndef M_PI_2
-#define M_PI_2      1.57079632679489661923  /* pi/2 */
-#endif
-
-#ifndef M_PI_4
-#define M_PI_4      0.78539816339744830962  /* pi/4 */
-#endif
-
-#ifndef M_1_PI
-#define M_1_PI      0.31830988618379067154  /* 1/pi */
-#endif
-
-#ifndef M_2_PI
-#define M_2_PI      0.63661977236758134308  /* 2/pi */
-#endif
-
-#ifndef M_2_SQRTPI
-#define M_2_SQRTPI  1.12837916709551257390  /* 2/sqrt(pi) */
-#endif
-
-#ifndef M_SQRT2
-#define M_SQRT2 1.41421356237309504880  /* sqrt(2) */
-#endif
-
-#ifndef M_SQRT1_2
-#define M_SQRT1_2   0.70710678118654752440  /* 1/sqrt(2) */
-#endif
-
 QWT_EXPORT double qwtGetMin( const double *array, int size );
 QWT_EXPORT double qwtGetMax( const double *array, int size );
+
+QWT_EXPORT double qwtNormalizeRadians( double radians );
+QWT_EXPORT double qwtNormalizeDegrees( double degrees );
 
 /*!
@@ -162,20 +102,47 @@
 }
 
-//! Like qRound, but without converting the result to an int
-inline double qwtRoundF(double d)
-{ 
-    return ::floor( d + 0.5 );
+//! Approximation of arc tangent ( error below 0,005 radians )
+inline double qwtFastAtan( double x )
+{
+    if ( x < -1.0 )
+        return -M_PI_2 - x / ( x * x + 0.28 );
+
+    if ( x > 1.0 )
+        return M_PI_2 - x / ( x * x + 0.28 );
+
+    return x / ( 1.0 + x * x * 0.28 );
 }
 
-//! Like qFloor, but without converting the result to an int
-inline double qwtFloorF(double d)
-{ 
-    return ::floor( d );
+//! Approximation of arc tangent ( error below 0,005 radians )
+inline double qwtFastAtan2( double y, double x )
+{
+    if ( x > 0 )
+        return qwtFastAtan( y / x );
+
+    if ( x < 0 )
+    {
+        const double d = qwtFastAtan( y / x );
+        return ( y >= 0 ) ? d + M_PI : d - M_PI;
+    }
+
+    if ( y < 0.0 )
+        return -M_PI_2;
+
+    if ( y > 0.0 )
+        return M_PI_2;
+
+    return 0.0;
 }
 
-//! Like qCeil, but without converting the result to an int
-inline double qwtCeilF(double d)
-{ 
-    return ::ceil( d );
+//! Translate degrees into radians
+inline double qwtRadians( double degrees )
+{
+    return degrees * M_PI / 180.0;
+}
+
+//! Translate radians into degrees
+inline double qwtDegrees( double degrees )
+{
+    return degrees * 180.0 / M_PI;
 }
 
Index: trunk/BNC/qwt/qwt_matrix_raster_data.cpp
===================================================================
--- trunk/BNC/qwt/qwt_matrix_raster_data.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_matrix_raster_data.cpp	(revision 8127)
@@ -21,5 +21,5 @@
     }
 
-    inline double value(size_t row, size_t col) const
+    inline double value(int row, int col) const
     {
         return values.data()[ row * numColumns + col ];
@@ -29,6 +29,6 @@
 
     QVector<double> values;
-    size_t numColumns;
-    size_t numRows;
+    int numColumns;
+    int numRows;
 
     double dx;
@@ -55,5 +55,5 @@
    \sa resampleMode(), value()
 */
-void QwtMatrixRasterData::setResampleMode(ResampleMode mode)
+void QwtMatrixRasterData::setResampleMode( ResampleMode mode )
 {
     d_data->resampleMode = mode;
@@ -106,8 +106,8 @@
 */
 void QwtMatrixRasterData::setValueMatrix( 
-    const QVector<double> &values, size_t numColumns )
+    const QVector<double> &values, int numColumns )
 {
     d_data->values = values;
-    d_data->numColumns = numColumns;
+    d_data->numColumns = qMax( numColumns, 0 );
     update();
 }
@@ -123,8 +123,27 @@
 
 /*!
+  \brief Change a single value in the matrix
+
+  \param row Row index
+  \param col Column index
+  \param value New value
+
+  \sa value(), setValueMatrix()
+*/
+void QwtMatrixRasterData::setValue( int row, int col, double value )
+{
+    if ( row >= 0 && row < d_data->numRows &&
+        col >= 0 && col < d_data->numColumns )
+    {
+        const int index = row * d_data->numColumns + col;
+        d_data->values.data()[ index ] = value;
+    }
+}
+
+/*!
    \return Number of columns of the value matrix
    \sa valueMatrix(), numRows(), setValueMatrix()
 */
-size_t QwtMatrixRasterData::numColumns() const
+int QwtMatrixRasterData::numColumns() const
 {
     return d_data->numColumns;
@@ -135,5 +154,5 @@
    \sa valueMatrix(), numColumns(), setValueMatrix()
 */
-size_t QwtMatrixRasterData::numRows() const
+int QwtMatrixRasterData::numRows() const
 {
     return d_data->numRows;
@@ -141,5 +160,9 @@
 
 /*!
-   \brief Pixel hint
+   \brief Calculate the pixel hint
+
+   pixelHint() returns the geometry of a pixel, that can be used 
+   to calculate the resolution and alignment of the plot item, that is
+   representing the data. 
 
    - NearestNeighbour\n
@@ -151,8 +174,13 @@
      to render in target device ( f.e. screen ) resolution. 
 
+   \param area Requested area, ignored
+   \return Calculated hint
+
    \sa ResampleMode, setMatrix(), setInterval()
 */
-QRectF QwtMatrixRasterData::pixelHint( const QRectF & ) const
-{
+QRectF QwtMatrixRasterData::pixelHint( const QRectF &area ) const
+{
+    Q_UNUSED( area )
+
     QRectF rect;
     if ( d_data->resampleMode == NearestNeighbour )
@@ -199,10 +227,10 @@
             if ( col1 < 0 )
                 col1 = col2;
-            else if ( col2 >= (int)d_data->numColumns )
+            else if ( col2 >= static_cast<int>( d_data->numColumns ) )
                 col2 = col1;
 
             if ( row1 < 0 )
                 row1 = row2;
-            else if ( row2 >= (int)d_data->numRows )
+            else if ( row2 >= static_cast<int>( d_data->numRows ) )
                 row2 = row1;
 
@@ -230,6 +258,6 @@
         default:
         {
-            uint row = uint( (y - yInterval.minValue() ) / d_data->dy );
-            uint col = uint( (x - xInterval.minValue() ) / d_data->dx );
+            int row = int( (y - yInterval.minValue() ) / d_data->dy );
+            int col = int( (x - xInterval.minValue() ) / d_data->dx );
 
             // In case of intervals, where the maximum is included
Index: trunk/BNC/qwt/qwt_matrix_raster_data.h
===================================================================
--- trunk/BNC/qwt/qwt_matrix_raster_data.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_matrix_raster_data.h	(revision 8127)
@@ -52,9 +52,12 @@
 
     virtual void setInterval( Qt::Axis, const QwtInterval & );
-    void setValueMatrix( const QVector<double> &values, size_t numColumns );
-    
+
+    void setValueMatrix( const QVector<double> &values, int numColumns );
     const QVector<double> valueMatrix() const;
-    size_t numColumns() const;
-    size_t numRows() const;
+
+    void setValue( int row, int col, double value );
+
+    int numColumns() const;
+    int numRows() const;
 
     virtual QRectF pixelHint( const QRectF & ) const;
Index: trunk/BNC/qwt/qwt_null_paintdevice.cpp
===================================================================
--- trunk/BNC/qwt/qwt_null_paintdevice.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_null_paintdevice.cpp	(revision 8127)
@@ -16,9 +16,9 @@
 public:
     PrivateData():
-        size( 0, 0 )
-    {
-    }
-
-    QSize size;
+        mode( QwtNullPaintDevice::NormalMode )
+    {
+    }
+
+    QwtNullPaintDevice::Mode mode;
 };
 
@@ -26,5 +26,5 @@
 {
 public:
-    PaintEngine( QPaintEngine::PaintEngineFeatures );
+    PaintEngine();
 
     virtual bool begin( QPaintDevice * );
@@ -55,24 +55,23 @@
 
     virtual void drawTextItem(const QPointF &, const QTextItem &);
+
     virtual void drawTiledPixmap(const QRectF &, 
         const QPixmap &, const QPointF &s);
+
     virtual void drawImage(const QRectF &, 
         const QImage &, const QRectF &, Qt::ImageConversionFlags );
 
 private:
-    QwtNullPaintDevice *d_device;
+    QwtNullPaintDevice *nullDevice();
 };
     
-QwtNullPaintDevice::PaintEngine::PaintEngine( 
-        QPaintEngine::PaintEngineFeatures features ):
-    QPaintEngine( features ),
-    d_device(NULL)
-{
-}
-
-bool QwtNullPaintDevice::PaintEngine::begin( 
-    QPaintDevice *device )
-{
-    d_device = static_cast<QwtNullPaintDevice *>( device );
+QwtNullPaintDevice::PaintEngine::PaintEngine():
+    QPaintEngine( QPaintEngine::AllFeatures )
+{
+}
+
+bool QwtNullPaintDevice::PaintEngine::begin( QPaintDevice * )
+{
+    setActive( true );
     return true;
 }
@@ -80,10 +79,9 @@
 bool QwtNullPaintDevice::PaintEngine::end()
 {
-    d_device = NULL;
+    setActive( false );
     return true;
 }
 
-QPaintEngine::Type 
-QwtNullPaintDevice::PaintEngine::type () const
+QPaintEngine::Type QwtNullPaintDevice::PaintEngine::type() const
 {
     return QPaintEngine::User;
@@ -93,6 +91,15 @@
     const QRect *rects, int rectCount)
 {
-    if ( d_device )
-        d_device->drawRects( rects, rectCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawRects( rects, rectCount );
+        return;
+    }
+
+    device->drawRects( rects, rectCount );
 }
 
@@ -100,6 +107,15 @@
     const QRectF *rects, int rectCount)
 {
-    if ( d_device )
-        d_device->drawRects( rects, rectCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawRects( rects, rectCount );
+        return;
+    }
+
+    device->drawRects( rects, rectCount );
 }
 
@@ -107,6 +123,15 @@
     const QLine *lines, int lineCount)
 {
-    if ( d_device )
-        d_device->drawLines( lines, lineCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawLines( lines, lineCount );
+        return;
+    }
+
+    device->drawLines( lines, lineCount );
 }
 
@@ -114,6 +139,15 @@
     const QLineF *lines, int lineCount)
 {
-    if ( d_device )
-        d_device->drawLines( lines, lineCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawLines( lines, lineCount );
+        return;
+    }
+
+    device->drawLines( lines, lineCount );
 }
 
@@ -121,6 +155,15 @@
     const QRectF &rect)
 {
-    if ( d_device )
-        d_device->drawEllipse( rect );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawEllipse( rect );
+        return;
+    }
+
+    device->drawEllipse( rect );
 }
 
@@ -128,6 +171,15 @@
     const QRect &rect)
 {
-    if ( d_device )
-        d_device->drawEllipse( rect );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawEllipse( rect );
+        return;
+    }
+
+    device->drawEllipse( rect );
 }
 
@@ -136,6 +188,9 @@
     const QPainterPath &path)
 {
-    if ( d_device )
-        d_device->drawPath( path );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    device->drawPath( path );
 }
 
@@ -143,6 +198,15 @@
     const QPointF *points, int pointCount)
 {
-    if ( d_device )
-        d_device->drawPoints( points, pointCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawPoints( points, pointCount );
+        return;
+    }
+
+    device->drawPoints( points, pointCount );
 }
 
@@ -150,6 +214,15 @@
     const QPoint *points, int pointCount)
 {
-    if ( d_device )
-        d_device->drawPoints( points, pointCount );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawPoints( points, pointCount );
+        return;
+    }
+
+    device->drawPoints( points, pointCount );
 }
 
@@ -157,6 +230,27 @@
     const QPointF *points, int pointCount, PolygonDrawMode mode)
 {
-    if ( d_device )
-        d_device->drawPolygon( points, pointCount, mode );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() == QwtNullPaintDevice::PathMode )
+    {
+        QPainterPath path;
+
+        if ( pointCount > 0 )
+        {
+            path.moveTo( points[0] );
+            for ( int i = 1; i < pointCount; i++ )
+                path.lineTo( points[i] );
+
+            if ( mode != PolylineMode )
+                path.closeSubpath();
+        }
+
+        device->drawPath( path );
+        return;
+    }
+
+    device->drawPolygon( points, pointCount, mode );
 }
 
@@ -164,6 +258,27 @@
     const QPoint *points, int pointCount, PolygonDrawMode mode)
 {
-    if ( d_device )
-        d_device->drawPolygon( points, pointCount, mode );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() == QwtNullPaintDevice::PathMode )
+    {
+        QPainterPath path;
+
+        if ( pointCount > 0 )
+        {
+            path.moveTo( points[0] );
+            for ( int i = 1; i < pointCount; i++ )
+                path.lineTo( points[i] );
+
+            if ( mode != PolylineMode )
+                path.closeSubpath();
+        }
+
+        device->drawPath( path );
+        return;
+    }
+
+    device->drawPolygon( points, pointCount, mode );
 }
 
@@ -171,6 +286,9 @@
     const QRectF &rect, const QPixmap &pm, const QRectF &subRect )
 {
-    if ( d_device )
-        d_device->drawPixmap( rect, pm, subRect );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    device->drawPixmap( rect, pm, subRect );
 }
 
@@ -178,6 +296,15 @@
     const QPointF &pos, const QTextItem &textItem)
 {
-    if ( d_device )
-        d_device->drawTextItem( pos, textItem );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawTextItem( pos, textItem );
+        return;
+    }
+
+    device->drawTextItem( pos, textItem );
 }
 
@@ -186,6 +313,15 @@
     const QPointF &subRect)
 {
-    if ( d_device )
-        d_device->drawTiledPixmap( rect, pixmap, subRect );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    if ( device->mode() != QwtNullPaintDevice::NormalMode )
+    {
+        QPaintEngine::drawTiledPixmap( rect, pixmap, subRect );
+        return;
+    }   
+
+    device->drawTiledPixmap( rect, pixmap, subRect );
 }
 
@@ -194,6 +330,9 @@
     const QRectF &subRect, Qt::ImageConversionFlags flags)
 {
-    if ( d_device )
-        d_device->drawImage( rect, image, subRect, flags );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    device->drawImage( rect, image, subRect, flags );
 }
 
@@ -201,27 +340,23 @@
     const QPaintEngineState &state)
 {
-    if ( d_device )
-        d_device->updateState( state );
+    QwtNullPaintDevice *device = nullDevice();
+    if ( device == NULL )
+        return;
+
+    device->updateState( state );
+}
+
+inline QwtNullPaintDevice *QwtNullPaintDevice::PaintEngine::nullDevice()
+{
+    if ( !isActive() )
+        return NULL;
+
+    return static_cast<QwtNullPaintDevice *>( paintDevice() );
 }
 
 //! Constructor
-QwtNullPaintDevice::QwtNullPaintDevice( 
-    QPaintEngine::PaintEngineFeatures features )
-{
-    init( features );
-}
-
-//! Constructor
-QwtNullPaintDevice::QwtNullPaintDevice( const QSize &size,
-    QPaintEngine::PaintEngineFeatures features )
-{
-    init( features );
-    d_data->size = size;
-}
-
-void QwtNullPaintDevice::init( 
-    QPaintEngine::PaintEngineFeatures features )
-{
-    d_engine = new PaintEngine( features );
+QwtNullPaintDevice::QwtNullPaintDevice():
+    d_engine( NULL )
+{
     d_data = new PrivateData;
 }
@@ -235,21 +370,21 @@
 
 /*!
-   Set the size of the paint device
-
-   \param size Size
-   \sa size()
+    Set the render mode
+
+    \param mode New mode
+    \sa mode()
+ */
+void QwtNullPaintDevice::setMode( Mode mode )
+{
+    d_data->mode = mode;
+}
+
+/*! 
+    \return Render mode
+    \sa setMode()
 */
-void QwtNullPaintDevice::setSize( const QSize & size )
-{
-    d_data->size = size;
-}
-
-/*! 
-    \return Size of the paint device
-    \sa setSize()
-*/
-QSize QwtNullPaintDevice::size() const
-{
-    return d_data->size;
+QwtNullPaintDevice::Mode QwtNullPaintDevice::mode() const
+{
+    return d_data->mode;
 }
 
@@ -257,4 +392,12 @@
 QPaintEngine *QwtNullPaintDevice::paintEngine() const
 {
+    if ( d_engine == NULL )
+    {
+        QwtNullPaintDevice *that = 
+            const_cast< QwtNullPaintDevice * >( this );
+
+        that->d_engine = new PaintEngine();
+    }
+
     return d_engine;
 }
@@ -262,32 +405,54 @@
 /*! 
     See QPaintDevice::metric()
-    \sa setSize()
+
+    \param deviceMetric Type of metric
+    \return Metric information for the given paint device metric.
+
+    \sa sizeMetrics()
 */
-int QwtNullPaintDevice::metric( PaintDeviceMetric metric ) const
-{
-    static QPixmap pm;
-
+int QwtNullPaintDevice::metric( PaintDeviceMetric deviceMetric ) const
+{
     int value;
 
-    switch ( metric ) 
+    switch ( deviceMetric ) 
     {
         case PdmWidth:
-            value = qMax( d_data->size.width(), 0 );
-            break;
+        {
+            value = sizeMetrics().width();
+            break;
+        }
         case PdmHeight:
-            value = qMax( d_data->size.height(), 0 );
-            break;
+        {
+            value = sizeMetrics().height();
+            break;
+        }
         case PdmNumColors:
-            value = 16777216;
-            break;
+        {
+            value = 0xffffffff;
+            break;
+        }
         case PdmDepth:
-            value = 24;
-            break;
+        {
+            value = 32;
+            break;
+        }
         case PdmPhysicalDpiX:
+        case PdmPhysicalDpiY:
         case PdmDpiY:
-        case PdmPhysicalDpiY:
+        case PdmDpiX:
+        {
+            value = 72;
+            break;
+        }
         case PdmWidthMM:
+        {
+            value = qRound( metric( PdmWidth ) * 25.4 / metric( PdmDpiX ) );
+            break;
+        }
         case PdmHeightMM:
-        case PdmDpiX:
+        {
+            value = qRound( metric( PdmHeight ) * 25.4 / metric( PdmDpiY ) );
+            break;
+        }
         default:
             value = 0;
Index: trunk/BNC/qwt/qwt_null_paintdevice.h
===================================================================
--- trunk/BNC/qwt/qwt_null_paintdevice.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_null_paintdevice.h	(revision 8127)
@@ -19,9 +19,9 @@
 
   Sometimes important layout/rendering geometries are not 
-  available or changable from the public Qt class interface. 
+  available or changeable from the public Qt class interface. 
   ( f.e hidden in the style implementation ).
 
   QwtNullPaintDevice can be used to manipulate or filter out 
-  these informations by analyzing the stream of paint primitives.
+  this information by analyzing the stream of paint primitives.
 
   F.e. QwtNullPaintDevice is used by QwtPlotCanvas to identify
@@ -32,14 +32,49 @@
 {
 public:
-    QwtNullPaintDevice( QPaintEngine::PaintEngineFeatures );
-    QwtNullPaintDevice( const QSize &size,
-        QPaintEngine::PaintEngineFeatures );
+    /*!
+      \brief Render mode
 
+      \sa setMode(), mode()
+     */
+    enum Mode
+    {
+        /*!
+           All vector graphic primitives are painted by
+           the corresponding draw methods
+         */
+        NormalMode, 
+
+        /*!
+           Vector graphic primitives ( beside polygons ) are mapped to a QPainterPath
+           and are painted by drawPath. In PathMode mode
+           only a few draw methods are called:
+
+           - drawPath()
+           - drawPixmap()
+           - drawImage()
+           - drawPolygon()
+         */
+        PolygonPathMode,
+
+        /*!
+           Vector graphic primitives are mapped to a QPainterPath
+           and are painted by drawPath. In PathMode mode
+           only a few draw methods are called:
+
+           - drawPath()
+           - drawPixmap()
+           - drawImage()
+         */
+        PathMode
+    };
+
+    QwtNullPaintDevice();
     virtual ~QwtNullPaintDevice();
 
-    void setSize( const QSize &);
-    QSize size() const;
+    void setMode( Mode );
+    Mode mode() const;
 
     virtual QPaintEngine *paintEngine() const;
+
     virtual int metric( PaintDeviceMetric metric ) const;
 
@@ -77,7 +112,9 @@
     virtual void updateState( const QPaintEngineState &state );
 
+protected:
+    //! \return Size needed to implement metric()
+    virtual QSize sizeMetrics() const = 0;
+
 private:
-    void init( QPaintEngine::PaintEngineFeatures );
-
     class PaintEngine;
     PaintEngine *d_engine;
Index: trunk/BNC/qwt/qwt_painter.cpp
===================================================================
--- trunk/BNC/qwt/qwt_painter.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_painter.cpp	(revision 8127)
@@ -29,8 +29,21 @@
 #include <qdesktopwidget.h>
 
+#if QT_VERSION >= 0x050000
+#include <qwindow.h>
+#endif
+
+#if QT_VERSION < 0x050000 
+
+#ifdef Q_WS_X11
+#include <qx11info_x11.h>
+#endif
+
+#endif
+
 bool QwtPainter::d_polylineSplitting = true;
 bool QwtPainter::d_roundingAlignment = true;
 
-static inline bool isClippingNeeded( const QPainter *painter, QRectF &clipRect )
+static inline bool qwtIsClippingNeeded( 
+    const QPainter *painter, QRectF &clipRect )
 {
     bool doClipping = false;
@@ -50,6 +63,7 @@
 }
 
-static inline void drawPolyline( QPainter *painter,
-    const QPointF *points, int pointCount, bool polylineSplitting )
+template <class T>
+static inline void qwtDrawPolyline( QPainter *painter,
+    const T *points, int pointCount, bool polylineSplitting )
 {
     bool doSplit = false;
@@ -71,5 +85,6 @@
     if ( doSplit )
     {
-        const int splitSize = 20;
+        const int splitSize = 6;
+
         for ( int i = 0; i < pointCount; i += splitSize )
         {
@@ -79,22 +94,31 @@
     }
     else
+    {
         painter->drawPolyline( points, pointCount );
-}
-
-static inline void unscaleFont( QPainter *painter )
+    }
+}
+
+static inline QSize qwtScreenResolution()
+{
+    static QSize screenResolution;
+    if ( !screenResolution.isValid() )
+    {
+        QDesktopWidget *desktop = QApplication::desktop();
+        if ( desktop )
+        {
+            screenResolution.setWidth( desktop->logicalDpiX() );
+            screenResolution.setHeight( desktop->logicalDpiY() );
+        }
+    }
+
+    return screenResolution;
+}
+
+static inline void qwtUnscaleFont( QPainter *painter )
 {
     if ( painter->font().pixelSize() >= 0 )
         return;
 
-    static QSize screenResolution;
-    if ( !screenResolution.isValid() )
-    {
-        QDesktopWidget *desktop = QApplication::desktop();
-        if ( desktop )
-        {
-            screenResolution.setWidth( desktop->logicalDpiX() );
-            screenResolution.setHeight( desktop->logicalDpiY() );
-        }
-    }
+    const QSize screenResolution = qwtScreenResolution();
 
     const QPaintDevice *pd = painter->device();
@@ -107,4 +131,25 @@
         painter->setFont( pixelFont );
     }
+}
+
+/*!
+  Check is the application is running with the X11 graphics system
+  that has some special capabilities that can be used for incremental
+  painting to a widget.
+
+  \return True, when the graphics system is X11
+*/
+bool QwtPainter::isX11GraphicsSystem()
+{
+    static int onX11 = -1;
+    if ( onX11 < 0 )
+    {
+        QPixmap pm( 1, 1 );
+        QPainter painter( &pm );
+
+        onX11 = ( painter.paintEngine()->type() == QPaintEngine::X11 ) ? 1 : 0;
+    }
+
+    return onX11 == 1;
 }
 
@@ -114,6 +159,10 @@
   beside QPaintEngine::Pdf and QPaintEngine::SVG.
 
+  If we have an integer based paint engine it is also
+  checked if the painter has a transformation matrix,
+  that rotates or scales.
+
   \param  painter Painter
-  \return true, when the paint engine is aligning
+  \return true, when the painter is aligning
 
   \sa setRoundingAlignment()
@@ -131,4 +180,11 @@
             default:;
         }
+
+        const QTransform tr = painter->transform();
+        if ( tr.isRotating() || tr.isScaling() )
+        {
+            // we might have to check translations too
+            return false;
+        }
     }
 
@@ -139,6 +195,6 @@
   Enable whether coordinates should be rounded, before they are painted
   to a paint engine that floors to integer values. For other paint engines
-  this ( Pdf, SVG ), this flag has no effect.
-  QwtPainter stores this flag only, the rounding itsself is done in 
+  ( PDF, SVG ) this flag has no effect.
+  QwtPainter stores this flag only, the rounding itself is done in 
   the painting code ( f.e the plot items ).
 
@@ -155,6 +211,9 @@
   \brief En/Disable line splitting for the raster paint engine
 
-  The raster paint engine paints polylines of many points
-  much faster when they are splitted in smaller chunks.
+  In some Qt versions the raster paint engine paints polylines of many points
+  much faster when they are split in smaller chunks: f.e all supported Qt versions
+  >= Qt 5.0 when drawing an antialiased polyline with a pen width >=2.
+
+  The default setting is true.
 
   \sa polylineSplitting()
@@ -183,5 +242,5 @@
 
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping )
@@ -214,9 +273,9 @@
 
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     /*
-      Performance of Qt4 is horrible for non trivial brushs. Without
-      clipping expect minutes or hours for repainting large rects
+      Performance of Qt4 is horrible for a non trivial brush. Without
+      clipping expect minutes or hours for repainting large rectangles
       (might result from zooming)
     */
@@ -232,5 +291,5 @@
     QRectF r = rect;
     if ( deviceClipping )
-        r = r.intersect( clipRect );
+        r = r.intersected( clipRect );
 
     if ( r.isValid() )
@@ -243,5 +302,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
     if ( deviceClipping && !clipRect.contains( rect ) )
         return;
@@ -254,5 +313,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping && !clipRect.contains( rect ) )
@@ -274,5 +333,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping && !clipRect.contains( pos ) )
@@ -281,5 +340,5 @@
 
     painter->save();
-    unscaleFont( painter );
+    qwtUnscaleFont( painter );
     painter->drawText( pos, text );
     painter->restore();
@@ -299,5 +358,5 @@
 {
     painter->save();
-    unscaleFont( painter );
+    qwtUnscaleFont( painter );
     painter->drawText( rect, flags, text );
     painter->restore();
@@ -321,23 +380,39 @@
     painter->save();
 
-    painter->setFont( txt->defaultFont() );
-    unscaleFont( painter );
+    QRectF unscaledRect = rect;
+
+    if ( painter->font().pixelSize() < 0 )
+    {
+        const QSize res = qwtScreenResolution();
+
+        const QPaintDevice *pd = painter->device();
+        if ( pd->logicalDpiX() != res.width() ||
+            pd->logicalDpiY() != res.height() )
+        {
+            QTransform transform;
+            transform.scale( res.width() / double( pd->logicalDpiX() ),
+                res.height() / double( pd->logicalDpiY() ));
+
+            painter->setWorldTransform( transform, true );
+            unscaledRect = transform.inverted().mapRect(rect);
+        }
+    }  
 
     txt->setDefaultFont( painter->font() );
-    txt->setPageSize( QSizeF( rect.width(), QWIDGETSIZE_MAX ) );
+    txt->setPageSize( QSizeF( unscaledRect.width(), QWIDGETSIZE_MAX ) );
 
     QAbstractTextDocumentLayout* layout = txt->documentLayout();
 
     const double height = layout->documentSize().height();
-    double y = rect.y();
+    double y = unscaledRect.y();
     if ( flags & Qt::AlignBottom )
-        y += ( rect.height() - height );
+        y += ( unscaledRect.height() - height );
     else if ( flags & Qt::AlignVCenter )
-        y += ( rect.height() - height ) / 2;
+        y += ( unscaledRect.height() - height ) / 2;
 
     QAbstractTextDocumentLayout::PaintContext context;
     context.palette.setColor( QPalette::Text, painter->pen().color() );
 
-    painter->translate( rect.x(), y );
+    painter->translate( unscaledRect.x(), y );
     layout->draw( painter, context );
 
@@ -354,5 +429,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping &&
@@ -373,5 +448,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     QPolygonF cpa = polygon;
@@ -386,5 +461,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     QPolygonF cpa = polygon;
@@ -392,5 +467,5 @@
         cpa = QwtClipper::clipPolygonF( clipRect, cpa );
 
-    ::drawPolyline( painter,
+    qwtDrawPolyline<QPointF>( painter,
         cpa.constData(), cpa.size(), d_polylineSplitting );
 }
@@ -401,17 +476,66 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping )
     {
         QPolygonF polygon( pointCount );
-        qMemCopy( polygon.data(), points, pointCount * sizeof( QPointF ) );
+        ::memcpy( polygon.data(), points, pointCount * sizeof( QPointF ) );
 
         polygon = QwtClipper::clipPolygonF( clipRect, polygon );
-        ::drawPolyline( painter,
+        qwtDrawPolyline<QPointF>( painter,
             polygon.constData(), polygon.size(), d_polylineSplitting );
     }
     else
-        ::drawPolyline( painter, points, pointCount, d_polylineSplitting );
+    {
+        qwtDrawPolyline<QPointF>( painter, points, pointCount, d_polylineSplitting );
+    }
+}
+
+//! Wrapper for QPainter::drawPolygon()
+void QwtPainter::drawPolygon( QPainter *painter, const QPolygon &polygon )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    QPolygon cpa = polygon;
+    if ( deviceClipping )
+        cpa = QwtClipper::clipPolygon( clipRect, polygon );
+
+    painter->drawPolygon( cpa );
+}
+
+//! Wrapper for QPainter::drawPolyline()
+void QwtPainter::drawPolyline( QPainter *painter, const QPolygon &polygon )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    QPolygon cpa = polygon;
+    if ( deviceClipping )
+        cpa = QwtClipper::clipPolygon( clipRect, cpa );
+
+    qwtDrawPolyline<QPoint>( painter,
+        cpa.constData(), cpa.size(), d_polylineSplitting );
+}
+
+//! Wrapper for QPainter::drawPolyline()
+void QwtPainter::drawPolyline( QPainter *painter,
+    const QPoint *points, int pointCount )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    if ( deviceClipping )
+    {
+        QPolygon polygon( pointCount );
+        ::memcpy( polygon.data(), points, pointCount * sizeof( QPoint ) );
+
+        polygon = QwtClipper::clipPolygon( clipRect, polygon );
+        qwtDrawPolyline<QPoint>( painter,
+            polygon.constData(), polygon.size(), d_polylineSplitting );
+    }
+    else
+        qwtDrawPolyline<QPoint>( painter, points, pointCount, d_polylineSplitting );
 }
 
@@ -420,5 +544,5 @@
 {
     QRectF clipRect;
-    const bool deviceClipping = isClippingNeeded( painter, clipRect );
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
 
     if ( deviceClipping && !clipRect.contains( pos ) )
@@ -426,4 +550,86 @@
 
     painter->drawPoint( pos );
+}
+
+//! Wrapper for QPainter::drawPoint()
+void QwtPainter::drawPoint( QPainter *painter, const QPoint &pos )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    if ( deviceClipping )
+    {
+        const int minX = qCeil( clipRect.left() );
+        const int maxX = qFloor( clipRect.right() );
+        const int minY = qCeil( clipRect.top() );
+        const int maxY = qFloor( clipRect.bottom() );
+
+        if ( pos.x() < minX || pos.x() > maxX 
+            || pos.y() < minY || pos.y() > maxY )
+        {
+            return;
+        }
+    }
+
+    painter->drawPoint( pos );
+}
+
+//! Wrapper for QPainter::drawPoints()
+void QwtPainter::drawPoints( QPainter *painter, 
+    const QPoint *points, int pointCount )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    if ( deviceClipping )
+    {
+        const int minX = qCeil( clipRect.left() );
+        const int maxX = qFloor( clipRect.right() );
+        const int minY = qCeil( clipRect.top() );
+        const int maxY = qFloor( clipRect.bottom() );
+
+        const QRect r( minX, minY, maxX - minX, maxY - minY );
+
+        QPolygon clippedPolygon( pointCount );
+        QPoint *clippedData = clippedPolygon.data();
+
+        int numClippedPoints = 0;
+        for ( int i = 0; i < pointCount; i++ )
+        {
+            if ( r.contains( points[i] ) )
+                clippedData[ numClippedPoints++ ] = points[i];
+        }
+        painter->drawPoints( clippedData, numClippedPoints );
+    }
+    else
+    {
+        painter->drawPoints( points, pointCount );
+    }
+}
+
+//! Wrapper for QPainter::drawPoints()
+void QwtPainter::drawPoints( QPainter *painter, 
+    const QPointF *points, int pointCount )
+{
+    QRectF clipRect;
+    const bool deviceClipping = qwtIsClippingNeeded( painter, clipRect );
+
+    if ( deviceClipping )
+    {
+        QPolygonF clippedPolygon( pointCount );
+        QPointF *clippedData = clippedPolygon.data();
+
+        int numClippedPoints = 0;
+        for ( int i = 0; i < pointCount; i++ )
+        {
+            if ( clipRect.contains( points[i] ) )
+                clippedData[ numClippedPoints++ ] = points[i];
+        }
+        painter->drawPoints( clippedData, numClippedPoints );
+    }
+    else
+    {
+        painter->drawPoints( points, pointCount );
+    }
 }
 
@@ -471,5 +677,5 @@
 
 //! Draw a focus rectangle on a widget using its style.
-void QwtPainter::drawFocusRect( QPainter *painter, QWidget *widget )
+void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget )
 {
     drawFocusRect( painter, widget, widget->rect() );
@@ -477,5 +683,5 @@
 
 //! Draw a focus rectangle on a widget using its style.
-void QwtPainter::drawFocusRect( QPainter *painter, QWidget *widget,
+void QwtPainter::drawFocusRect( QPainter *painter, const QWidget *widget,
     const QRect &rect )
 {
@@ -484,11 +690,244 @@
     opt.rect = rect;
     opt.state |= QStyle::State_HasFocus;
-
-    widget->style()->drawPrimitive( QStyle::PE_FrameFocusRect,
-        &opt, painter, widget );
+    opt.backgroundColor = widget->palette().color( widget->backgroundRole() );
+
+    widget->style()->drawPrimitive(
+        QStyle::PE_FrameFocusRect, &opt, painter, widget );
 }
 
 /*!
-  Draw a frame with rounded borders
+  Draw a round frame 
+
+  \param painter Painter
+  \param rect Frame rectangle
+  \param palette QPalette::WindowText is used for plain borders
+                 QPalette::Dark and QPalette::Light for raised
+                 or sunken borders
+  \param lineWidth Line width
+  \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow
+*/
+void QwtPainter::drawRoundFrame( QPainter *painter,
+    const QRectF &rect, const QPalette &palette, 
+    int lineWidth, int frameStyle )
+{
+    enum Style
+    {
+        Plain,
+        Sunken,
+        Raised
+    };
+
+    Style style = Plain;
+    if ( (frameStyle & QFrame::Sunken) == QFrame::Sunken )
+        style = Sunken;
+    else if ( (frameStyle & QFrame::Raised) == QFrame::Raised )
+        style = Raised;
+
+    const double lw2 = 0.5 * lineWidth;
+    QRectF r = rect.adjusted( lw2, lw2, -lw2, -lw2 );
+
+    QBrush brush;
+
+    if ( style != Plain )
+    {
+        QColor c1 = palette.color( QPalette::Light );
+        QColor c2 = palette.color( QPalette::Dark );
+
+        if ( style == Sunken )
+            qSwap( c1, c2 );
+
+        QLinearGradient gradient( r.topLeft(), r.bottomRight() );
+        gradient.setColorAt( 0.0, c1 );
+#if 0
+        gradient.setColorAt( 0.3, c1 );
+        gradient.setColorAt( 0.7, c2 );
+#endif
+        gradient.setColorAt( 1.0, c2 );
+
+        brush = QBrush( gradient );
+    }
+    else // Plain
+    {
+        brush = palette.brush( QPalette::WindowText );
+    }
+
+    painter->save();
+
+    painter->setPen( QPen( brush, lineWidth ) );
+    painter->setBrush( Qt::NoBrush );
+
+    painter->drawEllipse( r );
+
+    painter->restore();
+}
+
+/*!
+  Draw a rectangular frame
+
+  \param painter Painter
+  \param rect Frame rectangle
+  \param palette Palette
+  \param foregroundRole Foreground role used for QFrame::Plain
+  \param frameWidth Frame width
+  \param midLineWidth Used for QFrame::Box
+  \param frameStyle bitwise OR´ed value of QFrame::Shape and QFrame::Shadow
+*/
+void QwtPainter::drawFrame( QPainter *painter, const QRectF &rect,
+    const QPalette &palette, QPalette::ColorRole foregroundRole,
+    int frameWidth, int midLineWidth, int frameStyle )
+{
+    if ( frameWidth <= 0 || rect.isEmpty() )
+        return;
+
+    const int shadow = frameStyle & QFrame::Shadow_Mask;
+
+    painter->save();
+
+    if ( shadow == QFrame::Plain )
+    {
+        const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
+        const QRectF innerRect = outerRect.adjusted( 
+            frameWidth, frameWidth, -frameWidth, -frameWidth );
+
+        QPainterPath path;
+        path.addRect( outerRect );
+        path.addRect( innerRect );
+
+        painter->setPen( Qt::NoPen );
+        painter->setBrush( palette.color( foregroundRole ) );
+
+        painter->drawPath( path );
+    }
+    else
+    {
+        const int shape = frameStyle & QFrame::Shape_Mask;
+
+        if ( shape == QFrame::Box )
+        {
+            const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
+            const QRectF midRect1 = outerRect.adjusted( 
+                frameWidth, frameWidth, -frameWidth, -frameWidth );
+            const QRectF midRect2 = midRect1.adjusted( 
+                midLineWidth, midLineWidth, -midLineWidth, -midLineWidth );
+
+            const QRectF innerRect = midRect2.adjusted( 
+                frameWidth, frameWidth, -frameWidth, -frameWidth );
+
+            QPainterPath path1;
+            path1.moveTo( outerRect.bottomLeft() );
+            path1.lineTo( outerRect.topLeft() );
+            path1.lineTo( outerRect.topRight() );
+            path1.lineTo( midRect1.topRight() );
+            path1.lineTo( midRect1.topLeft() );
+            path1.lineTo( midRect1.bottomLeft() );
+
+            QPainterPath path2;
+            path2.moveTo( outerRect.bottomLeft() );
+            path2.lineTo( outerRect.bottomRight() );
+            path2.lineTo( outerRect.topRight() );
+            path2.lineTo( midRect1.topRight() );
+            path2.lineTo( midRect1.bottomRight() );
+            path2.lineTo( midRect1.bottomLeft() );
+
+            QPainterPath path3;
+            path3.moveTo( midRect2.bottomLeft() );
+            path3.lineTo( midRect2.topLeft() );
+            path3.lineTo( midRect2.topRight() );
+            path3.lineTo( innerRect.topRight() );
+            path3.lineTo( innerRect.topLeft() );
+            path3.lineTo( innerRect.bottomLeft() );
+
+            QPainterPath path4;
+            path4.moveTo( midRect2.bottomLeft() );
+            path4.lineTo( midRect2.bottomRight() );
+            path4.lineTo( midRect2.topRight() );
+            path4.lineTo( innerRect.topRight() );
+            path4.lineTo( innerRect.bottomRight() );
+            path4.lineTo( innerRect.bottomLeft() );
+
+            QPainterPath path5;
+            path5.addRect( midRect1 );
+            path5.addRect( midRect2 );
+
+            painter->setPen( Qt::NoPen );
+
+            QBrush brush1 = palette.dark().color();
+            QBrush brush2 = palette.light().color();
+
+            if ( shadow == QFrame::Raised )
+                qSwap( brush1, brush2 );
+
+            painter->setBrush( brush1 );
+            painter->drawPath( path1 );
+            painter->drawPath( path4 );
+
+            painter->setBrush( brush2 );
+            painter->drawPath( path2 );
+            painter->drawPath( path3 );
+
+            painter->setBrush( palette.mid() );
+            painter->drawPath( path5 );
+        }
+#if 0
+        // qDrawWinPanel doesn't result in something nice
+        // on a scalable document like PDF. Better draw a
+        // Panel.
+
+        else if ( shape == QFrame::WinPanel )
+        {
+            painter->setRenderHint( QPainter::NonCosmeticDefaultPen, true );
+            qDrawWinPanel ( painter, rect.toRect(), palette,
+                frameStyle & QFrame::Sunken );
+        }
+        else if ( shape == QFrame::StyledPanel )
+        {
+        }
+#endif
+        else
+        {
+            const QRectF outerRect = rect.adjusted( 0.0, 0.0, -1.0, -1.0 );
+            const QRectF innerRect = outerRect.adjusted( 
+                frameWidth - 1.0, frameWidth - 1.0, 
+                -( frameWidth - 1.0 ), -( frameWidth - 1.0 ) );
+
+            QPainterPath path1;
+            path1.moveTo( outerRect.bottomLeft() );
+            path1.lineTo( outerRect.topLeft() );
+            path1.lineTo( outerRect.topRight() );
+            path1.lineTo( innerRect.topRight() );
+            path1.lineTo( innerRect.topLeft() );
+            path1.lineTo( innerRect.bottomLeft() );
+
+
+            QPainterPath path2;
+            path2.moveTo( outerRect.bottomLeft() );
+            path2.lineTo( outerRect.bottomRight() );
+            path2.lineTo( outerRect.topRight() );
+            path2.lineTo( innerRect.topRight() );
+            path2.lineTo( innerRect.bottomRight() );
+            path2.lineTo( innerRect.bottomLeft() );
+
+            painter->setPen( Qt::NoPen );
+
+            QBrush brush1 = palette.dark().color();
+            QBrush brush2 = palette.light().color();
+
+            if ( shadow == QFrame::Raised )
+                qSwap( brush1, brush2 );
+
+            painter->setBrush( brush1 );
+            painter->drawPath( path1 );
+
+            painter->setBrush( brush2 );
+            painter->drawPath( path2 );
+        }
+
+    }
+
+    painter->restore();
+}
+
+/*!
+  Draw a rectangular frame with rounded borders
 
   \param painter Painter
@@ -567,7 +1006,9 @@
 
             QPen arcPen;
+            arcPen.setCapStyle( Qt::FlatCap );
             arcPen.setWidth( lineWidth );
 
             QPen linePen;
+            linePen.setCapStyle( Qt::FlatCap );
             linePen.setWidth( lineWidth );
 
@@ -660,4 +1101,6 @@
 
     QPixmap pixmap( devRect.size() );
+    pixmap.fill( Qt::transparent );
+
     QPainter pmPainter( &pixmap );
     pmPainter.translate( -devRect.x(), -devRect.y() );
@@ -673,5 +1116,5 @@
 
             if ( colorMap.format() == QwtColorMap::RGB )
-                c.setRgb( colorMap.rgb( interval, value ) );
+                c.setRgba( colorMap.rgb( interval, value ) );
             else
                 c = colorTable[colorMap.colorIndex( interval, value )];
@@ -691,5 +1134,5 @@
 
             if ( colorMap.format() == QwtColorMap::RGB )
-                c.setRgb( colorMap.rgb( interval, value ) );
+                c.setRgba( colorMap.rgb( interval, value ) );
             else
                 c = colorTable[colorMap.colorIndex( interval, value )];
@@ -703,2 +1146,154 @@
     drawPixmap( painter, rect, pixmap );
 }
+
+static inline void qwtFillRect( const QWidget *widget, QPainter *painter, 
+    const QRect &rect, const QBrush &brush)
+{
+    if ( brush.style() == Qt::TexturePattern ) 
+    {
+        painter->save();
+
+        painter->setClipRect( rect );
+        painter->drawTiledPixmap(rect, brush.texture(), rect.topLeft());
+
+        painter->restore();
+    } 
+    else if ( brush.gradient() )
+    {
+        painter->save();
+
+        painter->setClipRect( rect );
+        painter->fillRect(0, 0, widget->width(), 
+            widget->height(), brush);
+
+        painter->restore();
+    } 
+    else 
+    {
+        painter->fillRect(rect, brush);
+    }
+}
+
+/*!
+  Fill a pixmap with the content of a widget
+
+  In Qt >= 5.0 QPixmap::fill() is a nop, in Qt 4.x it is buggy
+  for backgrounds with gradients. Thus fillPixmap() offers 
+  an alternative implementation.
+
+  \param widget Widget
+  \param pixmap Pixmap to be filled
+  \param offset Offset 
+
+  \sa QPixmap::fill()
+ */
+void QwtPainter::fillPixmap( const QWidget *widget, 
+    QPixmap &pixmap, const QPoint &offset )
+{
+    const QRect rect( offset, pixmap.size() );
+
+    QPainter painter( &pixmap );
+    painter.translate( -offset );
+
+    const QBrush autoFillBrush = 
+        widget->palette().brush( widget->backgroundRole() );
+
+    if ( !( widget->autoFillBackground() && autoFillBrush.isOpaque() ) ) 
+    {
+        const QBrush bg = widget->palette().brush( QPalette::Window );
+        qwtFillRect( widget, &painter, rect, bg);
+    }
+
+    if ( widget->autoFillBackground() )
+        qwtFillRect( widget, &painter, rect, autoFillBrush);
+
+    if ( widget->testAttribute(Qt::WA_StyledBackground) ) 
+    {
+        painter.setClipRegion( rect );
+
+        QStyleOption opt;
+        opt.initFrom( widget );
+        widget->style()->drawPrimitive( QStyle::PE_Widget, 
+            &opt, &painter, widget );
+    }
+}
+
+/*!
+  Fill rect with the background of a widget
+
+  \param painter Painter
+  \param rect Rectangle to be filled
+  \param widget Widget
+
+  \sa QStyle::PE_Widget, QWidget::backgroundRole()
+ */
+void QwtPainter::drawBackgound( QPainter *painter,
+    const QRectF &rect, const QWidget *widget )
+{
+    if ( widget->testAttribute( Qt::WA_StyledBackground ) )
+    {
+        QStyleOption opt;
+        opt.initFrom( widget );
+        opt.rect = rect.toAlignedRect();
+
+        widget->style()->drawPrimitive(
+            QStyle::PE_Widget, &opt, painter, widget);
+    }
+    else
+    {
+        const QBrush brush =
+            widget->palette().brush( widget->backgroundRole() );
+
+        painter->fillRect( rect, brush );
+    }
+}
+
+/*!
+  \return A pixmap that can be used as backing store
+
+  \param widget Widget, for which the backingstore is intended
+  \param size Size of the pixmap
+ */
+QPixmap QwtPainter::backingStore( QWidget *widget, const QSize &size )
+{
+    QPixmap pm;
+
+#define QWT_HIGH_DPI 1
+
+#if QT_VERSION >= 0x050000 && QWT_HIGH_DPI
+    qreal pixelRatio = 1.0;
+
+    if ( widget && widget->windowHandle() )
+    {
+#if QT_VERSION < 0x050100
+        pixelRatio = widget->windowHandle()->devicePixelRatio();
+#else
+        pixelRatio = widget->devicePixelRatio();
+#endif
+    }
+    else
+    {
+        if ( qApp )
+            pixelRatio = qApp->devicePixelRatio();
+    }
+
+    pm = QPixmap( size * pixelRatio );
+    pm.setDevicePixelRatio( pixelRatio );
+#else
+    Q_UNUSED( widget )
+    pm = QPixmap( size );
+#endif
+
+#if QT_VERSION < 0x050000 
+#ifdef Q_WS_X11
+    if ( widget && isX11GraphicsSystem() )
+    {
+        if ( pm.x11Info().screen() != widget->x11Info().screen() )
+            pm.x11SetScreen( widget->x11Info().screen() );
+    }
+#endif
+#endif
+
+    return pm;
+}
+
Index: trunk/BNC/qwt/qwt_painter.h
===================================================================
--- trunk/BNC/qwt/qwt_painter.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_painter.h	(revision 8127)
@@ -17,4 +17,5 @@
 #include <qpen.h>
 #include <qline.h>
+#include <qpalette.h>
 
 class QPainter;
@@ -30,5 +31,4 @@
 class QwtInterval;
 
-class QPalette;
 class QTextDocument;
 class QPainterPath;
@@ -70,10 +70,20 @@
     static void drawLine( QPainter *, const QLineF & );
 
-    static void drawPolygon( QPainter *, const QPolygonF &pa );
-    static void drawPolyline( QPainter *, const QPolygonF &pa );
+    static void drawPolygon( QPainter *, const QPolygonF & );
+    static void drawPolyline( QPainter *, const QPolygonF & );
     static void drawPolyline( QPainter *, const QPointF *, int pointCount );
+
+    static void drawPolygon( QPainter *, const QPolygon & );
+    static void drawPolyline( QPainter *, const QPolygon & );
+    static void drawPolyline( QPainter *, const QPoint *, int pointCount );
+
+    static void drawPoint( QPainter *, const QPoint & );
+    static void drawPoints( QPainter *, const QPolygon & );
+    static void drawPoints( QPainter *, const QPoint *, int pointCount );
 
     static void drawPoint( QPainter *, double x, double y );
     static void drawPoint( QPainter *, const QPointF & );
+    static void drawPoints( QPainter *, const QPolygonF & );
+    static void drawPoints( QPainter *, const QPointF *, int pointCount );
 
     static void drawPath( QPainter *, const QPainterPath & );
@@ -81,10 +91,17 @@
     static void drawPixmap( QPainter *, const QRectF &, const QPixmap & );
 
+    static void drawRoundFrame( QPainter *,
+        const QRectF &, const QPalette &, int lineWidth, int frameStyle );
+
     static void drawRoundedFrame( QPainter *, 
         const QRectF &, double xRadius, double yRadius,
         const QPalette &, int lineWidth, int frameStyle );
 
-    static void drawFocusRect( QPainter *, QWidget * );
-    static void drawFocusRect( QPainter *, QWidget *, const QRect & );
+    static void drawFrame( QPainter *, const QRectF &rect,
+        const QPalette &palette, QPalette::ColorRole foregroundRole,
+        int lineWidth, int midLineWidth, int frameStyle ); 
+
+    static void drawFocusRect( QPainter *, const QWidget * );
+    static void drawFocusRect( QPainter *, const QWidget *, const QRect & );
 
     static void drawColorBar( QPainter *painter,
@@ -93,4 +110,13 @@
 
     static bool isAligning( QPainter *painter );
+    static bool isX11GraphicsSystem();
+
+    static void fillPixmap( const QWidget *, 
+        QPixmap &, const QPoint &offset = QPoint() );
+
+    static void drawBackgound( QPainter *painter,
+        const QRectF &rect, const QWidget *widget );
+
+    static QPixmap backingStore( QWidget *, const QSize & );
 
 private:
@@ -103,4 +129,16 @@
 {
     QwtPainter::drawPoint( painter, QPointF( x, y ) );
+}
+
+//! Wrapper for QPainter::drawPoints()
+inline void QwtPainter::drawPoints( QPainter *painter, const QPolygon &polygon )
+{
+    drawPoints( painter, polygon.data(), polygon.size() );
+}
+
+//! Wrapper for QPainter::drawPoints()
+inline void QwtPainter::drawPoints( QPainter *painter, const QPolygonF &polygon )
+{
+    drawPoints( painter, polygon.data(), polygon.size() );
 }
 
@@ -119,5 +157,5 @@
 
 /*!
-  Returns whether line splitting for the raster paint engine is enabled.
+  \return True, when line splitting for the raster paint engine is enabled.
   \sa setPolylineSplitting()
 */
@@ -128,8 +166,9 @@
 
 /*!
-  Returns whether coordinates should be rounded, before they are painted
-  to a paint engine that floors to integer values.  For other paint engines
-  this ( Pdf, SVG ), this flag has no effect.
+  Check whether coordinates should be rounded, before they are painted
+  to a paint engine that rounds to integer values. For other paint engines
+  ( PDF, SVG ), this flag has no effect.
 
+  \return True, when rounding is enabled
   \sa setRoundingAlignment(), isAligning()
 */
Index: trunk/BNC/qwt/qwt_painter_command.cpp
===================================================================
--- trunk/BNC/qwt/qwt_painter_command.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_painter_command.cpp	(revision 8127)
@@ -0,0 +1,237 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_painter_command.h"
+
+//! Construct an invalid command
+QwtPainterCommand::QwtPainterCommand():
+    d_type( Invalid )
+{
+}
+
+//! Copy constructor
+QwtPainterCommand::QwtPainterCommand( const QPainterPath &path ):
+    d_type( Path )
+{
+    d_path = new QPainterPath( path );
+}
+
+/*!
+  Constructor for Pixmap paint operation
+
+  \param rect Target rectangle
+  \param pixmap Pixmap
+  \param subRect Rectangle inside the pixmap
+
+  \sa QPainter::drawPixmap()
+ */
+QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
+        const QPixmap &pixmap, const QRectF& subRect ):
+    d_type( Pixmap )
+{
+    d_pixmapData = new PixmapData();
+    d_pixmapData->rect = rect;
+    d_pixmapData->pixmap = pixmap;
+    d_pixmapData->subRect = subRect;
+}
+
+/*!
+  Constructor for Image paint operation
+
+  \param rect Target rectangle
+  \param image Image
+  \param subRect Rectangle inside the image
+  \param flags Conversion flags
+
+  \sa QPainter::drawImage()
+ */
+QwtPainterCommand::QwtPainterCommand( const QRectF &rect,
+        const QImage &image, const QRectF& subRect,
+        Qt::ImageConversionFlags flags ):
+    d_type( Image )
+{
+    d_imageData = new ImageData();
+    d_imageData->rect = rect;
+    d_imageData->image = image;
+    d_imageData->subRect = subRect;
+    d_imageData->flags = flags;
+}
+
+/*! 
+  Constructor for State paint operation
+  \param state Paint engine state
+ */  
+QwtPainterCommand::QwtPainterCommand( const QPaintEngineState &state ):
+    d_type( State )
+{
+    d_stateData = new StateData();
+
+    d_stateData->flags = state.state();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyPen ) 
+        d_stateData->pen = state.pen();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyBrush ) 
+        d_stateData->brush = state.brush();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyBrushOrigin ) 
+        d_stateData->brushOrigin = state.brushOrigin();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyFont ) 
+        d_stateData->font = state.font();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyBackground ) 
+    {
+        d_stateData->backgroundMode = state.backgroundMode();
+        d_stateData->backgroundBrush = state.backgroundBrush();
+    }
+
+    if ( d_stateData->flags & QPaintEngine::DirtyTransform ) 
+        d_stateData->transform = state.transform();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyClipEnabled ) 
+        d_stateData->isClipEnabled = state.isClipEnabled();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyClipRegion ) 
+    {
+        d_stateData->clipRegion = state.clipRegion();
+        d_stateData->clipOperation = state.clipOperation();
+    }
+
+    if ( d_stateData->flags & QPaintEngine::DirtyClipPath ) 
+    {
+        d_stateData->clipPath = state.clipPath();
+        d_stateData->clipOperation = state.clipOperation();
+    }
+
+    if ( d_stateData->flags & QPaintEngine::DirtyHints ) 
+        d_stateData->renderHints = state.renderHints();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyCompositionMode ) 
+        d_stateData->compositionMode = state.compositionMode();
+
+    if ( d_stateData->flags & QPaintEngine::DirtyOpacity ) 
+        d_stateData->opacity = state.opacity();
+}
+
+/*!
+  Copy constructor
+  \param other Command to be copied
+  
+ */
+QwtPainterCommand::QwtPainterCommand(const QwtPainterCommand &other)
+{
+    copy( other );
+}
+
+//! Destructor
+QwtPainterCommand::~QwtPainterCommand()
+{
+    reset();
+}
+
+/*!
+  Assignment operator
+
+  \param other Command to be copied
+  \return Modified command
+ */
+QwtPainterCommand &QwtPainterCommand::operator=(const QwtPainterCommand &other)
+{
+    reset();
+    copy( other );
+
+    return *this;
+}
+
+void QwtPainterCommand::copy( const QwtPainterCommand &other )
+{
+    d_type = other.d_type;
+
+    switch( other.d_type )
+    {
+        case Path:
+        {
+            d_path = new QPainterPath( *other.d_path );
+            break;
+        }
+        case Pixmap:
+        {
+            d_pixmapData = new PixmapData( *other.d_pixmapData );
+            break;
+        }
+        case Image:
+        {
+            d_imageData = new ImageData( *other.d_imageData );
+            break;
+        }
+        case State:
+        {
+            d_stateData = new StateData( *other.d_stateData );
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+void QwtPainterCommand::reset()
+{
+    switch( d_type )
+    {
+        case Path:
+        {
+            delete d_path;
+            break;
+        }
+        case Pixmap:
+        {
+            delete d_pixmapData;
+            break;
+        }
+        case Image:
+        {
+            delete d_imageData;
+            break;
+        }
+        case State:
+        {
+            delete d_stateData;
+            break;
+        }
+        default:
+            break;
+    }
+
+    d_type = Invalid;
+}
+
+//! \return Painter path to be painted
+QPainterPath *QwtPainterCommand::path() 
+{
+    return d_path;
+}
+
+//! \return Attributes how to paint a QPixmap
+QwtPainterCommand::PixmapData* QwtPainterCommand::pixmapData() 
+{
+    return d_pixmapData;
+}
+
+//! \return Attributes how to paint a QImage
+QwtPainterCommand::ImageData* QwtPainterCommand::imageData() 
+{
+    return d_imageData;
+}
+
+//! \return Attributes of a state change
+QwtPainterCommand::StateData* QwtPainterCommand::stateData() 
+{
+    return d_stateData;
+}
Index: trunk/BNC/qwt/qwt_painter_command.h
===================================================================
--- trunk/BNC/qwt/qwt_painter_command.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_painter_command.h	(revision 8127)
@@ -0,0 +1,173 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PAINTER_COMMAND_H
+#define QWT_PAINTER_COMMAND_H
+
+#include "qwt_global.h"
+#include <qpaintengine.h>
+#include <qpixmap.h>
+#include <qimage.h>
+#include <qpolygon.h>
+
+class QPainterPath;
+
+/*!
+  QwtPainterCommand represents the attributes of a paint operation
+  how it is used between QPainter and QPaintDevice
+
+  It is used by QwtGraphic to record and replay paint operations
+
+  \sa QwtGraphic::commands()
+ */
+  
+class QWT_EXPORT QwtPainterCommand
+{
+public:
+    //! Type of the paint command
+    enum Type
+    {
+        //! Invalid command
+        Invalid = -1,
+
+        //! Draw a QPainterPath
+        Path,
+
+        //! Draw a QPixmap
+        Pixmap,
+
+        //! Draw a QImage
+        Image,
+
+        //! QPainter state change
+        State
+    };
+
+    //! Attributes how to paint a QPixmap 
+    struct PixmapData
+    {
+        QRectF rect;
+        QPixmap pixmap;
+        QRectF subRect;
+    };
+
+    //! Attributes how to paint a QImage 
+    struct ImageData
+    {
+        QRectF rect;
+        QImage image;
+        QRectF subRect;
+        Qt::ImageConversionFlags flags;
+    };
+
+    //! Attributes of a state change
+    struct StateData
+    {
+        QPaintEngine::DirtyFlags flags;
+
+        QPen pen;
+        QBrush brush;
+        QPointF brushOrigin;
+        QBrush backgroundBrush;
+        Qt::BGMode backgroundMode;
+        QFont font;
+        QMatrix matrix;
+        QTransform transform;
+
+        Qt::ClipOperation clipOperation;
+        QRegion clipRegion;
+        QPainterPath clipPath;
+        bool isClipEnabled;
+
+        QPainter::RenderHints renderHints;
+        QPainter::CompositionMode compositionMode;
+        qreal opacity;
+    };
+
+    QwtPainterCommand();
+    QwtPainterCommand(const QwtPainterCommand &);
+
+    QwtPainterCommand( const QPainterPath & );
+
+    QwtPainterCommand( const QRectF &rect,
+            const QPixmap &, const QRectF& subRect );
+
+    QwtPainterCommand( const QRectF &rect,
+            const QImage &, const QRectF& subRect,
+            Qt::ImageConversionFlags );
+
+    QwtPainterCommand( const QPaintEngineState & );
+
+    ~QwtPainterCommand();
+
+    QwtPainterCommand &operator=(const QwtPainterCommand & );
+
+    Type type() const;
+
+    QPainterPath *path();
+    const QPainterPath *path() const;
+
+    PixmapData* pixmapData();
+    const PixmapData* pixmapData() const;
+
+    ImageData* imageData();
+    const ImageData* imageData() const;
+
+    StateData* stateData();
+    const StateData* stateData() const;
+
+private:
+    void copy( const QwtPainterCommand & );
+    void reset();
+
+    Type d_type;
+
+    union
+    {
+        QPainterPath *d_path;
+        PixmapData *d_pixmapData;
+        ImageData *d_imageData;
+        StateData *d_stateData;
+    };
+};
+
+//! \return Type of the command
+inline QwtPainterCommand::Type QwtPainterCommand::type() const
+{
+    return d_type;
+}
+
+//! \return Painter path to be painted
+inline const QPainterPath *QwtPainterCommand::path() const
+{
+    return d_path;
+}
+
+//! \return Attributes how to paint a QPixmap
+inline const QwtPainterCommand::PixmapData* 
+QwtPainterCommand::pixmapData() const
+{
+    return d_pixmapData;
+}
+
+//! \return Attributes how to paint a QImage
+inline const QwtPainterCommand::ImageData * 
+QwtPainterCommand::imageData() const
+{
+    return d_imageData;
+}
+
+//! \return Attributes of a state change
+inline const QwtPainterCommand::StateData * 
+QwtPainterCommand::stateData() const
+{
+    return d_stateData;
+}
+
+#endif
Index: trunk/BNC/qwt/qwt_panner.cpp
===================================================================
--- trunk/BNC/qwt/qwt_panner.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_panner.cpp	(revision 8127)
@@ -10,4 +10,5 @@
 #include "qwt_panner.h"
 #include "qwt_picker.h"
+#include "qwt_painter.h"
 #include <qpainter.h>
 #include <qpixmap.h>
@@ -23,11 +24,7 @@
     for ( int i = 0; i < children.size(); i++ )
     {
-        QObject *obj = children[i];
-        if ( obj->inherits( "QwtPicker" ) )
-        {
-            QwtPicker *picker = ( QwtPicker * )obj;
-            if ( picker->isEnabled() )
-                pickers += picker;
-        }
+        QwtPicker *picker = qobject_cast<QwtPicker *>( children[i] );
+        if ( picker && picker->isEnabled() )
+            pickers += picker;
     }
 
@@ -40,7 +37,7 @@
     PrivateData():
         button( Qt::LeftButton ),
-        buttonState( Qt::NoButton ),
+        buttonModifiers( Qt::NoModifier ),
         abortKey( Qt::Key_Escape ),
-        abortKeyState( Qt::NoButton ),
+        abortKeyModifiers( Qt::NoModifier ),
 #ifndef QT_NO_CURSOR
         cursor( NULL ),
@@ -61,8 +58,9 @@
     }
 
-    int button;
-    int buttonState;
+    Qt::MouseButton button;
+    Qt::KeyboardModifiers  buttonModifiers;
+
     int abortKey;
-    int abortKeyState;
+    Qt::KeyboardModifiers abortKeyModifiers;
 
     QPoint initialPos;
@@ -106,38 +104,42 @@
 
 /*!
-   Change the mouse button
-   The defaults are Qt::LeftButton and Qt::NoButton
-*/
-void QwtPanner::setMouseButton( int button, int buttonState )
+   Change the mouse button and modifiers used for panning
+   The defaults are Qt::LeftButton and Qt::NoModifier
+*/
+void QwtPanner::setMouseButton( Qt::MouseButton button,
+    Qt::KeyboardModifiers modifiers )
 {
     d_data->button = button;
-    d_data->buttonState = buttonState;
-}
-
-//! Get the mouse button
-void QwtPanner::getMouseButton( int &button, int &buttonState ) const
+    d_data->buttonModifiers = modifiers;
+}
+
+//! Get mouse button and modifiers used for panning
+void QwtPanner::getMouseButton( Qt::MouseButton &button,
+    Qt::KeyboardModifiers &modifiers ) const
 {
     button = d_data->button;
-    buttonState = d_data->buttonState;
+    modifiers = d_data->buttonModifiers;
 }
 
 /*!
    Change the abort key
-   The defaults are Qt::Key_Escape and Qt::NoButton
+   The defaults are Qt::Key_Escape and Qt::NoModifiers
 
    \param key Key ( See Qt::Keycode )
-   \param state State
-*/
-void QwtPanner::setAbortKey( int key, int state )
+   \param modifiers Keyboard modifiers
+*/
+void QwtPanner::setAbortKey( int key, 
+    Qt::KeyboardModifiers modifiers )
 {
     d_data->abortKey = key;
-    d_data->abortKeyState = state;
-}
-
-//! Get the abort key
-void QwtPanner::getAbortKey( int &key, int &state ) const
+    d_data->abortKeyModifiers = modifiers;
+}
+
+//! Get the abort key and modifiers
+void QwtPanner::getAbortKey( int &key, 
+    Qt::KeyboardModifiers &modifiers ) const
 {
     key = d_data->abortKey;
-    state = d_data->abortKeyState;
+    modifiers = d_data->abortKeyModifiers;
 }
 
@@ -223,5 +225,5 @@
 
 /*!
-   Return true if a orientatio is enabled
+   \return True if an orientation is enabled
    \sa orientations(), setOrientations()
 */
@@ -257,5 +259,5 @@
 
     QPixmap pm( size() );
-    pm.fill( parentWidget(), 0, 0 );
+    QwtPainter::fillPixmap( parentWidget(), pm );
 
     QPainter painter( &pm );
@@ -298,8 +300,13 @@
 /*!
   Grab the widget into a pixmap.
+  \return Grabbed pixmap
 */
 QPixmap QwtPanner::grab() const
 {
+#if QT_VERSION >= 0x050000
+    return parentWidget()->grab( parentWidget()->rect() );
+#else
     return QPixmap::grabWidget( parentWidget() );
+#endif
 }
 
@@ -307,9 +314,13 @@
   \brief Event filter
 
-  When isEnabled() the mouse events of the observed widget are filtered.
+  When isEnabled() is true mouse events of the
+  observed widget are filtered.
 
   \param object Object to be filtered
   \param event Event
 
+  \return Always false, beside for paint events for the
+          parent widget.
+
   \sa widgetMousePressEvent(), widgetMouseReleaseEvent(),
       widgetMouseMoveEvent()
@@ -324,25 +335,25 @@
         case QEvent::MouseButtonPress:
         {
-            widgetMousePressEvent( ( QMouseEvent * )event );
+            widgetMousePressEvent( static_cast<QMouseEvent *>( event ) );
             break;
         }
         case QEvent::MouseMove:
         {
-            widgetMouseMoveEvent( ( QMouseEvent * )event );
+            widgetMouseMoveEvent( static_cast<QMouseEvent *>( event ) );
             break;
         }
         case QEvent::MouseButtonRelease:
         {
-            widgetMouseReleaseEvent( ( QMouseEvent * )event );
+            widgetMouseReleaseEvent( static_cast<QMouseEvent *>( event ) );
             break;
         }
         case QEvent::KeyPress:
         {
-            widgetKeyPressEvent( ( QKeyEvent * )event );
+            widgetKeyPressEvent( static_cast<QKeyEvent *>( event ) );
             break;
         }
         case QEvent::KeyRelease:
         {
-            widgetKeyReleaseEvent( ( QKeyEvent * )event );
+            widgetKeyReleaseEvent( static_cast<QKeyEvent *>( event ) );
             break;
         }
@@ -368,6 +379,9 @@
 void QwtPanner::widgetMousePressEvent( QMouseEvent *mouseEvent )
 {
-    if ( mouseEvent->button() != d_data->button )
+    if ( ( mouseEvent->button() != d_data->button )
+        || ( mouseEvent->modifiers() != d_data->buttonModifiers ) )
+    {
         return;
+    }
 
     QWidget *w = parentWidget();
@@ -375,10 +389,4 @@
         return;
 
-    if ( ( mouseEvent->modifiers() & Qt::KeyboardModifierMask ) !=
-        ( int )( d_data->buttonState & Qt::KeyboardModifierMask ) )
-    {
-        return;
-    }
-
 #ifndef QT_NO_CURSOR
     showCursor( true );
@@ -391,5 +399,5 @@
     // We don't want to grab the picker !
     QVector<QwtPicker *> pickers = qwtActivePickers( parentWidget() );
-    for ( int i = 0; i < ( int )pickers.size(); i++ )
+    for ( int i = 0; i < pickers.size(); i++ )
         pickers[i]->setEnabled( false );
 
@@ -397,5 +405,5 @@
     d_data->contentsMask = contentsMask();
 
-    for ( int i = 0; i < ( int )pickers.size(); i++ )
+    for ( int i = 0; i < pickers.size(); i++ )
         pickers[i]->setEnabled( true );
 
@@ -472,17 +480,13 @@
 void QwtPanner::widgetKeyPressEvent( QKeyEvent *keyEvent )
 {
-    if ( keyEvent->key() == d_data->abortKey )
-    {
-        const bool matched =
-            ( keyEvent->modifiers() & Qt::KeyboardModifierMask ) ==
-                ( int )( d_data->abortKeyState & Qt::KeyboardModifierMask );
-        if ( matched )
-        {
-            hide();
-#ifndef QT_NO_CURSOR
-            showCursor( false );
-#endif
-            d_data->pixmap = QPixmap();
-        }
+    if ( ( keyEvent->key() == d_data->abortKey )
+        && ( keyEvent->modifiers() == d_data->abortKeyModifiers ) )
+    {
+        hide();
+
+#ifndef QT_NO_CURSOR
+        showCursor( false );
+#endif
+        d_data->pixmap = QPixmap();
     }
 }
Index: trunk/BNC/qwt/qwt_panner.h
===================================================================
--- trunk/BNC/qwt/qwt_panner.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_panner.h	(revision 8127)
@@ -44,8 +44,11 @@
     bool isEnabled() const;
 
-    void setMouseButton( int button, int buttonState = Qt::NoButton );
-    void getMouseButton( int &button, int &buttonState ) const;
-    void setAbortKey( int key, int state = Qt::NoButton );
-    void getAbortKey( int &key, int &state ) const;
+    void setMouseButton( Qt::MouseButton, 
+        Qt::KeyboardModifiers = Qt::NoModifier );
+    void getMouseButton( Qt::MouseButton &button, 
+        Qt::KeyboardModifiers & ) const;
+
+    void setAbortKey( int key, Qt::KeyboardModifiers = Qt::NoModifier );
+    void getAbortKey( int &key, Qt::KeyboardModifiers & ) const;
 
     void setCursor( const QCursor & );
Index: trunk/BNC/qwt/qwt_picker.cpp
===================================================================
--- trunk/BNC/qwt/qwt_picker.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_picker.cpp	(revision 8127)
@@ -12,4 +12,5 @@
 #include "qwt_painter.h"
 #include "qwt_math.h"
+#include "qwt_widget_overlay.h"
 #include <qapplication.h>
 #include <qevent.h>
@@ -22,33 +23,87 @@
 #include <qmath.h>
 
-class QwtPicker::PickerWidget: public QWidget
+static inline QRegion qwtMaskRegion( const QRect &r, int penWidth )
+{
+    const int pw = qMax( penWidth, 1 );
+    const int pw2 = penWidth / 2;
+
+    int x1 = r.left() - pw2;
+    int x2 = r.right() + 1 + pw2 + ( pw % 2 );
+
+    int y1 = r.top() - pw2;
+    int y2 = r.bottom() + 1 + pw2 + ( pw % 2 );
+
+    QRegion region;
+
+    region += QRect( x1, y1, x2 - x1, pw );
+    region += QRect( x1, y1, pw, y2 - y1 );
+    region += QRect( x1, y2 - pw, x2 - x1, pw );
+    region += QRect( x2 - pw, y1, pw, y2 - y1 );
+
+    return region;
+}
+
+static inline QRegion qwtMaskRegion( const QLine &l, int penWidth )
+{
+    const int pw = qMax( penWidth, 1 );
+    const int pw2 = penWidth / 2;
+
+    QRegion region;
+
+    if ( l.x1() == l.x2() )
+    {
+        region += QRect( l.x1() - pw2, l.y1(), 
+            pw, l.y2() ).normalized();
+    }
+    else if ( l.y1() == l.y2() )
+    {
+        region += QRect( l.x1(), l.y1() - pw2, 
+            l.x2(), pw ).normalized();
+    }
+
+    return region;
+}
+
+class QwtPickerRubberband: public QwtWidgetOverlay
 {
 public:
-    enum Type
-    {
-        RubberBand,
-        Text
-    };
-
-    PickerWidget( QwtPicker *, QWidget *, Type );
-    void updateMask();
-
-    /*
-       For a tracker text with a background we can use the background
-       rect as mask. Also for "regular" Qt widgets >= 4.3.0 we
-       don't need to mask the text anymore.
-     */
-    bool d_hasTextMask;
+    QwtPickerRubberband( QwtPicker *, QWidget * );
 
 protected:
-    virtual void paintEvent( QPaintEvent * );
+    virtual void drawOverlay( QPainter * ) const;
+    virtual QRegion maskHint() const;
 
     QwtPicker *d_picker;
-    Type d_type;
 };
 
+class QwtPickerTracker: public QwtWidgetOverlay
+{                                  
+public:
+    QwtPickerTracker( QwtPicker *, QWidget * );
+    
+protected:
+    virtual void drawOverlay( QPainter * ) const;
+    virtual QRegion maskHint() const;
+    
+    QwtPicker *d_picker;
+};  
+
+
 class QwtPicker::PrivateData
 {
 public:
+    PrivateData():
+        enabled( false ),
+        stateMachine( NULL ),
+        resizeMode( QwtPicker::Stretch ),
+        rubberBand( QwtPicker::NoRubberBand ),
+        trackerMode( QwtPicker::AlwaysOff ),
+        isActive( false ),
+        trackerPosition( -1, -1 ),
+        mouseTracking( false ),
+        openGL( false )
+    {
+    }
+        
     bool enabled;
 
@@ -70,129 +125,46 @@
     bool mouseTracking; // used to save previous value
 
-    /*
-      On X11 the widget below the picker widgets gets paint events
-      with a region that is the bounding rect of the mask, if it is complex.
-      In case of (f.e) a CrossRubberBand and a text this creates complete
-      repaints of the widget. So we better use two different widgets.
-     */
-
-    QPointer<PickerWidget> rubberBandWidget;
-    QPointer<PickerWidget> trackerWidget;
+    QPointer< QwtPickerRubberband > rubberBandOverlay;
+    QPointer< QwtPickerTracker> trackerOverlay;
+
+    bool openGL;
 };
 
-QwtPicker::PickerWidget::PickerWidget(
-        QwtPicker *picker, QWidget *parent, Type type ):
-    QWidget( parent ),
-    d_hasTextMask( false ),
-    d_picker( picker ),
-    d_type( type )
-{
-    setAttribute( Qt::WA_TransparentForMouseEvents );
-    setAttribute( Qt::WA_NoSystemBackground );
-    setFocusPolicy( Qt::NoFocus );
-}
-
-void QwtPicker::PickerWidget::updateMask()
-{
-    QRegion mask;
-
-    if ( d_type == RubberBand )
-    {
-        QBitmap bm( width(), height() );
-        bm.fill( Qt::color0 );
-
-        QPainter painter( &bm );
-        QPen pen = d_picker->rubberBandPen();
-        pen.setColor( Qt::color1 );
-        painter.setPen( pen );
-
-        d_picker->drawRubberBand( &painter );
-
-        mask = QRegion( bm );
-    }
-    if ( d_type == Text )
-    {
-        d_hasTextMask = parentWidget()->testAttribute( Qt::WA_PaintOnScreen );
-
-        if ( d_hasTextMask )
-        {
-            const QwtText label = d_picker->trackerText(
-                d_picker->trackerPosition() );
-
-            if ( label.testPaintAttribute( QwtText::PaintBackground )
-                && label.backgroundBrush().style() != Qt::NoBrush )
-            {
-                if ( label.backgroundBrush().color().alpha() > 0 )
-                {
-                    // We don't need a text mask, when we have a background
-                    d_hasTextMask = false;
-                }
-            }
-        }
-
-        if ( d_hasTextMask )
-        {
-            QBitmap bm( width(), height() );
-            bm.fill( Qt::color0 );
-
-            QPainter painter( &bm );
-            painter.setFont( font() );
-
-            QPen pen = d_picker->trackerPen();
-            pen.setColor( Qt::color1 );
-            painter.setPen( pen );
-
-            d_picker->drawTracker( &painter );
-
-            mask = QRegion( bm );
-        }
-        else
-        {
-            mask = d_picker->trackerRect( font() );
-        }
-    }
-
-    QWidget *w = parentWidget();
-    if ( w && !w->testAttribute( Qt::WA_PaintOnScreen ) )
-    {
-        // The parent widget gets an update for its complete rectangle
-        // when the mask is changed in visible state.
-        // With this hide/show we only get an update for the
-        // previous mask.
-
-        hide();
-    }
-    setMask( mask );
-    setVisible( !mask.isEmpty() );
-}
-
-void QwtPicker::PickerWidget::paintEvent( QPaintEvent *e )
-{
-    QPainter painter( this );
-    painter.setClipRegion( e->region() );
-
-    if ( d_type == RubberBand )
-    {
-        painter.setPen( d_picker->rubberBandPen() );
-        d_picker->drawRubberBand( &painter );
-    }
-
-    if ( d_type == Text )
-    {
-        /*
-           If we have a text mask we simply fill the region of
-           the mask. This gives better results for antialiased fonts.
-         */
-        if ( d_hasTextMask )
-        {
-            painter.fillRect( e->rect(), 
-                QBrush( d_picker->trackerPen().color() ) );
-        }
-        else
-        {
-            painter.setPen( d_picker->trackerPen() );
-            d_picker->drawTracker( &painter );
-        }
-    }
+QwtPickerRubberband::QwtPickerRubberband(
+        QwtPicker *picker, QWidget *parent ):
+    QwtWidgetOverlay( parent ),
+    d_picker( picker )
+{
+    setMaskMode( QwtWidgetOverlay::MaskHint );
+}
+
+QRegion QwtPickerRubberband::maskHint() const
+{
+    return d_picker->rubberBandMask();
+}
+
+void QwtPickerRubberband::drawOverlay( QPainter *painter ) const
+{
+    painter->setPen( d_picker->rubberBandPen() );
+    d_picker->drawRubberBand( painter );
+}
+
+QwtPickerTracker::QwtPickerTracker(
+        QwtPicker *picker, QWidget *parent ):
+    QwtWidgetOverlay( parent ),
+    d_picker( picker )
+{
+    setMaskMode( QwtWidgetOverlay::MaskHint );
+}
+
+QRegion QwtPickerTracker::maskHint() const
+{
+    return d_picker->trackerRect( font() );
+}
+
+void QwtPickerTracker::drawOverlay( QPainter *painter ) const
+{
+    painter->setPen( d_picker->trackerPen() );
+    d_picker->drawTracker( painter );
 }
 
@@ -201,5 +173,5 @@
 
   Creates an picker that is enabled, but without a state machine.
-  rubberband and tracker are disabled.
+  rubber band and tracker are disabled.
 
   \param parent Parent widget, that will be observed
@@ -215,5 +187,5 @@
   Constructor
 
-  \param rubberBand Rubberband style
+  \param rubberBand Rubber band style
   \param trackerMode Tracker mode
   \param parent Parent widget, that will be observed
@@ -230,11 +202,13 @@
 {
     setMouseTracking( false );
+
     delete d_data->stateMachine;
-    delete d_data->rubberBandWidget;
-    delete d_data->trackerWidget;
+    delete d_data->rubberBandOverlay;
+    delete d_data->trackerOverlay;
+
     delete d_data;
 }
 
-//! Init the picker, used by the constructors
+//! Initialize the picker - used by the constructors
 void QwtPicker::init( QWidget *parent,
     RubberBand rubberBand, DisplayMode trackerMode )
@@ -242,16 +216,5 @@
     d_data = new PrivateData;
 
-    d_data->rubberBandWidget = NULL;
-    d_data->trackerWidget = NULL;
-
     d_data->rubberBand = rubberBand;
-    d_data->enabled = false;
-    d_data->resizeMode = Stretch;
-    d_data->trackerMode = AlwaysOff;
-    d_data->isActive = false;
-    d_data->trackerPosition = QPoint( -1, -1 );
-    d_data->mouseTracking = false;
-
-    d_data->stateMachine = NULL;
 
     if ( parent )
@@ -260,8 +223,11 @@
             parent->setFocusPolicy( Qt::WheelFocus );
 
+        d_data->openGL = parent->inherits( "QGLWidget" );
         d_data->trackerFont = parent->font();
         d_data->mouseTracking = parent->hasMouseTracking();
+
         setEnabled( true );
     }
+
     setTrackerMode( trackerMode );
 }
@@ -326,7 +292,7 @@
 
 /*!
-  Set the rubberband style
-
-  \param rubberBand Rubberband style
+  Set the rubber band style
+
+  \param rubberBand Rubber band style
          The default value is NoRubberBand.
 
@@ -339,5 +305,5 @@
 
 /*!
-  \return Rubberband style
+  \return Rubber band style
   \sa setRubberBand(), RubberBand, rubberBandPen()
 */
@@ -500,5 +466,5 @@
   Set the pen for the rubberband
 
-  \param pen Rubberband pen
+  \param pen Rubber band pen
   \sa rubberBandPen(), setRubberBand()
 */
@@ -513,5 +479,5 @@
 
 /*!
-  \return Rubberband pen
+  \return Rubber band pen
   \sa setRubberBandPen(), rubberBand()
 */
@@ -553,20 +519,19 @@
 
 /*!
-   Draw a rubberband, depending on rubberBand()
-
-   \param painter Painter, initialized with clip rect
-
-   \sa rubberBand(), RubberBand
-*/
-
-void QwtPicker::drawRubberBand( QPainter *painter ) const
-{
+  Calculate the mask for the rubber band overlay
+
+  \return Region for the mask
+  \sa QWidget::setMask()
+ */
+QRegion QwtPicker::rubberBandMask() const
+{
+    QRegion mask;
+
     if ( !isActive() || rubberBand() == NoRubberBand ||
         rubberBandPen().style() == Qt::NoPen )
     {
-        return;
-    }
-
-    const QRect &pRect = pickRect();
+        return mask;
+    }
+
     const QPolygon pa = adjustedPoints( d_data->pickedPoints );
 
@@ -583,21 +548,135 @@
         {
             if ( pa.count() < 1 )
+                return mask;
+
+            const QPoint pos = pa[0];
+            const int pw = rubberBandPen().width();
+
+            const QRect pRect = pickArea().boundingRect().toRect();
+            switch ( rubberBand() )
+            {
+                case VLineRubberBand:
+                {
+                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), 
+                        pos.x(), pRect.bottom() ), pw );
+                    break;
+                }
+                case HLineRubberBand:
+                {
+                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), 
+                        pRect.right(), pos.y() ), pw );
+                    break;
+                }
+                case CrossRubberBand:
+                {
+                    mask += qwtMaskRegion( QLine( pos.x(), pRect.top(), 
+                        pos.x(), pRect.bottom() ), pw );
+                    mask += qwtMaskRegion( QLine( pRect.left(), pos.y(), 
+                        pRect.right(), pos.y() ), pw );
+                    break;
+                }
+                default:
+                    break;
+            }
+            break;
+        }
+        case QwtPickerMachine::RectSelection:
+        {
+            if ( pa.count() < 2 )
+                return mask;
+
+            const int pw = rubberBandPen().width();
+
+            switch ( rubberBand() )
+            {
+                case RectRubberBand:
+                {
+                    const QRect r = QRect( pa.first(), pa.last() );
+                    mask = qwtMaskRegion( r.normalized(), pw );
+                    break;
+                }
+                case EllipseRubberBand:
+                {
+                    const QRect r = QRect( pa.first(), pa.last() );
+                    mask += r.adjusted( -pw, -pw, pw, pw );
+                    break;
+                }
+                default:
+                    break;
+            }
+            break;
+        }
+        case QwtPickerMachine::PolygonSelection:
+        {
+            const int pw = rubberBandPen().width();
+            if ( pw <= 1 )
+            {
+                // because of the join style we better
+                // return a mask for a pen width <= 1 only
+
+                const int off = 2 * pw;
+                const QRect r = pa.boundingRect();
+                mask += r.adjusted( -off, -off, off, off );
+            }
+            break;
+        }
+        default:
+            break;
+    }
+
+    return mask;
+}
+
+/*!
+   Draw a rubber band, depending on rubberBand()
+
+   \param painter Painter, initialized with a clip region
+
+   \sa rubberBand(), RubberBand
+*/
+
+void QwtPicker::drawRubberBand( QPainter *painter ) const
+{
+    if ( !isActive() || rubberBand() == NoRubberBand ||
+        rubberBandPen().style() == Qt::NoPen )
+    {
+        return;
+    }
+
+    const QPolygon pa = adjustedPoints( d_data->pickedPoints );
+
+    QwtPickerMachine::SelectionType selectionType =
+        QwtPickerMachine::NoSelection;
+
+    if ( d_data->stateMachine )
+        selectionType = d_data->stateMachine->selectionType();
+
+    switch ( selectionType )
+    {
+        case QwtPickerMachine::NoSelection:
+        case QwtPickerMachine::PointSelection:
+        {
+            if ( pa.count() < 1 )
                 return;
 
             const QPoint pos = pa[0];
 
+            const QRect pRect = pickArea().boundingRect().toRect();
             switch ( rubberBand() )
             {
                 case VLineRubberBand:
+                {
                     QwtPainter::drawLine( painter, pos.x(),
                         pRect.top(), pos.x(), pRect.bottom() );
                     break;
-
+                }
                 case HLineRubberBand:
+                {
                     QwtPainter::drawLine( painter, pRect.left(),
                         pos.y(), pRect.right(), pos.y() );
                     break;
-
+                }
                 case CrossRubberBand:
+                {
                     QwtPainter::drawLine( painter, pos.x(),
                         pRect.top(), pos.x(), pRect.bottom() );
@@ -605,4 +684,5 @@
                         pos.y(), pRect.right(), pos.y() );
                     break;
+                }
                 default:
                     break;
@@ -615,16 +695,17 @@
                 return;
 
-            const QPoint p1 = pa[0];
-            const QPoint p2 = pa[int( pa.count() - 1 )];
-
-            const QRect rect = QRect( p1, p2 ).normalized();
+            const QRect rect = QRect( pa.first(), pa.last() ).normalized();
             switch ( rubberBand() )
             {
                 case EllipseRubberBand:
+                {
                     QwtPainter::drawEllipse( painter, rect );
                     break;
+                }
                 case RectRubberBand:
+                {
                     QwtPainter::drawRect( painter, rect );
                     break;
+                }
                 default:
                     break;
@@ -694,4 +775,7 @@
     return adjusted;
 }\endverbatim\n
+
+  \param points Selected points
+  \return Selected points unmodified
 */
 QPolygon QwtPicker::adjustedPoints( const QPolygon &points ) const
@@ -773,10 +857,12 @@
     textRect.moveTopLeft( QPoint( x, y ) );
 
-    int right = qMin( textRect.right(), pickRect().right() - margin );
-    int bottom = qMin( textRect.bottom(), pickRect().bottom() - margin );
+    const QRect pickRect = pickArea().boundingRect().toRect();
+
+    int right = qMin( textRect.right(), pickRect.right() - margin );
+    int bottom = qMin( textRect.bottom(), pickRect.bottom() - margin );
     textRect.moveBottomRight( QPoint( right, bottom ) );
 
-    int left = qMax( textRect.left(), pickRect().left() + margin );
-    int top = qMax( textRect.top(), pickRect().top() + margin );
+    int left = qMax( textRect.left(), pickRect.left() + margin );
+    int top = qMax( textRect.top(), pickRect.top() + margin );
     textRect.moveTopLeft( QPoint( left, top ) );
 
@@ -787,11 +873,13 @@
   \brief Event filter
 
-  When isEnabled() == true all events of the observed widget are filtered.
+  When isEnabled() is true all events of the observed widget are filtered.
   Mouse and keyboard events are translated into widgetMouse- and widgetKey-
   and widgetWheel-events. Paint and Resize events are handled to keep
-  rubberband and tracker up to date.
+  rubber band and tracker up to date.
 
   \param object Object to be filtered
   \param event Event
+
+  \return Always false.
 
   \sa widgetEnterEvent(), widgetLeaveEvent(),
@@ -809,42 +897,69 @@
             case QEvent::Resize:
             {
-                const QResizeEvent *re = ( QResizeEvent * )event;
+                const QResizeEvent *re = static_cast<QResizeEvent *>( event );
+
+                /*
+                   Adding/deleting additional event filters inside of an event filter
+                   is not safe dues to the implementation in Qt ( changing alist while iterating ).
+                   So we create the overlays in a way, that they don't install en event filter
+                   ( parent set to NULL ) and do the resizing here.
+                 */
+                if ( d_data->trackerOverlay )
+                    d_data->trackerOverlay->resize( re->size() );
+
+                if ( d_data->rubberBandOverlay )
+                    d_data->rubberBandOverlay->resize( re->size() );
+
                 if ( d_data->resizeMode == Stretch )
                     stretchSelection( re->oldSize(), re->size() );
 
-                if ( d_data->rubberBandWidget )
-                    d_data->rubberBandWidget->resize( re->size() );
-
-                if ( d_data->trackerWidget )
-                    d_data->trackerWidget->resize( re->size() );
+                updateDisplay();
                 break;
             }
             case QEvent::Enter:
+            {
                 widgetEnterEvent( event );
                 break;
+            }
             case QEvent::Leave:
+            {
                 widgetLeaveEvent( event );
                 break;
+            }
             case QEvent::MouseButtonPress:
-                widgetMousePressEvent( ( QMouseEvent * )event );
+            {
+                widgetMousePressEvent( static_cast<QMouseEvent *>( event ) );
                 break;
+            }
             case QEvent::MouseButtonRelease:
-                widgetMouseReleaseEvent( ( QMouseEvent * )event );
+            {
+                widgetMouseReleaseEvent( static_cast<QMouseEvent *>( event ) );
                 break;
+            }
             case QEvent::MouseButtonDblClick:
-                widgetMouseDoubleClickEvent( ( QMouseEvent * )event );
+            {
+                widgetMouseDoubleClickEvent( static_cast<QMouseEvent *>( event ) );
                 break;
+            }
             case QEvent::MouseMove:
-                widgetMouseMoveEvent( ( QMouseEvent * )event );
+            {
+                widgetMouseMoveEvent( static_cast<QMouseEvent *>( event ) );
                 break;
+            }
             case QEvent::KeyPress:
-                widgetKeyPressEvent( ( QKeyEvent * )event );
+            {
+                widgetKeyPressEvent( static_cast<QKeyEvent *>( event ) );
                 break;
+            }
             case QEvent::KeyRelease:
-                widgetKeyReleaseEvent( ( QKeyEvent * )event );
+            {
+                widgetKeyReleaseEvent( static_cast<QKeyEvent *>( event ) );
                 break;
+            }
             case QEvent::Wheel:
-                widgetWheelEvent( ( QWheelEvent * )event );
+            {
+                widgetWheelEvent( static_cast<QWheelEvent *>( event ) );
                 break;
+            }
             default:
                 break;
@@ -879,5 +994,5 @@
 void QwtPicker::widgetMouseMoveEvent( QMouseEvent *mouseEvent )
 {
-    if ( pickRect().contains( mouseEvent->pos() ) )
+    if ( pickArea().contains( mouseEvent->pos() ) )
         d_data->trackerPosition = mouseEvent->pos();
     else
@@ -923,5 +1038,5 @@
 
 /*!
-  Handle a mouse relase event for the observed widget.
+  Handle a mouse release event for the observed widget.
 
   \param mouseEvent Mouse event
@@ -964,5 +1079,5 @@
 void QwtPicker::widgetWheelEvent( QWheelEvent *wheelEvent )
 {
-    if ( pickRect().contains( wheelEvent->pos() ) )
+    if ( pickArea().contains( wheelEvent->pos() ) )
         d_data->trackerPosition = wheelEvent->pos();
     else
@@ -1014,5 +1129,5 @@
     if ( dx != 0 || dy != 0 )
     {
-        const QRect rect = pickRect();
+        const QRect rect = pickArea().boundingRect().toRect();
         const QPoint pos = parentWidget()->mapFromGlobal( QCursor::pos() );
 
@@ -1048,5 +1163,5 @@
   Passes an event to the state machine and executes the resulting
   commands. Append and Move commands use the current position
-  of the cursor (QCursor::pos()).
+  of the cursor ( QCursor::pos() ).
 
   \param event Event
@@ -1177,5 +1292,5 @@
 
 /*!
-   Reset the state machine and terminate (end(false)) the selection
+   Reset the state machine and terminate ( end(false) ) the selection
 */
 void QwtPicker::reset()
@@ -1189,5 +1304,5 @@
 
 /*!
-  Append a point to the selection and update rubberband and tracker.
+  Append a point to the selection and update rubber band and tracker.
   The appended() signal is emitted.
 
@@ -1259,9 +1374,9 @@
 
 /*!
-  \brief Validate and fixup the selection
+  \brief Validate and fix up the selection
 
   Accepts all selections unmodified
 
-  \param selection Selection to validate and fixup
+  \param selection Selection to validate and fix up
   \return true, when accepted, false otherwise
 */
@@ -1359,14 +1474,16 @@
   \return parentWidget()->contentsRect() 
 */
-QRect QwtPicker::pickRect() const
-{
+QPainterPath QwtPicker::pickArea() const
+{
+    QPainterPath path;
+
     const QWidget *widget = parentWidget();
     if ( widget )
-        return widget->contentsRect();
-
-    return QRect();
-}
-
-//! Update the state of rubberband and tracker label
+        path.addRect( widget->contentsRect() );
+
+    return path;
+}
+
+//! Update the state of rubber band and tracker label
 void QwtPicker::updateDisplay()
 {
@@ -1375,4 +1492,5 @@
     bool showRubberband = false;
     bool showTracker = false;
+
     if ( w && w->isVisible() && d_data->enabled )
     {
@@ -1386,49 +1504,90 @@
             ( trackerMode() == ActiveOnly && isActive() ) )
         {
-            if ( trackerPen() != Qt::NoPen )
+            if ( trackerPen() != Qt::NoPen 
+                && !trackerRect( QFont() ).isEmpty() )
+            {
                 showTracker = true;
-        }
-    }
-
-    QPointer<PickerWidget> &rw = d_data->rubberBandWidget;
+            }
+        }
+    }
+
+    QPointer< QwtPickerRubberband > &rw = d_data->rubberBandOverlay;
     if ( showRubberband )
     {
         if ( rw.isNull() )
         {
-            rw = new PickerWidget( this, w, PickerWidget::RubberBand );
+            rw = new QwtPickerRubberband( this, NULL ); // NULL -> no extra event filter
+            rw->setObjectName( "PickerRubberBand" );
+            rw->setParent( w );
             rw->resize( w->size() );
         }
-        rw->updateMask();
-        rw->update(); // Needed, when the mask doesn't change
+
+        if ( d_data->rubberBand <= RectRubberBand )
+            rw->setMaskMode( QwtWidgetOverlay::MaskHint );
+        else
+            rw->setMaskMode( QwtWidgetOverlay::AlphaMask );
+
+        rw->updateOverlay();
     }
     else
-        delete rw;
-
-    QPointer<PickerWidget> &tw = d_data->trackerWidget;
+    {
+        if ( d_data->openGL )
+        {
+            // Qt 4.8 crashes for a delete
+            if ( !rw.isNull() )
+            {
+                rw->hide();
+                rw->deleteLater();
+                rw = NULL;
+            }
+        }
+        else
+        {
+            delete rw;
+        }
+    }
+
+    QPointer< QwtPickerTracker > &tw = d_data->trackerOverlay;
     if ( showTracker )
     {
         if ( tw.isNull() )
         {
-            tw = new PickerWidget( this, w, PickerWidget::Text );
+            tw = new QwtPickerTracker( this, NULL ); // NULL -> no extra event filter
+            tw->setObjectName( "PickerTracker" );
+            tw->setParent( w );
             tw->resize( w->size() );
         }
         tw->setFont( d_data->trackerFont );
-        tw->updateMask();
-        tw->update(); // Needed, when the mask doesn't change
+        tw->updateOverlay();
     }
     else
-        delete tw;
-}
-
-//! \return Widget displaying the rubberband
-const QWidget *QwtPicker::rubberBandWidget() const
-{
-    return d_data->rubberBandWidget;
-}
-
-//! \return Widget displaying the tracker text
-const QWidget *QwtPicker::trackerWidget() const
-{
-    return d_data->trackerWidget;
-}
-
+    {
+        if ( d_data->openGL )
+        {
+            // Qt 4.8 crashes for a delete
+            if ( !tw.isNull() )
+            {
+                tw->hide();
+                tw->deleteLater();
+                tw = NULL;
+            }
+        }
+        else
+        {
+            delete tw;
+        }
+    }
+}
+
+//! \return Overlay displaying the rubber band
+const QwtWidgetOverlay *QwtPicker::rubberBandOverlay() const
+{
+    return d_data->rubberBandOverlay;
+}
+
+//! \return Overlay displaying the tracker text
+const QwtWidgetOverlay *QwtPicker::trackerOverlay() const
+{
+    return d_data->trackerOverlay;
+}
+
Index: trunk/BNC/qwt/qwt_picker.h
===================================================================
--- trunk/BNC/qwt/qwt_picker.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_picker.h	(revision 8127)
@@ -18,4 +18,5 @@
 #include <qfont.h>
 #include <qrect.h>
+#include <qpainterpath.h>
 
 class QWidget;
@@ -24,4 +25,5 @@
 class QKeyEvent;
 class QwtPickerMachine;
+class QwtWidgetOverlay;
 
 /*!
@@ -48,10 +50,10 @@
 
   QwtPicker translates the picked points into a selection using the
-  adjustedPoints method. adjustedPoints is intended to be reimplemented
-  to fixup the selection according to application specific requirements.
+  adjustedPoints() method. adjustedPoints() is intended to be reimplemented
+  to fix up the selection according to application specific requirements.
   (F.e. when an application accepts rectangles of a fixed aspect ratio only.)
 
   Optionally QwtPicker support the process of collecting points by a
-  rubberband and tracker displaying a text for the current mouse
+  rubber band and tracker displaying a text for the current mouse
   position.
 
@@ -79,5 +81,5 @@
 
   The picker is active (isActive()), between begin() and end().
-  In active state the rubberband is displayed, and the tracker is visible
+  In active state the rubber band is displayed, and the tracker is visible
   in case of trackerMode is ActiveOnly or AlwaysOn.
 
@@ -95,7 +97,5 @@
     Q_OBJECT
 
-    Q_ENUMS( RubberBand )
-    Q_ENUMS( DisplayMode )
-    Q_ENUMS( ResizeMode )
+    Q_ENUMS( RubberBand DisplayMode ResizeMode )
 
     Q_PROPERTY( bool isEnabled READ isEnabled WRITE setEnabled )
@@ -111,5 +111,5 @@
 public:
     /*!
-      Rubberband style
+      Rubber band style
 
       The default value is QwtPicker::NoRubberBand.
@@ -122,20 +122,20 @@
         NoRubberBand = 0,
 
-        //! A horizontal line ( only for QwtPicker::PointSelection )
+        //! A horizontal line ( only for QwtPickerMachine::PointSelection )
         HLineRubberBand,
 
-        //! A vertical line ( only for QwtPicker::PointSelection )
+        //! A vertical line ( only for QwtPickerMachine::PointSelection )
         VLineRubberBand,
 
-        //! A crosshair ( only for QwtPicker::PointSelection )
+        //! A crosshair ( only for QwtPickerMachine::PointSelection )
         CrossRubberBand,
 
-        //! A rectangle ( only for QwtPicker::RectSelection )
+        //! A rectangle ( only for QwtPickerMachine::RectSelection )
         RectRubberBand,
 
-        //! An ellipse ( only for QwtPicker::RectSelection )
+        //! An ellipse ( only for QwtPickerMachine::RectSelection )
         EllipseRubberBand,
 
-        //! A polygon ( only for QwtPicker::&PolygonSelection )
+        //! A polygon ( only for QwtPickerMachine::PolygonSelection )
         PolygonRubberBand,
 
@@ -216,8 +216,10 @@
     const QWidget *parentWidget() const;
 
-    virtual QRect pickRect() const;
+    virtual QPainterPath pickArea() const;
 
     virtual void drawRubberBand( QPainter * ) const;
     virtual void drawTracker( QPainter * ) const;
+
+    virtual QRegion rubberBandMask() const;
 
     virtual QwtText trackerText( const QPoint &pos ) const;
@@ -269,4 +271,5 @@
       selection has been removed.
 
+      \param pos Position of the point, that has been removed
       \sa remove(), appended()
     */
@@ -310,6 +313,6 @@
     virtual void updateDisplay();
 
-    const QWidget *rubberBandWidget() const;
-    const QWidget *trackerWidget() const;
+    const QwtWidgetOverlay *rubberBandOverlay() const;
+    const QwtWidgetOverlay *trackerOverlay() const;
 
     const QPolygon &pickedPoints() const;
@@ -320,5 +323,4 @@
     void setMouseTracking( bool );
 
-    class PickerWidget;
     class PrivateData;
     PrivateData *d_data;
Index: trunk/BNC/qwt/qwt_picker_machine.cpp
===================================================================
--- trunk/BNC/qwt/qwt_picker_machine.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_picker_machine.cpp	(revision 8127)
@@ -98,14 +98,14 @@
 //! Transition
 QList<QwtPickerMachine::Command> QwtPickerClickPointMachine::transition(
-    const QwtEventPattern &eventPattern, const QEvent *e )
-{
-    QList<QwtPickerMachine::Command> cmdList;
-
-    switch ( e->type() )
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch ( event->type() )
     {
         case QEvent::MouseButtonPress:
         {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 cmdList += Begin;
@@ -117,10 +117,13 @@
         case QEvent::KeyPress:
         {
-            if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
-            {
-                cmdList += Begin;
-                cmdList += Append;
-                cmdList += End;
+            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
+            {
+                if ( !keyEvent->isAutoRepeat() )
+                {
+                    cmdList += Begin;
+                    cmdList += Append;
+                    cmdList += End;
+                }
             }
             break;
@@ -141,14 +144,14 @@
 //! Transition
 QList<QwtPickerMachine::Command> QwtPickerDragPointMachine::transition(
-    const QwtEventPattern &eventPattern, const QEvent *e )
-{
-    QList<QwtPickerMachine::Command> cmdList;
-
-    switch ( e->type() )
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch ( event->type() )
     {
         case QEvent::MouseButtonPress:
         {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 if ( state() == 0 )
@@ -179,17 +182,20 @@
         case QEvent::KeyPress:
         {
-            if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
-            {
-                if ( state() == 0 )
-                {
-                    cmdList += Begin;
-                    cmdList += Append;
-                    setState( 1 );
-                }
-                else
-                {
-                    cmdList += End;
-                    setState( 0 );
+            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
+            {
+                if ( !keyEvent->isAutoRepeat() )
+                {
+                    if ( state() == 0 )
+                    {
+                        cmdList += Begin;
+                        cmdList += Append;
+                        setState( 1 );
+                    }
+                    else
+                    {
+                        cmdList += End;
+                        setState( 0 );
+                    }
                 }
             }
@@ -211,14 +217,14 @@
 //! Transition
 QList<QwtPickerMachine::Command> QwtPickerClickRectMachine::transition(
-    const QwtEventPattern &eventPattern, const QEvent *e )
-{
-    QList<QwtPickerMachine::Command> cmdList;
-
-    switch ( e->type() )
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch ( event->type() )
     {
         case QEvent::MouseButtonPress:
         {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 switch ( state() )
@@ -243,4 +249,5 @@
                 }
             }
+            break;
         }
         case QEvent::MouseMove:
@@ -253,6 +260,6 @@
         case QEvent::MouseButtonRelease:
         {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 if ( state() == 1 )
@@ -266,6 +273,57 @@
         case QEvent::KeyPress:
         {
-            if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
+            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
+            {
+                if ( !keyEvent->isAutoRepeat() )
+                {
+                    if ( state() == 0 )
+                    {
+                        cmdList += Begin;
+                        cmdList += Append;
+                        setState( 1 );
+                    }
+                    else
+                    {
+                        if ( state() == 1 )
+                        {
+                            cmdList += Append;
+                            setState( 2 );
+                        }
+                        else if ( state() == 2 )
+                        {
+                            cmdList += End;
+                            setState( 0 );
+                        }
+                    }
+                }
+            }
+            break;
+        }
+        default:
+            break;
+    }
+
+    return cmdList;
+}
+
+//! Constructor
+QwtPickerDragRectMachine::QwtPickerDragRectMachine():
+    QwtPickerMachine( RectSelection )
+{
+}
+
+//! Transition
+QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch ( event->type() )
+    {
+        case QEvent::MouseButtonPress:
+        {
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 if ( state() == 0 )
@@ -273,14 +331,127 @@
                     cmdList += Begin;
                     cmdList += Append;
+                    cmdList += Append;
+                    setState( 2 );
+                }
+            }
+            break;
+        }
+        case QEvent::MouseMove:
+        case QEvent::Wheel:
+        {
+            if ( state() != 0 )
+                cmdList += Move;
+            break;
+        }
+        case QEvent::MouseButtonRelease:
+        {
+            if ( state() == 2 )
+            {
+                cmdList += End;
+                setState( 0 );
+            }
+            break;
+        }
+        case QEvent::KeyPress:
+        {
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, 
+                static_cast<const QKeyEvent *> ( event ) ) )
+            {
+                if ( state() == 0 )
+                {
+                    cmdList += Begin;
+                    cmdList += Append;
+                    cmdList += Append;
+                    setState( 2 );
+                }
+                else
+                {
+                    cmdList += End;
+                    setState( 0 );
+                }
+            }
+            break;
+        }
+        default:
+            break;
+    }
+
+    return cmdList;
+}
+
+//! Constructor
+QwtPickerPolygonMachine::QwtPickerPolygonMachine():
+    QwtPickerMachine( PolygonSelection )
+{
+}
+
+//! Transition
+QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch ( event->type() )
+    {
+        case QEvent::MouseButtonPress:
+        {
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1, 
+                static_cast<const QMouseEvent *>( event ) ) )
+            {
+                if ( state() == 0 )
+                {
+                    cmdList += Begin;
+                    cmdList += Append;
+                    cmdList += Append;
                     setState( 1 );
                 }
                 else
                 {
+                    cmdList += Append;
+                }
+            }
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect2, 
+                static_cast<const QMouseEvent *>( event ) ) )
+            {
+                if ( state() == 1 )
+                {
+                    cmdList += End;
+                    setState( 0 );
+                }
+            }
+            break;
+        }
+        case QEvent::MouseMove:
+        case QEvent::Wheel:
+        {
+            if ( state() != 0 )
+                cmdList += Move;
+            break;
+        }
+        case QEvent::KeyPress:
+        {
+            const QKeyEvent *keyEvent = static_cast<const QKeyEvent *> ( event );
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1, keyEvent ) )
+            {
+                if ( !keyEvent->isAutoRepeat() )
+                {
+                    if ( state() == 0 )
+                    {
+                        cmdList += Begin;
+                        cmdList += Append;
+                        cmdList += Append;
+                        setState( 1 );
+                    }
+                    else
+                    {
+                        cmdList += Append;
+                    }
+                }
+            }
+            else if ( eventPattern.keyMatch( QwtEventPattern::KeySelect2, keyEvent ) )
+            {
+                if ( !keyEvent->isAutoRepeat() )
+                {
                     if ( state() == 1 )
-                    {
-                        cmdList += Append;
-                        setState( 2 );
-                    }
-                    else if ( state() == 2 )
                     {
                         cmdList += End;
@@ -299,21 +470,21 @@
 
 //! Constructor
-QwtPickerDragRectMachine::QwtPickerDragRectMachine():
-    QwtPickerMachine( RectSelection )
-{
-}
-
-//! Transition
-QList<QwtPickerMachine::Command> QwtPickerDragRectMachine::transition(
-    const QwtEventPattern &eventPattern, const QEvent *e )
-{
-    QList<QwtPickerMachine::Command> cmdList;
-
-    switch ( e->type() )
+QwtPickerDragLineMachine::QwtPickerDragLineMachine():
+    QwtPickerMachine( PolygonSelection )
+{
+}
+
+//! Transition
+QList<QwtPickerMachine::Command> QwtPickerDragLineMachine::transition(
+    const QwtEventPattern &eventPattern, const QEvent *event )
+{
+    QList<QwtPickerMachine::Command> cmdList;
+
+    switch( event->type() )
     {
         case QEvent::MouseButtonPress:
         {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
+            if ( eventPattern.mouseMatch( QwtEventPattern::MouseSelect1,
+                static_cast<const QMouseEvent *>( event ) ) )
             {
                 if ( state() == 0 )
@@ -322,5 +493,25 @@
                     cmdList += Append;
                     cmdList += Append;
-                    setState( 2 );
+                    setState( 1 );
+                }
+            }
+            break;
+        }
+        case QEvent::KeyPress:
+        {
+            if ( eventPattern.keyMatch( QwtEventPattern::KeySelect1,
+                static_cast<const QKeyEvent *> ( event ) ) )
+            {
+                if ( state() == 0 )
+                {
+                    cmdList += Begin;
+                    cmdList += Append;
+                    cmdList += Append;
+                    setState( 1 );
+                }
+                else
+                {
+                    cmdList += End;
+                    setState( 0 );
                 }
             }
@@ -332,119 +523,19 @@
             if ( state() != 0 )
                 cmdList += Move;
+
             break;
         }
         case QEvent::MouseButtonRelease:
         {
-            if ( state() == 2 )
+            if ( state() != 0 )
             {
                 cmdList += End;
                 setState( 0 );
             }
-            break;
-        }
-        case QEvent::KeyPress:
-        {
-            if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
-            {
-                if ( state() == 0 )
-                {
-                    cmdList += Begin;
-                    cmdList += Append;
-                    cmdList += Append;
-                    setState( 2 );
-                }
-                else
-                {
-                    cmdList += End;
-                    setState( 0 );
-                }
-            }
-            break;
-        }
-        default:
-            break;
-    }
-
-    return cmdList;
-}
-
-//! Constructor
-QwtPickerPolygonMachine::QwtPickerPolygonMachine():
-    QwtPickerMachine( PolygonSelection )
-{
-}
-
-//! Transition
-QList<QwtPickerMachine::Command> QwtPickerPolygonMachine::transition(
-    const QwtEventPattern &eventPattern, const QEvent *e )
-{
-    QList<QwtPickerMachine::Command> cmdList;
-
-    switch ( e->type() )
-    {
-        case QEvent::MouseButtonPress:
-        {
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect1, ( const QMouseEvent * )e ) )
-            {
-                if ( state() == 0 )
-                {
-                    cmdList += Begin;
-                    cmdList += Append;
-                    cmdList += Append;
-                    setState( 1 );
-                }
-                else
-                {
-                    cmdList += End;
-                    setState( 0 );
-                }
-            }
-            if ( eventPattern.mouseMatch(
-                QwtEventPattern::MouseSelect2, ( const QMouseEvent * )e ) )
-            {
-                if ( state() == 1 )
-                    cmdList += Append;
-            }
-            break;
-        }
-        case QEvent::MouseMove:
-        case QEvent::Wheel:
-        {
-            if ( state() != 0 )
-                cmdList += Move;
-            break;
-        }
-        case QEvent::KeyPress:
-        {
-            if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect1, ( const QKeyEvent * )e ) )
-            {
-                if ( state() == 0 )
-                {
-                    cmdList += Begin;
-                    cmdList += Append;
-                    cmdList += Append;
-                    setState( 1 );
-                }
-                else
-                {
-                    cmdList += End;
-                    setState( 0 );
-                }
-            }
-            else if ( eventPattern.keyMatch(
-                QwtEventPattern::KeySelect2, ( const QKeyEvent * )e ) )
-            {
-                if ( state() == 1 )
-                    cmdList += Append;
-            }
-            break;
-        }
-        default:
-            break;
-    }
-
-    return cmdList;
-}
+        }
+        default:
+            break;
+    }
+
+    return cmdList;
+}
Index: trunk/BNC/qwt/qwt_picker_machine.h
===================================================================
--- trunk/BNC/qwt/qwt_picker_machine.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_picker_machine.h	(revision 8127)
@@ -169,4 +169,28 @@
 
 /*!
+  \brief A state machine for line selections
+    
+  Pressing QwtEventPattern::MouseSelect1 selects
+  the first point, releasing it the second point.
+  Pressing QwtEventPattern::KeySelect1 also selects the
+  first point, a second press selects the second point and terminates
+  the selection.
+
+  A common use case of QwtPickerDragLineMachine are pickers for
+  distance measurements.
+  
+  \sa QwtEventPattern::MousePatternCode, QwtEventPattern::KeyPatternCode
+*/              
+                    
+class QWT_EXPORT QwtPickerDragLineMachine: public QwtPickerMachine
+{
+public:
+    QwtPickerDragLineMachine();
+
+    virtual QList<Command> transition(
+        const QwtEventPattern &, const QEvent * );
+};
+
+/*!
   \brief A state machine for polygon selections
 
Index: trunk/BNC/qwt/qwt_pixel_matrix.cpp
===================================================================
--- trunk/BNC/qwt/qwt_pixel_matrix.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_pixel_matrix.cpp	(revision 8127)
@@ -0,0 +1,51 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_pixel_matrix.h"
+
+/*!
+  \brief Constructor
+
+  \param rect Bounding rectangle for the matrix
+*/
+QwtPixelMatrix::QwtPixelMatrix( const QRect& rect ):
+    QBitArray( qMax( rect.width() * rect.height(), 0 ) ),
+    d_rect( rect )
+{
+}
+
+//! Destructor
+QwtPixelMatrix::~QwtPixelMatrix()
+{
+}
+
+/*!
+    Set the bounding rectangle of the matrix
+
+    \param rect Bounding rectangle
+
+    \note All bits are cleared
+ */
+void QwtPixelMatrix::setRect( const QRect& rect )
+{
+    if ( rect != d_rect )
+    {
+        d_rect = rect;
+        const int sz = qMax( rect.width() * rect.height(), 0 );
+        resize( sz );
+    }
+
+    fill( false );
+}
+
+//! \return Bounding rectangle
+QRect QwtPixelMatrix::rect() const
+{
+    return d_rect;
+}
Index: trunk/BNC/qwt/qwt_pixel_matrix.h
===================================================================
--- trunk/BNC/qwt/qwt_pixel_matrix.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_pixel_matrix.h	(revision 8127)
@@ -0,0 +1,98 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PIXEL_MATRIX_H
+#define QWT_PIXEL_MATRIX_H
+
+#include "qwt_global.h"
+#include <qbitarray.h>
+#include <qrect.h>
+
+/*!
+  \brief A bit field corresponding to the pixels of a rectangle
+
+  QwtPixelMatrix is intended to filter out duplicates in an
+  unsorted array of points.
+*/
+class QWT_EXPORT QwtPixelMatrix: public QBitArray
+{
+public:
+    QwtPixelMatrix( const QRect& rect );
+    ~QwtPixelMatrix();
+
+    void setRect( const QRect& rect );
+    QRect rect() const;
+
+    bool testPixel( int x, int y ) const;
+    bool testAndSetPixel( int x, int y, bool on );
+
+    int index( int x, int y ) const;
+
+private:
+    QRect d_rect;
+};
+
+/*!
+  \brief Test if a pixel has been set
+
+  \param x X-coordinate
+  \param y Y-coordinate
+
+  \return true, when pos is outside of rect(), or when the pixel
+          has already been set.
+ */
+inline bool QwtPixelMatrix::testPixel( int x, int y ) const
+{
+    const int idx = index( x, y );
+    return ( idx >= 0 ) ? testBit( idx ) : true;
+}
+
+/*!
+  \brief Set a pixel and test if a pixel has been set before
+
+  \param x X-coordinate
+  \param y Y-coordinate
+  \param on Set/Clear the pixel
+
+  \return true, when pos is outside of rect(), or when the pixel
+          was set before.
+ */
+inline bool QwtPixelMatrix::testAndSetPixel( int x, int y, bool on )
+{
+    const int idx = index( x, y );
+    if ( idx < 0 )
+        return true;
+
+    const bool onBefore = testBit( idx );
+    setBit( idx, on );
+
+    return onBefore;
+}
+
+/*!
+  \brief Calculate the index in the bit field corresponding to a position
+
+  \param x X-coordinate
+  \param y Y-coordinate
+  \return Index, when rect() contains pos - otherwise -1.
+ */
+inline int QwtPixelMatrix::index( int x, int y ) const
+{
+    const int dx = x - d_rect.x();
+    if ( dx < 0 || dx >= d_rect.width() )
+        return -1;
+
+    const int dy = y - d_rect.y();
+    if ( dy < 0 || dy >= d_rect.height() )
+        return -1;
+
+    return dy * d_rect.width() + dx;
+}
+
+#endif
Index: trunk/BNC/qwt/qwt_plot.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot.cpp	(revision 8127)
@@ -15,6 +15,7 @@
 #include "qwt_text_label.h"
 #include "qwt_legend.h"
-#include "qwt_dyngrid_layout.h"
+#include "qwt_legend_data.h"
 #include "qwt_plot_canvas.h"
+#include <qmath.h>
 #include <qpainter.h>
 #include <qpointer.h>
@@ -23,10 +24,79 @@
 #include <qevent.h>
 
+static inline void qwtEnableLegendItems( QwtPlot *plot, bool on )
+{
+    if ( on )
+    {
+        QObject::connect( 
+            plot, SIGNAL( legendDataChanged(
+                const QVariant &, const QList<QwtLegendData> & ) ),
+            plot, SLOT( updateLegendItems( 
+                const QVariant &, const QList<QwtLegendData> & ) ) );
+    }
+    else
+    {
+        QObject::disconnect( 
+            plot, SIGNAL( legendDataChanged(
+                const QVariant &, const QList<QwtLegendData> & ) ),
+            plot, SLOT( updateLegendItems( 
+                const QVariant &, const QList<QwtLegendData> & ) ) );
+    }
+}
+
+static void qwtSetTabOrder( 
+    QWidget *first, QWidget *second, bool withChildren )
+{
+    QList<QWidget *> tabChain;
+    tabChain += first;
+    tabChain += second;
+
+    if ( withChildren )
+    {
+        QList<QWidget *> children = second->findChildren<QWidget *>();
+
+        QWidget *w = second->nextInFocusChain();
+        while ( children.contains( w ) )
+        {
+            children.removeAll( w );
+
+            tabChain += w;
+            w = w->nextInFocusChain();
+        }
+    }
+
+    for ( int i = 0; i < tabChain.size() - 1; i++ )
+    {
+        QWidget *from = tabChain[i];
+        QWidget *to = tabChain[i+1];
+
+        const Qt::FocusPolicy policy1 = from->focusPolicy();
+        const Qt::FocusPolicy policy2 = to->focusPolicy();
+
+        QWidget *proxy1 = from->focusProxy();
+        QWidget *proxy2 = to->focusProxy();
+
+        from->setFocusPolicy( Qt::TabFocus );
+        from->setFocusProxy( NULL);
+
+        to->setFocusPolicy( Qt::TabFocus );
+        to->setFocusProxy( NULL);
+
+        QWidget::setTabOrder( from, to );
+
+        from->setFocusPolicy( policy1 );
+        from->setFocusProxy( proxy1);
+
+        to->setFocusPolicy( policy2 );
+        to->setFocusProxy( proxy2 );
+    }
+}
+
 class QwtPlot::PrivateData
 {
 public:
-    QPointer<QwtTextLabel> lblTitle;
-    QPointer<QwtPlotCanvas> canvas;
-    QPointer<QwtLegend> legend;
+    QPointer<QwtTextLabel> titleLabel;
+    QPointer<QwtTextLabel> footerLabel;
+    QPointer<QWidget> canvas;
+    QPointer<QwtAbstractLegend> legend;
     QwtPlotLayout *layout;
 
@@ -58,4 +128,5 @@
 QwtPlot::~QwtPlot()
 {
+    setAutoReplot( false );
     detachItems( QwtPlotItem::Rtti_PlotItem, autoDelete() );
 
@@ -76,23 +147,31 @@
     d_data->autoReplot = false;
 
-    d_data->lblTitle = new QwtTextLabel( title, this );
-    d_data->lblTitle->setObjectName( "QwtPlotTitle" );
-
-    d_data->lblTitle->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
+    // title
+    d_data->titleLabel = new QwtTextLabel( this );
+    d_data->titleLabel->setObjectName( "QwtPlotTitle" );
+    d_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
 
     QwtText text( title );
     text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
-    d_data->lblTitle->setText( text );
-
+    d_data->titleLabel->setText( text );
+
+    // footer
+    d_data->footerLabel = new QwtTextLabel( this );
+    d_data->footerLabel->setObjectName( "QwtPlotFooter" );
+
+    QwtText footer;
+    footer.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
+    d_data->footerLabel->setText( footer );
+
+    // legend
     d_data->legend = NULL;
 
+    // axis
     initAxesData();
 
+    // canvas
     d_data->canvas = new QwtPlotCanvas( this );
     d_data->canvas->setObjectName( "QwtPlotCanvas" );
-    d_data->canvas->setFrameStyle( QFrame::Panel | QFrame::Sunken );
-    d_data->canvas->setLineWidth( 2 );
-
-    updateTabOrder();
+    d_data->canvas->installEventFilter( this );
 
     setSizePolicy( QSizePolicy::MinimumExpanding,
@@ -100,4 +179,56 @@
 
     resize( 200, 200 );
+
+    QList<QWidget *> focusChain;
+    focusChain << this << d_data->titleLabel << axisWidget( xTop )
+        << axisWidget( yLeft ) << d_data->canvas << axisWidget( yRight )
+        << axisWidget( xBottom ) << d_data->footerLabel;
+
+    for ( int i = 0; i < focusChain.size() - 1; i++ )
+        qwtSetTabOrder( focusChain[i], focusChain[i+1], false );
+
+    qwtEnableLegendItems( this, true );
+}
+
+/*!
+  \brief Set the drawing canvas of the plot widget
+
+  QwtPlot invokes methods of the canvas as meta methods ( see QMetaObject ).
+  In opposite to using conventional C++ techniques like virtual methods
+  they allow to use canvas implementations that are derived from 
+  QWidget or QGLWidget.
+
+  The following meta methods could be implemented:
+
+  - replot()
+    When the canvas doesn't offer a replot method, QwtPlot calls
+    update() instead.
+
+  - borderPath()
+    The border path is necessary to clip the content of the canvas
+    When the canvas doesn't have any special border ( f.e rounded corners )
+    it is o.k. not to implement this method.
+
+  The default canvas is a QwtPlotCanvas 
+
+  \param canvas Canvas Widget
+  \sa canvas()
+ */
+void QwtPlot::setCanvas( QWidget *canvas )
+{
+    if ( canvas == d_data->canvas )
+        return;
+
+    delete d_data->canvas;
+    d_data->canvas = canvas;
+
+    if ( canvas )
+    {
+        canvas->setParent( this );
+        canvas->installEventFilter( this );
+
+        if ( isVisible() )
+            canvas->show();
+    }
 }
 
@@ -105,4 +236,6 @@
   \brief Adds handling of layout requests
   \param event Event
+
+  \return See QFrame::event()
 */
 bool QwtPlot::event( QEvent *event )
@@ -122,4 +255,39 @@
 }
 
+/*!
+  \brief Event filter
+
+  The plot handles the following events for the canvas:
+
+  - QEvent::Resize
+    The canvas margins might depend on its size
+
+  - QEvent::ContentsRectChange
+    The layout needs to be recalculated
+
+  \param object Object to be filtered
+  \param event Event
+
+  \return See QFrame::eventFilter()
+
+  \sa updateCanvasMargins(), updateLayout()
+*/
+bool QwtPlot::eventFilter( QObject *object, QEvent *event )
+{
+    if ( object == d_data->canvas )
+    {
+        if ( event->type() == QEvent::Resize )
+        {
+            updateCanvasMargins();
+        }
+        else if ( event->type() == QEvent::ContentsRectChange )
+        {
+            updateLayout();
+        }
+    }
+
+    return QFrame::eventFilter( object, event );
+}
+
 //! Replots the plot if autoReplot() is \c true.
 void QwtPlot::autoRefresh()
@@ -164,7 +332,7 @@
 void QwtPlot::setTitle( const QString &title )
 {
-    if ( title != d_data->lblTitle->text().text() )
-    {
-        d_data->lblTitle->setText( title );
+    if ( title != d_data->titleLabel->text().text() )
+    {
+        d_data->titleLabel->setText( title );
         updateLayout();
     }
@@ -177,18 +345,91 @@
 void QwtPlot::setTitle( const QwtText &title )
 {
-    if ( title != d_data->lblTitle->text() )
-    {
-        d_data->lblTitle->setText( title );
+    if ( title != d_data->titleLabel->text() )
+    {
+        d_data->titleLabel->setText( title );
         updateLayout();
     }
 }
 
-//! \return the plot's title
+//! \return Title of the plot
 QwtText QwtPlot::title() const
 {
-    return d_data->lblTitle->text();
-}
-
-//! \return the plot's title
+    return d_data->titleLabel->text();
+}
+
+//! \return Title label widget.
+QwtTextLabel *QwtPlot::titleLabel()
+{
+    return d_data->titleLabel;
+}
+
+//! \return Title label widget.
+const QwtTextLabel *QwtPlot::titleLabel() const
+{
+    return d_data->titleLabel;
+}
+
+/*!
+  Change the text the footer 
+  \param text New text of the footer
+*/
+void QwtPlot::setFooter( const QString &text )
+{
+    if ( text != d_data->footerLabel->text().text() )
+    {
+        d_data->footerLabel->setText( text );
+        updateLayout();
+    }
+}
+
+/*!
+  Change the text the footer 
+  \param text New text of the footer
+*/
+void QwtPlot::setFooter( const QwtText &text )
+{
+    if ( text != d_data->footerLabel->text() )
+    {
+        d_data->footerLabel->setText( text );
+        updateLayout();
+    }
+}
+
+//! \return Text of the footer
+QwtText QwtPlot::footer() const
+{
+    return d_data->footerLabel->text();
+}
+
+//! \return Footer label widget.
+QwtTextLabel *QwtPlot::footerLabel()
+{
+    return d_data->footerLabel;
+}
+
+//! \return Footer label widget.
+const QwtTextLabel *QwtPlot::footerLabel() const
+{
+    return d_data->footerLabel;
+}
+
+/*!
+   \brief Assign a new plot layout
+
+   \param layout Layout()
+   \sa plotLayout()
+ */
+void QwtPlot::setPlotLayout( QwtPlotLayout *layout )
+{
+    if ( layout != d_data->layout )
+    {
+        delete d_data->layout;
+        d_data->layout = layout;
+
+        updateLayout();
+    }
+}
+
+//! \return the plot's layout
 QwtPlotLayout *QwtPlot::plotLayout()
 {
@@ -196,22 +437,8 @@
 }
 
-//! \return the plot's titel label.
+//! \return the plot's layout
 const QwtPlotLayout *QwtPlot::plotLayout() const
 {
     return d_data->layout;
-}
-
-//! \return the plot's titel label.
-QwtTextLabel *QwtPlot::titleLabel()
-{
-    return d_data->lblTitle;
-}
-
-/*!
-  \return the plot's titel label.
-*/
-const QwtTextLabel *QwtPlot::titleLabel() const
-{
-    return d_data->lblTitle;
 }
 
@@ -220,5 +447,5 @@
   \sa insertLegend()
 */
-QwtLegend *QwtPlot::legend()
+QwtAbstractLegend *QwtPlot::legend()
 {
     return d_data->legend;
@@ -229,5 +456,5 @@
   \sa insertLegend()
 */
-const QwtLegend *QwtPlot::legend() const
+const QwtAbstractLegend *QwtPlot::legend() const
 {
     return d_data->legend;
@@ -238,5 +465,5 @@
   \return the plot's canvas
 */
-QwtPlotCanvas *QwtPlot::canvas()
+QWidget *QwtPlot::canvas()
 {
     return d_data->canvas;
@@ -246,5 +473,5 @@
   \return the plot's canvas
 */
-const QwtPlotCanvas *QwtPlot::canvas() const
+const QWidget *QwtPlot::canvas() const
 {
     return d_data->canvas;
@@ -252,8 +479,7 @@
 
 /*!
-  Return sizeHint
+  \return Size hint for the plot widget
   \sa minimumSizeHint()
 */
-
 QSize QwtPlot::sizeHint() const
 {
@@ -316,6 +542,5 @@
   be refreshed explicitly in order to make changes visible.
 
-  \sa setAutoReplot()
-  \warning Calls canvas()->repaint, take care of infinite recursions
+  \sa updateAxes(), setAutoReplot()
 */
 void QwtPlot::replot()
@@ -333,5 +558,14 @@
     QApplication::sendPostedEvents( this, QEvent::LayoutRequest );
 
-    d_data->canvas->replot();
+    if ( d_data->canvas )
+    {
+        const bool ok = QMetaObject::invokeMethod( 
+            d_data->canvas, "replot", Qt::DirectConnection );
+        if ( !ok )
+        {
+            // fallback, when canvas has no a replot method
+            d_data->canvas->update( d_data->canvas->contentsRect() );
+        }
+    }
 
     setAutoReplot( doAutoReplot );
@@ -347,4 +581,5 @@
 
     QRect titleRect = d_data->layout->titleRect().toRect();
+    QRect footerRect = d_data->layout->footerRect().toRect();
     QRect scaleRect[QwtPlot::axisCnt];
     for ( int axisId = 0; axisId < axisCnt; axisId++ )
@@ -353,51 +588,77 @@
     QRect canvasRect = d_data->layout->canvasRect().toRect();
 
-    //
     // resize and show the visible widgets
-    //
-    if ( !d_data->lblTitle->text().isEmpty() )
-    {
-        d_data->lblTitle->setGeometry( titleRect );
-        if ( !d_data->lblTitle->isVisibleTo( this ) )
-            d_data->lblTitle->show();
+
+    if ( !d_data->titleLabel->text().isEmpty() )
+    {
+        d_data->titleLabel->setGeometry( titleRect );
+        if ( !d_data->titleLabel->isVisibleTo( this ) )
+            d_data->titleLabel->show();
     }
     else
-        d_data->lblTitle->hide();
+        d_data->titleLabel->hide();
+
+    if ( !d_data->footerLabel->text().isEmpty() )
+    {
+        d_data->footerLabel->setGeometry( footerRect );
+        if ( !d_data->footerLabel->isVisibleTo( this ) )
+            d_data->footerLabel->show();
+    }
+    else
+    {
+        d_data->footerLabel->hide();
+    }
 
     for ( int axisId = 0; axisId < axisCnt; axisId++ )
     {
+        QwtScaleWidget* scaleWidget = axisWidget( axisId );
+
         if ( axisEnabled( axisId ) )
         {
-            axisWidget( axisId )->setGeometry( scaleRect[axisId] );
-
+            if ( scaleRect[axisId] != scaleWidget->geometry() )
+            {
+                scaleWidget->setGeometry( scaleRect[axisId] );
+
+                int startDist, endDist;
+                scaleWidget->getBorderDistHint( startDist, endDist );
+                scaleWidget->setBorderDist( startDist, endDist );
+            }
+
+#if 1
             if ( axisId == xBottom || axisId == xTop )
             {
+                // do we need this code any longer ???
+
                 QRegion r( scaleRect[axisId] );
                 if ( axisEnabled( yLeft ) )
-                    r = r.subtract( QRegion( scaleRect[yLeft] ) );
+                    r = r.subtracted( QRegion( scaleRect[yLeft] ) );
                 if ( axisEnabled( yRight ) )
-                    r = r.subtract( QRegion( scaleRect[yRight] ) );
-                r.translate( -d_data->layout->scaleRect( axisId ).x(),
+                    r = r.subtracted( QRegion( scaleRect[yRight] ) );
+                r.translate( -scaleRect[ axisId ].x(),
                     -scaleRect[axisId].y() );
 
-                axisWidget( axisId )->setMask( r );
+                scaleWidget->setMask( r );
             }
-            if ( !axisWidget( axisId )->isVisibleTo( this ) )
-                axisWidget( axisId )->show();
+#endif
+            if ( !scaleWidget->isVisibleTo( this ) )
+                scaleWidget->show();
         }
         else
-            axisWidget( axisId )->hide();
-    }
-
-    if ( d_data->legend &&
-        d_data->layout->legendPosition() != ExternalLegend )
-    {
-        if ( d_data->legend->itemCount() > 0 )
+        {
+            scaleWidget->hide();
+        }
+    }
+
+    if ( d_data->legend )
+    {
+        if ( d_data->legend->isEmpty() )
+        {
+            d_data->legend->hide();
+        }
+        else
         {
             d_data->legend->setGeometry( legendRect );
             d_data->legend->show();
         }
-        else
-            d_data->legend->hide();
     }
 
@@ -406,64 +667,75 @@
 
 /*!
-   Update the focus tab order
-
-   The order is changed so that the canvas will be in front of the
-   first legend item, or behind the last legend item - depending
-   on the position of the legend.
-*/
-
-void QwtPlot::updateTabOrder()
-{
-    if ( d_data->canvas->focusPolicy() == Qt::NoFocus )
-        return;
-    if ( d_data->legend.isNull()
-        || d_data->layout->legendPosition() == ExternalLegend
-        || d_data->legend->legendItems().count() == 0 )
-    {
-        return;
-    }
-
-    // Depending on the position of the legend the
-    // tab order will be changed that the canvas is
-    // next to the last legend item, or before
-    // the first one.
-
-    const bool canvasFirst =
-        d_data->layout->legendPosition() == QwtPlot::BottomLegend ||
-        d_data->layout->legendPosition() == QwtPlot::RightLegend;
-
-    QWidget *previous = NULL;
-
-    QWidget *w = d_data->canvas;
-    while ( ( w = w->nextInFocusChain() ) != d_data->canvas )
-    {
-        bool isLegendItem = false;
-        if ( w->focusPolicy() != Qt::NoFocus
-            && w->parent() && w->parent() == d_data->legend->contentsWidget() )
-        {
-            isLegendItem = true;
-        }
-
-        if ( canvasFirst )
-        {
-            if ( isLegendItem )
-                break;
-
-            previous = w;
-        }
-        else
-        {
-            if ( isLegendItem )
-                previous = w;
-            else
-            {
-                if ( previous )
-                    break;
-            }
-        }
-    }
-
-    if ( previous && previous != d_data->canvas )
-        setTabOrder( previous, d_data->canvas );
+  \brief Calculate the canvas margins
+
+  \param maps QwtPlot::axisCnt maps, mapping between plot and paint device coordinates
+  \param canvasRect Bounding rectangle where to paint
+  \param left Return parameter for the left margin
+  \param top Return parameter for the top margin
+  \param right Return parameter for the right margin
+  \param bottom Return parameter for the bottom margin
+
+  Plot items might indicate, that they need some extra space
+  at the borders of the canvas by the QwtPlotItem::Margins flag.
+
+  updateCanvasMargins(), QwtPlotItem::getCanvasMarginHint()
+ */
+void QwtPlot::getCanvasMarginsHint(
+    const QwtScaleMap maps[], const QRectF &canvasRect,
+    double &left, double &top, double &right, double &bottom) const
+{
+    left = top = right = bottom = -1.0;
+
+    const QwtPlotItemList& itmList = itemList();
+    for ( QwtPlotItemIterator it = itmList.begin();
+        it != itmList.end(); ++it )
+    {
+        const QwtPlotItem *item = *it;
+        if ( item->testItemAttribute( QwtPlotItem::Margins ) )
+        {
+            double m[ QwtPlot::axisCnt ];
+            item->getCanvasMarginHint(
+                maps[ item->xAxis() ], maps[ item->yAxis() ],
+                canvasRect, m[yLeft], m[xTop], m[yRight], m[xBottom] );
+
+            left = qMax( left, m[yLeft] );
+            top = qMax( top, m[xTop] );
+            right = qMax( right, m[yRight] );
+            bottom = qMax( bottom, m[xBottom] );
+        }
+    }
+}
+
+/*!
+  \brief Update the canvas margins
+
+  Plot items might indicate, that they need some extra space
+  at the borders of the canvas by the QwtPlotItem::Margins flag.
+
+  getCanvasMarginsHint(), QwtPlotItem::getCanvasMarginHint()
+ */
+void QwtPlot::updateCanvasMargins()
+{
+    QwtScaleMap maps[axisCnt];
+    for ( int axisId = 0; axisId < axisCnt; axisId++ )
+        maps[axisId] = canvasMap( axisId );
+
+    double margins[axisCnt];
+    getCanvasMarginsHint( maps, canvas()->contentsRect(),
+        margins[yLeft], margins[xTop], margins[yRight], margins[xBottom] );
+    
+    bool doUpdate = false;
+    for ( int axisId = 0; axisId < axisCnt; axisId++ )
+    {
+        if ( margins[axisId] >= 0.0 )
+        {
+            const int m = qCeil( margins[axisId] );
+            plotLayout()->setCanvasMargin( m, axisId);
+            doUpdate = true;
+        }
+    }
+
+    if ( doUpdate )
+        updateLayout();
 }
 
@@ -488,11 +760,17 @@
 /*!
   Redraw the canvas items.
+
   \param painter Painter used for drawing
   \param canvasRect Bounding rectangle where to paint
-  \param map QwtPlot::axisCnt maps, mapping between plot and paint device coordinates
+  \param maps QwtPlot::axisCnt maps, mapping between plot and paint device coordinates
+
+  \note Usually canvasRect is contentsRect() of the plot canvas.
+        Due to a bug in Qt this rectangle might be wrong for certain 
+        frame styles ( f.e QFrame::Box ) and it might be necessary to 
+        fix the margins manually using QWidget::setContentsMargins()
 */
 
 void QwtPlot::drawItems( QPainter *painter, const QRectF &canvasRect,
-        const QwtScaleMap map[axisCnt] ) const
+        const QwtScaleMap maps[axisCnt] ) const
 {
     const QwtPlotItemList& itmList = itemList();
@@ -507,7 +785,9 @@
             painter->setRenderHint( QPainter::Antialiasing,
                 item->testRenderHint( QwtPlotItem::RenderAntialiased ) );
+            painter->setRenderHint( QPainter::HighQualityAntialiasing,
+                item->testRenderHint( QwtPlotItem::RenderAntialiased ) );
 
             item->draw( painter,
-                map[item->xAxis()], map[item->yAxis()],
+                maps[item->xAxis()], maps[item->yAxis()],
                 canvasRect );
 
@@ -532,6 +812,6 @@
     map.setTransformation( axisScaleEngine( axisId )->transformation() );
 
-    const QwtScaleDiv *sd = axisScaleDiv( axisId );
-    map.setScaleInterval( sd->lowerBound(), sd->upperBound() );
+    const QwtScaleDiv &sd = axisScaleDiv( axisId );
+    map.setScaleInterval( sd.lowerBound(), sd.upperBound() );
 
     if ( axisEnabled( axisId ) )
@@ -553,20 +833,33 @@
     else
     {
-        int margin = 0;
-        if ( !plotLayout()->alignCanvasToScales() )
-            margin = plotLayout()->canvasMargin( axisId );
-
         const QRect &canvasRect = d_data->canvas->contentsRect();
         if ( axisId == yLeft || axisId == yRight )
         {
-            map.setPaintInterval( canvasRect.bottom() - margin,
-                canvasRect.top() + margin );
+            int top = 0;
+            if ( !plotLayout()->alignCanvasToScale( xTop ) )
+                top = plotLayout()->canvasMargin( xTop );
+
+            int bottom = 0;
+            if ( !plotLayout()->alignCanvasToScale( xBottom ) )
+                bottom = plotLayout()->canvasMargin( xBottom );
+
+            map.setPaintInterval( canvasRect.bottom() - bottom,
+                canvasRect.top() + top );
         }
         else
         {
-            map.setPaintInterval( canvasRect.left() + margin,
-                canvasRect.right() - margin );
-        }
-    }
+            int left = 0;
+            if ( !plotLayout()->alignCanvasToScale( yLeft ) )
+                left = plotLayout()->canvasMargin( yLeft );
+
+            int right = 0;
+            if ( !plotLayout()->alignCanvasToScale( yRight ) )
+                right = plotLayout()->canvasMargin( yRight );
+
+            map.setPaintInterval( canvasRect.left() + left,
+                canvasRect.right() - right );
+        }
+    }
+
     return map;
 }
@@ -575,5 +868,5 @@
   \brief Change the background of the plotting area
 
-  Sets brush to QPalette::Window of all colorgroups of
+  Sets brush to QPalette::Window of all color groups of
   the palette of the canvas. Using canvas()->setPalette()
   is a more powerful way to set these colors.
@@ -585,7 +878,5 @@
 {
     QPalette pal = d_data->canvas->palette();
-
-    for ( int i = 0; i < QPalette::NColorGroups; i++ )
-        pal.setBrush( ( QPalette::ColorGroup )i, QPalette::Window, brush );
+    pal.setBrush( QPalette::Window, brush );
 
     canvas()->setPalette( pal );
@@ -606,29 +897,4 @@
 
 /*!
-  \brief Change the border width of the plotting area
-
-  Nothing else than canvas()->setLineWidth(w),
-  left for compatibility only.
-
-  \param width New border width
-*/
-void QwtPlot::setCanvasLineWidth( int width )
-{
-    canvas()->setLineWidth( width );
-    updateLayout();
-}
-
-/*!
-  Nothing else than: canvas()->lineWidth(),
-  left for compatibility only.
-
-  \return the border width of the plotting area
-*/
-int QwtPlot::canvasLineWidth() const
-{
-    return canvas()->lineWidth();
-}
-
-/*!
   \return \c true if the specified axis exists, otherwise \c false
   \param axisId axis index
@@ -637,34 +903,4 @@
 {
     return ( ( axisId >= QwtPlot::yLeft ) && ( axisId < QwtPlot::axisCnt ) );
-}
-
-/*!
-  Called internally when the legend has been clicked on.
-  Emits a legendClicked() signal.
-*/
-void QwtPlot::legendItemClicked()
-{
-    if ( d_data->legend && sender()->isWidgetType() )
-    {
-        QwtPlotItem *plotItem =
-            ( QwtPlotItem* )d_data->legend->find( ( QWidget * )sender() );
-        if ( plotItem )
-            Q_EMIT legendClicked( plotItem );
-    }
-}
-
-/*!
-  Called internally when the legend has been checked
-  Emits a legendClicked() signal.
-*/
-void QwtPlot::legendItemChecked( bool on )
-{
-    if ( d_data->legend && sender()->isWidgetType() )
-    {
-        QwtPlotItem *plotItem =
-            ( QwtPlotItem* )d_data->legend->find( ( QWidget * )sender() );
-        if ( plotItem )
-            Q_EMIT legendChecked( plotItem, on );
-    }
 }
 
@@ -677,15 +913,21 @@
   with a best fit number of columns from left to right.
 
-  If pos != QwtPlot::ExternalLegend the plot widget will become
-  parent of the legend. It will be deleted when the plot is deleted,
-  or another legend is set with insertLegend().
+  insertLegend() will set the plot widget as parent for the legend.
+  The legend will be deleted in the destructor of the plot or when 
+  another legend is inserted.
+
+  Legends, that are not inserted into the layout of the plot widget
+  need to connect to the legendDataChanged() signal. Calling updateLegend()
+  initiates this signal for an initial update. When the application code
+  wants to implement its own layout this also needs to be done for
+  rendering plots to a document ( see QwtPlotRenderer ).
 
   \param legend Legend
   \param pos The legend's position. For top/left position the number
-             of colums will be limited to 1, otherwise it will be set to
+             of columns will be limited to 1, otherwise it will be set to
              unlimited.
 
-  \param ratio Ratio between legend and the bounding rect
-               of title, canvas and axes. The legend will be shrinked
+  \param ratio Ratio between legend and the bounding rectangle
+               of title, canvas and axes. The legend will be shrunk
                if it would need more space than the given ratio.
                The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
@@ -696,5 +938,5 @@
       QwtPlotLayout::setLegendPosition()
 */
-void QwtPlot::insertLegend( QwtLegend *legend,
+void QwtPlot::insertLegend( QwtAbstractLegend *legend,
     QwtPlot::LegendPosition pos, double ratio )
 {
@@ -710,20 +952,21 @@
         if ( d_data->legend )
         {
-            if ( pos != ExternalLegend )
-            {
-                if ( d_data->legend->parent() != this )
-                    d_data->legend->setParent( this );
-            }
-
-            const QwtPlotItemList& itmList = itemList();
-            for ( QwtPlotItemIterator it = itmList.begin();
-                it != itmList.end(); ++it )
-            {
-                ( *it )->updateLegend( d_data->legend );
-            }
-
-            QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
-                d_data->legend->contentsWidget()->layout() );
-            if ( tl )
+            connect( this, 
+                SIGNAL( legendDataChanged( 
+                    const QVariant &, const QList<QwtLegendData> & ) ),
+                d_data->legend, 
+                SLOT( updateLegend( 
+                    const QVariant &, const QList<QwtLegendData> & ) ) 
+            );
+
+            if ( d_data->legend->parent() != this )
+                d_data->legend->setParent( this );
+
+            qwtEnableLegendItems( this, false );
+            updateLegend();
+            qwtEnableLegendItems( this, true );
+
+            QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
+            if ( lgd )
             {
                 switch ( d_data->layout->legendPosition() )
@@ -731,18 +974,216 @@
                     case LeftLegend:
                     case RightLegend:
-                        tl->setMaxCols( 1 ); // 1 column: align vertical
+                    {
+                        if ( lgd->maxColumns() == 0     )
+                            lgd->setMaxColumns( 1 ); // 1 column: align vertical
                         break;
+                    }
                     case TopLegend:
                     case BottomLegend:
-                        tl->setMaxCols( 0 ); // unlimited
+                    {
+                        lgd->setMaxColumns( 0 ); // unlimited
                         break;
-                    case ExternalLegend:
+                    }
+                    default:
                         break;
                 }
             }
-        }
-        updateTabOrder();
+
+            QWidget *previousInChain = NULL;
+            switch ( d_data->layout->legendPosition() )
+            {
+                case LeftLegend:
+                {
+                    previousInChain = axisWidget( QwtPlot::xTop );
+                    break;
+                }
+                case TopLegend:
+                {
+                    previousInChain = this;
+                    break;
+                }
+                case RightLegend:
+                {
+                    previousInChain = axisWidget( QwtPlot::yRight );
+                    break;
+                }
+                case BottomLegend:
+                {
+                    previousInChain = footerLabel();
+                    break;
+                }
+            }
+
+            if ( previousInChain )
+                qwtSetTabOrder( previousInChain, legend, true );
+        }
     }
 
     updateLayout();
 }
+
+/*!
+  Emit legendDataChanged() for all plot item
+
+  \sa QwtPlotItem::legendData(), legendDataChanged()
+ */
+void QwtPlot::updateLegend()
+{
+    const QwtPlotItemList& itmList = itemList();
+    for ( QwtPlotItemIterator it = itmList.begin();
+        it != itmList.end(); ++it )
+    {
+        updateLegend( *it );
+    }
+}
+
+/*!
+  Emit legendDataChanged() for a plot item
+
+  \param plotItem Plot item
+  \sa QwtPlotItem::legendData(), legendDataChanged()
+ */
+void QwtPlot::updateLegend( const QwtPlotItem *plotItem )
+{
+    if ( plotItem == NULL )
+        return;
+
+    QList<QwtLegendData> legendData;
+
+    if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
+        legendData = plotItem->legendData();
+
+    const QVariant itemInfo = itemToInfo( const_cast< QwtPlotItem *>( plotItem) );
+    Q_EMIT legendDataChanged( itemInfo, legendData );
+}
+
+/*!
+  \brief Update all plot items interested in legend attributes
+
+  Call QwtPlotItem::updateLegend(), when the QwtPlotItem::LegendInterest
+  flag is set.
+
+  \param itemInfo Info about the plot item
+  \param legendData Entries to be displayed for the plot item ( usually 1 )
+
+  \sa QwtPlotItem::LegendInterest,
+      QwtPlotLegendItem, QwtPlotItem::updateLegend()
+ */
+void QwtPlot::updateLegendItems( const QVariant &itemInfo,
+    const QList<QwtLegendData> &legendData )
+{
+    QwtPlotItem *plotItem = infoToItem( itemInfo );
+    if ( plotItem )
+    {
+        const QwtPlotItemList& itmList = itemList();
+        for ( QwtPlotItemIterator it = itmList.begin();
+            it != itmList.end(); ++it )
+        {
+            QwtPlotItem *item = *it;
+            if ( item->testItemInterest( QwtPlotItem::LegendInterest ) )
+                item->updateLegend( plotItem, legendData );
+        }
+    }
+}
+
+/*!
+  \brief Attach/Detach a plot item 
+
+  \param plotItem Plot item
+  \param on When true attach the item, otherwise detach it
+ */
+void QwtPlot::attachItem( QwtPlotItem *plotItem, bool on )
+{
+    if ( plotItem->testItemInterest( QwtPlotItem::LegendInterest ) )
+    {
+        // plotItem is some sort of legend
+
+        const QwtPlotItemList& itmList = itemList();
+        for ( QwtPlotItemIterator it = itmList.begin();
+            it != itmList.end(); ++it )
+        {
+            QwtPlotItem *item = *it;
+
+            QList<QwtLegendData> legendData;
+            if ( on && item->testItemAttribute( QwtPlotItem::Legend ) )
+            {
+                legendData = item->legendData();
+                plotItem->updateLegend( item, legendData );
+            }
+        }
+    }
+
+    if ( on )
+        insertItem( plotItem );
+    else 
+        removeItem( plotItem );
+
+    Q_EMIT itemAttached( plotItem, on );
+
+    if ( plotItem->testItemAttribute( QwtPlotItem::Legend ) )
+    {
+        // the item wants to be represented on the legend
+
+        if ( on )
+        {
+            updateLegend( plotItem );
+        }
+        else
+        {
+            const QVariant itemInfo = itemToInfo( plotItem );
+            Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
+        }
+    }
+
+    autoRefresh();
+}
+
+/*!
+  \brief Build an information, that can be used to identify
+         a plot item on the legend.
+
+  The default implementation simply wraps the plot item
+  into a QVariant object. When overloading itemToInfo()
+  usually infoToItem() needs to reimplemeted too.
+
+\code
+    QVariant itemInfo;
+    qVariantSetValue( itemInfo, plotItem );
+\endcode
+
+  \param plotItem Plot item
+  \return Plot item embedded in a QVariant
+  \sa infoToItem()
+ */
+QVariant QwtPlot::itemToInfo( QwtPlotItem *plotItem ) const
+{
+    QVariant itemInfo;
+    qVariantSetValue( itemInfo, plotItem );
+
+    return itemInfo;
+}
+
+/*!
+  \brief Identify the plot item according to an item info object,
+         that has bee generated from itemToInfo().
+
+  The default implementation simply tries to unwrap a QwtPlotItem 
+  pointer:
+
+\code
+    if ( itemInfo.canConvert<QwtPlotItem *>() )
+        return qvariant_cast<QwtPlotItem *>( itemInfo );
+\endcode
+  \param itemInfo Plot item
+  \return A plot item, when successful, otherwise a NULL pointer.
+  \sa itemToInfo()
+*/
+QwtPlotItem *QwtPlot::infoToItem( const QVariant &itemInfo ) const
+{
+    if ( itemInfo.canConvert<QwtPlotItem *>() )
+        return qvariant_cast<QwtPlotItem *>( itemInfo );
+
+    return NULL;
+}
+
+
Index: trunk/BNC/qwt/qwt_plot.h
===================================================================
--- trunk/BNC/qwt/qwt_plot.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot.h	(revision 8127)
@@ -17,7 +17,9 @@
 #include "qwt_interval.h"
 #include <qframe.h>
+#include <qlist.h>
+#include <qvariant.h>
 
 class QwtPlotLayout;
-class QwtLegend;
+class QwtAbstractLegend;
 class QwtScaleWidget;
 class QwtScaleEngine;
@@ -25,5 +27,4 @@
 class QwtScaleDraw;
 class QwtTextLabel;
-class QwtPlotCanvas;
 
 /*!
@@ -36,7 +37,10 @@
   from QwtPlotItem.
   A plot can have up to four axes, with each plot item attached to an x- and
-  a y axis. The scales at the axes can be explicitely set (QwtScaleDiv), or
+  a y axis. The scales at the axes can be explicitly set (QwtScaleDiv), or
   are calculated from the plot items, using algorithms (QwtScaleEngine) which
   can be configured separately for each axis.
+
+  The simpleplot example is a good starting point to see how to set up a 
+  plot widget.
 
   \image html plot.png
@@ -56,5 +60,5 @@
 QwtPlotCurve *curve2 = new QwtPlotCurve("Curve 2");
 
-// copy the data into the curves
+// connect or copy the data to the curves
 curve1->setData(...);
 curve2->setData(...);
@@ -71,6 +75,17 @@
 {
     Q_OBJECT
+
+    Q_PROPERTY( QBrush canvasBackground 
+        READ canvasBackground WRITE setCanvasBackground )
+    Q_PROPERTY( bool autoReplot READ autoReplot WRITE setAutoReplot )
+
+#if 0
+    // This property is intended to configure the plot
+    // widget from a special dialog in the deigner plugin.
+    // Disabled until such a dialog has been implemented.
+
     Q_PROPERTY( QString propertiesDocument
         READ grabProperties WRITE applyProperties )
+#endif
 
 public:
@@ -98,6 +113,4 @@
 
         \sa insertLegend()
-        \note In case of ExternalLegend, the legend is not
-              handled by QwtPlotRenderer
      */
     enum LegendPosition
@@ -109,21 +122,13 @@
         RightLegend,
 
-        //! The legend will be below QwtPlot::xBottom axis.
+        //! The legend will be below the footer 
         BottomLegend,
 
-        //! The legend will be between QwtPlot::xTop axis and the title.
-        TopLegend,
-
-        /*!
-          External means that only the content of the legend
-          will be handled by QwtPlot, but not its geometry.
-          This type can be used to have a legend in an 
-          external window ( or on the canvas ).
-         */
-        ExternalLegend
+        //! The legend will be above the title
+        TopLegend
     };
 
     explicit QwtPlot( QWidget * = NULL );
-    explicit QwtPlot( const QwtText &title, QWidget *p = NULL );
+    explicit QwtPlot( const QwtText &title, QWidget * = NULL );
 
     virtual ~QwtPlot();
@@ -132,8 +137,10 @@
     QString grabProperties() const;
 
-    void setAutoReplot( bool tf = true );
+    void setAutoReplot( bool = true );
     bool autoReplot() const;
 
     // Layout
+
+    void setPlotLayout( QwtPlotLayout * );
 
     QwtPlotLayout *plotLayout();
@@ -149,14 +156,22 @@
     const QwtTextLabel *titleLabel() const;
 
+    // Footer
+
+    void setFooter( const QString & );
+    void setFooter( const QwtText &t );
+    QwtText footer() const;
+
+    QwtTextLabel *footerLabel();
+    const QwtTextLabel *footerLabel() const;
+
     // Canvas
 
-    QwtPlotCanvas *canvas();
-    const QwtPlotCanvas *canvas() const;
+    void setCanvas( QWidget * );
+
+    QWidget *canvas();
+    const QWidget *canvas() const;
 
     void setCanvasBackground( const QBrush & );
     QBrush canvasBackground() const;
-
-    void setCanvasLineWidth( int w );
-    int canvasLineWidth() const;
 
     virtual QwtScaleMap canvasMap( int axisId ) const;
@@ -187,6 +202,5 @@
     QwtInterval axisInterval( int axisId ) const;
 
-    const QwtScaleDiv *axisScaleDiv( int axisId ) const;
-    QwtScaleDiv *axisScaleDiv( int axisId );
+    const QwtScaleDiv &axisScaleDiv( int axisId ) const;
 
     const QwtScaleDraw *axisScaleDraw( int axisId ) const;
@@ -211,9 +225,12 @@
     // Legend
 
-    void insertLegend( QwtLegend *, LegendPosition = QwtPlot::RightLegend,
-        double ratio = -1.0 );
-
-    QwtLegend *legend();
-    const QwtLegend *legend() const;
+    void insertLegend( QwtAbstractLegend *, 
+        LegendPosition = QwtPlot::RightLegend, double ratio = -1.0 );
+
+    QwtAbstractLegend *legend();
+    const QwtAbstractLegend *legend() const;
+
+    void updateLegend();
+    void updateLegend( const QwtPlotItem * );
 
     // Misc
@@ -226,36 +243,40 @@
 
     void updateAxes();
+    void updateCanvasMargins();
+
+    virtual void getCanvasMarginsHint( 
+        const QwtScaleMap maps[], const QRectF &canvasRect,
+        double &left, double &top, double &right, double &bottom) const;
 
     virtual bool event( QEvent * );
+    virtual bool eventFilter( QObject *, QEvent * );
 
     virtual void drawItems( QPainter *, const QRectF &,
         const QwtScaleMap maps[axisCnt] ) const;
 
+    virtual QVariant itemToInfo( QwtPlotItem * ) const;
+    virtual QwtPlotItem *infoToItem( const QVariant & ) const;
+
 Q_SIGNALS:
     /*!
-      A signal which is emitted when the user has clicked on
-      a legend item, which is in QwtLegend::ClickableItem mode.
-
-      \param plotItem Corresponding plot item of the
-                 selected legend item
-
-      \note clicks are disabled as default
-      \sa QwtLegend::setItemMode(), QwtLegend::itemMode()
+      A signal indicating, that an item has been attached/detached
+
+      \param plotItem Plot item
+      \param on Attached/Detached
      */
-    void legendClicked( QwtPlotItem *plotItem );
+    void itemAttached( QwtPlotItem *plotItem, bool on );
 
     /*!
-      A signal which is emitted when the user has clicked on
-      a legend item, which is in QwtLegend::CheckableItem mode
-
-      \param plotItem Corresponding plot item of the
-                 selected legend item
-      \param on True when the legen item is checked
-
-      \note clicks are disabled as default
-      \sa QwtLegend::setItemMode(), QwtLegend::itemMode()
+      A signal with the attributes how to update 
+      the legend entries for a plot item.
+
+      \param itemInfo Info about a plot item, build from itemToInfo()
+      \param data Attributes of the entries ( usually <= 1 ) for
+                  the plot item.
+
+      \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
      */
-
-    void legendChecked( QwtPlotItem *plotItem, bool on );
+    void legendDataChanged( const QVariant &itemInfo, 
+        const QList<QwtLegendData> &data );
 
 public Q_SLOTS:
@@ -263,16 +284,17 @@
     void autoRefresh();
 
-protected Q_SLOTS:
-    virtual void legendItemClicked();
-    virtual void legendItemChecked( bool );
-
 protected:
     static bool axisValid( int axisId );
 
-    virtual void updateTabOrder();
-
     virtual void resizeEvent( QResizeEvent *e );
 
+private Q_SLOTS:
+    void updateLegendItems( const QVariant &itemInfo,
+        const QList<QwtLegendData> &data );
+
 private:
+    friend class QwtPlotItem;
+    void attachItem( QwtPlotItem *, bool );
+
     void initAxesData();
     void deleteAxesData();
Index: trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_abstract_barchart.cpp	(revision 8127)
@@ -0,0 +1,368 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_abstract_barchart.h"
+#include "qwt_scale_map.h"
+
+static inline double qwtTransformWidth(
+    const QwtScaleMap &map, double value, double width )
+{
+    const double w2 = 0.5 * width;
+
+    const double v1 = map.transform( value - w2 );
+    const double v2 = map.transform( value + w2 );
+
+    return qAbs( v2 - v1 );
+}
+
+class QwtPlotAbstractBarChart::PrivateData
+{
+public:
+    PrivateData():
+        layoutPolicy( QwtPlotAbstractBarChart::AutoAdjustSamples ),
+        layoutHint( 0.5 ),
+        spacing( 10 ),
+        margin( 5 ),
+        baseline( 0.0 )
+    {
+    }
+
+    QwtPlotAbstractBarChart::LayoutPolicy layoutPolicy;
+    double layoutHint;
+    int spacing;
+    int margin;
+    double baseline;
+};
+
+/*!
+  Constructor
+  \param title Title of the chart
+*/
+QwtPlotAbstractBarChart::QwtPlotAbstractBarChart( const QwtText &title ):
+    QwtPlotSeriesItem( title )
+{
+    d_data = new PrivateData;
+
+    setItemAttribute( QwtPlotItem::Legend, true );
+    setItemAttribute( QwtPlotItem::AutoScale, true );
+    setItemAttribute( QwtPlotItem::Margins, true );
+    setZ( 19.0 );
+}
+
+//! Destructor
+QwtPlotAbstractBarChart::~QwtPlotAbstractBarChart()
+{
+    delete d_data;
+}
+
+/*!
+  The combination of layoutPolicy() and layoutHint() define how the width
+  of the bars is calculated
+
+  \param policy Layout policy
+
+  \sa layoutPolicy(), layoutHint()
+ */
+void QwtPlotAbstractBarChart::setLayoutPolicy( LayoutPolicy policy )
+{
+    if ( policy != d_data->layoutPolicy )
+    {
+        d_data->layoutPolicy = policy;
+        itemChanged();
+    }
+}
+
+/*!
+  The combination of layoutPolicy() and layoutHint() define how the width
+  of the bars is calculated
+
+  \return Layout policy of the chart item
+  \sa setLayoutPolicy(), layoutHint()
+ */
+QwtPlotAbstractBarChart::LayoutPolicy QwtPlotAbstractBarChart::layoutPolicy() const
+{
+    return d_data->layoutPolicy;
+}
+
+/*!
+  The combination of layoutPolicy() and layoutHint() define how the width
+  of the bars is calculated
+
+  \param hint Layout hint
+
+  \sa LayoutPolicy, layoutPolicy(), layoutHint()
+ */
+void QwtPlotAbstractBarChart::setLayoutHint( double hint )
+{
+    hint = qMax( 0.0, hint );
+    if ( hint != d_data->layoutHint )
+    {
+        d_data->layoutHint = hint;
+        itemChanged();
+    }
+}
+
+/*!
+  The combination of layoutPolicy() and layoutHint() define how the width
+  of the bars is calculated
+
+  \return Layout policy of the chart item
+  \sa LayoutPolicy, setLayoutHint(), layoutPolicy()
+*/
+double QwtPlotAbstractBarChart::layoutHint() const
+{
+    return d_data->layoutHint;
+}
+
+/*!
+  \brief Set the spacing
+
+  The spacing is the distance between 2 samples ( bars for QwtPlotBarChart or
+  a group of bars for QwtPlotMultiBarChart ) in paint device coordinates.
+
+  \sa spacing()
+ */
+void QwtPlotAbstractBarChart::setSpacing( int spacing )
+{
+    spacing = qMax( spacing, 0 );
+    if ( spacing != d_data->spacing )
+    {
+        d_data->spacing = spacing;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Spacing between 2 samples ( bars or groups of bars )
+  \sa setSpacing(), margin()
+ */
+int QwtPlotAbstractBarChart::spacing() const
+{
+    return d_data->spacing;
+}
+/*!
+  \brief Set the margin
+
+  The margin is the distance between the outmost bars and the contentsRect()
+  of the canvas. The default setting is 5 pixels.
+
+  \param margin Margin
+
+  \sa spacing(), margin()
+ */
+void QwtPlotAbstractBarChart::setMargin( int margin )
+{
+    margin = qMax( margin, 0 );
+    if ( margin != d_data->margin )
+    {
+        d_data->margin = margin;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Margin between the outmost bars and the contentsRect()
+  of the canvas.
+
+  \sa setMargin(), spacing()
+ */
+int QwtPlotAbstractBarChart::margin() const
+{
+    return d_data->margin;
+}
+
+/*!
+   \brief Set the baseline
+
+   The baseline is the origin for the chart. Each bar is 
+   painted from the baseline in the direction of the sample 
+   value. In case of a horizontal orientation() the baseline
+   is interpreted as x - otherwise as y - value.
+
+   The default value for the baseline is 0.
+
+   \param value Value for the baseline
+
+   \sa baseline(), QwtPlotSeriesItem::orientation()
+*/
+void QwtPlotAbstractBarChart::setBaseline( double value )
+{
+    if ( value != d_data->baseline )
+    {
+        d_data->baseline = value;
+        itemChanged();
+    }
+}
+
+/*! 
+   \return Value for the origin of the bar chart
+   \sa setBaseline(), QwtPlotSeriesItem::orientation()
+ */
+double QwtPlotAbstractBarChart::baseline() const
+{
+    return d_data->baseline;
+}
+
+/*!
+   Calculate the width for a sample in paint device coordinates
+
+   \param map Scale map for the corresponding scale
+   \param canvasSize Size of the canvas in paint device coordinates
+   \param boundingSize Bounding size of the chart in plot coordinates
+                       ( used in AutoAdjustSamples mode )
+   \param value Value of the sample
+
+   \return Sample width
+   \sa layoutPolicy(), layoutHint()
+*/
+double QwtPlotAbstractBarChart::sampleWidth( const QwtScaleMap &map,
+    double canvasSize, double boundingSize, double value ) const
+{
+    double width;
+
+    switch( d_data->layoutPolicy )
+    {
+        case ScaleSamplesToAxes:
+        {
+            width = qwtTransformWidth( map, value, d_data->layoutHint );
+            break;
+        }
+        case ScaleSampleToCanvas:
+        {
+            width = canvasSize * d_data->layoutHint;
+            break;
+        }
+        case FixedSampleSize:
+        {
+            width = d_data->layoutHint;
+            break;
+        }
+        case AutoAdjustSamples:
+        default:
+        {
+            const size_t numSamples = dataSize();
+
+            double w = 1.0;
+            if ( numSamples > 1 )
+            {
+                w = qAbs( boundingSize / ( numSamples - 1 ) );
+            }
+
+            width = qwtTransformWidth( map, value, w );
+            width -= d_data->spacing;
+            width = qMax( width, d_data->layoutHint );
+        }
+    }
+
+    return width;
+}
+
+/*!
+   \brief Calculate a hint for the canvas margin
+
+   Bar charts need to reserve some space for displaying the bars
+   for the first and the last sample.  The hint is calculated
+   from the layoutHint() depending on the layoutPolicy().
+
+   The margins are in target device coordinates ( pixels on screen )
+
+   \param xMap Maps x-values into pixel coordinates.
+   \param yMap Maps y-values into pixel coordinates.
+   \param canvasRect Contents rectangle of the canvas in painter coordinates
+   \param left Returns the left margin
+   \param top Returns the top margin
+   \param right Returns the right margin
+   \param bottom Returns the bottom margin
+
+   \return Margin
+
+   \sa layoutPolicy(), layoutHint(), QwtPlotItem::Margins
+       QwtPlot::getCanvasMarginsHint(), QwtPlot::updateCanvasMargins()
+ */
+void QwtPlotAbstractBarChart::getCanvasMarginHint( const QwtScaleMap &xMap, 
+    const QwtScaleMap &yMap, const QRectF &canvasRect,
+    double &left, double &top, double &right, double &bottom ) const
+{
+    double hint = -1.0;
+
+    switch( layoutPolicy() )
+    {
+        case ScaleSampleToCanvas:
+        {
+            if ( orientation() == Qt::Vertical )
+                hint = 0.5 * canvasRect.width() * d_data->layoutHint;
+            else
+                hint = 0.5 * canvasRect.height() * d_data->layoutHint;
+
+            break;
+        }
+        case FixedSampleSize:
+        {
+            hint = 0.5 * d_data->layoutHint;
+            break;
+        }
+        case AutoAdjustSamples:
+        case ScaleSamplesToAxes:
+        default:
+        {
+            const size_t numSamples = dataSize();
+            if ( numSamples <= 0 )
+                break;
+
+            // doesn't work for nonlinear scales
+
+            const QRectF br = dataRect();
+            double spacing = 0.0;
+            double sampleWidthS = 1.0;
+
+            if ( layoutPolicy() == ScaleSamplesToAxes )
+            {
+                sampleWidthS = qMax( d_data->layoutHint, 0.0 );
+            }
+            else
+            {
+                spacing = d_data->spacing;
+
+                if ( numSamples > 1 )
+                {
+                    sampleWidthS = qAbs( br.width() / ( numSamples - 1 ) );
+                }
+            }
+
+            double ds, w;
+            if ( orientation() == Qt::Vertical )
+            {
+                ds = qAbs( xMap.sDist() );
+                w = canvasRect.width();
+            }
+            else
+            {
+                ds = qAbs( yMap.sDist() );
+                w = canvasRect.height();
+            }
+
+            const double sampleWidthP = ( w - spacing * ( numSamples - 1 ) )
+                * sampleWidthS / ( ds + sampleWidthS );
+
+            hint = 0.5 * sampleWidthP;
+            hint += qMax( d_data->margin, 0 );
+        }
+    }
+
+    if ( orientation() == Qt::Vertical )
+    {
+        left = right = hint;
+        top = bottom = -1.0; // no hint
+    }
+    else
+    {
+        left = right = -1.0; // no hint
+        top = bottom = hint;
+    }
+}
Index: trunk/BNC/qwt/qwt_plot_abstract_barchart.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_abstract_barchart.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_abstract_barchart.h	(revision 8127)
@@ -0,0 +1,97 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_ABSTRACT_BAR_CHART_H
+#define QWT_PLOT_ABSTRACT_BAR_CHART_H
+
+#include "qwt_global.h"
+#include "qwt_plot_seriesitem.h"
+#include "qwt_series_data.h"
+
+/*!
+  \brief Abstract base class for bar chart items
+
+  In opposite to almost all other plot items bar charts can't be 
+  displayed inside of their bounding rectangle and need a special
+  API  how to calculate the width of the bars and how they affect
+  the layout of the attached plot.
+ */
+class QWT_EXPORT QwtPlotAbstractBarChart: public QwtPlotSeriesItem
+{
+public:
+    /*!
+        \brief Mode how to calculate the bar width
+
+        setLayoutPolicy(), setLayoutHint(), barWidthHint()
+     */
+    enum LayoutPolicy
+    {
+        /*!
+          The sample width is calculated by dividing the bounding rectangle
+          by the number of samples. The layoutHint() is used as a minimum width
+          in paint device coordinates.
+
+          \sa boundingRectangle()
+         */
+        AutoAdjustSamples,
+
+        /*!
+          layoutHint() defines an interval in axis coordinates
+         */
+        ScaleSamplesToAxes,
+
+        /*!
+          The bar width is calculated by multiplying layoutHint()
+          with the height or width of the canvas.
+
+          \sa boundingRectangle()
+         */
+        ScaleSampleToCanvas,
+
+        /*!
+          layoutHint() defines a fixed width in paint device coordinates.
+         */
+        FixedSampleSize
+    };
+
+    explicit QwtPlotAbstractBarChart( const QwtText &title );
+    virtual ~QwtPlotAbstractBarChart();
+
+    void setLayoutPolicy( LayoutPolicy );
+    LayoutPolicy layoutPolicy() const;
+
+    void setLayoutHint( double );
+    double layoutHint() const;
+
+    void setSpacing( int );
+    int spacing() const;
+
+    void setMargin( int );
+    int margin() const;
+
+    void setBaseline( double );
+    double baseline() const;
+
+    virtual void getCanvasMarginHint( 
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect,
+        double &left, double &top, double &right, double &bottom) const;
+
+
+protected:
+    double sampleWidth( const QwtScaleMap &map,
+        double canvasSize, double dataSize,
+        double value ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_axis.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_axis.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_axis.cpp	(revision 8127)
@@ -27,4 +27,6 @@
     int maxMinor;
 
+    bool isValid;
+
     QwtScaleDiv scaleDiv;
     QwtScaleEngine *scaleEngine;
@@ -54,10 +56,18 @@
     d_axisData[xBottom]->scaleWidget->setObjectName( "QwtPlotAxisXBottom" );
 
+#if 1
+    // better find the font sizes from the application font
     QFont fscl( fontInfo().family(), 10 );
     QFont fttl( fontInfo().family(), 12, QFont::Bold );
+#endif
 
     for ( axisId = 0; axisId < axisCnt; axisId++ )
     {
         AxisData &d = *d_axisData[axisId];
+
+        d.scaleEngine = new QwtLinearScaleEngine;
+
+        d.scaleWidget->setTransformation( 
+            d.scaleEngine->transformation() );
 
         d.scaleWidget->setFont( fscl );
@@ -77,7 +87,6 @@
         d.maxMajor = 8;
 
-        d.scaleEngine = new QwtLinearScaleEngine;
-
-        d.scaleDiv.invalidate();
+
+        d.isValid = false;
     }
 
@@ -99,6 +108,6 @@
 
 /*!
-  \return specified axis, or NULL if axisId is invalid.
-  \param axisId axis index
+  \return Scale widget of the specified axis, or NULL if axisId is invalid.
+  \param axisId Axis index
 */
 const QwtScaleWidget *QwtPlot::axisWidget( int axisId ) const
@@ -111,6 +120,6 @@
 
 /*!
-  \return specified axis, or NULL if axisId is invalid.
-  \param axisId axis index
+  \return Scale widget of the specified axis, or NULL if axisId is invalid.
+  \param axisId Axis index
 */
 QwtScaleWidget *QwtPlot::axisWidget( int axisId )
@@ -123,7 +132,7 @@
 
 /*!
-   Change the scale engine for an axis
-
-  \param axisId axis index
+  Change the scale engine for an axis
+
+  \param axisId Axis index
   \param scaleEngine Scale engine
 
@@ -139,5 +148,8 @@
         d.scaleEngine = scaleEngine;
 
-        d.scaleDiv.invalidate();
+        d_axisData[axisId]->scaleWidget->setTransformation( 
+            scaleEngine->transformation() );
+
+        d.isValid = false;
 
         autoRefresh();
@@ -146,5 +158,5 @@
 
 /*!
-  \param axisId axis index
+  \param axisId Axis index
   \return Scale engine for a specific axis
 */
@@ -158,5 +170,5 @@
 
 /*!
-  \param axisId axis index
+  \param axisId Axis index
   \return Scale engine for a specific axis
 */
@@ -169,6 +181,6 @@
 }
 /*!
-  \return \c true if autoscaling is enabled
-  \param axisId axis index
+  \return \c True, if autoscaling is enabled
+  \param axisId Axis index
 */
 bool QwtPlot::axisAutoScale( int axisId ) const
@@ -182,6 +194,6 @@
 
 /*!
-  \return \c true if a specified axis is enabled
-  \param axisId axis index
+  \return \c True, if a specified axis is enabled
+  \param axisId Axis index
 */
 bool QwtPlot::axisEnabled( int axisId ) const
@@ -194,6 +206,6 @@
 
 /*!
-  \return the font of the scale labels for a specified axis
-  \param axisId axis index
+  \return The font of the scale labels for a specified axis
+  \param axisId Axis index
 */
 QFont QwtPlot::axisFont( int axisId ) const
@@ -207,7 +219,7 @@
 
 /*!
-  \return the maximum number of major ticks for a specified axis
-  \param axisId axis index
-  \sa setAxisMaxMajor()
+  \return The maximum number of major ticks for a specified axis
+  \param axisId Axis index
+  \sa setAxisMaxMajor(), QwtScaleEngine::divideScale()
 */
 int QwtPlot::axisMaxMajor( int axisId ) const
@@ -221,6 +233,6 @@
 /*!
   \return the maximum number of minor ticks for a specified axis
-  \param axisId axis index
-  \sa setAxisMaxMinor()
+  \param axisId Axis index
+  \sa setAxisMaxMinor(), QwtScaleEngine::divideScale()
 */
 int QwtPlot::axisMaxMinor( int axisId ) const
@@ -235,76 +247,54 @@
   \brief Return the scale division of a specified axis
 
-  axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound()
+  axisScaleDiv(axisId).lowerBound(), axisScaleDiv(axisId).upperBound()
   are the current limits of the axis scale.
 
-  \param axisId axis index
+  \param axisId Axis index
   \return Scale division
 
-  \sa QwtScaleDiv, setAxisScaleDiv()
-*/
-const QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId ) const
+  \sa QwtScaleDiv, setAxisScaleDiv(), QwtScaleEngine::divideScale()
+*/
+const QwtScaleDiv &QwtPlot::axisScaleDiv( int axisId ) const
+{
+    return d_axisData[axisId]->scaleDiv;
+}
+
+/*!
+  \brief Return the scale draw of a specified axis
+
+  \param axisId Axis index
+  \return Specified scaleDraw for axis, or NULL if axis is invalid.
+*/
+const QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) const
 {
     if ( !axisValid( axisId ) )
         return NULL;
 
-    return &d_axisData[axisId]->scaleDiv;
-}
-
-/*!
-  \brief Return the scale division of a specified axis
-
-  axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound()
-  are the current limits of the axis scale.
-
-  \param axisId axis index
-  \return Scale division
-
-  \sa QwtScaleDiv, setAxisScaleDiv()
-*/
-QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId )
+    return axisWidget( axisId )->scaleDraw();
+}
+
+/*!
+  \brief Return the scale draw of a specified axis
+
+  \param axisId Axis index
+  \return Specified scaleDraw for axis, or NULL if axis is invalid.
+*/
+QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId )
 {
     if ( !axisValid( axisId ) )
         return NULL;
 
-    return &d_axisData[axisId]->scaleDiv;
-}
-
-/*!
-  \returns the scale draw of a specified axis
-  \param axisId axis index
-  \return specified scaleDraw for axis, or NULL if axis is invalid.
-  \sa QwtScaleDraw
-*/
-const QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) const
-{
-    if ( !axisValid( axisId ) )
-        return NULL;
-
     return axisWidget( axisId )->scaleDraw();
 }
 
 /*!
-  \returns the scale draw of a specified axis
-  \param axisId axis index
-  \return specified scaleDraw for axis, or NULL if axis is invalid.
-  \sa QwtScaleDraw
-*/
-QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId )
-{
-    if ( !axisValid( axisId ) )
-        return NULL;
-
-    return axisWidget( axisId )->scaleDraw();
-}
-
-/*!
-   Return the step size parameter, that has been set
-   in setAxisScale. This doesn't need to be the step size
-   of the current scale.
-
-  \param axisId axis index
+  \brief Return the step size parameter that has been set in setAxisScale. 
+
+  This doesn't need to be the step size of the current scale.
+
+  \param axisId Axis index
   \return step size parameter value
 
-   \sa setAxisScale()
+   \sa setAxisScale(), QwtScaleEngine::divideScale()
 */
 double QwtPlot::axisStepSize( int axisId ) const
@@ -321,5 +311,5 @@
   This is only a convenience function for axisScaleDiv( axisId )->interval();
   
-  \param axisId axis index
+  \param axisId Axis index
   \return Scale interval
 
@@ -335,6 +325,6 @@
 
 /*!
-  \return the title of a specified axis
-  \param axisId axis index
+  \return Title of a specified axis
+  \param axisId Axis index
 */
 QwtText QwtPlot::axisTitle( int axisId ) const
@@ -355,5 +345,6 @@
 
   Only xBottom and yLeft are enabled by default.
-  \param axisId axis index
+
+  \param axisId Axis index
   \param tf \c true (enabled) or \c false (disabled)
 */
@@ -370,6 +361,10 @@
   Transform the x or y coordinate of a position in the
   drawing region into a value.
-  \param axisId axis index
+
+  \param axisId Axis index
   \param pos position
+
+  \return Position as axis coordinate
+
   \warning The position can be an x or a y coordinate,
            depending on the specified axis.
@@ -386,7 +381,8 @@
 /*!
   \brief Transform a value into a coordinate in the plotting region
-  \param axisId axis index
+
+  \param axisId Axis index
   \param value value
-  \return X or y coordinate in the plotting region corresponding
+  \return X or Y coordinate in the plotting region corresponding
           to the value.
 */
@@ -401,13 +397,14 @@
 /*!
   \brief Change the font of an axis
-  \param axisId axis index
-  \param f font
+
+  \param axisId Axis index
+  \param font Font
   \warning This function changes the font of the tick labels,
            not of the axis title.
 */
-void QwtPlot::setAxisFont( int axisId, const QFont &f )
-{
-    if ( axisValid( axisId ) )
-        axisWidget( axisId )->setFont( f );
+void QwtPlot::setAxisFont( int axisId, const QFont &font )
+{
+    if ( axisValid( axisId ) )
+        axisWidget( axisId )->setFont( font );
 }
 
@@ -418,5 +415,5 @@
   after a fixed scale has been set. Autoscaling is enabled by default.
 
-  \param axisId axis index
+  \param axisId Axis index
   \param on On/Off
   \sa setAxisScale(), setAxisScaleDiv(), updateAxes()
@@ -436,10 +433,16 @@
 /*!
   \brief Disable autoscaling and specify a fixed scale for a selected axis.
-  \param axisId axis index
-  \param min
-  \param max minimum and maximum of the scale
+
+  In updateAxes() the scale engine calculates a scale division from the 
+  specified parameters, that will be assigned to the scale widget. So 
+  updates of the scale widget usually happen delayed with the next replot.
+
+  \param axisId Axis index
+  \param min Minimum of the scale
+  \param max Maximum of the scale
   \param stepSize Major step size. If <code>step == 0</code>, the step size is
-            calculated automatically using the maxMajor setting.
-  \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize()
+                  calculated automatically using the maxMajor setting.
+
+  \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), QwtScaleEngine::divideScale()
 */
 void QwtPlot::setAxisScale( int axisId, double min, double max, double stepSize )
@@ -450,5 +453,5 @@
 
         d.doAutoScale = false;
-        d.scaleDiv.invalidate();
+        d.isValid = false;
 
         d.minValue = min;
@@ -462,6 +465,12 @@
 /*!
   \brief Disable autoscaling and specify a fixed scale for a selected axis.
-  \param axisId axis index
+
+  The scale division will be stored locally only until the next call
+  of updateAxes(). So updates of the scale widget usually happen delayed with 
+  the next replot.
+
+  \param axisId Axis index
   \param scaleDiv Scale division
+
   \sa setAxisScale(), setAxisAutoScale()
 */
@@ -474,4 +483,5 @@
         d.doAutoScale = false;
         d.scaleDiv = scaleDiv;
+        d.isValid = true;
 
         autoRefresh();
@@ -481,6 +491,7 @@
 /*!
   \brief Set a scale draw
-  \param axisId axis index
-  \param scaleDraw object responsible for drawing scales.
+
+  \param axisId Axis index
+  \param scaleDraw Object responsible for drawing scales.
 
   By passing scaleDraw it is possible to extend QwtScaleDraw
@@ -505,6 +516,8 @@
 /*!
   Change the alignment of the tick labels
-  \param axisId axis index
+
+  \param axisId Axis index
   \param alignment Or'd Qt::AlignmentFlags see <qnamespace.h>
+
   \sa QwtScaleDraw::setLabelAlignment()
 */
@@ -517,7 +530,9 @@
 /*!
   Rotate all tick labels
-  \param axisId axis index
+
+  \param axisId Axis index
   \param rotation Angle in degrees. When changing the label rotation,
                   the label alignment might be adjusted too.
+
   \sa QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment()
 */
@@ -531,6 +546,7 @@
   Set the maximum number of minor scale intervals for a specified axis
 
-  \param axisId axis index
-  \param maxMinor maximum number of minor steps
+  \param axisId Axis index
+  \param maxMinor Maximum number of minor steps
+
   \sa axisMaxMinor()
 */
@@ -545,5 +561,5 @@
         {
             d.maxMinor = maxMinor;
-            d.scaleDiv.invalidate();
+            d.isValid = false;
             autoRefresh();
         }
@@ -554,6 +570,7 @@
   Set the maximum number of major scale intervals for a specified axis
 
-  \param axisId axis index
-  \param maxMajor maximum number of major steps
+  \param axisId Axis index
+  \param maxMajor Maximum number of major steps
+
   \sa axisMaxMajor()
 */
@@ -568,5 +585,5 @@
         {
             d.maxMajor = maxMajor;
-            d.scaleDiv.invalidate();
+            d.isValid = false;
             autoRefresh();
         }
@@ -576,5 +593,6 @@
 /*!
   \brief Change the title of a specified axis
-  \param axisId axis index
+
+  \param axisId Axis index
   \param title axis title
 */
@@ -587,6 +605,7 @@
 /*!
   \brief Change the title of a specified axis
-  \param axisId axis index
-  \param title axis title
+
+  \param axisId Axis index
+  \param title Axis title
 */
 void QwtPlot::setAxisTitle( int axisId, const QwtText &title )
@@ -596,5 +615,28 @@
 }
 
-//! Rebuild the scales
+/*! 
+  \brief Rebuild the axes scales
+
+  In case of autoscaling the boundaries of a scale are calculated 
+  from the bounding rectangles of all plot items, having the 
+  QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). 
+  Then a scale division is calculated ( QwtScaleEngine::didvideScale() ) 
+  and assigned to scale widget.
+
+  When the scale boundaries have been assigned with setAxisScale() a 
+  scale division is calculated ( QwtScaleEngine::didvideScale() )
+  for this interval and assigned to the scale widget.
+
+  When the scale has been set explicitly by setAxisScaleDiv() the 
+  locally stored scale division gets assigned to the scale widget.
+
+  The scale widget indicates modifications by emitting a 
+  QwtScaleWidget::scaleDivChanged() signal.
+
+  updateAxes() is usually called by replot(). 
+
+  \sa setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot()
+      QwtPlotItem::boundingRect()
+ */
 void QwtPlot::updateAxes()
 {
@@ -620,6 +662,10 @@
         {
             const QRectF rect = item->boundingRect();
-            intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() );
-            intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() );
+
+            if ( rect.width() >= 0.0 )
+                intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() );
+
+            if ( rect.height() >= 0.0 )
+                intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() );
         }
     }
@@ -637,5 +683,5 @@
         if ( d.doAutoScale && intv[axisId].isValid() )
         {
-            d.scaleDiv.invalidate();
+            d.isValid = false;
 
             minValue = intv[axisId].minValue();
@@ -645,14 +691,14 @@
                 minValue, maxValue, stepSize );
         }
-        if ( !d.scaleDiv.isValid() )
+        if ( !d.isValid )
         {
             d.scaleDiv = d.scaleEngine->divideScale(
                 minValue, maxValue,
                 d.maxMajor, d.maxMinor, stepSize );
+            d.isValid = true;
         }
 
         QwtScaleWidget *scaleWidget = axisWidget( axisId );
-        scaleWidget->setScaleDiv(
-            d.scaleEngine->transformation(), d.scaleDiv );
+        scaleWidget->setScaleDiv( d.scaleDiv );
 
         int startDist, endDist;
@@ -664,7 +710,10 @@
     {
         QwtPlotItem *item = *it;
-        item->updateScaleDiv( *axisScaleDiv( item->xAxis() ),
-            *axisScaleDiv( item->yAxis() ) );
-    }
-}
-
+        if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) )
+        {
+            item->updateScaleDiv( axisScaleDiv( item->xAxis() ),
+                axisScaleDiv( item->yAxis() ) );
+        }
+    }
+}
+
Index: trunk/BNC/qwt/qwt_plot_barchart.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_barchart.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_barchart.cpp	(revision 8127)
@@ -0,0 +1,459 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_barchart.h"
+#include "qwt_scale_map.h"
+#include "qwt_column_symbol.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+
+class QwtPlotBarChart::PrivateData
+{
+public:
+    PrivateData():
+        symbol( NULL ),
+        legendMode( QwtPlotBarChart::LegendChartTitle )
+    {
+    }
+ 
+    ~PrivateData()
+    {
+        delete symbol;
+    }
+
+    QwtColumnSymbol *symbol;
+    QwtPlotBarChart::LegendMode legendMode;
+};
+
+/*!
+  Constructor
+  \param title Title of the curve
+*/
+QwtPlotBarChart::QwtPlotBarChart( const QwtText &title ):
+    QwtPlotAbstractBarChart( title )
+{
+    init();
+}
+
+/*!
+  Constructor
+  \param title Title of the curve
+*/
+QwtPlotBarChart::QwtPlotBarChart( const QString &title ):
+    QwtPlotAbstractBarChart( QwtText( title ) )
+{
+    init();
+}
+
+//! Destructor
+QwtPlotBarChart::~QwtPlotBarChart()
+{
+    delete d_data;
+}
+
+void QwtPlotBarChart::init()
+{
+    d_data = new PrivateData;
+    setData( new QwtPointSeriesData() );
+}
+
+//! \return QwtPlotItem::Rtti_PlotBarChart
+int QwtPlotBarChart::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotBarChart;
+}
+
+/*!
+  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 )
+{
+    setData( new QwtPointSeriesData( samples ) );
+}
+
+/*!
+  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;
+    for ( int i = 0; i < samples.size(); i++ )
+        points += QPointF( i, samples[ i ] );
+
+    setData( new QwtPointSeriesData( points ) );
+}
+
+/*!
+  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 )
+{
+    setData( data );
+}
+
+/*!
+  \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;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \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
+ */
+void QwtPlotBarChart::setLegendMode( LegendMode mode )
+{
+    if ( mode != d_data->legendMode )
+    {
+        d_data->legendMode = mode;
+        legendChanged();
+    }
+}
+
+/*!
+  \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.
+*/
+QRectF QwtPlotBarChart::boundingRect() const
+{
+    const size_t numSamples = dataSize();
+    if ( numSamples == 0 )
+        return QwtPlotSeriesItem::boundingRect();
+
+    QRectF rect = QwtPlotSeriesItem::boundingRect();
+    if ( rect.height() >= 0 )
+    {
+        const double baseLine = baseline();
+
+        if ( rect.bottom() < baseLine )
+            rect.setBottom( baseLine );
+
+        if ( rect.top() > baseLine )
+            rect.setTop( baseLine );
+    }
+
+    if ( orientation() == Qt::Horizontal )
+        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
+
+    return rect;
+}
+
+/*!
+  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
+{
+    if ( to < 0 )
+        to = dataSize() - 1;
+
+    if ( from < 0 )
+        from = 0;
+
+    if ( from > to )
+        return;
+
+
+    const QRectF br = data()->boundingRect();
+    const QwtInterval interval( br.left(), br.right() );
+
+    painter->save();
+
+    for ( int i = from; i <= to; i++ )
+    {
+        drawSample( painter, xMap, yMap,
+                    canvasRect, interval, i, sample( i ) );
+    }
+
+    painter->restore();
+}
+
+/*!
+  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
+{
+    QwtColumnRect barRect;
+
+    if ( orientation() == Qt::Horizontal )
+    {
+        const double barHeight = sampleWidth( yMap, canvasRect.height(),
+            boundingInterval.width(), sample.y() );
+
+        const double x1 = xMap.transform( baseline() );
+        const double x2 = xMap.transform( sample.y() );
+
+        const double y = yMap.transform( sample.x() );
+        const double y1 = y - 0.5 * barHeight;
+        const double y2 = y + 0.5 * barHeight;
+
+        barRect.direction = ( x1 < x2 ) ?
+            QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;
+
+        barRect.hInterval = QwtInterval( x1, x2 ).normalized();
+        barRect.vInterval = QwtInterval( y1, y2 );
+    }
+    else
+    {
+        const double barWidth = sampleWidth( xMap, canvasRect.width(),
+            boundingInterval.width(), sample.y() );
+
+        const double x = xMap.transform( sample.x() );
+        const double x1 = x - 0.5 * barWidth;
+        const double x2 = x + 0.5 * barWidth;
+
+        const double y1 = yMap.transform( baseline() );
+        const double y2 = yMap.transform( sample.y() );
+
+        barRect.direction = ( y1 < y2 ) ?
+            QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;
+
+        barRect.hInterval = QwtInterval( x1, x2 );
+        barRect.vInterval = QwtInterval( y1, y2 ).normalized();
+    }
+
+    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 = 
+        specialSymbol( sampleIndex, sample );
+
+    const QwtColumnSymbol *sym = specialSym;
+    if ( sym == NULL )
+        sym = d_data->symbol;
+
+    if ( sym )
+    {
+        sym->draw( painter, rect );
+    }
+    else
+    {
+        // we build a temporary default symbol
+        QwtColumnSymbol sym( QwtColumnSymbol::Box );
+        sym.setLineWidth( 1 );
+        sym.setFrameStyle( QwtColumnSymbol::Plain );
+        sym.draw( painter, rect );
+    }
+
+    delete specialSym;
+}
+
+/*!
+  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 );
+    Q_UNUSED( sample );
+
+    return NULL;
+}
+
+/*!
+  \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
+{
+    Q_UNUSED( sampleIndex );
+    return QwtText();
+}
+
+/*!
+   \brief Return all information, that is needed to represent
+          the item on the legend
+
+   In case of LegendBarTitles an entry for each bar is returned,
+   otherwise the chart is represented like any other plot item
+   from its title() and the legendIcon().
+
+   \return Information, that is needed to represent the item on the legend
+   \sa title(), setLegendMode(), barTitle(), QwtLegend, QwtPlotLegendItem
+ */
+QList<QwtLegendData> QwtPlotBarChart::legendData() const
+{
+    QList<QwtLegendData> list;
+
+    if ( d_data->legendMode == LegendBarTitles )
+    {
+        const size_t numSamples = dataSize();
+        for ( size_t i = 0; i < numSamples; i++ )
+        {
+            QwtLegendData data;
+
+            QVariant titleValue;
+            qVariantSetValue( titleValue, barTitle( i ) );
+            data.setValue( QwtLegendData::TitleRole, titleValue );
+
+            if ( !legendIconSize().isEmpty() )
+            {
+                QVariant iconValue;
+                qVariantSetValue( iconValue,
+                    legendIcon( i, legendIconSize() ) );
+
+                data.setValue( QwtLegendData::IconRole, iconValue );
+            }
+
+            list += data;
+        }
+    }
+    else
+    {
+        return QwtPlotAbstractBarChart::legendData();
+    }
+
+    return list;
+}
+
+/*!
+   \return Icon representing a bar or the chart on the legend
+
+   When the legendMode() is LegendBarTitles the icon shows
+   the bar corresponding to index - otherwise the bar
+   displays the default symbol.
+
+   \param index Index of the legend entry 
+   \param size Icon size
+
+   \sa setLegendMode(), drawBar(), 
+       QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
+ */
+QwtGraphic QwtPlotBarChart::legendIcon( 
+    int index, const QSizeF &size ) const
+{
+    QwtColumnRect column;
+    column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
+    column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );
+
+    QwtGraphic icon;
+    icon.setDefaultSize( size );
+    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &icon );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPlotItem::RenderAntialiased ) );
+
+    int barIndex = -1;
+    if ( d_data->legendMode == QwtPlotBarChart::LegendBarTitles )
+        barIndex = index;
+        
+    drawBar( &painter, barIndex, QPointF(), column );
+
+    return icon;
+}
Index: trunk/BNC/qwt/qwt_plot_barchart.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_barchart.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_barchart.h	(revision 8127)
@@ -0,0 +1,118 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_BAR_CHART_H
+#define QWT_PLOT_BAR_CHART_H
+
+#include "qwt_global.h"
+#include "qwt_plot_abstract_barchart.h"
+#include "qwt_series_data.h"
+
+class QwtColumnRect;
+class QwtColumnSymbol;
+
+/*!
+  \brief QwtPlotBarChart displays a series of a values as bars.
+
+  Each bar might be customized individually by implementing
+  a specialSymbol(). Otherwise it is rendered using a default symbol.
+
+  Depending on its orientation() the bars are displayed horizontally 
+  or vertically. The bars cover the interval between the baseline() 
+  and the value.
+
+  By activating the LegendBarTitles mode each sample will have
+  its own entry on the legend.
+
+  The most common use case of a bar chart is to display a
+  list of y coordinates, where the x coordinate is simply the index
+  in the list. But for other situations ( f.e. when values are related
+  to dates ) it is also possible to set x coordinates explicitly.
+
+  \sa QwtPlotMultiBarChart, QwtPlotHistogram, QwtPlotCurve::Sticks,
+      QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
+ */
+class QWT_EXPORT QwtPlotBarChart:
+    public QwtPlotAbstractBarChart, public QwtSeriesStore<QPointF>
+{
+public:
+    /*!
+      \brief Legend modes.
+
+      The default setting is QwtPlotBarChart::LegendChartTitle.
+      \sa setLegendMode(), legendMode()
+    */
+    enum LegendMode
+    {
+        /*! 
+          One entry on the legend showing the default symbol
+          and the title() of the chart
+
+          \sa QwtPlotItem::title()
+         */
+        LegendChartTitle,
+
+        /*!
+          One entry for each value showing the individual symbol
+          of the corresponding bar and the bar title.
+
+          \sa specialSymbol(), barTitle()
+         */
+        LegendBarTitles
+    };
+
+    explicit QwtPlotBarChart( const QString &title = QString::null );
+    explicit QwtPlotBarChart( const QwtText &title );
+
+    virtual ~QwtPlotBarChart();
+
+    virtual int rtti() const;
+
+    void setSamples( const QVector<QPointF> & );
+    void setSamples( const QVector<double> & );
+    void setSamples( QwtSeriesData<QPointF> *series );
+
+    void setSymbol( QwtColumnSymbol * );
+    const QwtColumnSymbol *symbol() const;
+
+    void setLegendMode( LegendMode );
+    LegendMode legendMode() const;
+
+    virtual void drawSeries( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual QRectF boundingRect() const;
+
+    virtual QwtColumnSymbol *specialSymbol( 
+        int sampleIndex, const QPointF& ) const;
+
+    virtual QwtText barTitle( int sampleIndex ) const;
+
+protected:
+    virtual void drawSample( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, const QwtInterval &boundingInterval,
+        int index, const QPointF& sample ) const;
+
+    virtual void drawBar( QPainter *,
+        int sampleIndex, const QPointF& point, 
+        const QwtColumnRect & ) const;
+
+    QList<QwtLegendData> legendData() const;
+    QwtGraphic legendIcon( int index, const QSizeF & ) const;
+
+private:
+    void init();
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_canvas.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_canvas.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_canvas.cpp	(revision 8127)
@@ -18,8 +18,4 @@
 #include <qpaintengine.h>
 #include <qevent.h>
-#include <qbitmap.h>
-#ifdef Q_WS_X11
-#include <qx11info_x11.h>
-#endif
 
 class QwtStyleSheetRecorder: public QwtNullPaintDevice
@@ -27,7 +23,6 @@
 public:
     QwtStyleSheetRecorder( const QSize &size ):
-        QwtNullPaintDevice( QPaintEngine::AllFeatures )
-    {
-        setSize( size );
+        d_size( size )
+    {
     }
 
@@ -56,5 +51,5 @@
     virtual void drawPath( const QPainterPath &path )
     {
-        const QRectF rect( QPointF( 0.0, 0.0 ) , size() );
+        const QRectF rect( QPointF( 0.0, 0.0 ), d_size );
         if ( path.controlPointRect().contains( rect.center() ) )
         {
@@ -117,4 +112,10 @@
     }
 
+protected:
+    virtual QSize sizeMetrics() const
+    {
+        return d_size;
+    }
+
 private:
     void alignCornerRects( const QRectF &rect )
@@ -154,4 +155,6 @@
 
 private:
+    const QSize d_size;
+
     QPen d_pen;
     QBrush d_brush;
@@ -159,13 +162,19 @@
 };
 
-static void qwtDrawBackground( QPainter *painter, QWidget *widget )
-{
+static void qwtDrawBackground( QPainter *painter, QwtPlotCanvas *canvas )
+{
+    painter->save();
+
+    const QPainterPath borderClip = canvas->borderPath( canvas->rect() );
+    if ( !borderClip.isEmpty() )
+        painter->setClipPath( borderClip, Qt::IntersectClip );
+
     const QBrush &brush = 
-        widget->palette().brush( widget->backgroundRole() );
+        canvas->palette().brush( canvas->backgroundRole() );
 
     if ( brush.style() == Qt::TexturePattern )
     {
-        QPixmap pm( widget->size() );
-        pm.fill( widget, 0, 0 );
+        QPixmap pm( canvas->size() );
+        QwtPainter::fillPixmap( canvas, pm );
         painter->drawPixmap( 0, 0, pm );
     }
@@ -176,5 +185,5 @@
         if ( brush.gradient()->coordinateMode() == QGradient::ObjectBoundingMode )
         {
-            rects += widget->rect();
+            rects += canvas->rect();
         } 
         else 
@@ -215,5 +224,5 @@
             }
             
-            QImage image( widget->size(), format );
+            QImage image( canvas->size(), format );
 
             QPainter p( &image );
@@ -229,18 +238,12 @@
         else
         {
-            painter->save();
-
             painter->setPen( Qt::NoPen );
             painter->setBrush( brush );
 
             painter->drawRects( rects );
-
-            painter->restore();
         }
     }
     else
     {
-        painter->save();
-
         painter->setPen( Qt::NoPen );
         painter->setBrush( brush );
@@ -248,6 +251,7 @@
         painter->drawRects( painter->clipRegion().rects() );
 
-        painter->restore();
-    }
+    }
+
+    painter->restore();
 }
 
@@ -256,11 +260,9 @@
     if ( path.elementCount() == 4 )
     {
-        QPainterPath::Element &el0 = 
-            const_cast<QPainterPath::Element &>( path.elementAt(0) );
-        QPainterPath::Element &el2 = 
-            const_cast<QPainterPath::Element &>( path.elementAt(3) );
-
-        qSwap( el0.x, el2.x );
-        qSwap( el0.y, el2.y );
+        QPainterPath::Element el0 = path.elementAt(0);
+        QPainterPath::Element el3 = path.elementAt(3);
+
+        path.setElementPositionAt( 0, el3.x, el3.y );
+        path.setElementPositionAt( 3, el0.x, el0.y );
     }
 }
@@ -439,5 +441,5 @@
         {
             QPixmap pm( rect.size() );
-            pm.fill( bgWidget, widget->mapTo( bgWidget, rect.topLeft() ) );
+            QwtPainter::fillPixmap( bgWidget, pm, widget->mapTo( bgWidget, rect.topLeft() ) );
             painter->drawPixmap( rect, pm );
         }
@@ -468,5 +470,5 @@
         if ( radius > 0.0 )
         {
-            QSize sz( radius, radius );
+            QSizeF sz( radius, radius );
 
             rects += QRectF( r.topLeft(), sz );
@@ -519,9 +521,16 @@
 };
 
-//! Sets a cross cursor, enables QwtPlotCanvas::BackingStore
-
+/*! 
+  \brief Constructor
+
+  \param plot Parent plot widget
+  \sa QwtPlot::setCanvas()
+*/
 QwtPlotCanvas::QwtPlotCanvas( QwtPlot *plot ):
     QFrame( plot )
 {
+    setFrameStyle( QFrame::Panel | QFrame::Sunken );
+    setLineWidth( 2 );
+
     d_data = new PrivateData;
 
@@ -545,5 +554,5 @@
 QwtPlot *QwtPlotCanvas::plot()
 {
-    return qobject_cast<QwtPlot *>( parentWidget() );
+    return qobject_cast<QwtPlot *>( parent() );
 }
 
@@ -551,5 +560,5 @@
 const QwtPlot *QwtPlotCanvas::plot() const
 {
-    return qobject_cast<const QwtPlot *>( parentWidget() );
+    return qobject_cast<const QwtPlot *>( parent() );
 }
 
@@ -583,6 +592,10 @@
                 if ( isVisible() )
                 {
+#if QT_VERSION >= 0x050000
+                    *d_data->backingStore = grab( rect() );
+#else
                     *d_data->backingStore = 
                         QPixmap::grabWidget( this, rect() );
+#endif
                 }
             }
@@ -610,8 +623,8 @@
 
 /*!
-  Test wether a paint attribute is enabled
+  Test whether a paint attribute is enabled
 
   \param attribute Paint attribute
-  \return true if the attribute is enabled
+  \return true, when attribute is enabled
   \sa setPaintAttribute()
 */
@@ -676,5 +689,7 @@
 /*!
   Qt event handler for QEvent::PolishRequest and QEvent::StyleChange
+
   \param event Qt Event
+  \return See QFrame::event()
 */
 bool QwtPlotCanvas::event( QEvent *event )
@@ -716,10 +731,5 @@
         if ( bs.size() != size() )
         {
-            bs = QPixmap( size() );
-
-#ifdef Q_WS_X11
-            if ( bs.x11Info().screen() != x11Info().screen() )
-                bs.x11SetScreen( x11Info().screen() );
-#endif
+            bs = QwtPainter::backingStore( this, size() );
 
             if ( testAttribute(Qt::WA_StyledBackground) )
@@ -734,5 +744,5 @@
                 if ( d_data->borderRadius <= 0.0 )
                 {
-                    bs.fill( this, 0, 0 );
+                    QwtPainter::fillPixmap( this, bs );
                     p.begin( &bs );
                     drawCanvas( &p, false );
@@ -771,5 +781,25 @@
             {
                 if ( autoFillBackground() )
+                {
+                    qwtFillBackground( &painter, this );
                     qwtDrawBackground( &painter, this );
+                }
+            }
+            else
+            {
+                if ( borderRadius() > 0.0 )
+                {
+                    QPainterPath clipPath;
+                    clipPath.addRect( rect() );
+                    clipPath = clipPath.subtracted( borderPath( rect() ) );
+
+                    painter.save();
+
+                    painter.setClipPath( clipPath, Qt::IntersectClip );
+                    qwtFillBackground( &painter, this );
+                    qwtDrawBackground( &painter, this );
+
+                    painter.restore();
+                }
             }
 
@@ -838,5 +868,5 @@
             painter->setBrush( palette().brush( backgroundRole() ) );
 
-            if ( d_data->borderRadius > 0.0 )
+            if ( d_data->borderRadius > 0.0 && ( rect() == frameRect() ) )
             {
                 if ( frameWidth() > 0 )
@@ -853,5 +883,5 @@
             else
             {
-                painter->drawRect( contentsRect() );
+                painter->drawRect( rect() );
             }
         }
@@ -870,5 +900,5 @@
     {
         if ( d_data->borderRadius > 0.0 )
-            painter->setClipPath( borderPath( rect() ), Qt::IntersectClip );
+            painter->setClipPath( borderPath( frameRect() ), Qt::IntersectClip );
         else
             painter->setClipRect( contentsRect(), Qt::IntersectClip );
@@ -892,5 +922,5 @@
 
   \param painter Painter
-  \sa setBorderRadius(), QFrame::drawFrame()
+  \sa setBorderRadius()
 */
 void QwtPlotCanvas::drawBorder( QPainter *painter )
@@ -900,5 +930,5 @@
         if ( frameWidth() > 0 )
         {
-            QwtPainter::drawRoundedFrame( painter, QRectF( rect() ), 
+            QwtPainter::drawRoundedFrame( painter, QRectF( frameRect() ), 
                 d_data->borderRadius, d_data->borderRadius,
                 palette(), frameWidth(), frameStyle() );
@@ -907,5 +937,48 @@
     else
     {
+#if QT_VERSION >= 0x040500
+#if QT_VERSION < 0x050000
+        QStyleOptionFrameV3 opt;
+#else
+        QStyleOptionFrame opt;
+#endif
+        opt.init(this);
+
+        int frameShape  = frameStyle() & QFrame::Shape_Mask;
+        int frameShadow = frameStyle() & QFrame::Shadow_Mask;
+
+        opt.frameShape = QFrame::Shape( int( opt.frameShape ) | frameShape );
+#if 0
+        opt.rect = frameRect();
+#endif
+
+        switch (frameShape) 
+        {
+            case QFrame::Box:
+            case QFrame::HLine:
+            case QFrame::VLine:
+            case QFrame::StyledPanel:
+            case QFrame::Panel:
+            {
+                opt.lineWidth = lineWidth();
+                opt.midLineWidth = midLineWidth();
+                break; 
+            }
+            default: 
+            {
+                opt.lineWidth = frameWidth();
+                break;
+            }
+        }
+    
+        if ( frameShadow == Sunken )
+            opt.state |= QStyle::State_Sunken;
+        else if ( frameShadow == Raised )
+            opt.state |= QStyle::State_Raised;
+
+        style()->drawControl(QStyle::CE_ShapedFrame, &opt, painter, this);
+#else
         drawFrame( painter );
+#endif
     }
 }
@@ -950,5 +1023,5 @@
 }
 
-//! Update the cached informations about the current style sheet
+//! Update the cached information about the current style sheet
 void QwtPlotCanvas::updateStyleSheetInfo()
 {
@@ -1027,53 +1100,2 @@
     return QPainterPath();
 }
-
-/*!
-   Calculate a mask, that can be used to clip away the border frame
-
-   \param size Size including the frame
-*/
-QBitmap QwtPlotCanvas::borderMask( const QSize &size ) const
-{
-    const QRect r( 0, 0, size.width(), size.height() );
-
-    const QPainterPath path = borderPath( r );
-    if ( path.isEmpty() )
-        return QBitmap();
-
-    QImage image( size, QImage::Format_ARGB32_Premultiplied );
-    image.fill( Qt::color0 );
-
-    QPainter painter( &image );
-    painter.setClipPath( path );
-    painter.fillRect( r, Qt::color1 );
-
-    // now erase the frame
-
-    painter.setCompositionMode( QPainter::CompositionMode_DestinationOut );
-
-    if ( testAttribute(Qt::WA_StyledBackground ) )
-    {
-        QStyleOptionFrame opt;
-        opt.initFrom(this);
-        opt.rect = r;
-        style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, this );
-    }
-    else
-    {
-        if ( d_data->borderRadius > 0 && frameWidth() > 0 )
-        {
-            painter.setPen( QPen( Qt::color1, frameWidth() ) );
-            painter.setBrush( Qt::NoBrush );
-            painter.setRenderHint( QPainter::Antialiasing, true );
-
-            painter.drawPath( path );
-        }
-    }
-
-    painter.end();
-
-    const QImage mask = image.createMaskFromColor(
-        QColor( Qt::color1 ).rgb(), Qt::MaskOutColor );
-
-    return QBitmap::fromImage( mask );
-}
Index: trunk/BNC/qwt/qwt_plot_canvas.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_canvas.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_canvas.h	(revision 8127)
@@ -13,7 +13,5 @@
 #include "qwt_global.h"
 #include <qframe.h>
-#include <qpen.h>
 #include <qpainterpath.h>
-#include <qbitmap.h>
 
 class QwtPlot;
@@ -22,9 +20,14 @@
 /*!
   \brief Canvas of a QwtPlot.
-  \sa QwtPlot
+  
+   Canvas is the widget where all plot items are displayed
+
+  \sa QwtPlot::setCanvas(), QwtPlotGLCanvas
 */
 class QWT_EXPORT QwtPlotCanvas : public QFrame
 {
     Q_OBJECT
+
+    Q_PROPERTY( double borderRadius READ borderRadius WRITE setBorderRadius )
 
 public:
@@ -44,5 +47,5 @@
 
           Using a backing store might improve the performance
-          significantly, when workin with widget overlays ( like rubberbands ).
+          significantly, when working with widget overlays ( like rubber bands ).
           Disabling the cache might improve the performance for
           incremental paints (using QwtPlotDirectPainter ).
@@ -78,8 +81,8 @@
 
           When HackStyledBackground is enabled the plot canvas tries
-          to seperate the background from the background border
-          by reverse engeneering to paint the background before and
+          to separate the background from the background border
+          by reverse engineering to paint the background before and
           the border after the plot items. In this order the border
-          gets prefectly antialiased and you can avoid some pixel
+          gets perfectly antialiased and you can avoid some pixel
           artifacts in the corners.
          */
@@ -100,28 +103,28 @@
     /*!
       \brief Focus indicator
-
-      - NoFocusIndicator\n
-        Don't paint a focus indicator
-
-      - CanvasFocusIndicator\n
-        The focus is related to the complete canvas.
-        Paint the focus indicator using paintFocus()
-
-      - ItemFocusIndicator\n
-        The focus is related to an item (curve, point, ...) on
-        the canvas. It is up to the application to display a
-        focus indication using f.e. highlighting.
-
-      \sa setFocusIndicator(), focusIndicator(), paintFocus()
+      The default setting is NoFocusIndicator
+      \sa setFocusIndicator(), focusIndicator(), drawFocusIndicator()
     */
 
     enum FocusIndicator
     {
+        //! Don't paint a focus indicator
         NoFocusIndicator,
+
+        /*!
+          The focus is related to the complete canvas.
+          Paint the focus indicator using drawFocusIndicator()
+         */
         CanvasFocusIndicator,
+
+        /*!
+          The focus is related to an item (curve, point, ...) on
+          the canvas. It is up to the application to display a
+          focus indication using f.e. highlighting.
+         */
         ItemFocusIndicator
     };
 
-    explicit QwtPlotCanvas( QwtPlot * );
+    explicit QwtPlotCanvas( QwtPlot * = NULL );
     virtual ~QwtPlotCanvas();
 
@@ -135,7 +138,4 @@
     double borderRadius() const;
 
-    QPainterPath borderPath( const QRect &rect ) const;
-    QBitmap borderMask( const QSize & ) const;
-
     void setPaintAttribute( PaintAttribute, bool on = true );
     bool testPaintAttribute( PaintAttribute ) const;
@@ -144,7 +144,10 @@
     void invalidateBackingStore();
 
+    virtual bool event( QEvent * );
+
+    Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
+
+public Q_SLOTS:
     void replot();
-
-    virtual bool event( QEvent * );
 
 protected:
Index: trunk/BNC/qwt/qwt_plot_curve.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_curve.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_curve.cpp	(revision 8127)
@@ -9,14 +9,13 @@
 
 #include "qwt_plot_curve.h"
+#include "qwt_point_data.h"
 #include "qwt_math.h"
 #include "qwt_clipper.h"
 #include "qwt_painter.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
 #include "qwt_scale_map.h"
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_curve_fitter.h"
 #include "qwt_symbol.h"
+#include "qwt_point_mapper.h"
 #include <qpainter.h>
 #include <qpixmap.h>
@@ -24,5 +23,28 @@
 #include <qmath.h>
 
-static int verifyRange( int size, int &i1, int &i2 )
+static void qwtUpdateLegendIconSize( QwtPlotCurve *curve )
+{
+    if ( curve->symbol() && 
+        curve->testLegendAttribute( QwtPlotCurve::LegendShowSymbol ) )
+    {
+        QSize sz = curve->symbol()->boundingRect().size();
+        sz += QSize( 2, 2 ); // margin
+
+        if ( curve->testLegendAttribute( QwtPlotCurve::LegendShowLine ) )
+        {
+            // Avoid, that the line is completely covered by the symbol
+
+            int w = qCeil( 1.5 * sz.width() );
+            if ( w % 2 )
+                w++;
+
+            sz.setWidth( qMax( 8, w ) );
+        }
+
+        curve->setLegendIconSize( sz );
+    }
+}
+
+static int qwtVerifyRange( int size, int &i1, int &i2 )
 {
     if ( size < 1 )
@@ -46,5 +68,6 @@
         symbol( NULL ),
         attributes( 0 ),
-        paintAttributes( QwtPlotCurve::ClipPolygons ),
+        paintAttributes( 
+            QwtPlotCurve::ClipPolygons | QwtPlotCurve::FilterPoints ),
         legendAttributes( 0 )
     {
@@ -79,5 +102,5 @@
 */
 QwtPlotCurve::QwtPlotCurve( const QwtText &title ):
-    QwtPlotSeriesItem<QPointF>( title )
+    QwtPlotSeriesItem( title )
 {
     init();
@@ -89,5 +112,5 @@
 */
 QwtPlotCurve::QwtPlotCurve( const QString &title ):
-    QwtPlotSeriesItem<QPointF>( QwtText( title ) )
+    QwtPlotSeriesItem( QwtText( title ) )
 {
     init();
@@ -107,5 +130,5 @@
 
     d_data = new PrivateData;
-    d_series = new QwtPointSeriesData();
+    setData( new QwtPointSeriesData() );
 
     setZ( 20.0 );
@@ -134,5 +157,5 @@
 
 /*!
-    \brief Return the current paint attributes
+    \return True, when attribute is enabled
     \sa setPaintAttribute()
 */
@@ -143,21 +166,27 @@
 
 /*!
-  Specify an attribute how to draw the legend identifier
+  Specify an attribute how to draw the legend icon
 
   \param attribute Attribute
   \param on On/Off
-  /sa testLegendAttribute()
+  /sa testLegendAttribute(). legendIcon()
 */
 void QwtPlotCurve::setLegendAttribute( LegendAttribute attribute, bool on )
 {
-    if ( on )
-        d_data->legendAttributes |= attribute;
-    else
-        d_data->legendAttributes &= ~attribute;
-}
-
-/*!
-    \brief Return the current paint attributes
-    \sa setLegendAttribute()
+    if ( on != testLegendAttribute( attribute ) )
+    {
+        if ( on )
+            d_data->legendAttributes |= attribute;
+        else
+            d_data->legendAttributes &= ~attribute;
+
+        qwtUpdateLegendIconSize( this );
+        legendChanged();
+    }
+}
+
+/*!
+  \return True, when attribute is enabled
+  \sa setLegendAttribute()
 */
 bool QwtPlotCurve::testLegendAttribute( LegendAttribute attribute ) const
@@ -177,4 +206,6 @@
     {
         d_data->style = style;
+
+        legendChanged();
         itemChanged();
     }
@@ -182,6 +213,6 @@
 
 /*!
-    Return the current style
-    \sa setStyle()
+  \return Style of the curve
+  \sa setStyle()
 */
 QwtPlotCurve::CurveStyle QwtPlotCurve::style() const
@@ -191,10 +222,14 @@
 
 /*!
-  Assign a symbol
+  \brief Assign a symbol
+
+  The curve 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 QwtPlotCurve::setSymbol( const QwtSymbol *symbol )
+void QwtPlotCurve::setSymbol( QwtSymbol *symbol )
 {
     if ( symbol != d_data->symbol )
@@ -202,4 +237,8 @@
         delete d_data->symbol;
         d_data->symbol = symbol;
+
+        qwtUpdateLegendIconSize( this );
+
+        legendChanged();
         itemChanged();
     }
@@ -216,4 +255,22 @@
 
 /*!
+  Build and assign a pen
+
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+
+  \sa pen(), brush()
+ */
+void QwtPlotCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{
+    setPen( QPen( color, width, style ) );
+}
+
+/*!
   Assign a pen
 
@@ -226,4 +283,6 @@
     {
         d_data->pen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -259,4 +318,6 @@
     {
         d_data->brush = brush;
+
+        legendChanged();
         itemChanged();
     }
@@ -278,5 +339,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle 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
@@ -289,11 +350,13 @@
     const QRectF &canvasRect, int from, int to ) const
 {
-    if ( !painter || dataSize() <= 0 )
+    const size_t numSamples = dataSize();
+
+    if ( !painter || numSamples <= 0 )
         return;
 
     if ( to < 0 )
-        to = dataSize() - 1;
-
-    if ( verifyRange( dataSize(), from, to ) > 0 )
+        to = numSamples - 1;
+
+    if ( qwtVerifyRange( numSamples, from, to ) > 0 )
     {
         painter->save();
@@ -326,5 +389,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from index of the first point to be painted
   \param to index of the last point to be painted
@@ -371,5 +434,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from index of the first point to be painted
   \param to index of the last point to be painted
@@ -382,47 +445,100 @@
     const QRectF &canvasRect, int from, int to ) const
 {
-    int size = to - from + 1;
-    if ( size <= 0 )
+    if ( from > to )
         return;
 
     const bool doAlign = QwtPainter::roundingAlignment( painter );
-
-    QPolygonF polyline( size );
-
-    QPointF *points = polyline.data();
-    for ( int i = from; i <= to; i++ )
-    {
-        const QPointF sample = d_series->sample( i );
-
-        double x = xMap.transform( sample.x() );
-        double y = yMap.transform( sample.y() );
-        if ( doAlign )
-        {
-            x = qRound( x );
-            y = qRound( y );
-        }
-
-        points[i - from].rx() = x;
-        points[i - from].ry() = y;
-    }
-
-    if ( ( d_data->attributes & Fitted ) && d_data->curveFitter )
-        polyline = d_data->curveFitter->fitCurve( polyline );
-
+    const bool doFit = ( d_data->attributes & Fitted ) && d_data->curveFitter;
+    const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
+            && ( d_data->brush.color().alpha() > 0 );
+
+    QRectF clipRect;
     if ( d_data->paintAttributes & ClipPolygons )
     {
         qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
-        const QPolygonF clipped = QwtClipper::clipPolygonF( 
-            canvasRect.adjusted(-pw, -pw, pw, pw), polyline, false );
-
-        QwtPainter::drawPolyline( painter, clipped );
+        clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
+    }
+
+    bool doIntegers = false;
+
+#if QT_VERSION < 0x040800
+
+    // For Qt <= 4.7 the raster paint engine is significantly faster
+    // for rendering QPolygon than for QPolygonF. So let's
+    // see if we can use it.
+
+    if ( painter->paintEngine()->type() == QPaintEngine::Raster )
+    {
+        // In case of filling or fitting performance doesn't count
+        // because both operations are much more expensive
+        // then drawing the polyline itself
+
+        if ( !doFit && !doFill )
+            doIntegers = true; 
+    }
+#endif
+
+    const bool noDuplicates = d_data->paintAttributes & FilterPoints;
+
+    QwtPointMapper mapper;
+    mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
+    mapper.setFlag( QwtPointMapper::WeedOutPoints, noDuplicates );
+    mapper.setBoundingRect( canvasRect );
+
+    if ( doIntegers )
+    {
+        QPolygon polyline = mapper.toPolygon( 
+            xMap, yMap, data(), from, to );
+
+        if ( d_data->paintAttributes & ClipPolygons )
+        {
+            polyline = QwtClipper::clipPolygon( 
+                clipRect.toAlignedRect(), polyline, false );
+        }
+
+        QwtPainter::drawPolyline( painter, polyline );
     }
     else
     {
-        QwtPainter::drawPolyline( painter, polyline );
-    }
-
-    if ( d_data->brush.style() != Qt::NoBrush )
-        fillCurve( painter, xMap, yMap, canvasRect, polyline );
+        QPolygonF polyline = mapper.toPolygonF( xMap, yMap, data(), from, to );
+
+        if ( doFit )
+            polyline = d_data->curveFitter->fitCurve( polyline );
+
+        if ( doFill )
+        {
+            if ( painter->pen().style() != Qt::NoPen )
+            {
+                // here we are wasting memory for the filled copy,
+                // do polygon clipping twice etc .. TODO
+
+                QPolygonF filled = polyline;
+                fillCurve( painter, xMap, yMap, canvasRect, filled );
+                filled.clear();
+
+                if ( d_data->paintAttributes & ClipPolygons )
+                {
+                    polyline = QwtClipper::clipPolygonF( 
+                        clipRect, polyline, false );
+                }
+
+                QwtPainter::drawPolyline( painter, polyline );
+            }
+            else
+            {
+                fillCurve( painter, xMap, yMap, canvasRect, polyline );
+            }
+        }
+        else
+        {
+            if ( d_data->paintAttributes & ClipPolygons )
+            {
+                polyline = QwtClipper::clipPolygonF(
+                    clipRect, polyline, false );
+            }
+
+            QwtPainter::drawPolyline( painter, polyline );
+        }
+    }
 }
 
@@ -433,5 +549,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from index of the first point to be painted
   \param to index of the last point to be painted
@@ -458,7 +574,9 @@
     const Qt::Orientation o = orientation();
 
+    const QwtSeriesData<QPointF> *series = data();
+
     for ( int i = from; i <= to; i++ )
     {
-        const QPointF sample = d_series->sample( i );
+        const QPointF sample = series->sample( i );
         double xi = xMap.transform( sample.x() );
         double yi = yMap.transform( sample.y() );
@@ -484,5 +602,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from index of the first point to be painted
   \param to index of the last point to be painted
@@ -494,35 +612,84 @@
     const QRectF &canvasRect, int from, int to ) const
 {
-    const bool doFill = d_data->brush.style() != Qt::NoBrush;
+    const QColor color = painter->pen().color();
+
+    if ( painter->pen().style() == Qt::NoPen || color.alpha() == 0 )
+    {
+        return;
+    }
+
+    const bool doFill = ( d_data->brush.style() != Qt::NoBrush )
+            && ( d_data->brush.color().alpha() > 0 );
     const bool doAlign = QwtPainter::roundingAlignment( painter );
 
-    QPolygonF polyline;
+    QwtPointMapper mapper;
+    mapper.setBoundingRect( canvasRect );
+    mapper.setFlag( QwtPointMapper::RoundPoints, doAlign );
+
+    if ( d_data->paintAttributes & FilterPoints )
+    {
+        if ( ( color.alpha() == 255 )
+            && !( painter->renderHints() & QPainter::Antialiasing ) )
+        {
+            mapper.setFlag( QwtPointMapper::WeedOutPoints, true );
+        }
+    }
+
     if ( doFill )
-        polyline.resize( to - from + 1 );
-
-    QPointF *points = polyline.data();
-
-    for ( int i = from; i <= to; i++ )
-    {
-        const QPointF sample = d_series->sample( i );
-        double xi = xMap.transform( sample.x() );
-        double yi = yMap.transform( sample.y() );
+    {
+        mapper.setFlag( QwtPointMapper::WeedOutPoints, false );
+
+        QPolygonF points = mapper.toPointsF( 
+            xMap, yMap, data(), from, to );
+
+        QwtPainter::drawPoints( painter, points );
+        fillCurve( painter, xMap, yMap, canvasRect, points );
+    }
+    else if ( d_data->paintAttributes & ImageBuffer )
+    {
+        const QImage image = mapper.toImage( xMap, yMap,
+            data(), from, to, d_data->pen, 
+            painter->testRenderHint( QPainter::Antialiasing ),
+            renderThreadCount() );
+
+        painter->drawImage( canvasRect.toAlignedRect(), image );
+    }
+    else if ( d_data->paintAttributes & MinimizeMemory )
+    {
+        const QwtSeriesData<QPointF> *series = data();
+
+        for ( int i = from; i <= to; i++ )
+        {
+            const QPointF sample = series->sample( i );
+
+            double xi = xMap.transform( sample.x() );
+            double yi = yMap.transform( sample.y() );
+
+            if ( doAlign )
+            {
+                xi = qRound( xi );
+                yi = qRound( yi );
+            }
+
+            QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
+        }
+    }
+    else
+    {
         if ( doAlign )
         {
-            xi = qRound( xi );
-            yi = qRound( yi );
-        }
-
-        QwtPainter::drawPoint( painter, QPointF( xi, yi ) );
-
-        if ( doFill )
-        {
-            points[i - from].rx() = xi;
-            points[i - from].ry() = yi;
-        }
-    }
-
-    if ( doFill )
-        fillCurve( painter, xMap, yMap, canvasRect, polyline );
+            const QPolygon points = mapper.toPoints(
+                xMap, yMap, data(), from, to ); 
+
+            QwtPainter::drawPoints( painter, points );
+        }
+        else
+        {
+            const QPolygonF points = mapper.toPointsF( 
+                xMap, yMap, data(), from, to );
+
+            QwtPainter::drawPoints( painter, points );
+        }
+    }
 }
 
@@ -535,5 +702,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from index of the first point to be painted
   \param to index of the last point to be painted
@@ -555,8 +722,10 @@
         inverted = !inverted;
 
+    const QwtSeriesData<QPointF> *series = data();
+
     int i, ip;
     for ( i = from, ip = 0; i <= to; i++, ip += 2 )
     {
-        const QPointF sample = d_series->sample( i );
+        const QPointF sample = series->sample( i );
         double xi = xMap.transform( sample.x() );
         double yi = yMap.transform( sample.y() );
@@ -590,6 +759,9 @@
     if ( d_data->paintAttributes & ClipPolygons )
     {
+        qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
+        const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
+        
         const QPolygonF clipped = QwtClipper::clipPolygonF( 
-            canvasRect, polygon, false );
+            clipRect, polygon, false );
 
         QwtPainter::drawPolyline( painter, clipped );
@@ -678,5 +850,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param polygon Polygon - will be modified !
 
@@ -733,9 +905,6 @@
     if ( orientation() == Qt::Vertical )
     {
-        if ( yMap.transformation()->type() == QwtScaleTransformation::Log10 )
-        {
-            if ( baseline < QwtScaleMap::LogMin )
-                baseline = QwtScaleMap::LogMin;
-        }
+        if ( yMap.transformation() )
+            baseline = yMap.transformation()->bounded( baseline );
 
         double refY = yMap.transform( baseline );
@@ -748,9 +917,6 @@
     else
     {
-        if ( xMap.transformation()->type() == QwtScaleTransformation::Log10 )
-        {
-            if ( baseline < QwtScaleMap::LogMin )
-                baseline = QwtScaleMap::LogMin;
-        }
+        if ( xMap.transformation() )
+            baseline = xMap.transformation()->bounded( baseline );
 
         double refX = xMap.transform( baseline );
@@ -770,5 +936,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first point to be painted
   \param to Index of the last point to be painted
@@ -780,72 +946,22 @@
     const QRectF &canvasRect, int from, int to ) const
 {
-    const bool doAlign = QwtPainter::roundingAlignment( painter );
-
-    bool usePixmap = testPaintAttribute( CacheSymbols );
-    if ( usePixmap && !doAlign )
-    {
-        // Don't use the pixmap, when the paint device
-        // could generate scalable vectors
-
-        usePixmap = false;
-    }
-
-    if ( usePixmap )
-    {
-        QPixmap pm( symbol.boundingSize() );
-        pm.fill( Qt::transparent );
-
-        const double pw2 = 0.5 * pm.width();
-        const double ph2 = 0.5 * pm.height();
-
-        QPainter p( &pm );
-        p.setRenderHints( painter->renderHints() );
-        symbol.drawSymbol( &p, QPointF( pw2, ph2 ) );
-        p.end();
-
-        for ( int i = from; i <= to; i++ )
-        {
-            const QPointF sample = d_series->sample( i );
-
-            double xi = xMap.transform( sample.x() );
-            double yi = yMap.transform( sample.y() );
-            if ( doAlign )
-            {
-                xi = qRound( xi );
-                yi = qRound( yi );
-            }
-
-            if ( canvasRect.contains( xi, yi ) )
-            {
-                const int left = qCeil( xi ) - pw2;
-                const int top = qCeil( yi ) - ph2;
-
-                painter->drawPixmap( left, top, pm );
-            }
-        }
-    }
-    else
-    {
-        const int chunkSize = 500;
-
-        for ( int i = from; i <= to; i += chunkSize )
-        {
-            const int n = qMin( chunkSize, to - i + 1 );
-
-            QPolygonF points;
-            for ( int j = 0; j < n; j++ )
-            {
-                const QPointF sample = d_series->sample( i + j );
-
-                const double xi = xMap.transform( sample.x() );
-                const double yi = yMap.transform( sample.y() );
-
-                if ( canvasRect.contains( xi, yi ) )
-                    points += QPointF( xi, yi );
-            }
-
-            if ( points.size() > 0 )
-                symbol.drawSymbols( painter, points );
-        }
+    QwtPointMapper mapper;
+    mapper.setFlag( QwtPointMapper::RoundPoints, 
+        QwtPainter::roundingAlignment( painter ) );
+    mapper.setFlag( QwtPointMapper::WeedOutPoints, 
+        testPaintAttribute( QwtPlotCurve::FilterPoints ) );
+    mapper.setBoundingRect( canvasRect );
+
+    const int chunkSize = 500;
+
+    for ( int i = from; i <= to; i += chunkSize )
+    {
+        const int n = qMin( chunkSize, to - i + 1 );
+
+        const QPolygonF points = mapper.toPointsF( xMap, yMap,
+            data(), i, i + n - 1 );
+
+        if ( points.size() > 0 )
+            symbol.drawSymbols( painter, points );
     }
 }
@@ -856,7 +972,8 @@
   The baseline is needed for filling the curve with a brush or
   the Sticks drawing style.
-  The interpretation of the baseline depends on the CurveType.
-  With QwtPlotCurve::Yfx, the baseline is interpreted as a horizontal line
-  at y = baseline(), with QwtPlotCurve::Yfy, it is interpreted as a vertical
+
+  The interpretation of the baseline depends on the orientation().
+  With Qt::Horizontal, the baseline is interpreted as a horizontal line
+  at y = baseline(), with Qt::Vertical, it is interpreted as a vertical
   line at x = baseline().
 
@@ -864,5 +981,5 @@
 
   \param value Value of the baseline
-  \sa baseline(), setBrush(), setStyle(), setStyle()
+  \sa baseline(), setBrush(), setStyle(), QwtPlotAbstractSeriesItem::orientation()
 */
 void QwtPlotCurve::setBaseline( double value )
@@ -889,5 +1006,5 @@
   \param pos Position, where to look for the closest curve point
   \param dist If dist != NULL, closestPoint() returns the distance between
-              the position and the clostest curve point
+              the position and the closest curve point
   \return Index of the closest curve point, or -1 if none can be found
           ( f.e when the curve has no points )
@@ -897,6 +1014,10 @@
 int QwtPlotCurve::closestPoint( const QPoint &pos, double *dist ) const
 {
-    if ( plot() == NULL || dataSize() <= 0 )
+    const size_t numSamples = dataSize();
+
+    if ( plot() == NULL || numSamples <= 0 )
         return -1;
+
+    const QwtSeriesData<QPointF> *series = data();
 
     const QwtScaleMap xMap = plot()->canvasMap( xAxis() );
@@ -906,7 +1027,7 @@
     double dmin = 1.0e10;
 
-    for ( uint i = 0; i < dataSize(); i++ )
-    {
-        const QPointF sample = d_series->sample( i );
+    for ( uint i = 0; i < numSamples; i++ )
+    {
+        const QPointF sample = series->sample( i );
 
         const double cx = xMap.transform( sample.x() ) - pos.x();
@@ -927,76 +1048,40 @@
 
 /*!
-   \brief Update the widget that represents the item on the legend
-
-   \param legend Legend
-   \sa drawLegendIdentifier(), legendItem(), QwtPlotItem::Legend
-*/
-void QwtPlotCurve::updateLegend( QwtLegend *legend ) const
-{
-    if ( legend && testItemAttribute( QwtPlotItem::Legend )
-        && ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
-        && d_data->symbol
-        && d_data->symbol->style() != QwtSymbol::NoSymbol )
-    {
-        QWidget *lgdItem = legend->find( this );
-        if ( lgdItem == NULL )
-        {
-            lgdItem = legendItem();
-            if ( lgdItem )
-                legend->insert( this, lgdItem );
-        }
-
-        QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
-        if ( l )
-        {
-            QSize sz = d_data->symbol->boundingSize();
-            sz += QSize( 2, 2 ); // margin
-
-            if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
+   \return Icon representing the curve on the legend
+
+   \param index Index of the legend entry 
+                ( ignored as there is only one )
+   \param size Icon size
+
+   \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
+ */
+QwtGraphic QwtPlotCurve::legendIcon( int index, 
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+
+    if ( size.isEmpty() )
+        return QwtGraphic();
+
+    QwtGraphic graphic;
+    graphic.setDefaultSize( size );
+    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &graphic );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPlotItem::RenderAntialiased ) );
+
+    if ( d_data->legendAttributes == 0 ||
+        d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
+    {
+        QBrush brush = d_data->brush;
+
+        if ( brush.style() == Qt::NoBrush &&
+            d_data->legendAttributes == 0 )
+        {
+            if ( style() != QwtPlotCurve::NoCurve )
             {
-                // Avoid, that the line is completely covered by the symbol
-
-                int w = qCeil( 1.5 * sz.width() );
-                if ( w % 2 )
-                    w++;
-
-                sz.setWidth( qMax( 8, w ) );
+                brush = QBrush( pen().color() );
             }
-
-            l->setIdentifierSize( sz );
-        }
-    }
-
-    QwtPlotItem::updateLegend( legend );
-}
-
-/*!
-  \brief Draw the identifier representing the curve on the legend
-
-  \param painter Painter
-  \param rect Bounding rectangle for the identifier
-
-  \sa setLegendAttribute(), QwtPlotItem::Legend
-*/
-void QwtPlotCurve::drawLegendIdentifier(
-    QPainter *painter, const QRectF &rect ) const
-{
-    if ( rect.isEmpty() )
-        return;
-
-    const int dim = qMin( rect.width(), rect.height() );
-
-    QSize size( dim, dim );
-
-    QRectF r( 0, 0, size.width(), size.height() );
-    r.moveCenter( rect.center() );
-
-    if ( d_data->legendAttributes == 0 )
-    {
-        QBrush brush = d_data->brush;
-        if ( brush.style() == Qt::NoBrush )
-        {
-            if ( style() != QwtPlotCurve::NoCurve )
-                brush = QBrush( pen().color() );
             else if ( d_data->symbol &&
                 ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
@@ -1005,60 +1090,63 @@
             }
         }
+
         if ( brush.style() != Qt::NoBrush )
-            painter->fillRect( r, brush );
-    }
-    if ( d_data->legendAttributes & QwtPlotCurve::LegendShowBrush )
-    {
-        if ( d_data->brush.style() != Qt::NoBrush )
-            painter->fillRect( r, d_data->brush );
-    }
+        {
+            QRectF r( 0, 0, size.width(), size.height() );
+            painter.fillRect( r, brush );
+        }
+    }
+
     if ( d_data->legendAttributes & QwtPlotCurve::LegendShowLine )
     {
         if ( pen() != Qt::NoPen )
         {
-            painter->setPen( pen() );
-            QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
-                                  rect.right() - 1.0, rect.center().y() );
-        }
-    }
+            QPen pn = pen();
+            pn.setCapStyle( Qt::FlatCap );
+
+            painter.setPen( pn );
+
+            const double y = 0.5 * size.height();
+            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
+        }
+    }
+
     if ( d_data->legendAttributes & QwtPlotCurve::LegendShowSymbol )
     {
-        if ( d_data->symbol &&
-            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
-        {
-            QSize symbolSize = d_data->symbol->boundingSize();
-            symbolSize -= QSize( 2, 2 );
-
-            // scale the symbol size down if it doesn't fit into rect.
-
-            double xRatio = 1.0;
-            if ( rect.width() < symbolSize.width() )
-                xRatio = rect.width() / symbolSize.width();
-            double yRatio = 1.0;
-            if ( rect.height() < symbolSize.height() )
-                yRatio = rect.height() / symbolSize.height();
-
-            const double ratio = qMin( xRatio, yRatio );
-
-            painter->save();
-            painter->scale( ratio, ratio );
-
-            d_data->symbol->drawSymbol( painter, rect.center() / ratio );
-
-            painter->restore();
-        }
-    }
-}
-
-/*!
-  Initialize data with an array of points (explicitly shared).
+        if ( d_data->symbol )
+        {
+            QRectF r( 0, 0, size.width(), size.height() );
+            d_data->symbol->drawSymbol( &painter, r );
+        }
+    }
+
+    return graphic;
+}
+
+/*!
+  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 QwtPlotCurve::setSamples( const QVector<QPointF> &samples )
 {
-    delete d_series;
-    d_series = new QwtPointSeriesData( samples );
-    itemChanged();
+    setData( new QwtPointSeriesData( samples ) );
+}
+
+/*!
+  Assign a series of points
+
+  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 QwtPlotCurve::setSamples( QwtSeriesData<QPointF> *data )
+{
+    setData( data );
 }
 
@@ -1082,7 +1170,5 @@
     const double *xData, const double *yData, int size )
 {
-    delete d_series;
-    d_series = new QwtCPointerData( xData, yData, size );
-    itemChanged();
+    setData( new QwtCPointerData( xData, yData, size ) );
 }
 
@@ -1101,7 +1187,5 @@
     const double *xData, const double *yData, int size )
 {
-    delete d_series;
-    d_series = new QwtPointArrayData( xData, yData, size );
-    itemChanged();
+    setData( new QwtPointArrayData( xData, yData, size ) );
 }
 
@@ -1117,8 +1201,7 @@
     const QVector<double> &yData )
 {
-    delete d_series;
-    d_series = new QwtPointArrayData( xData, yData );
-    itemChanged();
-}
+    setData( new QwtPointArrayData( xData, yData ) );
+}
+
 #endif // !QWT_NO_COMPAT
 
Index: trunk/BNC/qwt/qwt_plot_curve.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_curve.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_curve.h	(revision 8127)
@@ -53,5 +53,6 @@
   \sa QwtPointSeriesData, QwtSymbol, QwtScaleMap
 */
-class QWT_EXPORT QwtPlotCurve: public QwtPlotSeriesItem<QPointF>
+class QWT_EXPORT QwtPlotCurve: 
+    public QwtPlotSeriesItem, public QwtSeriesStore<QPointF>
 {
 public:
@@ -120,5 +121,5 @@
           interpolate/smooth the curve, before it is painted.
 
-          \note Curve fitting requires temorary memory
+          \note Curve fitting requires temporary memory
           for calculating coefficients and additional points.
           If painting in QwtPlotCurve::Fitted mode is slow it might be better
@@ -135,5 +136,5 @@
 
         \sa setLegendAttribute(), testLegendAttribute(),
-            drawLegendIdentifier()
+            QwtPlotItem::legendData(), legendIcon()
      */
 
@@ -169,5 +170,5 @@
     /*!
         Attributes to modify the drawing algorithm.
-        The default setting enables ClipPolygons
+        The default setting enables ClipPolygons | FilterPoints
 
         \sa setPaintAttribute(), testPaintAttribute()
@@ -183,10 +184,26 @@
 
         /*!
-          Paint the symbol to a QPixmap and paint the pixmap
-          instead rendering the symbol for each point. The flag has
-          no effect, when the curve is not painted to the canvas
-          ( f.e when exporting the plot to a PDF document ).
-         */
-        CacheSymbols = 0x02
+          Tries to reduce the data that has to be painted, by sorting out
+          duplicates, or paintings outside the visible area. Might have a
+          notable impact on curves with many close points.
+          Only a couple of very basic filtering algorithms are implemented.
+         */
+        FilterPoints = 0x02,
+
+        /*!
+          Minimize memory usage that is temporarily needed for the 
+          translated points, before they get painted.
+          This might slow down the performance of painting 
+         */
+        MinimizeMemory = 0x04,
+
+        /*!
+          Render the points to a temporary image and paint the image.
+          This is a very special optimization for Dots style, when
+          having a huge amount of points. 
+          With a reasonable number of points QPainter::drawPoints()
+          will be faster.
+         */
+        ImageBuffer = 0x08
     };
 
@@ -213,4 +230,5 @@
 #endif
     void setSamples( const QVector<QPointF> & );
+    void setSamples( QwtSeriesData<QPointF> * );
 
     int closestPoint( const QPoint &pos, double *dist = NULL ) const;
@@ -224,4 +242,5 @@
     bool testCurveAttribute( CurveAttribute ) const;
 
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setPen( const QPen & );
     const QPen &pen() const;
@@ -230,5 +249,5 @@
     const QBrush &brush() const;
 
-    void setBaseline( double ref );
+    void setBaseline( double );
     double baseline() const;
 
@@ -236,5 +255,5 @@
     CurveStyle style() const;
 
-    void setSymbol( const QwtSymbol *s );
+    void setSymbol( QwtSymbol * );
     const QwtSymbol *symbol() const;
 
@@ -246,6 +265,5 @@
         const QRectF &canvasRect, int from, int to ) const;
 
-    virtual void updateLegend( QwtLegend * ) const;
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
 
 protected:
@@ -261,17 +279,17 @@
         const QRectF &canvasRect, int from, int to ) const;
 
-    void drawLines( QPainter *p,
-        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-        const QRectF &canvasRect, int from, int to ) const;
-
-    void drawSticks( QPainter *p,
-        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-        const QRectF &canvasRect, int from, int to ) const;
-
-    void drawDots( QPainter *p,
-        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
-        const QRectF &canvasRect, int from, int to ) const;
-
-    void drawSteps( QPainter *p,
+    virtual void drawLines( QPainter *p,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual void drawSticks( QPainter *p,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual void drawDots( QPainter *p,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual void drawSteps( QPainter *p,
         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
         const QRectF &canvasRect, int from, int to ) const;
Index: trunk/BNC/qwt/qwt_plot_dict.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_dict.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_dict.cpp	(revision 8127)
@@ -64,5 +64,5 @@
 
    Auto deletion is enabled.
-   \sa setAutoDelete(), attachItem()
+   \sa setAutoDelete(), QwtPlotItem::attach()
 */
 QwtPlotDict::QwtPlotDict()
@@ -75,6 +75,6 @@
    Destructor
 
-   If autoDelete is on, all attached items will be deleted
-   \sa setAutoDelete(), autoDelete(), attachItem()
+   If autoDelete() is on, all attached items will be deleted
+   \sa setAutoDelete(), autoDelete(), QwtPlotItem::attach()
 */
 QwtPlotDict::~QwtPlotDict()
@@ -90,5 +90,5 @@
    in the destructor of QwtPlotDict. The default value is on.
 
-   \sa autoDelete(), attachItem()
+   \sa autoDelete(), insertItem()
 */
 void QwtPlotDict::setAutoDelete( bool autoDelete )
@@ -99,5 +99,5 @@
 /*!
    \return true if auto deletion is enabled
-   \sa setAutoDelete(), attachItem()
+   \sa setAutoDelete(), insertItem()
 */
 bool QwtPlotDict::autoDelete() const
@@ -107,21 +107,23 @@
 
 /*!
-   Attach/Detach a plot item
+  Insert a plot item
 
-   Attached items will be deleted in the destructor,
-   if auto deletion is enabled (default). Manually detached
-   items are not deleted.
+  \param item PlotItem
+  \sa removeItem()
+ */
+void QwtPlotDict::insertItem( QwtPlotItem *item )
+{
+    d_data->itemList.insertItem( item );
+}
 
-   \param item Plot item to attach/detach
-   \ on If true attach, else detach the item
+/*!
+  Remove a plot item
 
-   \sa setAutoDelete(), ~QwtPlotDict()
-*/
-void QwtPlotDict::attachItem( QwtPlotItem *item, bool on )
+  \param item PlotItem
+  \sa insertItem()
+ */
+void QwtPlotDict::removeItem( QwtPlotItem *item )
 {
-    if ( on )
-        d_data->itemList.insertItem( item );
-    else
-        d_data->itemList.removeItem( item );
+    d_data->itemList.removeItem( item );
 }
 
@@ -168,4 +170,5 @@
 /*!
   \return List of all attached plot items of a specific type.
+  \param rtti See QwtPlotItem::RttiValues
   \sa QwtPlotItem::rtti()
 */
Index: trunk/BNC/qwt/qwt_plot_dict.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_dict.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_dict.h	(revision 8127)
@@ -27,4 +27,6 @@
   If autoDelete() is enabled, all attached items will be deleted
   in the destructor of the dictionary.
+  QwtPlotDict can be used to get access to all QwtPlotItem items - or all
+  items of a specific type -  that are currently on the plot.
 
   \sa QwtPlotItem::attach(), QwtPlotItem::detach(), QwtPlotItem::z()
@@ -45,9 +47,9 @@
         bool autoDelete = true );
 
+protected:
+    void insertItem( QwtPlotItem * );
+    void removeItem( QwtPlotItem * );
+
 private:
-    friend class QwtPlotItem;
-
-    void attachItem( QwtPlotItem *, bool );
-
     class PrivateData;
     PrivateData *d_data;
Index: trunk/BNC/qwt/qwt_plot_directpainter.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_directpainter.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_directpainter.cpp	(revision 8127)
@@ -18,7 +18,7 @@
 #include <qpixmap.h>
 
-static inline void renderItem( 
+static inline void qwtRenderItem( 
     QPainter *painter, const QRect &canvasRect,
-    QwtPlotAbstractSeriesItem *seriesItem, int from, int to )
+    QwtPlotSeriesItem *seriesItem, int from, int to )
 {
     // A minor performance improvement is possible
@@ -32,4 +32,10 @@
         seriesItem->testRenderHint( QwtPlotItem::RenderAntialiased ) );
     seriesItem->drawSeries( painter, xMap, yMap, canvasRect, from, to );
+}
+
+static inline bool qwtHasBackingStore( const QwtPlotCanvas *canvas )
+{
+    return canvas->testPaintAttribute( QwtPlotCanvas::BackingStore )
+        && canvas->backingStore() && !canvas->backingStore()->isNull();
 }
 
@@ -40,5 +46,7 @@
         attributes( 0 ),
         hasClipping(false),
-        seriesItem( NULL )
+        seriesItem( NULL ),
+        from( 0 ),
+        to( 0 )
     {
     }
@@ -51,5 +59,5 @@
     QPainter painter;
 
-    QwtPlotAbstractSeriesItem *seriesItem;
+    QwtPlotSeriesItem *seriesItem;
     int from;
     int to;
@@ -92,6 +100,5 @@
 
 /*!
-  Check if a attribute is set.
-
+  \return True, when attribute is enabled
   \param attribute Attribute to be tested
   \sa Attribute, setAttribute()
@@ -152,5 +159,5 @@
 
   When observing an measurement while it is running, new points have to be
-  added to an existing seriesItem. drawSeries can be used to display them avoiding
+  added to an existing seriesItem. drawSeries() can be used to display them avoiding
   a complete redraw of the canvas.
 
@@ -165,29 +172,28 @@
 */
 void QwtPlotDirectPainter::drawSeries(
-    QwtPlotAbstractSeriesItem *seriesItem, int from, int to )
+    QwtPlotSeriesItem *seriesItem, int from, int to )
 {
     if ( seriesItem == NULL || seriesItem->plot() == NULL )
         return;
 
-    QwtPlotCanvas *canvas = seriesItem->plot()->canvas();
+    QWidget *canvas = seriesItem->plot()->canvas();
     const QRect canvasRect = canvas->contentsRect();
 
-    const bool hasBackingStore = 
-        canvas->testPaintAttribute( QwtPlotCanvas::BackingStore ) 
-        && canvas->backingStore() && !canvas->backingStore()->isNull();
-
-    if ( hasBackingStore )
-    {
-        QPainter painter( const_cast<QPixmap *>( canvas->backingStore() ) );
-        painter.translate( -canvasRect.x(), -canvasRect.y() );
+    QwtPlotCanvas *plotCanvas = qobject_cast<QwtPlotCanvas *>( canvas );
+
+    if ( plotCanvas && qwtHasBackingStore( plotCanvas ) )
+    {
+        QPainter painter( const_cast<QPixmap *>( plotCanvas->backingStore() ) );
 
         if ( d_data->hasClipping )
             painter.setClipRegion( d_data->clipRegion );
 
-        renderItem( &painter, canvasRect, seriesItem, from, to );
+        qwtRenderItem( &painter, canvasRect, seriesItem, from, to );
+
+        painter.end();
 
         if ( testAttribute( QwtPlotDirectPainter::FullRepaint ) )
         {
-            canvas->repaint();
+            plotCanvas->repaint();
             return;
         }
@@ -195,13 +201,14 @@
 
     bool immediatePaint = true;
-    if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) &&
-        !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
-    {
-        immediatePaint = false;
+    if ( !canvas->testAttribute( Qt::WA_WState_InPaintEvent ) ) 
+    {
+#if QT_VERSION < 0x050000
+        if ( !canvas->testAttribute( Qt::WA_PaintOutsidePaintEvent ) )
+#endif
+            immediatePaint = false;
     }
 
     if ( immediatePaint )
     {
-        QwtPlotCanvas *canvas = seriesItem->plot()->canvas();
         if ( !d_data->painter.isActive() )
         {
@@ -223,5 +230,5 @@
         }
 
-        renderItem( &d_data->painter, canvasRect, seriesItem, from, to );
+        qwtRenderItem( &d_data->painter, canvasRect, seriesItem, from, to );
 
         if ( d_data->attributes & QwtPlotDirectPainter::AtomicPainter )
@@ -260,5 +267,5 @@
     if ( d_data->painter.isActive() )
     {
-        QWidget *w = ( QWidget * )d_data->painter.device();
+        QWidget *w = static_cast<QWidget *>( d_data->painter.device() );
         if ( w )
             w->removeEventFilter( this );
@@ -279,28 +286,29 @@
             const QPaintEvent *pe = static_cast< QPaintEvent *>( event );
 
-            QwtPlotCanvas *canvas = d_data->seriesItem->plot()->canvas();
+            QWidget *canvas = d_data->seriesItem->plot()->canvas();
 
             QPainter painter( canvas );
             painter.setClipRegion( pe->region() );
 
-            bool copyCache = testAttribute( CopyBackingStore )
-                && canvas->testPaintAttribute( QwtPlotCanvas::BackingStore );
-
-            if ( copyCache )
+            bool doCopyCache = testAttribute( CopyBackingStore );
+
+            if ( doCopyCache )
             {
-                // is something valid in the cache ?
-                copyCache = ( canvas->backingStore() != NULL )
-                    && !canvas->backingStore()->isNull();
+                QwtPlotCanvas *plotCanvas = 
+                    qobject_cast<QwtPlotCanvas *>( canvas );
+                if ( plotCanvas )
+                {
+                    doCopyCache = qwtHasBackingStore( plotCanvas );
+                    if ( doCopyCache )
+                    {
+                        painter.drawPixmap( plotCanvas->rect().topLeft(), 
+                            *plotCanvas->backingStore() );
+                    }
+                }
             }
 
-            if ( copyCache )
+            if ( !doCopyCache )
             {
-                painter.drawPixmap( 
-                    canvas->contentsRect().topLeft(), 
-                    *canvas->backingStore() );
-            }
-            else
-            {
-                renderItem( &painter, canvas->contentsRect(),
+                qwtRenderItem( &painter, canvas->contentsRect(),
                     d_data->seriesItem, d_data->from, d_data->to );
             }
Index: trunk/BNC/qwt/qwt_plot_directpainter.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_directpainter.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_directpainter.h	(revision 8127)
@@ -15,5 +15,5 @@
 
 class QRegion;
-class QwtPlotAbstractSeriesItem;
+class QwtPlotSeriesItem;
 
 /*!
@@ -55,5 +55,5 @@
 
         /*!
-          When FullRepaint is set the plot canvas is explicitely repainted
+          When FullRepaint is set the plot canvas is explicitly repainted
           after the samples have been rendered.
          */
@@ -64,5 +64,5 @@
           has to paint to the backing store and the widget. In certain 
           situations/environments it might be faster to paint to 
-          the backing store only and then copy the backingstore to the canvas.
+          the backing store only and then copy the backing store to the canvas.
           This flag can also be useful for settings, where Qt fills the
           the clip region with the widget background.
@@ -86,5 +86,5 @@
     QRegion clipRegion() const;
 
-    void drawSeries( QwtPlotAbstractSeriesItem *, int from, int to );
+    void drawSeries( QwtPlotSeriesItem *, int from, int to );
     void reset();
 
Index: trunk/BNC/qwt/qwt_plot_glcanvas.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_glcanvas.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_glcanvas.cpp	(revision 8127)
@@ -0,0 +1,377 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_glcanvas.h"
+#include "qwt_plot.h"
+#include "qwt_painter.h"
+#include <qevent.h>
+#include <qpainter.h>
+#include <qdrawutil.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+
+#define FIX_GL_TRANSLATION 0
+
+static QWidget *qwtBGWidget( QWidget *widget )
+{
+    QWidget *w = widget;
+
+    for ( ; w->parentWidget() != NULL; w = w->parentWidget() )
+    {
+        if ( w->autoFillBackground() || 
+            w->testAttribute( Qt::WA_StyledBackground ) )
+        {
+            return w;
+        }
+    }
+
+    return w;
+}
+
+static void qwtUpdateContentsRect( QwtPlotGLCanvas *canvas )
+{
+    const int fw = canvas->frameWidth();
+    canvas->setContentsMargins( fw, fw, fw, fw );
+}
+
+class QwtPlotGLCanvas::PrivateData
+{
+public:
+    PrivateData():
+        frameStyle( QFrame::Panel | QFrame::Sunken),
+        lineWidth( 2 ),
+        midLineWidth( 0 )
+    {
+    }
+
+    int frameStyle;
+    int lineWidth;
+    int midLineWidth;
+};
+
+class QwtPlotGLCanvasFormat: public QGLFormat
+{
+public:
+    QwtPlotGLCanvasFormat():
+        QGLFormat( QGLFormat::defaultFormat() )
+    {
+        setSampleBuffers( true );
+    }
+};
+
+/*! 
+  \brief Constructor
+
+  \param plot Parent plot widget
+  \sa QwtPlot::setCanvas()
+*/
+QwtPlotGLCanvas::QwtPlotGLCanvas( QwtPlot *plot ):
+    QGLWidget( QwtPlotGLCanvasFormat(), plot )
+{
+    d_data = new PrivateData;
+
+#ifndef QT_NO_CURSOR
+    setCursor( Qt::CrossCursor );
+#endif
+
+    setAutoFillBackground( true );
+    qwtUpdateContentsRect( this );
+}
+
+//! Destructor
+QwtPlotGLCanvas::~QwtPlotGLCanvas()
+{
+    delete d_data;
+}
+
+/*!
+  Set the frame style
+
+  \param style The bitwise OR between a shape and a shadow. 
+  
+  \sa frameStyle(), QFrame::setFrameStyle(), 
+      setFrameShadow(), setFrameShape()
+ */
+void QwtPlotGLCanvas::setFrameStyle( int style )
+{
+    if ( style != d_data->frameStyle )
+    {
+        d_data->frameStyle = style;
+        qwtUpdateContentsRect( this );
+
+        update();
+    }
+}
+
+/*!
+  \return The bitwise OR between a frameShape() and a frameShadow()
+  \sa setFrameStyle(), QFrame::frameStyle()
+ */
+int QwtPlotGLCanvas::frameStyle() const
+{
+    return d_data->frameStyle;
+}
+
+/*!
+  Set the frame shadow
+
+  \param shadow Frame shadow
+  \sa frameShadow(), setFrameShape(), QFrame::setFrameShadow()
+ */
+void QwtPlotGLCanvas::setFrameShadow( Shadow shadow )
+{
+    setFrameStyle(( d_data->frameStyle & QFrame::Shape_Mask ) | shadow );
+}
+
+/*!
+  \return Frame shadow
+  \sa setFrameShadow(), QFrame::setFrameShadow()
+ */
+QwtPlotGLCanvas::Shadow QwtPlotGLCanvas::frameShadow() const
+{
+    return (Shadow) ( d_data->frameStyle & QFrame::Shadow_Mask );
+}
+
+/*!
+  Set the frame shape
+
+  \param shape Frame shape
+  \sa frameShape(), setFrameShadow(), QFrame::frameShape()
+ */
+void QwtPlotGLCanvas::setFrameShape( Shape shape )
+{
+    setFrameStyle( ( d_data->frameStyle & QFrame::Shadow_Mask ) | shape );
+}
+
+/*!
+  \return Frame shape
+  \sa setFrameShape(), QFrame::frameShape()
+ */
+QwtPlotGLCanvas::Shape QwtPlotGLCanvas::frameShape() const
+{
+    return (Shape) ( d_data->frameStyle & QFrame::Shape_Mask );
+}
+
+/*!
+   Set the frame line width
+
+   The default line width is 2 pixels.
+
+   \param width Line width of the frame
+   \sa lineWidth(), setMidLineWidth()
+*/
+void QwtPlotGLCanvas::setLineWidth( int width )
+{
+    width = qMax( width, 0 );
+    if ( width != d_data->lineWidth )
+    {
+        d_data->lineWidth = qMax( width, 0 );
+        qwtUpdateContentsRect( this );
+        update();
+    }
+}
+
+/*!
+  \return Line width of the frame
+  \sa setLineWidth(), midLineWidth()
+ */
+int QwtPlotGLCanvas::lineWidth() const
+{
+    return d_data->lineWidth;
+}
+
+/*!
+   Set the frame mid line width
+
+   The default midline width is 0 pixels.
+
+   \param width Midline width of the frame
+   \sa midLineWidth(), setLineWidth()
+*/
+void QwtPlotGLCanvas::setMidLineWidth( int width )
+{
+    width = qMax( width, 0 );
+    if ( width != d_data->midLineWidth )
+    {
+        d_data->midLineWidth = width;
+        qwtUpdateContentsRect( this );
+        update();
+    }
+}
+
+/*!
+  \return Midline width of the frame
+  \sa setMidLineWidth(), lineWidth()
+ */ 
+int QwtPlotGLCanvas::midLineWidth() const
+{
+    return d_data->midLineWidth;
+}
+
+/*!
+  \return Frame width depending on the style, line width and midline width.
+ */
+int QwtPlotGLCanvas::frameWidth() const
+{
+    return ( frameStyle() != NoFrame ) ? d_data->lineWidth : 0;
+}
+
+/*!
+  Paint event
+
+  \param event Paint event
+  \sa QwtPlot::drawCanvas()
+*/
+void QwtPlotGLCanvas::paintEvent( QPaintEvent *event )
+{
+    Q_UNUSED( event );
+
+    QPainter painter( this );
+
+#if FIX_GL_TRANSLATION
+    if ( painter.paintEngine()->type() == QPaintEngine::OpenGL2 )
+    {
+        // work around a translation bug of QPaintEngine::OpenGL2
+        painter.translate( 1, 1 );
+    }
+#endif
+
+    drawBackground( &painter );
+    drawItems( &painter );
+
+    if ( !testAttribute( Qt::WA_StyledBackground ) )
+    {
+        if ( frameWidth() > 0 )
+            drawBorder( &painter );
+    }
+}
+/*!
+  Qt event handler for QEvent::PolishRequest and QEvent::StyleChange
+  \param event Qt Event
+  \return See QGLWidget::event()
+*/
+bool QwtPlotGLCanvas::event( QEvent *event )
+{
+    const bool ok = QGLWidget::event( event );
+
+    if ( event->type() == QEvent::PolishRequest ||
+        event->type() == QEvent::StyleChange )
+    {
+        // assuming, that we always have a styled background
+        // when we have a style sheet
+
+        setAttribute( Qt::WA_StyledBackground,
+            testAttribute( Qt::WA_StyleSheet ) );
+    }
+
+    return ok;
+}
+
+/*!
+  Draw the plot items
+  \param painter Painter
+
+  \sa QwtPlot::drawCanvas()
+*/  
+void QwtPlotGLCanvas::drawItems( QPainter *painter )
+{
+    painter->save();
+
+    painter->setClipRect( contentsRect(), Qt::IntersectClip );
+
+    QwtPlot *plot = qobject_cast< QwtPlot *>( parent() );
+    if ( plot )
+        plot->drawCanvas( painter );
+
+    painter->restore();
+}
+
+/*!
+  Draw the background of the canvas
+  \param painter Painter
+*/ 
+void QwtPlotGLCanvas::drawBackground( QPainter *painter )
+{
+    painter->save();
+
+    QWidget *w = qwtBGWidget( this );
+
+    const QPoint off = mapTo( w, QPoint() );
+    painter->translate( -off );
+
+    const QRect fillRect = rect().translated( off );
+
+    if ( w->testAttribute( Qt::WA_StyledBackground ) )
+    {
+        painter->setClipRect( fillRect );
+
+        QStyleOption opt;
+        opt.initFrom( w );
+        w->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, w);
+    }
+    else 
+    {
+        painter->fillRect( fillRect,
+            w->palette().brush( w->backgroundRole() ) );
+    }
+
+    painter->restore();
+}
+
+/*!
+  Draw the border of the canvas
+  \param painter Painter
+*/
+void QwtPlotGLCanvas::drawBorder( QPainter *painter )
+{
+    const int fw = frameWidth();
+    if ( fw <= 0 )
+        return;
+
+    if ( frameShadow() == QwtPlotGLCanvas::Plain )
+    {
+        qDrawPlainRect( painter, frameRect(), 
+            palette().shadow().color(), lineWidth() );
+    }
+    else
+    {
+        if ( frameShape() == QwtPlotGLCanvas::Box )
+        {
+            qDrawShadeRect( painter, frameRect(), palette(),
+                frameShadow() == Sunken, lineWidth(), midLineWidth() );
+        }
+        else
+        {
+            qDrawShadePanel( painter, frameRect(), palette(), 
+                frameShadow() == Sunken, lineWidth() );
+        }
+    }
+}
+
+//! Calls repaint()
+void QwtPlotGLCanvas::replot()
+{
+    repaint();
+}
+
+/*!
+   \return Empty path
+*/
+QPainterPath QwtPlotGLCanvas::borderPath( const QRect &rect ) const
+{
+    Q_UNUSED( rect );
+    return QPainterPath();
+}
+
+//! \return The rectangle where the frame is drawn in.
+QRect QwtPlotGLCanvas::frameRect() const
+{
+    const int fw = frameWidth();
+    return contentsRect().adjusted( -fw, -fw, fw, fw );
+}
Index: trunk/BNC/qwt/qwt_plot_glcanvas.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_glcanvas.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_glcanvas.h	(revision 8127)
@@ -0,0 +1,130 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_GLCANVAS_H
+#define QWT_PLOT_GLCANVAS_H
+
+#include "qwt_global.h"
+#include <qframe.h>
+#include <qgl.h>
+
+class QwtPlot;
+
+/*!
+  \brief An alternative canvas for a QwtPlot derived from QGLWidget
+  
+  QwtPlotGLCanvas implements the very basics to act as canvas
+  inside of a QwtPlot widget. It might be extended to a full
+  featured alternative to QwtPlotCanvas in a future version of Qwt.
+
+  Even if QwtPlotGLCanvas is not derived from QFrame it imitates
+  its API. When using style sheets it supports the box model - beside
+  backgrounds with rounded borders.
+
+  \sa QwtPlot::setCanvas(), QwtPlotCanvas
+
+  \note With Qt4 you might want to use the QPaintEngine::OpenGL paint engine
+        ( see QGL::setPreferredPaintEngine() ). On a Linux test system 
+        QPaintEngine::OpenGL2 shows very basic problems like translated
+        geometries.
+*/
+class QWT_EXPORT QwtPlotGLCanvas: public QGLWidget
+{
+    Q_OBJECT
+
+    Q_ENUMS( Shape Shadow )
+
+    Q_PROPERTY( Shadow frameShadow READ frameShadow WRITE setFrameShadow )
+    Q_PROPERTY( Shape frameShape READ frameShape WRITE setFrameShape )
+    Q_PROPERTY( int lineWidth READ lineWidth WRITE setLineWidth )
+    Q_PROPERTY( int midLineWidth READ midLineWidth WRITE setMidLineWidth )
+    Q_PROPERTY( int frameWidth READ frameWidth )
+    Q_PROPERTY( QRect frameRect READ frameRect DESIGNABLE false )
+
+public:
+    /*!
+        \brief Frame shadow
+
+         Unfortunately it is not possible to use QFrame::Shadow
+         as a property of a widget that is not derived from QFrame.
+         The following enum is made for the designer only. It is safe
+         to use QFrame::Shadow instead.
+     */
+    enum Shadow
+    {
+        //! QFrame::Plain
+        Plain = QFrame::Plain,
+
+        //! QFrame::Raised
+        Raised = QFrame::Raised,
+
+        //! QFrame::Sunken
+        Sunken = QFrame::Sunken
+    };
+
+    /*!
+        \brief Frame shape
+
+        Unfortunately it is not possible to use QFrame::Shape
+        as a property of a widget that is not derived from QFrame.
+        The following enum is made for the designer only. It is safe
+        to use QFrame::Shadow instead.
+
+        \note QFrame::StyledPanel and QFrame::WinPanel are unsuported 
+              and will be displayed as QFrame::Panel.
+     */
+    enum Shape
+    {
+        NoFrame = QFrame::NoFrame,
+
+        Box = QFrame::Box,
+        Panel = QFrame::Panel
+    };
+
+    explicit QwtPlotGLCanvas( QwtPlot * = NULL );
+    virtual ~QwtPlotGLCanvas();
+
+    void setFrameStyle( int style );
+    int frameStyle() const;
+
+    void setFrameShadow( Shadow );
+    Shadow frameShadow() const;
+
+    void setFrameShape( Shape );
+    Shape frameShape() const;
+
+    void setLineWidth( int );
+    int lineWidth() const;
+
+    void setMidLineWidth( int );
+    int midLineWidth() const;
+
+    int frameWidth() const;
+    QRect frameRect() const;
+
+    Q_INVOKABLE QPainterPath borderPath( const QRect & ) const;
+
+    virtual bool event( QEvent * );
+
+public Q_SLOTS:
+    void replot();
+
+protected:
+    virtual void paintEvent( QPaintEvent * );
+
+    virtual void drawBackground( QPainter * );
+    virtual void drawBorder( QPainter * );
+    virtual void drawItems( QPainter * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_grid.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_grid.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_grid.cpp	(revision 8127)
@@ -36,6 +36,6 @@
     QwtScaleDiv yScaleDiv;
 
-    QPen majPen;
-    QPen minPen;
+    QPen majorPen;
+    QPen minorPen;
 };
 
@@ -45,4 +45,6 @@
 {
     d_data = new PrivateData;
+
+    setItemInterest( QwtPlotItem::ScaleInterest, true );
     setZ( 10.0 );
 }
@@ -61,57 +63,65 @@
 
 /*!
-  \brief Enable or disable vertical gridlines
-  \param tf Enable (true) or disable
-
-  \sa Minor gridlines can be enabled or disabled with
+  \brief Enable or disable vertical grid lines
+  \param on Enable (true) or disable
+
+  \sa Minor grid lines can be enabled or disabled with
       enableXMin()
 */
-void QwtPlotGrid::enableX( bool tf )
-{
-    if ( d_data->xEnabled != tf )
-    {
-        d_data->xEnabled = tf;
-        itemChanged();
-    }
-}
-
-/*!
-  \brief Enable or disable horizontal gridlines
-  \param tf Enable (true) or disable
-  \sa Minor gridlines can be enabled or disabled with enableYMin()
-*/
-void QwtPlotGrid::enableY( bool tf )
-{
-    if ( d_data->yEnabled != tf )
-    {
-        d_data->yEnabled = tf;
-        itemChanged();
-    }
-}
-
-/*!
-  \brief Enable or disable  minor vertical gridlines.
-  \param tf Enable (true) or disable
+void QwtPlotGrid::enableX( bool on )
+{
+    if ( d_data->xEnabled != on )
+    {
+        d_data->xEnabled = on;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \brief Enable or disable horizontal grid lines
+  \param on Enable (true) or disable
+  \sa Minor grid lines can be enabled or disabled with enableYMin()
+*/
+void QwtPlotGrid::enableY( bool on )
+{
+    if ( d_data->yEnabled != on )
+    {
+        d_data->yEnabled = on;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \brief Enable or disable  minor vertical grid lines.
+  \param on Enable (true) or disable
   \sa enableX()
 */
-void QwtPlotGrid::enableXMin( bool tf )
-{
-    if ( d_data->xMinEnabled != tf )
-    {
-        d_data->xMinEnabled = tf;
-        itemChanged();
-    }
-}
-
-/*!
-  \brief Enable or disable minor horizontal gridlines
-  \param tf Enable (true) or disable
+void QwtPlotGrid::enableXMin( bool on )
+{
+    if ( d_data->xMinEnabled != on )
+    {
+        d_data->xMinEnabled = on;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \brief Enable or disable minor horizontal grid lines
+  \param on Enable (true) or disable
   \sa enableY()
 */
-void QwtPlotGrid::enableYMin( bool tf )
-{
-    if ( d_data->yMinEnabled != tf )
-    {
-        d_data->yMinEnabled = tf;
+void QwtPlotGrid::enableYMin( bool on )
+{
+    if ( d_data->yMinEnabled != on )
+    {
+        d_data->yMinEnabled = on;
+
+        legendChanged();
         itemChanged();
     }
@@ -147,45 +157,105 @@
 
 /*!
-  Assign a pen for both major and minor gridlines
+  Build and assign a pen for both major and minor grid lines
+
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+
+  \sa pen(), brush()
+ */
+void QwtPlotGrid::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{
+    setPen( QPen( color, width, style ) );
+}
+
+/*!
+  Assign a pen for both major and minor grid lines
 
   \param pen Pen
-  \sa setMajPen(), setMinPen()
+  \sa setMajorPen(), setMinorPen()
 */
 void QwtPlotGrid::setPen( const QPen &pen )
 {
-    if ( d_data->majPen != pen || d_data->minPen != pen )
-    {
-        d_data->majPen = pen;
-        d_data->minPen = pen;
-        itemChanged();
-    }
-}
-
-/*!
-  Assign a pen for the major gridlines
+    if ( d_data->majorPen != pen || d_data->minorPen != pen )
+    {
+        d_data->majorPen = pen;
+        d_data->minorPen = pen;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  Build and assign a pen for both major grid lines
+
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+
+  \sa pen(), brush()
+ */
+void QwtPlotGrid::setMajorPen( const QColor &color, qreal width, Qt::PenStyle style )
+{
+    setMajorPen( QPen( color, width, style ) );
+}
+
+/*!
+  Assign a pen for the major grid lines
 
   \param pen Pen
-  \sa majPen(), setMinPen(), setPen()
-*/
-void QwtPlotGrid::setMajPen( const QPen &pen )
-{
-    if ( d_data->majPen != pen )
-    {
-        d_data->majPen = pen;
-        itemChanged();
-    }
-}
-
-/*!
-  Assign a pen for the minor gridlines
+  \sa majorPen(), setMinorPen(), setPen()
+*/
+void QwtPlotGrid::setMajorPen( const QPen &pen )
+{
+    if ( d_data->majorPen != pen )
+    {
+        d_data->majorPen = pen;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  Build and assign a pen for the minor grid lines
+
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+
+  \sa pen(), brush()
+ */
+void QwtPlotGrid::setMinorPen( const QColor &color, qreal width, Qt::PenStyle style )
+{
+    setMinorPen( QPen( color, width, style ) );
+}
+
+/*!
+  Assign a pen for the minor grid lines
 
   \param pen Pen
-  \sa minPen(), setMajPen(), setPen()
-*/
-void QwtPlotGrid::setMinPen( const QPen &pen )
-{
-    if ( d_data->minPen != pen )
-    {
-        d_data->minPen = pen;
+  \sa minorPen(), setMajorPen(), setPen()
+*/
+void QwtPlotGrid::setMinorPen( const QPen &pen )
+{
+    if ( d_data->minorPen != pen )
+    {
+        d_data->minorPen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -196,11 +266,12 @@
 
   The grid is drawn into the bounding rectangle such that
-  gridlines begin and end at the rectangle's borders. The X and Y
+  grid lines begin and end at the rectangle's borders. The X and Y
   maps are used to map the scale divisions into the drawing region
   screen.
+
   \param painter  Painter
   \param xMap X axis map
   \param yMap Y axis
-  \param canvasRect Contents rect of the plot canvas
+  \param canvasRect Contents rectangle of the plot canvas
 */
 void QwtPlotGrid::draw( QPainter *painter,
@@ -208,9 +279,9 @@
     const QRectF &canvasRect ) const
 {
-    //  draw minor gridlines
-    QPen minPen = d_data->minPen;
-    minPen.setCapStyle( Qt::FlatCap );
-
-    painter->setPen( minPen );
+    //  draw minor grid lines
+    QPen minorPen = d_data->minorPen;
+    minorPen.setCapStyle( Qt::FlatCap );
+
+    painter->setPen( minorPen );
 
     if ( d_data->xEnabled && d_data->xMinEnabled )
@@ -230,9 +301,9 @@
     }
 
-    //  draw major gridlines
-    QPen majPen = d_data->majPen;
-    majPen.setCapStyle( Qt::FlatCap );
-
-    painter->setPen( majPen );
+    //  draw major grid lines
+    QPen majorPen = d_data->majorPen;
+    majorPen.setCapStyle( Qt::FlatCap );
+
+    painter->setPen( majorPen );
 
     if ( d_data->xEnabled )
@@ -286,23 +357,23 @@
 
 /*!
-  \return the pen for the major gridlines
-  \sa setMajPen(), setMinPen(), setPen()
-*/
-const QPen &QwtPlotGrid::majPen() const
-{
-    return d_data->majPen;
-}
-
-/*!
-  \return the pen for the minor gridlines
-  \sa setMinPen(), setMajPen(), setPen()
-*/
-const QPen &QwtPlotGrid::minPen() const
-{
-    return d_data->minPen;
-}
-
-/*!
-  \return true if vertical gridlines are enabled
+  \return the pen for the major grid lines
+  \sa setMajorPen(), setMinorPen(), setPen()
+*/
+const QPen &QwtPlotGrid::majorPen() const
+{
+    return d_data->majorPen;
+}
+
+/*!
+  \return the pen for the minor grid lines
+  \sa setMinorPen(), setMajorPen(), setPen()
+*/
+const QPen &QwtPlotGrid::minorPen() const
+{
+    return d_data->minorPen;
+}
+
+/*!
+  \return true if vertical grid lines are enabled
   \sa enableX()
 */
@@ -313,5 +384,5 @@
 
 /*!
-  \return true if minor vertical gridlines are enabled
+  \return true if minor vertical grid lines are enabled
   \sa enableXMin()
 */
@@ -322,5 +393,5 @@
 
 /*!
-  \return true if horizontal gridlines are enabled
+  \return true if horizontal grid lines are enabled
   \sa enableY()
 */
@@ -331,5 +402,5 @@
 
 /*!
-  \return true if minor horizontal gridlines are enabled
+  \return true if minor horizontal grid lines are enabled
   \sa enableYMin()
 */
Index: trunk/BNC/qwt/qwt_plot_grid.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_grid.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_grid.h	(revision 8127)
@@ -25,5 +25,5 @@
   The QwtPlotGrid class can be used to draw a coordinate grid.
   A coordinate grid consists of major and minor vertical
-  and horizontal gridlines. The locations of the gridlines
+  and horizontal grid lines. The locations of the grid lines
   are determined by the X and Y scale divisions which can
   be assigned with setXDiv() and setYDiv().
@@ -58,11 +58,14 @@
     const QwtScaleDiv &yScaleDiv() const;
 
-    void setPen( const QPen &p );
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setPen( const QPen & );
 
-    void setMajPen( const QPen &p );
-    const QPen& majPen() const;
+    void setMajorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setMajorPen( const QPen & );
+    const QPen& majorPen() const;
 
-    void setMinPen( const QPen &p );
-    const QPen& minPen() const;
+    void setMinorPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setMinorPen( const QPen &p );
+    const QPen& minorPen() const;
 
     virtual void draw( QPainter *p,
Index: trunk/BNC/qwt/qwt_plot_histogram.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_histogram.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_histogram.cpp	(revision 8127)
@@ -10,6 +10,4 @@
 #include "qwt_plot_histogram.h"
 #include "qwt_plot.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
 #include "qwt_painter.h"
 #include "qwt_column_symbol.h"
@@ -18,5 +16,5 @@
 #include <qpainter.h>
 
-static inline bool isCombinable( const QwtInterval &d1,
+static inline bool qwtIsCombinable( const QwtInterval &d1,
     const QwtInterval &d2 )
 {
@@ -63,7 +61,6 @@
   \param title Title of the histogram.
 */
-
 QwtPlotHistogram::QwtPlotHistogram( const QwtText &title ):
-    QwtPlotSeriesItem<QwtIntervalSample>( title )
+    QwtPlotSeriesItem( title )
 {
     init();
@@ -75,5 +72,5 @@
 */
 QwtPlotHistogram::QwtPlotHistogram( const QString &title ):
-    QwtPlotSeriesItem<QwtIntervalSample>( title )
+    QwtPlotSeriesItem( title )
 {
     init();
@@ -90,5 +87,5 @@
 {
     d_data = new PrivateData();
-    d_series = new QwtIntervalSeriesData();
+    setData( new QwtIntervalSeriesData() );
 
     setItemAttribute( QwtPlotItem::AutoScale, true );
@@ -109,4 +106,6 @@
     {
         d_data->style = style;
+
+        legendChanged();
         itemChanged();
     }
@@ -114,5 +113,5 @@
 
 /*!
-    Return the current style
+    \return Style of the histogram
     \sa HistogramStyle, setStyle()
 */
@@ -121,4 +120,22 @@
     return d_data->style;
 }
+
+/*!
+  Build and assign a pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */
+void QwtPlotHistogram::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setPen( QPen( color, width, style ) );
+}   
 
 /*!
@@ -133,4 +150,6 @@
     {
         d_data->pen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -157,4 +176,6 @@
     {
         d_data->brush = brush;
+
+        legendChanged();
         itemChanged();
     }
@@ -181,5 +202,5 @@
 
   \note In applications, where different intervals need to be displayed
-        in a different way ( f.e different colors or even using differnt symbols)
+        in a different way ( f.e different colors or even using different symbols)
         it is recommended to overload drawColumn().
 */
@@ -190,4 +211,6 @@
         delete d_data->symbol;
         d_data->symbol = symbol;
+
+        legendChanged();
         itemChanged();
     }
@@ -238,5 +261,5 @@
 QRectF QwtPlotHistogram::boundingRect() const
 {
-    QRectF rect = d_series->boundingRect();
+    QRectF rect = data()->boundingRect();
     if ( !rect.isValid() )
         return rect;
@@ -276,7 +299,21 @@
     const QVector<QwtIntervalSample> &samples )
 {
-    delete d_series;
-    d_series = new QwtIntervalSeriesData( samples );
-    itemChanged();
+    setData( new QwtIntervalSeriesData( samples ) );
+}
+
+/*!
+  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 QwtPlotHistogram::setSamples( 
+    QwtSeriesData<QwtIntervalSample> *data )
+{
+    setData( data );
 }
 
@@ -287,5 +324,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted. If to < 0 the
@@ -350,5 +387,5 @@
     for ( int i = from; i <= to; i++ )
     {
-        const QwtIntervalSample sample = d_series->sample( i );
+        const QwtIntervalSample sample = this->sample( i );
 
         if ( !sample.interval.isValid() )
@@ -361,5 +398,5 @@
         if ( previous.interval.isValid() )
         {
-            if ( !isCombinable( previous.interval, sample.interval ) )
+            if ( !qwtIsCombinable( previous.interval, sample.interval ) )
                 flushPolygon( painter, v0, polygon );
         }
@@ -426,7 +463,9 @@
     painter->setBrush( d_data->brush );
 
+    const QwtSeriesData<QwtIntervalSample> *series = data();
+
     for ( int i = from; i <= to; i++ )
     {
-        const QwtIntervalSample sample = d_series->sample( i );
+        const QwtIntervalSample sample = series->sample( i );
         if ( !sample.interval.isNull() )
         {
@@ -458,7 +497,9 @@
     painter->setBrush( Qt::NoBrush );
 
+    const QwtSeriesData<QwtIntervalSample> *series = data();
+
     for ( int i = from; i <= to; i++ )
     {
-        const QwtIntervalSample sample = d_series->sample( i );
+        const QwtIntervalSample sample = series->sample( i );
         if ( !sample.interval.isNull() )
         {
@@ -532,6 +573,9 @@
             polygon += QPointF( baseLine, polygon.first().y() );
         }
+
         QwtPainter::drawPolygon( painter, polygon );
-        polygon.resize( polygon.size() - 2 );
+
+        polygon.pop_back();
+        polygon.pop_back();
     }
     if ( d_data->pen.style() != Qt::NoPen )
@@ -601,5 +645,5 @@
 
   \note In applications, where different intervals need to be displayed
-        in a different way ( f.e different colors or even using differnt symbols)
+        in a different way ( f.e different colors or even using different symbols)
         it is recommended to overload drawColumn().
 */
@@ -630,19 +674,17 @@
 
 /*!
-  Draw a plain rectangle without pen using the brush() as identifier
-
-  \param painter Painter
-  \param rect Bounding rectangle for the identifier
-*/
-void QwtPlotHistogram::drawLegendIdentifier(
-    QPainter *painter, const QRectF &rect ) const
-{
-    const double dim = qMin( rect.width(), rect.height() );
-
-    QSizeF size( dim, dim );
-
-    QRectF r( 0, 0, size.width(), size.height() );
-    r.moveCenter( rect.center() );
-
-    painter->fillRect( r, d_data->brush );
-}
+  A plain rectangle without pen using the brush()
+
+  \param index Index of the legend entry 
+                ( ignored as there is only one )
+  \param size Icon size
+  \return A graphic displaying the icon
+    
+  \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
+*/
+QwtGraphic QwtPlotHistogram::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+    return defaultIcon( d_data->brush, size );
+}
Index: trunk/BNC/qwt/qwt_plot_histogram.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_histogram.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_histogram.h	(revision 8127)
@@ -33,7 +33,10 @@
         While "image histograms" can be displayed by a QwtPlotCurve there
         is no applicable plot item for a "color histogram" yet.
+
+  \sa QwtPlotBarChart, QwtPlotMultiBarChart
 */
 
-class QWT_EXPORT QwtPlotHistogram: public QwtPlotSeriesItem<QwtIntervalSample>
+class QWT_EXPORT QwtPlotHistogram: 
+    public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
 {
 public:
@@ -80,4 +83,5 @@
     virtual int rtti() const;
 
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setPen( const QPen & );
     const QPen &pen() const;
@@ -87,4 +91,5 @@
 
     void setSamples( const QVector<QwtIntervalSample> & );
+    void setSamples( QwtSeriesData<QwtIntervalSample> * );
 
     void setBaseline( double reference );
@@ -103,5 +108,5 @@
     virtual QRectF boundingRect() const;
 
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
 
 protected:
Index: trunk/BNC/qwt/qwt_plot_intervalcurve.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_intervalcurve.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_intervalcurve.cpp	(revision 8127)
@@ -13,4 +13,5 @@
 #include "qwt_clipper.h"
 #include "qwt_painter.h"
+#include <string.h>
 
 #include <qpainter.h>
@@ -24,5 +25,5 @@
 
     const bool isOffScreen = ( y < yMin ) || ( y > yMax )
-        || ( x1 < xMin && x2 < xMin ) || ( x1 > yMax && x2 > xMax );
+        || ( x1 < xMin && x2 < xMin ) || ( x1 > xMax && x2 > xMax );
 
     return !isOffScreen;
@@ -46,5 +47,5 @@
 public:
     PrivateData():
-        style( Tube ),
+        style( QwtPlotIntervalCurve::Tube ),
         symbol( NULL ),
         pen( Qt::black ),
@@ -53,5 +54,5 @@
         paintAttributes = QwtPlotIntervalCurve::ClipPolygons;
         paintAttributes |= QwtPlotIntervalCurve::ClipSymbol;
-    
+
         pen.setCapStyle( Qt::FlatCap );
     }
@@ -62,5 +63,5 @@
     }
 
-    CurveStyle style;
+    QwtPlotIntervalCurve::CurveStyle style;
     const QwtIntervalSymbol *symbol;
 
@@ -76,5 +77,5 @@
 */
 QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QwtText &title ):
-    QwtPlotSeriesItem<QwtIntervalSample>( title )
+    QwtPlotSeriesItem( title )
 {
     init();
@@ -86,5 +87,5 @@
 */
 QwtPlotIntervalCurve::QwtPlotIntervalCurve( const QString &title ):
-    QwtPlotSeriesItem<QwtIntervalSample>( QwtText( title ) )
+    QwtPlotSeriesItem( QwtText( title ) )
 {
     init();
@@ -104,5 +105,5 @@
 
     d_data = new PrivateData;
-    d_series = new QwtIntervalSeriesData();
+    setData( new QwtIntervalSeriesData() );
 
     setZ( 19.0 );
@@ -122,5 +123,5 @@
   \sa testPaintAttribute()
 */
-void QwtPlotIntervalCurve::setPaintAttribute( 
+void QwtPlotIntervalCurve::setPaintAttribute(
     PaintAttribute attribute, bool on )
 {
@@ -132,8 +133,8 @@
 
 /*!
-    \brief Return the current paint attributes
+    \return True, when attribute is enabled
     \sa PaintAttribute, setPaintAttribute()
 */
-bool QwtPlotIntervalCurve::testPaintAttribute( 
+bool QwtPlotIntervalCurve::testPaintAttribute(
     PaintAttribute attribute ) const
 {
@@ -148,7 +149,21 @@
     const QVector<QwtIntervalSample> &samples )
 {
-    delete d_series;
-    d_series = new QwtIntervalSeriesData( samples );
-    itemChanged();
+    setData( new QwtIntervalSeriesData( samples ) );
+}
+
+/*!
+  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 QwtPlotIntervalCurve::setSamples( 
+    QwtSeriesData<QwtIntervalSample> *data )
+{
+    setData( data );
 }
 
@@ -164,4 +179,6 @@
     {
         d_data->style = style;
+
+        legendChanged();
         itemChanged();
     }
@@ -169,5 +186,5 @@
 
 /*!
-    \brief Return the current style
+    \return Style of the curve
     \sa setStyle()
 */
@@ -189,4 +206,6 @@
         delete d_data->symbol;
         d_data->symbol = symbol;
+
+        legendChanged();
         itemChanged();
     }
@@ -201,4 +220,22 @@
     return d_data->symbol;
 }
+
+/*!
+  Build and assign a pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */
+void QwtPlotIntervalCurve::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setPen( QPen( color, width, style ) );
+}   
 
 /*!
@@ -212,4 +249,6 @@
     {
         d_data->pen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -217,5 +256,5 @@
 
 /*!
-    \brief Return the pen used to draw the lines
+    \return Pen used to draw the lines
     \sa setPen(), brush()
 */
@@ -238,4 +277,6 @@
     {
         d_data->brush = brush;
+
+        legendChanged();
         itemChanged();
     }
@@ -257,5 +298,5 @@
 QRectF QwtPlotIntervalCurve::boundingRect() const
 {
-    QRectF rect = QwtPlotSeriesItem<QwtIntervalSample>::boundingRect();
+    QRectF rect = QwtPlotSeriesItem::boundingRect();
     if ( rect.isValid() && orientation() == Qt::Vertical )
         rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
@@ -270,5 +311,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted. If to < 0 the
@@ -304,5 +345,5 @@
         ( d_data->symbol->style() != QwtIntervalSymbol::NoSymbol ) )
     {
-        drawSymbols( painter, *d_data->symbol, 
+        drawSymbols( painter, *d_data->symbol,
             xMap, yMap, canvasRect, from, to );
     }
@@ -319,5 +360,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted. If to < 0 the
@@ -388,6 +429,6 @@
         {
             const qreal m = 1.0;
-            const QPolygonF p = QwtClipper::clipPolygonF( 
-                canvasRect.adjusted(-m, -m, m, m), polygon, true );
+            const QPolygonF p = QwtClipper::clipPolygonF(
+               canvasRect.adjusted( -m, -m, m, m ), polygon, true );
 
             QwtPainter::drawPolygon( painter, p );
@@ -406,17 +447,17 @@
         if ( d_data->paintAttributes & ClipPolygons )
         {
-            qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
-            const QRectF clipRect = canvasRect.adjusted(-pw, -pw, pw, pw);
+            qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF() );
+            const QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw );
 
             QPolygonF p;
 
             p.resize( size );
-            qMemCopy( p.data(), points, size * sizeof( QPointF ) );
-            p = QwtClipper::clipPolygonF( canvasRect, p );
+            ::memcpy( p.data(), points, size * sizeof( QPointF ) );
+            p = QwtClipper::clipPolygonF( clipRect, p );
             QwtPainter::drawPolyline( painter, p );
 
             p.resize( size );
-            qMemCopy( p.data(), points + size, size * sizeof( QPointF ) );
-            p = QwtClipper::clipPolygonF( canvasRect, p );
+            ::memcpy( p.data(), points + size, size * sizeof( QPointF ) );
+            p = QwtClipper::clipPolygonF( clipRect, p );
             QwtPainter::drawPolyline( painter, p );
         }
@@ -438,5 +479,5 @@
   \param xMap x map
   \param yMap y map
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted
@@ -457,5 +498,5 @@
     painter->setBrush( symbol.brush() );
 
-    const QRectF &tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect);
+    const QRectF tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect );
 
     const double xMin = tr.left();
@@ -464,5 +505,5 @@
     const double yMax = tr.bottom();
 
-    const bool doClip = d_data->paintAttributes & ClipPolygons;
+    const bool doClip = d_data->paintAttributes & ClipSymbol;
 
     for ( int i = from; i <= to; i++ )
@@ -500,24 +541,35 @@
 
 /*!
-  In case of Tibe stale() a plain rectangle is painted without a pen filled
-  the brush(). If a symbol is assigned it is painted cebtered into rect.
-
-  \param painter Painter
-  \param rect Bounding rectangle for the identifier
-*/
-
-void QwtPlotIntervalCurve::drawLegendIdentifier(
-    QPainter *painter, const QRectF &rect ) const
-{
-    const double dim = qMin( rect.width(), rect.height() );
-
-    QSizeF size( dim, dim );
-
-    QRectF r( 0, 0, size.width(), size.height() );
-    r.moveCenter( rect.center() );
+  \return Icon for the legend
+
+  In case of Tube style() the icon is a plain rectangle filled with the brush().
+  If a symbol is assigned it is scaled to size.
+
+  \param index Index of the legend entry 
+               ( ignored as there is only one )
+  \param size Icon size
+    
+  \sa QwtPlotItem::setLegendIconSize(), QwtPlotItem::legendData()
+*/
+QwtGraphic QwtPlotIntervalCurve::legendIcon( 
+    int index, const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+
+    if ( size.isEmpty() )
+        return QwtGraphic();
+
+    QwtGraphic icon;
+    icon.setDefaultSize( size );
+    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &icon );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPlotItem::RenderAntialiased ) );
 
     if ( d_data->style == Tube )
     {
-        painter->fillRect( r, d_data->brush );
+        QRectF r( 0, 0, size.width(), size.height() );
+        painter.fillRect( r, d_data->brush );
     }
 
@@ -529,19 +581,23 @@
         pen.setCapStyle( Qt::FlatCap );
 
-        painter->setPen( pen );
-        painter->setBrush( d_data->symbol->brush() );
+        painter.setPen( pen );
+        painter.setBrush( d_data->symbol->brush() );
 
         if ( orientation() == Qt::Vertical )
         {
-            d_data->symbol->draw( painter, orientation(),
-                QPointF( r.center().x(), r.top() ),
-                QPointF( r.center().x(), r.bottom() - 1 ) );
+            const double x = 0.5 * size.width();
+
+            d_data->symbol->draw( &painter, orientation(),
+                QPointF( x, 0 ), QPointF( x, size.height() - 1.0 ) );
         }
         else
         {
-            d_data->symbol->draw( painter, orientation(),
-                QPointF( r.left(), r.center().y() ),
-                QPointF( r.right() - 1, r.center().y() ) );
-        }
-    }
-}
+            const double y = 0.5 * size.height();
+
+            d_data->symbol->draw( &painter, orientation(),
+                QPointF( 0.0, y ), QPointF( size.width() - 1.0, y ) );
+        }
+    }
+
+    return icon;
+}
Index: trunk/BNC/qwt/qwt_plot_intervalcurve.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_intervalcurve.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_intervalcurve.h	(revision 8127)
@@ -23,8 +23,8 @@
   The representation depends on the style() and an optional symbol()
   that is displayed for each interval. QwtPlotIntervalCurve might be used
-  to disply error bars or the area between 2 curves.
+  to display error bars or the area between 2 curves.
 */
-
-class QWT_EXPORT QwtPlotIntervalCurve: public QwtPlotSeriesItem<QwtIntervalSample>
+class QWT_EXPORT QwtPlotIntervalCurve: 
+    public QwtPlotSeriesItem, public QwtSeriesStore<QwtIntervalSample>
 {
 public:
@@ -35,5 +35,4 @@
         \sa setStyle(), style()
     */
-
     enum CurveStyle
     {
@@ -89,5 +88,7 @@
 
     void setSamples( const QVector<QwtIntervalSample> & );
+    void setSamples( QwtSeriesData<QwtIntervalSample> * );
 
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setPen( const QPen & );
     const QPen &pen() const;
@@ -107,5 +108,6 @@
 
     virtual QRectF boundingRect() const;
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
+
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
 
 protected:
Index: trunk/BNC/qwt/qwt_plot_item.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_item.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_item.cpp	(revision 8127)
@@ -11,7 +11,7 @@
 #include "qwt_text.h"
 #include "qwt_plot.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
+#include "qwt_legend_data.h"
 #include "qwt_scale_div.h"
+#include "qwt_graphic.h"
 #include <qpainter.h>
 
@@ -23,8 +23,11 @@
         isVisible( true ),
         attributes( 0 ),
+        interests( 0 ),
         renderHints( 0 ),
+        renderThreadCount( 1 ),
         z( 0.0 ),
         xAxis( QwtPlot::xBottom ),
-        yAxis( QwtPlot::yLeft )
+        yAxis( QwtPlot::yLeft ),
+        legendIconSize( 8, 8 )
     {
     }
@@ -33,6 +36,11 @@
 
     bool isVisible;
+
     QwtPlotItem::ItemAttributes attributes;
+    QwtPlotItem::ItemInterests interests;
+
     QwtPlotItem::RenderHints renderHints;
+    uint renderThreadCount;
+
     double z;
 
@@ -41,4 +49,5 @@
 
     QwtText title;
+    QSize legendIconSize;
 };
 
@@ -76,26 +85,11 @@
         return;
 
-    // remove the item from the previous plot
-
     if ( d_data->plot )
-    {
-        if ( d_data->plot->legend() )
-            d_data->plot->legend()->remove( this );
-
         d_data->plot->attachItem( this, false );
 
-        if ( d_data->plot->autoReplot() )
-            d_data->plot->update();
-    }
-
     d_data->plot = plot;
 
     if ( d_data->plot )
-    {
-        // insert the item into the current plot
-
         d_data->plot->attachItem( this, true );
-        itemChanged();
-    }
 }
 
@@ -191,5 +185,9 @@
     {
         d_data->title = title;
-        itemChanged();
+
+        legendChanged();
+#if 0
+        itemChanged();
+#endif
     }
 }
@@ -210,9 +208,9 @@
    \param on true/false
 
-   \sa testItemAttribute(), ItemAttribute
+   \sa testItemAttribute(), ItemInterest
 */
 void QwtPlotItem::setItemAttribute( ItemAttribute attribute, bool on )
 {
-    if ( bool( d_data->attributes & attribute ) != on )
+    if ( d_data->attributes.testFlag( attribute ) != on )
     {
         if ( on )
@@ -221,4 +219,7 @@
             d_data->attributes &= ~attribute;
 
+        if ( attribute == QwtPlotItem::Legend )
+            legendChanged();
+
         itemChanged();
     }
@@ -230,9 +231,42 @@
    \param attribute Attribute type
    \return true/false
-   \sa setItemAttribute(), ItemAttribute
+   \sa setItemAttribute(), ItemInterest
 */
 bool QwtPlotItem::testItemAttribute( ItemAttribute attribute ) const
 {
-    return ( d_data->attributes & attribute );
+    return d_data->attributes.testFlag( attribute );
+}
+
+/*!
+   Toggle an item interest
+
+   \param interest Interest type
+   \param on true/false
+
+   \sa testItemInterest(), ItemAttribute
+*/
+void QwtPlotItem::setItemInterest( ItemInterest interest, bool on )
+{
+    if ( d_data->interests.testFlag( interest ) != on )
+    {
+        if ( on )
+            d_data->interests |= interest;
+        else
+            d_data->interests &= ~interest;
+
+        itemChanged();
+    }
+}
+
+/*!
+   Test an item interest
+
+   \param interest Interest type
+   \return true/false
+   \sa setItemInterest(), ItemAttribute
+*/
+bool QwtPlotItem::testItemInterest( ItemInterest interest ) const
+{
+    return d_data->interests.testFlag( interest );
 }
 
@@ -247,5 +281,5 @@
 void QwtPlotItem::setRenderHint( RenderHint hint, bool on )
 {
-    if ( ( ( d_data->renderHints & hint ) != 0 ) != on )
+    if ( d_data->renderHints.testFlag( hint ) != on )
     {
         if ( on )
@@ -267,6 +301,108 @@
 bool QwtPlotItem::testRenderHint( RenderHint hint ) const
 {
-    return ( d_data->renderHints & hint );
-}
+    return d_data->renderHints.testFlag( hint );
+}
+
+/*!
+   On multi core systems rendering of certain plot item 
+   ( f.e QwtPlotRasterItem ) can be done in parallel in 
+   several threads.
+
+   The default setting is set to 1.
+
+   \param numThreads Number of threads to be used for rendering.
+                     If numThreads is set to 0, the system specific
+                     ideal thread count is used.
+
+   The default thread count is 1 ( = no additional threads )
+*/
+void QwtPlotItem::setRenderThreadCount( uint numThreads )
+{
+    d_data->renderThreadCount = numThreads;
+}
+
+/*!
+   \return Number of threads to be used for rendering.
+           If numThreads() is set to 0, the system specific
+           ideal thread count is used.
+*/
+uint QwtPlotItem::renderThreadCount() const
+{
+    return d_data->renderThreadCount;
+}
+
+/*!
+   Set the size of the legend icon
+
+   The default setting is 8x8 pixels
+
+   \param size Size
+   \sa legendIconSize(), legendIcon()
+*/
+void QwtPlotItem::setLegendIconSize( const QSize &size )
+{
+    if ( d_data->legendIconSize != size )
+    {
+        d_data->legendIconSize = size;
+        legendChanged();
+    }
+}
+
+/*!
+   \return Legend icon size
+   \sa setLegendIconSize(), legendIcon()
+*/
+QSize QwtPlotItem::legendIconSize() const
+{
+    return d_data->legendIconSize;
+}
+
+/*!
+   \return Icon representing the item on the legend
+
+   The default implementation returns an invalid icon
+
+   \param index Index of the legend entry 
+                ( usually there is only one )
+   \param size Icon size
+
+   \sa setLegendIconSize(), legendData()
+ */
+QwtGraphic QwtPlotItem::legendIcon( 
+    int index, const QSizeF &size ) const
+{
+    Q_UNUSED( index )
+    Q_UNUSED( size )
+
+    return QwtGraphic();
+}
+
+/*!
+   \brief Return a default icon from a brush
+
+   The default icon is a filled rectangle used
+   in several derived classes as legendIcon().
+
+   \param brush Fill brush
+   \param size Icon size
+
+   \return A filled rectangle
+ */
+QwtGraphic QwtPlotItem::defaultIcon( 
+    const QBrush &brush, const QSizeF &size ) const
+{   
+    QwtGraphic icon;
+    if ( !size.isEmpty() )
+    {
+        icon.setDefaultSize( size );
+        
+        QRectF r( 0, 0, size.width(), size.height() );
+        
+        QPainter painter( &icon );
+        painter.fillRect( r, brush );
+    }   
+    
+    return icon;
+}   
 
 //! Show the item
@@ -307,18 +443,23 @@
 
 /*!
-   Update the legend and call QwtPlot::autoRefresh for the
+   Update the legend and call QwtPlot::autoRefresh() for the
    parent plot.
 
-   \sa updateLegend()
+   \sa QwtPlot::legendChanged(), QwtPlot::autoRefresh()
 */
 void QwtPlotItem::itemChanged()
 {
     if ( d_data->plot )
-    {
-        if ( d_data->plot->legend() )
-            updateLegend( d_data->plot->legend() );
-
         d_data->plot->autoRefresh();
-    }
+}
+
+/*!
+   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 );
 }
 
@@ -326,10 +467,10 @@
    Set X and Y axis
 
-   The item will painted according to the coordinates its Axes.
-
-   \param xAxis X Axis
-   \param yAxis Y Axis
-
-   \sa setXAxis(), setYAxis(), xAxis(), yAxis()
+   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 )
@@ -349,6 +490,6 @@
    The item will painted according to the coordinates its Axes.
 
-   \param axis X Axis
-   \sa setAxes(), setYAxis(), xAxis()
+   \param axis X Axis ( QwtPlot::xBottom or QwtPlot::xTop )
+   \sa setAxes(), setYAxis(), xAxis(), QwtPlot::Axis
 */
 void QwtPlotItem::setXAxis( int axis )
@@ -366,6 +507,6 @@
    The item will painted according to the coordinates its Axes.
 
-   \param axis Y Axis
-   \sa setAxes(), setXAxis(), yAxis()
+   \param axis Y Axis ( QwtPlot::yLeft or QwtPlot::yRight )
+   \sa setAxes(), setXAxis(), yAxis(), QwtPlot::Axis
 */
 void QwtPlotItem::setYAxis( int axis )
@@ -392,4 +533,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
@@ -399,93 +541,79 @@
 
 /*!
-   \brief Allocate the widget that represents the item on the legend
-
-   The default implementation returns a QwtLegendItem(), but an item 
-   could be represented by any type of widget,
-   by overloading legendItem() and updateLegend().
-
-   \return QwtLegendItem()
-   \sa updateLegend() QwtLegend()
-*/
-QWidget *QwtPlotItem::legendItem() const
-{
-    QwtLegendItem *item = new QwtLegendItem;
-    if ( d_data->plot )
-    {
-        QObject::connect( item, SIGNAL( clicked() ),
-            d_data->plot, SLOT( legendItemClicked() ) );
-        QObject::connect( item, SIGNAL( checked( bool ) ),
-            d_data->plot, SLOT( legendItemChecked( bool ) ) );
-    }
-    return item;
-}
-
-/*!
-   \brief Update the widget that represents the item on the legend
-
-   updateLegend() is called from itemChanged() to adopt the widget
-   representing the item on the legend to its new configuration.
-
-   The default implementation updates a QwtLegendItem(), 
-   but an item could be represented by any type of widget,
-   by overloading legendItem() and updateLegend().
-
-   \param legend Legend
-
-   \sa legendItem(), itemChanged(), QwtLegend()
-*/
-void QwtPlotItem::updateLegend( QwtLegend *legend ) const
-{
-    if ( legend == NULL )
-        return;
-
-    QWidget *lgdItem = legend->find( this );
-    if ( testItemAttribute( QwtPlotItem::Legend ) )
-    {
-        if ( lgdItem == NULL )
-        {
-            lgdItem = legendItem();
-            if ( lgdItem )
-                legend->insert( this, lgdItem );
-        }
-
-        QwtLegendItem *label = qobject_cast<QwtLegendItem *>( lgdItem );
-        if ( label )
-        {
-            // paint the identifier
-            const QSize sz = label->identifierSize();
-
-            QPixmap identifier( sz.width(), sz.height() );
-            identifier.fill( Qt::transparent );
-
-            QPainter painter( &identifier );
-            painter.setRenderHint( QPainter::Antialiasing,
-                testRenderHint( QwtPlotItem::RenderAntialiased ) );
-            drawLegendIdentifier( &painter,
-                QRect( 0, 0, sz.width(), sz.height() ) );
-            painter.end();
-
-            const bool doUpdate = label->updatesEnabled();
-            if ( doUpdate )
-                label->setUpdatesEnabled( false );
-
-            label->setText( title() );
-            label->setIdentifier( identifier );
-            label->setItemMode( legend->itemMode() );
-
-            if ( doUpdate )
-                label->setUpdatesEnabled( true );
-
-            label->update();
-        }
-    }
-    else
-    {
-        if ( lgdItem )
-        {
-            lgdItem->hide();
-            lgdItem->deleteLater();
-        }
-    }
+   \brief Calculate a hint for the canvas margin
+
+   When the QwtPlotItem::Margins flag is enabled the plot item
+   indicates, that it needs some margins at the borders of the canvas.
+   This is f.e. used by bar charts to reserve space for displaying
+   the bars.
+
+   The margins are in target device coordinates ( pixels on screen )
+
+   \param xMap Maps x-values into pixel coordinates.
+   \param yMap Maps y-values into pixel coordinates.
+   \param canvasRect Contents rectangle of the canvas in painter coordinates
+   \param left Returns the left margin
+   \param top Returns the top margin
+   \param right Returns the right margin
+   \param bottom Returns the bottom margin
+
+   \return The default implementation returns 0 for all margins
+
+   \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
+{
+    Q_UNUSED( xMap );
+    Q_UNUSED( yMap );
+    Q_UNUSED( canvasRect );
+
+    // use QMargins, when we don't need to support Qt < 4.6 anymore
+    left = top = right = bottom = 0.0;
+}
+
+/*!
+   \brief Return all information, that is needed to represent
+          the item on the legend
+
+   Most items are represented by one entry on the legend
+   showing an icon and a text, but f.e. QwtPlotMultiBarChart
+   displays one entry for each bar.
+
+   QwtLegendData is basically a list of QVariants that makes it
+   possible to overload and reimplement legendData() to 
+   return almost any type of information, that is understood
+   by the receiver that acts as the legend.
+
+   The default implementation returns one entry with 
+   the title() of the item and the legendIcon().
+
+   \return Data, that is needed to represent the item on the legend
+   \sa title(), legendIcon(), QwtLegend, QwtPlotLegendItem
+ */
+QList<QwtLegendData> QwtPlotItem::legendData() const
+{
+    QwtLegendData data;
+
+    QwtText label = title();
+    label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
+            
+    QVariant titleValue;
+    qVariantSetValue( titleValue, label );
+    data.setValue( QwtLegendData::TitleRole, titleValue );
+        
+    const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
+    if ( !graphic.isNull() )
+    {   
+        QVariant iconValue;
+        qVariantSetValue( iconValue, graphic );
+        data.setValue( QwtLegendData::IconRole, iconValue );
+    }   
+        
+    QList<QwtLegendData> list;
+    list += data;
+
+    return list;
 }
 
@@ -498,8 +626,11 @@
    updateScaleDiv()
 
+   updateScaleDiv() is only called when the ScaleInterest interest
+   is enabled. The default implementation does nothing.
+
    \param xScaleDiv Scale division of the x-axis
    \param yScaleDiv Scale division of the y-axis
 
-   \sa QwtPlot::updateAxes()
+   \sa QwtPlot::updateAxes(), ScaleInterest
 */
 void QwtPlotItem::updateScaleDiv( const QwtScaleDiv &xScaleDiv,
@@ -511,10 +642,35 @@
 
 /*!
-   \brief Calculate the bounding scale rect of 2 maps
-
-   \param xMap X map
-   \param yMap X map
-
-   \return Bounding scale rect of the scale maps, normalized
+   \brief Update the item to changes of the legend info
+
+   Plot items that want to display a legend ( not those, that want to
+   be displayed on a legend ! ) will have to implement updateLegend().
+
+   updateLegend() is only called when the LegendInterest interest
+   is enabled. The default implementation does nothing.
+
+   \param item Plot item to be displayed on a legend
+   \param data Attributes how to display item on the legend
+
+   \sa QwtPlotLegendItem
+
+   \note Plot items, that want to be displayed on a legend
+         need to enable the QwtPlotItem::Legend flag and to implement
+         legendData() and legendIcon()
+ */
+void QwtPlotItem::updateLegend( const QwtPlotItem *item, 
+    const QList<QwtLegendData> &data )
+{
+    Q_UNUSED( item );
+    Q_UNUSED( data );
+}
+
+/*!
+   \brief Calculate the bounding scale rectangle of 2 maps
+
+   \param xMap Maps x-values into pixel coordinates.
+   \param yMap Maps y-values into pixel coordinates.
+
+   \return Bounding scale rect of the scale maps, not normalized
 */
 QRectF QwtPlotItem::scaleRect( const QwtScaleMap &xMap,
@@ -526,10 +682,10 @@
 
 /*!
-   \brief Calculate the bounding paint rect of 2 maps
-
-   \param xMap X map
-   \param yMap X map
-
-   \return Bounding paint rect of the scale maps, normalized
+   \brief Calculate the bounding paint rectangle of 2 maps
+
+   \param xMap Maps x-values into pixel coordinates.
+   \param yMap Maps y-values into pixel coordinates.
+
+   \return Bounding paint rectangle of the scale maps, not normalized
 */
 QRectF QwtPlotItem::paintRect( const QwtScaleMap &xMap,
Index: trunk/BNC/qwt/qwt_plot_item.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_item.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_item.h	(revision 8127)
@@ -12,15 +12,15 @@
 
 #include "qwt_global.h"
-#include "qwt_legend_itemmanager.h"
 #include "qwt_text.h"
+#include "qwt_legend_data.h"
+#include "qwt_graphic.h"
 #include <qrect.h>
-
-class QString;
+#include <qlist.h>
+#include <qmetatype.h>
+
 class QPainter;
-class QWidget;
-class QwtPlot;
-class QwtLegend;
 class QwtScaleMap;
 class QwtScaleDiv;
+class QwtPlot;
 
 /*!
@@ -51,5 +51,5 @@
 
   Depending on the QwtPlotItem::ItemAttribute flags, an item is included
-  into autoscaling or has an entry on the legnd.
+  into autoscaling or has an entry on the legend.
 
   Before misusing the existing item classes it might be better to
@@ -62,5 +62,5 @@
 */
 
-class QWT_EXPORT QwtPlotItem: public QwtLegendItemManager
+class QWT_EXPORT QwtPlotItem
 {
 public:
@@ -73,22 +73,70 @@
     enum RttiValues
     {
+        //! Unspecific value, that can be used, when it doesn't matter
         Rtti_PlotItem = 0,
 
+        //! For QwtPlotGrid
         Rtti_PlotGrid,
+
+        //! For QwtPlotScaleItem
         Rtti_PlotScale,
+
+        //! For QwtPlotLegendItem
+        Rtti_PlotLegend,
+
+        //! For QwtPlotMarker
         Rtti_PlotMarker,
+
+        //! For QwtPlotCurve
         Rtti_PlotCurve,
+
+        //! For QwtPlotSpectroCurve
         Rtti_PlotSpectroCurve,
+
+        //! For QwtPlotIntervalCurve
         Rtti_PlotIntervalCurve,
+
+        //! For QwtPlotHistogram
         Rtti_PlotHistogram,
+
+        //! For QwtPlotSpectrogram
         Rtti_PlotSpectrogram,
+
+        //! For QwtPlotSvgItem
         Rtti_PlotSVG,
 
+        //! For QwtPlotTradingCurve
+        Rtti_PlotTradingCurve,
+
+        //! For QwtPlotBarChart
+        Rtti_PlotBarChart,
+
+        //! For QwtPlotMultiBarChart
+        Rtti_PlotMultiBarChart,
+
+        //! For QwtPlotShapeItem
+        Rtti_PlotShape,
+
+        //! For QwtPlotTextLabel
+        Rtti_PlotTextLabel,
+
+        //! For QwtPlotZoneItem
+        Rtti_PlotZone,
+
+        /*! 
+           Values >= Rtti_PlotUserItem are reserved for plot items
+           not implemented in the Qwt library.
+         */
         Rtti_PlotUserItem = 1000
     };
 
     /*!
-       Plot Item Attributes
-       \sa setItemAttribute(), testItemAttribute()
+       \brief Plot Item Attributes
+
+       Various aspects of a plot widget depend on the attributes of
+       the attached plot items. If and how a single plot item 
+       participates in these updates depends on its attributes.
+       
+       \sa setItemAttribute(), testItemAttribute(), ItemInterest
      */
     enum ItemAttribute
@@ -98,12 +146,54 @@
 
         /*!
-         The boundingRect() of the item is included in the
-         autoscaling calculation.
-         */
-        AutoScale = 0x02
+           The boundingRect() of the item is included in the
+           autoscaling calculation as long as its width or height
+           is >= 0.0.
+         */
+        AutoScale = 0x02,
+
+        /*!
+           The item needs extra space to display something outside
+           its bounding rectangle. 
+           \sa getCanvasMarginHint()
+         */
+        Margins = 0x04
     };
 
     //! Plot Item Attributes
     typedef QFlags<ItemAttribute> ItemAttributes;
+
+    /*!
+       \brief Plot Item Interests
+
+       Plot items might depend on the situation of the corresponding
+       plot widget. By enabling an interest the plot item will be
+       notified, when the corresponding attribute of the plot widgets
+       has changed.
+
+       \sa setItemAttribute(), testItemAttribute(), ItemInterest
+     */
+    enum ItemInterest
+    {
+        /*! 
+           The item is interested in updates of the scales
+           \sa updateScaleDiv()
+         */
+        ScaleInterest = 0x01,
+
+        /*! 
+           The item is interested in updates of the legend ( of other items )
+           This flag is intended for items, that want to implement a legend
+           for displaying entries of other plot item.
+
+           \note If the plot item wants to be represented on a legend
+                 enable QwtPlotItem::Legend instead.
+
+           \sa updateLegend()
+         */
+        LegendInterest = 0x02
+    };
+
+    //! Plot Item Interests
+    typedef QFlags<ItemInterest> ItemInterests;
 
     //! Render hints
@@ -111,5 +201,5 @@
     {
         //! Enable antialiasing
-        RenderAntialiased = 1
+        RenderAntialiased = 0x1
     };
 
@@ -134,6 +224,15 @@
     bool testItemAttribute( ItemAttribute ) const;
 
+    void setItemInterest( ItemInterest, bool on = true );
+    bool testItemInterest( ItemInterest ) const;
+
     void setRenderHint( RenderHint, bool on = true );
     bool testRenderHint( RenderHint ) const;
+
+    void setRenderThreadCount( uint numThreads );
+    uint renderThreadCount() const;
+
+    void setLegendIconSize( const QSize & );
+    QSize legendIconSize() const;
 
     double z() const;
@@ -154,4 +253,5 @@
 
     virtual void itemChanged();
+    virtual void legendChanged();
 
     /*!
@@ -169,12 +269,24 @@
     virtual QRectF boundingRect() const;
 
-    virtual void updateLegend( QwtLegend * ) const;
+    virtual void getCanvasMarginHint( 
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasSize,
+        double &left, double &top, double &right, double &bottom) const;
+
     virtual void updateScaleDiv( 
         const QwtScaleDiv&, const QwtScaleDiv& );
 
-    virtual QWidget *legendItem() const;
+    virtual void updateLegend( const QwtPlotItem *,
+        const QList<QwtLegendData> & );
 
     QRectF scaleRect( const QwtScaleMap &, const QwtScaleMap & ) const;
     QRectF paintRect( const QwtScaleMap &, const QwtScaleMap & ) const;
+
+    virtual QList<QwtLegendData> legendData() const;
+
+    virtual QwtGraphic legendIcon( int index, const QSizeF  & ) const;
+
+protected:
+    QwtGraphic defaultIcon( const QBrush &, const QSizeF & ) const;
 
 private:
@@ -188,5 +300,8 @@
 
 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemAttributes )
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::ItemInterests )
 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotItem::RenderHints )
 
+Q_DECLARE_METATYPE( QwtPlotItem * )
+
 #endif
Index: trunk/BNC/qwt/qwt_plot_layout.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_layout.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_layout.cpp	(revision 8127)
@@ -11,7 +11,6 @@
 #include "qwt_text.h"
 #include "qwt_text_label.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_scale_widget.h"
-#include "qwt_legend.h"
+#include "qwt_abstract_legend.h"
 #include <qscrollbar.h>
 #include <qmath.h>
@@ -25,6 +24,6 @@
     {
         int frameWidth;
-        int vScrollBarWidth;
-        int hScrollBarHeight;
+        int hScrollExtent;
+        int vScrollExtent;
         QSize hint;
     } legend;
@@ -35,4 +34,10 @@
         int frameWidth;
     } title;
+
+    struct t_footerData
+    {
+        QwtText text;
+        int frameWidth;
+    } footer;
 
     struct t_scaleData
@@ -44,5 +49,5 @@
         int end;
         int baseLineOffset;
-        int tickOffset;
+        double tickOffset;
         int dimWithoutTitle;
     } scale[QwtPlot::axisCnt];
@@ -50,5 +55,6 @@
     struct t_canvasData
     {
-        int frameWidth;
+        int contentsMargins[ QwtPlot::axisCnt ];
+
     } canvas;
 };
@@ -57,27 +63,23 @@
   Extract all layout relevant data from the plot components
 */
-
 void QwtPlotLayout::LayoutData::init( const QwtPlot *plot, const QRectF &rect )
 {
     // legend
 
-    if ( plot->plotLayout()->legendPosition() != QwtPlot::ExternalLegend
-        && plot->legend() )
+    if ( plot->legend() )
     {
         legend.frameWidth = plot->legend()->frameWidth();
-        legend.vScrollBarWidth =
-            plot->legend()->verticalScrollBar()->sizeHint().width();
-        legend.hScrollBarHeight =
-            plot->legend()->horizontalScrollBar()->sizeHint().height();
+        legend.hScrollExtent =
+            plot->legend()->scrollExtent( Qt::Horizontal );
+        legend.vScrollExtent =
+            plot->legend()->scrollExtent( Qt::Vertical );
 
         const QSize hint = plot->legend()->sizeHint();
 
-        int w = qMin( hint.width(), qFloor( rect.width() ) );
+        const int w = qMin( hint.width(), qFloor( rect.width() ) );
+
         int h = plot->legend()->heightForWidth( w );
-        if ( h == 0 )
+        if ( h <= 0 )
             h = hint.height();
-
-        if ( h > rect.height() )
-            w += legend.vScrollBarWidth;
 
         legend.hint = QSize( w, h );
@@ -99,4 +101,19 @@
     }
 
+    // footer
+
+    footer.frameWidth = 0;
+    footer.text = QwtText();
+
+    if ( plot->footerLabel() )
+    {
+        const QwtTextLabel *label = plot->footerLabel();
+        footer.text = label->text();
+        if ( !( footer.text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) )
+            footer.text.setFont( label->font() );
+
+        footer.frameWidth = plot->footerLabel()->frameWidth();
+    }
+
     // scales
 
@@ -140,5 +157,5 @@
             scale[axis].end = 0;
             scale[axis].baseLineOffset = 0;
-            scale[axis].tickOffset = 0;
+            scale[axis].tickOffset = 0.0;
             scale[axis].dimWithoutTitle = 0;
         }
@@ -147,5 +164,9 @@
     // canvas
 
-    canvas.frameWidth = plot->canvas()->frameWidth();
+    plot->canvas()->getContentsMargins( 
+        &canvas.contentsMargins[ QwtPlot::yLeft ], 
+        &canvas.contentsMargins[ QwtPlot::xTop ],
+        &canvas.contentsMargins[ QwtPlot::yRight ],
+        &canvas.contentsMargins[ QwtPlot::xBottom ] );
 }
 
@@ -154,10 +175,10 @@
 public:
     PrivateData():
-        spacing( 5 ),
-        alignCanvasToScales( false )
+        spacing( 5 )
     {
     }
 
     QRectF titleRect;
+    QRectF footerRect;
     QRectF legendRect;
     QRectF scaleRect[QwtPlot::axisCnt];
@@ -170,5 +191,5 @@
     unsigned int spacing;
     unsigned int canvasMargin[QwtPlot::axisCnt];
-    bool alignCanvasToScales;
+    bool alignCanvasToScales[QwtPlot::axisCnt];
 };
 
@@ -183,4 +204,5 @@
     setLegendPosition( QwtPlot::BottomLegend );
     setCanvasMargin( 4 );
+    setAlignCanvasToScales( false );
 
     invalidate();
@@ -203,5 +225,5 @@
   \sa canvasMargin()
 
-  \warning The margin will have no effect when alignCanvasToScales is true
+  \warning The margin will have no effect when alignCanvasToScale() is true
 */
 
@@ -221,30 +243,49 @@
 
 /*!
+    \param axisId Axis index
     \return Margin around the scale tick borders
     \sa setCanvasMargin()
 */
-int QwtPlotLayout::canvasMargin( int axis ) const
-{
-    if ( axis < 0 || axis >= QwtPlot::axisCnt )
+int QwtPlotLayout::canvasMargin( int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPlot::axisCnt )
         return 0;
 
-    return d_data->canvasMargin[axis];
+    return d_data->canvasMargin[axisId];
+}
+
+/*!
+  \brief Set the align-canvas-to-axis-scales flag for all axes
+
+  \param on True/False
+  \sa setAlignCanvasToScale(), alignCanvasToScale()
+*/
+void QwtPlotLayout::setAlignCanvasToScales( bool on )
+{
+    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
+        d_data->alignCanvasToScales[axis] = on;
 }
 
 /*!
   Change the align-canvas-to-axis-scales setting. The canvas may:
+
   - extend beyond the axis scale ends to maximize its size,
   - align with the axis scale ends to control its size.
 
-  \param alignCanvasToScales New align-canvas-to-axis-scales setting
-
-  \sa setCanvasMargin()
-  \note In this context the term 'scale' means the backbone of a scale.
-  \warning In case of alignCanvasToScales == true canvasMargin will have
-           no effect
-*/
-void QwtPlotLayout::setAlignCanvasToScales( bool alignCanvasToScales )
-{
-    d_data->alignCanvasToScales = alignCanvasToScales;
+  The axisId parameter is somehow confusing as it identifies a border
+  of the plot and not the axes, that are aligned. F.e when QwtPlot::yLeft
+  is set, the left end of the the x-axes ( QwtPlot::xTop, QwtPlot::xBottom )
+  is aligned.
+
+  \param axisId Axis index
+  \param on New align-canvas-to-axis-scales setting
+
+  \sa setCanvasMargin(), alignCanvasToScale(), setAlignCanvasToScales()
+  \warning In case of on == true canvasMargin() will have no effect
+*/
+void QwtPlotLayout::setAlignCanvasToScale( int axisId, bool on )
+{
+    if ( axisId >= 0 && axisId < QwtPlot::axisCnt )
+        d_data->alignCanvasToScales[axisId] = on;
 }
 
@@ -254,11 +295,14 @@
   - align with the axis scale ends to control its size.
 
+  \param axisId Axis index
   \return align-canvas-to-axis-scales setting
-  \sa setAlignCanvasToScales, setCanvasMargin()
-  \note In this context the term 'scale' means the backbone of a scale.
-*/
-bool QwtPlotLayout::alignCanvasToScales() const
-{
-    return d_data->alignCanvasToScales;
+  \sa setAlignCanvasToScale(), setAlignCanvasToScale(), setCanvasMargin()
+*/
+bool QwtPlotLayout::alignCanvasToScale( int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPlot::axisCnt )
+        return false;
+
+    return d_data->alignCanvasToScales[ axisId ];
 }
 
@@ -267,6 +311,6 @@
   between the plot components.
 
-  \param spacing new spacing
-  \sa setMargin(), spacing()
+  \param spacing New spacing
+  \sa setCanvasMargin(), spacing()
 */
 void QwtPlotLayout::setSpacing( int spacing )
@@ -276,5 +320,5 @@
 
 /*!
-  \return spacing
+  \return Spacing
   \sa margin(), setSpacing()
 */
@@ -287,6 +331,6 @@
   \brief Specify the position of the legend
   \param pos The legend's position.
-  \param ratio Ratio between legend and the bounding rect
-               of title, canvas and axes. The legend will be shrinked
+  \param ratio Ratio between legend and the bounding rectangle
+               of title, footer, canvas and axes. The legend will be shrunk
                if it would need more space than the given ratio.
                The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
@@ -318,7 +362,4 @@
             d_data->legendPos = pos;
             break;
-        case QwtPlot::ExternalLegend:
-            d_data->legendRatio = ratio; // meaningless
-            d_data->legendPos = pos;
         default:
             break;
@@ -351,6 +392,6 @@
 /*!
   Specify the relative size of the legend in the plot
-  \param ratio Ratio between legend and the bounding rect
-               of title, canvas and axes. The legend will be shrinked
+  \param ratio Ratio between legend and the bounding rectangle
+               of title, footer, canvas and axes. The legend will be shrunk
                if it would need more space than the given ratio.
                The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
@@ -373,11 +414,60 @@
 
 /*!
+  \brief Set the geometry for the title
+
+  This method is intended to be used from derived layouts
+  overloading activate()
+
+  \sa titleRect(), activate()
+ */
+void QwtPlotLayout::setTitleRect( const QRectF &rect )
+{
+    d_data->titleRect = rect;
+}
+
+/*!
   \return Geometry for the title
   \sa activate(), invalidate()
 */
-
-const QRectF &QwtPlotLayout::titleRect() const
+QRectF QwtPlotLayout::titleRect() const
 {
     return d_data->titleRect;
+}
+
+/*!
+  \brief Set the geometry for the footer
+
+  This method is intended to be used from derived layouts
+  overloading activate()
+
+  \sa footerRect(), activate()
+ */
+void QwtPlotLayout::setFooterRect( const QRectF &rect )
+{
+    d_data->footerRect = rect;
+}
+
+/*!
+  \return Geometry for the footer
+  \sa activate(), invalidate()
+*/
+QRectF QwtPlotLayout::footerRect() const
+{
+    return d_data->footerRect;
+}
+
+/*!
+  \brief Set the geometry for the legend
+
+  This method is intended to be used from derived layouts
+  overloading activate()
+
+  \param rect Rectangle for the legend
+
+  \sa legendRect(), activate()
+ */
+void QwtPlotLayout::setLegendRect( const QRectF &rect )
+{
+    d_data->legendRect = rect;
 }
 
@@ -386,8 +476,24 @@
   \sa activate(), invalidate()
 */
-
-const QRectF &QwtPlotLayout::legendRect() const
+QRectF QwtPlotLayout::legendRect() const
 {
     return d_data->legendRect;
+}
+
+/*!
+  \brief Set the geometry for an axis
+
+  This method is intended to be used from derived layouts
+  overloading activate()
+
+  \param axis Axis index
+  \param rect Rectangle for the scale
+
+  \sa scaleRect(), activate()
+ */
+void QwtPlotLayout::setScaleRect( int axis, const QRectF &rect )
+{
+    if ( axis >= 0 && axis < QwtPlot::axisCnt )
+        d_data->scaleRect[axis] = rect;
 }
 
@@ -397,6 +503,5 @@
   \sa activate(), invalidate()
 */
-
-const QRectF &QwtPlotLayout::scaleRect( int axis ) const
+QRectF QwtPlotLayout::scaleRect( int axis ) const
 {
     if ( axis < 0 || axis >= QwtPlot::axisCnt )
@@ -409,9 +514,21 @@
 
 /*!
+  \brief Set the geometry for the canvas
+
+  This method is intended to be used from derived layouts
+  overloading activate()
+
+  \sa canvasRect(), activate()
+ */
+void QwtPlotLayout::setCanvasRect( const QRectF &rect )
+{
+    d_data->canvasRect = rect;
+}
+
+/*!
   \return Geometry for the canvas
   \sa activate(), invalidate()
 */
-
-const QRectF &QwtPlotLayout::canvasRect() const
+QRectF QwtPlotLayout::canvasRect() const
 {
     return d_data->canvasRect;
@@ -424,5 +541,7 @@
 void QwtPlotLayout::invalidate()
 {
-    d_data->titleRect = d_data->legendRect = d_data->canvasRect = QRect();
+    d_data->titleRect = d_data->footerRect
+        = d_data->legendRect = d_data->canvasRect = QRect();
+
     for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
         d_data->scaleRect[axis] = QRect();
@@ -430,5 +549,7 @@
 
 /*!
-  \brief Return a minimum size hint
+  \return Minimum size hint
+  \param plot Plot widget
+
   \sa QwtPlot::minimumSizeHint()
 */
@@ -453,4 +574,7 @@
     int canvasBorder[QwtPlot::axisCnt];
 
+    int fw;
+    plot->canvas()->getContentsMargins( &fw, NULL, NULL, NULL );
+
     int axis;
     for ( axis = 0; axis < QwtPlot::axisCnt; axis++ )
@@ -467,10 +591,8 @@
             sd.tickOffset = scl->margin();
             if ( scl->scaleDraw()->hasComponent( QwtAbstractScaleDraw::Ticks ) )
-                sd.tickOffset += scl->scaleDraw()->maxTickLength();
-        }
-
-        canvasBorder[axis] = plot->canvas()->frameWidth() +
-            d_data->canvasMargin[axis] + 1;
-
+                sd.tickOffset += qCeil( scl->scaleDraw()->maxTickLength() );
+        }
+
+        canvasBorder[axis] = fw + d_data->canvasMargin[axis] + 1;
     }
 
@@ -524,52 +646,62 @@
     }
 
-    const QwtPlotCanvas *canvas = plot->canvas();
+    const QWidget *canvas = plot->canvas();
+
+    int left, top, right, bottom;
+    canvas->getContentsMargins( &left, &top, &right, &bottom );
+
     const QSize minCanvasSize = canvas->minimumSize();
 
     int w = scaleData[QwtPlot::yLeft].w + scaleData[QwtPlot::yRight].w;
     int cw = qMax( scaleData[QwtPlot::xBottom].w, scaleData[QwtPlot::xTop].w )
-        + 2 * ( canvas->frameWidth() + 1 );
+        + left + 1 + right + 1;
     w += qMax( cw, minCanvasSize.width() );
 
     int h = scaleData[QwtPlot::xBottom].h + scaleData[QwtPlot::xTop].h;
     int ch = qMax( scaleData[QwtPlot::yLeft].h, scaleData[QwtPlot::yRight].h )
-        + 2 * ( canvas->frameWidth() + 1 );
+        + top + 1 + bottom + 1;
     h += qMax( ch, minCanvasSize.height() );
 
-    const QwtTextLabel *title = plot->titleLabel();
-    if ( title && !title->text().isEmpty() )
-    {
-        // If only QwtPlot::yLeft or QwtPlot::yRight is showing,
-        // we center on the plot canvas.
-        const bool centerOnCanvas = !( plot->axisEnabled( QwtPlot::yLeft )
-            && plot->axisEnabled( QwtPlot::yRight ) );
-
-        int titleW = w;
-        if ( centerOnCanvas )
-        {
-            titleW -= scaleData[QwtPlot::yLeft].w
-                + scaleData[QwtPlot::yRight].w;
-        }
-
-        int titleH = title->heightForWidth( titleW );
-        if ( titleH > titleW ) // Compensate for a long title
-        {
-            w = titleW = titleH;
+    const QwtTextLabel *labels[2];
+    labels[0] = plot->titleLabel();
+    labels[1] = plot->footerLabel();
+
+    for ( int i = 0; i < 2; i++ )
+    {
+        const QwtTextLabel *label   = labels[i];
+        if ( label && !label->text().isEmpty() )
+        {
+            // If only QwtPlot::yLeft or QwtPlot::yRight is showing,
+            // we center on the plot canvas.
+            const bool centerOnCanvas = !( plot->axisEnabled( QwtPlot::yLeft )
+                && plot->axisEnabled( QwtPlot::yRight ) );
+
+            int labelW = w;
             if ( centerOnCanvas )
             {
-                w += scaleData[QwtPlot::yLeft].w
+                labelW -= scaleData[QwtPlot::yLeft].w
                     + scaleData[QwtPlot::yRight].w;
             }
 
-            titleH = title->heightForWidth( titleW );
-        }
-        h += titleH + d_data->spacing;
+            int labelH = label->heightForWidth( labelW );
+            if ( labelH > labelW ) // Compensate for a long title
+            {
+                w = labelW = labelH;
+                if ( centerOnCanvas )
+                {
+                    w += scaleData[QwtPlot::yLeft].w
+                        + scaleData[QwtPlot::yRight].w;
+                }
+
+                labelH = label->heightForWidth( labelW );
+            }
+            h += labelH + d_data->spacing;
+        }
     }
 
     // Compute the legend contribution
 
-    const QwtLegend *legend = plot->legend();
-    if ( d_data->legendPos != QwtPlot::ExternalLegend
-        && legend && !legend->isEmpty() )
+    const QwtAbstractLegend *legend = plot->legend();
+    if ( legend && !legend->isEmpty() )
     {
         if ( d_data->legendPos == QwtPlot::LeftLegend
@@ -583,5 +715,5 @@
 
             if ( legendH > h )
-                legendW += legend->verticalScrollBar()->sizeHint().height();
+                legendW += legend->scrollExtent( Qt::Horizontal );
 
             if ( d_data->legendRatio < 1.0 )
@@ -610,6 +742,8 @@
 /*!
   Find the geometry for the legend
+
   \param options Options how to layout the legend
   \param rect Rectangle where to place the legend
+
   \return Geometry for the legend
   \sa Options
@@ -637,5 +771,5 @@
                 // space for the vertical scrollbar.
 
-                dim += d_data->layoutData.legend.vScrollBarWidth;
+                dim += d_data->layoutData.legend.hScrollExtent;
             }
         }
@@ -644,5 +778,5 @@
     {
         dim = qMin( hint.height(), int( rect.height() * d_data->legendRatio ) );
-        dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
+        dim = qMax( dim, d_data->layoutData.legend.vScrollExtent );
     }
 
@@ -664,6 +798,4 @@
             legendRect.setHeight( dim );
             break;
-        case QwtPlot::ExternalLegend:
-            break;
     }
 
@@ -673,6 +805,8 @@
 /*!
   Align the legend to the canvas
+
   \param canvasRect Geometry of the canvas
   \param legendRect Maximum geometry for the legend
+
   \return Geometry for the aligned legend
 */
@@ -708,14 +842,15 @@
 
   \param options Options how to layout the legend
-  \param rect Bounding rect for title, axes and canvas.
+  \param rect Bounding rectangle for title, footer, axes and canvas.
   \param dimTitle Expanded height of the title widget
+  \param dimFooter Expanded height of the footer widget
   \param dimAxis Expanded heights of the axis in axis orientation.
 
   \sa Options
 */
-void QwtPlotLayout::expandLineBreaks( int options, const QRectF &rect,
-    int &dimTitle, int dimAxis[QwtPlot::axisCnt] ) const
-{
-    dimTitle = 0;
+void QwtPlotLayout::expandLineBreaks( Options options, const QRectF &rect,
+    int &dimTitle, int &dimFooter, int dimAxis[QwtPlot::axisCnt] ) const
+{
+    dimTitle = dimFooter = 0;
     for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
         dimAxis[axis] = 0;
@@ -725,8 +860,9 @@
     {
         backboneOffset[axis] = 0;
-        if ( !d_data->alignCanvasToScales )
+        if ( !( options & IgnoreFrames ) )
+            backboneOffset[axis] += d_data->layoutData.canvas.contentsMargins[ axis ];
+
+        if ( !d_data->alignCanvasToScales[axis] )
             backboneOffset[axis] += d_data->canvasMargin[axis];
-        if ( !( options & IgnoreFrames ) )
-            backboneOffset[axis] += d_data->layoutData.canvas.frameWidth;
     }
 
@@ -744,7 +880,8 @@
         // axis ... . So we loop as long until no size changes.
 
-        if ( !d_data->layoutData.title.text.isEmpty() )
-        {
-            int w = rect.width();
+        if ( !( ( options & IgnoreTitle ) ||
+            d_data->layoutData.title.text.isEmpty() ) )
+        {
+            double w = rect.width();
 
             if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled
@@ -766,4 +903,27 @@
         }
 
+        if ( !( ( options & IgnoreFooter ) ||
+            d_data->layoutData.footer.text.isEmpty() ) )
+        {
+            double w = rect.width();
+
+            if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled
+                != d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
+            {
+                // center to the canvas
+                w -= dimAxis[QwtPlot::yLeft] + dimAxis[QwtPlot::yRight];
+            }
+
+            int d = qCeil( d_data->layoutData.footer.text.heightForWidth( w ) );
+            if ( !( options & IgnoreFrames ) )
+                d += 2 * d_data->layoutData.footer.frameWidth;
+
+            if ( d > dimFooter )
+            {
+                dimFooter = d;
+                done = false;
+            }
+        }
+
         for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
         {
@@ -773,5 +933,5 @@
             if ( scaleData.isEnabled )
             {
-                int length;
+                double length;
                 if ( axis == QwtPlot::xTop || axis == QwtPlot::xBottom )
                 {
@@ -804,5 +964,5 @@
                         length += qMin(
                             d_data->layoutData.scale[QwtPlot::xBottom].tickOffset,
-                            scaleData.start - backboneOffset[QwtPlot::xBottom] );
+                            double( scaleData.start - backboneOffset[QwtPlot::xBottom] ) );
                     }
                     if ( dimAxis[QwtPlot::xTop] > 0 )
@@ -810,5 +970,5 @@
                         length += qMin(
                             d_data->layoutData.scale[QwtPlot::xTop].tickOffset,
-                            scaleData.end - backboneOffset[QwtPlot::xTop] );
+                            double( scaleData.end - backboneOffset[QwtPlot::xTop] ) );
                     }
 
@@ -820,5 +980,5 @@
                 if ( !scaleData.scaleWidget->title().isEmpty() )
                 {
-                    d += scaleData.scaleWidget->titleHeightForWidth( length );
+                    d += scaleData.scaleWidget->titleHeightForWidth( qFloor( length ) );
                 }
 
@@ -838,8 +998,12 @@
   the empty corners.
 
+  \param options Layout options
+  \param canvasRect Geometry of the canvas ( IN/OUT )
+  \param scaleRect Geometries of the scales ( IN/OUT )
+
   \sa Options
 */
 
-void QwtPlotLayout::alignScales( int options,
+void QwtPlotLayout::alignScales( Options options,
     QRectF &canvasRect, QRectF scaleRect[QwtPlot::axisCnt] ) const
 {
@@ -848,8 +1012,15 @@
     {
         backboneOffset[axis] = 0;
-        if ( !d_data->alignCanvasToScales )
+
+        if ( !d_data->alignCanvasToScales[axis] )
+        {
             backboneOffset[axis] += d_data->canvasMargin[axis];
+        }
+
         if ( !( options & IgnoreFrames ) )
-            backboneOffset[axis] += d_data->layoutData.canvas.frameWidth;
+        {
+            backboneOffset[axis] += 
+                d_data->layoutData.canvas.contentsMargins[axis];
+        }
     }
 
@@ -872,6 +1043,6 @@
             if ( leftScaleRect.isValid() )
             {
-                const int dx = leftOffset + leftScaleRect.width();
-                if ( d_data->alignCanvasToScales && dx < 0 )
+                const double dx = leftOffset + leftScaleRect.width();
+                if ( d_data->alignCanvasToScales[QwtPlot::yLeft] && dx < 0.0 )
                 {
                     /*
@@ -879,6 +1050,6 @@
                       of the left scale.
                      */
-                    canvasRect.setLeft( qMax( canvasRect.left(),
-                        axisRect.left() - dx ) );
+                    const double cLeft = canvasRect.left(); // qreal -> double
+                    canvasRect.setLeft( qMax( cLeft, axisRect.left() - dx ) );
                 }
                 else
@@ -891,5 +1062,5 @@
             else
             {
-                if ( d_data->alignCanvasToScales && leftOffset < 0 )
+                if ( d_data->alignCanvasToScales[QwtPlot::yLeft] && leftOffset < 0 )
                 {
                     canvasRect.setLeft( qMax( canvasRect.left(),
@@ -909,6 +1080,6 @@
             if ( rightScaleRect.isValid() )
             {
-                const int dx = rightOffset + rightScaleRect.width();
-                if ( d_data->alignCanvasToScales && dx < 0 )
+                const double dx = rightOffset + rightScaleRect.width();
+                if ( d_data->alignCanvasToScales[QwtPlot::yRight] && dx < 0 )
                 {
                     /*
@@ -916,6 +1087,6 @@
                       of the right scale.
                      */
-                    canvasRect.setRight( qMin( canvasRect.right(),
-                        axisRect.right() + dx ) );
+                    const double cRight = canvasRect.right(); // qreal -> double
+                    canvasRect.setRight( qMin( cRight, axisRect.right() + dx ) );
                 }   
 
@@ -926,5 +1097,5 @@
             else
             {
-                if ( d_data->alignCanvasToScales && rightOffset < 0 )
+                if ( d_data->alignCanvasToScales[QwtPlot::yRight] && rightOffset < 0 )
                 {
                     canvasRect.setRight( qMin( canvasRect.right(),
@@ -946,6 +1117,6 @@
             if ( bottomScaleRect.isValid() )
             {
-                const int dy = bottomOffset + bottomScaleRect.height();
-                if ( d_data->alignCanvasToScales && dy < 0 )
+                const double dy = bottomOffset + bottomScaleRect.height();
+                if ( d_data->alignCanvasToScales[QwtPlot::xBottom] && dy < 0 )
                 {
                     /*
@@ -953,6 +1124,6 @@
                       of the bottom scale.
                      */
-                    canvasRect.setBottom( qMin( canvasRect.bottom(),
-                        axisRect.bottom() + dy ) );
+                    const double cBottom = canvasRect.bottom(); // qreal -> double
+                    canvasRect.setBottom( qMin( cBottom, axisRect.bottom() + dy ) );
                 }
                 else
@@ -966,5 +1137,5 @@
             else
             {
-                if ( d_data->alignCanvasToScales && bottomOffset < 0 )
+                if ( d_data->alignCanvasToScales[QwtPlot::xBottom] && bottomOffset < 0 )
                 {
                     canvasRect.setBottom( qMin( canvasRect.bottom(),
@@ -983,6 +1154,6 @@
             if ( topScaleRect.isValid() )
             {
-                const int dy = topOffset + topScaleRect.height();
-                if ( d_data->alignCanvasToScales && dy < 0 )
+                const double dy = topOffset + topScaleRect.height();
+                if ( d_data->alignCanvasToScales[QwtPlot::xTop] && dy < 0 )
                 {
                     /*
@@ -990,6 +1161,6 @@
                       of the top scale.
                      */
-                    canvasRect.setTop( qMax( canvasRect.top(),
-                        axisRect.top() - dy ) );
+                    const double cTop = canvasRect.top(); // qreal -> double
+                    canvasRect.setTop( qMax( cTop, axisRect.top() - dy ) );
                 }
                 else
@@ -1003,5 +1174,5 @@
             else
             {
-                if ( d_data->alignCanvasToScales && topOffset < 0 )
+                if ( d_data->alignCanvasToScales[QwtPlot::xTop] && topOffset < 0 )
                 {
                     canvasRect.setTop( qMax( canvasRect.top(),
@@ -1017,44 +1188,71 @@
     }
 
-    if ( d_data->alignCanvasToScales )
-    {
-        /*
-          The canvas has been aligned to the scale with largest
-          border distances. Now we have to realign the other scale.
-         */
-
-        int fw = 0;
-        if ( !( options & IgnoreFrames ) )
-            fw = d_data->layoutData.canvas.frameWidth;
-
-        for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
-        {
-            if ( !scaleRect[axis].isValid() )
-                continue;
-
-            if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
-            {
-                scaleRect[axis].setLeft( canvasRect.left() + fw
-                    - d_data->layoutData.scale[axis].start );
-                scaleRect[axis].setRight( canvasRect.right() - fw - 1
-                    + d_data->layoutData.scale[axis].end );
-            }   
-            else
-            {
-                scaleRect[axis].setTop( canvasRect.top() + fw
-                    - d_data->layoutData.scale[axis].start );
-                scaleRect[axis].setBottom( canvasRect.bottom() - fw - 1
-                    + d_data->layoutData.scale[axis].end );
-            }
-        }
-
-        if ( scaleRect[QwtPlot::xTop].isValid() )
-            scaleRect[QwtPlot::xTop].setBottom( canvasRect.top() );
-        if ( scaleRect[QwtPlot::xBottom].isValid() )
-            scaleRect[QwtPlot::xBottom].setTop( canvasRect.bottom() );
-        if ( scaleRect[QwtPlot::yLeft].isValid() )
-            scaleRect[QwtPlot::yLeft].setRight( canvasRect.left() );
-        if ( scaleRect[QwtPlot::yRight].isValid() )
-            scaleRect[QwtPlot::yRight].setLeft( canvasRect.right() );
+    /*
+      The canvas has been aligned to the scale with largest
+      border distances. Now we have to realign the other scale.
+     */
+
+
+    for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
+    {
+        QRectF &sRect = scaleRect[axis];
+
+        if ( !sRect.isValid() )
+            continue;
+
+        if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
+        {
+            if ( d_data->alignCanvasToScales[QwtPlot::yLeft] )
+            {
+                double y = canvasRect.left() - d_data->layoutData.scale[axis].start;
+                if ( !( options & IgnoreFrames ) )
+                    y += d_data->layoutData.canvas.contentsMargins[ QwtPlot::yLeft ];
+
+                sRect.setLeft( y );
+            }
+            if ( d_data->alignCanvasToScales[QwtPlot::yRight] )
+            {
+                double y = canvasRect.right() - 1 + d_data->layoutData.scale[axis].end;
+                if ( !( options & IgnoreFrames ) )
+                    y -= d_data->layoutData.canvas.contentsMargins[ QwtPlot::yRight ];
+
+                sRect.setRight( y );
+            }
+
+            if ( d_data->alignCanvasToScales[ axis ] )
+            {
+                if ( axis == QwtPlot::xTop )
+                    sRect.setBottom( canvasRect.top() );
+                else
+                    sRect.setTop( canvasRect.bottom() );
+            }
+        }
+        else
+        {
+            if ( d_data->alignCanvasToScales[QwtPlot::xTop] )
+            {
+                double x = canvasRect.top() - d_data->layoutData.scale[axis].start;
+                if ( !( options & IgnoreFrames ) )
+                    x += d_data->layoutData.canvas.contentsMargins[ QwtPlot::xTop ];
+
+                sRect.setTop( x );
+            }
+            if ( d_data->alignCanvasToScales[QwtPlot::xBottom] )
+            {
+                double x = canvasRect.bottom() - 1 + d_data->layoutData.scale[axis].end;
+                if ( !( options & IgnoreFrames ) )
+                    x -= d_data->layoutData.canvas.contentsMargins[ QwtPlot::xBottom ];
+
+                sRect.setBottom( x );
+            }
+
+            if ( d_data->alignCanvasToScales[ axis ] )
+            {
+                if ( axis == QwtPlot::yLeft )
+                    sRect.setRight( canvasRect.left() );
+                else
+                    sRect.setLeft( canvasRect.right() );
+            }
+        }
     }
 }
@@ -1064,8 +1262,8 @@
 
   \param plot Plot to be layout
-  \param plotRect Rect where to place the components
+  \param plotRect Rectangle where to place the components
   \param options Layout options
 
-  \sa invalidate(), titleRect(),
+  \sa invalidate(), titleRect(), footerRect()
       legendRect(), scaleRect(), canvasRect()
 */
@@ -1077,11 +1275,10 @@
     QRectF rect( plotRect );  // undistributed rest of the plot rect
 
-    // We extract all layout relevant data from the widgets,
-    // filter them through pfilter and save them to d_data->layoutData.
+    // We extract all layout relevant parameters from the widgets,
+    // and save them to d_data->layoutData.
 
     d_data->layoutData.init( plot, rect );
 
     if ( !( options & IgnoreLegend )
-        && d_data->legendPos != QwtPlot::ExternalLegend
         && plot->legend() && !plot->legend()->isEmpty() )
     {
@@ -1091,5 +1288,5 @@
 
         const QRegion region( rect.toRect() );
-        rect = region.subtract( d_data->legendRect.toRect() ).boundingRect();
+        rect = region.subtracted( d_data->legendRect.toRect() ).boundingRect();
 
         switch ( d_data->legendPos )
@@ -1107,6 +1304,4 @@
                 rect.setBottom( rect.bottom() - d_data->spacing );
                 break;
-            case QwtPlot::ExternalLegend:
-                break; // suppress compiler warning
         }
     }
@@ -1125,20 +1320,24 @@
      |   |   Axis    |   |
      +---+-----------+---+
+     |      Footer       |
+     +---+-----------+---+
     */
 
-    // axes and title include text labels. The height of each
+    // title, footer and axes include text labels. The height of each
     // label depends on its line breaks, that depend on the width
     // for the label. A line break in a horizontal text will reduce
     // the available width for vertical texts and vice versa.
-    // expandLineBreaks finds the height/width for title and axes
+    // expandLineBreaks finds the height/width for title, footer and axes
     // including all line breaks.
 
-    int dimTitle, dimAxes[QwtPlot::axisCnt];
-    expandLineBreaks( options, rect, dimTitle, dimAxes );
+    int dimTitle, dimFooter, dimAxes[QwtPlot::axisCnt];
+    expandLineBreaks( options, rect, dimTitle, dimFooter, dimAxes );
 
     if ( dimTitle > 0 )
     {
-        d_data->titleRect = QRect( rect.x(), rect.y(),
-            rect.width(), dimTitle );
+        d_data->titleRect.setRect(
+            rect.left(), rect.top(), rect.width(), dimTitle );
+
+        rect.setTop( d_data->titleRect.bottom() + d_data->spacing );
 
         if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled !=
@@ -1148,11 +1347,27 @@
             // the title centered to the canvas
 
-            d_data->titleRect.setX( rect.x() + dimAxes[QwtPlot::yLeft] );
+            d_data->titleRect.setX( rect.left() + dimAxes[QwtPlot::yLeft] );
             d_data->titleRect.setWidth( rect.width()
                 - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yRight] );
         }
-
-        // subtract title
-        rect.setTop( rect.top() + dimTitle + d_data->spacing );
+    }
+
+    if ( dimFooter > 0 )
+    {
+        d_data->footerRect.setRect(
+            rect.left(), rect.bottom() - dimFooter, rect.width(), dimFooter );
+
+        rect.setBottom( d_data->footerRect.top() - d_data->spacing );
+
+        if ( d_data->layoutData.scale[QwtPlot::yLeft].isEnabled !=
+            d_data->layoutData.scale[QwtPlot::yRight].isEnabled )
+        {
+            // if only one of the y axes is missing we align
+            // the footer centered to the canvas
+
+            d_data->footerRect.setX( rect.left() + dimAxes[QwtPlot::yLeft] );
+            d_data->footerRect.setWidth( rect.width()
+                - dimAxes[QwtPlot::yLeft] - dimAxes[QwtPlot::yRight] );
+        }
     }
 
Index: trunk/BNC/qwt/qwt_plot_layout.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_layout.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_layout.h	(revision 8127)
@@ -20,4 +20,6 @@
   or by QwtPlot::print() to render its content to a QPaintDevice like
   a QPrinter, QPixmap/QImage or QSvgRenderer.
+
+  \sa QwtPlot::setPlotLayout()
 */
 
@@ -44,5 +46,11 @@
 
         //! Ignore the legend.
-        IgnoreLegend = 0x08
+        IgnoreLegend = 0x08,
+
+        //! Ignore the title.
+        IgnoreTitle = 0x10,
+
+        //! Ignore the footer.
+        IgnoreFooter = 0x20
     };
 
@@ -57,5 +65,7 @@
 
     void setAlignCanvasToScales( bool );
-    bool alignCanvasToScales() const;
+
+    void setAlignCanvasToScale( int axisId, bool );
+    bool alignCanvasToScale( int axisId ) const;
 
     void setSpacing( int );
@@ -76,8 +86,9 @@
     virtual void invalidate();
 
-    const QRectF &titleRect() const;
-    const QRectF &legendRect() const;
-    const QRectF &scaleRect( int axis ) const;
-    const QRectF &canvasRect() const;
+    QRectF titleRect() const;
+    QRectF footerRect() const;
+    QRectF legendRect() const;
+    QRectF scaleRect( int axis ) const;
+    QRectF canvasRect() const;
 
     class LayoutData;
@@ -85,12 +96,18 @@
 protected:
 
+    void setTitleRect( const QRectF & );
+    void setFooterRect( const QRectF & );
+    void setLegendRect( const QRectF & );
+    void setScaleRect( int axis, const QRectF & );
+    void setCanvasRect( const QRectF & );
+
     QRectF layoutLegend( Options options, const QRectF & ) const;
     QRectF alignLegend( const QRectF &canvasRect,
         const QRectF &legendRect ) const;
 
-    void expandLineBreaks( int options, const QRectF &rect,
-        int &dimTitle, int dimAxes[QwtPlot::axisCnt] ) const;
+    void expandLineBreaks( Options options, const QRectF &rect,
+        int &dimTitle, int &dimFooter, int dimAxes[QwtPlot::axisCnt] ) const;
 
-    void alignScales( int options, QRectF &canvasRect,
+    void alignScales( Options options, QRectF &canvasRect,
         QRectF scaleRect[QwtPlot::axisCnt] ) const;
 
Index: trunk/BNC/qwt/qwt_plot_legenditem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_legenditem.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_legenditem.cpp	(revision 8127)
@@ -0,0 +1,872 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_legenditem.h"
+#include "qwt_dyngrid_layout.h"
+#include "qwt_scale_map.h"
+#include "qwt_painter.h"
+#include <qlayoutitem.h>
+#include <qpen.h>
+#include <qbrush.h>
+#include <qpainter.h>
+#include <qmath.h>
+
+class QwtLegendLayoutItem: public QLayoutItem
+{
+public:
+    QwtLegendLayoutItem( const QwtPlotLegendItem *, const QwtPlotItem * );
+    virtual ~QwtLegendLayoutItem();
+
+    const QwtPlotItem *plotItem() const;
+
+    void setData( const QwtLegendData & );
+    const QwtLegendData &data() const;
+
+    virtual Qt::Orientations expandingDirections() const;
+    virtual QRect geometry() const;
+    virtual bool hasHeightForWidth() const;
+    virtual int heightForWidth( int w ) const;
+    virtual bool isEmpty() const;
+    virtual QSize maximumSize() const;
+    virtual int minimumHeightForWidth( int w ) const;
+    virtual QSize minimumSize() const;
+    virtual void setGeometry( const QRect & r );
+    virtual QSize sizeHint() const;
+
+private:
+
+    const QwtPlotLegendItem *d_legendItem;
+    const QwtPlotItem *d_plotItem;
+    QwtLegendData d_data;
+
+    QRect d_rect;
+};
+
+QwtLegendLayoutItem::QwtLegendLayoutItem( 
+        const QwtPlotLegendItem *legendItem, const QwtPlotItem *plotItem ):
+    d_legendItem( legendItem ),
+    d_plotItem( plotItem)
+{
+}
+
+QwtLegendLayoutItem::~QwtLegendLayoutItem()
+{
+}
+
+const QwtPlotItem *QwtLegendLayoutItem::plotItem() const
+{
+    return d_plotItem;
+}
+
+void QwtLegendLayoutItem::setData( const QwtLegendData &data )
+{
+    d_data = data;
+}
+
+const QwtLegendData &QwtLegendLayoutItem::data() const
+{
+    return d_data;
+}
+
+Qt::Orientations QwtLegendLayoutItem::expandingDirections() const
+{
+    return Qt::Horizontal;
+}
+
+bool QwtLegendLayoutItem::hasHeightForWidth() const
+{
+    return !d_data.title().isEmpty();
+}
+
+int QwtLegendLayoutItem::minimumHeightForWidth( int w ) const
+{
+    return d_legendItem->heightForWidth( d_data, w );
+}
+
+int QwtLegendLayoutItem::heightForWidth( int w ) const
+{
+    return d_legendItem->heightForWidth( d_data, w );
+}
+
+bool QwtLegendLayoutItem::isEmpty() const
+{
+    return false;
+}
+
+QSize QwtLegendLayoutItem::maximumSize() const
+{
+    return QSize( QLAYOUTSIZE_MAX, QLAYOUTSIZE_MAX );
+}
+
+QSize QwtLegendLayoutItem::minimumSize() const
+{
+    return d_legendItem->minimumSize( d_data );
+}
+
+QSize QwtLegendLayoutItem::sizeHint() const
+{
+    return minimumSize();
+}
+
+void QwtLegendLayoutItem::setGeometry( const QRect &rect )
+{
+    d_rect = rect;
+}
+
+QRect QwtLegendLayoutItem::geometry() const
+{
+    return d_rect;
+}
+
+class QwtPlotLegendItem::PrivateData
+{
+public:
+    PrivateData():
+        itemMargin( 4 ),
+        itemSpacing( 4 ),
+        borderRadius( 0.0 ),
+        borderPen( Qt::NoPen ),
+        backgroundBrush( Qt::NoBrush ),
+        backgroundMode( QwtPlotLegendItem::LegendBackground ),
+        borderDistance( 10 ),
+        alignment( Qt::AlignRight | Qt::AlignBottom )
+    {
+        layout = new QwtDynGridLayout();
+        layout->setMaxColumns( 2 );
+
+        layout->setSpacing( 0 );
+        layout->setContentsMargins( 0, 0, 0, 0 );
+    }
+
+    ~PrivateData()
+    {
+        delete layout;
+    }
+
+    QFont font;
+    QPen textPen;
+    int itemMargin;
+    int itemSpacing;
+
+    double borderRadius;
+    QPen borderPen;
+    QBrush backgroundBrush;
+    QwtPlotLegendItem::BackgroundMode backgroundMode;
+
+    int borderDistance;
+    Qt::Alignment alignment;
+
+    QMap< const QwtPlotItem *, QList<QwtLegendLayoutItem *> > map;
+    QwtDynGridLayout *layout;
+};
+
+//! Constructor 
+QwtPlotLegendItem::QwtPlotLegendItem():
+    QwtPlotItem( QwtText( "Legend" ) )
+{
+    d_data = new PrivateData;
+
+    setItemInterest( QwtPlotItem::LegendInterest, true );
+    setZ( 100.0 );
+}
+
+//! Destructor
+QwtPlotLegendItem::~QwtPlotLegendItem()
+{
+    clearLegend();
+    delete d_data;
+}
+
+//! \return QwtPlotItem::Rtti_PlotLegend
+int QwtPlotLegendItem::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotLegend;
+}
+
+/*!
+  \brief Set the alignmnet
+
+  Alignment means the position of the legend relative
+  to the geometry of the plot canvas. 
+
+  \param alignment Alignment flags
+
+  \sa alignment(), setMaxColumns()
+
+  \note To align a legend with many items horizontally 
+        the number of columns need to be limited
+ */
+void QwtPlotLegendItem::setAlignment( Qt::Alignment alignment )
+{
+    if ( d_data->alignment != alignment )
+    {
+        d_data->alignment = alignment;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Alignment flags
+  \sa setAlignment()
+ */
+Qt::Alignment QwtPlotLegendItem::alignment() const
+{
+    return d_data->alignment;
+}
+
+/*!
+  \brief Limit the number of columns
+
+  When aligning the legend horizontally ( Qt::AlignLeft, Qt::AlignRight )
+  the number of columns needs to be limited to avoid, that
+  the width of the legend grows with an increasing number of entries.
+
+  \param maxColumns Maximum number of columns. 0 means unlimited.
+  \sa maxColumns(), QwtDynGridLayout::setMaxColumns()
+ */
+void QwtPlotLegendItem::setMaxColumns( uint maxColumns )
+{
+    if ( maxColumns != d_data->layout->maxColumns() )
+    {
+        d_data->layout->setMaxColumns( maxColumns );
+        itemChanged();
+    }
+}
+
+/*!
+  \return Maximum number of columns
+  \sa maxColumns(), QwtDynGridLayout::maxColumns()
+ */
+uint QwtPlotLegendItem::maxColumns() const
+{
+    return d_data->layout->maxColumns();
+}
+
+/*!
+  \brief Set the margin around legend items
+
+  The default setting for the margin is 0.
+
+  \param margin Margin in pixels
+  \sa margin(), setSpacing(), setItemMargin(), setItemSpacing
+ */
+void QwtPlotLegendItem::setMargin( int margin )
+{
+    margin = qMax( margin, 0 );
+    if ( margin != this->margin() )
+    {
+        d_data->layout->setContentsMargins( 
+            margin, margin, margin, margin );
+
+        itemChanged();
+    }
+}
+
+/*!
+  \return Margin around the legend items
+  \sa setMargin(), spacing(), itemMargin(), itemSpacing()
+ */
+int QwtPlotLegendItem::margin() const
+{
+    int left;
+    d_data->layout->getContentsMargins( &left, NULL, NULL, NULL );
+
+    return left;
+}
+
+/*!
+  \brief Set the spacing between the legend items
+
+  \param spacing Spacing in pixels
+  \sa spacing(), setMargin()
+*/
+void QwtPlotLegendItem::setSpacing( int spacing )
+{
+    spacing = qMax( spacing, 0 );
+    if ( spacing != d_data->layout->spacing() )
+    {
+        d_data->layout->setSpacing( spacing );
+        itemChanged();
+    }
+}
+
+/*!
+  \return Spacing between the legend items
+  \sa setSpacing(), margin(), itemSpacing(), itemMargin()
+ */
+int QwtPlotLegendItem::spacing() const
+{
+    return d_data->layout->spacing();
+}
+
+/*!
+  Set the margin around each item
+
+  \param margin Margin
+  \sa itemMargin(), setItemSpacing(), setMargin(), setSpacing()
+ */
+void QwtPlotLegendItem::setItemMargin( int margin )
+{
+    margin = qMax( margin, 0 );
+    if ( margin != d_data->itemMargin )
+    {
+        d_data->itemMargin = margin;
+
+        d_data->layout->invalidate();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Margin around each item
+  \sa setItemMargin(), itemSpacing(), margin(), spacing()
+*/
+int QwtPlotLegendItem::itemMargin() const
+{
+    return d_data->itemMargin;
+}
+
+/*!
+  Set the spacing inside of each item
+
+  \param spacing Spacing
+  \sa itemSpacing(), setItemMargin(), setMargin(), setSpacing()
+ */
+void QwtPlotLegendItem::setItemSpacing( int spacing )
+{
+    spacing = qMax( spacing, 0 );
+    if ( spacing != d_data->itemSpacing )
+    {
+        d_data->itemSpacing = spacing;
+
+        d_data->layout->invalidate();
+        itemChanged();
+    }
+
+}
+
+/*!
+  \return Spacing inside of each item
+  \sa setItemSpacing(), itemMargin(), margin(), spacing()
+*/
+int QwtPlotLegendItem::itemSpacing() const
+{
+    return d_data->itemSpacing;
+}
+
+/*!
+   Change the font used for drawing the text label
+
+   \param font Legend font
+   \sa font()
+*/
+void QwtPlotLegendItem::setFont( const QFont &font )
+{
+    if ( font != d_data->font )
+    {
+        d_data->font = font;
+
+        d_data->layout->invalidate();
+        itemChanged();
+    }
+}
+
+/*!
+   \return Font used for drawing the text label
+   \sa setFont()
+*/
+QFont QwtPlotLegendItem::font() const
+{
+    return d_data->font;
+}
+
+/*!
+  \brief Set the margin between the legend and the canvas border
+
+  The default setting for the margin is 10 pixels.
+
+  \param distance Margin in pixels
+  \sa setMargin()
+ */
+void QwtPlotLegendItem::setBorderDistance( int distance )
+{
+    if ( distance < 0 )
+        distance = -1;
+
+    if ( distance != d_data->borderDistance )
+    {
+        d_data->borderDistance = distance;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Margin between the legend and the canvas border
+  \sa margin()
+ */
+int QwtPlotLegendItem::borderDistance() const
+{
+    return d_data->borderDistance;
+}
+
+/*!
+  Set the radius for the border
+  
+  \param radius A value <= 0 defines a rectangular border
+  \sa borderRadius(), setBorderPen()
+ */
+void QwtPlotLegendItem::setBorderRadius( double radius )
+{
+    radius = qMax( 0.0, radius );
+
+    if ( radius != d_data->borderRadius )
+    {
+        d_data->borderRadius = radius;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Radius of the border
+  \sa setBorderRadius(), setBorderPen()
+ */
+double QwtPlotLegendItem::borderRadius() const
+{
+    return d_data->borderRadius;
+}
+
+/*!
+  Set the pen for drawing the border
+
+  \param pen Border pen
+  \sa borderPen(), setBackgroundBrush()
+ */
+void QwtPlotLegendItem::setBorderPen( const QPen &pen )
+{
+    if ( d_data->borderPen != pen )
+    {
+        d_data->borderPen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Pen for drawing the border
+  \sa setBorderPen(), backgroundBrush()
+ */
+QPen QwtPlotLegendItem::borderPen() const
+{
+    return d_data->borderPen;
+}
+
+/*!
+  \brief Set the background brush
+
+  The brush is used to fill the background
+
+  \param brush Brush
+  \sa backgroundBrush(), setBackgroundMode(), drawBackground()
+ */
+void QwtPlotLegendItem::setBackgroundBrush( const QBrush &brush )
+{
+    if ( d_data->backgroundBrush != brush )
+    {
+        d_data->backgroundBrush = brush;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Brush is used to fill the background
+  \sa setBackgroundBrush(), backgroundMode(), drawBackground()
+ */
+QBrush QwtPlotLegendItem::backgroundBrush() const
+{
+    return d_data->backgroundBrush;
+}
+
+/*!
+  \brief Set the background mode
+
+  Depending on the mode the complete legend or each item 
+  might have an background.
+
+  The default setting is LegendBackground.
+
+   \sa backgroundMode(), setBackgroundBrush(), drawBackground()
+ */
+void QwtPlotLegendItem::setBackgroundMode( BackgroundMode mode )
+{
+    if ( mode != d_data->backgroundMode )
+    {
+        d_data->backgroundMode = mode;
+        itemChanged();
+    }
+}
+
+/*! 
+  \return backgroundMode
+  \sa setBackgroundMode(), backgroundBrush(), drawBackground()
+ */
+QwtPlotLegendItem::BackgroundMode QwtPlotLegendItem::backgroundMode() const
+{
+    return d_data->backgroundMode;
+}
+
+/*!
+  \brief Set the pen for drawing text labels
+
+  \param pen Text pen
+  \sa textPen(), setFont()
+ */
+void QwtPlotLegendItem::setTextPen( const QPen &pen )
+{
+    if ( d_data->textPen != pen )
+    {
+        d_data->textPen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Pen for drawing text labels
+  \sa setTextPen(), font()
+ */
+QPen QwtPlotLegendItem::textPen() const
+{
+    return d_data->textPen;
+}
+
+/*!
+  Draw the legend
+
+  \param painter Painter
+  \param xMap x Scale Map
+  \param yMap y Scale Map
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
+*/
+void QwtPlotLegendItem::draw( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect ) const
+{
+    Q_UNUSED( xMap );
+    Q_UNUSED( yMap );
+
+    d_data->layout->setGeometry( geometry( canvasRect ) );
+    if ( d_data->layout->geometry().isEmpty() )
+    {
+        // don't draw a legend when having no content
+        return;
+    }
+
+    if ( d_data->backgroundMode == QwtPlotLegendItem::LegendBackground )
+        drawBackground( painter, d_data->layout->geometry() );
+    
+    for ( int i = 0; i <  d_data->layout->count(); i++ )
+    {
+        const QwtLegendLayoutItem *layoutItem = 
+            static_cast<QwtLegendLayoutItem *>( d_data->layout->itemAt( i ) );
+
+        if ( d_data->backgroundMode == QwtPlotLegendItem::ItemBackground )
+            drawBackground( painter, layoutItem->geometry() );
+
+        painter->save();
+
+        drawLegendData( painter, layoutItem->plotItem(),
+            layoutItem->data(), layoutItem->geometry() );
+
+        painter->restore();
+    }
+}
+
+/*!
+  Draw a rounded rect
+
+  \param painter Painter
+  \param rect Bounding rectangle
+
+  \sa setBorderRadius(), setBorderPen(),
+      setBackgroundBrush(), setBackgroundMode()
+ */
+void QwtPlotLegendItem::drawBackground( 
+    QPainter *painter, const QRectF &rect ) const
+{
+    painter->save();
+
+    painter->setPen( d_data->borderPen );
+    painter->setBrush( d_data->backgroundBrush );
+    
+    const double radius = d_data->borderRadius;
+    painter->drawRoundedRect( rect, radius, radius );
+    
+    painter->restore();
+}
+
+/*!
+  Calculate the geometry of the legend on the canvas
+
+  \param canvasRect Geometry of the canvas
+  \return Geometry of the legend
+*/
+QRect QwtPlotLegendItem::geometry( const QRectF &canvasRect ) const
+{
+    QRect rect;
+    rect.setSize( d_data->layout->sizeHint() );
+
+    int margin = d_data->borderDistance;
+    if ( d_data->alignment & Qt::AlignHCenter )
+    {
+        int x = qRound( canvasRect.center().x() );
+        rect.moveCenter( QPoint( x, rect.center().y() ) ); 
+    }
+    else if ( d_data->alignment & Qt::AlignRight )
+    {
+        rect.moveRight( qFloor( canvasRect.right() - margin ) );
+    }
+    else 
+    {
+        rect.moveLeft( qCeil( canvasRect.left() + margin ) );
+    }
+
+    if ( d_data->alignment & Qt::AlignVCenter )
+    {
+        int y = qRound( canvasRect.center().y() );
+        rect.moveCenter( QPoint( rect.center().x(), y ) );
+    }
+    else if ( d_data->alignment & Qt::AlignBottom )
+    {
+        rect.moveBottom( qFloor( canvasRect.bottom() - margin ) );
+    }
+    else 
+    {
+        rect.moveTop( qCeil( canvasRect.top() + margin ) ); 
+    }
+
+    return rect;
+}
+
+/*!
+  Update the legend items according to modifications of a 
+  plot item
+
+  \param plotItem Plot item
+  \param data Attributes of the legend entries
+ */
+void QwtPlotLegendItem::updateLegend( const QwtPlotItem *plotItem,
+        const QList<QwtLegendData> &data )
+{
+    if ( plotItem == NULL )
+        return;
+
+    QList<QwtLegendLayoutItem *> layoutItems;
+
+    QMap<const QwtPlotItem *, QList<QwtLegendLayoutItem *> >::iterator it = 
+        d_data->map.find( plotItem );
+    if ( it != d_data->map.end() )
+        layoutItems = it.value();
+
+    bool changed = false;
+
+    if ( data.size() != layoutItems.size() )
+    {
+        changed = true;
+
+        for ( int i = 0; i < layoutItems.size(); i++ )
+        {
+            d_data->layout->removeItem( layoutItems[i] );
+            delete layoutItems[i];
+        }
+        layoutItems.clear();
+
+        if ( it != d_data->map.end() )
+            d_data->map.remove( plotItem );
+
+        if ( !data.isEmpty() )
+        {
+            for ( int i = 0; i < data.size(); i++ )
+            {
+                QwtLegendLayoutItem *layoutItem = 
+                    new QwtLegendLayoutItem( this, plotItem );
+                d_data->layout->addItem( layoutItem );
+                layoutItems += layoutItem;
+            }
+
+            d_data->map.insert( plotItem, layoutItems );
+        }
+    }
+
+    for ( int i = 0; i < data.size(); i++ )
+    {
+        if ( layoutItems[i]->data().values() != data[i].values() )
+        {
+            layoutItems[i]->setData( data[i] );
+            changed = true;
+        }
+    }
+
+    if ( changed )
+    {
+        d_data->layout->invalidate();
+        itemChanged();
+    }
+}
+
+//! Remove all items from the legend
+void QwtPlotLegendItem::clearLegend()
+{
+    if ( !d_data->map.isEmpty() )
+    {
+        d_data->map.clear();
+
+        for ( int i = d_data->layout->count() - 1; i >= 0; i-- )
+            delete d_data->layout->takeAt( i );
+
+        itemChanged();
+    }
+}
+
+/*!
+  Draw an entry on the legend
+
+  \param painter Qt Painter
+  \param plotItem Plot item, represented by the entry
+  \param data Attributes of the legend entry
+  \param rect Bounding rectangle for the entry
+ */
+void QwtPlotLegendItem::drawLegendData( QPainter *painter,
+    const QwtPlotItem *plotItem, const QwtLegendData &data, 
+    const QRectF &rect ) const
+{
+    Q_UNUSED( plotItem );
+
+    const int m = d_data->itemMargin;
+    const QRectF r = rect.toRect().adjusted( m, m, -m, -m );
+
+    painter->setClipRect( r, Qt::IntersectClip );
+
+    int titleOff = 0;
+
+    const QwtGraphic graphic = data.icon();
+    if ( !graphic.isEmpty() )
+    {
+        QRectF iconRect( r.topLeft(), graphic.defaultSize() );
+
+        iconRect.moveCenter( 
+            QPoint( iconRect.center().x(), rect.center().y() ) );
+
+        graphic.render( painter, iconRect, Qt::KeepAspectRatio );
+
+        titleOff += iconRect.width() + d_data->itemSpacing;
+    }
+
+    const QwtText text = data.title();
+    if ( !text.isEmpty() )
+    {
+        painter->setPen( textPen() );
+        painter->setFont( font() );
+
+        const QRectF textRect = r.adjusted( titleOff, 0, 0, 0 );
+        text.draw( painter, textRect );
+    }
+}
+
+/*!
+  Minimum size hint needed to display an entry
+
+  \param data Attributes of the legend entry
+  \return Minimum size
+ */
+QSize QwtPlotLegendItem::minimumSize( const QwtLegendData &data ) const
+{
+    QSize size( 2 * d_data->itemMargin, 2 * d_data->itemMargin );
+
+    if ( !data.isValid() )
+        return size;
+
+    const QwtGraphic graphic = data.icon();
+    const QwtText text = data.title();
+
+    int w = 0;
+    int h = 0;
+
+    if ( !graphic.isNull() )
+    {
+        w = graphic.width();
+        h = graphic.height();
+    }
+
+    if ( !text.isEmpty() )
+    {
+        const QSizeF sz = text.textSize( font() );
+
+        w += qCeil( sz.width() );
+        h = qMax( h, qCeil( sz.height() ) );
+    }
+
+    if ( graphic.width() > 0 && !text.isEmpty() )
+        w += d_data->itemSpacing;
+
+    size += QSize( w, h );
+    return size;
+}
+
+/*!
+  \return The preferred height, for a width.
+  \param data Attributes of the legend entry
+  \param width Width
+*/
+int QwtPlotLegendItem::heightForWidth( 
+    const QwtLegendData &data, int width ) const
+{
+    width -= 2 * d_data->itemMargin;
+
+    const QwtGraphic graphic = data.icon();
+    const QwtText text = data.title();
+
+    if ( text.isEmpty() )
+        return graphic.height();
+
+    if ( graphic.width() > 0 )
+        width -= graphic.width() + d_data->itemSpacing;
+
+    int h = text.heightForWidth( width, font() );
+    h += 2 * d_data->itemMargin;
+
+    return qMax( graphic.height(), h );
+}
+
+/*! 
+  \return All plot items with an entry on the legend
+  \note A plot item might have more than one entry on the legend
+ */
+QList< const QwtPlotItem * > QwtPlotLegendItem::plotItems() const
+{
+    return d_data->map.keys();
+}
+
+/*!
+  \return Geometries of the items of a plot item
+  \note Usually a plot item has only one entry on the legend
+*/
+QList< QRect > QwtPlotLegendItem::legendGeometries( 
+    const QwtPlotItem *plotItem ) const
+{
+    QList<QwtLegendLayoutItem *> layoutItems;
+
+    QMap<const QwtPlotItem *, QList<QwtLegendLayoutItem *> >::iterator it =
+        d_data->map.find( plotItem );
+    if ( it != d_data->map.end() )
+        layoutItems = it.value();
+
+    QList<QRect> geometries;
+    for ( int i = 0; i < layoutItems.size(); i++ )
+        geometries += layoutItems[i]->geometry();
+
+    return geometries;
+}
Index: trunk/BNC/qwt/qwt_plot_legenditem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_legenditem.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_legenditem.h	(revision 8127)
@@ -0,0 +1,136 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_LEGEND_ITEM_H
+#define QWT_PLOT_LEGEND_ITEM_H
+
+#include "qwt_global.h"
+#include "qwt_plot_item.h"
+#include "qwt_legend_data.h"
+
+class QFont;
+
+/*!
+  \brief A class which draws a legend inside the plot canvas
+
+  QwtPlotLegendItem can be used to draw a inside the plot canvas.
+  It can be used together with a QwtLegend or instead of it
+  to have more space for the plot canvas.
+
+  In opposite to QwtLegend the legend item is not interactive. 
+  To identify mouse clicks on a legend item an event filter
+  needs to be installed catching mouse events ob the plot canvas.
+  The geometries of the legend items are available using
+  legendGeometries().
+  
+  The legend item is aligned to plot canvas according to 
+  its alignment() flags. It might have a background for the
+  complete legend ( usually semi transparent ) or for
+  each legend item.
+
+  \note An external QwtLegend with a transparent background 
+        on top the plot canvas might be another option 
+        with a similar effect.
+*/
+
+class QWT_EXPORT QwtPlotLegendItem: public QwtPlotItem
+{
+public:
+    /*!
+      \brief Background mode
+
+      Depending on the mode the complete legend or each item 
+      might have an background.
+
+      The default setting is LegendBackground.
+
+       \sa setBackgroundMode(), setBackgroundBrush(), drawBackground()
+     */
+    enum BackgroundMode
+    {
+        //! The legend has a background
+        LegendBackground,
+
+        //! Each item has a background
+        ItemBackground
+    };
+
+    explicit QwtPlotLegendItem();
+    virtual ~QwtPlotLegendItem();
+
+    virtual int rtti() const;
+
+    void setAlignment( Qt::Alignment );
+    Qt::Alignment alignment() const;
+
+    void setMaxColumns( uint );
+    uint maxColumns() const;
+
+    void setMargin( int );
+    int margin() const;
+
+    void setSpacing( int );
+    int spacing() const;
+
+    void setItemMargin( int );
+    int itemMargin() const;
+
+    void setItemSpacing( int );
+    int itemSpacing() const;
+    
+    void setFont( const QFont& );
+    QFont font() const;
+
+    void setBorderDistance( int numPixels );
+    int borderDistance() const;
+
+    void setBorderRadius( double );
+    double borderRadius() const;
+
+    void setBorderPen( const QPen & );
+    QPen borderPen() const;
+
+    void setBackgroundBrush( const QBrush & );
+    QBrush backgroundBrush() const;
+
+    void setBackgroundMode( BackgroundMode );
+    BackgroundMode backgroundMode() const;
+
+    void setTextPen( const QPen & );
+    QPen textPen() const;
+
+    virtual void draw( QPainter *p,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &rect ) const;
+
+    void clearLegend();
+
+    virtual void updateLegend( const QwtPlotItem *,
+        const QList<QwtLegendData> & );
+
+    virtual QRect geometry( const QRectF &canvasRect ) const;
+
+    virtual QSize minimumSize( const QwtLegendData & ) const;
+    virtual int heightForWidth( const QwtLegendData &, int w ) const;
+
+    QList< const QwtPlotItem * > plotItems() const;
+    QList< QRect > legendGeometries( const QwtPlotItem * ) const;
+
+protected:
+    virtual void drawLegendData( QPainter *painter, 
+        const QwtPlotItem *, const QwtLegendData &, const QRectF & ) const;
+
+    virtual void drawBackground( QPainter *, const QRectF &rect ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_magnifier.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_magnifier.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_magnifier.cpp	(revision 8127)
@@ -9,5 +9,4 @@
 
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_scale_div.h"
 #include "qwt_plot_magnifier.h"
@@ -30,5 +29,5 @@
    \param canvas Plot canvas to be magnified
 */
-QwtPlotMagnifier::QwtPlotMagnifier( QwtPlotCanvas *canvas ):
+QwtPlotMagnifier::QwtPlotMagnifier( QWidget *canvas ):
     QwtMagnifier( canvas )
 {
@@ -76,13 +75,13 @@
 
 //! Return observed plot canvas
-QwtPlotCanvas *QwtPlotMagnifier::canvas()
+QWidget *QwtPlotMagnifier::canvas()
 {
-    return qobject_cast<QwtPlotCanvas *>( parent() );
+    return parentWidget();
 }
 
 //! Return Observed plot canvas
-const QwtPlotCanvas *QwtPlotMagnifier::canvas() const
+const QWidget *QwtPlotMagnifier::canvas() const
 {
-    return qobject_cast<const QwtPlotCanvas *>( parent() );
+    return parentWidget();
 }
 
@@ -90,9 +89,9 @@
 QwtPlot *QwtPlotMagnifier::plot()
 {
-    QwtPlotCanvas *w = canvas();
+    QWidget *w = canvas();
     if ( w )
-        return w->plot();
+        w = w->parentWidget();
 
-    return NULL;
+    return qobject_cast<QwtPlot *>( w );
 }
 
@@ -100,9 +99,9 @@
 const QwtPlot *QwtPlotMagnifier::plot() const
 {
-    const QwtPlotCanvas *w = canvas();
+    const QWidget *w = canvas();
     if ( w )
-        return w->plot();
+        w = w->parentWidget();
 
-    return NULL;
+    return qobject_cast<const QwtPlot *>( w );
 }
 
@@ -113,4 +112,8 @@
 void QwtPlotMagnifier::rescale( double factor )
 {
+    QwtPlot* plt = plot();
+    if ( plt == NULL )
+        return;
+
     factor = qAbs( factor );
     if ( factor == 1.0 || factor == 0.0 )
@@ -118,5 +121,4 @@
 
     bool doReplot = false;
-    QwtPlot* plt = plot();
 
     const bool autoReplot = plt->autoReplot();
@@ -125,12 +127,32 @@
     for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
     {
-        const QwtScaleDiv *scaleDiv = plt->axisScaleDiv( axisId );
-        if ( isAxisEnabled( axisId ) && scaleDiv->isValid() )
+        if ( isAxisEnabled( axisId ) )
         {
-            const double center =
-                scaleDiv->lowerBound() + scaleDiv->range() / 2;
-            const double width_2 = scaleDiv->range() / 2 * factor;
+            const QwtScaleMap scaleMap = plt->canvasMap( axisId );
 
-            plt->setAxisScale( axisId, center - width_2, center + width_2 );
+            double v1 = scaleMap.s1();
+            double v2 = scaleMap.s2();
+
+            if ( scaleMap.transformation() )
+            {
+                // the coordinate system of the paint device is always linear
+
+                v1 = scaleMap.transform( v1 ); // scaleMap.p1()
+                v2 = scaleMap.transform( v2 ); // scaleMap.p2()
+            }
+
+            const double center = 0.5 * ( v1 + v2 );
+            const double width_2 = 0.5 * ( v2 - v1 ) * factor;
+
+            v1 = center - width_2;
+            v2 = center + width_2;
+
+            if ( scaleMap.transformation() )
+            {
+                v1 = scaleMap.invTransform( v1 );
+                v2 = scaleMap.invTransform( v2 );
+            }
+
+            plt->setAxisScale( axisId, v1, v2 );
             doReplot = true;
         }
Index: trunk/BNC/qwt/qwt_plot_magnifier.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_magnifier.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_magnifier.h	(revision 8127)
@@ -14,5 +14,4 @@
 #include "qwt_magnifier.h"
 
-class QwtPlotCanvas;
 class QwtPlot;
 
@@ -33,5 +32,5 @@
 
 public:
-    explicit QwtPlotMagnifier( QwtPlotCanvas * );
+    explicit QwtPlotMagnifier( QWidget * );
     virtual ~QwtPlotMagnifier();
 
@@ -39,6 +38,6 @@
     bool isAxisEnabled( int axis ) const;
 
-    QwtPlotCanvas *canvas();
-    const QwtPlotCanvas *canvas() const;
+    QWidget *canvas();
+    const QWidget *canvas() const;
 
     QwtPlot *plot();
Index: trunk/BNC/qwt/qwt_plot_marker.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_marker.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_marker.cpp	(revision 8127)
@@ -14,6 +14,4 @@
 #include "qwt_text.h"
 #include "qwt_math.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
 #include <qpainter.h>
 
@@ -51,6 +49,14 @@
 
 //! Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine
-QwtPlotMarker::QwtPlotMarker():
-    QwtPlotItem( QwtText( "Marker" ) )
+QwtPlotMarker::QwtPlotMarker( const QString &title ):
+    QwtPlotItem( QwtText( title ) )
+{
+    d_data = new PrivateData;
+    setZ( 30.0 );
+}
+
+//! Sets alignment to Qt::AlignCenter, and style to QwtPlotMarker::NoLine
+QwtPlotMarker::QwtPlotMarker( const QwtText &title ):
+    QwtPlotItem( title )
 {
     d_data = new PrivateData;
@@ -123,5 +129,5 @@
   \param xMap x Scale Map
   \param yMap y Scale Map
-  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
 */
 void QwtPlotMarker::draw( QPainter *painter,
@@ -140,5 +146,11 @@
         ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
     {
-        d_data->symbol->drawSymbol( painter, pos );
+        const QSizeF sz = d_data->symbol->size();
+
+        const QRectF clipRect = canvasRect.adjusted( 
+            -sz.width(), -sz.height(), sz.width(), sz.height() );
+
+        if ( clipRect.contains( pos ) )
+            d_data->symbol->drawSymbol( painter, pos );
     }
 
@@ -150,5 +162,5 @@
 
   \param painter Painter
-  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
   \param pos Position of the marker, translated into widget coordinates
 
@@ -190,5 +202,5 @@
 
   \param painter Painter
-  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
   \param pos Position of the marker, translated into widget coordinates
 
@@ -334,4 +346,6 @@
     {
         d_data->style = style;
+
+        legendChanged();
         itemChanged();
     }
@@ -358,4 +372,9 @@
         delete d_data->symbol;
         d_data->symbol = symbol;
+
+        if ( symbol )
+            setLegendIconSize( symbol->boundingRect().size() );
+
+        legendChanged();
         itemChanged();
     }
@@ -373,5 +392,5 @@
 /*!
   \brief Set the label
-  \param label label text
+  \param label Label text
   \sa label()
 */
@@ -484,4 +503,22 @@
 }
 
+/*! 
+  Build and assign a line pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtPlotMarker::setLinePen( const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setLinePen( QPen( color, width, style ) );
+}
+
 /*!
   Specify a pen for the line.
@@ -495,4 +532,6 @@
     {
         d_data->pen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -514,58 +553,39 @@
 
 /*!
-   \brief Update the widget that represents the item on the legend
-
-   \param legend Legend
-   \sa drawLegendIdentifier(), legendItem(), itemChanged(), QwtLegend()
-
-   \note In the default setting QwtPlotItem::Legend is disabled 
-*/
-void QwtPlotMarker::updateLegend( QwtLegend *legend ) const
-{
-    if ( legend && testItemAttribute( QwtPlotItem::Legend )
-        && d_data->symbol && d_data->symbol->style() != QwtSymbol::NoSymbol )
-    {
-        QWidget *lgdItem = legend->find( this );
-        if ( lgdItem == NULL )
-        {
-            lgdItem = legendItem();
-            if ( lgdItem )
-                legend->insert( this, lgdItem );
-        }
-
-        QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
-        if ( l )
-            l->setIdentifierSize( d_data->symbol->boundingSize() );
-    }
-
-    QwtPlotItem::updateLegend( legend );
-}
-
-/*!
-  \brief Draw the identifier representing the marker on the legend
-
-  \param painter Painter
-  \param rect Bounding rectangle for the identifier
-
-  \sa updateLegend(), QwtPlotItem::Legend
-*/
-void QwtPlotMarker::drawLegendIdentifier(
-    QPainter *painter, const QRectF &rect ) const
-{
-    if ( rect.isEmpty() )
-        return;
-
-    painter->save();
-    painter->setClipRect( rect, Qt::IntersectClip );
+   \return Icon representing the marker on the legend
+
+   \param index Index of the legend entry 
+                ( usually there is only one )
+   \param size Icon size
+
+   \sa setLegendIconSize(), legendData()
+*/
+QwtGraphic QwtPlotMarker::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+
+    if ( size.isEmpty() )
+        return QwtGraphic();
+
+    QwtGraphic icon;
+    icon.setDefaultSize( size );
+    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &icon );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPlotItem::RenderAntialiased ) );
 
     if ( d_data->style != QwtPlotMarker::NoLine )
     {
-        painter->setPen( d_data->pen );
+        painter.setPen( d_data->pen );
 
         if ( d_data->style == QwtPlotMarker::HLine ||
             d_data->style == QwtPlotMarker::Cross )
         {
-            QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
-                rect.right(), rect.center().y() );
+            const double y = 0.5 * size.height();
+
+            QwtPainter::drawLine( &painter, 
+                0.0, y, size.width(), y );
         }
 
@@ -573,30 +593,18 @@
             d_data->style == QwtPlotMarker::Cross )
         {
-            QwtPainter::drawLine( painter, rect.center().x(), rect.top(),
-                rect.center().x(), rect.bottom() );
+            const double x = 0.5 * size.width();
+
+            QwtPainter::drawLine( &painter, 
+                x, 0.0, x, size.height() );
         }
     }
 
-    if ( d_data->symbol && d_data->symbol->style() != QwtSymbol::NoSymbol )
-    {
-        QSize symbolSize = d_data->symbol->boundingSize();
-        symbolSize -= QSize( 2, 2 );
-
-        // scale the symbol size down if it doesn't fit into rect.
-
-        double xRatio = 1.0;
-        if ( rect.width() < symbolSize.width() )
-            xRatio = rect.width() / symbolSize.width();
-        double yRatio = 1.0;
-        if ( rect.height() < symbolSize.height() )
-            yRatio = rect.height() / symbolSize.height();
-
-        const double ratio = qMin( xRatio, yRatio );
-
-        painter->scale( ratio, ratio );
-        d_data->symbol->drawSymbol( painter, rect.center() / ratio );
-    }
-
-    painter->restore();
-}
-
+    if ( d_data->symbol )
+    {
+        const QRect r( 0.0, 0.0, size.width(), size.height() );
+        d_data->symbol->drawSymbol( &painter, r );
+    }
+
+    return icon;
+}
+
Index: trunk/BNC/qwt/qwt_plot_marker.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_marker.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_marker.h	(revision 8127)
@@ -29,5 +29,5 @@
   be drawn around a center point inside a bounding rectangle.
 
-  The QwtPlotMarker::setSymbol() member assigns a symbol to the marker.
+  The setSymbol() member assigns a symbol to the marker.
   The symbol is drawn at the specified point.
 
@@ -40,4 +40,8 @@
   left above the center point if the alignment was set to 
   Qt::AlignLeft | Qt::AlignTop.
+
+  \note QwtPlotTextLabel is intended to align a text label
+        according to the geometry of canvas 
+        ( unrelated to plot coordinates )
 */
 
@@ -65,5 +69,7 @@
     };
 
-    explicit QwtPlotMarker();
+    explicit QwtPlotMarker( const QString &title = QString::null );
+    explicit QwtPlotMarker( const QwtText &title );
+
     virtual ~QwtPlotMarker();
 
@@ -82,4 +88,5 @@
     LineStyle lineStyle() const;
 
+    void setLinePen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setLinePen( const QPen &p );
     const QPen &linePen() const;
@@ -106,6 +113,5 @@
     virtual QRectF boundingRect() const;
 
-    virtual void updateLegend( QwtLegend * ) const;
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
 
 protected:
Index: trunk/BNC/qwt/qwt_plot_multi_barchart.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_multi_barchart.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_multi_barchart.cpp	(revision 8127)
@@ -0,0 +1,744 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_multi_barchart.h"
+#include "qwt_scale_map.h"
+#include "qwt_column_symbol.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+#include <qpalette.h>
+#include <qmap.h>
+
+inline static bool qwtIsIncreasing(
+    const QwtScaleMap &map, const QVector<double> &values )
+{
+    bool isInverting = map.isInverting();
+
+    for ( int i = 0; i < values.size(); i++ )
+    {
+        const double y = values[ i ];
+        if ( y != 0.0 )
+            return ( map.isInverting() != ( y > 0.0 ) );
+    }
+
+    return !isInverting;
+}
+
+class QwtPlotMultiBarChart::PrivateData
+{
+public:
+    PrivateData():
+        style( QwtPlotMultiBarChart::Grouped )
+    {
+    }
+
+    QwtPlotMultiBarChart::ChartStyle style;
+    QList<QwtText> barTitles;
+    QMap<int, QwtColumnSymbol *> symbolMap;
+};
+
+/*!
+  Constructor
+  \param title Title of the chart
+*/
+QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QwtText &title ):
+    QwtPlotAbstractBarChart( title )
+{
+    init();
+}
+
+/*!
+  Constructor
+  \param title Title of the chart
+*/
+QwtPlotMultiBarChart::QwtPlotMultiBarChart( const QString &title ):
+    QwtPlotAbstractBarChart( QwtText( title ) )
+{
+    init();
+}
+
+//! Destructor
+QwtPlotMultiBarChart::~QwtPlotMultiBarChart()
+{
+    resetSymbolMap();
+    delete d_data;
+}
+
+void QwtPlotMultiBarChart::init()
+{
+    d_data = new PrivateData;
+    setData( new QwtSetSeriesData() );
+}
+
+//! \return QwtPlotItem::Rtti_PlotBarChart
+int QwtPlotMultiBarChart::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotMultiBarChart;
+}
+
+/*!
+  Initialize data with an array of samples.
+  \param samples Vector of points
+*/
+void QwtPlotMultiBarChart::setSamples(
+    const QVector<QwtSetSample> &samples )
+{
+    setData( new QwtSetSeriesData( samples ) );
+}
+
+/*!
+  Initialize data with an array of samples.
+  \param samples Vector of points
+*/
+void QwtPlotMultiBarChart::setSamples(
+    const QVector< QVector<double> > &samples )
+{
+    QVector<QwtSetSample> s;
+    for ( int i = 0; i < samples.size(); i++ )
+        s += QwtSetSample( i, samples[ i ] );
+
+    setData( new QwtSetSeriesData( s ) );
+}
+
+/*!
+  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 QwtPlotMultiBarChart::setSamples( 
+    QwtSeriesData<QwtSetSample> *data )
+{       
+    setData( data );
+}       
+
+/*!
+  \brief Set the titles for the bars
+
+  The titles are used for the legend.
+
+  \param titles Bar titles
+
+  \sa barTitles(), legendData()
+ */
+void QwtPlotMultiBarChart::setBarTitles( const QList<QwtText> &titles )
+{
+    d_data->barTitles = titles;
+    itemChanged();
+}
+
+/*! 
+  \return Bar titles
+  \sa setBarTitles(), legendData()
+ */
+QList<QwtText> QwtPlotMultiBarChart::barTitles() const
+{
+    return d_data->barTitles;
+}
+
+/*!
+  \brief Add a symbol to the symbol map
+
+  Assign a default symbol for drawing the bar representing all values
+  with the same index in a set.
+
+  \param valueIndex Index of a value in a set
+  \param symbol Symbol used for drawing a bar
+
+  \sa symbol(), resetSymbolMap(), specialSymbol()
+*/
+void QwtPlotMultiBarChart::setSymbol( int valueIndex, QwtColumnSymbol *symbol )
+{
+    if ( valueIndex < 0 )
+        return;
+
+    QMap<int, QwtColumnSymbol *>::iterator it = 
+        d_data->symbolMap.find(valueIndex);
+    if ( it == d_data->symbolMap.end() )
+    {
+        if ( symbol != NULL )
+        {
+            d_data->symbolMap.insert( valueIndex, symbol );
+
+            legendChanged();
+            itemChanged();
+        }
+    }
+    else
+    {
+        if ( symbol != it.value() )
+        {
+            delete it.value();
+
+            if ( symbol == NULL )
+            {
+                d_data->symbolMap.remove( valueIndex );
+            }
+            else
+            {
+                it.value() = symbol;
+            }
+
+            legendChanged();
+            itemChanged();
+        }
+    }
+}
+
+/*!
+  Find a symbol in the symbol map
+
+  \param valueIndex Index of a value in a set
+  \return The symbol, that had been set by setSymbol() or NULL.
+
+  \sa setSymbol(), specialSymbol(), drawBar()
+*/
+const QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) const
+{
+    QMap<int, QwtColumnSymbol *>::const_iterator it =
+        d_data->symbolMap.find( valueIndex );
+
+    return ( it == d_data->symbolMap.end() ) ? NULL : it.value();
+}
+
+/*!
+  Find a symbol in the symbol map
+
+  \param valueIndex Index of a value in a set
+  \return The symbol, that had been set by setSymbol() or NULL.
+
+  \sa setSymbol(), specialSymbol(), drawBar()
+*/
+QwtColumnSymbol *QwtPlotMultiBarChart::symbol( int valueIndex ) 
+{
+    QMap<int, QwtColumnSymbol *>::iterator it =
+        d_data->symbolMap.find( valueIndex );
+
+    return ( it == d_data->symbolMap.end() ) ? NULL : it.value();
+}
+
+/*!
+  Remove all symbols from the symbol map
+ */
+void QwtPlotMultiBarChart::resetSymbolMap()
+{
+    for ( QMap<int, QwtColumnSymbol *>::iterator it 
+        = d_data->symbolMap.begin(); it != d_data->symbolMap.end(); ++it )
+    {
+        delete it.value();
+    }
+
+    d_data->symbolMap.clear();
+}
+
+/*!
+  \brief Create a symbol for special values
+
+  Usually the symbols for displaying a bar are set by setSymbols() and
+  common for all sets. By overloading specialSymbol() it is possible to
+  create a temporary symbol() for displaying a special value.
+
+  The symbol has to be created by new each time specialSymbol() is
+  called. As soon as the symbol is painted this symbol gets deleted.
+
+  When no symbol ( NULL ) is returned, the value will be displayed
+  with the standard symbol that is used for all symbols with the same 
+  valueIndex.
+
+  \param sampleIndex Index of the sample
+  \param valueIndex Index of the value in the set
+
+  \return NULL, meaning that the value is not special
+    
+ */
+QwtColumnSymbol *QwtPlotMultiBarChart::specialSymbol( 
+    int sampleIndex, int valueIndex ) const
+{
+    Q_UNUSED( sampleIndex );
+    Q_UNUSED( valueIndex );
+
+    return NULL;
+}
+
+/*!
+  Set the style of the chart
+
+  \param style Chart style
+  \sa style()
+ */
+void QwtPlotMultiBarChart::setStyle( ChartStyle style )
+{
+    if ( style != d_data->style )
+    {
+        d_data->style = style;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Style of the chart
+  \sa setStyle()
+ */
+QwtPlotMultiBarChart::ChartStyle QwtPlotMultiBarChart::style() const
+{
+    return d_data->style;
+}
+
+/*!
+  \return Bounding rectangle of all samples.
+  For an empty series the rectangle is invalid.
+*/
+QRectF QwtPlotMultiBarChart::boundingRect() const
+{
+    const size_t numSamples = dataSize();
+
+    if ( numSamples == 0 )
+        return QwtPlotSeriesItem::boundingRect();
+
+    const double baseLine = baseline();
+
+    QRectF rect;
+
+    if ( d_data->style != QwtPlotMultiBarChart::Stacked )
+    {
+        rect = QwtPlotSeriesItem::boundingRect();
+
+        if ( rect.height() >= 0 )
+        {
+            if ( rect.bottom() < baseLine )
+                rect.setBottom( baseLine );
+            if ( rect.top() > baseLine )
+                rect.setTop( baseLine );
+        }
+    }
+    else
+    {
+        double xMin, xMax, yMin, yMax;
+
+        xMin = xMax = 0.0;
+        yMin = yMax = baseLine;
+
+        const QwtSeriesData<QwtSetSample> *series = data();
+
+        for ( size_t i = 0; i < numSamples; i++ )
+        {
+            const QwtSetSample sample = series->sample( i );
+            if ( i == 0 )
+            {
+                xMin = xMax = sample.value;
+            }
+            else
+            {
+                xMin = qMin( xMin, sample.value );
+                xMax = qMax( xMax, sample.value );
+            }
+
+            const double y = baseLine + sample.added();
+
+            yMin = qMin( yMin, y );
+            yMax = qMax( yMax, y );
+        }
+        rect.setRect( xMin, yMin, xMax - xMin, yMax - yMin );
+    }
+
+    if ( orientation() == Qt::Horizontal )
+        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
+
+    return rect;
+}
+
+/*!
+  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 rectangle 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 QwtPlotMultiBarChart::drawSeries( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, int from, int to ) const
+{
+    if ( to < 0 )
+        to = dataSize() - 1;
+
+    if ( from < 0 )
+        from = 0;
+
+    if ( from > to )
+        return;
+
+
+    const QRectF br = data()->boundingRect();
+    const QwtInterval interval( br.left(), br.right() );
+
+    painter->save();
+
+    for ( int i = from; i <= to; i++ )
+    {
+        drawSample( painter, xMap, yMap,
+            canvasRect, interval, i, sample( i ) );
+    }
+
+    painter->restore();
+}
+
+/*!
+  Draw a sample
+
+  \param painter Painter
+  \param xMap x map
+  \param yMap y map
+  \param canvasRect Contents rectangle of the canvas
+  \param boundingInterval Bounding interval of sample values
+  \param index Index of the sample to be painted
+  \param sample Sample value
+
+  \sa drawSeries()
+*/
+void QwtPlotMultiBarChart::drawSample( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, const QwtInterval &boundingInterval,
+    int index, const QwtSetSample& sample ) const
+{
+    if ( sample.set.size() <= 0 )
+        return;
+
+    double sampleW;
+
+    if ( orientation() == Qt::Horizontal )
+    {
+        sampleW = sampleWidth( yMap, canvasRect.height(),
+            boundingInterval.width(), sample.value );
+    }
+    else
+    {
+        sampleW = sampleWidth( xMap, canvasRect.width(),
+            boundingInterval.width(), sample.value );
+    }
+
+    if ( d_data->style == Stacked )
+    {
+        drawStackedBars( painter, xMap, yMap,
+            canvasRect, index, sampleW, sample );
+    }
+    else
+    {
+        drawGroupedBars( painter, xMap, yMap,
+            canvasRect, index, sampleW, sample );
+    }
+}
+
+/*!
+  Draw a grouped sample
+
+  \param painter Painter
+  \param xMap x map
+  \param yMap y map
+  \param canvasRect Contents rectangle of the canvas
+  \param index Index of the sample to be painted
+  \param sampleWidth Boundng width for all bars of the smaple
+  \param sample Sample 
+
+  \sa drawSeries(), sampleWidth()
+*/
+void QwtPlotMultiBarChart::drawGroupedBars( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, int index, double sampleWidth,
+    const QwtSetSample& sample ) const
+{
+    Q_UNUSED( canvasRect );
+
+    const int numBars = sample.set.size();
+    if ( numBars == 0 )
+        return;
+
+    if ( orientation() == Qt::Vertical )
+    {
+        const double barWidth = sampleWidth / numBars;
+
+        const double y1 = yMap.transform( baseline() );
+        const double x0 = xMap.transform( sample.value ) - 0.5 * sampleWidth;
+
+        for ( int i = 0; i < numBars; i++ )
+        {
+            const double x1 = x0 + i * barWidth;
+            const double x2 = x1 + barWidth;
+
+            const double y2 = yMap.transform( sample.set[i] );
+
+            QwtColumnRect barRect;
+            barRect.direction = ( y1 < y2 ) ?
+                QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;
+
+            barRect.hInterval = QwtInterval( x1, x2 ).normalized();
+            if ( i != 0 )
+                barRect.hInterval.setBorderFlags( QwtInterval::ExcludeMinimum );
+
+            barRect.vInterval = QwtInterval( y1, y2 ).normalized();
+
+            drawBar( painter, index, i, barRect );
+        }
+    }
+    else
+    {
+        const double barHeight = sampleWidth / numBars;
+
+        const double x1 = xMap.transform( baseline() );
+        const double y0 = yMap.transform( sample.value ) - 0.5 * sampleWidth;
+
+        for ( int i = 0; i < numBars; i++ )
+        {
+            double y1 = y0 + i * barHeight;
+            double y2 = y1 + barHeight;
+
+            double x2 = xMap.transform( sample.set[i] );
+
+            QwtColumnRect barRect;
+            barRect.direction = x1 < x2 ?
+                QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;
+
+            barRect.hInterval = QwtInterval( x1, x2 ).normalized();
+
+            barRect.vInterval = QwtInterval( y1, y2 );
+            if ( i != 0 )
+                barRect.vInterval.setBorderFlags( QwtInterval::ExcludeMinimum );
+
+            drawBar( painter, index, i, barRect );
+        }
+    }
+}
+
+/*!
+  Draw a stacked sample
+
+  \param painter Painter
+  \param xMap x map
+  \param yMap y map
+  \param canvasRect Contents rectangle of the canvas
+  \param index Index of the sample to be painted
+  \param sampleWidth Width of the bars
+  \param sample Sample 
+
+  \sa drawSeries(), sampleWidth()
+*/
+void QwtPlotMultiBarChart::drawStackedBars( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, int index, 
+    double sampleWidth, const QwtSetSample& sample ) const
+{
+    Q_UNUSED( canvasRect ); // clipping the bars ?
+
+    const int numBars = sample.set.size();
+    if ( numBars == 0 )
+        return;
+
+    QwtInterval::BorderFlag borderFlags = QwtInterval::IncludeBorders;
+
+    if ( orientation() == Qt::Vertical )
+    {
+        const double x1 = xMap.transform( sample.value ) - 0.5 * sampleWidth;
+        const double x2 = x1 + sampleWidth;
+
+        const bool increasing = qwtIsIncreasing( yMap, sample.set );
+
+        QwtColumnRect bar;
+        bar.direction = increasing ?
+            QwtColumnRect::TopToBottom : QwtColumnRect::BottomToTop;
+
+        bar.hInterval = QwtInterval( x1, x2 ).normalized();
+
+        double sum = baseline();
+
+        const int numBars = sample.set.size();
+        for ( int i = 0; i < numBars; i++ )
+        {
+            const double si = sample.set[ i ];
+            if ( si == 0.0 )
+                continue;
+
+            const double y1 = yMap.transform( sum );
+            const double y2 = yMap.transform( sum + si );
+
+            if ( ( y2 > y1 ) != increasing )
+            {
+                // stacked bars need to be in the same direction
+                continue;
+            }
+
+            bar.vInterval = QwtInterval( y1, y2 ).normalized();
+            bar.vInterval.setBorderFlags( borderFlags );
+
+            drawBar( painter, index, i, bar );
+
+            sum += si;
+
+            if ( increasing )
+                borderFlags = QwtInterval::ExcludeMinimum;
+            else
+                borderFlags = QwtInterval::ExcludeMaximum;
+        }
+    }
+    else
+    {
+        const double y1 = yMap.transform( sample.value ) - 0.5 * sampleWidth;
+        const double y2 = y1 + sampleWidth;
+
+        const bool increasing = qwtIsIncreasing( xMap, sample.set );
+
+        QwtColumnRect bar;
+        bar.direction = increasing ?
+            QwtColumnRect::LeftToRight : QwtColumnRect::RightToLeft;
+        bar.vInterval = QwtInterval( y1, y2 ).normalized();
+
+        double sum = baseline();
+
+        for ( int i = 0; i < sample.set.size(); i++ )
+        {
+            const double si = sample.set[ i ];
+            if ( si == 0.0 )
+                continue;
+
+            const double x1 = xMap.transform( sum );
+            const double x2 = xMap.transform( sum + si );
+
+            if ( ( x2 > x1 ) != increasing )
+            {
+                // stacked bars need to be in the same direction
+                continue;
+            }
+
+            bar.hInterval = QwtInterval( x1, x2 ).normalized();
+            bar.hInterval.setBorderFlags( borderFlags );
+
+            drawBar( painter, index, i, bar );
+
+            sum += si;
+
+            if ( increasing )
+                borderFlags = QwtInterval::ExcludeMinimum;
+            else
+                borderFlags = QwtInterval::ExcludeMaximum;
+        }
+    }
+}
+
+/*!
+  Draw a bar
+
+  \param painter Painter
+  \param sampleIndex Index of the sample - might be -1 when the
+                     bar is painted for the legend
+  \param valueIndex Index of a value in a set
+  \param rect Directed target rectangle for the bar
+
+  \sa drawSeries()
+*/
+void QwtPlotMultiBarChart::drawBar( QPainter *painter,
+    int sampleIndex, int valueIndex, const QwtColumnRect &rect ) const
+{
+    const QwtColumnSymbol *specialSym = NULL;
+    if ( sampleIndex >= 0 )
+        specialSym = specialSymbol( sampleIndex, valueIndex );
+
+    const QwtColumnSymbol *sym = specialSym;
+    if ( sym == NULL )
+        sym = symbol( valueIndex );
+
+    if ( sym )
+    {
+        sym->draw( painter, rect );
+    }
+    else
+    {
+        // we build a temporary default symbol
+        QwtColumnSymbol sym( QwtColumnSymbol::Box );
+        sym.setLineWidth( 1 );
+        sym.setFrameStyle( QwtColumnSymbol::Plain );
+        sym.draw( painter, rect );
+    }
+
+    delete specialSym;
+}
+
+/*!
+  \return Information to be displayed on the legend
+
+  The chart is represented by a list of entries - one for each bar title.
+  Each element contains a bar title and an icon showing its corresponding bar.
+
+  \sa barTitles(), legendIcon(), legendIconSize()
+*/
+QList<QwtLegendData> QwtPlotMultiBarChart::legendData() const
+{
+    QList<QwtLegendData> list;
+
+    for ( int i = 0; i < d_data->barTitles.size(); i++ )
+    {
+        QwtLegendData data;
+
+        QVariant titleValue;
+        qVariantSetValue( titleValue, d_data->barTitles[i] );
+        data.setValue( QwtLegendData::TitleRole, titleValue );
+
+        if ( !legendIconSize().isEmpty() )
+        {
+            QVariant iconValue;
+            qVariantSetValue( iconValue, 
+                legendIcon( i, legendIconSize() ) );
+
+            data.setValue( QwtLegendData::IconRole, iconValue );
+        }
+
+        list += data;
+    }
+
+    return list;
+}
+
+/*!
+  \return Icon for representing a bar on the legend
+
+  \param index Index of the bar
+  \param size Icon size
+  
+  \return An icon showing a bar
+  \sa drawBar(), legendData()
+ */
+QwtGraphic QwtPlotMultiBarChart::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    QwtColumnRect column;
+    column.hInterval = QwtInterval( 0.0, size.width() - 1.0 );
+    column.vInterval = QwtInterval( 0.0, size.height() - 1.0 );
+
+    QwtGraphic icon;
+    icon.setDefaultSize( size );
+    icon.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &icon );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPlotItem::RenderAntialiased ) );
+
+    drawBar( &painter, -1, index, column );
+
+    return icon;
+}
+
Index: trunk/BNC/qwt/qwt_plot_multi_barchart.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_multi_barchart.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_multi_barchart.h	(revision 8127)
@@ -0,0 +1,127 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_MULTI_BAR_CHART_H
+#define QWT_PLOT_MULTI_BAR_CHART_H
+
+#include "qwt_global.h"
+#include "qwt_plot_abstract_barchart.h"
+#include "qwt_series_data.h"
+
+class QwtColumnRect;
+class QwtColumnSymbol;
+
+/*!
+  \brief QwtPlotMultiBarChart displays a series of a samples that consist
+         each of a set of values. 
+
+  Each value is displayed as a bar, the bars of each set can be organized 
+  side by side or accumulated.
+
+  Each bar of a set is rendered by a QwtColumnSymbol, that is set by setSymbol().
+  The bars of different sets use the same symbols. Exceptions are possible
+  by overloading specialSymbol() or overloading drawBar().
+
+  Depending on its orientation() the bars are displayed horizontally 
+  or vertically. The bars cover the interval between the baseline() 
+  and the value.
+
+  In opposite to most other plot items, QwtPlotMultiBarChart returns more
+  than one entry for the legend - one for each symbol.
+   
+  \sa QwtPlotBarChart, QwtPlotHistogram
+      QwtPlotSeriesItem::orientation(), QwtPlotAbstractBarChart::baseline()
+ */
+class QWT_EXPORT QwtPlotMultiBarChart: 
+    public QwtPlotAbstractBarChart, public QwtSeriesStore<QwtSetSample>
+{
+public:
+    /*!
+        \brief Chart styles.
+
+        The default setting is QwtPlotMultiBarChart::Grouped.
+        \sa setStyle(), style()
+    */
+    enum ChartStyle
+    {
+        //! The bars of a set are displayed side by side
+        Grouped,
+
+        /*!
+            The bars are displayed on top of each other accumulating
+            to a single bar. All values of a set need to have the same
+            sign.
+         */
+        Stacked
+    };
+
+    explicit QwtPlotMultiBarChart( const QString &title = QString::null );
+    explicit QwtPlotMultiBarChart( const QwtText &title );
+
+    virtual ~QwtPlotMultiBarChart();
+
+    virtual int rtti() const;
+
+    void setBarTitles( const QList<QwtText> & );
+    QList<QwtText> barTitles() const;
+
+    void setSamples( const QVector<QwtSetSample> & );
+    void setSamples( const QVector< QVector<double> > & );
+    void setSamples( QwtSeriesData<QwtSetSample> * );
+
+    void setStyle( ChartStyle style );
+    ChartStyle style() const;
+
+    void setSymbol( int barIndex, QwtColumnSymbol *symbol );
+    const QwtColumnSymbol *symbol( int barIndex ) const;
+
+    void resetSymbolMap();
+
+    virtual void drawSeries( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual QRectF boundingRect() const;
+
+    virtual QList<QwtLegendData> legendData() const;
+
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
+
+protected:
+    QwtColumnSymbol *symbol( int barIndex );
+
+    virtual QwtColumnSymbol *specialSymbol( 
+        int sampleIndex, int valueIndex ) const;
+
+    virtual void drawSample( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, const QwtInterval &boundingInterval,
+        int index, const QwtSetSample& sample ) const;
+
+    virtual void drawBar( QPainter *, int sampleIndex,
+        int barIndex, const QwtColumnRect & ) const;
+
+    void drawStackedBars( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int index,
+        double sampleWidth, const QwtSetSample& sample ) const;
+
+    void drawGroupedBars( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int index,
+        double sampleWidth, const QwtSetSample& sample ) const;
+
+private:
+    void init();
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_panner.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_panner.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_panner.cpp	(revision 8127)
@@ -11,5 +11,80 @@
 #include "qwt_scale_div.h"
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
+#include "qwt_painter.h"
+#include <qbitmap.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+
+static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
+{
+    const QRect r( 0, 0, size.width(), size.height() );
+
+    QPainterPath borderPath;
+
+    ( void )QMetaObject::invokeMethod( 
+        const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection,
+        Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
+
+    if ( borderPath.isEmpty() )
+    {
+        if ( canvas->contentsRect() == canvas->rect() )
+            return QBitmap();
+
+        QBitmap mask( size );
+        mask.fill( Qt::color0 );
+
+        QPainter painter( &mask );
+        painter.fillRect( canvas->contentsRect(), Qt::color1 );
+
+        return mask;
+    }
+
+    QImage image( size, QImage::Format_ARGB32_Premultiplied );
+    image.fill( Qt::color0 );
+
+    QPainter painter( &image );
+    painter.setClipPath( borderPath );
+    painter.fillRect( r, Qt::color1 );
+
+    // now erase the frame
+
+    painter.setCompositionMode( QPainter::CompositionMode_DestinationOut );
+
+    if ( canvas->testAttribute(Qt::WA_StyledBackground ) )
+    {
+        QStyleOptionFrame opt;
+        opt.initFrom(canvas);
+        opt.rect = r;
+        canvas->style()->drawPrimitive( QStyle::PE_Frame, &opt, &painter, canvas );
+    }
+    else
+    {
+        const QVariant borderRadius = canvas->property( "borderRadius" );
+        const QVariant frameWidth = canvas->property( "frameWidth" );
+
+        if ( borderRadius.type() == QVariant::Double 
+            && frameWidth.type() == QVariant::Int )
+        {
+            const double br = borderRadius.toDouble();
+            const int fw = frameWidth.toInt();
+        
+            if ( br > 0.0 && fw > 0 )
+            {
+                painter.setPen( QPen( Qt::color1, fw ) );
+                painter.setBrush( Qt::NoBrush );
+                painter.setRenderHint( QPainter::Antialiasing, true );
+
+                painter.drawPath( borderPath );
+            }
+        }
+    }
+
+    painter.end();
+
+    const QImage mask = image.createMaskFromColor(
+        QColor( Qt::color1 ).rgb(), Qt::MaskOutColor );
+
+    return QBitmap::fromImage( mask );
+}
 
 class QwtPlotPanner::PrivateData
@@ -26,5 +101,5 @@
 
 /*!
-  \brief Create a plot panner
+  \brief A panner for the canvas of a QwtPlot
 
   The panner is enabled for all axes
@@ -34,5 +109,5 @@
   \sa setAxisEnabled()
 */
-QwtPlotPanner::QwtPlotPanner( QwtPlotCanvas *canvas ):
+QwtPlotPanner::QwtPlotPanner( QWidget *canvas ):
     QwtPanner( canvas )
 {
@@ -83,13 +158,13 @@
 
 //! Return observed plot canvas
-QwtPlotCanvas *QwtPlotPanner::canvas()
-{
-    return qobject_cast<QwtPlotCanvas *>( parentWidget() );
+QWidget *QwtPlotPanner::canvas()
+{
+    return parentWidget();
 }
 
 //! Return Observed plot canvas
-const QwtPlotCanvas *QwtPlotPanner::canvas() const
-{
-    return qobject_cast<const QwtPlotCanvas *>( parentWidget() );
+const QWidget *QwtPlotPanner::canvas() const
+{
+    return parentWidget();
 }
 
@@ -97,9 +172,9 @@
 QwtPlot *QwtPlotPanner::plot()
 {
-    QwtPlotCanvas *w = canvas();
+    QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
+        w = w->parentWidget();
+
+    return qobject_cast<QwtPlot *>( w );
 }
 
@@ -107,9 +182,9 @@
 const QwtPlot *QwtPlotPanner::plot() const
 {
-    const QwtPlotCanvas *w = canvas();
+    const QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
+        w = w->parentWidget();
+
+    return qobject_cast<const QwtPlot *>( w );
 }
 
@@ -141,6 +216,6 @@
         const QwtScaleMap map = plot->canvasMap( axis );
 
-        const double p1 = map.transform( plot->axisScaleDiv( axis )->lowerBound() );
-        const double p2 = map.transform( plot->axisScaleDiv( axis )->upperBound() );
+        const double p1 = map.transform( plot->axisScaleDiv( axis ).lowerBound() );
+        const double p2 = map.transform( plot->axisScaleDiv( axis ).upperBound() );
 
         double d1, d2;
@@ -164,12 +239,37 @@
 
 /*!
-    Calculate a mask from the border mask of the canvas
-    \sa QwtPlotCanvas::borderMask()
+   Calculate a mask from the border path of the canvas
+
+   \return Mask as bitmap
+   \sa QwtPlotCanvas::borderPath()
 */
 QBitmap QwtPlotPanner::contentsMask() const
 {
     if ( canvas() )
-        return canvas()->borderMask( size() );
+        return qwtBorderMask( canvas(), size() );
 
     return QwtPanner::contentsMask();
 }
+
+/*!
+   \return Pixmap with the content of the canvas
+ */
+QPixmap QwtPlotPanner::grab() const
+{   
+    const QWidget *cv = canvas();
+    if ( cv && cv->inherits( "QGLWidget" ) )
+    {
+        // we can't grab from a QGLWidget
+
+        QPixmap pm( cv->size() );
+        QwtPainter::fillPixmap( cv, pm );
+
+        QPainter painter( &pm );
+        const_cast<QwtPlot *>( plot() )->drawCanvas( &painter );
+
+        return pm;
+    }
+
+    return QwtPanner::grab();
+}   
+
Index: trunk/BNC/qwt/qwt_plot_panner.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_panner.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_panner.h	(revision 8127)
@@ -14,5 +14,4 @@
 #include "qwt_panner.h"
 
-class QwtPlotCanvas;
 class QwtPlot;
 
@@ -20,5 +19,5 @@
   \brief QwtPlotPanner provides panning of a plot canvas
 
-  QwtPlotPanner is a panner for a QwtPlotCanvas, that
+  QwtPlotPanner is a panner for a plot canvas, that
   adjusts the scales of the axes after dropping
   the canvas on its new position.
@@ -35,9 +34,9 @@
 
 public:
-    explicit QwtPlotPanner( QwtPlotCanvas * );
+    explicit QwtPlotPanner( QWidget * );
     virtual ~QwtPlotPanner();
 
-    QwtPlotCanvas *canvas();
-    const QwtPlotCanvas *canvas() const;
+    QWidget *canvas();
+    const QWidget *canvas() const;
 
     QwtPlot *plot();
@@ -52,4 +51,5 @@
 protected:
     virtual QBitmap contentsMask() const;
+    virtual QPixmap grab() const;
 
 private:
Index: trunk/BNC/qwt/qwt_plot_picker.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_picker.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_picker.cpp	(revision 8127)
@@ -28,5 +28,5 @@
 */
 
-QwtPlotPicker::QwtPlotPicker( QwtPlotCanvas *canvas ):
+QwtPlotPicker::QwtPlotPicker( QWidget *canvas ):
     QwtPicker( canvas ),
     d_xAxis( -1 ),
@@ -66,5 +66,5 @@
   \sa QwtPlot::autoReplot(), QwtPlot::replot(), scaleRect()
 */
-QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QwtPlotCanvas *canvas ):
+QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis, QWidget *canvas ):
     QwtPicker( canvas ),
     d_xAxis( xAxis ),
@@ -78,5 +78,5 @@
   \param xAxis X axis of the picker
   \param yAxis Y axis of the picker
-  \param rubberBand Rubberband style
+  \param rubberBand Rubber band style
   \param trackerMode Tracker mode
   \param canvas Plot canvas to observe, also the parent object
@@ -89,5 +89,5 @@
 QwtPlotPicker::QwtPlotPicker( int xAxis, int yAxis,
         RubberBand rubberBand, DisplayMode trackerMode,
-        QwtPlotCanvas *canvas ):
+        QWidget *canvas ):
     QwtPicker( rubberBand, trackerMode, canvas ),
     d_xAxis( xAxis ),
@@ -101,39 +101,38 @@
 }
 
-//! Return observed plot canvas
-QwtPlotCanvas *QwtPlotPicker::canvas()
-{
-    return qobject_cast<QwtPlotCanvas *>( parentWidget() );
-}
-
-//! Return Observed plot canvas
-const QwtPlotCanvas *QwtPlotPicker::canvas() const
-{
-    return qobject_cast<const QwtPlotCanvas *>( parentWidget() );
-}
-
-//! Return plot widget, containing the observed plot canvas
+//! \return Observed plot canvas
+QWidget *QwtPlotPicker::canvas()
+{
+    return parentWidget();
+}
+
+//! \return Observed plot canvas
+const QWidget *QwtPlotPicker::canvas() const
+{
+    return parentWidget();
+}
+
+//! \return Plot widget, containing the observed plot canvas
 QwtPlot *QwtPlotPicker::plot()
 {
-    QwtPlotCanvas *w = canvas();
+    QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
-}
-
-//! Return plot widget, containing the observed plot canvas
+        w = w->parentWidget();
+
+    return qobject_cast<QwtPlot *>( w );
+}
+
+//! \return Plot widget, containing the observed plot canvas
 const QwtPlot *QwtPlotPicker::plot() const
 {
-    const QwtPlotCanvas *w = canvas();
+    const QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
-}
-
-/*!
-  Return normalized bounding rect of the axes
-
+        w = w->parentWidget();
+
+    return qobject_cast<const QwtPlot *>( w );
+}
+
+/*!
+  \return Normalized bounding rectangle of the axes
   \sa QwtPlot::autoReplot(), QwtPlot::replot().
 */
@@ -144,13 +143,10 @@
     if ( plot() )
     {
-        const QwtScaleDiv *xs = plot()->axisScaleDiv( xAxis() );
-        const QwtScaleDiv *ys = plot()->axisScaleDiv( yAxis() );
-
-        if ( xs && ys )
-        {
-            rect = QRectF( xs->lowerBound(), ys->lowerBound(),
-                xs->range(), ys->range() );
-            rect = rect.normalized();
-        }
+        const QwtScaleDiv &xs = plot()->axisScaleDiv( xAxis() );
+        const QwtScaleDiv &ys = plot()->axisScaleDiv( yAxis() );
+
+        rect = QRectF( xs.lowerBound(), ys.lowerBound(),
+            xs.range(), ys.range() );
+        rect = rect.normalized();
     }
 
@@ -231,5 +227,5 @@
 
 /*!
-  Append a point to the selection and update rubberband and tracker.
+  Append a point to the selection and update rubber band and tracker.
 
   \param pos Additional point
@@ -265,5 +261,5 @@
   \param ok If true, complete the selection and emit selected signals
             otherwise discard the selection.
-  \return true if the selection is accepted, false otherwise
+  \return True if the selection has been accepted, false otherwise
 */
 
@@ -278,6 +274,6 @@
         return false;
 
-    const QPolygon pa = selection();
-    if ( pa.count() == 0 )
+    const QPolygon points = selection();
+    if ( points.count() == 0 )
         return false;
 
@@ -292,5 +288,5 @@
         case QwtPickerMachine::PointSelection:
         {
-            const QPointF pos = invTransform( pa[0] );
+            const QPointF pos = invTransform( points.first() );
             Q_EMIT selected( pos );
             break;
@@ -298,8 +294,8 @@
         case QwtPickerMachine::RectSelection:
         {
-            if ( pa.count() >= 2 )
+            if ( points.count() >= 2 )
             {
-                const QPoint p1 = pa[0];
-                const QPoint p2 = pa[int( pa.count() - 1 )];
+                const QPoint p1 = points.first();
+                const QPoint p2 = points.last();
 
                 const QRect rect = QRect( p1, p2 ).normalized();
@@ -310,7 +306,7 @@
         case QwtPickerMachine::PolygonSelection:
         {
-            QVector<QPointF> dpa( pa.count() );
-            for ( int i = 0; i < int( pa.count() ); i++ )
-                dpa[i] = invTransform( pa[i] );
+            QVector<QPointF> dpa( points.count() );
+            for ( int i = 0; i < points.count(); i++ )
+                dpa[i] = invTransform( points[i] );
 
             Q_EMIT selected( dpa );
Index: trunk/BNC/qwt/qwt_plot_picker.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_picker.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_picker.h	(revision 8127)
@@ -12,5 +12,4 @@
 
 #include "qwt_global.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_picker.h"
 #include <qvector.h>
@@ -23,5 +22,5 @@
   QwtPlotPicker is a QwtPicker tailored for selections on
   a plot canvas. It is set to a x-Axis and y-Axis and
-  translates all pixel coordinates into this coodinate system.
+  translates all pixel coordinates into this coordinate system.
 */
 
@@ -31,12 +30,11 @@
 
 public:
-    explicit QwtPlotPicker( QwtPlotCanvas * );
+    explicit QwtPlotPicker( QWidget *canvas );
     virtual ~QwtPlotPicker();
 
-    explicit QwtPlotPicker( int xAxis, int yAxis, QwtPlotCanvas * );
+    explicit QwtPlotPicker( int xAxis, int yAxis, QWidget * );
 
     explicit QwtPlotPicker( int xAxis, int yAxis,
-        RubberBand rubberBand, DisplayMode trackerMode,
-        QwtPlotCanvas * );
+        RubberBand rubberBand, DisplayMode trackerMode, QWidget * );
 
     virtual void setAxis( int xAxis, int yAxis );
@@ -48,11 +46,11 @@
     const QwtPlot *plot() const;
 
-    QwtPlotCanvas *canvas();
-    const QwtPlotCanvas *canvas() const;
+    QWidget *canvas();
+    const QWidget *canvas() const;
 
 Q_SIGNALS:
 
     /*!
-      A signal emitted in case of selectionFlags() & PointSelection.
+      A signal emitted in case of QwtPickerMachine::PointSelection.
       \param pos Selected point
     */
@@ -60,5 +58,5 @@
 
     /*!
-      A signal emitted in case of selectionFlags() & RectSelection.
+      A signal emitted in case of QwtPickerMachine::RectSelection.
       \param rect Selected rectangle
     */
Index: trunk/BNC/qwt/qwt_plot_rasteritem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_rasteritem.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_rasteritem.cpp	(revision 8127)
@@ -9,6 +9,4 @@
 
 #include "qwt_plot_rasteritem.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
 #include "qwt_scale_map.h"
 #include "qwt_painter.h"
@@ -17,4 +15,10 @@
 #include <qpainter.h>
 #include <qpaintengine.h>
+#include <qmath.h>
+#if QT_VERSION >= 0x040400
+#include <qthread.h>
+#include <qfuture.h>
+#include <qtconcurrentrun.h>
+#endif
 #include <float.h>
 
@@ -30,4 +34,5 @@
 
     int alpha;
+
     QwtPlotRasterItem::PaintAttributes paintAttributes;
 
@@ -186,5 +191,6 @@
                 }
 
-                const quint32 *line1 = (const quint32 *) image.scanLine( y1 );
+                const quint32 *line1 = 
+                    reinterpret_cast<const quint32 *>( image.scanLine( y1 ) );
 
                 for ( int x1 = 0; x1 < w; x1++ )
@@ -217,5 +223,7 @@
                     for ( int y2 = yy1; y2 < yy2; y2++ )
                     {
-                        quint32 *line2 = ( quint32 *) expanded.scanLine( y2 );
+                        quint32 *line2 = reinterpret_cast<quint32 *>( 
+                            expanded.scanLine( y2 ) );
+
                         for ( int x2 = xx1; x2 < xx2; x2++ ) 
                             line2[x2] = rgb;
@@ -297,5 +305,5 @@
 }   
 
-static QRectF expandToPixels(const QRectF &rect, const QRectF &pixelRect)
+static QRectF qwtExpandToPixels(const QRectF &rect, const QRectF &pixelRect)
 {
     const double pw = pixelRect.width();
@@ -316,5 +324,5 @@
 }
 
-static void transformMaps( const QTransform &tr,
+static void qwtTransformMaps( const QTransform &tr,
     const QwtScaleMap &xMap, const QwtScaleMap &yMap,
     QwtScaleMap &xxMap, QwtScaleMap &yyMap )
@@ -330,5 +338,5 @@
 }
 
-static void adjustMaps( QwtScaleMap &xMap, QwtScaleMap &yMap,
+static void qwtAdjustMaps( QwtScaleMap &xMap, QwtScaleMap &yMap,
     const QRectF &area, const QRectF &paintRect)
 {
@@ -351,5 +359,5 @@
 }
 
-static bool useCache( QwtPlotRasterItem::CachePolicy policy,
+static bool qwtUseCache( QwtPlotRasterItem::CachePolicy policy,
     const QPainter *painter )
 {
@@ -377,37 +385,35 @@
 }
 
-static QImage toRgba( const QImage& image, int alpha )
-{
-    if ( alpha < 0 || alpha >= 255 )
-        return image;
-
-    QImage alphaImage( image.size(), QImage::Format_ARGB32 );
-
+static void qwtToRgba( const QImage* from, QImage* to,  
+    const QRect& tile, int alpha )
+{
     const QRgb mask1 = qRgba( 0, 0, 0, alpha );
     const QRgb mask2 = qRgba( 255, 255, 255, 0 );
     const QRgb mask3 = qRgba( 0, 0, 0, 255 );
 
-    const int w = image.size().width();
-    const int h = image.size().height();
-
-    if ( image.depth() == 8 )
-    {
-        for ( int y = 0; y < h; y++ )
-        {
-            QRgb* alphaLine = ( QRgb* )alphaImage.scanLine( y );
-            const unsigned char *line = image.scanLine( y );
-
-            for ( int x = 0; x < w; x++ )
-                *alphaLine++ = ( image.color( *line++ ) & mask2 ) | mask1;
-        }
-    }
-    else if ( image.depth() == 32 )
-    {
-        for ( int y = 0; y < h; y++ )
-        {
-            QRgb* alphaLine = ( QRgb* )alphaImage.scanLine( y );
-            const QRgb* line = ( const QRgb* ) image.scanLine( y );
-
-            for ( int x = 0; x < w; x++ )
+    const int y0 = tile.top();
+    const int y1 = tile.bottom();
+    const int x0 = tile.left();
+    const int x1 = tile.right();
+
+    if ( from->depth() == 8 )
+    {
+        for ( int y = y0; y <= y1; y++ )
+        {
+            QRgb *alphaLine = reinterpret_cast<QRgb *>( to->scanLine( y ) );
+            const unsigned char *line = from->scanLine( y );
+
+            for ( int x = x0; x <= x1; x++ )
+                *alphaLine++ = ( from->color( *line++ ) & mask2 ) | mask1;
+        }
+    }
+    else if ( from->depth() == 32 )
+    {
+        for ( int y = y0; y <= y1; y++ )
+        {
+            QRgb *alphaLine = reinterpret_cast<QRgb *>( to->scanLine( y ) );
+            const QRgb *line = reinterpret_cast<const QRgb *>( from->scanLine( y ) );
+
+            for ( int x = x0; x <= x1; x++ )
             {
                 const QRgb rgb = *line++;
@@ -419,6 +425,4 @@
         }
     }
-
-    return alphaImage;
 }
 
@@ -469,5 +473,5 @@
 
 /*!
-    \brief Return the current paint attributes
+    \return True, when attribute is enabled
     \sa PaintAttribute, setPaintAttribute()
 */
@@ -572,5 +576,5 @@
 
    Width and height of the hint need to be the horizontal  
-   and vertical distances between 2 neighboured points. 
+   and vertical distances between 2 neighbored points. 
    The center of the hint has to be the position of any point 
    ( it doesn't matter which one ).
@@ -602,5 +606,5 @@
   \param xMap X-Scale Map
   \param yMap Y-Scale Map
-  \param canvasRect Contents rect of the plot canvas
+  \param canvasRect Contents rectangle of the plot canvas
 */
 void QwtPlotRasterItem::draw( QPainter *painter,
@@ -611,5 +615,5 @@
         return;
 
-    const bool doCache = useCache( d_data->cache.policy, painter );
+    const bool doCache = qwtUseCache( d_data->cache.policy, painter );
 
     const QwtInterval xInterval = interval( Qt::XAxis );
@@ -617,5 +621,5 @@
 
     /*
-        Scaling a rastered image always results in a loss of
+        Scaling an image always results in a loss of
         precision/quality. So we always render the image in
         paint device resolution.
@@ -623,5 +627,5 @@
 
     QwtScaleMap xxMap, yyMap;
-    transformMaps( painter->transform(), xMap, yMap, xxMap, yyMap );
+    qwtTransformMaps( painter->transform(), xMap, yMap, xxMap, yyMap );
 
     QRectF paintRect = painter->transform().mapRect( canvasRect );
@@ -644,9 +648,9 @@
     if ( !pixelRect.isEmpty() )
     {
-        const QRectF r = QwtScaleMap::invTransform( 
-            xxMap, yyMap, QRectF(0, 0, 1, 1) ).normalized();
-
-        if ( r.width() > pixelRect.width() &&
-            r.height() > pixelRect.height() )
+        // one pixel of the target device in plot coordinates
+        const double dx = qAbs( xxMap.invTransform( 1 ) - xxMap.invTransform( 0 ) );
+        const double dy = qAbs( yyMap.invTransform( 1 ) - yyMap.invTransform( 0 ) );
+
+        if ( dx > pixelRect.width() && dy > pixelRect.height() )
         {
             /*
@@ -657,4 +661,17 @@
             pixelRect = QRectF();
         }
+        else
+        {
+            /*
+              If only one dimension is of the data pixel is higher 
+              we expand the pixel rect to the resolution of the target device.
+             */
+
+            if ( dx > pixelRect.width() )
+                pixelRect.setWidth( dx );
+
+            if ( dy > pixelRect.height() )
+                pixelRect.setHeight( dy );
+        }
     }
 
@@ -667,5 +684,5 @@
 
             paintRect = qwtAlignRect(paintRect);
-            adjustMaps(xxMap, yyMap, area, paintRect);
+            qwtAdjustMaps(xxMap, yyMap, area, paintRect);
         }
 
@@ -701,5 +718,5 @@
 
         // align the area to the data pixels
-        QRectF imageArea = expandToPixels(area, pixelRect);
+        QRectF imageArea = qwtExpandToPixels(area, pixelRect);
 
         if ( imageArea.right() == xInterval.maxValue() &&
@@ -717,6 +734,8 @@
         imageSize.setWidth( qRound( imageArea.width() / pixelRect.width() ) );
         imageSize.setHeight( qRound( imageArea.height() / pixelRect.height() ) );
+
         image = compose(xxMap, yyMap, 
             imageArea, paintRect, imageSize, doCache );
+
         if ( image.isNull() )
             return;
@@ -760,5 +779,5 @@
 
 /*!
-   \return Bounding rect of the data
+   \return Bounding rectangle of the data
    \sa QwtPlotRasterItem::interval()
 */
@@ -844,5 +863,41 @@
 
     if ( d_data->alpha >= 0 && d_data->alpha < 255 )
-        image = toRgba( image, d_data->alpha );
+    {
+        QImage alphaImage( image.size(), QImage::Format_ARGB32 );
+
+#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
+        uint numThreads = renderThreadCount();
+
+        if ( numThreads <= 0 )
+            numThreads = QThread::idealThreadCount();
+
+        if ( numThreads <= 0 )
+            numThreads = 1;
+
+        const int numRows = image.height() / numThreads;
+
+        QList< QFuture<void> > futures;
+        for ( uint i = 0; i < numThreads; i++ )
+        {
+            QRect tile( 0, i * numRows, image.width(), numRows );
+            if ( i == numThreads - 1 )
+            {
+                tile.setHeight( image.height() - i * numRows );
+                qwtToRgba( &image, &alphaImage, tile, d_data->alpha );
+            }
+            else
+            {
+                futures += QtConcurrent::run(
+                    &qwtToRgba, &image, &alphaImage, tile, d_data->alpha );
+            }
+        }
+        for ( int i = 0; i < futures.size(); i++ )
+            futures[i].waitForFinished();
+#else
+        const QRect tile( 0, 0, image.width(), image.height() );
+        qwtToRgba( &image, &alphaImage, tile, d_data->alpha );
+#endif
+        image = alphaImage;
+    }
 
     return image;
@@ -857,4 +912,6 @@
    \param imageSize Image size
    \param pixelSize Width/Height of a data pixel
+
+   \return Calculated scale map
 */
 QwtScaleMap QwtPlotRasterItem::imageMap(
Index: trunk/BNC/qwt/qwt_plot_rasteritem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_rasteritem.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_rasteritem.h	(revision 8127)
@@ -39,18 +39,22 @@
 public:
     /*!
-      - NoCache\n
-        renderImage() is called, whenever the item has to be repainted
-      - PaintCache\n
-        renderImage() is called, whenever the image cache is not valid,
-        or the scales, or the size of the canvas has changed. This type
-        of cache is only useful for improving the performance of hide/show
-        operations. All other situations are already handled by the
-        plot canvas cache.
-
+      \brief Cache policy
       The default policy is NoCache
      */
     enum CachePolicy
     {
+        /*!
+          renderImage() is called each time the item has to be repainted
+         */
         NoCache,
+
+        /*!
+          renderImage() is called, whenever the image cache is not valid,
+          or the scales, or the size of the canvas has changed. 
+
+          This type of cache is useful for improving the performance 
+          of hide/show operations or manipulations of the alpha value. 
+          All other situations are handled by the canvas backing store.
+         */
         PaintCache
     };
@@ -118,4 +122,6 @@
       \param area Requested area for the image in scale coordinates
       \param imageSize Requested size of the image
+   
+      \return Rendered image
      */
     virtual QImage renderImage( const QwtScaleMap &xMap,
Index: trunk/BNC/qwt/qwt_plot_renderer.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_renderer.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_renderer.cpp	(revision 8127)
@@ -11,9 +11,6 @@
 #include "qwt_plot.h"
 #include "qwt_painter.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_plot_layout.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
-#include "qwt_dyngrid_layout.h"
+#include "qwt_abstract_legend.h"
 #include "qwt_scale_widget.h"
 #include "qwt_scale_engine.h"
@@ -25,8 +22,10 @@
 #include <qtransform.h>
 #include <qprinter.h>
+#include <qprintdialog.h>
+#include <qfiledialog.h>
+#include <qfileinfo.h>
 #include <qstyle.h>
 #include <qstyleoption.h>
 #include <qimagewriter.h>
-#include <qfileinfo.h>
 #ifndef QWT_NO_SVG
 #ifdef QT_SVG_LIB
@@ -35,9 +34,33 @@
 #endif
 
+static QPainterPath qwtCanvasClip( 
+    const QWidget* canvas, const QRectF &canvasRect )
+{
+    // The clip region is calculated in integers
+    // To avoid too much rounding errors better
+    // calculate it in target device resolution
+
+    int x1 = qCeil( canvasRect.left() );
+    int x2 = qFloor( canvasRect.right() );
+    int y1 = qCeil( canvasRect.top() );
+    int y2 = qFloor( canvasRect.bottom() );
+
+    const QRect r( x1, y1, x2 - x1 - 1, y2 - y1 - 1 );
+
+    QPainterPath clipPath;
+
+    ( void ) QMetaObject::invokeMethod(
+        const_cast< QWidget *>( canvas ), "borderPath",
+        Qt::DirectConnection,
+        Q_RETURN_ARG( QPainterPath, clipPath ), Q_ARG( QRect, r ) );
+
+    return clipPath;
+}
+
 class QwtPlotRenderer::PrivateData
 {
 public:
     PrivateData():
-        discardFlags( QwtPlotRenderer::DiscardBackground ),
+        discardFlags( QwtPlotRenderer::DiscardNone ),
         layoutFlags( QwtPlotRenderer::DefaultLayout )
     {
@@ -47,25 +70,4 @@
     QwtPlotRenderer::LayoutFlags layoutFlags;
 };
-
-static void qwtRenderBackground( QPainter *painter,
-    const QRectF &rect, const QWidget *widget )
-{
-    if ( widget->testAttribute( Qt::WA_StyledBackground ) )
-    {
-        QStyleOption opt;
-        opt.initFrom( widget );
-        opt.rect = rect.toAlignedRect();
-
-        widget->style()->drawPrimitive(
-            QStyle::PE_Widget, &opt, painter, widget);
-    }
-    else
-    {
-        const QBrush brush = 
-            widget->palette().brush( widget->backgroundRole() );
-
-        painter->fillRect( rect, brush );
-    }
-}
 
 /*! 
@@ -102,6 +104,5 @@
 
 /*!
-  Check if a flag is set.
-
+  \return True, if flag is enabled.
   \param flag Flag to be tested
   \sa DiscardFlag, setDiscardFlag(), setDiscardFlags(), discardFlags()
@@ -149,6 +150,5 @@
 
 /*!
-  Check if a flag is set.
-
+  \return True, if flag is enabled.
   \param flag Flag to be tested
   \sa LayoutFlag, setLayoutFlag(), setLayoutFlags(), layoutFlags()
@@ -182,6 +182,6 @@
   Render a plot to a file
 
-  The format of the document will be autodetected from the
-  suffix of the filename.
+  The format of the document will be auto-detected from the
+  suffix of the file name.
 
   \param plot Plot widget
@@ -239,18 +239,36 @@
 
     const QString fmt = format.toLower();
-    if ( fmt == "pdf" || fmt == "ps" )
+    if ( fmt == "pdf" )
     {
 #ifndef QT_NO_PRINTER
         QPrinter printer;
+        printer.setOutputFormat( QPrinter::PdfFormat );
+        printer.setColorMode( QPrinter::Color );
         printer.setFullPage( true );
         printer.setPaperSize( sizeMM, QPrinter::Millimeter );
         printer.setDocName( title );
         printer.setOutputFileName( fileName );
-        printer.setOutputFormat( ( format == "pdf" )
-            ? QPrinter::PdfFormat : QPrinter::PostScriptFormat );
         printer.setResolution( resolution );
 
         QPainter painter( &printer );
         render( plot, &painter, documentRect );
+#endif
+    }
+    else if ( fmt == "ps" )
+    {
+#if QT_VERSION < 0x050000
+#ifndef QT_NO_PRINTER
+        QPrinter printer;
+        printer.setOutputFormat( QPrinter::PostScriptFormat );
+        printer.setColorMode( QPrinter::Color );
+        printer.setFullPage( true );
+        printer.setPaperSize( sizeMM, QPrinter::Millimeter );
+        printer.setDocName( title );
+        printer.setOutputFileName( fileName );
+        printer.setResolution( resolution );
+
+        QPainter painter( &printer );
+        render( plot, &painter, documentRect );
+#endif
 #endif
     }
@@ -393,12 +411,12 @@
     QPainter *painter, const QRectF &plotRect ) const
 {
-    int axisId;
-
     if ( painter == 0 || !painter->isActive() ||
             !plotRect.isValid() || plot->size().isNull() )
+    {
         return;
+    }
 
     if ( !( d_data->discardFlags & DiscardBackground ) )
-        qwtRenderBackground( painter, plotRect, plot );
+        QwtPainter::drawBackgound( painter, plotRect, plot );
 
     /*
@@ -412,10 +430,25 @@
         double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() );
 
-    painter->save();
+    QRectF layoutRect = transform.inverted().mapRect( plotRect );
+
+    if ( !( d_data->discardFlags & DiscardBackground ) )
+    {
+        // subtract the contents margins
+
+        int left, top, right, bottom;
+        plot->getContentsMargins( &left, &top, &right, &bottom );
+        layoutRect.adjust( left, top, -right, -bottom );
+    }
+
+    QwtPlotLayout *layout = plot->plotLayout();
 
     int baseLineDists[QwtPlot::axisCnt];
-    if ( d_data->layoutFlags & FrameWithScales )
-    {
-        for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+    int canvasMargins[QwtPlot::axisCnt];
+
+    for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+    {
+        canvasMargins[ axisId ] = layout->canvasMargin( axisId );
+
+        if ( d_data->layoutFlags & FrameWithScales )
         {
             QwtScaleWidget *scaleWidget = plot->axisWidget( axisId );
@@ -425,28 +458,90 @@
                 scaleWidget->setMargin( 0 );
             }
-        }
-    }
-    // Calculate the layout for the print.
-
-    QwtPlotLayout::Options layoutOptions = 
-        QwtPlotLayout::IgnoreScrollbars | QwtPlotLayout::IgnoreFrames;
+
+            if ( !plot->axisEnabled( axisId ) )
+            {
+                int left = 0;
+                int right = 0;
+                int top = 0;
+                int bottom = 0;
+
+                // When we have a scale the frame is painted on
+                // the position of the backbone - otherwise we
+                // need to introduce a margin around the canvas
+
+                switch( axisId )
+                {
+                    case QwtPlot::yLeft:
+                        layoutRect.adjust( 1, 0, 0, 0 );
+                        break;
+                    case QwtPlot::yRight:
+                        layoutRect.adjust( 0, 0, -1, 0 );
+                        break;
+                    case QwtPlot::xTop:
+                        layoutRect.adjust( 0, 1, 0, 0 );
+                        break;
+                    case QwtPlot::xBottom:
+                        layoutRect.adjust( 0, 0, 0, -1 );
+                        break;
+                    default:
+                        break;
+                }
+                layoutRect.adjust( left, top, right, bottom );
+            }
+        }
+    }
+
+    // Calculate the layout for the document.
+
+    QwtPlotLayout::Options layoutOptions = QwtPlotLayout::IgnoreScrollbars;
+
+    if ( ( d_data->layoutFlags & FrameWithScales ) ||
+        ( d_data->discardFlags & DiscardCanvasFrame ) )
+    {
+        layoutOptions |= QwtPlotLayout::IgnoreFrames;
+    } 
+
+
     if ( d_data->discardFlags & DiscardLegend )
         layoutOptions |= QwtPlotLayout::IgnoreLegend;
 
-    const QRectF layoutRect = transform.inverted().mapRect( plotRect );
-    plot->plotLayout()->activate( plot, layoutRect, layoutOptions );
-
+    if ( d_data->discardFlags & DiscardTitle )
+        layoutOptions |= QwtPlotLayout::IgnoreTitle;
+
+    if ( d_data->discardFlags & DiscardFooter )
+        layoutOptions |= QwtPlotLayout::IgnoreFooter;
+
+    layout->activate( plot, layoutRect, layoutOptions );
+
+    // canvas
+
+    QwtScaleMap maps[QwtPlot::axisCnt];
+    buildCanvasMaps( plot, layout->canvasRect(), maps );
+    if ( updateCanvasMargins( plot, layout->canvasRect(), maps ) )
+    {
+        // recalculate maps and layout, when the margins
+        // have been changed
+
+        layout->activate( plot, layoutRect, layoutOptions );
+        buildCanvasMaps( plot, layout->canvasRect(), maps );
+    }
+
+    // now start painting
+
+    painter->save();
     painter->setWorldTransform( transform, true );
 
-    // canvas
-
-    QwtScaleMap maps[QwtPlot::axisCnt];
-    buildCanvasMaps( plot, plot->plotLayout()->canvasRect(), maps );
-    renderCanvas( plot, painter, plot->plotLayout()->canvasRect(), maps );
+    renderCanvas( plot, painter, layout->canvasRect(), maps );
 
     if ( !( d_data->discardFlags & DiscardTitle )
         && ( !plot->titleLabel()->text().isEmpty() ) )
     {
-        renderTitle( plot, painter, plot->plotLayout()->titleRect() );
+        renderTitle( plot, painter, layout->titleRect() );
+    }
+
+    if ( !( d_data->discardFlags & DiscardFooter )
+        && ( !plot->footerLabel()->text().isEmpty() ) )
+    {
+        renderFooter( plot, painter, layout->footerRect() );
     }
 
@@ -454,8 +549,8 @@
         && plot->legend() && !plot->legend()->isEmpty() )
     {
-        renderLegend( plot, painter, plot->plotLayout()->legendRect() );
-    }
-
-    for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+        renderLegend( plot, painter, layout->legendRect() );
+    }
+
+    for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
     {
         QwtScaleWidget *scaleWidget = plot->axisWidget( axisId );
@@ -468,17 +563,14 @@
 
             renderScale( plot, painter, axisId, startDist, endDist,
-                baseDist, plot->plotLayout()->scaleRect( axisId ) );
-        }
-    }
-
-
-    plot->plotLayout()->invalidate();
-
-    // reset all widgets with their original attributes.
-    if ( d_data->layoutFlags & FrameWithScales )
-    {
-        // restore the previous base line dists
-
-        for ( axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+                baseDist, layout->scaleRect( axisId ) );
+        }
+    }
+
+    painter->restore();
+
+    // restore all setting to their original attributes.
+    for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+    {
+        if ( d_data->layoutFlags & FrameWithScales )
         {
             QwtScaleWidget *scaleWidget = plot->axisWidget( axisId );
@@ -486,7 +578,10 @@
                 scaleWidget->setMargin( baseLineDists[axisId] );
         }
-    }
-
-    painter->restore();
+
+        layout->setCanvasMargin( canvasMargins[axisId] );
+    }
+
+    layout->invalidate();
+
 }
 
@@ -511,5 +606,5 @@
 
 /*!
-  Render the legend into a given rectangle.
+  Render the footer into a given rectangle.
 
   \param plot Plot widget
@@ -517,94 +612,31 @@
   \param rect Bounding rectangle
 */
+void QwtPlotRenderer::renderFooter( const QwtPlot *plot,
+    QPainter *painter, const QRectF &rect ) const
+{
+    painter->setFont( plot->footerLabel()->font() );
+
+    const QColor color = plot->footerLabel()->palette().color(
+            QPalette::Active, QPalette::Text );
+
+    painter->setPen( color );
+    plot->footerLabel()->text().draw( painter, rect );
+}
+
+
+/*!
+  Render the legend into a given rectangle.
+
+  \param plot Plot widget
+  \param painter Painter
+  \param rect Bounding rectangle
+*/
 void QwtPlotRenderer::renderLegend( const QwtPlot *plot,
     QPainter *painter, const QRectF &rect ) const
 {
-    if ( !plot->legend() || plot->legend()->isEmpty() )
-        return;
-
-    if ( !( d_data->discardFlags & DiscardBackground ) )
-    {
-        if ( plot->legend()->autoFillBackground() ||
-            plot->legend()->testAttribute( Qt::WA_StyledBackground ) )
-        {
-            qwtRenderBackground( painter, rect, plot->legend() );
-        }
-    }
-
-    const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>( 
-        plot->legend()->contentsWidget()->layout() );
-    if ( legendLayout == NULL )
-        return;
-
-    uint numCols = legendLayout->columnsForWidth( rect.width() );
-    QList<QRect> itemRects =
-        legendLayout->layoutItems( rect.toRect(), numCols );
-
-    int index = 0;
-
-    for ( int i = 0; i < legendLayout->count(); i++ )
-    {
-        QLayoutItem *item = legendLayout->itemAt( i );
-        QWidget *w = item->widget();
-        if ( w )
-        {
-            painter->save();
-
-            painter->setClipRect( itemRects[index] );
-            renderLegendItem( plot, painter, w, itemRects[index] );
-
-            index++;
-            painter->restore();
-        }
-    }
-}
-
-/*!
-  Render the legend item into a given rectangle.
-
-  \param plot Plot widget
-  \param painter Painter
-  \param widget Widget representing a legend item
-  \param rect Bounding rectangle
-
-  \note When widget is not derived from QwtLegendItem renderLegendItem
-        does nothing and needs to be overloaded
-*/
-void QwtPlotRenderer::renderLegendItem( const QwtPlot *plot,
-    QPainter *painter, const QWidget *widget, const QRectF &rect ) const
-{
-    if ( !( d_data->discardFlags & DiscardBackground ) )
-    {
-        if ( widget->autoFillBackground() ||
-            widget->testAttribute( Qt::WA_StyledBackground ) )
-        {
-            qwtRenderBackground( painter, rect, widget );
-        }
-    }
-
-    const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
-    if ( item )
-    {
-        const QSize sz = item->identifierSize();
-
-        const QRectF identifierRect( rect.x() + item->margin(), 
-            rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() );
-
-        QwtLegendItemManager *itemManger = plot->legend()->find( item );
-        if ( itemManger )
-        {
-            painter->save();
-            painter->setClipRect( identifierRect, Qt::IntersectClip );
-            itemManger->drawLegendIdentifier( painter, identifierRect );
-            painter->restore();
-        }
-
-        // Label
-
-        QRectF titleRect = rect;
-        titleRect.setX( identifierRect.right() + 2 * item->spacing() );
-
-        painter->setFont( item->font() );
-        item->text().draw( painter, titleRect );
+    if ( plot->legend() )
+    {
+        bool fillBackground = !( d_data->discardFlags & DiscardBackground );
+        plot->legend()->renderLegend( painter, rect, fillBackground );
     }
 }
@@ -635,10 +667,5 @@
     {
         scaleWidget->drawColorBar( painter, scaleWidget->colorBarRect( rect ) );
-
-        const int off = scaleWidget->colorBarWidth() + scaleWidget->spacing();
-        if ( scaleWidget->scaleDraw()->orientation() == Qt::Horizontal )
-            baseDist += off;
-        else
-            baseDist += off;
+        baseDist += scaleWidget->colorBarWidth() + scaleWidget->spacing();
     }
 
@@ -720,7 +747,5 @@
     const QwtScaleMap *map ) const
 {
-    painter->save();
-
-    QPainterPath clipPath;
+    const QWidget *canvas = plot->canvas();
 
     QRectF r = canvasRect.adjusted( 0.0, 0.0, -1.0, -1.0 );
@@ -728,4 +753,6 @@
     if ( d_data->layoutFlags & FrameWithScales )
     {
+        painter->save();
+
         r.adjust( -1.0, -1.0, 1.0, 1.0 );
         painter->setPen( QPen( Qt::black ) );
@@ -734,46 +761,111 @@
         {
             const QBrush bgBrush =
-                plot->canvas()->palette().brush( plot->backgroundRole() );
+                canvas->palette().brush( plot->backgroundRole() );
             painter->setBrush( bgBrush );
         }
 
         QwtPainter::drawRect( painter, r );
+
+        painter->restore();
+        painter->save();
+
+        painter->setClipRect( canvasRect );
+        plot->drawItems( painter, canvasRect, map );
+
+        painter->restore();
+    }
+    else if ( canvas->testAttribute( Qt::WA_StyledBackground ) )
+    {
+        QPainterPath clipPath;
+
+        painter->save();
+
+        if ( !( d_data->discardFlags & DiscardCanvasBackground ) )
+        {
+            QwtPainter::drawBackgound( painter, r, canvas );
+            clipPath = qwtCanvasClip( canvas, canvasRect );
+        }
+
+        painter->restore();
+        painter->save();
+
+        if ( clipPath.isEmpty() )
+            painter->setClipRect( canvasRect );
+        else
+            painter->setClipPath( clipPath );
+
+        plot->drawItems( painter, canvasRect, map );
+
+        painter->restore();
     }
     else
     {
+        QPainterPath clipPath;
+
+        int frameWidth = 0;
+
+        if ( !( d_data->discardFlags & DiscardCanvasFrame ) )
+        {
+            const QVariant fw = canvas->property( "frameWidth" );
+            if ( fw.type() == QVariant::Int )
+                frameWidth = fw.toInt();
+
+            clipPath = qwtCanvasClip( canvas, canvasRect );
+        }
+
+        QRectF innerRect = canvasRect.adjusted( 
+            frameWidth, frameWidth, -frameWidth, -frameWidth );
+
+        painter->save();
+
+        if ( clipPath.isEmpty() )
+        {
+            painter->setClipRect( innerRect );
+        }
+        else
+        {
+            painter->setClipPath( clipPath );
+        }
+
         if ( !( d_data->discardFlags & DiscardCanvasBackground ) )
         {
-            qwtRenderBackground( painter, r, plot->canvas() );
-
-            if ( plot->canvas()->testAttribute( Qt::WA_StyledBackground ) )
+            QwtPainter::drawBackgound( painter, innerRect, canvas );
+        }
+
+        plot->drawItems( painter, innerRect, map );
+
+        painter->restore();
+
+        if ( frameWidth > 0 )
+        {
+            painter->save();
+
+            const int frameStyle =
+                canvas->property( "frameShadow" ).toInt() |
+                canvas->property( "frameShape" ).toInt();
+
+            const int frameWidth = canvas->property( "frameWidth" ).toInt();
+
+
+            const QVariant borderRadius = canvas->property( "borderRadius" );
+            if ( borderRadius.type() == QVariant::Double 
+                && borderRadius.toDouble() > 0.0 )
             {
-                // The clip region is calculated in integers
-                // To avoid too much rounding errors better
-                // calculate it in target device resolution
-                // TODO ...
-
-                int x1 = qCeil( canvasRect.left() );
-                int x2 = qFloor( canvasRect.right() );
-                int y1 = qCeil( canvasRect.top() );
-                int y2 = qFloor( canvasRect.bottom() );
-
-                clipPath = plot->canvas()->borderPath( 
-                    QRect( x1, y1, x2 - x1 - 1, y2 - y1 - 1 ) );
+                const double r = borderRadius.toDouble();
+
+                QwtPainter::drawRoundedFrame( painter, canvasRect,
+                    r, r, canvas->palette(), frameWidth, frameStyle );
             }
-        }
-    }
-
-    painter->restore();
-
-    painter->save();
-
-    if ( clipPath.isEmpty() )
-        painter->setClipRect( canvasRect );
-    else
-        painter->setClipPath( clipPath );
-
-    plot->drawItems( painter, canvasRect, map );
-
-    painter->restore();
+            else
+            {
+                const int midLineWidth = canvas->property( "midLineWidth" ).toInt();
+
+                QwtPainter::drawFrame( painter, canvasRect,
+                    canvas->palette(), canvas->foregroundRole(),
+                    frameWidth, midLineWidth, frameStyle );
+            }
+            painter->restore();
+        }
+    }
 }
 
@@ -793,5 +885,5 @@
             plot->axisScaleEngine( axisId )->transformation() );
 
-        const QwtScaleDiv &scaleDiv = *plot->axisScaleDiv( axisId );
+        const QwtScaleDiv &scaleDiv = plot->axisScaleDiv( axisId );
         maps[axisId].setScaleInterval(
             scaleDiv.lowerBound(), scaleDiv.upperBound() );
@@ -802,5 +894,5 @@
             const int sDist = plot->axisWidget( axisId )->startBorderDist();
             const int eDist = plot->axisWidget( axisId )->endBorderDist();
-            const QRectF &scaleRect = plot->plotLayout()->scaleRect( axisId );
+            const QRectF scaleRect = plot->plotLayout()->scaleRect( axisId );
 
             if ( axisId == QwtPlot::xTop || axisId == QwtPlot::xBottom )
@@ -817,5 +909,8 @@
         else
         {
-            int margin = plot->plotLayout()->canvasMargin( axisId );
+            int margin = 0;
+            if ( !plot->plotLayout()->alignCanvasToScale( axisId ) )
+                margin = plot->plotLayout()->canvasMargin( axisId );
+
             if ( axisId == QwtPlot::yLeft || axisId == QwtPlot::yRight )
             {
@@ -832,2 +927,88 @@
     }
 }
+
+bool QwtPlotRenderer::updateCanvasMargins( QwtPlot *plot,
+    const QRectF &canvasRect, const QwtScaleMap maps[] ) const
+{
+    double margins[QwtPlot::axisCnt];
+    plot->getCanvasMarginsHint( maps, canvasRect,
+        margins[QwtPlot::yLeft], margins[QwtPlot::xTop], 
+        margins[QwtPlot::yRight], margins[QwtPlot::xBottom] );
+
+    bool marginsChanged = false;
+    for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
+    {
+        if ( margins[axisId] >= 0.0 )
+        {
+            const int m = qCeil( margins[axisId] );
+            plot->plotLayout()->setCanvasMargin( m, axisId);
+            marginsChanged = true;
+        }
+    }
+
+    return marginsChanged;
+}
+
+/*!
+   \brief Execute a file dialog and render the plot to the selected file
+
+   \param plot Plot widget
+   \param documentName Default document name
+   \param sizeMM Size for the document in millimeters.
+   \param resolution Resolution in dots per Inch (dpi)
+
+   \return True, when exporting was successful
+   \sa renderDocument()
+*/
+bool QwtPlotRenderer::exportTo( QwtPlot *plot, const QString &documentName,
+     const QSizeF &sizeMM, int resolution )
+{       
+    if ( plot == NULL )
+        return false;
+    
+    QString fileName = documentName;
+
+    // What about translation 
+
+#ifndef QT_NO_FILEDIALOG
+    const QList<QByteArray> imageFormats =
+        QImageWriter::supportedImageFormats();
+        
+    QStringList filter;
+#ifndef QT_NO_PRINTER
+    filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)";
+#endif
+#ifndef QWT_NO_SVG 
+    filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)";
+#endif
+#ifndef QT_NO_PRINTER
+    filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)";
+#endif
+    
+    if ( imageFormats.size() > 0 )
+    {
+        QString imageFilter( tr( "Images" ) );
+        imageFilter += " (";
+        for ( int i = 0; i < imageFormats.size(); i++ )
+        {
+            if ( i > 0 )
+                imageFilter += " ";
+            imageFilter += "*."; 
+            imageFilter += imageFormats[i];
+        }   
+        imageFilter += ")";
+        
+        filter += imageFilter;
+    }   
+    
+    fileName = QFileDialog::getSaveFileName(
+        NULL, tr( "Export File Name" ), fileName,
+        filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite );
+#endif  
+    if ( fileName.isEmpty() )
+        return false;
+
+    renderDocument( plot, fileName, sizeMM, resolution );
+
+    return true;
+}   
Index: trunk/BNC/qwt/qwt_plot_renderer.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_renderer.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_renderer.h	(revision 8127)
@@ -13,8 +13,8 @@
 #include "qwt_global.h"
 #include <qobject.h>
+#include <qsize.h>
 
 class QwtPlot;
 class QwtScaleMap;
-class QSizeF;
 class QRectF;
 class QPainter;
@@ -56,5 +56,18 @@
 
         //! Don't render the background of the canvas
-        DiscardCanvasBackground = 0x08
+        DiscardCanvasBackground = 0x08,
+
+        //! Don't render the footer of the plot
+        DiscardFooter           = 0x10,
+
+        /*! 
+            Don't render the frame of the canvas
+
+            \note This flag has no effect when using
+                  style sheets, where the frame is part
+                  of the background
+         */
+        DiscardCanvasFrame           = 0x20
+
     };
 
@@ -68,9 +81,6 @@
     enum LayoutFlag
     {
-        //! Use the default layout without margins and frames
+        //! Use the default layout as on screen
         DefaultLayout   = 0x00,
-
-        //! Render all frames of the plot
-        KeepFrames      = 0x01,
 
         /*!
@@ -78,5 +88,5 @@
           where the scale ticks are aligned to.
          */
-        FrameWithScales = 0x02
+        FrameWithScales = 0x01
     };
 
@@ -99,9 +109,9 @@
     LayoutFlags layoutFlags() const;
 
-    void renderDocument( QwtPlot *, const QString &format,
+    void renderDocument( QwtPlot *, const QString &fileName,
         const QSizeF &sizeMM, int resolution = 85 );
 
     void renderDocument( QwtPlot *,
-        const QString &title, const QString &format,
+        const QString &fileName, const QString &format,
         const QSizeF &sizeMM, int resolution = 85 );
 
@@ -123,8 +133,8 @@
         QPainter *, const QRectF &rect ) const;
 
-    virtual void renderLegendItem( const QwtPlot *, 
-        QPainter *, const QWidget *, const QRectF & ) const;
+    virtual void renderTitle( const QwtPlot *,
+        QPainter *, const QRectF & ) const;
 
-    virtual void renderTitle( const QwtPlot *,
+    virtual void renderFooter( const QwtPlot *,
         QPainter *, const QRectF & ) const;
 
@@ -140,7 +150,13 @@
         const QwtPlot *, QPainter *, const QRectF & ) const;
 
-protected:
+    bool exportTo( QwtPlot *, const QString &documentName,
+        const QSizeF &sizeMM = QSizeF( 300, 200 ), int resolution = 85 );
+
+private:
     void buildCanvasMaps( const QwtPlot *,
         const QRectF &, QwtScaleMap maps[] ) const;
+
+    bool updateCanvasMargins( QwtPlot *,
+        const QRectF &, const QwtScaleMap maps[] ) const;
 
 private:
Index: trunk/BNC/qwt/qwt_plot_rescaler.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_rescaler.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_rescaler.cpp	(revision 8127)
@@ -10,7 +10,7 @@
 #include "qwt_plot_rescaler.h"
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_scale_div.h"
 #include "qwt_interval.h"
+#include "qwt_plot_canvas.h"
 #include <qevent.h>
 #include <qalgorithms.h>
@@ -59,5 +59,5 @@
    \sa setRescalePolicy(), setReferenceAxis()
 */
-QwtPlotRescaler::QwtPlotRescaler( QwtPlotCanvas *canvas,
+QwtPlotRescaler::QwtPlotRescaler( QWidget *canvas,
         int referenceAxis, RescalePolicy policy ):
     QObject( canvas )
@@ -179,5 +179,5 @@
 
 /*!
-  Return direction in which an axis should be expanded
+  \return Direction in which an axis should be expanded
 
   \param axis Axis index ( see QwtPlot::AxisId )
@@ -224,5 +224,5 @@
 
 /*!
-  Return aspect ratio between an axis and the reference axis.
+  \return Aspect ratio between an axis and the reference axis.
 
   \param axis Axis index ( see QwtPlot::AxisId )
@@ -241,5 +241,5 @@
 
   In Fitting mode, the hint is used as minimal interval
-  taht always needs to be displayed.
+  that always needs to be displayed.
 
   \param axis Axis, see QwtPlot::Axis
@@ -268,13 +268,13 @@
 
 //! \return plot canvas
-QwtPlotCanvas *QwtPlotRescaler::canvas()
-{
-    return qobject_cast<QwtPlotCanvas *>( parent() );
+QWidget *QwtPlotRescaler::canvas()
+{
+    return qobject_cast<QWidget *>( parent() );
 }
 
 //! \return plot canvas
-const QwtPlotCanvas *QwtPlotRescaler::canvas() const
-{
-    return qobject_cast<const QwtPlotCanvas *>( parent() );
+const QWidget *QwtPlotRescaler::canvas() const
+{
+    return qobject_cast<const QWidget *>( parent() );
 }
 
@@ -282,9 +282,9 @@
 QwtPlot *QwtPlotRescaler::plot()
 {
-    QwtPlotCanvas *w = canvas();
+    QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
+        w = w->parentWidget();
+
+    return qobject_cast<QwtPlot *>( w );
 }
 
@@ -292,24 +292,28 @@
 const QwtPlot *QwtPlotRescaler::plot() const
 {
-    const QwtPlotCanvas *w = canvas();
+    const QWidget *w = canvas();
     if ( w )
-        return w->plot();
-
-    return NULL;
+        w = w->parentWidget();
+
+    return qobject_cast<const QwtPlot *>( w );
 }
 
 //!  Event filter for the plot canvas
-bool QwtPlotRescaler::eventFilter( QObject *o, QEvent *e )
-{
-    if ( o && o == canvas() )
-    {
-        switch ( e->type() )
+bool QwtPlotRescaler::eventFilter( QObject *object, QEvent *event )
+{
+    if ( object && object == canvas() )
+    {
+        switch ( event->type() )
         {
             case QEvent::Resize:
-                canvasResizeEvent( ( QResizeEvent * )e );
+            {
+                canvasResizeEvent( static_cast<QResizeEvent *>( event ) );
                 break;
+            }
             case QEvent::PolishRequest:
+            {
                 rescale();
                 break;
+            }
             default:;
         }
@@ -327,7 +331,11 @@
 void QwtPlotRescaler::canvasResizeEvent( QResizeEvent* event )
 {
-    const int fw = 2 * canvas()->frameWidth();
-    const QSize newSize = event->size() - QSize( fw, fw );
-    const QSize oldSize = event->oldSize() - QSize( fw, fw );
+    int left, top, right, bottom;
+    canvas()->getContentsMargins( &left, &top, &right, &bottom );
+
+    const QSize marginSize( left + right, top + bottom );
+
+    const QSize newSize = event->size() - marginSize;
+    const QSize oldSize = event->oldSize() - marginSize;
 
     rescale( oldSize, newSize );
@@ -433,9 +441,11 @@
 
 /*!
-   Synchronize an axis scale according to the scale of the reference axis
+  Synchronize an axis scale according to the scale of the reference axis
 
   \param axis Axis index ( see QwtPlot::AxisId )
   \param reference Interval of the reference axis
   \param size Size of the canvas
+
+  \return New interval for axis
 */
 QwtInterval QwtPlotRescaler::syncScale( int axis,
@@ -467,5 +477,5 @@
 
 /*!
-  Return orientation of an axis
+  \return Orientation of an axis
   \param axis Axis index ( see QwtPlot::AxisId )
 */
@@ -479,6 +489,6 @@
 
 /*!
-  Return interval of an axis
-  \param axis Axis index ( see QwtPlot::AxisId )
+  \param axis Axis index ( see QwtPlot::AxisId )
+  \return Normalized interval of an axis
 */
 QwtInterval QwtPlotRescaler::interval( int axis ) const
@@ -487,10 +497,5 @@
         return QwtInterval();
 
-    const QwtPlot *plt = plot();
-
-    const double v1 = plt->axisScaleDiv( axis )->lowerBound();
-    const double v2 = plt->axisScaleDiv( axis )->upperBound();
-
-    return QwtInterval( v1, v2 ).normalized();
+    return plot()->axisScaleDiv( axis ).interval().normalized();
 }
 
@@ -584,14 +589,9 @@
             double v2 = intervals[axis].maxValue();
 
-            if ( plt->axisScaleDiv( axis )->lowerBound() >
-                plt->axisScaleDiv( axis )->upperBound() )
-            {
+            if ( !plt->axisScaleDiv( axis ).isIncreasing() )
                 qSwap( v1, v2 );
-            }
 
             if ( d_data->inReplot >= 1 )
-            {
-                d_data->axisData[axis].scaleDiv = *plt->axisScaleDiv( axis );
-            }
+                d_data->axisData[axis].scaleDiv = plt->axisScaleDiv( axis );
 
             if ( d_data->inReplot >= 2 )
@@ -610,7 +610,12 @@
     }
 
-    const bool immediatePaint = 
-        plt->canvas()->testPaintAttribute( QwtPlotCanvas::ImmediatePaint );
-    plt->canvas()->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false );
+    QwtPlotCanvas *canvas = qobject_cast<QwtPlotCanvas *>( plt->canvas() );
+
+    bool immediatePaint = false;
+    if ( canvas )
+    {
+        immediatePaint = canvas->testPaintAttribute( QwtPlotCanvas::ImmediatePaint );
+        canvas->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, false );
+    }
 
     plt->setAutoReplot( doReplot );
@@ -620,5 +625,7 @@
     d_data->inReplot--;
 
-    plt->canvas()->setPaintAttribute( 
-        QwtPlotCanvas::ImmediatePaint, immediatePaint );
-}
+    if ( canvas && immediatePaint )
+    {
+        canvas->setPaintAttribute( QwtPlotCanvas::ImmediatePaint, true );
+    }
+}
Index: trunk/BNC/qwt/qwt_plot_rescaler.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_rescaler.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_rescaler.h	(revision 8127)
@@ -16,5 +16,4 @@
 #include <qobject.h>
 
-class QwtPlotCanvas;
 class QwtPlot;
 class QResizeEvent;
@@ -23,5 +22,5 @@
     \brief QwtPlotRescaler takes care of fixed aspect ratios for plot scales
 
-    QwtPlotRescaler autoadjusts the axes of a QwtPlot according
+    QwtPlotRescaler auto adjusts the axes of a QwtPlot according
     to fixed aspect ratios.
 */
@@ -46,5 +45,5 @@
 
         /*!
-          The interval of the reference axis will be shrinked/expanded,
+          The interval of the reference axis will be shrunk/expanded,
           when the geometry of the canvas changes. All other axes
           will be adjusted according to their aspect ratio.
@@ -78,5 +77,5 @@
     };
 
-    explicit QwtPlotRescaler( QwtPlotCanvas *,
+    explicit QwtPlotRescaler( QWidget *canvas,
         int referenceAxis = QwtPlot::xBottom,
         RescalePolicy = Expanding );
@@ -104,6 +103,6 @@
     QwtInterval intervalHint( int axis ) const;
 
-    QwtPlotCanvas *canvas();
-    const QwtPlotCanvas *canvas() const;
+    QWidget *canvas();
+    const QWidget *canvas() const;
 
     QwtPlot *plot();
Index: trunk/BNC/qwt/qwt_plot_scaleitem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_scaleitem.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_scaleitem.cpp	(revision 8127)
@@ -10,5 +10,4 @@
 #include "qwt_plot_scaleitem.h"
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_scale_map.h"
 #include "qwt_interval.h"
@@ -32,6 +31,6 @@
     }
 
-    void updateBorders( const QRectF &,
-        const QwtScaleMap &, const QwtScaleMap & );
+    QwtInterval scaleInterval( const QRectF &,
+        const QwtScaleMap &, const QwtScaleMap & ) const;
 
     QPalette palette;
@@ -41,12 +40,9 @@
     bool scaleDivFromAxis;
     QwtScaleDraw *scaleDraw;
-    QRectF canvasRectCache;
 };
 
-void QwtPlotScaleItem::PrivateData::updateBorders( const QRectF &canvasRect,
-    const QwtScaleMap &xMap, const QwtScaleMap &yMap )
-{
-    canvasRectCache = canvasRect;
-
+QwtInterval QwtPlotScaleItem::PrivateData::scaleInterval( const QRectF &canvasRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap ) const
+{
     QwtInterval interval;
     if ( scaleDraw->orientation() == Qt::Horizontal )
@@ -61,8 +57,7 @@
     }
 
-    QwtScaleDiv scaleDiv = scaleDraw->scaleDiv();
-    scaleDiv.setInterval( interval );
-    scaleDraw->setScaleDiv( scaleDiv );
-}
+    return interval;
+}
+
 /*!
    \brief Constructor for scale item at the position pos.
@@ -84,4 +79,5 @@
     d_data->scaleDraw->setAlignment( alignment );
 
+    setItemInterest( QwtPlotItem::ScaleInterest, true );
     setZ( 11.0 );
 }
@@ -137,6 +133,6 @@
             if ( plt )
             {
-                updateScaleDiv( *plt->axisScaleDiv( xAxis() ),
-                    *plt->axisScaleDiv( yAxis() ) );
+                updateScaleDiv( plt->axisScaleDiv( xAxis() ),
+                    plt->axisScaleDiv( yAxis() ) );
                 itemChanged();
             }
@@ -164,4 +160,6 @@
     {
         d_data->palette = palette;
+
+        legendChanged();
         itemChanged();
     }
@@ -223,6 +221,6 @@
     if ( plt )
     {
-        updateScaleDiv( *plt->axisScaleDiv( xAxis() ),
-            *plt->axisScaleDiv( yAxis() ) );
+        updateScaleDiv( plt->axisScaleDiv( xAxis() ),
+            plt->axisScaleDiv( yAxis() ) );
     }
 
@@ -282,5 +280,5 @@
 
    If distance is >= 0 the scale will be aligned to a
-   border of the contents rect of the canvas. If
+   border of the contents rectangle of the canvas. If
    alignment() is QwtScaleDraw::LeftScale, the scale will
    be aligned to the right border, if it is QwtScaleDraw::TopScale
@@ -348,8 +346,17 @@
     const QRectF &canvasRect ) const
 {
+    QwtScaleDraw *sd = d_data->scaleDraw;
+
     if ( d_data->scaleDivFromAxis )
     {
-        if ( canvasRect != d_data->canvasRectCache )
-            d_data->updateBorders( canvasRect, xMap, yMap );
+        const QwtInterval interval = 
+            d_data->scaleInterval( canvasRect, xMap, yMap );
+
+        if ( interval != sd->scaleDiv().interval() )
+        {
+            QwtScaleDiv scaleDiv = sd->scaleDiv();
+            scaleDiv.setInterval( interval );
+            sd->setScaleDiv( scaleDiv );
+        }
     }
 
@@ -358,5 +365,4 @@
     painter->setPen( pen );
 
-    QwtScaleDraw *sd = d_data->scaleDraw;
     if ( sd->orientation() == Qt::Horizontal )
     {
@@ -382,5 +388,10 @@
         sd->move( canvasRect.left(), y );
         sd->setLength( canvasRect.width() - 1 );
-        sd->setTransformation( xMap.transformation()->copy() );
+
+        QwtTransform *transform = NULL;
+        if ( xMap.transformation() )
+            transform = xMap.transformation()->copy();
+
+        sd->setTransformation( transform );
     }
     else // == Qt::Vertical
@@ -405,5 +416,10 @@
         sd->move( x, canvasRect.top() );
         sd->setLength( canvasRect.height() - 1 );
-        sd->setTransformation( yMap.transformation()->copy() );
+
+        QwtTransform *transform = NULL;
+        if ( yMap.transformation() )
+            transform = yMap.transformation()->copy();
+
+        sd->setTransformation( transform );
     }
 
@@ -428,16 +444,35 @@
     const QwtScaleDiv& yScaleDiv )
 {
-    QwtScaleDraw *sd = d_data->scaleDraw;
-    if ( d_data->scaleDivFromAxis && sd )
-    {
-        sd->setScaleDiv(
-            sd->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv );
+    QwtScaleDraw *scaleDraw = d_data->scaleDraw;
+
+    if ( d_data->scaleDivFromAxis && scaleDraw )
+    {
+        const QwtScaleDiv &scaleDiv = 
+            scaleDraw->orientation() == Qt::Horizontal ? xScaleDiv : yScaleDiv;
 
         const QwtPlot *plt = plot();
         if ( plt != NULL )
         {
-            d_data->updateBorders( plt->canvas()->contentsRect(),
-                plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) );
-        }
-    }
-}
+            const QRectF canvasRect = plt->canvas()->contentsRect();
+
+            const QwtInterval interval = d_data->scaleInterval( 
+                canvasRect, plt->canvasMap( xAxis() ), plt->canvasMap( yAxis() ) );
+
+            QwtScaleDiv sd = scaleDiv;
+            sd.setInterval( interval );
+
+            if ( sd != scaleDraw->scaleDiv() )
+            {
+                // the internal label cache of QwtScaleDraw
+                // is cleared here, so better avoid pointless
+                // assignments.
+
+                scaleDraw->setScaleDiv( sd );
+            }
+        }
+        else
+        {
+            scaleDraw->setScaleDiv( scaleDiv );
+        }
+    }
+}
Index: trunk/BNC/qwt/qwt_plot_seriesitem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_seriesitem.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_seriesitem.cpp	(revision 8127)
@@ -10,5 +10,5 @@
 #include "qwt_plot_seriesitem.h"
 
-class QwtPlotAbstractSeriesItem::PrivateData
+class QwtPlotSeriesItem::PrivateData
 {
 public:
@@ -25,8 +25,9 @@
   \param title Title of the curve
 */
-QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QwtText &title ):
+QwtPlotSeriesItem::QwtPlotSeriesItem( const QwtText &title ):
     QwtPlotItem( title )
 {
     d_data = new PrivateData();
+    setItemInterest( QwtPlotItem::ScaleInterest, true );
 }
 
@@ -35,5 +36,5 @@
   \param title Title of the curve
 */
-QwtPlotAbstractSeriesItem::QwtPlotAbstractSeriesItem( const QString &title ):
+QwtPlotSeriesItem::QwtPlotSeriesItem( const QString &title ):
     QwtPlotItem( QwtText( title ) )
 {
@@ -42,5 +43,5 @@
 
 //! Destructor
-QwtPlotAbstractSeriesItem::~QwtPlotAbstractSeriesItem()
+QwtPlotSeriesItem::~QwtPlotSeriesItem()
 {
     delete d_data;
@@ -56,9 +57,11 @@
   \sa orientation()
 */
-void QwtPlotAbstractSeriesItem::setOrientation( Qt::Orientation orientation )
+void QwtPlotSeriesItem::setOrientation( Qt::Orientation orientation )
 {
     if ( d_data->orientation != orientation )
     {
         d_data->orientation = orientation;
+
+        legendChanged();
         itemChanged();
     }
@@ -69,5 +72,5 @@
   \sa setOrientation()
 */
-Qt::Orientation QwtPlotAbstractSeriesItem::orientation() const
+Qt::Orientation QwtPlotSeriesItem::orientation() const
 {
     return d_data->orientation;
@@ -80,7 +83,7 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
 */
-void QwtPlotAbstractSeriesItem::draw( QPainter *painter,
+void QwtPlotSeriesItem::draw( QPainter *painter,
         const QwtScaleMap &xMap, const QwtScaleMap &yMap,
         const QRectF &canvasRect ) const
@@ -89,2 +92,21 @@
 }
 
+QRectF QwtPlotSeriesItem::boundingRect() const
+{
+    return dataRect();
+}
+
+void QwtPlotSeriesItem::updateScaleDiv(
+    const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv )
+{   
+    const QRectF rect = QRectF(
+        xScaleDiv.lowerBound(), yScaleDiv.lowerBound(),
+        xScaleDiv.range(), yScaleDiv.range() );
+        
+    setRectOfInterest( rect );
+}   
+
+void QwtPlotSeriesItem::dataChanged()
+{
+    itemChanged();
+}
Index: trunk/BNC/qwt/qwt_plot_seriesitem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_seriesitem.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_seriesitem.h	(revision 8127)
@@ -15,15 +15,17 @@
 #include "qwt_scale_div.h"
 #include "qwt_series_data.h"
+#include "qwt_series_store.h"
 
 /*!
   \brief Base class for plot items representing a series of samples
 */
-class QWT_EXPORT QwtPlotAbstractSeriesItem: public QwtPlotItem
+class QWT_EXPORT QwtPlotSeriesItem: public QwtPlotItem,
+    public virtual QwtAbstractSeriesStore
 {
 public:
-    explicit QwtPlotAbstractSeriesItem( const QString &title = QString::null );
-    explicit QwtPlotAbstractSeriesItem( const QwtText &title );
+    explicit QwtPlotSeriesItem( const QString &title = QString::null );
+    explicit QwtPlotSeriesItem( const QwtText &title );
 
-    virtual ~QwtPlotAbstractSeriesItem();
+    virtual ~QwtPlotSeriesItem();
 
     void setOrientation( Qt::Orientation );
@@ -40,5 +42,5 @@
       \param xMap Maps x-values into pixel coordinates.
       \param yMap Maps y-values into pixel coordinates.
-      \param canvasRect Contents rect of the canvas
+      \param canvasRect Contents rectangle 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
@@ -49,4 +51,12 @@
         const QRectF &canvasRect, int from, int to ) const = 0;
 
+    virtual QRectF boundingRect() const;
+
+    virtual void updateScaleDiv( 
+        const QwtScaleDiv &, const QwtScaleDiv & );
+
+protected:
+    virtual void dataChanged();
+
 private:
     class PrivateData;
@@ -54,150 +64,3 @@
 };
 
-/*!
-  \brief Class template for plot items representing a series of samples
-*/
-template <typename T>
-class QwtPlotSeriesItem: public QwtPlotAbstractSeriesItem
-{
-public:
-    explicit QwtPlotSeriesItem<T>( const QString &title = QString::null );
-    explicit QwtPlotSeriesItem<T>( const QwtText &title );
-
-    virtual ~QwtPlotSeriesItem<T>();
-
-    void setData( QwtSeriesData<T> * );
-
-    QwtSeriesData<T> *data();
-    const QwtSeriesData<T> *data() const;
-
-    size_t dataSize() const;
-    T sample( int index ) const;
-
-    virtual QRectF boundingRect() const;
-    virtual void updateScaleDiv( const QwtScaleDiv &,
-                                 const QwtScaleDiv & );
-
-protected:
-    //! Series
-    QwtSeriesData<T> *d_series;
-};
-
-/*!
-  Constructor
-  \param title Title of the series item
-*/
-template <typename T>
-QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QString &title ):
-    QwtPlotAbstractSeriesItem( QwtText( title ) ),
-    d_series( NULL )
-{
-}
-
-/*!
-  Constructor
-  \param title Title of the series item
-*/
-template <typename T>
-QwtPlotSeriesItem<T>::QwtPlotSeriesItem( const QwtText &title ):
-    QwtPlotAbstractSeriesItem( title ),
-    d_series( NULL )
-{
-}
-
-//! Destructor
-template <typename T>
-QwtPlotSeriesItem<T>::~QwtPlotSeriesItem()
-{
-    delete d_series;
-}
-
-//! \return the the curve data
-template <typename T>
-inline QwtSeriesData<T> *QwtPlotSeriesItem<T>::data()
-{
-    return d_series;
-}
-
-//! \return the the curve data
-template <typename T>
-inline const QwtSeriesData<T> *QwtPlotSeriesItem<T>::data() const
-{
-    return d_series;
-}
-
-/*!
-    \param index Index
-    \return Sample at position index
-*/
-template <typename T>
-inline T QwtPlotSeriesItem<T>::sample( int index ) const
-{
-    return d_series ? d_series->sample( index ) : T();
-}
-
-/*!
-  Assign a series of samples
-
-  \param data Data
-  \warning The item takes ownership of the data object, deleting
-           it when its not used anymore.
-*/
-template <typename T>
-void QwtPlotSeriesItem<T>::setData( QwtSeriesData<T> *data )
-{
-    if ( d_series != data )
-    {
-        delete d_series;
-        d_series = data;
-        itemChanged();
-    }
-}
-
-/*!
-  Return the size of the data arrays
-  \sa setData()
-*/
-template <typename T>
-size_t QwtPlotSeriesItem<T>::dataSize() const
-{
-    if ( d_series == NULL )
-        return 0;
-
-    return d_series->size();
-}
-
-/*!
-  \return Bounding rectangle of the data.
-  If there is no bounding rect, like for empty data the rectangle is invalid.
-
-  \sa QwtSeriesData<T>::boundingRect(), QRectF::isValid()
-*/
-template <typename T>
-QRectF QwtPlotSeriesItem<T>::boundingRect() const
-{
-    if ( d_series == NULL )
-        return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
-
-    return d_series->boundingRect();
-}
-
-/*!
-   Update the rect of interest according to the current scale ranges
-
-   \param xScaleDiv Scale division of the x-axis
-   \param yScaleDiv Scale division of the y-axis
-
-   \sa QwtSeriesData<T>::setRectOfInterest()
-*/
-template <typename T>
-void QwtPlotSeriesItem<T>::updateScaleDiv( 
-    const QwtScaleDiv &xScaleDiv, const QwtScaleDiv &yScaleDiv )
-{
-    const QRectF rect = QRectF(
-        xScaleDiv.lowerBound(), yScaleDiv.lowerBound(),
-        xScaleDiv.range(), yScaleDiv.range() );
-
-    d_series->setRectOfInterest( rect );
-}
-
 #endif
Index: trunk/BNC/qwt/qwt_plot_shapeitem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_shapeitem.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_shapeitem.cpp	(revision 8127)
@@ -0,0 +1,497 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_shapeitem.h"
+#include "qwt_scale_map.h"
+#include "qwt_painter.h"
+#include "qwt_curve_fitter.h"
+#include "qwt_clipper.h"
+
+static QPainterPath qwtTransformPath( const QwtScaleMap &xMap,
+        const QwtScaleMap &yMap, const QPainterPath &path, bool doAlign )
+{
+    QPainterPath shape;
+    shape.setFillRule( path.fillRule() );
+
+    for ( int i = 0; i < path.elementCount(); i++ )
+    {
+        const QPainterPath::Element &element = path.elementAt( i );
+
+        double x = xMap.transform( element.x );
+        double y = yMap.transform( element.y );
+
+        switch( element.type )
+        {
+            case QPainterPath::MoveToElement:
+            {
+                if ( doAlign )
+                {
+                    x = qRound( x );
+                    y = qRound( y );
+                }
+
+                shape.moveTo( x, y );
+                break;
+            }
+            case QPainterPath::LineToElement:
+            {
+                if ( doAlign )
+                {
+                    x = qRound( x );
+                    y = qRound( y );
+                }
+
+                shape.lineTo( x, y );
+                break;
+            }
+            case QPainterPath::CurveToElement:
+            {
+                const QPainterPath::Element& element1 = path.elementAt( ++i );
+                const double x1 = xMap.transform( element1.x );
+                const double y1 = yMap.transform( element1.y );
+
+                const QPainterPath::Element& element2 = path.elementAt( ++i );
+                const double x2 = xMap.transform( element2.x );
+                const double y2 = yMap.transform( element2.y );
+
+                shape.cubicTo( x, y, x1, y1, x2, y2 );
+                break;
+            }
+            case QPainterPath::CurveToDataElement:
+            {
+                break;
+            }
+        }
+    }
+
+    return shape;
+}
+
+
+class QwtPlotShapeItem::PrivateData
+{
+public:
+    PrivateData():
+        legendMode( QwtPlotShapeItem::LegendColor ),
+        renderTolerance( 0.0 )
+    {
+    }
+
+    QwtPlotShapeItem::PaintAttributes paintAttributes;
+    QwtPlotShapeItem::LegendMode legendMode;
+
+    double renderTolerance;
+    QRectF boundingRect;
+
+    QPen pen;
+    QBrush brush;
+    QPainterPath shape;
+};
+
+/*!
+   \brief Constructor
+
+   Sets the following item attributes:
+   - QwtPlotItem::AutoScale: true
+   - QwtPlotItem::Legend:    false
+
+   \param title Title
+*/
+QwtPlotShapeItem::QwtPlotShapeItem( const QString& title ):
+    QwtPlotItem( QwtText( title ) )
+{
+    init();
+}
+
+/*!
+   \brief Constructor
+
+   Sets the following item attributes:
+   - QwtPlotItem::AutoScale: true
+   - QwtPlotItem::Legend:    false
+
+   \param title Title
+*/
+QwtPlotShapeItem::QwtPlotShapeItem( const QwtText& title ):
+    QwtPlotItem( title )
+{
+    init();
+}
+
+//! Destructor
+QwtPlotShapeItem::~QwtPlotShapeItem()
+{
+    delete d_data;
+}
+
+void QwtPlotShapeItem::init()
+{
+    d_data = new PrivateData();
+    d_data->boundingRect = QwtPlotItem::boundingRect();
+
+    setItemAttribute( QwtPlotItem::AutoScale, true );
+    setItemAttribute( QwtPlotItem::Legend, false );
+
+    setZ( 8.0 );
+}
+
+//! \return QwtPlotItem::Rtti_PlotShape
+int QwtPlotShapeItem::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotShape;
+}
+
+/*!
+  Specify an attribute how to draw the shape
+
+  \param attribute Paint attribute
+  \param on On/Off
+  \sa testPaintAttribute()
+*/
+void QwtPlotShapeItem::setPaintAttribute( PaintAttribute attribute, bool on )
+{
+    if ( on )
+        d_data->paintAttributes |= attribute;
+    else
+        d_data->paintAttributes &= ~attribute;
+}
+
+/*!
+  \return True, when attribute is enabled
+  \sa setPaintAttribute()
+*/
+bool QwtPlotShapeItem::testPaintAttribute( PaintAttribute attribute ) const
+{
+    return ( d_data->paintAttributes & attribute );
+}
+
+/*!
+  Set the mode how to represent the item on the legend
+
+  \param mode Mode
+  \sa legendMode()
+ */
+void QwtPlotShapeItem::setLegendMode( LegendMode mode )
+{
+    if ( mode != d_data->legendMode )
+    {
+        d_data->legendMode = mode;
+        legendChanged();
+    }
+}
+
+/*!
+  \return Mode how to represent the item on the legend
+  \sa legendMode()
+ */
+QwtPlotShapeItem::LegendMode QwtPlotShapeItem::legendMode() const
+{
+    return d_data->legendMode;
+}
+
+//! Bounding rectangle of the shape
+QRectF QwtPlotShapeItem::boundingRect() const
+{
+    return d_data->boundingRect;
+}
+
+/*!
+  \brief Set a path built from a rectangle
+
+  \param rect Rectangle
+  \sa setShape(), setPolygon(), shape()
+ */
+void QwtPlotShapeItem::setRect( const QRectF &rect ) 
+{
+    QPainterPath path;
+    path.addRect( rect );
+
+    setShape( path );
+}
+
+/*!
+  \brief Set a path built from a polygon
+
+  \param polygon Polygon
+  \sa setShape(), setRect(), shape()
+ */
+void QwtPlotShapeItem::setPolygon( const QPolygonF &polygon )
+{
+    QPainterPath shape;
+    shape.addPolygon( polygon );
+
+    setShape( shape );
+}
+
+/*!
+  \brief Set the shape to be displayed
+
+  \param shape Shape
+  \sa setShape(), shape()
+ */
+void QwtPlotShapeItem::setShape( const QPainterPath &shape )
+{
+    if ( shape != d_data->shape )
+    {
+        d_data->shape = shape;
+        if ( shape.isEmpty() )
+        {
+            d_data->boundingRect = QwtPlotItem::boundingRect();
+        }
+        else
+        {
+            d_data->boundingRect = shape.boundingRect();
+        }
+
+        itemChanged();
+    }
+}
+
+/*!
+  \return Shape to be displayed
+  \sa setShape()
+ */
+QPainterPath QwtPlotShapeItem::shape() const
+{
+    return d_data->shape;
+}
+
+/*! 
+  Build and assign a pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtPlotShapeItem::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setPen( QPen( color, width, style ) );
+}
+
+/*!
+  \brief Assign a pen
+
+  The pen is used to draw the outline of the shape
+
+  \param pen Pen
+  \sa pen(), brush()
+*/
+void QwtPlotShapeItem::setPen( const QPen &pen )
+{
+    if ( pen != d_data->pen )
+    {
+        d_data->pen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+    \return Pen used to draw the outline of the shape
+    \sa setPen(), brush()
+*/
+QPen QwtPlotShapeItem::pen() const
+{
+    return d_data->pen;
+}
+
+/*!
+  Assign a brush.
+
+  The brush is used to fill the path
+
+  \param brush Brush
+  \sa brush(), pen()
+*/
+void QwtPlotShapeItem::setBrush( const QBrush &brush )
+{
+    if ( brush != d_data->brush )
+    {
+        d_data->brush = brush;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Brush used to fill the shape
+  \sa setBrush(), pen()
+*/
+QBrush QwtPlotShapeItem::brush() const
+{
+    return d_data->brush;
+}
+
+/*!
+  \brief Set the tolerance for the weeding optimization
+
+  After translating the shape into target device coordinate 
+  ( usually widget geometries ) the painter path can be simplified
+  by a point weeding algorithm ( Douglas-Peucker ).
+
+  For shapes built from curves and ellipses weeding might
+  have the opposite effect because they have to be expanded
+  to polygons.
+
+  \param tolerance Accepted error when reducing the number of points
+                   A value <= 0.0 disables weeding.
+
+  \sa renderTolerance(), QwtWeedingCurveFitter
+ */
+void QwtPlotShapeItem::setRenderTolerance( double tolerance )
+{
+    tolerance = qMax( tolerance, 0.0 );
+
+    if ( tolerance != d_data->renderTolerance )
+    {
+        d_data->renderTolerance = tolerance;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Tolerance for the weeding optimization
+  \sa setRenderTolerance()
+ */
+double QwtPlotShapeItem::renderTolerance() const
+{
+    return d_data->renderTolerance;
+}
+
+/*!
+  Draw the shape item
+
+  \param painter Painter
+  \param xMap X-Scale Map
+  \param yMap Y-Scale Map
+  \param canvasRect Contents rect of the plot canvas
+*/
+void QwtPlotShapeItem::draw( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect ) const
+{
+    if ( d_data->shape.isEmpty() )
+        return;
+
+    if ( d_data->pen.style() == Qt::NoPen 
+        && d_data->brush.style() == Qt::NoBrush )
+    {
+        return;
+    }
+
+    const QRectF cr = QwtScaleMap::invTransform(
+        xMap, yMap, canvasRect.toRect() );
+
+    const QRectF &br = d_data->boundingRect;
+
+    if ( ( br.left() > cr.right() ) || ( br.right() < cr.left() )
+        || ( br.top() > cr.bottom() ) || ( br.bottom() < cr.top() ) )
+    {
+        // outside the visisble area
+        return;
+    }
+
+    const bool doAlign = QwtPainter::roundingAlignment( painter );
+
+    QPainterPath path = qwtTransformPath( xMap, yMap, 
+        d_data->shape, doAlign );
+
+    if ( testPaintAttribute( QwtPlotShapeItem::ClipPolygons ) )
+    {
+        qreal pw = qMax( qreal( 1.0 ), painter->pen().widthF());
+        QRectF clipRect = canvasRect.adjusted( -pw, -pw, pw, pw );
+
+        QPainterPath clippedPath;
+        clippedPath.setFillRule( path.fillRule() );
+
+        const QList<QPolygonF> polygons = path.toSubpathPolygons();
+        for ( int i = 0; i < polygons.size(); i++ )
+        {
+            const QPolygonF p = QwtClipper::clipPolygonF(
+                clipRect, polygons[i], true );
+
+            clippedPath.addPolygon( p );
+
+        }
+
+        path = clippedPath;
+    }
+
+    if ( d_data->renderTolerance > 0.0 )
+    {
+        QwtWeedingCurveFitter fitter( d_data->renderTolerance );
+
+        QPainterPath fittedPath;
+        fittedPath.setFillRule( path.fillRule() );
+
+        const QList<QPolygonF> polygons = path.toSubpathPolygons();
+        for ( int i = 0; i < polygons.size(); i++ )
+            fittedPath.addPolygon( fitter.fitCurve( polygons[ i ] ) );
+
+        path = fittedPath;
+    }
+
+    painter->setPen( d_data->pen );
+    painter->setBrush( d_data->brush );
+
+    painter->drawPath( path );
+}
+
+/*!
+  \return A rectangle filled with the color of the brush ( or the pen )
+
+  \param index Index of the legend entry 
+                ( usually there is only one )
+  \param size Icon size
+
+  \sa setLegendIconSize(), legendData()
+*/
+QwtGraphic QwtPlotShapeItem::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+
+    QwtGraphic icon;
+    icon.setDefaultSize( size );
+
+    if ( size.isEmpty() )
+        return icon;
+
+    if ( d_data->legendMode == QwtPlotShapeItem::LegendShape )
+    {
+        const QRectF &br = d_data->boundingRect;
+
+        QPainter painter( &icon );
+        painter.setRenderHint( QPainter::Antialiasing,
+            testRenderHint( QwtPlotItem::RenderAntialiased ) );
+
+        painter.translate( -br.topLeft() );
+
+        painter.setPen( d_data->pen );
+        painter.setBrush( d_data->brush );
+        painter.drawPath( d_data->shape );
+    }
+    else
+    {
+        QColor iconColor;
+        if ( d_data->brush.style() != Qt::NoBrush )
+            iconColor = d_data->brush.color();
+        else
+            iconColor = d_data->pen.color();
+
+        icon = defaultIcon( iconColor, size );
+    }
+
+    return icon;
+}
+
Index: trunk/BNC/qwt/qwt_plot_shapeitem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_shapeitem.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_shapeitem.h	(revision 8127)
@@ -0,0 +1,111 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_SHAPE_ITEM_H
+#define QWT_PLOT_SHAPE_ITEM_H
+
+#include "qwt_global.h"
+#include "qwt_plot_item.h"
+#include <qpainterpath.h>
+
+/*!
+  \brief A plot item, which displays any graphical shape, 
+         that can be defined by a QPainterPath
+
+  A QPainterPath is a shape composed from intersecting and uniting
+  regions, rectangles, ellipses or irregular areas defined by lines, and curves.
+  QwtPlotShapeItem displays a shape with a pen and brush.
+
+  QwtPlotShapeItem offers a couple of optimizations like clipping or weeding.
+  These algorithms need to convert the painter path into polygons that might be
+  less performant for paths built from curves and ellipses.
+
+  \sa QwtPlotZone
+*/
+class QWT_EXPORT QwtPlotShapeItem: public QwtPlotItem
+{
+public:
+    /*!
+        Attributes to modify the drawing algorithm.
+        The default disables all attributes
+
+        \sa setPaintAttribute(), testPaintAttribute()
+    */
+    enum PaintAttribute
+    {
+        /*!
+          Clip polygons before painting them. In situations, where points
+          are far outside the visible area (f.e when zooming deep) this
+          might be a substantial improvement for the painting performance
+
+          But polygon clipping will convert the painter path into
+          polygons what might introduce a negative impact on the
+          performance of paths composed from curves or ellipses.
+         */
+        ClipPolygons = 0x01,
+    };
+
+    //! Paint attributes
+    typedef QFlags<PaintAttribute> PaintAttributes;
+
+    //! Mode how to display the item on the legend
+    enum LegendMode
+    {
+        //! Display a scaled down version of the shape
+        LegendShape,
+
+        //! Display a filled rectangle 
+        LegendColor
+    };
+
+    explicit QwtPlotShapeItem( const QString &title = QString::null );
+    explicit QwtPlotShapeItem( const QwtText &title );
+
+    virtual ~QwtPlotShapeItem();
+
+    void setPaintAttribute( PaintAttribute, bool on = true );
+    bool testPaintAttribute( PaintAttribute ) const;
+
+    void setLegendMode( LegendMode );
+    LegendMode legendMode() const;
+
+    void setRect( const QRectF & );
+    void setPolygon( const QPolygonF & );
+
+    void setShape( const QPainterPath & );
+    QPainterPath shape() const;
+
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setPen( const QPen & );
+    QPen pen() const;
+
+    void setBrush( const QBrush & );
+    QBrush brush() const;
+
+    void setRenderTolerance( double );
+    double renderTolerance() const;
+
+    virtual QRectF boundingRect() const;
+
+    virtual void draw( QPainter *p,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &rect ) const;
+
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
+
+    virtual int rtti() const;
+
+private:
+    void init();
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_spectrocurve.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_spectrocurve.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_spectrocurve.cpp	(revision 8127)
@@ -42,5 +42,5 @@
 */
 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QwtText &title ):
-    QwtPlotSeriesItem<QwtPoint3D>( title )
+    QwtPlotSeriesItem( title )
 {
     init();
@@ -52,5 +52,5 @@
 */
 QwtPlotSpectroCurve::QwtPlotSpectroCurve( const QString &title ):
-    QwtPlotSeriesItem<QwtPoint3D>( QwtText( title ) )
+    QwtPlotSeriesItem( QwtText( title ) )
 {
     init();
@@ -72,5 +72,5 @@
 
     d_data = new PrivateData;
-    d_series = new QwtPoint3DSeriesData();
+    setData( new QwtPoint3DSeriesData() );
 
     setZ( 20.0 );
@@ -99,5 +99,5 @@
 
 /*!
-    \brief Return the current paint attributes
+    \return True, when attribute is enabled
     \sa PaintAttribute, setPaintAttribute()
 */
@@ -113,8 +113,22 @@
 void QwtPlotSpectroCurve::setSamples( const QVector<QwtPoint3D> &samples )
 {
-    delete d_series;
-    d_series = new QwtPoint3DSeriesData( samples );
-    itemChanged();
-}
+    setData( new QwtPoint3DSeriesData( samples ) );
+}
+
+/*!
+  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 QwtPlotSpectroCurve::setSamples(
+    QwtSeriesData<QwtPoint3D> *data )
+{
+    setData( data );
+}  
 
 /*!
@@ -137,4 +151,5 @@
     }
 
+    legendChanged();
     itemChanged();
 }
@@ -162,4 +177,6 @@
     {
         d_data->colorRange = interval;
+
+        legendChanged();
         itemChanged();
     }
@@ -189,4 +206,6 @@
     {
         d_data->penWidth = penWidth;
+
+        legendChanged();
         itemChanged();
     }
@@ -208,5 +227,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted. If to < 0 the
@@ -228,5 +247,5 @@
         from = 0;
 
-    if ( from >= to )
+    if ( from > to )
         return;
 
@@ -240,5 +259,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas
+  \param canvasRect Contents rectangle of the canvas
   \param from Index of the first sample to be painted
   \param to Index of the last sample to be painted. If to < 0 the
@@ -260,7 +279,9 @@
         d_data->colorTable = d_data->colorMap->colorTable( d_data->colorRange );
 
+    const QwtSeriesData<QwtPoint3D> *series = data();
+
     for ( int i = from; i <= to; i++ )
     {
-        const QwtPoint3D sample = d_series->sample( i );
+        const QwtPoint3D sample = series->sample( i );
 
         double xi = xMap.transform( sample.x() );
@@ -283,5 +304,5 @@
                 d_data->colorRange, sample.z() );
 
-            painter->setPen( QPen( QColor( rgb ), d_data->penWidth ) );
+            painter->setPen( QPen( QColor::fromRgba( rgb ), d_data->penWidth ) );
         }
         else
@@ -290,5 +311,5 @@
                 d_data->colorRange, sample.z() );
 
-            painter->setPen( QPen( QColor( d_data->colorTable[index] ), 
+            painter->setPen( QPen( QColor::fromRgba( d_data->colorTable[index] ), 
                 d_data->penWidth ) );
         }
Index: trunk/BNC/qwt/qwt_plot_spectrocurve.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_spectrocurve.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_spectrocurve.h	(revision 8127)
@@ -22,5 +22,6 @@
            mapped to a color.
 */
-class QWT_EXPORT QwtPlotSpectroCurve: public QwtPlotSeriesItem<QwtPoint3D>
+class QWT_EXPORT QwtPlotSpectroCurve: 
+    public QwtPlotSeriesItem, QwtSeriesStore<QwtPoint3D>
 {
 public:
@@ -46,4 +47,6 @@
 
     void setSamples( const QVector<QwtPoint3D> & );
+    void setSamples( QwtSeriesData<QwtPoint3D> * );
+
 
     void setColorMap( QwtColorMap * );
Index: trunk/BNC/qwt/qwt_plot_spectrogram.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_spectrogram.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_spectrogram.cpp	(revision 8127)
@@ -24,10 +24,15 @@
 #endif
 
+#define DEBUG_RENDER 0
+
+#if DEBUG_RENDER
+#include <QElapsedTimer>
+#endif
+
 class QwtPlotSpectrogram::PrivateData
 {
 public:
     PrivateData():
-        data( NULL ),
-        renderThreadCount( 1 )
+        data( NULL )
     {
         colorMap = new QwtLinearColorMap();
@@ -35,5 +40,7 @@
 
         conrecFlags = QwtRasterData::IgnoreAllVerticesOnLevel;
+#if 0
         conrecFlags |= QwtRasterData::IgnoreOutOfRange;
+#endif
     }
     ~PrivateData()
@@ -46,6 +53,4 @@
     QwtColorMap *colorMap;
     DisplayModes displayMode;
-
-    uint renderThreadCount;
 
     QList<double> contourLevels;
@@ -108,4 +113,5 @@
     }
 
+    legendChanged();
     itemChanged();
 }
@@ -123,35 +129,4 @@
 
 /*!
-   Rendering an image from the raster data can often be done
-   parallel on a multicore system.
-
-   \param numThreads Number of threads to be used for rendering.
-                     If numThreads is set to 0, the system specific
-                     ideal thread count is used.
-
-   The default thread count is 1 ( = no additional threads )
-
-   \warning Rendering in multiple threads is only supported for Qt >= 4.4
-   \sa renderThreadCount(), renderImage(), renderTile()
-*/
-void QwtPlotSpectrogram::setRenderThreadCount( uint numThreads )
-{
-    d_data->renderThreadCount = numThreads;
-}
-
-/*!
-   \return Number of threads to be used for rendering.
-           If numThreads is set to 0, the system specific
-           ideal thread count is used.
-
-   \warning Rendering in multiple threads is only supported for Qt >= 4.4
-   \sa setRenderThreadCount(), renderImage(), renderTile()
-*/
-uint QwtPlotSpectrogram::renderThreadCount() const
-{
-    return d_data->renderThreadCount;
-}
-
-/*!
   Change the color map
 
@@ -173,4 +148,6 @@
 
     invalidateCache();
+
+    legendChanged();
     itemChanged();
 }
@@ -183,4 +160,23 @@
 {
     return d_data->colorMap;
+}
+
+/*! 
+  Build and assign the default pen for the contour lines
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtPlotSpectrogram::setDefaultContourPen( 
+    const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setDefaultContourPen( QPen( color, width, style ) );
 }
 
@@ -200,4 +196,6 @@
     {
         d_data->defaultContourPen = pen;
+
+        legendChanged();
         itemChanged();
     }
@@ -266,4 +264,6 @@
    \return true, is enabled
 
+   The default setting enables QwtRasterData::IgnoreAllVerticesOnLevel
+
    \sa setConrecClag(), renderContourLines(),
        QwtRasterData::contourLines()
@@ -288,9 +288,11 @@
     d_data->contourLevels = levels;
     qSort( d_data->contourLevels );
+
+    legendChanged();
     itemChanged();
 }
 
 /*!
-   \brief Return the levels of the contour lines.
+   \return Levels of the contour lines.
 
    The levels are sorted in increasing order.
@@ -384,5 +386,5 @@
    \brief Render an image from data and color map.
 
-   For each pixel of rect the value is mapped into a color.
+   For each pixel of area the value is mapped into a color.
 
   \param xMap X-Scale Map
@@ -421,6 +423,11 @@
     d_data->data->initRaster( area, image.size() );
 
+#if DEBUG_RENDER
+	QElapsedTimer time;
+	time.start();
+#endif
+
 #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
-    uint numThreads = d_data->renderThreadCount;
+    uint numThreads = renderThreadCount();
 
     if ( numThreads <= 0 )
@@ -456,4 +463,9 @@
 #endif
 
+#if DEBUG_RENDER
+    const qint64 elapsed = time.elapsed();
+    qDebug() << "renderImage" << imageSize << elapsed;
+#endif
+
     d_data->data->discardRaster();
 
@@ -486,5 +498,5 @@
             const double ty = yMap.invTransform( y );
 
-            QRgb *line = ( QRgb * )image->scanLine( y );
+            QRgb *line = reinterpret_cast<QRgb *>( image->scanLine( y ) );
             line += tile.left();
 
@@ -521,5 +533,5 @@
    \brief Return the raster to be used by the CONREC contour algorithm.
 
-   A larger size will improve the precisision of the CONREC algorithm,
+   A larger size will improve the precision of the CONREC algorithm,
    but will slow down the time that is needed to calculate the lines.
 
@@ -527,6 +539,6 @@
    the resolution depending on pixelSize().
 
-   \param area Rect, where to calculate the contour lines
-   \param rect Rect in pixel coordinates, where to paint the contour lines
+   \param area Rectangle, where to calculate the contour lines
+   \param rect Rectangle in pixel coordinates, where to paint the contour lines
    \return Raster to be used by the CONREC contour algorithm.
 
@@ -556,4 +568,5 @@
    \param rect Rectangle, where to calculate the contour lines
    \param raster Raster, used by the CONREC algorithm
+   \return Calculated contour lines
 
    \sa contourLevels(), setConrecFlag(),
@@ -586,6 +599,4 @@
     if ( d_data->data == NULL )
         return;
-
-    const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
 
     const int numLevels = d_data->contourLevels.size();
@@ -622,5 +633,5 @@
   \param xMap Maps x-values into pixel coordinates.
   \param yMap Maps y-values into pixel coordinates.
-  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
 
   \sa setDisplayMode(), renderImage(),
Index: trunk/BNC/qwt/qwt_plot_spectrogram.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_spectrogram.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_spectrogram.h	(revision 8127)
@@ -21,7 +21,11 @@
   \brief A plot item, which displays a spectrogram
 
-  A spectrogram displays threedimenional data, where the 3rd dimension
+  A spectrogram displays 3-dimensional data, where the 3rd dimension
   ( the intensity ) is displayed using colors. The colors are calculated
   from the values using a color map.
+
+  On multi-core systems the performance of the image composition
+  can often be improved by dividing the area into tiles - each of them
+  rendered in a different thread ( see QwtPlotItem::setRenderThreadCount() ).
 
   In ContourMode contour lines are painted for the contour levels.
@@ -29,5 +33,5 @@
   \image html spectrogram3.png
 
-  \sa QwtRasterData, QwtColorMap
+  \sa QwtRasterData, QwtColorMap, QwtPlotItem::setRenderThreadCount()
 */
 
@@ -55,7 +59,4 @@
     virtual ~QwtPlotSpectrogram();
 
-    void setRenderThreadCount( uint numThreads );
-    uint renderThreadCount() const;
-
     void setDisplayMode( DisplayMode, bool on = true );
     bool testDisplayMode( DisplayMode ) const;
@@ -71,4 +72,6 @@
     virtual QRectF pixelHint( const QRectF & ) const;
 
+    void setDefaultContourPen( const QColor &, 
+        qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setDefaultContourPen( const QPen & );
     QPen defaultContourPen() const;
Index: trunk/BNC/qwt/qwt_plot_svgitem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_svgitem.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_svgitem.cpp	(revision 8127)
@@ -10,6 +10,4 @@
 #include "qwt_plot_svgitem.h"
 #include "qwt_scale_map.h"
-#include "qwt_legend.h"
-#include "qwt_legend_item.h"
 #include "qwt_painter.h"
 #include <qpainter.h>
@@ -66,4 +64,5 @@
 {
     d_data = new PrivateData();
+    d_data->boundingRect = QwtPlotItem::boundingRect();
 
     setItemAttribute( QwtPlotItem::AutoScale, true );
@@ -92,5 +91,8 @@
     d_data->boundingRect = rect;
     const bool ok = d_data->renderer.load( fileName );
+
+    legendChanged();
     itemChanged();
+
     return ok;
 }
@@ -109,9 +111,12 @@
     d_data->boundingRect = rect;
     const bool ok = d_data->renderer.load( data );
+
+    legendChanged();
     itemChanged();
+
     return ok;
 }
 
-//! Bounding rect of the item
+//! Bounding rectangle of the item
 QRectF QwtPlotSvgItem::boundingRect() const
 {
@@ -161,6 +166,6 @@
 
   \param painter Painter
-  \param viewBox View Box, see QSvgRenderer::viewBox
-  \param rect Traget rectangle on the paint device
+  \param viewBox View Box, see QSvgRenderer::viewBox()
+  \param rect Target rectangle on the paint device
 */
 void QwtPlotSvgItem::render( QPainter *painter,
@@ -185,8 +190,8 @@
 
 /*!
-  Calculate the viewBox from an rect and boundingRect().
+  Calculate the view box from rect and boundingRect().
 
   \param rect Rectangle in scale coordinates
-  \return viewBox View Box, see QSvgRenderer::viewBox
+  \return View box, see QSvgRenderer::viewBox()
 */
 QRectF QwtPlotSvgItem::viewBox( const QRectF &rect ) const
Index: trunk/BNC/qwt/qwt_plot_svgitem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_svgitem.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_svgitem.h	(revision 8127)
Index: trunk/BNC/qwt/qwt_plot_textlabel.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_textlabel.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_textlabel.cpp	(revision 8127)
@@ -0,0 +1,272 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_textlabel.h"
+#include "qwt_painter.h"
+#include "qwt_scale_map.h"
+#include <qpainter.h>
+#include <qpixmap.h>
+#include <qmath.h>
+
+static QRect qwtItemRect( int renderFlags,
+    const QRectF &rect, const QSizeF &itemSize ) 
+{
+    int x;
+    if ( renderFlags & Qt::AlignLeft )
+    {
+        x = rect.left();
+    }
+    else if ( renderFlags & Qt::AlignRight )
+    {
+        x = rect.right() - itemSize.width();
+    }
+    else
+    {
+        x = rect.center().x() - 0.5 * itemSize.width();
+    }
+
+    int y;
+    if ( renderFlags & Qt::AlignTop ) 
+    {
+        y = rect.top();
+    }
+    else if ( renderFlags & Qt::AlignBottom )
+    {
+        y = rect.bottom() - itemSize.height();
+    }
+    else
+    {
+        y = rect.center().y() - 0.5 * itemSize.height();
+    }
+
+    return QRect( x, y, itemSize.width(), itemSize.height() );
+}
+
+class QwtPlotTextLabel::PrivateData
+{   
+public:
+    PrivateData():
+        margin( 5 )
+    {
+    }
+
+    QwtText text;
+    int margin;
+
+    QPixmap pixmap;
+};  
+
+/*!
+   \brief Constructor
+
+   Initializes an text label with an empty text
+
+   Sets the following item attributes:
+
+   - QwtPlotItem::AutoScale: true
+   - QwtPlotItem::Legend:    false
+
+   The z value is initialized by 150
+
+   \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
+*/
+
+QwtPlotTextLabel::QwtPlotTextLabel():
+    QwtPlotItem( QwtText( "Label" ) )
+{
+    d_data = new PrivateData;
+
+    setItemAttribute( QwtPlotItem::AutoScale, false );
+    setItemAttribute( QwtPlotItem::Legend, false );
+
+    setZ( 150 );
+}
+
+//! Destructor
+QwtPlotTextLabel::~QwtPlotTextLabel()
+{
+    delete d_data;
+}
+
+//! \return QwtPlotItem::Rtti_PlotTextLabel
+int QwtPlotTextLabel::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotTextLabel;
+}
+
+/*!
+  Set the text 
+
+  The label will be aligned to the plot canvas according to
+  the alignment flags of text.
+
+  \param text Text to be displayed
+
+  \sa text(), QwtText::renderFlags()
+*/
+void QwtPlotTextLabel::setText( const QwtText &text )
+{
+    if ( d_data->text != text )
+    {
+        d_data->text = text;
+
+        invalidateCache();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Text to be displayed
+  \sa setText()
+*/
+QwtText QwtPlotTextLabel::text() const
+{
+    return d_data->text;
+}
+
+/*!
+  Set the margin
+
+  The margin is the distance between the contentsRect()
+  of the plot canvas and the rectangle where the label can
+  be displayed.
+
+  \param margin Margin
+
+  \sa margin(), textRect()
+ */
+void QwtPlotTextLabel::setMargin( int margin )
+{
+    margin = qMax( margin, 0 );
+    if ( d_data->margin != margin )
+    {
+        d_data->margin = margin;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Margin added to the contentsMargins() of the canvas
+  \sa setMargin()
+*/
+int QwtPlotTextLabel::margin() const
+{
+    return d_data->margin;
+}
+
+/*!
+  Draw the text label
+
+  \param painter Painter
+  \param xMap x Scale Map
+  \param yMap y Scale Map
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
+
+  \sa textRect()
+*/
+
+void QwtPlotTextLabel::draw( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect ) const
+{
+    Q_UNUSED( xMap );
+    Q_UNUSED( yMap );
+
+    const int m = d_data->margin;
+
+    const QRectF rect = textRect( canvasRect.adjusted( m, m, -m, -m ),
+        d_data->text.textSize( painter->font() ) );
+
+    bool doCache = QwtPainter::roundingAlignment( painter );
+    if ( doCache )
+    {
+        switch( painter->paintEngine()->type() )
+        {
+            case QPaintEngine::Picture:
+            case QPaintEngine::User: // usually QwtGraphic
+            {
+                // don't use a cache for record/replay devices
+                doCache = false;
+                break;
+            }
+            default:;
+        }
+    }
+
+    if ( doCache )
+    {
+        // when the paint device is aligning it is not one
+        // where scalability matters ( PDF, SVG ).
+        // As rendering a text label is an expensive operation
+        // we use a cache.
+
+        int pw = 0;
+        if ( d_data->text.borderPen().style() != Qt::NoPen )
+            pw = qMax( d_data->text.borderPen().width(), 1 );
+
+        QRect pixmapRect; 
+        pixmapRect.setLeft( qFloor( rect.left() ) - pw );
+        pixmapRect.setTop( qFloor( rect.top() ) - pw );
+        pixmapRect.setRight( qCeil( rect.right() ) + pw );
+        pixmapRect.setBottom( qCeil( rect.bottom() ) + pw );
+        
+#define QWT_HIGH_DPI 1
+
+#if QT_VERSION >= 0x050100 && QWT_HIGH_DPI
+        const qreal pixelRatio = painter->device()->devicePixelRatio();
+        const QSize scaledSize = pixmapRect.size() * pixelRatio;
+#else
+        const QSize scaledSize = pixmapRect.size();
+#endif
+        if ( d_data->pixmap.isNull() || 
+            ( scaledSize != d_data->pixmap.size() )  )
+        {
+            d_data->pixmap = QPixmap( scaledSize );
+#if QT_VERSION >= 0x050100 && QWT_HIGH_DPI
+            d_data->pixmap.setDevicePixelRatio( pixelRatio );
+#endif
+            d_data->pixmap.fill( Qt::transparent );
+
+            const QRect r( pw, pw, 
+                pixmapRect.width() - 2 * pw, pixmapRect.height() - 2 * pw );
+
+            QPainter pmPainter( &d_data->pixmap );
+            d_data->text.draw( &pmPainter, r );
+        }
+
+        painter->drawPixmap( pixmapRect, d_data->pixmap );
+    }
+    else
+    {
+        d_data->text.draw( painter, rect );
+    }
+}
+
+/*!
+   \brief Align the text label
+
+   \param rect Canvas rectangle with margins subtracted
+   \param textSize Size required to draw the text
+
+   \return A rectangle aligned according the the alignment flags of
+           the text.
+
+   \sa setMargin(), QwtText::renderFlags(), QwtText::textSize()
+ */
+QRectF QwtPlotTextLabel::textRect( 
+    const QRectF &rect, const QSizeF &textSize ) const
+{
+    return qwtItemRect( d_data->text.renderFlags(), rect, textSize );
+}
+
+//!  Invalidate all internal cache
+void QwtPlotTextLabel::invalidateCache()
+{
+    d_data->pixmap = QPixmap();
+}
Index: trunk/BNC/qwt/qwt_plot_textlabel.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_textlabel.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_textlabel.h	(revision 8127)
@@ -0,0 +1,75 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_TEXT_LABEL_H
+#define QWT_PLOT_TEXT_LABEL_H 1
+
+#include "qwt_global.h"
+#include "qwt_plot_item.h"
+#include "qwt_text.h"
+
+/*!
+  \brief A plot item, which displays a text label
+
+  QwtPlotTextLabel displays a text label aligned to the plot canvas.
+
+  In opposite to QwtPlotMarker the position of the label is unrelated to
+  plot coordinates.
+    
+  As drawing a text is an expensive operation the label is cached
+  in a pixmap to speed up replots.
+
+  \par Example
+  The following code shows how to add a title.
+
+\verbatim
+    QwtText title( "Plot Title" );
+    title.setRenderFlags( Qt::AlignHCenter | Qt::AlignTop );
+
+    QFont font;
+    font.setBold( true );
+    title.setFont( font );
+
+    QwtPlotTextLabel *titleItem = new QwtPlotTextLabel();
+    titleItem->setText( title );
+    titleItem->attach( this );
+\endverbatim
+
+  \sa QwtPlotMarker
+*/  
+
+class QWT_EXPORT QwtPlotTextLabel: public QwtPlotItem
+{
+public:
+    QwtPlotTextLabel();
+    virtual ~QwtPlotTextLabel();
+
+    virtual int rtti() const;
+
+    void setText( const QwtText & );
+    QwtText text() const;
+
+    void setMargin( int margin );
+    int margin() const;
+
+    virtual QRectF textRect( const QRectF &, const QSizeF & ) const;
+
+protected:
+    virtual void draw( QPainter *,
+        const QwtScaleMap &, const QwtScaleMap &,
+        const QRectF &) const;
+
+    void invalidateCache();
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_tradingcurve.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_tradingcurve.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_tradingcurve.cpp	(revision 8127)
@@ -0,0 +1,682 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_tradingcurve.h"
+#include "qwt_scale_map.h"
+#include "qwt_clipper.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+
+static inline bool qwtIsSampleInside( const QwtOHLCSample &sample,
+    double tMin, double tMax, double vMin, double vMax )
+{
+    const double t = sample.time;
+    const QwtInterval interval = sample.boundingInterval();
+
+    const bool isOffScreen = ( t < tMin ) || ( t > tMax )
+        || ( interval.maxValue() < vMin ) || ( interval.minValue() > vMax );
+
+    return !isOffScreen;
+}
+
+class QwtPlotTradingCurve::PrivateData
+{
+public:
+    PrivateData():
+        symbolStyle( QwtPlotTradingCurve::CandleStick ),
+        symbolExtent( 0.6 ),
+        minSymbolWidth( 2.0 ),
+        maxSymbolWidth( -1.0 ),
+        paintAttributes( QwtPlotTradingCurve::ClipSymbols )
+    {
+        symbolBrush[0] = QBrush( Qt::white );
+        symbolBrush[1] = QBrush( Qt::black );
+    }
+
+    QwtPlotTradingCurve::SymbolStyle symbolStyle;
+    double symbolExtent;
+    double minSymbolWidth;
+    double maxSymbolWidth;
+
+    QPen symbolPen;
+    QBrush symbolBrush[2]; // Increasing/Decreasing
+
+    QwtPlotTradingCurve::PaintAttributes paintAttributes;
+};
+
+/*!
+  Constructor
+  \param title Title of the curve
+*/
+QwtPlotTradingCurve::QwtPlotTradingCurve( const QwtText &title ):
+    QwtPlotSeriesItem( title )
+{
+    init();
+}
+
+/*!
+  Constructor
+  \param title Title of the curve
+*/
+QwtPlotTradingCurve::QwtPlotTradingCurve( const QString &title ):
+    QwtPlotSeriesItem( QwtText( title ) )
+{
+    init();
+}
+
+//! Destructor
+QwtPlotTradingCurve::~QwtPlotTradingCurve()
+{
+    delete d_data;
+}
+
+//! Initialize internal members
+void QwtPlotTradingCurve::init()
+{
+    setItemAttribute( QwtPlotItem::Legend, true );
+    setItemAttribute( QwtPlotItem::AutoScale, true );
+
+    d_data = new PrivateData;
+    setData( new QwtTradingChartData() );
+
+    setZ( 19.0 );
+}
+
+//! \return QwtPlotItem::Rtti_PlotTradingCurve
+int QwtPlotTradingCurve::rtti() const
+{
+    return QwtPlotTradingCurve::Rtti_PlotTradingCurve;
+}
+
+/*!
+  Specify an attribute how to draw the curve
+
+  \param attribute Paint attribute
+  \param on On/Off
+  \sa testPaintAttribute()
+*/
+void QwtPlotTradingCurve::setPaintAttribute(
+    PaintAttribute attribute, bool on )
+{
+    if ( on )
+        d_data->paintAttributes |= attribute;
+    else
+        d_data->paintAttributes &= ~attribute;
+}
+
+/*!
+    \return True, when attribute is enabled
+    \sa PaintAttribute, setPaintAttribute()
+*/
+bool QwtPlotTradingCurve::testPaintAttribute(
+    PaintAttribute attribute ) const
+{
+    return ( d_data->paintAttributes & attribute );
+}
+
+/*!
+  Initialize data with an array of samples.
+  \param samples Vector of samples
+
+  \sa QwtPlotSeriesItem::setData()
+*/
+void QwtPlotTradingCurve::setSamples(
+    const QVector<QwtOHLCSample> &samples )
+{
+    setData( new QwtTradingChartData( samples ) );
+}
+
+/*!
+  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 QwtPlotTradingCurve::setSamples(
+    QwtSeriesData<QwtOHLCSample> *data )
+{
+    setData( data );
+}   
+
+/*!
+  Set the symbol style
+
+  \param style Symbol style
+
+  \sa symbolStyle(), setSymbolExtent(),
+      setSymbolPen(), setSymbolBrush()
+*/
+void QwtPlotTradingCurve::setSymbolStyle( SymbolStyle style )
+{
+    if ( style != d_data->symbolStyle )
+    {
+        d_data->symbolStyle = style;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Symbol style
+  \sa setSymbolStyle(), symbolExtent(), symbolPen(), symbolBrush()
+*/
+QwtPlotTradingCurve::SymbolStyle QwtPlotTradingCurve::symbolStyle() const
+{
+    return d_data->symbolStyle;
+}
+
+/*! 
+  Build and assign the symbol pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtPlotTradingCurve::setSymbolPen( 
+    const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setSymbolPen( QPen( color, width, style ) );
+}
+
+/*!
+  \brief Set the symbol pen
+
+  The symbol pen is used for rendering the lines of the
+  bar or candlestick symbols
+
+  \sa symbolPen(), setSymbolBrush()
+*/
+void QwtPlotTradingCurve::setSymbolPen( const QPen &pen )
+{
+    if ( pen != d_data->symbolPen )
+    {
+        d_data->symbolPen = pen;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Symbol pen
+  \sa setSymbolPen(), symbolBrush()
+*/
+QPen QwtPlotTradingCurve::symbolPen() const
+{
+    return d_data->symbolPen;
+}
+
+/*!
+  Set the symbol brush
+
+  \param direction Direction type
+  \param brush Brush used to fill the body of all candlestick
+               symbols with the direction
+
+  \sa symbolBrush(), setSymbolPen()
+*/
+void QwtPlotTradingCurve::setSymbolBrush(
+    Direction direction, const QBrush &brush )
+{
+    if ( direction < 0 || direction >= 2 )
+        return;
+
+    if ( brush != d_data->symbolBrush[ direction ] )
+    {
+        d_data->symbolBrush[ direction ] = brush;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \param direction
+  \return Brush used to fill the body of all candlestick
+          symbols with the direction
+
+  \sa setSymbolPen(), symbolBrush()
+*/
+QBrush QwtPlotTradingCurve::symbolBrush( Direction direction ) const
+{
+    if ( direction < 0 || direction >= 2 )
+        return QBrush();
+
+    return d_data->symbolBrush[ direction ];
+}
+
+/*!
+  \brief Set the extent of the symbol
+
+  The width of the symbol is given in scale coordinates. When painting
+  a symbol the width is scaled into paint device coordinates
+  by scaledSymbolWidth(). The scaled width is bounded by
+  minSymbolWidth(), maxSymbolWidth()
+
+  \param extent Symbol width in scale coordinates
+
+  \sa symbolExtent(), scaledSymbolWidth(), 
+      setMinSymbolWidth(), setMaxSymbolWidth()
+*/
+void QwtPlotTradingCurve::setSymbolExtent( double extent )
+{
+    extent = qMax( 0.0, extent );
+    if ( extent != d_data->symbolExtent )
+    {
+        d_data->symbolExtent = extent;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Extent of a symbol in scale coordinates
+  \sa setSymbolExtent(), scaledSymbolWidth(),
+      minSymbolWidth(), maxSymbolWidth()
+*/
+double QwtPlotTradingCurve::symbolExtent() const
+{
+    return d_data->symbolExtent;
+}
+
+/*!
+  Set a minimum for the symbol width
+
+  \param width Width in paint device coordinates
+  \sa minSymbolWidth(), setMaxSymbolWidth(), setSymbolExtent()
+ */
+void QwtPlotTradingCurve::setMinSymbolWidth( double width )
+{
+    width = qMax( width, 0.0 );
+    if ( width != d_data->minSymbolWidth )
+    {
+        d_data->minSymbolWidth = width;
+
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Minmum for the symbol width
+  \sa setMinSymbolWidth(), maxSymbolWidth(), symbolExtent()
+ */
+double QwtPlotTradingCurve::minSymbolWidth() const
+{
+    return d_data->minSymbolWidth;
+}
+
+/*!
+  Set a maximum for the symbol width
+
+  A value <= 0.0 means an unlimited width
+
+  \param width Width in paint device coordinates
+  \sa maxSymbolWidth(), setMinSymbolWidth(), setSymbolExtent()
+ */
+void QwtPlotTradingCurve::setMaxSymbolWidth( double width )
+{
+    if ( width != d_data->maxSymbolWidth )
+    {
+        d_data->maxSymbolWidth = width;
+    
+        legendChanged();
+        itemChanged();
+    }
+}
+
+/*!
+  \return Maximum for the symbol width
+  \sa setMaxSymbolWidth(), minSymbolWidth(), symbolExtent()
+ */
+double QwtPlotTradingCurve::maxSymbolWidth() const
+{
+    return d_data->maxSymbolWidth;
+}
+
+/*!
+  \return Bounding rectangle of all samples.
+  For an empty series the rectangle is invalid.
+*/
+QRectF QwtPlotTradingCurve::boundingRect() const
+{
+    QRectF rect = QwtPlotSeriesItem::boundingRect();
+    if ( rect.isValid() && orientation() == Qt::Vertical )
+        rect.setRect( rect.y(), rect.x(), rect.height(), rect.width() );
+
+    return rect;
+}
+
+/*!
+  Draw an interval of the curve
+
+  \param painter Painter
+  \param xMap Maps x-values into pixel coordinates.
+  \param yMap Maps y-values into pixel coordinates.
+  \param canvasRect Contents rectangle 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 QwtPlotTradingCurve::drawSeries( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, int from, int to ) const
+{
+    if ( to < 0 )
+        to = dataSize() - 1;
+
+    if ( from < 0 )
+        from = 0;
+
+    if ( from > to )
+        return;
+
+    painter->save();
+
+    if ( d_data->symbolStyle != QwtPlotTradingCurve::NoSymbol )
+        drawSymbols( painter, xMap, yMap, canvasRect, from, to );
+
+    painter->restore();
+}
+
+/*!
+  Draw symbols
+
+  \param painter Painter
+  \param xMap x map
+  \param yMap y map
+  \param canvasRect Contents rectangle of the canvas
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+
+  \sa drawSeries()
+*/
+void QwtPlotTradingCurve::drawSymbols( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect, int from, int to ) const
+{
+    const QRectF tr = QwtScaleMap::invTransform( xMap, yMap, canvasRect );
+
+    const QwtScaleMap *timeMap, *valueMap;
+    double tMin, tMax, vMin, vMax;
+
+    const Qt::Orientation orient = orientation();
+    if ( orient == Qt::Vertical )
+    {
+        timeMap = &xMap;
+        valueMap = &yMap;
+
+        tMin = tr.left();
+        tMax = tr.right();
+        vMin = tr.top();
+        vMax = tr.bottom();
+    }
+    else
+    {
+        timeMap = &yMap;
+        valueMap = &xMap;
+
+        vMin = tr.left();
+        vMax = tr.right();
+        tMin = tr.top();
+        tMax = tr.bottom();
+    }
+
+    const bool inverted = timeMap->isInverting();
+    const bool doClip = d_data->paintAttributes & ClipSymbols;
+    const bool doAlign = QwtPainter::roundingAlignment( painter );
+
+    double symbolWidth = scaledSymbolWidth( xMap, yMap, canvasRect );
+    if ( doAlign )
+        symbolWidth = qFloor( 0.5 * symbolWidth ) * 2.0;
+
+    QPen pen = d_data->symbolPen;
+    pen.setCapStyle( Qt::FlatCap );
+
+    painter->setPen( pen );
+
+    for ( int i = from; i <= to; i++ )
+    {
+        const QwtOHLCSample s = sample( i );
+
+        if ( !doClip || qwtIsSampleInside( s, tMin, tMax, vMin, vMax ) )
+        {
+            QwtOHLCSample translatedSample;
+
+            translatedSample.time = timeMap->transform( s.time );
+            translatedSample.open = valueMap->transform( s.open );
+            translatedSample.high = valueMap->transform( s.high );
+            translatedSample.low = valueMap->transform( s.low );
+            translatedSample.close = valueMap->transform( s.close );
+
+            const int brushIndex = ( s.open < s.close )
+                ? QwtPlotTradingCurve::Increasing
+                : QwtPlotTradingCurve::Decreasing;
+
+            if ( doAlign )
+            {
+                translatedSample.time = qRound( translatedSample.time );
+                translatedSample.open = qRound( translatedSample.open );
+                translatedSample.high = qRound( translatedSample.high );
+                translatedSample.low = qRound( translatedSample.low );
+                translatedSample.close = qRound( translatedSample.close );
+            }
+
+            switch( d_data->symbolStyle )
+            {
+                case Bar:
+                {
+                    drawBar( painter, translatedSample, 
+                        orient, inverted, symbolWidth );
+                    break;
+                }
+                case CandleStick:
+                {
+                    painter->setBrush( d_data->symbolBrush[ brushIndex ] );
+                    drawCandleStick( painter, translatedSample, 
+                        orient, symbolWidth );
+                    break;
+                }
+                default:
+                {
+                    if ( d_data->symbolStyle >= UserSymbol )
+                    {
+                        painter->setBrush( d_data->symbolBrush[ brushIndex ] );
+                        drawUserSymbol( painter, d_data->symbolStyle,
+                            translatedSample, orient, inverted, symbolWidth );
+                    }
+                }
+            }
+        }
+    }
+}
+
+/*!
+  \brief Draw a symbol for a symbol style >= UserSymbol
+
+  The implementation does nothing and is intended to be overloaded
+
+  \param painter Qt painter, initialized with pen/brush
+  \param symbolStyle Symbol style
+  \param sample Samples already translated into paint device coordinates
+  \param orientation Vertical or horizontal
+  \param inverted True, when the opposite scale 
+                  ( Qt::Vertical: x, Qt::Horizontal: y ) is increasing
+                  in the opposite direction as QPainter coordinates.
+  \param symbolWidth Width of the symbol in paint device coordinates
+*/
+void QwtPlotTradingCurve::drawUserSymbol( QPainter *painter,
+    SymbolStyle symbolStyle, const QwtOHLCSample &sample,
+    Qt::Orientation orientation, bool inverted, double symbolWidth ) const
+{
+    Q_UNUSED( painter )
+    Q_UNUSED( symbolStyle )
+    Q_UNUSED( orientation )
+    Q_UNUSED( inverted )
+    Q_UNUSED( symbolWidth )
+    Q_UNUSED( sample )
+}
+
+/*!
+  \brief Draw a bar
+
+  \param painter Qt painter, initialized with pen/brush
+  \param sample Sample, already translated into paint device coordinates
+  \param orientation Vertical or horizontal
+  \param inverted When inverted is false the open tick is painted
+                  to the left/top, otherwise it is painted right/bottom.
+                  The close tick is painted in the opposite direction
+                  of the open tick.
+                  painted in the opposite d
+                  opposite direction.
+  \param width Width or height of the candle, depending on the orientation
+
+  \sa Bar
+*/
+void QwtPlotTradingCurve::drawBar( QPainter *painter,
+    const QwtOHLCSample &sample, Qt::Orientation orientation, 
+    bool inverted, double width ) const
+{
+    double w2 = 0.5 * width;
+    if ( inverted )
+        w2 *= -1;
+
+    if ( orientation == Qt::Vertical )
+    {
+        QwtPainter::drawLine( painter,
+            sample.time, sample.low, sample.time, sample.high );
+
+        QwtPainter::drawLine( painter,
+            sample.time - w2, sample.open, sample.time, sample.open );
+        QwtPainter::drawLine( painter,
+            sample.time + w2, sample.close, sample.time, sample.close );
+    }
+    else
+    {
+        QwtPainter::drawLine( painter, sample.low, sample.time,
+            sample.high, sample.time );
+        QwtPainter::drawLine( painter,
+            sample.open, sample.time - w2, sample.open, sample.time );
+        QwtPainter::drawLine( painter,
+            sample.close, sample.time + w2, sample.close, sample.time );
+    }
+}
+
+/*!
+  \brief Draw a candle stick
+
+  \param painter Qt painter, initialized with pen/brush
+  \param sample Samples already translated into paint device coordinates
+  \param orientation Vertical or horizontal
+  \param width Width or height of the candle, depending on the orientation
+
+  \sa CandleStick
+*/
+void QwtPlotTradingCurve::drawCandleStick( QPainter *painter,
+    const QwtOHLCSample &sample, Qt::Orientation orientation, 
+    double width ) const
+{
+    const double t = sample.time;
+    const double v1 = qMin( sample.low, sample.high );
+    const double v2 = qMin( sample.open, sample.close );
+    const double v3 = qMax( sample.low, sample.high );
+    const double v4 = qMax( sample.open, sample.close );
+
+    if ( orientation == Qt::Vertical )
+    {
+        QwtPainter::drawLine( painter, t, v1, t, v2 );
+        QwtPainter::drawLine( painter, t, v3, t, v4 );
+
+        QRectF rect( t - 0.5 * width, sample.open,
+            width, sample.close - sample.open );
+
+        QwtPainter::drawRect( painter, rect );
+    }
+    else
+    {
+        QwtPainter::drawLine( painter, v1, t, v2, t );
+        QwtPainter::drawLine( painter, v3, t, v4, t );
+
+        const QRectF rect( sample.open, t - 0.5 * width,
+            sample.close - sample.open, width );
+
+        QwtPainter::drawRect( painter, rect );
+    }
+}
+
+/*!
+  \return A rectangle filled with the color of the symbol pen
+
+  \param index Index of the legend entry 
+                ( usually there is only one )
+  \param size Icon size
+
+  \sa setLegendIconSize(), legendData()
+*/
+QwtGraphic QwtPlotTradingCurve::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+    return defaultIcon( d_data->symbolPen.color(), size );
+}
+
+/*!
+  Calculate the symbol width in paint coordinates
+
+  The width is calculated by scaling the symbol extent into
+  paint device coordinates bounded by the minimum/maximum
+  symbol width.
+
+  \param xMap Maps x-values into pixel coordinates.
+  \param yMap Maps y-values into pixel coordinates.
+  \param canvasRect Contents rectangle of the canvas
+
+  \return Symbol width in paint coordinates
+
+  \sa symbolExtent(), minSymbolWidth(), maxSymbolWidth()
+*/
+double QwtPlotTradingCurve::scaledSymbolWidth(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect ) const
+{
+    Q_UNUSED( canvasRect );
+
+    if ( d_data->maxSymbolWidth > 0.0 &&
+        d_data->minSymbolWidth >= d_data->maxSymbolWidth )
+    {
+        return d_data->minSymbolWidth;
+    }
+
+    const QwtScaleMap *map =
+        ( orientation() == Qt::Vertical ) ? &xMap : &yMap;
+
+    const double pos = map->transform( map->s1() + d_data->symbolExtent ); 
+
+    double width = qAbs( pos - map->p1() );
+
+    width = qMax( width,  d_data->minSymbolWidth );
+    if ( d_data->maxSymbolWidth > 0.0 )
+        width = qMin( width, d_data->maxSymbolWidth );
+
+    return width;
+}
Index: trunk/BNC/qwt/qwt_plot_tradingcurve.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_tradingcurve.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_tradingcurve.h	(revision 8127)
@@ -0,0 +1,174 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_TRADING_CURVE_H
+#define QWT_PLOT_TRADING_CURVE_H
+
+#include "qwt_global.h"
+#include "qwt_plot_seriesitem.h"
+#include "qwt_series_data.h"
+
+/*!
+  \brief QwtPlotTradingCurve illustrates movements in the price of a
+         financial instrument over time.
+
+  QwtPlotTradingCurve supports candlestick or bar ( OHLC ) charts
+  that are used in the domain of technical analysis.
+
+  While the length ( height or width depending on orientation() ) 
+  of each symbol depends on the corresponding OHLC sample the size
+  of the other dimension can be controlled using:
+
+  - setSymbolExtent()
+  - setSymbolMinWidth()
+  - setSymbolMaxWidth()
+
+  The extent is a size in scale coordinates, so that the symbol width
+  is increasing when the plot is zoomed in. Minimum/Maximum width
+  is in widget coordinates independent from the zoom level. 
+  When setting the minimum and maximum to the same value, the width of 
+  the symbol is fixed. 
+*/
+class QWT_EXPORT QwtPlotTradingCurve: 
+    public QwtPlotSeriesItem, QwtSeriesStore<QwtOHLCSample>
+{
+public:
+    /*!
+        \brief Symbol styles.
+
+        The default setting is QwtPlotSeriesItem::CandleStick.
+        \sa setSymbolStyle(), symbolStyle()
+    */
+    enum SymbolStyle
+    {
+        //! Nothing is displayed
+        NoSymbol = -1,
+
+        /*!
+          A line on the chart shows the price range (the highest and lowest
+          prices) over one unit of time, e.g. one day or one hour.
+          Tick marks project from each side of the line indicating the
+          opening and closing price.
+         */
+        Bar,
+
+        /*!
+          The range between opening/closing price are displayed as
+          a filled box. The fill brush depends on the direction of the
+          price movement. The box is connected to the highest/lowest
+          values by lines.
+        */
+        CandleStick,
+
+        /*!
+          SymbolTypes >= UserSymbol are displayed by drawUserSymbol(),
+          that needs to be overloaded and implemented in derived
+          curve classes.
+
+          \sa drawUserSymbol()
+        */
+        UserSymbol = 100
+    };
+
+    /*!
+        \brief Direction of a price movement
+     */
+    enum Direction
+    {
+        //! The closing price is higher than the opening price
+        Increasing,
+
+        //! The closing price is lower than the opening price
+        Decreasing
+    };
+
+    /*!
+        Attributes to modify the drawing algorithm.
+        \sa setPaintAttribute(), testPaintAttribute()
+    */
+    enum PaintAttribute
+    {
+        //! Check if a symbol is on the plot canvas before painting it.
+        ClipSymbols   = 0x01
+    };
+
+    //! Paint attributes
+    typedef QFlags<PaintAttribute> PaintAttributes;
+
+    explicit QwtPlotTradingCurve( const QString &title = QString::null );
+    explicit QwtPlotTradingCurve( const QwtText &title );
+
+    virtual ~QwtPlotTradingCurve();
+
+    virtual int rtti() const;
+
+    void setPaintAttribute( PaintAttribute, bool on = true );
+    bool testPaintAttribute( PaintAttribute ) const;
+
+    void setSamples( const QVector<QwtOHLCSample> & );
+    void setSamples( QwtSeriesData<QwtOHLCSample> * );
+
+    void setSymbolStyle( SymbolStyle style );
+    SymbolStyle symbolStyle() const;
+
+    void setSymbolPen( const QColor &, 
+        qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setSymbolPen( const QPen & );
+    QPen symbolPen() const;
+
+    void setSymbolBrush( Direction, const QBrush & );
+    QBrush symbolBrush( Direction ) const;
+
+    void setSymbolExtent( double width );
+    double symbolExtent() const;
+
+    void setMinSymbolWidth( double );
+    double minSymbolWidth() const;
+
+    void setMaxSymbolWidth( double );
+    double maxSymbolWidth() const;
+
+    virtual void drawSeries( QPainter *painter,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual QRectF boundingRect() const;
+
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
+
+protected:
+
+    void init();
+
+    virtual void drawSymbols( QPainter *,
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect, int from, int to ) const;
+
+    virtual void drawUserSymbol( QPainter *, 
+        SymbolStyle, const QwtOHLCSample &,
+        Qt::Orientation, bool inverted, double width ) const;
+
+    void drawBar( QPainter *painter, const QwtOHLCSample &, 
+        Qt::Orientation, bool inverted, double width ) const;
+
+    void drawCandleStick( QPainter *, const QwtOHLCSample &, 
+        Qt::Orientation, double width ) const;
+
+    virtual double scaledSymbolWidth(
+        const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QRectF &canvasRect ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPlotTradingCurve::PaintAttributes )
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_xml.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_xml.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_xml.cpp	(revision 8127)
@@ -29,4 +29,5 @@
   from a specific editor in the Qwt designer plugin.
 
+  \return QString::null
   \warning The plot editor has never been implemented.
 */
Index: trunk/BNC/qwt/qwt_plot_zoneitem.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_zoneitem.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_zoneitem.cpp	(revision 8127)
@@ -0,0 +1,315 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_plot_zoneitem.h"
+#include "qwt_painter.h"
+#include "qwt_scale_map.h"
+#include <qpainter.h>
+
+class QwtPlotZoneItem::PrivateData
+{   
+public:
+    PrivateData():
+        orientation( Qt::Vertical ),
+        pen( Qt::NoPen )
+    {
+        QColor c( Qt::darkGray );
+        c.setAlpha( 100 );
+        brush = QBrush( c );
+    }
+        
+    Qt::Orientation orientation;
+    QPen pen;
+    QBrush brush;
+    QwtInterval interval;
+};  
+
+/*!
+   \brief Constructor
+
+   Initializes the zone with no pen and a semi transparent gray brush
+
+   Sets the following item attributes:
+
+   - QwtPlotItem::AutoScale: false
+   - QwtPlotItem::Legend:    false
+
+   The z value is initialized by 5
+
+   \sa QwtPlotItem::setItemAttribute(), QwtPlotItem::setZ()
+*/
+QwtPlotZoneItem::QwtPlotZoneItem():
+    QwtPlotItem( QwtText( "Zone" ) )
+{
+    d_data = new PrivateData;
+
+    setItemAttribute( QwtPlotItem::AutoScale, false );
+    setItemAttribute( QwtPlotItem::Legend, false );
+
+    setZ( 5 );
+}
+
+//! Destructor
+QwtPlotZoneItem::~QwtPlotZoneItem()
+{
+    delete d_data;
+}
+
+//! \return QwtPlotItem::Rtti_PlotZone
+int QwtPlotZoneItem::rtti() const
+{
+    return QwtPlotItem::Rtti_PlotZone;
+}
+
+/*! 
+  Build and assign a pen
+    
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
+  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
+  to hide this incompatibility.
+    
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+    
+  \sa pen(), brush()
+ */ 
+void QwtPlotZoneItem::setPen( const QColor &color, qreal width, Qt::PenStyle style )
+{   
+    setPen( QPen( color, width, style ) );
+}
+
+/*!
+  \brief Assign a pen 
+
+  The pen is used to draw the border lines of the zone
+
+  \param pen Pen
+  \sa pen(), setBrush()
+*/
+void QwtPlotZoneItem::setPen( const QPen &pen )
+{
+    if ( d_data->pen != pen )
+    {
+        d_data->pen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Pen used to draw the border lines
+  \sa setPen(), brush()
+*/
+const QPen &QwtPlotZoneItem::pen() const
+{
+    return d_data->pen;
+}
+
+/*! 
+  \brief Assign a brush 
+    
+  The brush is used to fill the zone
+
+  \param brush Brush
+  \sa pen(), setBrush()
+*/
+void QwtPlotZoneItem::setBrush( const QBrush &brush )
+{
+    if ( d_data->brush != brush )
+    {
+        d_data->brush = brush;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Brush used to fill the zone
+  \sa setPen(), brush()
+*/
+const QBrush &QwtPlotZoneItem::brush() const
+{
+    return d_data->brush;
+}
+
+/*!
+  \brief Set the orientation of the zone
+
+  A horizontal zone highlights an interval of the y axis, 
+  a vertical zone of the x axis. It is unbounded in the 
+  opposite direction.
+
+  \sa orientation(), QwtPlotItem::setAxes()
+*/
+void QwtPlotZoneItem::setOrientation( Qt::Orientation orientation )
+{
+    if ( d_data->orientation != orientation )
+    {
+        d_data->orientation = orientation;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Orientation of the zone
+  \sa setOrientation()
+ */
+Qt::Orientation QwtPlotZoneItem::orientation()
+{
+    return d_data->orientation;
+}
+
+/*!
+  Set the interval of the zone
+
+  For a horizontal zone the interval is related to the y axis,
+  for a vertical zone it is related to the x axis.
+
+  \param min Minimum of the interval
+  \param max Maximum of the interval
+
+  \sa interval(), setOrientation()
+ */
+void QwtPlotZoneItem::setInterval( double min, double max )
+{
+    setInterval( QwtInterval( min, max ) );
+}
+
+/*!
+  Set the interval of the zone
+
+  For a horizontal zone the interval is related to the y axis,
+  for a vertical zone it is related to the x axis.
+
+  \param interval Zone interval
+
+  \sa interval(), setOrientation()
+ */
+void QwtPlotZoneItem::setInterval( const QwtInterval &interval )
+{
+    if ( d_data->interval != interval )
+    {
+        d_data->interval = interval;
+        itemChanged(); 
+    }   
+}   
+
+/*!
+  \return Zone interval
+  \sa setInterval(), orientation()
+ */
+QwtInterval QwtPlotZoneItem::interval() const
+{
+    return d_data->interval;
+}   
+
+/*!
+  Draw the zone
+
+  \param painter Painter
+  \param xMap x Scale Map
+  \param yMap y Scale Map
+  \param canvasRect Contents rectangle of the canvas in painter coordinates
+*/
+
+void QwtPlotZoneItem::draw( QPainter *painter,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QRectF &canvasRect ) const
+{
+    if ( !d_data->interval.isValid() )
+        return;
+
+    QPen pen = d_data->pen;
+    pen.setCapStyle( Qt::FlatCap );
+
+    const bool doAlign = QwtPainter::roundingAlignment( painter );
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        double y1 = yMap.transform( d_data->interval.minValue() );
+        double y2 = yMap.transform( d_data->interval.maxValue() );
+
+        if ( doAlign )
+        {
+            y1 = qRound( y1 );
+            y2 = qRound( y2 );
+        }
+
+        QRectF r( canvasRect.left(), y1, canvasRect.width(), y2 - y1 );
+        r = r.normalized();
+
+        if ( ( d_data->brush.style() != Qt::NoBrush ) && ( y1 != y2 ) )
+        {
+            QwtPainter::fillRect( painter, r, d_data->brush );
+        }
+
+        if ( d_data->pen.style() != Qt::NoPen )
+        {
+            painter->setPen( d_data->pen );
+
+            QwtPainter::drawLine( painter, r.left(), r.top(), r.right(), r.top() );
+            QwtPainter::drawLine( painter, r.left(), r.bottom(), r.right(), r.bottom() );
+        }
+    }
+    else
+    {
+        double x1 = xMap.transform( d_data->interval.minValue() );
+        double x2 = xMap.transform( d_data->interval.maxValue() );
+
+        if ( doAlign )
+        {
+            x1 = qRound( x1 );
+            x2 = qRound( x2 );
+        }
+
+        QRectF r( x1, canvasRect.top(), x2 - x1, canvasRect.height() );
+        r = r.normalized();
+
+        if ( ( d_data->brush.style() != Qt::NoBrush ) && ( x1 != x2 ) )
+        {
+            QwtPainter::fillRect( painter, r, d_data->brush );
+        }
+
+        if ( d_data->pen.style() != Qt::NoPen )
+        {
+            painter->setPen( d_data->pen );
+
+            QwtPainter::drawLine( painter, r.left(), r.top(), r.left(), r.bottom() );
+            QwtPainter::drawLine( painter, r.right(), r.top(), r.right(), r.bottom() );
+        }
+    }
+}
+
+/*! 
+  The bounding rectangle is build from the interval in one direction
+  and something invalid for the opposite direction.
+
+  \return An invalid rectangle with valid boundaries in one direction
+*/
+QRectF QwtPlotZoneItem::boundingRect() const
+{
+    QRectF br = QwtPlotItem::boundingRect();
+
+    const QwtInterval &intv = d_data->interval;
+
+    if ( intv.isValid() )
+    {
+        if ( d_data->orientation == Qt::Horizontal )
+        {
+            br.setTop( intv.minValue() );
+            br.setBottom( intv.maxValue() );
+        }
+        else
+        {
+            br.setLeft( intv.minValue() );
+            br.setRight( intv.maxValue() );
+        }
+    }
+
+    return br;
+}
Index: trunk/BNC/qwt/qwt_plot_zoneitem.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_zoneitem.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_plot_zoneitem.h	(revision 8127)
@@ -0,0 +1,65 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_PLOT_ZONE_ITEM_H
+#define QWT_PLOT_ZONE_ITEM_H
+
+#include "qwt_global.h"
+#include "qwt_plot_item.h"
+#include "qwt_interval.h"
+
+class QPen;
+class QBrush;
+
+/*!
+  \brief A plot item, which displays a zone
+
+  A horizontal zone highlights an interval of the y axis - a vertical 
+  zone an interval of the x axis - and is unbounded in the opposite direction.
+  It is filled with a brush and its border lines are optionally displayed with a pen. 
+
+  \note For displaying an area that is bounded for x and y coordinates 
+        use QwtPlotShapeItem
+*/
+
+class QWT_EXPORT QwtPlotZoneItem: 
+    public QwtPlotItem
+{
+public:
+    explicit QwtPlotZoneItem();
+    virtual ~QwtPlotZoneItem();
+
+    virtual int rtti() const;
+
+    void setOrientation( Qt::Orientation );
+    Qt::Orientation orientation();
+
+    void setInterval( double min, double max );
+    void setInterval( const QwtInterval & );
+    QwtInterval interval() const;
+
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
+    void setPen( const QPen & );
+    const QPen &pen() const;
+
+    void setBrush( const QBrush & );
+    const QBrush &brush() const;
+
+    virtual void draw( QPainter *,
+        const QwtScaleMap &, const QwtScaleMap &,
+        const QRectF &) const;
+
+    virtual QRectF boundingRect() const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_plot_zoomer.cpp
===================================================================
--- trunk/BNC/qwt/qwt_plot_zoomer.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_zoomer.cpp	(revision 8127)
@@ -10,8 +10,69 @@
 #include "qwt_plot_zoomer.h"
 #include "qwt_plot.h"
-#include "qwt_plot_canvas.h"
 #include "qwt_scale_div.h"
 #include "qwt_picker_machine.h"
 #include <qalgorithms.h>
+
+static QwtInterval qwtExpandedZoomInterval( double v1, double v2, 
+    double minRange, const QwtTransform* transform )
+{
+    double min = v1;
+    double max = v2;
+
+    if ( max - min < minRange )
+    {
+        min = 0.5 * ( min + max - minRange );
+        max = min + minRange;
+
+        if ( transform )
+        {
+            // f.e the logarithmic scale doesn't allow values
+            // outside [QwtLogTransform::LogMin/QwtLogTransform::LogMax]
+
+            double minBounded = transform->bounded( min );
+            double maxBounded = transform->bounded( max );
+
+            if ( minBounded != min )
+            {
+                maxBounded = transform->bounded( minBounded + minRange );
+            }
+            else if ( maxBounded != max )
+            {
+                minBounded = transform->bounded( maxBounded - minRange );
+            }
+
+            min = minBounded;
+            max = maxBounded;
+        }
+    }
+
+    return QwtInterval( min, max );
+}
+
+static QRectF qwtExpandedZoomRect( const QRectF &zoomRect, const QSizeF &minSize,
+    const QwtTransform* transformX, const QwtTransform* transformY )
+{
+    QRectF r = zoomRect;
+
+    if ( minSize.width() > r.width() )
+    {
+        const QwtInterval intv = qwtExpandedZoomInterval(
+            r.left(), r.right(), minSize.width(), transformX );
+
+        r.setLeft( intv.minValue() );
+        r.setRight( intv.maxValue() );
+    }
+
+    if ( minSize.height() > r.height() )
+    {
+        const QwtInterval intv = qwtExpandedZoomInterval(
+            zoomRect.top(), zoomRect.bottom(), minSize.height(), transformY );
+
+        r.setTop( intv.minValue() );
+        r.setBottom( intv.maxValue() );
+    }
+
+    return r;
+}
 
 class QwtPlotZoomer::PrivateData
@@ -33,9 +94,9 @@
 
   The zoomer is initialized with a QwtPickerDragRectMachine,
-  the tracker mode is set to QwtPicker::ActiveOnly and the rubberband
+  the tracker mode is set to QwtPicker::ActiveOnly and the rubber band
   is set to QwtPicker::RectRubberBand
 
   \param canvas Plot canvas to observe, also the parent object
-  \param doReplot Call replot for the attached plot before initializing
+  \param doReplot Call QwtPlot::replot() for the attached plot before initializing
                   the zoomer with its scales. This might be necessary,
                   when the plot is in a state with pending scale changes.
@@ -43,5 +104,5 @@
   \sa QwtPlot::autoReplot(), QwtPlot::replot(), setZoomBase()
 */
-QwtPlotZoomer::QwtPlotZoomer( QwtPlotCanvas *canvas, bool doReplot ):
+QwtPlotZoomer::QwtPlotZoomer( QWidget *canvas, bool doReplot ):
     QwtPlotPicker( canvas )
 {
@@ -54,5 +115,5 @@
 
   The zoomer is initialized with a QwtPickerDragRectMachine,
-  the tracker mode is set to QwtPicker::ActiveOnly and the rubberband
+  the tracker mode is set to QwtPicker::ActiveOnly and the rubber band
   is set to QwtPicker;;RectRubberBand
 
@@ -60,5 +121,5 @@
   \param yAxis Y axis of the zoomer
   \param canvas Plot canvas to observe, also the parent object
-  \param doReplot Call replot for the attached plot before initializing
+  \param doReplot Call QwtPlot::replot() for the attached plot before initializing
                   the zoomer with its scales. This might be necessary,
                   when the plot is in a state with pending scale changes.
@@ -68,5 +129,5 @@
 
 QwtPlotZoomer::QwtPlotZoomer( int xAxis, int yAxis,
-        QwtPlotCanvas *canvas, bool doReplot ):
+        QWidget *canvas, bool doReplot ):
     QwtPlotPicker( xAxis, yAxis, canvas )
 {
@@ -141,6 +202,6 @@
 
 /*!
-  Return the zoom stack. zoomStack()[0] is the zoom base,
-  zoomStack()[1] the first zoomed rectangle.
+  \return The zoom stack. zoomStack()[0] is the zoom base,
+          zoomStack()[1] the first zoomed rectangle.
 
   \sa setZoomStack(), zoomRectIndex()
@@ -163,5 +224,5 @@
   Reinitialized the zoom stack with scaleRect() as base.
 
-  \param doReplot Call replot for the attached plot before initializing
+  \param doReplot Call QwtPlot::replot() for the attached plot before initializing
                   the zoomer with its scales. This might be necessary,
                   when the plot is in a state with pending scale changes.
@@ -189,5 +250,5 @@
 
   base is united with the current scaleRect() and the zoom stack is
-  reinitalized with it as zoom base. plot is zoomed to scaleRect().
+  reinitialized with it as zoom base. plot is zoomed to scaleRect().
 
   \param base Zoom base
@@ -218,6 +279,5 @@
 
 /*!
-  Rectangle at the current position on the zoom stack.
-
+  \return Rectangle at the current position on the zoom stack.
   \sa zoomRectIndex(), scaleRect().
 */
@@ -239,5 +299,5 @@
 
   Clears all rectangles above the current position of the
-  zoom stack and pushs the normalized rect on it.
+  zoom stack and pushes the normalized rectangle on it.
 
   \note If the maximal stack depth is reached, zoom is ignored.
@@ -275,5 +335,5 @@
 
   Activate a rectangle on the zoom stack with an offset relative
-  to the current position. Negative values of offest will zoom out,
+  to the current position. Negative values of offset will zoom out,
   positive zoom in. A value of 0 zooms out to the zoom base.
 
@@ -344,5 +404,5 @@
   Adjust the observed plot to zoomRect()
 
-  \note Initiates QwtPlot::replot
+  \note Initiates QwtPlot::replot()
 */
 
@@ -361,9 +421,6 @@
         double x1 = rect.left();
         double x2 = rect.right();
-        if ( plt->axisScaleDiv( xAxis() )->lowerBound() >
-            plt->axisScaleDiv( xAxis() )->upperBound() )
-        {
+        if ( !plt->axisScaleDiv( xAxis() ).isIncreasing() )
             qSwap( x1, x2 );
-        }
 
         plt->setAxisScale( xAxis(), x1, x2 );
@@ -371,9 +428,7 @@
         double y1 = rect.top();
         double y2 = rect.bottom();
-        if ( plt->axisScaleDiv( yAxis() )->lowerBound() >
-            plt->axisScaleDiv( yAxis() )->upperBound() )
-        {
+        if ( !plt->axisScaleDiv( yAxis() ).isIncreasing() )
             qSwap( y1, y2 );
-        }
+
         plt->setAxisScale( yAxis(), y1, y2 );
 
@@ -495,10 +550,10 @@
   \brief Check and correct a selected rectangle
 
-  Reject rectangles with a hight or width < 2, otherwise
+  Reject rectangles with a height or width < 2, otherwise
   expand the selected rectangle to a minimum size of 11x11
   and accept it.
 
-  \return true If rect is accepted, or has been changed
-          to a accepted rectangle.
+  \return true If the rectangle is accepted, or has been changed
+          to an accepted one.
 */
 
@@ -573,5 +628,9 @@
   if accepted.
 
+  \param ok If true, complete the selection and emit selected signals
+            otherwise discard the selection.
+
   \sa accept(), minZoomSize()
+  \return True if the selection has been accepted, false otherwise
 */
 bool QwtPlotZoomer::end( bool ok )
@@ -592,13 +651,11 @@
     rect = rect.normalized();
 
-    QRectF zoomRect = invTransform( rect ).normalized();
-
-    const QSizeF minSize = minZoomSize();
-    if ( minSize.isValid() )
-    {
-        const QPointF center = zoomRect.center();
-        zoomRect.setSize( zoomRect.size().expandedTo( minZoomSize() ) );
-        zoomRect.moveCenter( center );
-    }
+    const QwtScaleMap xMap = plot->canvasMap( xAxis() );
+    const QwtScaleMap yMap = plot->canvasMap( yAxis() );
+
+    QRectF zoomRect = QwtScaleMap::invTransform( xMap, yMap, rect ).normalized();
+
+    zoomRect = qwtExpandedZoomRect( zoomRect, minZoomSize(),
+        xMap.transformation(), yMap.transformation() );
 
     zoom( zoomRect );
Index: trunk/BNC/qwt/qwt_plot_zoomer.h
===================================================================
--- trunk/BNC/qwt/qwt_plot_zoomer.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_plot_zoomer.h	(revision 8127)
@@ -18,23 +18,59 @@
   \brief QwtPlotZoomer provides stacked zooming for a plot widget
 
-  QwtPlotZoomer offers rubberband selections on the plot canvas,
-  translating the selected rectangles into plot coordinates and
-  adjusting the axes to them. Zooming can repeated as often as
-  possible, limited only by maxStackDepth() or minZoomSize().
-  Each rectangle is pushed on a stack.
+  QwtPlotZoomer selects rectangles from user inputs ( mouse or keyboard )
+  translates them into plot coordinates and adjusts the axes to them.
+  The selection is supported by a rubber band and optionally by displaying
+  the coordinates of the current mouse position.
 
-  Zoom rectangles can be selected depending on selectionFlags() using the
-  mouse or keyboard (QwtEventPattern, QwtPickerMachine).
-  QwtEventPattern::MouseSelect3,QwtEventPattern::KeyUndo,
-  or QwtEventPattern::MouseSelect6,QwtEventPattern::KeyRedo
-  walk up and down the zoom stack.
-  QwtEventPattern::MouseSelect2 or QwtEventPattern::KeyHome unzoom to
-  the initial size.
+  Zooming can be repeated as often as possible, limited only by 
+  maxStackDepth() or minZoomSize().  Each rectangle is pushed on a stack.
+
+  The default setting how to select rectangles is 
+  a QwtPickerDragRectMachine with the following bindings:
+
+  - QwtEventPattern::MouseSelect1\n
+    The first point of the zoom rectangle is selected by a mouse press, 
+    the second point from the position, where the mouse is released.
+
+  - QwtEventPattern::KeySelect1\n
+    The first key press selects the first, the second key press
+    selects the second point.
+
+  - QwtEventPattern::KeyAbort\n
+    Discard the selection in the state, where the first point
+    is selected.
+
+  To traverse the zoom stack the following bindings are used:
+
+  - QwtEventPattern::MouseSelect3, QwtEventPattern::KeyUndo\n
+    Zoom out one position on the zoom stack
+    
+  - QwtEventPattern::MouseSelect6, QwtEventPattern::KeyRedo\n
+    Zoom in one position on the zoom stack
+
+  - QwtEventPattern::MouseSelect2, QwtEventPattern::KeyHome\n
+    Zoom to the zoom base
+
+  The setKeyPattern() and setMousePattern() functions can be used
+  to configure the zoomer actions. The following example 
+  shows, how to configure the 'I' and 'O' keys for zooming in and out 
+  one position on the zoom stack. The "Home" key is used to 
+  "unzoom" the plot.
+
+  \code
+   zoomer = new QwtPlotZoomer( plot );
+   zoomer->setKeyPattern( QwtEventPattern::KeyRedo, Qt::Key_I, Qt::ShiftModifier );
+   zoomer->setKeyPattern( QwtEventPattern::KeyUndo, Qt::Key_O, Qt::ShiftModifier );
+   zoomer->setKeyPattern( QwtEventPattern::KeyHome, Qt::Key_Home );
+  \endcode
 
   QwtPlotZoomer is tailored for plots with one x and y axis, but it is
-  allowed to attach a second QwtPlotZoomer for the other axes.
+  allowed to attach a second QwtPlotZoomer ( without rubber band and tracker )
+  for the other axes.
 
   \note The realtime example includes an derived zoomer class that adds
         scrollbars to the plot canvas.
+
+  \sa QwtPlotPanner, QwtPlotMagnifier
 */
 
@@ -43,7 +79,7 @@
     Q_OBJECT
 public:
-    explicit QwtPlotZoomer( QwtPlotCanvas *, bool doReplot = true );
+    explicit QwtPlotZoomer( QWidget *, bool doReplot = true );
     explicit QwtPlotZoomer( int xAxis, int yAxis,
-                            QwtPlotCanvas *, bool doReplot = true );
+                            QWidget *, bool doReplot = true );
 
     virtual ~QwtPlotZoomer();
Index: trunk/BNC/qwt/qwt_point_3d.h
===================================================================
--- trunk/BNC/qwt/qwt_point_3d.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_point_3d.h	(revision 8127)
@@ -103,5 +103,5 @@
 
 /*!
-    Returns true if the point is null; otherwise returns false.
+    \return True if the point is null; otherwise returns false.
 
     A point is considered to be null if x, y and z-coordinates
@@ -110,8 +110,8 @@
 inline bool QwtPoint3D::isNull() const
 {
-    return d_x == 0.0 && d_y == 0.0 && d_z == 0;
+    return d_x == 0.0 && d_y == 0.0 && d_z == 0.0;
 }
 
-//! Returns the x-coordinate of the point.
+//! \return The x-coordinate of the point.
 inline double QwtPoint3D::x() const
 {
@@ -119,5 +119,5 @@
 }
 
-//! Returns the y-coordinate of the point.
+//! \return The y-coordinate of the point.
 inline double QwtPoint3D::y() const
 {
@@ -125,5 +125,5 @@
 }
 
-//! Returns the z-coordinate of the point.
+//! \return The z-coordinate of the point.
 inline double QwtPoint3D::z() const
 {
@@ -131,5 +131,5 @@
 }
 
-//! Returns a reference to the x-coordinate of the point.
+//! \return A reference to the x-coordinate of the point.
 inline double &QwtPoint3D::rx()
 {
@@ -137,5 +137,5 @@
 }
 
-//! Returns a reference to the y-coordinate of the point.
+//! \return A reference to the y-coordinate of the point.
 inline double &QwtPoint3D::ry()
 {
@@ -143,5 +143,5 @@
 }
 
-//! Returns a reference to the z-coordinate of the point.
+//! \return A reference to the z-coordinate of the point.
 inline double &QwtPoint3D::rz()
 {
@@ -168,5 +168,5 @@
 
 /*!
-   Rounds 2D point, where the z coordinate is dropped.
+   \return 2D point, where the z coordinate is dropped.
 */
 inline QPointF QwtPoint3D::toPoint() const
@@ -175,5 +175,5 @@
 }
 
-//! Returns true if this point and other are equal; otherwise returns false.
+//! \return True, if this point and other are equal; otherwise returns false.
 inline bool QwtPoint3D::operator==( const QwtPoint3D &other ) const
 {
@@ -181,5 +181,5 @@
 }
 
-//! Returns true if this rect and other are different; otherwise returns false.
+//! \return True if this rect and other are different; otherwise returns false.
 inline bool QwtPoint3D::operator!=( const QwtPoint3D &other ) const
 {
Index: trunk/BNC/qwt/qwt_point_data.cpp
===================================================================
--- trunk/BNC/qwt/qwt_point_data.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_point_data.cpp	(revision 8127)
@@ -0,0 +1,307 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_point_data.h"
+#include "qwt_math.h"
+#include <string.h>
+
+/*!
+  Constructor
+
+  \param x Array of x values
+  \param y Array of y values
+
+  \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
+*/
+QwtPointArrayData::QwtPointArrayData(
+        const QVector<double> &x, const QVector<double> &y ):
+    d_x( x ),
+    d_y( y )
+{
+}
+
+/*!
+  Constructor
+
+  \param x Array of x values
+  \param y Array of y values
+  \param size Size of the x and y arrays
+  \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
+*/
+QwtPointArrayData::QwtPointArrayData( const double *x,
+        const double *y, size_t size )
+{
+    d_x.resize( size );
+    ::memcpy( d_x.data(), x, size * sizeof( double ) );
+
+    d_y.resize( size );
+    ::memcpy( d_y.data(), y, size * sizeof( double ) );
+}
+
+/*!
+  \brief Calculate the bounding rectangle
+
+  The bounding rectangle is calculated once by iterating over all
+  points and is stored for all following requests.
+
+  \return Bounding rectangle
+*/
+QRectF QwtPointArrayData::boundingRect() const
+{
+    if ( d_boundingRect.width() < 0 )
+        d_boundingRect = qwtBoundingRect( *this );
+
+    return d_boundingRect;
+}
+
+//! \return Size of the data set
+size_t QwtPointArrayData::size() const
+{
+    return qMin( d_x.size(), d_y.size() );
+}
+
+/*!
+  Return the sample at position i
+
+  \param index Index
+  \return Sample at position i
+*/
+QPointF QwtPointArrayData::sample( size_t index ) const
+{
+    return QPointF( d_x[int( index )], d_y[int( index )] );
+}
+
+//! \return Array of the x-values
+const QVector<double> &QwtPointArrayData::xData() const
+{
+    return d_x;
+}
+
+//! \return Array of the y-values
+const QVector<double> &QwtPointArrayData::yData() const
+{
+    return d_y;
+}
+
+/*!
+  Constructor
+
+  \param x Array of x values
+  \param y Array of y values
+  \param size Size of the x and y arrays
+
+  \warning The programmer must assure that the memory blocks referenced
+           by the pointers remain valid during the lifetime of the
+           QwtPlotCPointer object.
+
+  \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
+*/
+QwtCPointerData::QwtCPointerData(
+        const double *x, const double *y, size_t size ):
+    d_x( x ),
+    d_y( y ),
+    d_size( size )
+{
+}
+
+/*!
+  \brief Calculate the bounding rectangle
+
+  The bounding rectangle is calculated once by iterating over all
+  points and is stored for all following requests.
+
+  \return Bounding rectangle
+*/
+QRectF QwtCPointerData::boundingRect() const
+{
+    if ( d_boundingRect.width() < 0 )
+        d_boundingRect = qwtBoundingRect( *this );
+
+    return d_boundingRect;
+}
+
+//! \return Size of the data set
+size_t QwtCPointerData::size() const
+{
+    return d_size;
+}
+
+/*!
+  Return the sample at position i
+
+  \param index Index
+  \return Sample at position i
+*/
+QPointF QwtCPointerData::sample( size_t index ) const
+{
+    return QPointF( d_x[int( index )], d_y[int( index )] );
+}
+
+//! \return Array of the x-values
+const double *QwtCPointerData::xData() const
+{
+    return d_x;
+}
+
+//! \return Array of the y-values
+const double *QwtCPointerData::yData() const
+{
+    return d_y;
+}
+
+/*!
+   Constructor
+
+   \param size Number of points
+   \param interval Bounding interval for the points
+
+   \sa setInterval(), setSize()
+*/
+QwtSyntheticPointData::QwtSyntheticPointData(
+        size_t size, const QwtInterval &interval ):
+    d_size( size ),
+    d_interval( interval )
+{
+}
+
+/*!
+  Change the number of points
+
+  \param size Number of points
+  \sa size(), setInterval()
+*/
+void QwtSyntheticPointData::setSize( size_t size )
+{
+    d_size = size;
+}
+
+/*!
+  \return Number of points
+  \sa setSize(), interval()
+*/
+size_t QwtSyntheticPointData::size() const
+{
+    return d_size;
+}
+
+/*!
+   Set the bounding interval
+
+   \param interval Interval
+   \sa interval(), setSize()
+*/
+void QwtSyntheticPointData::setInterval( const QwtInterval &interval )
+{
+    d_interval = interval.normalized();
+}
+
+/*!
+   \return Bounding interval
+   \sa setInterval(), size()
+*/
+QwtInterval QwtSyntheticPointData::interval() const
+{
+    return d_interval;
+}
+
+/*!
+   Set a the "rectangle of interest"
+
+   QwtPlotSeriesItem defines the current area of the plot canvas
+   as "rect of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
+
+   If interval().isValid() == false the x values are calculated
+   in the interval rect.left() -> rect.right().
+
+   \sa rectOfInterest()
+*/
+void QwtSyntheticPointData::setRectOfInterest( const QRectF &rect )
+{
+    d_rectOfInterest = rect;
+    d_intervalOfInterest = QwtInterval(
+        rect.left(), rect.right() ).normalized();
+}
+
+/*!
+   \return "rectangle of interest"
+   \sa setRectOfInterest()
+*/
+QRectF QwtSyntheticPointData::rectOfInterest() const
+{
+    return d_rectOfInterest;
+}
+
+/*!
+  \brief Calculate the bounding rectangle
+
+  This implementation iterates over all points, what could often
+  be implemented much faster using the characteristics of the series.
+  When there are many points it is recommended to overload and
+  reimplement this method using the characteristics of the series
+  ( if possible ).
+
+  \return Bounding rectangle
+*/
+QRectF QwtSyntheticPointData::boundingRect() const
+{
+    if ( d_size == 0 ||
+        !( d_interval.isValid() || d_intervalOfInterest.isValid() ) )
+    {
+        return QRectF( 1.0, 1.0, -2.0, -2.0 ); // something invalid
+    }
+
+    return qwtBoundingRect( *this );
+}
+
+/*!
+   Calculate the point from an index
+
+   \param index Index
+   \return QPointF(x(index), y(x(index)));
+
+   \warning For invalid indices ( index < 0 || index >= size() )
+            (0, 0) is returned.
+*/
+QPointF QwtSyntheticPointData::sample( size_t index ) const
+{
+    if ( index >= d_size )
+        return QPointF( 0, 0 );
+
+    const double xValue = x( index );
+    const double yValue = y( xValue );
+
+    return QPointF( xValue, yValue );
+}
+
+/*!
+   Calculate a x-value from an index
+
+   x values are calculated by dividing an interval into
+   equidistant steps. If !interval().isValid() the
+   interval is calculated from the "rectangle of interest".
+
+   \param index Index of the requested point 
+   \return Calculated x coordinate
+
+   \sa interval(), rectOfInterest(), y()
+*/
+double QwtSyntheticPointData::x( uint index ) const
+{
+    const QwtInterval &interval = d_interval.isValid() ?
+        d_interval : d_intervalOfInterest;
+
+    if ( !interval.isValid() ) 
+        return 0.0;
+
+    if ( d_size <= 1 )
+        return interval.minValue();
+
+    const double dx = interval.width() / ( d_size - 1 );
+    return interval.minValue() + index * dx;
+}
Index: trunk/BNC/qwt/qwt_point_data.h
===================================================================
--- trunk/BNC/qwt/qwt_point_data.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_point_data.h	(revision 8127)
@@ -0,0 +1,146 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_POINT_DATA_H
+#define QWT_POINT_DATA_H 1
+
+#include "qwt_global.h"
+#include "qwt_series_data.h"
+
+/*!
+  \brief Interface for iterating over two QVector<double> objects.
+*/
+class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
+{
+public:
+    QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
+    QwtPointArrayData( const double *x, const double *y, size_t size );
+
+    virtual QRectF boundingRect() const;
+
+    virtual size_t size() const;
+    virtual QPointF sample( size_t i ) const;
+
+    const QVector<double> &xData() const;
+    const QVector<double> &yData() const;
+
+private:
+    QVector<double> d_x;
+    QVector<double> d_y;
+};
+
+/*!
+  \brief Data class containing two pointers to memory blocks of doubles.
+ */
+class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
+{
+public:
+    QwtCPointerData( const double *x, const double *y, size_t size );
+
+    virtual QRectF boundingRect() const;
+    virtual size_t size() const;
+    virtual QPointF sample( size_t i ) const;
+
+    const double *xData() const;
+    const double *yData() const;
+
+private:
+    const double *d_x;
+    const double *d_y;
+    size_t d_size;
+};
+
+/*!
+  \brief Synthetic point data
+
+  QwtSyntheticPointData provides a fixed number of points for an interval.
+  The points are calculated in equidistant steps in x-direction.
+
+  If the interval is invalid, the points are calculated for
+  the "rectangle of interest", what normally is the displayed area on the
+  plot canvas. In this mode you get different levels of detail, when
+  zooming in/out.
+
+  \par Example
+
+  The following example shows how to implement a sinus curve.
+
+  \code
+#include <cmath>
+#include <qwt_series_data.h>
+#include <qwt_plot_curve.h>
+#include <qwt_plot.h>
+#include <qapplication.h>
+
+class SinusData: public QwtSyntheticPointData
+{
+public:
+    SinusData():
+        QwtSyntheticPointData( 100 )
+    {
+    }
+
+    virtual double y( double x ) const
+    {
+        return qSin( x );
+    }
+};
+
+int main(int argc, char **argv)
+{
+    QApplication a( argc, argv );
+
+    QwtPlot plot;
+    plot.setAxisScale( QwtPlot::xBottom, 0.0, 10.0 );
+    plot.setAxisScale( QwtPlot::yLeft, -1.0, 1.0 );
+
+    QwtPlotCurve *curve = new QwtPlotCurve( "y = sin(x)" );
+    curve->setData( new SinusData() );
+    curve->attach( &plot );
+
+    plot.show();
+    return a.exec();
+}
+   \endcode
+*/
+class QWT_EXPORT QwtSyntheticPointData: public QwtSeriesData<QPointF>
+{
+public:
+    QwtSyntheticPointData( size_t size,
+        const QwtInterval & = QwtInterval() );
+
+    void setSize( size_t size );
+    virtual size_t size() const;
+
+    void setInterval( const QwtInterval& );
+    QwtInterval interval() const;
+
+    virtual QRectF boundingRect() const;
+    virtual QPointF sample( size_t i ) const;
+
+    /*!
+       Calculate a y value for a x value
+
+       \param x x value
+       \return Corresponding y value
+     */
+    virtual double y( double x ) const = 0;
+    virtual double x( uint index ) const;
+
+    virtual void setRectOfInterest( const QRectF & );
+    QRectF rectOfInterest() const;
+
+private:
+    size_t d_size;
+    QwtInterval d_interval;
+    QRectF d_rectOfInterest;
+    QwtInterval d_intervalOfInterest;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_point_mapper.cpp
===================================================================
--- trunk/BNC/qwt/qwt_point_mapper.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_point_mapper.cpp	(revision 8127)
@@ -0,0 +1,717 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_point_mapper.h"
+#include "qwt_scale_map.h"
+#include "qwt_pixel_matrix.h"
+#include <qpolygon.h>
+#include <qimage.h>
+#include <qpen.h>
+#include <qpainter.h>
+
+#if QT_VERSION >= 0x040400
+
+#include <qthread.h>
+#include <qfuture.h>
+#include <qtconcurrentrun.h>
+
+#if !defined(QT_NO_QFUTURE)
+#define QWT_USE_THREADS 0
+#endif
+
+#endif
+
+static QRectF qwtInvalidRect( 0.0, 0.0, -1.0, -1.0 );
+
+// Helper class to work around the 5 parameters
+// limitation of QtConcurrent::run()
+class QwtDotsCommand
+{
+public:
+    const QwtSeriesData<QPointF> *series;
+    int from;
+    int to;
+    QRgb rgb;
+};
+
+static void qwtRenderDots(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtDotsCommand command, const QPoint &pos, QImage *image ) 
+{
+    const QRgb rgb = command.rgb;
+    QRgb *bits = reinterpret_cast<QRgb *>( image->bits() );
+
+    const int w = image->width();
+    const int h = image->height();
+
+    const int x0 = pos.x();
+    const int y0 = pos.y();
+
+    for ( int i = command.from; i <= command.to; i++ )
+    {
+        const QPointF sample = command.series->sample( i );
+
+        const int x = static_cast<int>( xMap.transform( sample.x() ) + 0.5 ) - x0;
+        const int y = static_cast<int>( yMap.transform( sample.y() ) + 0.5 ) - y0;
+
+        if ( x >= 0 && x < w && y >= 0 && y < h )
+            bits[ y * w + x ] = rgb;
+    }
+}
+
+static inline int qwtRoundValue( double value )
+{
+    return qRound( value );
+}
+
+// some functors, so that the compile can inline
+struct QwtRoundI
+{
+    inline int operator()( double value )
+    {
+        return qwtRoundValue( value );
+    }
+};
+
+struct QwtRoundF
+{
+    inline double operator()( double value )
+    {
+#if 1
+        // MS Windows and at least IRIX does not have C99's nearbyint() function
+        return ( value >= 0.0 ) ? ::floor( value + 0.5 ) : ::ceil( value - 0.5 );
+#else
+        // slightly faster than the code above
+        return nearbyint( value );
+#endif
+    }
+};
+
+struct QwtNoRoundF
+{   
+    inline double operator()( double value )
+    {
+        return value;
+    }
+};
+
+// mapping points without any filtering - beside checking
+// the bounding rectangle
+
+template<class Polygon, class Point, class Round>
+static inline Polygon qwtToPoints( 
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, 
+    int from, int to, Round round )
+{
+    Polygon polyline( to - from + 1 );
+    Point *points = polyline.data();
+
+    int numPoints = 0;
+
+    if ( boundingRect.isValid() )
+    {
+        // iterating over all values
+        // filtering out all points outside of
+        // the bounding rectangle
+
+        for ( int i = from; i <= to; i++ )
+        {
+            const QPointF sample = series->sample( i );
+
+            const double x = xMap.transform( sample.x() );
+            const double y = yMap.transform( sample.y() );
+
+            if ( boundingRect.contains( x, y ) )
+            {
+                points[ numPoints ].rx() = round( x );
+                points[ numPoints ].ry() = round( y );
+
+                numPoints++;
+            }
+        }
+
+        polyline.resize( numPoints );
+    }
+    else
+    {
+        // simply iterating over all values
+        // without any filtering
+
+        for ( int i = from; i <= to; i++ )
+        {
+            const QPointF sample = series->sample( i );
+
+            const double x = xMap.transform( sample.x() );
+            const double y = yMap.transform( sample.y() );
+
+            points[ numPoints ].rx() = round( x );
+            points[ numPoints ].ry() = round( y );
+
+            numPoints++;
+        }
+    }
+
+    return polyline;
+}
+
+static inline QPolygon qwtToPointsI(
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series,
+    int from, int to )
+{
+    return qwtToPoints<QPolygon, QPoint>( 
+        boundingRect, xMap, yMap, series, from, to, QwtRoundI() );
+}
+
+template<class Round>
+static inline QPolygonF qwtToPointsF(
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series,
+    int from, int to, Round round )
+{
+    return qwtToPoints<QPolygonF, QPointF>( 
+        boundingRect, xMap, yMap, series, from, to, round );
+}
+
+// Mapping points with filtering out consecutive
+// points mapped to the same position
+
+template<class Polygon, class Point, class Round>
+static inline Polygon qwtToPolylineFiltered( 
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, 
+    int from, int to, Round round )
+{
+    // in curves with many points consecutive points
+    // are often mapped to the same position. As this might
+    // result in empty lines ( or symbols hidden by others )
+    // we try to filter them out
+
+    Polygon polyline( to - from + 1 );
+    Point *points = polyline.data();
+
+    const QPointF sample0 = series->sample( from );
+
+    points[0].rx() = round( xMap.transform( sample0.x() ) );
+    points[0].ry() = round( yMap.transform( sample0.y() ) );
+
+    int pos = 0;
+    for ( int i = from + 1; i <= to; i++ )
+    {
+        const QPointF sample = series->sample( i );
+
+        const Point p( round( xMap.transform( sample.x() ) ),
+            round( yMap.transform( sample.y() ) ) );
+
+        if ( points[pos] != p )
+            points[++pos] = p;
+    }
+
+    polyline.resize( pos + 1 );
+    return polyline;
+}
+
+static inline QPolygon qwtToPolylineFilteredI(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series,
+    int from, int to )
+{
+    return qwtToPolylineFiltered<QPolygon, QPoint>(
+        xMap, yMap, series, from, to, QwtRoundI() );
+}
+
+template<class Round>
+static inline QPolygonF qwtToPolylineFilteredF(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series,
+    int from, int to, Round round )
+{
+    return qwtToPolylineFiltered<QPolygonF, QPointF>(
+        xMap, yMap, series, from, to, round );
+} 
+
+template<class Polygon, class Point>
+static inline Polygon qwtToPointsFiltered(
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to )
+{
+    // F.e. in scatter plots ( no connecting lines ) we
+    // can sort out all duplicates ( not only consecutive points )
+
+    Polygon polygon( to - from + 1 );
+    Point *points = polygon.data();
+
+    QwtPixelMatrix pixelMatrix( boundingRect.toAlignedRect() );
+
+    int numPoints = 0;
+    for ( int i = from; i <= to; i++ )
+    {
+        const QPointF sample = series->sample( i );
+
+        const int x = qwtRoundValue( xMap.transform( sample.x() ) );
+        const int y = qwtRoundValue( yMap.transform( sample.y() ) );
+
+        if ( pixelMatrix.testAndSetPixel( x, y, true ) == false )
+        {
+            points[ numPoints ].rx() = x;
+            points[ numPoints ].ry() = y;
+
+            numPoints++;
+        }
+    }
+
+    polygon.resize( numPoints );
+    return polygon;
+}
+
+static inline QPolygon qwtToPointsFilteredI(
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to )
+{
+    return qwtToPointsFiltered<QPolygon, QPoint>(
+        boundingRect, xMap, yMap, series, from, to );
+} 
+
+static inline QPolygonF qwtToPointsFilteredF(
+    const QRectF &boundingRect,
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to )
+{
+    return qwtToPointsFiltered<QPolygonF, QPointF>(
+        boundingRect, xMap, yMap, series, from, to );
+}
+
+class QwtPointMapper::PrivateData
+{
+public:
+    PrivateData():
+        boundingRect( qwtInvalidRect )
+    {
+    }
+
+    QRectF boundingRect;
+    QwtPointMapper::TransformationFlags flags;
+};
+
+//! Constructor
+QwtPointMapper::QwtPointMapper()
+{
+    d_data = new PrivateData();
+}
+
+//! Destructor
+QwtPointMapper::~QwtPointMapper()
+{
+    delete d_data;
+}
+
+/*!
+  Set the flags affecting the transformation process
+
+  \param flags Flags
+  \sa flags(), setFlag()
+ */
+void QwtPointMapper::setFlags( TransformationFlags flags )
+{
+    d_data->flags = flags;
+}
+
+/*!
+  \return Flags affecting the transformation process
+  \sa setFlags(), setFlag()
+ */
+QwtPointMapper::TransformationFlags QwtPointMapper::flags() const
+{
+    return d_data->flags;
+}
+
+/*!
+  Modify a flag affecting the transformation process
+
+  \param flag Flag type
+  \param on Value
+
+  \sa flag(), setFlags()
+ */
+void QwtPointMapper::setFlag( TransformationFlag flag, bool on )
+{
+    if ( on )
+        d_data->flags |= flag;
+    else
+        d_data->flags &= ~flag;
+}
+
+/*!
+  \return True, when the flag is set
+  \param flag Flag type
+  \sa setFlag(), setFlags()
+ */
+bool QwtPointMapper::testFlag( TransformationFlag flag ) const
+{
+    return d_data->flags & flag;
+}
+
+/*!
+  Set a bounding rectangle for the point mapping algorithm
+
+  A valid bounding rectangle can be used for optimizations
+
+  \param rect Bounding rectangle
+  \sa boundingRect()
+ */
+void QwtPointMapper::setBoundingRect( const QRectF &rect )
+{
+    d_data->boundingRect = rect;
+}
+
+/*!
+  \return Bounding rectangle
+  \sa setBoundingRect()
+ */
+QRectF QwtPointMapper::boundingRect() const
+{
+    return d_data->boundingRect;
+}
+
+/*!
+  \brief Translate a series of points into a QPolygonF
+
+  When the WeedOutPoints flag is enabled consecutive points,
+  that are mapped to the same position will be one point. 
+
+  When RoundPoints is set all points are rounded to integers
+  but returned as PolygonF - what only makes sense
+  when the further processing of the values need a QPolygonF.
+
+  \param xMap x map
+  \param yMap y map
+  \param series Series of points to be mapped
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+
+  \return Translated polygon
+*/
+QPolygonF QwtPointMapper::toPolygonF(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to ) const
+{
+    QPolygonF polyline;
+
+    if ( d_data->flags & WeedOutPoints )
+    {
+        if ( d_data->flags & RoundPoints )
+        {
+            polyline = qwtToPolylineFilteredF( 
+                xMap, yMap, series, from, to, QwtRoundF() );
+        }
+        else
+        {
+            polyline = qwtToPolylineFilteredF( 
+                xMap, yMap, series, from, to, QwtNoRoundF() );
+        }
+    }
+    else
+    {
+        if ( d_data->flags & RoundPoints )
+        {
+            polyline = qwtToPointsF( qwtInvalidRect, 
+                xMap, yMap, series, from, to, QwtRoundF() );
+        }
+        else
+        {
+            polyline = qwtToPointsF( qwtInvalidRect, 
+                xMap, yMap, series, from, to, QwtNoRoundF() );
+        }
+    }
+
+    return polyline;
+}
+
+/*!
+  \brief Translate a series of points into a QPolygon
+
+  When the WeedOutPoints flag is enabled consecutive points,
+  that are mapped to the same position will be one point. 
+
+  \param xMap x map
+  \param yMap y map
+  \param series Series of points to be mapped
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+
+  \return Translated polygon
+*/
+QPolygon QwtPointMapper::toPolygon(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to ) const
+{
+    QPolygon polyline;
+
+    if ( d_data->flags & WeedOutPoints )
+    {
+        polyline = qwtToPolylineFilteredI( 
+            xMap, yMap, series, from, to );
+    }
+    else
+    {
+        polyline = qwtToPointsI( 
+            qwtInvalidRect, xMap, yMap, series, from, to );
+    }
+
+    return polyline;
+}
+
+/*!
+  \brief Translate a series into a QPolygonF
+
+  - WeedOutPoints & RoundPoints & boundingRect().isValid()
+    All points that are mapped to the same position 
+    will be one point. Points outside of the bounding
+    rectangle are ignored.
+ 
+  - WeedOutPoints & RoundPoints & !boundingRect().isValid()
+    All consecutive points that are mapped to the same position 
+    will one point
+
+  - WeedOutPoints & !RoundPoints 
+    All consecutive points that are mapped to the same position 
+    will one point
+
+  - !WeedOutPoints & boundingRect().isValid()
+    Points outside of the bounding rectangle are ignored.
+
+  When RoundPoints is set all points are rounded to integers
+  but returned as PolygonF - what only makes sense
+  when the further processing of the values need a QPolygonF.
+
+  \param xMap x map
+  \param yMap y map
+  \param series Series of points to be mapped
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+
+  \return Translated polygon
+*/
+QPolygonF QwtPointMapper::toPointsF(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to ) const
+{
+    QPolygonF points;
+
+    if ( d_data->flags & WeedOutPoints )
+    {
+        if ( d_data->flags & RoundPoints )
+        {
+            if ( d_data->boundingRect.isValid() )
+            {   
+                points = qwtToPointsFilteredF( d_data->boundingRect,
+                    xMap, yMap, series, from, to );
+            }
+            else
+            {   
+                // without a bounding rectangle all we can
+                // do is to filter out duplicates of
+                // consecutive points
+
+                points = qwtToPolylineFilteredF( 
+                    xMap, yMap, series, from, to, QwtRoundF() );
+            }
+        }
+        else
+        {
+            // when rounding is not allowed we can't use
+            // qwtToPointsFilteredF
+
+            points = qwtToPolylineFilteredF( 
+                xMap, yMap, series, from, to, QwtNoRoundF() );
+        }
+    }
+    else
+    {
+        if ( d_data->flags & RoundPoints )
+        {
+            points = qwtToPointsF( d_data->boundingRect,
+                xMap, yMap, series, from, to, QwtRoundF() );
+        }
+        else
+        {
+            points = qwtToPointsF( d_data->boundingRect,
+                xMap, yMap, series, from, to, QwtNoRoundF() );
+        }
+    }
+
+    return points;
+}
+
+/*!
+  \brief Translate a series of points into a QPolygon
+
+  - WeedOutPoints & boundingRect().isValid()
+    All points that are mapped to the same position 
+    will be one point. Points outside of the bounding
+    rectangle are ignored.
+ 
+  - WeedOutPoints & !boundingRect().isValid()
+    All consecutive points that are mapped to the same position 
+    will one point
+
+  - !WeedOutPoints & boundingRect().isValid()
+    Points outside of the bounding rectangle are ignored.
+
+  \param xMap x map
+  \param yMap y map
+  \param series Series of points to be mapped
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+
+  \return Translated polygon
+*/
+QPolygon QwtPointMapper::toPoints(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to ) const
+{
+    QPolygon points;
+
+    if ( d_data->flags & WeedOutPoints )
+    {
+        if ( d_data->boundingRect.isValid() )
+        {
+            points = qwtToPointsFilteredI( d_data->boundingRect,
+                xMap, yMap, series, from, to );
+        }
+        else
+        {
+            // when we don't have the bounding rectangle all
+            // we can do is to filter out consecutive duplicates
+
+            points = qwtToPolylineFilteredI( 
+                xMap, yMap, series, from, to );
+        }
+    }
+    else
+    {
+        points = qwtToPointsI( 
+            d_data->boundingRect, xMap, yMap, series, from, to );
+    }
+
+    return points;
+}
+
+
+/*!
+  \brief Translate a series into a QImage
+
+  \param xMap x map
+  \param yMap y map
+  \param series Series of points to be mapped
+  \param from Index of the first point to be painted
+  \param to Index of the last point to be painted
+  \param pen Pen used for drawing a point
+             of the image, where a point is mapped to
+  \param antialiased True, when the dots should be displayed
+                     antialiased
+  \param numThreads Number of threads to be used for rendering.
+                   If numThreads is set to 0, the system specific
+                   ideal thread count is used.
+
+  \return Image displaying the series
+*/
+QImage QwtPointMapper::toImage(
+    const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+    const QwtSeriesData<QPointF> *series, int from, int to, 
+    const QPen &pen, bool antialiased, uint numThreads ) const
+{
+    Q_UNUSED( antialiased )
+
+#if QWT_USE_THREADS
+    if ( numThreads == 0 )
+        numThreads = QThread::idealThreadCount();
+
+    if ( numThreads <= 0 )
+        numThreads = 1;
+#else
+    Q_UNUSED( numThreads )
+#endif
+
+    // a very special optimization for scatter plots
+    // where every sample is mapped to one pixel only.
+
+    const QRect rect = d_data->boundingRect.toAlignedRect();
+
+    QImage image( rect.size(), QImage::Format_ARGB32 );
+    image.fill( Qt::transparent );
+
+    if ( pen.width() <= 1 && pen.color().alpha() == 255 )
+    {
+        QwtDotsCommand command;
+        command.series = series;
+        command.rgb = pen.color().rgba();
+
+#if QWT_USE_THREADS
+        const int numPoints = ( to - from + 1 ) / numThreads;
+
+        QList< QFuture<void> > futures;
+        for ( uint i = 0; i < numThreads; i++ )
+        {
+            const QPoint pos = rect.topLeft();
+
+            const int index0 = from + i * numPoints;
+            if ( i == numThreads - 1 )
+            {
+                command.from = index0;
+                command.to = to;
+
+                qwtRenderDots( xMap, yMap, command, pos, &image );
+            }
+            else
+            {
+                command.from = index0;
+                command.to = index0 + numPoints - 1;
+
+                futures += QtConcurrent::run( &qwtRenderDots, 
+                    xMap, yMap, command, pos, &image );
+            }
+        }
+        for ( int i = 0; i < futures.size(); i++ )
+            futures[i].waitForFinished();
+#else
+        command.from = from;
+        command.to = to;
+
+        qwtRenderDots( xMap, yMap, command, rect.topLeft(), &image );
+#endif
+    }
+    else
+    {
+        // fallback implementation: to be replaced later by
+        // setting the pixels of the image like above, TODO ...
+
+        QPainter painter( &image );
+        painter.setPen( pen );
+        painter.setRenderHint( QPainter::Antialiasing, antialiased );
+
+        const int chunkSize = 1000;
+        for ( int i = from; i <= to; i += chunkSize )
+        {
+            const int indexTo = qMin( i + chunkSize - 1, to );
+            const QPolygon points = toPoints(
+                xMap, yMap, series, i, indexTo );
+
+            painter.drawPoints( points );
+        }
+    }
+
+    return image;
+}
Index: trunk/BNC/qwt/qwt_point_mapper.h
===================================================================
--- trunk/BNC/qwt/qwt_point_mapper.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_point_mapper.h	(revision 8127)
@@ -0,0 +1,89 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_POINT_MAPPER_H
+#define QWT_POINT_MAPPER_H
+
+#include "qwt_global.h"
+#include "qwt_series_data.h"
+#include <qimage.h>
+
+class QwtScaleMap;
+class QPolygonF;
+class QPolygon;
+
+/*!
+  \brief A helper class for translating a series of points
+
+  QwtPointMapper is a collection of methods and optimizations
+  for translating a series of points into paint device coordinates. 
+  It is used by QwtPlotCurve but might also be useful for 
+  similar plot items displaying a QwtSeriesData<QPointF>.
+ */
+class QWT_EXPORT QwtPointMapper
+{
+public:
+    /*!  
+      \brief Flags affecting the transformation process
+      \sa setFlag(), setFlags()
+     */
+    enum TransformationFlag
+    {
+        //! Round points to integer values
+        RoundPoints = 0x01,
+
+        /*! 
+          Try to remove points, that are translated to the
+          same position.
+         */
+        WeedOutPoints = 0x02
+    };
+
+    /*!  
+      \brief Flags affecting the transformation process
+      \sa setFlag(), setFlags()
+     */
+    typedef QFlags<TransformationFlag> TransformationFlags;
+
+    QwtPointMapper();
+    ~QwtPointMapper();
+
+    void setFlags( TransformationFlags );
+    TransformationFlags flags() const;
+
+    void setFlag( TransformationFlag, bool on = true );
+    bool testFlag( TransformationFlag ) const;
+
+    void setBoundingRect( const QRectF & );
+    QRectF boundingRect() const;
+
+    QPolygonF toPolygonF( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QwtSeriesData<QPointF> *series, int from, int to ) const;
+
+    QPolygon toPolygon( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QwtSeriesData<QPointF> *series, int from, int to ) const;
+
+    QPolygon toPoints( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QwtSeriesData<QPointF> *series, int from, int to ) const;
+
+    QPolygonF toPointsF( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QwtSeriesData<QPointF> *series, int from, int to ) const;
+
+    QImage toImage( const QwtScaleMap &xMap, const QwtScaleMap &yMap,
+        const QwtSeriesData<QPointF> *series, int from, int to, 
+        const QPen &, bool antialiased, uint numThreads ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPointMapper::TransformationFlags )
+
+#endif
Index: trunk/BNC/qwt/qwt_point_polar.cpp
===================================================================
--- trunk/BNC/qwt/qwt_point_polar.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_point_polar.cpp	(revision 8127)
@@ -39,4 +39,6 @@
    Convert and return values in Cartesian coordinates
 
+   \return Converted point in Cartesian coordinates
+
    \note Invalid or null points will be returned as QPointF(0.0, 0.0)
    \sa isValid(), isNull()
@@ -54,9 +56,11 @@
 
 /*!
-    Returns true if point1 is equal to point2; otherwise returns false.
+    \brief Compare 2 points
 
     Two points are equal to each other if radius and
     azimuth-coordinates are the same. Points are not equal, when
     the azimuth differs, but other.azimuth() == azimuth() % (2 * PI).
+
+    \return True if the point is equal to other; otherwise return false.
 
     \sa normalized()
@@ -68,5 +72,5 @@
 
 /*!
-    Returns true if point1 is not equal to point2; otherwise returns false.
+    Compare 2 points
 
     Two points are equal to each other if radius and
@@ -74,4 +78,5 @@
     the azimuth differs, but other.azimuth() == azimuth() % (2 * PI).
 
+    \return True if the point is not equal to other; otherwise return false.
     \sa normalized()
 */
@@ -86,4 +91,6 @@
    When the radius is < 0.0 it is set to 0.0. The azimuth is
    a value >= 0.0 and < 2 * M_PI.
+
+   \return Normalized point
 */
 QwtPointPolar QwtPointPolar::normalized() const
Index: trunk/BNC/qwt/qwt_point_polar.h
===================================================================
--- trunk/BNC/qwt/qwt_point_polar.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_point_polar.h	(revision 8127)
@@ -63,5 +63,5 @@
 /*!
     Constructs a null point, with a radius and azimuth set to 0.0.
-    \sa QPointF::isNull
+    \sa QPointF::isNull()
 */
 inline QwtPointPolar::QwtPointPolar():
@@ -195,3 +195,9 @@
 } 
 
+inline QwtPointPolar qwtFastPos2Polar( const QPointF &pos )
+{
+    return QwtPointPolar( qwtFastAtan2( pos.y(), pos.x() ),
+        qSqrt( qwtSqr( pos.x() ) + qwtSqr( pos.y() ) ) );
+}
+
 #endif 
Index: trunk/BNC/qwt/qwt_raster_data.cpp
===================================================================
--- trunk/BNC/qwt/qwt_raster_data.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_raster_data.cpp	(revision 8127)
@@ -10,4 +10,5 @@
 #include "qwt_raster_data.h"
 #include "qwt_point_3d.h"
+#include <qnumeric.h>
 
 class QwtRasterData::ContourPlane
@@ -94,5 +95,5 @@
         case 6:
             // e(-1,1,0), e(1,0,-1)
-            line[0] = vertex[1].toPoint();
+            line[0] = vertex[2].toPoint();
             line[1] = intersection( vertex[0], vertex[1] );
             break;
@@ -181,9 +182,9 @@
   \brief Initialize a raster
 
-  Before the composition of an image QwtPlotSpectrogram calls initRaster,
+  Before the composition of an image QwtPlotSpectrogram calls initRaster(),
   announcing the area and its resolution that will be requested.
 
   The default implementation does nothing, but for data sets that
-  are stored in files, it might be good idea to reimplement initRaster,
+  are stored in files, it might be good idea to reimplement initRaster(),
   where the data is resampled and loaded into memory.
 
@@ -221,5 +222,5 @@
    
    Width and height of the hint need to be the horizontal  
-   and vertical distances between 2 neighboured points. 
+   and vertical distances between 2 neighbored points. 
    The center of the hint has to be the position of any point 
    ( it doesn't matter which one ).
@@ -247,4 +248,11 @@
 /*!
    Calculate contour lines
+
+   \param rect Bounding rectangle for the contour lines
+   \param raster Number of data pixels of the raster data
+   \param levels List of limits, where to insert contour lines
+   \param flags Flags to customize the contouring algorithm
+
+   \return Calculated contour lines
 
    An adaption of CONREC, a simple contouring algorithm.
@@ -337,4 +345,10 @@
                 if ( z > zMax )
                     zMax = z;
+            }
+
+            if ( qIsNaN( zSum ) )
+            {
+                // one of the points is NaN
+                continue;
             }
 
Index: trunk/BNC/qwt/qwt_raster_data.h
===================================================================
--- trunk/BNC/qwt/qwt_raster_data.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_raster_data.h	(revision 8127)
@@ -39,5 +39,5 @@
     enum ConrecFlag
     {
-        //! Ignore all verices on the same level
+        //! Ignore all vertices on the same level
         IgnoreAllVerticesOnLevel = 0x01,
 
Index: trunk/BNC/qwt/qwt_round_scale_draw.cpp
===================================================================
--- trunk/BNC/qwt/qwt_round_scale_draw.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_round_scale_draw.cpp	(revision 8127)
@@ -12,4 +12,5 @@
 #include "qwt_scale_div.h"
 #include "qwt_scale_map.h"
+#include "qwt_math.h"
 #include <qpen.h>
 #include <qpainter.h>
@@ -21,8 +22,8 @@
 public:
     PrivateData():
-        center( 50, 50 ),
-        radius( 50 ),
-        startAngle( -135 * 16 ),
-        endAngle( 135 * 16 )
+        center( 50.0, 50.0 ),
+        radius( 50.0 ),
+        startAngle( -135.0 ),
+        endAngle( 135.0 )
     {
     }
@@ -64,5 +65,5 @@
   \sa moveCenter()
 */
-void QwtRoundScaleDraw::setRadius( int radius )
+void QwtRoundScaleDraw::setRadius( double radius )
 {
     d_data->radius = radius;
@@ -74,7 +75,8 @@
   Radius is the radius of the backbone without ticks and labels.
 
+  \return Radius of the scale
   \sa setRadius(), extent()
 */
-int QwtRoundScaleDraw::radius() const
+double QwtRoundScaleDraw::radius() const
 {
     return d_data->radius;
@@ -110,16 +112,18 @@
   <li>The angle range is limited to [-360, 360] degrees. Angles exceeding
       this range will be clipped.
-  <li>For angles more than 359 degrees above or below min(angle1, angle2),
+  <li>For angles more or equal than 360 degrees above or below min(angle1, angle2),
       scale marks will not be drawn.
-  <li>If you need a counterclockwise scale, use QwtScaleDiv::setRange
+  <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval()
   </ul>
 */
 void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 )
 {
+#if 0
     angle1 = qBound( -360.0, angle1, 360.0 );
     angle2 = qBound( -360.0, angle2, 360.0 );
-
-    d_data->startAngle = angle1 * 16.0;
-    d_data->endAngle = angle2 * 16.0;
+#endif
+
+    d_data->startAngle = angle1;
+    d_data->endAngle = angle2;
 
     if ( d_data->startAngle == d_data->endAngle )
@@ -142,15 +146,15 @@
 void QwtRoundScaleDraw::drawLabel( QPainter *painter, double value ) const
 {
+    const double tval = scaleMap().transform( value );
+    if ( ( tval >= d_data->startAngle + 360.0 )
+        || ( tval <= d_data->startAngle - 360.0 ) )
+    {
+        return;
+    }
+
     const QwtText label = tickLabel( painter->font(), value );
     if ( label.isEmpty() )
         return;
 
-    const double tval = scaleMap().transform( value );
-    if ( ( tval > d_data->startAngle + 359 * 16 )
-        || ( tval < d_data->startAngle - 359 * 16 ) )
-    {
-        return;
-    }
-
     double radius = d_data->radius;
     if ( hasComponent( QwtAbstractScaleDraw::Ticks ) ||
@@ -164,10 +168,10 @@
 
     const QSizeF sz = label.textSize( painter->font() );
-    const double arc = tval / 16.0 / 360.0 * 2 * M_PI;
+    const double arc = qwtRadians( tval );
 
     const double x = d_data->center.x() +
         ( radius + sz.width() / 2.0 ) * qSin( arc );
     const double y = d_data->center.y() -
-        ( radius + sz.height() / 2.0 ) * cos( arc );
+        ( radius + sz.height() / 2.0 ) * qCos( arc );
 
     const QRectF r( x - sz.width() / 2, y - sz.height() / 2,
@@ -196,8 +200,8 @@
     const double radius = d_data->radius;
 
-    if ( ( tval <= d_data->startAngle + 359 * 16 )
-        || ( tval >= d_data->startAngle - 359 * 16 ) )
-    {
-        const double arc = double( tval ) / 16.0 * M_PI / 180.0;
+    if ( ( tval < d_data->startAngle + 360.0 )
+        && ( tval > d_data->startAngle - 360.0 ) )
+    {
+        const double arc = qwtRadians( tval );
 
         const double sinArc = qSin( arc );
@@ -221,6 +225,9 @@
 void QwtRoundScaleDraw::drawBackbone( QPainter *painter ) const
 {
-    const double a1 = qMin( scaleMap().p1(), scaleMap().p2() ) - 90 * 16;
-    const double a2 = qMax( scaleMap().p1(), scaleMap().p2() ) - 90 * 16;
+    const double deg1 = scaleMap().p1();
+    const double deg2 = scaleMap().p2();
+
+    const int a1 = qRound( qMin( deg1, deg2 ) - 90 );
+    const int a2 = qRound( qMax( deg1, deg2 ) - 90 );
 
     const double radius = d_data->radius;
@@ -228,6 +235,6 @@
     const double y = d_data->center.y() - radius;
 
-    painter->drawArc( x, y, 2 * radius, 2 * radius,
-        -a2, a2 - a1 + 1 );          // counterclockwise
+    painter->drawArc( QRectF( x, y, 2 * radius, 2 * radius ),
+        -a2 * 16, ( a2 - a1 + 1 ) * 16 );          // counterclockwise
 }
 
@@ -240,7 +247,8 @@
 
    \param font Font used for painting the labels
+   \return Calculated extent
 
    \sa setMinimumExtent(), minimumExtent()
-   \warning The implemented algo is not too smart and
+   \warning The implemented algorithm is not too smart and
             calculates only an upper limit, that might be a
             few pixels too large
@@ -260,13 +268,13 @@
                 continue;
 
-            const QwtText label = tickLabel( font, value );
-            if ( label.isEmpty() )
-                continue;
-
             const double tval = scaleMap().transform( value );
-            if ( ( tval < d_data->startAngle + 360 * 16 )
-                && ( tval > d_data->startAngle - 360 * 16 ) )
+            if ( ( tval < d_data->startAngle + 360 )
+                && ( tval > d_data->startAngle - 360 ) )
             {
-                const double arc = tval / 16.0 / 360.0 * 2 * M_PI;
+                const QwtText label = tickLabel( font, value );
+                if ( label.isEmpty() )
+                    continue;
+
+                const double arc = qwtRadians( tval );
 
                 const QSizeF sz = label.textSize( font );
@@ -290,5 +298,5 @@
     if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
     {
-        const double pw = qMax( 1, penWidth() );  // penwidth can be zero
+        const double pw = qMax( 1, penWidth() );  // pen width can be zero
         d += pw;
     }
Index: trunk/BNC/qwt/qwt_round_scale_draw.h
===================================================================
--- trunk/BNC/qwt/qwt_round_scale_draw.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_round_scale_draw.h	(revision 8127)
@@ -15,13 +15,11 @@
 #include <qpoint.h>
 
-class QPen;
-
 /*!
   \brief A class for drawing round scales
 
   QwtRoundScaleDraw can be used to draw round scales.
-  The circle segment can be adjusted by QwtRoundScaleDraw::setAngleRange().
+  The circle segment can be adjusted by setAngleRange().
   The geometry of the scale can be specified with
-  QwtRoundScaleDraw::moveCenter() and QwtRoundScaleDraw::setRadius().
+  moveCenter() and setRadius().
 
   After a scale division has been specified as a QwtScaleDiv object
@@ -36,6 +34,6 @@
     virtual ~QwtRoundScaleDraw();
 
-    void setRadius( int radius );
-    int radius() const;
+    void setRadius( double radius );
+    double radius() const;
 
     void moveCenter( double x, double y );
@@ -48,7 +46,7 @@
 
 protected:
-    virtual void drawTick( QPainter *p, double val, double len ) const;
-    virtual void drawBackbone( QPainter *p ) const;
-    virtual void drawLabel( QPainter *p, double val ) const;
+    virtual void drawTick( QPainter *, double val, double len ) const;
+    virtual void drawBackbone( QPainter * ) const;
+    virtual void drawLabel( QPainter *, double val ) const;
 
 private:
Index: trunk/BNC/qwt/qwt_samples.h
===================================================================
--- trunk/BNC/qwt/qwt_samples.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_samples.h	(revision 8127)
@@ -0,0 +1,239 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_SAMPLES_H
+#define QWT_SAMPLES_H 1
+
+#include "qwt_global.h"
+#include "qwt_interval.h"
+#include <qvector.h>
+#include <qrect.h>
+
+//! \brief A sample of the types (x1-x2, y) or (x, y1-y2)
+class QWT_EXPORT QwtIntervalSample
+{
+public:
+    QwtIntervalSample();
+    QwtIntervalSample( double, const QwtInterval & );
+    QwtIntervalSample( double value, double min, double max );
+
+    bool operator==( const QwtIntervalSample & ) const;
+    bool operator!=( const QwtIntervalSample & ) const;
+
+    //! Value
+    double value;
+
+    //! Interval
+    QwtInterval interval;
+};
+
+/*!
+  Constructor
+  The value is set to 0.0, the interval is invalid
+*/
+inline QwtIntervalSample::QwtIntervalSample():
+    value( 0.0 )
+{
+}
+
+//! Constructor
+inline QwtIntervalSample::QwtIntervalSample(
+        double v, const QwtInterval &intv ):
+    value( v ),
+    interval( intv )
+{
+}
+
+//! Constructor
+inline QwtIntervalSample::QwtIntervalSample(
+        double v, double min, double max ):
+    value( v ),
+    interval( min, max )
+{
+}
+
+//! Compare operator
+inline bool QwtIntervalSample::operator==(
+    const QwtIntervalSample &other ) const
+{
+    return value == other.value && interval == other.interval;
+}
+
+//! Compare operator
+inline bool QwtIntervalSample::operator!=(
+    const QwtIntervalSample &other ) const
+{
+    return !( *this == other );
+}
+
+//! \brief A sample of the types (x1...xn, y) or (x, y1..yn)
+class QWT_EXPORT QwtSetSample
+{
+public:
+    QwtSetSample();
+    QwtSetSample( double, const QVector<double> & = QVector<double>() );
+
+    bool operator==( const QwtSetSample &other ) const;
+    bool operator!=( const QwtSetSample &other ) const;
+
+    double added() const;
+
+    //! value
+    double value;
+
+    //! Vector of values associated to value
+    QVector<double> set;
+};
+
+/*!
+  Constructor
+  The value is set to 0.0
+*/
+inline QwtSetSample::QwtSetSample():
+    value( 0.0 )
+{
+}
+
+/*!
+  Constructor
+
+  \param v Value
+  \param s Set of values
+*/
+inline QwtSetSample::QwtSetSample( double v, const QVector< double > &s ):
+    value( v ),
+    set( s )
+{
+}
+
+//! Compare operator
+inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
+{
+    return value == other.value && set == other.set;
+}
+
+//! Compare operator
+inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
+{
+    return !( *this == other );
+}
+
+//! \return All values of the set added
+inline double QwtSetSample::added() const
+{
+    double y = 0.0;
+    for ( int i = 0; i < set.size(); i++ )
+        y += set[i];
+
+    return y;
+}
+
+/*!
+   \brief Open-High-Low-Close sample used in financial charts
+
+   In financial charts the movement of a price in a time interval is often
+   represented by the opening/closing prices and the lowest/highest prices
+   in this interval.
+
+   \sa QwtTradingChartData
+*/
+class QWT_EXPORT QwtOHLCSample
+{
+public:
+    QwtOHLCSample( double time = 0.0,
+        double open = 0.0, double high = 0.0,
+        double low = 0.0, double close = 0.0 );
+
+    QwtInterval boundingInterval() const;
+
+    bool isValid() const;
+
+    /*!
+      Time of the sample, usually a number representing
+      a specific interval - like a day.
+    */
+    double time;
+
+    //! Opening price
+    double open;
+
+    //! Highest price
+    double high;
+
+    //! Lowest price
+    double low;
+
+    //! Closing price
+    double close;
+};
+
+
+/*!
+  Constructor
+
+  \param t Time value
+  \param o Open value
+  \param h High value
+  \param l Low value
+  \param c Close value
+*/
+inline QwtOHLCSample::QwtOHLCSample( double t,
+        double o, double h, double l, double c ):
+    time( t ),
+    open( o ),
+    high( h ),
+    low( l ),
+    close( c )
+{
+}
+
+/*!
+  \brief Check if a sample is valid
+
+  A sample is valid, when all of the following checks are true:
+
+  - low <= high
+  - low <= open <= high
+  - low <= close <= high
+
+  \return True, when the sample is valid
+ */
+inline bool QwtOHLCSample::isValid() const
+{
+    return ( low <= high )
+        && ( open >= low )
+        && ( open <= high )
+        && ( close >= low )
+        && ( close <= high );
+}
+
+/*!
+   \brief Calculate the bounding interval of the OHLC values
+
+   For valid samples the limits of this interval are always low/high.
+
+   \return Bounding interval
+   \sa isValid()
+ */
+inline QwtInterval QwtOHLCSample::boundingInterval() const
+{
+    double minY = open;
+    minY = qMin( minY, high );
+    minY = qMin( minY, low );
+    minY = qMin( minY, close );
+
+    double maxY = open;
+    maxY = qMax( maxY, high );
+    maxY = qMax( maxY, low );
+    maxY = qMax( maxY, close );
+
+    return QwtInterval( minY, maxY );
+}
+
+#endif
Index: trunk/BNC/qwt/qwt_sampling_thread.h
===================================================================
--- trunk/BNC/qwt/qwt_sampling_thread.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_sampling_thread.h	(revision 8127)
@@ -8,9 +8,9 @@
   \brief A thread collecting samples at regular intervals.
 
-  Contiounous signals are converted into a discrete signal by
+  Continuous signals are converted into a discrete signal by
   collecting samples at regular intervals. A discrete signal
   can be displayed by a QwtPlotSeriesItem on a QwtPlot widget.
 
-  QwtSamplingThread starts a thread calling perodically sample(),
+  QwtSamplingThread starts a thread calling periodically sample(),
   to collect and store ( or emit ) a single sample.
 
@@ -39,5 +39,5 @@
        Collect a sample
 
-       \param elapsed Time since the thread was started in miliseconds
+       \param elapsed Time since the thread was started in milliseconds
      */
     virtual void sample( double elapsed ) = 0;
Index: trunk/BNC/qwt/qwt_scale_div.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_div.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_div.cpp	(revision 8127)
@@ -10,17 +10,22 @@
 #include "qwt_scale_div.h"
 #include "qwt_math.h"
-#include "qwt_interval.h"
 #include <qalgorithms.h>
 
-//! Construct an invalid QwtScaleDiv instance.
-QwtScaleDiv::QwtScaleDiv():
-    d_lowerBound( 0.0 ),
-    d_upperBound( 0.0 ),
-    d_isValid( false )
-{
-}
-
-/*!
-  Construct QwtScaleDiv instance.
+/*!
+  Construct a division without ticks
+
+  \param lowerBound First boundary
+  \param upperBound Second boundary
+
+  \note lowerBound might be greater than upperBound for inverted scales
+ */
+QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound ):
+    d_lowerBound( lowerBound ),
+    d_upperBound( upperBound )
+{
+}
+
+/*!
+  Construct a scale division
 
   \param interval Interval
@@ -30,6 +35,5 @@
         QList<double> ticks[NTickTypes] ):
     d_lowerBound( interval.minValue() ),
-    d_upperBound( interval.maxValue() ),
-    d_isValid( true )
+    d_upperBound( interval.maxValue() )
 {
     for ( int i = 0; i < NTickTypes; i++ )
@@ -38,16 +42,16 @@
 
 /*!
-  Construct QwtScaleDiv instance.
-
-  \param lowerBound First interval limit
-  \param upperBound Second interval limit
+  Construct a scale division
+
+  \param lowerBound First boundary
+  \param upperBound Second boundary
   \param ticks List of major, medium and minor ticks
-*/
-QwtScaleDiv::QwtScaleDiv(
-        double lowerBound, double upperBound,
+
+  \note lowerBound might be greater than upperBound for inverted scales
+*/
+QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound,
         QList<double> ticks[NTickTypes] ):
     d_lowerBound( lowerBound ),
-    d_upperBound( upperBound ),
-    d_isValid( true )
+    d_upperBound( upperBound )
 {
     for ( int i = 0; i < NTickTypes; i++ )
@@ -56,10 +60,105 @@
 
 /*!
+  Construct a scale division
+
+  \param lowerBound First boundary
+  \param upperBound Second boundary
+  \param minorTicks List of minor ticks
+  \param mediumTicks List medium ticks
+  \param majorTicks List of major ticks
+
+  \note lowerBound might be greater than upperBound for inverted scales
+*/
+QwtScaleDiv::QwtScaleDiv( double lowerBound, double upperBound,
+        const QList<double> &minorTicks, 
+        const QList<double> &mediumTicks,
+        const QList<double> &majorTicks ):
+    d_lowerBound( lowerBound ),
+    d_upperBound( upperBound )
+{
+    d_ticks[ MinorTick ] = minorTicks;
+    d_ticks[ MediumTick ] = mediumTicks;
+    d_ticks[ MajorTick ] = majorTicks;
+}
+
+/*!
+  Change the interval
+
+  \param lowerBound First boundary
+  \param upperBound Second boundary
+
+  \note lowerBound might be greater than upperBound for inverted scales
+*/
+void QwtScaleDiv::setInterval( double lowerBound, double upperBound )
+{
+    d_lowerBound = lowerBound;
+    d_upperBound = upperBound;
+}
+
+/*!
    Change the interval
+
    \param interval Interval
 */
 void QwtScaleDiv::setInterval( const QwtInterval &interval )
 {
-    setInterval( interval.minValue(), interval.maxValue() );
+    d_lowerBound = interval.minValue();
+    d_upperBound = interval.maxValue();
+}
+
+/*!
+  \return lowerBound -> upperBound
+*/
+QwtInterval QwtScaleDiv::interval() const
+{
+    return QwtInterval( d_lowerBound, d_upperBound );
+}
+
+/*!
+  Set the first boundary
+
+  \param lowerBound First boundary
+  \sa lowerBiound(), setUpperBound()
+ */
+void QwtScaleDiv::setLowerBound( double lowerBound  )
+{
+    d_lowerBound = lowerBound;
+}
+
+/*!
+  \return First boundary
+  \sa upperBound()
+*/
+double QwtScaleDiv::lowerBound() const
+{
+    return d_lowerBound;
+}   
+
+/*!
+  Set the second boundary
+
+  \param upperBound Second boundary
+  \sa upperBound(), setLowerBound()
+ */
+void QwtScaleDiv::setUpperBound( double upperBound  )
+{
+    d_upperBound = upperBound;
+} 
+
+/*!
+  \return upper bound
+  \sa lowerBound()
+*/
+double QwtScaleDiv::upperBound() const
+{
+    return d_upperBound;
+}
+
+/*!
+  \return upperBound() - lowerBound()
+*/
+double QwtScaleDiv::range() const
+{
+    return d_upperBound - d_lowerBound;
 }
 
@@ -71,6 +170,5 @@
 {
     if ( d_lowerBound != other.d_lowerBound ||
-        d_upperBound != other.d_upperBound ||
-        d_isValid != other.d_isValid )
+        d_upperBound != other.d_upperBound )
     {
         return false;
@@ -88,27 +186,21 @@
 /*!
   \brief Inequality
-  \return true if this instance is not equal to s
-*/
-bool QwtScaleDiv::operator!=( const QwtScaleDiv &s ) const
-{
-    return ( !( *this == s ) );
-}
-
-//! Invalidate the scale division
-void QwtScaleDiv::invalidate()
-{
-    d_isValid = false;
-
-    // detach arrays
-    for ( int i = 0; i < NTickTypes; i++ )
-        d_ticks[i].clear();
-
-    d_lowerBound = d_upperBound = 0;
-}
-
-//! Check if the scale division is valid
-bool QwtScaleDiv::isValid() const
-{
-    return d_isValid;
+  \return true if this instance is not equal to other
+*/
+bool QwtScaleDiv::operator!=( const QwtScaleDiv &other ) const
+{
+    return ( !( *this == other ) );
+}
+
+//! Check if the scale division is empty( lowerBound() == upperBound() )
+bool QwtScaleDiv::isEmpty() const
+{
+    return ( d_lowerBound == d_upperBound );
+}
+
+//! Check if the scale division is increasing( lowerBound() <= upperBound() )
+bool QwtScaleDiv::isIncreasing() const
+{
+    return d_lowerBound <= d_upperBound;
 }
 
@@ -121,7 +213,4 @@
 bool QwtScaleDiv::contains( double value ) const
 {
-    if ( !d_isValid )
-        return false;
-
     const double min = qMin( d_lowerBound, d_upperBound );
     const double max = qMax( d_lowerBound, d_upperBound );
@@ -130,5 +219,8 @@
 }
 
-//! Invert the scale divison
+/*! 
+   Invert the scale division
+   \sa inverted()
+ */
 void QwtScaleDiv::invert()
 {
@@ -142,7 +234,58 @@
         const int size2 = size / 2;
 
-        for ( int i = 0; i < size2; i++ )
-            qSwap( ticks[i], ticks[size - 1 - i] );
+        for ( int j = 0; j < size2; j++ )
+            qSwap( ticks[j], ticks[size - 1 - j] );
     }
+}
+
+/*! 
+  \return A scale division with inverted boundaries and ticks
+  \sa invert()
+ */
+QwtScaleDiv QwtScaleDiv::inverted() const
+{
+    QwtScaleDiv other = *this;
+    other.invert();
+
+    return other;
+}
+
+/*! 
+   Return a scale division with an interval [lowerBound, upperBound]
+   where all ticks outside this interval are removed
+
+   \param lowerBound Lower bound
+   \param upperBound Upper bound
+
+   \return Scale division with all ticks inside of the given interval
+
+   \note lowerBound might be greater than upperBound for inverted scales
+*/
+QwtScaleDiv QwtScaleDiv::bounded( 
+    double lowerBound, double upperBound ) const
+{
+    const double min = qMin( lowerBound, upperBound );
+    const double max = qMax( lowerBound, upperBound );
+
+    QwtScaleDiv sd;
+    sd.setInterval( lowerBound, upperBound );
+
+    for ( int tickType = 0; tickType < QwtScaleDiv::NTickTypes; tickType++ )
+    {
+        const QList<double> &ticks = d_ticks[ tickType ];
+
+        QList<double> boundedTicks;
+        for ( int i = 0; i < ticks.size(); i++ )
+        {
+            const double tick = ticks[i];
+            if ( tick >= min && tick <= max )
+                boundedTicks += tick;
+        }
+
+        sd.setTicks( tickType, boundedTicks );
+    }
+
+    return sd;
+
 }
 
@@ -155,5 +298,5 @@
 void QwtScaleDiv::setTicks( int type, const QList<double> &ticks )
 {
-    if ( type >= 0 || type < NTickTypes )
+    if ( type >= 0 && type < NTickTypes )
         d_ticks[type] = ticks;
 }
@@ -163,11 +306,26 @@
 
    \param type MinorTick, MediumTick or MajorTick
-*/
-const QList<double> &QwtScaleDiv::ticks( int type ) const
-{
-    if ( type >= 0 || type < NTickTypes )
+   \return Tick list
+*/
+QList<double> QwtScaleDiv::ticks( int type ) const
+{
+    if ( type >= 0 && type < NTickTypes )
         return d_ticks[type];
 
-    static QList<double> noTicks;
-    return noTicks;
-}
+    return QList<double>();
+}
+
+#ifndef QT_NO_DEBUG_STREAM
+
+QDebug operator<<( QDebug debug, const QwtScaleDiv &scaleDiv )
+{
+    debug << scaleDiv.lowerBound() << "<->" << scaleDiv.upperBound();
+    debug << "Major: " << scaleDiv.ticks( QwtScaleDiv::MajorTick );
+    debug << "Medium: " << scaleDiv.ticks( QwtScaleDiv::MediumTick );
+    debug << "Minor: " << scaleDiv.ticks( QwtScaleDiv::MinorTick );
+
+    return debug;
+}
+
+#endif
+
Index: trunk/BNC/qwt/qwt_scale_div.h
===================================================================
--- trunk/BNC/qwt/qwt_scale_div.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_div.h	(revision 8127)
@@ -15,15 +15,21 @@
 #include <qlist.h>
 
-class QwtInterval;
+#ifndef QT_NO_DEBUG_STREAM
+#include <qdebug.h>
+#endif
 
 /*!
   \brief A class representing a scale division
 
-  A scale division consists of its limits and 3 list
-  of tick values qualified as major, medium and minor ticks.
+  A Qwt scale is defined by its boundaries and 3 list
+  for the positions of the major, medium and minor ticks.
 
-  In most cases scale divisions are calculated by a QwtScaleEngine.
+  The upperBound() might be smaller than the lowerBound()
+  to indicate inverted scales.
 
-  \sa subDivideInto(), subDivide()
+  Scale divisions can be calculated from a QwtScaleEngine.
+
+  \sa QwtScaleEngine::divideScale(), QwtPlot::setAxisScaleDiv(),
+      QwtAbstractSlider::setScaleDiv()
 */
 
@@ -50,11 +56,18 @@
     };
 
-    explicit QwtScaleDiv();
+    explicit QwtScaleDiv( double lowerBound = 0.0, 
+        double upperBound = 0.0 );
+
     explicit QwtScaleDiv( const QwtInterval &, QList<double>[NTickTypes] );
-    explicit QwtScaleDiv( 
-        double lowerBound, double upperBound, QList<double>[NTickTypes] );
 
-    bool operator==( const QwtScaleDiv &s ) const;
-    bool operator!=( const QwtScaleDiv &s ) const;
+    explicit QwtScaleDiv( double lowerBound, double upperBound,
+        QList<double>[NTickTypes] );
+
+    explicit QwtScaleDiv( double lowerBound, double upperBound, 
+        const QList<double> &minorTicks, const QList<double> &mediumTicks,
+        const QList<double> &majorTicks );
+
+    bool operator==( const QwtScaleDiv & ) const;
+    bool operator!=( const QwtScaleDiv & ) const;
 
     void setInterval( double lowerBound, double upperBound );
@@ -62,17 +75,24 @@
     QwtInterval interval() const;
 
+    void setLowerBound( double );
     double lowerBound() const;
+
+    void setUpperBound( double );
     double upperBound() const;
+
     double range() const;
 
-    bool contains( double v ) const;
+    bool contains( double value ) const;
 
-    void setTicks( int type, const QList<double> & );
-    const QList<double> &ticks( int type ) const;
+    void setTicks( int tickType, const QList<double> & );
+    QList<double> ticks( int tickType ) const;
 
-    void invalidate();
-    bool isValid() const;
+    bool isEmpty() const;
+    bool isIncreasing() const;
 
     void invert();
+    QwtScaleDiv inverted() const;
+
+    QwtScaleDiv bounded( double lowerBound, double upperBound ) const;
 
 private:
@@ -80,53 +100,11 @@
     double d_upperBound;
     QList<double> d_ticks[NTickTypes];
-
-    bool d_isValid;
 };
 
-Q_DECLARE_TYPEINFO(QwtScaleDiv, Q_MOVABLE_TYPE);
+Q_DECLARE_TYPEINFO( QwtScaleDiv, Q_MOVABLE_TYPE );
 
-/*!
-   Change the interval
-   \param lowerBound lower bound
-   \param upperBound upper bound
-*/
-inline void QwtScaleDiv::setInterval( double lowerBound, double upperBound )
-{
-    d_lowerBound = lowerBound;
-    d_upperBound = upperBound;
-}
+#ifndef QT_NO_DEBUG_STREAM
+QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleDiv & );
+#endif
 
-/*!
-  \return lowerBound -> upperBound
-*/
-inline QwtInterval QwtScaleDiv::interval() const
-{
-    return QwtInterval( d_lowerBound, d_upperBound );
-}
-
-/*!
-  \return lower bound
-  \sa upperBound()
-*/
-inline double QwtScaleDiv::lowerBound() const
-{
-    return d_lowerBound;
-}
-
-/*!
-  \return upper bound
-  \sa lowerBound()
-*/
-inline double QwtScaleDiv::upperBound() const
-{
-    return d_upperBound;
-}
-
-/*!
-  \return upperBound() - lowerBound()
-*/
-inline double QwtScaleDiv::range() const
-{
-    return d_upperBound - d_lowerBound;
-}
 #endif
Index: trunk/BNC/qwt/qwt_scale_draw.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_draw.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_draw.cpp	(revision 8127)
@@ -17,4 +17,9 @@
 #include <qmath.h>
 
+#if QT_VERSION < 0x040601
+#define qFastSin(x) qSin(x)
+#define qFastCos(x) qCos(x)
+#endif
+
 class QwtScaleDraw::PrivateData
 {
@@ -59,4 +64,5 @@
    Return alignment of the scale
    \sa setAlignment()
+   \return Alignment of the scale
 */
 QwtScaleDraw::Alignment QwtScaleDraw::alignment() const
@@ -67,4 +73,6 @@
 /*!
    Set the alignment of the scale
+
+   \param align Alignment of the scale
 
    The default alignment is QwtScaleDraw::BottomScale
@@ -81,4 +89,6 @@
   TopScale, BottomScale are horizontal (Qt::Horizontal) scales,
   LeftScale, RightScale are vertical (Qt::Vertical) scales.
+
+  \return Orientation of the scale
 
   \sa alignment()
@@ -108,9 +118,9 @@
   \param end End border distance
 */
-void QwtScaleDraw::getBorderDistHint( const QFont &font,
-                                      int &start, int &end ) const
+void QwtScaleDraw::getBorderDistHint( 
+    const QFont &font, int &start, int &end ) const
 {
     start = 0;
-    end = 0;
+    end = 1.0;
 
     if ( !hasComponent( QwtAbstractScaleDraw::Labels ) )
@@ -189,5 +199,5 @@
 
     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
-    if ( ticks.count() == 0 )
+    if ( ticks.isEmpty() )
         return 0;
 
@@ -200,7 +210,8 @@
     if ( vertical )
     {
-        bRect2.setRect( -bRect2.bottom(), 0, bRect2.height(), bRect2.width() );
-    }
-    int maxDist = 0;
+        bRect2.setRect( -bRect2.bottom(), 0.0, bRect2.height(), bRect2.width() );
+    }
+
+    double maxDist = 0.0;
 
     for ( int i = 1; i < ticks.count(); i++ )
@@ -210,9 +221,9 @@
         if ( vertical )
         {
-            bRect2.setRect( -bRect2.bottom(), 0,
+            bRect2.setRect( -bRect2.bottom(), 0.0,
                 bRect2.height(), bRect2.width() );
         }
 
-        int dist = fm.leading(); // space between the labels
+        double dist = fm.leading(); // space between the labels
         if ( bRect1.right() > 0 )
             dist += bRect1.right();
@@ -224,10 +235,11 @@
     }
 
-    double angle = labelRotation() / 180.0 * M_PI;
+    double angle = qwtRadians( labelRotation() ); 
     if ( vertical )
         angle += M_PI / 2;
 
-    if ( qSin( angle ) == 0.0 )
-        return maxDist;
+    const double sinA = qFastSin( angle ); // qreal -> double
+    if ( qFuzzyCompare( sinA + 1.0, 1.0 ) )
+        return qCeil( maxDist );
 
     const int fmHeight = fm.ascent() - 2;
@@ -235,13 +247,10 @@
     // The distance we need until there is
     // the height of the label font. This height is needed
-    // for the neighbour labal.
-
-    int labelDist = qFloor( fmHeight / qSin( angle ) * qCos( angle ) );
+    // for the neighbored label.
+
+    double labelDist = fmHeight / qFastSin( angle ) * qFastCos( angle );
     if ( labelDist < 0 )
         labelDist = -labelDist;
 
-    // The cast above floored labelDist. We want to ceil.
-    labelDist++;
-
     // For text orientations close to the scale orientation
 
@@ -255,5 +264,5 @@
         labelDist = fmHeight;
 
-    return labelDist;
+    return qCeil( labelDist );
 }
 
@@ -267,4 +276,5 @@
 
    \param font Font used for painting the labels
+   \return Extent
 
    \sa minLength()
@@ -292,5 +302,5 @@
     if ( hasComponent( QwtAbstractScaleDraw::Backbone ) )
     {
-        const double pw = qMax( 1, penWidth() );  // penwidth can be zero
+        const double pw = qMax( 1, penWidth() );  // pen width can be zero
         d += pw;
     }
@@ -304,4 +314,5 @@
 
    \param font Font used for painting the labels
+   \return Minimum length that is needed to draw the scale
 
    \sa extent()
@@ -337,8 +348,9 @@
    Find the position, where to paint a label
 
-   The position has a distance of majTickLength() + spacing() + 1
-   from the backbone. The direction depends on the alignment()
+   The position has a distance that depends on the length of the ticks 
+   in direction of the alignment().
 
    \param value Value
+   \return Position, where to paint a label
 */
 QPointF QwtScaleDraw::labelPosition( double value ) const
@@ -391,5 +403,5 @@
    \param painter Painter
    \param value Value of the tick
-   \param len Lenght of the tick
+   \param len Length of the tick
 
    \sa drawBackbone(), drawLabel()
@@ -597,12 +609,20 @@
   overlapping labels.
 
+  \param length Length of the backbone
+
   \sa move(), minLabelDist()
 */
 void QwtScaleDraw::setLength( double length )
 {
+#if 1
     if ( length >= 0 && length < 10 )
         length = 10;
+
+    // why should we accept negative lengths ???
     if ( length < 0 && length > -10 )
         length = -10;
+#else
+    length = qMax( length, 10 );
+#endif
 
     d_data->len = length;
@@ -648,6 +668,7 @@
 
 /*!
-  Find the bounding rect for the label. The coordinates of
-  the rect are absolute coordinates ( calculated from pos() ).
+  \brief Find the bounding rectangle for the label.
+
+  The coordinates of the rectangle are absolute ( calculated from pos() ).
   in direction of the tick.
 
@@ -655,4 +676,5 @@
   \param value Value
 
+  \return Bounding rectangle
   \sa labelRect()
 */
@@ -677,4 +699,5 @@
    \param size Size of the label
 
+   \return Transformation matrix
    \sa setLabelAlignment(), setLabelRotation()
 */
@@ -740,10 +763,12 @@
 
 /*!
-  Find the bounding rect for the label. The coordinates of
-  the rect are relative to spacing + ticklength from the backbone
+  Find the bounding rectangle for the label. The coordinates of
+  the rectangle are relative to spacing + tick length from the backbone
   in direction of the tick.
 
   \param font Font used for painting
   \param value Value
+
+   \return Bounding rectangle that is needed to draw a label
 */
 QRectF QwtScaleDraw::labelRect( const QFont &font, double value ) const
@@ -769,4 +794,6 @@
    \param font Label font
    \param value Value
+
+   \return Size that is needed to draw a label
 */
 QSizeF QwtScaleDraw::labelSize( const QFont &font, double value ) const
@@ -805,5 +832,5 @@
   \brief Change the label flags
 
-  Labels are aligned to the point ticklength + spacing away from the backbone.
+  Labels are aligned to the point tick length + spacing away from the backbone.
 
   The alignment is relative to the orientation of the label text.
@@ -824,5 +851,5 @@
            The alignment of the label is not the alignment
            of the scale and is not the alignment of the flags
-           (QwtText::flags()) returned from QwtAbstractScaleDraw::label().
+           ( QwtText::flags() ) returned from QwtAbstractScaleDraw::label().
 */
 
@@ -847,5 +874,5 @@
 int QwtScaleDraw::maxLabelWidth( const QFont &font ) const
 {
-    int maxWidth = 0;
+    double maxWidth = 0.0;
 
     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
@@ -855,5 +882,5 @@
         if ( scaleDiv().contains( v ) )
         {
-            const int w = labelSize( font, ticks[i] ).width();
+            const double w = labelSize( font, ticks[i] ).width();
             if ( w > maxWidth )
                 maxWidth = w;
@@ -861,5 +888,5 @@
     }
 
-    return maxWidth;
+    return qCeil( maxWidth );
 }
 
@@ -870,5 +897,5 @@
 int QwtScaleDraw::maxLabelHeight( const QFont &font ) const
 {
-    int maxHeight = 0;
+    double maxHeight = 0.0;
 
     const QList<double> &ticks = scaleDiv().ticks( QwtScaleDiv::MajorTick );
@@ -878,5 +905,5 @@
         if ( scaleDiv().contains( v ) )
         {
-            const int h = labelSize( font, ticks[i] ).height();
+            const double h = labelSize( font, ticks[i] ).height();
             if ( h > maxHeight )
                 maxHeight = h;
@@ -884,5 +911,5 @@
     }
 
-    return maxHeight;
+    return qCeil( maxHeight );
 }
 
Index: trunk/BNC/qwt/qwt_scale_draw.h
===================================================================
--- trunk/BNC/qwt/qwt_scale_draw.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_draw.h	(revision 8127)
@@ -29,5 +29,4 @@
   the scale can be drawn with the QwtAbstractScaleDraw::draw() member.
 */
-
 class QWT_EXPORT QwtScaleDraw: public QwtAbstractScaleDraw
 {
@@ -108,4 +107,8 @@
 /*!
    Move the position of the scale
+
+   \param x X coordinate
+   \param y Y coordinate
+
    \sa move(const QPointF &)
 */
Index: trunk/BNC/qwt/qwt_scale_engine.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_engine.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_engine.cpp	(revision 8127)
@@ -13,4 +13,6 @@
 #include <qalgorithms.h>
 #include <qmath.h>
+#include <float.h>
+#include <limits>
 
 #if QT_VERSION < 0x040601
@@ -19,4 +21,90 @@
 #endif
 
+static inline double qwtLog( double base, double value )
+{
+    return log( value ) / log( base );
+}
+
+static inline QwtInterval qwtLogInterval( double base, const QwtInterval &interval )
+{
+    return QwtInterval( qwtLog( base, interval.minValue() ),
+            qwtLog( base, interval.maxValue() ) );
+}
+
+static inline QwtInterval qwtPowInterval( double base, const QwtInterval &interval ) 
+{
+    return QwtInterval( qPow( base, interval.minValue() ),
+            qPow( base, interval.maxValue() ) );
+}
+
+static inline long double qwtIntervalWidthL( const QwtInterval &interval )
+{
+    if ( !interval.isValid() )
+        return 0.0;
+
+    return static_cast<long double>( interval.maxValue() )
+        - static_cast<long double>( interval.minValue() );
+}
+
+#if 1
+
+// this version often doesn't find the best ticks: f.e for 15: 5, 10
+static double qwtStepSize( double intervalSize, int maxSteps, uint base )
+{
+    const double minStep = 
+        QwtScaleArithmetic::divideInterval( intervalSize, maxSteps, base );
+
+    if ( minStep != 0.0 )
+    {
+        // # ticks per interval
+        const int numTicks = qCeil( qAbs( intervalSize / minStep ) ) - 1;
+
+        // Do the minor steps fit into the interval?
+        if ( qwtFuzzyCompare( ( numTicks +  1 ) * qAbs( minStep ),
+            qAbs( intervalSize ), intervalSize ) > 0 )
+        {
+            // The minor steps doesn't fit into the interval
+            return 0.5 * intervalSize;
+        }
+    }
+
+    return minStep;
+}
+
+#else
+
+static double qwtStepSize( double intervalSize, int maxSteps, uint base )
+{
+    if ( maxSteps <= 0 )
+        return 0.0;
+
+    if ( maxSteps > 2 )
+    {
+        for ( int numSteps = maxSteps; numSteps > 1; numSteps-- )
+        {
+            const double stepSize = intervalSize / numSteps;
+
+            const double p = ::floor( ::log( stepSize ) / ::log( base ) );
+            const double fraction = qPow( base, p );
+
+            for ( uint n = base; n > 1; n /= 2 )
+            {
+                if ( qFuzzyCompare( stepSize, n * fraction ) )
+                    return stepSize;
+
+                if ( n == 3 && ( base % 2 ) == 0 )
+                {
+                    if ( qFuzzyCompare( stepSize, 2 * fraction ) )
+                        return stepSize;
+                }
+            }
+        }
+    }
+
+    return intervalSize * 0.5;
+}
+
+#endif
+
 static const double _eps = 1.0e-6;
 
@@ -24,6 +112,8 @@
   Ceil a value, relative to an interval
 
-  \param value Value to ceil
+  \param value Value to be ceiled
   \param intervalSize Interval size
+
+  \return Rounded value
 
   \sa floorEps()
@@ -35,5 +125,5 @@
 
     value = ( value - eps ) / intervalSize;
-    return qwtCeilF( value ) * intervalSize;
+    return ::ceil( value ) * intervalSize;
 }
 
@@ -41,7 +131,8 @@
   Floor a value, relative to an interval
 
-  \param value Value to floor
+  \param value Value to be floored
   \param intervalSize Interval size
 
+  \return Rounded value
   \sa floorEps()
 */
@@ -51,5 +142,5 @@
 
     value = ( value + eps ) / intervalSize;
-    return qwtFloorF( value ) * intervalSize;
+    return ::floor( value ) * intervalSize;
 }
 
@@ -72,57 +163,36 @@
 
 /*!
-  Find the smallest value out of {1,2,5}*10^n with an integer number n
-  which is greater than or equal to x
-
-  \param x Input value
-*/
-double QwtScaleArithmetic::ceil125( double x )
-{
-    if ( x == 0.0 )
+  Calculate a step size for a given interval
+
+  \param intervalSize Interval size
+  \param numSteps Number of steps
+  \param base Base for the division ( usually 10 )
+
+  \return Calculated step size
+ */
+double QwtScaleArithmetic::divideInterval( 
+    double intervalSize, int numSteps, uint base ) 
+{
+    if ( numSteps <= 0 )
         return 0.0;
 
-    const double sign = ( x > 0 ) ? 1.0 : -1.0;
-    const double lx = ::log10( qFabs( x ) );
-    const double p10 = qwtFloorF( lx );
-
-    double fr = qPow( 10.0, lx - p10 );
-    if ( fr <= 1.0 )
-        fr = 1.0;
-    else if ( fr <= 2.0 )
-        fr = 2.0;
-    else if ( fr <= 5.0 )
-        fr = 5.0;
-    else
-        fr = 10.0;
-
-    return sign * fr * qPow( 10.0, p10 );
-}
-
-/*!
-  \brief Find the largest value out of {1,2,5}*10^n with an integer number n
-  which is smaller than or equal to x
-
-  \param x Input value
-*/
-double QwtScaleArithmetic::floor125( double x )
-{
-    if ( x == 0.0 )
+    const double v = QwtScaleArithmetic::divideEps( intervalSize, numSteps );
+    if ( v == 0.0 )
         return 0.0;
 
-    double sign = ( x > 0 ) ? 1.0 : -1.0;
-    const double lx = ::log10( qFabs( x ) );
-    const double p10 = qwtFloorF( lx );
-
-    double fr = qPow( 10.0, lx - p10 );
-    if ( fr >= 10.0 )
-        fr = 10.0;
-    else if ( fr >= 5.0 )
-        fr = 5.0;
-    else if ( fr >= 2.0 )
-        fr = 2.0;
-    else
-        fr = 1.0;
-
-    return sign * fr * qPow( 10.0, p10 );
+    const double lx = qwtLog( base, qFabs( v ) );
+    const double p = ::floor( lx );
+
+    const double fraction = qPow( base, lx - p );
+
+    uint n = base;
+    while ( ( n > 1 ) && ( fraction <= n / 2 ) )
+        n /= 2;
+
+    double stepSize = n * qPow( base, p );
+    if ( v < 0 )
+        stepSize = -stepSize;
+
+    return stepSize;
 }
 
@@ -134,21 +204,37 @@
         lowerMargin( 0.0 ),
         upperMargin( 0.0 ),
-        referenceValue( 0.0 )
-    {
-    }
-
-    QwtScaleEngine::Attributes attributes;       // scale attributes
-
-    double lowerMargin;      // margins
+        referenceValue( 0.0 ),
+        base( 10 ),
+        transform( NULL )
+    {
+    }
+
+    ~PrivateData()
+    {
+        delete transform;
+    }
+
+    QwtScaleEngine::Attributes attributes;
+
+    double lowerMargin;
     double upperMargin;
 
-    double referenceValue; // reference value
-
+    double referenceValue;
+
+    uint base;
+
+    QwtTransform* transform;
 };
 
-//! Constructor
-QwtScaleEngine::QwtScaleEngine()
+/*!
+  Constructor
+
+  \param base Base of the scale engine
+  \sa setBase()
+ */
+QwtScaleEngine::QwtScaleEngine( uint base )
 {
     d_data = new PrivateData;
+    setBase( base );
 }
 
@@ -158,4 +244,43 @@
 {
     delete d_data;
+}
+
+/*!
+   Assign a transformation
+
+   \param transform Transformation
+
+   The transformation object is used as factory for clones
+   that are returned by transformation()
+
+   The scale engine takes ownership of the transformation.
+
+   \sa QwtTransform::copy(), transformation()
+
+ */
+void QwtScaleEngine::setTransformation( QwtTransform *transform )
+{
+    if ( transform != d_data->transform )
+    {
+        delete d_data->transform;
+        d_data->transform = transform;
+    }
+}
+
+/*!
+   Create and return a clone of the transformation 
+   of the engine. When the engine has no special transformation
+   NULL is returned, indicating no transformation.
+
+   \return A clone of the transfomation
+   \sa setTransformation()
+ */
+QwtTransform *QwtScaleEngine::transformation() const
+{
+    QwtTransform *transform = NULL;
+    if ( d_data->transform )
+        transform = d_data->transform->copy();
+
+    return transform;
 }
 
@@ -193,5 +318,5 @@
 
   \warning
-  \li QwtLog10ScaleEngine measures the margins in decades.
+  \li QwtLogScaleEngine measures the margins in decades.
 
   \sa upperMargin(), lowerMargin()
@@ -215,9 +340,6 @@
     double intervalSize, int numSteps ) const
 {
-    if ( numSteps <= 0 )
-        return 0.0;
-
-    double v = QwtScaleArithmetic::divideEps( intervalSize, numSteps );
-    return QwtScaleArithmetic::ceil125( v );
+    return QwtScaleArithmetic::divideInterval( 
+        intervalSize, numSteps, d_data->base );
 }
 
@@ -228,5 +350,5 @@
   \param value Value
 
-  \sa QwtScaleArithmetic::compareEps()
+  \return True, when the value is inside the interval
 */
 bool QwtScaleEngine::contains(
@@ -275,14 +397,24 @@
 
 /*!
-  \brief Build an interval for a value
+  \brief Build an interval around a value
 
   In case of v == 0.0 the interval is [-0.5, 0.5],
   otherwide it is [0.5 * v, 1.5 * v]
-*/
-
-QwtInterval QwtScaleEngine::buildInterval( double v ) const
-{
-    const double delta = ( v == 0.0 ) ? 0.5 : qAbs( 0.5 * v );
-    return QwtInterval( v - delta, v + delta );
+
+  \param value Initial value
+  \return Calculated interval
+*/
+
+QwtInterval QwtScaleEngine::buildInterval( double value ) const
+{
+    const double delta = ( value == 0.0 ) ? 0.5 : qAbs( 0.5 * value );
+
+    if ( DBL_MAX - delta < value )
+        return QwtInterval( DBL_MAX - delta, DBL_MAX );
+
+    if ( -DBL_MAX + delta > value )
+        return QwtInterval( -DBL_MAX, -DBL_MAX + delta );
+
+    return QwtInterval( value - delta, value + delta );
 }
 
@@ -304,5 +436,5 @@
 
 /*!
-  Check if a attribute is set.
+  \return True, if attribute is enabled.
 
   \param attribute Attribute to be tested
@@ -326,5 +458,5 @@
 
 /*!
-  Return the scale attributes
+  \return Scale attributes
   \sa Attribute, setAttributes(), testAttribute()
 */
@@ -349,6 +481,6 @@
 
 /*!
- \return the reference value
- \sa setReference(), setAttribute()
+  \return the reference value
+  \sa setReference(), setAttribute()
 */
 double QwtScaleEngine::reference() const
@@ -358,20 +490,54 @@
 
 /*!
-  Return a transformation, for linear scales
-*/
-QwtScaleTransformation *QwtLinearScaleEngine::transformation() const
-{
-    return new QwtScaleTransformation( QwtScaleTransformation::Linear );
-}
-
-/*!
-    Align and divide an interval
-
-   \param maxNumSteps Max. number of steps
-   \param x1 First limit of the interval (In/Out)
-   \param x2 Second limit of the interval (In/Out)
-   \param stepSize Step size (Out)
-
-   \sa setAttribute()
+  Set the base of the scale engine
+
+  While a base of 10 is what 99.9% of all applications need
+  certain scales might need a different base: f.e 2
+
+  The default setting is 10
+
+  \param base Base of the engine
+
+  \sa base()
+ */
+void QwtScaleEngine::setBase( uint base )
+{ 
+    d_data->base = qMax( base, 2U );
+}
+
+/*!
+  \return base Base of the scale engine
+  \sa setBase()
+ */
+uint QwtScaleEngine::base() const
+{
+    return d_data->base;
+}
+
+/*!
+  Constructor
+
+  \param base Base of the scale engine
+  \sa setBase()
+ */
+QwtLinearScaleEngine::QwtLinearScaleEngine( uint base ):
+    QwtScaleEngine( base )
+{
+}
+
+//! Destructor
+QwtLinearScaleEngine::~QwtLinearScaleEngine()
+{
+}
+
+/*!
+  Align and divide an interval
+
+  \param maxNumSteps Max. number of steps
+  \param x1 First limit of the interval (In/Out)
+  \param x2 Second limit of the interval (In/Out)
+  \param stepSize Step size (Out)
+
+  \sa setAttribute()
 */
 void QwtLinearScaleEngine::autoScale( int maxNumSteps,
@@ -393,5 +559,6 @@
         interval = buildInterval( interval.minValue() );
 
-    stepSize = divideInterval( interval.width(), qMax( maxNumSteps, 1 ) );
+    stepSize = QwtScaleArithmetic::divideInterval( 
+        interval.width(), qMax( maxNumSteps, 1 ), base() );
 
     if ( !testAttribute( QwtScaleEngine::Floating ) )
@@ -409,19 +576,26 @@
 
 /*!
-   \brief Calculate a scale division
+   \brief Calculate a scale division for an interval
 
    \param x1 First interval limit
    \param x2 Second interval limit
-   \param maxMajSteps Maximum for the number of major steps
-   \param maxMinSteps Maximum number of minor steps
-   \param stepSize Step size. If stepSize == 0, the scaleEngine
+   \param maxMajorSteps Maximum for the number of major steps
+   \param maxMinorSteps Maximum number of minor steps
+   \param stepSize Step size. If stepSize == 0, the engine
                    calculates one.
 
-   \sa QwtScaleEngine::stepSize(), QwtScaleEngine::subDivide()
+   \return Calculated scale division
 */
 QwtScaleDiv QwtLinearScaleEngine::divideScale( double x1, double x2,
-    int maxMajSteps, int maxMinSteps, double stepSize ) const
+    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
 {
     QwtInterval interval = QwtInterval( x1, x2 ).normalized();
+
+    if ( qwtIntervalWidthL( interval ) > std::numeric_limits<double>::max() )
+    {
+        qWarning() << "QwtLinearScaleEngine::divideScale: overflow";
+        return QwtScaleDiv();
+    }
+
     if ( interval.width() <= 0 )
         return QwtScaleDiv();
@@ -430,8 +604,9 @@
     if ( stepSize == 0.0 )
     {
-        if ( maxMajSteps < 1 )
-            maxMajSteps = 1;
-
-        stepSize = divideInterval( interval.width(), maxMajSteps );
+        if ( maxMajorSteps < 1 )
+            maxMajorSteps = 1;
+
+        stepSize = QwtScaleArithmetic::divideInterval( 
+            interval.width(), maxMajorSteps, base() );
     }
 
@@ -441,5 +616,5 @@
     {
         QList<double> ticks[QwtScaleDiv::NTickTypes];
-        buildTicks( interval, stepSize, maxMinSteps, ticks );
+        buildTicks( interval, stepSize, maxMinorSteps, ticks );
 
         scaleDiv = QwtScaleDiv( interval, ticks );
@@ -457,5 +632,5 @@
    \param interval Interval
    \param stepSize Step size
-   \param maxMinSteps Maximum number of minor steps
+   \param maxMinorSteps Maximum number of minor steps
    \param ticks Arrays to be filled with the calculated ticks
 
@@ -463,16 +638,15 @@
 */
 void QwtLinearScaleEngine::buildTicks(
-    const QwtInterval& interval, double stepSize, int maxMinSteps,
+    const QwtInterval& interval, double stepSize, int maxMinorSteps,
     QList<double> ticks[QwtScaleDiv::NTickTypes] ) const
 {
-    const QwtInterval boundingInterval =
-        align( interval, stepSize );
+    const QwtInterval boundingInterval = align( interval, stepSize );
 
     ticks[QwtScaleDiv::MajorTick] =
         buildMajorTicks( boundingInterval, stepSize );
 
-    if ( maxMinSteps > 0 )
-    {
-        buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinSteps, stepSize,
+    if ( maxMinorSteps > 0 )
+    {
+        buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize,
             ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] );
     }
@@ -522,5 +696,5 @@
 
    \param majorTicks Major ticks
-   \param maxMinSteps Maximum number of minor steps
+   \param maxMinorSteps Maximum number of minor steps
    \param stepSize Step size
    \param minorTicks Array to be filled with the calculated minor ticks
@@ -530,22 +704,14 @@
 void QwtLinearScaleEngine::buildMinorTicks(
     const QList<double>& majorTicks,
-    int maxMinSteps, double stepSize,
+    int maxMinorSteps, double stepSize,
     QList<double> &minorTicks,
     QList<double> &mediumTicks ) const
 {
-    double minStep = divideInterval( stepSize, maxMinSteps );
+    double minStep = qwtStepSize( stepSize, maxMinorSteps, base() );
     if ( minStep == 0.0 )
         return;
 
     // # ticks per interval
-    int numTicks = qCeil( qAbs( stepSize / minStep ) ) - 1;
-
-    // Do the minor steps fit into the interval?
-    if ( qwtFuzzyCompare( ( numTicks +  1 ) * qAbs( minStep ),
-        qAbs( stepSize ), stepSize ) > 0 )
-    {
-        numTicks = 1;
-        minStep = stepSize * 0.5;
-    }
+    const int numTicks = qCeil( qAbs( stepSize / minStep ) ) - 1;
 
     int medIndex = -1;
@@ -588,11 +754,24 @@
     const QwtInterval &interval, double stepSize ) const
 {
-    double x1 = QwtScaleArithmetic::floorEps( interval.minValue(), stepSize );
-    if ( qwtFuzzyCompare( interval.minValue(), x1, stepSize ) == 0 )
-        x1 = interval.minValue();
-
-    double x2 = QwtScaleArithmetic::ceilEps( interval.maxValue(), stepSize );
-    if ( qwtFuzzyCompare( interval.maxValue(), x2, stepSize ) == 0 )
-        x2 = interval.maxValue();
+    double x1 = interval.minValue();
+    double x2 = interval.maxValue();
+
+    // when there is no rounding beside some effect, when 
+    // calculating with doubles, we keep the original value
+
+    const double eps = 0.000000000001; // since Qt 4.8: qFuzzyIsNull
+    if ( -DBL_MAX + stepSize <= x1 )
+    {
+        const double x = QwtScaleArithmetic::floorEps( x1, stepSize );
+        if ( qAbs(x) <= eps || !qFuzzyCompare( x1, x ) )
+            x1 = x;
+    }
+
+    if ( DBL_MAX - stepSize >= x2 )
+    {
+        const double x = QwtScaleArithmetic::ceilEps( x2, stepSize );
+        if ( qAbs(x) <= eps || !qFuzzyCompare( x2, x ) )
+            x2 = x;
+    }
 
     return QwtInterval( x1, x2 );
@@ -600,9 +779,18 @@
 
 /*!
-  Return a transformation, for logarithmic (base 10) scales
-*/
-QwtScaleTransformation *QwtLog10ScaleEngine::transformation() const
-{
-    return new QwtScaleTransformation( QwtScaleTransformation::Log10 );
+  Constructor
+
+  \param base Base of the scale engine
+  \sa setBase()
+ */
+QwtLogScaleEngine::QwtLogScaleEngine( uint base ):
+    QwtScaleEngine( base )
+{
+    setTransformation( new QwtLogTransform() );
+}
+
+//! Destructor
+QwtLogScaleEngine::~QwtLogScaleEngine()
+{
 }
 
@@ -617,16 +805,18 @@
    \sa QwtScaleEngine::setAttribute()
 */
-void QwtLog10ScaleEngine::autoScale( int maxNumSteps,
-                                     double &x1, double &x2, double &stepSize ) const
+void QwtLogScaleEngine::autoScale( int maxNumSteps,
+    double &x1, double &x2, double &stepSize ) const
 {
     if ( x1 > x2 )
         qSwap( x1, x2 );
 
-    QwtInterval interval( x1 / qPow( 10.0, lowerMargin() ),
-        x2 * qPow( 10.0, upperMargin() ) );
-
-    if ( interval.maxValue() / interval.minValue() < 10.0 )
-    {
-        // scale width is less than one decade -> build linear scale
+    const double logBase = base();
+
+    QwtInterval interval( x1 / qPow( logBase, lowerMargin() ),
+        x2 * qPow( logBase, upperMargin() ) );
+
+    if ( interval.maxValue() / interval.minValue() < logBase )
+    {
+        // scale width is less than one step -> try to build a linear scale
 
         QwtLinearScaleEngine linearScaler;
@@ -636,7 +826,25 @@
 
         linearScaler.autoScale( maxNumSteps, x1, x2, stepSize );
-        stepSize = ::log10( stepSize );
-
-        return;
+
+        QwtInterval linearInterval = QwtInterval( x1, x2 ).normalized();
+        linearInterval = linearInterval.limited( LOG_MIN, LOG_MAX );
+
+        if ( linearInterval.maxValue() / linearInterval.minValue() < logBase )
+        {
+            // the aligned scale is still less than one step
+
+#if 1
+            // this code doesn't make any sense, but for compatibility
+            // reasons we keep it until 6.2. But it will be ignored
+            // in divideScale
+
+            if ( stepSize < 0.0 )
+                stepSize = -qwtLog( logBase, qAbs( stepSize ) );
+            else
+                stepSize = qwtLog( logBase, stepSize );
+#endif
+
+            return;
+        }
     }
 
@@ -660,5 +868,6 @@
         interval = buildInterval( interval.minValue() );
 
-    stepSize = divideInterval( log10( interval ).width(), qMax( maxNumSteps, 1 ) );
+    stepSize = divideInterval( qwtLogInterval( logBase, interval ).width(), 
+        qMax( maxNumSteps, 1 ) );
     if ( stepSize < 1.0 )
         stepSize = 1.0;
@@ -678,17 +887,17 @@
 
 /*!
-   \brief Calculate a scale division
+   \brief Calculate a scale division for an interval
 
    \param x1 First interval limit
    \param x2 Second interval limit
-   \param maxMajSteps Maximum for the number of major steps
-   \param maxMinSteps Maximum number of minor steps
-   \param stepSize Step size. If stepSize == 0, the scaleEngine
+   \param maxMajorSteps Maximum for the number of major steps
+   \param maxMinorSteps Maximum number of minor steps
+   \param stepSize Step size. If stepSize == 0, the engine
                    calculates one.
 
-   \sa QwtScaleEngine::stepSize(), QwtLog10ScaleEngine::subDivide()
-*/
-QwtScaleDiv QwtLog10ScaleEngine::divideScale( double x1, double x2,
-    int maxMajSteps, int maxMinSteps, double stepSize ) const
+   \return Calculated scale division
+*/
+QwtScaleDiv QwtLogScaleEngine::divideScale( double x1, double x2,
+    int maxMajorSteps, int maxMinorSteps, double stepSize ) const
 {
     QwtInterval interval = QwtInterval( x1, x2 ).normalized();
@@ -698,5 +907,7 @@
         return QwtScaleDiv();
 
-    if ( interval.maxValue() / interval.minValue() < 10.0 )
+    const double logBase = base();
+
+    if ( interval.maxValue() / interval.minValue() < logBase )
     {
         // scale width is less than one decade -> build linear scale
@@ -707,9 +918,6 @@
         linearScaler.setMargins( lowerMargin(), upperMargin() );
 
-        if ( stepSize != 0.0 )
-            stepSize = qPow( 10.0, stepSize );
-
         return linearScaler.divideScale( x1, x2,
-            maxMajSteps, maxMinSteps, stepSize );
+            maxMajorSteps, maxMinorSteps, 0.0 );
     }
 
@@ -717,8 +925,9 @@
     if ( stepSize == 0.0 )
     {
-        if ( maxMajSteps < 1 )
-            maxMajSteps = 1;
-
-        stepSize = divideInterval( log10( interval ).width(), maxMajSteps );
+        if ( maxMajorSteps < 1 )
+            maxMajorSteps = 1;
+
+        stepSize = divideInterval( 
+            qwtLogInterval( logBase, interval ).width(), maxMajorSteps );
         if ( stepSize < 1.0 )
             stepSize = 1.0; // major step must be >= 1 decade
@@ -729,5 +938,5 @@
     {
         QList<double> ticks[QwtScaleDiv::NTickTypes];
-        buildTicks( interval, stepSize, maxMinSteps, ticks );
+        buildTicks( interval, stepSize, maxMinorSteps, ticks );
 
         scaleDiv = QwtScaleDiv( interval, ticks );
@@ -744,5 +953,5 @@
 
    \param interval Interval
-   \param maxMinSteps Maximum number of minor steps
+   \param maxMinorSteps Maximum number of minor steps
    \param stepSize Step size
    \param ticks Arrays to be filled with the calculated ticks
@@ -750,6 +959,6 @@
    \sa buildMajorTicks(), buildMinorTicks
 */
-void QwtLog10ScaleEngine::buildTicks(
-    const QwtInterval& interval, double stepSize, int maxMinSteps,
+void QwtLogScaleEngine::buildTicks(
+    const QwtInterval& interval, double stepSize, int maxMinorSteps,
     QList<double> ticks[QwtScaleDiv::NTickTypes] ) const
 {
@@ -759,8 +968,8 @@
         buildMajorTicks( boundingInterval, stepSize );
 
-    if ( maxMinSteps > 0 )
-    {
-        ticks[QwtScaleDiv::MinorTick] = buildMinorTicks(
-            ticks[QwtScaleDiv::MajorTick], maxMinSteps, stepSize );
+    if ( maxMinorSteps > 0 )
+    {
+        buildMinorTicks( ticks[QwtScaleDiv::MajorTick], maxMinorSteps, stepSize,
+            ticks[QwtScaleDiv::MinorTick], ticks[QwtScaleDiv::MediumTick] );
     }
 
@@ -777,8 +986,8 @@
    \return Calculated ticks
 */
-QList<double> QwtLog10ScaleEngine::buildMajorTicks(
+QList<double> QwtLogScaleEngine::buildMajorTicks(
     const QwtInterval &interval, double stepSize ) const
 {
-    double width = log10( interval ).width();
+    double width = qwtLogInterval( base(), interval ).width();
 
     int numTicks = qRound( width / stepSize ) + 1;
@@ -806,91 +1015,99 @@
 
    \param majorTicks Major ticks
-   \param maxMinSteps Maximum number of minor steps
+   \param maxMinorSteps Maximum number of minor steps
    \param stepSize Step size
-*/
-QList<double> QwtLog10ScaleEngine::buildMinorTicks(
+   \param minorTicks Array to be filled with the calculated minor ticks
+   \param mediumTicks Array to be filled with the calculated medium ticks
+*/
+void QwtLogScaleEngine::buildMinorTicks(
     const QList<double> &majorTicks,
-    int maxMinSteps, double stepSize ) const
-{
-    if ( stepSize < 1.1 )          // major step width is one decade
-    {
-        if ( maxMinSteps < 1 )
-            return QList<double>();
-
-        int k0, kstep, kmax;
-
-        if ( maxMinSteps >= 8 )
+    int maxMinorSteps, double stepSize,
+    QList<double> &minorTicks,
+    QList<double> &mediumTicks ) const
+{
+    const double logBase = base();
+
+    if ( stepSize < 1.1 )          // major step width is one base
+    {
+        double minStep = divideInterval( stepSize, maxMinorSteps + 1 );
+        if ( minStep == 0.0 )
+            return;
+        
+        const int numSteps = qRound( stepSize / minStep ); 
+
+        int mediumTickIndex = -1;
+        if ( ( numSteps > 2 ) && ( numSteps % 2 == 0 ) )
+            mediumTickIndex = numSteps / 2;
+
+        for ( int i = 0; i < majorTicks.count() - 1; i++ )
         {
-            k0 = 2;
-            kmax = 9;
-            kstep = 1;
+            const double v = majorTicks[i];
+            const double s = logBase / numSteps;
+
+            if ( s >= 1.0 )
+            {
+                if ( !qFuzzyCompare( s, 1.0 ) )
+                    minorTicks += v * s;
+
+                for ( int j = 2; j < numSteps; j++ )
+                {
+                    minorTicks += v * j * s;
+                }
+            }
+            else
+            {
+                for ( int j = 1; j < numSteps; j++ )
+                {
+                    const double tick = v + j * v * ( logBase - 1 ) / numSteps;
+                    if ( j == mediumTickIndex )
+                        mediumTicks += tick;
+                    else
+                        minorTicks += tick;
+                }
+            }
         }
-        else if ( maxMinSteps >= 4 )
+    }
+    else
+    {
+        double minStep = divideInterval( stepSize, maxMinorSteps );
+        if ( minStep == 0.0 )
+            return;
+
+        if ( minStep < 1.0 )
+            minStep = 1.0;
+
+        // # subticks per interval
+        int numTicks = qRound( stepSize / minStep ) - 1;
+
+        // Do the minor steps fit into the interval?
+        if ( qwtFuzzyCompare( ( numTicks +  1 ) * minStep,
+            stepSize, stepSize ) > 0 )
         {
-            k0 = 2;
-            kmax = 8;
-            kstep = 2;
+            numTicks = 0;
         }
-        else if ( maxMinSteps >= 2 )
-        {
-            k0 = 2;
-            kmax = 5;
-            kstep = 3;
-        }
-        else
-        {
-            k0 = 5;
-            kmax = 5;
-            kstep = 1;
-        }
-
-        QList<double> minorTicks;
+
+        if ( numTicks < 1 )
+            return; 
+
+        int mediumTickIndex = -1;
+        if ( ( numTicks > 2 ) && ( numTicks % 2 ) )
+            mediumTickIndex = numTicks / 2;
+
+        // substep factor = base^substeps
+        const qreal minFactor = qMax( qPow( logBase, minStep ), qreal( logBase ) );
 
         for ( int i = 0; i < majorTicks.count(); i++ )
         {
-            const double v = majorTicks[i];
-            for ( int k = k0; k <= kmax; k += kstep )
-                minorTicks += v * double( k );
-        }
-
-        return minorTicks;
-    }
-    else  // major step > one decade
-    {
-        double minStep = divideInterval( stepSize, maxMinSteps );
-        if ( minStep == 0.0 )
-            return QList<double>();
-
-        if ( minStep < 1.0 )
-            minStep = 1.0;
-
-        // # subticks per interval
-        int nMin = qRound( stepSize / minStep ) - 1;
-
-        // Do the minor steps fit into the interval?
-
-        if ( qwtFuzzyCompare( ( nMin +  1 ) * minStep,
-            qAbs( stepSize ), stepSize ) > 0 )
-        {
-            nMin = 0;
-        }
-
-        if ( nMin < 1 )
-            return QList<double>();      // no subticks
-
-        // substep factor = 10^substeps
-        const qreal minFactor = qMax( qPow( 10.0, minStep ), qreal( 10.0 ) );
-
-        QList<double> minorTicks;
-        for ( int i = 0; i < majorTicks.count(); i++ )
-        {
-            double val = majorTicks[i];
-            for ( int k = 0; k < nMin; k++ )
+            double tick = majorTicks[i];
+            for ( int j = 0; j < numTicks; j++ )
             {
-                val *= minFactor;
-                minorTicks += val;
+                tick *= minFactor;
+
+                if ( j == mediumTickIndex )
+                    mediumTicks += tick;
+                else
+                    minorTicks += tick;
             }
         }
-        return minorTicks;
     }
 }
@@ -907,8 +1124,8 @@
   \return Aligned interval
 */
-QwtInterval QwtLog10ScaleEngine::align(
+QwtInterval QwtLogScaleEngine::align(
     const QwtInterval &interval, double stepSize ) const
 {
-    const QwtInterval intv = log10( interval );
+    const QwtInterval intv = qwtLogInterval( base(), interval );
 
     double x1 = QwtScaleArithmetic::floorEps( intv.minValue(), stepSize );
@@ -920,23 +1137,4 @@
         x2 = interval.maxValue();
 
-    return pow10( QwtInterval( x1, x2 ) );
-}
-
-/*!
-  Return the interval [log10(interval.minValue(), log10(interval.maxValue]
-*/
-
-QwtInterval QwtLog10ScaleEngine::log10( const QwtInterval &interval ) const
-{
-    return QwtInterval( ::log10( interval.minValue() ),
-            ::log10( interval.maxValue() ) );
-}
-
-/*!
-  Return the interval [pow10(interval.minValue(), pow10(interval.maxValue]
-*/
-QwtInterval QwtLog10ScaleEngine::pow10( const QwtInterval &interval ) const
-{
-    return QwtInterval( qPow( 10.0, interval.minValue() ),
-            qPow( 10.0, interval.maxValue() ) );
-}
+    return qwtPowInterval( base(), QwtInterval( x1, x2 ) );
+}
Index: trunk/BNC/qwt/qwt_scale_engine.h
===================================================================
--- trunk/BNC/qwt/qwt_scale_engine.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_engine.h	(revision 8127)
@@ -15,5 +15,5 @@
 #include "qwt_interval.h"
 
-class QwtScaleTransformation;
+class QwtTransform;
 
 /*!
@@ -28,6 +28,6 @@
     static double divideEps( double interval, double steps );
 
-    static double ceil125( double x );
-    static double floor125( double x );
+    static double divideInterval( double interval, 
+        int numSteps, uint base );
 };
 
@@ -40,7 +40,5 @@
   The layout of the scale can be varied with setAttribute().
 
-  Qwt offers implementations for logarithmic (log10)
-  and linear scales. Contributions for other types of scale engines
-  (date/time, log2 ... ) are welcome.
+  Qwt offers implementations for logarithmic and linear scales. 
 */
 
@@ -81,6 +79,9 @@
     typedef QFlags<Attribute> Attributes;
 
-    explicit QwtScaleEngine();
+    explicit QwtScaleEngine( uint base = 10 );
     virtual ~QwtScaleEngine();
+
+    void setBase( uint base );
+    uint base() const;
 
     void setAttribute( Attribute, bool on = true );
@@ -113,19 +114,22 @@
       \param x1 First interval limit
       \param x2 Second interval limit
-      \param maxMajSteps Maximum for the number of major steps
-      \param maxMinSteps Maximum number of minor steps
+      \param maxMajorSteps Maximum for the number of major steps
+      \param maxMinorSteps Maximum number of minor steps
       \param stepSize Step size. If stepSize == 0.0, the scaleEngine
                    calculates one.
+
+      \return Calculated scale division
     */
     virtual QwtScaleDiv divideScale( double x1, double x2,
-        int maxMajSteps, int maxMinSteps,
+        int maxMajorSteps, int maxMinorSteps,
         double stepSize = 0.0 ) const = 0;
 
-    //! \return a transformation
-    virtual QwtScaleTransformation *transformation() const = 0;
+    void setTransformation( QwtTransform * );
+    QwtTransform *transformation() const;
 
 protected:
     bool contains( const QwtInterval &, double val ) const;
     QList<double> strip( const QList<double>&, const QwtInterval & ) const;
+
     double divideInterval( double interval, int numSteps ) const;
 
@@ -147,4 +151,7 @@
 {
 public:
+    QwtLinearScaleEngine( uint base = 10 );
+    virtual ~QwtLinearScaleEngine();
+
     virtual void autoScale( int maxSteps,
         double &x1, double &x2, double &stepSize ) const;
@@ -154,5 +161,4 @@
                                      double stepSize = 0.0 ) const;
 
-    virtual QwtScaleTransformation *transformation() const;
 
 protected:
@@ -166,12 +172,11 @@
         const QwtInterval &interval, double stepSize ) const;
 
-    void buildMinorTicks(
-        const QList<double>& majorTicks,
-        int maxMinMark, double step,
-        QList<double> &, QList<double> & ) const;
-};
-
-/*!
-  \brief A scale engine for logarithmic (base 10) scales
+    void buildMinorTicks( const QList<double>& majorTicks,
+        int maxMinorSteps, double stepSize,
+        QList<double> &minorTicks, QList<double> &mediumTicks ) const;
+};
+
+/*!
+  \brief A scale engine for logarithmic scales
 
   The step size is measured in *decades*
@@ -183,7 +188,10 @@
 */
 
-class QWT_EXPORT QwtLog10ScaleEngine: public QwtScaleEngine
-{
-public:
+class QWT_EXPORT QwtLogScaleEngine: public QwtScaleEngine
+{
+public:
+    QwtLogScaleEngine( uint base = 10 );
+    virtual ~QwtLogScaleEngine();
+
     virtual void autoScale( int maxSteps,
         double &x1, double &x2, double &stepSize ) const;
@@ -193,10 +201,5 @@
         double stepSize = 0.0 ) const;
 
-    virtual QwtScaleTransformation *transformation() const;
-
 protected:
-    QwtInterval log10( const QwtInterval& ) const;
-    QwtInterval pow10( const QwtInterval& ) const;
-
     QwtInterval align( const QwtInterval&, double stepSize ) const;
 
@@ -208,7 +211,7 @@
         const QwtInterval &interval, double stepSize ) const;
 
-    QList<double> buildMinorTicks(
-        const QList<double>& majorTicks,
-        int maxMinMark, double step ) const;
+    void buildMinorTicks( const QList<double>& majorTicks,
+        int maxMinorSteps, double stepSize,
+        QList<double> &minorTicks, QList<double> &mediumTicks ) const;
 };
 
Index: trunk/BNC/qwt/qwt_scale_map.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_map.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_map.cpp	(revision 8127)
@@ -9,89 +9,7 @@
 
 #include "qwt_scale_map.h"
+#include "qwt_math.h"
 #include <qrect.h>
-#include <qalgorithms.h>
-#include <qmath.h>
 #include <qdebug.h>
-
-#if QT_VERSION < 0x040601
-#define qExp(x) ::exp(x)
-#endif
-
-//! Smallest allowed value for logarithmic scales: 1.0e-150
-QT_STATIC_CONST_IMPL double QwtScaleMap::LogMin = 1.0e-150;
-
-//! Largest allowed value for logarithmic scales: 1.0e150
-QT_STATIC_CONST_IMPL double QwtScaleMap::LogMax = 1.0e150;
-
-//! Constructor for a linear transformation
-QwtScaleTransformation::QwtScaleTransformation( Type type ):
-    d_type( type )
-{
-}
-
-//! Destructor
-QwtScaleTransformation::~QwtScaleTransformation()
-{
-}
-
-//! Create a clone of the transformation
-QwtScaleTransformation *QwtScaleTransformation::copy() const
-{
-    return new QwtScaleTransformation( d_type );
-}
-
-/*!
-  \brief Transform a value from the coordinate system of a scale
-         into the coordinate system of the paint device
-
-  \param s  Value related to the coordinate system of the scale
-  \param s1 First border of the coordinate system of the scale
-  \param s2 Second border of the coordinate system of the scale
-  \param p1 First border of the coordinate system of the paint device
-  \param p2 Second border of the coordinate system of the paint device
-  \return
-  <dl>
-  <dt>linear mapping:<dd>p1 + (p2 - p1) / (s2 - s1) * (s - s1);</dd>
-  </dl>
-  <dl>
-  <dt>log10 mapping: <dd>p1 + (p2 - p1) / log(s2 / s1) * log(s / s1);</dd>
-  </dl>
-*/
-
-double QwtScaleTransformation::xForm(
-    double s, double s1, double s2, double p1, double p2 ) const
-{
-    if ( d_type == Log10 )
-        return p1 + ( p2 - p1 ) / log( s2 / s1 ) * log( s / s1 );
-    else
-        return p1 + ( p2 - p1 ) / ( s2 - s1 ) * ( s - s1 );
-}
-
-/*!
-  \brief Transform a value from the coordinate system of the paint device
-         into the coordinate system of a scale.
-
-  \param p Value related to the coordinate system of the paint device 
-  \param p1 First border of the coordinate system of the paint device
-  \param p2 Second border of the coordinate system of the paint device
-  \param s1 First border of the coordinate system of the scale
-  \param s2 Second border of the coordinate system of the scale
-  \return
-  <dl>
-  <dt>linear mapping:<dd>s1 + ( s2 - s1 ) / ( p2 - p1 ) * ( p - p1 );</dd>
-  </dl>
-  <dl>
-  <dt>log10 mapping:<dd>exp((p - p1) / (p2 - p1) * log(s2 / s1)) * s1;</dd>
-  </dl>
-*/
-
-double QwtScaleTransformation::invXForm( double p, double p1, double p2,
-    double s1, double s2 ) const
-{
-    if ( d_type == Log10 )
-        return qExp( ( p - p1 ) / ( p2 - p1 ) * log( s2 / s1 ) ) * s1;
-    else
-        return s1 + ( s2 - s1 ) / ( p2 - p1 ) * ( p - p1 );
-}
 
 /*!
@@ -105,8 +23,8 @@
     d_p1( 0.0 ),
     d_p2( 1.0 ),
-    d_cnv( 1.0 )
-{
-    d_transformation = new QwtScaleTransformation(
-        QwtScaleTransformation::Linear );
+    d_cnv( 1.0 ),
+    d_ts1( 0.0 ),
+    d_transform( NULL )
+{
 }
 
@@ -117,7 +35,10 @@
     d_p1( other.d_p1 ),
     d_p2( other.d_p2 ),
-    d_cnv( other.d_cnv )
-{
-    d_transformation = other.d_transformation->copy();
+    d_cnv( other.d_cnv ),
+    d_ts1( other.d_ts1 ),
+    d_transform( NULL )
+{
+    if ( other.d_transform )
+        d_transform = other.d_transform->copy();
 }
 
@@ -127,5 +48,5 @@
 QwtScaleMap::~QwtScaleMap()
 {
-    delete d_transformation;
+    delete d_transform;
 }
 
@@ -138,7 +59,11 @@
     d_p2 = other.d_p2;
     d_cnv = other.d_cnv;
-
-    delete d_transformation;
-    d_transformation = other.d_transformation->copy();
+    d_ts1 = other.d_ts1;
+
+    delete d_transform;
+    d_transform = NULL;
+
+    if ( other.d_transform )
+        d_transform = other.d_transform->copy();
 
     return *this;
@@ -148,14 +73,10 @@
    Initialize the map with a transformation
 */
-void QwtScaleMap::setTransformation(
-    QwtScaleTransformation *transformation )
-{
-    if ( transformation == NULL )
-        return;
-
-    if ( transformation != d_transformation )
+void QwtScaleMap::setTransformation( QwtTransform *transform )
+{
+    if ( transform != d_transform )
     {
-        delete d_transformation;
-        d_transformation = transformation;
+        delete d_transform;
+        d_transform = transform;
     }
 
@@ -164,7 +85,7 @@
 
 //! Get the transformation
-const QwtScaleTransformation *QwtScaleMap::transformation() const
-{
-    return d_transformation;
+const QwtTransform *QwtScaleMap::transformation() const
+{
+    return d_transform;
 }
 
@@ -173,26 +94,19 @@
   \param s1 first border
   \param s2 second border
-  \warning logarithmic scales might be aligned to [LogMin, LogMax]
+  \warning scales might be aligned to 
+           transformation depending boundaries
 */
 void QwtScaleMap::setScaleInterval( double s1, double s2 )
 {
-    if ( d_transformation->type() == QwtScaleTransformation::Log10 )
-    {
-        if ( s1 < LogMin )
-            s1 = LogMin;
-        else if ( s1 > LogMax )
-            s1 = LogMax;
-
-        if ( s2 < LogMin )
-            s2 = LogMin;
-        else if ( s2 > LogMax )
-            s2 = LogMax;
-    }
-
     d_s1 = s1;
     d_s2 = s2;
 
-    if ( d_transformation->type() != QwtScaleTransformation::Other )
-        newFactor();
+    if ( d_transform )
+    {
+        d_s1 = d_transform->bounded( d_s1 );
+        d_s2 = d_transform->bounded( d_s2 );
+    }
+
+    updateFactor();
 }
 
@@ -207,31 +121,21 @@
     d_p2 = p2;
 
-    if ( d_transformation->type() != QwtScaleTransformation::Other )
-        newFactor();
-}
-
-/*!
-  \brief Re-calculate the conversion factor.
-*/
-void QwtScaleMap::newFactor()
-{
-    d_cnv = 0.0;
-
-    switch ( d_transformation->type() )
+    updateFactor();
+}
+
+void QwtScaleMap::updateFactor()
+{
+    d_ts1 = d_s1;
+    double ts2 = d_s2;
+
+    if ( d_transform )
     {
-        case QwtScaleTransformation::Linear:
-        {
-            if ( d_s2 != d_s1 )
-                d_cnv = ( d_p2 - d_p1 ) / ( d_s2 - d_s1 );
-            break;
-        }
-        case QwtScaleTransformation::Log10:
-        {
-            if ( d_s1 != 0 )
-                d_cnv = ( d_p2 - d_p1 ) / log( d_s2 / d_s1 );
-            break;
-        }
-        default:;
+        d_ts1 = d_transform->transform( d_ts1 );
+        ts2 = d_transform->transform( ts2 );
     }
+
+    d_cnv = 1.0;
+    if ( d_ts1 != ts2 )
+        d_cnv = ( d_p2 - d_p1 ) / ( ts2 - d_ts1 );
 }
 
@@ -334,5 +238,5 @@
 {
     debug.nospace() << "QwtScaleMap("
-        << static_cast<int>( map.transformation()->type() )
+        << map.transformation()
         << ", s:" << map.s1() << "->" << map.s2()
         << ", p:" << map.p1() << "->" << map.p2()
Index: trunk/BNC/qwt/qwt_scale_map.h
===================================================================
--- trunk/BNC/qwt/qwt_scale_map.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_map.h	(revision 8127)
@@ -12,5 +12,7 @@
 
 #include "qwt_global.h"
-#include "qwt_math.h"
+#include "qwt_transform.h"
+#include <qrect.h>
+
 #ifndef QT_NO_DEBUG_STREAM
 #include <qdebug.h>
@@ -18,52 +20,4 @@
 
 class QRectF;
-
-/*!
-   \brief A transformation between coordinate systems
-
-   QwtScaleTransformation offers transformations from the coordinate system
-   of a scale into the linear coordinate system of a paint device 
-   and vice versa.
-*/
-class QWT_EXPORT QwtScaleTransformation
-{
-public:
-    //! Transformation type
-    enum Type
-    {
-        //! Transformation between 2 linear scales
-        Linear,
-
-        //! Transformation between a linear and a logarithmic ( base 10 ) scale
-        Log10,
-
-        //! Any other type of transformation
-        Other
-    };
-
-    QwtScaleTransformation( Type type );
-    virtual ~QwtScaleTransformation();
-
-    virtual double xForm( double x, double s1, double s2,
-        double p1, double p2 ) const;
-    virtual double invXForm( double x, double p1, double p2,
-        double s1, double s2 ) const;
-
-    Type type() const;
-
-    virtual QwtScaleTransformation *copy() const;
-
-private:
-    QwtScaleTransformation();
-    QwtScaleTransformation &operator=( const QwtScaleTransformation );
-
-    const Type d_type;
-};
-
-//! \return Transformation type
-inline QwtScaleTransformation::Type QwtScaleTransformation::type() const
-{
-    return d_type;
-}
 
 /*!
@@ -84,6 +38,6 @@
     QwtScaleMap &operator=( const QwtScaleMap & );
 
-    void setTransformation( QwtScaleTransformation * );
-    const QwtScaleTransformation *transformation() const;
+    void setTransformation( QwtTransform * );
+    const QwtTransform *transformation() const;
 
     void setPaintInterval( double p1, double p2 );
@@ -102,7 +56,4 @@
     double sDist() const;
 
-    QT_STATIC_CONST double LogMin;
-    QT_STATIC_CONST double LogMax;
-
     static QRectF transform( const QwtScaleMap &,
         const QwtScaleMap &, const QRectF & );
@@ -118,5 +69,5 @@
 
 private:
-    void newFactor();
+    void updateFactor();
 
     double d_s1, d_s2;     // scale interval boundaries
@@ -124,6 +75,7 @@
 
     double d_cnv;       // conversion factor
+    double d_ts1;
 
-    QwtScaleTransformation *d_transformation;
+    QwtTransform *d_transform;
 };
 
@@ -181,16 +133,14 @@
 
   \param s Value relative to the coordinates of the scale
+  \return Transformed value
+
+  \sa invTransform()
 */
 inline double QwtScaleMap::transform( double s ) const
 {
-    // try to inline code from QwtScaleTransformation
+    if ( d_transform )
+        s = d_transform->transform( s );
 
-    if ( d_transformation->type() == QwtScaleTransformation::Linear )
-        return d_p1 + ( s - d_s1 ) * d_cnv;
-
-    if ( d_transformation->type() == QwtScaleTransformation::Log10 )
-        return d_p1 + log( s / d_s1 ) * d_cnv;
-
-    return d_transformation->xForm( s, d_s1, d_s2, d_p1, d_p2 );
+    return d_p1 + ( s - d_ts1 ) * d_cnv;
 }
 
@@ -200,9 +150,15 @@
 
   \param p Value relative to the coordinates of the paint device
+  \return Transformed value
+
   \sa transform()
 */
 inline double QwtScaleMap::invTransform( double p ) const
 {
-    return d_transformation->invXForm( p, d_p1, d_p2, d_s1, d_s2 );
+    double s = d_ts1 + ( p - d_p1 ) / d_cnv;
+    if ( d_transform )
+        s = d_transform->invTransform( s );
+
+    return s;
 }
 
Index: trunk/BNC/qwt/qwt_scale_widget.cpp
===================================================================
--- trunk/BNC/qwt/qwt_scale_widget.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_widget.cpp	(revision 8127)
@@ -15,4 +15,5 @@
 #include "qwt_scale_div.h"
 #include "qwt_text.h"
+#include "qwt_scale_engine.h"
 #include <qpainter.h>
 #include <qevent.h>
@@ -107,4 +108,7 @@
     d_data->scaleDraw->setLength( 10 );
 
+    d_data->scaleDraw->setScaleDiv(
+        QwtLinearScaleEngine().divideScale( 0.0, 100.0, 10, 5 ) );
+
     d_data->colorBar.colorMap = new QwtLinearColorMap();
     d_data->colorBar.isEnabled = false;
@@ -202,4 +206,7 @@
 void QwtScaleWidget::setAlignment( QwtScaleDraw::Alignment alignment )
 {
+    if ( d_data->scaleDraw )
+        d_data->scaleDraw->setAlignment( alignment );
+
     if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
     {
@@ -208,4 +215,5 @@
         if ( d_data->scaleDraw->orientation() == Qt::Vertical )
             policy.transpose();
+
         setSizePolicy( policy );
 
@@ -213,6 +221,4 @@
     }
 
-    if ( d_data->scaleDraw )
-        d_data->scaleDraw->setAlignment( alignment );
     layoutScale();
 }
@@ -305,20 +311,33 @@
 /*!
   Set a scale draw
-  sd has to be created with new and will be deleted in
+
+  scaleDraw has to be created with new and will be deleted in
   ~QwtScaleWidget() or the next call of setScaleDraw().
-
-  \param sd ScaleDraw object
+  scaleDraw will be initialized with the attributes of
+  the previous scaleDraw object.
+
+  \param scaleDraw ScaleDraw object
   \sa scaleDraw()
 */
-void QwtScaleWidget::setScaleDraw( QwtScaleDraw *sd )
-{
-    if ( sd == NULL || sd == d_data->scaleDraw )
+void QwtScaleWidget::setScaleDraw( QwtScaleDraw *scaleDraw )
+{
+    if ( ( scaleDraw == NULL ) || ( scaleDraw == d_data->scaleDraw ) )
         return;
 
-    if ( d_data->scaleDraw )
-        sd->setAlignment( d_data->scaleDraw->alignment() );
+    const QwtScaleDraw* sd = d_data->scaleDraw;
+    if ( sd )
+    {
+        scaleDraw->setAlignment( sd->alignment() );
+        scaleDraw->setScaleDiv( sd->scaleDiv() );
+
+        QwtTransform *transform = NULL;
+        if ( sd->scaleMap().transformation() )
+            transform = sd->scaleMap().transformation()->copy();
+
+        scaleDraw->setTransformation( transform );
+    }
 
     delete d_data->scaleDraw;
-    d_data->scaleDraw = sd;
+    d_data->scaleDraw = scaleDraw;
 
     layoutScale();
@@ -326,5 +345,5 @@
 
 /*!
-    scaleDraw of this scale
+    \return scaleDraw of this scale
     \sa setScaleDraw(), QwtScaleDraw::setScaleDraw()
 */
@@ -335,5 +354,5 @@
 
 /*!
-    scaleDraw of this scale
+    \return scaleDraw of this scale
     \sa QwtScaleDraw::setScaleDraw()
 */
@@ -436,5 +455,5 @@
 
   \param rect Bounding rectangle for all components of the scale
-  \return Rectabgle for the color bar
+  \return Rectangle for the color bar
 */
 QRectF QwtScaleWidget::colorBarRect( const QRectF& rect ) const
@@ -490,5 +509,5 @@
 
 /*!
-  Event handler for resize event
+  Event handler for resize events
   \param event Resize event
 */
@@ -501,5 +520,5 @@
 /*!
   Recalculate the scale's geometry and layout based on
-  the current rect and fonts.
+  the current geometry and fonts.
 
   \param update_geometry Notify the layout system and call update
@@ -646,5 +665,5 @@
     QwtText title = d_data->title;
     title.setRenderFlags( flags );
-    title.draw( painter, QRect( 0, 0, r.width(), r.height() ) );
+    title.draw( painter, QRectF( 0.0, 0.0, r.width(), r.height() ) );
 
     painter->restore();
@@ -713,5 +732,5 @@
 int QwtScaleWidget::titleHeightForWidth( int width ) const
 {
-    return d_data->title.heightForWidth( width, font() );
+    return qCeil( d_data->title.heightForWidth( width, font() ) );
 }
 
@@ -749,4 +768,9 @@
   is returned.
 
+  \param start Return parameter for the border width at 
+               the beginning of the scale
+  \param end Return parameter for the border width at the 
+             end of the scale
+
   \warning
   <ul> <li>The minimum border distance depends on the font.</ul>
@@ -784,4 +808,9 @@
   the widget borders.
 
+  \param start Return parameter for the border width at 
+               the beginning of the scale
+  \param end Return parameter for the border width at the 
+             end of the scale
+
   \sa setMinBorderDist(), getBorderDistHint()
 */
@@ -797,18 +826,12 @@
   The scale division determines where to set the tick marks.
 
-  \param transformation Transformation, needed to translate between
-                        scale and pixal values
   \param scaleDiv Scale Division
   \sa For more information about scale divisions, see QwtScaleDiv.
 */
-void QwtScaleWidget::setScaleDiv(
-    QwtScaleTransformation *transformation,
-    const QwtScaleDiv &scaleDiv )
+void QwtScaleWidget::setScaleDiv( const QwtScaleDiv &scaleDiv )
 {
     QwtScaleDraw *sd = d_data->scaleDraw;
-    if ( sd->scaleDiv() != scaleDiv ||
-        sd->scaleMap().transformation()->type() != transformation->type() )
-    {
-        sd->setTransformation( transformation );
+    if ( sd->scaleDiv() != scaleDiv )
+    {
         sd->setScaleDiv( scaleDiv );
         layoutScale();
@@ -816,14 +839,16 @@
         Q_EMIT scaleDivChanged();
     }
-    else
-    {
-        /*
-          The transformation doesn't anything different as the 
-          previous one. So we better throw it silently away instead of 
-          initiating heavy updates
-         */
-
-        delete transformation;
-    }
+}
+
+/*!
+  Set the transformation
+
+  \param transformation Transformation
+  \sa QwtAbstractScaleDraw::scaleDraw(), QwtScaleMap
+ */
+void QwtScaleWidget::setTransformation( QwtTransform *transformation )
+{
+    d_data->scaleDraw->setTransformation( transformation );
+    layoutScale();
 }
 
Index: trunk/BNC/qwt/qwt_scale_widget.h
===================================================================
--- trunk/BNC/qwt/qwt_scale_widget.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_scale_widget.h	(revision 8127)
@@ -20,5 +20,5 @@
 
 class QPainter;
-class QwtScaleTransformation;
+class QwtTransform;
 class QwtScaleDiv;
 class QwtColorMap;
@@ -54,5 +54,5 @@
 
 Q_SIGNALS:
-    //! Signal emitted, whenever the scale divison changes
+    //! Signal emitted, whenever the scale division changes
     void scaleDivChanged();
 
@@ -80,5 +80,6 @@
     int spacing() const;
 
-    void setScaleDiv( QwtScaleTransformation *, const QwtScaleDiv &sd );
+    void setScaleDiv( const QwtScaleDiv &sd );
+    void setTransformation( QwtTransform * );
 
     void setScaleDraw( QwtScaleDraw * );
Index: trunk/BNC/qwt/qwt_series_data.cpp
===================================================================
--- trunk/BNC/qwt/qwt_series_data.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_series_data.cpp	(revision 8127)
@@ -34,23 +34,29 @@
 static inline QRectF qwtBoundingRect( const QwtSetSample &sample )
 {
-    double minX = sample.set[0];
-    double maxX = sample.set[0];
-
-    for ( int i = 1; i < ( int )sample.set.size(); i++ )
+    double minY = sample.set[0];
+    double maxY = sample.set[0];
+
+    for ( int i = 1; i < sample.set.size(); i++ )
     {
-        if ( sample.set[i] < minX )
-            minX = sample.set[i];
-        if ( sample.set[i] > maxX )
-            maxX = sample.set[i];
+        if ( sample.set[i] < minY )
+            minY = sample.set[i];
+        if ( sample.set[i] > maxY )
+            maxY = sample.set[i];
     }
 
-    double minY = sample.value;
-    double maxY = sample.value;
+    double minX = sample.value;
+    double maxX = sample.value;
 
     return QRectF( minX, minY, maxX - minX, maxY - minY );
 }
 
-/*!
-  \brief Calculate the bounding rect of a series subset
+static inline QRectF qwtBoundingRect( const QwtOHLCSample &sample )
+{
+    const QwtInterval interval = sample.boundingInterval();
+    return QRectF( interval.minValue(), sample.time, interval.width(), 0.0 );
+}
+
+/*!
+  \brief Calculate the bounding rectangle of a series subset
 
   Slow implementation, that iterates over the series.
@@ -64,5 +70,5 @@
 
 template <class T>
-QRectF qwtBoundingRectT( 
+QRectF qwtBoundingRectT(
     const QwtSeriesData<T>& series, int from, int to )
 {
@@ -106,15 +112,15 @@
 
 /*!
-  \brief Calculate the bounding rect of a series subset
-
-  Slow implementation, that iterates over the series.
-
-  \param series Series
-  \param from Index of the first sample, <= 0 means from the beginning
-  \param to Index of the last sample, < 0 means to the end
-
-  \return Bounding rectangle
-*/
-QRectF qwtBoundingRect( 
+  \brief Calculate the bounding rectangle of a series subset
+
+  Slow implementation, that iterates over the series.
+
+  \param series Series
+  \param from Index of the first sample, <= 0 means from the beginning
+  \param to Index of the last sample, < 0 means to the end
+
+  \return Bounding rectangle
+*/
+QRectF qwtBoundingRect(
     const QwtSeriesData<QPointF> &series, int from, int to )
 {
@@ -123,15 +129,15 @@
 
 /*!
-  \brief Calculate the bounding rect of a series subset
-
-  Slow implementation, that iterates over the series.
-
-  \param series Series
-  \param from Index of the first sample, <= 0 means from the beginning
-  \param to Index of the last sample, < 0 means to the end
-
-  \return Bounding rectangle
-*/
-QRectF qwtBoundingRect( 
+  \brief Calculate the bounding rectangle of a series subset
+
+  Slow implementation, that iterates over the series.
+
+  \param series Series
+  \param from Index of the first sample, <= 0 means from the beginning
+  \param to Index of the last sample, < 0 means to the end
+
+  \return Bounding rectangle
+*/
+QRectF qwtBoundingRect(
     const QwtSeriesData<QwtPoint3D> &series, int from, int to )
 {
@@ -140,5 +146,5 @@
 
 /*!
-  \brief Calculate the bounding rect of a series subset
+  \brief Calculate the bounding rectangle of a series subset
 
   The horizontal coordinates represent the azimuth, the
@@ -153,5 +159,5 @@
   \return Bounding rectangle
 */
-QRectF qwtBoundingRect( 
+QRectF qwtBoundingRect(
     const QwtSeriesData<QwtPointPolar> &series, int from, int to )
 {
@@ -160,15 +166,15 @@
 
 /*!
-  \brief Calculate the bounding rect of a series subset
-
-  Slow implementation, that iterates over the series.
-
-  \param series Series
-  \param from Index of the first sample, <= 0 means from the beginning
-  \param to Index of the last sample, < 0 means to the end
-
-  \return Bounding rectangle
-*/
-QRectF qwtBoundingRect( 
+  \brief Calculate the bounding rectangle of a series subset
+
+  Slow implementation, that iterates over the series.
+
+  \param series Series
+  \param from Index of the first sample, <= 0 means from the beginning
+  \param to Index of the last sample, < 0 means to the end
+
+  \return Bounding rectangle
+*/
+QRectF qwtBoundingRect(
     const QwtSeriesData<QwtIntervalSample>& series, int from, int to )
 {
@@ -177,15 +183,32 @@
 
 /*!
-  \brief Calculate the bounding rect of a series subset
-
-  Slow implementation, that iterates over the series.
-
-  \param series Series
-  \param from Index of the first sample, <= 0 means from the beginning
-  \param to Index of the last sample, < 0 means to the end
-
-  \return Bounding rectangle
-*/
-QRectF qwtBoundingRect( 
+  \brief Calculate the bounding rectangle of a series subset
+
+  Slow implementation, that iterates over the series.
+
+  \param series Series
+  \param from Index of the first sample, <= 0 means from the beginning
+  \param to Index of the last sample, < 0 means to the end
+
+  \return Bounding rectangle
+*/
+QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtOHLCSample>& series, int from, int to )
+{
+    return qwtBoundingRectT<QwtOHLCSample>( series, from, to );
+}
+
+/*!
+  \brief Calculate the bounding rectangle of a series subset
+
+  Slow implementation, that iterates over the series.
+
+  \param series Series
+  \param from Index of the first sample, <= 0 means from the beginning
+  \param to Index of the last sample, < 0 means to the end
+
+  \return Bounding rectangle
+*/
+QRectF qwtBoundingRect(
     const QwtSeriesData<QwtSetSample>& series, int from, int to )
 {
@@ -204,5 +227,5 @@
 
 /*!
-  \brief Calculate the bounding rect
+  \brief Calculate the bounding rectangle
 
   The bounding rectangle is calculated once by iterating over all
@@ -230,5 +253,5 @@
 
 /*!
-  \brief Calculate the bounding rect
+  \brief Calculate the bounding rectangle
 
   The bounding rectangle is calculated once by iterating over all
@@ -256,5 +279,5 @@
 
 /*!
-  \brief Calculate the bounding rect
+  \brief Calculate the bounding rectangle
 
   The bounding rectangle is calculated once by iterating over all
@@ -282,5 +305,5 @@
 
 /*!
-  \brief Calculate the bounding rect
+  \brief Calculate the bounding rectangle
 
   The bounding rectangle is calculated once by iterating over all
@@ -298,289 +321,26 @@
 
 /*!
-  Constructor
-
-  \param x Array of x values
-  \param y Array of y values
-
-  \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
-*/
-QwtPointArrayData::QwtPointArrayData(
-        const QVector<double> &x, const QVector<double> &y ):
-    d_x( x ),
-    d_y( y )
-{
-}
-
-/*!
-  Constructor
-
-  \param x Array of x values
-  \param y Array of y values
-  \param size Size of the x and y arrays
-  \sa QwtPlotCurve::setData(), QwtPlotCurve::setSamples()
-*/
-QwtPointArrayData::QwtPointArrayData( const double *x,
-        const double *y, size_t size )
-{
-    d_x.resize( size );
-    qMemCopy( d_x.data(), x, size * sizeof( double ) );
-
-    d_y.resize( size );
-    qMemCopy( d_y.data(), y, size * sizeof( double ) );
-}
-
-/*!
-  \brief Calculate the bounding rect
-
-  The bounding rectangle is calculated once by iterating over all
-  points and is stored for all following requests.
-
-  \return Bounding rectangle
-*/
-QRectF QwtPointArrayData::boundingRect() const
-{
-    if ( d_boundingRect.width() < 0 )
-        d_boundingRect = qwtBoundingRect( *this );
-
-    return d_boundingRect;
-}
-
-//! \return Size of the data set
-size_t QwtPointArrayData::size() const
-{
-    return qMin( d_x.size(), d_y.size() );
-}
-
-/*!
-  Return the sample at position i
-
-  \param i Index
-  \return Sample at position i
-*/
-QPointF QwtPointArrayData::sample( size_t i ) const
-{
-    return QPointF( d_x[int( i )], d_y[int( i )] );
-}
-
-//! \return Array of the x-values
-const QVector<double> &QwtPointArrayData::xData() const
-{
-    return d_x;
-}
-
-//! \return Array of the y-values
-const QVector<double> &QwtPointArrayData::yData() const
-{
-    return d_y;
-}
-
-/*!
-  Constructor
-
-  \param x Array of x values
-  \param y Array of y values
-  \param size Size of the x and y arrays
-
-  \warning The programmer must assure that the memory blocks referenced
-           by the pointers remain valid during the lifetime of the
-           QwtPlotCPointer object.
-
-  \sa QwtPlotCurve::setData(), QwtPlotCurve::setRawSamples()
-*/
-QwtCPointerData::QwtCPointerData(
-        const double *x, const double *y, size_t size ):
-    d_x( x ),
-    d_y( y ),
-    d_size( size )
-{
-}
-
-/*!
-  \brief Calculate the bounding rect
-
-  The bounding rectangle is calculated once by iterating over all
-  points and is stored for all following requests.
-
-  \return Bounding rectangle
-*/
-QRectF QwtCPointerData::boundingRect() const
-{
-    if ( d_boundingRect.width() < 0 )
-        d_boundingRect = qwtBoundingRect( *this );
-
-    return d_boundingRect;
-}
-
-//! \return Size of the data set
-size_t QwtCPointerData::size() const
-{
-    return d_size;
-}
-
-/*!
-  Return the sample at position i
-
-  \param i Index
-  \return Sample at position i
-*/
-QPointF QwtCPointerData::sample( size_t i ) const
-{
-    return QPointF( d_x[int( i )], d_y[int( i )] );
-}
-
-//! \return Array of the x-values
-const double *QwtCPointerData::xData() const
-{
-    return d_x;
-}
-
-//! \return Array of the y-values
-const double *QwtCPointerData::yData() const
-{
-    return d_y;
-}
-
-/*!
-   Constructor
-
-   \param size Number of points
-   \param interval Bounding interval for the points
-
-   \sa setInterval(), setSize()
-*/
-QwtSyntheticPointData::QwtSyntheticPointData(
-        size_t size, const QwtInterval &interval ):
-    d_size( size ),
-    d_interval( interval )
-{
-}
-
-/*!
-  Change the number of points
-
-  \param size Number of points
-  \sa size(), setInterval()
-*/
-void QwtSyntheticPointData::setSize( size_t size )
-{
-    d_size = size;
-}
-
-/*!
-  \return Number of points
-  \sa setSize(), interval()
-*/
-size_t QwtSyntheticPointData::size() const
-{
-    return d_size;
-}
-
-/*!
-   Set the bounding interval
-
-   \param interval Interval
-   \sa interval(), setSize()
-*/
-void QwtSyntheticPointData::setInterval( const QwtInterval &interval )
-{
-    d_interval = interval.normalized();
-}
-
-/*!
-   \return Bounding interval
-   \sa setInterval(), size()
-*/
-QwtInterval QwtSyntheticPointData::interval() const
-{
-    return d_interval;
-}
-
-/*!
-   Set a the "rect of interest"
-
-   QwtPlotSeriesItem defines the current area of the plot canvas
-   as "rect of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
-
-   If interval().isValid() == false the x values are calculated
-   in the interval rect.left() -> rect.right().
-
-   \sa rectOfInterest()
-*/
-void QwtSyntheticPointData::setRectOfInterest( const QRectF &rect )
-{
-    d_rectOfInterest = rect;
-    d_intervalOfInterest = QwtInterval(
-        rect.left(), rect.right() ).normalized();
-}
-
-/*!
-   \return "rect of interest"
-   \sa setRectOfInterest()
-*/
-QRectF QwtSyntheticPointData::rectOfInterest() const
-{
-    return d_rectOfInterest;
-}
-
-/*!
-  \brief Calculate the bounding rect
-
-  This implementation iterates over all points, what could often
-  be implemented much faster using the characteristics of the series.
-  When there are many points it is recommended to overload and
-  reimplement this method using the characteristics of the series
-  ( if possible ).
-
-  \return Bounding rectangle
-*/
-QRectF QwtSyntheticPointData::boundingRect() const
-{
-    if ( d_size == 0 || 
-        !( d_interval.isValid() || d_intervalOfInterest.isValid() ) )
-    {
-        return QRectF(1.0, 1.0, -2.0, -2.0); // something invalid
-    }
-
-    return qwtBoundingRect( *this );
-}
-
-/*!
-   Calculate the point from an index
-
-   \param index Index
-   \return QPointF(x(index), y(x(index)));
-
-   \warning For invalid indices ( index < 0 || index >= size() )
-            (0, 0) is returned.
-*/
-QPointF QwtSyntheticPointData::sample( size_t index ) const
-{
-    if ( index >= d_size )
-        return QPointF( 0, 0 );
-
-    const double xValue = x( index );
-    const double yValue = y( xValue );
-
-    return QPointF( xValue, yValue );
-}
-
-/*!
-   Calculate a x-value from an index
-
-   x values are calculated by deviding an interval into
-   equidistant steps. If !interval().isValid() the
-   interval is calculated from the "rect of interest".
-
-   \sa interval(), rectOfInterest(), y()
-*/
-double QwtSyntheticPointData::x( uint index ) const
-{
-    const QwtInterval &interval = d_interval.isValid() ?
-        d_interval : d_intervalOfInterest;
-
-    if ( !interval.isValid() || d_size == 0 || index >= d_size )
-        return 0.0;
-
-    const double dx = interval.width() / d_size;
-    return interval.minValue() + index * dx;
-}
+   Constructor
+   \param samples Samples
+*/
+QwtTradingChartData::QwtTradingChartData(
+        const QVector<QwtOHLCSample> &samples ):
+    QwtArraySeriesData<QwtOHLCSample>( samples )
+{
+}
+
+/*!
+  \brief Calculate the bounding rectangle
+
+  The bounding rectangle is calculated once by iterating over all
+  points and is stored for all following requests.
+
+  \return Bounding rectangle
+*/
+QRectF QwtTradingChartData::boundingRect() const
+{
+    if ( d_boundingRect.width() < 0.0 )
+        d_boundingRect = qwtBoundingRect( *this );
+
+    return d_boundingRect;
+}
Index: trunk/BNC/qwt/qwt_series_data.h
===================================================================
--- trunk/BNC/qwt/qwt_series_data.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_series_data.h	(revision 8127)
@@ -12,5 +12,5 @@
 
 #include "qwt_global.h"
-#include "qwt_interval.h"
+#include "qwt_samples.h"
 #include "qwt_point_3d.h"
 #include "qwt_point_polar.h"
@@ -18,97 +18,4 @@
 #include <qrect.h>
 
-//! \brief A sample of the types (x1-x2, y) or (x, y1-y2)
-class QWT_EXPORT QwtIntervalSample
-{
-public:
-    QwtIntervalSample();
-    QwtIntervalSample( double, const QwtInterval & );
-    QwtIntervalSample( double value, double min, double max );
-
-    bool operator==( const QwtIntervalSample & ) const;
-    bool operator!=( const QwtIntervalSample & ) const;
-
-    //! Value
-    double value;
-
-    //! Interval
-    QwtInterval interval;
-};
-
-/*!
-  Constructor
-  The value is set to 0.0, the interval is invalid
-*/
-inline QwtIntervalSample::QwtIntervalSample():
-    value( 0.0 )
-{
-}
-
-//! Constructor
-inline QwtIntervalSample::QwtIntervalSample(
-        double v, const QwtInterval &intv ):
-    value( v ),
-    interval( intv )
-{
-}
-
-//! Constructor
-inline QwtIntervalSample::QwtIntervalSample(
-        double v, double min, double max ):
-    value( v ),
-    interval( min, max )
-{
-}
-
-//! Compare operator
-inline bool QwtIntervalSample::operator==( 
-    const QwtIntervalSample &other ) const
-{
-    return value == other.value && interval == other.interval;
-}
-
-//! Compare operator
-inline bool QwtIntervalSample::operator!=( 
-    const QwtIntervalSample &other ) const
-{
-    return !( *this == other );
-}
-
-//! \brief A sample of the types (x1...xn, y) or (x, y1..yn)
-class QWT_EXPORT QwtSetSample
-{
-public:
-    QwtSetSample();
-    bool operator==( const QwtSetSample &other ) const;
-    bool operator!=( const QwtSetSample &other ) const;
-
-    //! value
-    double value;
-
-    //! Vector of values associated to value
-    QVector<double> set;
-};
-
-/*!
-  Constructor
-  The value is set to 0.0
-*/
-inline QwtSetSample::QwtSetSample():
-    value( 0.0 )
-{
-}
-
-//! Compare operator
-inline bool QwtSetSample::operator==( const QwtSetSample &other ) const
-{
-    return value == other.value && set == other.set;
-}
-
-//! Compare operator
-inline bool QwtSetSample::operator!=( const QwtSetSample &other ) const
-{
-    return !( *this == other );
-}
-
 /*!
    \brief Abstract interface for iterating over samples
@@ -118,4 +25,22 @@
    needs to be displayed, without having to copy it, it is recommended
    to implement an individual data access.
+
+   A subclass of QwtSeriesData<QPointF> must implement: 
+
+   - size()\n 
+     Should return number of data points.
+
+   - sample()\n
+     Should return values x and y values of the sample at specific position
+     as QPointF object.
+
+   - boundingRect()\n 
+     Should return the bounding rectangle of the data series.
+     It is used for autoscaling and might help certain algorithms for displaying
+     the data. You can use qwtBoundingRect() for an implementation
+     but often it is possible to implement a more efficient algorithm 
+     depending on the characteristics of the series.
+     The member d_boundingRect is intended for caching the calculated rectangle.
+    
 */
 template <typename T>
@@ -123,5 +48,8 @@
 {
 public:
+    //! Constructor
     QwtSeriesData();
+
+    //! Destructor
     virtual ~QwtSeriesData();
 
@@ -144,9 +72,22 @@
        qwtBoundingRect(...) offers slow implementations iterating
        over the samples. For large sets it is recommended to implement
-       something faster f.e. by caching the bounding rect.
+       something faster f.e. by caching the bounding rectangle.
+
+       \return Bounding rectangle
      */
     virtual QRectF boundingRect() const = 0;
 
-    virtual void setRectOfInterest( const QRectF & );
+    /*!
+       Set a the "rect of interest"
+
+       QwtPlotSeriesItem defines the current area of the plot canvas
+       as "rectangle of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
+       It can be used to implement different levels of details.
+
+       The default implementation does nothing.
+   
+       \param rect Rectangle of interest
+    */
+    virtual void setRectOfInterest( const QRectF &rect );
 
 protected:
@@ -158,5 +99,4 @@
 };
 
-//! Constructor
 template <typename T>
 QwtSeriesData<T>::QwtSeriesData():
@@ -165,5 +105,4 @@
 }
 
-//! Destructor
 template <typename T>
 QwtSeriesData<T>::~QwtSeriesData()
@@ -171,13 +110,4 @@
 }
 
-/*!
-   Set a the "rect of interest"
-
-   QwtPlotSeriesItem defines the current area of the plot canvas
-   as "rect of interest" ( QwtPlotSeriesItem::updateScaleDiv() ).
-   It can be used to implement different levels of details.
-
-   The default implementation does nothing.
-*/
 template <typename T>
 void QwtSeriesData<T>::setRectOfInterest( const QRectF & )
@@ -195,12 +125,32 @@
 {
 public:
+    //! Constructor
     QwtArraySeriesData();
-    QwtArraySeriesData( const QVector<T> & );
-
-    void setSamples( const QVector<T> & );
+
+    /*!
+       Constructor
+       \param samples Array of samples
+    */
+    QwtArraySeriesData( const QVector<T> &samples );
+
+    /*!
+      Assign an array of samples
+      \param samples Array of samples
+    */
+    void setSamples( const QVector<T> &samples );
+
+    //! \return Array of samples
     const QVector<T> samples() const;
 
+    //! \return Number of samples
     virtual size_t size() const;
-    virtual T sample( size_t ) const;
+
+    /*!
+      \return Sample at a specific position
+
+      \param index Index
+      \return Sample at position index
+    */
+    virtual T sample( size_t index ) const;
 
 protected:
@@ -209,5 +159,4 @@
 };
 
-//! Constructor
 template <typename T>
 QwtArraySeriesData<T>::QwtArraySeriesData()
@@ -215,8 +164,4 @@
 }
 
-/*!
-   Constructor
-   \param samples Array of samples
-*/
 template <typename T>
 QwtArraySeriesData<T>::QwtArraySeriesData( const QVector<T> &samples ):
@@ -225,8 +170,4 @@
 }
 
-/*!
-  Assign an array of samples
-  \param samples Array of samples
-*/
 template <typename T>
 void QwtArraySeriesData<T>::setSamples( const QVector<T> &samples )
@@ -236,5 +177,4 @@
 }
 
-//! \return Array of samples
 template <typename T>
 const QVector<T> QwtArraySeriesData<T>::samples() const
@@ -243,5 +183,4 @@
 }
 
-//! \return Number of samples
 template <typename T>
 size_t QwtArraySeriesData<T>::size() const
@@ -250,13 +189,8 @@
 }
 
-/*!
-  Return a sample
-  \param i Index
-  \return Sample at position i
-*/
 template <typename T>
 T QwtArraySeriesData<T>::sample( size_t i ) const
 {
-    return d_samples[i];
+    return d_samples[ static_cast<int>( i ) ];
 }
 
@@ -301,142 +235,121 @@
 
 /*!
-  \brief Interface for iterating over two QVector<double> objects.
+    Interface for iterating over an array of OHLC samples
 */
-class QWT_EXPORT QwtPointArrayData: public QwtSeriesData<QPointF>
-{
-public:
-    QwtPointArrayData( const QVector<double> &x, const QVector<double> &y );
-    QwtPointArrayData( const double *x, const double *y, size_t size );
-
-    virtual QRectF boundingRect() const;
-
-    virtual size_t size() const;
-    virtual QPointF sample( size_t i ) const;
-
-    const QVector<double> &xData() const;
-    const QVector<double> &yData() const;
-
-private:
-    QVector<double> d_x;
-    QVector<double> d_y;
-};
+class QWT_EXPORT QwtTradingChartData: public QwtArraySeriesData<QwtOHLCSample>
+{
+public:
+    QwtTradingChartData(
+        const QVector<QwtOHLCSample> & = QVector<QwtOHLCSample>() );
+
+    virtual QRectF boundingRect() const;
+};
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QPointF> &, int from = 0, int to = -1 );
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtPoint3D> &, int from = 0, int to = -1 );
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtPointPolar> &, int from = 0, int to = -1 );
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtIntervalSample> &, int from = 0, int to = -1 );
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtSetSample> &, int from = 0, int to = -1 );
+
+QWT_EXPORT QRectF qwtBoundingRect(
+    const QwtSeriesData<QwtOHLCSample> &, int from = 0, int to = -1 );
 
 /*!
-  \brief Data class containing two pointers to memory blocks of doubles.
- */
-class QWT_EXPORT QwtCPointerData: public QwtSeriesData<QPointF>
-{
-public:
-    QwtCPointerData( const double *x, const double *y, size_t size );
-
-    virtual QRectF boundingRect() const;
-    virtual size_t size() const;
-    virtual QPointF sample( size_t i ) const;
-
-    const double *xData() const;
-    const double *yData() const;
-
-private:
-    const double *d_x;
-    const double *d_y;
-    size_t d_size;
-};
-
-/*!
-  \brief Synthetic point data
-
-  QwtSyntheticPointData provides a fixed number of points for an interval.
-  The points are calculated in equidistant steps in x-direction.
-
-  If the interval is invalid, the points are calculated for
-  the "rect of interest", what normally is the displayed area on the
-  plot canvas. In this mode you get different levels of detail, when
-  zooming in/out.
+    Binary search for a sorted series of samples
+
+    qwtUpperSampleIndex returns the index of sample that is the upper bound
+    of value. Is the the value smaller than the smallest value the return
+    value will be 0. Is the value greater or equal than the largest
+    value the return value will be -1.
 
   \par Example
-
-  The following example shows how to implement a sinus curve.
+    The following example shows finds a point of curve from an x
+    coordinate
 
   \verbatim
-#include <cmath>
 #include <qwt_series_data.h>
 #include <qwt_plot_curve.h>
-#include <qwt_plot.h>
-#include <qapplication.h>
-
-class SinusData: public QwtSyntheticPointData
-{
-public:
-    SinusData():
-        QwtSyntheticPointData(100)
+
+struct compareX
+{
+    inline bool operator()( const double x, const QPointF &pos ) const
     {
+        return ( x < pos.x() );
     }
-    virtual double y(double x) const
+};
+
+QLineF curveLineAt( const QwtPlotCurve *curve, double x )
+{
+    int index = qwtUpperSampleIndex<QPointF>( 
+        *curve->data(), x, compareX() );
+            
+    if ( index == -1 && 
+        x == curve->sample( curve->dataSize() - 1 ).x() )
+    {   
+        // the last sample is excluded from qwtUpperSampleIndex
+        index = curve->dataSize() - 1;
+    }
+
+    QLineF line; // invalid
+    if ( index > 0 )
     {
-        return qSin(x);
+        line.setP1( curve->sample( index - 1 ) );
+        line.setP2( curve->sample( index ) );
     }
-};
-
-int main(int argc, char **argv)
-{
-    QApplication a(argc, argv);
-
-    QwtPlot plot;
-    plot.setAxisScale(QwtPlot::xBottom, 0.0, 10.0);
-    plot.setAxisScale(QwtPlot::yLeft, -1.0, 1.0);
-
-    QwtPlotCurve *curve = new QwtPlotCurve("y = sin(x)");
-    curve->setData(SinusData());
-    curve->attach(&plot);
-
-    plot.show();
-    return a.exec();
-}
-   \endverbatim
-*/
-class QWT_EXPORT QwtSyntheticPointData: public QwtSeriesData<QPointF>
-{
-public:
-    QwtSyntheticPointData( size_t size,
-        const QwtInterval & = QwtInterval() );
-
-    void setSize( size_t size );
-    size_t size() const;
-
-    void setInterval( const QwtInterval& );
-    QwtInterval interval() const;
-
-    virtual QRectF boundingRect() const;
-    virtual QPointF sample( size_t i ) const;
-
-    /*!
-       Calculate a y value for a x value
-
-       \param x x value
-       \return Corresponding y value
-     */
-    virtual double y( double x ) const = 0;
-    virtual double x( uint index ) const;
-
-    virtual void setRectOfInterest( const QRectF & );
-    QRectF rectOfInterest() const;
-
-private:
-    size_t d_size;
-    QwtInterval d_interval;
-    QRectF d_rectOfInterest;
-    QwtInterval d_intervalOfInterest;
-};
-
-QWT_EXPORT QRectF qwtBoundingRect(
-    const QwtSeriesData<QPointF> &, int from = 0, int to = -1 );
-QWT_EXPORT QRectF qwtBoundingRect(
-    const QwtSeriesData<QwtPoint3D> &, int from = 0, int to = -1 );
-QWT_EXPORT QRectF qwtBoundingRect(
-    const QwtSeriesData<QwtPointPolar> &, int from = 0, int to = -1 );
-QWT_EXPORT QRectF qwtBoundingRect(
-    const QwtSeriesData<QwtIntervalSample> &, int from = 0, int to = -1 );
-QWT_EXPORT QRectF qwtBoundingRect(
-    const QwtSeriesData<QwtSetSample> &, int from = 0, int to = -1 );
-
-#endif 
+
+    return line;
+}
+
+\endverbatim
+
+
+    \param series Series of samples
+    \param value Value
+    \param lessThan Compare operation
+
+    \note The samples must be sorted according to the order specified 
+          by the lessThan object
+
+of the range [begin, end) and returns the position of the one-past-the-last occurrence of value. If no such item is found, returns the position where the item should be inserted.
+ */
+template <typename T, typename LessThan>
+inline int qwtUpperSampleIndex( const QwtSeriesData<T> &series,
+    double value, LessThan lessThan  ) 
+{
+    const int indexMax = series.size() - 1;
+
+    if ( indexMax < 0 || !lessThan( value, series.sample( indexMax ) )  )
+        return -1;
+
+    int indexMin = 0;
+    int n = indexMax;
+
+    while ( n > 0 )
+    {
+        const int half = n >> 1;
+        const int indexMid = indexMin + half;
+
+        if ( lessThan( value, series.sample( indexMid ) ) )
+        {
+            n = half;
+        }
+        else
+        {
+            indexMin = indexMid + 1;
+            n -= half + 1;
+        }
+    }
+
+    return indexMin;
+}
+
+#endif
Index: trunk/BNC/qwt/qwt_series_store.h
===================================================================
--- trunk/BNC/qwt/qwt_series_store.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_series_store.h	(revision 8127)
@@ -0,0 +1,199 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_SERIES_STORE_H
+#define QWT_SERIES_STORE_H
+
+#include "qwt_global.h"
+#include "qwt_series_data.h"
+
+/*!
+  \brief Bridge between QwtSeriesStore and QwtPlotSeriesItem
+
+  QwtAbstractSeriesStore is an abstract interface only
+  to make it possible to isolate the template based methods ( QwtSeriesStore )
+  from the regular methods ( QwtPlotSeriesItem ) to make it possible
+  to derive from QwtPlotSeriesItem without any hassle with templates.
+*/
+class QwtAbstractSeriesStore
+{
+protected:
+    //! Destructor
+    virtual ~QwtAbstractSeriesStore() {}
+
+    //! dataChanged() indicates, that the series has been changed.
+    virtual void dataChanged() = 0;
+
+    /*!
+      Set a the "rectangle of interest" for the stored series
+      \sa QwtSeriesData<T>::setRectOfInterest()
+     */
+    virtual void setRectOfInterest( const QRectF & ) = 0;
+
+    //! \return Bounding rectangle of the stored series
+    virtual QRectF dataRect() const = 0;
+
+    //! \return Number of samples
+    virtual size_t dataSize() const = 0;
+};
+
+/*!
+  \brief Class storing a QwtSeriesData object
+
+  QwtSeriesStore and QwtPlotSeriesItem are intended as base classes for all
+  plot items iterating over a series of samples. Both classes share
+  a virtual base class ( QwtAbstractSeriesStore ) to bridge between them.
+
+  QwtSeriesStore offers the template based part for the plot item API, so
+  that QwtPlotSeriesItem can be derived without any hassle with templates.
+ */
+template <typename T>
+class QwtSeriesStore: public virtual QwtAbstractSeriesStore
+{
+public:
+    /*!
+      \brief Constructor
+      The store contains no series
+    */
+    explicit QwtSeriesStore<T>();
+
+    //! Destructor
+    ~QwtSeriesStore<T>();
+
+    /*!
+      Assign a series of samples
+
+      \param series Data
+      \warning The item takes ownership of the data object, deleting
+               it when its not used anymore.
+    */
+    void setData( QwtSeriesData<T> *series );
+
+    //! \return the the series data
+    QwtSeriesData<T> *data();
+
+    //! \return the the series data
+    const QwtSeriesData<T> *data() const;
+
+    /*!
+        \param index Index
+        \return Sample at position index
+    */
+    T sample( int index ) const;
+
+    /*!
+      \return Number of samples of the series
+      \sa setData(), QwtSeriesData<T>::size()
+    */
+    virtual size_t dataSize() const;
+
+    /*!
+      \return Bounding rectangle of the series
+              or an invalid rectangle, when no series is stored
+
+      \sa QwtSeriesData<T>::boundingRect()
+    */
+    virtual QRectF dataRect() const;
+
+    /*!
+      Set a the "rect of interest" for the series
+
+      \param rect Rectangle of interest
+      \sa QwtSeriesData<T>::setRectOfInterest()
+    */
+    virtual void setRectOfInterest( const QRectF &rect );
+
+    /*!
+      Replace a series without deleting the previous one
+
+      \param series New series
+      \return Previously assigned series
+     */
+    QwtSeriesData<T> *swapData( QwtSeriesData<T> *series );
+
+private:
+    QwtSeriesData<T> *d_series;
+};
+
+template <typename T>
+QwtSeriesStore<T>::QwtSeriesStore():
+    d_series( NULL )
+{
+}
+
+template <typename T>
+QwtSeriesStore<T>::~QwtSeriesStore()
+{
+    delete d_series;
+}
+
+template <typename T>
+inline QwtSeriesData<T> *QwtSeriesStore<T>::data()
+{
+    return d_series;
+}
+
+template <typename T>
+inline const QwtSeriesData<T> *QwtSeriesStore<T>::data() const
+{
+    return d_series;
+}
+
+template <typename T>
+inline T QwtSeriesStore<T>::sample( int index ) const
+{
+    return d_series ? d_series->sample( index ) : T();
+}
+
+template <typename T>
+void QwtSeriesStore<T>::setData( QwtSeriesData<T> *series )
+{
+    if ( d_series != series )
+    {
+        delete d_series;
+        d_series = series;
+        dataChanged();
+    }
+}
+
+template <typename T>
+size_t QwtSeriesStore<T>::dataSize() const
+{
+    if ( d_series == NULL )
+        return 0;
+
+    return d_series->size();
+}
+
+template <typename T>
+QRectF QwtSeriesStore<T>::dataRect() const
+{
+    if ( d_series == NULL )
+        return QRectF( 1.0, 1.0, -2.0, -2.0 ); // invalid
+
+    return d_series->boundingRect();
+}
+
+template <typename T>
+void QwtSeriesStore<T>::setRectOfInterest( const QRectF &rect )
+{
+    if ( d_series )
+        d_series->setRectOfInterest( rect );
+}
+
+template <typename T>
+QwtSeriesData<T>* QwtSeriesStore<T>::swapData( QwtSeriesData<T> *series )
+{
+    QwtSeriesData<T> * swappedSeries = d_series;
+    d_series = series;
+
+    return swappedSeries;
+}
+
+#endif
Index: trunk/BNC/qwt/qwt_slider.cpp
===================================================================
--- trunk/BNC/qwt/qwt_slider.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_slider.cpp	(revision 8127)
@@ -0,0 +1,1004 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_slider.h"
+#include "qwt_painter.h"
+#include "qwt_scale_draw.h"
+#include "qwt_scale_map.h"
+#include <qevent.h>
+#include <qdrawutil.h>
+#include <qpainter.h>
+#include <qalgorithms.h>
+#include <qmath.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qapplication.h>
+
+static QSize qwtHandleSize( const QSize &size, 
+    Qt::Orientation orientation, bool hasTrough )
+{
+    QSize handleSize = size;
+
+    if ( handleSize.isEmpty() )
+    {
+        const int handleThickness = 16;
+        handleSize.setWidth( 2 * handleThickness );
+        handleSize.setHeight( handleThickness );
+
+        if ( !hasTrough )
+            handleSize.transpose();
+
+        if ( orientation == Qt::Vertical )
+            handleSize.transpose();
+    }
+
+    return handleSize;
+}
+
+static QwtScaleDraw::Alignment qwtScaleDrawAlignment( 
+    Qt::Orientation orientation, QwtSlider::ScalePosition scalePos )
+{
+    QwtScaleDraw::Alignment align;
+
+    if ( orientation == Qt::Vertical )
+    {
+        // NoScale lays out like Left
+        if ( scalePos == QwtSlider::LeadingScale )
+            align = QwtScaleDraw::RightScale;
+        else
+            align = QwtScaleDraw::LeftScale;
+    }
+    else
+    {
+        // NoScale lays out like Bottom
+        if ( scalePos == QwtSlider::TrailingScale )
+            align = QwtScaleDraw::TopScale;
+        else
+            align = QwtScaleDraw::BottomScale;
+    }
+
+    return align;
+}
+
+class QwtSlider::PrivateData
+{
+public:
+    PrivateData():
+        repeatTimerId( 0 ),
+        updateInterval( 150 ),
+        stepsIncrement( 0 ),
+        pendingValueChange( false ),
+        borderWidth( 2 ),
+        spacing( 4 ),
+        scalePosition( QwtSlider::TrailingScale ),
+        hasTrough( true ),
+        hasGroove( false ),
+        mouseOffset( 0 )
+    {
+    }
+
+    int repeatTimerId;
+    bool timerTick;
+    int updateInterval;
+    int stepsIncrement;
+    bool pendingValueChange;
+
+    QRect sliderRect;
+
+    QSize handleSize;
+    int borderWidth;
+    int spacing;
+
+    Qt::Orientation orientation;
+    QwtSlider::ScalePosition scalePosition;
+
+    bool hasTrough;
+    bool hasGroove;
+
+    int mouseOffset;
+
+    mutable QSize sizeHintCache;
+};
+/*!
+  Construct vertical slider in QwtSlider::Trough style
+  with a scale to the left. 
+
+  The scale is initialized to [0.0, 100.0] and the value set to 0.0.
+
+  \param parent Parent widget
+
+  \sa setOrientation(), setScalePosition(), setBackgroundStyle()
+*/
+QwtSlider::QwtSlider( QWidget *parent ):
+    QwtAbstractSlider( parent )
+{
+    initSlider( Qt::Vertical );
+}
+
+/*!
+  Construct a slider in QwtSlider::Trough style
+
+  When orientation is Qt::Vertical the scale will be aligned to
+  the left - otherwise at the the top of the slider.
+
+  The scale is initialized to [0.0, 100.0] and the value set to 0.0.
+
+  \param parent Parent widget
+  \param orientation Orientation of the slider. 
+*/
+QwtSlider::QwtSlider( Qt::Orientation orientation, QWidget *parent ):
+    QwtAbstractSlider( parent )
+{
+    initSlider( orientation );
+}
+
+//! Destructor
+QwtSlider::~QwtSlider()
+{
+    delete d_data;
+}
+
+void QwtSlider::initSlider( Qt::Orientation orientation )
+{
+    if ( orientation == Qt::Vertical )
+        setSizePolicy( QSizePolicy::Fixed, QSizePolicy::Expanding );
+    else
+        setSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
+
+    setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+
+    d_data = new QwtSlider::PrivateData;
+
+    d_data->orientation = orientation;
+
+    scaleDraw()->setAlignment( 
+        qwtScaleDrawAlignment( orientation, d_data->scalePosition ) );
+    scaleDraw()->setLength( 100 );
+
+    setScale( 0.0, 100.0 );
+    setValue( 0.0 );
+}
+
+/*!
+  \brief Set the orientation.
+  \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
+
+  \sa orientation(), scalePosition()
+*/
+void QwtSlider::setOrientation( Qt::Orientation orientation )
+{
+    if ( orientation == d_data->orientation )
+        return;
+
+    d_data->orientation = orientation;
+
+    scaleDraw()->setAlignment( 
+        qwtScaleDrawAlignment( orientation, d_data->scalePosition ) );
+
+    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
+    {
+        QSizePolicy sp = sizePolicy();
+        sp.transpose();
+        setSizePolicy( sp );
+
+        setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+    }
+
+    if ( testAttribute( Qt::WA_WState_Polished ) )
+        layoutSlider( true );
+}
+
+/*!
+  \return Orientation
+  \sa setOrientation()
+*/
+Qt::Orientation QwtSlider::orientation() const
+{
+    return d_data->orientation;
+}
+
+/*!
+  \brief Change the position of the scale
+  \param scalePosition Position of the scale.
+
+  \sa ScalePosition, scalePosition()
+*/
+void QwtSlider::setScalePosition( ScalePosition scalePosition )
+{
+    if ( d_data->scalePosition == scalePosition )
+        return;
+
+    d_data->scalePosition = scalePosition;
+    scaleDraw()->setAlignment( 
+        qwtScaleDrawAlignment( d_data->orientation, scalePosition ) );
+
+    if ( testAttribute( Qt::WA_WState_Polished ) )
+        layoutSlider( true );
+}
+
+/*! 
+  \return Position of the scale
+  \sa setScalePosition()
+ */
+QwtSlider::ScalePosition QwtSlider::scalePosition() const
+{
+    return d_data->scalePosition;
+}
+
+/*!
+  \brief Change the slider's border width
+
+  The border width is used for drawing the slider handle and the
+  trough.
+
+  \param width Border width
+  \sa borderWidth()
+*/
+void QwtSlider::setBorderWidth( int width )
+{
+    if ( width < 0 )
+        width = 0;
+
+    if ( width != d_data->borderWidth )
+    {
+        d_data->borderWidth = width;
+
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+}
+
+/*!
+  \return the border width.
+  \sa setBorderWidth()
+*/
+int QwtSlider::borderWidth() const
+{
+    return d_data->borderWidth;
+}
+
+/*!
+  \brief Change the spacing between trough and scale
+
+  A spacing of 0 means, that the backbone of the scale is covered
+  by the trough.
+
+  The default setting is 4 pixels.
+
+  \param spacing Number of pixels
+  \sa spacing();
+*/
+void QwtSlider::setSpacing( int spacing )
+{
+    if ( spacing <= 0 )
+        spacing = 0;
+
+    if ( spacing != d_data->spacing  )
+    {
+        d_data->spacing = spacing;
+
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+}
+
+/*!
+  \return Number of pixels between slider and scale
+  \sa setSpacing()
+*/
+int QwtSlider::spacing() const
+{
+    return d_data->spacing;
+}
+
+/*!
+  \brief Set the slider's handle size
+
+  When the size is empty the slider handle will be painted with a
+  default size depending on its orientation() and backgroundStyle().
+
+  \param size New size
+
+  \sa handleSize()
+*/
+void QwtSlider::setHandleSize( const QSize &size )
+{
+    if ( size != d_data->handleSize )
+    {
+        d_data->handleSize = size;
+
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+}
+
+/*!
+  \return Size of the handle.
+  \sa setHandleSize()
+*/
+QSize QwtSlider::handleSize() const
+{
+    return d_data->handleSize;
+}
+
+/*!
+  \brief Set a scale draw
+
+  For changing the labels of the scales, it
+  is necessary to derive from QwtScaleDraw and
+  overload QwtScaleDraw::label().
+
+  \param scaleDraw ScaleDraw object, that has to be created with
+                   new and will be deleted in ~QwtSlider() or the next
+                   call of setScaleDraw().
+
+  \sa scaleDraw()
+*/
+void QwtSlider::setScaleDraw( QwtScaleDraw *scaleDraw )
+{
+    const QwtScaleDraw *previousScaleDraw = this->scaleDraw();
+    if ( scaleDraw == NULL || scaleDraw == previousScaleDraw )
+        return;
+
+    if ( previousScaleDraw )
+        scaleDraw->setAlignment( previousScaleDraw->alignment() );
+
+    setAbstractScaleDraw( scaleDraw );
+
+    if ( testAttribute( Qt::WA_WState_Polished ) )
+        layoutSlider( true );
+}
+
+/*!
+  \return the scale draw of the slider
+  \sa setScaleDraw()
+*/
+const QwtScaleDraw *QwtSlider::scaleDraw() const
+{
+    return static_cast<const QwtScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+  \return the scale draw of the slider
+  \sa setScaleDraw()
+*/
+QwtScaleDraw *QwtSlider::scaleDraw()
+{
+    return static_cast<QwtScaleDraw *>( abstractScaleDraw() );
+}
+
+//! Notify changed scale
+void QwtSlider::scaleChange()
+{
+    QwtAbstractSlider::scaleChange();
+
+    if ( testAttribute( Qt::WA_WState_Polished ) )
+        layoutSlider( true );
+}
+
+/*!
+  \brief Specify the update interval for automatic scrolling
+
+  The minimal accepted value is 50 ms.
+
+  \param interval Update interval in milliseconds
+
+  \sa setUpdateInterval()
+*/
+void QwtSlider::setUpdateInterval( int interval )
+{
+    d_data->updateInterval = qMax( interval, 50 );
+}
+
+/*!
+  \return Update interval in milliseconds for automatic scrolling
+  \sa setUpdateInterval()
+ */
+int QwtSlider::updateInterval() const
+{
+    return d_data->updateInterval;
+}
+
+/*!
+   Draw the slider into the specified rectangle.
+
+   \param painter Painter
+   \param sliderRect Bounding rectangle of the slider
+*/
+void QwtSlider::drawSlider( 
+    QPainter *painter, const QRect &sliderRect ) const
+{
+    QRect innerRect( sliderRect );
+
+    if ( d_data->hasTrough )
+    {
+        const int bw = d_data->borderWidth;
+        innerRect = sliderRect.adjusted( bw, bw, -bw, -bw );
+
+        painter->fillRect( innerRect, palette().brush( QPalette::Mid ) );
+        qDrawShadePanel( painter, sliderRect, palette(), true, bw, NULL );
+    }
+
+    const QSize handleSize = qwtHandleSize( d_data->handleSize,
+        d_data->orientation, d_data->hasTrough );
+
+    if ( d_data->hasGroove )
+    {
+        const int slotExtent = 4;
+        const int slotMargin = 4;
+
+        QRect slotRect; 
+        if ( orientation() == Qt::Horizontal )
+        {
+            int slotOffset = qMax( 1, handleSize.width() / 2 - slotMargin );
+            int slotHeight = slotExtent + ( innerRect.height() % 2 );
+
+            slotRect.setWidth( innerRect.width() - 2 * slotOffset );
+            slotRect.setHeight( slotHeight );
+        }
+        else
+        {
+            int slotOffset = qMax( 1, handleSize.height() / 2 - slotMargin );
+            int slotWidth = slotExtent + ( innerRect.width() % 2 );
+
+            slotRect.setWidth( slotWidth );
+            slotRect.setHeight( innerRect.height() - 2 * slotOffset );
+
+        }
+
+        slotRect.moveCenter( innerRect.center() );
+
+        QBrush brush = palette().brush( QPalette::Dark );
+        qDrawShadePanel( painter, slotRect, palette(), true, 1 , &brush );
+    }
+
+    if ( isValid() )
+        drawHandle( painter, handleRect(), transform( value() ) );
+}
+
+/*!
+  Draw the thumb at a position
+
+  \param painter Painter
+  \param handleRect Bounding rectangle of the handle
+  \param pos Position of the handle marker in widget coordinates
+*/
+void QwtSlider::drawHandle( QPainter *painter, 
+    const QRect &handleRect, int pos ) const
+{
+    const int bw = d_data->borderWidth;
+
+    qDrawShadePanel( painter, 
+        handleRect, palette(), false, bw,
+        &palette().brush( QPalette::Button ) );
+
+    pos++; // shade line points one pixel below
+    if ( orientation() == Qt::Horizontal )
+    {
+        qDrawShadeLine( painter, pos, handleRect.top() + bw,
+            pos, handleRect.bottom() - bw, palette(), true, 1 );
+    }
+    else // Vertical
+    {
+        qDrawShadeLine( painter, handleRect.left() + bw, pos,
+            handleRect.right() - bw, pos, palette(), true, 1 );
+    }
+}
+
+/*!
+  \brief Determine what to do when the user presses a mouse button.
+
+  \param pos Mouse position
+
+  \retval True, when handleRect() contains pos 
+  \sa scrolledTo()
+*/
+bool QwtSlider::isScrollPosition( const QPoint &pos ) const
+{
+    if ( handleRect().contains( pos ) )
+    {
+        const double v = ( orientation() == Qt::Horizontal ) 
+            ? pos.x() : pos.y();
+
+        d_data->mouseOffset = v - transform( value() );
+        return true;
+    }
+
+    return false;
+}
+
+/*!
+  \brief Determine the value for a new position of the
+         slider handle.
+
+  \param pos Mouse position
+
+  \return Value for the mouse position
+  \sa isScrollPosition()
+*/
+double QwtSlider::scrolledTo( const QPoint &pos ) const
+{
+    int p = ( orientation() == Qt::Horizontal ) 
+        ? pos.x() : pos.y();
+
+    p -= d_data->mouseOffset;
+
+    int min = transform( lowerBound() );
+    int max = transform( upperBound() );
+    if ( min > max )
+        qSwap( min, max );
+
+    p = qBound( min, p, max );
+
+    return scaleMap().invTransform( p );
+}
+
+/*!
+   Mouse press event handler
+   \param event Mouse event
+*/
+void QwtSlider::mousePressEvent( QMouseEvent *event )
+{
+    if ( isReadOnly() )
+    {
+        event->ignore();
+        return;
+    }
+
+    const QPoint pos = event->pos();
+
+    if ( isValid() && d_data->sliderRect.contains( pos ) )
+    {
+        if ( !handleRect().contains( pos ) )
+        {
+            const int markerPos = transform( value() );
+
+            d_data->stepsIncrement = pageSteps();
+
+            if ( d_data->orientation == Qt::Horizontal )
+            {
+                if ( pos.x() < markerPos )
+                    d_data->stepsIncrement = -d_data->stepsIncrement;
+            }
+            else
+            {
+                if ( pos.y() < markerPos )
+                    d_data->stepsIncrement = -d_data->stepsIncrement;
+            }
+
+            if ( isInverted() )
+                d_data->stepsIncrement = -d_data->stepsIncrement;
+
+            const double v = value();
+            incrementValue( d_data->stepsIncrement );
+
+            if ( v != value() )
+            {
+                if ( isTracking() )
+                    Q_EMIT valueChanged( value() );
+                else
+                    d_data->pendingValueChange = true;
+
+                Q_EMIT sliderMoved( value() );
+            }
+
+            d_data->timerTick = false;
+            d_data->repeatTimerId = startTimer( qMax( 250, 2 * updateInterval() ) );
+
+            return;
+        }
+    }
+
+    QwtAbstractSlider::mousePressEvent( event );
+}
+
+/*!
+   Mouse release event handler
+   \param event Mouse event
+*/
+void QwtSlider::mouseReleaseEvent( QMouseEvent *event )
+{
+    if ( d_data->repeatTimerId > 0 )
+    {
+        killTimer( d_data->repeatTimerId );
+        d_data->repeatTimerId = 0;
+        d_data->timerTick = false;
+        d_data->stepsIncrement = 0;
+    }
+
+    if ( d_data->pendingValueChange )
+    {
+        d_data->pendingValueChange = false;
+        Q_EMIT valueChanged( value() );
+    }
+
+    QwtAbstractSlider::mouseReleaseEvent( event );
+}
+
+/*!
+   Timer event handler
+
+   Handles the timer, when the mouse stays pressed
+   inside the sliderRect().
+
+   \param event Mouse event
+*/  
+void QwtSlider::timerEvent( QTimerEvent *event )
+{
+    if ( event->timerId() != d_data->repeatTimerId )
+    {
+        QwtAbstractSlider::timerEvent( event );
+        return;
+    }
+
+    if ( !isValid() )
+    {
+        killTimer( d_data->repeatTimerId );
+        d_data->repeatTimerId = 0;
+        return;
+    }
+
+    const double v = value();
+    incrementValue( d_data->stepsIncrement );
+
+    if ( v != value() )
+    {
+        if ( isTracking() )
+            Q_EMIT valueChanged( value() );
+        else
+            d_data->pendingValueChange = true;
+
+        Q_EMIT sliderMoved( value() );
+    }
+
+    if ( !d_data->timerTick )
+    {
+        // restart the timer with a shorter interval
+        killTimer( d_data->repeatTimerId );
+        d_data->repeatTimerId = startTimer( updateInterval() );
+        
+        d_data->timerTick = true;
+    }   
+}
+
+/*!
+   Qt paint event handler
+   \param event Paint event
+*/
+void QwtSlider::paintEvent( QPaintEvent *event )
+{
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    QStyleOption opt;
+    opt.init(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    if ( d_data->scalePosition != QwtSlider::NoScale )
+    {
+        if ( !d_data->sliderRect.contains( event->rect() ) )
+            scaleDraw()->draw( &painter, palette() );
+    }
+
+    drawSlider( &painter, d_data->sliderRect );
+
+    if ( hasFocus() )
+        QwtPainter::drawFocusRect( &painter, this, d_data->sliderRect );
+}
+
+/*!
+   Qt resize event handler
+   \param event Resize event
+*/
+void QwtSlider::resizeEvent( QResizeEvent *event )
+{
+    Q_UNUSED( event );
+
+    layoutSlider( false );
+}
+
+/*!
+   Handles QEvent::StyleChange and QEvent::FontChange events
+   \param event Change event
+*/
+void QwtSlider::changeEvent( QEvent *event )
+{
+    if ( event->type() == QEvent::StyleChange || 
+        event->type() == QEvent::FontChange )
+    {
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+
+    QwtAbstractSlider::changeEvent( event );
+}
+
+/*!
+  Recalculate the slider's geometry and layout based on
+  the current geometry and fonts.
+
+  \param update_geometry  notify the layout system and call update
+         to redraw the scale
+*/
+void QwtSlider::layoutSlider( bool update_geometry )
+{
+    int bw = 0;
+    if ( d_data->hasTrough )
+        bw = d_data->borderWidth;
+
+    const QSize handleSize = qwtHandleSize( d_data->handleSize,
+        d_data->orientation, d_data->hasTrough );
+
+    QRect sliderRect = contentsRect();
+
+    /*
+       The marker line of the handle needs to be aligned to
+       the scale. But the marker is in the center 
+       and we need space enough to display the rest of the handle.
+
+       But the scale itself usually needs margins for displaying
+       the tick labels, that also might needs space beyond the
+       backbone.
+
+       Now it depends on what needs more margins. If it is the
+       slider the scale gets shrunk, otherwise the slider.
+     */
+
+    int scaleMargin = 0;
+    if ( d_data->scalePosition != QwtSlider::NoScale )
+    {
+        int d1, d2;
+        scaleDraw()->getBorderDistHint( font(), d1, d2 );
+
+        scaleMargin = qMax( d1, d2 ) - bw;
+    }
+
+    int scaleX, scaleY, scaleLength;
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        const int handleMargin = handleSize.width() / 2 - 1;
+        if ( scaleMargin > handleMargin )
+        {
+            int off = scaleMargin - handleMargin;
+            sliderRect.adjust( off, 0, -off, 0 );
+        }
+
+        scaleX = sliderRect.left() + bw + handleSize.width() / 2 - 1;
+        scaleLength = sliderRect.width() - handleSize.width();
+    }
+    else
+    {
+        int handleMargin = handleSize.height() / 2 - 1;
+        if ( scaleMargin > handleMargin )
+        {
+            int off = scaleMargin - handleMargin;
+            sliderRect.adjust( 0, off, 0, -off );
+        }
+
+        scaleY = sliderRect.top() + bw + handleSize.height() / 2 - 1;
+        scaleLength = sliderRect.height() - handleSize.height();
+    }
+
+    scaleLength -= 2 * bw;
+
+    // now align slider and scale according to the ScalePosition
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        const int h = handleSize.height() + 2 * bw;
+
+        if ( d_data->scalePosition == QwtSlider::TrailingScale )
+        {
+            sliderRect.setTop( sliderRect.bottom() + 1 - h );
+            scaleY = sliderRect.top() - d_data->spacing;
+        }
+        else
+        {
+            sliderRect.setHeight( h );
+            scaleY = sliderRect.bottom() + 1 + d_data->spacing;
+        }
+    }
+    else // Qt::Vertical
+    {
+        const int w = handleSize.width() + 2 * bw;
+
+        if ( d_data->scalePosition == QwtSlider::LeadingScale )
+        {
+            sliderRect.setWidth( w );
+            scaleX = sliderRect.right() + 1 + d_data->spacing;
+        }
+        else
+        {
+            sliderRect.setLeft( sliderRect.right() + 1 - w );
+            scaleX = sliderRect.left() - d_data->spacing;
+        }
+    }
+
+    d_data->sliderRect = sliderRect;
+
+    scaleDraw()->move( scaleX, scaleY );
+    scaleDraw()->setLength( scaleLength );
+
+    if ( update_geometry )
+    {
+        d_data->sizeHintCache = QSize(); // invalidate
+        updateGeometry();
+        update();
+    }
+}
+
+/*!
+  En/Disable the trough
+
+  The slider can be cutomized by showing a trough for the
+  handle.
+
+  \param on When true, the groove is visible
+  \sa hasTrough(), setGroove()
+ */
+void QwtSlider::setTrough( bool on )
+{
+    if ( d_data->hasTrough != on )
+    {
+        d_data->hasTrough = on;
+
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+}
+
+/*!
+  \return True, when the trough is visisble
+  \sa setTrough(), hasGroove()
+ */
+bool QwtSlider::hasTrough() const
+{
+    return d_data->hasTrough;
+}
+
+/*!
+  En/Disable the groove
+
+  The slider can be cutomized by showing a groove for the
+  handle.
+
+  \param on When true, the groove is visible
+  \sa hasGroove(), setThrough()
+ */
+void QwtSlider::setGroove( bool on )
+{
+    if ( d_data->hasGroove != on )
+    {
+        d_data->hasGroove = on;
+        
+        if ( testAttribute( Qt::WA_WState_Polished ) )
+            layoutSlider( true );
+    }
+}
+
+/*!
+  \return True, when the groove is visisble
+  \sa setGroove(), hasTrough()
+ */
+bool QwtSlider::hasGroove() const
+{
+    return d_data->hasGroove;
+} 
+
+/*!
+  \return minimumSizeHint()
+*/
+QSize QwtSlider::sizeHint() const
+{
+    const QSize hint = minimumSizeHint();
+    return hint.expandedTo( QApplication::globalStrut() );
+}
+
+/*!
+  \return Minimum size hint
+  \sa sizeHint()
+*/
+QSize QwtSlider::minimumSizeHint() const
+{
+    if ( !d_data->sizeHintCache.isEmpty() )
+        return d_data->sizeHintCache;
+
+    const QSize handleSize = qwtHandleSize( d_data->handleSize,
+        d_data->orientation, d_data->hasTrough );
+
+    int bw = 0;
+    if ( d_data->hasTrough )
+        bw = d_data->borderWidth;
+
+    int sliderLength = 0; 
+    int scaleExtent = 0;
+
+    if ( d_data->scalePosition != QwtSlider::NoScale )
+    {
+        int d1, d2;
+        scaleDraw()->getBorderDistHint( font(), d1, d2 );
+
+        const int scaleBorderDist = 2 * ( qMax( d1, d2 ) - bw );
+
+        int handleBorderDist;
+        if ( d_data->orientation == Qt::Horizontal )
+            handleBorderDist = handleSize.width();
+        else
+            handleBorderDist = handleSize.height();
+
+        sliderLength = scaleDraw()->minLength( font() );
+        if ( handleBorderDist > scaleBorderDist )
+        {
+            // We need additional space for the overlapping handle
+            sliderLength += handleBorderDist - scaleBorderDist;
+        }
+
+        scaleExtent += d_data->spacing;
+        scaleExtent += qCeil( scaleDraw()->extent( font() ) );
+    }
+
+    sliderLength = qMax( sliderLength, 84 ); // from QSlider
+
+    int w = 0;
+    int h = 0;
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        w = sliderLength;
+        h = handleSize.height() + 2 * bw + scaleExtent;
+    }
+    else
+    {
+        w = handleSize.width() + 2 * bw + scaleExtent;
+        h = sliderLength;
+    }
+
+    // finally add margins
+    int left, right, top, bottom;
+    getContentsMargins( &left, &top, &right, &bottom );
+
+    w += left + right;
+    h += top + bottom;
+
+    d_data->sizeHintCache = QSize( w, h );
+    return d_data->sizeHintCache;
+}
+
+/*!
+   \return Bounding rectangle of the slider handle
+ */
+QRect QwtSlider::handleRect() const
+{
+    if ( !isValid() )
+        return QRect();
+
+    const int markerPos = transform( value() );
+
+    QPoint center = d_data->sliderRect.center();
+    if ( d_data->orientation == Qt::Horizontal )
+        center.setX( markerPos );
+    else
+        center.setY( markerPos );
+
+    QRect rect;
+    rect.setSize( qwtHandleSize( d_data->handleSize,
+        d_data->orientation, d_data->hasTrough ) );
+    rect.moveCenter( center );
+
+    return rect;
+}
+
+/*!
+ \return Bounding rectangle of the slider - without the scale
+ */
+QRect QwtSlider::sliderRect() const
+{
+    return d_data->sliderRect;
+}
Index: trunk/BNC/qwt/qwt_slider.h
===================================================================
--- trunk/BNC/qwt/qwt_slider.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_slider.h	(revision 8127)
@@ -0,0 +1,130 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_SLIDER_H
+#define QWT_SLIDER_H
+
+#include "qwt_global.h"
+#include "qwt_abstract_slider.h"
+
+class QwtScaleDraw;
+
+/*!
+  \brief The Slider Widget
+
+  QwtSlider is a slider widget which operates on an interval
+  of type double. Its position is related to a scale showing
+  the current value.
+
+  The slider can be customized by having a through, a groove - or both.
+
+  \image html sliders.png
+*/
+
+class QWT_EXPORT QwtSlider: public QwtAbstractSlider
+{
+    Q_OBJECT
+
+    Q_ENUMS( ScalePosition BackgroundStyle )
+
+    Q_PROPERTY( Qt::Orientation orientation
+                READ orientation WRITE setOrientation )
+    Q_PROPERTY( ScalePosition scalePosition READ scalePosition
+        WRITE setScalePosition )
+
+    Q_PROPERTY( bool trough READ hasTrough WRITE setTrough )
+    Q_PROPERTY( bool groove READ hasGroove WRITE setGroove )
+
+    Q_PROPERTY( QSize handleSize READ handleSize WRITE setHandleSize )
+    Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
+    Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
+
+public:
+
+    /*!
+      Position of the scale
+      \sa QwtSlider(), setScalePosition(), setOrientation()
+     */
+    enum ScalePosition
+    {
+        //! The slider has no scale
+        NoScale,
+
+        //! The scale is right of a vertical or below a horizontal slider
+        LeadingScale,
+
+        //! The scale is left of a vertical or above a horizontal slider
+        TrailingScale
+    };
+
+    explicit QwtSlider( QWidget *parent = NULL );
+    explicit QwtSlider( Qt::Orientation, QWidget *parent = NULL );
+
+    virtual ~QwtSlider();
+
+    void setOrientation( Qt::Orientation );
+    Qt::Orientation orientation() const;
+
+    void setScalePosition( ScalePosition );
+    ScalePosition scalePosition() const;
+
+    void setTrough( bool );
+    bool hasTrough() const;
+
+    void setGroove( bool );
+    bool hasGroove() const;
+
+    void setHandleSize( const QSize & );
+    QSize handleSize() const;
+
+    void setBorderWidth( int bw );
+    int borderWidth() const;
+
+    void setSpacing( int );
+    int spacing() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+    void setScaleDraw( QwtScaleDraw * );
+    const QwtScaleDraw *scaleDraw() const;
+
+    void setUpdateInterval( int );
+    int updateInterval() const;
+
+protected:
+    virtual double scrolledTo( const QPoint & ) const;
+    virtual bool isScrollPosition( const QPoint & ) const;
+
+    virtual void drawSlider ( QPainter *, const QRect & ) const;
+    virtual void drawHandle( QPainter *, const QRect &, int pos ) const;
+
+    virtual void mousePressEvent( QMouseEvent * );
+    virtual void mouseReleaseEvent( QMouseEvent * );
+    virtual void resizeEvent( QResizeEvent * );
+    virtual void paintEvent ( QPaintEvent * );
+    virtual void changeEvent( QEvent * );
+    virtual void timerEvent( QTimerEvent * );
+
+    virtual void scaleChange();
+
+    QRect sliderRect() const;
+    QRect handleRect() const;
+
+private:
+    QwtScaleDraw *scaleDraw();
+
+    void layoutSlider( bool );
+    void initSlider( Qt::Orientation );
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_spline.cpp
===================================================================
--- trunk/BNC/qwt/qwt_spline.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_spline.cpp	(revision 8127)
@@ -69,5 +69,5 @@
 /*!
    Copy constructor
-   \param other Spline used for initilization
+   \param other Spline used for initialization
 */
 QwtSpline::QwtSpline( const QwtSpline& other )
@@ -78,5 +78,6 @@
 /*!
    Assignment operator
-   \param other Spline used for initilization
+   \param other Spline used for initialization
+   \return *this
 */
 QwtSpline &QwtSpline::operator=( const QwtSpline & other )
@@ -153,5 +154,5 @@
 
 /*!
-   Return points passed by setPoints
+   \return Points, that have been by setPoints()
 */
 QPolygonF QwtSpline::points() const
@@ -197,4 +198,7 @@
   Calculate the interpolated function value corresponding
   to a given argument x.
+
+  \param x Coordinate
+  \return Interpolated coordinate
 */
 double QwtSpline::value( double x ) const
Index: trunk/BNC/qwt/qwt_symbol.cpp
===================================================================
--- trunk/BNC/qwt/qwt_symbol.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_symbol.cpp	(revision 8127)
@@ -10,7 +10,14 @@
 #include "qwt_symbol.h"
 #include "qwt_painter.h"
+#include "qwt_graphic.h"
 #include <qapplication.h>
 #include <qpainter.h>
+#include <qpainterpath.h>
+#include <qpixmap.h>
+#include <qpaintengine.h>
 #include <qmath.h>
+#ifndef QWT_NO_SVG
+#include <qsvgrenderer.h>
+#endif
 
 namespace QwtTriangle
@@ -23,4 +30,150 @@
         Down
     };
+}
+
+static QwtGraphic qwtPathGraphic( const QPainterPath &path, 
+    const QPen &pen, const QBrush& brush )
+{
+    QwtGraphic graphic;
+    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled );
+
+    QPainter painter( &graphic );
+    painter.setPen( pen );
+    painter.setBrush( brush );
+    painter.drawPath( path );
+    painter.end();
+
+    return graphic;
+}
+
+static inline QRectF qwtScaledBoundingRect( 
+    const QwtGraphic &graphic, const QSizeF size )
+{
+    QSizeF scaledSize = size;
+    if ( scaledSize.isEmpty() )
+        scaledSize = graphic.defaultSize();
+        
+    const QSizeF sz = graphic.controlPointRect().size();
+
+    double sx = 1.0;
+    if ( sz.width() > 0.0 )
+        sx = scaledSize.width() / sz.width();
+    
+    double sy = 1.0;
+    if ( sz.height() > 0.0 )
+        sy = scaledSize.height() / sz.height();
+
+    return graphic.scaledBoundingRect( sx, sy );
+}
+
+static inline void qwtDrawPixmapSymbols( QPainter *painter,
+    const QPointF *points, int numPoints, const QwtSymbol &symbol )
+{
+    QSize size = symbol.size();
+    if ( size.isEmpty() )
+        size = symbol.pixmap().size();
+
+    const QTransform transform = painter->transform();
+    if ( transform.isScaling() )
+    {
+        const QRect r( 0, 0, size.width(), size.height() );
+        size = transform.mapRect( r ).size();
+    }
+
+    QPixmap pm = symbol.pixmap();
+    if ( pm.size() != size )
+        pm = pm.scaled( size );
+    
+    QPointF pinPoint( 0.5 * size.width(), 0.5 * size.height() );
+    if ( symbol.isPinPointEnabled() )
+        pinPoint = symbol.pinPoint();
+
+    painter->resetTransform();
+
+    for ( int i = 0; i < numPoints; i++ )
+    {
+        const QPointF pos = transform.map( points[i] ) - pinPoint;
+
+        QwtPainter::drawPixmap( painter, 
+            QRect( pos.toPoint(), pm.size() ), pm );
+    }
+}
+
+#ifndef QWT_NO_SVG
+
+static inline void qwtDrawSvgSymbols( QPainter *painter, 
+    const QPointF *points, int numPoints, 
+    QSvgRenderer *renderer, const QwtSymbol &symbol )
+{
+    if ( renderer == NULL || !renderer->isValid() )
+        return;
+
+    const QRectF viewBox = renderer->viewBoxF();
+    if ( viewBox.isEmpty() )
+        return;
+
+    QSizeF sz = symbol.size();
+    if ( !sz.isValid() )
+        sz = viewBox.size();
+
+    const double sx = sz.width() / viewBox.width();
+    const double sy = sz.height() / viewBox.height();
+
+    QPointF pinPoint = viewBox.center();
+    if ( symbol.isPinPointEnabled() )
+        pinPoint = symbol.pinPoint();
+
+    const double dx = sx * ( pinPoint.x() - viewBox.left() );
+    const double dy = sy * ( pinPoint.y() - viewBox.top() );
+
+    for ( int i = 0; i < numPoints; i++ )
+    {
+        const double x = points[i].x() - dx;
+        const double y = points[i].y() - dy;
+
+        renderer->render( painter, 
+            QRectF( x, y, sz.width(), sz.height() ) );
+    }
+}
+
+#endif
+
+static inline void qwtDrawGraphicSymbols( QPainter *painter, 
+    const QPointF *points, int numPoints, const QwtGraphic &graphic,
+    const QwtSymbol &symbol )
+{
+    const QRectF pointRect = graphic.controlPointRect();
+    if ( pointRect.isEmpty() )
+        return;
+
+    double sx = 1.0;
+    double sy = 1.0;
+
+    const QSize sz = symbol.size();
+    if ( sz.isValid() )
+    {
+        sx = sz.width() / pointRect.width();
+        sy = sz.height() / pointRect.height();
+    }
+
+    QPointF pinPoint = pointRect.center();
+    if ( symbol.isPinPointEnabled() )
+        pinPoint = symbol.pinPoint();
+
+    const QTransform transform = painter->transform();
+
+    for ( int i = 0; i < numPoints; i++ )
+    {
+        QTransform tr = transform;
+        tr.translate( points[i].x(), points[i].y() );
+        tr.scale( sx, sy );
+        tr.translate( -pinPoint.x(), -pinPoint.y() );
+
+        painter->setTransform( tr );
+
+        graphic.render( painter );
+    }
+
+    painter->setTransform( transform );
 }
 
@@ -623,16 +776,19 @@
         size( sz ),
         brush( br ),
-        pen( pn )
-    {
-    }
-
-    bool operator==( const PrivateData &other ) const
-    {
-        return ( style == other.style )
-            && ( size == other.size )
-            && ( brush == other.brush )
-            && ( pen == other.pen );
-    }
-
+        pen( pn ),
+        isPinPointEnabled( false )
+    {
+        cache.policy = QwtSymbol::AutoCache;
+#ifndef QWT_NO_SVG
+        svg.renderer = NULL;
+#endif
+    }
+
+    ~PrivateData()
+    {
+#ifndef QWT_NO_SVG
+        delete svg.renderer;
+#endif
+    }
 
     Style style;
@@ -640,4 +796,40 @@
     QBrush brush;
     QPen pen;
+
+    bool isPinPointEnabled;
+    QPointF pinPoint;
+
+    struct Path
+    {
+        QPainterPath path;
+        QwtGraphic graphic;
+
+    } path;
+
+    struct Pixmap
+    {
+        QPixmap pixmap;
+
+    } pixmap;
+
+    struct Graphic
+    {
+        QwtGraphic graphic;
+
+    } graphic;
+
+#ifndef QWT_NO_SVG
+    struct SVG
+    {
+        QSvgRenderer *renderer;
+    } svg;
+#endif
+
+    struct PaintCache
+    {
+        QwtSymbol::CachePolicy policy;
+        QPixmap pixmap;
+
+    } cache;
 };
 
@@ -652,5 +844,5 @@
 {
     d_data = new PrivateData( style, QBrush( Qt::gray ),
-        QPen( Qt::black ), QSize( 0.0, 0.0 ) );
+        QPen( Qt::black, 0 ), QSize() );
 }
 
@@ -671,13 +863,23 @@
 
 /*!
-  \brief Copy constructor
-
-  \param other Symbol
+  \brief Constructor
+
+  The symbol gets initialized by a painter path. The style is
+  set to QwtSymbol::Path, the size is set to empty ( the path
+  is displayed unscaled ).
+
+  \param path painter path
+  \param brush brush to fill the interior
+  \param pen outline pen
+
+  \sa setPath(), setBrush(), setPen(), setSize()
 */
-QwtSymbol::QwtSymbol( const QwtSymbol &other )
-{
-    d_data = new PrivateData( other.style(), other.brush(),
-        other.pen(), other.size() );
-};
+
+QwtSymbol::QwtSymbol( const QPainterPath &path, 
+    const QBrush &brush, const QPen &pen )
+{
+    d_data = new PrivateData( QwtSymbol::Path, brush, pen, QSize() );
+    setPath( path );
+}
 
 //! Destructor
@@ -687,22 +889,166 @@
 }
 
-//! \brief Assignment operator
-QwtSymbol &QwtSymbol::operator=( const QwtSymbol &other )
-{
-    *d_data = *other.d_data;
-    return *this;
-}
-
-//! \brief Compare two symbols
-bool QwtSymbol::operator==( const QwtSymbol &other ) const
-{
-    return *d_data == *other.d_data;
-}
-
-//! \brief Compare two symbols
-bool QwtSymbol::operator!=( const QwtSymbol &other ) const
-{
-    return !( *d_data == *other.d_data );
-}
+/*!
+  Change the cache policy
+
+  The default policy is AutoCache
+
+  \param policy Cache policy
+  \sa CachePolicy, cachePolicy()
+*/
+void QwtSymbol::setCachePolicy(
+    QwtSymbol::CachePolicy policy )
+{
+    if ( d_data->cache.policy != policy )
+    {
+        d_data->cache.policy = policy;
+        invalidateCache();
+    }
+}
+
+/*!
+  \return Cache policy
+  \sa CachePolicy, setCachePolicy()
+*/
+QwtSymbol::CachePolicy QwtSymbol::cachePolicy() const
+{
+    return d_data->cache.policy;
+}
+
+/*!
+  \brief Set a painter path as symbol
+
+  The symbol is represented by a painter path, where the 
+  origin ( 0, 0 ) of the path coordinate system is mapped to
+  the position of the symbol.
+
+  When the symbol has valid size the painter path gets scaled
+  to fit into the size. Otherwise the symbol size depends on
+  the bounding rectangle of the path.
+
+  The following code defines a symbol drawing an arrow:
+
+  \verbatim
+#include <qwt_symbol.h>
+
+QwtSymbol *symbol = new QwtSymbol();
+
+QPen pen( Qt::black, 2 );
+pen.setJoinStyle( Qt::MiterJoin );
+
+symbol->setPen( pen );
+symbol->setBrush( Qt::red );
+
+QPainterPath path;
+path.moveTo( 0, 8 );
+path.lineTo( 0, 5 );
+path.lineTo( -3, 5 );
+path.lineTo( 0, 0 );
+path.lineTo( 3, 5 );
+path.lineTo( 0, 5 );
+
+QTransform transform;
+transform.rotate( -30.0 );
+path = transform.map( path );
+
+symbol->setPath( path );
+symbol->setPinPoint( QPointF( 0.0, 0.0 ) );
+
+setSize( 10, 14 );
+\endverbatim
+
+  \param path Painter path
+
+  \note The style is implicitely set to QwtSymbol::Path.
+  \sa path(), setSize()
+ */
+void QwtSymbol::setPath( const QPainterPath &path )
+{
+    d_data->style = QwtSymbol::Path;
+    d_data->path.path = path;
+    d_data->path.graphic.reset();
+}
+
+/*!
+   \return Painter path for displaying the symbol
+   \sa setPath()
+*/
+const QPainterPath &QwtSymbol::path() const
+{
+    return d_data->path.path;
+}
+
+/*!
+  Set a pixmap as symbol
+
+  \param pixmap Pixmap
+
+  \sa pixmap(), setGraphic()
+
+  \note the style() is set to QwtSymbol::Pixmap
+  \note brush() and pen() have no effect
+ */
+void QwtSymbol::setPixmap( const QPixmap &pixmap )
+{
+    d_data->style = QwtSymbol::Pixmap;
+    d_data->pixmap.pixmap = pixmap;
+}
+
+/*!
+  \return Assigned pixmap
+  \sa setPixmap()
+ */
+const QPixmap &QwtSymbol::pixmap() const
+{
+    return d_data->pixmap.pixmap;
+}
+
+/*!
+  Set a graphic as symbol
+
+  \param graphic Graphic
+
+  \sa graphic(), setPixmap()
+
+  \note the style() is set to QwtSymbol::Graphic
+  \note brush() and pen() have no effect
+ */
+void QwtSymbol::setGraphic( const QwtGraphic &graphic )
+{
+    d_data->style = QwtSymbol::Graphic;
+    d_data->graphic.graphic = graphic;
+}
+
+/*!
+  \return Assigned graphic
+  \sa setGraphic()
+ */
+const QwtGraphic &QwtSymbol::graphic() const
+{
+    return d_data->graphic.graphic;
+}
+
+#ifndef QWT_NO_SVG
+
+/*!
+  Set a SVG icon as symbol
+
+  \param svgDocument SVG icon
+
+  \sa setGraphic(), setPixmap()
+
+  \note the style() is set to QwtSymbol::SvgDocument
+  \note brush() and pen() have no effect
+ */
+void QwtSymbol::setSvgDocument( const QByteArray &svgDocument )
+{
+    d_data->style = QwtSymbol::SvgDocument;
+    if ( d_data->svg.renderer == NULL )
+        d_data->svg.renderer = new QSvgRenderer();
+
+    d_data->svg.renderer->load( svgDocument );
+}
+
+#endif
 
 /*!
@@ -712,4 +1058,5 @@
   and the 'w' parameter is greater than or equal to 0,
   the symbol size will be set to (w,w).
+
   \param width Width
   \param height Height (defaults to -1)
@@ -722,5 +1069,5 @@
         height = width;
 
-    d_data->size = QSize( width, height );
+    setSize( QSize( width, height ) );
 }
 
@@ -733,6 +1080,9 @@
 void QwtSymbol::setSize( const QSize &size )
 {
-    if ( size.isValid() )
+    if ( size.isValid() && size != d_data->size )
+    {
         d_data->size = size;
+        invalidateCache();
+    }
 }
 
@@ -756,5 +1106,12 @@
 void QwtSymbol::setBrush( const QBrush &brush )
 {
-    d_data->brush = brush;
+    if ( brush != d_data->brush )
+    {
+        d_data->brush = brush;
+        invalidateCache();
+
+        if ( d_data->style == QwtSymbol::Path )
+            d_data->path.graphic.reset();
+    }
 }
 
@@ -769,4 +1126,23 @@
 
 /*!
+  Build and assign a pen
+
+  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 )
+  what makes it non cosmetic ( see QPen::isCosmetic() ).
+  This method has been introduced to hide this incompatibility.
+
+  \param color Pen color
+  \param width Pen width
+  \param style Pen style
+
+  \sa pen(), brush()
+ */
+void QwtSymbol::setPen( const QColor &color,
+    qreal width, Qt::PenStyle style )
+{
+    setPen( QPen( color, width, style ) );
+}
+
+/*!
   Assign a pen
 
@@ -778,5 +1154,12 @@
 void QwtSymbol::setPen( const QPen &pen )
 {
-    d_data->pen = pen;
+    if ( pen != d_data->pen )
+    {
+        d_data->pen = pen;
+        invalidateCache();
+
+        if ( d_data->style == QwtSymbol::Path )
+            d_data->path.graphic.reset();
+    }
 }
 
@@ -815,5 +1198,9 @@
         case QwtSymbol::Hexagon:
         {
-            d_data->brush.setColor( color );
+            if ( d_data->brush.color() != color )
+            {
+                d_data->brush.setColor( color );
+                invalidateCache();
+            }
             break;
         }
@@ -824,9 +1211,19 @@
         case QwtSymbol::Star1:
         {
-            d_data->pen.setColor( color );
+            if ( d_data->pen.color() != color )
+            {
+                d_data->pen.setColor( color );
+                invalidateCache();
+            }
             break;
         }
         default:
         {
+            if ( d_data->brush.color() != color ||
+                d_data->pen.color() != color )
+            {
+                invalidateCache();
+            }
+
             d_data->brush.setColor( color );
             d_data->pen.setColor( color );
@@ -836,5 +1233,66 @@
 
 /*!
-  Draw an array of symbols
+  \brief Set and enable a pin point
+
+  The position of a complex symbol is not always aligned to its center
+  ( f.e an arrow, where the peak points to a position ). The pin point
+  defines the position inside of a Pixmap, Graphic, SvgDocument 
+  or PainterPath symbol where the represented point has to
+  be aligned to.
+  
+  \param pos Position
+  \param enable En/Disable the pin point alignment
+
+  \sa pinPoint(), setPinPointEnabled()
+ */
+void QwtSymbol::setPinPoint( const QPointF &pos, bool enable )
+{
+    if ( d_data->pinPoint != pos )
+    {
+        d_data->pinPoint = pos;
+        if ( d_data->isPinPointEnabled )
+        {
+            invalidateCache();
+        }
+    }
+
+    setPinPointEnabled( enable );
+}
+
+/*!
+  \return Pin point
+  \sa setPinPoint(), setPinPointEnabled()
+ */
+QPointF QwtSymbol::pinPoint() const
+{
+    return d_data->pinPoint;
+}
+
+/*!
+  En/Disable the pin point alignment
+
+  \param on Enabled, when on is true
+  \sa setPinPoint(), isPinPointEnabled()
+ */
+void QwtSymbol::setPinPointEnabled( bool on )
+{
+    if ( d_data->isPinPointEnabled != on )
+    {
+        d_data->isPinPointEnabled = on;
+        invalidateCache();
+    }
+}
+
+/*!
+  \return True, when the pin point translation is enabled
+  \sa setPinPoint(), setPinPointEnabled()
+ */
+bool QwtSymbol::isPinPointEnabled() const
+{
+    return d_data->isPinPointEnabled;
+}
+
+/*!
+  Render an array of symbols
 
   Painting several symbols is more effective than drawing symbols
@@ -852,6 +1310,180 @@
         return;
 
-    painter->save();
-
+    bool useCache = false;
+
+    // Don't use the pixmap, when the paint device
+    // could generate scalable vectors
+
+    if ( QwtPainter::roundingAlignment( painter ) &&
+        !painter->transform().isScaling() )
+    {
+        if ( d_data->cache.policy == QwtSymbol::Cache )
+        {
+            useCache = true;
+        }
+        else if ( d_data->cache.policy == QwtSymbol::AutoCache )
+        {
+            if ( painter->paintEngine()->type() == QPaintEngine::Raster )
+            {
+                useCache = true;
+            }
+            else
+            {
+                switch( d_data->style )
+                {
+                    case QwtSymbol::XCross:
+                    case QwtSymbol::HLine:
+                    case QwtSymbol::VLine:
+                    case QwtSymbol::Cross:
+                        break;
+
+                    case QwtSymbol::Pixmap:
+                    {
+                        if ( !d_data->size.isEmpty() &&
+                            d_data->size != d_data->pixmap.pixmap.size() ) 
+                        {
+                            useCache = true;
+                        }
+                        break;
+                    }                       
+                    default:
+                        useCache = true;
+                }
+            }
+        }
+    }
+
+    if ( useCache )
+    {
+        const QRect br = boundingRect();
+
+        const QRect rect( 0, 0, br.width(), br.height() );
+        
+        if ( d_data->cache.pixmap.isNull() )
+        {
+            d_data->cache.pixmap = QwtPainter::backingStore( NULL, br.size() );
+            d_data->cache.pixmap.fill( Qt::transparent );
+
+            QPainter p( &d_data->cache.pixmap );
+            p.setRenderHints( painter->renderHints() );
+            p.translate( -br.topLeft() );
+
+            const QPointF pos;
+            renderSymbols( &p, &pos, 1 );
+        }
+
+        const int dx = br.left();
+        const int dy = br.top();
+
+        for ( int i = 0; i < numPoints; i++ )
+        {
+            const int left = qRound( points[i].x() ) + dx;
+            const int top = qRound( points[i].y() ) + dy;
+
+            painter->drawPixmap( left, top, d_data->cache.pixmap );
+        }
+    }
+    else
+    {
+        painter->save();
+        renderSymbols( painter, points, numPoints );
+        painter->restore();
+    }
+}
+
+/*!
+  \brief Draw the symbol into a rectangle
+
+  The symbol is painted centered and scaled into the target rectangle.
+  It is always painted uncached and the pin point is ignored.
+
+  This method is primarily intended for drawing a symbol to
+  the legend.
+
+  \param painter Painter
+  \param rect Target rectangle for the symbol 
+*/
+void QwtSymbol::drawSymbol( QPainter *painter, const QRectF &rect ) const
+{
+    if ( d_data->style == QwtSymbol::NoSymbol )
+        return;
+
+    if ( d_data->style == QwtSymbol::Graphic )
+    {
+        d_data->graphic.graphic.render( 
+            painter, rect, Qt::KeepAspectRatio );
+    }
+    else if ( d_data->style == QwtSymbol::Path )
+    {
+        if ( d_data->path.graphic.isNull() )
+        {
+            d_data->path.graphic = qwtPathGraphic( 
+                d_data->path.path, d_data->pen, d_data->brush );
+        }
+
+        d_data->path.graphic.render( 
+            painter, rect, Qt::KeepAspectRatio );
+        return;
+    }
+    else if ( d_data->style == QwtSymbol::SvgDocument )
+    {
+#ifndef QWT_NO_SVG
+        if ( d_data->svg.renderer )
+        {
+            QRectF scaledRect;
+
+            QSizeF sz = d_data->svg.renderer->viewBoxF().size();
+            if ( !sz.isEmpty() )
+            {
+                sz.scale( rect.size(), Qt::KeepAspectRatio );
+                scaledRect.setSize( sz );
+                scaledRect.moveCenter( rect.center() );
+            }
+            else
+            {
+                scaledRect = rect;
+            }
+
+            d_data->svg.renderer->render( 
+                painter, scaledRect );
+        }
+#endif
+    }
+    else
+    {
+        const QRect br = boundingRect();
+
+        // scale the symbol size to fit into rect.
+
+        const double ratio = qMin( rect.width() / br.width(), 
+            rect.height() / br.height() );
+
+        painter->save();
+
+        painter->translate( rect.center() );
+        painter->scale( ratio, ratio );
+
+        const bool isPinPointEnabled = d_data->isPinPointEnabled;
+        d_data->isPinPointEnabled = false;
+
+        const QPointF pos;
+        renderSymbols( painter, &pos, 1 );
+    
+        d_data->isPinPointEnabled = isPinPointEnabled;
+
+        painter->restore();
+    }
+}
+
+/*!
+  Render the symbol to series of points
+
+  \param painter Qt painter
+  \param points Positions of the symbols
+  \param numPoints Number of points
+ */
+void QwtSymbol::renderSymbols( QPainter *painter,
+    const QPointF *points, int numPoints ) const
+{
     switch ( d_data->style )
     {
@@ -934,13 +1566,50 @@
             break;
         }
+        case QwtSymbol::Path:
+        {
+            if ( d_data->path.graphic.isNull() )
+            {
+                d_data->path.graphic = qwtPathGraphic( d_data->path.path, 
+                    d_data->pen, d_data->brush );
+            }
+
+            qwtDrawGraphicSymbols( painter, points, numPoints, 
+                d_data->path.graphic, *this );
+            break;
+        }
+        case QwtSymbol::Pixmap:
+        {
+            qwtDrawPixmapSymbols( painter, points, numPoints, *this );
+            break;
+        }
+        case QwtSymbol::Graphic:
+        {
+            qwtDrawGraphicSymbols( painter, points, numPoints, 
+                d_data->graphic.graphic, *this );
+            break;
+        }
+        case QwtSymbol::SvgDocument:
+        {
+#ifndef QWT_NO_SVG
+            qwtDrawSvgSymbols( painter, points, numPoints, 
+                d_data->svg.renderer, *this );
+#endif
+            break;
+        }
         default:;
     }
-    painter->restore();
-}
-
-//!  \return Size of the bounding rectangle of a symbol
-QSize QwtSymbol::boundingSize() const
-{
-    QSize size;
+}
+
+/*!
+  Calculate the bounding rectangle for a symbol
+  at position (0,0).
+
+  \return Bounding rectangle
+ */
+QRect QwtSymbol::boundingRect() const
+{
+    QRectF rect;
+
+    bool pinPointTranslation = false;
 
     switch ( d_data->style )
@@ -954,5 +1623,6 @@
                 pw = qMax( d_data->pen.widthF(), qreal( 1.0 ) );
 
-            size = d_data->size + QSize( pw, pw );
+            rect.setSize( d_data->size + QSizeF( pw, pw ) );
+            rect.moveCenter( QPointF( 0.0, 0.0 ) );
 
             break;
@@ -972,14 +1642,106 @@
                 pw = qMax( d_data->pen.widthF(), qreal( 1.0 ) );
 
-            size = d_data->size + QSize( 2 * pw, 2 * pw );
-            break;
-        }
+            rect.setSize( d_data->size + QSizeF( 2 * pw, 2 * pw ) );
+            rect.moveCenter( QPointF( 0.0, 0.0 ) );
+            break;
+        }
+        case QwtSymbol::Path:
+        {
+            if ( d_data->path.graphic.isNull() )
+            {
+                d_data->path.graphic = qwtPathGraphic(
+                    d_data->path.path, d_data->pen, d_data->brush );
+            }
+
+            rect = qwtScaledBoundingRect( 
+                d_data->path.graphic, d_data->size );
+            pinPointTranslation = true;
+
+            break;
+        }
+        case QwtSymbol::Pixmap:
+        {
+            if ( d_data->size.isEmpty() )
+                rect.setSize( d_data->pixmap.pixmap.size() );
+            else
+                rect.setSize( d_data->size );
+            
+            pinPointTranslation = true;
+
+            break;
+        }
+        case QwtSymbol::Graphic:
+        {
+            rect = qwtScaledBoundingRect( 
+                d_data->graphic.graphic, d_data->size );
+            pinPointTranslation = true;
+
+            break;
+        }
+#ifndef QWT_NO_SVG
+        case QwtSymbol::SvgDocument:
+        {
+            if ( d_data->svg.renderer )
+                rect = d_data->svg.renderer->viewBoxF();
+
+            if ( d_data->size.isValid() && !rect.isEmpty() )
+            {
+                QSizeF sz = rect.size();
+
+                const double sx = d_data->size.width() / sz.width();
+                const double sy = d_data->size.height() / sz.height();
+
+                QTransform transform;
+                transform.scale( sx, sy );
+
+                rect = transform.mapRect( rect );
+            }
+            pinPointTranslation = true;
+            break;
+        }
+#endif
         default:
         {
-            size = d_data->size;
-        }
-    }
-
-    return size + QSize( 1, 1 ); // for antialiasing
+            rect.setSize( d_data->size );
+            rect.moveCenter( QPointF( 0.0, 0.0 ) );
+        }
+    }
+
+    if ( pinPointTranslation )
+    {
+        QPointF pinPoint( 0.0, 0.0 );
+        if ( d_data->isPinPointEnabled )
+            pinPoint = rect.center() - d_data->pinPoint;
+
+        rect.moveCenter( pinPoint );
+    }
+
+    QRect r;
+    r.setLeft( qFloor( rect.left() ) );
+    r.setTop( qFloor( rect.top() ) );
+    r.setRight( qCeil( rect.right() ) );
+    r.setBottom( qCeil( rect.bottom() ) );
+
+    if ( d_data->style != QwtSymbol::Pixmap )
+        r.adjust( -1, -1, 1, 1 ); // for antialiasing
+
+    return r;
+}
+
+/*!
+  Invalidate the cached symbol pixmap
+
+  The symbol invalidates its cache, whenever an attribute is changed
+  that has an effect ob how to display a symbol. In case of derived
+  classes with individual styles ( >= QwtSymbol::UserStyle ) it
+  might be necessary to call invalidateCache() for attributes
+  that are relevant for this style.
+
+  \sa CachePolicy, setCachePolicy(), drawSymbols()
+ */
+void QwtSymbol::invalidateCache()
+{
+    if ( !d_data->cache.pixmap.isNull() )
+        d_data->cache.pixmap = QPixmap();
 }
 
@@ -992,5 +1754,9 @@
 void QwtSymbol::setStyle( QwtSymbol::Style style )
 {
-    d_data->style = style;
+    if ( d_data->style != style )
+    {
+        d_data->style = style;
+        invalidateCache();
+    }
 }
 
Index: trunk/BNC/qwt/qwt_symbol.h
===================================================================
--- trunk/BNC/qwt/qwt_symbol.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_symbol.h	(revision 8127)
@@ -12,5 +12,5 @@
 
 #include "qwt_global.h"
-#include <QPolygonF>
+#include <qpolygon.h>
 
 class QPainter;
@@ -21,4 +21,9 @@
 class QColor;
 class QPointF;
+class QPolygonF;
+class QPainterPath;
+class QPixmap;
+class QByteArray;
+class QwtGraphic;
 
 //! A class for drawing symbols
@@ -81,4 +86,37 @@
 
         /*!
+          The symbol is represented by a painter path, where the 
+          origin ( 0, 0 ) of the path coordinate system is mapped to
+          the position of the symbol.
+
+          \sa setPath(), path()
+         */
+        Path,
+
+        /*!
+          The symbol is represented by a pixmap. The pixmap is centered
+          or aligned to its pin point.
+
+          \sa setPinPoint()
+         */
+        Pixmap,
+
+        /*!
+          The symbol is represented by a graphic. The graphic is centered
+          or aligned to its pin point.
+
+          \sa setPinPoint()
+         */
+        Graphic,
+
+        /*!
+          The symbol is represented by a SVG graphic. The graphic is centered
+          or aligned to its pin point.
+
+          \sa setPinPoint()
+         */
+        SvgDocument,
+
+        /*!
          Styles >= QwtSymbol::UserSymbol are reserved for derived
          classes of QwtSymbol that overload drawSymbols() with
@@ -88,13 +126,51 @@
     };
 
+    /*!
+      Depending on the render engine and the complexity of the
+      symbol shape it might be faster to render the symbol
+      to a pixmap and to paint this pixmap.
+
+      F.e. the raster paint engine is a pure software renderer
+      where in cache mode a draw operation usually ends in 
+      raster operation with the the backing store, that are usually
+      faster, than the algorithms for rendering polygons.
+      But the opposite can be expected for graphic pipelines
+      that can make use of hardware acceleration.
+
+      The default setting is AutoCache
+
+      \sa setCachePolicy(), cachePolicy()
+
+      \note The policy has no effect, when the symbol is painted 
+            to a vector graphics format ( PDF, SVG ).
+      \warning Since Qt 4.8 raster is the default backend on X11
+     */
+
+    enum CachePolicy
+    {
+        //! Don't use a pixmap cache
+        NoCache,
+
+        //! Always use a pixmap cache
+        Cache,
+
+        /*! 
+           Use a cache when one of the following conditions is true:
+
+           - The symbol is rendered with the software 
+             renderer ( QPaintEngine::Raster )
+         */
+        AutoCache
+    };
+
 public:
     QwtSymbol( Style = NoSymbol );
     QwtSymbol( Style, const QBrush &, const QPen &, const QSize & );
-    QwtSymbol( const QwtSymbol & );
+    QwtSymbol( const QPainterPath &, const QBrush &, const QPen & );
+
     virtual ~QwtSymbol();
 
-    QwtSymbol &operator=( const QwtSymbol & );
-    bool operator==( const QwtSymbol & ) const;
-    bool operator!=( const QwtSymbol & ) const;
+    void setCachePolicy( CachePolicy );
+    CachePolicy cachePolicy() const;
 
     void setSize( const QSize & );
@@ -102,4 +178,10 @@
     const QSize& size() const;
 
+    void setPinPoint( const QPointF &pos, bool enable = true );
+    QPointF pinPoint() const;
+
+    void setPinPointEnabled( bool );
+    bool isPinPointEnabled() const;
+
     virtual void setColor( const QColor & );
 
@@ -107,4 +189,5 @@
     const QBrush& brush() const;
 
+    void setPen( const QColor &, qreal width = 0.0, Qt::PenStyle = Qt::SolidLine );
     void setPen( const QPen & );
     const QPen& pen() const;
@@ -113,14 +196,35 @@
     Style style() const;
 
+    void setPath( const QPainterPath & );
+    const QPainterPath &path() const;
+
+    void setPixmap( const QPixmap & );
+    const QPixmap &pixmap() const;
+
+    void setGraphic( const QwtGraphic & );
+    const QwtGraphic &graphic() const;
+
+#ifndef QWT_NO_SVG
+    void setSvgDocument( const QByteArray & );
+#endif
+
+    void drawSymbol( QPainter *, const QRectF & ) const;
     void drawSymbol( QPainter *, const QPointF & ) const;
     void drawSymbols( QPainter *, const QPolygonF & ) const;
-
-    virtual QSize boundingSize() const;
+    void drawSymbols( QPainter *,
+        const QPointF *, int numPoints ) const;
+
+    virtual QRect boundingRect() const;
+    void invalidateCache();
 
 protected:
-    virtual void drawSymbols( QPainter *,
+    virtual void renderSymbols( QPainter *,
         const QPointF *, int numPoints ) const;
 
 private:
+    // Disabled copy constructor and operator=
+    QwtSymbol( const QwtSymbol & );
+    QwtSymbol &operator=( const QwtSymbol & );
+
     class PrivateData;
     PrivateData *d_data;
Index: trunk/BNC/qwt/qwt_system_clock.cpp
===================================================================
--- trunk/BNC/qwt/qwt_system_clock.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_system_clock.cpp	(revision 8127)
@@ -9,4 +9,53 @@
 
 #include "qwt_system_clock.h"
+
+#if QT_VERSION >= 0x040800
+#define USE_ELAPSED_TIMER 1
+#endif
+
+#if USE_ELAPSED_TIMER
+
+#include <qelapsedtimer.h>
+
+class QwtSystemClock::PrivateData
+{
+public:
+    QElapsedTimer timer;
+};
+
+QwtSystemClock::QwtSystemClock()
+{
+    d_data = new PrivateData();
+}
+
+QwtSystemClock::~QwtSystemClock()
+{
+    delete d_data;
+}
+    
+bool QwtSystemClock::isNull() const
+{
+    return d_data->timer.isValid();
+}
+        
+void QwtSystemClock::start()
+{
+    d_data->timer.start();
+}
+
+double QwtSystemClock::restart()
+{
+    const qint64 nsecs = d_data->timer.restart();
+    return nsecs / 1e6;
+}
+
+double QwtSystemClock::elapsed() const
+{
+    const qint64 nsecs = d_data->timer.nsecsElapsed();
+    return nsecs / 1e6;
+}
+    
+#else // !USE_ELAPSED_TIMER
+
 #include <qdatetime.h>
 
@@ -111,5 +160,5 @@
         kern_return_t err = mach_timebase_info( &info );
 
-        //Convert the timebase into ms
+        // convert the timebase into ms
         if ( err == 0  )
             conversion = 1e-6 * ( double ) info.numer / ( double ) info.denom;
@@ -308,7 +357,6 @@
 
 /*!
-  The start time to the current time and
-  return the time, that is elapsed since the
-  previous start time.
+  Set the start time to the current time 
+  \return Time, that is elapsed since the previous start time.
 */
 double QwtSystemClock::restart()
@@ -346,19 +394,3 @@
 }
 
-/*!
-  \return Accuracy of the system clock in milliseconds.
-*/
-double QwtSystemClock::precision()
-{
-    static double prec = 0.0;
-    if ( prec <= 0.0 )
-    {
-#if defined(QWT_HIGH_RESOLUTION_CLOCK)
-        prec = QwtHighResolutionClock::precision();
-#endif
-        if ( prec <= 0.0 )
-            prec = 1.0; // QTime offers 1 ms
-    }
-
-    return prec;
-}
+#endif
Index: trunk/BNC/qwt/qwt_system_clock.h
===================================================================
--- trunk/BNC/qwt/qwt_system_clock.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_system_clock.h	(revision 8127)
@@ -40,6 +40,4 @@
     double elapsed() const;
 
-    static double precision();
-
 private:
     class PrivateData;
Index: trunk/BNC/qwt/qwt_text.cpp
===================================================================
--- trunk/BNC/qwt/qwt_text.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_text.cpp	(revision 8127)
@@ -2,5 +2,5 @@
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2003   Uwe Rathmann
+ * Copyright (C) 2002   Uwe Rathmann
  *
  * This library is free software; you can redistribute it and/or
@@ -139,5 +139,6 @@
     PrivateData():
         renderFlags( Qt::AlignCenter ),
-        backgroundPen( Qt::NoPen ),
+        borderRadius( 0 ),
+        borderPen( Qt::NoPen ),
         backgroundBrush( Qt::NoBrush ),
         paintAttributes( 0 ),
@@ -151,5 +152,6 @@
     QFont font;
     QColor color;
-    QPen backgroundPen;
+    double borderRadius;
+    QPen borderPen;
     QBrush backgroundBrush;
 
@@ -219,5 +221,6 @@
         d_data->font == other.d_data->font &&
         d_data->color == other.d_data->color &&
-        d_data->backgroundPen == other.d_data->backgroundPen &&
+        d_data->borderRadius == other.d_data->borderRadius &&
+        d_data->borderPen == other.d_data->borderPen &&
         d_data->backgroundBrush == other.d_data->backgroundBrush &&
         d_data->paintAttributes == other.d_data->paintAttributes &&
@@ -248,5 +251,5 @@
 
 /*!
-   Return the text.
+   \return Text as QString.
    \sa setText()
 */
@@ -261,5 +264,5 @@
    The default setting is Qt::AlignCenter
 
-   \param renderFlags Bitwise OR of the flags used like in QPainter::drawText
+   \param renderFlags Bitwise OR of the flags used like in QPainter::drawText()
 
    \sa renderFlags(), QwtTextEngine::draw()
@@ -304,9 +307,11 @@
 
 /*!
-  Return the font of the text, if it has one.
-  Otherwise return defaultFont.
-
-  \param defaultFont Default font
-  \sa setFont(), font(), PaintAttributes
+   Return the font of the text, if it has one.
+   Otherwise return defaultFont.
+
+   \param defaultFont Default font
+   \return Font used for drawing the text
+
+   \sa setFont(), font(), PaintAttributes
 */
 QFont QwtText::usedFont( const QFont &defaultFont ) const
@@ -319,5 +324,5 @@
 
 /*!
-   Set the pen color used for painting the text.
+   Set the pen color used for drawing the text.
 
    \param color Color
@@ -342,4 +347,6 @@
 
   \param defaultColor Default color
+  \return Color used for drawing the text
+
   \sa setColor(), color(), PaintAttributes
 */
@@ -353,12 +360,32 @@
 
 /*!
+  Set the radius for the corners of the border frame
+
+  \param radius Radius of a rounded corner
+  \sa borderRadius(), setBorderPen(), setBackgroundBrush()
+*/
+void QwtText::setBorderRadius( double radius )
+{
+    d_data->borderRadius = qMax( 0.0, radius );
+}
+
+/*!
+  \return Radius for the corners of the border frame
+  \sa setBorderRadius(), borderPen(), backgroundBrush()
+*/
+double QwtText::borderRadius() const
+{
+    return d_data->borderRadius;
+}
+
+/*!
    Set the background pen
 
    \param pen Background pen
-   \sa backgroundPen(), setBackgroundBrush()
-*/
-void QwtText::setBackgroundPen( const QPen &pen )
-{
-    d_data->backgroundPen = pen;
+   \sa borderPen(), setBackgroundBrush()
+*/
+void QwtText::setBorderPen( const QPen &pen )
+{
+    d_data->borderPen = pen;
     setPaintAttribute( PaintBackground );
 }
@@ -366,9 +393,9 @@
 /*!
    \return Background pen
-   \sa setBackgroundPen(), backgroundBrush()
-*/
-QPen QwtText::backgroundPen() const
-{
-    return d_data->backgroundPen;
+   \sa setBorderPen(), backgroundBrush()
+*/
+QPen QwtText::borderPen() const
+{
+    return d_data->borderPen;
 }
 
@@ -377,5 +404,5 @@
 
    \param brush Background brush
-   \sa backgroundBrush(), setBackgroundPen()
+   \sa backgroundBrush(), setBorderPen()
 */
 void QwtText::setBackgroundBrush( const QBrush &brush )
@@ -387,5 +414,5 @@
 /*!
    \return Background brush
-   \sa setBackgroundBrush(), backgroundPen()
+   \sa setBackgroundBrush(), borderPen()
 */
 QBrush QwtText::backgroundBrush() const
@@ -401,5 +428,5 @@
 
    \note Used by setFont(), setColor(),
-         setBackgroundPen() and setBackgroundBrush()
+         setBorderPen() and setBackgroundBrush()
    \sa testPaintAttribute()
 */
@@ -492,16 +519,8 @@
 
 /*!
-   Find the height for a given width
-
-   \param defaultFont Font, used for the calculation if the text has no font
-
-   \return Calculated height
-*/
-
-/*!
    Returns the size, that is needed to render text
 
    \param defaultFont Font of the text
-   \return Caluclated size
+   \return Calculated size
 */
 QSizeF QwtText::textSize( const QFont &defaultFont ) const
@@ -543,11 +562,23 @@
     if ( d_data->paintAttributes & PaintBackground )
     {
-        if ( d_data->backgroundPen != Qt::NoPen ||
+        if ( d_data->borderPen != Qt::NoPen ||
             d_data->backgroundBrush != Qt::NoBrush )
         {
             painter->save();
-            painter->setPen( d_data->backgroundPen );
+
+            painter->setPen( d_data->borderPen );
             painter->setBrush( d_data->backgroundBrush );
-            QwtPainter::drawRect( painter, rect );
+
+            if ( d_data->borderRadius == 0 )
+            {
+                QwtPainter::drawRect( painter, rect );
+            }
+            else
+            {
+                painter->setRenderHint( QPainter::Antialiasing, true );
+                painter->drawRoundedRect( rect,
+                    d_data->borderRadius, d_data->borderRadius );
+            }
+
             painter->restore();
         }
@@ -596,5 +627,5 @@
    In case of QwtText::AutoText the first text engine
    (beside QwtPlainTextEngine) is returned, where QwtTextEngine::mightRender
-   returns true. If there is none QwtPlainTextEngine is returnd.
+   returns true. If there is none QwtPlainTextEngine is returned.
 
    If no text engine is registered for the format QwtPlainTextEngine
@@ -603,4 +634,6 @@
    \param text Text, needed in case of AutoText
    \param format Text format
+
+   \return Corresponding text engine
 */
 const QwtTextEngine *QwtText::textEngine( const QString &text,
Index: trunk/BNC/qwt/qwt_text.h
===================================================================
--- trunk/BNC/qwt/qwt_text.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_text.h	(revision 8127)
@@ -2,5 +2,5 @@
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2003   Uwe Rathmann
+ * Copyright (C) 2002   Uwe Rathmann
  *
  * This library is free software; you can redistribute it and/or
@@ -15,4 +15,5 @@
 #include <qsize.h>
 #include <qfont.h>
+#include <qmetatype.h>
 
 class QColor;
@@ -32,8 +33,9 @@
     how to render it. Each format (f.e MathML, TeX, Qt Rich Text)
     has its own set of control sequences, that can be handles by
-    a QwtTextEngine for this format.
+    a special QwtTextEngine for this format.
   - Background\n
     A text might have a background, defined by a QPen and QBrush
-    to improve its visibility.
+    to improve its visibility. The corners of the background might
+    be rounded.
   - Font\n
     A text might have an individual font.
@@ -42,5 +44,5 @@
   - Render Flags\n
     Flags from Qt::AlignmentFlag and Qt::TextFlag used like in
-    QPainter::drawText.
+    QPainter::drawText().
 
   \sa QwtTextEngine, QwtTextLabel
@@ -63,5 +65,5 @@
     {
         /*!
-          The text format is determined using QwtTextEngine::mightRender for
+          The text format is determined using QwtTextEngine::mightRender() for
           all available text engines in increasing order > PlainText.
           If none of the text engines can render the text is rendered
@@ -168,6 +170,9 @@
     QColor usedColor( const QColor & ) const;
 
-    void setBackgroundPen( const QPen & );
-    QPen backgroundPen() const;
+    void setBorderRadius( double );
+    double borderRadius() const;
+
+    void setBorderPen( const QPen & );
+    QPen borderPen() const;
 
     void setBackgroundBrush( const QBrush & );
@@ -214,3 +219,5 @@
 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtText::LayoutAttributes )
 
+Q_DECLARE_METATYPE( QwtText )
+
 #endif
Index: trunk/BNC/qwt/qwt_text_engine.cpp
===================================================================
--- trunk/BNC/qwt/qwt_text_engine.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_text_engine.cpp	(revision 8127)
@@ -2,5 +2,5 @@
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2003   Uwe Rathmann
+ * Copyright (C) 2002   Uwe Rathmann
  *
  * This library is free software; you can redistribute it and/or
@@ -62,5 +62,5 @@
             option.setWrapMode( QTextOption::NoWrap );
 
-        option.setAlignment( ( Qt::Alignment ) flags );
+        option.setAlignment( static_cast<Qt::Alignment>( flags ) );
         setDefaultTextOption( option );
 
@@ -116,5 +116,6 @@
         for ( row = 0; row < img.height(); row++ )
         {
-            const QRgb *line = ( const QRgb * )img.scanLine( row );
+            const QRgb *line = reinterpret_cast<const QRgb *>( 
+                img.scanLine( row ) );
 
             const int w = pm.width();
@@ -181,5 +182,5 @@
   \param text Text to be rendered
 
-  \return Caluclated size
+  \return Calculated size
 */
 QSizeF QwtPlainTextEngine::textSize( const QFont &font,
@@ -248,5 +249,5 @@
 
    \param font Font of the text
-   \param flags Bitwise OR of the flags used like in QPainter::drawText
+   \param flags Bitwise OR of the flags used like in QPainter::drawText()
    \param text Text to be rendered
    \param width Width
@@ -267,8 +268,8 @@
 
   \param font Font of the text
-  \param flags Bitwise OR of the flags used like in QPainter::drawText
+  \param flags Bitwise OR of the flags used like in QPainter::drawText()
   \param text Text to be rendered
 
-  \return Caluclated size
+  \return Calculated size
 */
 
@@ -294,5 +295,5 @@
   \param painter Painter
   \param rect Clipping rectangle
-  \param flags Bitwise OR of the flags like in for QPainter::drawText
+  \param flags Bitwise OR of the flags like in for QPainter::drawText()
   \param text Text to be rendered
 */
@@ -308,5 +309,5 @@
 
    \param text Text
-   \param flags Bitwise OR of the flags like in for QPainter::drawText
+   \param flags Bitwise OR of the flags like in for QPainter::drawText()
 
    \return Tagged text
@@ -321,5 +322,5 @@
 
   \param text Text to be tested
-  \return QStyleSheet::mightBeRichText(text);
+  \return Qt::mightBeRichText(text);
 */
 bool QwtRichTextEngine::mightRender( const QString &text ) const
Index: trunk/BNC/qwt/qwt_text_engine.h
===================================================================
--- trunk/BNC/qwt/qwt_text_engine.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_text_engine.h	(revision 8127)
@@ -2,5 +2,5 @@
  * Qwt Widget Library
  * Copyright (C) 1997   Josef Wilgen
- * Copyright (C) 2003   Uwe Rathmann
+ * Copyright (C) 2002   Uwe Rathmann
  *
  * This library is free software; you can redistribute it and/or
@@ -58,5 +58,5 @@
       \param text Text to be rendered
 
-      \return Caluclated size
+      \return Calculated size
      */
     virtual QSizeF textSize( const QFont &font, int flags,
@@ -75,6 +75,6 @@
 
       The textSize might include margins around the
-      text, like QFontMetrics::descent. In situations
-      where texts need to be aligend in detail, knowing
+      text, like QFontMetrics::descent(). In situations
+      where texts need to be aligned in detail, knowing
       these margins might improve the layout calculations.
 
@@ -94,5 +94,5 @@
       \param painter Painter
       \param rect Clipping rectangle
-      \param flags Bitwise OR of the flags like in for QPainter::drawText
+      \param flags Bitwise OR of the flags like in for QPainter::drawText()
       \param text Text to be rendered
      */
Index: trunk/BNC/qwt/qwt_text_label.cpp
===================================================================
--- trunk/BNC/qwt/qwt_text_label.cpp	(revision 8125)
+++ trunk/BNC/qwt/qwt_text_label.cpp	(revision 8127)
@@ -64,4 +64,24 @@
 
 /*!
+   Interface for the designer plugin - does the same as setText()
+   \sa plainText()
+ */
+void QwtTextLabel::setPlainText( const QString &text )
+{
+    setText( QwtText( text ) );
+}
+
+/*!
+   Interface for the designer plugin
+
+   \return Text as plain text
+   \sa setPlainText(), text()
+ */
+QString QwtTextLabel::plainText() const
+{
+    return d_data->text.text();
+}
+
+/*!
    Change the label's text, keeping all other QwtText attributes
    \param text New text
@@ -70,5 +90,6 @@
   \sa QwtText
 */
-void QwtTextLabel::setText( const QString &text, QwtText::TextFormat textFormat )
+void QwtTextLabel::setText( const QString &text, 
+    QwtText::TextFormat textFormat )
 {
     d_data->text.setText( text, textFormat );
@@ -126,5 +147,5 @@
 }
 
-//! Return label's text indent in pixels
+//! Return label's text margin in pixels
 int QwtTextLabel::margin() const
 {
@@ -144,5 +165,5 @@
 }
 
-//! Return label's margin in pixels
+//! Return a size hint
 QSize QwtTextLabel::sizeHint() const
 {
@@ -177,6 +198,6 @@
 
 /*!
-   Returns the preferred height for this widget, given the width.
    \param width Width
+   \return Preferred height for this widget, given the width.
 */
 int QwtTextLabel::heightForWidth( int width ) const
@@ -192,6 +213,6 @@
         width -= indent;
 
-    int height = d_data->text.heightForWidth( width, font() );
-    if ( renderFlags & Qt::AlignTop || renderFlags & Qt::AlignBottom )
+    int height = qCeil( d_data->text.heightForWidth( width, font() ) );
+    if ( ( renderFlags & Qt::AlignTop ) || ( renderFlags & Qt::AlignBottom ) )
         height += indent;
 
@@ -232,14 +253,11 @@
     painter->setPen( palette().color( QPalette::Active, QPalette::Text ) );
 
-    drawText( painter, r );
+    drawText( painter, QRectF( r ) );
 
     if ( hasFocus() )
     {
-        const int margin = 2;
-
-        QRect focusRect = contentsRect();
-        focusRect.setRect( focusRect.x() + margin, focusRect.y() + margin,
-            focusRect.width() - 2 * margin - 2,
-            focusRect.height() - 2 * margin - 2 );
+        const int m = 2;
+
+        QRect focusRect = contentsRect().adjusted( m, m, -m + 1, -m + 1);
 
         QwtPainter::drawFocusRect( painter, this, focusRect );
@@ -248,5 +266,5 @@
 
 //! Redraw the text
-void QwtTextLabel::drawText( QPainter *painter, const QRect &textRect )
+void QwtTextLabel::drawText( QPainter *painter, const QRectF &textRect )
 {
     d_data->text.draw( painter, textRect );
@@ -254,6 +272,6 @@
 
 /*!
-  Calculate the rect for the text in widget coordinates
-  \return Text rect
+  Calculate geometry for the text in widget coordinates
+  \return Geometry for the text
 */
 QRect QwtTextLabel::textRect() const
Index: trunk/BNC/qwt/qwt_text_label.h
===================================================================
--- trunk/BNC/qwt/qwt_text_label.h	(revision 8125)
+++ trunk/BNC/qwt/qwt_text_label.h	(revision 8127)
@@ -29,4 +29,5 @@
     Q_PROPERTY( int indent READ indent WRITE setIndent )
     Q_PROPERTY( int margin READ margin WRITE setMargin )
+    Q_PROPERTY( QString plainText READ plainText WRITE setPlainText )
 
 public:
@@ -34,4 +35,7 @@
     explicit QwtTextLabel( const QwtText &, QWidget *parent = NULL );
     virtual ~QwtTextLabel();
+
+    void setPlainText( const QString & );
+    QString plainText() const;
 
 public Q_SLOTS:
@@ -57,8 +61,9 @@
     QRect textRect() const;
 
+    virtual void drawText( QPainter *, const QRectF & );
+
 protected:
     virtual void paintEvent( QPaintEvent *e );
     virtual void drawContents( QPainter * );
-    virtual void drawText( QPainter *, const QRect & );
 
 private:
Index: trunk/BNC/qwt/qwt_thermo.cpp
===================================================================
--- trunk/BNC/qwt/qwt_thermo.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_thermo.cpp	(revision 8127)
@@ -0,0 +1,1005 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_thermo.h"
+#include "qwt_scale_engine.h"
+#include "qwt_scale_draw.h"
+#include "qwt_scale_map.h"
+#include "qwt_color_map.h"
+#include <qpainter.h>
+#include <qevent.h>
+#include <qdrawutil.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qmath.h>
+
+static inline void qwtDrawLine( QPainter *painter, int pos, 
+    const QColor &color, const QRect &pipeRect, const QRect &liquidRect,
+    Qt::Orientation orientation )
+{
+    painter->setPen( color );
+    if ( orientation == Qt::Horizontal )
+    {
+        if ( pos >= liquidRect.left() && pos < liquidRect.right() )
+            painter->drawLine( pos, pipeRect.top(), pos, pipeRect.bottom() );
+    }
+    else
+    {
+        if ( pos >= liquidRect.top() && pos < liquidRect.bottom() )
+            painter->drawLine( pipeRect.left(), pos, pipeRect.right(), pos );
+    }
+}
+
+QVector<double> qwtTickList( const QwtScaleDiv &scaleDiv )
+{
+    QVector<double> values;
+
+    double lowerLimit = scaleDiv.interval().minValue();
+    double upperLimit = scaleDiv.interval().maxValue();
+
+    if ( upperLimit < lowerLimit )
+        qSwap( lowerLimit, upperLimit );
+
+    values += lowerLimit;
+
+    for ( int tickType = QwtScaleDiv::MinorTick;
+        tickType < QwtScaleDiv::NTickTypes; tickType++ )
+    {
+        const QList<double> ticks = scaleDiv.ticks( tickType );
+
+        for ( int i = 0; i < ticks.count(); i++ )
+        {
+            const double v = ticks[i];
+            if ( v > lowerLimit && v < upperLimit )
+                values += v;
+        }       
+    }   
+
+    values += upperLimit;
+    
+    return values;
+}
+
+class QwtThermo::PrivateData
+{
+public:
+    PrivateData():
+        orientation( Qt::Vertical ),
+        scalePosition( QwtThermo::TrailingScale ),
+        spacing( 3 ),
+        borderWidth( 2 ),
+        pipeWidth( 10 ),
+        alarmLevel( 0.0 ),
+        alarmEnabled( false ),
+        autoFillPipe( true ),
+        originMode( QwtThermo::OriginMinimum ),
+        origin( 0.0 ),
+        colorMap( NULL ),
+        value( 0.0 )
+    {
+        rangeFlags = QwtInterval::IncludeBorders;
+    }
+
+    ~PrivateData()
+    {
+        delete colorMap;
+    }
+
+    Qt::Orientation orientation;
+    QwtThermo::ScalePosition scalePosition;
+
+    int spacing;
+    int borderWidth;
+    int pipeWidth;
+
+    QwtInterval::BorderFlags rangeFlags;
+    double alarmLevel;
+    bool alarmEnabled;
+    bool autoFillPipe;
+    QwtThermo::OriginMode originMode;
+    double origin;
+
+    QwtColorMap *colorMap;
+
+    double value;
+};
+
+/*!
+  Constructor
+  \param parent Parent widget
+*/
+QwtThermo::QwtThermo( QWidget *parent ):
+    QwtAbstractScale( parent )
+{
+    d_data = new PrivateData;
+
+    QSizePolicy policy( QSizePolicy::MinimumExpanding, QSizePolicy::Fixed );
+    if ( d_data->orientation == Qt::Vertical )
+        policy.transpose();
+
+    setSizePolicy( policy );
+
+    setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+    layoutThermo( true );
+}
+
+//! Destructor
+QwtThermo::~QwtThermo()
+{
+    delete d_data;
+}
+
+/*!
+  \brief Exclude/Include min/max values
+
+  According to the flags minValue() and maxValue()
+  are included/excluded from the pipe. In case of an
+  excluded value the corresponding tick is painted
+  1 pixel off of the pipeRect().
+
+  F.e. when a minimum
+  of 0.0 has to be displayed as an empty pipe the minValue()
+  needs to be excluded.
+
+  \param flags Range flags
+  \sa rangeFlags()
+*/
+void QwtThermo::setRangeFlags( QwtInterval::BorderFlags flags )
+{
+    if ( d_data->rangeFlags != flags )
+    {
+        d_data->rangeFlags = flags;
+        update();
+    }
+}
+
+/*!
+  \return Range flags
+  \sa setRangeFlags()
+*/
+QwtInterval::BorderFlags QwtThermo::rangeFlags() const
+{
+    return d_data->rangeFlags;
+}
+
+/*!
+  Set the current value.
+
+  \param value New Value
+  \sa value()
+*/
+void QwtThermo::setValue( double value )
+{
+    if ( d_data->value != value )
+    {
+        d_data->value = value;
+        update();
+    }
+}
+
+//! Return the value.
+double QwtThermo::value() const
+{
+    return d_data->value;
+}
+
+/*!
+  \brief Set a scale draw
+
+  For changing the labels of the scales, it
+  is necessary to derive from QwtScaleDraw and
+  overload QwtScaleDraw::label().
+
+  \param scaleDraw ScaleDraw object, that has to be created with
+                   new and will be deleted in ~QwtThermo() or the next
+                   call of setScaleDraw().
+*/
+void QwtThermo::setScaleDraw( QwtScaleDraw *scaleDraw )
+{
+    setAbstractScaleDraw( scaleDraw );
+    layoutThermo( true );
+}
+
+/*!
+   \return the scale draw of the thermo
+   \sa setScaleDraw()
+*/
+const QwtScaleDraw *QwtThermo::scaleDraw() const
+{
+    return static_cast<const QwtScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+   \return the scale draw of the thermo
+   \sa setScaleDraw()
+*/
+QwtScaleDraw *QwtThermo::scaleDraw()
+{
+    return static_cast<QwtScaleDraw *>( abstractScaleDraw() );
+}
+
+/*!
+  Paint event handler
+  \param event Paint event
+*/
+void QwtThermo::paintEvent( QPaintEvent *event )
+{
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    QStyleOption opt;
+    opt.init(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    const QRect tRect = pipeRect();
+
+    if ( !tRect.contains( event->rect() ) )
+    {
+        if ( d_data->scalePosition != QwtThermo::NoScale )
+            scaleDraw()->draw( &painter, palette() );
+    }
+
+    const int bw = d_data->borderWidth;
+
+    const QBrush brush = palette().brush( QPalette::Base );
+    qDrawShadePanel( &painter, 
+        tRect.adjusted( -bw, -bw, bw, bw ),
+        palette(), true, bw, 
+        d_data->autoFillPipe ? &brush : NULL );
+
+    drawLiquid( &painter, tRect );
+}
+
+/*! 
+  Resize event handler
+  \param event Resize event
+*/
+void QwtThermo::resizeEvent( QResizeEvent *event )
+{
+    Q_UNUSED( event );
+    layoutThermo( false );
+}
+
+/*! 
+  Qt change event handler
+  \param event Event
+*/
+void QwtThermo::changeEvent( QEvent *event )
+{
+    switch( event->type() )
+    {
+        case QEvent::StyleChange:
+        case QEvent::FontChange:
+        {
+            layoutThermo( true );
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+/*!
+  Recalculate the QwtThermo geometry and layout based on
+  pipeRect() and the fonts.
+
+  \param update_geometry notify the layout system and call update
+         to redraw the scale
+*/
+void QwtThermo::layoutThermo( bool update_geometry )
+{
+    const QRect tRect = pipeRect();
+    const int bw = d_data->borderWidth + d_data->spacing;
+    const bool inverted = ( upperBound() < lowerBound() );
+
+    int from, to;
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        from = tRect.left();
+        to = tRect.right();
+
+        if ( d_data->rangeFlags & QwtInterval::ExcludeMinimum )
+        {
+            if ( inverted )
+                to++;
+            else
+                from--;
+        }
+        if ( d_data->rangeFlags & QwtInterval::ExcludeMaximum )
+        {
+            if ( inverted )
+                from--;
+            else
+                to++;
+        }
+
+        if ( d_data->scalePosition == QwtThermo::TrailingScale )
+        {
+            scaleDraw()->setAlignment( QwtScaleDraw::TopScale );
+            scaleDraw()->move( from, tRect.top() - bw );
+        }
+        else
+        {
+            scaleDraw()->setAlignment( QwtScaleDraw::BottomScale );
+            scaleDraw()->move( from, tRect.bottom() + bw );
+        }
+
+        scaleDraw()->setLength( qMax( to - from, 0 ) );
+    }
+    else // Qt::Vertical
+    {
+        from = tRect.top();
+        to = tRect.bottom();
+
+        if ( d_data->rangeFlags & QwtInterval::ExcludeMinimum )
+        {
+            if ( inverted )
+                from--;
+            else
+                to++;
+        }
+        if ( d_data->rangeFlags & QwtInterval::ExcludeMaximum )
+        {
+            if ( inverted )
+                to++;
+            else
+                from--;
+        }
+
+        if ( d_data->scalePosition == QwtThermo::LeadingScale )
+        {
+            scaleDraw()->setAlignment( QwtScaleDraw::RightScale );
+            scaleDraw()->move( tRect.right() + bw, from );
+        }
+        else
+        {
+            scaleDraw()->setAlignment( QwtScaleDraw::LeftScale );
+            scaleDraw()->move( tRect.left() - bw, from );
+        }
+
+        scaleDraw()->setLength( qMax( to - from, 0 ) );
+    }
+
+    if ( update_geometry )
+    {
+        updateGeometry();
+        update();
+    }
+}
+
+/*!
+  \return Bounding rectangle of the pipe ( without borders )
+          in widget coordinates
+*/
+QRect QwtThermo::pipeRect() const
+{
+    int mbd = 0;
+    if ( d_data->scalePosition != QwtThermo::NoScale )
+    {
+        int d1, d2;
+        scaleDraw()->getBorderDistHint( font(), d1, d2 );
+        mbd = qMax( d1, d2 );
+    }
+    const int bw = d_data->borderWidth;
+    const int scaleOff = bw + mbd;
+
+    const QRect cr = contentsRect();
+
+    QRect pipeRect = cr;
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        pipeRect.adjust( scaleOff, 0, -scaleOff, 0 );
+
+        if ( d_data->scalePosition == QwtThermo::TrailingScale )
+            pipeRect.setTop( cr.top() + cr.height() - bw - d_data->pipeWidth );
+        else
+            pipeRect.setTop( bw );
+
+        pipeRect.setHeight( d_data->pipeWidth );
+    }
+    else // Qt::Vertical
+    {
+        pipeRect.adjust( 0, scaleOff, 0, -scaleOff );
+
+        if ( d_data->scalePosition == QwtThermo::LeadingScale )
+            pipeRect.setLeft( bw );
+        else 
+            pipeRect.setLeft( cr.left() + cr.width() - bw - d_data->pipeWidth );
+
+        pipeRect.setWidth( d_data->pipeWidth );
+    }
+
+    return pipeRect;
+}
+
+/*!
+  \brief Set the orientation.
+  \param orientation Allowed values are Qt::Horizontal and Qt::Vertical.
+
+  \sa orientation(), scalePosition()
+*/
+void QwtThermo::setOrientation( Qt::Orientation orientation )
+{
+    if ( orientation == d_data->orientation )
+        return;
+
+    d_data->orientation = orientation;
+
+    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
+    {
+        QSizePolicy sp = sizePolicy();
+        sp.transpose();
+        setSizePolicy( sp );
+
+        setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+    }
+
+    layoutThermo( true );
+}
+
+/*!
+  \return Orientation
+  \sa setOrientation()
+*/
+Qt::Orientation QwtThermo::orientation() const
+{
+    return d_data->orientation;
+}
+
+/*!
+  \brief Change how the origin is determined.
+  \sa originMode(), serOrigin(), origin()
+ */
+void QwtThermo::setOriginMode( OriginMode m )
+{
+    if ( m == d_data->originMode )
+        return;
+
+    d_data->originMode = m;
+    update();
+}
+
+/*!
+  \return Mode, how the origin is determined.
+  \sa setOriginMode(), serOrigin(), origin()
+ */
+QwtThermo::OriginMode QwtThermo::originMode() const
+{
+    return d_data->originMode;
+}
+
+/*!
+  \brief Specifies the custom origin.
+
+  If originMode is set to OriginCustom this property controls where the
+  liquid starts.
+
+  \param origin New origin level
+  \sa setOriginMode(), originMode(), origin()
+ */
+void QwtThermo::setOrigin( double origin )
+{
+    if ( origin == d_data->origin )
+        return;
+
+    d_data->origin = origin;
+    update();
+}
+
+/*!
+  \return Origin of the thermo, when OriginCustom is enabled
+  \sa setOrigin(), setOriginMode(), originMode()
+ */
+double QwtThermo::origin() const
+{
+    return d_data->origin;
+}
+
+/*!
+  \brief Change the position of the scale
+  \param scalePosition Position of the scale.
+
+  \sa ScalePosition, scalePosition()
+*/
+void QwtThermo::setScalePosition( ScalePosition scalePosition )
+{
+    if ( d_data->scalePosition == scalePosition )
+        return;
+
+    d_data->scalePosition = scalePosition;
+
+    if ( testAttribute( Qt::WA_WState_Polished ) )
+        layoutThermo( true );
+}
+
+/*!
+   \return Scale position.
+   \sa setScalePosition()
+*/
+QwtThermo::ScalePosition QwtThermo::scalePosition() const
+{
+    return d_data->scalePosition;
+}
+
+//! Notify a scale change.
+void QwtThermo::scaleChange()
+{
+    layoutThermo( true );
+}
+
+/*!
+   Redraw the liquid in thermometer pipe.
+   \param painter Painter
+   \param pipeRect Bounding rectangle of the pipe without borders
+*/
+void QwtThermo::drawLiquid( 
+    QPainter *painter, const QRect &pipeRect ) const
+{
+    painter->save();
+    painter->setClipRect( pipeRect, Qt::IntersectClip );
+    painter->setPen( Qt::NoPen );
+
+    const QwtScaleMap scaleMap = scaleDraw()->scaleMap();
+
+    QRect liquidRect = fillRect( pipeRect );
+
+    if ( d_data->colorMap != NULL )
+    {
+        const QwtInterval interval = scaleDiv().interval().normalized();
+
+        // Because the positions of the ticks are rounded
+        // we calculate the colors for the rounded tick values
+
+        QVector<double> values = qwtTickList( scaleDraw()->scaleDiv() );
+
+        if ( scaleMap.isInverting() )
+            qSort( values.begin(), values.end(), qGreater<double>() );
+        else
+            qSort( values.begin(), values.end(), qLess<double>() );
+
+        int from;
+        if ( !values.isEmpty() )
+        {
+            from = qRound( scaleMap.transform( values[0] ) );
+            qwtDrawLine( painter, from,
+                d_data->colorMap->color( interval, values[0] ),
+                pipeRect, liquidRect, d_data->orientation );
+        }
+
+        for ( int i = 1; i < values.size(); i++ )
+        {
+            const int to = qRound( scaleMap.transform( values[i] ) );
+
+            for ( int pos = from + 1; pos < to; pos++ )
+            {
+                const double v = scaleMap.invTransform( pos );
+
+                qwtDrawLine( painter, pos, 
+                    d_data->colorMap->color( interval, v ),
+                    pipeRect, liquidRect, d_data->orientation );
+            }
+
+            qwtDrawLine( painter, to,
+                d_data->colorMap->color( interval, values[i] ),
+                pipeRect, liquidRect, d_data->orientation );
+
+            from = to;
+        }
+    }
+    else
+    {
+        if ( !liquidRect.isEmpty() && d_data->alarmEnabled )
+        {
+            const QRect r = alarmRect( liquidRect );
+            if ( !r.isEmpty() )
+            {
+                painter->fillRect( r, palette().brush( QPalette::Highlight ) );
+                liquidRect = QRegion( liquidRect ).subtracted( r ).boundingRect();
+            }
+        }
+
+        painter->fillRect( liquidRect, palette().brush( QPalette::ButtonText ) );
+    }
+
+    painter->restore();
+}
+
+/*!
+  \brief Change the spacing between pipe and scale
+
+  A spacing of 0 means, that the backbone of the scale is below
+  the pipe.
+
+  The default setting is 3 pixels.
+
+  \param spacing Number of pixels
+  \sa spacing();
+*/
+void QwtThermo::setSpacing( int spacing )
+{
+    if ( spacing <= 0 )
+        spacing = 0;
+
+    if ( spacing != d_data->spacing  )
+    {
+        d_data->spacing = spacing;
+        layoutThermo( true );
+    }
+}
+
+/*!
+  \return Number of pixels between pipe and scale
+  \sa setSpacing()
+*/
+int QwtThermo::spacing() const
+{
+    return d_data->spacing;
+}
+
+/*!
+   Set the border width of the pipe.
+   \param width Border width
+   \sa borderWidth()
+*/
+void QwtThermo::setBorderWidth( int width )
+{
+    if ( width <= 0 )
+        width = 0;
+
+    if ( width != d_data->borderWidth  )
+    {
+        d_data->borderWidth = width;
+        layoutThermo( true );
+    }
+}
+
+/*!
+   \return Border width of the thermometer pipe.
+   \sa setBorderWidth()
+*/
+int QwtThermo::borderWidth() const
+{
+    return d_data->borderWidth;
+}
+
+/*!
+  \brief Assign a color map for the fill color
+
+  \param colorMap Color map
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+void QwtThermo::setColorMap( QwtColorMap *colorMap )
+{
+    if ( colorMap != d_data->colorMap )
+    {
+        delete d_data->colorMap;
+        d_data->colorMap = colorMap;
+    }
+}
+
+/*!
+  \return Color map for the fill color
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+QwtColorMap *QwtThermo::colorMap()
+{
+    return d_data->colorMap;
+}
+
+/*!
+  \return Color map for the fill color
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+const QwtColorMap *QwtThermo::colorMap() const
+{
+    return d_data->colorMap;
+}
+
+/*!
+  \brief Change the brush of the liquid.
+ 
+  Changes the QPalette::ButtonText brush of the palette.
+
+  \param brush New brush. 
+  \sa fillBrush(), QWidget::setPalette()
+*/
+void QwtThermo::setFillBrush( const QBrush& brush )
+{
+    QPalette pal = palette();
+    pal.setBrush( QPalette::ButtonText, brush );
+    setPalette( pal );
+}
+
+/*!
+  \return Liquid ( QPalette::ButtonText ) brush. 
+  \sa setFillBrush(), QWidget::palette()
+*/
+QBrush QwtThermo::fillBrush() const
+{
+    return palette().brush( QPalette::ButtonText );
+}
+
+/*!
+  \brief Specify the liquid brush above the alarm threshold
+
+  Changes the QPalette::Highlight brush of the palette.
+
+  \param brush New brush. 
+  \sa alarmBrush(), QWidget::setPalette()
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+void QwtThermo::setAlarmBrush( const QBrush& brush )
+{
+    QPalette pal = palette();
+    pal.setBrush( QPalette::Highlight, brush );
+    setPalette( pal );
+}
+
+/*!
+  \return Liquid brush ( QPalette::Highlight ) above the alarm threshold.
+  \sa setAlarmBrush(), QWidget::palette()
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+QBrush QwtThermo::alarmBrush() const
+{
+    return palette().brush( QPalette::Highlight );
+}
+
+/*!
+  Specify the alarm threshold.
+
+  \param level Alarm threshold
+  \sa alarmLevel()
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+void QwtThermo::setAlarmLevel( double level )
+{
+    d_data->alarmLevel = level;
+    d_data->alarmEnabled = 1;
+    update();
+}
+
+/*!
+  \return Alarm threshold.
+  \sa setAlarmLevel()
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+double QwtThermo::alarmLevel() const
+{
+    return d_data->alarmLevel;
+}
+
+/*!
+  Change the width of the pipe.
+
+  \param width Width of the pipe
+  \sa pipeWidth()
+*/
+void QwtThermo::setPipeWidth( int width )
+{
+    if ( width > 0 )
+    {
+        d_data->pipeWidth = width;
+        layoutThermo( true );
+    }
+}
+
+/*!
+  \return Width of the pipe.
+  \sa setPipeWidth()
+*/
+int QwtThermo::pipeWidth() const
+{
+    return d_data->pipeWidth;
+}
+
+/*!
+  \brief Enable or disable the alarm threshold
+  \param on true (disabled) or false (enabled)
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+void QwtThermo::setAlarmEnabled( bool on )
+{
+    d_data->alarmEnabled = on;
+    update();
+}
+
+/*! 
+  \return True, when the alarm threshold is enabled.
+
+  \warning The alarm threshold has no effect, when
+           a color map has been assigned
+*/
+bool QwtThermo::alarmEnabled() const
+{
+    return d_data->alarmEnabled;
+}
+
+/*!
+  \return the minimum size hint
+  \sa minimumSizeHint()
+*/
+QSize QwtThermo::sizeHint() const
+{
+    return minimumSizeHint();
+}
+
+/*!
+  \return Minimum size hint
+  \warning The return value depends on the font and the scale.
+  \sa sizeHint()
+*/
+QSize QwtThermo::minimumSizeHint() const
+{
+    int w = 0, h = 0;
+
+    if ( d_data->scalePosition != NoScale )
+    {
+        const int sdExtent = qCeil( scaleDraw()->extent( font() ) );
+        const int sdLength = scaleDraw()->minLength( font() );
+
+        w = sdLength;
+        h = d_data->pipeWidth + sdExtent + d_data->spacing;
+
+    }
+    else // no scale
+    {
+        w = 200;
+        h = d_data->pipeWidth;
+    }
+
+    if ( d_data->orientation == Qt::Vertical )
+        qSwap( w, h );
+
+    w += 2 * d_data->borderWidth;
+    h += 2 * d_data->borderWidth;
+
+    // finally add the margins
+    int left, right, top, bottom;
+    getContentsMargins( &left, &top, &right, &bottom );
+    w += left + right;
+    h += top + bottom;
+
+    return QSize( w, h );
+}
+
+/*!
+  \brief Calculate the filled rectangle of the pipe
+
+  \param pipeRect Rectangle of the pipe
+  \return Rectangle to be filled ( fill and alarm brush )
+
+  \sa pipeRect(), alarmRect()
+ */
+QRect QwtThermo::fillRect( const QRect &pipeRect ) const
+{
+    double origin;        
+    if ( d_data->originMode == OriginMinimum )
+    {
+        origin = qMin( lowerBound(), upperBound() );
+    }
+    else if ( d_data->originMode == OriginMaximum )
+    {
+        origin = qMax( lowerBound(), upperBound() );
+    }
+    else // OriginCustom
+    {
+        origin = d_data->origin;
+    }
+
+    const QwtScaleMap scaleMap = scaleDraw()->scaleMap();
+
+    int from = qRound( scaleMap.transform( d_data->value ) );
+    int to = qRound( scaleMap.transform( origin ) );
+
+    if ( to < from )
+        qSwap( from, to );
+    
+    QRect fillRect = pipeRect;
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        fillRect.setLeft( from );
+        fillRect.setRight( to );
+    }
+    else // Qt::Vertical
+    {
+        fillRect.setTop( from );
+        fillRect.setBottom( to );
+    }
+
+    return fillRect.normalized();
+}
+
+/*!
+  \brief Calculate the alarm rectangle of the pipe
+
+  \param fillRect Filled rectangle in the pipe
+  \return Rectangle to be filled with the alarm brush
+
+  \sa pipeRect(), fillRect(), alarmLevel(), alarmBrush()
+ */
+QRect QwtThermo::alarmRect( const QRect &fillRect ) const
+{
+    QRect alarmRect( 0, 0, -1, -1); // something invalid
+
+    if ( !d_data->alarmEnabled )
+        return alarmRect;
+
+    const bool inverted = ( upperBound() < lowerBound() );
+    
+    bool increasing;
+    if ( d_data->originMode == OriginCustom )
+    {
+        increasing = d_data->value > d_data->origin;
+    }
+    else
+    {
+        increasing = d_data->originMode == OriginMinimum;
+    }
+
+    const QwtScaleMap map = scaleDraw()->scaleMap();
+    const int alarmPos = qRound( map.transform( d_data->alarmLevel ) );
+    const int valuePos = qRound( map.transform( d_data->value ) );
+    
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        int v1, v2;
+        if ( inverted )
+        {
+            v1 = fillRect.left();
+
+            v2 = alarmPos - 1;
+            v2 = qMin( v2, increasing ? fillRect.right() : valuePos );
+        }
+        else
+        {
+            v1 = alarmPos + 1;
+            v1 = qMax( v1, increasing ? fillRect.left() : valuePos );
+
+            v2 = fillRect.right();
+
+        }
+        alarmRect.setRect( v1, fillRect.top(), v2 - v1 + 1, fillRect.height() );
+    }
+    else
+    {
+        int v1, v2;
+        if ( inverted )
+        {
+            v1 = alarmPos + 1;
+            v1 = qMax( v1, increasing ? fillRect.top() : valuePos );
+
+            v2 = fillRect.bottom();
+        }
+        else
+        {
+            v1 = fillRect.top();
+
+            v2 = alarmPos - 1;
+            v2 = qMin( v2, increasing ? fillRect.bottom() : valuePos );
+        }
+        alarmRect.setRect( fillRect.left(), v1, fillRect.width(), v2 - v1 + 1 );
+    }
+
+    return alarmRect;
+} 
Index: trunk/BNC/qwt/qwt_thermo.h
===================================================================
--- trunk/BNC/qwt/qwt_thermo.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_thermo.h	(revision 8127)
@@ -0,0 +1,178 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_THERMO_H
+#define QWT_THERMO_H
+
+#include "qwt_global.h"
+#include "qwt_abstract_scale.h"
+#include "qwt_interval.h"
+
+class QwtScaleDraw;
+class QwtColorMap;
+
+/*!
+  \brief The Thermometer Widget
+
+  QwtThermo is a widget which displays a value in an interval. It supports:
+  - a horizontal or vertical layout;
+  - a range;
+  - a scale;
+  - an alarm level.
+
+  \image html sysinfo.png
+
+  The fill colors might be calculated from an optional color map
+  If no color map has been assigned QwtThermo uses the 
+  following colors/brushes from the widget palette:
+
+  - QPalette::Base
+    Background of the pipe
+  - QPalette::ButtonText
+    Fill brush below the alarm level
+  - QPalette::Highlight
+    Fill brush for the values above the alarm level
+  - QPalette::WindowText
+    For the axis of the scale
+  - QPalette::Text
+    For the labels of the scale
+*/
+class QWT_EXPORT QwtThermo: public QwtAbstractScale
+{
+    Q_OBJECT
+
+    Q_ENUMS( ScalePosition )
+    Q_ENUMS( OriginMode )
+
+    Q_PROPERTY( Qt::Orientation orientation
+        READ orientation WRITE setOrientation )
+    Q_PROPERTY( ScalePosition scalePosition 
+        READ scalePosition WRITE setScalePosition )
+    Q_PROPERTY( OriginMode originMode READ originMode WRITE setOriginMode )
+
+    Q_PROPERTY( bool alarmEnabled READ alarmEnabled WRITE setAlarmEnabled )
+    Q_PROPERTY( double alarmLevel READ alarmLevel WRITE setAlarmLevel )
+    Q_PROPERTY( double origin READ origin WRITE setOrigin )
+    Q_PROPERTY( int spacing READ spacing WRITE setSpacing )
+    Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
+    Q_PROPERTY( int pipeWidth READ pipeWidth WRITE setPipeWidth )
+    Q_PROPERTY( double value READ value WRITE setValue )
+
+public:
+
+    /*!
+      Position of the scale
+      \sa setScalePosition(), setOrientation()
+     */
+    enum ScalePosition
+    {
+        //! The slider has no scale
+        NoScale,
+
+        //! The scale is right of a vertical or below of a horizontal slider
+        LeadingScale,
+
+        //! The scale is left of a vertical or above of a horizontal slider
+        TrailingScale
+    };
+
+    /*!
+      Origin mode. This property specifies where the beginning of the liquid
+      is placed.
+
+      \sa setOriginMode(), setOrigin()
+    */
+    enum OriginMode
+    {
+        //! The origin is the minimum of the scale
+        OriginMinimum,
+
+        //! The origin is the maximum of the scale
+        OriginMaximum,
+
+        //! The origin is specified using the origin() property
+        OriginCustom
+    };
+
+    explicit QwtThermo( QWidget *parent = NULL );
+    virtual ~QwtThermo();
+
+    void setOrientation( Qt::Orientation );
+    Qt::Orientation orientation() const;
+
+    void setScalePosition( ScalePosition );
+    ScalePosition scalePosition() const;
+
+    void setSpacing( int );
+    int spacing() const;
+
+    void setBorderWidth( int w );
+    int borderWidth() const;
+
+    void setOriginMode( OriginMode );
+    OriginMode originMode() const;
+
+    void setOrigin( double );
+    double origin() const;
+
+    void setFillBrush( const QBrush &b );
+    QBrush fillBrush() const;
+
+    void setAlarmBrush( const QBrush &b );
+    QBrush alarmBrush() const;
+
+    void setAlarmLevel( double v );
+    double alarmLevel() const;
+
+    void setAlarmEnabled( bool tf );
+    bool alarmEnabled() const;
+
+    void setColorMap( QwtColorMap * );
+    QwtColorMap *colorMap();
+    const QwtColorMap *colorMap() const;
+
+    void setPipeWidth( int w );
+    int pipeWidth() const;
+
+    void setRangeFlags( QwtInterval::BorderFlags );
+    QwtInterval::BorderFlags rangeFlags() const;
+
+    double value() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+    void setScaleDraw( QwtScaleDraw * );
+    const QwtScaleDraw *scaleDraw() const;
+
+public Q_SLOTS:
+    virtual void setValue( double val );
+
+protected:
+    virtual void drawLiquid( QPainter *, const QRect & ) const;
+    virtual void scaleChange();
+
+    virtual void paintEvent( QPaintEvent * );
+    virtual void resizeEvent( QResizeEvent * );
+    virtual void changeEvent( QEvent * );
+
+    QwtScaleDraw *scaleDraw();
+
+    QRect pipeRect() const;
+    QRect fillRect( const QRect & ) const;
+    QRect alarmRect( const QRect & ) const;
+
+private:
+    void layoutThermo( bool );
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_transform.cpp
===================================================================
--- trunk/BNC/qwt/qwt_transform.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_transform.cpp	(revision 8127)
@@ -0,0 +1,177 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_transform.h"
+#include "qwt_math.h"
+
+#if QT_VERSION < 0x040601
+#define qExp(x) ::exp(x)
+#endif
+
+#if QT_VERSION >= 0x050400
+
+//! Smallest allowed value for logarithmic scales: 1.0e-150
+const double QwtLogTransform::LogMin = 1.0e-150;
+    
+//! Largest allowed value for logarithmic scales: 1.0e150
+const double QwtLogTransform::LogMax = 1.0e150;
+
+#else
+
+//! Smallest allowed value for logarithmic scales: 1.0e-150
+QT_STATIC_CONST_IMPL double QwtLogTransform::LogMin = 1.0e-150;
+
+//! Largest allowed value for logarithmic scales: 1.0e150
+QT_STATIC_CONST_IMPL double QwtLogTransform::LogMax = 1.0e150;
+
+#endif
+
+//! Constructor
+QwtTransform::QwtTransform()
+{
+}
+
+//! Destructor
+QwtTransform::~QwtTransform()
+{
+}
+
+/*! 
+  \param value Value to be bounded
+  \return value unmodified
+ */
+double QwtTransform::bounded( double value ) const
+{
+    return value;
+}
+
+//! Constructor
+QwtNullTransform::QwtNullTransform():
+    QwtTransform()
+{
+}
+
+//! Destructor
+QwtNullTransform::~QwtNullTransform()
+{
+}
+
+/*! 
+  \param value Value to be transformed
+  \return value unmodified
+ */
+double QwtNullTransform::transform( double value ) const
+{
+    return value;
+}
+
+/*! 
+  \param value Value to be transformed
+  \return value unmodified
+ */
+double QwtNullTransform::invTransform( double value ) const
+{
+    return value;
+}
+
+//! \return Clone of the transformation
+QwtTransform *QwtNullTransform::copy() const
+{
+    return new QwtNullTransform();
+}
+
+//! Constructor
+QwtLogTransform::QwtLogTransform():
+    QwtTransform()
+{
+}
+
+//! Destructor
+QwtLogTransform::~QwtLogTransform()
+{
+}
+
+/*! 
+  \param value Value to be transformed
+  \return log( value )
+ */
+double QwtLogTransform::transform( double value ) const
+{
+    return ::log( value );
+}
+
+/*! 
+  \param value Value to be transformed
+  \return exp( value )
+ */
+double QwtLogTransform::invTransform( double value ) const
+{
+    return qExp( value );
+}
+
+/*! 
+  \param value Value to be bounded
+  \return qBound( LogMin, value, LogMax )
+ */
+double QwtLogTransform::bounded( double value ) const
+{
+    return qBound( LogMin, value, LogMax );
+}
+
+//! \return Clone of the transformation
+QwtTransform *QwtLogTransform::copy() const
+{
+    return new QwtLogTransform();
+}
+
+/*!
+  Constructor
+  \param exponent Exponent
+*/
+QwtPowerTransform::QwtPowerTransform( double exponent ):
+    QwtTransform(),
+    d_exponent( exponent )
+{
+}
+
+//! Destructor
+QwtPowerTransform::~QwtPowerTransform()
+{
+}
+
+/*! 
+  \param value Value to be transformed
+  \return Exponentiation preserving the sign
+ */
+double QwtPowerTransform::transform( double value ) const
+{
+    if ( value < 0.0 )
+        return -qPow( -value, 1.0 / d_exponent );
+    else
+        return qPow( value, 1.0 / d_exponent );
+    
+}
+
+/*! 
+  \param value Value to be transformed
+  \return Inverse exponentiation preserving the sign
+ */
+double QwtPowerTransform::invTransform( double value ) const
+{
+    if ( value < 0.0 )
+        return -qPow( -value, d_exponent );
+    else
+        return qPow( value, d_exponent );
+}
+
+//! \return Clone of the transformation
+QwtTransform *QwtPowerTransform::copy() const
+{
+    return new QwtPowerTransform( d_exponent );
+}
Index: trunk/BNC/qwt/qwt_transform.h
===================================================================
--- trunk/BNC/qwt/qwt_transform.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_transform.h	(revision 8127)
@@ -0,0 +1,142 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_TRANSFORM_H
+#define QWT_TRANSFORM_H
+
+#include "qwt_global.h"
+
+/*!
+   \brief A transformation between coordinate systems
+
+   QwtTransform manipulates values, when being mapped between
+   the scale and the paint device coordinate system.
+
+   A transformation consists of 2 methods:
+
+   - transform
+   - invTransform
+
+   where one is is the inverse function of the other.
+
+   When p1, p2 are the boundaries of the paint device coordinates
+   and s1, s2 the boundaries of the scale, QwtScaleMap uses the
+   following calculations:
+
+   - p = p1 + ( p2 - p1 ) * ( T( s ) - T( s1 ) / ( T( s2 ) - T( s1 ) );
+   - s = invT ( T( s1 ) + ( T( s2 ) - T( s1 ) ) * ( p - p1 ) / ( p2 - p1 ) );
+*/
+class QWT_EXPORT QwtTransform
+{
+public:
+    QwtTransform();
+    virtual ~QwtTransform();
+
+    /*!
+       Modify value to be a valid value for the transformation.
+       The default implementation does nothing.
+     */
+    virtual double bounded( double value ) const;
+
+    /*!
+        Transformation function
+
+        \param value Value
+        \return Modified value
+
+        \sa invTransform()
+     */
+    virtual double transform( double value ) const = 0;
+
+    /*!
+        Inverse transformation function
+
+        \param value Value
+        \return Modified value
+
+        \sa transform()
+     */
+    virtual double invTransform( double value ) const = 0;
+
+    //! Virtualized copy operation
+    virtual QwtTransform *copy() const = 0;
+};
+
+/*!
+   \brief Null transformation
+
+   QwtNullTransform returns the values unmodified.
+   
+ */
+class QWT_EXPORT QwtNullTransform: public QwtTransform
+{
+public:
+    QwtNullTransform();
+    virtual ~QwtNullTransform();
+
+    virtual double transform( double value ) const;
+    virtual double invTransform( double value ) const;
+
+    virtual QwtTransform *copy() const;
+};
+/*!
+   \brief Logarithmic transformation
+
+   QwtLogTransform modifies the values using log() and exp().
+
+   \note In the calculations of QwtScaleMap the base of the log function
+         has no effect on the mapping. So QwtLogTransform can be used 
+         for log2(), log10() or any other logarithmic scale.
+ */
+class QWT_EXPORT QwtLogTransform: public QwtTransform
+{   
+public:
+    QwtLogTransform();
+    virtual ~QwtLogTransform();
+    
+    virtual double transform( double value ) const;
+    virtual double invTransform( double value ) const;
+
+    virtual double bounded( double value ) const;
+
+    virtual QwtTransform *copy() const;
+
+#if QT_VERSION >= 0x050400
+    static const double LogMin;
+    static const double LogMax;
+#else
+    QT_STATIC_CONST double LogMin;
+    QT_STATIC_CONST double LogMax;
+#endif
+};
+
+/*!
+   \brief A transformation using pow()
+
+   QwtPowerTransform preserves the sign of a value. 
+   F.e. a transformation with a factor of 2
+   transforms a value of -3 to -9 and v.v. Thus QwtPowerTransform
+   can be used for scales including negative values.
+ */
+class QWT_EXPORT QwtPowerTransform: public QwtTransform
+{
+public:
+    QwtPowerTransform( double exponent );
+    virtual ~QwtPowerTransform();
+
+    virtual double transform( double value ) const;
+    virtual double invTransform( double value ) const;
+
+    virtual QwtTransform *copy() const;
+
+private:
+    const double d_exponent;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_wheel.cpp
===================================================================
--- trunk/BNC/qwt/qwt_wheel.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_wheel.cpp	(revision 8127)
@@ -0,0 +1,1299 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_wheel.h"
+#include "qwt_math.h"
+#include "qwt_painter.h"
+#include <qevent.h>
+#include <qdrawutil.h>
+#include <qpainter.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#include <qapplication.h>
+#include <qdatetime.h>
+
+#if QT_VERSION < 0x040601
+#define qFabs(x) ::fabs(x)
+#define qFastSin(x) ::sin(x)
+#define qExp(x) ::exp(x)
+#endif
+
+class QwtWheel::PrivateData
+{
+public:
+    PrivateData():
+        orientation( Qt::Horizontal ),
+        viewAngle( 175.0 ),
+        totalAngle( 360.0 ),
+        tickCount( 10 ),
+        wheelBorderWidth( 2 ),
+        borderWidth( 2 ),
+        wheelWidth( 20 ),
+        isScrolling( false ),
+        mouseOffset( 0.0 ),
+        tracking( true ),
+        pendingValueChanged( false ),
+        updateInterval( 50 ),
+        mass( 0.0 ),
+        timerId( 0 ),
+        speed( 0.0 ),
+        mouseValue( 0.0 ),
+        flyingValue( 0.0 ),
+        minimum( 0.0 ),
+        maximum( 100.0 ),
+        singleStep( 1.0 ),
+        pageStepCount( 1 ),
+        stepAlignment( true ),
+        value( 0.0 ),
+        inverted( false ),
+        wrapping( false )
+    {
+    };
+
+    Qt::Orientation orientation;
+    double viewAngle;
+    double totalAngle;
+    int tickCount;
+    int wheelBorderWidth;
+    int borderWidth;
+    int wheelWidth;
+
+    bool isScrolling;
+    double mouseOffset;
+
+    bool tracking;
+    bool pendingValueChanged; // when not tracking
+
+    int updateInterval;
+    double mass;
+
+    // for the flying wheel effect
+    int timerId;
+    QTime time;
+    double speed;
+    double mouseValue;
+    double flyingValue;
+
+    double minimum;
+    double maximum;
+
+    double singleStep;
+    int pageStepCount;
+    bool stepAlignment;
+
+    double value;
+
+    bool inverted;
+    bool wrapping;
+};
+
+//! Constructor
+QwtWheel::QwtWheel( QWidget *parent ):
+    QWidget( parent )
+{
+    d_data = new PrivateData;
+
+    setFocusPolicy( Qt::StrongFocus );
+    setSizePolicy( QSizePolicy::Preferred, QSizePolicy::Fixed );
+    setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+}
+
+//! Destructor
+QwtWheel::~QwtWheel()
+{
+    delete d_data;
+}
+
+/*!
+  \brief En/Disable tracking
+
+  If tracking is enabled (the default), the wheel emits the valueChanged() 
+  signal while the wheel is moving. If tracking is disabled, the wheel 
+  emits the valueChanged() signal only when the wheel movement is terminated.
+
+  The wheelMoved() signal is emitted regardless id tracking is enabled or not.
+
+  \param enable On/Off
+  \sa isTracking()
+ */
+void QwtWheel::setTracking( bool enable )
+{
+    d_data->tracking = enable;
+}
+
+/*!
+  \return True, when tracking is enabled
+  \sa setTracking(), valueChanged(), wheelMoved()
+*/
+bool QwtWheel::isTracking() const
+{
+    return d_data->tracking;
+}
+
+/*!
+  \brief Specify the update interval when the wheel is flying
+
+  Default and minimum value is 50 ms.
+
+  \param interval Interval in milliseconds
+  \sa updateInterval(), setMass(), setTracking()
+*/
+void QwtWheel::setUpdateInterval( int interval )
+{
+    d_data->updateInterval = qMax( interval, 50 );
+}
+
+/*!
+  \return Update interval when the wheel is flying
+  \sa setUpdateInterval(), mass(), isTracking()
+ */
+int QwtWheel::updateInterval() const
+{
+    return d_data->updateInterval;
+}
+
+/*!
+   \brief Mouse press event handler
+
+   Start movement of the wheel. 
+
+   \param event Mouse event
+*/
+void QwtWheel::mousePressEvent( QMouseEvent *event )
+{
+    stopFlying();
+
+    d_data->isScrolling = wheelRect().contains( event->pos() );
+
+    if ( d_data->isScrolling )
+    {
+        d_data->time.start();
+        d_data->speed = 0.0;
+        d_data->mouseValue = valueAt( event->pos() );
+        d_data->mouseOffset = d_data->mouseValue - d_data->value;
+        d_data->pendingValueChanged = false;
+
+        Q_EMIT wheelPressed();
+    }
+}
+
+/*!
+   \brief Mouse Move Event handler
+
+   Turn the wheel according to the mouse position
+
+   \param event Mouse event
+*/
+void QwtWheel::mouseMoveEvent( QMouseEvent *event )
+{
+    if ( !d_data->isScrolling )
+        return;
+
+    double mouseValue = valueAt( event->pos() );
+
+    if ( d_data->mass > 0.0 )
+    {
+        double ms = d_data->time.restart();
+
+        // the interval when mouse move events are posted are somehow
+        // random. To avoid unrealistic speed values we limit ms
+
+        ms = qMax( ms, 5.0 );
+
+        d_data->speed = ( mouseValue - d_data->mouseValue ) / ms;
+    }
+    
+    d_data->mouseValue = mouseValue; 
+
+    double value = boundedValue( mouseValue - d_data->mouseOffset );
+    if ( d_data->stepAlignment )
+        value = alignedValue( value );
+        
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+
+        update();
+
+        Q_EMIT wheelMoved( d_data->value );
+
+        if ( d_data->tracking )
+            Q_EMIT valueChanged( d_data->value );
+        else
+            d_data->pendingValueChanged = true;
+    }
+}
+
+/*!
+   \brief Mouse Release Event handler
+
+   When the wheel has no mass the movement of the wheel stops, otherwise
+   it starts flying.
+
+   \param event Mouse event
+*/  
+
+void QwtWheel::mouseReleaseEvent( QMouseEvent *event )
+{
+    Q_UNUSED( event );
+
+    if ( !d_data->isScrolling )
+        return;
+
+    d_data->isScrolling = false;
+
+    bool startFlying = false;
+
+    if ( d_data->mass > 0.0 )
+    {
+        const int ms = d_data->time.elapsed();
+        if ( ( qFabs( d_data->speed ) > 0.0 ) && ( ms < 50 ) )
+            startFlying = true;
+    }
+
+    if ( startFlying )
+    {
+        d_data->flyingValue = 
+            boundedValue( d_data->mouseValue - d_data->mouseOffset );
+
+        d_data->timerId = startTimer( d_data->updateInterval );
+    }
+    else
+    {
+        if ( d_data->pendingValueChanged )
+            Q_EMIT valueChanged( d_data->value );
+    }
+
+    d_data->pendingValueChanged = false;
+    d_data->mouseOffset = 0.0;
+
+    Q_EMIT wheelReleased();
+}
+
+/*!
+  \brief Qt timer event
+
+  The flying wheel effect is implemented using a timer
+   
+  \param event Timer event
+
+  \sa updateInterval()
+ */
+void QwtWheel::timerEvent( QTimerEvent *event )
+{
+    if ( event->timerId() != d_data->timerId )
+    {
+        QWidget::timerEvent( event );
+        return;
+    }
+
+    d_data->speed *= qExp( -d_data->updateInterval * 0.001 / d_data->mass );
+
+    d_data->flyingValue += d_data->speed * d_data->updateInterval;
+    d_data->flyingValue = boundedValue( d_data->flyingValue );
+
+    double value = d_data->flyingValue;
+    if ( d_data->stepAlignment )
+        value = alignedValue( value );
+
+    if ( qFabs( d_data->speed ) < 0.001 * d_data->singleStep )
+    {
+        // stop if d_data->speed < one step per second
+        stopFlying();
+    }
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        update();
+
+        if ( d_data->tracking || d_data->timerId == 0 )
+            Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+
+/*!
+  \brief Handle wheel events
+
+  In/Decrement the value 
+
+  \param event Wheel event
+*/
+void QwtWheel::wheelEvent( QWheelEvent *event )
+{
+    if ( !wheelRect().contains( event->pos() ) )
+    {
+        event->ignore();
+        return;
+    }
+
+    if ( d_data->isScrolling )
+        return;
+
+    stopFlying();
+
+    double increment = 0.0;
+
+    if ( ( event->modifiers() & Qt::ControlModifier) || 
+        ( event->modifiers() & Qt::ShiftModifier ) )
+    {
+        // one page regardless of delta
+        increment = d_data->singleStep * d_data->pageStepCount;
+        if ( event->delta() < 0 )
+            increment = -increment;
+    }
+    else
+    {
+        const int numSteps = event->delta() / 120;
+        increment = d_data->singleStep * numSteps;
+    }
+
+    if ( d_data->orientation == Qt::Vertical && d_data->inverted )
+        increment = -increment;
+
+    double value = boundedValue( d_data->value + increment );
+
+    if ( d_data->stepAlignment )
+        value = alignedValue( value );
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        update();
+
+        Q_EMIT valueChanged( d_data->value );
+        Q_EMIT wheelMoved( d_data->value );
+    }
+}
+
+/*!
+  Handle key events
+
+  - Qt::Key_Home\n
+    Step to minimum()
+
+  - Qt::Key_End\n
+    Step to maximum()
+
+  - Qt::Key_Up\n
+    In case of a horizontal or not inverted vertical wheel the value 
+    will be incremented by the step size. For an inverted vertical wheel
+    the value will be decremented by the step size.
+
+  - Qt::Key_Down\n
+    In case of a horizontal or not inverted vertical wheel the value 
+    will be decremented by the step size. For an inverted vertical wheel
+    the value will be incremented by the step size.
+
+  - Qt::Key_PageUp\n
+    The value will be incremented by pageStepSize() * singleStepSize().
+
+  - Qt::Key_PageDown\n
+    The value will be decremented by pageStepSize() * singleStepSize().
+
+  \param event Key event
+*/
+void QwtWheel::keyPressEvent( QKeyEvent *event )
+{
+    if ( d_data->isScrolling )
+    {
+        // don't interfere mouse scrolling
+        return;
+    }
+
+    double value = d_data->value;
+    double increment = 0.0;
+
+    switch ( event->key() )
+    {
+        case Qt::Key_Down:
+        {
+            if ( d_data->orientation == Qt::Vertical && d_data->inverted )
+                increment = d_data->singleStep;
+            else
+                increment = -d_data->singleStep;
+
+            break;
+        }
+        case Qt::Key_Up:
+        {
+            if ( d_data->orientation == Qt::Vertical && d_data->inverted )
+                increment = -d_data->singleStep;
+            else
+                increment = d_data->singleStep;
+
+            break;
+        }
+        case Qt::Key_Left:
+        {
+            if ( d_data->orientation == Qt::Horizontal )
+            {
+                if ( d_data->inverted )
+                    increment = d_data->singleStep;
+                else
+                    increment = -d_data->singleStep;
+            }
+            break;
+        }
+        case Qt::Key_Right:
+        {
+            if ( d_data->orientation == Qt::Horizontal )
+            {
+                if ( d_data->inverted )
+                    increment = -d_data->singleStep;
+                else
+                    increment = d_data->singleStep;
+            }
+            break;
+        }
+        case Qt::Key_PageUp:
+        {
+            increment = d_data->pageStepCount * d_data->singleStep;
+            break;
+        }
+        case Qt::Key_PageDown:
+        {
+            increment = -d_data->pageStepCount * d_data->singleStep;
+            break;
+        }
+        case Qt::Key_Home:
+        {
+            value = d_data->minimum;
+            break;
+        }
+        case Qt::Key_End:
+        {
+            value = d_data->maximum;
+            break;
+        }
+        default:;
+        {
+            event->ignore();
+        }
+    }
+
+    if ( event->isAccepted() )
+        stopFlying();
+    
+    if ( increment != 0.0 )
+    {
+        value = boundedValue( d_data->value + increment );
+
+        if ( d_data->stepAlignment )
+            value = alignedValue( value );
+    }
+
+    if ( value != d_data->value )
+    {
+        d_data->value = value;
+        update();
+
+        Q_EMIT valueChanged( d_data->value );
+        Q_EMIT wheelMoved( d_data->value );
+    }
+}
+
+/*!
+  \brief Adjust the number of grooves in the wheel's surface.
+
+  The number of grooves is limited to 6 <= count <= 50.
+  Values outside this range will be clipped.
+  The default value is 10.
+
+  \param count Number of grooves per 360 degrees
+  \sa tickCount()
+*/
+void QwtWheel::setTickCount( int count )
+{
+    count = qBound( 6, count, 50 );
+
+    if ( count != d_data->tickCount )
+    {
+        d_data->tickCount = qBound( 6, count, 50 );
+        update();
+    }
+}
+
+/*!
+  \return Number of grooves in the wheel's surface.
+  \sa setTickCnt()
+*/
+int QwtWheel::tickCount() const
+{
+    return d_data->tickCount;
+}
+
+/*!
+  \brief Set the wheel border width of the wheel.
+
+  The wheel border must not be smaller than 1
+  and is limited in dependence on the wheel's size.
+  Values outside the allowed range will be clipped.
+
+  The wheel border defaults to 2.
+
+  \param borderWidth Border width
+  \sa internalBorder()
+*/
+void QwtWheel::setWheelBorderWidth( int borderWidth )
+{
+    const int d = qMin( width(), height() ) / 3;
+    borderWidth = qMin( borderWidth, d );
+    d_data->wheelBorderWidth = qMax( borderWidth, 1 );
+    update();
+}
+
+/*!
+   \return Wheel border width 
+   \sa setWheelBorderWidth()
+*/
+int QwtWheel::wheelBorderWidth() const
+{
+    return d_data->wheelBorderWidth;
+}
+
+/*!
+  \brief Set the border width 
+
+  The border defaults to 2.
+
+  \param width Border width
+  \sa borderWidth()
+*/
+void QwtWheel::setBorderWidth( int width )
+{
+    d_data->borderWidth = qMax( width, 0 );
+    update();
+}
+
+/*!
+   \return Border width 
+   \sa setBorderWidth()
+*/
+int QwtWheel::borderWidth() const
+{
+    return d_data->borderWidth;
+}
+
+/*!
+   \return Rectangle of the wheel without the outer border
+*/
+QRect QwtWheel::wheelRect() const
+{
+    const int bw = d_data->borderWidth;
+    return contentsRect().adjusted( bw, bw, -bw, -bw );
+}
+
+/*!
+  \brief Set the total angle which the wheel can be turned.
+
+  One full turn of the wheel corresponds to an angle of
+  360 degrees. A total angle of n*360 degrees means
+  that the wheel has to be turned n times around its axis
+  to get from the minimum value to the maximum value.
+
+  The default setting of the total angle is 360 degrees.
+
+  \param angle total angle in degrees
+  \sa totalAngle()
+*/
+void QwtWheel::setTotalAngle( double angle )
+{
+    if ( angle < 0.0 )
+        angle = 0.0;
+
+    d_data->totalAngle = angle;
+    update();
+}
+
+/*!
+  \return Total angle which the wheel can be turned.
+  \sa setTotalAngle()
+*/
+double QwtWheel::totalAngle() const
+{
+    return d_data->totalAngle;
+}
+
+/*!
+  \brief Set the wheel's orientation.
+
+  The default orientation is Qt::Horizontal.
+
+  \param orientation Qt::Horizontal or Qt::Vertical.
+  \sa orientation()
+*/
+void QwtWheel::setOrientation( Qt::Orientation orientation )
+{
+    if ( d_data->orientation == orientation )
+        return;
+
+    if ( !testAttribute( Qt::WA_WState_OwnSizePolicy ) )
+    {
+        QSizePolicy sp = sizePolicy();
+        sp.transpose();
+        setSizePolicy( sp );
+
+        setAttribute( Qt::WA_WState_OwnSizePolicy, false );
+    }
+
+    d_data->orientation = orientation;
+    update();
+}
+
+/*!
+  \return Orientation
+  \sa setOrientation()
+*/
+Qt::Orientation QwtWheel::orientation() const
+{
+    return d_data->orientation;
+}
+
+/*!
+  \brief Specify the visible portion of the wheel.
+
+  You may use this function for fine-tuning the appearance of
+  the wheel. The default value is 175 degrees. The value is
+  limited from 10 to 175 degrees.
+
+  \param angle Visible angle in degrees
+  \sa viewAngle(), setTotalAngle()
+*/
+void QwtWheel::setViewAngle( double angle )
+{
+    d_data->viewAngle = qBound( 10.0, angle, 175.0 );
+    update();
+}
+
+/*!
+  \return Visible portion of the wheel
+  \sa setViewAngle(), totalAngle()
+*/
+double QwtWheel::viewAngle() const
+{
+    return d_data->viewAngle;
+}
+
+/*! 
+  Determine the value corresponding to a specified point
+
+  \param pos Position
+  \return Value corresponding to pos
+*/
+double QwtWheel::valueAt( const QPoint &pos ) const
+{
+    const QRectF rect = wheelRect();
+
+    double w, dx;
+    if ( d_data->orientation == Qt::Vertical )
+    {
+        w = rect.height();
+        dx = rect.top() - pos.y();
+    }
+    else
+    {
+        w = rect.width();
+        dx = pos.x() - rect.left();
+    }
+
+    if ( w == 0.0 )
+        return 0.0;
+
+    if ( d_data->inverted )
+    {
+        dx = w - dx;
+    }
+
+    // w pixels is an arc of viewAngle degrees,
+    // so we convert change in pixels to change in angle
+    const double ang = dx * d_data->viewAngle / w;
+
+    // value range maps to totalAngle degrees,
+    // so convert the change in angle to a change in value
+    const double val = ang * ( maximum() - minimum() ) / d_data->totalAngle;
+
+    return val;
+}
+
+/*! 
+   \brief Qt Paint Event
+   \param event Paint event
+*/
+void QwtWheel::paintEvent( QPaintEvent *event )
+{
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    QStyleOption opt;
+    opt.init(this);
+    style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this);
+
+    qDrawShadePanel( &painter, 
+        contentsRect(), palette(), true, d_data->borderWidth );
+
+    drawWheelBackground( &painter, wheelRect() );
+    drawTicks( &painter, wheelRect() );
+
+    if ( hasFocus() )
+        QwtPainter::drawFocusRect( &painter, this );
+}
+
+/*!
+   Draw the Wheel's background gradient
+
+   \param painter Painter
+   \param rect Geometry for the wheel
+*/
+void QwtWheel::drawWheelBackground( 
+    QPainter *painter, const QRectF &rect )
+{
+    painter->save();
+
+    QPalette pal = palette();
+
+    //  draw shaded background
+    QLinearGradient gradient( rect.topLeft(), 
+        ( d_data->orientation == Qt::Horizontal ) ? rect.topRight() : rect.bottomLeft() );
+    gradient.setColorAt( 0.0, pal.color( QPalette::Button ) );
+    gradient.setColorAt( 0.2, pal.color( QPalette::Midlight ) );
+    gradient.setColorAt( 0.7, pal.color( QPalette::Mid ) );
+    gradient.setColorAt( 1.0, pal.color( QPalette::Dark ) );
+
+    painter->fillRect( rect, gradient );
+
+    // draw internal border
+
+    const QPen lightPen( palette().color( QPalette::Light ), 
+        d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
+    const QPen darkPen( pal.color( QPalette::Dark ), 
+        d_data->wheelBorderWidth, Qt::SolidLine, Qt::FlatCap );
+
+    const double bw2 = 0.5 * d_data->wheelBorderWidth;
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        painter->setPen( lightPen );
+        painter->drawLine( QPointF( rect.left(), rect.top() + bw2 ), 
+            QPointF( rect.right(), rect.top() + bw2 ) );
+
+        painter->setPen( darkPen );
+        painter->drawLine( QPointF( rect.left(), rect.bottom() - bw2 ), 
+            QPointF( rect.right(), rect.bottom() - bw2 ) );
+    }
+    else // Qt::Vertical
+    {
+        painter->setPen( lightPen );
+        painter->drawLine( QPointF( rect.left() + bw2, rect.top() ), 
+            QPointF( rect.left() + bw2, rect.bottom() ) );
+
+        painter->setPen( darkPen );
+        painter->drawLine( QPointF( rect.right() - bw2, rect.top() ), 
+            QPointF( rect.right() - bw2, rect.bottom() ) );
+    }
+
+    painter->restore();
+}
+
+/*!
+   Draw the Wheel's ticks
+
+   \param painter Painter
+   \param rect Geometry for the wheel
+*/
+void QwtWheel::drawTicks( QPainter *painter, const QRectF &rect )
+{
+    const double range = d_data->maximum - d_data->minimum;
+
+    if ( range == 0.0 || d_data->totalAngle == 0.0 )
+    {
+        return;
+    }
+
+    const QPen lightPen( palette().color( QPalette::Light ), 
+        0, Qt::SolidLine, Qt::FlatCap );
+    const QPen darkPen( palette().color( QPalette::Dark ), 
+        0, Qt::SolidLine, Qt::FlatCap );
+
+    const double cnvFactor = qAbs( d_data->totalAngle / range );
+    const double halfIntv = 0.5 * d_data->viewAngle / cnvFactor;
+    const double loValue = value() - halfIntv;
+    const double hiValue = value() + halfIntv;
+    const double tickWidth = 360.0 / double( d_data->tickCount ) / cnvFactor;
+    const double sinArc = qFastSin( d_data->viewAngle * M_PI / 360.0 );
+
+    if ( d_data->orientation == Qt::Horizontal )
+    {
+        const double radius = rect.width() * 0.5;
+
+        double l1 = rect.top() + d_data->wheelBorderWidth;
+        double l2 = rect.bottom() - d_data->wheelBorderWidth - 1;
+
+        // draw one point over the border if border > 1
+        if ( d_data->wheelBorderWidth > 1 )
+        {
+            l1--;
+            l2++;
+        }
+
+        const double maxpos = rect.right() - 2;
+        const double minpos = rect.left() + 2;
+
+        // draw tick marks
+        for ( double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
+            tickValue < hiValue; tickValue += tickWidth )
+        {
+            const double angle = qwtRadians( tickValue - value() );
+            const double s = qFastSin( angle * cnvFactor );
+
+            const double off = radius * ( sinArc + s ) / sinArc;
+
+            double tickPos;
+            if ( d_data->inverted ) 
+                tickPos = rect.left() + off;
+            else
+                tickPos = rect.right() - off;
+
+            if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
+            {
+                painter->setPen( darkPen );
+                painter->drawLine( QPointF( tickPos - 1 , l1 ), 
+                    QPointF( tickPos - 1,  l2 ) );
+                painter->setPen( lightPen );
+                painter->drawLine( QPointF( tickPos, l1 ), 
+                    QPointF( tickPos, l2 ) );
+            }
+        }
+    }
+    else // Qt::Vertical
+    {
+        const double radius = rect.height() * 0.5;
+
+        double l1 = rect.left() + d_data->wheelBorderWidth;
+        double l2 = rect.right() - d_data->wheelBorderWidth - 1;
+
+        if ( d_data->wheelBorderWidth > 1 )
+        {
+            l1--;
+            l2++;
+        }
+
+        const double maxpos = rect.bottom() - 2;
+        const double minpos = rect.top() + 2;
+
+        for ( double tickValue = ::ceil( loValue / tickWidth ) * tickWidth;
+            tickValue < hiValue; tickValue += tickWidth )
+        {
+            const double angle = qwtRadians( tickValue - value() );
+            const double s = qFastSin( angle * cnvFactor );
+
+            const double off = radius * ( sinArc + s ) / sinArc;
+
+            double tickPos;
+
+            if ( d_data->inverted )
+                tickPos = rect.bottom() - off;
+            else
+                tickPos = rect.top() + off;
+
+            if ( ( tickPos <= maxpos ) && ( tickPos > minpos ) )
+            {
+                painter->setPen( darkPen );
+                painter->drawLine( QPointF( l1, tickPos - 1 ), 
+                    QPointF( l2, tickPos - 1 ) );
+                painter->setPen( lightPen );
+                painter->drawLine( QPointF( l1, tickPos ), 
+                    QPointF( l2, tickPos ) );
+            }
+        }
+    }
+}
+
+/*!
+  \brief Set the width of the wheel
+
+  Corresponds to the wheel height for horizontal orientation,
+  and the wheel width for vertical orientation.
+
+  \param width the wheel's width
+  \sa wheelWidth()
+*/
+void QwtWheel::setWheelWidth( int width )
+{
+    d_data->wheelWidth = width;
+    update();
+}
+
+/*!
+  \return Width of the wheel
+  \sa setWheelWidth()
+*/
+int QwtWheel::wheelWidth() const
+{
+    return d_data->wheelWidth;
+}
+
+/*!
+  \return a size hint
+*/
+QSize QwtWheel::sizeHint() const
+{
+    const QSize hint = minimumSizeHint();
+    return hint.expandedTo( QApplication::globalStrut() );
+}
+
+/*!
+  \return Minimum size hint
+  \warning The return value is based on the wheel width.
+*/
+QSize QwtWheel::minimumSizeHint() const
+{
+    QSize sz( 3 * d_data->wheelWidth + 2 * d_data->borderWidth,
+        d_data->wheelWidth + 2 * d_data->borderWidth );
+    if ( d_data->orientation != Qt::Horizontal )
+        sz.transpose();
+
+    return sz;
+}
+
+/*!
+  \brief Set the step size of the counter
+
+  A value <= 0.0 disables stepping
+
+  \param stepSize Single step size
+  \sa singleStep(), setPageStepCount()
+*/
+void QwtWheel::setSingleStep( double stepSize )
+{
+    d_data->singleStep = qMax( stepSize, 0.0 );
+}
+
+/*!
+  \return Single step size
+  \sa setSingleStep()
+ */
+double QwtWheel::singleStep() const
+{
+    return d_data->singleStep;
+}
+
+/*!
+  \brief En/Disable step alignment
+
+  When step alignment is enabled value changes initiated by
+  user input ( mouse, keyboard, wheel ) are aligned to
+  the multiples of the single step.
+
+  \param on On/Off
+  \sa stepAlignment(), setSingleStep()
+ */
+void QwtWheel::setStepAlignment( bool on )
+{
+    if ( on != d_data->stepAlignment )
+    {
+        d_data->stepAlignment = on;
+    }
+}
+
+/*!
+  \return True, when the step alignment is enabled
+  \sa setStepAlignment(), singleStep()
+ */
+bool QwtWheel::stepAlignment() const
+{
+    return d_data->stepAlignment;
+}
+
+/*!
+  \brief Set the page step count  
+    
+  pageStepCount is a multiplicator for the single step size
+  that typically corresponds to the user pressing PageUp or PageDown.
+    
+  A value of 0 disables page stepping. 
+
+  The default value is 1.
+
+  \param count Multiplicator for the single step size
+  \sa pageStepCount(), setSingleStep()
+ */
+void QwtWheel::setPageStepCount( int count )
+{
+    d_data->pageStepCount = qMax( 0, count );
+}
+
+/*! 
+  \return Page step count
+  \sa setPageStepCount(), singleStep()
+ */
+int QwtWheel::pageStepCount() const
+{
+    return d_data->pageStepCount;
+}
+
+/*!
+  \brief Set the minimum and maximum values
+
+  The maximum is adjusted if necessary to ensure that the range remains valid.
+  The value might be modified to be inside of the range.
+
+  \param min Minimum value
+  \param max Maximum value
+
+  \sa minimum(), maximum()
+ */
+void QwtWheel::setRange( double min, double max )
+{
+    max = qMax( min, max );
+
+    if ( d_data->minimum == min && d_data->maximum == max )
+        return;
+
+    d_data->minimum = min;
+    d_data->maximum = max;
+
+    if ( d_data->value < min || d_data->value > max )
+    {
+        d_data->value = qBound( min, d_data->value, max );
+
+        update();
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+/*!
+  Set the minimum value of the range
+
+  \param value Minimum value
+  \sa setRange(), setMaximum(), minimum()
+
+  \note The maximum is adjusted if necessary to ensure that the range remains valid.
+*/
+void QwtWheel::setMinimum( double value )
+{
+    setRange( value, maximum() );
+}
+
+/*!
+  \return The minimum of the range
+  \sa setRange(), setMinimum(), maximum()
+*/
+double QwtWheel::minimum() const
+{
+    return d_data->minimum;
+}
+
+/*!
+  Set the maximum value of the range
+
+  \param value Maximum value
+  \sa setRange(), setMinimum(), maximum()
+*/
+void QwtWheel::setMaximum( double value )
+{
+    setRange( minimum(), value );
+}
+
+/*!
+  \return The maximum of the range
+  \sa setRange(), setMaximum(), minimum()
+*/
+double QwtWheel::maximum() const
+{
+    return d_data->maximum;
+}
+
+/*!
+  \brief Set a new value without adjusting to the step raster
+
+  \param value New value
+
+  \sa value(), valueChanged()
+  \warning The value is clipped when it lies outside the range.
+*/
+void QwtWheel::setValue( double value )
+{
+    stopFlying();
+    d_data->isScrolling = false;
+
+    value = qBound( d_data->minimum, value, d_data->maximum );
+
+    if ( d_data->value != value )
+    {
+        d_data->value = value;
+
+        update();
+        Q_EMIT valueChanged( d_data->value );
+    }
+}
+
+/*!
+  \return Current value of the wheel
+  \sa setValue(), valueChanged()
+ */
+double QwtWheel::value() const
+{
+    return d_data->value;
+}
+
+/*!
+  \brief En/Disable inverted appearance
+
+  An inverted wheel increases its values in the opposite direction.
+  The direction of an inverted horizontal wheel will be from right to left
+  an inverted vertical wheel will increase from bottom to top.
+  
+  \param on En/Disable inverted appearance
+  \sa isInverted()
+ 
+ */
+void QwtWheel::setInverted( bool on )
+{
+    if ( d_data->inverted != on )
+    {
+        d_data->inverted = on;
+        update();
+    }
+}
+
+/*!
+  \return True, when the wheel is inverted
+  \sa setInverted()
+ */
+bool QwtWheel::isInverted() const
+{
+    return d_data->inverted;
+}
+
+/*!
+  \brief En/Disable wrapping
+
+  If wrapping is true stepping up from maximum() value will take 
+  you to the minimum() value and vice versa. 
+
+  \param on En/Disable wrapping
+  \sa wrapping()
+ */
+void QwtWheel::setWrapping( bool on )
+{
+    d_data->wrapping = on;
+}
+
+/*!
+  \return True, when wrapping is set
+  \sa setWrapping()
+ */
+bool QwtWheel::wrapping() const
+{
+    return d_data->wrapping;
+}
+
+/*!
+  \brief Set the slider's mass for flywheel effect.
+
+  If the slider's mass is greater then 0, it will continue
+  to move after the mouse button has been released. Its speed
+  decreases with time at a rate depending on the slider's mass.
+  A large mass means that it will continue to move for a
+  long time.
+
+  Derived widgets may overload this function to make it public.
+
+  \param mass New mass in kg
+
+  \bug If the mass is smaller than 1g, it is set to zero.
+       The maximal mass is limited to 100kg.
+  \sa mass()
+*/
+void QwtWheel::setMass( double mass )
+{
+    if ( mass < 0.001 )
+    {
+        d_data->mass = 0.0;
+    }
+    else
+    {
+        d_data->mass = qMin( 100.0, mass );
+    }
+
+    if ( d_data->mass <= 0.0 )
+        stopFlying();
+}
+
+/*!
+  \return mass
+  \sa setMass()
+*/
+double QwtWheel::mass() const
+{
+    return d_data->mass;
+}
+
+//!  Stop the flying movement of the wheel
+void QwtWheel::stopFlying()
+{
+    if ( d_data->timerId != 0 )
+    {
+        killTimer( d_data->timerId );
+        d_data->timerId = 0;
+        d_data->speed = 0.0;
+    }
+}
+
+double QwtWheel::boundedValue( double value ) const
+{
+    const double range = d_data->maximum - d_data->minimum;
+    
+    if ( d_data->wrapping && range >= 0.0 )
+    {
+        if ( value < d_data->minimum )
+        {
+            value += ::ceil( ( d_data->minimum - value ) / range ) * range;
+        }       
+        else if ( value > d_data->maximum )
+        {
+            value -= ::ceil( ( value - d_data->maximum ) / range ) * range;
+        }
+    }
+    else
+    {
+        value = qBound( d_data->minimum, value, d_data->maximum );
+    }
+
+    return value;
+}
+
+double QwtWheel::alignedValue( double value ) const
+{
+    const double stepSize = d_data->singleStep;
+
+    if ( stepSize > 0.0 )
+    {
+        value = d_data->minimum +
+            qRound( ( value - d_data->minimum ) / stepSize ) * stepSize;
+
+        if ( stepSize > 1e-12 )
+        {
+            if ( qFuzzyCompare( value + 1.0, 1.0 ) )
+            {
+                // correct rounding error if value = 0
+                value = 0.0;
+            }
+            else if ( qFuzzyCompare( value, d_data->maximum ) )
+            {
+                // correct rounding error at the border
+                value = d_data->maximum;
+            }
+        }
+    }       
+
+    return value;
+}
+
Index: trunk/BNC/qwt/qwt_wheel.h
===================================================================
--- trunk/BNC/qwt/qwt_wheel.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_wheel.h	(revision 8127)
@@ -0,0 +1,178 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_WHEEL_H
+#define QWT_WHEEL_H
+
+#include "qwt_global.h"
+#include <qwidget.h>
+
+/*!
+  \brief The Wheel Widget
+
+  The wheel widget can be used to change values over a very large range
+  in very small steps. Using the setMass() member, it can be configured
+  as a flying wheel.
+
+  The default range of the wheel is [0.0, 100.0]
+
+  \sa The radio example.
+*/
+class QWT_EXPORT QwtWheel: public QWidget
+{
+    Q_OBJECT
+
+    Q_PROPERTY( Qt::Orientation orientation
+                READ orientation WRITE setOrientation )
+
+    Q_PROPERTY( double value READ value WRITE setValue )
+    Q_PROPERTY( double minimum READ minimum WRITE setMinimum )
+    Q_PROPERTY( double maximum READ maximum WRITE setMaximum )
+
+    Q_PROPERTY( double singleStep READ singleStep WRITE setSingleStep )
+    Q_PROPERTY( int pageStepCount READ pageStepCount WRITE setPageStepCount )
+    Q_PROPERTY( bool stepAlignment READ stepAlignment WRITE setStepAlignment )
+
+    Q_PROPERTY( bool tracking READ isTracking WRITE setTracking )
+    Q_PROPERTY( bool wrapping READ wrapping WRITE setWrapping )
+    Q_PROPERTY( bool inverted READ isInverted WRITE setInverted )
+
+    Q_PROPERTY( double mass READ mass WRITE setMass )
+    Q_PROPERTY( int updateInterval READ updateInterval WRITE setUpdateInterval )
+
+    Q_PROPERTY( double totalAngle READ totalAngle WRITE setTotalAngle )
+    Q_PROPERTY( double viewAngle READ viewAngle WRITE setViewAngle )
+    Q_PROPERTY( int tickCount READ tickCount WRITE setTickCount )
+    Q_PROPERTY( int wheelWidth READ wheelWidth WRITE setWheelWidth )
+    Q_PROPERTY( int borderWidth READ borderWidth WRITE setBorderWidth )
+    Q_PROPERTY( int wheelBorderWidth READ wheelBorderWidth WRITE setWheelBorderWidth )
+
+public:
+    explicit QwtWheel( QWidget *parent = NULL );
+    virtual ~QwtWheel();
+
+    double value() const;
+
+    void setOrientation( Qt::Orientation );
+    Qt::Orientation orientation() const;
+
+    double totalAngle() const;
+    double viewAngle() const;
+
+    void setTickCount( int );
+    int tickCount() const;
+
+    void setWheelWidth( int );
+    int wheelWidth() const;
+
+    void setWheelBorderWidth( int );
+    int wheelBorderWidth() const;
+
+    void setBorderWidth( int );
+    int borderWidth() const;
+
+    void setInverted( bool tf );
+    bool isInverted() const;
+
+    void setWrapping( bool tf );
+    bool wrapping() const;
+
+    void setSingleStep( double );
+    double singleStep() const;
+
+    void setPageStepCount( int );
+    int pageStepCount() const;
+
+    void setStepAlignment( bool on );
+    bool stepAlignment() const;
+
+    void setRange( double vmin, double vmax );
+
+    void setMinimum( double min );
+    double minimum() const;
+
+    void setMaximum( double max );
+    double maximum() const;
+
+    void setUpdateInterval( int );
+    int updateInterval() const;
+
+    void setTracking( bool enable );
+    bool isTracking() const;
+
+    double mass() const;
+
+public Q_SLOTS:
+    void setValue( double );
+    void setTotalAngle ( double );
+    void setViewAngle( double );
+    void setMass( double );
+
+Q_SIGNALS:
+
+    /*!
+      \brief Notify a change of value.
+
+      When tracking is enabled this signal will be emitted every
+      time the value changes. 
+
+      \param value new value
+      \sa setTracking()
+    */
+    void valueChanged( double value );
+
+    /*!
+      This signal is emitted when the user presses the
+      the wheel with the mouse
+    */
+    void wheelPressed();
+
+    /*!
+      This signal is emitted when the user releases the mouse
+    */
+    void wheelReleased();
+
+    /*!
+      This signal is emitted when the user moves the
+      wheel with the mouse.
+
+      \param value new value
+    */
+    void wheelMoved( double value );
+
+protected:
+    virtual void paintEvent( QPaintEvent * );
+    virtual void mousePressEvent( QMouseEvent * );
+    virtual void mouseReleaseEvent( QMouseEvent * );
+    virtual void mouseMoveEvent( QMouseEvent * );
+    virtual void keyPressEvent( QKeyEvent * );
+    virtual void wheelEvent( QWheelEvent * );
+    virtual void timerEvent( QTimerEvent * );
+
+    void stopFlying();
+
+    QRect wheelRect() const;
+
+    virtual QSize sizeHint() const;
+    virtual QSize minimumSizeHint() const;
+
+    virtual void drawTicks( QPainter *, const QRectF & );
+    virtual void drawWheelBackground( QPainter *, const QRectF & );
+
+    virtual double valueAt( const QPoint & ) const;
+
+private:
+    double alignedValue( double ) const;
+    double boundedValue( double ) const;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/qwt_widget_overlay.cpp
===================================================================
--- trunk/BNC/qwt/qwt_widget_overlay.cpp	(revision 8127)
+++ trunk/BNC/qwt/qwt_widget_overlay.cpp	(revision 8127)
@@ -0,0 +1,376 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#include "qwt_widget_overlay.h"
+#include "qwt_painter.h"
+#include <qpainter.h>
+#include <qpaintengine.h>
+#include <qimage.h>
+#include <qevent.h>
+
+static QImage::Format qwtMaskImageFormat()
+{
+    if ( QwtPainter::isX11GraphicsSystem() )
+        return QImage::Format_ARGB32;
+
+    return QImage::Format_ARGB32_Premultiplied;
+}
+
+static QRegion qwtAlphaMask( 
+    const QImage& image, const QVector<QRect> rects )
+{
+    const int w = image.width();
+    const int h = image.height();
+
+    QRegion region;
+    QRect rect;
+
+    for ( int i = 0; i < rects.size(); i++ )
+    {
+        int x1, x2, y1, y2;
+        rects[i].getCoords( &x1, &y1, &x2, &y2 );
+
+        x1 = qMax( x1, 0 );
+        x2 = qMin( x2, w - 1 );
+        y1 = qMax( y1, 0 );
+        y2 = qMin( y2, h - 1 );
+
+        for ( int y = y1; y <= y2; ++y ) 
+        {
+            bool inRect = false;
+            int rx0 = -1;
+
+            const uint *line = 
+                reinterpret_cast<const uint *> ( image.scanLine( y ) ) + x1;
+            for ( int x = x1; x <= x2; x++ ) 
+            {
+                const bool on = ( ( *line++ >> 24 ) != 0 );
+                if ( on != inRect ) 
+                {
+                    if ( inRect  ) 
+                    {
+                        rect.setCoords( rx0, y, x - 1, y );
+                        region += rect;
+                    } 
+                    else 
+                    {
+                        rx0 = x;
+                    }
+
+                    inRect = on;
+                } 
+            }
+
+            if ( inRect ) 
+            {
+                rect.setCoords( rx0, y, x2, y );
+                region = region.united( rect );
+            }
+        }
+    }
+
+    return region;
+}
+
+class QwtWidgetOverlay::PrivateData
+{
+public:
+    PrivateData():
+        maskMode( QwtWidgetOverlay::MaskHint ),
+        renderMode( QwtWidgetOverlay::AutoRenderMode ),
+        rgbaBuffer( NULL )
+    {
+    }
+
+    ~PrivateData()
+    {
+        resetRgbaBuffer();
+    }
+
+    void resetRgbaBuffer()
+    {
+        if ( rgbaBuffer )
+        {
+            ::free( rgbaBuffer );
+            rgbaBuffer = NULL;
+        }
+    }
+
+    MaskMode maskMode;
+    RenderMode renderMode;
+    uchar *rgbaBuffer;
+};
+
+/*!
+   \brief Constructor
+   \param widget Parent widget, where the overlay is aligned to
+*/
+QwtWidgetOverlay::QwtWidgetOverlay( QWidget* widget ):
+    QWidget( widget )
+{
+    d_data = new PrivateData;
+
+    setAttribute( Qt::WA_TransparentForMouseEvents );
+    setAttribute( Qt::WA_NoSystemBackground );
+    setFocusPolicy( Qt::NoFocus );
+
+    if ( widget )
+    {
+        resize( widget->size() );
+        widget->installEventFilter( this );
+    }
+}
+
+//! Destructor
+QwtWidgetOverlay::~QwtWidgetOverlay()
+{
+    delete d_data;
+}
+
+/*!
+   \brief Specify how to find the mask for the overlay
+
+   \param mode New mode
+   \sa maskMode()
+ */
+void QwtWidgetOverlay::setMaskMode( MaskMode mode )
+{
+    if ( mode != d_data->maskMode )
+    {
+        d_data->maskMode = mode;
+        d_data->resetRgbaBuffer();
+    }
+}
+
+/*!
+   \return Mode how to find the mask for the overlay
+   \sa setMaskMode()
+ */
+QwtWidgetOverlay::MaskMode QwtWidgetOverlay::maskMode() const
+{
+    return d_data->maskMode;
+}
+
+/*!
+   Set the render mode
+   \param mode Render mode
+
+   \sa RenderMode, renderMode()
+*/
+void QwtWidgetOverlay::setRenderMode( RenderMode mode )
+{
+    d_data->renderMode = mode;
+}
+
+/*!
+   \return Render mode
+   \sa RenderMode, setRenderMode()
+ */
+QwtWidgetOverlay::RenderMode QwtWidgetOverlay::renderMode() const
+{
+    return d_data->renderMode;
+}
+
+/*!
+   Recalculate the mask and repaint the overlay
+ */
+void QwtWidgetOverlay::updateOverlay()
+{
+    updateMask();
+    update();
+}
+
+void QwtWidgetOverlay::updateMask()
+{
+    d_data->resetRgbaBuffer();
+
+    QRegion mask;
+
+    if ( d_data->maskMode == QwtWidgetOverlay::MaskHint )
+    {
+        mask = maskHint();
+    }
+    else if ( d_data->maskMode == QwtWidgetOverlay::AlphaMask )
+    {
+        // TODO: the image doesn't need to be larger than
+        //       the bounding rectangle of the hint !!
+
+        QRegion hint = maskHint();
+        if ( hint.isEmpty() )
+            hint += QRect( 0, 0, width(), height() );
+
+        // A fresh buffer from calloc() is usually faster
+        // than reinitializing an existing one with
+        // QImage::fill( 0 ) or memset()
+
+        d_data->rgbaBuffer = ( uchar* )::calloc( width() * height(), 4 );
+
+        QImage image( d_data->rgbaBuffer, 
+            width(), height(), qwtMaskImageFormat() );
+
+        QPainter painter( &image );
+        draw( &painter );
+        painter.end();
+
+        mask = qwtAlphaMask( image, hint.rects() );
+
+        if ( d_data->renderMode == QwtWidgetOverlay::DrawOverlay )
+        {
+            // we don't need the buffer later
+            d_data->resetRgbaBuffer();
+        }
+    }
+
+    // A bug in Qt initiates a full repaint of the widget
+    // when we change the mask, while we are visible !
+
+    setVisible( false );
+
+    if ( mask.isEmpty() )
+        clearMask();
+    else
+        setMask( mask );
+
+    setVisible( true );
+}
+
+/*!
+  Paint event
+  \param event Paint event
+
+  \sa drawOverlay()
+*/
+void QwtWidgetOverlay::paintEvent( QPaintEvent* event )
+{
+    const QRegion clipRegion = event->region();
+
+    QPainter painter( this );
+
+    bool useRgbaBuffer = false;
+    if ( d_data->renderMode == QwtWidgetOverlay::CopyAlphaMask )
+    {
+        useRgbaBuffer = true;
+    }
+    else if ( d_data->renderMode == QwtWidgetOverlay::AutoRenderMode )
+    {
+        if ( painter.paintEngine()->type() == QPaintEngine::Raster )
+            useRgbaBuffer = true;
+    }
+
+    if ( d_data->rgbaBuffer && useRgbaBuffer )
+    {
+        const QImage image( d_data->rgbaBuffer, 
+            width(), height(), qwtMaskImageFormat() );
+
+        QVector<QRect> rects;
+        if ( clipRegion.rects().size() > 2000 )
+        {
+            // the region is to complex
+            painter.setClipRegion( clipRegion );
+            rects += clipRegion.boundingRect();
+        }
+        else
+        {
+            rects = clipRegion.rects();
+        }
+
+        for ( int i = 0; i < rects.size(); i++ )
+        {
+            const QRect r = rects[i];
+            painter.drawImage( r.topLeft(), image, r );
+        }
+    }
+    else
+    {
+        painter.setClipRegion( clipRegion );
+        draw( &painter );
+    }
+}
+
+/*!
+  Resize event
+  \param event Resize event
+*/
+void QwtWidgetOverlay::resizeEvent( QResizeEvent* event )
+{
+    Q_UNUSED( event );
+
+    d_data->resetRgbaBuffer();
+}
+
+void QwtWidgetOverlay::draw( QPainter *painter ) const
+{
+    QWidget *widget = const_cast< QWidget *>( parentWidget() );
+    if ( widget )
+    {
+        painter->setClipRect( parentWidget()->contentsRect() );
+
+        // something special for the plot canvas
+
+        const int idx = widget->metaObject()->indexOfMethod( "borderPath(QRect)" );
+        if ( idx >= 0 )
+        {
+            QPainterPath clipPath;
+
+            ( void )QMetaObject::invokeMethod(
+                widget, "borderPath", Qt::DirectConnection,
+                Q_RETURN_ARG( QPainterPath, clipPath ), Q_ARG( QRect, rect() ) );
+
+            if (!clipPath.isEmpty())
+                painter->setClipPath( clipPath, Qt::IntersectClip );
+        }
+    }
+
+    drawOverlay( painter );
+}
+
+/*!
+   \brief Calculate an approximation for the mask
+
+   - MaskHint
+     The hint is used as mask.
+
+   - AlphaMask
+     The hint is used to speed up the algorithm
+     for calculating a mask from non transparent pixels
+
+   - NoMask
+     The hint is unused.
+
+   The default implementation returns an invalid region
+   indicating no hint.
+
+   \return Hint for the mask
+ */
+QRegion QwtWidgetOverlay::maskHint() const
+{
+    return QRegion();
+}
+
+/*!
+  \brief Event filter
+
+  Resize the overlay according to the size of the parent widget.
+
+  \param object Object to be filtered
+  \param event Event
+
+  \return See QObject::eventFilter()
+*/
+
+bool QwtWidgetOverlay::eventFilter( QObject* object, QEvent* event )
+{
+    if ( object == parent() && event->type() == QEvent::Resize )
+    {
+        QResizeEvent *resizeEvent = static_cast<QResizeEvent *>( event );
+        resize( resizeEvent->size() );
+    }
+
+    return QObject::eventFilter( object, event );
+}
Index: trunk/BNC/qwt/qwt_widget_overlay.h
===================================================================
--- trunk/BNC/qwt/qwt_widget_overlay.h	(revision 8127)
+++ trunk/BNC/qwt/qwt_widget_overlay.h	(revision 8127)
@@ -0,0 +1,148 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * Qwt Widget Library
+ * Copyright (C) 1997   Josef Wilgen
+ * Copyright (C) 2002   Uwe Rathmann
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the Qwt License, Version 1.0
+ *****************************************************************************/
+
+#ifndef QWT_WIDGET_OVERLAY_H
+#define QWT_WIDGET_OVERLAY_H
+
+#include "qwt_global.h"
+#include <qwidget.h>
+#include <qregion.h>
+
+class QPainter;
+
+/*!
+   \brief An overlay for a widget
+
+   The main use case of an widget overlay is to avoid
+   heavy repaint operation of the widget below.
+
+   F.e. in combination with the plot canvas an overlay 
+   avoid replots as the content of the canvas can be restored from 
+   its backing store.
+
+   QwtWidgetOverlay is an abstract base class. Deriving classes are
+   supposed to reimplement the following methods:
+
+   - drawOverlay()
+   - maskHint()
+
+   Internally QwtPlotPicker uses overlays for displaying 
+   the rubber band and the tracker text.
+
+   \sa QwtPlotCanvas::BackingStore
+ */
+class QWT_EXPORT QwtWidgetOverlay: public QWidget
+{
+public:
+    /*!
+       \brief Mask mode
+
+       When using masks the widget below gets paint events for
+       the masked regions of the overlay only. Otherwise
+       Qt triggers full repaints. On less powerful hardware
+       ( f.e embedded systems ) - or when using the raster paint 
+       engine on a remote desktop - bit blitting is a noticeable
+       operation, that needs to be avoided.
+       
+       If and how to mask depends on how expensive the calculation 
+       of the mask is and how many pixels can be excluded by the mask.
+
+       The default setting is MaskHint.
+
+       \sa setMaskMode(), maskMode()
+     */
+    enum MaskMode
+    {
+        //! Don't use a mask.
+        NoMask,
+
+        /*!
+           \brief Use maskHint() as mask
+
+           For many situations a fast approximation is good enough 
+           and it is not necessary to build a more detailed mask
+           ( f.e the bounding rectangle of a text ).
+         */
+        MaskHint,
+
+        /*!
+           \brief Calculate a mask by checking the alpha values
+
+           Sometimes it is not possible to give a fast approximation
+           and the mask needs to be calculated by drawing the overlay
+           and testing the result.
+          
+           When a valid maskHint() is available
+           only pixels inside this approximation are checked.
+         */
+        AlphaMask
+    };
+
+    /*!
+       \brief Render mode
+
+       For calculating the alpha mask the overlay has already
+       been painted to a temporary QImage. Instead of rendering
+       the overlay twice this buffer can be copied for drawing
+       the overlay.
+
+       On graphic systems using the raster paint engine ( QWS, Windows )
+       it means usually copying some memory only. On X11 it results in an
+       expensive operation building a pixmap and for simple overlays
+       it might not be recommended.
+
+       \note The render mode has no effect, when maskMode() != AlphaMask.
+     */
+    enum RenderMode
+    {
+        //! Copy the buffer, when using the raster paint engine.
+        AutoRenderMode,
+
+        //! Always copy the buffer
+        CopyAlphaMask,
+
+        //! Never copy the buffer
+        DrawOverlay
+    };
+
+    QwtWidgetOverlay( QWidget* );
+    virtual ~QwtWidgetOverlay();
+
+    void setMaskMode( MaskMode );
+    MaskMode maskMode() const;
+
+    void setRenderMode( RenderMode );
+    RenderMode renderMode() const;
+
+    void updateOverlay();
+
+    virtual bool eventFilter( QObject *, QEvent *);
+
+protected:
+    virtual void paintEvent( QPaintEvent* event );
+    virtual void resizeEvent( QResizeEvent* event );
+
+    virtual QRegion maskHint() const;
+
+    /*!
+       Draw the widget overlay
+       \param painter Painter
+     */
+    virtual void drawOverlay( QPainter *painter ) const = 0;
+
+private:
+    void updateMask();
+    void draw( QPainter * ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: trunk/BNC/qwt/src.pri
===================================================================
--- trunk/BNC/qwt/src.pri	(revision 8127)
+++ trunk/BNC/qwt/src.pri	(revision 8127)
@@ -0,0 +1,247 @@
+################################################################
+# Qwt Widget Library
+# Copyright (C) 1997   Josef Wilgen
+# Copyright (C) 2002   Uwe Rathmann
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the Qwt License, Version 1.0
+################################################################
+
+
+HEADERS += \
+    qwt.h \
+    qwt_abstract_scale_draw.h \
+    qwt_clipper.h \
+    qwt_color_map.h \
+    qwt_compat.h \
+    qwt_column_symbol.h \
+    qwt_date.h \
+    qwt_date_scale_draw.h \
+    qwt_date_scale_engine.h \
+    qwt_dyngrid_layout.h \
+    qwt_global.h \
+    qwt_graphic.h \
+    qwt_interval.h \
+    qwt_interval_symbol.h \
+    qwt_math.h \
+    qwt_magnifier.h \
+    qwt_null_paintdevice.h \
+    qwt_painter.h \
+    qwt_painter_command.h \
+    qwt_panner.h \
+    qwt_picker.h \
+    qwt_picker_machine.h \
+    qwt_pixel_matrix.h \
+    qwt_point_3d.h \
+    qwt_point_polar.h \
+    qwt_round_scale_draw.h \
+    qwt_scale_div.h \
+    qwt_scale_draw.h \
+    qwt_scale_engine.h \
+    qwt_scale_map.h \
+    qwt_spline.h \
+    qwt_symbol.h \
+    qwt_system_clock.h \
+    qwt_text_engine.h \
+    qwt_text_label.h \
+    qwt_text.h \
+    qwt_transform.h \
+    qwt_widget_overlay.h
+
+SOURCES += \
+    qwt_abstract_scale_draw.cpp \
+    qwt_clipper.cpp \
+    qwt_color_map.cpp \
+    qwt_column_symbol.cpp \
+    qwt_date.cpp \
+    qwt_date_scale_draw.cpp \
+    qwt_date_scale_engine.cpp \
+    qwt_dyngrid_layout.cpp \
+    qwt_event_pattern.cpp \
+    qwt_graphic.cpp \
+    qwt_interval.cpp \
+    qwt_interval_symbol.cpp \
+    qwt_math.cpp \
+    qwt_magnifier.cpp \
+    qwt_null_paintdevice.cpp \
+    qwt_painter.cpp \
+    qwt_painter_command.cpp \
+    qwt_panner.cpp \
+    qwt_picker.cpp \
+    qwt_picker_machine.cpp \
+    qwt_pixel_matrix.cpp \
+    qwt_point_3d.cpp \
+    qwt_point_polar.cpp \
+    qwt_round_scale_draw.cpp \
+    qwt_scale_div.cpp \
+    qwt_scale_draw.cpp \
+    qwt_scale_map.cpp \
+    qwt_spline.cpp \
+    qwt_scale_engine.cpp \
+    qwt_symbol.cpp \
+    qwt_system_clock.cpp \
+    qwt_text_engine.cpp \
+    qwt_text_label.cpp \
+    qwt_text.cpp \
+    qwt_transform.cpp \
+    qwt_widget_overlay.cpp
+
+ 
+contains(QWT_CONFIG, QwtPlot) {
+
+    HEADERS += \
+        qwt_curve_fitter.h \
+        qwt_event_pattern.h \
+        qwt_abstract_legend.h \
+        qwt_legend.h \
+        qwt_legend_data.h \
+        qwt_legend_label.h \
+        qwt_plot.h \
+        qwt_plot_renderer.h \
+        qwt_plot_curve.h \
+        qwt_plot_dict.h \
+        qwt_plot_directpainter.h \
+        qwt_plot_grid.h \
+        qwt_plot_histogram.h \
+        qwt_plot_item.h \
+        qwt_plot_abstract_barchart.h \
+        qwt_plot_barchart.h \
+        qwt_plot_multi_barchart.h \
+        qwt_plot_intervalcurve.h \
+        qwt_plot_tradingcurve.h \
+        qwt_plot_layout.h \
+        qwt_plot_marker.h \
+        qwt_plot_zoneitem.h \
+        qwt_plot_textlabel.h \
+        qwt_plot_rasteritem.h \
+        qwt_plot_spectrogram.h \
+        qwt_plot_spectrocurve.h \
+        qwt_plot_scaleitem.h \
+        qwt_plot_legenditem.h \
+        qwt_plot_seriesitem.h \
+        qwt_plot_shapeitem.h \
+        qwt_plot_canvas.h \
+        qwt_plot_panner.h \
+        qwt_plot_picker.h \
+        qwt_plot_zoomer.h \
+        qwt_plot_magnifier.h \
+        qwt_plot_rescaler.h \
+        qwt_point_mapper.h \
+        qwt_raster_data.h \
+        qwt_matrix_raster_data.h \
+        qwt_sampling_thread.h \
+        qwt_samples.h \
+        qwt_series_data.h \
+        qwt_series_store.h \
+        qwt_point_data.h \
+        qwt_scale_widget.h 
+
+    SOURCES += \
+        qwt_curve_fitter.cpp \
+        qwt_abstract_legend.cpp \
+        qwt_legend.cpp \
+        qwt_legend_data.cpp \
+        qwt_legend_label.cpp \
+        qwt_plot.cpp \
+        qwt_plot_renderer.cpp \
+        qwt_plot_xml.cpp \
+        qwt_plot_axis.cpp \
+        qwt_plot_curve.cpp \
+        qwt_plot_dict.cpp \
+        qwt_plot_directpainter.cpp \
+        qwt_plot_grid.cpp \
+        qwt_plot_histogram.cpp \
+        qwt_plot_item.cpp \
+        qwt_plot_abstract_barchart.cpp \
+        qwt_plot_barchart.cpp \
+        qwt_plot_multi_barchart.cpp \
+        qwt_plot_intervalcurve.cpp \
+        qwt_plot_zoneitem.cpp \
+        qwt_plot_tradingcurve.cpp \
+        qwt_plot_spectrogram.cpp \
+        qwt_plot_spectrocurve.cpp \
+        qwt_plot_scaleitem.cpp \
+        qwt_plot_legenditem.cpp \
+        qwt_plot_seriesitem.cpp \
+        qwt_plot_shapeitem.cpp \
+        qwt_plot_marker.cpp \
+        qwt_plot_textlabel.cpp \
+        qwt_plot_layout.cpp \
+        qwt_plot_canvas.cpp \
+        qwt_plot_panner.cpp \
+        qwt_plot_rasteritem.cpp \
+        qwt_plot_picker.cpp \
+        qwt_plot_zoomer.cpp \
+        qwt_plot_magnifier.cpp \
+        qwt_plot_rescaler.cpp \
+        qwt_point_mapper.cpp \
+        qwt_raster_data.cpp \
+        qwt_matrix_raster_data.cpp \
+        qwt_sampling_thread.cpp \
+        qwt_series_data.cpp \
+        qwt_point_data.cpp \
+        qwt_scale_widget.cpp 
+}
+
+greaterThan(QT_MAJOR_VERSION, 4) {
+
+    QT += printsupport
+    QT += concurrent
+} 
+
+contains(QWT_CONFIG, QwtSvg) {
+
+    QT += svg
+
+    HEADERS += qwt_plot_svgitem.h
+    SOURCES += qwt_plot_svgitem.cpp 
+}
+else {
+
+    DEFINES += QWT_NO_SVG
+}
+
+contains(QWT_CONFIG, QwtOpenGL) {
+
+    QT += opengl
+
+    HEADERS += qwt_plot_glcanvas.h
+    SOURCES += qwt_plot_glcanvas.cpp
+}
+else {
+
+    DEFINES += QWT_NO_OPENGL
+}
+
+contains(QWT_CONFIG, QwtWidgets) {
+
+    HEADERS += \
+        qwt_abstract_slider.h \
+        qwt_abstract_scale.h \
+        qwt_arrow_button.h \
+        qwt_analog_clock.h \
+        qwt_compass.h \
+        qwt_compass_rose.h \
+        qwt_counter.h \
+        qwt_dial.h \
+        qwt_dial_needle.h \
+        qwt_knob.h \
+        qwt_slider.h \
+        qwt_thermo.h \
+        qwt_wheel.h
+    
+    SOURCES += \
+        qwt_abstract_slider.cpp \
+        qwt_abstract_scale.cpp \
+        qwt_arrow_button.cpp \
+        qwt_analog_clock.cpp \
+        qwt_compass.cpp \
+        qwt_compass_rose.cpp \
+        qwt_counter.cpp \
+        qwt_dial.cpp \
+        qwt_dial_needle.cpp \
+        qwt_knob.cpp \
+        qwt_slider.cpp \
+        qwt_thermo.cpp \
+        qwt_wheel.cpp
+}
Index: trunk/BNC/qwtpolar/qwt_polar_canvas.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_canvas.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_canvas.cpp	(revision 8127)
@@ -9,4 +9,5 @@
 #include "qwt_polar_canvas.h"
 #include "qwt_polar_plot.h"
+#include <qwt_painter.h>
 #include <qpainter.h>
 #include <qevent.h>
@@ -213,5 +214,8 @@
                 {
                     QWidget *bgWidget = qwtBackgroundWidget( plot() );
-                    bs.fill( bgWidget, mapTo( bgWidget, rect().topLeft() ) );
+
+					QwtPainter::fillPixmap( bgWidget, bs,
+						mapTo( bgWidget, rect().topLeft() ) );
+
                     p.begin( &bs );
                 }
Index: trunk/BNC/qwtpolar/qwt_polar_curve.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_curve.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_curve.cpp	(revision 8127)
@@ -14,5 +14,4 @@
 #include <qwt_symbol.h>
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
 #include <qwt_curve_fitter.h>
 #include <qwt_clipper.h>
@@ -174,5 +173,5 @@
   \sa symbol()
 */
-void QwtPolarCurve::setSymbol( const QwtSymbol *symbol )
+void QwtPolarCurve::setSymbol( QwtSymbol *symbol )
 {
     if ( symbol != d_data->symbol )
@@ -434,5 +433,5 @@
     if ( !clipRect.isEmpty() )
     {
-        double off = qCeil( qMax(qreal(1.0), painter->pen().widthF() ) );
+        double off = qCeil( qMax( qreal( 1.0 ), painter->pen().widthF() ) );
         clipRect = clipRect.toRect().adjusted( -off, -off, off, off );
         polyline = QwtClipper::clipPolygonF( clipRect, polyline );
@@ -501,70 +500,37 @@
 }
 
-//!  Update the widget that represents the curve on the legend
-void QwtPolarCurve::updateLegend( QwtLegend *legend ) const
-{
-    if ( legend && testItemAttribute( QwtPolarCurve::Legend )
-            && ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
-            && d_data->symbol
-            && d_data->symbol->style() != QwtSymbol::NoSymbol )
-    {
-        QWidget *lgdItem = legend->find( this );
-        if ( lgdItem == NULL )
-        {
-            lgdItem = legendItem();
-            if ( lgdItem )
-                legend->insert( this, lgdItem );
-        }
-
-        QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
-        if ( l )
-        {
-            QSize sz = d_data->symbol->boundingSize();
-            sz += QSize( 2, 2 ); // margin
-
-            if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
-            {
-                // Avoid, that the line is completely covered by the symbol
-
-                int w = qCeil( 1.5 * sz.width() );
-                if ( w % 2 )
-                    w++;
-
-                sz.setWidth( qMax( 8, w ) );
-            }
-
-            l->setIdentifierSize( sz );
-        }
-    }
-
-    QwtPolarItem::updateLegend( legend );
-}
-
-/*!
-  \brief Draw the identifier representing the curve on the legend
-
-  \param painter Qt Painter
-  \param rect Bounding rectangle for the identifier
-
-  \sa setLegendAttribute
-*/
-void QwtPolarCurve::drawLegendIdentifier(
-    QPainter *painter, const QRectF &rect ) const
-{
-    if ( rect.isEmpty() )
-        return;
-
-    const double dim = qMin( rect.width(), rect.height() );
-
-    QSizeF size( dim, dim );
-
-    QRectF r( 0, 0, size.width(), size.height() );
-    r.moveCenter( rect.center() );
+/*!
+   \return Icon representing the curve on the legend
+
+   \param index Index of the legend entry 
+                ( ignored as there is only one )
+   \param size Icon size
+
+   \sa QwtPolarItem::setLegendIconSize(), QwtPolarItem::legendData()
+ */
+QwtGraphic QwtPolarCurve::legendIcon( int index,
+    const QSizeF &size ) const
+{
+    Q_UNUSED( index );
+
+    if ( size.isEmpty() )
+        return QwtGraphic();
+
+    QwtGraphic graphic;
+    graphic.setDefaultSize( size );
+    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
+
+    QPainter painter( &graphic );
+    painter.setRenderHint( QPainter::Antialiasing,
+        testRenderHint( QwtPolarItem::RenderAntialiased ) );
 
     if ( d_data->legendAttributes == 0 )
     {
         QBrush brush;
+
         if ( style() != QwtPolarCurve::NoCurve )
+        {
             brush = QBrush( pen().color() );
+        }
         else if ( d_data->symbol &&
             ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
@@ -572,43 +538,36 @@
             brush = QBrush( d_data->symbol->pen().color() );
         }
+
         if ( brush.style() != Qt::NoBrush )
-            painter->fillRect( r, brush );
-    }
+        {
+            QRectF r( 0, 0, size.width(), size.height() );
+            painter.fillRect( r, brush );
+        }
+    }
+
     if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
     {
         if ( pen() != Qt::NoPen )
         {
-            painter->setPen( pen() );
-            QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
-                rect.right() - 1.0, rect.center().y() );
-        }
-    }
+            QPen pn = pen();
+            pn.setCapStyle( Qt::FlatCap );
+
+            painter.setPen( pn );
+
+            const double y = 0.5 * size.height();
+            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
+        }
+    }
+
     if ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
     {
-        if ( d_data->symbol &&
-            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
-        {
-            QSize symbolSize = d_data->symbol->boundingSize();
-            symbolSize -= QSize( 2, 2 );
-
-            // scale the symbol size down if it doesn't fit into rect.
-
-            double xRatio = 1.0;
-            if ( rect.width() < symbolSize.width() )
-                xRatio = rect.width() / symbolSize.width();
-            double yRatio = 1.0;
-            if ( rect.height() < symbolSize.height() )
-                yRatio = rect.height() / symbolSize.height();
-
-            const double ratio = qMin( xRatio, yRatio );
-
-            painter->save();
-            painter->scale( ratio, ratio );
-
-            d_data->symbol->drawSymbol( painter, rect.center() / ratio );
-
-            painter->restore();
-        }
-    }
+        if ( d_data->symbol )
+        {
+            QRectF r( 0, 0, size.width(), size.height() );
+            d_data->symbol->drawSymbol( &painter, r );
+        }
+    }
+
+    return graphic;
 }
 
@@ -634,2 +593,4 @@
     return QwtInterval();
 }
+
+
Index: trunk/BNC/qwtpolar/qwt_polar_curve.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_curve.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_curve.h	(revision 8127)
@@ -58,6 +58,5 @@
         In the default setting all attributes are off.
 
-        \sa setLegendAttribute(), testLegendAttribute(),
-            drawLegendIdentifier()
+        \sa setLegendAttribute(), testLegendAttribute()
      */
 
@@ -101,5 +100,5 @@
     CurveStyle style() const;
 
-    void setSymbol( const QwtSymbol * );
+    void setSymbol( QwtSymbol * );
     const QwtSymbol *symbol() const;
 
@@ -116,8 +115,7 @@
         const QPointF &pole, int from, int to ) const;
 
-    virtual void updateLegend( QwtLegend * ) const;
     virtual QwtInterval boundingInterval( int scaleId ) const;
 
-    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
+    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
 
 protected:
Index: trunk/BNC/qwtpolar/qwt_polar_global.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_global.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_global.h	(revision 8127)
@@ -14,8 +14,6 @@
 // QWT_POLAR_VERSION is (major << 16) + (minor << 8) + patch.
 
-#define QWT_POLAR_VERSION       0x010000
-#define QWT_POLAR_VERSION_STR   "1.0.0"
-
-#if defined(Q_WS_WIN) || defined(Q_WS_S60)
+#define QWT_POLAR_VERSION       0x010101
+#define QWT_POLAR_VERSION_STR   "1.1.1"
 
 #if defined(_MSC_VER) /* MSVC Compiler */
@@ -26,14 +24,12 @@
 #ifdef QWT_POLAR_DLL
 
-#if defined(QWT_POLAR_MAKEDLL)     // create a Qwt DLL library 
-#define QWT_POLAR_EXPORT  __declspec(dllexport)
+#if defined(QWT_POLAR_MAKEDLL)     // create DLL library 
+#define QWT_POLAR_EXPORT  Q_DECL_EXPORT
 #define QWT_POLAR_TEMPLATEDLL
-#else                        // use a Qwt DLL library
-#define QWT_POLAR_EXPORT  __declspec(dllimport)
+#else                        // use DLL library
+#define QWT_POLAR_EXPORT  Q_DECL_IMPORT
 #endif
 
-#endif // QWT_POLAR_MAKEDLL
-
-#endif // Q_WS_WIN
+#endif // QWT_POLAR_DLL
 
 #ifndef QWT_POLAR_EXPORT
Index: trunk/BNC/qwtpolar/qwt_polar_grid.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_grid.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_grid.cpp	(revision 8127)
@@ -877,5 +877,10 @@
 
             scaleDraw->setAngleRange( from, from - 360.0 );
-            scaleDraw->setTransformation( azimuthMap.transformation()->copy() );
+
+            const QwtTransform *transform = azimuthMap.transformation();
+            if ( transform )
+                scaleDraw->setTransformation( transform->copy() );
+            else
+                scaleDraw->setTransformation( NULL );
         }
         else
@@ -911,5 +916,9 @@
                 }
             }
-            scaleDraw->setTransformation( radialMap.transformation()->copy() );
+            const QwtTransform *transform = radialMap.transformation();
+            if ( transform )
+                scaleDraw->setTransformation( transform->copy() );
+            else
+                scaleDraw->setTransformation( NULL );
         }
     }
@@ -976,6 +985,5 @@
                 QwtScaleDiv sd = radialGrid.scaleDiv;
 
-                QList<double> &ticks =
-                    const_cast<QList<double> &>( sd.ticks( QwtScaleDiv::MajorTick ) );
+                QList<double> ticks = sd.ticks( QwtScaleDiv::MajorTick );
 
                 if ( testDisplayFlag( SmartOriginLabel ) )
@@ -1011,4 +1019,5 @@
                 }
 
+                sd.setTicks( QwtScaleDiv::MajorTick, ticks );
                 axis.scaleDraw->setScaleDiv( sd );
 
@@ -1049,5 +1058,5 @@
 const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
 {
-    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
+    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
         return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
 
@@ -1064,5 +1073,5 @@
 QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
 {
-    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
+    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
         return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
 
Index: trunk/BNC/qwtpolar/qwt_polar_item.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_item.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_item.cpp	(revision 8127)
@@ -10,5 +10,4 @@
 #include "qwt_polar_item.h"
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
 #include <qwt_scale_div.h>
 #include <qpainter.h>
@@ -22,5 +21,7 @@
         attributes( 0 ),
         renderHints( 0 ),
-        z( 0.0 )
+        renderThreadCount( 1 ),
+        z( 0.0 ),
+        legendIconSize( 8, 8 )
     {
     }
@@ -31,7 +32,10 @@
     QwtPolarItem::ItemAttributes attributes;
     QwtPolarItem::RenderHints renderHints;
+    uint renderThreadCount;
+
     double z;
 
     QwtText title;
+    QSize legendIconSize;
 };
 
@@ -74,26 +78,23 @@
         return;
 
-    // remove the item from the previous plot
-
     if ( d_data->plot )
-    {
-        if ( d_data->plot->legend() )
-            d_data->plot->legend()->remove( this );
-
         d_data->plot->attachItem( this, false );
 
-        if ( d_data->plot->autoReplot() )
-            d_data->plot->update();
-    }
-
     d_data->plot = plot;
 
     if ( d_data->plot )
-    {
-        // insert the item into the current plot
-
         d_data->plot->attachItem( this, true );
-        itemChanged();
-    }
+}
+
+/*!
+   \brief This method detaches a QwtPolarItem from the QwtPolarPlot it
+          has been associated with.
+
+   detach() is equivalent to calling attach( NULL )
+   \sa attach()
+*/
+void QwtPolarItem::detach() 
+{ 
+    attach( NULL ); 
 }
 
@@ -257,4 +258,58 @@
 }
 
+/*!
+   On multi core systems rendering of certain plot item 
+   ( f.e QwtPolarSpectrogram ) can be done in parallel in 
+   several threads.
+
+   The default setting is set to 1.
+
+   \param numThreads Number of threads to be used for rendering.
+                     If numThreads is set to 0, the system specific
+                     ideal thread count is used.
+
+   The default thread count is 1 ( = no additional threads )
+*/
+void QwtPolarItem::setRenderThreadCount( uint numThreads )
+{
+    d_data->renderThreadCount = numThreads;
+}
+
+/*!
+   \return Number of threads to be used for rendering.
+           If numThreads() is set to 0, the system specific
+           ideal thread count is used.
+*/
+uint QwtPolarItem::renderThreadCount() const
+{
+    return d_data->renderThreadCount;
+}
+
+/*!
+   Set the size of the legend icon
+
+   The default setting is 8x8 pixels
+
+   \param size Size
+   \sa legendIconSize(), legendIcon()
+*/
+void QwtPolarItem::setLegendIconSize( const QSize &size )
+{
+    if ( d_data->legendIconSize != size )
+    {
+        d_data->legendIconSize = size;
+        legendChanged();
+    }
+}
+
+/*!
+   \return Legend icon size
+   \sa setLegendIconSize(), legendIcon()
+*/
+QSize QwtPolarItem::legendIconSize() const
+{
+    return d_data->legendIconSize;
+}
+
 //! Show the item
 void QwtPolarItem::show()
@@ -302,10 +357,15 @@
 {
     if ( d_data->plot )
-    {
-        if ( d_data->plot->legend() )
-            updateLegend( d_data->plot->legend() );
-
         d_data->plot->autoRefresh();
-    }
+}
+
+/*!
+   Update the legend of the parent plot.
+   \sa QwtPolarPlot::updateLegend(), itemChanged()
+*/
+void QwtPolarItem::legendChanged()
+{
+    if ( testItemAttribute( QwtPolarItem::Legend ) && d_data->plot )
+        d_data->plot->updateLegend( this );
 }
 
@@ -351,92 +411,63 @@
 
 /*!
-   \brief Update the widget that represents the item on the legend
-
-   updateLegend() is called from itemChanged() to adopt the widget
-   representing the item on the legend to its new configuration.
-
-   The default implementation is made for QwtPolarCurve and updates a
-   QwtLegendItem(), but an item could be represented by any type of widget,
-   by overloading legendItem() and updateLegend().
-
-   \sa legendItem(), itemChanged(), QwtLegend()
-*/
-void QwtPolarItem::updateLegend( QwtLegend *legend ) const
-{
-    if ( legend == NULL )
-        return;
-
-    QWidget *lgdItem = legend->find( this );
-    if ( testItemAttribute( QwtPolarItem::Legend ) )
-    {
-        if ( lgdItem == NULL )
-        {
-            lgdItem = legendItem();
-            if ( lgdItem )
-                legend->insert( this, lgdItem );
-        }
-
-        QwtLegendItem* label = qobject_cast<QwtLegendItem *>( lgdItem );
-        if ( label )
-        {
-            // paint the identifier
-            const QSize sz = label->identifierSize();
-
-            QPixmap identifier( sz.width(), sz.height() );
-            identifier.fill( Qt::transparent );
-
-            QPainter painter( &identifier );
-            painter.setRenderHint( QPainter::Antialiasing,
-                testRenderHint( QwtPolarItem::RenderAntialiased ) );
-
-            drawLegendIdentifier( &painter,
-                QRect( 0, 0, sz.width(), sz.height() ) );
-
-            painter.end();
-
-            const bool doUpdate = label->updatesEnabled();
-            if ( doUpdate )
-                label->setUpdatesEnabled( false );
-
-            label->setText( title() );
-            label->setIdentifier( identifier );
-            label->setItemMode( legend->itemMode() );
-
-            if ( doUpdate )
-                label->setUpdatesEnabled( true );
-
-            label->update();
-        }
-    }
-    else
-    {
-        if ( lgdItem )
-        {
-            lgdItem->hide();
-            lgdItem->deleteLater();
-        }
-    }
-}
-/*!
-   \brief Allocate the widget that represents the item on the legend
-
-   The default implementation is made for QwtPolarCurve and returns a
-   QwtLegendItem(), but an item could be represented by any type of widget,
-   by overloading legendItem() and updateLegend().
-
-   \return QwtLegendItem()
-   \sa updateLegend() QwtLegend()
-*/
-QWidget *QwtPolarItem::legendItem() const
-{
-    QwtLegendItem *item = new QwtLegendItem;
-    if ( d_data->plot )
-    {
-        QObject::connect( item, SIGNAL( clicked() ),
-            d_data->plot, SLOT( legendItemClicked() ) );
-        QObject::connect( item, SIGNAL( checked( bool ) ),
-            d_data->plot, SLOT( legendItemChecked( bool ) ) );
-    }
-    return item;
+   \brief Return all information, that is needed to represent
+          the item on the legend
+
+   Most items are represented by one entry on the legend
+   showing an icon and a text.
+
+   QwtLegendData is basically a list of QVariants that makes it
+   possible to overload and reimplement legendData() to 
+   return almost any type of information, that is understood
+   by the receiver that acts as the legend.
+
+   The default implementation returns one entry with 
+   the title() of the item and the legendIcon().
+
+   \sa title(), legendIcon(), QwtLegend
+ */
+QList<QwtLegendData> QwtPolarItem::legendData() const
+{
+    QwtLegendData data;
+
+    QwtText label = title();
+    label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
+
+    QVariant titleValue;
+    qVariantSetValue( titleValue, label );
+    data.setValue( QwtLegendData::TitleRole, titleValue );
+
+    const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
+    if ( !graphic.isNull() )
+    {
+        QVariant iconValue;
+        qVariantSetValue( iconValue, graphic );
+        data.setValue( QwtLegendData::IconRole, iconValue );
+    }
+
+    QList<QwtLegendData> list;
+    list += data;
+
+    return list;
+}
+
+/*!
+   \return Icon representing the item on the legend
+
+   The default implementation returns an invalid icon
+
+   \param index Index of the legend entry 
+                ( usually there is only one )
+   \param size Icon size
+
+   \sa setLegendIconSize(), legendData()
+ */
+QwtGraphic QwtPolarItem::legendIcon(
+    int index, const QSizeF &size ) const
+{
+    Q_UNUSED( index )
+    Q_UNUSED( size )
+
+    return QwtGraphic();
 }
 
Index: trunk/BNC/qwtpolar/qwt_polar_item.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_item.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_item.h	(revision 8127)
@@ -12,5 +12,6 @@
 #include "qwt_polar_global.h"
 #include <qwt_text.h>
-#include <qwt_legend_itemmanager.h>
+#include <qwt_legend_data.h>
+#include <qwt_graphic.h>
 #include <qwt_interval.h>
 
@@ -34,5 +35,5 @@
   types of items.
 */
-class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
+class QWT_POLAR_EXPORT QwtPolarItem
 {
 public:
@@ -103,13 +104,5 @@
 
     void attach( QwtPolarPlot *plot );
-
-    /*!
-       \brief This method detaches a QwtPolarItem from any QwtPolarPlot it
-              has been associated with.
-
-       detach() is equivalent to calling attach( NULL )
-       \sa attach( QwtPolarPlot* plot )
-    */
-    void detach() { attach( NULL ); }
+    void detach();
 
     QwtPolarPlot *plot() const;
@@ -127,4 +120,7 @@
     bool testRenderHint( RenderHint ) const;
 
+    void setRenderThreadCount( uint numThreads );
+    uint renderThreadCount() const;
+
     double z() const;
     void setZ( double z );
@@ -136,4 +132,5 @@
 
     virtual void itemChanged();
+    virtual void legendChanged();
 
     /*!
@@ -154,11 +151,14 @@
     virtual QwtInterval boundingInterval( int scaleId ) const;
 
-    virtual QWidget *legendItem() const;
-
-    virtual void updateLegend( QwtLegend * ) const;
     virtual void updateScaleDiv( const QwtScaleDiv &,
         const QwtScaleDiv &, const QwtInterval & );
 
     virtual int marginHint() const;
+
+    void setLegendIconSize( const QSize & );
+    QSize legendIconSize() const;
+
+    virtual QList<QwtLegendData> legendData() const;
+    virtual QwtGraphic legendIcon( int index, const QSizeF  & ) const;
 
 private:
@@ -174,3 +174,5 @@
 Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
 
+Q_DECLARE_METATYPE( QwtPolarItem * )
+
 #endif
Index: trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp	(revision 8127)
@@ -110,21 +110,23 @@
 
 /*!
-   Attach/Detach a plot item
+  Insert a plot item
 
-   Attached items will be deleted in the destructor,
-   if auto deletion is enabled (default). Manually detached
-   items are not deleted.
+  \param item PlotItem
+  \sa removeItem()
+ */
+void QwtPolarItemDict::insertItem( QwtPolarItem *item )
+{
+    d_data->itemList.insertItem( item );
+}
 
-   \param item Plot item to attach/detach
-   \ on If true attach, else detach the item
+/*!
+  Remove a plot item
 
-   \sa setAutoDelete, ~QwtPolarItemDict
-*/
-void QwtPolarItemDict::attachItem( QwtPolarItem *item, bool on )
+  \param item PlotItem
+  \sa insertItem()
+ */
+void QwtPolarItemDict::removeItem( QwtPolarItem *item )
 {
-    if ( on )
-        d_data->itemList.insertItem( item );
-    else
-        d_data->itemList.removeItem( item );
+    d_data->itemList.removeItem( item );
 }
 
Index: trunk/BNC/qwtpolar/qwt_polar_itemdict.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_itemdict.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_itemdict.h	(revision 8127)
@@ -44,9 +44,9 @@
         bool autoDelete = true );
 
+protected:
+    void insertItem( QwtPolarItem * );
+    void removeItem( QwtPolarItem * );
+
 private:
-    friend class QwtPolarItem;
-
-    void attachItem( QwtPolarItem *, bool );
-
     class PrivateData;
     PrivateData *d_data;
Index: trunk/BNC/qwtpolar/qwt_polar_layout.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_layout.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_layout.cpp	(revision 8127)
@@ -23,6 +23,6 @@
     {
         int frameWidth;
-        int vScrollBarWidth;
-        int hScrollBarHeight;
+        int hScrollExtent;
+        int vScrollExtent;
         QSizeF hint;
     } legend;
@@ -49,8 +49,8 @@
     {
         legend.frameWidth = plot->legend()->frameWidth();
-        legend.vScrollBarWidth =
-            plot->legend()->verticalScrollBar()->sizeHint().width();
-        legend.hScrollBarHeight =
-            plot->legend()->horizontalScrollBar()->sizeHint().height();
+        legend.hScrollExtent =
+            plot->legend()->scrollExtent( Qt::Horizontal );
+        legend.vScrollExtent =
+            plot->legend()->scrollExtent( Qt::Vertical );
 
         const QSizeF hint = plot->legend()->sizeHint();
@@ -62,5 +62,5 @@
 
         if ( h > rect.height() )
-            w += legend.vScrollBarWidth;
+            w += legend.hScrollExtent;
 
         legend.hint = QSizeF( w, h );
@@ -279,5 +279,5 @@
         // half of the available space.
 
-        dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio) );
+        dim = qMin( double( hint.width() ), rect.width() * d_data->legendRatio );
 
         if ( !( options & IgnoreScrollbars ) )
@@ -288,5 +288,5 @@
                 // space for the vertical scrollbar.
 
-                dim += d_data->layoutData.legend.vScrollBarWidth;
+                dim += d_data->layoutData.legend.hScrollExtent;
             }
         }
@@ -294,6 +294,6 @@
     else
     {
-        dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio) );
-        dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
+        dim = qMin( double( hint.height() ), rect.height() * d_data->legendRatio );
+        dim = qMax( dim, d_data->layoutData.legend.vScrollExtent );
     }
 
Index: trunk/BNC/qwtpolar/qwt_polar_plot.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_plot.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_plot.cpp	(revision 8127)
@@ -16,5 +16,4 @@
 #include <qwt_round_scale_draw.h>
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
 #include <qwt_dyngrid_layout.h>
 #include <qpointer.h>
@@ -35,4 +34,5 @@
 public:
     ScaleData():
+        isValid( false ),
         scaleEngine( NULL )
     {
@@ -53,4 +53,6 @@
     int maxMinor;
 
+    bool isValid;
+
     QwtScaleDiv scaleDiv;
     QwtScaleEngine *scaleEngine;
@@ -70,5 +72,5 @@
     QPointer<QwtTextLabel> titleLabel;
     QPointer<QwtPolarCanvas> canvas;
-    QPointer<QwtLegend> legend;
+    QPointer<QwtAbstractLegend> legend;
     double azimuthOrigin;
 
@@ -183,8 +185,9 @@
       QwtPolarLayout::setLegendPosition()
 */
-void QwtPolarPlot::insertLegend( QwtLegend *legend,
+void QwtPolarPlot::insertLegend( QwtAbstractLegend *legend,
     QwtPolarPlot::LegendPosition pos, double ratio )
 {
     d_data->layout->setLegendPosition( pos, ratio );
+
     if ( legend != d_data->legend )
     {
@@ -196,41 +199,79 @@
         if ( d_data->legend )
         {
-            if ( pos != ExternalLegend )
+            connect( this,
+                SIGNAL( legendDataChanged(
+                    const QVariant &, const QList<QwtLegendData> & ) ),
+                d_data->legend,
+                SLOT( updateLegend(
+                    const QVariant &, const QList<QwtLegendData> & ) )
+            );
+
+            if ( d_data->legend->parent() != this )
+                d_data->legend->setParent( this );
+
+            updateLegend();
+
+            QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
+            if ( lgd )
             {
-                if ( d_data->legend->parent() != this )
-                    d_data->legend->setParent( this );
-            }
-
-            const QwtPolarItemList& itmList = itemList();
-            for ( QwtPolarItemIterator it = itmList.begin();
-                    it != itmList.end(); ++it )
-            {
-                ( *it )->updateLegend( d_data->legend );
-            }
-
-            QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
-                d_data->legend->contentsWidget()->layout() );
-
-            if ( tl )
-            {
-                switch( d_data->layout->legendPosition() )
+                switch ( d_data->layout->legendPosition() )
                 {
                     case LeftLegend:
                     case RightLegend:
-                        tl->setMaxCols( 1 ); // 1 column: align vertical
+                    {
+                        if ( lgd->maxColumns() == 0     )
+                            lgd->setMaxColumns( 1 ); // 1 column: align vertical
                         break;
-
+                    }
                     case TopLegend:
                     case BottomLegend:
-                        tl->setMaxCols( 0 ); // unlimited
+                    {
+                        lgd->setMaxColumns( 0 ); // unlimited
                         break;
-
-                    case ExternalLegend:
+                    }
+                    default:
                         break;
                 }
             }
-        }
-    }
+
+        }
+    }
+
     updateLayout();
+}
+
+/*!
+  Emit legendDataChanged() for all plot item
+
+  \sa QwtPlotItem::legendData(), legendDataChanged()
+ */
+void QwtPolarPlot::updateLegend()
+{
+    const QwtPolarItemList& itmList = itemList();
+    for ( QwtPolarItemIterator it = itmList.begin();
+        it != itmList.end(); ++it )
+    {
+        updateLegend( *it );
+    }
+}
+
+/*!
+  Emit legendDataChanged() for a plot item
+
+  \param plotItem Plot item
+  \sa QwtPlotItem::legendData(), legendDataChanged()
+ */
+void QwtPolarPlot::updateLegend( const QwtPolarItem *plotItem )
+{
+    if ( plotItem == NULL )
+        return;
+
+    QList<QwtLegendData> legendData;
+
+    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
+        legendData = plotItem->legendData();
+
+    const QVariant itemInfo = itemToInfo( const_cast< QwtPolarItem *>( plotItem) );
+    Q_EMIT legendDataChanged( itemInfo, legendData );
 }
 
@@ -239,5 +280,5 @@
   \sa insertLegend()
 */
-QwtLegend *QwtPolarPlot::legend()
+QwtAbstractLegend *QwtPolarPlot::legend()
 {
     return d_data->legend;
@@ -248,37 +289,7 @@
   \sa insertLegend()
 */
-const QwtLegend *QwtPolarPlot::legend() const
+const QwtAbstractLegend *QwtPolarPlot::legend() const
 {
     return d_data->legend;
-}
-
-/*!
-  Called internally when the legend has been clicked on.
-  Emits a legendClicked() signal.
-*/
-void QwtPolarPlot::legendItemClicked()
-{
-    if ( d_data->legend && sender()->isWidgetType() )
-    {
-        QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
-            d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
-        if ( plotItem )
-            Q_EMIT legendClicked( plotItem );
-    }
-}
-
-/*!
-  Called internally when the legend has been checked
-  Emits a legendClicked() signal.
-*/
-void QwtPolarPlot::legendItemChecked( bool on )
-{
-    if ( d_data->legend && sender()->isWidgetType() )
-    {
-        QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
-            d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
-        if ( plotItem )
-            Q_EMIT legendChecked( plotItem, on );
-    }
 }
 
@@ -389,8 +400,5 @@
         return;
 
-    if ( maxMinor < 0 )
-        maxMinor = 0;
-    if ( maxMinor > 100 )
-        maxMinor = 100;
+    maxMinor = qBound( 0, maxMinor, 100 );
 
     ScaleData &scaleData = d_data->scaleData[scaleId];
@@ -399,5 +407,5 @@
     {
         scaleData.maxMinor = maxMinor;
-        scaleData.scaleDiv.invalidate();
+        scaleData.isValid = false;
         autoRefresh();
     }
@@ -429,8 +437,5 @@
         return;
 
-    if ( maxMajor < 1 )
-        maxMajor = 1;
-    if ( maxMajor > 1000 )
-        maxMajor = 10000;
+    maxMajor = qBound( 1, maxMajor, 10000 );
 
     ScaleData &scaleData = d_data->scaleData[scaleId];
@@ -438,5 +443,5 @@
     {
         scaleData.maxMajor = maxMajor;
-        scaleData.scaleDiv.invalidate();
+        scaleData.isValid = false;
         autoRefresh();
     }
@@ -477,5 +482,5 @@
     scaleData.scaleEngine = scaleEngine;
 
-    scaleData.scaleDiv.invalidate();
+    scaleData.isValid = false;
 
     autoRefresh();
@@ -527,5 +532,5 @@
     ScaleData &scaleData = d_data->scaleData[scaleId];
 
-    scaleData.scaleDiv.invalidate();
+    scaleData.isValid = false;
 
     scaleData.minValue = min;
@@ -551,4 +556,5 @@
 
     scaleData.scaleDiv = scaleDiv;
+    scaleData.isValid = true;
     scaleData.doAutoScale = false;
 
@@ -732,5 +738,5 @@
     {
         map.setPaintInterval( d_data->azimuthOrigin,
-            d_data->azimuthOrigin + M_2PI );
+            d_data->azimuthOrigin + 2 * M_PI );
     }
     else
@@ -820,6 +826,7 @@
         scaleData.maxMajor = 8;
 
+        scaleData.isValid = false;
+
         scaleData.scaleEngine = new QwtLinearScaleEngine;
-        scaleData.scaleDiv.invalidate();
     }
     d_data->zoomFactor = 1.0;
@@ -858,14 +865,16 @@
     }
 
-    if ( d_data->legend &&
-        d_data->layout->legendPosition() != ExternalLegend )
-    {
-        if ( d_data->legend->itemCount() > 0 )
-        {
-            d_data->legend->setGeometry( d_data->layout->legendRect().toRect() );
+    if ( d_data->legend )
+    {
+        if ( d_data->legend->isEmpty() )
+        {
+            d_data->legend->hide();
+        }
+        else
+        {
+            const QRectF legendRect = d_data->layout->legendRect();
+            d_data->legend->setGeometry( legendRect.toRect() );
             d_data->legend->show();
         }
-        else
-            d_data->legend->hide();
     }
 
@@ -1054,11 +1063,12 @@
         d.scaleEngine->autoScale( d.maxMajor,
                                   minValue, maxValue, stepSize );
-        d.scaleDiv.invalidate();
-    }
-
-    if ( !d.scaleDiv.isValid() )
+        d.isValid = false;
+    }
+
+    if ( !d.isValid )
     {
         d.scaleDiv = d.scaleEngine->divideScale(
             minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
+        d.isValid = true;
     }
 
@@ -1270,2 +1280,83 @@
     return d_data->layout;
 }
+
+/*!
+  \brief Attach/Detach a plot item 
+
+  \param plotItem Plot item
+  \param on When true attach the item, otherwise detach it
+ */
+void QwtPolarPlot::attachItem( QwtPolarItem *plotItem, bool on )
+{
+    if ( on )
+        insertItem( plotItem );
+    else
+        removeItem( plotItem );
+
+    Q_EMIT itemAttached( plotItem, on );
+
+    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
+    {
+        // the item wants to be represented on the legend
+
+        if ( on )
+        {
+            updateLegend( plotItem );
+        }
+        else
+        {
+            const QVariant itemInfo = itemToInfo( plotItem );
+            Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
+        }
+    }
+
+    if ( autoReplot() )
+        update();
+}
+
+/*!
+  \brief Build an information, that can be used to identify
+         a plot item on the legend.
+
+  The default implementation simply wraps the plot item
+  into a QVariant object. When overloading itemToInfo()
+  usually infoToItem() needs to reimplemeted too.
+
+\code
+    QVariant itemInfo;
+    qVariantSetValue( itemInfo, plotItem );
+\endcode
+
+  \param plotItem Plot item
+  \sa infoToItem()
+ */
+QVariant QwtPolarPlot::itemToInfo( QwtPolarItem *plotItem ) const
+{
+    QVariant itemInfo;
+    qVariantSetValue( itemInfo, plotItem );
+
+    return itemInfo;
+}
+
+/*!
+  \brief Identify the plot item according to an item info object,
+         that has bee generated from itemToInfo().
+
+  The default implementation simply tries to unwrap a QwtPlotItem 
+  pointer:
+
+\code
+    if ( itemInfo.canConvert<QwtPlotItem *>() )
+        return qvariant_cast<QwtPlotItem *>( itemInfo );
+\endcode
+  \param itemInfo Plot item
+  \return A plot item, when successful, otherwise a NULL pointer.
+  \sa itemToInfo()
+*/
+QwtPolarItem *QwtPolarPlot::infoToItem( const QVariant &itemInfo ) const
+{
+    if ( itemInfo.canConvert<QwtPolarItem *>() )
+        return qvariant_cast<QwtPolarItem *>( itemInfo );
+
+    return NULL;
+}
Index: trunk/BNC/qwtpolar/qwt_polar_plot.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_plot.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_plot.h	(revision 8127)
@@ -24,4 +24,5 @@
 class QwtPolarCanvas;
 class QwtPolarLayout;
+class QwtAbstractLegend;
 
 /*!
@@ -141,9 +142,12 @@
     // Legend
 
-    void insertLegend( QwtLegend *,
+    void insertLegend( QwtAbstractLegend *,
         LegendPosition = RightLegend, double ratio = -1.0 );
 
-    QwtLegend *legend();
-    const QwtLegend *legend() const;
+    QwtAbstractLegend *legend();
+    const QwtAbstractLegend *legend() const;
+
+    void updateLegend();
+    void updateLegend( const QwtPolarItem * );
 
     // Layout
@@ -157,29 +161,26 @@
     int plotMarginHint() const;
 
+    virtual QVariant itemToInfo( QwtPolarItem * ) const;
+    virtual QwtPolarItem *infoToItem( const QVariant & ) const;
+
 Q_SIGNALS:
     /*!
-      A signal which is emitted when the user has clicked on
-      a legend item, which is in QwtLegend::ClickableItem mode.
-
-      \param plotItem Corresponding plot item of the
-                 selected legend item
-
-      \note clicks are disabled as default
-      \sa QwtLegend::setItemMode, QwtLegend::itemMode
-     */
-    void legendClicked( QwtPolarItem *plotItem );
-
-    /*!
-      A signal which is emitted when the user has clicked on
-      a legend item, which is in QwtLegend::CheckableItem mode
-
-      \param plotItem Corresponding plot item of the
-                 selected legend item
-      \param on True when the legen item is checked
-
-      \note clicks are disabled as default
-      \sa QwtLegend::setItemMode, QwtLegend::itemMode
-     */
-    void legendChecked( QwtPolarItem *plotItem, bool on );
+      A signal indicating, that an item has been attached/detached
+
+      \param plotItem Plot item
+      \param on Attached/Detached
+     */
+    void itemAttached( QwtPolarItem *plotItem, bool on );
+
+    /*! 
+      A signal with the attributes how to update 
+      the legend entries for a plot item.
+                
+      \param itemInfo Info about a plot, build from itemToInfo()
+    
+      \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
+     */
+    void legendDataChanged( const QVariant &itemInfo,
+        const QList<QwtLegendData> &data );
 
     /*!
@@ -194,8 +195,4 @@
     void setAzimuthOrigin( double );
 
-protected Q_SLOTS:
-    virtual void legendItemClicked();
-    virtual void legendItemChecked( bool );
-
 protected:
     virtual bool event( QEvent * );
@@ -210,4 +207,7 @@
 
 private:
+    friend class QwtPolarItem;
+    void attachItem( QwtPolarItem *, bool );
+
     void initPlot( const QwtText & );
 
Index: trunk/BNC/qwtpolar/qwt_polar_renderer.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_renderer.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_renderer.cpp	(revision 8127)
@@ -11,5 +11,4 @@
 #include "qwt_polar_layout.h"
 #include <qwt_legend.h>
-#include <qwt_legend_item.h>
 #include <qwt_dyngrid_layout.h>
 #include <qwt_text_label.h>
@@ -17,4 +16,6 @@
 #include <qpainter.h>
 #include <qprinter.h>
+#include <qprintdialog.h>
+#include <qfiledialog.h>
 #include <qimagewriter.h>
 #include <qfileinfo.h>
@@ -115,17 +116,37 @@
 
     const QString fmt = format.toLower();
-    if ( format == "pdf" || format == "ps" )
-    {
+    if ( format == "pdf" )
+    {
+#ifndef QT_NO_PRINTER
         QPrinter printer;
+        printer.setColorMode( QPrinter::Color );
         printer.setFullPage( true );
         printer.setPaperSize( sizeMM, QPrinter::Millimeter );
         printer.setDocName( title );
         printer.setOutputFileName( fileName );
-        printer.setOutputFormat( ( format == "pdf" )
-            ? QPrinter::PdfFormat : QPrinter::PostScriptFormat );
+        printer.setOutputFormat( QPrinter::PdfFormat );
         printer.setResolution( resolution );
 
         QPainter painter( &printer );
         render( plot, &painter, documentRect );
+#endif
+    }
+    else if ( format == "ps" )
+    {
+#if QT_VERSION < 0x050000
+#ifndef QT_NO_PRINTER
+        QPrinter printer;
+        printer.setColorMode( QPrinter::Color );
+        printer.setFullPage( true );
+        printer.setPaperSize( sizeMM, QPrinter::Millimeter );
+        printer.setDocName( title );
+        printer.setOutputFileName( fileName );
+        printer.setOutputFormat( QPrinter::PostScriptFormat );
+        printer.setResolution( resolution );
+
+        QPainter painter( &printer );
+        render( plot, &painter, documentRect );
+#endif
+#endif
     }
 #ifndef QWT_NO_POLAR_SVG
@@ -300,5 +321,5 @@
 
     painter->save();
-    renderLegend( painter, layout->legendRect() );
+    renderLegend( plot, painter, layout->legendRect() );
     painter->restore();
 
@@ -340,82 +361,77 @@
   Render the legend into a given rectangle.
 
+  \param plot Plot widget
   \param painter Painter
   \param rect Bounding rectangle
 */
-
-void QwtPolarRenderer::renderLegend(
+void QwtPolarRenderer::renderLegend( const QwtPolarPlot *plot,
     QPainter *painter, const QRectF &rect ) const
 {
-    QwtLegend *legend = d_data->plot->legend();
-    if ( legend == NULL || legend->isEmpty() )
-        return;
-
-    const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>(
-        legend->contentsWidget()->layout() );
-    if ( legendLayout == NULL )
-        return;
-
-    uint numCols = legendLayout->columnsForWidth( rect.width() );
-    const QList<QRect> itemRects =
-        legendLayout->layoutItems( rect.toRect(), numCols );
-
-    int index = 0;
-
-    for ( int i = 0; i < legendLayout->count(); i++ )
-    {
-        QLayoutItem *item = legendLayout->itemAt( i );
-        QWidget *w = item->widget();
-        if ( w )
+    if ( plot->legend() )
+        plot->legend()->renderLegend( painter, rect, true );
+}
+
+/*!
+   \brief Execute a file dialog and render the plot to the selected file
+
+   The document will be rendered in 85 dpi for a size 30x30 cm
+
+   \param plot Plot widget
+   \param documentName Default document name
+   \param sizeMM Size for the document in millimeters.
+   \param resolution Resolution in dots per Inch (dpi)
+
+   \sa renderDocument()
+*/
+bool QwtPolarRenderer::exportTo( QwtPolarPlot *plot, 
+    const QString &documentName, const QSizeF &sizeMM, int resolution )
+{
+    if ( plot == NULL )
+        return false;
+
+    QString fileName = documentName;
+
+    // What about translation 
+
+#ifndef QT_NO_FILEDIALOG
+    const QList<QByteArray> imageFormats =
+        QImageWriter::supportedImageFormats();
+
+    QStringList filter;
+#ifndef QT_NO_PRINTER
+    filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)";
+#endif
+#ifndef QWT_NO_SVG
+    filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)";
+#endif
+#ifndef QT_NO_PRINTER
+    filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)";
+#endif
+
+    if ( imageFormats.size() > 0 )
+    {
+        QString imageFilter( tr( "Images" ) );
+        imageFilter += " (";
+        for ( int i = 0; i < imageFormats.size(); i++ )
         {
-            painter->save();
-
-            painter->setClipRect( itemRects[index] );
-            renderLegendItem( painter, w, itemRects[index] );
-
-            index++;
-            painter->restore();
+            if ( i > 0 )
+                imageFilter += " ";
+            imageFilter += "*.";
+            imageFilter += imageFormats[i];
         }
-    }
-
-}
-
-/*!
-  Print the legend item into a given rectangle.
-
-  \param painter Painter
-  \param widget Widget representing a legend item
-  \param rect Bounding rectangle
-
-  \note When widget is not derived from QwtLegendItem renderLegendItem
-        does nothing and needs to be overloaded
-*/
-void QwtPolarRenderer::renderLegendItem( QPainter *painter,
-    const QWidget *widget, const QRectF &rect ) const
-{
-    const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
-    if ( item )
-    {
-        const QSize sz = item->identifierSize();
-
-        const QRectF identifierRect( rect.x() + item->margin(),
-            rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() );
-
-        QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item );
-        if ( itemManger )
-        {
-            painter->save();
-            painter->setClipRect( identifierRect, Qt::IntersectClip );
-            itemManger->drawLegendIdentifier( painter, identifierRect );
-            painter->restore();
-        }
-
-        // Label
-
-        QRectF titleRect = rect;
-        titleRect.setX( identifierRect.right() + 2 * item->spacing() );
-
-        painter->setFont( item->font() );
-        item->text().draw( painter, titleRect );
-    }
-}
-
+        imageFilter += ")";
+
+        filter += imageFilter;
+    }
+
+    fileName = QFileDialog::getSaveFileName(
+        NULL, tr( "Export File Name" ), fileName,
+        filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite );
+#endif
+    if ( fileName.isEmpty() )
+        return false;
+
+    renderDocument( plot, fileName, sizeMM, resolution );
+
+    return true;
+}
Index: trunk/BNC/qwtpolar/qwt_polar_renderer.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_renderer.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_renderer.h	(revision 8127)
@@ -12,7 +12,7 @@
 #include "qwt_polar_global.h"
 #include <qobject.h>
+#include <qsize.h>
 
 class QwtPolarPlot;
-class QSizeF;
 class QRectF;
 class QPainter;
@@ -52,15 +52,16 @@
 #endif
     void renderTo( QwtPolarPlot *, QPrinter & ) const;
-    void renderTo( QwtPolarPlot *, QPaintDevice &p ) const;
+    void renderTo( QwtPolarPlot *, QPaintDevice & ) const;
 
     virtual void render( QwtPolarPlot *,
         QPainter *, const QRectF &rect ) const;
 
-protected:
+    bool exportTo( QwtPolarPlot *, const QString &documentName,
+        const QSizeF &sizeMM = QSizeF( 200, 200 ), int resolution = 85 );
+
     virtual void renderTitle( QPainter *, const QRectF & ) const;
-    virtual void renderLegend( QPainter *, const QRectF & ) const;
 
-    virtual void renderLegendItem( QPainter *,
-        const QWidget *, const QRectF & ) const;
+    virtual void renderLegend(
+        const QwtPolarPlot *, QPainter *, const QRectF & ) const;
 
 private:
Index: trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp	(revision 8127)
@@ -95,6 +95,5 @@
 public:
     PrivateData():
-        data( NULL ),
-        renderThreadCount( 1 )
+        data( NULL )
     {
         colorMap = new QwtLinearColorMap();
@@ -109,6 +108,4 @@
     QwtRasterData *data;
     QwtColorMap *colorMap;
-
-    uint renderThreadCount;
 
     QwtPolarSpectrogram::PaintAttributes paintAttributes;
@@ -223,35 +220,4 @@
 {
     return ( d_data->paintAttributes & attribute );
-}
-
-/*!
-   Rendering an image from the raster data can often be done
-   parallel on a multicore system.
-
-   \param numThreads Number of threads to be used for rendering.
-                     If numThreads is set to 0, the system specific
-                     ideal thread count is used.
-
-   The default thread count is 1 ( = no additional threads )
-
-   \warning Rendering in multiple threads is only supported for Qt >= 4.4
-   \sa renderThreadCount(), renderImage(), renderTile()
-*/
-void QwtPolarSpectrogram::setRenderThreadCount( uint numThreads )
-{
-    d_data->renderThreadCount = numThreads;
-}
-
-/*!
-   \return Number of threads to be used for rendering.
-           If numThreads is set to 0, the system specific
-           ideal thread count is used.
-
-   \warning Rendering in multiple threads is only supported for Qt >= 4.4
-   \sa setRenderThreadCount(), renderImage(), renderTile()
-*/
-uint QwtPolarSpectrogram::renderThreadCount() const
-{
-    return d_data->renderThreadCount;
 }
 
@@ -357,5 +323,5 @@
 
 #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
-    uint numThreads = d_data->renderThreadCount;
+    uint numThreads = renderThreadCount();
 
     if ( numThreads <= 0 )
Index: trunk/BNC/qwtpolar/qwt_polar_spectrogram.h
===================================================================
--- trunk/BNC/qwtpolar/qwt_polar_spectrogram.h	(revision 8125)
+++ trunk/BNC/qwtpolar/qwt_polar_spectrogram.h	(revision 8127)
@@ -60,7 +60,4 @@
     bool testPaintAttribute( PaintAttribute ) const;
 
-    void setRenderThreadCount( uint numThreads );
-    uint renderThreadCount() const;
-
     virtual int rtti() const;
 
Index: trunk/BNC/qwtpolar/qwtpolar.pro
===================================================================
--- trunk/BNC/qwtpolar/qwtpolar.pro	(revision 8125)
+++ trunk/BNC/qwtpolar/qwtpolar.pro	(revision 8127)
@@ -6,4 +6,8 @@
 CONFIG += release
 DEFINES += QWT_POLAR_NO_SVG
+greaterThan(QT_MAJOR_VERSION, 4) {
+    QT += printsupport
+    QT += concurrent
+}
 
 INCLUDEPATH += ../qwt
@@ -45,3 +49,2 @@
     qwt_polar_renderer.cpp \
     qwt_polar_plot.cpp
-
Index: trunk/BNC/src/PPP_SSR_I/pppFilter.h
===================================================================
--- trunk/BNC/src/PPP_SSR_I/pppFilter.h	(revision 8125)
+++ trunk/BNC/src/PPP_SSR_I/pppFilter.h	(revision 8127)
@@ -90,5 +90,5 @@
   double       lkB;
   unsigned     obsIndex;
-  char system() const {return prn.toAscii()[0];}
+  char system() const {return prn.toLatin1()[0];}
 };
 
Index: trunk/BNC/src/bnccaster.cpp
===================================================================
--- trunk/BNC/src/bnccaster.cpp	(revision 8125)
+++ trunk/BNC/src/bnccaster.cpp	(revision 8127)
@@ -208,5 +208,5 @@
           emit( newMessage(QString("%1: Old epoch %2 thrown away")
                  .arg(staID.data()).arg(string(obs._time).c_str())
-               .toAscii(), true) );
+               .toLatin1(), true) );
         }
       }
@@ -232,5 +232,5 @@
   _sockets->push_back( _server->nextPendingConnection() );
   emit( newMessage(QString("New client connection on sync port: # %1")
-                   .arg(_sockets->size()).toAscii(), true) );
+                   .arg(_sockets->size()).toLatin1(), true) );
 }
 
@@ -238,5 +238,5 @@
   _uSockets->push_back( _uServer->nextPendingConnection() );
   emit( newMessage(QString("New client connection on usync port: # %1")
-                   .arg(_uSockets->size()).toAscii(), true) );
+                   .arg(_uSockets->size()).toLatin1(), true) );
 }
 
@@ -286,5 +286,5 @@
   _staIDs.removeAll(staID);
   emit( newMessage(
-           QString("Decoding %1 stream(s)").arg(_staIDs.size()).toAscii(), true) );
+           QString("Decoding %1 stream(s)").arg(_staIDs.size()).toLatin1(), true) );
   if (_staIDs.size() == 0) {
     emit(newMessage("bncCaster: Last get thread terminated", true));
@@ -406,9 +406,9 @@
     // ----------------
     if (!existFlg) {
-      QByteArray format    = hlp[1].toAscii();
-      QByteArray latitude  = hlp[3].toAscii();
-      QByteArray longitude = hlp[4].toAscii();
-      QByteArray nmea      = hlp[5].toAscii();
-      QByteArray ntripVersion = hlp[6].toAscii();
+      QByteArray format    = hlp[1].toLatin1();
+      QByteArray latitude  = hlp[3].toLatin1();
+      QByteArray longitude = hlp[4].toLatin1();
+      QByteArray nmea      = hlp[5].toLatin1();
+      QByteArray ntripVersion = hlp[6].toLatin1();
 
       bncGetThread* getThread = new bncGetThread(url, format, latitude,
@@ -450,5 +450,5 @@
                            + BNC_CORE->confFileName()
                            + ", %1 stream(s)")
-                            .arg(_threads.count()).toAscii(), true) );
+                            .arg(_threads.count()).toLatin1(), true) );
 
   // (Re-) Start the configuration timer
@@ -555,4 +555,4 @@
   _miscSockets->push_back( _miscServer->nextPendingConnection() );
   emit( newMessage(QString("New client connection on Miscellaneous Output Port: # %1")
-                   .arg(_miscSockets->size()).toAscii(), true) );
-}
+                   .arg(_miscSockets->size()).toLatin1(), true) );
+}
Index: trunk/BNC/src/bnccore.cpp
===================================================================
--- trunk/BNC/src/bnccore.cpp	(revision 8125)
+++ trunk/BNC/src/bnccore.cpp	(revision 8127)
@@ -170,5 +170,5 @@
       expandEnvVar(logFileName);
       _logFile = new QFile(logFileName + "_" +
-                          currDate.toString("yyMMdd").toAscii().data());
+                          currDate.toString("yyMMdd").toLatin1().data());
       _fileDate = currDate;
       if ( Qt::CheckState(settings.value("rnxAppend").toInt()) == Qt::Checked) {
@@ -189,5 +189,5 @@
       msgLocal = msg.mid(1);
     }
-    *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toAscii().data();
+    *_logStream << currentDateAndTimeGPS().toString("yy-MM-dd hh:mm:ss ").toLatin1().data();
     *_logStream << msgLocal.data() << endl;
     _logStream->flush();
@@ -202,9 +202,9 @@
   t_irc ircPut = _ephUser.putNewEph(eph, true);
   if      (eph->checkState() == t_eph::bad) {
-    messagePrivate("WRONG EPHEMERIS\n" + eph->toString(3.0).toAscii());
+    messagePrivate("WRONG EPHEMERIS\n" + eph->toString(3.0).toLatin1());
     return failure;
   }
   else if (eph->checkState() == t_eph::outdated) {
-    messagePrivate("OUTDATED EPHEMERIS\n" + eph->toString(3.0).toAscii());
+    messagePrivate("OUTDATED EPHEMERIS\n" + eph->toString(3.0).toLatin1());
     return failure;
   }
@@ -270,5 +270,5 @@
     comments.append("Source: " + decoder +
                     " " + url.encodedHost() +
-                    "/" + url.path().mid(1).toAscii());
+                    "/" + url.path().mid(1).toLatin1());
   }
 
@@ -388,11 +388,11 @@
         line.sprintf(
           "%9.2f%11sN: GNSS NAV DATA    M: Mixed%12sRINEX VERSION / TYPE\n",
-          t_rnxNavFile::defaultRnxNavVersion3, "", "");
+          defaultRnxNavVersion3, "", "");
         *_ephStreamGPS << line;
 
         QString hlp = currentDateAndTimeGPS().toString("yyyyMMdd hhmmss UTC").leftJustified(20, ' ', true);
-        *_ephStreamGPS << _pgmName.toAscii().data()
-                       << _userName.toAscii().data()
-                       << hlp.toAscii().data()
+        *_ephStreamGPS << _pgmName.toLatin1().data()
+                       << _userName.toLatin1().data()
+                       << hlp.toLatin1().data()
                        << "PGM / RUN BY / DATE" << endl;
 
@@ -415,11 +415,11 @@
         QString line;
         line.sprintf("%9.2f%11sN: GPS NAV DATA%25sRINEX VERSION / TYPE\n",
-                     t_rnxNavFile::defaultRnxNavVersion2, "", "");
+                     defaultRnxNavVersion2, "", "");
         *_ephStreamGPS << line;
 
         QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
-        *_ephStreamGPS << _pgmName.toAscii().data()
-                       << _userName.toAscii().data()
-                       << hlp.toAscii().data()
+        *_ephStreamGPS << _pgmName.toLatin1().data()
+                       << _userName.toLatin1().data()
+                       << hlp.toLatin1().data()
                        << "PGM / RUN BY / DATE" << endl;
 
@@ -437,11 +437,11 @@
         QString line;
         line.sprintf("%9.2f%11sG: GLONASS NAV DATA%21sRINEX VERSION / TYPE\n",
-                     t_rnxNavFile::defaultRnxNavVersion2, "", "");
+                     defaultRnxNavVersion2, "", "");
         *_ephStreamGlonass << line;
 
         QString hlp = currentDateAndTimeGPS().date().toString("dd-MMM-yyyy").leftJustified(20, ' ', true);
-        *_ephStreamGlonass << _pgmName.toAscii().data()
-                           << _userName.toAscii().data()
-                           << hlp.toAscii().data()
+        *_ephStreamGlonass << _pgmName.toLatin1().data()
+                           << _userName.toLatin1().data()
+                           << hlp.toLatin1().data()
                            << "PGM / RUN BY / DATE" << endl;
 
@@ -464,6 +464,6 @@
 void t_bncCore::printEph(const t_eph& eph, bool printFile) {
 
-  QString strV2 = eph.toString(t_rnxNavFile::defaultRnxNavVersion2);
-  QString strV3 = eph.toString(t_rnxObsHeader::defaultRnxObsVersion3);
+  QString strV2 = eph.toString(defaultRnxNavVersion2);
+  QString strV3 = eph.toString(defaultRnxObsVersion3);
 
   if     (_rinexVers == 2 && eph.type() == t_eph::GLONASS) {
@@ -487,8 +487,8 @@
   if (printFile && stream) {
     if (_rinexVers == 2) {
-      *stream << strV2.toAscii();
+      *stream << strV2.toLatin1();
     }
     else {
-      *stream << strV3.toAscii();
+      *stream << strV3.toLatin1();
     }
     stream->flush();
@@ -502,5 +502,5 @@
       QTcpSocket* sock = is.next();
       if (sock->state() == QAbstractSocket::ConnectedState) {
-        if (sock->write(strV3.toAscii()) == -1) {
+        if (sock->write(strV3.toLatin1()) == -1) {
           delete sock;
           is.remove();
Index: trunk/BNC/src/bncfigureppp.h
===================================================================
--- trunk/BNC/src/bncfigureppp.h	(revision 8125)
+++ trunk/BNC/src/bncfigureppp.h	(revision 8127)
@@ -43,5 +43,5 @@
 
  private:
-  const static double _tRange = 300;
+  enum {_tRange = 300};
 
   class pppPos {
Index: trunk/BNC/src/bncgetthread.cpp
===================================================================
--- trunk/BNC/src/bncgetthread.cpp	(revision 8125)
+++ trunk/BNC/src/bncgetthread.cpp	(revision 8127)
@@ -43,8 +43,12 @@
 #include <sstream>
 
+#include <QComboBox>
+#include <QDialog>
 #include <QFile>
 #include <QTextStream>
 #include <QMutex>
 #include <QtNetwork>
+#include <QPushButton>
+#include <QTableWidget>
 #include <QTime>
 
@@ -90,5 +94,5 @@
   _rawFile = 0;
   _mountPoint = mountPoint;
-  _staID = mountPoint.path().mid(1).toAscii();
+  _staID = mountPoint.path().mid(1).toLatin1();
   _format = format;
   _latitude = latitude;
@@ -134,5 +138,5 @@
       continue;
     }
-    QByteArray mp = hlp[0].toAscii();
+    QByteArray mp = hlp[0].toLatin1();
     if (_staID == mp) {
       nmeaPort = hlp[9].toInt();
@@ -275,5 +279,5 @@
         hlp = "0.0";
       }
-      QByteArray _serialHeightNMEA = hlp.toAscii();
+      QByteArray _serialHeightNMEA = hlp.toLatin1();
       _manualNMEAString = ggaString(_latitude, _longitude, _serialHeightNMEA,
           nmeaMode);
@@ -603,5 +607,5 @@
             QString prn(obs._prn.toString().c_str());
             emit(newMessage(
-                _staID + " (" + prn.toAscii() + ")"
+                _staID + " (" + prn.toLatin1() + ")"
                     + ": Wrong observation epoch(s)", false));
             continue;
@@ -619,5 +623,5 @@
             long oldTime = it.value();
             if (obsTime < oldTime) {
-              emit(newMessage(_staID + ": old observation " + prn.toAscii(),
+              emit(newMessage(_staID + ": old observation " + prn.toLatin1(),
                   false));
               continue;
@@ -625,5 +629,5 @@
               emit(newMessage(
                   _staID + ": observation coming more than once "
-                      + prn.toAscii(), false));
+                      + prn.toLatin1(), false));
               continue;
             }
@@ -774,5 +778,5 @@
       for (int ii = 0; ii < decoder()->_typeList.size(); ii++) {
         QString type = QString("%1 ").arg(decoder()->_typeList[ii]);
-        emit(newMessage(_staID + ": Received message type " + type.toAscii(),
+        emit(newMessage(_staID + ": Received message type " + type.toLatin1(),
             true));
       }
@@ -847,5 +851,5 @@
             str << " " << rnxTypes[iType];
           }
-          emit(newMessage(_staID + ": Observation Types: " + msg.toAscii(),
+          emit(newMessage(_staID + ": Observation Types: " + msg.toLatin1(),
               true));
         }
@@ -856,5 +860,5 @@
       for (int ii = 0; ii < decoder()->_antType.size(); ii++) {
         QString ant1 = QString("%1 ").arg(decoder()->_antType[ii]);
-        emit(newMessage(_staID + ": Antenna descriptor " + ant1.toAscii(), true));
+        emit(newMessage(_staID + ": Antenna descriptor " + ant1.toLatin1(), true));
       }
 
@@ -870,9 +874,9 @@
         QByteArray ant1, ant2, ant3;
         ant1 =
-            QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toAscii();
+            QString("%1 ").arg(decoder()->_antList[ii].xx, 0, 'f', 4).toLatin1();
         ant2 =
-            QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toAscii();
+            QString("%1 ").arg(decoder()->_antList[ii].yy, 0, 'f', 4).toLatin1();
         ant3 =
-            QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toAscii();
+            QString("%1 ").arg(decoder()->_antList[ii].zz, 0, 'f', 4).toLatin1();
         emit(newMessage(_staID + ": " + antT + " (ITRF) X " + ant1 + "m", true));
         emit(newMessage(_staID + ": " + antT + " (ITRF) Y " + ant2 + "m", true));
@@ -881,5 +885,5 @@
         if (decoder()->_antList[ii].height_f) {
           hh = decoder()->_antList[ii].height;
-          QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toAscii();
+          QByteArray ant4 = QString("%1 ").arg(hh, 0, 'f', 4).toLatin1();
           emit(newMessage(
               _staID + ": Antenna height above marker " + ant4 + "m", true));
@@ -902,5 +906,5 @@
           _gloSlots.sort();
           emit(newMessage(
-              _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toAscii(),
+              _staID + ": GLONASS Slot:Freq " + _gloSlots.join(" ").toLatin1(),
               true));
         }
@@ -983,5 +987,5 @@
   _nmeaSockets->push_back(_nmeaServer->nextPendingConnection());
   emit(newMessage(
-      QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toAscii(),
+      QString("New PPP client on port: # %1").arg(_nmeaSockets->size()).toLatin1(),
       true));
 }
Index: trunk/BNC/src/bncmap_svg.cpp
===================================================================
--- trunk/BNC/src/bncmap_svg.cpp	(revision 8125)
+++ trunk/BNC/src/bncmap_svg.cpp	(revision 8127)
@@ -247,5 +247,5 @@
     QwtPlotRenderer renderer;
     renderer.setDiscardFlag(QwtPlotRenderer::DiscardBackground, false);
-    renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
+    //renderer.setLayoutFlag(QwtPlotRenderer::KeepFrames, true);
     renderer.renderTo(_mapPlot, printer);
   }
Index: trunk/BNC/src/bncrinex.cpp
===================================================================
--- trunk/BNC/src/bncrinex.cpp	(revision 8125)
+++ trunk/BNC/src/bncrinex.cpp	(revision 8127)
@@ -124,5 +124,5 @@
       QStringList tags = line.split(";");
       if (tags.size() > 7) {
-        if (tags.at(1) == _mountPoint.path().mid(1).toAscii()) {
+        if (tags.at(1) == _mountPoint.path().mid(1).toLatin1()) {
           net = tags.at(7);
           break;
@@ -368,5 +368,5 @@
   }
 
-  _fName = path.toAscii();
+  _fName = path.toLatin1();
 }
 
Index: trunk/BNC/src/bnctabledlg.cpp
===================================================================
--- trunk/BNC/src/bnctabledlg.cpp	(revision 8125)
+++ trunk/BNC/src/bnctabledlg.cpp	(revision 8127)
@@ -40,4 +40,9 @@
 
 #include <iostream>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMessageBox>
+#include <QVBoxLayout>
 
 #include "bnctabledlg.h"
@@ -492,7 +497,7 @@
     if (url.host() == newHost) {
       _casterUserLineEdit->setText(
-                QUrl::fromPercentEncoding(url.userName().toAscii()));
+                QUrl::fromPercentEncoding(url.userName().toLatin1()));
       _casterPasswordLineEdit->setText(
-                QUrl::fromPercentEncoding(url.password().toAscii()));
+                QUrl::fromPercentEncoding(url.password().toLatin1()));
       if (url.port() > 0) {
         _casterPortLineEdit->setText(QString("%1").arg(url.port()));
Index: trunk/BNC/src/bnctabledlg.h
===================================================================
--- trunk/BNC/src/bnctabledlg.h	(revision 8125)
+++ trunk/BNC/src/bnctabledlg.h	(revision 8127)
@@ -28,4 +28,8 @@
 #include <QtCore>
 #include <QtGui>
+#include <QComboBox>
+#include <QDialog>
+#include <QPushButton>
+#include <QTableWidget>
 #include <QWhatsThis>
 
Index: trunk/BNC/src/bncwindow.cpp
===================================================================
--- trunk/BNC/src/bncwindow.cpp	(revision 8125)
+++ trunk/BNC/src/bncwindow.cpp	(revision 8127)
@@ -40,4 +40,24 @@
 
 #include <iostream>
+
+#include <QAction>
+#include <QApplication>
+#include <QCheckBox>
+#include <QComboBox>
+#include <QDialog>
+#include <QFontDialog>
+#include <QGridLayout>
+#include <QHeaderView>
+#include <QLabel>
+#include <QLineEdit>
+#include <QMenu>
+#include <QMenuBar>
+#include <QMessageBox>
+#include <QPushButton>
+#include <QRadioButton>
+#include <QSpinBox>
+#include <QTableWidgetItem>
+#include <QTextEdit>
+#include <QToolBar>
 
 #include <unistd.h>
@@ -409,5 +429,9 @@
   _mountPointsTable->horizontalHeader()->resizeSection(6,5*ww);
   _mountPointsTable->horizontalHeader()->resizeSection(7,5*ww);
+#if QT_VERSION < 0x050000
   _mountPointsTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  _mountPointsTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   _mountPointsTable->horizontalHeader()->setStretchLastSection(true);
   _mountPointsTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
@@ -439,5 +463,9 @@
   _cmbTable->horizontalHeader()->resizeSection(1,8*ww);
   _cmbTable->horizontalHeader()->resizeSection(2,8*ww);
+#if QT_VERSION < 0x050000
   _cmbTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  _cmbTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   _cmbTable->horizontalHeader()->setStretchLastSection(true);
   _cmbTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
@@ -501,5 +529,9 @@
   _uploadTable->horizontalHeader()->resizeSection(10, 4*ww);
   _uploadTable->horizontalHeader()->resizeSection(11,12*ww);
+#if QT_VERSION < 0x050000
   _uploadTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  _uploadTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   _uploadTable->horizontalHeader()->setStretchLastSection(true);
   _uploadTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
@@ -576,5 +608,9 @@
   _uploadEphTable->horizontalHeader()->resizeSection( 4,10*ww);
   _uploadEphTable->horizontalHeader()->resizeSection( 5,12*ww);
+#if QT_VERSION < 0x050000
   _uploadEphTable->horizontalHeader()->setResizeMode(QHeaderView::Interactive);
+#else
+  _uploadEphTable->horizontalHeader()->setSectionResizeMode(QHeaderView::Interactive);
+#endif
   _uploadEphTable->horizontalHeader()->setDefaultAlignment(Qt::AlignLeft);
 
@@ -2077,5 +2113,5 @@
            this, SLOT(slotMountPointsRead(QList<bncGetThread*>)));
 
-  BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION" ("BNC_OS") ==========", true);
+  BNC_CORE->slotMessage("========== Start BNC v" BNCVERSION " (" BNC_OS ") ==========", true);
 
   bncSettings settings;
@@ -2317,5 +2353,5 @@
   img->setPixmap(QPixmap(":ntrip-logo.png"));
   dlgLayout->addWidget(img, 0,0);
-  dlgLayout->addWidget(new QLabel("BKG Ntrip Client (BNC) Version "BNCVERSION), 0,1);
+  dlgLayout->addWidget(new QLabel("BKG Ntrip Client (BNC) Version " BNCVERSION), 0,1);
   dlgLayout->addWidget(tb,1,0,1,2);
   dlgLayout->addWidget(_closeButton,2,1,Qt::AlignRight);
Index: trunk/BNC/src/bncwindow.h
===================================================================
--- trunk/BNC/src/bncwindow.h	(revision 8125)
+++ trunk/BNC/src/bncwindow.h	(revision 8127)
@@ -27,4 +27,5 @@
 
 #include <QtGui>
+#include <QMainWindow>
 #include <QWhatsThis>
 
Index: trunk/BNC/src/rinex/availplot.cpp
===================================================================
--- trunk/BNC/src/rinex/availplot.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/availplot.cpp	(revision 8127)
@@ -75,5 +75,5 @@
 
   setCanvasBackground(QColor(Qt::white));
-  canvas()->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
+  ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
 
   // Axes
@@ -203,5 +203,9 @@
                                     const QVector<double>& yData) {
   QwtPlotCurve* curve = new QwtPlotCurve(name);
-  curve->setSymbol(new QwtSymbol(symbol));
+  QwtSymbol *s = new QwtSymbol(symbol.style());
+  s->setSize(symbol.size());
+  s->setBrush(symbol.brush());
+  s->setPen(symbol.pen());
+  curve->setSymbol(s);
   curve->setStyle(QwtPlotCurve::NoCurve);
   curve->setXAxis(QwtPlot::xBottom);
Index: trunk/BNC/src/rinex/dopplot.cpp
===================================================================
--- trunk/BNC/src/rinex/dopplot.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/dopplot.cpp	(revision 8127)
@@ -65,5 +65,5 @@
 
   setCanvasBackground(QColor(Qt::white));
-  canvas()->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
+  ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
 
   // Axes
Index: trunk/BNC/src/rinex/eleplot.cpp
===================================================================
--- trunk/BNC/src/rinex/eleplot.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/eleplot.cpp	(revision 8127)
@@ -65,5 +65,5 @@
 
   setCanvasBackground(QColor(Qt::white));
-  canvas()->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
+  ((QwtPlotCanvas *)canvas())->setFrameStyle(QFrame::NoFrame | QFrame::Plain);
 
   // Axes
@@ -115,5 +115,9 @@
                                     const QVector<double>& yData) {
   QwtPlotCurve* curve = new QwtPlotCurve(name);
-  curve->setSymbol(new QwtSymbol(symbol));
+  QwtSymbol *s = new QwtSymbol(symbol.style());
+  s->setSize(symbol.size());
+  s->setBrush(symbol.brush());
+  s->setPen(symbol.pen());
+  curve->setSymbol(s);
   curve->setStyle(QwtPlotCurve::NoCurve);
   curve->setXAxis(QwtPlot::xBottom);
Index: trunk/BNC/src/rinex/graphwin.cpp
===================================================================
--- trunk/BNC/src/rinex/graphwin.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/graphwin.cpp	(revision 8127)
@@ -89,6 +89,6 @@
     
      QwtLinearScaleEngine scaleEngine;
-     _colorScale->setScaleDiv(scaleEngine.transformation(),
-                              scaleEngine.divideScale(scaleInterval->minValue(),
+     _colorScale->setTransformation(scaleEngine.transformation());
+     _colorScale->setScaleDiv(scaleEngine.divideScale(scaleInterval->minValue(),
                                                       scaleInterval->maxValue(),
                                                       8, 5));
Index: trunk/BNC/src/rinex/polarplot.cpp
===================================================================
--- trunk/BNC/src/rinex/polarplot.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/polarplot.cpp	(revision 8127)
@@ -32,5 +32,6 @@
   t_colorMap colorMap;
   for (int ii = from; ii <= to; ii++) {
-    QwtSymbol ss(symbol);
+    QwtSymbol ss(symbol.style());
+    ss.setSize(symbol.size());
     const QwtPointPolar& point = sample(ii);
     const QColor color = colorMap.color(_scaleInterval, point._value);
Index: trunk/BNC/src/rinex/polarplot.h
===================================================================
--- trunk/BNC/src/rinex/polarplot.h	(revision 8125)
+++ trunk/BNC/src/rinex/polarplot.h	(revision 8127)
@@ -51,5 +51,5 @@
   virtual QwtPointPolar sample(size_t ii) const {
     const t_polarPoint* point = _data->at(ii);
-    QwtPointPolar qp(point->_az, point->_zen); qp._value = point->_value;
+    QwtPointPolar qp(point->_az, point->_zen);  qp._value = point->_value;
     return qp;
   }
Index: trunk/BNC/src/rinex/reqcedit.cpp
===================================================================
--- trunk/BNC/src/rinex/reqcedit.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/reqcedit.cpp	(revision 8127)
@@ -64,8 +64,8 @@
   int version     = settings.value("reqcRnxVersion").toInt();
   if (version < 3) {
-    _rnxVersion = t_rnxObsHeader::defaultRnxObsVersion2;
+    _rnxVersion = defaultRnxObsVersion2;
   }
   else {
-    _rnxVersion = t_rnxObsHeader::defaultRnxObsVersion3;
+    _rnxVersion = defaultRnxObsVersion3;
   }
   _samplingRate   = settings.value("reqcSampling").toInt();
@@ -578,8 +578,8 @@
 
   if ( (haveGPS && haveGlonass) || _rnxVersion >= 3.0) {
-    outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion3);
+    outNavFile.setVersion(defaultRnxNavVersion3);
   }
   else {
-    outNavFile.setVersion(t_rnxNavFile::defaultRnxNavVersion2);
+    outNavFile.setVersion(defaultRnxNavVersion2);
   }
 
Index: trunk/BNC/src/rinex/rnxnavfile.h
===================================================================
--- trunk/BNC/src/rinex/rnxnavfile.h	(revision 8125)
+++ trunk/BNC/src/rinex/rnxnavfile.h	(revision 8127)
@@ -35,11 +35,11 @@
 class t_eph;
 
+#define defaultRnxNavVersion2 2.11
+#define defaultRnxNavVersion3 3.03
+
 class t_rnxNavFile {
 
  public:
   enum e_inpOut {input, output};
-  static const double defaultRnxNavVersion2 = 2.11;
-  static const double defaultRnxNavVersion3 = 3.03;
-
  private:
   class t_rnxNavHeader {
Index: trunk/BNC/src/rinex/rnxobsfile.cpp
===================================================================
--- trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 8125)
+++ trunk/BNC/src/rinex/rnxobsfile.cpp	(revision 8127)
@@ -166,5 +166,5 @@
     else if (key == "# / TYPES OF OBSERV") {
       if (_version == 0.0) {
-        _version = t_rnxObsHeader::defaultRnxObsVersion2;
+        _version = defaultRnxObsVersion2;
       }
       QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly);
@@ -190,5 +190,5 @@
     else if (key == "SYS / # / OBS TYPES") {
       if (_version == 0.0) {
-        _version = t_rnxObsHeader::defaultRnxObsVersion3;
+        _version = defaultRnxObsVersion3;
       }
       QTextStream* in = new QTextStream(value.toAscii(), QIODevice::ReadOnly);
@@ -307,8 +307,8 @@
 
   if (version <= 2) {
-    _version = t_rnxObsHeader::defaultRnxObsVersion2;
+    _version = defaultRnxObsVersion2;
   }
   else {
-    _version = t_rnxObsHeader::defaultRnxObsVersion3;
+    _version = defaultRnxObsVersion3;
   }
 
@@ -371,8 +371,8 @@
 
   if (version <= 2) {
-    _version = t_rnxObsHeader::defaultRnxObsVersion2;
+    _version = defaultRnxObsVersion2;
   }
   else {
-    _version = t_rnxObsHeader::defaultRnxObsVersion3;
+    _version = defaultRnxObsVersion3;
   }
   _interval        = header._interval;
Index: trunk/BNC/src/rinex/rnxobsfile.h
===================================================================
--- trunk/BNC/src/rinex/rnxobsfile.h	(revision 8125)
+++ trunk/BNC/src/rinex/rnxobsfile.h	(revision 8127)
@@ -38,4 +38,7 @@
 #include "satObs.h"
 
+#define defaultRnxObsVersion2 2.11
+#define defaultRnxObsVersion3 3.03
+
 class t_rnxObsHeader {
 
@@ -43,6 +46,4 @@
 
  public:
-  static const double  defaultRnxObsVersion2 = 2.11;
-  static const double  defaultRnxObsVersion3 = 3.03;
   static const QString defaultSystems;
 
