* @brief Re-renders the axis overlay into m_axisLayer and clears the dirty flag. */
| 793 | * @brief Re-renders the axis overlay into m_axisLayer and clears the dirty flag. |
| 794 | */ |
| 795 | void Widgets::Waterfall::renderAxisLayer() |
| 796 | { |
| 797 | m_axisDirty = false; |
| 798 | |
| 799 | const QSize itemSize(qMax(1, qCeil(width())), qMax(1, qCeil(height()))); |
| 800 | const qreal dpr = (window() ? window()->devicePixelRatio() : 1.0); |
| 801 | const QSize bufSize = itemSize * dpr; |
| 802 | if (bufSize.isEmpty()) |
| 803 | return; |
| 804 | |
| 805 | if (m_axisLayer.size() != bufSize) { |
| 806 | m_axisLayer = QImage(bufSize, QImage::Format_ARGB32_Premultiplied); |
| 807 | m_axisLayer.setDevicePixelRatio(dpr); |
| 808 | } |
| 809 | m_axisLayer.fill(Qt::transparent); |
| 810 | |
| 811 | QPainter painter(&m_axisLayer); |
| 812 | painter.setRenderHint(QPainter::Antialiasing, true); |
| 813 | painter.setRenderHint(QPainter::TextAntialiasing, true); |
| 814 | |
| 815 | static auto& fonts = Misc::CommonFonts::instance(); |
| 816 | painter.setFont(fonts.widgetFont(0.83, false)); |
| 817 | |
| 818 | const QFontMetrics fm(painter.font()); |
| 819 | m_cachedPlotRect = computePlotRect(fm); |
| 820 | if (m_cachedPlotRect.isEmpty()) |
| 821 | return; |
| 822 | |
| 823 | painter.setPen(QPen(m_borderColor, 1)); |
| 824 | painter.setBrush(Qt::NoBrush); |
| 825 | painter.drawRect(m_cachedPlotRect); |
| 826 | |
| 827 | if (m_axisVisible && width() >= kMinAxisWidth && height() >= kMinAxisHeight) { |
| 828 | drawXAxis(&painter, m_cachedPlotRect); |
| 829 | drawYAxis(&painter, m_cachedPlotRect); |
| 830 | } |
| 831 | } |
| 832 | |
| 833 | /** |
| 834 | * @brief Marks the axis overlay as needing a re-render and schedules a repaint. |