Changeset 8127 in ntrip for trunk/BNC/qwtpolar


Ignore:
Timestamp:
May 10, 2017, 3:20:54 PM (7 years ago)
Author:
stoecker
Message:

update qwt and qwtpolar, many QT5 fixes (unfinished)

Location:
trunk/BNC/qwtpolar
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwtpolar/qwt_polar_canvas.cpp

    r4272 r8127  
    99#include "qwt_polar_canvas.h"
    1010#include "qwt_polar_plot.h"
     11#include <qwt_painter.h>
    1112#include <qpainter.h>
    1213#include <qevent.h>
     
    213214                {
    214215                    QWidget *bgWidget = qwtBackgroundWidget( plot() );
    215                     bs.fill( bgWidget, mapTo( bgWidget, rect().topLeft() ) );
     216
     217                                        QwtPainter::fillPixmap( bgWidget, bs,
     218                                                mapTo( bgWidget, rect().topLeft() ) );
     219
    216220                    p.begin( &bs );
    217221                }
  • trunk/BNC/qwtpolar/qwt_polar_curve.cpp

    r7990 r8127  
    1414#include <qwt_symbol.h>
    1515#include <qwt_legend.h>
    16 #include <qwt_legend_item.h>
    1716#include <qwt_curve_fitter.h>
    1817#include <qwt_clipper.h>
     
    174173  \sa symbol()
    175174*/
    176 void QwtPolarCurve::setSymbol( const QwtSymbol *symbol )
     175void QwtPolarCurve::setSymbol( QwtSymbol *symbol )
    177176{
    178177    if ( symbol != d_data->symbol )
     
    434433    if ( !clipRect.isEmpty() )
    435434    {
    436         double off = qCeil( qMax(qreal(1.0), painter->pen().widthF() ) );
     435        double off = qCeil( qMax( qreal( 1.0 ), painter->pen().widthF() ) );
    437436        clipRect = clipRect.toRect().adjusted( -off, -off, off, off );
    438437        polyline = QwtClipper::clipPolygonF( clipRect, polyline );
     
    501500}
    502501
    503 //!  Update the widget that represents the curve on the legend
    504 void QwtPolarCurve::updateLegend( QwtLegend *legend ) const
    505 {
    506     if ( legend && testItemAttribute( QwtPolarCurve::Legend )
    507             && ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
    508             && d_data->symbol
    509             && d_data->symbol->style() != QwtSymbol::NoSymbol )
    510     {
    511         QWidget *lgdItem = legend->find( this );
    512         if ( lgdItem == NULL )
    513         {
    514             lgdItem = legendItem();
    515             if ( lgdItem )
    516                 legend->insert( this, lgdItem );
    517         }
    518 
    519         QwtLegendItem *l = qobject_cast<QwtLegendItem *>( lgdItem );
    520         if ( l )
    521         {
    522             QSize sz = d_data->symbol->boundingSize();
    523             sz += QSize( 2, 2 ); // margin
    524 
    525             if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
    526             {
    527                 // Avoid, that the line is completely covered by the symbol
    528 
    529                 int w = qCeil( 1.5 * sz.width() );
    530                 if ( w % 2 )
    531                     w++;
    532 
    533                 sz.setWidth( qMax( 8, w ) );
    534             }
    535 
    536             l->setIdentifierSize( sz );
    537         }
    538     }
    539 
    540     QwtPolarItem::updateLegend( legend );
    541 }
    542 
    543 /*!
    544   \brief Draw the identifier representing the curve on the legend
    545 
    546   \param painter Qt Painter
    547   \param rect Bounding rectangle for the identifier
    548 
    549   \sa setLegendAttribute
    550 */
    551 void QwtPolarCurve::drawLegendIdentifier(
    552     QPainter *painter, const QRectF &rect ) const
    553 {
    554     if ( rect.isEmpty() )
    555         return;
    556 
    557     const double dim = qMin( rect.width(), rect.height() );
    558 
    559     QSizeF size( dim, dim );
    560 
    561     QRectF r( 0, 0, size.width(), size.height() );
    562     r.moveCenter( rect.center() );
     502/*!
     503   \return Icon representing the curve on the legend
     504
     505   \param index Index of the legend entry
     506                ( ignored as there is only one )
     507   \param size Icon size
     508
     509   \sa QwtPolarItem::setLegendIconSize(), QwtPolarItem::legendData()
     510 */
     511QwtGraphic QwtPolarCurve::legendIcon( int index,
     512    const QSizeF &size ) const
     513{
     514    Q_UNUSED( index );
     515
     516    if ( size.isEmpty() )
     517        return QwtGraphic();
     518
     519    QwtGraphic graphic;
     520    graphic.setDefaultSize( size );
     521    graphic.setRenderHint( QwtGraphic::RenderPensUnscaled, true );
     522
     523    QPainter painter( &graphic );
     524    painter.setRenderHint( QPainter::Antialiasing,
     525        testRenderHint( QwtPolarItem::RenderAntialiased ) );
    563526
    564527    if ( d_data->legendAttributes == 0 )
    565528    {
    566529        QBrush brush;
     530
    567531        if ( style() != QwtPolarCurve::NoCurve )
     532        {
    568533            brush = QBrush( pen().color() );
     534        }
    569535        else if ( d_data->symbol &&
    570536            ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
     
    572538            brush = QBrush( d_data->symbol->pen().color() );
    573539        }
     540
    574541        if ( brush.style() != Qt::NoBrush )
    575             painter->fillRect( r, brush );
    576     }
     542        {
     543            QRectF r( 0, 0, size.width(), size.height() );
     544            painter.fillRect( r, brush );
     545        }
     546    }
     547
    577548    if ( d_data->legendAttributes & QwtPolarCurve::LegendShowLine )
    578549    {
    579550        if ( pen() != Qt::NoPen )
    580551        {
    581             painter->setPen( pen() );
    582             QwtPainter::drawLine( painter, rect.left(), rect.center().y(),
    583                 rect.right() - 1.0, rect.center().y() );
    584         }
    585     }
     552            QPen pn = pen();
     553            pn.setCapStyle( Qt::FlatCap );
     554
     555            painter.setPen( pn );
     556
     557            const double y = 0.5 * size.height();
     558            QwtPainter::drawLine( &painter, 0.0, y, size.width(), y );
     559        }
     560    }
     561
    586562    if ( d_data->legendAttributes & QwtPolarCurve::LegendShowSymbol )
    587563    {
    588         if ( d_data->symbol &&
    589             ( d_data->symbol->style() != QwtSymbol::NoSymbol ) )
    590         {
    591             QSize symbolSize = d_data->symbol->boundingSize();
    592             symbolSize -= QSize( 2, 2 );
    593 
    594             // scale the symbol size down if it doesn't fit into rect.
    595 
    596             double xRatio = 1.0;
    597             if ( rect.width() < symbolSize.width() )
    598                 xRatio = rect.width() / symbolSize.width();
    599             double yRatio = 1.0;
    600             if ( rect.height() < symbolSize.height() )
    601                 yRatio = rect.height() / symbolSize.height();
    602 
    603             const double ratio = qMin( xRatio, yRatio );
    604 
    605             painter->save();
    606             painter->scale( ratio, ratio );
    607 
    608             d_data->symbol->drawSymbol( painter, rect.center() / ratio );
    609 
    610             painter->restore();
    611         }
    612     }
     564        if ( d_data->symbol )
     565        {
     566            QRectF r( 0, 0, size.width(), size.height() );
     567            d_data->symbol->drawSymbol( &painter, r );
     568        }
     569    }
     570
     571    return graphic;
    613572}
    614573
     
    634593    return QwtInterval();
    635594}
     595
     596
  • trunk/BNC/qwtpolar/qwt_polar_curve.h

    r4272 r8127  
    5858        In the default setting all attributes are off.
    5959
    60         \sa setLegendAttribute(), testLegendAttribute(),
    61             drawLegendIdentifier()
     60        \sa setLegendAttribute(), testLegendAttribute()
    6261     */
    6362
     
    101100    CurveStyle style() const;
    102101
    103     void setSymbol( const QwtSymbol * );
     102    void setSymbol( QwtSymbol * );
    104103    const QwtSymbol *symbol() const;
    105104
     
    116115        const QPointF &pole, int from, int to ) const;
    117116
    118     virtual void updateLegend( QwtLegend * ) const;
    119117    virtual QwtInterval boundingInterval( int scaleId ) const;
    120118
    121     virtual void drawLegendIdentifier( QPainter *, const QRectF & ) const;
     119    virtual QwtGraphic legendIcon( int index, const QSizeF & ) const;
    122120
    123121protected:
  • trunk/BNC/qwtpolar/qwt_polar_global.h

    r4272 r8127  
    1414// QWT_POLAR_VERSION is (major << 16) + (minor << 8) + patch.
    1515
    16 #define QWT_POLAR_VERSION       0x010000
    17 #define QWT_POLAR_VERSION_STR   "1.0.0"
    18 
    19 #if defined(Q_WS_WIN) || defined(Q_WS_S60)
     16#define QWT_POLAR_VERSION       0x010101
     17#define QWT_POLAR_VERSION_STR   "1.1.1"
    2018
    2119#if defined(_MSC_VER) /* MSVC Compiler */
     
    2624#ifdef QWT_POLAR_DLL
    2725
    28 #if defined(QWT_POLAR_MAKEDLL)     // create a Qwt DLL library
    29 #define QWT_POLAR_EXPORT  __declspec(dllexport)
     26#if defined(QWT_POLAR_MAKEDLL)     // create DLL library
     27#define QWT_POLAR_EXPORT  Q_DECL_EXPORT
    3028#define QWT_POLAR_TEMPLATEDLL
    31 #else                        // use a Qwt DLL library
    32 #define QWT_POLAR_EXPORT  __declspec(dllimport)
     29#else                        // use DLL library
     30#define QWT_POLAR_EXPORT  Q_DECL_IMPORT
    3331#endif
    3432
    35 #endif // QWT_POLAR_MAKEDLL
    36 
    37 #endif // Q_WS_WIN
     33#endif // QWT_POLAR_DLL
    3834
    3935#ifndef QWT_POLAR_EXPORT
  • trunk/BNC/qwtpolar/qwt_polar_grid.cpp

    r4272 r8127  
    877877
    878878            scaleDraw->setAngleRange( from, from - 360.0 );
    879             scaleDraw->setTransformation( azimuthMap.transformation()->copy() );
     879
     880            const QwtTransform *transform = azimuthMap.transformation();
     881            if ( transform )
     882                scaleDraw->setTransformation( transform->copy() );
     883            else
     884                scaleDraw->setTransformation( NULL );
    880885        }
    881886        else
     
    911916                }
    912917            }
    913             scaleDraw->setTransformation( radialMap.transformation()->copy() );
     918            const QwtTransform *transform = radialMap.transformation();
     919            if ( transform )
     920                scaleDraw->setTransformation( transform->copy() );
     921            else
     922                scaleDraw->setTransformation( NULL );
    914923        }
    915924    }
     
    976985                QwtScaleDiv sd = radialGrid.scaleDiv;
    977986
    978                 QList<double> &ticks =
    979                     const_cast<QList<double> &>( sd.ticks( QwtScaleDiv::MajorTick ) );
     987                QList<double> ticks = sd.ticks( QwtScaleDiv::MajorTick );
    980988
    981989                if ( testDisplayFlag( SmartOriginLabel ) )
     
    10111019                }
    10121020
     1021                sd.setTicks( QwtScaleDiv::MajorTick, ticks );
    10131022                axis.scaleDraw->setScaleDiv( sd );
    10141023
     
    10491058const QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId ) const
    10501059{
    1051     if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
     1060    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
    10521061        return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
    10531062
     
    10641073QwtScaleDraw *QwtPolarGrid::scaleDraw( int axisId )
    10651074{
    1066     if ( axisId >= QwtPolar::AxisLeft || axisId <= QwtPolar::AxisBottom )
     1075    if ( axisId >= QwtPolar::AxisLeft && axisId <= QwtPolar::AxisBottom )
    10671076        return static_cast<QwtScaleDraw *>( d_data->axisData[axisId].scaleDraw );
    10681077
  • trunk/BNC/qwtpolar/qwt_polar_item.cpp

    r4272 r8127  
    1010#include "qwt_polar_item.h"
    1111#include <qwt_legend.h>
    12 #include <qwt_legend_item.h>
    1312#include <qwt_scale_div.h>
    1413#include <qpainter.h>
     
    2221        attributes( 0 ),
    2322        renderHints( 0 ),
    24         z( 0.0 )
     23        renderThreadCount( 1 ),
     24        z( 0.0 ),
     25        legendIconSize( 8, 8 )
    2526    {
    2627    }
     
    3132    QwtPolarItem::ItemAttributes attributes;
    3233    QwtPolarItem::RenderHints renderHints;
     34    uint renderThreadCount;
     35
    3336    double z;
    3437
    3538    QwtText title;
     39    QSize legendIconSize;
    3640};
    3741
     
    7478        return;
    7579
    76     // remove the item from the previous plot
    77 
    7880    if ( d_data->plot )
    79     {
    80         if ( d_data->plot->legend() )
    81             d_data->plot->legend()->remove( this );
    82 
    8381        d_data->plot->attachItem( this, false );
    8482
    85         if ( d_data->plot->autoReplot() )
    86             d_data->plot->update();
    87     }
    88 
    8983    d_data->plot = plot;
    9084
    9185    if ( d_data->plot )
    92     {
    93         // insert the item into the current plot
    94 
    9586        d_data->plot->attachItem( this, true );
    96         itemChanged();
    97     }
     87}
     88
     89/*!
     90   \brief This method detaches a QwtPolarItem from the QwtPolarPlot it
     91          has been associated with.
     92
     93   detach() is equivalent to calling attach( NULL )
     94   \sa attach()
     95*/
     96void QwtPolarItem::detach()
     97{
     98    attach( NULL );
    9899}
    99100
     
    257258}
    258259
     260/*!
     261   On multi core systems rendering of certain plot item
     262   ( f.e QwtPolarSpectrogram ) can be done in parallel in
     263   several threads.
     264
     265   The default setting is set to 1.
     266
     267   \param numThreads Number of threads to be used for rendering.
     268                     If numThreads is set to 0, the system specific
     269                     ideal thread count is used.
     270
     271   The default thread count is 1 ( = no additional threads )
     272*/
     273void QwtPolarItem::setRenderThreadCount( uint numThreads )
     274{
     275    d_data->renderThreadCount = numThreads;
     276}
     277
     278/*!
     279   \return Number of threads to be used for rendering.
     280           If numThreads() is set to 0, the system specific
     281           ideal thread count is used.
     282*/
     283uint QwtPolarItem::renderThreadCount() const
     284{
     285    return d_data->renderThreadCount;
     286}
     287
     288/*!
     289   Set the size of the legend icon
     290
     291   The default setting is 8x8 pixels
     292
     293   \param size Size
     294   \sa legendIconSize(), legendIcon()
     295*/
     296void QwtPolarItem::setLegendIconSize( const QSize &size )
     297{
     298    if ( d_data->legendIconSize != size )
     299    {
     300        d_data->legendIconSize = size;
     301        legendChanged();
     302    }
     303}
     304
     305/*!
     306   \return Legend icon size
     307   \sa setLegendIconSize(), legendIcon()
     308*/
     309QSize QwtPolarItem::legendIconSize() const
     310{
     311    return d_data->legendIconSize;
     312}
     313
    259314//! Show the item
    260315void QwtPolarItem::show()
     
    302357{
    303358    if ( d_data->plot )
    304     {
    305         if ( d_data->plot->legend() )
    306             updateLegend( d_data->plot->legend() );
    307 
    308359        d_data->plot->autoRefresh();
    309     }
     360}
     361
     362/*!
     363   Update the legend of the parent plot.
     364   \sa QwtPolarPlot::updateLegend(), itemChanged()
     365*/
     366void QwtPolarItem::legendChanged()
     367{
     368    if ( testItemAttribute( QwtPolarItem::Legend ) && d_data->plot )
     369        d_data->plot->updateLegend( this );
    310370}
    311371
     
    351411
    352412/*!
    353    \brief Update the widget that represents the item on the legend
    354 
    355    updateLegend() is called from itemChanged() to adopt the widget
    356    representing the item on the legend to its new configuration.
    357 
    358    The default implementation is made for QwtPolarCurve and updates a
    359    QwtLegendItem(), but an item could be represented by any type of widget,
    360    by overloading legendItem() and updateLegend().
    361 
    362    \sa legendItem(), itemChanged(), QwtLegend()
    363 */
    364 void QwtPolarItem::updateLegend( QwtLegend *legend ) const
    365 {
    366     if ( legend == NULL )
    367         return;
    368 
    369     QWidget *lgdItem = legend->find( this );
    370     if ( testItemAttribute( QwtPolarItem::Legend ) )
    371     {
    372         if ( lgdItem == NULL )
    373         {
    374             lgdItem = legendItem();
    375             if ( lgdItem )
    376                 legend->insert( this, lgdItem );
    377         }
    378 
    379         QwtLegendItem* label = qobject_cast<QwtLegendItem *>( lgdItem );
    380         if ( label )
    381         {
    382             // paint the identifier
    383             const QSize sz = label->identifierSize();
    384 
    385             QPixmap identifier( sz.width(), sz.height() );
    386             identifier.fill( Qt::transparent );
    387 
    388             QPainter painter( &identifier );
    389             painter.setRenderHint( QPainter::Antialiasing,
    390                 testRenderHint( QwtPolarItem::RenderAntialiased ) );
    391 
    392             drawLegendIdentifier( &painter,
    393                 QRect( 0, 0, sz.width(), sz.height() ) );
    394 
    395             painter.end();
    396 
    397             const bool doUpdate = label->updatesEnabled();
    398             if ( doUpdate )
    399                 label->setUpdatesEnabled( false );
    400 
    401             label->setText( title() );
    402             label->setIdentifier( identifier );
    403             label->setItemMode( legend->itemMode() );
    404 
    405             if ( doUpdate )
    406                 label->setUpdatesEnabled( true );
    407 
    408             label->update();
    409         }
    410     }
    411     else
    412     {
    413         if ( lgdItem )
    414         {
    415             lgdItem->hide();
    416             lgdItem->deleteLater();
    417         }
    418     }
    419 }
    420 /*!
    421    \brief Allocate the widget that represents the item on the legend
    422 
    423    The default implementation is made for QwtPolarCurve and returns a
    424    QwtLegendItem(), but an item could be represented by any type of widget,
    425    by overloading legendItem() and updateLegend().
    426 
    427    \return QwtLegendItem()
    428    \sa updateLegend() QwtLegend()
    429 */
    430 QWidget *QwtPolarItem::legendItem() const
    431 {
    432     QwtLegendItem *item = new QwtLegendItem;
    433     if ( d_data->plot )
    434     {
    435         QObject::connect( item, SIGNAL( clicked() ),
    436             d_data->plot, SLOT( legendItemClicked() ) );
    437         QObject::connect( item, SIGNAL( checked( bool ) ),
    438             d_data->plot, SLOT( legendItemChecked( bool ) ) );
    439     }
    440     return item;
     413   \brief Return all information, that is needed to represent
     414          the item on the legend
     415
     416   Most items are represented by one entry on the legend
     417   showing an icon and a text.
     418
     419   QwtLegendData is basically a list of QVariants that makes it
     420   possible to overload and reimplement legendData() to
     421   return almost any type of information, that is understood
     422   by the receiver that acts as the legend.
     423
     424   The default implementation returns one entry with
     425   the title() of the item and the legendIcon().
     426
     427   \sa title(), legendIcon(), QwtLegend
     428 */
     429QList<QwtLegendData> QwtPolarItem::legendData() const
     430{
     431    QwtLegendData data;
     432
     433    QwtText label = title();
     434    label.setRenderFlags( label.renderFlags() & Qt::AlignLeft );
     435
     436    QVariant titleValue;
     437    qVariantSetValue( titleValue, label );
     438    data.setValue( QwtLegendData::TitleRole, titleValue );
     439
     440    const QwtGraphic graphic = legendIcon( 0, legendIconSize() );
     441    if ( !graphic.isNull() )
     442    {
     443        QVariant iconValue;
     444        qVariantSetValue( iconValue, graphic );
     445        data.setValue( QwtLegendData::IconRole, iconValue );
     446    }
     447
     448    QList<QwtLegendData> list;
     449    list += data;
     450
     451    return list;
     452}
     453
     454/*!
     455   \return Icon representing the item on the legend
     456
     457   The default implementation returns an invalid icon
     458
     459   \param index Index of the legend entry
     460                ( usually there is only one )
     461   \param size Icon size
     462
     463   \sa setLegendIconSize(), legendData()
     464 */
     465QwtGraphic QwtPolarItem::legendIcon(
     466    int index, const QSizeF &size ) const
     467{
     468    Q_UNUSED( index )
     469    Q_UNUSED( size )
     470
     471    return QwtGraphic();
    441472}
    442473
  • trunk/BNC/qwtpolar/qwt_polar_item.h

    r4272 r8127  
    1212#include "qwt_polar_global.h"
    1313#include <qwt_text.h>
    14 #include <qwt_legend_itemmanager.h>
     14#include <qwt_legend_data.h>
     15#include <qwt_graphic.h>
    1516#include <qwt_interval.h>
    1617
     
    3435  types of items.
    3536*/
    36 class QWT_POLAR_EXPORT QwtPolarItem: public QwtLegendItemManager
     37class QWT_POLAR_EXPORT QwtPolarItem
    3738{
    3839public:
     
    103104
    104105    void attach( QwtPolarPlot *plot );
    105 
    106     /*!
    107        \brief This method detaches a QwtPolarItem from any QwtPolarPlot it
    108               has been associated with.
    109 
    110        detach() is equivalent to calling attach( NULL )
    111        \sa attach( QwtPolarPlot* plot )
    112     */
    113     void detach() { attach( NULL ); }
     106    void detach();
    114107
    115108    QwtPolarPlot *plot() const;
     
    127120    bool testRenderHint( RenderHint ) const;
    128121
     122    void setRenderThreadCount( uint numThreads );
     123    uint renderThreadCount() const;
     124
    129125    double z() const;
    130126    void setZ( double z );
     
    136132
    137133    virtual void itemChanged();
     134    virtual void legendChanged();
    138135
    139136    /*!
     
    154151    virtual QwtInterval boundingInterval( int scaleId ) const;
    155152
    156     virtual QWidget *legendItem() const;
    157 
    158     virtual void updateLegend( QwtLegend * ) const;
    159153    virtual void updateScaleDiv( const QwtScaleDiv &,
    160154        const QwtScaleDiv &, const QwtInterval & );
    161155
    162156    virtual int marginHint() const;
     157
     158    void setLegendIconSize( const QSize & );
     159    QSize legendIconSize() const;
     160
     161    virtual QList<QwtLegendData> legendData() const;
     162    virtual QwtGraphic legendIcon( int index, const QSizeF  & ) const;
    163163
    164164private:
     
    174174Q_DECLARE_OPERATORS_FOR_FLAGS( QwtPolarItem::RenderHints )
    175175
     176Q_DECLARE_METATYPE( QwtPolarItem * )
     177
    176178#endif
  • trunk/BNC/qwtpolar/qwt_polar_itemdict.cpp

    r4272 r8127  
    110110
    111111/*!
    112    Attach/Detach a plot item
     112  Insert a plot item
    113113
    114    Attached items will be deleted in the destructor,
    115    if auto deletion is enabled (default). Manually detached
    116    items are not deleted.
     114  \param item PlotItem
     115  \sa removeItem()
     116 */
     117void QwtPolarItemDict::insertItem( QwtPolarItem *item )
     118{
     119    d_data->itemList.insertItem( item );
     120}
    117121
    118    \param item Plot item to attach/detach
    119    \ on If true attach, else detach the item
     122/*!
     123  Remove a plot item
    120124
    121    \sa setAutoDelete, ~QwtPolarItemDict
    122 */
    123 void QwtPolarItemDict::attachItem( QwtPolarItem *item, bool on )
     125  \param item PlotItem
     126  \sa insertItem()
     127 */
     128void QwtPolarItemDict::removeItem( QwtPolarItem *item )
    124129{
    125     if ( on )
    126         d_data->itemList.insertItem( item );
    127     else
    128         d_data->itemList.removeItem( item );
     130    d_data->itemList.removeItem( item );
    129131}
    130132
  • trunk/BNC/qwtpolar/qwt_polar_itemdict.h

    r4272 r8127  
    4444        bool autoDelete = true );
    4545
     46protected:
     47    void insertItem( QwtPolarItem * );
     48    void removeItem( QwtPolarItem * );
     49
    4650private:
    47     friend class QwtPolarItem;
    48 
    49     void attachItem( QwtPolarItem *, bool );
    50 
    5151    class PrivateData;
    5252    PrivateData *d_data;
  • trunk/BNC/qwtpolar/qwt_polar_layout.cpp

    r7990 r8127  
    2323    {
    2424        int frameWidth;
    25         int vScrollBarWidth;
    26         int hScrollBarHeight;
     25        int hScrollExtent;
     26        int vScrollExtent;
    2727        QSizeF hint;
    2828    } legend;
     
    4949    {
    5050        legend.frameWidth = plot->legend()->frameWidth();
    51         legend.vScrollBarWidth =
    52             plot->legend()->verticalScrollBar()->sizeHint().width();
    53         legend.hScrollBarHeight =
    54             plot->legend()->horizontalScrollBar()->sizeHint().height();
     51        legend.hScrollExtent =
     52            plot->legend()->scrollExtent( Qt::Horizontal );
     53        legend.vScrollExtent =
     54            plot->legend()->scrollExtent( Qt::Vertical );
    5555
    5656        const QSizeF hint = plot->legend()->sizeHint();
     
    6262
    6363        if ( h > rect.height() )
    64             w += legend.vScrollBarWidth;
     64            w += legend.hScrollExtent;
    6565
    6666        legend.hint = QSizeF( w, h );
     
    279279        // half of the available space.
    280280
    281         dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio) );
     281        dim = qMin( double( hint.width() ), rect.width() * d_data->legendRatio );
    282282
    283283        if ( !( options & IgnoreScrollbars ) )
     
    288288                // space for the vertical scrollbar.
    289289
    290                 dim += d_data->layoutData.legend.vScrollBarWidth;
     290                dim += d_data->layoutData.legend.hScrollExtent;
    291291            }
    292292        }
     
    294294    else
    295295    {
    296         dim = qMin( hint.width(), qreal(rect.width() * d_data->legendRatio) );
    297         dim = qMax( dim, d_data->layoutData.legend.hScrollBarHeight );
     296        dim = qMin( double( hint.height() ), rect.height() * d_data->legendRatio );
     297        dim = qMax( dim, d_data->layoutData.legend.vScrollExtent );
    298298    }
    299299
  • trunk/BNC/qwtpolar/qwt_polar_plot.cpp

    r4272 r8127  
    1616#include <qwt_round_scale_draw.h>
    1717#include <qwt_legend.h>
    18 #include <qwt_legend_item.h>
    1918#include <qwt_dyngrid_layout.h>
    2019#include <qpointer.h>
     
    3534public:
    3635    ScaleData():
     36        isValid( false ),
    3737        scaleEngine( NULL )
    3838    {
     
    5353    int maxMinor;
    5454
     55    bool isValid;
     56
    5557    QwtScaleDiv scaleDiv;
    5658    QwtScaleEngine *scaleEngine;
     
    7072    QPointer<QwtTextLabel> titleLabel;
    7173    QPointer<QwtPolarCanvas> canvas;
    72     QPointer<QwtLegend> legend;
     74    QPointer<QwtAbstractLegend> legend;
    7375    double azimuthOrigin;
    7476
     
    183185      QwtPolarLayout::setLegendPosition()
    184186*/
    185 void QwtPolarPlot::insertLegend( QwtLegend *legend,
     187void QwtPolarPlot::insertLegend( QwtAbstractLegend *legend,
    186188    QwtPolarPlot::LegendPosition pos, double ratio )
    187189{
    188190    d_data->layout->setLegendPosition( pos, ratio );
     191
    189192    if ( legend != d_data->legend )
    190193    {
     
    196199        if ( d_data->legend )
    197200        {
    198             if ( pos != ExternalLegend )
     201            connect( this,
     202                SIGNAL( legendDataChanged(
     203                    const QVariant &, const QList<QwtLegendData> & ) ),
     204                d_data->legend,
     205                SLOT( updateLegend(
     206                    const QVariant &, const QList<QwtLegendData> & ) )
     207            );
     208
     209            if ( d_data->legend->parent() != this )
     210                d_data->legend->setParent( this );
     211
     212            updateLegend();
     213
     214            QwtLegend *lgd = qobject_cast<QwtLegend *>( legend );
     215            if ( lgd )
    199216            {
    200                 if ( d_data->legend->parent() != this )
    201                     d_data->legend->setParent( this );
    202             }
    203 
    204             const QwtPolarItemList& itmList = itemList();
    205             for ( QwtPolarItemIterator it = itmList.begin();
    206                     it != itmList.end(); ++it )
    207             {
    208                 ( *it )->updateLegend( d_data->legend );
    209             }
    210 
    211             QwtDynGridLayout *tl = qobject_cast<QwtDynGridLayout *>(
    212                 d_data->legend->contentsWidget()->layout() );
    213 
    214             if ( tl )
    215             {
    216                 switch( d_data->layout->legendPosition() )
     217                switch ( d_data->layout->legendPosition() )
    217218                {
    218219                    case LeftLegend:
    219220                    case RightLegend:
    220                         tl->setMaxCols( 1 ); // 1 column: align vertical
     221                    {
     222                        if ( lgd->maxColumns() == 0     )
     223                            lgd->setMaxColumns( 1 ); // 1 column: align vertical
    221224                        break;
    222 
     225                    }
    223226                    case TopLegend:
    224227                    case BottomLegend:
    225                         tl->setMaxCols( 0 ); // unlimited
     228                    {
     229                        lgd->setMaxColumns( 0 ); // unlimited
    226230                        break;
    227 
    228                     case ExternalLegend:
     231                    }
     232                    default:
    229233                        break;
    230234                }
    231235            }
    232         }
    233     }
     236
     237        }
     238    }
     239
    234240    updateLayout();
     241}
     242
     243/*!
     244  Emit legendDataChanged() for all plot item
     245
     246  \sa QwtPlotItem::legendData(), legendDataChanged()
     247 */
     248void QwtPolarPlot::updateLegend()
     249{
     250    const QwtPolarItemList& itmList = itemList();
     251    for ( QwtPolarItemIterator it = itmList.begin();
     252        it != itmList.end(); ++it )
     253    {
     254        updateLegend( *it );
     255    }
     256}
     257
     258/*!
     259  Emit legendDataChanged() for a plot item
     260
     261  \param plotItem Plot item
     262  \sa QwtPlotItem::legendData(), legendDataChanged()
     263 */
     264void QwtPolarPlot::updateLegend( const QwtPolarItem *plotItem )
     265{
     266    if ( plotItem == NULL )
     267        return;
     268
     269    QList<QwtLegendData> legendData;
     270
     271    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
     272        legendData = plotItem->legendData();
     273
     274    const QVariant itemInfo = itemToInfo( const_cast< QwtPolarItem *>( plotItem) );
     275    Q_EMIT legendDataChanged( itemInfo, legendData );
    235276}
    236277
     
    239280  \sa insertLegend()
    240281*/
    241 QwtLegend *QwtPolarPlot::legend()
     282QwtAbstractLegend *QwtPolarPlot::legend()
    242283{
    243284    return d_data->legend;
     
    248289  \sa insertLegend()
    249290*/
    250 const QwtLegend *QwtPolarPlot::legend() const
     291const QwtAbstractLegend *QwtPolarPlot::legend() const
    251292{
    252293    return d_data->legend;
    253 }
    254 
    255 /*!
    256   Called internally when the legend has been clicked on.
    257   Emits a legendClicked() signal.
    258 */
    259 void QwtPolarPlot::legendItemClicked()
    260 {
    261     if ( d_data->legend && sender()->isWidgetType() )
    262     {
    263         QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
    264             d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
    265         if ( plotItem )
    266             Q_EMIT legendClicked( plotItem );
    267     }
    268 }
    269 
    270 /*!
    271   Called internally when the legend has been checked
    272   Emits a legendClicked() signal.
    273 */
    274 void QwtPolarPlot::legendItemChecked( bool on )
    275 {
    276     if ( d_data->legend && sender()->isWidgetType() )
    277     {
    278         QwtPolarItem *plotItem = static_cast< QwtPolarItem* >(
    279             d_data->legend->find( qobject_cast<const QWidget *>( sender() ) ) );
    280         if ( plotItem )
    281             Q_EMIT legendChecked( plotItem, on );
    282     }
    283294}
    284295
     
    389400        return;
    390401
    391     if ( maxMinor < 0 )
    392         maxMinor = 0;
    393     if ( maxMinor > 100 )
    394         maxMinor = 100;
     402    maxMinor = qBound( 0, maxMinor, 100 );
    395403
    396404    ScaleData &scaleData = d_data->scaleData[scaleId];
     
    399407    {
    400408        scaleData.maxMinor = maxMinor;
    401         scaleData.scaleDiv.invalidate();
     409        scaleData.isValid = false;
    402410        autoRefresh();
    403411    }
     
    429437        return;
    430438
    431     if ( maxMajor < 1 )
    432         maxMajor = 1;
    433     if ( maxMajor > 1000 )
    434         maxMajor = 10000;
     439    maxMajor = qBound( 1, maxMajor, 10000 );
    435440
    436441    ScaleData &scaleData = d_data->scaleData[scaleId];
     
    438443    {
    439444        scaleData.maxMajor = maxMajor;
    440         scaleData.scaleDiv.invalidate();
     445        scaleData.isValid = false;
    441446        autoRefresh();
    442447    }
     
    477482    scaleData.scaleEngine = scaleEngine;
    478483
    479     scaleData.scaleDiv.invalidate();
     484    scaleData.isValid = false;
    480485
    481486    autoRefresh();
     
    527532    ScaleData &scaleData = d_data->scaleData[scaleId];
    528533
    529     scaleData.scaleDiv.invalidate();
     534    scaleData.isValid = false;
    530535
    531536    scaleData.minValue = min;
     
    551556
    552557    scaleData.scaleDiv = scaleDiv;
     558    scaleData.isValid = true;
    553559    scaleData.doAutoScale = false;
    554560
     
    732738    {
    733739        map.setPaintInterval( d_data->azimuthOrigin,
    734             d_data->azimuthOrigin + M_2PI );
     740            d_data->azimuthOrigin + 2 * M_PI );
    735741    }
    736742    else
     
    820826        scaleData.maxMajor = 8;
    821827
     828        scaleData.isValid = false;
     829
    822830        scaleData.scaleEngine = new QwtLinearScaleEngine;
    823         scaleData.scaleDiv.invalidate();
    824831    }
    825832    d_data->zoomFactor = 1.0;
     
    858865    }
    859866
    860     if ( d_data->legend &&
    861         d_data->layout->legendPosition() != ExternalLegend )
    862     {
    863         if ( d_data->legend->itemCount() > 0 )
    864         {
    865             d_data->legend->setGeometry( d_data->layout->legendRect().toRect() );
     867    if ( d_data->legend )
     868    {
     869        if ( d_data->legend->isEmpty() )
     870        {
     871            d_data->legend->hide();
     872        }
     873        else
     874        {
     875            const QRectF legendRect = d_data->layout->legendRect();
     876            d_data->legend->setGeometry( legendRect.toRect() );
    866877            d_data->legend->show();
    867878        }
    868         else
    869             d_data->legend->hide();
    870879    }
    871880
     
    10541063        d.scaleEngine->autoScale( d.maxMajor,
    10551064                                  minValue, maxValue, stepSize );
    1056         d.scaleDiv.invalidate();
    1057     }
    1058 
    1059     if ( !d.scaleDiv.isValid() )
     1065        d.isValid = false;
     1066    }
     1067
     1068    if ( !d.isValid )
    10601069    {
    10611070        d.scaleDiv = d.scaleEngine->divideScale(
    10621071            minValue, maxValue, d.maxMajor, d.maxMinor, stepSize );
     1072        d.isValid = true;
    10631073    }
    10641074
     
    12701280    return d_data->layout;
    12711281}
     1282
     1283/*!
     1284  \brief Attach/Detach a plot item
     1285
     1286  \param plotItem Plot item
     1287  \param on When true attach the item, otherwise detach it
     1288 */
     1289void QwtPolarPlot::attachItem( QwtPolarItem *plotItem, bool on )
     1290{
     1291    if ( on )
     1292        insertItem( plotItem );
     1293    else
     1294        removeItem( plotItem );
     1295
     1296    Q_EMIT itemAttached( plotItem, on );
     1297
     1298    if ( plotItem->testItemAttribute( QwtPolarItem::Legend ) )
     1299    {
     1300        // the item wants to be represented on the legend
     1301
     1302        if ( on )
     1303        {
     1304            updateLegend( plotItem );
     1305        }
     1306        else
     1307        {
     1308            const QVariant itemInfo = itemToInfo( plotItem );
     1309            Q_EMIT legendDataChanged( itemInfo, QList<QwtLegendData>() );
     1310        }
     1311    }
     1312
     1313    if ( autoReplot() )
     1314        update();
     1315}
     1316
     1317/*!
     1318  \brief Build an information, that can be used to identify
     1319         a plot item on the legend.
     1320
     1321  The default implementation simply wraps the plot item
     1322  into a QVariant object. When overloading itemToInfo()
     1323  usually infoToItem() needs to reimplemeted too.
     1324
     1325\code
     1326    QVariant itemInfo;
     1327    qVariantSetValue( itemInfo, plotItem );
     1328\endcode
     1329
     1330  \param plotItem Plot item
     1331  \sa infoToItem()
     1332 */
     1333QVariant QwtPolarPlot::itemToInfo( QwtPolarItem *plotItem ) const
     1334{
     1335    QVariant itemInfo;
     1336    qVariantSetValue( itemInfo, plotItem );
     1337
     1338    return itemInfo;
     1339}
     1340
     1341/*!
     1342  \brief Identify the plot item according to an item info object,
     1343         that has bee generated from itemToInfo().
     1344
     1345  The default implementation simply tries to unwrap a QwtPlotItem
     1346  pointer:
     1347
     1348\code
     1349    if ( itemInfo.canConvert<QwtPlotItem *>() )
     1350        return qvariant_cast<QwtPlotItem *>( itemInfo );
     1351\endcode
     1352  \param itemInfo Plot item
     1353  \return A plot item, when successful, otherwise a NULL pointer.
     1354  \sa itemToInfo()
     1355*/
     1356QwtPolarItem *QwtPolarPlot::infoToItem( const QVariant &itemInfo ) const
     1357{
     1358    if ( itemInfo.canConvert<QwtPolarItem *>() )
     1359        return qvariant_cast<QwtPolarItem *>( itemInfo );
     1360
     1361    return NULL;
     1362}
  • trunk/BNC/qwtpolar/qwt_polar_plot.h

    r4272 r8127  
    2424class QwtPolarCanvas;
    2525class QwtPolarLayout;
     26class QwtAbstractLegend;
    2627
    2728/*!
     
    141142    // Legend
    142143
    143     void insertLegend( QwtLegend *,
     144    void insertLegend( QwtAbstractLegend *,
    144145        LegendPosition = RightLegend, double ratio = -1.0 );
    145146
    146     QwtLegend *legend();
    147     const QwtLegend *legend() const;
     147    QwtAbstractLegend *legend();
     148    const QwtAbstractLegend *legend() const;
     149
     150    void updateLegend();
     151    void updateLegend( const QwtPolarItem * );
    148152
    149153    // Layout
     
    157161    int plotMarginHint() const;
    158162
     163    virtual QVariant itemToInfo( QwtPolarItem * ) const;
     164    virtual QwtPolarItem *infoToItem( const QVariant & ) const;
     165
    159166Q_SIGNALS:
    160167    /*!
    161       A signal which is emitted when the user has clicked on
    162       a legend item, which is in QwtLegend::ClickableItem mode.
    163 
    164       \param plotItem Corresponding plot item of the
    165                  selected legend item
    166 
    167       \note clicks are disabled as default
    168       \sa QwtLegend::setItemMode, QwtLegend::itemMode
    169      */
    170     void legendClicked( QwtPolarItem *plotItem );
    171 
    172     /*!
    173       A signal which is emitted when the user has clicked on
    174       a legend item, which is in QwtLegend::CheckableItem mode
    175 
    176       \param plotItem Corresponding plot item of the
    177                  selected legend item
    178       \param on True when the legen item is checked
    179 
    180       \note clicks are disabled as default
    181       \sa QwtLegend::setItemMode, QwtLegend::itemMode
    182      */
    183     void legendChecked( QwtPolarItem *plotItem, bool on );
     168      A signal indicating, that an item has been attached/detached
     169
     170      \param plotItem Plot item
     171      \param on Attached/Detached
     172     */
     173    void itemAttached( QwtPolarItem *plotItem, bool on );
     174
     175    /*!
     176      A signal with the attributes how to update
     177      the legend entries for a plot item.
     178               
     179      \param itemInfo Info about a plot, build from itemToInfo()
     180   
     181      \sa itemToInfo(), infoToItem(), QwtAbstractLegend::updateLegend()
     182     */
     183    void legendDataChanged( const QVariant &itemInfo,
     184        const QList<QwtLegendData> &data );
    184185
    185186    /*!
     
    194195    void setAzimuthOrigin( double );
    195196
    196 protected Q_SLOTS:
    197     virtual void legendItemClicked();
    198     virtual void legendItemChecked( bool );
    199 
    200197protected:
    201198    virtual bool event( QEvent * );
     
    210207
    211208private:
     209    friend class QwtPolarItem;
     210    void attachItem( QwtPolarItem *, bool );
     211
    212212    void initPlot( const QwtText & );
    213213
  • trunk/BNC/qwtpolar/qwt_polar_renderer.cpp

    r4272 r8127  
    1111#include "qwt_polar_layout.h"
    1212#include <qwt_legend.h>
    13 #include <qwt_legend_item.h>
    1413#include <qwt_dyngrid_layout.h>
    1514#include <qwt_text_label.h>
     
    1716#include <qpainter.h>
    1817#include <qprinter.h>
     18#include <qprintdialog.h>
     19#include <qfiledialog.h>
    1920#include <qimagewriter.h>
    2021#include <qfileinfo.h>
     
    115116
    116117    const QString fmt = format.toLower();
    117     if ( format == "pdf" || format == "ps" )
    118     {
     118    if ( format == "pdf" )
     119    {
     120#ifndef QT_NO_PRINTER
    119121        QPrinter printer;
     122        printer.setColorMode( QPrinter::Color );
    120123        printer.setFullPage( true );
    121124        printer.setPaperSize( sizeMM, QPrinter::Millimeter );
    122125        printer.setDocName( title );
    123126        printer.setOutputFileName( fileName );
    124         printer.setOutputFormat( ( format == "pdf" )
    125             ? QPrinter::PdfFormat : QPrinter::PostScriptFormat );
     127        printer.setOutputFormat( QPrinter::PdfFormat );
    126128        printer.setResolution( resolution );
    127129
    128130        QPainter painter( &printer );
    129131        render( plot, &painter, documentRect );
     132#endif
     133    }
     134    else if ( format == "ps" )
     135    {
     136#if QT_VERSION < 0x050000
     137#ifndef QT_NO_PRINTER
     138        QPrinter printer;
     139        printer.setColorMode( QPrinter::Color );
     140        printer.setFullPage( true );
     141        printer.setPaperSize( sizeMM, QPrinter::Millimeter );
     142        printer.setDocName( title );
     143        printer.setOutputFileName( fileName );
     144        printer.setOutputFormat( QPrinter::PostScriptFormat );
     145        printer.setResolution( resolution );
     146
     147        QPainter painter( &printer );
     148        render( plot, &painter, documentRect );
     149#endif
     150#endif
    130151    }
    131152#ifndef QWT_NO_POLAR_SVG
     
    300321
    301322    painter->save();
    302     renderLegend( painter, layout->legendRect() );
     323    renderLegend( plot, painter, layout->legendRect() );
    303324    painter->restore();
    304325
     
    340361  Render the legend into a given rectangle.
    341362
     363  \param plot Plot widget
    342364  \param painter Painter
    343365  \param rect Bounding rectangle
    344366*/
    345 
    346 void QwtPolarRenderer::renderLegend(
     367void QwtPolarRenderer::renderLegend( const QwtPolarPlot *plot,
    347368    QPainter *painter, const QRectF &rect ) const
    348369{
    349     QwtLegend *legend = d_data->plot->legend();
    350     if ( legend == NULL || legend->isEmpty() )
    351         return;
    352 
    353     const QwtDynGridLayout *legendLayout = qobject_cast<QwtDynGridLayout *>(
    354         legend->contentsWidget()->layout() );
    355     if ( legendLayout == NULL )
    356         return;
    357 
    358     uint numCols = legendLayout->columnsForWidth( rect.width() );
    359     const QList<QRect> itemRects =
    360         legendLayout->layoutItems( rect.toRect(), numCols );
    361 
    362     int index = 0;
    363 
    364     for ( int i = 0; i < legendLayout->count(); i++ )
    365     {
    366         QLayoutItem *item = legendLayout->itemAt( i );
    367         QWidget *w = item->widget();
    368         if ( w )
     370    if ( plot->legend() )
     371        plot->legend()->renderLegend( painter, rect, true );
     372}
     373
     374/*!
     375   \brief Execute a file dialog and render the plot to the selected file
     376
     377   The document will be rendered in 85 dpi for a size 30x30 cm
     378
     379   \param plot Plot widget
     380   \param documentName Default document name
     381   \param sizeMM Size for the document in millimeters.
     382   \param resolution Resolution in dots per Inch (dpi)
     383
     384   \sa renderDocument()
     385*/
     386bool QwtPolarRenderer::exportTo( QwtPolarPlot *plot,
     387    const QString &documentName, const QSizeF &sizeMM, int resolution )
     388{
     389    if ( plot == NULL )
     390        return false;
     391
     392    QString fileName = documentName;
     393
     394    // What about translation
     395
     396#ifndef QT_NO_FILEDIALOG
     397    const QList<QByteArray> imageFormats =
     398        QImageWriter::supportedImageFormats();
     399
     400    QStringList filter;
     401#ifndef QT_NO_PRINTER
     402    filter += QString( "PDF " ) + tr( "Documents" ) + " (*.pdf)";
     403#endif
     404#ifndef QWT_NO_SVG
     405    filter += QString( "SVG " ) + tr( "Documents" ) + " (*.svg)";
     406#endif
     407#ifndef QT_NO_PRINTER
     408    filter += QString( "Postscript " ) + tr( "Documents" ) + " (*.ps)";
     409#endif
     410
     411    if ( imageFormats.size() > 0 )
     412    {
     413        QString imageFilter( tr( "Images" ) );
     414        imageFilter += " (";
     415        for ( int i = 0; i < imageFormats.size(); i++ )
    369416        {
    370             painter->save();
    371 
    372             painter->setClipRect( itemRects[index] );
    373             renderLegendItem( painter, w, itemRects[index] );
    374 
    375             index++;
    376             painter->restore();
     417            if ( i > 0 )
     418                imageFilter += " ";
     419            imageFilter += "*.";
     420            imageFilter += imageFormats[i];
    377421        }
    378     }
    379 
    380 }
    381 
    382 /*!
    383   Print the legend item into a given rectangle.
    384 
    385   \param painter Painter
    386   \param widget Widget representing a legend item
    387   \param rect Bounding rectangle
    388 
    389   \note When widget is not derived from QwtLegendItem renderLegendItem
    390         does nothing and needs to be overloaded
    391 */
    392 void QwtPolarRenderer::renderLegendItem( QPainter *painter,
    393     const QWidget *widget, const QRectF &rect ) const
    394 {
    395     const QwtLegendItem *item = qobject_cast<const QwtLegendItem *>( widget );
    396     if ( item )
    397     {
    398         const QSize sz = item->identifierSize();
    399 
    400         const QRectF identifierRect( rect.x() + item->margin(),
    401             rect.center().y() - 0.5 * sz.height(), sz.width(), sz.height() );
    402 
    403         QwtLegendItemManager *itemManger = d_data->plot->legend()->find( item );
    404         if ( itemManger )
    405         {
    406             painter->save();
    407             painter->setClipRect( identifierRect, Qt::IntersectClip );
    408             itemManger->drawLegendIdentifier( painter, identifierRect );
    409             painter->restore();
    410         }
    411 
    412         // Label
    413 
    414         QRectF titleRect = rect;
    415         titleRect.setX( identifierRect.right() + 2 * item->spacing() );
    416 
    417         painter->setFont( item->font() );
    418         item->text().draw( painter, titleRect );
    419     }
    420 }
    421 
     422        imageFilter += ")";
     423
     424        filter += imageFilter;
     425    }
     426
     427    fileName = QFileDialog::getSaveFileName(
     428        NULL, tr( "Export File Name" ), fileName,
     429        filter.join( ";;" ), NULL, QFileDialog::DontConfirmOverwrite );
     430#endif
     431    if ( fileName.isEmpty() )
     432        return false;
     433
     434    renderDocument( plot, fileName, sizeMM, resolution );
     435
     436    return true;
     437}
  • trunk/BNC/qwtpolar/qwt_polar_renderer.h

    r4272 r8127  
    1212#include "qwt_polar_global.h"
    1313#include <qobject.h>
     14#include <qsize.h>
    1415
    1516class QwtPolarPlot;
    16 class QSizeF;
    1717class QRectF;
    1818class QPainter;
     
    5252#endif
    5353    void renderTo( QwtPolarPlot *, QPrinter & ) const;
    54     void renderTo( QwtPolarPlot *, QPaintDevice &p ) const;
     54    void renderTo( QwtPolarPlot *, QPaintDevice & ) const;
    5555
    5656    virtual void render( QwtPolarPlot *,
    5757        QPainter *, const QRectF &rect ) const;
    5858
    59 protected:
     59    bool exportTo( QwtPolarPlot *, const QString &documentName,
     60        const QSizeF &sizeMM = QSizeF( 200, 200 ), int resolution = 85 );
     61
    6062    virtual void renderTitle( QPainter *, const QRectF & ) const;
    61     virtual void renderLegend( QPainter *, const QRectF & ) const;
    6263
    63     virtual void renderLegendItem( QPainter *,
    64         const QWidget *, const QRectF & ) const;
     64    virtual void renderLegend(
     65        const QwtPolarPlot *, QPainter *, const QRectF & ) const;
    6566
    6667private:
  • trunk/BNC/qwtpolar/qwt_polar_spectrogram.cpp

    r4272 r8127  
    9595public:
    9696    PrivateData():
    97         data( NULL ),
    98         renderThreadCount( 1 )
     97        data( NULL )
    9998    {
    10099        colorMap = new QwtLinearColorMap();
     
    109108    QwtRasterData *data;
    110109    QwtColorMap *colorMap;
    111 
    112     uint renderThreadCount;
    113110
    114111    QwtPolarSpectrogram::PaintAttributes paintAttributes;
     
    223220{
    224221    return ( d_data->paintAttributes & attribute );
    225 }
    226 
    227 /*!
    228    Rendering an image from the raster data can often be done
    229    parallel on a multicore system.
    230 
    231    \param numThreads Number of threads to be used for rendering.
    232                      If numThreads is set to 0, the system specific
    233                      ideal thread count is used.
    234 
    235    The default thread count is 1 ( = no additional threads )
    236 
    237    \warning Rendering in multiple threads is only supported for Qt >= 4.4
    238    \sa renderThreadCount(), renderImage(), renderTile()
    239 */
    240 void QwtPolarSpectrogram::setRenderThreadCount( uint numThreads )
    241 {
    242     d_data->renderThreadCount = numThreads;
    243 }
    244 
    245 /*!
    246    \return Number of threads to be used for rendering.
    247            If numThreads is set to 0, the system specific
    248            ideal thread count is used.
    249 
    250    \warning Rendering in multiple threads is only supported for Qt >= 4.4
    251    \sa setRenderThreadCount(), renderImage(), renderTile()
    252 */
    253 uint QwtPolarSpectrogram::renderThreadCount() const
    254 {
    255     return d_data->renderThreadCount;
    256222}
    257223
     
    357323
    358324#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
    359     uint numThreads = d_data->renderThreadCount;
     325    uint numThreads = renderThreadCount();
    360326
    361327    if ( numThreads <= 0 )
  • trunk/BNC/qwtpolar/qwt_polar_spectrogram.h

    r4272 r8127  
    6060    bool testPaintAttribute( PaintAttribute ) const;
    6161
    62     void setRenderThreadCount( uint numThreads );
    63     uint renderThreadCount() const;
    64 
    6562    virtual int rtti() const;
    6663
  • trunk/BNC/qwtpolar/qwtpolar.pro

    r5182 r8127  
    66CONFIG += release
    77DEFINES += QWT_POLAR_NO_SVG
     8greaterThan(QT_MAJOR_VERSION, 4) {
     9    QT += printsupport
     10    QT += concurrent
     11}
    812
    913INCLUDEPATH += ../qwt
     
    4549    qwt_polar_renderer.cpp \
    4650    qwt_polar_plot.cpp
    47 
Note: See TracChangeset for help on using the changeset viewer.