comparison layer/TimeRulerLayer.cpp @ 682:1a0dfcbffaf1

Drop std:: from cout, cerr, endl -- pull these in through Debug.h
author Chris Cannam
date Tue, 26 Nov 2013 14:06:40 +0000
parents 4806715f7a19
children 1d526ba11a24
comparison
equal deleted inserted replaced
681:eaf4446a1bef 682:1a0dfcbffaf1
27 #include <iostream> 27 #include <iostream>
28 #include <cmath> 28 #include <cmath>
29 29
30 //#define DEBUG_TIME_RULER_LAYER 1 30 //#define DEBUG_TIME_RULER_LAYER 1
31 31
32 using std::cerr; 32
33 using std::endl; 33
34 34
35 TimeRulerLayer::TimeRulerLayer() : 35 TimeRulerLayer::TimeRulerLayer() :
36 SingleColourLayer(), 36 SingleColourLayer(),
37 m_model(0), 37 m_model(0),
38 m_labelHeight(LabelTop) 38 m_labelHeight(LabelTop)
205 if (!sampleRate) return; 205 if (!sampleRate) return;
206 206
207 long startFrame = v->getFrameForX(rect.x() - 50); 207 long startFrame = v->getFrameForX(rect.x() - 50);
208 208
209 #ifdef DEBUG_TIME_RULER_LAYER 209 #ifdef DEBUG_TIME_RULER_LAYER
210 std::cerr << "start frame = " << startFrame << std::endl; 210 cerr << "start frame = " << startFrame << endl;
211 #endif 211 #endif
212 212
213 bool quarter = false; 213 bool quarter = false;
214 int incms = getMajorTickSpacing(v, quarter); 214 int incms = getMajorTickSpacing(v, quarter);
215 215
216 int ms = lrint(1000.0 * (double(startFrame) / double(sampleRate))); 216 int ms = lrint(1000.0 * (double(startFrame) / double(sampleRate)));
217 ms = (ms / incms) * incms - incms; 217 ms = (ms / incms) * incms - incms;
218 218
219 #ifdef DEBUG_TIME_RULER_LAYER 219 #ifdef DEBUG_TIME_RULER_LAYER
220 std::cerr << "start ms = " << ms << " at step " << incms << std::endl; 220 cerr << "start ms = " << ms << " at step " << incms << endl;
221 #endif 221 #endif
222 222
223 // Calculate the number of ticks per increment -- approximate 223 // Calculate the number of ticks per increment -- approximate
224 // values for x and frame counts here will do, no rounding issue. 224 // values for x and frame counts here will do, no rounding issue.
225 // We always use the exact incms in our calculations for where to 225 // We always use the exact incms in our calculations for where to
255 SVDEBUG << "Considering frame = " << frame << ", x = " << x << endl; 255 SVDEBUG << "Considering frame = " << frame << ", x = " << x << endl;
256 #endif 256 #endif
257 257
258 if (x >= rect.x() + rect.width() + 50) { 258 if (x >= rect.x() + rect.width() + 50) {
259 #ifdef DEBUG_TIME_RULER_LAYER 259 #ifdef DEBUG_TIME_RULER_LAYER
260 std::cerr << "X well out of range, ending here" << std::endl; 260 cerr << "X well out of range, ending here" << endl;
261 #endif 261 #endif
262 break; 262 break;
263 } 263 }
264 264
265 if (x >= rect.x() - 50) { 265 if (x >= rect.x() - 50) {
266 266
267 RealTime rt = RealTime::fromMilliseconds(ms); 267 RealTime rt = RealTime::fromMilliseconds(ms);
268 268
269 #ifdef DEBUG_TIME_RULER_LAYER 269 #ifdef DEBUG_TIME_RULER_LAYER
270 std::cerr << "X in range, drawing line here for time " << rt.toText() << std::endl; 270 cerr << "X in range, drawing line here for time " << rt.toText() << endl;
271 #endif 271 #endif
272 272
273 QString text(QString::fromStdString(rt.toText())); 273 QString text(QString::fromStdString(rt.toText()));
274 QFontMetrics metrics = paint.fontMetrics(); 274 QFontMetrics metrics = paint.fontMetrics();
275 int tw = metrics.width(text); 275 int tw = metrics.width(text);
276 276
277 if (tw < 50 && 277 if (tw < 50 &&
278 (x < rect.x() - tw/2 || 278 (x < rect.x() - tw/2 ||
279 x >= rect.x() + rect.width() + tw/2)) { 279 x >= rect.x() + rect.width() + tw/2)) {
280 #ifdef DEBUG_TIME_RULER_LAYER 280 #ifdef DEBUG_TIME_RULER_LAYER
281 std::cerr << "hm, maybe X isn't in range after all (x = " << x << ", tw = " << tw << ", rect.x() = " << rect.x() << ", rect.width() = " << rect.width() << ")" << std::endl; 281 cerr << "hm, maybe X isn't in range after all (x = " << x << ", tw = " << tw << ", rect.x() = " << rect.x() << ", rect.width() = " << rect.width() << ")" << endl;
282 #endif 282 #endif
283 } 283 }
284 284
285 paint.setPen(greyColour); 285 paint.setPen(greyColour);
286 paint.drawLine(x, 0, x, v->height()); 286 paint.drawLine(x, 0, x, v->height());
325 325
326 x = v->getXForFrame(frame); 326 x = v->getXForFrame(frame);
327 327
328 if (x < rect.x() || x >= rect.x() + rect.width()) { 328 if (x < rect.x() || x >= rect.x() + rect.width()) {
329 #ifdef DEBUG_TIME_RULER_LAYER 329 #ifdef DEBUG_TIME_RULER_LAYER
330 // std::cerr << "tick " << i << ": X out of range, going on to next tick" << std::endl; 330 // cerr << "tick " << i << ": X out of range, going on to next tick" << endl;
331 #endif 331 #endif
332 continue; 332 continue;
333 } 333 }
334 334
335 #ifdef DEBUG_TIME_RULER_LAYER 335 #ifdef DEBUG_TIME_RULER_LAYER
336 std::cerr << "tick " << i << " in range, drawing at " << x << std::endl; 336 cerr << "tick " << i << " in range, drawing at " << x << endl;
337 #endif 337 #endif
338 338
339 int sz = 5; 339 int sz = 5;
340 if (ticks == 10) { 340 if (ticks == 10) {
341 if ((i % 2) == 1) { 341 if ((i % 2) == 1) {