From 39254405071fc3127786a30d69dfb366bfa11d6b Mon Sep 17 00:00:00 2001 From: Allan Bazinet Date: Thu, 12 Sep 2024 13:12:44 -0700 Subject: [PATCH] Ensure bins per pixel sanity in manipulator MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Clamp the low bound of the bins per pixel value to 1 in the manipulator, not later on, by which time it’s already too late. --- plotter.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/plotter.cpp b/plotter.cpp index 9935b127..9c7eeeef 100644 --- a/plotter.cpp +++ b/plotter.cpp @@ -478,8 +478,6 @@ CPlotter::DrawOverlayScale(double const df, p.setPen(Qt::black); p.drawRect(0, 0, m_w, 30); - if (m_binsPerPixel < 1) m_binsPerPixel = 1; - std::size_t const hdivs = m_w * df / m_freqPerDiv + 0.9999; int f = ((m_startFreq + m_freqPerDiv - 1) / m_freqPerDiv) * m_freqPerDiv; double const xOffset = float(f - m_startFreq) / m_freqPerDiv; @@ -685,7 +683,7 @@ void CPlotter::UpdateOverlay() //UpdateOverlay void CPlotter::setBinsPerPixel(int const n) //setBinsPerPixel { - m_binsPerPixel = n; + m_binsPerPixel = n < 1 ? 1 : n; DrawOverlay(); //Redraw scales and ticks update(); //trigger a new paintEvent} }