Advertisement
Guest User

e4835fb42b914327192e87f9f8ede970d82bdc50.patch

a guest
Dec 16th, 2013
33
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 57.47 KB | None | 0 0
  1. From e4835fb42b914327192e87f9f8ede970d82bdc50 Mon Sep 17 00:00:00 2001
  2. From: Brandon Wood <btwood@geometeor.com>
  3. Date: Sun, 17 Nov 2013 17:22:25 -0500
  4. Subject: [PATCH] Modified QwtPolar to be up-to-date (trunk), removed incorrect
  5.  requirement stating that QwtPolar was incompatible with Qwt >= 6.1
  6.  
  7. ---
  8.  src/app/CMakeLists.txt                             |   4 -
  9.  src/app/gps/qwtpolar-1.0/qwt_polar_canvas.cpp      |  30 ++-
  10.  src/app/gps/qwtpolar-1.0/qwt_polar_curve.cpp       | 129 ++++-------
  11.  src/app/gps/qwtpolar-1.0/qwt_polar_curve.h         |  10 +-
  12.  src/app/gps/qwtpolar-1.0/qwt_polar_global.h        |  14 +-
  13.  src/app/gps/qwtpolar-1.0/qwt_polar_grid.cpp        |  21 +-
  14.  src/app/gps/qwtpolar-1.0/qwt_polar_item.cpp        | 216 ++++++++++--------
  15.  src/app/gps/qwtpolar-1.0/qwt_polar_item.h          |  30 +--
  16.  src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.cpp    |  28 +--
  17.  src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.h      |   8 +-
  18.  src/app/gps/qwtpolar-1.0/qwt_polar_layout.cpp      |  22 +-
  19.  src/app/gps/qwtpolar-1.0/qwt_polar_picker.cpp      |   3 +-
  20.  src/app/gps/qwtpolar-1.0/qwt_polar_plot.cpp        | 243 ++++++++++++++-------
  21.  src/app/gps/qwtpolar-1.0/qwt_polar_plot.h          |  54 ++---
  22.  src/app/gps/qwtpolar-1.0/qwt_polar_renderer.cpp    | 144 ++++++------
  23.  src/app/gps/qwtpolar-1.0/qwt_polar_renderer.h      |  13 +-
  24.  src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp |  40 +---
  25.  src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.h   |   3 -
  26.  18 files changed, 557 insertions(+), 455 deletions(-)
  27.  
  28. diff --git a/src/app/CMakeLists.txt b/src/app/CMakeLists.txt
  29. index b232140..bf9faad 100644
  30. --- a/src/app/CMakeLists.txt
  31. +++ b/src/app/CMakeLists.txt
  32. @@ -323,10 +323,6 @@ IF(WITH_INTERNAL_QWTPOLAR)
  33.  
  34.      SET(QWTPOLAR_INCLUDE_DIR gps/qwtpolar-0.1)
  35.    ELSE(QWT_VERSION_STR VERSION_LESS "6.0.0")
  36. -    IF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
  37. -      MESSAGE(FATAL_ERROR "Internal QwtPolar does not support Qwt 6.1 and above")
  38. -    ENDIF(NOT QWT_VERSION_STR VERSION_LESS "6.1.0")
  39. -
  40.      SET(QGIS_APP_SRCS
  41.        ${QGIS_APP_SRCS}
  42.        gps/qwtpolar-1.0/qwt_polar_canvas.cpp
  43. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_canvas.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_canvas.cpp
  44. index d7144ec..ae29bab 100644
  45. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_canvas.cpp
  46. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_canvas.cpp
  47. @@ -8,6 +8,7 @@
  48.  
  49.  #include "qwt_polar_canvas.h"
  50.  #include "qwt_polar_plot.h"
  51. +#include <qwt_painter.h>
  52.  #include <qpainter.h>
  53.  #include <qevent.h>
  54.  #include <qpixmap.h>
  55. @@ -212,7 +213,10 @@ void QwtPolarCanvas::paintEvent( QPaintEvent *event )
  56.                  else
  57.                  {
  58.                      QWidget *bgWidget = qwtBackgroundWidget( plot() );
  59. -                    bs.fill( bgWidget, mapTo( bgWidget, rect().topLeft() ) );
  60. +
  61. +                   QwtPainter::fillPixmap( bgWidget, bs,
  62. +                       mapTo( bgWidget, rect().topLeft() ) );
  63. +
  64.                      p.begin( &bs );
  65.                  }
  66.              }
  67. @@ -263,12 +267,30 @@ QwtPointPolar QwtPolarCanvas::invTransform( const QPoint &pos ) const
  68.      const QwtScaleMap azimuthMap = pl->scaleMap( QwtPolar::Azimuth );
  69.      const QwtScaleMap radialMap = pl->scaleMap( QwtPolar::Radius );
  70.  
  71. -    double dx = pos.x() - pl->plotRect().center().x();
  72. -    double dy = -( pos.y() - pl->plotRect().center().y() );
  73. +    const QPointF center = pl->plotRect().center();
  74. +
  75. +    double dx = pos.x() - center.x();
  76. +    double dy = -( pos.y() - center.y() );
  77.  
  78.      const QwtPointPolar polarPos = QwtPointPolar( QPoint( dx, dy ) ).normalized();
  79.  
  80. -    const double azimuth = azimuthMap.invTransform( polarPos.azimuth() );
  81. +    double azimuth = azimuthMap.invTransform( polarPos.azimuth() );
  82. +
  83. +    // normalize the azimuth
  84. +    double min = azimuthMap.s1();
  85. +    double max = azimuthMap.s2();
  86. +    if ( max < min )
  87. +        qSwap( min, max );
  88. +
  89. +    if ( azimuth < min )
  90. +    {
  91. +        azimuth += max - min;
  92. +    }
  93. +    else if ( azimuth > max )
  94. +    {
  95. +        azimuth -= max - min;
  96. +    }
  97. +
  98.      const double radius = radialMap.invTransform( polarPos.radius() );
  99.  
  100.      return QwtPointPolar( azimuth, radius );
  101. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_curve.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_curve.cpp
  102. index d63206a..e356455 100644
  103. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_curve.cpp
  104. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_curve.cpp
  105. @@ -7,13 +7,12 @@
  106.   *****************************************************************************/
  107.  
  108.  #include "qwt_polar_curve.h"
  109. +#include "qwt_polar.h"
  110.  #include <qwt_painter.h>
  111. -#include <qwt_polar.h>
  112.  #include <qwt_scale_map.h>
  113.  #include <qwt_math.h>
  114.  #include <qwt_symbol.h>
  115.  #include <qwt_legend.h>
  116. -#include <qwt_legend_item.h>
  117.  #include <qwt_curve_fitter.h>
  118.  #include <qwt_clipper.h>
  119.  #include <qpainter.h>
  120. @@ -173,7 +172,7 @@ void QwtPolarCurve::setStyle( CurveStyle style )
  121.    \param symbol Symbol
  122.    \sa symbol()
  123.  */
  124. -void QwtPolarCurve::setSymbol( const QwtSymbol *symbol )
  125. +void QwtPolarCurve::setSymbol( QwtSymbol *symbol )
  126.  {
  127.      if ( symbol != d_data->symbol )
  128.      {
  129. @@ -388,7 +387,7 @@ void QwtPolarCurve::drawLines( QPainter *painter,
  130.          polyline.resize( points.size() );
  131.  
  132.          QPointF *polylineData = polyline.data();
  133. -        QPointF *pointsData = polyline.data();
  134. +        QPointF *pointsData = points.data();
  135.  
  136.          for ( int i = 0; i < points.size(); i++ )
  137.          {
  138. @@ -433,7 +432,7 @@ void QwtPolarCurve::drawLines( QPainter *painter,
  139.  
  140.      if ( !clipRect.isEmpty() )
  141.      {
  142. -        double off = qCeil( qMax( 1.0, painter->pen().widthF() ) );
  143. +        double off = qCeil( qMax( qreal( 1.0 ), painter->pen().widthF() ) );
  144.          clipRect = clipRect.toRect().adjusted( -off, -off, off, off );
  145.          polyline = QwtClipper::clipPolygonF( clipRect, polyline );
  146.      }
  147. @@ -500,116 +499,76 @@ size_t QwtPolarCurve::dataSize() const
  148.      return d_series->size();
  149.  }
  150.  
  151. -//!  Update the widget that represents the curve on the legend
  152. -void QwtPolarCurve::updateLegend( QwtLegend *legend ) const
  153. -{
  154. -    if ( legend && testItemAttribute( QwtPolarCurve::Legend )
  155. -            && ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
  156. -            && d_data->symbol
  157. -            && d_data->symbol->style() != QwtSymbol::NoSymbol )
  158. -    {
  159. -        QWidget *lgdItem = legend->find( this );
  160. -        if ( lgdItem == NULL )
  161. -        {
  162. -            lgdItem = legendItem();
  163. -            if ( lgdItem )
  164. -                legend->insert( this, lgdItem );
  165. -        }
  166. -
  167. -        QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
  168. -        if ( l )
  169. -        {
  170. -            QSize sz = d_data->symbol->boundingSize();
  171. -            sz += QSize( 2, 2 ); // margin
  172. -
  173. -            if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
  174. -            {
  175. -                // Avoid, that the line is completely covered by the symbol
  176. -
  177. -                int w = qCeil( 1.5 * sz.width() );
  178. -                if ( w % 2 )
  179. -                    w++;
  180. -
  181. -                sz.setWidth( qMax( 8, w ) );
  182. -            }
  183. -
  184. -            l->setIdentifierSize( sz );
  185. -        }
  186. -    }
  187. -
  188. -    QwtPolarItem::updateLegend( legend );
  189. -}
  190. -
  191.  /*!
  192. -  \brief Draw the identifier representing the curve on the legend
  193. +   \return Icon representing the curve on the legend
  194.  
  195. -  \param painter Qt Painter
  196. -  \param rect Bounding rectangle for the identifier
  197. +   \param index Index of the legend entry
  198. +                ( ignored as there is only one )
  199. +   \param size Icon size
  200.  
  201. -  \sa setLegendAttribute
  202. -*/
  203. -void QwtPolarCurve::drawLegendIdentifier(
  204. -    QPainter *painter, const QRectF &rect ) const
  205. +   \sa QwtPolarItem::setLegendIconSize(), QwtPolarItem::legendData()
  206. + */
  207. +QwtGraphic QwtPolarCurve::legendIcon( int index,
  208. +    const QSizeF &size ) const
  209.  {
  210. -    if ( rect.isEmpty() )
  211. -        return;
  212. +    Q_UNUSED( index );
  213.  
  214. -    const double dim = qMin( rect.width(), rect.height() );
  215. +    if ( size.isEmpty() )
  216. +        return QwtGraphic();
  217.  
  218. -    QSizeF size( dim, dim );
  219. +    QwtGraphic graphic;
  220. +    graphic.setDefaultSize( size );
  221. +    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
  222.  
  223. -    QRectF r( 0, 0, size.width(), size.height() );
  224. -    r.moveCenter( rect.center() );
  225. +    QPainter painter( &graphic );
  226. +    painter.setRenderHint( QPainter::Antialiasing,
  227. +        testRenderHint( QwtPolarItem::RenderAntialiased ) );
  228.  
  229.      if ( d_data->legendAttributes == 0 )
  230.      {
  231.          QBrush brush;
  232. +
  233.          if ( style() != QwtPolarCurve::NoCurve )
  234. +        {
  235.              brush = QBrush( pen().color() );
  236. +        }
  237.          else if ( d_data->symbol &&
  238.              ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
  239.          {
  240.              brush = QBrush( d_data->symbol->pen().color() );
  241.          }
  242. +
  243.          if ( brush.style() != Qt::NoBrush )
  244. -            painter->fillRect( r, brush );
  245. +        {
  246. +            QRectF r( 0, 0, size.width(), size.height() );
  247. +            painter.fillRect( r, brush );
  248. +        }
  249.      }
  250. +
  251.      if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
  252.      {
  253.          if ( pen() != Qt::NoPen )
  254.          {
  255. -            painter->setPen( pen() );
  256. -            QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
  257. -                rect.right() - 1.0, rect.center().y() );
  258. +            QPen pn = pen();
  259. +            pn.setCapStyle( Qt::FlatCap );
  260. +
  261. +            painter.setPen( pn );
  262. +
  263. +            const double y = 0.5 * size.height();
  264. +            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
  265.          }
  266.      }
  267. +
  268.      if ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
  269.      {
  270. -        if ( d_data->symbol &&
  271. -            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
  272. +        if ( d_data->symbol )
  273.          {
  274. -            QSize symbolSize = d_data->symbol->boundingSize();
  275. -            symbolSize -= QSize( 2, 2 );
  276. -
  277. -            // scale the symbol size down if it doesn't fit into rect.
  278. -
  279. -            double xRatio = 1.0;
  280. -            if ( rect.width() < symbolSize.width() )
  281. -                xRatio = rect.width() / symbolSize.width();
  282. -            double yRatio = 1.0;
  283. -            if ( rect.height() < symbolSize.height() )
  284. -                yRatio = rect.height() / symbolSize.height();
  285. -
  286. -            const double ratio = qMin( xRatio, yRatio );
  287. -
  288. -            painter->save();
  289. -            painter->scale( ratio, ratio );
  290. -
  291. -            d_data->symbol->drawSymbol( painter, rect.center() / ratio );
  292. -
  293. -            painter->restore();
  294. +            QRectF r( 0, 0, size.width(), size.height() );
  295. +            d_data->symbol->drawSymbol( &painter, r );
  296.         }
  297.     }
  298. +
  299. +    return graphic;
  300. }
  301.  
  302. /*!
  303. @@ -633,3 +592,5 @@ QwtInterval QwtPolarCurve::boundingInterval( int scaleId ) const
  304.  
  305.     return QwtInterval();
  306. }
  307. +
  308. +
  309. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_curve.h b/src/app/gps/qwtpolar-1.0/qwt_polar_curve.h
  310. index 8143795..a474522 100644
  311. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_curve.h
  312. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_curve.h
  313. @@ -57,8 +57,7 @@ class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
  314.         a color representing the curve and paints a rectangle with it.
  315.         In the default setting all attributes are off.
  316.  
  317. -        \sa setLegendAttribute(), testLegendAttribute(),
  318. -            drawLegendIdentifier()
  319. +        \sa setLegendAttribute(), testLegendAttribute()
  320.      */
  321.  
  322.     enum LegendAttribute
  323. @@ -100,7 +99,7 @@ class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
  324.     void setStyle( CurveStyle style );
  325.     CurveStyle style() const;
  326.  
  327. -    void setSymbol( const QwtSymbol * );
  328. +    void setSymbol( QwtSymbol * );
  329.     const QwtSymbol *symbol() const;
  330.  
  331.     void setCurveFitter( QwtCurveFitter * );
  332. @@ -115,10 +114,9 @@ class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
  333.         const QwtScaleMap &azimuthMap, const QwtScaleMap &radialMap,
  334.         const QPointF &pole, int from, int to ) const;
  335.  
  336. -    virtual void updateLegend( QwtLegend * ) const;
  337.     virtual QwtInterval boundingInterval( int scaleId ) const;
  338.  
  339. -    virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
  340. +    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
  341.  
  342. protected:
  343.  
  344. @@ -143,7 +141,7 @@ class QWT_POLAR_EXPORT QwtPolarCurve: public QwtPolarItem
  345.     PrivateData *d_data;
  346. };
  347.  
  348. -//! \return the curve data
  349. +//! \return the the curve data
  350. inline const QwtSeriesData<QwtPointPolar> *QwtPolarCurve::data() const
  351. {
  352.     return d_series;
  353. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_global.h b/src/app/gps/qwtpolar-1.0/qwt_polar_global.h
  354. index 2437a43..b8b70fa 100644
  355. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_global.h
  356. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_global.h
  357. @@ -13,10 +13,8 @@
  358.  
  359. // QWT_POLAR_VERSION is (major << 16) + (minor << 8) + patch.
  360.  
  361. -#define QWT_POLAR_VERSION       0x010000
  362. -#define QWT_POLAR_VERSION_STR   "1.0.0"
  363. -
  364. -#if defined(Q_WS_WIN) || defined(Q_WS_S60)
  365. +#define QWT_POLAR_VERSION       0x010100
  366. +#define QWT_POLAR_VERSION_STR   "1.1.0"
  367.  
  368. #if defined(_MSC_VER) /* MSVC Compiler */
  369. /* template-class specialization 'identifier' is already instantiated */
  370. @@ -25,16 +23,14 @@
  371.  
  372. #ifdef QWT_POLAR_DLL
  373.  
  374. -#if defined(QWT_POLAR_MAKEDLL)     // create a Qwt DLL library
  375. +#if defined(QWT_POLAR_MAKEDLL)     // create DLL library
  376. #define QWT_POLAR_EXPORT  __declspec(dllexport)
  377. #define QWT_POLAR_TEMPLATEDLL
  378. -#else                        // use a Qwt DLL library
  379. +#else                        // use DLL library
  380. #define QWT_POLAR_EXPORT  __declspec(dllimport)
  381. #endif
  382.  
  383. -#endif // QWT_POLAR_MAKEDLL
  384. -
  385. -#endif // Q_WS_WIN
  386. +#endif // QWT_POLAR_DLL
  387.  
  388. #ifndef QWT_POLAR_EXPORT
  389. #define QWT_POLAR_EXPORT
  390. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_grid.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_grid.cpp
  391. index 7fa0cfb..3ea1ca4 100644
  392. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_grid.cpp
  393. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_grid.cpp
  394. @@ -876,7 +876,12 @@ void QwtPolarGrid::updateScaleDraws(
  395.                 from += 360.0;
  396.  
  397.             scaleDraw->setAngleRange( from, from - 360.0 );
  398. -            scaleDraw->setTransformation( azimuthMap.transformation()->copy() );
  399. +
  400. +            const QwtTransform *transform = azimuthMap.transformation();
  401. +            if ( transform )
  402. +                scaleDraw->setTransformation( transform->copy() );
  403. +            else
  404. +                scaleDraw->setTransformation( NULL );
  405.         }
  406.         else
  407.         {
  408. @@ -910,7 +915,11 @@ void QwtPolarGrid::updateScaleDraws(
  409.                     break;
  410.                 }
  411.             }
  412. -            scaleDraw->setTransformation( radialMap.transformation()->copy() );
  413. +            const QwtTransform *transform = radialMap.transformation();
  414. +            if ( transform )
  415. +                scaleDraw->setTransformation( transform->copy() );
  416. +            else
  417. +                scaleDraw->setTransformation( NULL );
  418.         }
  419.     }
  420. }
  421. @@ -975,8 +984,7 @@ void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
  422.             {
  423.                 QwtScaleDiv sd = radialGrid.scaleDiv;
  424.  
  425. -                QList<double> &ticks =
  426. -                    const_cast<QList<double> &>( sd.ticks( QwtScaleDiv::MajorTick ) );
  427. +                QList<double> ticks = sd.ticks( QwtScaleDiv::MajorTick );
  428.  
  429.                 if ( testDisplayFlag( SmartOriginLabel ) )
  430.                 {
  431. @@ -1010,6 +1018,7 @@ void QwtPolarGrid::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
  432.                         ticks.removeLast();
  433.                 }
  434.  
  435. +                sd.setTicks( QwtScaleDiv::MajorTick, ticks );
  436.                 axis.scaleDraw->setScaleDiv( sd );
  437.  
  438.                 if ( testDisplayFlag( SmartScaleDraw ) )
  439. @@ -1048,7 +1057,7 @@ int QwtPolarGrid::marginHint() const
  440. */
  441. const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
  442. {
  443. -    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
  444. +    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
  445.         return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
  446.  
  447.     return NULL;
  448. @@ -1063,7 +1072,7 @@ const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
  449. */
  450. QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
  451. {
  452. -    if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
  453. +    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
  454.         return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
  455.  
  456.     return NULL;
  457. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_item.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_item.cpp
  458. index 1541295..7d7895d 100644
  459. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_item.cpp
  460. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_item.cpp
  461. @@ -9,7 +9,7 @@
  462. #include "qwt_polar_plot.h"
  463. #include "qwt_polar_item.h"
  464. #include <qwt_legend.h>
  465. -#include <qwt_legend_item.h>
  466. +#include <qwt_scale_div.h>
  467. #include <qpainter.h>
  468.  
  469. class QwtPolarItem::PrivateData
  470. @@ -20,7 +20,9 @@ class QwtPolarItem::PrivateData
  471.         isVisible( true ),
  472.         attributes( 0 ),
  473.         renderHints( 0 ),
  474. -        z( 0.0 )
  475. +        renderThreadCount( 1 ),
  476. +        z( 0.0 ),
  477. +        legendIconSize( 8, 8 )
  478.     {
  479.     }
  480.  
  481. @@ -29,9 +31,12 @@ class QwtPolarItem::PrivateData
  482.     bool isVisible;
  483.     QwtPolarItem::ItemAttributes attributes;
  484.     QwtPolarItem::RenderHints renderHints;
  485. +    uint renderThreadCount;
  486. +
  487.     double z;
  488.  
  489.     QwtText title;
  490. +    QSize legendIconSize;
  491. };
  492.  
  493. /*!
  494. @@ -72,28 +77,25 @@ void QwtPolarItem::attach( QwtPolarPlot *plot )
  495.     if ( plot == d_data->plot )
  496.         return;
  497.  
  498. -    // remove the item from the previous plot
  499. -
  500.     if ( d_data->plot )
  501. -    {
  502. -        if ( d_data->plot->legend() )
  503. -            d_data->plot->legend()->remove( this );
  504. -
  505.         d_data->plot->attachItem( this, false );
  506.  
  507. -        if ( d_data->plot->autoReplot() )
  508. -            d_data->plot->update();
  509. -    }
  510. -
  511.     d_data->plot = plot;
  512.  
  513.     if ( d_data->plot )
  514. -    {
  515. -        // insert the item into the current plot
  516. -
  517.         d_data->plot->attachItem( this, true );
  518. -        itemChanged();
  519. -    }
  520. +}
  521. +
  522. +/*!
  523. +   \brief This method detaches a QwtPolarItem from the QwtPolarPlot it
  524. +          has been associated with.
  525. +
  526. +   detach() is equivalent to calling attach( NULL )
  527. +   \sa attach()
  528. +*/
  529. +void QwtPolarItem::detach()
  530. +{
  531. +    attach( NULL );
  532. }
  533.  
  534. /*!
  535. @@ -255,6 +257,60 @@ bool QwtPolarItem::testRenderHint( RenderHint hint ) const
  536.     return ( d_data->renderHints & hint );
  537. }
  538.  
  539. +/*!
  540. +   On multi core systems rendering of certain plot item
  541. +   ( f.e QwtPolarSpectrogram ) can be done in parallel in
  542. +   several threads.
  543. +
  544. +   The default setting is set to 1.
  545. +
  546. +   \param numThreads Number of threads to be used for rendering.
  547. +                     If numThreads is set to 0, the system specific
  548. +                     ideal thread count is used.
  549. +
  550. +   The default thread count is 1 ( = no additional threads )
  551. +*/
  552. +void QwtPolarItem::setRenderThreadCount( uint numThreads )
  553. +{
  554. +    d_data->renderThreadCount = numThreads;
  555. +}
  556. +
  557. +/*!
  558. +   \return Number of threads to be used for rendering.
  559. +           If numThreads() is set to 0, the system specific
  560. +           ideal thread count is used.
  561. +*/
  562. +uint QwtPolarItem::renderThreadCount() const
  563. +{
  564. +    return d_data->renderThreadCount;
  565. +}
  566. +
  567. +/*!
  568. +   Set the size of the legend icon
  569. +
  570. +   The default setting is 8x8 pixels
  571. +
  572. +   \param size Size
  573. +   \sa legendIconSize(), legendIcon()
  574. +*/
  575. +void QwtPolarItem::setLegendIconSize( const QSize &size )
  576. +{
  577. +    if ( d_data->legendIconSize != size )
  578. +    {
  579. +        d_data->legendIconSize = size;
  580. +        legendChanged();
  581. +    }
  582. +}
  583. +
  584. +/*!
  585. +   \return Legend icon size
  586. +   \sa setLegendIconSize(), legendIcon()
  587. +*/
  588. +QSize QwtPolarItem::legendIconSize() const
  589. +{
  590. +    return d_data->legendIconSize;
  591. +}
  592. +
  593. //! Show the item
  594. void QwtPolarItem::show()
  595. {
  596. @@ -300,12 +356,17 @@ bool QwtPolarItem::isVisible() const
  597. void QwtPolarItem::itemChanged()
  598. {
  599.     if ( d_data->plot )
  600. -    {
  601. -        if ( d_data->plot->legend() )
  602. -            updateLegend( d_data->plot->legend() );
  603. -
  604.         d_data->plot->autoRefresh();
  605. -    }
  606. +}
  607. +
  608. +/*!
  609. +   Update the legend of the parent plot.
  610. +   \sa QwtPolarPlot::updateLegend(), itemChanged()
  611. +*/
  612. +void QwtPolarItem::legendChanged()
  613. +{
  614. +    if ( testItemAttribute( QwtPolarItem::Legend ) && d_data->plot )
  615. +        d_data->plot->updateLegend( this );
  616. }
  617.  
  618. /*!
  619. @@ -349,86 +410,65 @@ void QwtPolarItem::updateScaleDiv( const QwtScaleDiv &azimuthScaleDiv,
  620. }
  621.  
  622. /*!
  623. -   \brief Update the widget that represents the item on the legend
  624. -
  625. -   updateLegend() is called from itemChanged() to adopt the widget
  626. -   representing the item on the legend to its new configuration.
  627. +   \brief Return all information, that is needed to represent
  628. +          the item on the legend
  629.  
  630. -   The default implementation is made for QwtPolarCurve and updates a
  631. -   QwtLegendItem(), but an item could be represented by any type of widget,
  632. -   by overloading legendItem() and updateLegend().
  633. +   Most items are represented by one entry on the legend
  634. +   showing an icon and a text.
  635.  
  636. -   \sa legendItem(), itemChanged(), QwtLegend()
  637. -*/
  638. -void QwtPolarItem::updateLegend( QwtLegend *legend ) const
  639. -{
  640. -    if ( legend == NULL )
  641. -        return;
  642. -
  643. -    QWidget *lgdItem = legend->find( this );
  644. -    if ( testItemAttribute( QwtPolarItem::Legend ) )
  645. -    {
  646. -        if ( lgdItem == NULL )
  647. -        {
  648. -            lgdItem = legendItem();
  649. -            if ( lgdItem )
  650. -                legend->insert( this, lgdItem );
  651. -        }
  652. -
  653. -        QwtLegendItem* label = qobject_cast<QwtLegendItem *>( lgdItem );
  654. -        if ( label )
  655. -        {
  656. -            // paint the identifier
  657. -            const QSize sz = label->identifierSize();
  658. -
  659. -            QPixmap identifier( sz.width(), sz.height() );
  660. -            identifier.fill( Qt::transparent );
  661. -
  662. -            QPainter painter( &identifier );
  663. -            painter.setRenderHint( QPainter::Antialiasing,
  664. -                testRenderHint( QwtPolarItem::RenderAntialiased ) );
  665. -
  666. -            drawLegendIdentifier( &painter,
  667. -                QRect( 0, 0, sz.width(), sz.height() ) );
  668. +   QwtLegendData is basically a list of QVariants that makes it
  669. +   possible to overload and reimplement legendData() to
  670. +   return almost any type of information, that is understood
  671. +   by the receiver that acts as the legend.
  672.  
  673. -            painter.end();
  674. +   The default implementation returns one entry with
  675. +   the title() of the item and the legendIcon().
  676.  
  677. -            const bool doUpdate = label->updatesEnabled();
  678. -            if ( doUpdate )
  679. -                label->setUpdatesEnabled( false );
  680. +   \sa title(), legendIcon(), QwtLegend
  681. + */
  682. +QList<QwtLegendData> QwtPolarItem::legendData() const
  683. +{
  684. +    QwtLegendData data;
  685.  
  686. -            label->setText( title() );
  687. -            label->setIdentifier( identifier );
  688. -            label->setItemMode( legend->itemMode() );
  689. +    QwtText label = title();
  690. +    label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
  691.  
  692. -            if ( doUpdate )
  693. -                label->setUpdatesEnabled( true );
  694. +    QVariant titleValue;
  695. +    qVariantSetValue( titleValue, label );
  696. +    data.setValue( QwtLegendData::TitleRole, titleValue );
  697.  
  698. -            label->update();
  699. -        }
  700. -    }
  701. -    else
  702. +    const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
  703. +    if ( !graphic.isNull() )
  704.     {
  705. -        if ( lgdItem )
  706. -        {
  707. -            lgdItem->hide();
  708. -            lgdItem->deleteLater();
  709. -        }
  710. +        QVariant iconValue;
  711. +        qVariantSetValue( iconValue, graphic );
  712. +        data.setValue( QwtLegendData::IconRole, iconValue );
  713.     }
  714. +
  715. +    QList<QwtLegendData> list;
  716. +    list += data;
  717. +
  718. +    return list;
  719. }
  720. +
  721. /*!
  722. -   \brief Allocate the widget that represents the item on the legend
  723. +   \return Icon representing the item on the legend
  724.  
  725. -   The default implementation is made for QwtPolarCurve and returns a
  726. -   QwtLegendItem(), but an item could be represented by any type of widget,
  727. -   by overloading legendItem() and updateLegend().
  728. +   The default implementation returns an invalid icon
  729.  
  730. -   \return QwtLegendItem()
  731. -   \sa updateLegend() QwtLegend()
  732. -*/
  733. -QWidget *QwtPolarItem::legendItem() const
  734. +   \param index Index of the legend entry
  735. +                ( usually there is only one )
  736. +   \param size Icon size
  737. +
  738. +   \sa setLegendIconSize(), legendData()
  739. + */
  740. +QwtGraphic QwtPolarItem::legendIcon(
  741. +    int index, const QSizeF &size ) const
  742. {
  743. -    return new QwtLegendItem;
  744. +    Q_UNUSED( index )
  745. +    Q_UNUSED( size )
  746. +
  747. +    return QwtGraphic();
  748. }
  749.  
  750. /*!
  751. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_item.h b/src/app/gps/qwtpolar-1.0/qwt_polar_item.h
  752. index 34446d7..f83ed94 100644
  753. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_item.h
  754. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_item.h
  755. @@ -11,7 +11,8 @@
  756.  
  757. #include "qwt_polar_global.h"
  758. #include <qwt_text.h>
  759. -#include <qwt_legend_itemmanager.h>
  760. +#include <qwt_legend_data.h>
  761. +#include <qwt_graphic.h>
  762. #include <qwt_interval.h>
  763.  
  764. class QString;
  765. @@ -33,7 +34,7 @@
  766.   but deriving from QwtPolarItem makes it easy to implement additional
  767.   types of items.
  768. */
  769. -class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  770. +class QWT_POLAR_EXPORT QwtPolarItem
  771. {
  772. public:
  773.     /*!
  774. @@ -102,15 +103,7 @@ class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  775.     virtual ~QwtPolarItem();
  776.  
  777.     void attach( QwtPolarPlot *plot );
  778. -
  779. -    /*!
  780. -       \brief This method detaches a QwtPolarItem from any QwtPolarPlot it
  781. -              has been associated with.
  782. -
  783. -       detach() is equivalent to calling attach( NULL )
  784. -       \sa attach( QwtPolarPlot* plot )
  785. -    */
  786. -    void detach() { attach( NULL ); }
  787. +    void detach();
  788.  
  789.     QwtPolarPlot *plot() const;
  790.  
  791. @@ -126,6 +119,9 @@ class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  792.     void setRenderHint( RenderHint, bool on = true );
  793.     bool testRenderHint( RenderHint ) const;
  794.  
  795. +    void setRenderThreadCount( uint numThreads );
  796. +    uint renderThreadCount() const;
  797. +
  798.     double z() const;
  799.     void setZ( double z );
  800.  
  801. @@ -135,6 +131,7 @@ class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  802.     bool isVisible () const;
  803.  
  804.     virtual void itemChanged();
  805. +    virtual void legendChanged();
  806.  
  807.     /*!
  808.       \brief Draw the item
  809. @@ -153,14 +150,17 @@ class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  810.  
  811.     virtual QwtInterval boundingInterval( int scaleId ) const;
  812.  
  813. -    virtual QWidget *legendItem() const;
  814. -
  815. -    virtual void updateLegend( QwtLegend * ) const;
  816.     virtual void updateScaleDiv( const QwtScaleDiv &,
  817.         const QwtScaleDiv &, const QwtInterval & );
  818.  
  819.     virtual int marginHint() const;
  820.  
  821. +    void setLegendIconSize( const QSize & );
  822. +    QSize legendIconSize() const;
  823. +
  824. +    virtual QList<QwtLegendData> legendData() const;
  825. +    virtual QwtGraphic legendIcon( int index, const QSizeF  & ) const;
  826. +
  827. private:
  828.     // Disabled copy constructor and operator=
  829.     QwtPolarItem( const QwtPolarItem & );
  830. @@ -173,4 +173,6 @@ class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
  831. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::ItemAttributes )
  832. Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
  833.  
  834. +Q_DECLARE_METATYPE( QwtPolarItem * )
  835. +
  836. #endif
  837. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
  838. index d239ac3..171aaac 100644
  839. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
  840. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.cpp
  841. @@ -109,23 +109,25 @@ bool QwtPolarItemDict::autoDelete() const
  842. }
  843.  
  844. /*!
  845. -   Attach/Detach a plot item
  846. +  Insert a plot item
  847.  
  848. -   Attached items will be deleted in the destructor,
  849. -   if auto deletion is enabled (default). Manually detached
  850. -   items are not deleted.
  851. +  \param item PlotItem
  852. +  \sa removeItem()
  853. + */
  854. +void QwtPolarItemDict::insertItem( QwtPolarItem *item )
  855. +{
  856. +    d_data->itemList.insertItem( item );
  857. +}
  858.  
  859. -   \param item Plot item to attach/detach
  860. -   \ on If true attach, else detach the item
  861. +/*!
  862. +  Remove a plot item
  863.  
  864. -   \sa setAutoDelete, ~QwtPolarItemDict
  865. -*/
  866. -void QwtPolarItemDict::attachItem( QwtPolarItem *item, bool on )
  867. +  \param item PlotItem
  868. +  \sa insertItem()
  869. + */
  870. +void QwtPolarItemDict::removeItem( QwtPolarItem *item )
  871. {
  872. -    if ( on )
  873. -        d_data->itemList.insertItem( item );
  874. -    else
  875. -        d_data->itemList.removeItem( item );
  876. +    d_data->itemList.removeItem( item );
  877. }
  878.  
  879. /*!
  880. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.h b/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.h
  881. index f24bd8f..862bc9d 100644
  882. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.h
  883. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_itemdict.h
  884. @@ -43,11 +43,11 @@ class QWT_POLAR_EXPORT QwtPolarItemDict
  885.     void detachItems( int rtti = QwtPolarItem::Rtti_PolarItem,
  886.         bool autoDelete = true );
  887.  
  888. -private:
  889. -    friend class QwtPolarItem;
  890. -
  891. -    void attachItem( QwtPolarItem *, bool );
  892. +protected:
  893. +    void insertItem( QwtPolarItem * );
  894. +    void removeItem( QwtPolarItem * );
  895.  
  896. +private:
  897.     class PrivateData;
  898.     PrivateData *d_data;
  899. };
  900. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_layout.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_layout.cpp
  901. index 1db2379..ed99294 100644
  902. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_layout.cpp
  903. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_layout.cpp
  904. @@ -22,8 +22,8 @@ class QwtPolarLayout::LayoutData
  905.     struct t_legendData
  906.     {
  907.         int frameWidth;
  908. -        int vScrollBarWidth;
  909. -        int hScrollBarHeight;
  910. +        int hScrollExtent;
  911. +        int vScrollExtent;
  912.         QSizeF hint;
  913.     } legend;
  914.  
  915. @@ -48,10 +48,10 @@ void QwtPolarLayout::LayoutData::init(
  916.             && plot->legend() )
  917.     {
  918.         legend.frameWidth = plot->legend()->frameWidth();
  919. -        legend.vScrollBarWidth =
  920. -            plot->legend()->verticalScrollBar()->sizeHint().width();
  921. -        legend.hScrollBarHeight =
  922. -            plot->legend()->horizontalScrollBar()->sizeHint().height();
  923. +        legend.hScrollExtent =
  924. +            plot->legend()->scrollExtent( Qt::Horizontal );
  925. +        legend.vScrollExtent =
  926. +            plot->legend()->scrollExtent( Qt::Vertical );
  927.  
  928.         const QSizeF hint = plot->legend()->sizeHint();
  929.  
  930. @@ -61,7 +61,7 @@ void QwtPolarLayout::LayoutData::init(
  931.             h = hint.height();
  932.  
  933.         if ( h > rect.height() )
  934. -            w += legend.vScrollBarWidth;
  935. +            w += legend.hScrollExtent;
  936.  
  937.         legend.hint = QSizeF( w, h );
  938.     }
  939. @@ -278,7 +278,7 @@ QRectF QwtPolarLayout::layoutLegend( Options options, QRectF &rect ) const
  940.         // We don't allow vertical legends to take more than
  941.          // half of the available space.
  942.  
  943. -        dim = qMin( hint.width(), rect.width() * d_data->legendRatio );
  944. +        dim = qMin( double( hint.width() ), rect.width() * d_data->legendRatio );
  945.  
  946.          if ( !( options & IgnoreScrollbars ) )
  947.          {
  948. @@ -287,14 +287,14 @@ QRectF QwtPolarLayout::layoutLegend( Options options, QRectF &rect ) const
  949.                  // The legend will need additional
  950.                  // space for the vertical scrollbar.
  951.  
  952. -                dim += d_data->layoutData.legend.vScrollBarWidth;
  953. +                dim += d_data->layoutData.legend.hScrollExtent;
  954.              }
  955.          }
  956.      }
  957.      else
  958.      {
  959. -        dim = qMin( hint.height(), rect.height() * d_data->legendRatio );
  960. -        dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
  961. +        dim = qMin( double( hint.height() ), rect.height() * d_data->legendRatio );
  962. +        dim = qMax( dim, d_data->layoutData.legend.vScrollExtent );
  963.      }
  964.  
  965.      QRectF legendRect = rect;
  966. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_picker.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_picker.cpp
  967. index 0b6a6c1..7a95fc4 100644
  968. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_picker.cpp
  969. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_picker.cpp
  970. @@ -98,7 +98,8 @@ const QwtPolarPlot *QwtPolarPicker::plot() const
  971.  */
  972.  QwtText QwtPolarPicker::trackerText( const QPoint &pos ) const
  973.  {
  974. -    return trackerTextPolar( invTransform( pos ) );
  975. +    const QwtPointPolar polarPoint = invTransform( pos );
  976. +    return trackerTextPolar( polarPoint );
  977.  }
  978.  
  979.  /*!
  980. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_plot.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_plot.cpp
  981. index aa6c404..09cc540 100644
  982. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_plot.cpp
  983. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_plot.cpp
  984. @@ -15,7 +15,6 @@
  985.  #include <qwt_text_label.h>
  986.  #include <qwt_round_scale_draw.h>
  987.  #include <qwt_legend.h>
  988. -#include <qwt_legend_item.h>
  989.  #include <qwt_dyngrid_layout.h>
  990.  #include <qpointer.h>
  991.  #include <qpaintengine.h>
  992. @@ -34,6 +33,7 @@ class QwtPolarPlot::ScaleData
  993.  {
  994.  public:
  995.      ScaleData():
  996. +        isValid( false ),
  997.          scaleEngine( NULL )
  998.      {
  999.      }
  1000. @@ -52,6 +52,8 @@ class QwtPolarPlot::ScaleData
  1001.      int maxMajor;
  1002.      int maxMinor;
  1003.  
  1004. +    bool isValid;
  1005. +
  1006.      QwtScaleDiv scaleDiv;
  1007.      QwtScaleEngine *scaleEngine;
  1008.  };
  1009. @@ -69,7 +71,7 @@ class QwtPolarPlot::PrivateData
  1010.      ScaleData scaleData[QwtPolar::ScaleCount];
  1011.      QPointer<QwtTextLabel> titleLabel;
  1012.      QPointer<QwtPolarCanvas> canvas;
  1013. -    QPointer<QwtLegend> legend;
  1014. +    QPointer<QwtAbstractLegend> legend;
  1015.      double azimuthOrigin;
  1016.  
  1017.      QwtPolarLayout *layout;
  1018. @@ -99,6 +101,8 @@ class QwtPolarPlot::PrivateData
  1019.  //! Destructor
  1020.  QwtPolarPlot::~QwtPolarPlot()
  1021.  {
  1022. +    detachItems( QwtPolarItem::Rtti_PolarItem, autoDelete() );
  1023. +
  1024.      delete d_data->layout;
  1025.      delete d_data;
  1026.  }
  1027. @@ -180,10 +184,11 @@ const QwtTextLabel *QwtPolarPlot::titleLabel() const
  1028.    \sa legend(), QwtPolarLayout::legendPosition(),
  1029.        QwtPolarLayout::setLegendPosition()
  1030.  */
  1031. -void QwtPolarPlot::insertLegend( QwtLegend *legend,
  1032. +void QwtPolarPlot::insertLegend( QwtAbstractLegend *legend,
  1033.      QwtPolarPlot::LegendPosition pos, double ratio )
  1034.  {
  1035.      d_data->layout->setLegendPosition( pos, ratio );
  1036. +
  1037.      if ( legend != d_data->legend )
  1038.      {
  1039.          if ( d_data->legend && d_data->legend->parent() == this )
  1040. @@ -193,91 +198,99 @@ void QwtPolarPlot::insertLegend( QwtLegend *legend,
  1041.  
  1042.          if ( d_data->legend )
  1043.          {
  1044. -            if ( pos != ExternalLegend )
  1045. -            {
  1046. -                if ( d_data->legend->parent() != this )
  1047. -                    d_data->legend->setParent( this );
  1048. -            }
  1049. +            connect( this,
  1050. +                SIGNAL( legendDataChanged(
  1051. +                    const QVariant &, const QList<QwtLegendData> & ) ),
  1052. +                d_data->legend,
  1053. +                SLOT( updateLegend(
  1054. +                    const QVariant &, const QList<QwtLegendData> & ) )
  1055. +            );
  1056.  
  1057. -            const QwtPolarItemList& itmList = itemList();
  1058. -            for ( QwtPolarItemIterator it = itmList.begin();
  1059. -                    it != itmList.end(); ++it )
  1060. -            {
  1061. -                ( *it )->updateLegend( d_data->legend );
  1062. -            }
  1063. +            if ( d_data->legend->parent() != this )
  1064. +                d_data->legend->setParent( this );
  1065.  
  1066. -            QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
  1067. -                d_data->legend->contentsWidget()->layout() );
  1068. +            updateLegend();
  1069.  
  1070. -            if ( tl )
  1071. +            QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
  1072. +            if ( lgd )
  1073.              {
  1074. -                switch( d_data->layout->legendPosition() )
  1075. +                switch ( d_data->layout->legendPosition() )
  1076.                  {
  1077.                      case LeftLegend:
  1078.                      case RightLegend:
  1079. -                        tl->setMaxCols( 1 ); // 1 column: align vertical
  1080. +                    {
  1081. +                        if ( lgd->maxColumns() == 0     )
  1082. +                            lgd->setMaxColumns( 1 ); // 1 column: align vertical
  1083.                          break;
  1084. -
  1085. +                    }
  1086.                      case TopLegend:
  1087.                      case BottomLegend:
  1088. -                        tl->setMaxCols( 0 ); // unlimited
  1089. +                    {
  1090. +                        lgd->setMaxColumns( 0 ); // unlimited
  1091.                          break;
  1092. -
  1093. -                    case ExternalLegend:
  1094. +                    }
  1095. +                    default:
  1096.                          break;
  1097.                  }
  1098.              }
  1099. +
  1100.          }
  1101.      }
  1102. +
  1103.      updateLayout();
  1104.  }
  1105.  
  1106.  /*!
  1107. -  \return the plot's legend
  1108. -  \sa insertLegend()
  1109. -*/
  1110. -QwtLegend *QwtPolarPlot::legend()
  1111. +  Emit legendDataChanged() for all plot item
  1112. +
  1113. +  \sa QwtPlotItem::legendData(), legendDataChanged()
  1114. + */
  1115. +void QwtPolarPlot::updateLegend()
  1116. {
  1117. -    return d_data->legend;
  1118. +    const QwtPolarItemList& itmList = itemList();
  1119. +    for ( QwtPolarItemIterator it = itmList.begin();
  1120. +        it != itmList.end(); ++it )
  1121. +    {
  1122. +        updateLegend( *it );
  1123. +    }
  1124. }
  1125.  
  1126. /*!
  1127. -  \return the plot's legend
  1128. -  \sa insertLegend()
  1129. -*/
  1130. -const QwtLegend *QwtPolarPlot::legend() const
  1131. +  Emit legendDataChanged() for a plot item
  1132. +
  1133. +  \param plotItem Plot item
  1134. +  \sa QwtPlotItem::legendData(), legendDataChanged()
  1135. + */
  1136. +void QwtPolarPlot::updateLegend( const QwtPolarItem *plotItem )
  1137.  {
  1138. -    return d_data->legend;
  1139. +    if ( plotItem == NULL )
  1140. +        return;
  1141. +
  1142. +    QList<QwtLegendData> legendData;
  1143. +
  1144. +    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
  1145. +        legendData = plotItem->legendData();
  1146. +
  1147. +    const QVariant itemInfo = itemToInfo( const_cast< QwtPolarItem *>( plotItem) );
  1148. +    Q_EMIT legendDataChanged( itemInfo, legendData );
  1149.  }
  1150.  
  1151.  /*!
  1152. -  Called internally when the legend has been clicked on.
  1153. -  Emits a legendClicked() signal.
  1154. +  \return the plot's legend
  1155. +  \sa insertLegend()
  1156. */
  1157. -void QwtPolarPlot::legendItemClicked()
  1158. +QwtAbstractLegend *QwtPolarPlot::legend()
  1159. {
  1160. -    if ( d_data->legend && sender()->isWidgetType() )
  1161. -    {
  1162. -        QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
  1163. -            d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
  1164. -        if ( plotItem )
  1165. -            Q_EMIT legendClicked( plotItem );
  1166. -    }
  1167. +    return d_data->legend;
  1168. }
  1169.  
  1170. /*!
  1171. -  Called internally when the legend has been checked
  1172. -  Emits a legendClicked() signal.
  1173. +  \return the plot's legend
  1174. +  \sa insertLegend()
  1175.  */
  1176. -void QwtPolarPlot::legendItemChecked( bool on )
  1177. +const QwtAbstractLegend *QwtPolarPlot::legend() const
  1178.  {
  1179. -    if ( d_data->legend && sender()->isWidgetType() )
  1180. -    {
  1181. -        QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
  1182. -            d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
  1183. -        if ( plotItem )
  1184. -            Q_EMIT legendChecked( plotItem, on );
  1185. -    }
  1186. +    return d_data->legend;
  1187.  }
  1188.  
  1189.  /*!
  1190. @@ -386,17 +399,14 @@ void QwtPolarPlot::setScaleMaxMinor( int scaleId, int maxMinor )
  1191.      if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
  1192.          return;
  1193.  
  1194. -    if ( maxMinor < 0 )
  1195. -        maxMinor = 0;
  1196. -    if ( maxMinor > 100 )
  1197. -        maxMinor = 100;
  1198. +    maxMinor = qBound( 0, maxMinor, 100 );
  1199.  
  1200.      ScaleData &scaleData = d_data->scaleData[scaleId];
  1201.  
  1202.      if ( maxMinor != scaleData.maxMinor )
  1203.      {
  1204.          scaleData.maxMinor = maxMinor;
  1205. -        scaleData.scaleDiv.invalidate();
  1206. +        scaleData.isValid = false;
  1207.          autoRefresh();
  1208.      }
  1209.  }
  1210. @@ -426,16 +436,13 @@ void QwtPolarPlot::setScaleMaxMajor( int scaleId, int maxMajor )
  1211.      if ( scaleId < 0 || scaleId >= QwtPolar::ScaleCount )
  1212.          return;
  1213.  
  1214. -    if ( maxMajor < 1 )
  1215. -        maxMajor = 1;
  1216. -    if ( maxMajor > 1000 )
  1217. -        maxMajor = 10000;
  1218. +    maxMajor = qBound( 1, maxMajor, 10000 );
  1219.  
  1220.      ScaleData &scaleData = d_data->scaleData[scaleId];
  1221.      if ( maxMajor != scaleData.maxMinor )
  1222.      {
  1223.          scaleData.maxMajor = maxMajor;
  1224. -        scaleData.scaleDiv.invalidate();
  1225. +        scaleData.isValid = false;
  1226.          autoRefresh();
  1227.      }
  1228.  }
  1229. @@ -474,7 +481,7 @@ void QwtPolarPlot::setScaleEngine( int scaleId, QwtScaleEngine *scaleEngine )
  1230.      delete scaleData.scaleEngine;
  1231.      scaleData.scaleEngine = scaleEngine;
  1232.  
  1233. -    scaleData.scaleDiv.invalidate();
  1234. +    scaleData.isValid = false;
  1235.  
  1236.      autoRefresh();
  1237.  }
  1238. @@ -524,7 +531,7 @@ void QwtPolarPlot::setScale( int scaleId,
  1239.  
  1240.      ScaleData &scaleData = d_data->scaleData[scaleId];
  1241.  
  1242. -    scaleData.scaleDiv.invalidate();
  1243. +    scaleData.isValid = false;
  1244.  
  1245.      scaleData.minValue = min;
  1246.      scaleData.maxValue = max;
  1247. @@ -548,6 +555,7 @@ void QwtPolarPlot::setScaleDiv( int scaleId, const QwtScaleDiv &scaleDiv )
  1248.      ScaleData &scaleData = d_data->scaleData[scaleId];
  1249.  
  1250.      scaleData.scaleDiv = scaleDiv;
  1251. +    scaleData.isValid = true;
  1252.      scaleData.doAutoScale = false;
  1253.  
  1254.      autoRefresh();
  1255. @@ -729,7 +737,7 @@ QwtScaleMap QwtPolarPlot::scaleMap( int scaleId, const double radius ) const
  1256.      if ( scaleId == QwtPolar::Azimuth )
  1257.      {
  1258.          map.setPaintInterval( d_data->azimuthOrigin,
  1259. -            d_data->azimuthOrigin + M_2PI );
  1260. +            d_data->azimuthOrigin + 2 * M_PI );
  1261.      }
  1262.      else
  1263.      {
  1264. @@ -817,8 +825,9 @@ void QwtPolarPlot::initPlot( const QwtText &title )
  1265.          scaleData.maxMinor = 5;
  1266.          scaleData.maxMajor = 8;
  1267.  
  1268. +        scaleData.isValid = false;
  1269. +
  1270.          scaleData.scaleEngine = new QwtLinearScaleEngine;
  1271. -        scaleData.scaleDiv.invalidate();
  1272.      }
  1273.      d_data->zoomFactor = 1.0;
  1274.      d_data->azimuthOrigin = 0.0;
  1275. @@ -855,16 +864,18 @@ void QwtPolarPlot::updateLayout()
  1276.              d_data->titleLabel->hide();
  1277.      }
  1278.  
  1279. -    if ( d_data->legend &&
  1280. -        d_data->layout->legendPosition() != ExternalLegend )
  1281. +    if ( d_data->legend )
  1282.      {
  1283. -        if ( d_data->legend->itemCount() > 0 )
  1284. +        if ( d_data->legend->isEmpty() )
  1285.          {
  1286. -            d_data->legend->setGeometry( d_data->layout->legendRect().toRect() );
  1287. -            d_data->legend->show();
  1288. +            d_data->legend->hide();
  1289.          }
  1290.          else
  1291. -            d_data->legend->hide();
  1292. +        {
  1293. +            const QRectF legendRect = d_data->layout->legendRect();
  1294. +            d_data->legend->setGeometry( legendRect.toRect() );
  1295. +            d_data->legend->show();
  1296. +        }
  1297.      }
  1298.  
  1299.      d_data->canvas->setGeometry( d_data->layout->canvasRect().toRect() );
  1300. @@ -1051,13 +1062,14 @@ void QwtPolarPlot::updateScale( int scaleId )
  1301.  
  1302.          d.scaleEngine->autoScale( d.maxMajor,
  1303.                                    minValue, maxValue, stepSize );
  1304. -        d.scaleDiv.invalidate();
  1305. +        d.isValid = false;
  1306.      }
  1307.  
  1308. -    if ( !d.scaleDiv.isValid() )
  1309. +    if ( !d.isValid )
  1310.      {
  1311.          d.scaleDiv = d.scaleEngine->divideScale(
  1312.              minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
  1313. +        d.isValid = true;
  1314.      }
  1315.  
  1316.      const QwtInterval interval = visibleInterval();
  1317. @@ -1267,3 +1279,84 @@ const QwtPolarLayout *QwtPolarPlot::plotLayout() const
  1318.  {
  1319.      return d_data->layout;
  1320.  }
  1321. +
  1322. +/*!
  1323. +  \brief Attach/Detach a plot item
  1324. +
  1325. +  \param plotItem Plot item
  1326. +  \param on When true attach the item, otherwise detach it
  1327. + */
  1328. +void QwtPolarPlot::attachItem( QwtPolarItem *plotItem, bool on )
  1329. +{
  1330. +    if ( on )
  1331. +        insertItem( plotItem );
  1332. +    else
  1333. +        removeItem( plotItem );
  1334. +
  1335. +    Q_EMIT itemAttached( plotItem, on );
  1336. +
  1337. +    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
  1338. +    {
  1339. +        // the item wants to be represented on the legend
  1340. +
  1341. +        if ( on )
  1342. +        {
  1343. +            updateLegend( plotItem );
  1344. +        }
  1345. +        else
  1346. +        {
  1347. +            const QVariant itemInfo = itemToInfo( plotItem );
  1348. +            Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
  1349. +        }
  1350. +    }
  1351. +
  1352. +    if ( autoReplot() )
  1353. +        update();
  1354. +}
  1355. +
  1356. +/*!
  1357. +  \brief Build an information, that can be used to identify
  1358. +         a plot item on the legend.
  1359. +
  1360. +  The default implementation simply wraps the plot item
  1361. +  into a QVariant object. When overloading itemToInfo()
  1362. +  usually infoToItem() needs to reimplemeted too.
  1363. +
  1364. +\code
  1365. +    QVariant itemInfo;
  1366. +    qVariantSetValue( itemInfo, plotItem );
  1367. +\endcode
  1368. +
  1369. +  \param plotItem Plot item
  1370. +  \sa infoToItem()
  1371. + */
  1372. +QVariant QwtPolarPlot::itemToInfo( QwtPolarItem *plotItem ) const
  1373. +{
  1374. +    QVariant itemInfo;
  1375. +    qVariantSetValue( itemInfo, plotItem );
  1376. +
  1377. +    return itemInfo;
  1378. +}
  1379. +
  1380. +/*!
  1381. +  \brief Identify the plot item according to an item info object,
  1382. +         that has bee generated from itemToInfo().
  1383. +
  1384. +  The default implementation simply tries to unwrap a QwtPlotItem
  1385. +  pointer:
  1386. +
  1387. +\code
  1388. +    if ( itemInfo.canConvert<QwtPlotItem *>() )
  1389. +        return qvariant_cast<QwtPlotItem *>( itemInfo );
  1390. +\endcode
  1391. +  \param itemInfo Plot item
  1392. +  \return A plot item, when successful, otherwise a NULL pointer.
  1393. +  \sa itemToInfo()
  1394. +*/
  1395. +QwtPolarItem *QwtPolarPlot::infoToItem( const QVariant &itemInfo ) const
  1396. +{
  1397. +    if ( itemInfo.canConvert<QwtPolarItem *>() )
  1398. +        return qvariant_cast<QwtPolarItem *>( itemInfo );
  1399. +
  1400. +    return NULL;
  1401. +}
  1402. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_plot.h b/src/app/gps/qwtpolar-1.0/qwt_polar_plot.h
  1403. index f6ce701..2e65aca 100644
  1404. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_plot.h
  1405. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_plot.h
  1406. @@ -23,6 +23,7 @@
  1407.  class QwtTextLabel;
  1408.  class QwtPolarCanvas;
  1409.  class QwtPolarLayout;
  1410. +class QwtAbstractLegend;
  1411.  
  1412.  /*!
  1413.    \brief A plotting widget, displaying a polar coordinate system
  1414. @@ -140,11 +141,14 @@ class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
  1415.  
  1416.      // Legend
  1417.  
  1418. -    void insertLegend( QwtLegend *,
  1419. +    void insertLegend( QwtAbstractLegend *,
  1420.          LegendPosition = RightLegend, double ratio = -1.0 );
  1421.  
  1422. -    QwtLegend *legend();
  1423. -    const QwtLegend *legend() const;
  1424. +    QwtAbstractLegend *legend();
  1425. +    const QwtAbstractLegend *legend() const;
  1426. +
  1427. +    void updateLegend();
  1428. +    void updateLegend( const QwtPolarItem * );
  1429.  
  1430.      // Layout
  1431.      QwtPolarLayout *plotLayout();
  1432. @@ -156,31 +160,28 @@ class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
  1433.  
  1434.      int plotMarginHint() const;
  1435.  
  1436. +    virtual QVariant itemToInfo( QwtPolarItem * ) const;
  1437. +    virtual QwtPolarItem *infoToItem( const QVariant & ) const;
  1438. +
  1439.  Q_SIGNALS:
  1440.      /*!
  1441. -      A signal which is emitted when the user has clicked on
  1442. -      a legend item, which is in QwtLegend::ClickableItem mode.
  1443. -
  1444. -      \param plotItem Corresponding plot item of the
  1445. -                 selected legend item
  1446. +      A signal indicating, that an item has been attached/detached
  1447.  
  1448. -      \note clicks are disabled as default
  1449. -      \sa QwtLegend::setItemMode, QwtLegend::itemMode
  1450. +      \param plotItem Plot item
  1451. +      \param on Attached/Detached
  1452.       */
  1453. -    void legendClicked( QwtPolarItem *plotItem );
  1454. -
  1455. -    /*!
  1456. -      A signal which is emitted when the user has clicked on
  1457. -      a legend item, which is in QwtLegend::CheckableItem mode
  1458. -
  1459. -      \param plotItem Corresponding plot item of the
  1460. -                 selected legend item
  1461. -      \param on True when the legen item is checked
  1462. -
  1463. -      \note clicks are disabled as default
  1464. -      \sa QwtLegend::setItemMode, QwtLegend::itemMode
  1465. +    void itemAttached( QwtPolarItem *plotItem, bool on );
  1466. +
  1467. +    /*!
  1468. +      A signal with the attributes how to update
  1469. +      the legend entries for a plot item.
  1470. +                
  1471. +      \param itemInfo Info about a plot, build from itemToInfo()
  1472. +    
  1473. +      \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
  1474.       */
  1475. -    void legendChecked( QwtPolarItem *plotItem, bool on );
  1476. +    void legendDataChanged( const QVariant &itemInfo,
  1477. +        const QList<QwtLegendData> &data );
  1478.  
  1479.      /*!
  1480.        A signal that is emitted, whenever the layout of the plot
  1481. @@ -193,10 +194,6 @@ class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
  1482.      void autoRefresh();
  1483.      void setAzimuthOrigin( double );
  1484.  
  1485. -protected Q_SLOTS:
  1486. -    virtual void legendItemClicked();
  1487. -    virtual void legendItemChecked( bool );
  1488. -
  1489.  protected:
  1490.      virtual bool event( QEvent * );
  1491.      virtual void resizeEvent( QResizeEvent * );
  1492. @@ -209,6 +206,9 @@ class QWT_POLAR_EXPORT QwtPolarPlot: public QFrame, public QwtPolarItemDict
  1493.          const QRectF &canvasRect ) const;
  1494.  
  1495.  private:
  1496. +    friend class QwtPolarItem;
  1497. +    void attachItem( QwtPolarItem *, bool );
  1498. +
  1499.      void initPlot( const QwtText & );
  1500.  
  1501.      class ScaleData;
  1502. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.cpp
  1503. index 890b295..a9dc4fa 100644
  1504. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.cpp
  1505. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.cpp
  1506. @@ -10,12 +10,13 @@
  1507.  #include "qwt_polar_plot.h"
  1508.  #include "qwt_polar_layout.h"
  1509.  #include <qwt_legend.h>
  1510. -#include <qwt_legend_item.h>
  1511.  #include <qwt_dyngrid_layout.h>
  1512.  #include <qwt_text_label.h>
  1513.  #include <qwt_text.h>
  1514.  #include <qpainter.h>
  1515.  #include <qprinter.h>
  1516. +#include <qprintdialog.h>
  1517. +#include <qfiledialog.h>
  1518.  #include <qimagewriter.h>
  1519.  #include <qfileinfo.h>
  1520.  #include <qmath.h>
  1521. @@ -114,19 +115,39 @@ void QwtPolarRenderer::renderDocument( QwtPolarPlot *plot,
  1522.      const QRectF documentRect( 0.0, 0.0, size.width(), size.height() );
  1523.  
  1524.      const QString fmt = format.toLower();
  1525. -    if ( format == "pdf" || format == "ps" )
  1526. +    if ( format == "pdf" )
  1527.      {
  1528. +#ifndef QT_NO_PRINTER
  1529.          QPrinter printer;
  1530. +        printer.setColorMode( QPrinter::Color );
  1531.          printer.setFullPage( true );
  1532.          printer.setPaperSize( sizeMM, QPrinter::Millimeter );
  1533.          printer.setDocName( title );
  1534.          printer.setOutputFileName( fileName );
  1535. -        printer.setOutputFormat( ( format == "pdf" )
  1536. -            ? QPrinter::PdfFormat : QPrinter::PostScriptFormat );
  1537. +        printer.setOutputFormat( QPrinter::PdfFormat );
  1538.          printer.setResolution( resolution );
  1539.  
  1540.          QPainter painter( &printer );
  1541.          render( plot, &painter, documentRect );
  1542. +#endif
  1543. +    }
  1544. +    else if ( format == "ps" )
  1545. +    {
  1546. +#if QT_VERSION < 0x050000
  1547. +#ifndef QT_NO_PRINTER
  1548. +        QPrinter printer;
  1549. +        printer.setColorMode( QPrinter::Color );
  1550. +        printer.setFullPage( true );
  1551. +        printer.setPaperSize( sizeMM, QPrinter::Millimeter );
  1552. +        printer.setDocName( title );
  1553. +        printer.setOutputFileName( fileName );
  1554. +        printer.setOutputFormat( QPrinter::PostScriptFormat );
  1555. +        printer.setResolution( resolution );
  1556. +
  1557. +        QPainter painter( &printer );
  1558. +        render( plot, &painter, documentRect );
  1559. +#endif
  1560. +#endif
  1561.      }
  1562.  #ifndef QWT_NO_POLAR_SVG
  1563.  #ifdef QT_SVG_LIB
  1564. @@ -299,7 +320,7 @@ void QwtPolarRenderer::render( QwtPolarPlot *plot,
  1565.      painter->restore();
  1566.  
  1567.      painter->save();
  1568. -    renderLegend( painter, layout->legendRect() );
  1569. +    renderLegend( plot, painter, layout->legendRect() );
  1570.      painter->restore();
  1571.  
  1572.      const QRectF canvasRect = layout->canvasRect();
  1573. @@ -339,83 +360,78 @@ void QwtPolarRenderer::renderTitle( QPainter *painter, const QRectF &rect ) cons
  1574.  /*!
  1575.    Render the legend into a given rectangle.
  1576.  
  1577. +  \param plot Plot widget
  1578.    \param painter Painter
  1579.    \param rect Bounding rectangle
  1580.  */
  1581. -
  1582. -void QwtPolarRenderer::renderLegend(
  1583. +void QwtPolarRenderer::renderLegend( const QwtPolarPlot *plot,
  1584.      QPainter *painter, const QRectF &rect ) const
  1585.  {
  1586. -    QwtLegend *legend = d_data->plot->legend();
  1587. -    if ( legend == NULL || legend->isEmpty() )
  1588. -        return;
  1589. +    if ( plot->legend() )
  1590. +        plot->legend()->renderLegend( painter, rect, true );
  1591. +}
  1592.  
  1593. -    const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>(
  1594. -        legend->contentsWidget()->layout() );
  1595. -    if ( legendLayout == NULL )
  1596. -        return;
  1597. +/*!
  1598. +   \brief Execute a file dialog and render the plot to the selected file
  1599.  
  1600. -    uint numCols = legendLayout->columnsForWidth( rect.width() );
  1601. -    const QList<QRect> itemRects =
  1602. -        legendLayout->layoutItems( rect.toRect(), numCols );
  1603. +   The document will be rendered in 85 dpi for a size 30x30 cm
  1604.  
  1605. -    int index = 0;
  1606. +   \param plot Plot widget
  1607. +   \param documentName Default document name
  1608. +   \param sizeMM Size for the document in millimeters.
  1609. +   \param resolution Resolution in dots per Inch (dpi)
  1610.  
  1611. -    for ( int i = 0; i < legendLayout->count(); i++ )
  1612. -    {
  1613. -        QLayoutItem *item = legendLayout->itemAt( i );
  1614. -        QWidget *w = item->widget();
  1615. -        if ( w )
  1616. -        {
  1617. -            painter->save();
  1618. +   \sa renderDocument()
  1619. +*/
  1620. +bool QwtPolarRenderer::exportTo( QwtPolarPlot *plot,
  1621. +    const QString &documentName, const QSizeF &sizeMM, int resolution )
  1622. +{
  1623. +    if ( plot == NULL )
  1624. +        return false;
  1625.  
  1626. -            painter->setClipRect( itemRects[index] );
  1627. -            renderLegendItem( painter, w, itemRects[index] );
  1628. +    QString fileName = documentName;
  1629.  
  1630. -            index++;
  1631. -            painter->restore();
  1632. -        }
  1633. -    }
  1634. +    // What about translation
  1635.  
  1636. -}
  1637. +#ifndef QT_NO_FILEDIALOG
  1638. +    const QList<QByteArray> imageFormats =
  1639. +        QImageWriter::supportedImageFormats();
  1640.  
  1641. -/*!
  1642. -  Print the legend item into a given rectangle.
  1643. -
  1644. -  \param painter Painter
  1645. -  \param widget Widget representing a legend item
  1646. -  \param rect Bounding rectangle
  1647. +    QStringList filter;
  1648. +#ifndef QT_NO_PRINTER
  1649. +    filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)";
  1650. +#endif
  1651. +#ifndef QWT_NO_SVG
  1652. +    filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)";
  1653. +#endif
  1654. +#ifndef QT_NO_PRINTER
  1655. +    filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)";
  1656. +#endif
  1657.  
  1658. -  \note When widget is not derived from QwtLegendItem renderLegendItem
  1659. -        does nothing and needs to be overloaded
  1660. -*/
  1661. -void QwtPolarRenderer::renderLegendItem( QPainter *painter,
  1662. -    const QWidget *widget, const QRectF &rect ) const
  1663. -{
  1664. -    const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
  1665. -    if ( item )
  1666. +    if ( imageFormats.size() > 0 )
  1667.      {
  1668. -        const QSize sz = item->identifierSize();
  1669. -
  1670. -        const QRectF identifierRect( rect.x() + item->margin(),
  1671. -            rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() );
  1672. -
  1673. -        QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item );
  1674. -        if ( itemManger )
  1675. +        QString imageFilter( tr( "Images" ) );
  1676. +        imageFilter += " (";
  1677. +        for ( int i = 0; i < imageFormats.size(); i++ )
  1678.          {
  1679. -            painter->save();
  1680. -            painter->setClipRect( identifierRect, Qt::IntersectClip );
  1681. -            itemManger->drawLegendIdentifier( painter, identifierRect );
  1682. -            painter->restore();
  1683. +            if ( i > 0 )
  1684. +                imageFilter += " ";
  1685. +            imageFilter += "*.";
  1686. +            imageFilter += imageFormats[i];
  1687.          }
  1688. +        imageFilter += ")";
  1689.  
  1690. -        // Label
  1691. +        filter += imageFilter;
  1692. +    }
  1693.  
  1694. -        QRectF titleRect = rect;
  1695. -        titleRect.setX( identifierRect.right() + 2 * item->spacing() );
  1696. +    fileName = QFileDialog::getSaveFileName(
  1697. +        NULL, tr( "Export File Name" ), fileName,
  1698. +        filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite );
  1699. +#endif
  1700. +    if ( fileName.isEmpty() )
  1701. +        return false;
  1702.  
  1703. -        painter->setFont( item->font() );
  1704. -        item->text().draw( painter, titleRect );
  1705. -    }
  1706. -}
  1707. +    renderDocument( plot, fileName, sizeMM, resolution );
  1708.  
  1709. +    return true;
  1710. +}
  1711. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.h b/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.h
  1712. index b562817..993e332 100644
  1713. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.h
  1714. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_renderer.h
  1715. @@ -11,9 +11,9 @@
  1716.  
  1717.  #include "qwt_polar_global.h"
  1718.  #include <qobject.h>
  1719. +#include <qsize.h>
  1720.  
  1721.  class QwtPolarPlot;
  1722. -class QSizeF;
  1723.  class QRectF;
  1724.  class QPainter;
  1725.  class QPrinter;
  1726. @@ -51,17 +51,18 @@ class QWT_POLAR_EXPORT QwtPolarRenderer: public QObject
  1727.  #endif
  1728.  #endif
  1729.      void renderTo( QwtPolarPlot *, QPrinter & ) const;
  1730. -    void renderTo( QwtPolarPlot *, QPaintDevice &p ) const;
  1731. +    void renderTo( QwtPolarPlot *, QPaintDevice & ) const;
  1732.  
  1733.      virtual void render( QwtPolarPlot *,
  1734.          QPainter *, const QRectF &rect ) const;
  1735.  
  1736. -protected:
  1737. +    bool exportTo( QwtPolarPlot *, const QString &documentName,
  1738. +        const QSizeF &sizeMM = QSizeF( 200, 200 ), int resolution = 85 );
  1739. +
  1740.      virtual void renderTitle( QPainter *, const QRectF & ) const;
  1741. -    virtual void renderLegend( QPainter *, const QRectF & ) const;
  1742.  
  1743. -    virtual void renderLegendItem( QPainter *,
  1744. -        const QWidget *, const QRectF & ) const;
  1745. +    virtual void renderLegend(
  1746. +        const QwtPolarPlot *, QPainter *, const QRectF & ) const;
  1747.  
  1748.  private:
  1749.      class PrivateData;
  1750. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp b/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
  1751. index 355e5b1..325b07a 100644
  1752. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
  1753. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.cpp
  1754. @@ -94,21 +94,20 @@ class QwtPolarSpectrogram::PrivateData
  1755.  {
  1756.  public:
  1757.      PrivateData():
  1758. -        data( NULL ),
  1759. -        renderThreadCount( 1 )
  1760. +        data( NULL )
  1761.      {
  1762.          colorMap = new QwtLinearColorMap();
  1763.      }
  1764.  
  1765.      ~PrivateData()
  1766.      {
  1767. +        delete data;
  1768. +        delete colorMap;
  1769.      }
  1770.  
  1771.      QwtRasterData *data;
  1772.      QwtColorMap *colorMap;
  1773.  
  1774. -    uint renderThreadCount;
  1775. -
  1776.      QwtPolarSpectrogram::PaintAttributes paintAttributes;
  1777.  };
  1778.  
  1779. @@ -223,37 +222,6 @@ bool QwtPolarSpectrogram::testPaintAttribute( PaintAttribute attribute ) const
  1780.  }
  1781.  
  1782.  /*!
  1783. -   Rendering an image from the raster data can often be done
  1784. -   parallel on a multicore system.
  1785. -
  1786. -   \param numThreads Number of threads to be used for rendering.
  1787. -                     If numThreads is set to 0, the system specific
  1788. -                     ideal thread count is used.
  1789. -
  1790. -   The default thread count is 1 ( = no additional threads )
  1791. -
  1792. -   \warning Rendering in multiple threads is only supported for Qt >= 4.4
  1793. -   \sa renderThreadCount(), renderImage(), renderTile()
  1794. -*/
  1795. -void QwtPolarSpectrogram::setRenderThreadCount( uint numThreads )
  1796. -{
  1797. -    d_data->renderThreadCount = numThreads;
  1798. -}
  1799. -
  1800. -/*!
  1801. -   \return Number of threads to be used for rendering.
  1802. -           If numThreads is set to 0, the system specific
  1803. -           ideal thread count is used.
  1804. -
  1805. -   \warning Rendering in multiple threads is only supported for Qt >= 4.4
  1806. -   \sa setRenderThreadCount(), renderImage(), renderTile()
  1807. -*/
  1808. -uint QwtPolarSpectrogram::renderThreadCount() const
  1809. -{
  1810. -    return d_data->renderThreadCount;
  1811. -}
  1812. -
  1813. -/*!
  1814.    Draw the spectrogram
  1815.  
  1816.    \param painter Painter
  1817. @@ -354,7 +322,7 @@ QImage QwtPolarSpectrogram::renderImage(
  1818.  
  1819.  
  1820.  #if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
  1821. -    uint numThreads = d_data->renderThreadCount;
  1822. +    uint numThreads = renderThreadCount();
  1823.  
  1824.      if ( numThreads <= 0 )
  1825.          numThreads = QThread::idealThreadCount();
  1826. diff --git a/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.h b/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.h
  1827. index 0d175f0..4bbf8f2 100644
  1828. --- a/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.h
  1829. +++ b/src/app/gps/qwtpolar-1.0/qwt_polar_spectrogram.h
  1830. @@ -59,9 +59,6 @@ class QWT_POLAR_EXPORT QwtPolarSpectrogram: public QwtPolarItem
  1831.      void setPaintAttribute( PaintAttribute, bool on = true );
  1832.      bool testPaintAttribute( PaintAttribute ) const;
  1833.  
  1834. -    void setRenderThreadCount( uint numThreads );
  1835. -    uint renderThreadCount() const;
  1836. -
  1837.      virtual int rtti() const;
  1838.  
  1839.      virtual void draw( QPainter *painter,
  1840. --
  1841. 1.8.5.1
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement