Mercurial > hg > svgui
comparison view/ViewProxy.h @ 1406:a18e78b9c78b fix-static-analysis
Use override throughout
author | Chris Cannam |
---|---|
date | Mon, 26 Nov 2018 13:52:27 +0000 |
parents | b0eeec95ab5b |
children | c83504eb2649 |
comparison
equal
deleted
inserted
replaced
1405:4c359c2b220c | 1406:a18e78b9c78b |
---|---|
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 int getId() const override { |
27 return m_view->getId(); | 27 return m_view->getId(); |
28 } | 28 } |
29 virtual sv_frame_t getStartFrame() const { | 29 sv_frame_t getStartFrame() const override { |
30 return m_view->getStartFrame(); | 30 return m_view->getStartFrame(); |
31 } | 31 } |
32 virtual sv_frame_t getCentreFrame() const { | 32 sv_frame_t getCentreFrame() const override { |
33 return m_view->getCentreFrame(); | 33 return m_view->getCentreFrame(); |
34 } | 34 } |
35 virtual sv_frame_t getEndFrame() const { | 35 sv_frame_t getEndFrame() const override { |
36 return m_view->getEndFrame(); | 36 return m_view->getEndFrame(); |
37 } | 37 } |
38 virtual int getXForFrame(sv_frame_t frame) const { | 38 int getXForFrame(sv_frame_t frame) const override { |
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 sv_frame_t getFrameForX(int x) const override { |
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); |
46 return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; | 46 return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; |
47 } | 47 } |
48 virtual int getXForViewX(int viewx) const { | 48 int getXForViewX(int viewx) const override { |
49 return viewx * m_scaleFactor; | 49 return viewx * m_scaleFactor; |
50 } | 50 } |
51 virtual int getViewXForX(int x) const { | 51 int getViewXForX(int x) const override { |
52 return x / m_scaleFactor; | 52 return x / m_scaleFactor; |
53 } | 53 } |
54 virtual sv_frame_t getModelsStartFrame() const { | 54 sv_frame_t getModelsStartFrame() const override { |
55 return m_view->getModelsStartFrame(); | 55 return m_view->getModelsStartFrame(); |
56 } | 56 } |
57 virtual sv_frame_t getModelsEndFrame() const { | 57 sv_frame_t getModelsEndFrame() const override { |
58 return m_view->getModelsEndFrame(); | 58 return m_view->getModelsEndFrame(); |
59 } | 59 } |
60 virtual double getYForFrequency(double frequency, | 60 double getYForFrequency(double frequency, |
61 double minFreq, double maxFreq, | 61 double minFreq, double maxFreq, |
62 bool logarithmic) const { | 62 bool logarithmic) const override { |
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 double getFrequencyForY(double y, double minFreq, double maxFreq, |
67 bool logarithmic) const { | 67 bool logarithmic) const override { |
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 int getTextLabelHeight(const Layer *layer, QPainter &paint) const override { |
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 bool getValueExtents(QString unit, double &min, double &max, |
75 bool &log) const { | 75 bool &log) const override { |
76 return m_view->getValueExtents(unit, min, max, log); | 76 return m_view->getValueExtents(unit, min, max, log); |
77 } | 77 } |
78 virtual ZoomLevel getZoomLevel() const { | 78 ZoomLevel getZoomLevel() const override { |
79 ZoomLevel z = m_view->getZoomLevel(); | 79 ZoomLevel z = m_view->getZoomLevel(); |
80 //!!! | 80 //!!! |
81 // cerr << "getZoomLevel: from " << z << " to "; | 81 // cerr << "getZoomLevel: from " << z << " to "; |
82 if (z.zone == ZoomLevel::FramesPerPixel) { | 82 if (z.zone == ZoomLevel::FramesPerPixel) { |
83 z.level /= m_scaleFactor; | 83 z.level /= m_scaleFactor; |
89 z.level *= m_scaleFactor; | 89 z.level *= m_scaleFactor; |
90 } | 90 } |
91 // cerr << z << endl; | 91 // cerr << z << endl; |
92 return z; | 92 return z; |
93 } | 93 } |
94 virtual QRect getPaintRect() const { | 94 QRect getPaintRect() const override { |
95 QRect r = m_view->getPaintRect(); | 95 QRect r = m_view->getPaintRect(); |
96 return QRect(r.x() * m_scaleFactor, | 96 return QRect(r.x() * m_scaleFactor, |
97 r.y() * m_scaleFactor, | 97 r.y() * m_scaleFactor, |
98 r.width() * m_scaleFactor, | 98 r.width() * m_scaleFactor, |
99 r.height() * m_scaleFactor); | 99 r.height() * m_scaleFactor); |
100 } | 100 } |
101 virtual QSize getPaintSize() const { | 101 QSize getPaintSize() const override { |
102 return getPaintRect().size(); | 102 return getPaintRect().size(); |
103 } | 103 } |
104 virtual int getPaintWidth() const { | 104 int getPaintWidth() const override { |
105 return getPaintRect().width(); | 105 return getPaintRect().width(); |
106 } | 106 } |
107 virtual int getPaintHeight() const { | 107 int getPaintHeight() const override { |
108 return getPaintRect().height(); | 108 return getPaintRect().height(); |
109 } | 109 } |
110 virtual bool hasLightBackground() const { | 110 bool hasLightBackground() const override { |
111 return m_view->hasLightBackground(); | 111 return m_view->hasLightBackground(); |
112 } | 112 } |
113 virtual QColor getForeground() const { | 113 QColor getForeground() const override { |
114 return m_view->getForeground(); | 114 return m_view->getForeground(); |
115 } | 115 } |
116 virtual QColor getBackground() const { | 116 QColor getBackground() const override { |
117 return m_view->getBackground(); | 117 return m_view->getBackground(); |
118 } | 118 } |
119 virtual ViewManager *getViewManager() const { | 119 ViewManager *getViewManager() const override { |
120 return m_view->getViewManager(); | 120 return m_view->getViewManager(); |
121 } | 121 } |
122 | 122 |
123 virtual bool shouldIlluminateLocalFeatures(const Layer *layer, | 123 bool shouldIlluminateLocalFeatures(const Layer *layer, |
124 QPoint &point) const { | 124 QPoint &point) const override { |
125 QPoint p; | 125 QPoint p; |
126 bool should = m_view->shouldIlluminateLocalFeatures(layer, p); | 126 bool should = m_view->shouldIlluminateLocalFeatures(layer, p); |
127 point = QPoint(p.x() * m_scaleFactor, p.y() * m_scaleFactor); | 127 point = QPoint(p.x() * m_scaleFactor, p.y() * m_scaleFactor); |
128 return should; | 128 return should; |
129 } | 129 } |
130 | 130 |
131 virtual bool shouldShowFeatureLabels() const { | 131 bool shouldShowFeatureLabels() const override { |
132 return m_view->shouldShowFeatureLabels(); | 132 return m_view->shouldShowFeatureLabels(); |
133 } | 133 } |
134 | 134 |
135 virtual void drawMeasurementRect(QPainter &p, const Layer *layer, | 135 void drawMeasurementRect(QPainter &p, const Layer *layer, |
136 QRect rect, bool focus) const { | 136 QRect rect, bool focus) const override { |
137 m_view->drawMeasurementRect(p, layer, rect, focus); | 137 m_view->drawMeasurementRect(p, layer, rect, focus); |
138 } | 138 } |
139 | 139 |
140 virtual void updatePaintRect(QRect r) { | 140 void updatePaintRect(QRect r) override { |
141 m_view->update(r.x() / m_scaleFactor, | 141 m_view->update(r.x() / m_scaleFactor, |
142 r.y() / m_scaleFactor, | 142 r.y() / m_scaleFactor, |
143 r.width() / m_scaleFactor, | 143 r.width() / m_scaleFactor, |
144 r.height() / m_scaleFactor); | 144 r.height() / m_scaleFactor); |
145 } | 145 } |
149 * doubling. This is like ViewManager::scalePixelSize, but taking | 149 * doubling. This is like ViewManager::scalePixelSize, but taking |
150 * and returning floating-point values rather than integer | 150 * and returning floating-point values rather than integer |
151 * pixels. It is also a little more conservative - it never | 151 * pixels. It is also a little more conservative - it never |
152 * shrinks the size, it can only increase or leave it unchanged. | 152 * shrinks the size, it can only increase or leave it unchanged. |
153 */ | 153 */ |
154 virtual double scaleSize(double size) const { | 154 double scaleSize(double size) const override { |
155 return m_view->scaleSize(size * m_scaleFactor); | 155 return m_view->scaleSize(size * m_scaleFactor); |
156 } | 156 } |
157 | 157 |
158 /** | 158 /** |
159 * Integer version of scaleSize. | 159 * Integer version of scaleSize. |
160 */ | 160 */ |
161 virtual int scalePixelSize(int size) const { | 161 int scalePixelSize(int size) const override { |
162 return m_view->scalePixelSize(size * m_scaleFactor); | 162 return m_view->scalePixelSize(size * m_scaleFactor); |
163 } | 163 } |
164 | 164 |
165 /** | 165 /** |
166 * Scale up pen width for a hi-dpi display without pixel doubling. | 166 * Scale up pen width for a hi-dpi display without pixel doubling. |
167 * This is like scaleSize except that it also scales the | 167 * This is like scaleSize except that it also scales the |
168 * zero-width case. | 168 * zero-width case. |
169 */ | 169 */ |
170 virtual double scalePenWidth(double width) const { | 170 double scalePenWidth(double width) const override { |
171 if (width <= 0) { // zero-width pen, produce a scaled one-pixel pen | 171 if (width <= 0) { // zero-width pen, produce a scaled one-pixel pen |
172 width = 1; | 172 width = 1; |
173 } | 173 } |
174 width *= sqrt(double(m_scaleFactor)); | 174 width *= sqrt(double(m_scaleFactor)); |
175 return m_view->scalePenWidth(width); | 175 return m_view->scalePenWidth(width); |
176 } | 176 } |
177 | 177 |
178 /** | 178 /** |
179 * Apply scalePenWidth to a pen. | 179 * Apply scalePenWidth to a pen. |
180 */ | 180 */ |
181 virtual QPen scalePen(QPen pen) const { | 181 QPen scalePen(QPen pen) const override { |
182 return QPen(pen.color(), scalePenWidth(pen.width())); | 182 return QPen(pen.color(), scalePenWidth(pen.width())); |
183 } | 183 } |
184 | 184 |
185 virtual View *getView() { return m_view; } | 185 View *getView() override { return m_view; } |
186 virtual const View *getView() const { return m_view; } | 186 const View *getView() const override { return m_view; } |
187 | 187 |
188 private: | 188 private: |
189 View *m_view; | 189 View *m_view; |
190 int m_scaleFactor; | 190 int m_scaleFactor; |
191 }; | 191 }; |