! \internal This is a \ref placeTickLabel helper function. Draws the tick label specified in \a labelData with \a painter at the pixel positions \a x and \a y. This function is used by \ref placeTickLabel to create new tick labels for the cache, or to directly draw the labels on the QCustomPlot surface when label caching is disabled, i.e. when QCP::phCacheLabels plotting hint is no
| 9586 | QCP::phCacheLabels plotting hint is not set. |
| 9587 | */ |
| 9588 | void QCPAxisPainterPrivate::drawTickLabel(QCPPainter *painter, double x, double y, const TickLabelData &labelData) const |
| 9589 | { |
| 9590 | // backup painter settings that we're about to change: |
| 9591 | QTransform oldTransform = painter->transform(); |
| 9592 | QFont oldFont = painter->font(); |
| 9593 | |
| 9594 | // transform painter to position/rotation: |
| 9595 | painter->translate(x, y); |
| 9596 | if (!qFuzzyIsNull(tickLabelRotation)) |
| 9597 | painter->rotate(tickLabelRotation); |
| 9598 | |
| 9599 | // draw text: |
| 9600 | if (!labelData.expPart.isEmpty()) // indicator that beautiful powers must be used |
| 9601 | { |
| 9602 | painter->setFont(labelData.baseFont); |
| 9603 | painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.basePart); |
| 9604 | if (!labelData.suffixPart.isEmpty()) |
| 9605 | painter->drawText(labelData.baseBounds.width()+1+labelData.expBounds.width(), 0, 0, 0, Qt::TextDontClip, labelData.suffixPart); |
| 9606 | painter->setFont(labelData.expFont); |
| 9607 | painter->drawText(labelData.baseBounds.width()+1, 0, labelData.expBounds.width(), labelData.expBounds.height(), Qt::TextDontClip, labelData.expPart); |
| 9608 | } else |
| 9609 | { |
| 9610 | painter->setFont(labelData.baseFont); |
| 9611 | painter->drawText(0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart); |
| 9612 | } |
| 9613 | |
| 9614 | // reset painter settings to what it was before: |
| 9615 | painter->setTransform(oldTransform); |
| 9616 | painter->setFont(oldFont); |
| 9617 | } |
| 9618 | |
| 9619 | /*! \internal |
| 9620 |