comparison view/View.cpp @ 1330:c1f719094c25 zoom

Ensure getFrameForX returns value on zoom blocksize boundary; take advantage of that (this is essentially reverting to the same behaviour as in the default branch, which we should probably have done all along)
author Chris Cannam
date Fri, 21 Sep 2018 11:50:05 +0100
parents 344f29e46258
children 9758dfc12555
comparison
equal deleted inserted replaced
1329:344f29e46258 1330:c1f719094c25
393 } 393 }
394 394
395 sv_frame_t 395 sv_frame_t
396 View::getFrameForX(int x) const 396 View::getFrameForX(int x) const
397 { 397 {
398 // Note, this must always return a value that is on a zoom-level
399 // boundary - regardless of whether the nominal centre frame is on
400 // such a boundary or not
401
398 int diff = x - (width()/2); 402 int diff = x - (width()/2);
399 sv_frame_t fdiff = diff; 403 sv_frame_t level = m_zoomLevel.level;
400 404 sv_frame_t fdiff, result;
405
401 if (m_zoomLevel.zone == ZoomLevel::FramesPerPixel) { 406 if (m_zoomLevel.zone == ZoomLevel::FramesPerPixel) {
402 fdiff *= m_zoomLevel.level; 407 fdiff = diff * level;
408 result = ((fdiff + m_centreFrame) / level) * level;
403 } else { 409 } else {
404 fdiff /= m_zoomLevel.level; 410 fdiff = diff / level;
405 } 411 result = fdiff + m_centreFrame;
406 412 }
407 return fdiff + m_centreFrame; 413 /*
414 if (x == 0) {
415 SVCERR << "getFrameForX(" << x << "): diff = " << diff << ", fdiff = "
416 << fdiff << ", m_centreFrame = " << m_centreFrame
417 << ", level = " << m_zoomLevel.level
418 << ", diff % level = " << (diff % m_zoomLevel.level)
419 << ", nominal " << fdiff + m_centreFrame
420 << ", will return " << result
421 << endl;
422 }
423 */
424 return result;
408 } 425 }
409 426
410 double 427 double
411 View::getYForFrequency(double frequency, 428 View::getYForFrequency(double frequency,
412 double minf, 429 double minf,