Skip to content

Commit

Permalink
use drawRect again
Browse files Browse the repository at this point in the history
  • Loading branch information
yuzawa-san committed Oct 26, 2024
1 parent 5d07847 commit 1c9f4be
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 12 deletions.
21 changes: 10 additions & 11 deletions src/qtgui/plotter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1584,23 +1585,21 @@ 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);
}
}

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())
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand Down
1 change: 0 additions & 1 deletion src/qtgui/plotter.h
Original file line number Diff line number Diff line change
Expand Up @@ -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<float> m_fftIIR;
std::vector<float> m_fftData;
Expand Down

0 comments on commit 1c9f4be

Please sign in to comment.