comparison layer/WaveformLayer.cpp @ 28:202d1dca67d2

* Rationalise the local feature identification API in Layer subclasses * Add segmentation mode to TimeInstantLayer
author Chris Cannam
date Mon, 06 Feb 2006 17:24:52 +0000
parents 38fe0ea9e46e
children c43f2c4f66f2
comparison
equal deleted inserted replaced
27:38fe0ea9e46e 28:202d1dca67d2
383 paint->drawRect(rect); 383 paint->drawRect(rect);
384 384
385 paint->setPen(Qt::black); 385 paint->setPen(Qt::black);
386 paint->setBrush(Qt::NoBrush); 386 paint->setBrush(Qt::NoBrush);
387 387
388 paint->setRenderHint(QPainter::Antialiasing, false);
389
390 } else { 388 } else {
391 paint = &viewPainter; 389 paint = &viewPainter;
392 } 390 }
391
392 paint->setRenderHint(QPainter::Antialiasing, false);
393 393
394 int x0 = 0, x1 = w - 1; 394 int x0 = 0, x1 = w - 1;
395 int y0 = 0, y1 = h - 1; 395 int y0 = 0, y1 = h - 1;
396 396
397 x0 = rect.left(); 397 x0 = rect.left();
398 x1 = rect.right(); 398 x1 = rect.right();
399 y0 = rect.top(); 399 y0 = rect.top();
400 y1 = rect.bottom(); 400 y1 = rect.bottom();
401
402 if (x0 > 0) --x0;
403 if (x1 < m_view->width()) ++x1;
401 404
402 long frame0 = getFrameForX(x0); 405 long frame0 = getFrameForX(x0);
403 long frame1 = getFrameForX(x1 + 1); 406 long frame1 = getFrameForX(x1 + 1);
404 407
405 #ifdef DEBUG_WAVEFORM_PAINT 408 #ifdef DEBUG_WAVEFORM_PAINT
438 } 441 }
439 442
440 for (size_t ch = minChannel; ch <= maxChannel; ++ch) { 443 for (size_t ch = minChannel; ch <= maxChannel; ++ch) {
441 444
442 int prevRangeBottom = -1, prevRangeTop = -1; 445 int prevRangeBottom = -1, prevRangeTop = -1;
446 QColor prevRangeBottomColour = m_colour, prevRangeTopColour = m_colour;
443 447
444 int m = (h / channels) / 2; 448 int m = (h / channels) / 2;
445 int my = m + (((ch - minChannel) * h) / channels); 449 int my = m + (((ch - minChannel) * h) / channels);
446 450
447 // std::cerr << "ch = " << ch << ", channels = " << channels << ", m = " << m << ", my = " << my << ", h = " << h << std::endl; 451 // std::cerr << "ch = " << ch << ", channels = " << channels << ", m = " << m << ", my = " << my << ", h = " << h << std::endl;
591 } 595 }
592 596
593 if (x != x0 && prevRangeBottom != -1) { 597 if (x != x0 && prevRangeBottom != -1) {
594 if (prevRangeBottom > rangeBottom && 598 if (prevRangeBottom > rangeBottom &&
595 prevRangeTop > rangeBottom) { 599 prevRangeTop > rangeBottom) {
596 paint->setPen(midColour); 600 // paint->setPen(midColour);
601 paint->setPen(m_colour);
597 paint->drawLine(x-1, prevRangeTop, x, rangeBottom); 602 paint->drawLine(x-1, prevRangeTop, x, rangeBottom);
598 paint->setPen(m_colour); 603 paint->setPen(prevRangeTopColour);
599 paint->drawPoint(x-1, prevRangeTop); 604 paint->drawPoint(x-1, prevRangeTop);
600 } else if (prevRangeBottom < rangeTop && 605 } else if (prevRangeBottom < rangeTop &&
601 prevRangeTop < rangeTop) { 606 prevRangeTop < rangeTop) {
602 paint->setPen(midColour); 607 // paint->setPen(midColour);
608 paint->setPen(m_colour);
603 paint->drawLine(x-1, prevRangeBottom, x, rangeTop); 609 paint->drawLine(x-1, prevRangeBottom, x, rangeTop);
604 paint->setPen(m_colour); 610 paint->setPen(prevRangeBottomColour);
605 paint->drawPoint(x-1, prevRangeBottom); 611 paint->drawPoint(x-1, prevRangeBottom);
606 } 612 }
607 } 613 }
608 614
609 if (ready) { 615 if (ready) {
618 paint->setPen(midColour); 624 paint->setPen(midColour);
619 } 625 }
620 626
621 paint->drawLine(x, rangeBottom, x, rangeTop); 627 paint->drawLine(x, rangeBottom, x, rangeTop);
622 628
629 prevRangeTopColour = m_colour;
630 prevRangeBottomColour = m_colour;
631
623 if (m_greyscale && (m_scale == LinearScale) && ready) { 632 if (m_greyscale && (m_scale == LinearScale) && ready) {
624 if (!clipped) { 633 if (!clipped) {
625 if (rangeTop < rangeBottom) { 634 if (rangeTop < rangeBottom) {
626 if (topFill > 0 && 635 if (topFill > 0 &&
627 (!drawMean || (rangeTop < meanTop - 1))) { 636 (!drawMean || (rangeTop < meanTop - 1))) {
628 paint->setPen(greys[topFill - 1]); 637 paint->setPen(greys[topFill - 1]);
629 paint->drawPoint(x, rangeTop); 638 paint->drawPoint(x, rangeTop);
639 prevRangeTopColour = greys[topFill - 1];
630 } 640 }
631 if (bottomFill > 0 && 641 if (bottomFill > 0 &&
632 (!drawMean || (rangeBottom > meanBottom + 1))) { 642 (!drawMean || (rangeBottom > meanBottom + 1))) {
633 paint->setPen(greys[bottomFill - 1]); 643 paint->setPen(greys[bottomFill - 1]);
634 paint->drawPoint(x, rangeBottom); 644 paint->drawPoint(x, rangeBottom);
645 prevRangeBottomColour = greys[bottomFill - 1];
635 } 646 }
636 } 647 }
637 } 648 }
638 } 649 }
639 650