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

update qwt and qwtpolar, many QT5 fixes (unfinished)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/BNC/qwt/qwt_plot_spectrogram.cpp

    r4271 r8127  
    2424#endif
    2525
     26#define DEBUG_RENDER 0
     27
     28#if DEBUG_RENDER
     29#include <QElapsedTimer>
     30#endif
     31
    2632class QwtPlotSpectrogram::PrivateData
    2733{
    2834public:
    2935    PrivateData():
    30         data( NULL ),
    31         renderThreadCount( 1 )
     36        data( NULL )
    3237    {
    3338        colorMap = new QwtLinearColorMap();
     
    3540
    3641        conrecFlags = QwtRasterData::IgnoreAllVerticesOnLevel;
     42#if 0
    3743        conrecFlags |= QwtRasterData::IgnoreOutOfRange;
     44#endif
    3845    }
    3946    ~PrivateData()
     
    4653    QwtColorMap *colorMap;
    4754    DisplayModes displayMode;
    48 
    49     uint renderThreadCount;
    5055
    5156    QList<double> contourLevels;
     
    108113    }
    109114
     115    legendChanged();
    110116    itemChanged();
    111117}
     
    123129
    124130/*!
    125    Rendering an image from the raster data can often be done
    126    parallel on a multicore system.
    127 
    128    \param numThreads Number of threads to be used for rendering.
    129                      If numThreads is set to 0, the system specific
    130                      ideal thread count is used.
    131 
    132    The default thread count is 1 ( = no additional threads )
    133 
    134    \warning Rendering in multiple threads is only supported for Qt >= 4.4
    135    \sa renderThreadCount(), renderImage(), renderTile()
    136 */
    137 void QwtPlotSpectrogram::setRenderThreadCount( uint numThreads )
    138 {
    139     d_data->renderThreadCount = numThreads;
    140 }
    141 
    142 /*!
    143    \return Number of threads to be used for rendering.
    144            If numThreads is set to 0, the system specific
    145            ideal thread count is used.
    146 
    147    \warning Rendering in multiple threads is only supported for Qt >= 4.4
    148    \sa setRenderThreadCount(), renderImage(), renderTile()
    149 */
    150 uint QwtPlotSpectrogram::renderThreadCount() const
    151 {
    152     return d_data->renderThreadCount;
    153 }
    154 
    155 /*!
    156131  Change the color map
    157132
     
    173148
    174149    invalidateCache();
     150
     151    legendChanged();
    175152    itemChanged();
    176153}
     
    183160{
    184161    return d_data->colorMap;
     162}
     163
     164/*!
     165  Build and assign the default pen for the contour lines
     166   
     167  In Qt5 the default pen width is 1.0 ( 0.0 in Qt4 ) what makes it
     168  non cosmetic ( see QPen::isCosmetic() ). This method has been introduced
     169  to hide this incompatibility.
     170   
     171  \param color Pen color
     172  \param width Pen width
     173  \param style Pen style
     174   
     175  \sa pen(), brush()
     176 */
     177void QwtPlotSpectrogram::setDefaultContourPen(
     178    const QColor &color, qreal width, Qt::PenStyle style )
     179{   
     180    setDefaultContourPen( QPen( color, width, style ) );
    185181}
    186182
     
    200196    {
    201197        d_data->defaultContourPen = pen;
     198
     199        legendChanged();
    202200        itemChanged();
    203201    }
     
    266264   \return true, is enabled
    267265
     266   The default setting enables QwtRasterData::IgnoreAllVerticesOnLevel
     267
    268268   \sa setConrecClag(), renderContourLines(),
    269269       QwtRasterData::contourLines()
     
    288288    d_data->contourLevels = levels;
    289289    qSort( d_data->contourLevels );
     290
     291    legendChanged();
    290292    itemChanged();
    291293}
    292294
    293295/*!
    294    \brief Return the levels of the contour lines.
     296   \return Levels of the contour lines.
    295297
    296298   The levels are sorted in increasing order.
     
    384386   \brief Render an image from data and color map.
    385387
    386    For each pixel of rect the value is mapped into a color.
     388   For each pixel of area the value is mapped into a color.
    387389
    388390  \param xMap X-Scale Map
     
    421423    d_data->data->initRaster( area, image.size() );
    422424
     425#if DEBUG_RENDER
     426        QElapsedTimer time;
     427        time.start();
     428#endif
     429
    423430#if QT_VERSION >= 0x040400 && !defined(QT_NO_QFUTURE)
    424     uint numThreads = d_data->renderThreadCount;
     431    uint numThreads = renderThreadCount();
    425432
    426433    if ( numThreads <= 0 )
     
    456463#endif
    457464
     465#if DEBUG_RENDER
     466    const qint64 elapsed = time.elapsed();
     467    qDebug() << "renderImage" << imageSize << elapsed;
     468#endif
     469
    458470    d_data->data->discardRaster();
    459471
     
    486498            const double ty = yMap.invTransform( y );
    487499
    488             QRgb *line = ( QRgb * )image->scanLine( y );
     500            QRgb *line = reinterpret_cast<QRgb *>( image->scanLine( y ) );
    489501            line += tile.left();
    490502
     
    521533   \brief Return the raster to be used by the CONREC contour algorithm.
    522534
    523    A larger size will improve the precisision of the CONREC algorithm,
     535   A larger size will improve the precision of the CONREC algorithm,
    524536   but will slow down the time that is needed to calculate the lines.
    525537
     
    527539   the resolution depending on pixelSize().
    528540
    529    \param area Rect, where to calculate the contour lines
    530    \param rect Rect in pixel coordinates, where to paint the contour lines
     541   \param area Rectangle, where to calculate the contour lines
     542   \param rect Rectangle in pixel coordinates, where to paint the contour lines
    531543   \return Raster to be used by the CONREC contour algorithm.
    532544
     
    556568   \param rect Rectangle, where to calculate the contour lines
    557569   \param raster Raster, used by the CONREC algorithm
     570   \return Calculated contour lines
    558571
    559572   \sa contourLevels(), setConrecFlag(),
     
    586599    if ( d_data->data == NULL )
    587600        return;
    588 
    589     const QwtInterval intensityRange = d_data->data->interval( Qt::ZAxis );
    590601
    591602    const int numLevels = d_data->contourLevels.size();
     
    622633  \param xMap Maps x-values into pixel coordinates.
    623634  \param yMap Maps y-values into pixel coordinates.
    624   \param canvasRect Contents rect of the canvas in painter coordinates
     635  \param canvasRect Contents rectangle of the canvas in painter coordinates
    625636
    626637  \sa setDisplayMode(), renderImage(),
Note: See TracChangeset for help on using the changeset viewer.