comparison layer/SliceLayer.cpp @ 1256:5a10e9d924d4

Make some corrections to crosshair (measure cursor) positioning and feature descriptions. Needs review.
author Chris Cannam
date Tue, 07 Mar 2017 18:54:15 +0000
parents bbdfe9b57857
children 5bab9562eaa3
comparison
equal deleted inserted replaced
1255:bbdfe9b57857 1256:5a10e9d924d4
113 { 113 {
114 minbin = 0; 114 minbin = 0;
115 maxbin = 0; 115 maxbin = 0;
116 if (!m_sliceableModel) return ""; 116 if (!m_sliceableModel) return "";
117 117
118 minbin = int(round(getBinForX(v, p.x()))); 118 minbin = int(getBinForX(v, p.x()));
119 maxbin = int(round(getBinForX(v, p.x() + 1))); 119 maxbin = int(getBinForX(v, p.x() + 1));
120 120
121 int mh = m_sliceableModel->getHeight(); 121 int mh = m_sliceableModel->getHeight();
122 if (minbin >= mh) minbin = mh - 1; 122 if (minbin >= mh) minbin = mh - 1;
123 if (maxbin >= mh) maxbin = mh - 1; 123 if (maxbin >= mh) maxbin = mh - 1;
124 if (minbin < 0) minbin = 0; 124 if (minbin < 0) minbin = 0;
235 int w = pw - origin; 235 int w = pw - origin;
236 if (w < 1) w = 1; 236 if (w < 1) w = 1;
237 237
238 x = x - origin; 238 x = x - origin;
239 if (x < 0) x = 0; 239 if (x < 0) x = 0;
240
241 double eps = 1e-10;
240 242
241 switch (m_binScale) { 243 switch (m_binScale) {
242 244
243 case LinearBins: 245 case LinearBins:
244 bin = int((x * count) / w + 0.0001); 246 bin = (x * count) / w + eps;
245 break; 247 break;
246 248
247 case LogBins: 249 case LogBins:
248 bin = int(pow(10.0, (x * log10(count + 1)) / w) - 1 + 0.0001); 250 bin = pow(10.0, (x * log10(count + 1)) / w) - 1.0 + eps;
249 break; 251 break;
250 252
251 case InvertedLogBins: 253 case InvertedLogBins:
252 bin = count + 1 - int(pow(10.0, (log10(count) * (w - x)) / double(w)) + 0.0001); 254 bin = count + 1 - pow(10.0, (log10(count) * (w - x)) / double(w)) + eps;
253 break; 255 break;
254 } 256 }
255 257
256 return bin + m_minbin; 258 return bin + m_minbin;
257 } 259 }