comparison layer/WaveformLayer.cpp @ 1334:0e4551fd7f14 zoom

Another tidy
author Chris Cannam
date Fri, 21 Sep 2018 14:33:43 +0100
parents 59f6830be8d8
children bc44b520405f
comparison
equal deleted inserted replaced
1333:59f6830be8d8 1334:0e4551fd7f14
552 paint->translate(QPointF(0, yt)); 552 paint->translate(QPointF(0, yt));
553 paint->scale(1.0, space); 553 paint->scale(1.0, space);
554 } 554 }
555 555
556 int x0 = 0, x1 = w - 1; 556 int x0 = 0, x1 = w - 1;
557 int y0 = 0, y1 = h - 1;
558 557
559 x0 = rect.left(); 558 x0 = rect.left();
560 x1 = rect.right(); 559 x1 = rect.right();
561 y0 = rect.top(); 560
562 y1 = rect.bottom(); 561 if (x0 > 0) {
563 562 rect.adjust(-1, 0, 0, 0);
564 if (x0 > 0) --x0; 563 x0 = rect.left();
565 if (x1 < w) ++x1; 564 }
565
566 if (x1 < w) {
567 rect.adjust(0, 0, 1, 0);
568 x1 = rect.right();
569 }
566 570
567 // Our zoom level may differ from that at which the underlying 571 // Our zoom level may differ from that at which the underlying
568 // model has its blocks. 572 // model has its blocks.
569 573
570 // Each pixel within our visible range must always draw from 574 // Each pixel within our visible range must always draw from
614 (1, frame0, frame1 - frame0, ranges[1], blockSize); 618 (1, frame0, frame1 - frame0, ranges[1], blockSize);
615 } 619 }
616 } 620 }
617 621
618 for (int ch = minChannel; ch <= maxChannel; ++ch) { 622 for (int ch = minChannel; ch <= maxChannel; ++ch) {
619 paintChannel(v, paint, ch, ranges, 623 paintChannel(v, paint, rect, ch, ranges, blockSize, frame0, frame1);
620 blockSize, x0, y0, x1, y1, frame0, frame1);
621 } 624 }
622 625
623 if (m_middleLineHeight != 0.5) { 626 if (m_middleLineHeight != 0.5) {
624 paint->restore(); 627 paint->restore();
625 } 628 }
634 viewPainter.drawPixmap(rect, *m_cache, rect); 637 viewPainter.drawPixmap(rect, *m_cache, rect);
635 } 638 }
636 } 639 }
637 640
638 void 641 void
639 WaveformLayer::paintChannel(LayerGeometryProvider *v, QPainter *paint, int ch, 642 WaveformLayer::paintChannel(LayerGeometryProvider *v, QPainter *paint,
643 QRect rect, int ch,
640 const vector<RangeSummarisableTimeValueModel::RangeBlock> &ranges, 644 const vector<RangeSummarisableTimeValueModel::RangeBlock> &ranges,
641 int blockSize, int x0, int y0, int x1, int y1, 645 int blockSize, sv_frame_t frame0, sv_frame_t frame1)
642 sv_frame_t frame0, sv_frame_t frame1)
643 const 646 const
644 { 647 {
645 int w = v->getPaintWidth(); 648 int x0 = rect.left();
649 int y0 = rect.top();
650
651 int x1 = rect.right();
652 int y1 = rect.bottom();
653
646 int h = v->getPaintHeight(); 654 int h = v->getPaintHeight();
647 655
648 int channels = 0, minChannel = 0, maxChannel = 0; 656 int channels = 0, minChannel = 0, maxChannel = 0;
649 bool mergingChannels = false, mixingChannels = false; 657 bool mergingChannels = false, mixingChannels = false;
650 658
688 m_channelMode != MergeChannels) { 696 m_channelMode != MergeChannels) {
689 m = (h / channels); 697 m = (h / channels);
690 my = m + (((ch - minChannel) * h) / channels); 698 my = m + (((ch - minChannel) * h) / channels);
691 } 699 }
692 700
701
702
693 paint->setPen(greys[1]); 703 paint->setPen(greys[1]);
694 paint->drawLine(x0, my, x1, my); 704 paint->drawLine(x0, my, x1, my);
695 705
696 int n = 10; 706 int n = 10;
697 int py = -1; 707 int py = -1;