| 593 | } |
| 594 | |
| 595 | void CartesianAxis::Private::drawTitleText(QPainter *painter, CartesianCoordinatePlane *plane, |
| 596 | const QRect &geoRect) const |
| 597 | { |
| 598 | const TextAttributes titleTA(titleTextAttributesWithAdjustedRotation()); |
| 599 | if (titleTA.isVisible()) { |
| 600 | TextLayoutItem titleItem(titleText, titleTA, plane->parent(), KDChartEnums::MeasureOrientationMinimum, |
| 601 | Qt::AlignHCenter | Qt::AlignVCenter); |
| 602 | QPointF point; |
| 603 | QSize size = titleItem.sizeHint(); |
| 604 | switch (position) { |
| 605 | case Top: |
| 606 | point.setX(geoRect.left() + geoRect.width() / 2); |
| 607 | point.setY(geoRect.top() + (size.height() / 2) / axisTitleSpace); |
| 608 | size.setWidth(qMin(size.width(), axis()->geometry().width())); |
| 609 | break; |
| 610 | case Bottom: |
| 611 | point.setX(geoRect.left() + geoRect.width() / 2); |
| 612 | point.setY(geoRect.bottom() - (size.height() / 2) / axisTitleSpace); |
| 613 | size.setWidth(qMin(size.width(), axis()->geometry().width())); |
| 614 | break; |
| 615 | case Left: |
| 616 | point.setX(geoRect.left() + (size.width() / 2) / axisTitleSpace); |
| 617 | point.setY(geoRect.top() + geoRect.height() / 2); |
| 618 | size.setHeight(qMin(size.height(), axis()->geometry().height())); |
| 619 | break; |
| 620 | case Right: |
| 621 | point.setX(geoRect.right() - (size.width() / 2) / axisTitleSpace); |
| 622 | point.setY(geoRect.top() + geoRect.height() / 2); |
| 623 | size.setHeight(qMin(size.height(), axis()->geometry().height())); |
| 624 | break; |
| 625 | } |
| 626 | const PainterSaver painterSaver(painter); |
| 627 | painter->setClipping(false); |
| 628 | painter->translate(point); |
| 629 | titleItem.setGeometry(QRect(QPoint(-size.width() / 2, -size.height() / 2), size)); |
| 630 | titleItem.paint(painter); |
| 631 | } |
| 632 | } |
| 633 | |
| 634 | bool CartesianAxis::Private::isVertical() const |
| 635 | { |