comparison layer/SpectrogramLayer.cpp @ 264:7e9e533f1863

* few more measurement mode bits
author Chris Cannam
date Fri, 15 Jun 2007 12:55:16 +0000
parents 11021509c4eb
children 4ed1446ad604
comparison
equal deleted inserted replaced
263:16fffa24da02 264:7e9e533f1863
2498 2498
2499 return true; 2499 return true;
2500 } 2500 }
2501 2501
2502 bool 2502 bool
2503 SpectrogramLayer::getCrosshairExtents(View *v, QPainter &, 2503 SpectrogramLayer::getCrosshairExtents(View *v, QPainter &paint,
2504 QPoint cursorPos, 2504 QPoint cursorPos,
2505 std::vector<QRect> &extents) const 2505 std::vector<QRect> &extents) const
2506 { 2506 {
2507 QRect vertical(cursorPos.x() - 12, 0, 12, v->height()); 2507 QRect vertical(cursorPos.x() - 12, 0, 12, v->height());
2508 extents.push_back(vertical); 2508 extents.push_back(vertical);
2509 2509
2510 QRect horizontal(0, cursorPos.y(), cursorPos.x(), 1); 2510 QRect horizontal(0, cursorPos.y(), cursorPos.x(), 1);
2511 extents.push_back(horizontal); 2511 extents.push_back(horizontal);
2512 2512
2513 int sw = getVerticalScaleWidth(v, paint);
2514
2515 QRect label(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
2516 paint.fontMetrics().width("123456 Hz") + sw + 2,
2517 paint.fontMetrics().height());
2518 extents.push_back(label);
2519
2513 return true; 2520 return true;
2514 } 2521 }
2515 2522
2516 void 2523 void
2517 SpectrogramLayer::paintCrosshairs(View *v, QPainter &paint, 2524 SpectrogramLayer::paintCrosshairs(View *v, QPainter &paint,
2522 2529
2523 paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y()); 2530 paint.drawLine(0, cursorPos.y(), cursorPos.x() - 1, cursorPos.y());
2524 paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->height()); 2531 paint.drawLine(cursorPos.x(), 0, cursorPos.x(), v->height());
2525 2532
2526 float fundamental = getFrequencyForY(v, cursorPos.y()); 2533 float fundamental = getFrequencyForY(v, cursorPos.y());
2534
2535 int sw = getVerticalScaleWidth(v, paint);
2536 paint.drawText(sw + 2, cursorPos.y() - 2, QString("%1 Hz").arg(fundamental));
2527 2537
2528 int harmonic = 2; 2538 int harmonic = 2;
2529 2539
2530 while (harmonic < 100) { 2540 while (harmonic < 100) {
2531 2541