! \brief Rebuild the axes scales In case of autoscaling the boundaries of a scale are calculated from the bounding rectangles of all plot items, having the QwtPlotItem::AutoScale flag enabled ( QwtScaleEngine::autoScale() ). Then a scale division is calculated ( QwtScaleEngine::didvideScale() ) and assigned to scale widget. When the scale boundaries have been assigned with s
| 668 | QwtPlotItem::boundingRect() |
| 669 | */ |
| 670 | void QwtPlot::updateAxes() |
| 671 | { |
| 672 | // Find bounding interval of the item data |
| 673 | // for all axes, where autoscaling is enabled |
| 674 | |
| 675 | QwtInterval boundingIntervals[QwtAxis::AxisPositions]; |
| 676 | |
| 677 | const QwtPlotItemList& itmList = itemList(); |
| 678 | |
| 679 | QwtPlotItemIterator it; |
| 680 | for ( it = itmList.begin(); it != itmList.end(); ++it ) |
| 681 | { |
| 682 | const QwtPlotItem* item = *it; |
| 683 | |
| 684 | if ( !item->testItemAttribute( QwtPlotItem::AutoScale ) ) |
| 685 | continue; |
| 686 | |
| 687 | if ( !item->isVisible() ) |
| 688 | continue; |
| 689 | |
| 690 | const QwtAxisId xAxis = item->xAxis(); |
| 691 | const QwtAxisId yAxis = item->yAxis(); |
| 692 | |
| 693 | if ( axisAutoScale( xAxis ) || axisAutoScale( yAxis ) ) |
| 694 | { |
| 695 | const QRectF rect = item->boundingRect(); |
| 696 | |
| 697 | if ( axisAutoScale( xAxis ) && rect.width() >= 0.0 ) |
| 698 | boundingIntervals[xAxis] |= QwtInterval( rect.left(), rect.right() ); |
| 699 | |
| 700 | if ( axisAutoScale( yAxis ) && rect.height() >= 0.0 ) |
| 701 | boundingIntervals[yAxis] |= QwtInterval( rect.top(), rect.bottom() ); |
| 702 | } |
| 703 | } |
| 704 | |
| 705 | // Adjust scales |
| 706 | |
| 707 | for ( int axisPos = 0; axisPos < QwtAxis::AxisPositions; axisPos++ ) |
| 708 | { |
| 709 | { |
| 710 | const QwtAxisId axisId( axisPos ); |
| 711 | |
| 712 | AxisData& d = m_scaleData->axisData( axisId ); |
| 713 | |
| 714 | double minValue = d.minValue; |
| 715 | double maxValue = d.maxValue; |
| 716 | double stepSize = d.stepSize; |
| 717 | |
| 718 | const QwtInterval& interval = boundingIntervals[axisId]; |
| 719 | |
| 720 | if ( d.doAutoScale && interval.isValid() ) |
| 721 | { |
| 722 | d.isValid = false; |
| 723 | |
| 724 | minValue = interval.minValue(); |
| 725 | maxValue = interval.maxValue(); |
| 726 | |
| 727 | d.scaleEngine->autoScale( d.maxMajor, |
no test coverage detected