Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_scale_map.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_scale_map.cpp (modified) (10 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_scale_map.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 10 10 #include "qwt_scale_map.h" 11 11 #include "qwt_math.h" 12 12 13 #include <qrect.h> 13 14 #include <qdebug.h> 14 15 15 16 /*! 16 \brief Constructor 17 18 The scale and paint device intervals are both set to [0,1]. 19 */ 20 QwtScaleMap::QwtScaleMap() :21 d_s1( 0.0 ),22 d_s2( 1.0 ),23 d_p1( 0.0 ),24 d_p2( 1.0 ),25 d_cnv( 1.0 ),26 d_ts1( 0.0 ),27 d_transform( NULL )17 \brief Constructor 18 19 The scale and paint device intervals are both set to [0,1]. 20 */ 21 QwtScaleMap::QwtScaleMap() 22 : m_s1( 0.0 ) 23 , m_s2( 1.0 ) 24 , m_p1( 0.0 ) 25 , m_p2( 1.0 ) 26 , m_cnv( 1.0 ) 27 , m_ts1( 0.0 ) 28 , m_transform( NULL ) 28 29 { 29 30 } 30 31 31 32 //! Copy constructor 32 QwtScaleMap::QwtScaleMap( const QwtScaleMap& other ) :33 d_s1( other.d_s1 ),34 d_s2( other.d_s2 ),35 d_p1( other.d_p1 ),36 d_p2( other.d_p2 ),37 d_cnv( other.d_cnv ),38 d_ts1( other.d_ts1 ),39 d_transform( NULL )40 { 41 if ( other. d_transform )42 d_transform = other.d_transform->copy();43 } 44 45 /*! 46 Destructor 47 */ 33 QwtScaleMap::QwtScaleMap( const QwtScaleMap& other ) 34 : m_s1( other.m_s1 ) 35 , m_s2( other.m_s2 ) 36 , m_p1( other.m_p1 ) 37 , m_p2( other.m_p2 ) 38 , m_cnv( other.m_cnv ) 39 , m_ts1( other.m_ts1 ) 40 , m_transform( NULL ) 41 { 42 if ( other.m_transform ) 43 m_transform = other.m_transform->copy(); 44 } 45 46 /*! 47 Destructor 48 */ 48 49 QwtScaleMap::~QwtScaleMap() 49 50 { 50 delete d_transform;51 delete m_transform; 51 52 } 52 53 53 54 //! Assignment operator 54 QwtScaleMap &QwtScaleMap::operator=( const QwtScaleMap& other )55 { 56 d_s1 = other.d_s1;57 d_s2 = other.d_s2;58 d_p1 = other.d_p1;59 d_p2 = other.d_p2;60 d_cnv = other.d_cnv;61 d_ts1 = other.d_ts1;62 63 delete d_transform;64 d_transform = NULL;65 66 if ( other. d_transform )67 d_transform = other.d_transform->copy();55 QwtScaleMap& QwtScaleMap::operator=( const QwtScaleMap& other ) 56 { 57 m_s1 = other.m_s1; 58 m_s2 = other.m_s2; 59 m_p1 = other.m_p1; 60 m_p2 = other.m_p2; 61 m_cnv = other.m_cnv; 62 m_ts1 = other.m_ts1; 63 64 delete m_transform; 65 m_transform = NULL; 66 67 if ( other.m_transform ) 68 m_transform = other.m_transform->copy(); 68 69 69 70 return *this; … … 72 73 /*! 73 74 Initialize the map with a transformation 74 */ 75 void QwtScaleMap::setTransformation( QwtTransform *transform )76 { 77 if ( transform != d_transform )75 */ 76 void QwtScaleMap::setTransformation( QwtTransform* transform ) 77 { 78 if ( transform != m_transform ) 78 79 { 79 delete d_transform;80 d_transform = transform;80 delete m_transform; 81 m_transform = transform; 81 82 } 82 83 83 setScaleInterval( d_s1, d_s2 );84 setScaleInterval( m_s1, m_s2 ); 84 85 } 85 86 86 87 //! Get the transformation 87 const QwtTransform *QwtScaleMap::transformation() const88 { 89 return d_transform;90 } 91 92 /*! 93 \brief Specify the borders of the scale interval 94 \param s1 first border 95 \param s2 second border 96 \warning scales might be aligned to 88 const QwtTransform* QwtScaleMap::transformation() const 89 { 90 return m_transform; 91 } 92 93 /*! 94 \brief Specify the borders of the scale interval 95 \param s1 first border 96 \param s2 second border 97 \warning scales might be aligned to 97 98 transformation depending boundaries 98 */ 99 */ 99 100 void QwtScaleMap::setScaleInterval( double s1, double s2 ) 100 101 { 101 d_s1 = s1;102 d_s2 = s2;103 104 if ( d_transform )102 m_s1 = s1; 103 m_s2 = s2; 104 105 if ( m_transform ) 105 106 { 106 d_s1 = d_transform->bounded(d_s1 );107 d_s2 = d_transform->bounded(d_s2 );107 m_s1 = m_transform->bounded( m_s1 ); 108 m_s2 = m_transform->bounded( m_s2 ); 108 109 } 109 110 … … 112 113 113 114 /*! 114 \brief Specify the borders of the paint device interval 115 \param p1 first border 116 \param p2 second border 117 */ 115 \brief Specify the borders of the paint device interval 116 \param p1 first border 117 \param p2 second border 118 */ 118 119 void QwtScaleMap::setPaintInterval( double p1, double p2 ) 119 120 { 120 d_p1 = p1;121 d_p2 = p2;121 m_p1 = p1; 122 m_p2 = p2; 122 123 123 124 updateFactor(); … … 126 127 void QwtScaleMap::updateFactor() 127 128 { 128 d_ts1 =d_s1;129 double ts2 = d_s2;130 131 if ( d_transform )129 m_ts1 = m_s1; 130 double ts2 = m_s2; 131 132 if ( m_transform ) 132 133 { 133 d_ts1 =d_transform->transform(d_ts1 );134 ts2 = d_transform->transform( ts2 );134 m_ts1 = m_transform->transform( m_ts1 ); 135 ts2 = m_transform->transform( ts2 ); 135 136 } 136 137 137 d_cnv = 1.0;138 if ( d_ts1 != ts2 )139 d_cnv = (d_p2 - d_p1 ) / ( ts2 -d_ts1 );138 m_cnv = 1.0; 139 if ( m_ts1 != ts2 ) 140 m_cnv = ( m_p2 - m_p1 ) / ( ts2 - m_ts1 ); 140 141 } 141 142 … … 149 150 150 151 \sa invTransform() 151 */ 152 QRectF QwtScaleMap::transform( const QwtScaleMap &xMap,153 const QwtScaleMap &yMap, const QRectF&rect )152 */ 153 QRectF QwtScaleMap::transform( const QwtScaleMap& xMap, 154 const QwtScaleMap& yMap, const QRectF& rect ) 154 155 { 155 156 double x1 = xMap.transform( rect.left() ); … … 183 184 \return Position in scale coordinates 184 185 \sa transform() 185 */ 186 QPointF QwtScaleMap::invTransform( const QwtScaleMap &xMap,187 const QwtScaleMap &yMap, const QPointF&pos )186 */ 187 QPointF QwtScaleMap::invTransform( const QwtScaleMap& xMap, 188 const QwtScaleMap& yMap, const QPointF& pos ) 188 189 { 189 190 return QPointF( 190 191 xMap.invTransform( pos.x() ), 191 192 yMap.invTransform( pos.y() ) 192 ); 193 ); 193 194 } 194 195 … … 202 203 203 204 \sa invTransform() 204 */ 205 QPointF QwtScaleMap::transform( const QwtScaleMap &xMap,206 const QwtScaleMap &yMap, const QPointF&pos )205 */ 206 QPointF QwtScaleMap::transform( const QwtScaleMap& xMap, 207 const QwtScaleMap& yMap, const QPointF& pos ) 207 208 { 208 209 return QPointF( 209 210 xMap.transform( pos.x() ), 210 211 yMap.transform( pos.y() ) 211 ); 212 ); 212 213 } 213 214 … … 220 221 \return Rectangle in scale coordinates 221 222 \sa transform() 222 */ 223 QRectF QwtScaleMap::invTransform( const QwtScaleMap &xMap,224 const QwtScaleMap &yMap, const QRectF&rect )223 */ 224 QRectF QwtScaleMap::invTransform( const QwtScaleMap& xMap, 225 const QwtScaleMap& yMap, const QRectF& rect ) 225 226 { 226 227 const double x1 = xMap.invTransform( rect.left() ); … … 235 236 #ifndef QT_NO_DEBUG_STREAM 236 237 237 QDebug operator<<( QDebug debug, const QwtScaleMap &map )238 QDebug operator<<( QDebug debug, const QwtScaleMap& map ) 238 239 { 239 240 debug.nospace() << "QwtScaleMap(" 240 << map.transformation() 241 << ", s:" << map.s1() << "->" << map.s2() 242 << ", p:" << map.p1() << "->" << map.p2() 243 << ")"; 241 << map.transformation() 242 << ", s:" << map.s1() << "->" << map.s2() 243 << ", p:" << map.p1() << "->" << map.p2() 244 << ")"; 244 245 245 246 return debug.space();
Note:
See TracChangeset
for help on using the changeset viewer.
