Mercurial > hg > svgui
comparison view/ViewProxy.h @ 950:43888f891733 osx-retina
Some scaling & zoom bits
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 14:01:39 +0100 |
parents | a5488775f880 |
children | 17cb48115d22 |
comparison
equal
deleted
inserted
replaced
949:e3c7da3d896e | 950:43888f891733 |
---|---|
31 } | 31 } |
32 virtual sv_frame_t getEndFrame() const { | 32 virtual sv_frame_t getEndFrame() const { |
33 return m_view->getEndFrame(); | 33 return m_view->getEndFrame(); |
34 } | 34 } |
35 virtual int getXForFrame(sv_frame_t frame) const { | 35 virtual int getXForFrame(sv_frame_t frame) const { |
36 //!!! not actually correct, if frame lies between view's pixels | |
36 return m_scaleFactor * m_view->getXForFrame(frame); | 37 return m_scaleFactor * m_view->getXForFrame(frame); |
37 } | 38 } |
38 virtual sv_frame_t getFrameForX(int x) const { | 39 virtual sv_frame_t getFrameForX(int x) const { |
39 //!!! todo: interpolate | 40 sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); |
40 return m_view->getFrameForX(x / m_scaleFactor); | 41 if (m_scaleFactor == 1) return f0; |
42 sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1); | |
43 return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; | |
41 } | 44 } |
42 virtual sv_frame_t getModelsStartFrame() const { | 45 virtual sv_frame_t getModelsStartFrame() const { |
43 return m_view->getModelsStartFrame(); | 46 return m_view->getModelsStartFrame(); |
44 } | 47 } |
45 virtual sv_frame_t getModelsEndFrame() const { | 48 virtual sv_frame_t getModelsEndFrame() const { |
51 return m_scaleFactor * | 54 return m_scaleFactor * |
52 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); | 55 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); |
53 } | 56 } |
54 virtual double getFrequencyForY(int y, double minFreq, double maxFreq, | 57 virtual double getFrequencyForY(int y, double minFreq, double maxFreq, |
55 bool logarithmic) const { | 58 bool logarithmic) const { |
56 //!!! todo: interpolate | 59 double f0 = m_view->getFrequencyForY |
57 return m_view->getFrequencyForY(y / m_scaleFactor, minFreq, maxFreq, logarithmic); | 60 (y / m_scaleFactor, minFreq, maxFreq, logarithmic); |
61 if (m_scaleFactor == 1) return f0; | |
62 double f1 = m_view->getFrequencyForY | |
63 ((y / m_scaleFactor) + 1, minFreq, maxFreq, logarithmic); | |
64 return f0 + ((f1 - f0) * (y % m_scaleFactor)) / m_scaleFactor; | |
58 } | 65 } |
59 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { | 66 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { |
60 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); | 67 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); |
61 } | 68 } |
62 virtual bool getValueExtents(QString unit, double &min, double &max, | 69 virtual bool getValueExtents(QString unit, double &min, double &max, |