comparison layer/TimeRulerLayer.cpp @ 1021:33d7e1a6747b colourschemes

Some debug
author Chris Cannam
date Fri, 22 Jan 2016 15:17:25 +0000
parents 2adca8f05583
children ee01a4062747
comparison
equal deleted inserted replaced
1020:69c4f8403ebf 1021:33d7e1a6747b
24 24
25 #include <QPainter> 25 #include <QPainter>
26 26
27 #include <iostream> 27 #include <iostream>
28 #include <cmath> 28 #include <cmath>
29 #include <stdexcept>
29 30
30 //#define DEBUG_TIME_RULER_LAYER 1 31 //#define DEBUG_TIME_RULER_LAYER 1
31
32
33 32
34 33
35 TimeRulerLayer::TimeRulerLayer() : 34 TimeRulerLayer::TimeRulerLayer() :
36 SingleColourLayer(), 35 SingleColourLayer(),
37 m_model(0), 36 m_model(0),
180 quarterTicks = false; 179 quarterTicks = false;
181 } 180 }
182 } else { 181 } else {
183 incms = 1; 182 incms = 1;
184 int ms = rtGap.msec(); 183 int ms = rtGap.msec();
184 // cerr << "rtGap.msec = " << ms << ", rtGap = " << rtGap << ", count = " << count << endl;
185 // cerr << "startFrame = " << startFrame << ", endFrame = " << endFrame << " rtStart = " << rtStart << ", rtEnd = " << rtEnd << endl;
185 if (ms > 0) { incms *= 10; ms /= 10; } 186 if (ms > 0) { incms *= 10; ms /= 10; }
186 if (ms > 0) { incms *= 10; ms /= 10; } 187 if (ms > 0) { incms *= 10; ms /= 10; }
187 if (ms > 0) { incms *= 5; ms /= 5; } 188 if (ms > 0) { incms *= 5; ms /= 5; }
188 if (ms > 0) { incms *= 2; ms /= 2; } 189 if (ms > 0) { incms *= 2; ms /= 2; }
189 } 190 }
239 240
240 // Do not label time zero - we now overlay an opaque area over 241 // Do not label time zero - we now overlay an opaque area over
241 // time < 0 which would cut it in half 242 // time < 0 which would cut it in half
242 int minlabel = 1; // ms 243 int minlabel = 1; // ms
243 244
245 // used for a sanity check
246 sv_frame_t prevframe = 0;
247
244 while (1) { 248 while (1) {
245 249
246 // frame is used to determine where to draw the lines, so it 250 // frame is used to determine where to draw the lines, so it
247 // needs to correspond to an exact pixel (so that we don't get 251 // needs to correspond to an exact pixel (so that we don't get
248 // a different pixel when scrolling a small amount and 252 // a different pixel when scrolling a small amount and
251 double dms = ms; 255 double dms = ms;
252 sv_frame_t frame = lrint((dms * sampleRate) / 1000.0); 256 sv_frame_t frame = lrint((dms * sampleRate) / 1000.0);
253 frame /= v->getZoomLevel(); 257 frame /= v->getZoomLevel();
254 frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel 258 frame *= v->getZoomLevel(); // so frame corresponds to an exact pixel
255 259
260 if (frame == prevframe && prevframe != 0) {
261 cerr << "ERROR: frame == prevframe (== " << frame
262 << ") in TimeRulerLayer::paint" << endl;
263 throw std::logic_error("frame == prevframe in TimeRulerLayer::paint");
264 }
265 prevframe = frame;
266
256 int x = v->getXForFrame(frame); 267 int x = v->getXForFrame(frame);
257 268
258 #ifdef DEBUG_TIME_RULER_LAYER 269 #ifdef DEBUG_TIME_RULER_LAYER
259 SVDEBUG << "Considering frame = " << frame << ", x = " << x << endl; 270 cerr << "Considering frame = " << frame << ", x = " << x << endl;
260 #endif 271 #endif
261 272
262 if (x >= rect.x() + rect.width() + 50) { 273 if (x >= rect.x() + rect.width() + 50) {
263 #ifdef DEBUG_TIME_RULER_LAYER 274 #ifdef DEBUG_TIME_RULER_LAYER
264 cerr << "X well out of range, ending here" << endl; 275 cerr << "X well out of range, ending here" << endl;