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_magnifier.cpp

    r8127 r11158  
    1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
     1/******************************************************************************
    22 * Qwt Widget Library
    33 * Copyright (C) 1997   Josef Wilgen
    … …  
    99
    1010#include "qwt_plot.h"
    11 #include "qwt_scale_div.h"
     11#include "qwt_scale_map.h"
    1212#include "qwt_plot_magnifier.h"
    13 #include <qevent.h>
    1413
    1514class QwtPlotMagnifier::PrivateData
    1615{
    17 public:
     16  public:
    1817    PrivateData()
    1918    {
    20         for ( int axis = 0; axis < QwtPlot::axisCnt; axis++ )
     19        for ( int axis = 0; axis < QwtAxis::AxisPositions; axis++ )
    2120            isAxisEnabled[axis] = true;
    2221    }
    2322
    24     bool isAxisEnabled[QwtPlot::axisCnt];
     23    bool isAxisEnabled[QwtAxis::AxisPositions];
    2524};
    2625
    … …  
    2827   Constructor
    2928   \param canvas Plot canvas to be magnified
    30 */
    31 QwtPlotMagnifier::QwtPlotMagnifier( QWidget *canvas ):
    32     QwtMagnifier( canvas )
     29 */
     30QwtPlotMagnifier::QwtPlotMagnifier( QWidget* canvas )
     31    : QwtMagnifier( canvas )
    3332{
    34     d_data = new PrivateData();
     33    m_data = new PrivateData();
    3534}
    3635
    … …  
    3837QwtPlotMagnifier::~QwtPlotMagnifier()
    3938{
    40     delete d_data;
     39    delete m_data;
    4140}
    4241
    … …  
    4746   All other axes will remain unchanged.
    4847
    49    \param axis Axis, see QwtPlot::Axis
     48   \param axisId Axis
    5049   \param on On/Off
    5150
    5251   \sa isAxisEnabled()
    53 */
    54 void QwtPlotMagnifier::setAxisEnabled( int axis, bool on )
     52 */
     53void QwtPlotMagnifier::setAxisEnabled( QwtAxisId axisId, bool on )
    5554{
    56     if ( axis >= 0 && axis < QwtPlot::axisCnt )
    57         d_data->isAxisEnabled[axis] = on;
     55    if ( QwtAxis::isValid( axisId ) )
     56        m_data->isAxisEnabled[axisId] = on;
    5857}
    5958
    … …  
    6160   Test if an axis is enabled
    6261
    63    \param axis Axis, see QwtPlot::Axis
     62   \param axisId Axis
    6463   \return True, if the axis is enabled
    6564
    6665   \sa setAxisEnabled()
    67 */
    68 bool QwtPlotMagnifier::isAxisEnabled( int axis ) const
     66 */
     67bool QwtPlotMagnifier::isAxisEnabled( QwtAxisId axisId ) const
    6968{
    70     if ( axis >= 0 && axis < QwtPlot::axisCnt )
    71         return d_data->isAxisEnabled[axis];
     69    if ( QwtAxis::isValid( axisId ) )
     70        return m_data->isAxisEnabled[axisId];
    7271
    7372    return true;
    … …  
    7574
    7675//! Return observed plot canvas
    77 QWidget *QwtPlotMagnifier::canvas()
     76QWidget* QwtPlotMagnifier::canvas()
    7877{
    7978    return parentWidget();
    … …  
    8180
    8281//! Return Observed plot canvas
    83 const QWidget *QwtPlotMagnifier::canvas() const
     82const QWidget* QwtPlotMagnifier::canvas() const
    8483{
    8584    return parentWidget();
    … …  
    8786
    8887//! Return plot widget, containing the observed plot canvas
    89 QwtPlot *QwtPlotMagnifier::plot()
     88QwtPlot* QwtPlotMagnifier::plot()
    9089{
    91     QWidget *w = canvas();
     90    QWidget* w = canvas();
    9291    if ( w )
    9392        w = w->parentWidget();
    9493
    95     return qobject_cast<QwtPlot *>( w );
     94    return qobject_cast< QwtPlot* >( w );
    9695}
    9796
    9897//! Return plot widget, containing the observed plot canvas
    99 const QwtPlot *QwtPlotMagnifier::plot() const
     98const QwtPlot* QwtPlotMagnifier::plot() const
    10099{
    101     const QWidget *w = canvas();
     100    const QWidget* w = canvas();
    102101    if ( w )
    103102        w = w->parentWidget();
    104103
    105     return qobject_cast<const QwtPlot *>( w );
     104    return qobject_cast< const QwtPlot* >( w );
    106105}
    107106
    … …  
    109108   Zoom in/out the axes scales
    110109   \param factor A value < 1.0 zooms in, a value > 1.0 zooms out.
    111 */
     110 */
    112111void QwtPlotMagnifier::rescale( double factor )
    113112{
    … …  
    125124    plt->setAutoReplot( false );
    126125
    127     for ( int axisId = 0; axisId < QwtPlot::axisCnt; axisId++ )
     126    for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ )
    128127    {
    129         if ( isAxisEnabled( axisId ) )
    130128        {
    131             const QwtScaleMap scaleMap = plt->canvasMap( axisId );
     129            const QwtAxisId axisId( axisPos );
    132130
    133             double v1 = scaleMap.s1();
    134             double v2 = scaleMap.s2();
     131            if ( isAxisEnabled( axisId ) )
     132            {
     133                const QwtScaleMap scaleMap = plt->canvasMap( axisId );
    135134
    136             if ( scaleMap.transformation() )
    137             {
    138                 // the coordinate system of the paint device is always linear
     135                double v1 = scaleMap.s1();
     136                double v2 = scaleMap.s2();
    139137
    140                 v1 = scaleMap.transform( v1 ); // scaleMap.p1()
    141                 v2 = scaleMap.transform( v2 ); // scaleMap.p2()
     138                if ( scaleMap.transformation() )
     139                {
     140                    // the coordinate system of the paint device is always linear
     141
     142                    v1 = scaleMap.transform( v1 ); // scaleMap.p1()
     143                    v2 = scaleMap.transform( v2 ); // scaleMap.p2()
     144                }
     145
     146                const double center = 0.5 * ( v1 + v2 );
     147                const double width_2 = 0.5 * ( v2 - v1 ) * factor;
     148
     149                v1 = center - width_2;
     150                v2 = center + width_2;
     151
     152                if ( scaleMap.transformation() )
     153                {
     154                    v1 = scaleMap.invTransform( v1 );
     155                    v2 = scaleMap.invTransform( v2 );
     156                }
     157
     158                plt->setAxisScale( axisId, v1, v2 );
     159                doReplot = true;
    142160            }
    143 
    144             const double center = 0.5 * ( v1 + v2 );
    145             const double width_2 = 0.5 * ( v2 - v1 ) * factor;
    146 
    147             v1 = center - width_2;
    148             v2 = center + width_2;
    149 
    150             if ( scaleMap.transformation() )
    151             {
    152                 v1 = scaleMap.invTransform( v1 );
    153                 v2 = scaleMap.invTransform( v2 );
    154             }
    155 
    156             plt->setAxisScale( axisId, v1, v2 );
    157             doReplot = true;
    158161        }
    159162    }
    … …  
    164167        plt->replot();
    165168}
     169
     170#include "moc_qwt_plot_magnifier.cpp"
Note: See TracChangeset for help on using the changeset viewer.