Mercurial > hg > svgui
comparison layer/SliceLayer.cpp @ 1384:413e09f303ba spectrogramparam
Fix "colour" rendering for spectrum (now resembles a filled "line" mode rather than a filled "block" mode)
author | Chris Cannam |
---|---|
date | Thu, 08 Nov 2018 11:12:04 +0000 |
parents | 86f319dd6ab9 |
children | fc3d89f88690 |
comparison
equal
deleted
inserted
replaced
1383:86f319dd6ab9 | 1384:413e09f303ba |
---|---|
481 | 481 |
482 ColourMapper mapper(m_colourMap, m_colourInverted, 0, 1); | 482 ColourMapper mapper(m_colourMap, m_colourInverted, 0, 1); |
483 | 483 |
484 double ytop = 0, ybottom = 0; | 484 double ytop = 0, ybottom = 0; |
485 bool firstBinOfPixel = true; | 485 bool firstBinOfPixel = true; |
486 | |
487 QColor prevColour = v->getBackground(); | |
488 double prevPx = 0; | |
489 double prevYtop = 0; | |
486 | 490 |
487 for (int bin = 0; bin < mh; ++bin) { | 491 for (int bin = 0; bin < mh; ++bin) { |
488 | 492 |
489 double x = nx; | 493 double x = nx; |
490 nx = getXForBin(v, bin + bin0 + 1); | 494 nx = getXForBin(v, bin + bin0 + 1); |
502 | 506 |
503 if (int(nx) != int(x) || bin+1 == mh) { | 507 if (int(nx) != int(x) || bin+1 == mh) { |
504 | 508 |
505 if (m_plotStyle == PlotLines) { | 509 if (m_plotStyle == PlotLines) { |
506 | 510 |
507 auto px = (x + nx) / 2; | 511 double px = (x + nx) / 2; |
508 | 512 |
509 if (bin == 0) { | 513 if (bin == 0) { |
510 path.moveTo(px, y); | 514 path.moveTo(px, y); |
511 } else { | 515 } else { |
512 if (ytop != ybottom) { | 516 if (ytop != ybottom) { |
527 } | 531 } |
528 path.lineTo(nx, ytop); | 532 path.lineTo(nx, ytop); |
529 | 533 |
530 } else if (m_plotStyle == PlotBlocks) { | 534 } else if (m_plotStyle == PlotBlocks) { |
531 | 535 |
532 path.moveTo(x, yorigin); | 536 // work in pixel coords here, as we don't want the |
533 path.lineTo(x, ytop); | 537 // vertical edges to be antialiased |
534 path.lineTo(nx, ytop); | 538 |
535 path.lineTo(nx, yorigin); | 539 path.moveTo(QPoint(int(x), int(yorigin))); |
536 path.lineTo(x, yorigin); | 540 path.lineTo(QPoint(int(x), int(ytop))); |
541 path.lineTo(QPoint(int(nx), int(ytop))); | |
542 path.lineTo(QPoint(int(nx), int(yorigin))); | |
543 path.lineTo(QPoint(int(x), int(yorigin))); | |
537 | 544 |
538 } else if (m_plotStyle == PlotFilledBlocks) { | 545 } else if (m_plotStyle == PlotFilledBlocks) { |
539 | 546 |
540 paint.fillRect(QRectF(x, ytop, nx - x, yorigin - ytop), | 547 QColor c = mapper.map(norm); |
541 mapper.map(norm)); | 548 paint.setPen(Qt::NoPen); |
549 | |
550 // work in pixel coords here, as we don't want the | |
551 // vertical edges to be antialiased | |
552 | |
553 if (nx > x + 1) { | |
554 | |
555 double px = (x + nx) / 2; | |
556 | |
557 QVector<QPoint> pp; | |
558 | |
559 if (bin > 0) { | |
560 paint.setBrush(prevColour); | |
561 pp.clear(); | |
562 pp << QPoint(int(prevPx), int(yorigin)); | |
563 pp << QPoint(int(prevPx), int(prevYtop)); | |
564 pp << QPoint(int((px + prevPx) / 2), | |
565 int((ytop + prevYtop) / 2)); | |
566 pp << QPoint(int((px + prevPx) / 2), | |
567 int(yorigin)); | |
568 paint.drawConvexPolygon(QPolygon(pp)); | |
569 | |
570 paint.setBrush(c); | |
571 pp.clear(); | |
572 pp << QPoint(int((px + prevPx) / 2), | |
573 int(yorigin)); | |
574 pp << QPoint(int((px + prevPx) / 2), | |
575 int((ytop + prevYtop) / 2)); | |
576 pp << QPoint(int(px), int(ytop)); | |
577 pp << QPoint(int(px), int(yorigin)); | |
578 paint.drawConvexPolygon(QPolygon(pp)); | |
579 } | |
580 | |
581 prevPx = px; | |
582 prevColour = c; | |
583 prevYtop = ytop; | |
584 | |
585 } else { | |
586 | |
587 paint.fillRect(QRect(int(x), int(ytop), | |
588 int(nx) - int(x), | |
589 int(yorigin) - int(ytop)), | |
590 c); | |
591 } | |
542 } | 592 } |
543 | 593 |
544 firstBinOfPixel = true; | 594 firstBinOfPixel = true; |
545 | 595 |
546 } else { | 596 } else { |