Mercurial > hg > svgui
comparison view/ViewProxy.h @ 1148:c0d841cb8ab9 tony-2.0-integration
Merge latest SV 3.0 branch code
author | Chris Cannam |
---|---|
date | Fri, 19 Aug 2016 15:58:57 +0100 |
parents | 179ea8a2f650 |
children | a34a2a25907c |
comparison
equal
deleted
inserted
replaced
1009:96cf499fad62 | 1148:c0d841cb8ab9 |
---|---|
13 */ | 13 */ |
14 | 14 |
15 #ifndef VIEW_PROXY_H | 15 #ifndef VIEW_PROXY_H |
16 #define VIEW_PROXY_H | 16 #define VIEW_PROXY_H |
17 | 17 |
18 #include "LayerGeometryProvider.h" | 18 #include "layer/LayerGeometryProvider.h" |
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 { | |
27 return m_view->getId(); | |
28 } | |
26 virtual sv_frame_t getStartFrame() const { | 29 virtual sv_frame_t getStartFrame() const { |
27 return m_view->getStartFrame(); | 30 return m_view->getStartFrame(); |
28 } | 31 } |
29 virtual sv_frame_t getCentreFrame() const { | 32 virtual sv_frame_t getCentreFrame() const { |
30 return m_view->getCentreFrame(); | 33 return m_view->getCentreFrame(); |
40 sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); | 43 sv_frame_t f0 = m_view->getFrameForX(x / m_scaleFactor); |
41 if (m_scaleFactor == 1) return f0; | 44 if (m_scaleFactor == 1) return f0; |
42 sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1); | 45 sv_frame_t f1 = m_view->getFrameForX((x / m_scaleFactor) + 1); |
43 return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; | 46 return f0 + ((f1 - f0) * (x % m_scaleFactor)) / m_scaleFactor; |
44 } | 47 } |
48 virtual int getXForViewX(int viewx) const { | |
49 return viewx * m_scaleFactor; | |
50 } | |
51 virtual int getViewXForX(int x) const { | |
52 return x / m_scaleFactor; | |
53 } | |
45 virtual sv_frame_t getModelsStartFrame() const { | 54 virtual sv_frame_t getModelsStartFrame() const { |
46 return m_view->getModelsStartFrame(); | 55 return m_view->getModelsStartFrame(); |
47 } | 56 } |
48 virtual sv_frame_t getModelsEndFrame() const { | 57 virtual sv_frame_t getModelsEndFrame() const { |
49 return m_view->getModelsEndFrame(); | 58 return m_view->getModelsEndFrame(); |
52 double minFreq, double maxFreq, | 61 double minFreq, double maxFreq, |
53 bool logarithmic) const { | 62 bool logarithmic) const { |
54 return m_scaleFactor * | 63 return m_scaleFactor * |
55 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); | 64 m_view->getYForFrequency(frequency, minFreq, maxFreq, logarithmic); |
56 } | 65 } |
57 virtual double getFrequencyForY(int y, double minFreq, double maxFreq, | 66 virtual double getFrequencyForY(double y, double minFreq, double maxFreq, |
58 bool logarithmic) const { | 67 bool logarithmic) const { |
59 double f0 = m_view->getFrequencyForY | 68 return m_view->getFrequencyForY |
60 (y / m_scaleFactor, minFreq, maxFreq, logarithmic); | 69 (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; | |
65 } | 70 } |
66 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { | 71 virtual int getTextLabelHeight(const Layer *layer, QPainter &paint) const { |
67 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); | 72 return m_scaleFactor * m_view->getTextLabelHeight(layer, paint); |
68 } | 73 } |
69 virtual bool getValueExtents(QString unit, double &min, double &max, | 74 virtual bool getValueExtents(QString unit, double &min, double &max, |
117 | 122 |
118 virtual bool shouldShowFeatureLabels() const { | 123 virtual bool shouldShowFeatureLabels() const { |
119 return m_view->shouldShowFeatureLabels(); | 124 return m_view->shouldShowFeatureLabels(); |
120 } | 125 } |
121 | 126 |
122 virtual void drawVisibleText(QPainter &p, int x, int y, | |
123 QString text, TextStyle style) const { | |
124 m_view->drawVisibleText(p, x, y, text, style); | |
125 } | |
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) { | |
133 m_view->update(r.x() / m_scaleFactor, | |
134 r.y() / m_scaleFactor, | |
135 r.width() / m_scaleFactor, | |
136 r.height() / m_scaleFactor); | |
137 } | |
138 | |
132 virtual View *getView() { return m_view; } | 139 virtual View *getView() { return m_view; } |
133 virtual const View *getView() const { return m_view; } | 140 virtual const View *getView() const { return m_view; } |
134 | 141 |
135 private: | 142 private: |
136 View *m_view; | 143 View *m_view; |