| 1077 | } |
| 1078 | |
| 1079 | QRectF 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 | |
| 1103 | void PlotViewWidget::initViewFromModel() |
| 1104 | { |
no test coverage detected