MCPcopy Create free account
hub / github.com/IENT/YUView / getMaxLabelDrawSize

Method getMaxLabelDrawSize

YUViewLib/src/ui/views/PlotViewWidget.cpp:1079–1101  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1077}
1078
1079QRectF PlotViewWidget::getMaxLabelDrawSize(QPainter & painter,
1080 Axis axis,
1081 const QList<TickValue> &ticks) const
1082{
1083 if (!this->model)
1084 return {};
1085
1086 painter.setPen(QPen(Qt::black, 1));
1087 painter.setBrush(Qt::NoBrush);
1088 QFont displayFont = painter.font();
1089 QFontMetricsF metrics(displayFont);
1090 QRectF maxSize;
1091 for (auto tick : ticks)
1092 {
1093 const auto text = this->model->formatValue(axis, tick.value);
1094 auto textSize = metrics.size(0, text);
1095 if (textSize.width() > maxSize.width())
1096 maxSize.setWidth(textSize.width());
1097 if (textSize.height() > maxSize.height())
1098 maxSize.setHeight(textSize.height());
1099 }
1100 return maxSize;
1101}
1102
1103void PlotViewWidget::initViewFromModel()
1104{

Callers 2

drawAxisTickLabelsMethod · 0.95
updatePlotRectAndAxisMethod · 0.95

Calls 2

formatValueMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected