Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_round_scale_draw.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_round_scale_draw.cpp
r4271 r8127 12 12 #include "qwt_scale_div.h" 13 13 #include "qwt_scale_map.h" 14 #include "qwt_math.h" 14 15 #include <qpen.h> 15 16 #include <qpainter.h> … … 21 22 public: 22 23 PrivateData(): 23 center( 50 , 50 ),24 radius( 50 ),25 startAngle( -135 * 16),26 endAngle( 135 * 16)24 center( 50.0, 50.0 ), 25 radius( 50.0 ), 26 startAngle( -135.0 ), 27 endAngle( 135.0 ) 27 28 { 28 29 } … … 64 65 \sa moveCenter() 65 66 */ 66 void QwtRoundScaleDraw::setRadius( intradius )67 void QwtRoundScaleDraw::setRadius( double radius ) 67 68 { 68 69 d_data->radius = radius; … … 74 75 Radius is the radius of the backbone without ticks and labels. 75 76 77 \return Radius of the scale 76 78 \sa setRadius(), extent() 77 79 */ 78 intQwtRoundScaleDraw::radius() const80 double QwtRoundScaleDraw::radius() const 79 81 { 80 82 return d_data->radius; … … 110 112 <li>The angle range is limited to [-360, 360] degrees. Angles exceeding 111 113 this range will be clipped. 112 <li>For angles more than 359degrees above or below min(angle1, angle2),114 <li>For angles more or equal than 360 degrees above or below min(angle1, angle2), 113 115 scale marks will not be drawn. 114 <li>If you need a counterclockwise scale, use QwtScaleDiv::set Range116 <li>If you need a counterclockwise scale, use QwtScaleDiv::setInterval() 115 117 </ul> 116 118 */ 117 119 void QwtRoundScaleDraw::setAngleRange( double angle1, double angle2 ) 118 120 { 121 #if 0 119 122 angle1 = qBound( -360.0, angle1, 360.0 ); 120 123 angle2 = qBound( -360.0, angle2, 360.0 ); 121 122 d_data->startAngle = angle1 * 16.0; 123 d_data->endAngle = angle2 * 16.0; 124 #endif 125 126 d_data->startAngle = angle1; 127 d_data->endAngle = angle2; 124 128 125 129 if ( d_data->startAngle == d_data->endAngle ) … … 142 146 void QwtRoundScaleDraw::drawLabel( QPainter *painter, double value ) const 143 147 { 148 const double tval = scaleMap().transform( value ); 149 if ( ( tval >= d_data->startAngle + 360.0 ) 150 || ( tval <= d_data->startAngle - 360.0 ) ) 151 { 152 return; 153 } 154 144 155 const QwtText label = tickLabel( painter->font(), value ); 145 156 if ( label.isEmpty() ) 146 157 return; 147 158 148 const double tval = scaleMap().transform( value );149 if ( ( tval > d_data->startAngle + 359 * 16 )150 || ( tval < d_data->startAngle - 359 * 16 ) )151 {152 return;153 }154 155 159 double radius = d_data->radius; 156 160 if ( hasComponent( QwtAbstractScaleDraw::Ticks ) || … … 164 168 165 169 const QSizeF sz = label.textSize( painter->font() ); 166 const double arc = tval / 16.0 / 360.0 * 2 * M_PI;170 const double arc = qwtRadians( tval ); 167 171 168 172 const double x = d_data->center.x() + 169 173 ( radius + sz.width() / 2.0 ) * qSin( arc ); 170 174 const double y = d_data->center.y() - 171 ( radius + sz.height() / 2.0 ) * cos( arc );175 ( radius + sz.height() / 2.0 ) * qCos( arc ); 172 176 173 177 const QRectF r( x - sz.width() / 2, y - sz.height() / 2, … … 196 200 const double radius = d_data->radius; 197 201 198 if ( ( tval < = d_data->startAngle + 359 * 16)199 || ( tval >= d_data->startAngle - 359 * 16) )200 { 201 const double arc = double( tval ) / 16.0 * M_PI / 180.0;202 if ( ( tval < d_data->startAngle + 360.0 ) 203 && ( tval > d_data->startAngle - 360.0 ) ) 204 { 205 const double arc = qwtRadians( tval ); 202 206 203 207 const double sinArc = qSin( arc ); … … 221 225 void QwtRoundScaleDraw::drawBackbone( QPainter *painter ) const 222 226 { 223 const double a1 = qMin( scaleMap().p1(), scaleMap().p2() ) - 90 * 16; 224 const double a2 = qMax( scaleMap().p1(), scaleMap().p2() ) - 90 * 16; 227 const double deg1 = scaleMap().p1(); 228 const double deg2 = scaleMap().p2(); 229 230 const int a1 = qRound( qMin( deg1, deg2 ) - 90 ); 231 const int a2 = qRound( qMax( deg1, deg2 ) - 90 ); 225 232 226 233 const double radius = d_data->radius; … … 228 235 const double y = d_data->center.y() - radius; 229 236 230 painter->drawArc( x, y, 2 * radius, 2 * radius,231 -a2 , a2 - a1 + 1); // counterclockwise237 painter->drawArc( QRectF( x, y, 2 * radius, 2 * radius ), 238 -a2 * 16, ( a2 - a1 + 1 ) * 16 ); // counterclockwise 232 239 } 233 240 … … 240 247 241 248 \param font Font used for painting the labels 249 \return Calculated extent 242 250 243 251 \sa setMinimumExtent(), minimumExtent() 244 \warning The implemented algo is not too smart and252 \warning The implemented algorithm is not too smart and 245 253 calculates only an upper limit, that might be a 246 254 few pixels too large … … 260 268 continue; 261 269 262 const QwtText label = tickLabel( font, value );263 if ( label.isEmpty() )264 continue;265 266 270 const double tval = scaleMap().transform( value ); 267 if ( ( tval < d_data->startAngle + 360 * 16)268 && ( tval > d_data->startAngle - 360 * 16) )271 if ( ( tval < d_data->startAngle + 360 ) 272 && ( tval > d_data->startAngle - 360 ) ) 269 273 { 270 const double arc = tval / 16.0 / 360.0 * 2 * M_PI; 274 const QwtText label = tickLabel( font, value ); 275 if ( label.isEmpty() ) 276 continue; 277 278 const double arc = qwtRadians( tval ); 271 279 272 280 const QSizeF sz = label.textSize( font ); … … 290 298 if ( hasComponent( QwtAbstractScaleDraw::Backbone ) ) 291 299 { 292 const double pw = qMax( 1, penWidth() ); // pen width can be zero300 const double pw = qMax( 1, penWidth() ); // pen width can be zero 293 301 d += pw; 294 302 }
Note:
See TracChangeset
for help on using the changeset viewer.