Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_point_polar.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_point_polar.cpp (modified) (9 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_point_polar.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * QwtPolar Widget Library 3 3 * Copyright (C) 2008 Uwe Rathmann … … 10 10 #include "qwt_math.h" 11 11 12 #if QT_VERSION < 0x040601 13 #define qAtan2(y, x) ::atan2(y, x) 12 #if QT_VERSION >= 0x050200 13 14 static QwtPointPolar qwtPointToPolar( const QPointF& point ) 15 { 16 return QwtPointPolar( point ); 17 } 18 14 19 #endif 20 21 namespace 22 { 23 static const struct RegisterQwtPointPolar 24 { 25 inline RegisterQwtPointPolar() 26 { 27 qRegisterMetaType< QwtPointPolar >(); 28 29 #if QT_VERSION >= 0x050200 30 QMetaType::registerConverter< QPointF, QwtPointPolar >( qwtPointToPolar ); 31 QMetaType::registerConverter< QwtPointPolar, QPointF >( &QwtPointPolar::toPoint ); 32 #endif 33 } 34 35 } qwtRegisterQwtPointPolar; 36 } 15 37 16 38 /*! … … 19 41 \param p Point in Cartesian coordinates 20 42 \sa setPoint(), toPoint() 21 */ 22 QwtPointPolar::QwtPointPolar( const QPointF &p )43 */ 44 QwtPointPolar::QwtPointPolar( const QPointF& p ) 23 45 { 24 d_radius =qSqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) );25 d_azimuth =qAtan2( p.y(), p.x() );46 m_radius = std::sqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) ); 47 m_azimuth = std::atan2( p.y(), p.x() ); 26 48 } 27 49 … … 29 51 Convert and assign values from a point in Cartesian coordinates 30 52 \param p Point in Cartesian coordinates 31 */ 32 void QwtPointPolar::setPoint( const QPointF &p )53 */ 54 void QwtPointPolar::setPoint( const QPointF& p ) 33 55 { 34 d_radius =qSqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) );35 d_azimuth =qAtan2( p.y(), p.x() );56 m_radius = std::sqrt( qwtSqr( p.x() ) + qwtSqr( p.y() ) ); 57 m_azimuth = std::atan2( p.y(), p.x() ); 36 58 } 37 59 … … 43 65 \note Invalid or null points will be returned as QPointF(0.0, 0.0) 44 66 \sa isValid(), isNull() 45 */ 67 */ 46 68 QPointF QwtPointPolar::toPoint() const 47 69 { 48 if ( d_radius <= 0.0 )70 if ( m_radius <= 0.0 ) 49 71 return QPointF( 0.0, 0.0 ); 50 72 51 const double x = d_radius *qCos( d_azimuth );52 const double y = d_radius *qSin( d_azimuth );73 const double x = m_radius * std::cos( m_azimuth ); 74 const double y = m_radius * std::sin( m_azimuth ); 53 75 54 76 return QPointF( x, y ); … … 65 87 66 88 \sa normalized() 67 */ 68 bool QwtPointPolar::operator==( const QwtPointPolar &other ) const89 */ 90 bool QwtPointPolar::operator==( const QwtPointPolar& other ) const 69 91 { 70 return d_radius == other.d_radius &&d_azimuth == other.d_azimuth;92 return m_radius == other.m_radius && m_azimuth == other.m_azimuth; 71 93 } 72 94 … … 80 102 \return True if the point is not equal to other; otherwise return false. 81 103 \sa normalized() 82 */ 83 bool QwtPointPolar::operator!=( const QwtPointPolar &other ) const104 */ 105 bool QwtPointPolar::operator!=( const QwtPointPolar& other ) const 84 106 { 85 return d_radius != other.d_radius ||d_azimuth != other.d_azimuth;107 return m_radius != other.m_radius || m_azimuth != other.m_azimuth; 86 108 } 87 109 … … 93 115 94 116 \return Normalized point 95 */ 117 */ 96 118 QwtPointPolar QwtPointPolar::normalized() const 97 119 { 98 const double radius = q Max( d_radius, 0.0 );120 const double radius = qwtMaxF( m_radius, 0.0 ); 99 121 100 double azimuth = d_azimuth;122 double azimuth = m_azimuth; 101 123 if ( azimuth < -2.0 * M_PI || azimuth >= 2 * M_PI ) 102 azimuth = ::fmod( d_azimuth, 2 * M_PI );124 azimuth = std::fmod( m_azimuth, 2 * M_PI ); 103 125 104 126 if ( azimuth < 0.0 ) … … 110 132 #ifndef QT_NO_DEBUG_STREAM 111 133 112 QDebug operator<<( QDebug debug, const QwtPointPolar &point ) 134 #include <qdebug.h> 135 136 QDebug operator<<( QDebug debug, const QwtPointPolar& point ) 113 137 { 114 138 debug.nospace() << "QwtPointPolar(" 115 << point.azimuth() << "," << point.radius() << ")"; 139 << point.azimuth() << "," << point.radius() << ")"; 116 140 117 141 return debug.space();
Note:
See TracChangeset
for help on using the changeset viewer.
