qwt_scale_map.h
Go to the documentation of this file.
00001 /* -*- mode: C++ ; c-file-style: "stroustrup" -*- *****************************
00002  * Qwt Widget Library
00003  * Copyright (C) 1997   Josef Wilgen
00004  * Copyright (C) 2002   Uwe Rathmann
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the Qwt License, Version 1.0
00008  *****************************************************************************/
00009 
00010 #ifndef QWT_SCALE_MAP_H
00011 #define QWT_SCALE_MAP_H
00012 
00013 #include "qwt_global.h"
00014 #include "qwt_transform.h"
00015 #include <qrect.h>
00016 
00017 #ifndef QT_NO_DEBUG_STREAM
00018 #include <qdebug.h>
00019 #endif
00020 
00021 class QRectF;
00022 
00030 class QWT_EXPORT QwtScaleMap
00031 {
00032 public:
00033     QwtScaleMap();
00034     QwtScaleMap( const QwtScaleMap& );
00035 
00036     ~QwtScaleMap();
00037 
00038     QwtScaleMap &operator=( const QwtScaleMap & );
00039 
00040     void setTransformation( QwtTransform * );
00041     const QwtTransform *transformation() const;
00042 
00043     void setPaintInterval( double p1, double p2 );
00044     void setScaleInterval( double s1, double s2 );
00045 
00046     double transform( double s ) const;
00047     double invTransform( double p ) const;
00048 
00049     double p1() const;
00050     double p2() const;
00051 
00052     double s1() const;
00053     double s2() const;
00054 
00055     double pDist() const;
00056     double sDist() const;
00057 
00058     static QRectF transform( const QwtScaleMap &,
00059         const QwtScaleMap &, const QRectF & );
00060     static QRectF invTransform( const QwtScaleMap &,
00061         const QwtScaleMap &, const QRectF & );
00062 
00063     static QPointF transform( const QwtScaleMap &,
00064         const QwtScaleMap &, const QPointF & );
00065     static QPointF invTransform( const QwtScaleMap &,
00066         const QwtScaleMap &, const QPointF & );
00067 
00068     bool isInverting() const;
00069 
00070 private:
00071     void updateFactor();
00072 
00073     double d_s1, d_s2;     // scale interval boundaries
00074     double d_p1, d_p2;     // paint device interval boundaries
00075 
00076     double d_cnv;       // conversion factor
00077     double d_ts1;
00078 
00079     QwtTransform *d_transform;
00080 };
00081 
00085 inline double QwtScaleMap::s1() const
00086 {
00087     return d_s1;
00088 }
00089 
00093 inline double QwtScaleMap::s2() const
00094 {
00095     return d_s2;
00096 }
00097 
00101 inline double QwtScaleMap::p1() const
00102 {
00103     return d_p1;
00104 }
00105 
00109 inline double QwtScaleMap::p2() const
00110 {
00111     return d_p2;
00112 }
00113 
00117 inline double QwtScaleMap::pDist() const
00118 {
00119     return qAbs( d_p2 - d_p1 );
00120 }
00121 
00125 inline double QwtScaleMap::sDist() const
00126 {
00127     return qAbs( d_s2 - d_s1 );
00128 }
00129 
00139 inline double QwtScaleMap::transform( double s ) const
00140 {
00141     if ( d_transform )
00142         s = d_transform->transform( s );
00143 
00144     return d_p1 + ( s - d_ts1 ) * d_cnv;
00145 }
00146 
00156 inline double QwtScaleMap::invTransform( double p ) const
00157 {
00158     double s = d_ts1 + ( p - d_p1 ) / d_cnv;
00159     if ( d_transform )
00160         s = d_transform->invTransform( s );
00161 
00162     return s;
00163 }
00164 
00166 inline bool QwtScaleMap::isInverting() const
00167 {
00168     return ( ( d_p1 < d_p2 ) != ( d_s1 < d_s2 ) );
00169 }
00170 
00171 #ifndef QT_NO_DEBUG_STREAM
00172 QWT_EXPORT QDebug operator<<( QDebug, const QwtScaleMap & );
00173 #endif
00174 
00175 #endif


plotjuggler
Author(s): Davide Faconti
autogenerated on Fri Sep 1 2017 02:41:56