MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / computePlotRect

Method computePlotRect

app/src/UI/Widgets/Waterfall.cpp:849–870  ·  view source on GitHub ↗

* @brief Computes the inner plot rectangle after reserving axis-label margins. */

Source from the content-addressed store, hash-verified

847 * @brief Computes the inner plot rectangle after reserving axis-label margins.
848 */
849QRectF Widgets::Waterfall::computePlotRect(const QFontMetrics& fm) const
850{
851 if (!m_axisVisible || width() < kMinAxisWidth || height() < kMinAxisHeight)
852 return QRectF(0.5, 0.5, qMax(0.0, width() - 1), qMax(0.0, height() - 1));
853
854 static auto& fonts = Misc::CommonFonts::instance();
855 const QFontMetrics titleFm(fonts.widgetFont(0.91, true));
856
857 const int yTickWidth =
858 fm.horizontalAdvance(QStringLiteral("00.00")) + kAxisTickPx + kAxisLabelPad;
859 const int yTitleWidth = titleFm.height() + 2;
860
861 const int leftMargin = yTitleWidth + yTickWidth;
862 const int rightMargin = kAxisLabelPad;
863 const int topMargin = kAxisLabelPad;
864 const int bottomMargin = fm.height() + kAxisTickPx + kAxisLabelPad * 2;
865
866 return QRectF(leftMargin + 0.5,
867 topMargin + 0.5,
868 qMax(0.0, width() - leftMargin - rightMargin - 1),
869 qMax(0.0, height() - topMargin - bottomMargin - 1));
870}
871
872/**
873 * @brief Draws the ring-buffered history: the visible logical rows map to at most two

Callers

nothing calls this directly

Calls 2

widgetFontMethod · 0.80
heightMethod · 0.80

Tested by

no test coverage detected