From 1c9f4bef0d019c954c25cf3682fa1916f6b1c6d6 Mon Sep 17 00:00:00 2001 From: James Yuzawa Date: Fri, 25 Oct 2024 22:07:48 -0400 Subject: [PATCH] use drawRect again --- src/qtgui/plotter.cpp | 21 ++++++++++----------- src/qtgui/plotter.h | 1 - 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/src/qtgui/plotter.cpp b/src/qtgui/plotter.cpp index 352718da9..073594806 100644 --- a/src/qtgui/plotter.cpp +++ b/src/qtgui/plotter.cpp @@ -1540,6 +1540,7 @@ void CPlotter::draw(bool newData) const float binSizeY = (float)plotHeight / (float)histBinsDisplayed; QPolygonF abPolygon; + qreal yFillMax = 0; for (i = 0; i < npts; i++) { const int ix = i + xmin; @@ -1584,6 +1585,7 @@ void CPlotter::draw(bool newData) // Fill area between markers, even if they are off screen qreal yFill = m_PlotMode == PLOT_MODE_MAX ? yMaxD : yAvgD; + yFillMax = std::max(yFillMax, yFill); if (fillMarkers && (ix) > minMarker && (ix) < maxMarker) { abPolygon << QPointF(ixPlot, yFill); } @@ -1591,16 +1593,13 @@ void CPlotter::draw(bool newData) if (m_FftFill && m_PlotMode != PLOT_MODE_HISTOGRAM) { - qreal yFillMax = 0; for (i = 0; i < npts; i++) { - QPointF yFill = m_PlotMode == PLOT_MODE_MAX ? m_maxLineBuf[i] : m_avgLineBuf[i]; - m_fillLineBuf[i] = QLineF(yFill, QPointF(yFill.x(), plotHeight)); - yFillMax = std::max(yFillMax, yFill.y()); + const QPointF point = m_PlotMode == PLOT_MODE_MAX ? m_maxLineBuf[i] : m_avgLineBuf[i]; + const qreal yFill = point.y(); + painter2.fillRect(QRectF(point.x(), yFill, 1.0, yFillMax - yFill), m_FftFillCol); } - painter2.setPen(QPen(m_FftFillCol)); - painter2.drawLines(m_fillLineBuf, npts); - painter2.fillRect(QRectF(xmin, yFillMax, npts, plotHeight - yFillMax), QBrush(m_FftFillCol)); + painter2.fillRect(QRectF(xmin, yFillMax, npts, plotHeight - yFillMax), m_FftFillCol); } if (!abPolygon.isEmpty()) @@ -1634,7 +1633,7 @@ void CPlotter::draw(bool newData) // Min hold if (m_MinHoldActive) { - // Show min(avg) except when showing only max on scree + // Show min(avg) except when showing only max on screen for (i = 0; i < npts; i++) { const int ix = i + xmin; @@ -1655,10 +1654,10 @@ void CPlotter::draw(bool newData) { for (i = 0; i < npts; i++) { - m_fillLineBuf[i] = QLineF(m_maxLineBuf[i], m_avgLineBuf[i]); + const QPointF maxPoint = m_maxLineBuf[i]; + const qreal yMax = maxPoint.y(); + painter2.fillRect(QRectF(maxPoint.x(), yMax, 1.0, m_avgLineBuf[i].y() - yMax), m_FilledModeFillCol); } - painter2.setPen(QPen(m_FilledModeFillCol)); - painter2.drawLines(m_fillLineBuf, npts); } if (doMaxLine) diff --git a/src/qtgui/plotter.h b/src/qtgui/plotter.h index f8264927d..10ca83c7b 100644 --- a/src/qtgui/plotter.h +++ b/src/qtgui/plotter.h @@ -253,7 +253,6 @@ public slots: QPointF m_avgLineBuf[MAX_SCREENSIZE]{}; QPointF m_maxLineBuf[MAX_SCREENSIZE]{}; QPointF m_holdLineBuf[MAX_SCREENSIZE]{}; - QLineF m_fillLineBuf[MAX_SCREENSIZE]{}; float m_histMaxIIR; std::vector m_fftIIR; std::vector m_fftData;