comparison view/ViewProxy.h @ 1266:a34a2a25907c

Untabify
author Chris Cannam
date Thu, 01 Mar 2018 18:02:22 +0000
parents 179ea8a2f650
children 97c68bffbda6
comparison
equal deleted inserted replaced
1265:6e724c81f18f 1266:a34a2a25907c
19 19
20 class ViewProxy : public LayerGeometryProvider 20 class ViewProxy : public LayerGeometryProvider
21 { 21 {
22 public: 22 public:
23 ViewProxy(View *view, int scaleFactor) : 23 ViewProxy(View *view, int scaleFactor) :
24 m_view(view), m_scaleFactor(scaleFactor) { } 24 m_view(view), m_scaleFactor(scaleFactor) { }
25 25
26 virtual int getId() const { 26 virtual int getId() const {
27 return m_view->getId(); 27 return m_view->getId();
28 } 28 }
29 virtual sv_frame_t getStartFrame() const { 29 virtual sv_frame_t getStartFrame() const {
30 return m_view->getStartFrame(); 30 return m_view->getStartFrame();
31 } 31 }
32 virtual sv_frame_t getCentreFrame() const { 32 virtual sv_frame_t getCentreFrame() const {
33 return m_view->getCentreFrame(); 33 return m_view->getCentreFrame();
34 } 34 }
35 virtual sv_frame_t getEndFrame() const { 35 virtual sv_frame_t getEndFrame() const {
36 return m_view->getEndFrame(); 36 return m_view->getEndFrame();
37 } 37 }
38 virtual int getXForFrame(sv_frame_t frame) const { 38 virtual int getXForFrame(sv_frame_t frame) const {
39 //!!! not actually correct, if frame lies between view's pixels 39 //!!! not actually correct, if frame lies between view's pixels
40 return m_scaleFactor * m_view->getXForFrame(frame); 40 return m_scaleFactor * m_view->getXForFrame(frame);
41 } 41 }
42 virtual sv_frame_t getFrameForX(int x) const { 42 virtual sv_frame_t getFrameForX(int x) const {
43 sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); 43 sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor);
44 if (m_scaleFactor == 1) return f0; 44 if (m_scaleFactor == 1) return f0;
45 sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1); 45 sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1);
50 } 50 }
51 virtual int getViewXForX(int x) const { 51 virtual int getViewXForX(int x) const {
52 return x / m_scaleFactor; 52 return x / m_scaleFactor;
53 } 53 }
54 virtual sv_frame_t getModelsStartFrame() const { 54 virtual sv_frame_t getModelsStartFrame() const {
55 return m_view->getModelsStartFrame(); 55 return m_view->getModelsStartFrame();
56 } 56 }
57 virtual sv_frame_t getModelsEndFrame() const { 57 virtual sv_frame_t getModelsEndFrame() const {
58 return m_view->getModelsEndFrame(); 58 return m_view->getModelsEndFrame();
59 } 59 }
60 virtual double getYForFrequency(double frequency, 60 virtual double getYForFrequency(double frequency,
61 double minFreq, double maxFreq, 61 double minFreq, double maxFreq,
62 bool logarithmic) const { 62 bool logarithmic) const {
63 return m_scaleFactor * 63 return m_scaleFactor *
64 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); 64 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic);
65 } 65 }
66 virtual double getFrequencyForY(double y, double minFreq, double maxFreq, 66 virtual double getFrequencyForY(double y, double minFreq, double maxFreq,
67 bool logarithmic) const { 67 bool logarithmic) const {
68 return m_view->getFrequencyForY 68 return m_view->getFrequencyForY
69 (y / m_scaleFactor, minFreq, maxFreq, logarithmic); 69 (y / m_scaleFactor, minFreq, maxFreq, logarithmic);
70 } 70 }
71 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { 71 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const {
72 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); 72 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint);
73 } 73 }
74 virtual bool getValueExtents(QString unit, double &min, double &max, 74 virtual bool getValueExtents(QString unit, double &min, double &max,
75 bool &log) const { 75 bool &log) const {
76 return m_view->getValueExtents(unit, min, max, log); 76 return m_view->getValueExtents(unit, min, max, log);
77 } 77 }
78 virtual int getZoomLevel() const { 78 virtual int getZoomLevel() const {
79 int z = m_view->getZoomLevel(); 79 int z = m_view->getZoomLevel();
80 // cerr << "getZoomLevel: from " << z << " to "; 80 // cerr << "getZoomLevel: from " << z << " to ";
81 z = z / m_scaleFactor; 81 z = z / m_scaleFactor;
82 // cerr << z << endl; 82 // cerr << z << endl;
83 if (z < 1) z = 1; 83 if (z < 1) z = 1;
84 return z; 84 return z;
85 } 85 }
86 virtual QRect getPaintRect() const { 86 virtual QRect getPaintRect() const {
87 QRect r = m_view->getPaintRect(); 87 QRect r = m_view->getPaintRect();
88 return QRect(r.x() * m_scaleFactor, 88 return QRect(r.x() * m_scaleFactor,
89 r.y() * m_scaleFactor, 89 r.y() * m_scaleFactor,
90 r.width() * m_scaleFactor, 90 r.width() * m_scaleFactor,
91 r.height() * m_scaleFactor); 91 r.height() * m_scaleFactor);
92 } 92 }
93 virtual QSize getPaintSize() const { 93 virtual QSize getPaintSize() const {
94 return getPaintRect().size(); 94 return getPaintRect().size();
95 } 95 }
96 virtual int getPaintWidth() const { 96 virtual int getPaintWidth() const {
98 } 98 }
99 virtual int getPaintHeight() const { 99 virtual int getPaintHeight() const {
100 return getPaintRect().height(); 100 return getPaintRect().height();
101 } 101 }
102 virtual bool hasLightBackground() const { 102 virtual bool hasLightBackground() const {
103 return m_view->hasLightBackground(); 103 return m_view->hasLightBackground();
104 } 104 }
105 virtual QColor getForeground() const { 105 virtual QColor getForeground() const {
106 return m_view->getForeground(); 106 return m_view->getForeground();
107 } 107 }
108 virtual QColor getBackground() const { 108 virtual QColor getBackground() const {
109 return m_view->getBackground(); 109 return m_view->getBackground();
110 } 110 }
111 virtual ViewManager *getViewManager() const { 111 virtual ViewManager *getViewManager() const {
112 return m_view->getViewManager(); 112 return m_view->getViewManager();
113 } 113 }
114 114
115 virtual bool shouldIlluminateLocalFeatures(const Layer *layer, 115 virtual bool shouldIlluminateLocalFeatures(const Layer *layer,
116 QPoint &point) const { 116 QPoint &point) const {
117 QPoint p; 117 QPoint p;
118 bool should = m_view->shouldIlluminateLocalFeatures(layer, p); 118 bool should = m_view->shouldIlluminateLocalFeatures(layer, p);
119 point = QPoint(p.x() * m_scaleFactor, p.y() * m_scaleFactor); 119 point = QPoint(p.x() * m_scaleFactor, p.y() * m_scaleFactor);
120 return should; 120 return should;
121 } 121 }
122 122
123 virtual bool shouldShowFeatureLabels() const { 123 virtual bool shouldShowFeatureLabels() const {
124 return m_view->shouldShowFeatureLabels(); 124 return m_view->shouldShowFeatureLabels();
125 } 125 }
126 126
127 virtual void drawMeasurementRect(QPainter &p, const Layer *layer, 127 virtual void drawMeasurementRect(QPainter &p, const Layer *layer,
128 QRect rect, bool focus) const { 128 QRect rect, bool focus) const {
129 m_view->drawMeasurementRect(p, layer, rect, focus); 129 m_view->drawMeasurementRect(p, layer, rect, focus);
130 } 130 }
131 131
132 virtual void updatePaintRect(QRect r) { 132 virtual void updatePaintRect(QRect r) {
133 m_view->update(r.x() / m_scaleFactor, 133 m_view->update(r.x() / m_scaleFactor,
134 r.y() / m_scaleFactor, 134 r.y() / m_scaleFactor,