MCPcopy Create free account
hub / github.com/LUX-Core/lux / getMaxTickLabelSize

Method getMaxTickLabelSize

src/qt/qcustomplot.cpp:9798–9817  ·  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

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

Callers

nothing calls this directly

Calls 3

setWidthMethod · 0.80
containsMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected