Mercurial > hg > svgui
comparison layer/Colour3DPlotLayer.cpp @ 1220:2954e9952b78
Fix #1781 Running CQ Chromagram spits out stacks of "bin index out of range" warnings
author | Chris Cannam |
---|---|
date | Thu, 26 Jan 2017 10:41:50 +0000 |
parents | a1ee3108d1d3 |
children | eaab8bab3522 |
comparison
equal
deleted
inserted
replaced
1219:c06861dec245 | 1220:2954e9952b78 |
---|---|
759 if (!m_model) return bin; | 759 if (!m_model) return bin; |
760 double mn = 0, mx = m_model->getHeight(); | 760 double mn = 0, mx = m_model->getHeight(); |
761 getDisplayExtents(mn, mx); | 761 getDisplayExtents(mn, mx); |
762 double h = v->getPaintHeight(); | 762 double h = v->getPaintHeight(); |
763 if (m_binScale == BinScale::Linear) { | 763 if (m_binScale == BinScale::Linear) { |
764 bin = mn + ((h - y) * (mx - mn)) / h; | 764 // Arrange that the first bin (mn) appears as the exact result |
765 // for the first pixel (which is pixel h-1) and the first | |
766 // out-of-range bin (mx) would appear as the exact result for | |
767 // the first out-of-range pixel (which would be pixel -1) | |
768 bin = mn + ((h - y - 1) * (mx - mn)) / h; | |
765 } else { | 769 } else { |
766 double logmin = mn + 1, logmax = mx + 1; | 770 double logmin = mn + 1, logmax = mx + 1; |
767 LogRange::mapRange(logmin, logmax); | 771 LogRange::mapRange(logmin, logmax); |
768 bin = LogRange::unmap(logmin + ((h - y) * (logmax - logmin)) / h) - 1; | 772 bin = LogRange::unmap(logmin + ((h - y - 1) * (logmax - logmin)) / h) - 1; |
769 } | 773 } |
770 return bin; | 774 return bin; |
771 } | 775 } |
772 | 776 |
773 QString | 777 QString |