MCPcopy Create free account
hub / github.com/Audio4Linux/JDSP4Linux / drawText

Method drawText

3rdparty/qcustomplot/qcustomplot.cpp:5788–5830  ·  view source on GitHub ↗

! \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

Source from the content-addressed store, hash-verified

5786 QCP::phCacheLabels plotting hint is not set.
5787*/
5788void QCPLabelPainterPrivate::drawText(QCPPainter *painter, const QPointF &pos, const LabelData &labelData) const
5789{
5790 // backup painter settings that we're about to change:
5791 QTransform oldTransform = painter->transform();
5792 QFont oldFont = painter->font();
5793 QPen oldPen = painter->pen();
5794
5795 // transform painter to position/rotation:
5796 painter->translate(pos);
5797 painter->setTransform(labelData.transform, true);
5798
5799 // draw text:
5800 painter->setFont(labelData.baseFont);
5801 painter->setPen(QPen(labelData.color));
5802 if (!labelData.expPart.isEmpty()) // use superscripted exponent typesetting
5803 {
5804 painter->drawText(0, 0, 0, 0, Qt::TextDontClip, labelData.basePart);
5805 if (!labelData.suffixPart.isEmpty())
5806 painter->drawText(labelData.baseBounds.width()+1+labelData.expBounds.width(), 0, 0, 0, Qt::TextDontClip, labelData.suffixPart);
5807 painter->setFont(labelData.expFont);
5808 painter->drawText(labelData.baseBounds.width()+1, 0, labelData.expBounds.width(), labelData.expBounds.height(), Qt::TextDontClip, labelData.expPart);
5809 } else
5810 {
5811 painter->drawText(0, 0, labelData.totalBounds.width(), labelData.totalBounds.height(), Qt::TextDontClip | Qt::AlignHCenter, labelData.basePart);
5812 }
5813
5814 /* Debug code to draw label bounding boxes, baseline, and capheight
5815 painter->save();
5816 painter->setPen(QPen(QColor(0, 0, 0, 150)));
5817 painter->drawRect(labelData.totalBounds);
5818 const int baseline = labelData.totalBounds.height()-mLetterDescent;
5819 painter->setPen(QPen(QColor(255, 0, 0, 150)));
5820 painter->drawLine(QLineF(0, baseline, labelData.totalBounds.width(), baseline));
5821 painter->setPen(QPen(QColor(0, 0, 255, 150)));
5822 painter->drawLine(QLineF(0, baseline-mLetterCapHeight, labelData.totalBounds.width(), baseline-mLetterCapHeight));
5823 painter->restore();
5824 */
5825
5826 // reset painter settings to what it was before:
5827 painter->setTransform(oldTransform);
5828 painter->setFont(oldFont);
5829 painter->setPen(oldPen);
5830}
5831
5832/*! \internal
5833

Callers 8

drawMethod · 0.80
drawTickLabelMethod · 0.80
onDrawMethod · 0.80
onDrawMethod · 0.80
onDrawMethod · 0.80
paintEventMethod · 0.80
paintEventMethod · 0.80
paintMethod · 0.80

Calls 4

fontMethod · 0.80
setFontMethod · 0.80
setPenMethod · 0.80
isEmptyMethod · 0.45

Tested by

no test coverage detected