Mercurial > hg > svgui
comparison 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 |
comparison
equal
deleted
inserted
replaced
1398:f228bee4981c | 1399:ba1f0234efa7 |
---|---|
207 int pw = v->getPaintWidth(); | 207 int pw = v->getPaintWidth(); |
208 int origin = m_xorigins[v->getId()]; | 208 int origin = m_xorigins[v->getId()]; |
209 int w = pw - origin; | 209 int w = pw - origin; |
210 if (w < 1) w = 1; | 210 if (w < 1) w = 1; |
211 | 211 |
212 if (pmax <= pmin) { | |
213 pmax = pmin + 1.0; | |
214 } | |
215 | |
212 if (p < pmin) p = pmin; | 216 if (p < pmin) p = pmin; |
213 if (p > pmax) p = pmax; | 217 if (p > pmax) p = pmax; |
214 | 218 |
215 if (m_binScale == LinearBins) { | 219 if (m_binScale == LinearBins) { |
216 x = (w * (p - pmin)) / (pmax - pmin); | 220 x = (w * (p - pmin)) / (pmax - pmin); |
217 } else { | 221 } else { |
218 | 222 |
219 if (m_binScale == InvertedLogBins) { | 223 if (m_binScale == InvertedLogBins) { |
244 | 248 |
245 double pminlog = log10(pmin + reqdshift + origin); | 249 double pminlog = log10(pmin + reqdshift + origin); |
246 double pmaxlog = log10(pmax + reqdshift + origin); | 250 double pmaxlog = log10(pmax + reqdshift + origin); |
247 double plog = log10(p + reqdshift + origin); | 251 double plog = log10(p + reqdshift + origin); |
248 x = (w * (plog - pminlog)) / (pmaxlog - pminlog); | 252 x = (w * (plog - pminlog)) / (pmaxlog - pminlog); |
249 | 253 /* |
250 /* | |
251 cerr << "getXForScalePoint(" << p << "): pmin = " << pmin | 254 cerr << "getXForScalePoint(" << p << "): pmin = " << pmin |
252 << ", pmax = " << pmax << ", w = " << w | 255 << ", pmax = " << pmax << ", w = " << w |
253 << ", reqdshift = " << reqdshift | 256 << ", reqdshift = " << reqdshift |
254 << ", pminlog = " << pminlog << ", pmaxlog = " << pmaxlog | 257 << ", pminlog = " << pminlog << ", pmaxlog = " << pmaxlog |
255 << ", plog = " << plog | 258 << ", plog = " << plog |
256 << " -> x = " << x << endl; | 259 << " -> x = " << x << endl; |
257 */ | 260 */ |
258 | |
259 if (m_binScale == InvertedLogBins) { | 261 if (m_binScale == InvertedLogBins) { |
260 // still stoopid | 262 // still stoopid |
261 x = w - x; | 263 x = w - x; |
262 } | 264 } |
263 } | 265 } |
285 | 287 |
286 x = x - origin; | 288 x = x - origin; |
287 if (x < 0) x = 0; | 289 if (x < 0) x = 0; |
288 | 290 |
289 double eps = 1e-10; | 291 double eps = 1e-10; |
292 | |
293 if (pmax <= pmin) { | |
294 pmax = pmin + 1.0; | |
295 } | |
290 | 296 |
291 if (m_binScale == LinearBins) { | 297 if (m_binScale == LinearBins) { |
292 p = pmin + eps + (x * (pmax - pmin)) / w; | 298 p = pmin + eps + (x * (pmax - pmin)) / w; |
293 } else { | 299 } else { |
294 | 300 |