Mercurial > hg > svgui
comparison view/Overview.cpp @ 642:2c35737cd3f8
Debug -- overview centre frame relocation is not currently working with qt5
author | Chris Cannam |
---|---|
date | Wed, 15 May 2013 22:15:49 +0100 |
parents | 4806715f7a19 |
children | 77fa3fdbfc7e |
comparison
equal
deleted
inserted
replaced
641:28973ecd4a55 | 642:2c35737cd3f8 |
---|---|
19 #include "base/ZoomConstraint.h" | 19 #include "base/ZoomConstraint.h" |
20 | 20 |
21 #include <QPaintEvent> | 21 #include <QPaintEvent> |
22 #include <QPainter> | 22 #include <QPainter> |
23 #include <iostream> | 23 #include <iostream> |
24 | |
25 #define DEBUG_OVERVIEW 1 | |
24 | 26 |
25 using std::cerr; | 27 using std::cerr; |
26 using std::endl; | 28 using std::endl; |
27 | 29 |
28 Overview::Overview(QWidget *w) : | 30 Overview::Overview(QWidget *w) : |
88 m_views.erase(view); | 90 m_views.erase(view); |
89 update(); | 91 update(); |
90 } | 92 } |
91 | 93 |
92 void | 94 void |
93 Overview::globalCentreFrameChanged(unsigned long) | 95 Overview::globalCentreFrameChanged(unsigned long f) |
94 { | 96 { |
97 #ifdef DEBUG_OVERVIEW | |
98 std::cerr << "Overview::globalCentreFrameChanged: " << f << std::endl; | |
99 #endif | |
95 update(); | 100 update(); |
96 } | 101 } |
97 | 102 |
98 void | 103 void |
99 Overview::viewCentreFrameChanged(View *v, unsigned long) | 104 Overview::viewCentreFrameChanged(View *v, unsigned long f) |
100 { | 105 { |
106 #ifdef DEBUG_OVERVIEW | |
107 std::cerr << "Overview[" << this << "]::viewCentreFrameChanged(" << v << "): " << f << std::endl; | |
108 #endif | |
101 if (m_views.find(v) != m_views.end()) { | 109 if (m_views.find(v) != m_views.end()) { |
102 update(); | 110 update(); |
103 } | 111 } |
104 } | 112 } |
105 | 113 |
113 } | 121 } |
114 | 122 |
115 void | 123 void |
116 Overview::viewManagerPlaybackFrameChanged(unsigned long f) | 124 Overview::viewManagerPlaybackFrameChanged(unsigned long f) |
117 { | 125 { |
126 #ifdef DEBUG_OVERVIEW | |
127 std::cerr << "Overview[" << this << "]::viewManagerPlaybackFrameChanged(" << f << "): " << f << std::endl; | |
128 #endif | |
129 | |
118 bool changed = false; | 130 bool changed = false; |
119 | 131 |
120 f = getAlignedPlaybackFrame(); | 132 f = getAlignedPlaybackFrame(); |
121 | 133 |
122 if (getXForFrame(m_playPointerFrame) != getXForFrame(f)) changed = true; | 134 if (getXForFrame(m_playPointerFrame) != getXForFrame(f)) changed = true; |
128 void | 140 void |
129 Overview::paintEvent(QPaintEvent *e) | 141 Overview::paintEvent(QPaintEvent *e) |
130 { | 142 { |
131 // Recalculate zoom in case the size of the widget has changed. | 143 // Recalculate zoom in case the size of the widget has changed. |
132 | 144 |
133 // SVDEBUG << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << endl; | 145 #ifdef DEBUG_OVERVIEW |
146 std::cerr << "Overview::paintEvent: width is " << width() << ", centre frame " << m_centreFrame << std::endl; | |
147 #endif | |
134 | 148 |
135 size_t startFrame = getModelsStartFrame(); | 149 size_t startFrame = getModelsStartFrame(); |
136 size_t frameCount = getModelsEndFrame() - getModelsStartFrame(); | 150 size_t frameCount = getModelsEndFrame() - getModelsStartFrame(); |
137 int zoomLevel = frameCount / width(); | 151 int zoomLevel = frameCount / width(); |
138 if (zoomLevel < 1) zoomLevel = 1; | 152 if (zoomLevel < 1) zoomLevel = 1; |
146 size_t centreFrame = startFrame + m_zoomLevel * (width() / 2); | 160 size_t centreFrame = startFrame + m_zoomLevel * (width() / 2); |
147 if (centreFrame > (startFrame + getModelsEndFrame())/2) { | 161 if (centreFrame > (startFrame + getModelsEndFrame())/2) { |
148 centreFrame = (startFrame + getModelsEndFrame())/2; | 162 centreFrame = (startFrame + getModelsEndFrame())/2; |
149 } | 163 } |
150 if (centreFrame != m_centreFrame) { | 164 if (centreFrame != m_centreFrame) { |
151 // SVDEBUG << "Overview::paintEvent: Centre frame changed from " | 165 #ifdef DEBUG_OVERVIEW |
152 // << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); | 166 std::cerr << "Overview::paintEvent: Centre frame changed from " |
167 << m_centreFrame << " to " << centreFrame << " and thus start frame from " << getStartFrame(); | |
168 #endif | |
153 m_centreFrame = centreFrame; | 169 m_centreFrame = centreFrame; |
154 // SVDEBUG << " to " << getStartFrame() << endl; | 170 #ifdef DEBUG_OVERVIEW |
171 std::cerr << " to " << getStartFrame() << std::endl; | |
172 #endif | |
155 emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); | 173 emit centreFrameChanged(m_centreFrame, false, PlaybackIgnore); |
156 } | 174 } |
157 | 175 |
158 View::paintEvent(e); | 176 View::paintEvent(e); |
159 | 177 |