# HG changeset patch # User Chris Cannam # Date 1525188755 -3600 # Node ID 82258db9624453da0169403c257bc9b2772d05e7 # Parent b4cb11ca8233607fe6a974e65d93edfab46601b3 Draw some ticks diff -r b4cb11ca8233 -r 82258db96244 layer/LogNumericalScale.cpp --- a/layer/LogNumericalScale.cpp Tue May 01 16:14:22 2018 +0100 +++ b/layer/LogNumericalScale.cpp Tue May 01 16:32:35 2018 +0100 @@ -95,15 +95,17 @@ paint.drawLine(x0, y0, x1, y0); - double f0 = p->getFrequencyForX(v, x0); + double f0 = p->getFrequencyForX(v, x0 ? x0 : 1); double f1 = p->getFrequencyForX(v, x1); + cerr << "f0 = " << f0 << " at x " << (x0 ? x0 : 1) << endl; + cerr << "f1 = " << f1 << " at x " << x1 << endl; + int n = 10; auto ticks = ScaleTickIntervals::logarithmic({ f0, f1, n }); n = int(ticks.size()); -// int prevx = -1; - (void)y1; + int marginx = -1; for (int i = 0; i < n; ++i) { @@ -113,10 +115,19 @@ cerr << "i = " << i << ", value = " << val << ", tw = " << tw << endl; - double x = p->getXForFrequency(v, val); + int x = int(round(p->getXForFrequency(v, val))); cerr << "x = " << x << endl; + + if (x < marginx) continue; + //!!! todo: pixel scaling (here & elsewhere in these classes) + + paint.drawLine(x, y0, x, y1); + + paint.drawText(x + 5, y0 + paint.fontMetrics().ascent() + 5, label); + + marginx = x + tw + 10; } } diff -r b4cb11ca8233 -r 82258db96244 layer/SpectrumLayer.cpp --- a/layer/SpectrumLayer.cpp Tue May 01 16:14:22 2018 +0100 +++ b/layer/SpectrumLayer.cpp Tue May 01 16:32:35 2018 +0100 @@ -686,7 +686,7 @@ LogNumericalScale().paintHorizontal (v, this, paint, - QRect(xorigin, h - scaleh, w + xorigin, scaleh)); + QRect(int(getXForBin(v, 0)), h - scaleh, w + xorigin, scaleh)); paint.restore(); }