Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_scale_map.h
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_scale_map.h
r4271 r8127 12 12 13 13 #include "qwt_global.h" 14 #include "qwt_math.h" 14 #include "qwt_transform.h" 15 #include <qrect.h> 16 15 17 #ifndef QT_NO_DEBUG_STREAM 16 18 #include <qdebug.h> … … 18 20 19 21 class QRectF; 20 21 /*!22 \brief A transformation between coordinate systems23 24 QwtScaleTransformation offers transformations from the coordinate system25 of a scale into the linear coordinate system of a paint device26 and vice versa.27 */28 class QWT_EXPORT QwtScaleTransformation29 {30 public:31 //! Transformation type32 enum Type33 {34 //! Transformation between 2 linear scales35 Linear,36 37 //! Transformation between a linear and a logarithmic ( base 10 ) scale38 Log10,39 40 //! Any other type of transformation41 Other42 };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 type64 inline QwtScaleTransformation::Type QwtScaleTransformation::type() const65 {66 return d_type;67 }68 22 69 23 /*! … … 84 38 QwtScaleMap &operator=( const QwtScaleMap & ); 85 39 86 void setTransformation( Qwt ScaleTransformation* );87 const Qwt ScaleTransformation*transformation() const;40 void setTransformation( QwtTransform * ); 41 const QwtTransform *transformation() const; 88 42 89 43 void setPaintInterval( double p1, double p2 ); … … 102 56 double sDist() const; 103 57 104 QT_STATIC_CONST double LogMin;105 QT_STATIC_CONST double LogMax;106 107 58 static QRectF transform( const QwtScaleMap &, 108 59 const QwtScaleMap &, const QRectF & ); … … 118 69 119 70 private: 120 void newFactor();71 void updateFactor(); 121 72 122 73 double d_s1, d_s2; // scale interval boundaries … … 124 75 125 76 double d_cnv; // conversion factor 77 double d_ts1; 126 78 127 Qwt ScaleTransformation *d_transformation;79 QwtTransform *d_transform; 128 80 }; 129 81 … … 181 133 182 134 \param s Value relative to the coordinates of the scale 135 \return Transformed value 136 137 \sa invTransform() 183 138 */ 184 139 inline double QwtScaleMap::transform( double s ) const 185 140 { 186 // try to inline code from QwtScaleTransformation 141 if ( d_transform ) 142 s = d_transform->transform( s ); 187 143 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; 195 145 } 196 146 … … 200 150 201 151 \param p Value relative to the coordinates of the paint device 152 \return Transformed value 153 202 154 \sa transform() 203 155 */ 204 156 inline double QwtScaleMap::invTransform( double p ) const 205 157 { 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; 207 163 } 208 164
Note:
See TracChangeset
for help on using the changeset viewer.