Mercurial > hg > svgui
changeset 1256:5a10e9d924d4
Make some corrections to crosshair (measure cursor) positioning and feature descriptions. Needs review.
author | Chris Cannam |
---|---|
date | Tue, 07 Mar 2017 18:54:15 +0000 |
parents | bbdfe9b57857 |
children | 14dcdc596baf |
files | layer/SliceLayer.cpp layer/SpectrumLayer.cpp |
diffstat | 2 files changed, 9 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/layer/SliceLayer.cpp Tue Mar 07 18:39:37 2017 +0000 +++ b/layer/SliceLayer.cpp Tue Mar 07 18:54:15 2017 +0000 @@ -115,8 +115,8 @@ maxbin = 0; if (!m_sliceableModel) return ""; - minbin = int(round(getBinForX(v, p.x()))); - maxbin = int(round(getBinForX(v, p.x() + 1))); + minbin = int(getBinForX(v, p.x())); + maxbin = int(getBinForX(v, p.x() + 1)); int mh = m_sliceableModel->getHeight(); if (minbin >= mh) minbin = mh - 1; @@ -237,19 +237,21 @@ x = x - origin; if (x < 0) x = 0; + + double eps = 1e-10; switch (m_binScale) { case LinearBins: - bin = int((x * count) / w + 0.0001); + bin = (x * count) / w + eps; break; case LogBins: - bin = int(pow(10.0, (x * log10(count + 1)) / w) - 1 + 0.0001); + bin = pow(10.0, (x * log10(count + 1)) / w) - 1.0 + eps; break; case InvertedLogBins: - bin = count + 1 - int(pow(10.0, (log10(count) * (w - x)) / double(w)) + 0.0001); + bin = count + 1 - pow(10.0, (log10(count) * (w - x)) / double(w)) + eps; break; }
--- a/layer/SpectrumLayer.cpp Tue Mar 07 18:39:37 2017 +0000 +++ b/layer/SpectrumLayer.cpp Tue Mar 07 18:54:15 2017 +0000 @@ -302,6 +302,7 @@ { if (!m_sliceableModel) return 0; double bin = getBinForX(v, x); + cerr << "bin = " << bin << endl; return (m_sliceableModel->getSampleRate() * bin) / (m_sliceableModel->getHeight() * 2); } @@ -462,7 +463,6 @@ while (harmonic < 100) { int hx = int(lrint(getXForFrequency(v, fundamental * harmonic))); - hx += xorigin; if (hx < xorigin || hx > v->getPaintWidth()) break; @@ -513,7 +513,7 @@ QString hzstr; int minfreq = int(lrint((minbin * m_sliceableModel->getSampleRate()) / m_windowSize)); - int maxfreq = int(lrint((std::max(maxbin, minbin+1) + int maxfreq = int(lrint((std::max(maxbin, minbin) * m_sliceableModel->getSampleRate()) / m_windowSize));