Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 200:17f8d9cf60d7
* Return ranges from RangeSummarisableTimeValueModel::getRanges by references
instead of by return value. Trying to isolate a Win32 problem.
author | Chris Cannam |
---|---|
date | Wed, 07 Feb 2007 14:21:14 +0000 |
parents | 4a3bdde1ef13 |
children | 8520b7918104 |
comparison
equal
deleted
inserted
replaced
199:45e995ed84d9 | 200:17f8d9cf60d7 |
---|---|
511 | 511 |
512 #ifdef DEBUG_WAVEFORM_PAINT | 512 #ifdef DEBUG_WAVEFORM_PAINT |
513 std::cerr << "Painting waveform from " << frame0 << " to " << frame1 << " (" << (x1-x0+1) << " pixels at zoom " << zoomLevel << ")" << std::endl; | 513 std::cerr << "Painting waveform from " << frame0 << " to " << frame1 << " (" << (x1-x0+1) << " pixels at zoom " << zoomLevel << ")" << std::endl; |
514 #endif | 514 #endif |
515 | 515 |
516 RangeSummarisableTimeValueModel::RangeBlock ranges; | 516 RangeSummarisableTimeValueModel::RangeBlock *ranges = |
517 RangeSummarisableTimeValueModel::RangeBlock otherChannelRanges; | 517 new RangeSummarisableTimeValueModel::RangeBlock; |
518 | |
519 RangeSummarisableTimeValueModel::RangeBlock *otherChannelRanges = 0; | |
518 RangeSummarisableTimeValueModel::Range range; | 520 RangeSummarisableTimeValueModel::Range range; |
519 | 521 |
520 QColor greys[3]; | 522 QColor greys[3]; |
521 if (m_colour == Qt::black) { | 523 if (m_colour == Qt::black) { |
522 for (int i = 0; i < 3; ++i) { // 0 lightest, 2 darkest | 524 for (int i = 0; i < 3; ++i) { // 0 lightest, 2 darkest |
639 | 641 |
640 if (frame1 <= 0) continue; | 642 if (frame1 <= 0) continue; |
641 | 643 |
642 size_t modelZoomLevel = zoomLevel; | 644 size_t modelZoomLevel = zoomLevel; |
643 | 645 |
644 ranges = m_model->getRanges | 646 m_model->getRanges |
645 (ch, frame0 < 0 ? 0 : frame0, frame1, modelZoomLevel); | 647 (ch, frame0 < 0 ? 0 : frame0, frame1, *ranges, modelZoomLevel); |
646 | 648 |
647 if (mergingChannels || mixingChannels) { | 649 if (mergingChannels || mixingChannels) { |
648 if (m_model->getChannelCount() > 1) { | 650 if (m_model->getChannelCount() > 1) { |
649 otherChannelRanges = m_model->getRanges | 651 if (!otherChannelRanges) { |
650 (1, frame0 < 0 ? 0 : frame0, frame1, modelZoomLevel); | 652 otherChannelRanges = |
653 new RangeSummarisableTimeValueModel::RangeBlock; | |
654 } | |
655 m_model->getRanges | |
656 (1, frame0 < 0 ? 0 : frame0, frame1, *otherChannelRanges, | |
657 modelZoomLevel); | |
651 } else { | 658 } else { |
659 if (otherChannelRanges != ranges) delete otherChannelRanges; | |
652 otherChannelRanges = ranges; | 660 otherChannelRanges = ranges; |
653 } | 661 } |
654 } | 662 } |
655 | 663 |
656 for (int x = x0; x <= x1; ++x) { | 664 for (int x = x0; x <= x1; ++x) { |
681 maxIndex = size_t((double(index + 1) * zoomLevel) | 689 maxIndex = size_t((double(index + 1) * zoomLevel) |
682 / modelZoomLevel) - 1; | 690 / modelZoomLevel) - 1; |
683 } | 691 } |
684 } | 692 } |
685 | 693 |
686 if (index < ranges.size()) { | 694 if (ranges && index < ranges->size()) { |
687 | 695 |
688 range = ranges[index]; | 696 range = (*ranges)[index]; |
689 | 697 |
690 if (maxIndex > index && maxIndex < ranges.size()) { | 698 if (maxIndex > index && maxIndex < ranges->size()) { |
691 range.max = std::max(range.max, ranges[maxIndex].max); | 699 range.max = std::max(range.max, (*ranges)[maxIndex].max); |
692 range.min = std::min(range.min, ranges[maxIndex].min); | 700 range.min = std::min(range.min, (*ranges)[maxIndex].min); |
693 range.absmean = (range.absmean + | 701 range.absmean = (range.absmean + |
694 ranges[maxIndex].absmean) / 2; | 702 (*ranges)[maxIndex].absmean) / 2; |
695 } | 703 } |
696 | 704 |
697 } else { | 705 } else { |
698 continue; | 706 continue; |
699 } | 707 } |
700 | 708 |
701 int rangeBottom = 0, rangeTop = 0, meanBottom = 0, meanTop = 0; | 709 int rangeBottom = 0, rangeTop = 0, meanBottom = 0, meanTop = 0; |
702 | 710 |
703 if (mergingChannels) { | 711 if (mergingChannels) { |
704 | 712 |
705 if (index < otherChannelRanges.size()) { | 713 if (otherChannelRanges && index < otherChannelRanges->size()) { |
706 | 714 |
707 range.max = fabsf(range.max); | 715 range.max = fabsf(range.max); |
708 range.min = -fabsf(otherChannelRanges[index].max); | 716 range.min = -fabsf((*otherChannelRanges)[index].max); |
709 range.absmean = (range.absmean + | 717 range.absmean = (range.absmean + |
710 otherChannelRanges[index].absmean) / 2; | 718 (*otherChannelRanges)[index].absmean) / 2; |
711 | 719 |
712 if (maxIndex > index && maxIndex < ranges.size()) { | 720 if (maxIndex > index && maxIndex < otherChannelRanges->size()) { |
713 // let's not concern ourselves about the mean | 721 // let's not concern ourselves about the mean |
714 range.min = std::min | 722 range.min = std::min |
715 (range.min, | 723 (range.min, |
716 -fabsf(otherChannelRanges[maxIndex].max)); | 724 -fabsf((*otherChannelRanges)[maxIndex].max)); |
717 } | 725 } |
718 } | 726 } |
719 | 727 |
720 } else if (mixingChannels) { | 728 } else if (mixingChannels) { |
721 | 729 |
722 if (index < otherChannelRanges.size()) { | 730 if (otherChannelRanges && index < otherChannelRanges->size()) { |
723 | 731 |
724 range.max = (range.max + otherChannelRanges[index].max) / 2; | 732 range.max = (range.max + (*otherChannelRanges)[index].max) / 2; |
725 range.min = (range.min + otherChannelRanges[index].min) / 2; | 733 range.min = (range.min + (*otherChannelRanges)[index].min) / 2; |
726 range.absmean = (range.absmean + otherChannelRanges[index].absmean) / 2; | 734 range.absmean = (range.absmean + (*otherChannelRanges)[index].absmean) / 2; |
727 } | 735 } |
728 } | 736 } |
729 | 737 |
730 int greyLevels = 1; | 738 int greyLevels = 1; |
731 if (m_greyscale && (m_scale == LinearScale)) greyLevels = 4; | 739 if (m_greyscale && (m_scale == LinearScale)) greyLevels = 4; |
882 } | 890 } |
883 paint->end(); | 891 paint->end(); |
884 delete paint; | 892 delete paint; |
885 viewPainter.drawPixmap(rect, *m_cache, rect); | 893 viewPainter.drawPixmap(rect, *m_cache, rect); |
886 } | 894 } |
895 | |
896 if (otherChannelRanges != ranges) delete otherChannelRanges; | |
897 delete ranges; | |
887 } | 898 } |
888 | 899 |
889 QString | 900 QString |
890 WaveformLayer::getFeatureDescription(View *v, QPoint &pos) const | 901 WaveformLayer::getFeatureDescription(View *v, QPoint &pos) const |
891 { | 902 { |
921 if (channels == 0) return ""; | 932 if (channels == 0) return ""; |
922 | 933 |
923 for (size_t ch = minChannel; ch <= maxChannel; ++ch) { | 934 for (size_t ch = minChannel; ch <= maxChannel; ++ch) { |
924 | 935 |
925 size_t blockSize = v->getZoomLevel(); | 936 size_t blockSize = v->getZoomLevel(); |
926 RangeSummarisableTimeValueModel::RangeBlock ranges = | 937 RangeSummarisableTimeValueModel::RangeBlock ranges; |
927 m_model->getRanges(ch, f0, f1, blockSize); | 938 m_model->getRanges(ch, f0, f1, ranges, blockSize); |
928 | 939 |
929 if (ranges.empty()) continue; | 940 if (ranges.empty()) continue; |
930 | 941 |
931 RangeSummarisableTimeValueModel::Range range = ranges[0]; | 942 RangeSummarisableTimeValueModel::Range range = ranges[0]; |
932 | 943 |