Index: /trunk/BNC/qwtpolar/qwt_polar.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar.h	(revision 4272)
@@ -0,0 +1,84 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_H
+#define QWT_POLAR_H 1
+
+#include "qwt_polar_global.h"
+
+namespace QwtPolar
+{
+    //! Unit of an angle
+    enum AngleUnit
+    {
+        //! 0.0 -> 2_M_PI
+        Radians,
+
+        //! 0.0 -> 360.0
+        Degrees,
+
+        //! 0.0 - 400.0
+        Gradians,
+
+        //! 0.0 - 1.0
+        Turns
+    };
+
+    //! An enum, that identifies the type of a coordinate
+    enum Coordinate
+    {
+        //! Azimuth
+        Azimuth,
+
+        //! Radius
+        Radius
+    };
+
+    /*!
+      Indices used to identify an axis.
+      \sa Scale
+     */
+    enum Axis
+    {
+        //! Azimuth axis
+        AxisAzimuth,
+
+        //! Left axis
+        AxisLeft,
+
+        //! Right axis
+        AxisRight,
+
+        //! Top axis
+        AxisTop,
+
+        //! Bottom axis
+        AxisBottom,
+
+        //! Number of available axis
+        AxesCount
+    };
+
+    /*!
+      Indices used to identify a scale.
+      \sa Axis
+     */
+    enum Scale
+    {
+        //! Azimuth scale
+        ScaleAzimuth = Azimuth,
+
+        //! Radial scale
+        ScaleRadius = Radius,
+
+        //! Number of scales
+        ScaleCount
+    };
+}
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_canvas.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_canvas.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_canvas.cpp	(revision 4272)
@@ -0,0 +1,316 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_canvas.h"
+#include "qwt_polar_plot.h"
+#include <qpainter.h>
+#include <qevent.h>
+#include <qpixmap.h>
+#include <qstyle.h>
+#include <qstyleoption.h>
+#ifdef Q_WS_X11
+#include <qx11info_x11.h>
+#endif
+
+static inline void qwtDrawStyledBackground(
+    QWidget *widget, QPainter *painter )
+{
+    QStyleOption opt;
+    opt.initFrom( widget );
+    widget->style()->drawPrimitive( QStyle::PE_Widget, &opt, painter, widget );
+}
+
+static QWidget *qwtBackgroundWidget( QWidget *w )
+{
+    if ( w->parentWidget() == NULL )
+        return w;
+
+    if ( w->autoFillBackground() )
+    {
+        const QBrush brush = w->palette().brush( w->backgroundRole() );
+        if ( brush.color().alpha() > 0 )
+            return w;
+    }
+
+    if ( w->testAttribute( Qt::WA_StyledBackground ) )
+    {
+        QImage image( 1, 1, QImage::Format_ARGB32 );
+        image.fill( Qt::transparent );
+
+        QPainter painter( &image );
+        painter.translate( -w->rect().center() );
+        qwtDrawStyledBackground( w, &painter );
+        painter.end();
+
+        if ( qAlpha( image.pixel( 0, 0 ) ) != 0 )
+            return w;
+    }
+
+    return qwtBackgroundWidget( w->parentWidget() );
+}
+
+class QwtPolarCanvas::PrivateData
+{
+public:
+    PrivateData():
+        paintAttributes( 0 ),
+        backingStore( NULL )
+    {
+    }
+
+    ~PrivateData()
+    {
+        delete backingStore;
+    }
+
+    QwtPolarCanvas::PaintAttributes paintAttributes;
+    QPixmap *backingStore;
+};
+
+//! Constructor
+QwtPolarCanvas::QwtPolarCanvas( QwtPolarPlot *plot ):
+    QFrame( plot )
+{
+    d_data = new PrivateData;
+
+#ifndef QT_NO_CURSOR
+    setCursor( Qt::CrossCursor );
+#endif
+    setFocusPolicy( Qt::WheelFocus );
+
+    setPaintAttribute( BackingStore, true );
+}
+
+//! Destructor
+QwtPolarCanvas::~QwtPolarCanvas()
+{
+    delete d_data;
+}
+
+//! \return Parent plot widget
+QwtPolarPlot *QwtPolarCanvas::plot()
+{
+    return qobject_cast<QwtPolarPlot *>( parent() );
+}
+
+//! \return Parent plot widget
+const QwtPolarPlot *QwtPolarCanvas::plot() const
+{
+    return qobject_cast<QwtPolarPlot *>( parent() );
+}
+
+/*!
+  \brief Changing the paint attributes
+
+  \param attribute Paint attribute
+  \param on On/Off
+
+  The default setting enables BackingStore
+
+  \sa testPaintAttribute(), paintCache()
+*/
+void QwtPolarCanvas::setPaintAttribute( PaintAttribute attribute, bool on )
+{
+    if ( bool( d_data->paintAttributes & attribute ) == on )
+        return;
+
+    if ( on )
+        d_data->paintAttributes |= attribute;
+    else
+        d_data->paintAttributes &= ~attribute;
+
+    switch( attribute )
+    {
+        case BackingStore:
+        {
+            if ( on )
+            {
+                if ( d_data->backingStore == NULL )
+                    d_data->backingStore = new QPixmap();
+
+                if ( isVisible() )
+                {
+                    const QRect cr = contentsRect();
+                    *d_data->backingStore = QPixmap::grabWidget( this, cr );
+                }
+            }
+            else
+            {
+                delete d_data->backingStore;
+                d_data->backingStore = NULL;
+            }
+            break;
+        }
+    }
+}
+
+/*!
+  Test wether a paint attribute is enabled
+
+  \param attribute Paint attribute
+  \return true if the attribute is enabled
+  \sa setPaintAttribute()
+*/
+bool QwtPolarCanvas::testPaintAttribute( PaintAttribute attribute ) const
+{
+    return ( d_data->paintAttributes & attribute ) != 0;
+}
+
+//! \return Backing store, might be null
+const QPixmap *QwtPolarCanvas::backingStore() const
+{
+    return d_data->backingStore;
+}
+
+//! Invalidate the internal backing store
+void QwtPolarCanvas::invalidateBackingStore()
+{
+    if ( d_data->backingStore )
+        *d_data->backingStore = QPixmap();
+}
+
+/*!
+  Paint event
+  \param event Paint event
+*/
+void QwtPolarCanvas::paintEvent( QPaintEvent *event )
+{
+    QPainter painter( this );
+    painter.setClipRegion( event->region() );
+
+    if ( ( d_data->paintAttributes & BackingStore )
+        && d_data->backingStore != NULL )
+    {
+        QPixmap &bs = *d_data->backingStore;
+        if ( bs.size() != size() )
+        {
+            bs = QPixmap( size() );
+#ifdef Q_WS_X11
+            if ( bs.x11Info().screen() != x11Info().screen() )
+                bs.x11SetScreen( x11Info().screen() );
+#endif
+
+            QPainter p;
+
+            if ( testAttribute( Qt::WA_StyledBackground ) )
+            {
+                p.begin( &bs );
+                qwtDrawStyledBackground( this, &p );
+            }
+            else
+            {
+                if ( autoFillBackground() )
+                {
+                    p.begin( &bs );
+                    p.fillRect( rect(), palette().brush( backgroundRole() ) );
+                }
+                else
+                {
+                    QWidget *bgWidget = qwtBackgroundWidget( plot() );
+                    bs.fill( bgWidget, mapTo( bgWidget, rect().topLeft() ) );
+                    p.begin( &bs );
+                }
+            }
+
+            plot()->drawCanvas( &p, contentsRect() );
+
+            if ( frameWidth() > 0 )
+                drawFrame( &p );
+        }
+
+        painter.drawPixmap( 0, 0, *d_data->backingStore );
+    }
+    else
+    {
+        qwtDrawStyledBackground( this, &painter );
+
+        plot()->drawCanvas( &painter, contentsRect() );
+
+        if ( frameWidth() > 0 )
+            drawFrame( &painter );
+    }
+}
+
+/*!
+  Resize event
+  \param event Resize event
+*/
+void QwtPolarCanvas::resizeEvent( QResizeEvent *event )
+{
+    QFrame::resizeEvent( event );
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+        plot()->updateScale( scaleId );
+}
+
+/*!
+    Translate a point from widget into plot coordinates
+
+    \param pos Point in widget coordinates of the plot canvas
+    \return Point in plot coordinates
+
+    \sa transform()
+*/
+QwtPointPolar QwtPolarCanvas::invTransform( const QPoint &pos ) const
+{
+    const QwtPolarPlot *pl = plot();
+
+    const QwtScaleMap azimuthMap = pl->scaleMap( QwtPolar::Azimuth );
+    const QwtScaleMap radialMap = pl->scaleMap( QwtPolar::Radius );
+
+    const QPointF center = pl->plotRect().center();
+
+    double dx = pos.x() - center.x();
+    double dy = -( pos.y() - center.y() );
+
+    const QwtPointPolar polarPos = QwtPointPolar( QPoint( dx, dy ) ).normalized();
+
+    double azimuth = azimuthMap.invTransform( polarPos.azimuth() );
+
+    // normalize the azimuth
+    double min = azimuthMap.s1();
+    double max = azimuthMap.s2();
+    if ( max < min )
+        qSwap( min, max );
+
+    if ( azimuth < min )
+    {
+        azimuth += max - min;
+    }
+    else if ( azimuth > max )
+    {
+        azimuth -= max - min;
+    }
+
+    const double radius = radialMap.invTransform( polarPos.radius() );
+
+    return QwtPointPolar( azimuth, radius );
+}
+
+/*!
+    Translate a point from plot into widget coordinates
+
+    \param polarPos Point in plot coordinates
+    \return Point in widget coordinates
+    \sa transform()
+*/
+QPoint QwtPolarCanvas::transform( const QwtPointPolar &polarPos ) const
+{
+    const QwtPolarPlot *pl = plot();
+
+    const QwtScaleMap azimuthMap = pl->scaleMap( QwtPolar::Azimuth );
+    const QwtScaleMap radialMap = pl->scaleMap( QwtPolar::Radius );
+
+    const double radius = radialMap.transform( polarPos.radius() );
+    const double azimuth = azimuthMap.transform( polarPos.azimuth() );
+
+    const QPointF pos = qwtPolar2Pos(
+        pl->plotRect().center(), radius, azimuth );
+
+    return pos.toPoint();
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_canvas.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_canvas.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_canvas.h	(revision 4272)
@@ -0,0 +1,79 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_CANVAS_H
+#define QWT_POLAR_CANVAS_H 1
+
+#include "qwt_polar_global.h"
+#include <qwt_point_polar.h>
+#include <qframe.h>
+
+class QPainter;
+class QwtPolarPlot;
+
+/*!
+  \brief Canvas of a QwtPolarPlot.
+
+  The canvas is the widget, where all polar items are painted to.
+
+  \note In opposite to QwtPlot all axes are painted on the canvas.
+  \sa QwtPolarPlot
+*/
+class QWT_POLAR_EXPORT QwtPolarCanvas: public QFrame
+{
+    Q_OBJECT
+
+public:
+    /*!
+      \brief Paint attributes
+
+      The default setting enables BackingStore
+
+      \sa setPaintAttribute(), testPaintAttribute(), backingStore()
+     */
+
+    enum PaintAttribute
+    {
+        /*!
+          Paint double buffered and reuse the content of the pixmap buffer
+          for some spontaneous repaints that happen when a plot gets unhidden,
+          deiconified or changes the focus.
+         */
+        BackingStore = 0x01
+    };
+
+    //! Paint attributes
+    typedef QFlags<PaintAttribute> PaintAttributes;
+
+    explicit QwtPolarCanvas( QwtPolarPlot * );
+    virtual ~QwtPolarCanvas();
+
+    QwtPolarPlot *plot();
+    const QwtPolarPlot *plot() const;
+
+    void setPaintAttribute( PaintAttribute, bool on = true );
+    bool testPaintAttribute( PaintAttribute ) const;
+
+    const QPixmap *backingStore() const;
+    void invalidateBackingStore();
+
+    QwtPointPolar invTransform( const QPoint & ) const;
+    QPoint transform( const QwtPointPolar & ) const;
+
+protected:
+    virtual void paintEvent( QPaintEvent * );
+    virtual void resizeEvent( QResizeEvent * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCanvas::PaintAttributes )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_curve.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_curve.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_curve.cpp	(revision 4272)
@@ -0,0 +1,635 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_curve.h"
+#include "qwt_polar.h"
+#include <qwt_painter.h>
+#include <qwt_scale_map.h>
+#include <qwt_math.h>
+#include <qwt_symbol.h>
+#include <qwt_legend.h>
+#include <qwt_legend_item.h>
+#include <qwt_curve_fitter.h>
+#include <qwt_clipper.h>
+#include <qpainter.h>
+
+static inline bool qwtInsidePole( const QwtScaleMap &map, double radius )
+{
+    return map.isInverting() ? ( radius > map.s1() ) : ( radius < map.s1() );
+}
+
+static int qwtVerifyRange( int size, int &i1, int &i2 )
+{
+    if ( size < 1 )
+        return 0;
+
+    i1 = qBound( 0, i1, size - 1 );
+    i2 = qBound( 0, i2, size - 1 );
+
+    if ( i1 > i2 )
+        qSwap( i1, i2 );
+
+    return ( i2 - i1 + 1 );
+}
+
+class QwtPolarCurve::PrivateData
+{
+public:
+    PrivateData():
+        style( QwtPolarCurve::Lines ),
+        curveFitter( NULL ),
+        legendAttributes( 0 )
+    {
+        symbol = new QwtSymbol();
+        pen = QPen( Qt::black );
+    }
+
+    ~PrivateData()
+    {
+        delete symbol;
+        delete curveFitter;
+    }
+
+    QwtPolarCurve::CurveStyle style;
+    const QwtSymbol *symbol;
+    QPen pen;
+    QwtCurveFitter *curveFitter;
+
+    QwtPolarCurve::LegendAttributes legendAttributes;
+};
+
+//! Constructor
+QwtPolarCurve::QwtPolarCurve():
+    QwtPolarItem( QwtText() )
+{
+    init();
+}
+
+/*!
+  Constructor
+  \param title title of the curve
+*/
+QwtPolarCurve::QwtPolarCurve( const QwtText &title ):
+    QwtPolarItem( title )
+{
+    init();
+}
+
+/*!
+  Constructor
+  \param title title of the curve
+*/
+QwtPolarCurve::QwtPolarCurve( const QString &title ):
+    QwtPolarItem( QwtText( title ) )
+{
+    init();
+}
+
+//! Destructor
+QwtPolarCurve::~QwtPolarCurve()
+{
+    delete d_series;
+    delete d_data;
+}
+
+//! Initialize data members
+void QwtPolarCurve::init()
+{
+    d_data = new PrivateData;
+    d_series = NULL;
+
+    setItemAttribute( QwtPolarItem::AutoScale );
+    setItemAttribute( QwtPolarItem::Legend );
+    setZ( 20.0 );
+
+    setRenderHint( RenderAntialiased, true );
+}
+
+//! \return QwtPolarCurve::Rtti_PolarCurve
+int QwtPolarCurve::rtti() const
+{
+    return QwtPolarItem::Rtti_PolarCurve;
+}
+
+/*!
+  Specify an attribute how to draw the legend identifier
+
+  \param attribute Attribute
+  \param on On/Off
+  /sa LegendAttribute, testLegendAttribute()
+*/
+void QwtPolarCurve::setLegendAttribute( LegendAttribute attribute, bool on )
+{
+    if ( on )
+        d_data->legendAttributes |= attribute;
+    else
+        d_data->legendAttributes &= ~attribute;
+}
+
+/*!
+    \brief Test if a lefend attribute is enables
+
+    \param attribute Legend attribute
+
+    \return True if attribute is enabled
+    \sa LegendAttribute, setLegendAttribute()
+*/
+bool QwtPolarCurve::testLegendAttribute( LegendAttribute attribute ) const
+{
+    return ( d_data->legendAttributes & attribute );
+}
+
+/*!
+  Set the curve's drawing style
+
+  \param style Curve style
+  \sa CurveStyle, style()
+*/
+void QwtPolarCurve::setStyle( CurveStyle style )
+{
+    if ( style != d_data->style )
+    {
+        d_data->style = style;
+        itemChanged();
+    }
+}
+
+/*!
+    \return Current style
+    \sa CurveStyle, setStyle()
+*/
+QwtPolarCurve::CurveStyle QwtPolarCurve::style() const
+{
+    return d_data->style;
+}
+
+/*!
+  \brief Assign a symbol
+  \param symbol Symbol
+  \sa symbol()
+*/
+void QwtPolarCurve::setSymbol( const QwtSymbol *symbol )
+{
+    if ( symbol != d_data->symbol )
+    {
+        delete d_data->symbol;
+        d_data->symbol = symbol;
+        itemChanged();
+    }
+}
+
+/*!
+    \return The current symbol
+    \sa setSymbol()
+*/
+const QwtSymbol *QwtPolarCurve::symbol() const
+{
+    return d_data->symbol;
+}
+
+/*!
+  \brief Assign a pen
+  \param pen New pen
+  \sa pen()
+*/
+void QwtPolarCurve::setPen( const QPen &pen )
+{
+    if ( pen != d_data->pen )
+    {
+        d_data->pen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+    \return Pen used to draw the lines
+    \sa setPen()
+*/
+const QPen& QwtPolarCurve::pen() const
+{
+    return d_data->pen;
+}
+
+/*!
+  Initialize data with a pointer to QwtSeriesData<QwtPointPolar>.
+
+  The x-values of the data object represent the azimuth,
+  the y-value respresent the radius.
+
+  \param data Data
+*/
+void QwtPolarCurve::setData( QwtSeriesData<QwtPointPolar> *data )
+{
+    if ( d_series != data )
+    {
+        delete d_series;
+        d_series = data;
+        itemChanged();
+    }
+}
+
+/*!
+  \brief Insert a curve fitter
+
+  \param curveFitter Curve fitter
+
+  A curve fitter interpolates the curve points. F.e QwtPolarFitter
+  adds equidistant points so that the connection gets rounded instead
+  of having straight lines. If curveFitter is NULL fitting is disabled.
+
+  \sa curveFitter()
+*/
+void QwtPolarCurve::setCurveFitter( QwtCurveFitter *curveFitter )
+{
+    if ( curveFitter != d_data->curveFitter )
+    {
+        delete d_data->curveFitter;
+        d_data->curveFitter = curveFitter;
+
+        itemChanged();
+    }
+}
+
+/*!
+  \return The curve fitter
+  \sa setCurveFitter()
+*/
+QwtCurveFitter *QwtPolarCurve::curveFitter() const
+{
+    return d_data->curveFitter;
+}
+
+/*!
+  Draw the curve
+
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param radius Radius of the complete plot area in painter coordinates
+  \param canvasRect Contents rect of the canvas in painter coordinates
+*/
+void QwtPolarCurve::draw( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double radius,
+    const QRectF &canvasRect ) const
+{
+    Q_UNUSED( radius );
+    Q_UNUSED( canvasRect );
+
+    draw( painter, azimuthMap, radialMap, pole, 0, -1 );
+}
+
+/*!
+  \brief Draw an interval of the curve
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \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 drawCurve(), drawSymbols(),
+*/
+void QwtPolarCurve::draw( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, int from, int to ) const
+{
+    if ( !painter || dataSize() <= 0 )
+        return;
+
+    if ( to < 0 )
+        to = dataSize() - 1;
+
+    if ( qwtVerifyRange( dataSize(), from, to ) > 0 )
+    {
+        painter->save();
+        painter->setPen( d_data->pen );
+
+        drawCurve( painter, d_data->style,
+            azimuthMap, radialMap, pole, from, to );
+
+        painter->restore();
+
+        if ( d_data->symbol->style() != QwtSymbol::NoSymbol )
+        {
+            painter->save();
+            drawSymbols( painter, *d_data->symbol,
+                azimuthMap, radialMap, pole, from, to );
+            painter->restore();
+        }
+    }
+}
+
+/*!
+  Draw the line part (without symbols) of a curve interval.
+
+  \param painter Painter
+  \param style Curve style, see QwtPolarCurve::CurveStyle
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param from index of the first point to be painted
+  \param to index of the last point to be painted.
+  \sa draw(), drawLines()
+*/
+void QwtPolarCurve::drawCurve( QPainter *painter, int style,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, int from, int to ) const
+{
+    switch ( style )
+    {
+        case Lines:
+            drawLines( painter, azimuthMap, radialMap, pole, from, to );
+            break;
+        case NoCurve:
+        default:
+            break;
+    }
+}
+
+/*!
+  Draw lines
+
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param from index of the first point to be painted
+  \param to index of the last point to be painted.
+  \sa draw(), drawLines(), setCurveFitter()
+*/
+void QwtPolarCurve::drawLines( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, int from, int to ) const
+{
+    int size = to - from + 1;
+    if ( size <= 0 )
+        return;
+
+    QPolygonF polyline;
+    if ( d_data->curveFitter )
+    {
+        QPolygonF points( size );
+        for ( int j = from; j <= to; j++ )
+        {
+            const QwtPointPolar point = sample( j );
+            points[j - from] = QPointF( point.azimuth(), point.radius() );
+        }
+
+        points = d_data->curveFitter->fitCurve( points );
+
+        polyline.resize( points.size() );
+
+        QPointF *polylineData = polyline.data();
+        QPointF *pointsData = points.data();
+
+        for ( int i = 0; i < points.size(); i++ )
+        {
+            const QwtPointPolar point( pointsData[i].x(), pointsData[i].y() );
+
+            double r = radialMap.transform( point.radius() );
+            const double a = azimuthMap.transform( point.azimuth() );
+
+            polylineData[i] = qwtPolar2Pos( pole, r, a );
+        }
+    }
+    else
+    {
+        polyline.resize( size );
+        QPointF *polylineData = polyline.data();
+
+        for ( int i = from; i <= to; i++ )
+        {
+            QwtPointPolar point = sample( i );
+            if ( !qwtInsidePole( radialMap, point.radius() ) )
+            {
+                double r = radialMap.transform( point.radius() );
+                const double a = azimuthMap.transform( point.azimuth() );
+                polylineData[i - from] = qwtPolar2Pos( pole, r, a );
+            }
+            else
+            {
+                polylineData[i - from] = pole;
+            }
+        }
+    }
+
+    QRectF clipRect;
+    if ( painter->hasClipping() )
+        clipRect = painter->clipRegion().boundingRect();
+    else
+    {
+        clipRect = painter->window();
+        if ( !clipRect.isEmpty() )
+            clipRect = painter->transform().inverted().mapRect( clipRect );
+    }
+
+    if ( !clipRect.isEmpty() )
+    {
+        double off = qCeil( qMax( 1.0, painter->pen().widthF() ) );
+        clipRect = clipRect.toRect().adjusted( -off, -off, off, off );
+        polyline = QwtClipper::clipPolygonF( clipRect, polyline );
+    }
+
+    QwtPainter::drawPolyline( painter, polyline );
+    painter->drawPolyline( polyline );
+}
+
+/*!
+  Draw symbols
+
+  \param painter Painter
+  \param symbol Curve symbol
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param from index of the first point to be painted
+  \param to index of the last point to be painted.
+
+  \sa setSymbol(), draw(), drawCurve()
+*/
+void QwtPolarCurve::drawSymbols( QPainter *painter, const QwtSymbol &symbol,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, int from, int to ) const
+{
+    painter->setBrush( symbol.brush() );
+    painter->setPen( symbol.pen() );
+
+    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 QwtPointPolar point = sample( i + j );
+
+            if ( !qwtInsidePole( radialMap, point.radius() ) )
+            {
+                const double r = radialMap.transform( point.radius() );
+                const double a = azimuthMap.transform( point.azimuth() );
+
+                points += qwtPolar2Pos( pole, r, a );
+            }
+            else
+            {
+                points += pole;
+            }
+        }
+
+        if ( points.size() > 0 )
+            symbol.drawSymbols( painter, points );
+    }
+}
+
+/*!
+  \return Number of points
+  \sa setData()
+*/
+size_t QwtPolarCurve::dataSize() const
+{
+    return d_series->size();
+}
+
+//!  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() );
+
+    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 ) )
+        {
+            brush = QBrush( d_data->symbol->pen().color() );
+        }
+        if ( brush.style() != Qt::NoBrush )
+            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() );
+        }
+    }
+    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();
+        }
+    }
+}
+
+/*!
+   Interval, that is necessary to display the item
+   This interval can be useful for operations like clipping or autoscaling
+
+   \param scaleId Scale index
+   \return bounding interval
+
+   \sa QwtData::boundingRect()
+*/
+QwtInterval QwtPolarCurve::boundingInterval( int scaleId ) const
+{
+    const QRectF boundingRect = d_series->boundingRect();
+
+    if ( scaleId == QwtPolar::ScaleAzimuth )
+        return QwtInterval( boundingRect.left(), boundingRect.right() );
+
+    if ( scaleId == QwtPolar::ScaleRadius )
+        return QwtInterval( boundingRect.top(), boundingRect.bottom() );
+
+    return QwtInterval();
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_curve.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_curve.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_curve.h	(revision 4272)
@@ -0,0 +1,163 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_CURVE_H
+#define QWT_POLAR_CURVE_H
+
+#include "qwt_polar_global.h"
+#include "qwt_polar_item.h"
+#include <qwt_point_polar.h>
+#include <qwt_series_data.h>
+
+class QPainter;
+class QwtSymbol;
+class QwtCurveFitter;
+
+/*!
+  \brief An item, that represents a series of points
+
+  A curve is the representation of a series of points in polar coordinates.
+  The points are connected to the curve using the abstract QwtData interface.
+
+  \sa QwtPolarPlot, QwtSymbol, QwtScaleMap
+*/
+
+class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
+{
+public:
+    /*!
+        Curve styles.
+        \sa setStyle(), style()
+    */
+    enum CurveStyle
+    {
+        //! Don't draw a curve. Note: This doesn't affect the symbols.
+        NoCurve,
+
+        /*!
+          Connect the points with straight lines. The lines might
+          be interpolated depending on the 'Fitted' attribute. Curve
+          fitting can be configured using setCurveFitter().
+         */
+        Lines,
+
+        //! Values > 100 are reserved for user specific curve styles
+        UserCurve = 100
+    };
+
+    /*!
+        \brief Attributes how to represent the curve on the legend
+
+        If none of the flags is activated QwtPlotCurve tries to find
+        a color representing the curve and paints a rectangle with it.
+        In the default setting all attributes are off.
+
+        \sa setLegendAttribute(), testLegendAttribute(),
+            drawLegendIdentifier()
+     */
+
+    enum LegendAttribute
+    {
+        /*!
+          If the curveStyle() is not NoCurve a line is painted with the
+          curvePen().
+         */
+        LegendShowLine = 0x01,
+
+        //! If the curve has a valid symbol it is painted.
+        LegendShowSymbol = 0x02
+    };
+
+    //! Legend attributes
+    typedef QFlags<LegendAttribute> LegendAttributes;
+
+
+    explicit QwtPolarCurve();
+    explicit QwtPolarCurve( const QwtText &title );
+    explicit QwtPolarCurve( const QString &title );
+
+    virtual ~QwtPolarCurve();
+
+    virtual int rtti() const;
+
+    void setLegendAttribute( LegendAttribute, bool on = true );
+    bool testLegendAttribute( LegendAttribute ) const;
+
+    void setData( QwtSeriesData<QwtPointPolar> *data );
+    const QwtSeriesData<QwtPointPolar> *data() const;
+
+    size_t dataSize() const;
+    QwtPointPolar sample( int i ) const;
+
+    void setPen( const QPen & );
+    const QPen &pen() const;
+
+    void setStyle( CurveStyle style );
+    CurveStyle style() const;
+
+    void setSymbol( const QwtSymbol * );
+    const QwtSymbol *symbol() const;
+
+    void setCurveFitter( QwtCurveFitter * );
+    QwtCurveFitter *curveFitter() const;
+
+    virtual void draw( QPainter *p,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, double radius,
+        const QRectF &canvasRect ) const;
+
+    virtual void draw( QPainter *p,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        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;
+
+protected:
+
+    void init();
+
+    virtual void drawCurve( QPainter *, int style,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, int from, int to ) const;
+
+    virtual void drawSymbols( QPainter *, const QwtSymbol &,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, int from, int to ) const;
+
+    void drawLines( QPainter *,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, int from, int to ) const;
+
+private:
+    QwtSeriesData<QwtPointPolar> *d_series;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+//! \return the the curve data
+inline const QwtSeriesData<QwtPointPolar> *QwtPolarCurve::data() const
+{
+    return d_series;
+}
+
+/*!
+    \param i index
+    \return point at position i
+*/
+inline QwtPointPolar QwtPolarCurve::sample( int i ) const
+{
+    return d_series->sample( i );
+}
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarCurve::LegendAttributes )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_fitter.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_fitter.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_fitter.cpp	(revision 4272)
@@ -0,0 +1,100 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_fitter.h"
+
+class QwtPolarFitter::PrivateData
+{
+public:
+    PrivateData():
+        stepCount( 5 )
+    {
+    }
+
+    int stepCount;
+};
+
+/*!
+   Constructor
+
+   \param stepCount Number of points, that will be inserted between 2 points
+   \sa setStepCount()
+*/
+QwtPolarFitter::QwtPolarFitter( int stepCount )
+{
+    d_data = new PrivateData;
+    d_data->stepCount = stepCount;
+}
+
+//! Destructor
+QwtPolarFitter::~QwtPolarFitter()
+{
+    delete d_data;
+}
+
+/*!
+   Assign the number of points, that will be inserted between 2 points
+   The default value is 5.
+
+   \param stepCount Number of steps
+
+   \sa stepCount()
+*/
+void QwtPolarFitter::setStepCount( int stepCount )
+{
+    d_data->stepCount = qMax( stepCount, 0 );
+}
+
+/*!
+   \return Number of points, that will be inserted between 2 points
+   \sa setStepCount()
+*/
+int QwtPolarFitter::stepCount() const
+{
+    return d_data->stepCount;
+}
+
+/*!
+   Insert stepCount() number of additional points between 2 elements
+   of points.
+
+   \param points Array of points
+   \return Array of points including the additional points
+*/
+QPolygonF QwtPolarFitter::fitCurve( const QPolygonF &points ) const
+{
+    if ( d_data->stepCount <= 0 || points.size() <= 1 )
+        return points;
+
+    QPolygonF fittedPoints;
+
+    int numPoints = points.size() + ( points.size() - 1 ) * d_data->stepCount;
+
+    fittedPoints.resize( numPoints );
+
+    int index = 0;
+    fittedPoints[index++] = points[0];
+    for ( int i = 1; i < points.size(); i++ )
+    {
+        const QPointF &p1 = points[i-1];
+        const QPointF &p2 = points[i];
+
+        const double dx = ( p2.x() - p1.x() ) / d_data->stepCount;
+        const double dy = ( p2.y() - p1.y() ) / d_data->stepCount;
+        for ( int j = 1; j <= d_data->stepCount; j++ )
+        {
+            const double x = p1.x() + j * dx;
+            const double y = p1.y() + j * dy;
+
+            fittedPoints[index++] = QPointF( x, y );
+        }
+    }
+    fittedPoints.resize( index );
+
+    return fittedPoints;
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_fitter.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_fitter.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_fitter.h	(revision 4272)
@@ -0,0 +1,40 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_FITTER_H
+#define QWT_POLAR_FITTER_H
+
+#include "qwt_polar_global.h"
+#include <qwt_curve_fitter.h>
+
+/*!
+  \brief A simple curve fitter for polar points
+
+  QwtPolarFitter adds equidistant points between 2 curve points,
+  so that the connection gets rounded according to the nature of
+  a polar plot.
+
+  \sa QwtPolarCurve::setCurveFitter()
+*/
+class QWT_POLAR_EXPORT QwtPolarFitter: public QwtCurveFitter
+{
+public:
+    QwtPolarFitter( int stepCount = 5 );
+    virtual ~QwtPolarFitter();
+
+    void setStepCount( int size );
+    int stepCount() const;
+
+    virtual QPolygonF fitCurve( const QPolygonF & ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_global.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_global.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_global.h	(revision 4272)
@@ -0,0 +1,43 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_GLOBAL_H
+#define QWT_POLAR_GLOBAL_H
+
+#include <qglobal.h>
+
+// 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)
+
+#if defined(_MSC_VER) /* MSVC Compiler */
+/* template-class specialization 'identifier' is already instantiated */
+#pragma warning(disable: 4660)
+#endif // _MSC_VER
+
+#ifdef QWT_POLAR_DLL
+
+#if defined(QWT_POLAR_MAKEDLL)     // create a Qwt DLL library 
+#define QWT_POLAR_EXPORT  __declspec(dllexport)
+#define QWT_POLAR_TEMPLATEDLL
+#else                        // use a Qwt DLL library
+#define QWT_POLAR_EXPORT  __declspec(dllimport)
+#endif
+
+#endif // QWT_POLAR_MAKEDLL
+
+#endif // Q_WS_WIN
+
+#ifndef QWT_POLAR_EXPORT
+#define QWT_POLAR_EXPORT
+#endif
+
+#endif // QWT_POLAR_GLOBAL_H
Index: /trunk/BNC/qwtpolar/qwt_polar_grid.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_grid.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_grid.cpp	(revision 4272)
@@ -0,0 +1,1129 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_grid.h"
+#include <qwt_painter.h>
+#include <qwt_text.h>
+#include <qwt_clipper.h>
+#include <qwt_scale_map.h>
+#include <qwt_scale_engine.h>
+#include <qwt_scale_div.h>
+#include <qwt_scale_draw.h>
+#include <qwt_round_scale_draw.h>
+#include <qpainter.h>
+#include <qpen.h>
+#include <float.h>
+
+static inline bool isClose( double value1, double value2 )
+{
+    return qAbs( value1 - value2 ) < DBL_EPSILON;
+}
+
+class QwtPolarGrid::AxisData
+{
+public:
+    AxisData():
+        isVisible( false ),
+        scaleDraw( NULL )
+    {
+    }
+    ~AxisData()
+    {
+        delete scaleDraw;
+    }
+
+    bool isVisible;
+    mutable QwtAbstractScaleDraw *scaleDraw;
+    QPen pen;
+    QFont font;
+};
+
+class QwtPolarGrid::GridData
+{
+public:
+    GridData():
+        isVisible( true ),
+        isMinorVisible( false )
+    {
+    }
+
+    bool isVisible;
+    bool isMinorVisible;
+    QwtScaleDiv scaleDiv;
+
+    QPen majorPen;
+    QPen minorPen;
+};
+
+class QwtPolarGrid::PrivateData
+{
+public:
+    GridData gridData[QwtPolar::ScaleCount];
+    AxisData axisData[QwtPolar::AxesCount];
+    QwtPolarGrid::DisplayFlags displayFlags;
+    QwtPolarGrid::GridAttributes attributes;
+};
+
+/*!
+   \brief Constructor
+
+   Enables major and disables minor grid lines.
+   The azimuth and right radial axis are visible. all other axes
+   are hidden. Autoscaling is enabled.
+*/
+QwtPolarGrid::QwtPolarGrid():
+    QwtPolarItem( QwtText( "Grid" ) )
+{
+    d_data = new PrivateData;
+
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        AxisData &axis = d_data->axisData[axisId];
+        switch( axisId )
+        {
+            case QwtPolar::AxisAzimuth:
+            {
+                axis.scaleDraw = new QwtRoundScaleDraw;
+                axis.scaleDraw->setTickLength( QwtScaleDiv::MinorTick, 2 );
+                axis.scaleDraw->setTickLength( QwtScaleDiv::MediumTick, 2 );
+                axis.scaleDraw->setTickLength( QwtScaleDiv::MajorTick, 4 );
+                axis.isVisible = true;
+                break;
+            }
+            case QwtPolar::AxisLeft:
+            {
+                QwtScaleDraw *scaleDraw = new QwtScaleDraw;
+                scaleDraw->setAlignment( QwtScaleDraw::BottomScale );
+
+                axis.scaleDraw = scaleDraw;
+                axis.isVisible = false;
+                break;
+            }
+            case QwtPolar::AxisRight:
+            {
+                QwtScaleDraw *scaleDraw = new QwtScaleDraw;
+                scaleDraw->setAlignment( QwtScaleDraw::BottomScale );
+
+                axis.scaleDraw = scaleDraw;
+                axis.isVisible = true;
+                break;
+            }
+            case QwtPolar::AxisTop:
+            {
+                QwtScaleDraw *scaleDraw = new QwtScaleDraw;
+                scaleDraw->setAlignment( QwtScaleDraw::LeftScale );
+
+                axis.scaleDraw = scaleDraw;
+                axis.isVisible = false;
+                break;
+            }
+            case QwtPolar::AxisBottom:
+            {
+                QwtScaleDraw *scaleDraw = new QwtScaleDraw;
+                scaleDraw->setAlignment( QwtScaleDraw::LeftScale );
+
+                axis.scaleDraw = scaleDraw;
+                axis.isVisible = true;
+                break;
+            }
+            default:;
+        }
+    }
+
+    d_data->attributes = AutoScaling;
+
+    d_data->displayFlags = 0;
+    d_data->displayFlags |= SmartOriginLabel;
+    d_data->displayFlags |= HideMaxRadiusLabel;
+    d_data->displayFlags |= ClipAxisBackground;
+    d_data->displayFlags |= SmartScaleDraw;
+    d_data->displayFlags |= ClipGridLines;
+
+    setZ( 10.0 );
+    setRenderHint( RenderAntialiased, true );
+}
+
+//! Destructor
+QwtPolarGrid::~QwtPolarGrid()
+{
+    delete d_data;
+}
+
+//! \return QwtPlotItem::Rtti_PolarGrid
+int QwtPolarGrid::rtti() const
+{
+    return QwtPolarItem::Rtti_PolarGrid;
+}
+
+/*!
+   Change the display flags
+
+   \param flag See DisplayFlag
+   \param on true/false
+*/
+void QwtPolarGrid::setDisplayFlag( DisplayFlag flag, bool on )
+{
+    if ( ( ( d_data->displayFlags & flag ) != 0 ) != on )
+    {
+        if ( on )
+            d_data->displayFlags |= flag;
+        else
+            d_data->displayFlags &= ~flag;
+
+        itemChanged();
+    }
+}
+
+/*!
+   \return true, if flag is enabled
+   \param flag See DisplayFlag
+*/
+bool QwtPolarGrid::testDisplayFlag( DisplayFlag flag ) const
+{
+    return ( d_data->displayFlags & flag );
+}
+
+/*!
+  \brief Specify an attribute for the grid
+
+  \param attribute Grid attribute
+  \param on On/Off
+
+  /sa GridAttribute, testGridAttribute(), updateScaleDiv(),
+      QwtPolarPlot::zoom(), QwtPolarPlot::scaleDiv()
+*/
+void QwtPolarGrid::setGridAttribute( GridAttribute attribute, bool on )
+{
+    if ( bool( d_data->attributes & attribute ) == on )
+        return;
+
+    if ( on )
+        d_data->attributes |= attribute;
+    else
+        d_data->attributes &= ~attribute;
+
+    itemChanged();
+}
+
+/*!
+    \return true, if attribute is enabled
+    \sa GridAttribute, setGridAttribute()
+*/
+bool QwtPolarGrid::testGridAttribute( GridAttribute attribute ) const
+{
+    return d_data->attributes & attribute;
+}
+
+/*!
+  Assign a pen for painting an axis
+
+  \param axisId Axis id (QwtPolar::Axis)
+  \param pen Pen
+
+  \sa axisPen()
+*/
+void QwtPolarGrid::setAxisPen( int axisId, const QPen &pen )
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return;
+
+    AxisData &axisData = d_data->axisData[axisId];
+    if ( axisData.pen != pen )
+    {
+        axisData.pen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+   Show/Hide grid lines for a scale
+
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \param show true/false
+*/
+void QwtPolarGrid::showGrid( int scaleId, bool show )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    GridData &grid = d_data->gridData[scaleId];
+    if ( grid.isVisible != show )
+    {
+        grid.isVisible = show;
+        itemChanged();
+    }
+}
+
+/*!
+  \return true if grid lines are enabled
+  \param scaleId Scale id ( QwtPolar::Scale )
+  \sa QwtPolar::Scale, showGrid()
+*/
+bool QwtPolarGrid::isGridVisible( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return false;
+
+    return d_data->gridData[scaleId].isVisible;
+}
+
+/*!
+   Show/Hide minor grid lines for a scale
+
+   To display minor grid lines. showGrid() needs to be enabled too.
+
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \param show true/false
+
+   \sa showGrid
+*/
+void QwtPolarGrid::showMinorGrid( int scaleId, bool show )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    GridData &grid = d_data->gridData[scaleId];
+    if ( grid.isMinorVisible != show )
+    {
+        grid.isMinorVisible = show;
+        itemChanged();
+    }
+}
+
+/*!
+  \return true if minor grid lines are enabled
+  \param scaleId Scale id ( QwtPolar::Scale )
+  \sa showMinorGrid()
+*/
+bool QwtPolarGrid::isMinorGridVisible( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return false;
+
+    return d_data->gridData[scaleId].isMinorVisible;
+}
+
+/*!
+  Show/Hide an axis
+
+  \param axisId Axis id (QwtPolar::Axis)
+  \param show true/false
+
+  \sa isAxisVisible()
+*/
+void QwtPolarGrid::showAxis( int axisId, bool show )
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return;
+
+    AxisData &axisData = d_data->axisData[axisId];
+    if ( axisData.isVisible != show )
+    {
+        axisData.isVisible = show;
+        itemChanged();
+    }
+}
+
+/*!
+  \return true if the axis is visible
+  \param axisId Axis id (QwtPolar::Axis)
+
+  \sa showAxis()
+*/
+bool QwtPolarGrid::isAxisVisible( int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return false;
+
+    return d_data->axisData[axisId].isVisible;
+}
+
+/*!
+   Assign a pen for all axes and grid lines
+
+   \param pen Pen
+   \sa setMajorGridPen(), setMinorGridPen(), setAxisPen()
+*/
+void QwtPolarGrid::setPen( const QPen &pen )
+{
+    bool isChanged = false;
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+    {
+        GridData &grid = d_data->gridData[scaleId];
+        if ( grid.majorPen != pen || grid.minorPen != pen )
+        {
+            grid.majorPen = pen;
+            grid.minorPen = pen;
+            isChanged = true;
+        }
+    }
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        AxisData &axis = d_data->axisData[axisId];
+        if ( axis.pen != pen )
+        {
+            axis.pen = pen;
+            isChanged = true;
+        }
+    }
+    if ( isChanged )
+        itemChanged();
+}
+
+/*!
+   Assign a font for all scale tick labels
+
+   \param font Font
+   \sa setAxisFont()
+*/
+void QwtPolarGrid::setFont( const QFont &font )
+{
+    bool isChanged = false;
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        AxisData &axis = d_data->axisData[axisId];
+        if ( axis.font != font )
+        {
+            axis.font = font;
+            isChanged = true;
+        }
+    }
+    if ( isChanged )
+        itemChanged();
+}
+
+/*!
+   Assign a pen for the major grid lines
+
+   \param pen Pen
+   \sa setPen(), setMinorGridPen(), majorGridPen
+*/
+void QwtPolarGrid::setMajorGridPen( const QPen &pen )
+{
+    bool isChanged = false;
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+    {
+        GridData &grid = d_data->gridData[scaleId];
+        if ( grid.majorPen != pen )
+        {
+            grid.majorPen = pen;
+            isChanged = true;
+        }
+    }
+    if ( isChanged )
+        itemChanged();
+}
+
+/*!
+   Assign a pen for the major grid lines of a specific scale
+
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \param pen Pen
+   \sa setPen(), setMinorGridPen(), majorGridPen
+*/
+void QwtPolarGrid::setMajorGridPen( int scaleId, const QPen &pen )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    GridData &grid = d_data->gridData[scaleId];
+    if ( grid.majorPen != pen )
+    {
+        grid.majorPen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+   \return Pen for painting the major grid lines of a specific scale
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \sa setMajorGridPen(), minorGridPen()
+*/
+QPen QwtPolarGrid::majorGridPen( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return QPen();
+
+    const GridData &grid = d_data->gridData[scaleId];
+    return grid.majorPen;
+}
+
+/*!
+   Assign a pen for the minor grid lines
+
+   \param pen Pen
+   \sa setPen(), setMajorGridPen(), minorGridPen()
+*/
+void QwtPolarGrid::setMinorGridPen( const QPen &pen )
+{
+    bool isChanged = false;
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+    {
+        GridData &grid = d_data->gridData[scaleId];
+        if ( grid.minorPen != pen )
+        {
+            grid.minorPen = pen;
+            isChanged = true;
+        }
+    }
+    if ( isChanged )
+        itemChanged();
+}
+
+/*!
+   Assign a pen for the minor grid lines of a specific scale
+
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \param pen Pen
+   \sa setPen(), setMajorGridPen(), minorGridPen
+*/
+void QwtPolarGrid::setMinorGridPen( int scaleId, const QPen &pen )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    GridData &grid = d_data->gridData[scaleId];
+    if ( grid.minorPen != pen )
+    {
+        grid.minorPen = pen;
+        itemChanged();
+    }
+}
+
+/*!
+   \return Pen for painting the minor grid lines of a specific scale
+   \param scaleId Scale id ( QwtPolar::Scale )
+*/
+QPen QwtPolarGrid::minorGridPen( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return QPen();
+
+    const GridData &grid = d_data->gridData[scaleId];
+    return grid.minorPen;
+}
+
+/*!
+   \return Pen for painting a specific axis
+
+   \param axisId Axis id (QwtPolar::Axis)
+   \sa setAxisPen()
+*/
+QPen QwtPolarGrid::axisPen( int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return QPen();
+
+    return d_data->axisData[axisId].pen;
+}
+
+/*!
+  Assign a font for the tick labels of a specific axis
+
+  \param axisId Axis id (QwtPolar::Axis)
+  \param font new Font
+*/
+void QwtPolarGrid::setAxisFont( int axisId, const QFont &font )
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return;
+
+    AxisData &axisData = d_data->axisData[axisId];
+    if ( axisData.font != font )
+    {
+        axisData.font = font;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Font for the tick labels of a specific axis
+  \param axisId Axis id (QwtPolar::Axis)
+*/
+QFont QwtPolarGrid::axisFont( int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return QFont();
+
+    return d_data->axisData[axisId].font;
+}
+
+/*!
+  Draw the grid and axes
+
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param radius Radius of the complete plot area in painter coordinates
+  \param canvasRect Contents rect of the canvas in painter coordinates
+*/
+void QwtPolarGrid::draw( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double radius,
+    const QRectF &canvasRect ) const
+{
+    updateScaleDraws( azimuthMap, radialMap, pole, radius );
+
+    painter->save();
+
+    if ( testDisplayFlag( ClipAxisBackground ) )
+    {
+        QRegion clipRegion( canvasRect.toRect() );
+        for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+        {
+            const AxisData &axis = d_data->axisData[axisId];
+            if ( axisId != QwtPolar::AxisAzimuth && axis.isVisible )
+            {
+                QwtScaleDraw *scaleDraw = static_cast<QwtScaleDraw *>( axis.scaleDraw );
+                if ( scaleDraw->hasComponent( QwtScaleDraw::Labels ) )
+                {
+                    const QList<double> &ticks =
+                        scaleDraw->scaleDiv().ticks( QwtScaleDiv::MajorTick );
+                    for ( int i = 0; i < int( ticks.size() ); i++ )
+                    {
+                        if ( !scaleDraw->scaleDiv().contains( ticks[i] ) )
+                            continue;
+
+                        QRect labelRect =
+                            scaleDraw->boundingLabelRect( axis.font, ticks[i] );
+
+                        const int margin = 2;
+                        labelRect.adjust( -margin, -margin, margin, margin );
+
+                        if ( labelRect.isValid() )
+                            clipRegion -= QRegion( labelRect );
+                    }
+                }
+            }
+        }
+        painter->setClipRegion( clipRegion );
+    }
+
+    //  draw radial grid
+
+    const GridData &radialGrid = d_data->gridData[QwtPolar::Radius];
+    if ( radialGrid.isVisible && radialGrid.isMinorVisible )
+    {
+        painter->setPen( radialGrid.minorPen );
+
+        drawCircles( painter, canvasRect, pole, radialMap,
+            radialGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
+        drawCircles( painter, canvasRect, pole, radialMap,
+            radialGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
+    }
+    if ( radialGrid.isVisible )
+    {
+        painter->setPen( radialGrid.majorPen );
+
+        drawCircles( painter, canvasRect, pole, radialMap,
+            radialGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
+    }
+
+    // draw azimuth grid
+
+    const GridData &azimuthGrid =
+        d_data->gridData[QwtPolar::Azimuth];
+
+    if ( azimuthGrid.isVisible && azimuthGrid.isMinorVisible )
+    {
+        painter->setPen( azimuthGrid.minorPen );
+
+        drawRays( painter, canvasRect, pole, radius, azimuthMap,
+            azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MinorTick ) );
+        drawRays( painter, canvasRect, pole, radius, azimuthMap,
+            azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MediumTick ) );
+    }
+    if ( azimuthGrid.isVisible )
+    {
+        painter->setPen( azimuthGrid.majorPen );
+
+        drawRays( painter, canvasRect, pole, radius, azimuthMap,
+            azimuthGrid.scaleDiv.ticks( QwtScaleDiv::MajorTick ) );
+    }
+    painter->restore();
+
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        const AxisData &axis = d_data->axisData[axisId];
+        if ( axis.isVisible )
+        {
+            painter->save();
+            drawAxis( painter, axisId );
+            painter->restore();
+        }
+    }
+}
+
+/*!
+  Draw lines from the pole
+
+  \param painter Painter
+  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param pole Position of the pole in painter coordinates
+  \param radius Length of the lines in painter coordinates
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param values Azimuth values, indicating the direction of the lines
+*/
+void QwtPolarGrid::drawRays(
+    QPainter *painter, const QRectF &canvasRect,
+    const QPointF &pole, double radius,
+    const QwtScaleMap &azimuthMap, const QList<double> &values ) const
+{
+    for ( int i = 0; i < int( values.size() ); i++ )
+    {
+        double azimuth = azimuthMap.transform( values[i] );
+        azimuth = ::fmod( azimuth, 2 * M_PI );
+
+        bool skipLine = false;
+        if ( testDisplayFlag( SmartScaleDraw ) )
+        {
+            const QwtAbstractScaleDraw::ScaleComponent bone =
+                QwtAbstractScaleDraw::Backbone;
+            if ( isClose( azimuth, 0.0 ) )
+            {
+                const AxisData &axis = d_data->axisData[QwtPolar::AxisRight];
+                if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
+                    skipLine = true;
+            }
+            else if ( isClose( azimuth, M_PI / 2 ) )
+            {
+                const AxisData &axis = d_data->axisData[QwtPolar::AxisTop];
+                if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
+                    skipLine = true;
+            }
+            else if ( isClose( azimuth, M_PI ) )
+            {
+                const AxisData &axis = d_data->axisData[QwtPolar::AxisLeft];
+                if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
+                    skipLine = true;
+            }
+            else if ( isClose( azimuth, 3 * M_PI / 2.0 ) )
+            {
+                const AxisData &axis = d_data->axisData[QwtPolar::AxisBottom];
+                if ( axis.isVisible && axis.scaleDraw->hasComponent( bone ) )
+                    skipLine = true;
+            }
+        }
+        if ( !skipLine )
+        {
+            const QPointF pos = qwtPolar2Pos( pole, radius, azimuth );
+
+            /*
+                Qt4 is horrible slow, when painting primitives,
+                with coordinates far outside the visible area.
+             */
+
+            QPolygonF polygon( 2 );
+            polygon[0] = pole.toPoint();
+            polygon[1] = pos.toPoint();
+
+            if ( testDisplayFlag( ClipGridLines ) )
+                polygon = QwtClipper::clipPolygonF( canvasRect, polygon );
+
+            QwtPainter::drawPolyline( painter, polygon );
+        }
+    }
+}
+
+/*!
+  Draw circles
+
+  \param painter Painter
+  \param canvasRect Contents rect of the canvas in painter coordinates
+  \param pole Position of the pole in painter coordinates
+  \param radialMap Maps radius values into painter coordinates.
+  \param values Radial values, indicating the distances from the pole
+*/
+void QwtPolarGrid::drawCircles(
+    QPainter *painter, const QRectF &canvasRect,
+    const QPointF &pole, const QwtScaleMap &radialMap,
+    const QList<double> &values ) const
+{
+    for ( int i = 0; i < int( values.size() ); i++ )
+    {
+        const double val = values[i];
+
+        const GridData &gridData =
+            d_data->gridData[QwtPolar::Radius];
+
+        bool skipLine = false;
+        if ( testDisplayFlag( SmartScaleDraw ) )
+        {
+            const AxisData &axis = d_data->axisData[QwtPolar::AxisAzimuth];
+            if ( axis.isVisible &&
+                axis.scaleDraw->hasComponent( QwtAbstractScaleDraw::Backbone ) )
+            {
+                if ( isClose( val, gridData.scaleDiv.upperBound() ) )
+                    skipLine = true;
+            }
+        }
+
+        if ( isClose( val, gridData.scaleDiv.lowerBound() ) )
+            skipLine = true;
+
+        if ( !skipLine )
+        {
+            const double radius = radialMap.transform( val );
+
+            QRectF outerRect( 0, 0, 2 * radius, 2 * radius );
+            outerRect.moveCenter( pole );
+
+            if ( testDisplayFlag( ClipGridLines ) )
+            {
+                /*
+                    Qt4 is horrible slow, when painting primitives,
+                    with coordinates far outside the visible area.
+                    We need to clip.
+                */
+
+                const QVector<QwtInterval> angles =
+                    QwtClipper::clipCircle( canvasRect, pole, radius );
+                for ( int i = 0; i < angles.size(); i++ )
+                {
+                    const QwtInterval intv = angles[i];
+                    if ( intv.minValue() == 0 && intv.maxValue() == 2 * M_PI )
+                        QwtPainter::drawEllipse( painter, outerRect );
+                    else
+                    {
+                        const double from = intv.minValue() / M_PI * 180;
+                        const double to = intv.maxValue() / M_PI * 180;
+                        double span = to - from;
+                        if ( span < 0.0 )
+                            span += 360.0;
+
+                        painter->drawArc( outerRect,
+                            qRound( from * 16 ), qRound( span * 16 ) );
+                    }
+                }
+            }
+            else
+            {
+                QwtPainter::drawEllipse( painter, outerRect );
+            }
+        }
+    }
+}
+
+/*!
+  Paint an axis
+
+  \param painter Painter
+  \param axisId Axis id (QwtPolar::Axis)
+*/
+void QwtPolarGrid::drawAxis( QPainter *painter, int axisId ) const
+{
+    if ( axisId < 0 || axisId >= QwtPolar::AxesCount )
+        return;
+
+    AxisData &axis = d_data->axisData[axisId];
+
+    painter->setPen( axis.pen );
+    painter->setFont( axis.font );
+
+    QPalette pal;
+    pal.setColor( QPalette::Foreground, axis.pen.color() );
+    pal.setColor( QPalette::Text, axis.pen.color() );
+
+    axis.scaleDraw->draw( painter, pal );
+}
+
+/*!
+   Update the axis scale draw geometries
+
+   \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+   \param radialMap Maps radius values into painter coordinates.
+   \param pole Position of the pole in painter coordinates
+   \param radius Radius of the complete plot area in painter coordinates
+
+   \sa updateScaleDiv()
+*/
+void QwtPolarGrid::updateScaleDraws(
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double radius ) const
+{
+    const QPoint p = pole.toPoint();
+
+    const QwtInterval interval =
+        d_data->gridData[QwtPolar::ScaleRadius].scaleDiv.interval();
+
+    const int min = radialMap.transform( interval.minValue() );
+    const int max = radialMap.transform( interval.maxValue() );
+    const int l = max - min;
+
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        AxisData &axis = d_data->axisData[axisId];
+
+        if ( axisId == QwtPolar::AxisAzimuth )
+        {
+            QwtRoundScaleDraw *scaleDraw =
+                static_cast<QwtRoundScaleDraw *>( axis.scaleDraw );
+
+            scaleDraw->setRadius( qRound( radius ) );
+            scaleDraw->moveCenter( p );
+
+            double from = ::fmod( 90.0 - azimuthMap.p1() * 180.0 / M_PI, 360.0 );
+            if ( from < 0.0 )
+                from += 360.0;
+
+            scaleDraw->setAngleRange( from, from - 360.0 );
+            scaleDraw->setTransformation( azimuthMap.transformation()->copy() );
+        }
+        else
+        {
+            QwtScaleDraw *scaleDraw =
+                static_cast<QwtScaleDraw *>( axis.scaleDraw );
+
+            switch( axisId )
+            {
+                case QwtPolar::AxisLeft:
+                {
+                    scaleDraw->move( p.x() - min, p.y() );
+                    scaleDraw->setLength( -l );
+                    break;
+                }
+                case QwtPolar::AxisRight:
+                {
+                    scaleDraw->move( p.x() + min, p.y() );
+                    scaleDraw->setLength( l );
+                    break;
+                }
+                case QwtPolar::AxisTop:
+                {
+                    scaleDraw->move( p.x(), p.y() - max );
+                    scaleDraw->setLength( l );
+                    break;
+                }
+                case QwtPolar::AxisBottom:
+                {
+                    scaleDraw->move( p.x(), p.y() + max );
+                    scaleDraw->setLength( -l );
+                    break;
+                }
+            }
+            scaleDraw->setTransformation( radialMap.transformation()->copy() );
+        }
+    }
+}
+
+/*!
+   \brief Update the item to changes of the axes scale division
+
+   If AutoScaling is enabled the radial scale is calculated
+   from the interval, otherwise the scales are adopted to
+   the plot scales.
+
+   \param azimuthScaleDiv Scale division of the azimuth-scale
+   \param radialScaleDiv Scale division of the radius-axis
+   \param interval The interval of the radius-axis, that is
+                   visible on the canvas
+
+   \sa QwtPolarPlot::setGridAttributes()
+*/
+
+void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
+    const QwtScaleDiv &radialScaleDiv, const QwtInterval &interval )
+{
+    GridData &radialGrid = d_data->gridData[QwtPolar::Radius];
+
+    const QwtPolarPlot *plt = plot();
+    if ( plt && testGridAttribute( AutoScaling ) )
+    {
+        const QwtScaleEngine *se = plt->scaleEngine( QwtPolar::Radius );
+        radialGrid.scaleDiv = se->divideScale(
+            interval.minValue(), interval.maxValue(),
+            plt->scaleMaxMajor( QwtPolar::Radius ),
+            plt->scaleMaxMinor( QwtPolar::Radius ), 0 );
+    }
+    else
+    {
+        if ( radialGrid.scaleDiv != radialScaleDiv )
+            radialGrid.scaleDiv = radialScaleDiv;
+    }
+
+    GridData &azimuthGrid = d_data->gridData[QwtPolar::Azimuth];
+    if ( azimuthGrid.scaleDiv != azimuthScaleDiv )
+    {
+        azimuthGrid.scaleDiv = azimuthScaleDiv;
+    }
+
+    bool hasOrigin = false;
+    for ( int axisId = 0; axisId < QwtPolar::AxesCount; axisId++ )
+    {
+        AxisData &axis = d_data->axisData[axisId];
+        if ( axis.isVisible && axis.scaleDraw )
+        {
+            if ( axisId == QwtPolar::AxisAzimuth )
+            {
+                axis.scaleDraw->setScaleDiv( azimuthGrid.scaleDiv );
+                if ( testDisplayFlag( SmartScaleDraw ) )
+                {
+                    axis.scaleDraw->enableComponent(
+                        QwtAbstractScaleDraw::Ticks, !azimuthGrid.isVisible );
+                }
+            }
+            else
+            {
+                QwtScaleDiv sd = radialGrid.scaleDiv;
+
+                QList<double> &ticks =
+                    const_cast<QList<double> &>( sd.ticks( QwtScaleDiv::MajorTick ) );
+
+                if ( testDisplayFlag( SmartOriginLabel ) )
+                {
+                    bool skipOrigin = hasOrigin;
+                    if ( !skipOrigin )
+                    {
+                        if ( axisId == QwtPolar::AxisLeft
+                            || axisId == QwtPolar::AxisRight )
+                        {
+                            if ( d_data->axisData[QwtPolar::AxisBottom].isVisible )
+                                skipOrigin = true;
+                        }
+                        else
+                        {
+                            if ( d_data->axisData[QwtPolar::AxisLeft].isVisible )
+                                skipOrigin = true;
+                        }
+                    }
+                    if ( ticks.size() > 0 && ticks.first() == sd.lowerBound() )
+                    {
+                        if ( skipOrigin )
+                            ticks.removeFirst();
+                        else
+                            hasOrigin = true;
+                    }
+                }
+
+                if ( testDisplayFlag( HideMaxRadiusLabel ) )
+                {
+                    if ( ticks.size() > 0 && ticks.last() == sd.upperBound() )
+                        ticks.removeLast();
+                }
+
+                axis.scaleDraw->setScaleDiv( sd );
+
+                if ( testDisplayFlag( SmartScaleDraw ) )
+                {
+                    axis.scaleDraw->enableComponent(
+                        QwtAbstractScaleDraw::Ticks, !radialGrid.isVisible );
+                }
+
+            }
+        }
+    }
+}
+
+/*!
+   \return Number of pixels, that are necessary to paint the azimuth scale
+   \sa QwtRoundScaleDraw::extent()
+*/
+int QwtPolarGrid::marginHint() const
+{
+    const AxisData &axis = d_data->axisData[QwtPolar::AxisAzimuth];
+    if ( axis.isVisible )
+    {
+        const int extent = axis.scaleDraw->extent( axis.font );
+        return extent;
+    }
+
+    return 0;
+}
+
+/*!
+  Returns the scale draw of a specified axis
+
+  \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom)
+  \return specified scaleDraw for axis, or NULL if axis is invalid.
+  \sa azimuthScaleDraw()
+*/
+const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
+{
+    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
+        return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
+
+    return NULL;
+}
+
+/*!
+  Returns the scale draw of a specified axis
+
+  \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom)
+  \return specified scaleDraw for axis, or NULL if axis is invalid.
+  \sa setScaleDraw(), azimuthScaleDraw()
+*/
+QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
+{
+    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
+        return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
+
+    return NULL;
+}
+
+/*!
+  \brief Set a scale draw
+
+  \param axisId axis index ( QwtPolar::AxisLeft <= axisId <= QwtPolar::AxisBottom)
+  \param scaleDraw object responsible for drawing scales.
+
+  \sa scaleDraw(), setAzimuthScaleDraw()
+*/
+void QwtPolarGrid::setScaleDraw( int axisId, QwtScaleDraw *scaleDraw )
+{
+    if ( axisId < QwtPolar::AxisLeft || axisId > QwtPolar::AxisBottom )
+        return;
+
+    AxisData &axisData = d_data->axisData[axisId];
+    if ( axisData.scaleDraw != scaleDraw )
+    {
+        delete axisData.scaleDraw;
+        axisData.scaleDraw = scaleDraw;
+        itemChanged();
+    }
+}
+
+/*!
+  \return Scale draw for the azimuth scale
+  \sa setAzimuthScaleDraw(), scaleDraw()
+*/
+const QwtRoundScaleDraw *QwtPolarGrid::azimuthScaleDraw() const
+{
+    return static_cast<QwtRoundScaleDraw *>(
+        d_data->axisData[QwtPolar::AxisAzimuth].scaleDraw );
+}
+
+/*!
+  \return Scale draw for the azimuth scale
+  \sa setAzimuthScaleDraw(), scaleDraw()
+*/
+QwtRoundScaleDraw *QwtPolarGrid::azimuthScaleDraw()
+{
+    return static_cast<QwtRoundScaleDraw *>(
+        d_data->axisData[QwtPolar::AxisAzimuth].scaleDraw );
+}
+
+/*!
+  \brief Set a scale draw for the azimuth scale
+
+  \param scaleDraw object responsible for drawing scales.
+  \sa azimuthScaleDraw(), setScaleDraw()
+*/
+void QwtPolarGrid::setAzimuthScaleDraw( QwtRoundScaleDraw *scaleDraw )
+{
+    AxisData &axisData = d_data->axisData[QwtPolar::AxisAzimuth];
+    if ( axisData.scaleDraw != scaleDraw )
+    {
+        delete axisData.scaleDraw;
+        axisData.scaleDraw = scaleDraw;
+        itemChanged();
+    }
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_grid.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_grid.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_grid.h	(revision 4272)
@@ -0,0 +1,187 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_GRID_H
+#define QWT_POLAR_GRID_H
+
+#include "qwt_polar_global.h"
+#include "qwt_polar.h"
+#include "qwt_polar_item.h"
+#include "qwt_polar_plot.h"
+
+class QPainter;
+class QPen;
+class QwtScaleMap;
+class QwtScaleDiv;
+class QwtRoundScaleDraw;
+class QwtScaleDraw;
+
+/*!
+  \brief An item which draws scales and grid lines on a polar plot.
+
+  The QwtPolarGrid class can be used to draw a coordinate grid.
+  A coordinate grid consists of major and minor gridlines.
+  The locations of the gridlines are determined by the azimuth and radial
+  scale divisions.
+
+  QwtPolarGrid is also responsible for drawing the axis representing the
+  scales. It is possible to display 4 radial and one azimuth axis.
+
+  Whenever the scale divisions of the plot widget changes the grid
+  is synchronized by updateScaleDiv().
+
+  \sa QwtPolarPlot, QwtPolar::Axis
+*/
+
+class QWT_POLAR_EXPORT QwtPolarGrid: public QwtPolarItem
+{
+public:
+    /*!
+       Mysterious flags trying to avoid conflicts, when painting the
+       scales and grid lines.
+
+      The default setting enables all flags.
+
+      \sa setDisplayFlag(), testDisplayFlag()
+     */
+    enum DisplayFlag
+    {
+        /*!
+          Try to avoid situations, where the label of the origin is
+          painted over another axis.
+         */
+        SmartOriginLabel = 1,
+
+        /*!
+        Often the outermost tick of the radial scale is close to the
+        canvas border. With HideMaxRadiusLabel enabled it is not painted.
+         */
+        HideMaxRadiusLabel = 2,
+
+        /*!
+        The tick labels of the radial scales might be hard to read, when
+        they are painted on top of the radial grid lines ( or on top
+        of a curve/spectrogram ). When ClipAxisBackground the bounding rect
+        of each label is added to the clip region.
+         */
+        ClipAxisBackground = 4,
+
+        /*!
+        Don't paint the backbone of the radial axes, when they are very close
+        to a line of the azimuth grid.
+         */
+        SmartScaleDraw = 8,
+
+        /*!
+        All grid lines are clipped against the plot area before being painted.
+        When the plot is zoomed in this will have an significant impact
+        on the performance of the painting cde.
+         */
+        ClipGridLines = 16
+    };
+
+    //! Display flags
+    typedef QFlags<DisplayFlag> DisplayFlags;
+
+    /*!
+      \brief Grid attributes
+      \sa setGridAttributes(), testGridAttributes()
+     */
+    enum GridAttribute
+    {
+        /*!
+          When AutoScaling is enabled, the radial axes will be adjusted
+          to the interval, that is currently visible on the canvas plot.
+         */
+        AutoScaling = 0x01
+    };
+
+    //! Grid attributes
+    typedef QFlags<GridAttribute> GridAttributes;
+
+    explicit QwtPolarGrid();
+    virtual ~QwtPolarGrid();
+
+    virtual int rtti() const;
+
+    void setDisplayFlag( DisplayFlag, bool on = true );
+    bool testDisplayFlag( DisplayFlag ) const;
+
+    void setGridAttribute( GridAttribute, bool on = true );
+    bool testGridAttribute( GridAttribute ) const;
+
+    void showGrid( int scaleId, bool show = true );
+    bool isGridVisible( int scaleId ) const;
+
+    void showMinorGrid( int scaleId, bool show = true );
+    bool isMinorGridVisible( int scaleId ) const;
+
+    void showAxis( int axisId, bool show = true );
+    bool isAxisVisible( int axisId ) const;
+
+    void setPen( const QPen &p );
+    void setFont( const QFont & );
+
+    void setMajorGridPen( const QPen &p );
+    void setMajorGridPen( int scaleId, const QPen &p );
+    QPen majorGridPen( int scaleId ) const;
+
+    void setMinorGridPen( const QPen &p );
+    void setMinorGridPen( int scaleId, const QPen &p );
+    QPen minorGridPen( int scaleId ) const;
+
+    void setAxisPen( int axisId, const QPen &p );
+    QPen axisPen( int axisId ) const;
+
+    void setAxisFont( int axisId, const QFont &p );
+    QFont axisFont( int axisId ) const;
+
+    void setScaleDraw( int axisId, QwtScaleDraw * );
+    const QwtScaleDraw *scaleDraw( int axisId ) const;
+    QwtScaleDraw *scaleDraw( int axisId );
+
+    void setAzimuthScaleDraw( QwtRoundScaleDraw * );
+    const QwtRoundScaleDraw *azimuthScaleDraw() const;
+    QwtRoundScaleDraw *azimuthScaleDraw();
+
+    virtual void draw( QPainter *p,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, double radius,
+        const QRectF &rect ) const;
+
+    virtual void updateScaleDiv( const QwtScaleDiv &azimuthMap,
+        const QwtScaleDiv &radialMap, const QwtInterval & );
+
+    virtual int marginHint() const;
+
+protected:
+    void drawRays( QPainter *, const QRectF &,
+        const QPointF &pole, double radius,
+        const QwtScaleMap &azimuthMap, const QList<double> & ) const;
+    void drawCircles( QPainter *, const QRectF &,
+        const QPointF &pole, const QwtScaleMap &radialMap,
+        const QList<double> & ) const;
+
+    void drawAxis( QPainter *, int axisId ) const;
+
+private:
+    void updateScaleDraws(
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, const double radius ) const;
+
+private:
+    class GridData;
+    class AxisData;
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::DisplayFlags )
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarGrid::GridAttributes )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_item.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_item.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_item.cpp	(revision 4272)
@@ -0,0 +1,453 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_plot.h"
+#include "qwt_polar_item.h"
+#include <qwt_legend.h>
+#include <qwt_legend_item.h>
+#include <qwt_scale_div.h>
+#include <qpainter.h>
+
+class QwtPolarItem::PrivateData
+{
+public:
+    PrivateData():
+        plot( NULL ),
+        isVisible( true ),
+        attributes( 0 ),
+        renderHints( 0 ),
+        z( 0.0 )
+    {
+    }
+
+    mutable QwtPolarPlot *plot;
+
+    bool isVisible;
+    QwtPolarItem::ItemAttributes attributes;
+    QwtPolarItem::RenderHints renderHints;
+    double z;
+
+    QwtText title;
+};
+
+/*!
+   Constructor
+
+   \param title Item title, f.e used on a legend
+
+   \sa setTitle()
+*/
+QwtPolarItem::QwtPolarItem( const QwtText &title )
+{
+    d_data = new PrivateData;
+    d_data->title = title;
+}
+
+//! Destroy the QwtPolarItem
+QwtPolarItem::~QwtPolarItem()
+{
+    attach( NULL );
+    delete d_data;
+}
+
+/*!
+  \brief Attach the item to a plot.
+
+  This method will attach a QwtPolarItem to the QwtPolarPlot argument.
+  It will first detach the QwtPolarItem from any plot from a previous
+  call to attach (if necessary).
+  If a NULL argument is passed, it will detach from any QwtPolarPlot it
+  was attached to.
+
+  \param plot Plot widget
+
+  \sa QwtPolarItem::detach()
+*/
+void QwtPolarItem::attach( QwtPolarPlot *plot )
+{
+    if ( plot == d_data->plot )
+        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();
+    }
+}
+
+/*!
+   Return rtti for the specific class represented. QwtPolarItem is simply
+   a virtual interface class, and base classes will implement this method
+   with specific rtti values so a user can differentiate them.
+
+   The rtti value is useful for environments, where the
+   runtime type information is disabled and it is not possible
+   to do a dynamic_cast<...>.
+
+   \return rtti value
+   \sa RttiValues
+*/
+int QwtPolarItem::rtti() const
+{
+    return Rtti_PolarItem;
+}
+
+//! \return Attached plot
+QwtPolarPlot *QwtPolarItem::plot() const
+{
+    return d_data->plot;
+}
+
+/*!
+   Plot items are painted in increasing z-order.
+
+   \return Z value
+   \sa setZ(), QwtPolarItemDict::itemList()
+*/
+double QwtPolarItem::z() const
+{
+    return d_data->z;
+}
+
+/*!
+   \brief Set the z value
+
+   Plot items are painted in increasing z-order.
+
+   \param z Z-value
+   \sa z(), QwtPolarItemDict::itemList()
+*/
+void QwtPolarItem::setZ( double z )
+{
+    if ( d_data->z != z )
+    {
+        if ( d_data->plot )
+            d_data->plot->attachItem( this, false );
+
+        d_data->z = z;
+
+        if ( d_data->plot )
+            d_data->plot->attachItem( this, true );
+
+        itemChanged();
+    }
+}
+
+/*!
+   Set a new title
+
+   \param title Title
+   \sa title()
+*/
+void QwtPolarItem::setTitle( const QString &title )
+{
+    setTitle( QwtText( title ) );
+}
+
+/*!
+   Set a new title
+
+   \param title Title
+   \sa title()
+*/
+void QwtPolarItem::setTitle( const QwtText &title )
+{
+    if ( d_data->title != title )
+    {
+        d_data->title = title;
+        itemChanged();
+    }
+}
+
+/*!
+   \return Title of the item
+   \sa setTitle()
+*/
+const QwtText &QwtPolarItem::title() const
+{
+    return d_data->title;
+}
+
+/*!
+   Toggle an item attribute
+
+   \param attribute Attribute type
+   \param on true/false
+
+   \sa testItemAttribute(), ItemAttribute
+*/
+void QwtPolarItem::setItemAttribute( ItemAttribute attribute, bool on )
+{
+    if ( bool( d_data->attributes & attribute ) != on )
+    {
+        if ( on )
+            d_data->attributes |= attribute;
+        else
+            d_data->attributes &= ~attribute;
+
+        itemChanged();
+    }
+}
+
+/*!
+   Test an item attribute
+
+   \param attribute Attribute type
+   \return true/false
+   \sa setItemAttribute(), ItemAttribute
+*/
+bool QwtPolarItem::testItemAttribute( ItemAttribute attribute ) const
+{
+    return d_data->attributes & attribute;
+}
+
+/*!
+   Toggle an render hint
+
+   \param hint Render hint
+   \param on true/false
+
+   \sa testRenderHint(), RenderHint
+*/
+void QwtPolarItem::setRenderHint( RenderHint hint, bool on )
+{
+    if ( ( ( d_data->renderHints & hint ) != 0 ) != on )
+    {
+        if ( on )
+            d_data->renderHints |= hint;
+        else
+            d_data->renderHints &= ~hint;
+
+        itemChanged();
+    }
+}
+
+/*!
+   Test a render hint
+
+   \param hint Render hint
+   \return true/false
+   \sa setRenderHint(), RenderHint
+*/
+bool QwtPolarItem::testRenderHint( RenderHint hint ) const
+{
+    return ( d_data->renderHints & hint );
+}
+
+//! Show the item
+void QwtPolarItem::show()
+{
+    setVisible( true );
+}
+
+//! Hide the item
+void QwtPolarItem::hide()
+{
+    setVisible( false );
+}
+
+/*!
+    Show/Hide the item
+
+    \param on Show if true, otherwise hide
+    \sa isVisible(), show(), hide()
+*/
+void QwtPolarItem::setVisible( bool on )
+{
+    if ( on != d_data->isVisible )
+    {
+        d_data->isVisible = on;
+        itemChanged();
+    }
+}
+
+/*!
+    \return true if visible
+    \sa setVisible(), show(), hide()
+*/
+bool QwtPolarItem::isVisible() const
+{
+    return d_data->isVisible;
+}
+
+/*!
+   Update the legend and call QwtPolarPlot::autoRefresh for the
+   parent plot.
+
+   \sa updateLegend()
+*/
+void QwtPolarItem::itemChanged()
+{
+    if ( d_data->plot )
+    {
+        if ( d_data->plot->legend() )
+            updateLegend( d_data->plot->legend() );
+
+        d_data->plot->autoRefresh();
+    }
+}
+
+/*!
+   Interval, that is necessary to display the item
+
+   This interval can be useful for operations like clipping or autoscaling
+   For items ( like the grid ), where a bounding interval makes no
+   sense an invalid interval is returned.
+
+   \param scaleId Scale id ( QwtPolar::Scale )
+   \return Bounding interval of the plot item for a specific scale
+*/
+QwtInterval QwtPolarItem::boundingInterval( int scaleId ) const
+{
+    Q_UNUSED( scaleId );
+
+    return QwtInterval(); // invalid
+}
+
+/*!
+   \brief Update the item to changes of the axes scale division
+
+   Update the item, when the axes of plot have changed.
+   The default implementation does nothing, but items that depend
+   on the scale division (like QwtPolarGrid()) have to reimplement
+   updateScaleDiv()
+
+   \param azimuthScaleDiv Scale division of the azimuth-scale
+   \param radialScaleDiv Scale division of the radius-axis
+   \param interval The interval of the radius-axis, that is
+                   visible on the canvas
+
+   \sa QwtPolarPlot::updateAxes()
+*/
+void QwtPolarItem::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
+    const QwtScaleDiv &radialScaleDiv, const QwtInterval &interval )
+{
+    Q_UNUSED( azimuthScaleDiv );
+    Q_UNUSED( radialScaleDiv );
+    Q_UNUSED( interval );
+}
+
+/*!
+   \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;
+}
+
+/*!
+   Some items like to display something (f.e. the azimuth axis) outside
+   of the area of the interval of the radial scale.
+   The default implementation returns 0 pixels
+
+   \return Hint for the margin
+*/
+int QwtPolarItem::marginHint() const
+{
+    return 0;
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_item.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_item.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_item.h	(revision 4272)
@@ -0,0 +1,176 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_ITEM_H
+#define QWT_POLAR_ITEM_H
+
+#include "qwt_polar_global.h"
+#include <qwt_text.h>
+#include <qwt_legend_itemmanager.h>
+#include <qwt_interval.h>
+
+class QString;
+class QRect;
+class QPointF;
+class QPainter;
+class QwtPolarPlot;
+class QwtScaleMap;
+class QwtScaleDiv;
+
+/*!
+  \brief Base class for items on a polar plot
+
+  A QwtPolarItem is "something that can be painted on the canvas".
+  It is connected to the QwtPolar framework by a couple of virtual
+  methods, that are individually implemented in derived item classes.
+
+  QwtPolar offers an implementation of the most common types of items,
+  but deriving from QwtPolarItem makes it easy to implement additional
+  types of items.
+*/
+class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
+{
+public:
+    /*!
+        \brief Runtime type information
+
+        RttiValues is used to cast plot items, without
+        having to enable runtime type information of the compiler.
+     */
+    enum RttiValues
+    {
+        //! Unspecific value, that can be used, when it doesn't matter
+        Rtti_PolarItem = 0,
+
+        //! For QwtPolarGrid
+        Rtti_PolarGrid,
+
+        //! For QwtPolarMarker
+        Rtti_PolarMarker,
+
+        //! For QwtPolarCurve
+        Rtti_PolarCurve,
+
+        //! For QwtPolarSpectrogram
+        Rtti_PolarSpectrogram,
+
+        /*! 
+           Values >= Rtti_PolarUserItem are reserved for plot items
+           not implemented in the QwtPolar library.
+         */
+        Rtti_PolarUserItem = 1000
+    };
+
+    /*!
+       \brief Plot Item Attributes
+       \sa setItemAttribute(), testItemAttribute()
+     */
+    enum ItemAttribute
+    {
+        //! The item is represented on the legend.
+        Legend    = 0x01,
+
+        /*!
+          The boundingRect() of the item is included in the
+          autoscaling calculation.
+         */
+        AutoScale = 0x02
+    };
+
+    //! Item attributes
+    typedef QFlags<ItemAttribute> ItemAttributes;
+
+    /*!
+       \brief Render hints
+       \sa setRenderHint(), testRenderHint()
+     */
+    enum RenderHint
+    {
+        //! Enable antialiasing
+        RenderAntialiased = 0x01
+    };
+
+    //! Item attributes
+    typedef QFlags<RenderHint> RenderHints;
+
+    explicit QwtPolarItem( const QwtText &title = QwtText() );
+    virtual ~QwtPolarItem();
+
+    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 ); }
+
+    QwtPolarPlot *plot() const;
+
+    void setTitle( const QString &title );
+    void setTitle( const QwtText &title );
+    const QwtText &title() const;
+
+    virtual int rtti() const;
+
+    void setItemAttribute( ItemAttribute, bool on = true );
+    bool testItemAttribute( ItemAttribute ) const;
+
+    void setRenderHint( RenderHint, bool on = true );
+    bool testRenderHint( RenderHint ) const;
+
+    double z() const;
+    void setZ( double z );
+
+    void show();
+    void hide();
+    virtual void setVisible( bool );
+    bool isVisible () const;
+
+    virtual void itemChanged();
+
+    /*!
+      \brief Draw the item
+
+      \param painter Painter
+      \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+      \param radialMap Maps radius values into painter coordinates.
+      \param pole Position of the pole in painter coordinates
+      \param radius Radius of the complete plot area in painter coordinates
+      \param canvasRect Contents rect of the canvas in painter coordinates
+    */
+    virtual void draw( QPainter *painter,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, double radius,
+        const QRectF &canvasRect ) const = 0;
+
+    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;
+
+private:
+    // Disabled copy constructor and operator=
+    QwtPolarItem( const QwtPolarItem & );
+    QwtPolarItem &operator=( const QwtPolarItem & );
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes )
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp	(revision 4272)
@@ -0,0 +1,169 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_itemdict.h"
+
+class QwtPolarItemDict::PrivateData
+{
+public:
+    class ItemList: public QList<QwtPolarItem *>
+    {
+    public:
+        void insertItem( QwtPolarItem *item )
+        {
+            if ( item == NULL )
+                return;
+
+            // Unfortunately there is no inSort operation
+            // for lists in Qt4. The implementation below
+            // is slow, but there shouldn't be many plot items.
+
+            QList<QwtPolarItem *>::Iterator it;
+            for ( it = begin(); it != end(); ++it )
+            {
+                if ( *it == item )
+                    return;
+
+                if ( ( *it )->z() > item->z() )
+                {
+                    insert( it, item );
+                    return;
+                }
+            }
+            append( item );
+        }
+
+        void removeItem( QwtPolarItem *item )
+        {
+            if ( item == NULL )
+                return;
+
+            int i = 0;
+
+            QList<QwtPolarItem *>::Iterator it;
+            for ( it = begin(); it != end(); ++it )
+            {
+                if ( item == *it )
+                {
+                    removeAt( i );
+                    return;
+                }
+                i++;
+            }
+        }
+    };
+
+    ItemList itemList;
+    bool autoDelete;
+};
+
+/*!
+   Constructor
+
+   Auto deletion is enabled.
+   \sa setAutoDelete, attachItem
+*/
+QwtPolarItemDict::QwtPolarItemDict()
+{
+    d_data = new QwtPolarItemDict::PrivateData;
+    d_data->autoDelete = true;
+}
+
+/*!
+   Destructor
+
+   If autoDelete is on, all attached items will be deleted
+   \sa setAutoDelete, autoDelete, attachItem
+*/
+QwtPolarItemDict::~QwtPolarItemDict()
+{
+    detachItems( QwtPolarItem::Rtti_PolarItem, d_data->autoDelete );
+    delete d_data;
+}
+
+/*!
+   En/Disable Auto deletion
+
+   If Auto deletion is on all attached plot items will be deleted
+   in the destructor of QwtPolarItemDict. The default value is on.
+
+   \sa autoDelete, attachItem
+*/
+void QwtPolarItemDict::setAutoDelete( bool autoDelete )
+{
+    d_data->autoDelete = autoDelete;
+}
+
+/*!
+   \return true if auto deletion is enabled
+   \sa setAutoDelete, attachItem
+*/
+bool QwtPolarItemDict::autoDelete() const
+{
+    return d_data->autoDelete;
+}
+
+/*!
+   Attach/Detach 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 Plot item to attach/detach
+   \ on If true attach, else detach the item
+
+   \sa setAutoDelete, ~QwtPolarItemDict
+*/
+void QwtPolarItemDict::attachItem( QwtPolarItem *item, bool on )
+{
+    if ( on )
+        d_data->itemList.insertItem( item );
+    else
+        d_data->itemList.removeItem( item );
+}
+
+/*!
+   Detach items from the dictionary
+
+   \param rtti In case of QwtPolarItem::Rtti_PlotItem detach all items
+               otherwise only those items of the type rtti.
+   \param autoDelete If true, delete all detached items
+*/
+void QwtPolarItemDict::detachItems( int rtti, bool autoDelete )
+{
+    PrivateData::ItemList list = d_data->itemList;
+    QwtPolarItemIterator it = list.begin();
+    while ( it != list.end() )
+    {
+        QwtPolarItem *item = *it;
+
+        ++it; // increment before removing item from the list
+
+        if ( rtti == QwtPolarItem::Rtti_PolarItem || item->rtti() == rtti )
+        {
+            item->attach( NULL );
+            if ( autoDelete )
+                delete item;
+        }
+    }
+}
+
+/*!
+  \brief A QwtPolarItemList of all attached plot items.
+
+  \return List of all attached plot items.
+  \note Use caution when iterating these lists, as removing/detaching
+        an item will invalidate the iterator.
+        Instead you can place pointers to objects to be
+        removed in a removal list, and traverse that list later.
+*/
+const QwtPolarItemList &QwtPolarItemDict::itemList() const
+{
+    return d_data->itemList;
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_itemdict.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_itemdict.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_itemdict.h	(revision 4272)
@@ -0,0 +1,55 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_ITEMDICT_H
+#define QWT_POLAR_ITEMDICT_H
+
+/*! \file !*/
+
+#include "qwt_polar_global.h"
+#include "qwt_polar_item.h"
+#include <qlist.h>
+
+typedef QList<QwtPolarItem *>::ConstIterator QwtPolarItemIterator;
+/// \var typedef QList< QwtPolarItem *> QwtPolarItemList
+/// \brief See QT 4.x assistant documentation for QList
+typedef QList<QwtPolarItem *> QwtPolarItemList;
+
+/*!
+  \brief A dictionary for polar plot items
+
+  QwtPolarItemDict organizes polar plot items in increasing z-order.
+  If autoDelete() is enabled, all attached items will be deleted
+  in the destructor of the dictionary.
+
+  \sa QwtPolarItem::attach(), QwtPolarItem::detach(), QwtPolarItem::z()
+*/
+class QWT_POLAR_EXPORT QwtPolarItemDict
+{
+public:
+    explicit QwtPolarItemDict();
+    ~QwtPolarItemDict();
+
+    void setAutoDelete( bool );
+    bool autoDelete() const;
+
+    const QwtPolarItemList& itemList() const;
+
+    void detachItems( int rtti = QwtPolarItem::Rtti_PolarItem,
+        bool autoDelete = true );
+
+private:
+    friend class QwtPolarItem;
+
+    void attachItem( QwtPolarItem *, bool );
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_layout.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_layout.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_layout.cpp	(revision 4272)
@@ -0,0 +1,444 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_layout.h"
+#include "qwt_polar_plot.h"
+#include "qwt_polar_canvas.h"
+#include <qwt_text.h>
+#include <qwt_text_label.h>
+#include <qwt_legend.h>
+#include <qscrollbar.h>
+
+class QwtPolarLayout::LayoutData
+{
+public:
+    void init( const QwtPolarPlot *, const QRectF &rect );
+
+    struct t_legendData
+    {
+        int frameWidth;
+        int vScrollBarWidth;
+        int hScrollBarHeight;
+        QSizeF hint;
+    } legend;
+
+    struct t_titleData
+    {
+        QwtText text;
+        int frameWidth;
+    } title;
+
+    struct t_canvasData
+    {
+        int frameWidth;
+    } canvas;
+};
+
+void QwtPolarLayout::LayoutData::init(
+    const QwtPolarPlot *plot, const QRectF &rect )
+{
+    // legend
+
+    if ( plot->plotLayout()->legendPosition() != QwtPolarPlot::ExternalLegend
+            && plot->legend() )
+    {
+        legend.frameWidth = plot->legend()->frameWidth();
+        legend.vScrollBarWidth =
+            plot->legend()->verticalScrollBar()->sizeHint().width();
+        legend.hScrollBarHeight =
+            plot->legend()->horizontalScrollBar()->sizeHint().height();
+
+        const QSizeF hint = plot->legend()->sizeHint();
+
+        double w = qMin( hint.width(), rect.width() );
+        double h = plot->legend()->heightForWidth( w );
+        if ( h == 0.0 )
+            h = hint.height();
+
+        if ( h > rect.height() )
+            w += legend.vScrollBarWidth;
+
+        legend.hint = QSizeF( w, h );
+    }
+
+    // title
+
+    title.frameWidth = 0;
+    title.text = QwtText();
+
+    if ( plot->titleLabel() )
+    {
+        const QwtTextLabel *label = plot->titleLabel();
+        title.text = label->text();
+        if ( !( title.text.testPaintAttribute( QwtText::PaintUsingTextFont ) ) )
+            title.text.setFont( label->font() );
+
+        title.frameWidth = plot->titleLabel()->frameWidth();
+    }
+
+    // canvas
+
+    canvas.frameWidth = plot->canvas()->frameWidth();
+}
+
+class QwtPolarLayout::PrivateData
+{
+public:
+    PrivateData():
+        margin( 0 ),
+        spacing( 0 )
+    {
+    }
+
+    QRectF titleRect;
+    QRectF legendRect;
+    QRectF canvasRect;
+
+    QwtPolarLayout::LayoutData layoutData;
+
+    QwtPolarPlot::LegendPosition legendPos;
+    double legendRatio;
+
+    unsigned int margin;
+    unsigned int spacing;
+};
+
+/*!
+  \brief Constructor
+ */
+
+QwtPolarLayout::QwtPolarLayout()
+{
+    d_data = new PrivateData;
+
+    setLegendPosition( QwtPolarPlot::BottomLegend );
+    invalidate();
+}
+
+//! Destructor
+QwtPolarLayout::~QwtPolarLayout()
+{
+    delete d_data;
+}
+
+/*!
+  \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
+               if it would need more space than the given ratio.
+               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
+               it will be reset to the default ratio.
+               The default vertical/horizontal ratio is 0.33/0.5.
+
+  \sa QwtPolarPlot::setLegendPosition()
+*/
+
+void QwtPolarLayout::setLegendPosition(
+    QwtPolarPlot::LegendPosition pos, double ratio )
+{
+    if ( ratio > 1.0 )
+        ratio = 1.0;
+
+    switch( pos )
+    {
+        case QwtPolarPlot::TopLegend:
+        case QwtPolarPlot::BottomLegend:
+        {
+            if ( ratio <= 0.0 )
+                ratio = 0.33;
+            d_data->legendRatio = ratio;
+            d_data->legendPos = pos;
+            break;
+        }
+        case QwtPolarPlot::LeftLegend:
+        case QwtPolarPlot::RightLegend:
+        {
+            if ( ratio <= 0.0 )
+                ratio = 0.5;
+            d_data->legendRatio = ratio;
+            d_data->legendPos = pos;
+            break;
+        }
+        case QwtPolarPlot::ExternalLegend:
+        {
+            d_data->legendRatio = ratio; // meaningless
+            d_data->legendPos = pos;
+            break;
+        }
+        default:
+            break;
+    }
+}
+
+/*!
+  \brief Specify the position of the legend
+  \param pos The legend's position. Valid values are
+      \c QwtPolarPlot::LeftLegend, \c QwtPolarPlot::RightLegend,
+      \c QwtPolarPlot::TopLegend, \c QwtPolarPlot::BottomLegend.
+
+  \sa QwtPolarPlot::setLegendPosition()
+*/
+void QwtPolarLayout::setLegendPosition( QwtPolarPlot::LegendPosition pos )
+{
+    setLegendPosition( pos, 0.0 );
+}
+
+/*!
+  \return Position of the legend
+  \sa setLegendPosition(), QwtPolarPlot::setLegendPosition(),
+      QwtPolarPlot::legendPosition()
+*/
+QwtPolarPlot::LegendPosition QwtPolarLayout::legendPosition() const
+{
+    return d_data->legendPos;
+}
+
+/*!
+  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
+               if it would need more space than the given ratio.
+               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
+               it will be reset to the default ratio.
+               The default vertical/horizontal ratio is 0.33/0.5.
+*/
+void QwtPolarLayout::setLegendRatio( double ratio )
+{
+    setLegendPosition( legendPosition(), ratio );
+}
+
+/*!
+  \return The relative size of the legend in the plot.
+  \sa setLegendPosition()
+*/
+double QwtPolarLayout::legendRatio() const
+{
+    return d_data->legendRatio;
+}
+
+/*!
+  \return Geometry for the title
+  \sa activate(), invalidate()
+*/
+
+const QRectF &QwtPolarLayout::titleRect() const
+{
+    return d_data->titleRect;
+}
+
+/*!
+  \return Geometry for the legend
+  \sa activate(), invalidate()
+*/
+
+const QRectF &QwtPolarLayout::legendRect() const
+{
+    return d_data->legendRect;
+}
+
+/*!
+  \return Geometry for the canvas
+  \sa activate(), invalidate()
+*/
+const QRectF &QwtPolarLayout::canvasRect() const
+{
+    return d_data->canvasRect;
+}
+
+/*!
+  Invalidate the geometry of all components.
+  \sa activate()
+*/
+void QwtPolarLayout::invalidate()
+{
+    d_data->titleRect = d_data->legendRect = d_data->canvasRect = QRect();
+}
+
+/*!
+  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
+*/
+
+QRectF QwtPolarLayout::layoutLegend( Options options, QRectF &rect ) const
+{
+    const QSizeF hint( d_data->layoutData.legend.hint );
+
+    int dim;
+    if ( d_data->legendPos == QwtPolarPlot::LeftLegend
+        || d_data->legendPos == QwtPolarPlot::RightLegend )
+    {
+        // We don't allow vertical legends to take more than
+        // half of the available space.
+
+        dim = qMin( hint.width(), rect.width() * d_data->legendRatio );
+
+        if ( !( options & IgnoreScrollbars ) )
+        {
+            if ( hint.height() > rect.height() )
+            {
+                // The legend will need additional
+                // space for the vertical scrollbar.
+
+                dim += d_data->layoutData.legend.vScrollBarWidth;
+            }
+        }
+    }
+    else
+    {
+        dim = qMin( hint.height(), rect.height() * d_data->legendRatio );
+        dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
+    }
+
+    QRectF legendRect = rect;
+    switch( d_data->legendPos )
+    {
+        case QwtPolarPlot::LeftLegend:
+        {
+            legendRect.setWidth( dim );
+            rect.setLeft( legendRect.right() );
+            break;
+        }
+        case QwtPolarPlot::RightLegend:
+        {
+            legendRect.setX( rect.right() - dim + 1 );
+            legendRect.setWidth( dim );
+            rect.setRight( legendRect.left() );
+            break;
+        }
+        case QwtPolarPlot::TopLegend:
+        {
+            legendRect.setHeight( dim );
+            rect.setTop( legendRect.bottom() );
+            break;
+        }
+        case QwtPolarPlot::BottomLegend:
+        {
+            legendRect.setY( rect.bottom() - dim + 1 );
+            legendRect.setHeight( dim );
+            rect.setBottom( legendRect.top() );
+            break;
+        }
+        case QwtPolarPlot::ExternalLegend:
+            break;
+    }
+
+    return legendRect;
+}
+
+/*!
+  \brief Recalculate the geometry of all components.
+
+  \param plot Plot to be layout
+  \param boundingRect Rect where to place the components
+  \param options Options
+
+  \sa invalidate(), titleRect(), legendRect(), canvasRect()
+*/
+void QwtPolarLayout::activate( const QwtPolarPlot *plot,
+    const QRectF &boundingRect, Options options )
+{
+    invalidate();
+
+    QRectF rect( boundingRect ); // undistributed rest of the plot rect
+    rect.adjust( d_data->margin, d_data->margin,
+        -d_data->margin, -d_data->margin );
+
+    // We extract all layout relevant data from the widgets
+    // and save them to d_data->layoutData.
+
+    d_data->layoutData.init( plot, rect );
+    if ( !( options & IgnoreLegend )
+        && d_data->legendPos != QwtPolarPlot::ExternalLegend
+        && plot->legend() && !plot->legend()->isEmpty() )
+    {
+        d_data->legendRect = layoutLegend( options, rect );
+        if ( d_data->layoutData.legend.frameWidth &&
+                !( options & IgnoreFrames ) )
+        {
+            // In case of a frame we have to insert a spacing.
+            // Otherwise the leading of the font separates
+            // legend and scale/canvas
+
+            switch( d_data->legendPos )
+            {
+                case QwtPolarPlot::LeftLegend:
+                    rect.setLeft( rect.left() + d_data->spacing );
+                    break;
+
+                case QwtPolarPlot::RightLegend:
+                    rect.setRight( rect.right() - d_data->spacing );
+                    break;
+
+                case QwtPolarPlot::TopLegend:
+                    rect.setTop( rect.top() + d_data->spacing );
+                    break;
+
+                case QwtPolarPlot::BottomLegend:
+                    rect.setBottom( rect.bottom() - d_data->spacing );
+                    break;
+
+                case QwtPolarPlot::ExternalLegend:
+                    break; // suppress compiler warning
+            }
+        }
+    }
+
+    if ( !( options & IgnoreTitle ) &&
+        !d_data->layoutData.title.text.isEmpty() )
+    {
+        int h = d_data->layoutData.title.text.heightForWidth( rect.width() );
+        if ( !( options & IgnoreFrames ) )
+            h += 2 * d_data->layoutData.title.frameWidth;
+
+        d_data->titleRect = QRectF( rect.x(), rect.y(), rect.width(), h );
+
+        // subtract title
+        rect.setTop( rect.top() + h + d_data->spacing );
+    }
+
+    if ( plot->zoomPos().radius() > 0.0 || plot->zoomFactor() < 1.0 )
+    {
+        // In zoomed state we have no idea about the geometry that
+        // is best for the plot. So we use the complete rectangle
+        // accepting, that there might a lot of space wasted
+        // around the plot.
+
+        d_data->canvasRect = rect;
+    }
+    else
+    {
+        // In full state we know, that we want
+        // to display something circular.
+
+        const int dim = qMin( rect.width(), rect.height() );
+
+        d_data->canvasRect.setX( rect.center().x() - dim / 2 );
+        d_data->canvasRect.setY( rect.y() );
+        d_data->canvasRect.setSize( QSize( dim, dim ) );
+    }
+
+    if ( !d_data->legendRect.isEmpty() )
+    {
+        if ( d_data->legendPos == QwtPolarPlot::LeftLegend
+            || d_data->legendPos == QwtPolarPlot::RightLegend )
+        {
+            // We prefer to align the legend to the canvas - not to
+            // the complete plot - if possible.
+
+            if ( d_data->layoutData.legend.hint.height()
+                    < d_data->canvasRect.height() )
+            {
+                d_data->legendRect.setY( d_data->canvasRect.y() );
+                d_data->legendRect.setHeight( d_data->canvasRect.height() );
+            }
+        }
+    }
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_layout.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_layout.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_layout.h	(revision 4272)
@@ -0,0 +1,78 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_LAYOUT_H
+#define QWT_POLAR_LAYOUT_H
+
+#include "qwt_polar_global.h"
+#include "qwt_polar_plot.h"
+
+/*!
+  \brief Layout class for QwtPolarPlot.
+
+  Organizes the geometry for the different QwtPolarPlot components.
+  It is used by the QwtPolar widget to organize its internal widgets
+  or by QwtPolarRnderer to render its content to a QPaintDevice like
+  a QPrinter, QPixmap/QImage or QSvgRenderer.
+*/
+
+class QWT_POLAR_EXPORT QwtPolarLayout
+{
+public:
+
+    //! \brief Options to configure the plot layout engine
+    enum Option
+    {
+        //! Ignore the dimension of the scrollbars.
+        IgnoreScrollbars = 0x01,
+
+        //! Ignore all frames.
+        IgnoreFrames     = 0x02,
+
+        //! Ignore the title.
+        IgnoreTitle      = 0x04,
+
+        //! Ignore the legend.
+        IgnoreLegend     = 0x08
+    };
+
+    //! Options to configure the plot layout engine
+    typedef QFlags<Option> Options;
+
+    explicit QwtPolarLayout();
+    virtual ~QwtPolarLayout();
+
+    void setLegendPosition( QwtPolarPlot::LegendPosition pos, double ratio );
+    void setLegendPosition( QwtPolarPlot::LegendPosition pos );
+    QwtPolarPlot::LegendPosition legendPosition() const;
+
+    void setLegendRatio( double ratio );
+    double legendRatio() const;
+
+    virtual void activate( const QwtPolarPlot *,
+        const QRectF &rect, Options options = 0 );
+
+    virtual void invalidate();
+
+    const QRectF &titleRect() const;
+    const QRectF &legendRect() const;
+    const QRectF &canvasRect() const;
+
+    class LayoutData;
+
+protected:
+    QRectF layoutLegend( Options options, QRectF & ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarLayout::Options )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_magnifier.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_magnifier.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_magnifier.cpp	(revision 4272)
@@ -0,0 +1,167 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_magnifier.h"
+#include "qwt_polar_plot.h"
+#include "qwt_polar_canvas.h"
+#include <qwt_scale_div.h>
+#include <qwt_point_polar.h>
+#include <qevent.h>
+
+class QwtPolarMagnifier::PrivateData
+{
+public:
+    PrivateData():
+        unzoomKey( Qt::Key_Home ),
+        unzoomKeyModifiers( Qt::NoModifier )
+    {
+    }
+
+    int unzoomKey;
+    int unzoomKeyModifiers;
+};
+
+/*!
+   Constructor
+   \param canvas Plot canvas to be magnified
+*/
+QwtPolarMagnifier::QwtPolarMagnifier( QwtPolarCanvas *canvas ):
+    QwtMagnifier( canvas )
+{
+    d_data = new PrivateData();
+}
+
+//! Destructor
+QwtPolarMagnifier::~QwtPolarMagnifier()
+{
+    delete d_data;
+}
+
+/*!
+   Assign key and modifiers, that are used for unzooming
+   The default combination is Qt::Key_Home + Qt::NoModifier.
+
+   \param key Key code
+   \param modifiers Modifiers
+   \sa getUnzoomKey(), QwtPolarPlot::unzoom()
+*/
+void QwtPolarMagnifier::setUnzoomKey( int key, int modifiers )
+{
+    d_data->unzoomKey = key;
+    d_data->unzoomKeyModifiers = modifiers;
+}
+
+/*!
+   \return Key, and modifiers that are used for unzooming
+
+   \param key Key code
+   \param modifiers Modifiers
+   \sa setUnzoomKey(), QwtPolarPlot::unzoom()
+*/
+void QwtPolarMagnifier::getUnzoomKey( int &key, int &modifiers ) const
+{
+    key = d_data->unzoomKey;
+    modifiers = d_data->unzoomKeyModifiers;
+}
+
+//! \return Observed plot canvas
+QwtPolarCanvas *QwtPolarMagnifier::canvas()
+{
+    return qobject_cast<QwtPolarCanvas *>( parent() );
+}
+
+//! \return Observed plot canvas
+const QwtPolarCanvas *QwtPolarMagnifier::canvas() const
+{
+    return qobject_cast<QwtPolarCanvas *>( parent() );
+}
+
+//! \return Observed plot
+QwtPolarPlot *QwtPolarMagnifier::plot()
+{
+    QwtPolarCanvas *c = canvas();
+    if ( c )
+        return c->plot();
+
+    return NULL;
+}
+
+//! \return observed plot
+const QwtPolarPlot *QwtPolarMagnifier::plot() const
+{
+    const QwtPolarCanvas *c = canvas();
+    if ( c )
+        return c->plot();
+
+    return NULL;
+}
+
+/*!
+  Handle a key press event for the observed widget.
+
+  \param event Key event
+*/
+void QwtPolarMagnifier::widgetKeyPressEvent( QKeyEvent *event )
+{
+    const int key = event->key();
+    const int state = event->modifiers();
+
+    if ( key == d_data->unzoomKey &&
+        state == d_data->unzoomKeyModifiers )
+    {
+        unzoom();
+        return;
+    }
+
+    QwtMagnifier::widgetKeyPressEvent( event );
+}
+
+/*!
+   Zoom in/out the zoomed area
+   \param factor A value < 1.0 zooms in, a value > 1.0 zooms out.
+*/
+void QwtPolarMagnifier::rescale( double factor )
+{
+    factor = qAbs( factor );
+    if ( factor == 1.0 || factor == 0.0 )
+        return;
+
+    QwtPolarPlot* plt = plot();
+    if ( plt == NULL )
+        return;
+
+    QwtPointPolar zoomPos;
+    double newZoomFactor = plt->zoomFactor() * factor;
+
+    if ( newZoomFactor >= 1.0 )
+        newZoomFactor = 1.0;
+    else
+        zoomPos = plt->zoomPos();
+
+    const bool autoReplot = plt->autoReplot();
+    plt->setAutoReplot( false );
+
+    plt->zoom( zoomPos, newZoomFactor );
+
+    plt->setAutoReplot( autoReplot );
+    plt->replot();
+}
+
+//! Unzoom the plot widget
+void QwtPolarMagnifier::unzoom()
+{
+    QwtPolarPlot* plt = plot();
+
+    const bool autoReplot = plt->autoReplot();
+    plt->setAutoReplot( false );
+
+    plt->unzoom();
+
+    plt->setAutoReplot( autoReplot );
+    plt->replot();
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_magnifier.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_magnifier.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_magnifier.h	(revision 4272)
@@ -0,0 +1,58 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_MAGNIFIER_H
+#define QWT_POLAR_MAGNIFIER_H 1
+
+#include "qwt_polar_global.h"
+#include "qwt_magnifier.h"
+
+class QwtPolarPlot;
+class QwtPolarCanvas;
+
+/*!
+  \brief QwtPolarMagnifier provides zooming, by magnifying in steps.
+
+  Using QwtPlotMagnifier a plot can be zoomed in/out in steps using
+  keys, the mouse wheel or moving a mouse button in vertical direction.
+
+  Together with QwtPolarPanner it is possible to implement
+  an individual navigation of the plot canvas.
+
+  \sa QwtPolarPanner, QwtPolarPlot, QwtPolarCanvas
+*/
+
+class QWT_POLAR_EXPORT QwtPolarMagnifier: public QwtMagnifier
+{
+    Q_OBJECT
+
+public:
+    explicit QwtPolarMagnifier( QwtPolarCanvas * );
+    virtual ~QwtPolarMagnifier();
+
+    void setUnzoomKey( int key, int modifiers );
+    void getUnzoomKey( int &key, int &modifiers ) const;
+
+    QwtPolarPlot *plot();
+    const QwtPolarPlot *plot() const;
+
+    QwtPolarCanvas *canvas();
+    const QwtPolarCanvas *canvas() const;
+
+protected:
+    virtual void rescale( double factor );
+    void unzoom();
+
+    virtual void widgetKeyPressEvent( QKeyEvent * );
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_marker.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_marker.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_marker.cpp	(revision 4272)
@@ -0,0 +1,233 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_marker.h"
+#include "qwt_polar.h"
+#include <qwt_scale_map.h>
+#include <qwt_symbol.h>
+#include <qwt_text.h>
+#include <qpainter.h>
+
+static const int LabelDist = 2;
+
+class QwtPolarMarker::PrivateData
+{
+public:
+    PrivateData():
+        align( Qt::AlignCenter )
+    {
+        symbol = new QwtSymbol();
+    }
+
+    ~PrivateData()
+    {
+        delete symbol;
+    }
+
+    QwtText label;
+    Qt::Alignment align;
+    QPen pen;
+    const QwtSymbol *symbol;
+
+    QwtPointPolar pos;
+};
+
+//! Sets alignment to Qt::AlignCenter, and style to NoLine
+QwtPolarMarker::QwtPolarMarker():
+    QwtPolarItem( QwtText( "Marker" ) )
+{
+    d_data = new PrivateData;
+
+    setItemAttribute( QwtPolarItem::AutoScale );
+    setZ( 30.0 );
+}
+
+//! Destructor
+QwtPolarMarker::~QwtPolarMarker()
+{
+    delete d_data;
+}
+
+//! \return QwtPolarItem::Rtti_PlotMarker
+int QwtPolarMarker::rtti() const
+{
+    return QwtPolarItem::Rtti_PolarMarker;
+}
+
+//! \return Position of the marker
+QwtPointPolar QwtPolarMarker::position() const
+{
+    return d_data->pos;
+}
+
+//! Change the position of the marker
+void QwtPolarMarker::setPosition( const QwtPointPolar &pos )
+{
+    if ( d_data->pos != pos )
+    {
+        d_data->pos = pos;
+        itemChanged();
+    }
+}
+
+/*!
+  Draw the marker
+
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param radius Radius of the complete plot area in painter coordinates
+  \param canvasRect Contents rect of the canvas in painter coordinates
+*/
+void QwtPolarMarker::draw( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double radius,
+    const QRectF &canvasRect ) const
+{
+    Q_UNUSED( radius );
+    Q_UNUSED( canvasRect );
+
+    const double r = radialMap.transform( d_data->pos.radius() );
+    const double a = azimuthMap.transform( d_data->pos.azimuth() );
+
+    const QPointF pos = qwtPolar2Pos( pole, r, a );
+
+
+    // draw symbol
+    QSize sSym( 0, 0 );
+    if ( d_data->symbol->style() != QwtSymbol::NoSymbol )
+    {
+        sSym = d_data->symbol->size();
+        d_data->symbol->drawSymbol( painter, pos );
+    }
+
+    // draw label
+    if ( !d_data->label.isEmpty() )
+    {
+        int xlw = qMax( int( d_data->pen.width() ), 1 );
+        int ylw = xlw;
+
+        int xlw1 = qMax( ( xlw + 1 ) / 2, ( sSym.width() + 1 ) / 2 ) + LabelDist;
+        xlw = qMax( xlw / 2, ( sSym.width() + 1 ) / 2 ) + LabelDist;
+        int ylw1 = qMax( ( ylw + 1 ) / 2, ( sSym.height() + 1 ) / 2 ) + LabelDist;
+        ylw = qMax( ylw / 2, ( sSym. height() + 1 ) / 2 ) + LabelDist;
+
+        QRect tr( QPoint( 0, 0 ), d_data->label.textSize( painter->font() ).toSize() );
+        tr.moveCenter( QPoint( 0, 0 ) );
+
+        int dx = pos.x();
+        int dy = pos.y();
+
+        if ( d_data->align & Qt::AlignTop )
+            dy += tr.y() - ylw1;
+        else if ( d_data->align & Qt::AlignBottom )
+            dy -= tr.y() - ylw1;
+
+        if ( d_data->align & Qt::AlignLeft )
+            dx += tr.x() - xlw1;
+        else if ( d_data->align & Qt::AlignRight )
+            dx -= tr.x() - xlw1;
+
+        tr.translate( dx, dy );
+        d_data->label.draw( painter, tr );
+    }
+}
+
+/*!
+  \brief Assign a symbol
+  \param symbol New symbol
+  \sa symbol()
+*/
+void QwtPolarMarker::setSymbol( const QwtSymbol *symbol )
+{
+    if ( d_data->symbol != symbol )
+    {
+        delete d_data->symbol;
+        d_data->symbol = symbol;
+        itemChanged();
+    }
+}
+
+/*!
+  \return the symbol
+  \sa setSymbol(), QwtSymbol
+*/
+const QwtSymbol *QwtPolarMarker::symbol() const
+{
+    return d_data->symbol;
+}
+
+/*!
+  \brief Set the label
+  \param label label text
+  \sa label()
+*/
+void QwtPolarMarker::setLabel( const QwtText& label )
+{
+    if ( label != d_data->label )
+    {
+        d_data->label = label;
+        itemChanged();
+    }
+}
+
+/*!
+  \return the label
+  \sa setLabel()
+*/
+QwtText QwtPolarMarker::label() const
+{
+    return d_data->label;
+}
+
+/*!
+  \brief Set the alignment of the label
+
+  The alignment determines where the label is drawn relative to
+  the marker's position.
+
+  \param align Alignment. A combination of AlignTop, AlignBottom,
+    AlignLeft, AlignRight, AlignCenter, AlgnHCenter,
+    AlignVCenter.
+  \sa labelAlignment()
+*/
+void QwtPolarMarker::setLabelAlignment( Qt::Alignment align )
+{
+    if ( align == d_data->align )
+        return;
+
+    d_data->align = align;
+    itemChanged();
+}
+
+/*!
+  \return the label alignment
+  \sa setLabelAlignment()
+*/
+Qt::Alignment QwtPolarMarker::labelAlignment() const
+{
+    return d_data->align;
+}
+
+/*!
+   Interval, that is necessary to display the item
+   This interval can be useful for operations like clipping or autoscaling
+
+   \param scaleId Scale index
+   \return bounding interval ( == position )
+
+   \sa position()
+*/
+QwtInterval QwtPolarMarker::boundingInterval( int scaleId ) const
+{
+    const double v = ( scaleId == QwtPolar::ScaleRadius )
+        ? d_data->pos.radius() : d_data->pos.azimuth();
+
+    return QwtInterval( v, v );
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_marker.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_marker.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_marker.h	(revision 4272)
@@ -0,0 +1,70 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_MARKER_H
+#define QWT_POLAR_MARKER_H
+
+#include "qwt_polar_global.h"
+#include "qwt_polar_item.h"
+#include <qwt_point_polar.h>
+#include <qstring.h>
+
+class QRect;
+class QwtText;
+class QwtSymbol;
+
+/*!
+  \brief A class for drawing markers
+
+  A marker can be a a symbol, a label or a combination of them, which can
+  be drawn around a center point inside a bounding rectangle.
+
+  The setSymbol() member assigns a symbol to the marker.
+  The symbol is drawn at the specified point.
+
+  With setLabel(), a label can be assigned to the marker.
+  The setLabelAlignment() member specifies where the label is
+  drawn. All the Align*-constants in Qt::AlignmentFlags (see Qt documentation)
+  are valid. The alignment refers to the center point of
+  the marker, which means, for example, that the label would be painted
+  left above the center point if the alignment was set to AlignLeft|AlignTop.
+*/
+
+class QWT_POLAR_EXPORT QwtPolarMarker: public QwtPolarItem
+{
+public:
+    explicit QwtPolarMarker();
+    virtual ~QwtPolarMarker();
+
+    virtual int rtti() const;
+
+    void setPosition( const QwtPointPolar & );
+    QwtPointPolar position() const;
+
+    void setSymbol( const QwtSymbol *s );
+    const QwtSymbol *symbol() const;
+
+    void setLabel( const QwtText& );
+    QwtText label() const;
+
+    void setLabelAlignment( Qt::Alignment );
+    Qt::Alignment labelAlignment() const;
+
+    virtual void draw( QPainter *painter,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, double radius,
+        const QRectF &canvasRect ) const;
+
+    virtual QwtInterval boundingInterval( int scaleId ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_panner.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_panner.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_panner.cpp	(revision 4272)
@@ -0,0 +1,118 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_panner.h"
+#include "qwt_polar_plot.h"
+#include "qwt_polar_canvas.h"
+#include <qwt_scale_div.h>
+#include <qwt_point_polar.h>
+
+//! Create a plot panner for a polar plot canvas
+QwtPolarPanner::QwtPolarPanner( QwtPolarCanvas *canvas ):
+    QwtPanner( canvas )
+{
+    connect( this, SIGNAL( panned( int, int ) ),
+        SLOT( movePlot( int, int ) ) );
+}
+
+//! Destructor
+QwtPolarPanner::~QwtPolarPanner()
+{
+}
+
+//! \return observed plot canvas
+QwtPolarCanvas *QwtPolarPanner::canvas()
+{
+    return qobject_cast<QwtPolarCanvas *>( parent() );
+}
+
+//! \return observed plot canvas
+const QwtPolarCanvas *QwtPolarPanner::canvas() const
+{
+    return qobject_cast<const QwtPolarCanvas *>( parent() );
+}
+
+//! \return observed plot
+QwtPolarPlot *QwtPolarPanner::plot()
+{
+    QwtPolarCanvas *c = canvas();
+    if ( c )
+        return c->plot();
+
+    return NULL;
+}
+
+//! \return observed plot
+const QwtPolarPlot *QwtPolarPanner::plot() const
+{
+    const QwtPolarCanvas *c = canvas();
+    if ( c )
+        return c->plot();
+
+    return NULL;
+}
+
+/*!
+   Adjust the zoomed area according to dx/dy
+
+   \param dx Pixel offset in x direction
+   \param dy Pixel offset in y direction
+
+   \sa QwtPanner::panned(), QwtPolarPlot::zoom()
+*/
+void QwtPolarPanner::movePlot( int dx, int dy )
+{
+    QwtPolarPlot *plot = QwtPolarPanner::plot();
+    if ( plot == NULL || ( dx == 0 && dy == 0 ) )
+        return;
+
+    const QwtScaleMap map = plot->scaleMap( QwtPolar::Radius );
+
+    QwtPointPolar pos = plot->zoomPos();
+    if ( map.s1() <= map.s2() )
+    {
+        pos.setRadius(
+            map.transform( map.s1() + pos.radius() ) - map.p1() );
+        pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
+        pos.setRadius(
+            map.invTransform( map.p1() + pos.radius() ) - map.s1() );
+    }
+    else
+    {
+        pos.setRadius(
+            map.transform( map.s1() - pos.radius() ) - map.p1() );
+        pos.setPoint( pos.toPoint() - QPointF( dx, -dy ) );
+        pos.setRadius(
+            map.s1() - map.invTransform( map.p1() + pos.radius() ) );
+    }
+
+    const bool doAutoReplot = plot->autoReplot();
+    plot->setAutoReplot( false );
+
+    plot->zoom( pos, plot->zoomFactor() );
+
+    plot->setAutoReplot( doAutoReplot );
+    plot->replot();
+}
+
+/*!
+  Block panning when the plot zoom factor is >= 1.0.
+
+  \param event Mouse event
+*/
+void QwtPolarPanner::widgetMousePressEvent( QMouseEvent *event )
+{
+    const QwtPolarPlot *plot = QwtPolarPanner::plot();
+    if ( plot )
+    {
+        if ( plot->zoomFactor() < 1.0 )
+            QwtPanner::widgetMousePressEvent( event );
+    }
+}
+
+
Index: /trunk/BNC/qwtpolar/qwt_polar_panner.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_panner.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_panner.h	(revision 4272)
@@ -0,0 +1,52 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_PANNER_H
+#define QWT_POLAR_PANNER_H 1
+
+#include "qwt_polar_global.h"
+#include "qwt_panner.h"
+
+class QwtPolarPlot;
+class QwtPolarCanvas;
+
+/*!
+  \brief QwtPolarPanner provides panning of a polar plot canvas
+
+  QwtPolarPanner is a panner for a QwtPolarCanvas, that
+  adjusts the visible area after dropping
+  the canvas on its new position.
+
+  Together with QwtPolarMagnifier individual ways
+  of navigating on a QwtPolarPlot widget can be implemented easily.
+
+  \sa QwtPolarMagnifier
+*/
+
+class QWT_POLAR_EXPORT QwtPolarPanner: public QwtPanner
+{
+    Q_OBJECT
+
+public:
+    explicit QwtPolarPanner( QwtPolarCanvas * );
+    virtual ~QwtPolarPanner();
+
+    QwtPolarPlot *plot();
+    const QwtPolarPlot *plot() const;
+
+    QwtPolarCanvas *canvas();
+    const QwtPolarCanvas *canvas() const;
+
+protected Q_SLOTS:
+    virtual void movePlot( int dx, int dy );
+
+protected:
+    virtual void widgetMousePressEvent( QMouseEvent * );
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_picker.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_picker.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_picker.cpp	(revision 4272)
@@ -0,0 +1,246 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_picker.h"
+#include "qwt_polar_plot.h"
+#include "qwt_polar_canvas.h"
+#include <qwt_scale_map.h>
+#include <qwt_picker_machine.h>
+#include <qwt_point_polar.h>
+
+class QwtPolarPicker::PrivateData
+{
+public:
+    PrivateData()
+    {
+    }
+};
+
+/*!
+  \brief Create a polar plot picker
+  \param canvas Plot canvas to observe, also the parent object
+*/
+
+QwtPolarPicker::QwtPolarPicker( QwtPolarCanvas *canvas ):
+    QwtPicker( canvas )
+{
+    d_data = new PrivateData;
+}
+
+/*!
+  Create a plot picker
+
+  \param rubberBand Rubberband style
+  \param trackerMode Tracker mode
+  \param canvas Plot canvas to observe, also the parent object
+
+  \sa QwtPicker, QwtPicker::setSelectionFlags(), QwtPicker::setRubberBand(),
+      QwtPicker::setTrackerMode
+
+  \sa QwtPolarPlot::autoReplot(), QwtPolarPlot::replot(), scaleRect()
+*/
+QwtPolarPicker::QwtPolarPicker( 
+        RubberBand rubberBand, DisplayMode trackerMode,
+        QwtPolarCanvas *canvas ):
+    QwtPicker( rubberBand, trackerMode, canvas )
+{
+    d_data = new PrivateData;
+}
+
+//! Destructor
+QwtPolarPicker::~QwtPolarPicker()
+{
+    delete d_data;
+}
+
+//! \return Observed plot canvas
+QwtPolarCanvas *QwtPolarPicker::canvas()
+{
+    return qobject_cast<QwtPolarCanvas *>( parentWidget() );
+}
+
+//! \return Observed plot canvas
+const QwtPolarCanvas *QwtPolarPicker::canvas() const
+{
+    return qobject_cast<const QwtPolarCanvas *>( parentWidget() );
+}
+
+//! \return Plot widget, containing the observed plot canvas
+QwtPolarPlot *QwtPolarPicker::plot()
+{
+    QwtPolarCanvas *w = canvas();
+    if ( w )
+        return w->plot();
+
+    return NULL;
+}
+
+//! \return Plot widget, containing the observed plot canvas
+const QwtPolarPlot *QwtPolarPicker::plot() const
+{
+    const QwtPolarCanvas *w = canvas();
+    if ( w )
+        return w->plot();
+
+    return NULL;
+}
+
+/*!
+  Translate a pixel position into a position string
+
+  \param pos Position in pixel coordinates
+  \return Position string
+*/
+QwtText QwtPolarPicker::trackerText( const QPoint &pos ) const
+{
+    const QwtPointPolar polarPoint = invTransform( pos );
+    return trackerTextPolar( polarPoint );
+}
+
+/*!
+  \brief Translate a position into a position string
+
+  In case of HLineRubberBand the label is the value of the
+  y position, in case of VLineRubberBand the value of the x position.
+  Otherwise the label contains x and y position separated by a ',' .
+
+  The format for the double to string conversion is "%.4f".
+
+  \param pos Position
+  \return Position string
+*/
+QwtText QwtPolarPicker::trackerTextPolar( const QwtPointPolar &pos ) const
+{
+    QString text;
+    text.sprintf( "%.4f, %.4f", pos.radius(), pos.azimuth() );
+
+    return QwtText( text );
+}
+
+/*!
+  Append a point to the selection and update rubberband and tracker.
+
+  \param pos Additional point
+  \sa isActive, begin(), end(), move(), appended()
+
+  \note The appended(const QPoint &), appended(const QDoublePoint &)
+        signals are emitted.
+*/
+void QwtPolarPicker::append( const QPoint &pos )
+{
+    QwtPicker::append( pos );
+    Q_EMIT appended( invTransform( pos ) );
+}
+
+/*!
+  Move the last point of the selection
+
+  \param pos New position
+  \sa isActive, begin(), end(), append()
+
+  \note The moved(const QPoint &), moved(const QDoublePoint &)
+        signals are emitted.
+*/
+void QwtPolarPicker::move( const QPoint &pos )
+{
+    QwtPicker::move( pos );
+    Q_EMIT moved( invTransform( pos ) );
+}
+
+/*!
+  Close a selection setting the state to inactive.
+
+  \param ok If true, complete the selection and emit selected signals
+            otherwise discard the selection.
+  \return true if the selection is accepted, false otherwise
+*/
+
+bool QwtPolarPicker::end( bool ok )
+{
+    ok = QwtPicker::end( ok );
+    if ( !ok )
+        return false;
+
+    QwtPolarPlot *plot = QwtPolarPicker::plot();
+    if ( !plot )
+        return false;
+
+    const QPolygon points = selection();
+    if ( points.count() == 0 )
+        return false;
+
+    QwtPickerMachine::SelectionType selectionType =
+        QwtPickerMachine::NoSelection;
+
+    if ( stateMachine() )
+        selectionType = stateMachine()->selectionType();
+
+    switch ( selectionType )
+    {
+        case QwtPickerMachine::PointSelection:
+        {
+            const QwtPointPolar pos = invTransform( points[0] );
+            Q_EMIT selected( pos );
+            break;
+        }
+        case QwtPickerMachine::RectSelection:
+        case QwtPickerMachine::PolygonSelection:
+        {
+            QVector<QwtPointPolar> polarPoints( points.count() );
+            for ( int i = 0; i < points.count(); i++ )
+                polarPoints[i] = invTransform( points[i] );
+
+            Q_EMIT selected( polarPoints );
+        }
+        default:
+            break;
+    }
+
+    return true;
+}
+
+/*!
+    Translate a point from widget into plot coordinates
+
+    \param pos Point in widget coordinates of the plot canvas
+    \return Point in plot coordinates
+    \sa transform(), canvas()
+*/
+QwtPointPolar QwtPolarPicker::invTransform( const QPoint &pos ) const
+{
+    QwtPointPolar polarPos;
+    if ( canvas() == NULL )
+        return QwtPointPolar();
+
+    return canvas()->invTransform( pos );
+}
+
+/*!
+    \return Bounding rectangle of the region, where picking is
+            supported.
+*/
+QRect QwtPolarPicker::pickRect() const
+{
+    const QRect cr = canvas()->contentsRect();
+    const QRect pr = plot()->plotRect( cr ).toRect();
+
+    return cr & pr;
+}
+
+QPainterPath QwtPolarPicker::pickArea() const
+{
+    const QRect cr = canvas()->contentsRect();
+
+    QPainterPath crPath;
+    crPath.addRect( cr );
+
+    QPainterPath prPath;
+    prPath.addEllipse( plot()->plotRect( cr ) );
+
+    return crPath.intersected( prPath );
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_picker.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_picker.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_picker.h	(revision 4272)
@@ -0,0 +1,98 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_PICKER_H
+#define QWT_POLAR_PICKER_H
+
+#include "qwt_polar_global.h"
+#include "qwt_picker.h"
+#include <qvector.h>
+#include <qpainterpath.h>
+
+class QwtPolarPlot;
+class QwtPolarCanvas;
+class QwtPointPolar;
+
+/*!
+  \brief QwtPolarPicker provides selections on a plot canvas
+
+  QwtPolarPicker is a QwtPicker tailored for selections on
+  a polar plot canvas.
+*/
+
+class QWT_POLAR_EXPORT QwtPolarPicker: public QwtPicker
+{
+    Q_OBJECT
+
+public:
+    explicit QwtPolarPicker( QwtPolarCanvas * );
+    virtual ~QwtPolarPicker();
+
+    explicit QwtPolarPicker(
+        RubberBand rubberBand, DisplayMode trackerMode,
+        QwtPolarCanvas * );
+
+    QwtPolarPlot *plot();
+    const QwtPolarPlot *plot() const;
+
+    QwtPolarCanvas *canvas();
+    const QwtPolarCanvas *canvas() const;
+
+    virtual QRect pickRect() const;
+
+Q_SIGNALS:
+
+    /*!
+      A signal emitted in case of selectionFlags() & PointSelection.
+      \param pos Selected point
+    */
+    void selected( const QwtPointPolar &pos );
+
+    /*!
+      A signal emitting the selected points,
+      at the end of a selection.
+
+      \param points Selected points
+    */
+    void selected( const QVector<QwtPointPolar> &points );
+
+    /*!
+      A signal emitted when a point has been appended to the selection
+
+      \param pos Position of the appended point.
+      \sa append(). moved()
+    */
+    void appended( const QwtPointPolar &pos );
+
+    /*!
+      A signal emitted whenever the last appended point of the
+      selection has been moved.
+
+      \param pos Position of the moved last point of the selection.
+      \sa move(), appended()
+    */
+    void moved( const QwtPointPolar &pos );
+
+protected:
+    QwtPointPolar invTransform( const QPoint & ) const;
+
+    virtual QwtText trackerText( const QPoint & ) const;
+    virtual QwtText trackerTextPolar( const QwtPointPolar & ) const;
+
+    virtual void move( const QPoint & );
+    virtual void append( const QPoint & );
+    virtual bool end( bool ok = true );
+
+private:
+    virtual QPainterPath pickArea() const;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_plot.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_plot.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_plot.cpp	(revision 4272)
@@ -0,0 +1,1271 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_plot.h"
+#include "qwt_polar_canvas.h"
+#include "qwt_polar_layout.h"
+#include <qwt_painter.h>
+#include <qwt_scale_engine.h>
+#include <qwt_scale_div.h>
+#include <qwt_text_label.h>
+#include <qwt_round_scale_draw.h>
+#include <qwt_legend.h>
+#include <qwt_legend_item.h>
+#include <qwt_dyngrid_layout.h>
+#include <qpointer.h>
+#include <qpaintengine.h>
+#include <qpainter.h>
+#include <qevent.h>
+
+static inline double qwtDistance(
+    const QPointF &p1, const QPointF &p2 )
+{
+    double dx = p2.x() - p1.x();
+    double dy = p2.y() - p1.y();
+    return qSqrt( dx * dx + dy * dy );
+}
+
+class QwtPolarPlot::ScaleData
+{
+public:
+    ScaleData():
+        scaleEngine( NULL )
+    {
+    }
+
+    ~ScaleData()
+    {
+        delete scaleEngine;
+    }
+
+    bool doAutoScale;
+
+    double minValue;
+    double maxValue;
+    double stepSize;
+
+    int maxMajor;
+    int maxMinor;
+
+    QwtScaleDiv scaleDiv;
+    QwtScaleEngine *scaleEngine;
+};
+
+class QwtPolarPlot::PrivateData
+{
+public:
+    QBrush canvasBrush;
+
+    bool autoReplot;
+
+    QwtPointPolar zoomPos;
+    double zoomFactor;
+
+    ScaleData scaleData[QwtPolar::ScaleCount];
+    QPointer<QwtTextLabel> titleLabel;
+    QPointer<QwtPolarCanvas> canvas;
+    QPointer<QwtLegend> legend;
+    double azimuthOrigin;
+
+    QwtPolarLayout *layout;
+};
+
+/*!
+  Constructor
+  \param parent Parent widget
+ */
+QwtPolarPlot::QwtPolarPlot( QWidget *parent ):
+    QFrame( parent )
+{
+    initPlot( QwtText() );
+}
+
+/*!
+  Constructor
+  \param title Title text
+  \param parent Parent widget
+ */
+QwtPolarPlot::QwtPolarPlot( const QwtText &title, QWidget *parent ):
+    QFrame( parent )
+{
+    initPlot( title );
+}
+
+//! Destructor
+QwtPolarPlot::~QwtPolarPlot()
+{
+    detachItems( QwtPolarItem::Rtti_PolarItem, autoDelete() );
+
+    delete d_data->layout;
+    delete d_data;
+}
+
+/*!
+  Change the plot's title
+  \param title New title
+*/
+void QwtPolarPlot::setTitle( const QString &title )
+{
+    if ( title != d_data->titleLabel->text().text() )
+    {
+        d_data->titleLabel->setText( title );
+        if ( !title.isEmpty() )
+            d_data->titleLabel->show();
+        else
+            d_data->titleLabel->hide();
+    }
+}
+
+/*!
+  Change the plot's title
+  \param title New title
+*/
+void QwtPolarPlot::setTitle( const QwtText &title )
+{
+    if ( title != d_data->titleLabel->text() )
+    {
+        d_data->titleLabel->setText( title );
+        if ( !title.isEmpty() )
+            d_data->titleLabel->show();
+        else
+            d_data->titleLabel->hide();
+    }
+}
+
+//! \return the plot's title
+QwtText QwtPolarPlot::title() const
+{
+    return d_data->titleLabel->text();
+}
+
+//! \return the plot's title
+QwtTextLabel *QwtPolarPlot::titleLabel()
+{
+    return d_data->titleLabel;
+}
+
+//! \return the plot's titel label.
+const QwtTextLabel *QwtPolarPlot::titleLabel() const
+{
+    return d_data->titleLabel;
+}
+
+/*!
+  \brief Insert a legend
+
+  If the position legend is \c QwtPolarPlot::LeftLegend or \c QwtPolarPlot::RightLegend
+  the legend will be organized in one column from top to down.
+  Otherwise the legend items will be placed in a table
+  with a best fit number of columns from left to right.
+
+  If pos != QwtPolarPlot::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().
+
+  \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
+             unlimited.
+
+  \param ratio Ratio between legend and the bounding rect
+               of title, canvas and axes. The legend will be shrinked
+               if it would need more space than the given ratio.
+               The ratio is limited to ]0.0 .. 1.0]. In case of <= 0.0
+               it will be reset to the default ratio.
+               The default vertical/horizontal ratio is 0.33/0.5.
+
+  \sa legend(), QwtPolarLayout::legendPosition(),
+      QwtPolarLayout::setLegendPosition()
+*/
+void QwtPolarPlot::insertLegend( QwtLegend *legend,
+    QwtPolarPlot::LegendPosition pos, double ratio )
+{
+    d_data->layout->setLegendPosition( pos, ratio );
+    if ( legend != d_data->legend )
+    {
+        if ( d_data->legend && d_data->legend->parent() == this )
+            delete d_data->legend;
+
+        d_data->legend = legend;
+
+        if ( d_data->legend )
+        {
+            if ( pos != ExternalLegend )
+            {
+                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() )
+                {
+                    case LeftLegend:
+                    case RightLegend:
+                        tl->setMaxCols( 1 ); // 1 column: align vertical
+                        break;
+
+                    case TopLegend:
+                    case BottomLegend:
+                        tl->setMaxCols( 0 ); // unlimited
+                        break;
+
+                    case ExternalLegend:
+                        break;
+                }
+            }
+        }
+    }
+    updateLayout();
+}
+
+/*!
+  \return the plot's legend
+  \sa insertLegend()
+*/
+QwtLegend *QwtPolarPlot::legend()
+{
+    return d_data->legend;
+}
+
+/*!
+  \return the plot's legend
+  \sa insertLegend()
+*/
+const QwtLegend *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 );
+    }
+}
+
+/*!
+   \brief Set the background of the plot area
+
+   The plot area is the circle around the pole. It's radius
+   is defined by the radial scale.
+
+   \param brush Background Brush
+   \sa plotBackground(), plotArea()
+*/
+void QwtPolarPlot::setPlotBackground( const QBrush &brush )
+{
+    if ( brush != d_data->canvasBrush )
+    {
+        d_data->canvasBrush = brush;
+        autoRefresh();
+    }
+}
+
+/*!
+   \return plot background brush
+   \sa plotBackground(), plotArea()
+*/
+const QBrush &QwtPolarPlot::plotBackground() const
+{
+    return d_data->canvasBrush;
+}
+
+/*!
+  \brief Set or reset the autoReplot option
+
+  If the autoReplot option is set, the plot will be
+  updated implicitly by manipulating member functions.
+  Since this may be time-consuming, it is recommended
+  to leave this option switched off and call replot()
+  explicitly if necessary.
+
+  The autoReplot option is set to false by default, which
+  means that the user has to call replot() in order to make
+  changes visible.
+  \param enable \c true or \c false. Defaults to \c true.
+  \sa replot()
+*/
+void QwtPolarPlot::setAutoReplot( bool enable )
+{
+    d_data->autoReplot = enable;
+}
+
+//! \return true if the autoReplot option is set.
+bool QwtPolarPlot::autoReplot() const
+{
+    return d_data->autoReplot;
+}
+
+/*!
+  \brief Enable autoscaling
+
+  This member function is used to switch back to autoscaling mode
+  after a fixed scale has been set. Autoscaling calculates a useful
+  scale division from the bounding interval of all plot items with
+  the QwtPolarItem::AutoScale attribute.
+
+  Autoscaling is only supported for the radial scale and enabled as default.
+
+  \param scaleId Scale index
+
+  \sa hasAutoScale(), setScale(), setScaleDiv(),
+      QwtPolarItem::boundingInterval()
+*/
+void QwtPolarPlot::setAutoScale( int scaleId )
+{
+    if ( scaleId != QwtPolar::ScaleRadius )
+        return;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+    if ( !scaleData.doAutoScale )
+    {
+        scaleData.doAutoScale = true;
+        autoRefresh();
+    }
+}
+
+/*!
+  \return \c true if autoscaling is enabled
+  \param scaleId Scale index
+  \sa setAutoScale()
+*/
+bool QwtPolarPlot::hasAutoScale( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return false;
+
+    return d_data->scaleData[scaleId].doAutoScale;
+}
+
+/*!
+  Set the maximum number of major scale intervals for a specified scale
+
+  \param scaleId Scale index
+  \param maxMinor maximum number of minor steps
+  \sa scaleMaxMajor()
+*/
+void QwtPolarPlot::setScaleMaxMinor( int scaleId, int maxMinor )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    if ( maxMinor < 0 )
+        maxMinor = 0;
+    if ( maxMinor > 100 )
+        maxMinor = 100;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+
+    if ( maxMinor != scaleData.maxMinor )
+    {
+        scaleData.maxMinor = maxMinor;
+        scaleData.scaleDiv.invalidate();
+        autoRefresh();
+    }
+}
+
+/*!
+  \return the maximum number of minor ticks for a specified axis
+  \param scaleId Scale index
+  \sa setScaleMaxMinor()
+*/
+int QwtPolarPlot::scaleMaxMinor( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return 0;
+
+    return d_data->scaleData[scaleId].maxMinor;
+}
+
+/*!
+  Set the maximum number of major scale intervals for a specified scale
+
+  \param scaleId Scale index
+  \param maxMajor maximum number of major steps
+  \sa scaleMaxMajor()
+*/
+void QwtPolarPlot::setScaleMaxMajor( int scaleId, int maxMajor )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    if ( maxMajor < 1 )
+        maxMajor = 1;
+    if ( maxMajor > 1000 )
+        maxMajor = 10000;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+    if ( maxMajor != scaleData.maxMinor )
+    {
+        scaleData.maxMajor = maxMajor;
+        scaleData.scaleDiv.invalidate();
+        autoRefresh();
+    }
+}
+
+/*!
+  \return the maximum number of major ticks for a specified axis
+  \param scaleId Scale index
+
+  \sa setScaleMaxMajor()
+*/
+int QwtPolarPlot::scaleMaxMajor( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return 0;
+
+    return d_data->scaleData[scaleId].maxMajor;
+}
+
+/*!
+  Change the scale engine for an axis
+
+  \param scaleId Scale index
+  \param scaleEngine Scale engine
+
+  \sa axisScaleEngine()
+*/
+void QwtPolarPlot::setScaleEngine( int scaleId, QwtScaleEngine *scaleEngine )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+    if ( scaleEngine == NULL || scaleEngine == scaleData.scaleEngine )
+        return;
+
+    delete scaleData.scaleEngine;
+    scaleData.scaleEngine = scaleEngine;
+
+    scaleData.scaleDiv.invalidate();
+
+    autoRefresh();
+}
+
+/*!
+  \return Scale engine for a specific scale
+
+  \param scaleId Scale index
+  \sa setScaleEngine()
+*/
+QwtScaleEngine *QwtPolarPlot::scaleEngine( int scaleId )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return NULL;
+
+    return d_data->scaleData[scaleId].scaleEngine;
+}
+
+/*!
+  \return Scale engine for a specific scale
+
+  \param scaleId Scale index
+  \sa setScaleEngine()
+*/
+const QwtScaleEngine *QwtPolarPlot::scaleEngine( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return NULL;
+
+    return d_data->scaleData[scaleId].scaleEngine;
+}
+
+/*!
+  \brief Disable autoscaling and specify a fixed scale for a selected scale.
+  \param scaleId Scale index
+  \param min
+  \param max minimum and 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 setScaleMaxMajor(), setAutoScale()
+*/
+void QwtPolarPlot::setScale( int scaleId,
+    double min, double max, double stepSize )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+
+    scaleData.scaleDiv.invalidate();
+
+    scaleData.minValue = min;
+    scaleData.maxValue = max;
+    scaleData.stepSize = stepSize;
+    scaleData.doAutoScale = false;
+
+    autoRefresh();
+}
+
+/*!
+  \brief Disable autoscaling and specify a fixed scale for a selected scale.
+  \param scaleId Scale index
+  \param scaleDiv Scale division
+  \sa setScale(), setAutoScale()
+*/
+void QwtPolarPlot::setScaleDiv( int scaleId, const QwtScaleDiv &scaleDiv )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    ScaleData &scaleData = d_data->scaleData[scaleId];
+
+    scaleData.scaleDiv = scaleDiv;
+    scaleData.doAutoScale = false;
+
+    autoRefresh();
+}
+
+/*!
+  \brief Return the scale division of a specified scale
+
+  scaleDiv(scaleId)->lBound(), scaleDiv(scaleId)->hBound()
+  are the current limits of the scale.
+
+  \param scaleId Scale index
+  \return Scale division
+
+  \sa QwtScaleDiv, setScaleDiv(), setScale()
+*/
+const QwtScaleDiv *QwtPolarPlot::scaleDiv( int scaleId ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return NULL;
+
+    return &d_data->scaleData[scaleId].scaleDiv;
+}
+
+/*!
+  \brief Return the scale division of a specified scale
+
+  scaleDiv(scaleId)->lBound(), scaleDiv(scaleId)->hBound()
+  are the current limits of the scale.
+
+  \param scaleId Scale index
+  \return Scale division
+
+  \sa QwtScaleDiv, setScaleDiv(), setScale()
+*/
+QwtScaleDiv *QwtPolarPlot::scaleDiv( int scaleId )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return NULL;
+
+    return &d_data->scaleData[scaleId].scaleDiv;
+}
+
+/*!
+  \brief Change the origin of the azimuth scale
+
+  The azimuth origin is the angle where the azimuth scale
+  shows the value 0.0.  The default origin is 0.0.
+
+  \param origin New origin
+  \sa azimuthOrigin()
+*/
+void QwtPolarPlot::setAzimuthOrigin( double origin )
+{
+    origin = ::fmod( origin, 2 * M_PI );
+    if ( origin != d_data->azimuthOrigin )
+    {
+        d_data->azimuthOrigin = origin;
+        autoRefresh();
+    }
+}
+
+/*!
+  The azimuth origin is the angle where the azimuth scale
+  shows the value 0.0.
+
+  \return Origin of the azimuth scale
+  \sa setAzimuthOrigin()
+*/
+double QwtPolarPlot::azimuthOrigin() const
+{
+    return d_data->azimuthOrigin;
+}
+
+/*!
+   \brief Translate and in/decrease the zoom factor
+
+   In zoom mode the zoom position is in the center of the
+   canvas. The radius of the circle depends on the size of the plot canvas,
+   that is devided by the zoom factor. Thus a factor < 1.0 zoom in.
+
+   Setting an invalid zoom position disables zooming.
+
+   \param zoomPos Center of the translation
+   \param zoomFactor Zoom factor
+
+   \sa unzoom(), zoomPos(), zoomFactor()
+*/
+void QwtPolarPlot::zoom( const QwtPointPolar &zoomPos, double zoomFactor )
+{
+    zoomFactor = qAbs( zoomFactor );
+    if ( zoomPos != d_data->zoomPos ||
+            zoomFactor != d_data->zoomFactor )
+    {
+        d_data->zoomPos = zoomPos;
+        d_data->zoomFactor = zoomFactor;
+        updateLayout();
+        autoRefresh();
+    }
+}
+
+/*!
+   Unzoom the plot
+   \sa zoom()
+*/
+void QwtPolarPlot::unzoom()
+{
+    if ( d_data->zoomFactor != 1.0 || d_data->zoomPos.isValid() )
+    {
+        d_data->zoomFactor = 1.0;
+        d_data->zoomPos = QwtPointPolar();
+        autoRefresh();
+    }
+}
+
+/*!
+   \return Zoom position
+   \sa zoom(), zoomFactor()
+*/
+QwtPointPolar QwtPolarPlot::zoomPos() const
+{
+    return d_data->zoomPos;
+}
+
+/*!
+   \return Zoom factor
+   \sa zoom(), zoomPos()
+*/
+double QwtPolarPlot::zoomFactor() const
+{
+    return d_data->zoomFactor;
+}
+
+/*!
+  Build a scale map
+
+  The azimuth map translates between the scale values and angles from
+  [0.0, 2 * PI[. The radial map translates scale values into the distance
+  from the pole. The radial map is calculated from the current geometry
+  of the canvas.
+
+  \param scaleId Scale index
+  \return Map for the scale on the canvas. With this map pixel coordinates can
+          translated to plot coordinates and vice versa.
+
+  \sa QwtScaleMap, transform(), invTransform()
+*/
+QwtScaleMap QwtPolarPlot::scaleMap( int scaleId ) const
+{
+    const QRectF pr = plotRect();
+    return scaleMap( scaleId, pr.width() / 2.0 );
+}
+
+/*!
+  Build a scale map
+
+  The azimuth map translates between the scale values and angles from
+  [0.0, 2 * PI[. The radial map translates scale values into the distance
+  from the pole.
+
+  \param scaleId Scale index
+  \param radius Radius of the plot are in pixels
+  \return Map for the scale on the canvas. With this map pixel coordinates can
+          translated to plot coordinates and vice versa.
+
+  \sa QwtScaleMap, transform(), invTransform()
+*/
+QwtScaleMap QwtPolarPlot::scaleMap( int scaleId, const double radius ) const
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return QwtScaleMap();
+
+    QwtScaleMap map;
+    map.setTransformation( scaleEngine( scaleId )->transformation() );
+
+    const QwtScaleDiv *sd = scaleDiv( scaleId );
+    map.setScaleInterval( sd->lowerBound(), sd->upperBound() );
+
+    if ( scaleId == QwtPolar::Azimuth )
+    {
+        map.setPaintInterval( d_data->azimuthOrigin,
+            d_data->azimuthOrigin + M_2PI );
+    }
+    else
+    {
+        map.setPaintInterval( 0.0, radius );
+    }
+
+    return map;
+}
+
+/*!
+    \brief Qt event handler
+
+    Handles QEvent::LayoutRequest and QEvent::PolishRequest
+
+    \param e Qt Event
+    \return True, when the event was processed
+*/
+bool QwtPolarPlot::event( QEvent *e )
+{
+    bool ok = QWidget::event( e );
+    switch( e->type() )
+    {
+        case QEvent::LayoutRequest:
+        {
+            updateLayout();
+            break;
+        }
+        case QEvent::PolishRequest:
+        {
+            updateLayout();
+            replot();
+            break;
+        }
+        default:;
+    }
+    return ok;
+}
+
+//! Resize and update internal layout
+void QwtPolarPlot::resizeEvent( QResizeEvent *e )
+{
+    QFrame::resizeEvent( e );
+    updateLayout();
+}
+
+void QwtPolarPlot::initPlot( const QwtText &title )
+{
+    d_data = new PrivateData;
+    d_data->layout = new QwtPolarLayout;
+
+    QwtText text( title );
+    text.setRenderFlags( Qt::AlignCenter | Qt::TextWordWrap );
+
+    d_data->titleLabel = new QwtTextLabel( text, this );
+    d_data->titleLabel->setFont( QFont( fontInfo().family(), 14, QFont::Bold ) );
+    if ( !text.isEmpty() )
+        d_data->titleLabel->show();
+    else
+        d_data->titleLabel->hide();
+
+    d_data->canvas = new QwtPolarCanvas( this );
+
+    d_data->autoReplot = false;
+    d_data->canvasBrush = QBrush( Qt::white );
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+    {
+        ScaleData &scaleData = d_data->scaleData[scaleId];
+
+        if ( scaleId == QwtPolar::Azimuth )
+        {
+            scaleData.minValue = 0.0;
+            scaleData.maxValue = 360.0;
+            scaleData.stepSize = 30.0;
+        }
+        else
+        {
+            scaleData.minValue = 0.0;
+            scaleData.maxValue = 1000.0;
+            scaleData.stepSize = 0.0;
+        }
+
+        scaleData.doAutoScale = true;
+
+        scaleData.maxMinor = 5;
+        scaleData.maxMajor = 8;
+
+        scaleData.scaleEngine = new QwtLinearScaleEngine;
+        scaleData.scaleDiv.invalidate();
+    }
+    d_data->zoomFactor = 1.0;
+    d_data->azimuthOrigin = 0.0;
+
+    setSizePolicy( QSizePolicy::MinimumExpanding,
+                   QSizePolicy::MinimumExpanding );
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+        updateScale( scaleId );
+}
+
+//! Replots the plot if QwtPlot::autoReplot() is \c true.
+void QwtPolarPlot::autoRefresh()
+{
+    if ( d_data->autoReplot )
+        replot();
+}
+
+//! Rebuild the layout
+void QwtPolarPlot::updateLayout()
+{
+    d_data->layout->activate( this, contentsRect() );
+
+    // resize and show the visible widgets
+    if ( d_data->titleLabel )
+    {
+        if ( !d_data->titleLabel->text().isEmpty() )
+        {
+            d_data->titleLabel->setGeometry( d_data->layout->titleRect().toRect() );
+            if ( !d_data->titleLabel->isVisible() )
+                d_data->titleLabel->show();
+        }
+        else
+            d_data->titleLabel->hide();
+    }
+
+    if ( d_data->legend &&
+        d_data->layout->legendPosition() != ExternalLegend )
+    {
+        if ( d_data->legend->itemCount() > 0 )
+        {
+            d_data->legend->setGeometry( d_data->layout->legendRect().toRect() );
+            d_data->legend->show();
+        }
+        else
+            d_data->legend->hide();
+    }
+
+    d_data->canvas->setGeometry( d_data->layout->canvasRect().toRect() );
+    Q_EMIT layoutChanged();
+}
+
+/*!
+  \brief Redraw the plot
+
+  If the autoReplot option is not set (which is the default)
+  or if any curves are attached to raw data, the plot has to
+  be refreshed explicitly in order to make changes visible.
+
+  \sa setAutoReplot()
+  \warning Calls canvas()->repaint, take care of infinite recursions
+*/
+void QwtPolarPlot::replot()
+{
+    bool doAutoReplot = autoReplot();
+    setAutoReplot( false );
+
+    for ( int scaleId = 0; scaleId < QwtPolar::ScaleCount; scaleId++ )
+        updateScale( scaleId );
+
+    d_data->canvas->invalidateBackingStore();
+    d_data->canvas->repaint();
+
+    setAutoReplot( doAutoReplot );
+}
+
+//!  \return the plot's canvas
+QwtPolarCanvas *QwtPolarPlot::canvas()
+{
+    return d_data->canvas;
+}
+
+//!  \return the plot's canvas
+const QwtPolarCanvas *QwtPolarPlot::canvas() const
+{
+    return d_data->canvas;
+}
+
+/*!
+  Redraw the canvas.
+  \param painter Painter used for drawing
+  \param canvasRect Contents rect of the canvas
+*/
+void QwtPolarPlot::drawCanvas( QPainter *painter,
+    const QRectF &canvasRect ) const
+{
+    const QRectF cr = canvasRect;
+    const QRectF pr = plotRect( cr );
+
+    const double radius = pr.width() / 2.0;
+
+    if ( d_data->canvasBrush.style() != Qt::NoBrush )
+    {
+        painter->save();
+        painter->setPen( Qt::NoPen );
+        painter->setBrush( d_data->canvasBrush );
+
+        if ( qwtDistance( pr.center(), cr.topLeft() ) < radius &&
+            qwtDistance( pr.center(), cr.topRight() ) < radius &&
+            qwtDistance( pr.center(), cr.bottomRight() ) < radius &&
+            qwtDistance( pr.center(), cr.bottomLeft() ) < radius )
+        {
+            QwtPainter::drawRect( painter, cr );
+        }
+        else
+        {
+            painter->setRenderHint( QPainter::Antialiasing, true );
+            QwtPainter::drawEllipse( painter, pr );
+        }
+        painter->restore();
+    }
+
+    drawItems( painter,
+        scaleMap( QwtPolar::Azimuth, radius ),
+        scaleMap( QwtPolar::Radius, radius ),
+        pr.center(), radius, canvasRect );
+}
+
+/*!
+  Redraw the canvas items.
+
+  \param painter Painter used for drawing
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param radius Radius of the complete plot area in painter coordinates
+  \param canvasRect Contents rect of the canvas in painter coordinates
+*/
+void QwtPolarPlot::drawItems( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double radius,
+    const QRectF &canvasRect ) const
+{
+    const QRectF pr = plotRect( canvasRect );
+
+    const QwtPolarItemList& itmList = itemList();
+    for ( QwtPolarItemIterator it = itmList.begin();
+            it != itmList.end(); ++it )
+    {
+        QwtPolarItem *item = *it;
+        if ( item && item->isVisible() )
+        {
+            painter->save();
+
+            // Unfortunately circular clipping slows down
+            // painting a lot. So we better try to avoid it.
+
+            bool doClipping = false;
+            if ( item->rtti() != QwtPolarItem::Rtti_PolarGrid )
+            {
+                const QwtInterval intv =
+                    item->boundingInterval( QwtPolar::Radius );
+
+                if ( !intv.isValid() )
+                    doClipping = true;
+                else
+                {
+                    if ( radialMap.s1() < radialMap.s2() )
+                        doClipping = intv.maxValue() > radialMap.s2();
+                    else
+                        doClipping = intv.minValue() < radialMap.s2();
+                }
+            }
+
+            if ( doClipping )
+            {
+                const int margin = item->marginHint();
+
+                const QRectF clipRect = pr.adjusted(
+                    -margin, -margin, margin, margin );
+                if ( !clipRect.contains( canvasRect ) )
+                {
+                    QRegion clipRegion( clipRect.toRect(), QRegion::Ellipse );
+                    painter->setClipRegion( clipRegion, Qt::IntersectClip );
+                }
+            }
+
+            painter->setRenderHint( QPainter::Antialiasing,
+                item->testRenderHint( QwtPolarItem::RenderAntialiased ) );
+
+            item->draw( painter, azimuthMap, radialMap,
+                pole, radius, canvasRect );
+
+            painter->restore();
+        }
+    }
+}
+
+/*!
+  Rebuild the scale
+  \param scaleId Scale index
+*/
+
+void QwtPolarPlot::updateScale( int scaleId )
+{
+    if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
+        return;
+
+    ScaleData &d = d_data->scaleData[scaleId];
+
+    double minValue = d.minValue;
+    double maxValue = d.maxValue;
+    double stepSize = d.stepSize;
+
+    if ( scaleId == QwtPolar::ScaleRadius && d.doAutoScale )
+    {
+        QwtInterval interval;
+
+        const QwtPolarItemList& itmList = itemList();
+        for ( QwtPolarItemIterator it = itmList.begin();
+                it != itmList.end(); ++it )
+        {
+            const QwtPolarItem *item = *it;
+            if ( item->testItemAttribute( QwtPolarItem::AutoScale ) )
+                interval |= item->boundingInterval( scaleId );
+        }
+
+        minValue = interval.minValue();
+        maxValue = interval.maxValue();
+
+        d.scaleEngine->autoScale( d.maxMajor,
+                                  minValue, maxValue, stepSize );
+        d.scaleDiv.invalidate();
+    }
+
+    if ( !d.scaleDiv.isValid() )
+    {
+        d.scaleDiv = d.scaleEngine->divideScale(
+            minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
+    }
+
+    const QwtInterval interval = visibleInterval();
+
+    const QwtPolarItemList& itmList = itemList();
+    for ( QwtPolarItemIterator it = itmList.begin();
+            it != itmList.end(); ++it )
+    {
+        QwtPolarItem *item = *it;
+        item->updateScaleDiv( *scaleDiv( QwtPolar::Azimuth ),
+            *scaleDiv( QwtPolar::Radius ), interval );
+    }
+}
+
+/*!
+   \return Maximum of all item margin hints.
+   \sa QwtPolarItem::marginHint()
+*/
+int QwtPolarPlot::plotMarginHint() const
+{
+    int margin = 0;
+    const QwtPolarItemList& itmList = itemList();
+    for ( QwtPolarItemIterator it = itmList.begin();
+            it != itmList.end(); ++it )
+    {
+        QwtPolarItem *item = *it;
+        if ( item && item->isVisible() )
+        {
+            const int hint = item->marginHint();
+            if ( hint > margin )
+                margin = hint;
+        }
+    }
+    return margin;
+}
+
+/*!
+   The plot area depends on the size of the canvas
+   and the zoom parameters.
+
+   \return Bounding rect of the plot area
+
+*/
+QRectF QwtPolarPlot::plotRect() const
+{
+    return plotRect( canvas()->contentsRect() );
+}
+
+/*!
+   \brief Calculate the bounding rect of the plot area
+
+   The plot area depends on the zoom parameters.
+
+   \param canvasRect Rectangle of the canvas
+   \return Rectangle for displaying 100% of the plot
+*/
+QRectF QwtPolarPlot::plotRect( const QRectF &canvasRect ) const
+{
+    const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );
+    const QwtScaleEngine *se = scaleEngine( QwtPolar::Radius );
+
+    const int margin = plotMarginHint();
+    const QRectF cr = canvasRect;
+    const int radius = qMin( cr.width(), cr.height() ) / 2 - margin;
+
+    QwtScaleMap map;
+    map.setTransformation( se->transformation() );
+    map.setPaintInterval( 0.0, radius / d_data->zoomFactor );
+    map.setScaleInterval( sd->lowerBound(), sd->upperBound() );
+
+    double v = map.s1();
+    if ( map.s1() <= map.s2() )
+        v += d_data->zoomPos.radius();
+    else
+        v -= d_data->zoomPos.radius();
+    v = map.transform( v );
+
+    const QPointF off =
+        QwtPointPolar( d_data->zoomPos.azimuth(), v ).toPoint();
+
+    QPointF center( cr.center().x(), cr.top() + margin + radius );
+    center -= QPointF( off.x(), -off.y() );
+
+    QRectF rect( 0, 0, 2 * map.p2(), 2 * map.p2() );
+    rect.moveCenter( center );
+
+    return rect;
+}
+
+/*!
+   \return Bounding interval of the radial scale that is
+           visible on the canvas.
+*/
+QwtInterval QwtPolarPlot::visibleInterval() const
+{
+    const QwtScaleDiv *sd = scaleDiv( QwtPolar::Radius );
+
+    const QRectF cRect = canvas()->contentsRect();
+    const QRectF pRect = plotRect( cRect );
+    if ( cRect.contains( pRect ) || !cRect.intersects( pRect ) )
+    {
+        return QwtInterval( sd->lowerBound(), sd->upperBound() );
+    }
+
+    const QPointF pole = pRect.center();
+    const QRectF scaleRect = pRect & cRect;
+
+    const QwtScaleMap map = scaleMap( QwtPolar::Radius );
+
+    double dmin = 0.0;
+    double dmax = 0.0;
+    if ( scaleRect.contains( pole ) )
+    {
+        dmin = 0.0;
+
+        QPointF corners[4];
+        corners[0] = scaleRect.bottomRight();
+        corners[1] = scaleRect.topRight();
+        corners[2] = scaleRect.topLeft();
+        corners[3] = scaleRect.bottomLeft();
+
+        dmax = 0.0;
+        for ( int i = 0; i < 4; i++ )
+        {
+            const double dist = qwtDistance( pole, corners[i] );
+            if ( dist > dmax )
+                dmax = dist;
+        }
+    }
+    else
+    {
+        if ( pole.x() < scaleRect.left() )
+        {
+            if ( pole.y() < scaleRect.top() )
+            {
+                dmin = qwtDistance( pole, scaleRect.topLeft() );
+                dmax = qwtDistance( pole, scaleRect.bottomRight() );
+            }
+            else if ( pole.y() > scaleRect.bottom() )
+            {
+                dmin = qwtDistance( pole, scaleRect.bottomLeft() );
+                dmax = qwtDistance( pole, scaleRect.topRight() );
+            }
+            else
+            {
+                dmin = scaleRect.left() - pole.x();
+                dmax = qMax( qwtDistance( pole, scaleRect.bottomRight() ),
+                    qwtDistance( pole, scaleRect.topRight() ) );
+            }
+        }
+        else if ( pole.x() > scaleRect.right() )
+        {
+            if ( pole.y() < scaleRect.top() )
+            {
+                dmin = qwtDistance( pole, scaleRect.topRight() );
+                dmax = qwtDistance( pole, scaleRect.bottomLeft() );
+            }
+            else if ( pole.y() > scaleRect.bottom() )
+            {
+                dmin = qwtDistance( pole, scaleRect.bottomRight() );
+                dmax = qwtDistance( pole, scaleRect.topLeft() );
+            }
+            else
+            {
+                dmin = pole.x() - scaleRect.right();
+                dmax = qMax( qwtDistance( pole, scaleRect.bottomLeft() ),
+                    qwtDistance( pole, scaleRect.topLeft() ) );
+            }
+        }
+        else if ( pole.y() < scaleRect.top() )
+        {
+            dmin = scaleRect.top() - pole.y();
+            dmax = qMax( qwtDistance( pole, scaleRect.bottomLeft() ),
+                qwtDistance( pole, scaleRect.bottomRight() ) );
+        }
+        else if ( pole.y() > scaleRect.bottom() )
+        {
+            dmin = pole.y() - scaleRect.bottom();
+            dmax = qMax( qwtDistance( pole, scaleRect.topLeft() ),
+                qwtDistance( pole, scaleRect.topRight() ) );
+        }
+    }
+
+    const double radius = pRect.width() / 2.0;
+    if ( dmax > radius )
+        dmax = radius;
+
+    QwtInterval interval;
+    interval.setMinValue( map.invTransform( dmin ) );
+    interval.setMaxValue( map.invTransform( dmax ) );
+
+    return interval;
+}
+
+/*!
+  \return Layout, responsible for the geometry of the plot components
+*/
+QwtPolarLayout *QwtPolarPlot::plotLayout()
+{
+    return d_data->layout;
+}
+
+/*!
+  \return Layout, responsible for the geometry of the plot components
+*/
+const QwtPolarLayout *QwtPolarPlot::plotLayout() const
+{
+    return d_data->layout;
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_plot.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_plot.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_plot.h	(revision 4272)
@@ -0,0 +1,219 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_PLOT_H
+#define QWT_POLAR_PLOT_H 1
+
+#include "qwt_polar_global.h"
+#include "qwt_polar.h"
+#include "qwt_polar_itemdict.h"
+#include <qwt_interval.h>
+#include <qwt_scale_map.h>
+#include <qwt_point_polar.h>
+#include <qframe.h>
+
+class QwtRoundScaleDraw;
+class QwtScaleEngine;
+class QwtScaleDiv;
+class QwtTextLabel;
+class QwtPolarCanvas;
+class QwtPolarLayout;
+
+/*!
+  \brief A plotting widget, displaying a polar coordinate system
+
+  An unlimited number of plot items can be displayed on
+  its canvas. Plot items might be curves (QwtPolarCurve), markers
+  (QwtPolarMarker), the grid (QwtPolarGrid), or anything else derived
+  from QwtPolarItem.
+
+  The coordinate system is defined by a radial and a azimuth scale.
+  The scales at the axes can be explicitely set (QwtScaleDiv), or
+  are calculated from the plot items, using algorithms (QwtScaleEngine) which
+  can be configured separately for each axis. Autoscaling is supported
+  for the radial scale.
+
+  In opposite to QwtPlot the scales might be different from the
+  view, that is displayed on the canvas. The view can be changed by
+  zooming - f.e. by using QwtPolarPanner or QwtPolarMaginfier.
+*/
+class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
+{
+    Q_OBJECT
+
+    Q_PROPERTY( QBrush plotBackground READ plotBackground WRITE setPlotBackground )
+    Q_PROPERTY( double azimuthOrigin READ azimuthOrigin WRITE setAzimuthOrigin )
+
+
+public:
+    /*!
+        Position of the legend, relative to the canvas.
+        \sa insertLegend()
+     */
+    enum LegendPosition
+    {
+        //! The legend will be left from the canvas.
+        LeftLegend,
+
+        //! The legend will be right from the canvas.
+        RightLegend,
+
+        //! The legend will be below the canvas.
+        BottomLegend,
+
+        //! The legend will be between canvas and title.
+        TopLegend,
+
+        /*!
+          External means that only the content of the legend
+          will be handled by QwtPlot, but not its geometry.
+          This might be interesting if an application wants to
+          have a legend in an external window ( or on the canvas ).
+
+          \note The legend is not painted by QwtPolarRenderer
+         */
+        ExternalLegend
+    };
+
+    explicit QwtPolarPlot( QWidget *parent = NULL );
+    QwtPolarPlot( const QwtText &title, QWidget *parent = NULL );
+
+    virtual ~QwtPolarPlot();
+
+    void setTitle( const QString & );
+    void setTitle( const QwtText & );
+
+    QwtText title() const;
+
+    QwtTextLabel *titleLabel();
+    const QwtTextLabel *titleLabel() const;
+
+    void setAutoReplot( bool tf = true );
+    bool autoReplot() const;
+
+    void setAutoScale( int scaleId );
+    bool hasAutoScale( int scaleId ) const;
+
+    void setScaleMaxMinor( int scaleId, int maxMinor );
+    int scaleMaxMinor( int scaleId ) const;
+
+    int scaleMaxMajor( int scaleId ) const;
+    void setScaleMaxMajor( int scaleId, int maxMajor );
+
+    QwtScaleEngine *scaleEngine( int scaleId );
+    const QwtScaleEngine *scaleEngine( int scaleId ) const;
+    void setScaleEngine( int scaleId, QwtScaleEngine * );
+
+    void setScale( int scaleId, double min, double max, double step = 0 );
+
+    void setScaleDiv( int scaleId, const QwtScaleDiv & );
+    const QwtScaleDiv *scaleDiv( int scaleId ) const;
+    QwtScaleDiv *scaleDiv( int scaleId );
+
+    QwtScaleMap scaleMap( int scaleId, double radius ) const;
+    QwtScaleMap scaleMap( int scaleId ) const;
+
+    void updateScale( int scaleId );
+
+    double azimuthOrigin() const;
+
+    void zoom( const QwtPointPolar&, double factor );
+    void unzoom();
+
+    QwtPointPolar zoomPos() const;
+    double zoomFactor() const;
+
+    // Canvas
+
+    QwtPolarCanvas *canvas();
+    const QwtPolarCanvas *canvas() const;
+
+    void setPlotBackground ( const QBrush &c );
+    const QBrush& plotBackground() const;
+
+    virtual void drawCanvas( QPainter *, const QRectF & ) const;
+
+    // Legend
+
+    void insertLegend( QwtLegend *,
+        LegendPosition = RightLegend, double ratio = -1.0 );
+
+    QwtLegend *legend();
+    const QwtLegend *legend() const;
+
+    // Layout
+    QwtPolarLayout *plotLayout();
+    const QwtPolarLayout *plotLayout() const;
+
+    QwtInterval visibleInterval() const;
+    QRectF plotRect() const;
+    QRectF plotRect( const QRectF & ) const;
+
+    int plotMarginHint() 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 that is emitted, whenever the layout of the plot
+      has been recalculated.
+     */
+    void layoutChanged();
+
+public Q_SLOTS:
+    virtual void replot();
+    void autoRefresh();
+    void setAzimuthOrigin( double );
+
+protected Q_SLOTS:
+    virtual void legendItemClicked();
+    virtual void legendItemChecked( bool );
+
+protected:
+    virtual bool event( QEvent * );
+    virtual void resizeEvent( QResizeEvent * );
+
+    virtual void updateLayout();
+
+    virtual void drawItems( QPainter *painter,
+        const QwtScaleMap &radialMap, const QwtScaleMap &azimuthMap,
+        const QPointF &pole, double radius,
+        const QRectF &canvasRect ) const;
+
+private:
+    void initPlot( const QwtText & );
+
+    class ScaleData;
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_renderer.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_renderer.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_renderer.cpp	(revision 4272)
@@ -0,0 +1,421 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_renderer.h"
+#include "qwt_polar_plot.h"
+#include "qwt_polar_layout.h"
+#include <qwt_legend.h>
+#include <qwt_legend_item.h>
+#include <qwt_dyngrid_layout.h>
+#include <qwt_text_label.h>
+#include <qwt_text.h>
+#include <qpainter.h>
+#include <qprinter.h>
+#include <qimagewriter.h>
+#include <qfileinfo.h>
+#include <qmath.h>
+#ifndef QWT_NO_POLAR_POLAR_SVG
+#ifdef QT_SVG_LIB
+#include <qsvggenerator.h>
+#endif
+#endif
+
+
+static inline double qwtDistance(
+    const QPointF &p1, const QPointF &p2 )
+{
+    double dx = p2.x() - p1.x();
+    double dy = p2.y() - p1.y();
+    return qSqrt( dx * dx + dy * dy );
+}
+
+class QwtPolarRenderer::PrivateData
+{
+public:
+    PrivateData():
+        plot( NULL )
+    {
+    }
+
+    QwtPolarPlot *plot;
+};
+
+/*!
+  Constructor
+  \param parent Parent object
+ */
+QwtPolarRenderer::QwtPolarRenderer( QObject *parent ):
+    QObject( parent )
+{
+    d_data = new PrivateData;
+}
+
+//! Destructor
+QwtPolarRenderer::~QwtPolarRenderer()
+{
+    delete d_data;
+}
+
+/*!
+  Render a polar plot to a file
+
+  The format of the document will be autodetected from the
+  suffix of the filename.
+
+  \param plot Plot widget
+  \param fileName Path of the file, where the document will be stored
+  \param sizeMM Size for the document in millimeters.
+  \param resolution Resolution in dots per Inch (dpi)
+*/
+void QwtPolarRenderer::renderDocument( QwtPolarPlot *plot,
+    const QString &fileName, const QSizeF &sizeMM, int resolution )
+{
+    renderDocument( plot, fileName,
+        QFileInfo( fileName ).suffix(), sizeMM, resolution );
+}
+
+/*!
+  Render a plot to a file
+
+  Supported formats are:
+
+  - pdf\n
+  - ps\n
+  - svg\n
+  - all image formats supported by Qt, see QImageWriter::supportedImageFormats()
+
+  \param plot Plot widget
+  \param fileName Path of the file, where the document will be stored
+  \param format Format for the document
+  \param sizeMM Size for the document in millimeters.
+  \param resolution Resolution in dots per Inch (dpi)
+
+  \sa renderTo(), render(), QwtPainter::setRoundingAlignment()
+*/
+void QwtPolarRenderer::renderDocument( QwtPolarPlot *plot,
+    const QString &fileName, const QString &format,
+    const QSizeF &sizeMM, int resolution )
+{
+    if ( plot == NULL || sizeMM.isEmpty() || resolution <= 0 )
+        return;
+
+    QString title = plot->title().text();
+    if ( title.isEmpty() )
+        title = "Plot Document";
+
+    const double mmToInch = 1.0 / 25.4;
+    const QSizeF size = sizeMM * mmToInch * resolution;
+
+    const QRectF documentRect( 0.0, 0.0, size.width(), size.height() );
+
+    const QString fmt = format.toLower();
+    if ( format == "pdf" || format == "ps" )
+    {
+        QPrinter printer;
+        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 );
+    }
+#ifndef QWT_NO_POLAR_SVG
+#ifdef QT_SVG_LIB
+#if QT_VERSION >= 0x040500
+    else if ( format == "svg" )
+    {
+        QSvgGenerator generator;
+        generator.setTitle( title );
+        generator.setFileName( fileName );
+        generator.setResolution( resolution );
+        generator.setViewBox( documentRect );
+
+        QPainter painter( &generator );
+        render( plot, &painter, documentRect );
+    }
+#endif
+#endif
+#endif
+    else
+    {
+        if ( QImageWriter::supportedImageFormats().indexOf(
+            format.toLatin1() ) >= 0 )
+        {
+            const QRect imageRect = documentRect.toRect();
+            const int dotsPerMeter = qRound( resolution * mmToInch * 1000.0 );
+
+            QImage image( imageRect.size(), QImage::Format_ARGB32 );
+            image.setDotsPerMeterX( dotsPerMeter );
+            image.setDotsPerMeterY( dotsPerMeter );
+            image.fill( QColor( Qt::white ).rgb() );
+
+            QPainter painter( &image );
+            render( plot, &painter, imageRect );
+            painter.end();
+
+            image.save( fileName, format.toLatin1() );
+        }
+    }
+}
+
+/*!
+  \brief Render the plot to a \c QPaintDevice
+
+  This function renders the contents of a QwtPolarPlot instance to
+  \c QPaintDevice object. The target rectangle is derived from
+  its device metrics.
+
+  \param plot Plot to be rendered
+  \param paintDevice device to paint on, f.e a QImage
+
+  \sa renderDocument(), render(), QwtPainter::setRoundingAlignment()
+*/
+
+void QwtPolarRenderer::renderTo(
+    QwtPolarPlot *plot, QPaintDevice &paintDevice ) const
+{
+    int w = paintDevice.width();
+    int h = paintDevice.height();
+
+    QPainter p( &paintDevice );
+    render( plot, &p, QRectF( 0, 0, w, h ) );
+}
+
+
+/*!
+  \brief Render the plot to a QPrinter
+
+  This function renders the contents of a QwtPolarPlot instance to
+  \c QPaintDevice object. The size is derived from the printer
+  metrics.
+
+  \param plot Plot to be rendered
+  \param printer Printer to paint on
+
+  \sa renderDocument(), render(), QwtPainter::setRoundingAlignment()
+*/
+
+void QwtPolarRenderer::renderTo(
+    QwtPolarPlot *plot, QPrinter &printer ) const
+{
+    int w = printer.width();
+    int h = printer.height();
+
+    QRectF rect( 0, 0, w, h );
+    double aspect = rect.width() / rect.height();
+    if ( ( aspect < 1.0 ) )
+        rect.setHeight( aspect * rect.width() );
+
+    QPainter p( &printer );
+    render( plot, &p, rect );
+}
+
+#ifndef QWT_NO_POLAR_SVG
+#ifdef QT_SVG_LIB
+#if QT_VERSION >= 0x040500
+
+/*!
+  \brief Render the plot to a QSvgGenerator
+
+  If the generator has a view box, the plot will be rendered into it.
+  If it has no viewBox but a valid size the target coordinates
+  will be (0, 0, generator.width(), generator.height()). Otherwise
+  the target rectangle will be QRectF(0, 0, 800, 600);
+
+  \param plot Plot to be rendered
+  \param generator SVG generator
+*/
+void QwtPolarRenderer::renderTo(
+    QwtPolarPlot *plot, QSvgGenerator &generator ) const
+{
+    QRectF rect = generator.viewBoxF();
+    if ( rect.isEmpty() )
+        rect.setRect( 0, 0, generator.width(), generator.height() );
+
+    if ( rect.isEmpty() )
+        rect.setRect( 0, 0, 800, 600 ); // something
+
+    QPainter p( &generator );
+    render( plot, &p, rect );
+}
+#endif
+#endif
+#endif
+
+/*!
+   \brief Render the plot to a given rectangle ( f.e QPrinter, QSvgRenderer )
+
+   \param plot Plot widget to be rendered
+   \param painter Painter
+   \param plotRect Bounding rectangle for the plot
+*/
+void QwtPolarRenderer::render( QwtPolarPlot *plot,
+    QPainter *painter, const QRectF &plotRect ) const
+{
+    if ( plot == NULL || painter == NULL || !painter->isActive() ||
+        !plotRect.isValid() || plot->size().isNull() )
+    {
+        return;
+    }
+
+    d_data->plot = plot;
+
+    /*
+      The layout engine uses the same methods as they are used
+      by the Qt layout system. Therefore we need to calculate the
+      layout in screen coordinates and paint with a scaled painter.
+     */
+    QTransform transform;
+    transform.scale(
+        double( painter->device()->logicalDpiX() ) / plot->logicalDpiX(),
+        double( painter->device()->logicalDpiY() ) / plot->logicalDpiY() );
+
+    const QRectF layoutRect = transform.inverted().mapRect( plotRect );
+
+    QwtPolarLayout *layout = plot->plotLayout();
+
+    // All paint operations need to be scaled according to
+    // the paint device metrics.
+
+    QwtPolarLayout::Options layoutOptions =
+        QwtPolarLayout::IgnoreScrollbars | QwtPolarLayout::IgnoreFrames;
+
+    layout->activate( plot, layoutRect, layoutOptions );
+
+    painter->save();
+    painter->setWorldTransform( transform, true );
+
+    painter->save();
+    renderTitle( painter, layout->titleRect() );
+    painter->restore();
+
+    painter->save();
+    renderLegend( painter, layout->legendRect() );
+    painter->restore();
+
+    const QRectF canvasRect = layout->canvasRect();
+
+    painter->save();
+    painter->setClipRect( canvasRect );
+    plot->drawCanvas( painter, canvasRect );
+    painter->restore();
+
+    painter->restore();
+
+    layout->invalidate();
+
+    d_data->plot = NULL;
+}
+
+/*!
+  Render the title into a given rectangle.
+
+  \param painter Painter
+  \param rect Bounding rectangle
+*/
+
+void QwtPolarRenderer::renderTitle( QPainter *painter, const QRectF &rect ) const
+{
+    QwtTextLabel *title = d_data->plot->titleLabel();
+
+    painter->setFont( title->font() );
+
+    const QColor color = title->palette().color(
+        QPalette::Active, QPalette::Text );
+
+    painter->setPen( color );
+    title->text().draw( painter, rect );
+}
+
+/*!
+  Render the legend into a given rectangle.
+
+  \param painter Painter
+  \param rect Bounding rectangle
+*/
+
+void QwtPolarRenderer::renderLegend(
+    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 )
+        {
+            painter->save();
+
+            painter->setClipRect( itemRects[index] );
+            renderLegendItem( painter, w, itemRects[index] );
+
+            index++;
+            painter->restore();
+        }
+    }
+
+}
+
+/*!
+  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 );
+    }
+}
+
Index: /trunk/BNC/qwtpolar/qwt_polar_renderer.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_renderer.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_renderer.h	(revision 4272)
@@ -0,0 +1,71 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_RENDERER_H
+#define QWT_POLAR_RENDERER_H 1
+
+#include "qwt_polar_global.h"
+#include <qobject.h>
+
+class QwtPolarPlot;
+class QSizeF;
+class QRectF;
+class QPainter;
+class QPrinter;
+class QPaintDevice;
+#ifndef QWT_NO_POLAR_SVG
+#ifdef QT_SVG_LIB
+class QSvgGenerator;
+#endif
+#endif
+
+/*!
+  \brief Renderer for exporting a polar plot to a document, a printer
+         or anything else, that is supported by QPainter/QPaintDevice
+*/
+class QWT_POLAR_EXPORT QwtPolarRenderer: public QObject
+{
+    Q_OBJECT
+
+public:
+    explicit QwtPolarRenderer( QObject *parent = NULL );
+    virtual ~QwtPolarRenderer();
+
+    void renderDocument( QwtPolarPlot *, const QString &format,
+        const QSizeF &sizeMM, int resolution = 85 );
+
+    void renderDocument( QwtPolarPlot *,
+        const QString &title, const QString &format,
+        const QSizeF &sizeMM, int resolution = 85 );
+
+#ifndef QWT_NO_POLAR_SVG
+#ifdef QT_SVG_LIB
+#if QT_VERSION >= 0x040500
+    void renderTo( QwtPolarPlot *, QSvgGenerator & ) const;
+#endif
+#endif
+#endif
+    void renderTo( QwtPolarPlot *, QPrinter & ) const;
+    void renderTo( QwtPolarPlot *, QPaintDevice &p ) const;
+
+    virtual void render( QwtPolarPlot *,
+        QPainter *, const QRectF &rect ) const;
+
+protected:
+    virtual void renderTitle( QPainter *, const QRectF & ) const;
+    virtual void renderLegend( QPainter *, const QRectF & ) const;
+
+    virtual void renderLegendItem( QPainter *,
+        const QWidget *, const QRectF & ) const;
+
+private:
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+#endif
Index: /trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp	(revision 4272)
@@ -0,0 +1,529 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_polar_spectrogram.h"
+#include "qwt_polar.h"
+#include "qwt_polar_plot.h"
+#include <qwt_color_map.h>
+#include <qwt_scale_map.h>
+#include <qwt_raster_data.h>
+#include <qwt_math.h>
+#include <qpainter.h>
+#if QT_VERSION >= 0x040400
+#include <qthread.h>
+#include <qfuture.h>
+#include <qtconcurrentrun.h>
+#endif
+
+#if QWT_VERSION < 0x060100
+
+static 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 );
+}
+
+static 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;
+}
+
+#endif // QWT_VERSION < 0x060100
+
+#if QT_VERSION < 0x040601
+#define qAtan2(y, x) ::atan2(y, x)
+#endif
+
+static bool qwtNeedsClipping( const QRectF &plotRect, const QRectF &rect )
+{
+    QPointF points[4];
+    points[0] = rect.topLeft();
+    points[1] = rect.topRight();
+    points[2] = rect.bottomLeft();
+    points[3] = rect.bottomRight();
+
+    const double radius = plotRect.width() / 2.0;
+    const QPointF pole = plotRect.center();
+
+    for ( int i = 0; i < 4; i++ )
+    {
+        const double dx = points[i].x() - pole.x();
+        const double dy = points[i].y() - pole.y();
+
+        if ( qSqrt( dx * dx + dy * dy ) > radius )
+            return true;
+    }
+
+    return false;
+}
+
+class QwtPolarSpectrogram::TileInfo
+{
+public:
+    QPoint imagePos;
+    QRect rect;
+    QImage *image;
+};
+
+class QwtPolarSpectrogram::PrivateData
+{
+public:
+    PrivateData():
+        data( NULL ),
+        renderThreadCount( 1 )
+    {
+        colorMap = new QwtLinearColorMap();
+    }
+
+    ~PrivateData()
+    {
+        delete data;
+        delete colorMap;
+    }
+
+    QwtRasterData *data;
+    QwtColorMap *colorMap;
+
+    uint renderThreadCount;
+
+    QwtPolarSpectrogram::PaintAttributes paintAttributes;
+};
+
+//!  Constructor
+QwtPolarSpectrogram::QwtPolarSpectrogram():
+    QwtPolarItem( QwtText( "Spectrogram" ) )
+{
+    d_data = new PrivateData;
+
+    setItemAttribute( QwtPolarItem::AutoScale );
+    setItemAttribute( QwtPolarItem::Legend, false );
+
+    setZ( 20.0 );
+}
+
+//! Destructor
+QwtPolarSpectrogram::~QwtPolarSpectrogram()
+{
+    delete d_data;
+}
+
+//! \return QwtPolarItem::Rtti_PolarSpectrogram
+int QwtPolarSpectrogram::rtti() const
+{
+    return QwtPolarItem::Rtti_PolarSpectrogram;
+}
+
+/*!
+  Set the data to be displayed
+
+  \param data Spectrogram Data
+  \sa data()
+
+  \warning QwtRasterData::initRaster() is called each time before the
+           image is rendered, but without any useful parameters.
+           Also QwtRasterData::rasterHint() is not used.
+*/
+void QwtPolarSpectrogram::setData( QwtRasterData *data )
+{
+    if ( data != d_data->data )
+    {
+        delete d_data->data;
+        d_data->data = data;
+
+        itemChanged();
+    }
+}
+
+/*!
+  \return Spectrogram data
+  \sa setData()
+*/
+const QwtRasterData *QwtPolarSpectrogram::data() const
+{
+    return d_data->data;
+}
+
+/*!
+  Change the color map
+
+  Often it is useful to display the mapping between intensities and
+  colors as an additional plot axis, showing a color bar.
+
+  \param colorMap Color Map
+
+  \sa colorMap(), QwtScaleWidget::setColorBarEnabled(),
+      QwtScaleWidget::setColorMap()
+*/
+void QwtPolarSpectrogram::setColorMap( QwtColorMap *colorMap )
+{
+    if ( d_data->colorMap != colorMap )
+    {
+        delete d_data->colorMap;
+        d_data->colorMap = colorMap;
+    }
+
+    itemChanged();
+}
+
+/*!
+   \return Color Map used for mapping the intensity values to colors
+   \sa setColorMap()
+*/
+const QwtColorMap *QwtPolarSpectrogram::colorMap() const
+{
+    return d_data->colorMap;
+}
+
+/*!
+  Specify an attribute how to draw the curve
+
+  \param attribute Paint attribute
+  \param on On/Off
+  \sa testPaintAttribute()
+*/
+void QwtPolarSpectrogram::setPaintAttribute( PaintAttribute attribute, bool on )
+{
+    if ( on )
+        d_data->paintAttributes |= attribute;
+    else
+        d_data->paintAttributes &= ~attribute;
+}
+
+/*!
+    \param attribute Paint attribute
+    \return True, when attribute has been set
+    \sa setPaintAttribute()
+*/
+bool QwtPolarSpectrogram::testPaintAttribute( PaintAttribute attribute ) const
+{
+    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;
+}
+
+/*!
+  Draw the spectrogram
+
+  \param painter Painter
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param radius Radius of the complete plot area in painter coordinates
+  \param canvasRect Contents rect of the canvas in painter coordinates
+*/
+void QwtPolarSpectrogram::draw( QPainter *painter,
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, double,
+    const QRectF &canvasRect ) const
+{
+    const QRectF plotRect = plot()->plotRect( canvasRect.toRect() );
+
+    QRegion clipRegion( canvasRect.toRect() );
+    if ( qwtNeedsClipping( plotRect, canvasRect ) )
+    {
+        // For large plotRects the ellipse becomes a huge polygon.
+        // So we better clip only, when we really need to.
+
+        clipRegion &= QRegion( plotRect.toRect(), QRegion::Ellipse );
+    }
+
+    QRect imageRect = canvasRect.toRect();
+
+    if ( painter->hasClipping() )
+        imageRect &= painter->clipRegion().boundingRect();
+
+    const QwtInterval radialInterval =
+        boundingInterval( QwtPolar::ScaleRadius );
+    if ( radialInterval.isValid() )
+    {
+        const double radius = radialMap.transform( radialInterval.maxValue() ) -
+                              radialMap.transform( radialInterval.minValue() );
+
+        QRectF r( 0, 0, 2 * radius, 2 * radius );
+        r.moveCenter( pole );
+
+        clipRegion &= QRegion( r.toRect(), QRegion::Ellipse );;
+
+        imageRect &= r.toRect();
+    }
+
+    const QImage image = renderImage( azimuthMap, radialMap, pole, imageRect );
+
+    painter->save();
+    painter->setClipRegion( clipRegion );
+
+    painter->drawImage( imageRect, image );
+
+    painter->restore();
+}
+
+/*!
+   \brief Render an image from the data and color map.
+
+   The area is translated into a rect of the paint device.
+   For each pixel of this rect the intensity is mapped
+   into a color.
+
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param rect Target rectangle of the image in painter coordinates
+
+   \return A QImage::Format_Indexed8 or QImage::Format_ARGB32 depending
+           on the color map.
+
+   \sa QwtRasterData::intensity(), QwtColorMap::rgb(),
+       QwtColorMap::colorIndex()
+*/
+QImage QwtPolarSpectrogram::renderImage(
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, const QRect &rect ) const
+{
+    if ( d_data->data == NULL || d_data->colorMap == NULL )
+        return QImage();
+
+    QImage image( rect.size(), d_data->colorMap->format() == QwtColorMap::RGB
+                  ? QImage::Format_ARGB32 : QImage::Format_Indexed8 );
+
+    const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
+    if ( !intensityRange.isValid() )
+        return image;
+
+    if ( d_data->colorMap->format() == QwtColorMap::Indexed )
+        image.setColorTable( d_data->colorMap->colorTable( intensityRange ) );
+
+    /*
+     For the moment we only announce the composition of the image by
+     calling initRaster(), but we don't pass any useful parameters.
+     ( How to map rect into something, that is useful to initialize a matrix
+       of values in polar coordinates ? )
+     */
+    d_data->data->initRaster( QRectF(), QSize() );
+
+
+#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
+    uint numThreads = d_data->renderThreadCount;
+
+    if ( numThreads <= 0 )
+        numThreads = QThread::idealThreadCount();
+
+    if ( numThreads <= 0 )
+        numThreads = 1;
+
+    const int numRows = rect.height() / numThreads;
+
+
+    QVector<TileInfo> tileInfos;
+    for ( uint i = 0; i < numThreads; i++ )
+    {
+        QRect tile( rect.x(), rect.y() + i * numRows, rect.width(), numRows );
+        if ( i == numThreads - 1 )
+            tile.setHeight( rect.height() - i * numRows );
+
+        TileInfo tileInfo;
+        tileInfo.imagePos = rect.topLeft();
+        tileInfo.rect = tile;
+        tileInfo.image = &image;
+
+        tileInfos += tileInfo;
+    }
+
+    QVector< QFuture<void> > futures;
+    for ( int i = 0; i < tileInfos.size(); i++ )
+    {
+        if ( i == tileInfos.size() - 1 )
+        {
+            renderTile( azimuthMap, radialMap, pole, &tileInfos[i] );
+        }
+        else
+        {
+            futures += QtConcurrent::run( this, &QwtPolarSpectrogram::renderTile,
+                azimuthMap, radialMap, pole, &tileInfos[i] );
+        }
+    }
+    for ( int i = 0; i < futures.size(); i++ )
+        futures[i].waitForFinished();
+
+#else // QT_VERSION < 0x040400
+    renderTile( azimuthMap, radialMap, pole, rect.topLeft(), rect, &image );
+#endif
+
+    d_data->data->discardRaster();
+
+    return image;
+}
+
+void QwtPolarSpectrogram::renderTile(
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, TileInfo *tileInfo ) const
+{
+    renderTile( azimuthMap, radialMap, pole,
+        tileInfo->imagePos, tileInfo->rect, tileInfo->image );
+}
+
+/*!
+  \brief Render a sub-rectangle of an image 
+
+  renderTile() is called by renderImage() to render different parts
+  of the image by concurrent threads.
+
+  \param azimuthMap Maps azimuth values to values related to 0.0, M_2PI
+  \param radialMap Maps radius values into painter coordinates.
+  \param pole Position of the pole in painter coordinates
+  \param imagePos Top/left position of the image in painter coordinates
+  \param tile Sub-rectangle of the tile in painter coordinates
+  \param image Image to be rendered
+
+   \sa setRenderThreadCount()
+   \note renderTile needs to be reentrant
+*/
+void QwtPolarSpectrogram::renderTile(
+    const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+    const QPointF &pole, const QPoint &imagePos,
+    const QRect &tile, QImage *image ) const
+{
+    const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
+    if ( !intensityRange.isValid() )
+        return;
+
+    const bool doFastAtan = testPaintAttribute( ApproximatedAtan );
+
+    const int y0 = imagePos.y();
+    const int y1 = tile.top();
+    const int y2 = tile.bottom();
+
+    const int x0 = imagePos.x();
+    const int x1 = tile.left();
+    const int x2 = tile.right();
+
+    if ( d_data->colorMap->format() == QwtColorMap::RGB )
+    {
+        for ( int y = y1; y <= y2; y++ )
+        {
+            const double dy = pole.y() - y;
+            const double dy2 = qwtSqr( dy );
+
+            QRgb *line = reinterpret_cast<QRgb *>( image->scanLine( y - y0 ) );
+            line += x1 - x0;
+
+            for ( int x = x1; x <= x2; x++ )
+            {
+                const double dx = x - pole.x();
+
+                double a =  doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
+                if ( a < 0.0 )
+                    a += 2 * M_PI;
+                if ( a < azimuthMap.p1() )
+                    a += 2 * M_PI;
+
+                const double r = qSqrt( qwtSqr( dx ) + dy2 );
+
+                const double azimuth = azimuthMap.invTransform( a );
+                const double radius = radialMap.invTransform( r );
+
+                const double value = d_data->data->value( azimuth, radius );
+                *line++ = d_data->colorMap->rgb( intensityRange, value );
+            }
+        }
+    }
+    else if ( d_data->colorMap->format() == QwtColorMap::Indexed )
+    {
+        for ( int y = y1; y <= y2; y++ )
+        {
+            const double dy = pole.y() - y;
+            const double dy2 = qwtSqr( dy );
+
+            unsigned char *line = image->scanLine( y - y0 );
+            line += x1 - x0;
+            for ( int x = x1; x <= x2; x++ )
+            {
+                const double dx = x - pole.x();
+
+                double a =  doFastAtan ? qwtFastAtan2( dy, dx ) : qAtan2( dy, dx );
+                if ( a < 0.0 )
+                    a += 2 * M_PI;
+                if ( a < azimuthMap.p1() )
+                    a += 2 * M_PI;
+
+                const double r = qSqrt( qwtSqr( dx ) + dy2 );
+
+                const double azimuth = azimuthMap.invTransform( a );
+                const double radius = radialMap.invTransform( r );
+
+                const double value = d_data->data->value( azimuth, radius );
+                *line++ = d_data->colorMap->colorIndex( intensityRange, value );
+            }
+        }
+    }
+}
+
+/*!
+   Interval, that is necessary to display the item
+   This interval can be useful for operations like clipping or autoscaling
+
+   \param scaleId Scale index
+   \return bounding interval ( == position )
+
+   \sa position()
+*/
+QwtInterval QwtPolarSpectrogram::boundingInterval( int scaleId ) const
+{
+    if ( scaleId == QwtPolar::ScaleRadius )
+        return d_data->data->interval( Qt::YAxis );
+
+    return QwtPolarItem::boundingInterval( scaleId );
+}
Index: /trunk/BNC/qwtpolar/qwt_polar_spectrogram.h
===================================================================
--- /trunk/BNC/qwtpolar/qwt_polar_spectrogram.h	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwt_polar_spectrogram.h	(revision 4272)
@@ -0,0 +1,95 @@
+/* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
+ * QwtPolar Widget Library
+ * Copyright (C) 2008   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_POLAR_SPECTROGRAM_H
+#define QWT_POLAR_SPECTROGRAM_H
+
+#include "qwt_polar_global.h"
+#include "qwt_polar_item.h"
+#include <qimage.h>
+
+class QwtRasterData;
+class QwtColorMap;
+
+/*!
+  \brief An item, which displays a spectrogram
+
+  A spectrogram displays threedimenional data, where the 3rd dimension
+  ( the intensity ) is displayed using colors. The colors are calculated
+  from the values using a color map.
+
+  \sa QwtRasterData, QwtColorMap
+*/
+class QWT_POLAR_EXPORT QwtPolarSpectrogram: public QwtPolarItem
+{
+public:
+    /*!
+        Attributes to modify the drawing algorithm.
+        The default setting disables ApproximatedAtan
+
+        \sa setPaintAttribute(), testPaintAttribute()
+    */
+    enum PaintAttribute
+    {
+        /*!
+           Use qwtFastAtan2 instead of atan2 for translating
+           widget into polar coordinates.
+         */
+
+        ApproximatedAtan = 0x01
+    };
+
+    //! Paint attributes
+    typedef QFlags<PaintAttribute> PaintAttributes;
+
+    explicit QwtPolarSpectrogram();
+    virtual ~QwtPolarSpectrogram();
+
+    void setData( QwtRasterData *data );
+    const QwtRasterData *data() const;
+
+    void setColorMap( QwtColorMap * );
+    const QwtColorMap *colorMap() const;
+
+    void setPaintAttribute( PaintAttribute, bool on = true );
+    bool testPaintAttribute( PaintAttribute ) const;
+
+    void setRenderThreadCount( uint numThreads );
+    uint renderThreadCount() const;
+
+    virtual int rtti() const;
+
+    virtual void draw( QPainter *painter,
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, double radius,
+        const QRectF &canvasRect ) const;
+
+    virtual QwtInterval boundingInterval( int scaleId ) const;
+
+protected:
+    virtual QImage renderImage(
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, const QRect &rect ) const;
+
+    virtual void renderTile(
+        const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
+        const QPointF &pole, const QPoint &imagePos,
+        const QRect &tile, QImage *image ) const;
+
+private:
+    class TileInfo;
+    void renderTile( const QwtScaleMap &, const QwtScaleMap &,
+        const QPointF &pole, TileInfo * ) const;
+
+    class PrivateData;
+    PrivateData *d_data;
+};
+
+Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarSpectrogram::PaintAttributes )
+
+#endif
Index: /trunk/BNC/qwtpolar/qwtpolar.pro
===================================================================
--- /trunk/BNC/qwtpolar/qwtpolar.pro	(revision 4272)
+++ /trunk/BNC/qwtpolar/qwtpolar.pro	(revision 4272)
@@ -0,0 +1,40 @@
+
+TEMPLATE = lib
+TARGET   = qwtpolar
+CONFIG  += qt qwt staticlib
+DEFINES += QWT_POLAR_NO_SVG
+
+HEADERS += \
+    qwt_polar_global.h \
+    qwt_polar.h \
+    qwt_polar_fitter.h \
+    qwt_polar_item.h \
+    qwt_polar_picker.h \
+    qwt_polar_panner.h \
+    qwt_polar_magnifier.h \
+    qwt_polar_grid.h \
+    qwt_polar_curve.h \
+    qwt_polar_spectrogram.h \
+    qwt_polar_marker.h \
+    qwt_polar_itemdict.h \
+    qwt_polar_canvas.h \
+    qwt_polar_layout.h \
+    qwt_polar_renderer.h \
+    qwt_polar_plot.h
+
+SOURCES += \
+    qwt_polar_fitter.cpp \
+    qwt_polar_item.cpp \
+    qwt_polar_picker.cpp \
+    qwt_polar_panner.cpp \
+    qwt_polar_magnifier.cpp \
+    qwt_polar_grid.cpp \
+    qwt_polar_curve.cpp \
+    qwt_polar_spectrogram.cpp \
+    qwt_polar_marker.cpp \
+    qwt_polar_itemdict.cpp \
+    qwt_polar_canvas.cpp \
+    qwt_polar_layout.cpp \
+    qwt_polar_renderer.cpp \
+    qwt_polar_plot.cpp
+
