Changeset 8127 in ntrip for trunk/BNC/qwt/qwt_plot_axis.cpp
- Timestamp:
- May 10, 2017, 3:20:54 PM (7 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/BNC/qwt/qwt_plot_axis.cpp
r4271 r8127 27 27 int maxMinor; 28 28 29 bool isValid; 30 29 31 QwtScaleDiv scaleDiv; 30 32 QwtScaleEngine *scaleEngine; … … 54 56 d_axisData[xBottom]->scaleWidget->setObjectName( "QwtPlotAxisXBottom" ); 55 57 58 #if 1 59 // better find the font sizes from the application font 56 60 QFont fscl( fontInfo().family(), 10 ); 57 61 QFont fttl( fontInfo().family(), 12, QFont::Bold ); 62 #endif 58 63 59 64 for ( axisId = 0; axisId < axisCnt; axisId++ ) 60 65 { 61 66 AxisData &d = *d_axisData[axisId]; 67 68 d.scaleEngine = new QwtLinearScaleEngine; 69 70 d.scaleWidget->setTransformation( 71 d.scaleEngine->transformation() ); 62 72 63 73 d.scaleWidget->setFont( fscl ); … … 77 87 d.maxMajor = 8; 78 88 79 d.scaleEngine = new QwtLinearScaleEngine; 80 81 d.scaleDiv.invalidate(); 89 90 d.isValid = false; 82 91 } 83 92 … … 99 108 100 109 /*! 101 \return specified axis, or NULL if axisId is invalid.102 \param axisId axis index110 \return Scale widget of the specified axis, or NULL if axisId is invalid. 111 \param axisId Axis index 103 112 */ 104 113 const QwtScaleWidget *QwtPlot::axisWidget( int axisId ) const … … 111 120 112 121 /*! 113 \return specified axis, or NULL if axisId is invalid.114 \param axisId axis index122 \return Scale widget of the specified axis, or NULL if axisId is invalid. 123 \param axisId Axis index 115 124 */ 116 125 QwtScaleWidget *QwtPlot::axisWidget( int axisId ) … … 123 132 124 133 /*! 125 126 127 \param axisId axis index134 Change the scale engine for an axis 135 136 \param axisId Axis index 128 137 \param scaleEngine Scale engine 129 138 … … 139 148 d.scaleEngine = scaleEngine; 140 149 141 d.scaleDiv.invalidate(); 150 d_axisData[axisId]->scaleWidget->setTransformation( 151 scaleEngine->transformation() ); 152 153 d.isValid = false; 142 154 143 155 autoRefresh(); … … 146 158 147 159 /*! 148 \param axisId axis index160 \param axisId Axis index 149 161 \return Scale engine for a specific axis 150 162 */ … … 158 170 159 171 /*! 160 \param axisId axis index172 \param axisId Axis index 161 173 \return Scale engine for a specific axis 162 174 */ … … 169 181 } 170 182 /*! 171 \return \c trueif autoscaling is enabled172 \param axisId axis index183 \return \c True, if autoscaling is enabled 184 \param axisId Axis index 173 185 */ 174 186 bool QwtPlot::axisAutoScale( int axisId ) const … … 182 194 183 195 /*! 184 \return \c trueif a specified axis is enabled185 \param axisId axis index196 \return \c True, if a specified axis is enabled 197 \param axisId Axis index 186 198 */ 187 199 bool QwtPlot::axisEnabled( int axisId ) const … … 194 206 195 207 /*! 196 \return the font of the scale labels for a specified axis197 \param axisId axis index208 \return The font of the scale labels for a specified axis 209 \param axisId Axis index 198 210 */ 199 211 QFont QwtPlot::axisFont( int axisId ) const … … 207 219 208 220 /*! 209 \return the maximum number of major ticks for a specified axis210 \param axisId axis index211 \sa setAxisMaxMajor() 221 \return The maximum number of major ticks for a specified axis 222 \param axisId Axis index 223 \sa setAxisMaxMajor(), QwtScaleEngine::divideScale() 212 224 */ 213 225 int QwtPlot::axisMaxMajor( int axisId ) const … … 221 233 /*! 222 234 \return the maximum number of minor ticks for a specified axis 223 \param axisId axis index224 \sa setAxisMaxMinor() 235 \param axisId Axis index 236 \sa setAxisMaxMinor(), QwtScaleEngine::divideScale() 225 237 */ 226 238 int QwtPlot::axisMaxMinor( int axisId ) const … … 235 247 \brief Return the scale division of a specified axis 236 248 237 axisScaleDiv(axisId) ->lowerBound(), axisScaleDiv(axisId)->upperBound()249 axisScaleDiv(axisId).lowerBound(), axisScaleDiv(axisId).upperBound() 238 250 are the current limits of the axis scale. 239 251 240 \param axisId axis index252 \param axisId Axis index 241 253 \return Scale division 242 254 243 \sa QwtScaleDiv, setAxisScaleDiv() 244 */ 245 const QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId ) const 255 \sa QwtScaleDiv, setAxisScaleDiv(), QwtScaleEngine::divideScale() 256 */ 257 const QwtScaleDiv &QwtPlot::axisScaleDiv( int axisId ) const 258 { 259 return d_axisData[axisId]->scaleDiv; 260 } 261 262 /*! 263 \brief Return the scale draw of a specified axis 264 265 \param axisId Axis index 266 \return Specified scaleDraw for axis, or NULL if axis is invalid. 267 */ 268 const QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) const 246 269 { 247 270 if ( !axisValid( axisId ) ) 248 271 return NULL; 249 272 250 return &d_axisData[axisId]->scaleDiv; 251 } 252 253 /*! 254 \brief Return the scale division of a specified axis 255 256 axisScaleDiv(axisId)->lowerBound(), axisScaleDiv(axisId)->upperBound() 257 are the current limits of the axis scale. 258 259 \param axisId axis index 260 \return Scale division 261 262 \sa QwtScaleDiv, setAxisScaleDiv() 263 */ 264 QwtScaleDiv *QwtPlot::axisScaleDiv( int axisId ) 273 return axisWidget( axisId )->scaleDraw(); 274 } 275 276 /*! 277 \brief Return the scale draw of a specified axis 278 279 \param axisId Axis index 280 \return Specified scaleDraw for axis, or NULL if axis is invalid. 281 */ 282 QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) 265 283 { 266 284 if ( !axisValid( axisId ) ) 267 285 return NULL; 268 286 269 return &d_axisData[axisId]->scaleDiv;270 }271 272 /*!273 \returns the scale draw of a specified axis274 \param axisId axis index275 \return specified scaleDraw for axis, or NULL if axis is invalid.276 \sa QwtScaleDraw277 */278 const QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) const279 {280 if ( !axisValid( axisId ) )281 return NULL;282 283 287 return axisWidget( axisId )->scaleDraw(); 284 288 } 285 289 286 290 /*! 287 \returns the scale draw of a specified axis 288 \param axisId axis index 289 \return specified scaleDraw for axis, or NULL if axis is invalid. 290 \sa QwtScaleDraw 291 */ 292 QwtScaleDraw *QwtPlot::axisScaleDraw( int axisId ) 293 { 294 if ( !axisValid( axisId ) ) 295 return NULL; 296 297 return axisWidget( axisId )->scaleDraw(); 298 } 299 300 /*! 301 Return the step size parameter, that has been set 302 in setAxisScale. This doesn't need to be the step size 303 of the current scale. 304 305 \param axisId axis index 291 \brief Return the step size parameter that has been set in setAxisScale. 292 293 This doesn't need to be the step size of the current scale. 294 295 \param axisId Axis index 306 296 \return step size parameter value 307 297 308 \sa setAxisScale() 298 \sa setAxisScale(), QwtScaleEngine::divideScale() 309 299 */ 310 300 double QwtPlot::axisStepSize( int axisId ) const … … 321 311 This is only a convenience function for axisScaleDiv( axisId )->interval(); 322 312 323 \param axisId axis index313 \param axisId Axis index 324 314 \return Scale interval 325 315 … … 335 325 336 326 /*! 337 \return the title of a specified axis338 \param axisId axis index327 \return Title of a specified axis 328 \param axisId Axis index 339 329 */ 340 330 QwtText QwtPlot::axisTitle( int axisId ) const … … 355 345 356 346 Only xBottom and yLeft are enabled by default. 357 \param axisId axis index 347 348 \param axisId Axis index 358 349 \param tf \c true (enabled) or \c false (disabled) 359 350 */ … … 370 361 Transform the x or y coordinate of a position in the 371 362 drawing region into a value. 372 \param axisId axis index 363 364 \param axisId Axis index 373 365 \param pos position 366 367 \return Position as axis coordinate 368 374 369 \warning The position can be an x or a y coordinate, 375 370 depending on the specified axis. … … 386 381 /*! 387 382 \brief Transform a value into a coordinate in the plotting region 388 \param axisId axis index 383 384 \param axisId Axis index 389 385 \param value value 390 \return X or ycoordinate in the plotting region corresponding386 \return X or Y coordinate in the plotting region corresponding 391 387 to the value. 392 388 */ … … 401 397 /*! 402 398 \brief Change the font of an axis 403 \param axisId axis index 404 \param f font 399 400 \param axisId Axis index 401 \param font Font 405 402 \warning This function changes the font of the tick labels, 406 403 not of the axis title. 407 404 */ 408 void QwtPlot::setAxisFont( int axisId, const QFont &f )409 { 410 if ( axisValid( axisId ) ) 411 axisWidget( axisId )->setFont( f );405 void QwtPlot::setAxisFont( int axisId, const QFont &font ) 406 { 407 if ( axisValid( axisId ) ) 408 axisWidget( axisId )->setFont( font ); 412 409 } 413 410 … … 418 415 after a fixed scale has been set. Autoscaling is enabled by default. 419 416 420 \param axisId axis index417 \param axisId Axis index 421 418 \param on On/Off 422 419 \sa setAxisScale(), setAxisScaleDiv(), updateAxes() … … 436 433 /*! 437 434 \brief Disable autoscaling and specify a fixed scale for a selected axis. 438 \param axisId axis index 439 \param min 440 \param max minimum and maximum of the scale 435 436 In updateAxes() the scale engine calculates a scale division from the 437 specified parameters, that will be assigned to the scale widget. So 438 updates of the scale widget usually happen delayed with the next replot. 439 440 \param axisId Axis index 441 \param min Minimum of the scale 442 \param max Maximum of the scale 441 443 \param stepSize Major step size. If <code>step == 0</code>, the step size is 442 calculated automatically using the maxMajor setting. 443 \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize() 444 calculated automatically using the maxMajor setting. 445 446 \sa setAxisMaxMajor(), setAxisAutoScale(), axisStepSize(), QwtScaleEngine::divideScale() 444 447 */ 445 448 void QwtPlot::setAxisScale( int axisId, double min, double max, double stepSize ) … … 450 453 451 454 d.doAutoScale = false; 452 d. scaleDiv.invalidate();455 d.isValid = false; 453 456 454 457 d.minValue = min; … … 462 465 /*! 463 466 \brief Disable autoscaling and specify a fixed scale for a selected axis. 464 \param axisId axis index 467 468 The scale division will be stored locally only until the next call 469 of updateAxes(). So updates of the scale widget usually happen delayed with 470 the next replot. 471 472 \param axisId Axis index 465 473 \param scaleDiv Scale division 474 466 475 \sa setAxisScale(), setAxisAutoScale() 467 476 */ … … 474 483 d.doAutoScale = false; 475 484 d.scaleDiv = scaleDiv; 485 d.isValid = true; 476 486 477 487 autoRefresh(); … … 481 491 /*! 482 492 \brief Set a scale draw 483 \param axisId axis index 484 \param scaleDraw object responsible for drawing scales. 493 494 \param axisId Axis index 495 \param scaleDraw Object responsible for drawing scales. 485 496 486 497 By passing scaleDraw it is possible to extend QwtScaleDraw … … 505 516 /*! 506 517 Change the alignment of the tick labels 507 \param axisId axis index 518 519 \param axisId Axis index 508 520 \param alignment Or'd Qt::AlignmentFlags see <qnamespace.h> 521 509 522 \sa QwtScaleDraw::setLabelAlignment() 510 523 */ … … 517 530 /*! 518 531 Rotate all tick labels 519 \param axisId axis index 532 533 \param axisId Axis index 520 534 \param rotation Angle in degrees. When changing the label rotation, 521 535 the label alignment might be adjusted too. 536 522 537 \sa QwtScaleDraw::setLabelRotation(), setAxisLabelAlignment() 523 538 */ … … 531 546 Set the maximum number of minor scale intervals for a specified axis 532 547 533 \param axisId axis index 534 \param maxMinor maximum number of minor steps 548 \param axisId Axis index 549 \param maxMinor Maximum number of minor steps 550 535 551 \sa axisMaxMinor() 536 552 */ … … 545 561 { 546 562 d.maxMinor = maxMinor; 547 d. scaleDiv.invalidate();563 d.isValid = false; 548 564 autoRefresh(); 549 565 } … … 554 570 Set the maximum number of major scale intervals for a specified axis 555 571 556 \param axisId axis index 557 \param maxMajor maximum number of major steps 572 \param axisId Axis index 573 \param maxMajor Maximum number of major steps 574 558 575 \sa axisMaxMajor() 559 576 */ … … 568 585 { 569 586 d.maxMajor = maxMajor; 570 d. scaleDiv.invalidate();587 d.isValid = false; 571 588 autoRefresh(); 572 589 } … … 576 593 /*! 577 594 \brief Change the title of a specified axis 578 \param axisId axis index 595 596 \param axisId Axis index 579 597 \param title axis title 580 598 */ … … 587 605 /*! 588 606 \brief Change the title of a specified axis 589 \param axisId axis index 590 \param title axis title 607 608 \param axisId Axis index 609 \param title Axis title 591 610 */ 592 611 void QwtPlot::setAxisTitle( int axisId, const QwtText &title ) … … 596 615 } 597 616 598 //! Rebuild the scales 617 /*! 618 \brief Rebuild the axes scales 619 620 In case of autoscaling the boundaries of a scale are calculated 621 from the bounding rectangles of all plot items, having the 622 QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). 623 Then a scale division is calculated ( QwtScaleEngine::didvideScale() ) 624 and assigned to scale widget. 625 626 When the scale boundaries have been assigned with setAxisScale() a 627 scale division is calculated ( QwtScaleEngine::didvideScale() ) 628 for this interval and assigned to the scale widget. 629 630 When the scale has been set explicitly by setAxisScaleDiv() the 631 locally stored scale division gets assigned to the scale widget. 632 633 The scale widget indicates modifications by emitting a 634 QwtScaleWidget::scaleDivChanged() signal. 635 636 updateAxes() is usually called by replot(). 637 638 \sa setAxisAutoScale(), setAxisScale(), setAxisScaleDiv(), replot() 639 QwtPlotItem::boundingRect() 640 */ 599 641 void QwtPlot::updateAxes() 600 642 { … … 620 662 { 621 663 const QRectF rect = item->boundingRect(); 622 intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() ); 623 intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() ); 664 665 if ( rect.width() >= 0.0 ) 666 intv[item->xAxis()] |= QwtInterval( rect.left(), rect.right() ); 667 668 if ( rect.height() >= 0.0 ) 669 intv[item->yAxis()] |= QwtInterval( rect.top(), rect.bottom() ); 624 670 } 625 671 } … … 637 683 if ( d.doAutoScale && intv[axisId].isValid() ) 638 684 { 639 d. scaleDiv.invalidate();685 d.isValid = false; 640 686 641 687 minValue = intv[axisId].minValue(); … … 645 691 minValue, maxValue, stepSize ); 646 692 } 647 if ( !d. scaleDiv.isValid())693 if ( !d.isValid ) 648 694 { 649 695 d.scaleDiv = d.scaleEngine->divideScale( 650 696 minValue, maxValue, 651 697 d.maxMajor, d.maxMinor, stepSize ); 698 d.isValid = true; 652 699 } 653 700 654 701 QwtScaleWidget *scaleWidget = axisWidget( axisId ); 655 scaleWidget->setScaleDiv( 656 d.scaleEngine->transformation(), d.scaleDiv ); 702 scaleWidget->setScaleDiv( d.scaleDiv ); 657 703 658 704 int startDist, endDist; … … 664 710 { 665 711 QwtPlotItem *item = *it; 666 item->updateScaleDiv( *axisScaleDiv( item->xAxis() ), 667 *axisScaleDiv( item->yAxis() ) ); 668 } 669 } 670 712 if ( item->testItemInterest( QwtPlotItem::ScaleInterest ) ) 713 { 714 item->updateScaleDiv( axisScaleDiv( item->xAxis() ), 715 axisScaleDiv( item->yAxis() ) ); 716 } 717 } 718 } 719
Note:
See TracChangeset
for help on using the changeset viewer.