Mercurial > hg > svgui
diff layer/SliceLayer.cpp @ 1399:ba1f0234efa7
Fixes to spectrum axis calculations, + default to starting at bin 1
author | Chris Cannam |
---|---|
date | Wed, 14 Nov 2018 15:47:21 +0000 |
parents | 4a36f6130056 |
children | decb7741d036 |
line wrap: on
line diff
--- a/layer/SliceLayer.cpp Wed Nov 14 15:14:21 2018 +0000 +++ b/layer/SliceLayer.cpp Wed Nov 14 15:47:21 2018 +0000 @@ -209,9 +209,13 @@ int w = pw - origin; if (w < 1) w = 1; + if (pmax <= pmin) { + pmax = pmin + 1.0; + } + if (p < pmin) p = pmin; if (p > pmax) p = pmax; - + if (m_binScale == LinearBins) { x = (w * (p - pmin)) / (pmax - pmin); } else { @@ -246,16 +250,14 @@ double pmaxlog = log10(pmax + reqdshift + origin); double plog = log10(p + reqdshift + origin); x = (w * (plog - pminlog)) / (pmaxlog - pminlog); - -/* + /* cerr << "getXForScalePoint(" << p << "): pmin = " << pmin << ", pmax = " << pmax << ", w = " << w << ", reqdshift = " << reqdshift << ", pminlog = " << pminlog << ", pmaxlog = " << pmaxlog << ", plog = " << plog << " -> x = " << x << endl; -*/ - + */ if (m_binScale == InvertedLogBins) { // still stoopid x = w - x; @@ -288,6 +290,10 @@ double eps = 1e-10; + if (pmax <= pmin) { + pmax = pmin + 1.0; + } + if (m_binScale == LinearBins) { p = pmin + eps + (x * (pmax - pmin)) / w; } else {