Changeset 11158 in ntrip for trunk/BNC/qwt/qwt_round_scale_draw.cpp
- Timestamp:
- Nov 3, 2026, 10:53:35 AM (3 weeks ago)
- File:
-
- 1 edited
-
trunk/BNC/qwt/qwt_round_scale_draw.cpp (modified) (18 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_round_scale_draw.cpp
r9383 r11158 1 /* -*- mode: C++ ; c-file-style: "stroustrup" -*-*****************************1 /****************************************************************************** 2 2 * Qwt Widget Library 3 3 * Copyright (C) 1997 Josef Wilgen … … 12 12 #include "qwt_scale_div.h" 13 13 #include "qwt_scale_map.h" 14 #include "qwt_text.h" 14 15 #include "qwt_math.h" 15 #include <qpen.h> 16 16 17 #include <qpainter.h> 17 #include <qfontmetrics.h>18 #include <qmath.h>19 18 20 19 class QwtRoundScaleDraw::PrivateData 21 20 { 22 public: 23 PrivateData() :24 center( 50.0, 50.0 ) ,25 radius( 50.0 ) ,26 startAngle( -135.0 ) ,27 endAngle( 135.0 ) 21 public: 22 PrivateData() 23 : center( 50.0, 50.0 ) 24 , radius( 50.0 ) 25 , startAngle( -135.0 ) 26 , endAngle( 135.0 ) 28 27 { 29 28 } … … 37 36 38 37 /*! 39 \brief Constructor 40 41 The range of the scale is initialized to [0, 100], 42 The center is set to (50, 50) with a radius of 50. 43 The angle range is set to [-135, 135]. 44 */ 38 \brief Constructor 39 40 The range of the scale is initialized to [0, 100], 41 The center is set to (50, 50) with a radius of 50. 42 The angle range is set to [-135, 135]. 43 */ 45 44 QwtRoundScaleDraw::QwtRoundScaleDraw() 46 45 { 47 d_data = new QwtRoundScaleDraw::PrivateData;46 m_data = new QwtRoundScaleDraw::PrivateData; 48 47 49 48 setRadius( 50 ); 50 scaleMap().setPaintInterval( d_data->startAngle,d_data->endAngle );49 scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle ); 51 50 } 52 51 … … 54 53 QwtRoundScaleDraw::~QwtRoundScaleDraw() 55 54 { 56 delete d_data;57 } 58 59 /*! 60 Change of radius the scale 61 62 Radius is the radius of the backbone without ticks and labels. 63 64 \param radius New Radius 65 \sa moveCenter() 66 */ 55 delete m_data; 56 } 57 58 /*! 59 Change of radius the scale 60 61 Radius is the radius of the backbone without ticks and labels. 62 63 \param radius New Radius 64 \sa moveCenter() 65 */ 67 66 void QwtRoundScaleDraw::setRadius( double radius ) 68 67 { 69 d_data->radius = radius;70 } 71 72 /*! 73 Get the radius 74 75 Radius is the radius of the backbone without ticks and labels. 76 77 \return Radius of the scale 78 \sa setRadius(), extent() 79 */ 68 m_data->radius = radius; 69 } 70 71 /*! 72 Get the radius 73 74 Radius is the radius of the backbone without ticks and labels. 75 76 \return Radius of the scale 77 \sa setRadius(), extent() 78 */ 80 79 double QwtRoundScaleDraw::radius() const 81 80 { 82 return d_data->radius;81 return m_data->radius; 83 82 } 84 83 … … 88 87 \param center New center 89 88 \sa setRadius() 90 */ 91 void QwtRoundScaleDraw::moveCenter( const QPointF ¢er )92 { 93 d_data->center = center;89 */ 90 void QwtRoundScaleDraw::moveCenter( const QPointF& center ) 91 { 92 m_data->center = center; 94 93 } 95 94 … … 97 96 QPointF QwtRoundScaleDraw::center() const 98 97 { 99 return d_data->center;100 } 101 102 /*! 103 \brief Adjust the baseline circle segment for round scales. 104 105 The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). 106 The default setting is [ -135, 135 ]. 107 An angle of 0 degrees corresponds to the 12 o'clock position, 108 and positive angles count in a clockwise direction. 109 \param angle1 110 \param angle2 boundaries of the angle interval in degrees. 111 \warning <ul> 112 <li>The angle range is limited to [-360, 360] degrees. Angles exceeding 98 return m_data->center; 99 } 100 101 /*! 102 \brief Adjust the baseline circle segment for round scales. 103 104 The baseline will be drawn from min(angle1,angle2) to max(angle1, angle2). 105 The default setting is [ -135, 135 ]. 106 An angle of 0 degrees corresponds to the 12 o'clock position, 107 and positive angles count in a clockwise direction. 108 \param angle1 109 \param angle2 boundaries of the angle interval in degrees. 110 \warning <ul> 111 <li>The angle range is limited to [-360, 360] degrees. Angles exceeding 113 112 this range will be clipped. 114 <li>For angles more or equal than 360 degrees above or below min(angle1, angle2), 113 <li>For angles more or equal than 360 degrees above or below min(angle1, angle2), 115 114 scale marks will not be drawn. 116 <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval() 117 </ul> 118 */ 115 <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval() 116 </ul> 117 */ 119 118 void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 ) 120 119 { … … 124 123 #endif 125 124 126 d_data->startAngle = angle1;127 d_data->endAngle = angle2;128 129 if ( d_data->startAngle ==d_data->endAngle )130 { 131 d_data->startAngle -= 1;132 d_data->endAngle += 1;133 } 134 135 scaleMap().setPaintInterval( d_data->startAngle,d_data->endAngle );125 m_data->startAngle = angle1; 126 m_data->endAngle = angle2; 127 128 if ( m_data->startAngle == m_data->endAngle ) 129 { 130 m_data->startAngle -= 1; 131 m_data->endAngle += 1; 132 } 133 134 scaleMap().setPaintInterval( m_data->startAngle, m_data->endAngle ); 136 135 } 137 136 … … 143 142 144 143 \sa drawTick(), drawBackbone() 145 */ 146 void QwtRoundScaleDraw::drawLabel( QPainter *painter, double value ) const144 */ 145 void QwtRoundScaleDraw::drawLabel( QPainter* painter, double value ) const 147 146 { 148 147 const double tval = scaleMap().transform( value ); 149 if ( ( tval >= d_data->startAngle + 360.0 )150 || ( tval <= d_data->startAngle - 360.0 ) )148 if ( ( tval >= m_data->startAngle + 360.0 ) 149 || ( tval <= m_data->startAngle - 360.0 ) ) 151 150 { 152 151 return; … … 157 156 return; 158 157 159 double radius = d_data->radius;158 double radius = m_data->radius; 160 159 if ( hasComponent( QwtAbstractScaleDraw::Ticks ) || 161 160 hasComponent( QwtAbstractScaleDraw::Backbone ) ) … … 170 169 const double arc = qwtRadians( tval ); 171 170 172 const double x = d_data->center.x() +173 ( radius + sz.width() / 2.0 ) * qSin( arc );174 const double y = d_data->center.y() -175 ( radius + sz.height() / 2.0 ) * qCos( arc );171 const double x = m_data->center.x() + 172 ( radius + sz.width() / 2.0 ) * std::sin( arc ); 173 const double y = m_data->center.y() - 174 ( radius + sz.height() / 2.0 ) * std::cos( arc ); 176 175 177 176 const QRectF r( x - sz.width() / 2, y - sz.height() / 2, … … 188 187 189 188 \sa drawBackbone(), drawLabel() 190 */ 191 void QwtRoundScaleDraw::drawTick( QPainter *painter, double value, double len ) const189 */ 190 void QwtRoundScaleDraw::drawTick( QPainter* painter, double value, double len ) const 192 191 { 193 192 if ( len <= 0 ) … … 196 195 const double tval = scaleMap().transform( value ); 197 196 198 const double cx = d_data->center.x();199 const double cy = d_data->center.y();200 const double radius = d_data->radius;201 202 if ( ( tval < d_data->startAngle + 360.0 )203 && ( tval > d_data->startAngle - 360.0 ) )197 const double cx = m_data->center.x(); 198 const double cy = m_data->center.y(); 199 const double radius = m_data->radius; 200 201 if ( ( tval < m_data->startAngle + 360.0 ) 202 && ( tval > m_data->startAngle - 360.0 ) ) 204 203 { 205 204 const double arc = qwtRadians( tval ); 206 205 207 const double sinArc = qSin( arc );208 const double cosArc = qCos( arc );206 const double sinArc = std::sin( arc ); 207 const double cosArc = std::cos( arc ); 209 208 210 209 const double x1 = cx + radius * sinArc; … … 222 221 223 222 \sa drawTick(), drawLabel() 224 */ 225 void QwtRoundScaleDraw::drawBackbone( QPainter *painter ) const223 */ 224 void QwtRoundScaleDraw::drawBackbone( QPainter* painter ) const 226 225 { 227 226 const double deg1 = scaleMap().p1(); 228 227 const double deg2 = scaleMap().p2(); 229 228 230 const int a1 = qRound( q Min( deg1, deg2 ) - 90 );231 const int a2 = qRound( q Max( deg1, deg2 ) - 90 );232 233 const double radius = d_data->radius;234 const double x = d_data->center.x() - radius;235 const double y = d_data->center.y() - radius;229 const int a1 = qRound( qwtMinF( deg1, deg2 ) - 90 ); 230 const int a2 = qRound( qwtMaxF( deg1, deg2 ) - 90 ); 231 232 const double radius = m_data->radius; 233 const double x = m_data->center.x() - radius; 234 const double y = m_data->center.y() - radius; 236 235 237 236 painter->drawArc( QRectF( x, y, 2 * radius, 2 * radius ), … … 253 252 calculates only an upper limit, that might be a 254 253 few pixels too large 255 */ 256 double QwtRoundScaleDraw::extent( const QFont &font ) const254 */ 255 double QwtRoundScaleDraw::extent( const QFont& font ) const 257 256 { 258 257 double d = 0.0; … … 260 259 if ( hasComponent( QwtAbstractScaleDraw::Labels ) ) 261 260 { 262 const QwtScaleDiv &sd = scaleDiv();263 const QList< double> &ticks = sd.ticks( QwtScaleDiv::MajorTick );261 const QwtScaleDiv& sd = scaleDiv(); 262 const QList< double >& ticks = sd.ticks( QwtScaleDiv::MajorTick ); 264 263 for ( int i = 0; i < ticks.count(); i++ ) 265 264 { … … 269 268 270 269 const double tval = scaleMap().transform( value ); 271 if ( ( tval < d_data->startAngle + 360 )272 && ( tval > d_data->startAngle - 360 ) )270 if ( ( tval < m_data->startAngle + 360 ) 271 && ( tval > m_data->startAngle - 360 ) ) 273 272 { 274 273 const QwtText label = tickLabel( font, value ); … … 281 280 const double off = qMax( sz.width(), sz.height() ); 282 281 283 double x = off * qSin( arc );284 double y = off * qCos( arc );285 286 const double dist = qSqrt( x * x + y * y );282 double x = off * std::sin( arc ); 283 double y = off * std::cos( arc ); 284 285 const double dist = std::sqrt( x * x + y * y ); 287 286 if ( dist > d ) 288 287 d = dist; … … 298 297 if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) 299 298 { 300 const double pw = qMax( 1, penWidth() ); // pen width can be zero 301 d += pw; 299 d += qwtMaxF( penWidthF(), 1.0 ); 302 300 } 303 301 304 302 if ( hasComponent( QwtAbstractScaleDraw::Labels ) && 305 303 ( hasComponent( QwtAbstractScaleDraw::Ticks ) || 306 hasComponent( QwtAbstractScaleDraw::Backbone ) ) )304 hasComponent( QwtAbstractScaleDraw::Backbone ) ) ) 307 305 { 308 306 d += spacing(); 309 307 } 310 308 311 d = q Max( d, minimumExtent() );309 d = qwtMaxF( d, minimumExtent() ); 312 310 313 311 return d;
Note:
See TracChangeset
for help on using the changeset viewer.
