# HG changeset patch # User Chris Cannam # Date 1488912855 0 # Node ID 5a10e9d924d428470414e83603ad4c794a192c01 # Parent bbdfe9b57857bc5375445a55069ad32f72bf1aa9 Make some corrections to crosshair (measure cursor) positioning and feature descriptions. Needs review. diff -r bbdfe9b57857 -r 5a10e9d924d4 layer/SliceLayer.cpp --- 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; } diff -r bbdfe9b57857 -r 5a10e9d924d4 layer/SpectrumLayer.cpp --- 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));