# HG changeset patch # User Chris Cannam # Date 1429534899 -3600 # Node ID 43888f891733f722f93246ba690281174fd3e6b3 # Parent e3c7da3d896e722b0ade45a422a97971de68558b Some scaling & zoom bits diff -r e3c7da3d896e -r 43888f891733 view/View.cpp --- a/view/View.cpp Mon Apr 20 11:00:48 2015 +0100 +++ b/view/View.cpp Mon Apr 20 14:01:39 2015 +0100 @@ -452,6 +452,8 @@ void View::setZoomLevel(int z) { + int dpratio = devicePixelRatio(); + if (z < dpratio) return; if (z < 1) z = 1; if (m_zoomLevel != int(z)) { m_zoomLevel = z; diff -r e3c7da3d896e -r 43888f891733 view/ViewProxy.h --- a/view/ViewProxy.h Mon Apr 20 11:00:48 2015 +0100 +++ b/view/ViewProxy.h Mon Apr 20 14:01:39 2015 +0100 @@ -33,11 +33,14 @@ return m_view->getEndFrame(); } virtual int getXForFrame(sv_frame_t frame) const { + //!!! not actually correct, if frame lies between view's pixels return m_scaleFactor * m_view->getXForFrame(frame); } virtual sv_frame_t getFrameForX(int x) const { - //!!! todo: interpolate - return m_view->getFrameForX(x / m_scaleFactor); + sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); + if (m_scaleFactor == 1) return f0; + sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1); + return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; } virtual sv_frame_t getModelsStartFrame() const { return m_view->getModelsStartFrame(); @@ -53,8 +56,12 @@ } virtual double getFrequencyForY(int y, double minFreq, double maxFreq, bool logarithmic) const { - //!!! todo: interpolate - return m_view->getFrequencyForY(y / m_scaleFactor, minFreq, maxFreq, logarithmic); + double f0 = m_view->getFrequencyForY + (y / m_scaleFactor, minFreq, maxFreq, logarithmic); + if (m_scaleFactor == 1) return f0; + double f1 = m_view->getFrequencyForY + ((y / m_scaleFactor) + 1, minFreq, maxFreq, logarithmic); + return f0 + ((f1 - f0) * (y % m_scaleFactor)) / m_scaleFactor; } virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { return m_scaleFactor * m_view->getTextLabelHeight(layer, paint);