MCPcopy Create free account
hub / github.com/CieNTi/serial_port_plotter / getMaxTickLabelSize

Method getMaxTickLabelSize

qcustomplot/qcustomplot.cpp:9809–9828  ·  view source on GitHub ↗

! \internal Simulates the steps done by \ref placeTickLabel by calculating bounding boxes of the text label to be drawn, depending on number format etc. Since only the largest tick label is wanted for the margin calculation, the passed \a tickLabelsSize is only expanded, if it's currently set to a smaller width/height. */

Source from the content-addressed store, hash-verified

9807 smaller width/height.
9808*/
9809void QCPAxisPainterPrivate::getMaxTickLabelSize(const QFont &font, const QString &text, QSize *tickLabelsSize) const
9810{
9811 // note: this function must return the same tick label sizes as the placeTickLabel function.
9812 QSize finalSize;
9813 if (mParentPlot->plottingHints().testFlag(QCP::phCacheLabels) && mLabelCache.contains(text)) // label caching enabled and have cached label
9814 {
9815 const CachedLabel *cachedLabel = mLabelCache.object(text);
9816 finalSize = cachedLabel->pixmap.size()/mParentPlot->bufferDevicePixelRatio();
9817 } else // label caching disabled or no label with this text cached:
9818 {
9819 TickLabelData labelData = getTickLabelData(font, text);
9820 finalSize = labelData.rotatedTotalBounds.size();
9821 }
9822
9823 // expand passed tickLabelsSize if current tick label is larger:
9824 if (finalSize.width() > tickLabelsSize->width())
9825 tickLabelsSize->setWidth(finalSize.width());
9826 if (finalSize.height() > tickLabelsSize->height())
9827 tickLabelsSize->setHeight(finalSize.height());
9828}
9829/* end of 'src/axis/axis.cpp' */
9830
9831

Callers

nothing calls this directly

Calls 3

containsMethod · 0.80
setWidthMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected