Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_plot_panner.cpp


Ignore:
Timestamp:
Nov 3, 2026, 10:53:35 AM (3 weeks ago)
Author:
stuerze
Message:

deprecated functions exchanged libs updated

File:
1 edited

Legend:

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

    r9383 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    1111#include "qwt_scale_div.h"
    1212#include "qwt_plot.h"
     13#include "qwt_scale_map.h"
    1314#include "qwt_painter.h"
     15
    1416#include <qbitmap.h>
    1517#include <qstyle.h>
    1618#include <qstyleoption.h>
     19#include <qpainter.h>
    1720#include <qpainterpath.h>
    1821
     22static QBitmap qwtBorderMask( const QWidget* canvas, const QSize& size )
     23{
    1924#if QT_VERSION >= 0x050000
    20 #if QT_VERSION < 0x050100
    21 #define QWT_USE_WINDOW_HANDLE 1
     25    const qreal pixelRatio = QwtPainter::devicePixelRatio( canvas );
    2226#endif
    23 #endif
    24 
    25 #ifdef QWT_USE_WINDOW_HANDLE
    26 #include <qwindow.h>
    27 #endif
    28 
    29 static QBitmap qwtBorderMask( const QWidget *canvas, const QSize &size )
    30 {
    31 #if QT_VERSION >= 0x050000
    32     qreal pixelRatio = 1.0;
    33 
    34 #ifdef QWT_USE_WINDOW_HANDLE
    35     pixelRatio = canvas->windowHandle()->devicePixelRatio();
    36 #else
    37     pixelRatio = canvas->devicePixelRatio();
    38 #endif
    39 #endif
    4027
    4128    const QRect r( 0, 0, size.width(), size.height() );
    … …  
    4431
    4532    ( void )QMetaObject::invokeMethod(
    46         const_cast< QWidget *>( canvas ), "borderPath", Qt::DirectConnection,
     33        const_cast< QWidget* >( canvas ), "borderPath", Qt::DirectConnection,
    4734        Q_RETURN_ARG( QPainterPath, borderPath ), Q_ARG( QRect, r ) );
    4835
    … …  
    5340
    5441#if QT_VERSION >= 0x050000
    55         QBitmap mask( size * pixelRatio );
     42        QBitmap mask( size* pixelRatio );
    5643        mask.setDevicePixelRatio( pixelRatio );
    5744#else
    … …  
    6754
    6855#if QT_VERSION >= 0x050000
    69     QImage image( size * pixelRatio, QImage::Format_ARGB32_Premultiplied );
     56    QImage image( size* pixelRatio, QImage::Format_ARGB32_Premultiplied );
    7057    image.setDevicePixelRatio( pixelRatio );
    7158#else
    … …  
    9481        const QVariant frameWidth = canvas->property( "frameWidth" );
    9582
    96         if ( borderRadius.type() == QVariant::Double
    97             && frameWidth.type() == QVariant::Int )
     83        if ( borderRadius.canConvert< double >() && frameWidth.canConvert< int >() )
    9884        {
    99             const double br = borderRadius.toDouble();
    100             const int fw = frameWidth.toInt();
     85            const double br = borderRadius.value< double >();
     86            const int fw = frameWidth.value< int >();
    10187
    10288            if ( br > 0.0 && fw > 0 )
    … …  
    121107class QwtPlotPanner::PrivateData
    122108{
    123 public:
     109  public:
    124110    PrivateData()
    125111    {
    126         for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
     112        for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ )
    127113            isAxisEnabled[axis] = true;
    128114    }
    129115
    130     bool isAxisEnabled[QwtPlot::axisCnt];
     116    bool isAxisEnabled[QwtAxis::AxisPositions];
    131117};
    132118
    133119/*!
    134   \brief A panner for the canvas of a QwtPlot
    135 
    136   The panner is enabled for all axes
    137 
    138   \param canvas Plot canvas to pan, also the parent object
    139 
    140   \sa setAxisEnabled()
    141 */
    142 QwtPlotPanner::QwtPlotPanner( QWidget *canvas ):
    143     QwtPanner( canvas )
    144 {
    145     d_data = new PrivateData();
     120   \brief A panner for the canvas of a QwtPlot
     121
     122   The panner is enabled for all axes
     123
     124   \param canvas Plot canvas to pan, also the parent object
     125
     126   \sa setAxisEnabled()
     127 */
     128QwtPlotPanner::QwtPlotPanner( QWidget* canvas )
     129    : QwtPanner( canvas )
     130{
     131    m_data = new PrivateData();
    146132
    147133    connect( this, SIGNAL(panned(int,int)),
    … …  
    152138QwtPlotPanner::~QwtPlotPanner()
    153139{
    154     delete d_data;
     140    delete m_data;
    155141}
    156142
    … …  
    161147   result of panning. All other axes will remain unchanged.
    162148
    163    \param axis Axis, see QwtPlot::Axis
     149   \param axisId Axis id
    164150   \param on On/Off
    165151
    166152   \sa isAxisEnabled(), moveCanvas()
    167 */
    168 void QwtPlotPanner::setAxisEnabled( int axis, bool on )
    169 {
    170     if ( axis >= 0 && axis < QwtPlot::axisCnt )
    171         d_data->isAxisEnabled[axis] = on;
     153 */
     154void QwtPlotPanner::setAxisEnabled( QwtAxisId axisId, bool on )
     155{
     156    if ( QwtAxis::isValid( axisId ) )
     157        m_data->isAxisEnabled[axisId] = on;
    172158}
    173159
    … …  
    175161   Test if an axis is enabled
    176162
    177    \param axis Axis, see QwtPlot::Axis
     163   \param axisId Axis
    178164   \return True, if the axis is enabled
    179165
    180166   \sa setAxisEnabled(), moveCanvas()
    181 */
    182 bool QwtPlotPanner::isAxisEnabled( int axis ) const
    183 {
    184     if ( axis >= 0 && axis < QwtPlot::axisCnt )
    185         return d_data->isAxisEnabled[axis];
     167 */
     168bool QwtPlotPanner::isAxisEnabled( QwtAxisId axisId ) const
     169{
     170    if ( QwtAxis::isValid( axisId ) )
     171        return m_data->isAxisEnabled[axisId];
    186172
    187173    return true;
    … …  
    189175
    190176//! Return observed plot canvas
    191 QWidget *QwtPlotPanner::canvas()
     177QWidget* QwtPlotPanner::canvas()
    192178{
    193179    return parentWidget();
    … …  
    195181
    196182//! Return Observed plot canvas
    197 const QWidget *QwtPlotPanner::canvas() const
     183const QWidget* QwtPlotPanner::canvas() const
    198184{
    199185    return parentWidget();
    … …  
    201187
    202188//! Return plot widget, containing the observed plot canvas
    203 QwtPlot *QwtPlotPanner::plot()
    204 {
    205     QWidget *w = canvas();
     189QwtPlot* QwtPlotPanner::plot()
     190{
     191    QWidget* w = canvas();
    206192    if ( w )
    207193        w = w->parentWidget();
    208194
    209     return qobject_cast<QwtPlot *>( w );
     195    return qobject_cast< QwtPlot* >( w );
    210196}
    211197
    212198//! Return plot widget, containing the observed plot canvas
    213 const QwtPlot *QwtPlotPanner::plot() const
    214 {
    215     const QWidget *w = canvas();
     199const QwtPlot* QwtPlotPanner::plot() const
     200{
     201    const QWidget* w = canvas();
    216202    if ( w )
    217203        w = w->parentWidget();
    218204
    219     return qobject_cast<const QwtPlot *>( w );
     205    return qobject_cast< const QwtPlot* >( w );
    220206}
    221207
    … …  
    227213
    228214   \sa QwtPanner::panned()
    229 */
     215 */
    230216void QwtPlotPanner::moveCanvas( int dx, int dy )
    231217{
    … …  
    233219        return;
    234220
    235     QwtPlot *plot = this->plot();
     221    QwtPlot* plot = this->plot();
    236222    if ( plot == NULL )
    237223        return;
    … …  
    240226    plot->setAutoReplot( false );
    241227
    242     for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
    243     {
    244         if ( !d_data->isAxisEnabled[axis] )
    245             continue;
    246 
    247         const QwtScaleMap map = plot->canvasMap( axis );
    248 
    249         const double p1 = map.transform( plot->axisScaleDiv( axis ).lowerBound() );
    250         const double p2 = map.transform( plot->axisScaleDiv( axis ).upperBound() );
    251 
    252         double d1, d2;
    253         if ( axis == QwtPlot::xBottom || axis == QwtPlot::xTop )
     228    for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
     229    {
    254230        {
    255             d1 = map.invTransform( p1 - dx );
    256             d2 = map.invTransform( p2 - dx );
     231            const QwtAxisId axisId( axisPos );
     232
     233            if ( !m_data->isAxisEnabled[axisId] )
     234                continue;
     235
     236            const QwtScaleMap map = plot->canvasMap( axisId );
     237
     238            const double p1 = map.transform( plot->axisScaleDiv( axisId ).lowerBound() );
     239            const double p2 = map.transform( plot->axisScaleDiv( axisId ).upperBound() );
     240
     241            double d1, d2;
     242            if ( QwtAxis::isXAxis( axisPos ) )
     243            {
     244                d1 = map.invTransform( p1 - dx );
     245                d2 = map.invTransform( p2 - dx );
     246            }
     247            else
     248            {
     249                d1 = map.invTransform( p1 - dy );
     250                d2 = map.invTransform( p2 - dy );
     251            }
     252
     253            plot->setAxisScale( axisId, d1, d2 );
    257254        }
    258         else
    259         {
    260             d1 = map.invTransform( p1 - dy );
    261             d2 = map.invTransform( p2 - dy );
    262         }
    263 
    264         plot->setAxisScale( axis, d1, d2 );
    265255    }
    266256
    … …  
    274264   \return Mask as bitmap
    275265   \sa QwtPlotCanvas::borderPath()
    276 */
     266 */
    277267QBitmap QwtPlotPanner::contentsMask() const
    278268{
    … …  
    288278QPixmap QwtPlotPanner::grab() const
    289279{
    290     const QWidget *cv = canvas();
     280    const QWidget* cv = canvas();
    291281    if ( cv && cv->inherits( "QGLWidget" ) )
    292282    {
    … …  
    297287
    298288        QPainter painter( &pm );
    299         const_cast<QwtPlot *>( plot() )->drawCanvas( &painter );
     289        const_cast< QwtPlot* >( plot() )->drawCanvas( &painter );
    300290
    301291        return pm;
    … …  
    305295}
    306296
     297#include "moc_qwt_plot_panner.cpp"
Note: See TracChangeset for help on using the changeset viewer.