Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_scale_map.h


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_scale_map.h

    r4271 r8127  
    1212
    1313#include "qwt_global.h"
    14 #include "qwt_math.h"
     14#include "qwt_transform.h"
     15#include <qrect.h>
     16
    1517#ifndef QT_NO_DEBUG_STREAM
    1618#include <qdebug.h>
     
    1820
    1921class QRectF;
    20 
    21 /*!
    22    \brief A transformation between coordinate systems
    23 
    24    QwtScaleTransformation offers transformations from the coordinate system
    25    of a scale into the linear coordinate system of a paint device
    26    and vice versa.
    27 */
    28 class QWT_EXPORT QwtScaleTransformation
    29 {
    30 public:
    31     //! Transformation type
    32     enum Type
    33     {
    34         //! Transformation between 2 linear scales
    35         Linear,
    36 
    37         //! Transformation between a linear and a logarithmic ( base 10 ) scale
    38         Log10,
    39 
    40         //! Any other type of transformation
    41         Other
    42     };
    43 
    44     QwtScaleTransformation( Type type );
    45     virtual ~QwtScaleTransformation();
    46 
    47     virtual double xForm( double x, double s1, double s2,
    48         double p1, double p2 ) const;
    49     virtual double invXForm( double x, double p1, double p2,
    50         double s1, double s2 ) const;
    51 
    52     Type type() const;
    53 
    54     virtual QwtScaleTransformation *copy() const;
    55 
    56 private:
    57     QwtScaleTransformation();
    58     QwtScaleTransformation &operator=( const QwtScaleTransformation );
    59 
    60     const Type d_type;
    61 };
    62 
    63 //! \return Transformation type
    64 inline QwtScaleTransformation::Type QwtScaleTransformation::type() const
    65 {
    66     return d_type;
    67 }
    6822
    6923/*!
     
    8438    QwtScaleMap &operator=( const QwtScaleMap & );
    8539
    86     void setTransformation( QwtScaleTransformation * );
    87     const QwtScaleTransformation *transformation() const;
     40    void setTransformation( QwtTransform * );
     41    const QwtTransform *transformation() const;
    8842
    8943    void setPaintInterval( double p1, double p2 );
     
    10256    double sDist() const;
    10357
    104     QT_STATIC_CONST double LogMin;
    105     QT_STATIC_CONST double LogMax;
    106 
    10758    static QRectF transform( const QwtScaleMap &,
    10859        const QwtScaleMap &, const QRectF & );
     
    11869
    11970private:
    120     void newFactor();
     71    void updateFactor();
    12172
    12273    double d_s1, d_s2;     // scale interval boundaries
     
    12475
    12576    double d_cnv;       // conversion factor
     77    double d_ts1;
    12678
    127     QwtScaleTransformation *d_transformation;
     79    QwtTransform *d_transform;
    12880};
    12981
     
    181133
    182134  \param s Value relative to the coordinates of the scale
     135  \return Transformed value
     136
     137  \sa invTransform()
    183138*/
    184139inline double QwtScaleMap::transform( double s ) const
    185140{
    186     // try to inline code from QwtScaleTransformation
     141    if ( d_transform )
     142        s = d_transform->transform( s );
    187143
    188     if ( d_transformation->type() == QwtScaleTransformation::Linear )
    189         return d_p1 + ( s - d_s1 ) * d_cnv;
    190 
    191     if ( d_transformation->type() == QwtScaleTransformation::Log10 )
    192         return d_p1 + log( s / d_s1 ) * d_cnv;
    193 
    194     return d_transformation->xForm( s, d_s1, d_s2, d_p1, d_p2 );
     144    return d_p1 + ( s - d_ts1 ) * d_cnv;
    195145}
    196146
     
    200150
    201151  \param p Value relative to the coordinates of the paint device
     152  \return Transformed value
     153
    202154  \sa transform()
    203155*/
    204156inline double QwtScaleMap::invTransform( double p ) const
    205157{
    206     return d_transformation->invXForm( p, d_p1, d_p2, d_s1, d_s2 );
     158    double s = d_ts1 + ( p - d_p1 ) / d_cnv;
     159    if ( d_transform )
     160        s = d_transform->invTransform( s );
     161
     162    return s;
    207163}
    208164
Note: See TracChangeset for help on using the changeset viewer.