comparison view/Pane.cpp @ 277:8acd30ed735c

* Fix up and simplify the LayerTreeModel, removing a horrible memory leak * Move phase-unwrapped frequency estimation from SpectrogramLayer to FFTDataServer * Make the spectrum show peak phase-unwrapped frequencies as well (still needs work) * Start adding piano keyboard horizontal scale to spectrum * Debug output for id3 tags
author Chris Cannam
date Tue, 03 Jul 2007 12:46:18 +0000
parents 21c7152ddba8
children 3c402c6052f6
comparison
equal deleted inserted replaced
276:21c7152ddba8 277:8acd30ed735c
395 } 395 }
396 } 396 }
397 } 397 }
398 398
399 Layer *topLayer = getTopLayer(); 399 Layer *topLayer = getTopLayer();
400 bool haveSomeTimeXAxis = false;
400 401
401 const Model *waveformModel = 0; // just for reporting purposes 402 const Model *waveformModel = 0; // just for reporting purposes
402 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) { 403 for (LayerList::iterator vi = m_layers.end(); vi != m_layers.begin(); ) {
403 --vi; 404 --vi;
405 if (!haveSomeTimeXAxis && (*vi)->hasTimeXAxis()) {
406 haveSomeTimeXAxis = true;
407 }
404 if (dynamic_cast<WaveformLayer *>(*vi)) { 408 if (dynamic_cast<WaveformLayer *>(*vi)) {
405 waveformModel = (*vi)->getModel(); 409 waveformModel = (*vi)->getModel();
406 break; 410 }
407 } 411 if (waveformModel && haveSomeTimeXAxis) break;
408 } 412 }
409 413
410 m_scaleWidth = 0; 414 m_scaleWidth = 0;
411 415
412 if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) { 416 if (m_manager && m_manager->shouldShowVerticalScale() && topLayer) {
421 paint.setBrush(Qt::NoBrush); 425 paint.setBrush(Qt::NoBrush);
422 426
423 if (m_centreLineVisible && 427 if (m_centreLineVisible &&
424 m_manager && 428 m_manager &&
425 m_manager->shouldShowCentreLine()) { 429 m_manager->shouldShowCentreLine()) {
426 drawCentreLine(sampleRate, paint); 430 drawCentreLine(sampleRate, paint, !haveSomeTimeXAxis);
427 } 431 }
428 432
429 paint.setPen(QColor(50, 50, 50)); 433 paint.setPen(QColor(50, 50, 50));
430 434
431 if (waveformModel && 435 if (waveformModel &&
626 paint.restore(); 630 paint.restore();
627 } 631 }
628 } 632 }
629 633
630 void 634 void
631 Pane::drawCentreLine(int sampleRate, QPainter &paint) 635 Pane::drawCentreLine(int sampleRate, QPainter &paint, bool omitLine)
632 { 636 {
633 int fontHeight = paint.fontMetrics().height(); 637 int fontHeight = paint.fontMetrics().height();
634 int fontAscent = paint.fontMetrics().ascent(); 638 int fontAscent = paint.fontMetrics().ascent();
635 639
636 QColor c = QColor(0, 0, 0); 640 QColor c = QColor(0, 0, 0);
637 if (!hasLightBackground()) { 641 if (!hasLightBackground()) {
638 c = QColor(240, 240, 240); 642 c = QColor(240, 240, 240);
639 } 643 }
644
640 paint.setPen(c); 645 paint.setPen(c);
641 int x = width() / 2; 646 int x = width() / 2;
642 paint.drawLine(x, 0, x, height() - 1); 647
643 paint.drawLine(x-1, 1, x+1, 1); 648 if (!omitLine) {
644 paint.drawLine(x-2, 0, x+2, 0); 649 paint.drawLine(x, 0, x, height() - 1);
645 paint.drawLine(x-1, height() - 2, x+1, height() - 2); 650 paint.drawLine(x-1, 1, x+1, 1);
646 paint.drawLine(x-2, height() - 1, x+2, height() - 1); 651 paint.drawLine(x-2, 0, x+2, 0);
652 paint.drawLine(x-1, height() - 2, x+1, height() - 2);
653 paint.drawLine(x-2, height() - 1, x+2, height() - 1);
654 }
647 655
648 paint.setPen(QColor(50, 50, 50)); 656 paint.setPen(QColor(50, 50, 50));
649 657
650 int y = height() - fontHeight + fontAscent - 6; 658 int y = height() - fontHeight + fontAscent - 6;
651 659