Mercurial > hg > svgui
comparison layer/WaveformLayer.cpp @ 1372:2c01be836570
Short-circuit drawing a little bit for contiguous ranges
author | Chris Cannam |
---|---|
date | Fri, 02 Nov 2018 15:23:53 +0000 |
parents | ca9a36a5ab76 |
children | cca66ce390e0 |
comparison
equal
deleted
inserted
replaced
1371:ca9a36a5ab76 | 1372:2c01be836570 |
---|---|
799 QPainterPath meanPath; | 799 QPainterPath meanPath; |
800 QPainterPath clipPath; | 800 QPainterPath clipPath; |
801 vector<QPointF> individualSamplePoints; | 801 vector<QPointF> individualSamplePoints; |
802 | 802 |
803 bool firstPoint = true; | 803 bool firstPoint = true; |
804 double prevRangeBottom = 0, prevRangeTop = 0; | |
804 | 805 |
805 for (int x = x0; x <= x1; ++x) { | 806 for (int x = x0; x <= x1; ++x) { |
806 | 807 |
807 sv_frame_t f0, f1; | 808 sv_frame_t f0, f1; |
808 sv_frame_t i0, i1; | 809 sv_frame_t i0, i1; |
984 if (!trivialRange) { | 985 if (!trivialRange) { |
985 // common e.g. in "butterfly" merging mode | 986 // common e.g. in "butterfly" merging mode |
986 individualSamplePoints.push_back(QPointF(px, rangeBottom)); | 987 individualSamplePoints.push_back(QPointF(px, rangeBottom)); |
987 } | 988 } |
988 } | 989 } |
990 | |
991 bool contiguous = true; | |
992 if (rangeTop > prevRangeBottom + 0.5 || | |
993 rangeBottom < prevRangeTop - 0.5) { | |
994 contiguous = false; | |
995 } | |
989 | 996 |
990 if (firstPoint) { | 997 if (firstPoint || (contiguous && !trivialRange)) { |
991 waveformPath = QPainterPath(QPointF(px, rangeMiddle)); | 998 waveformPath.moveTo(QPointF(px, rangeTop)); |
992 firstPoint = false; | 999 waveformPath.lineTo(QPointF(px, rangeBottom)); |
1000 waveformPath.moveTo(QPointF(px, rangeMiddle)); | |
993 } else { | 1001 } else { |
994 waveformPath.lineTo(QPointF(px, rangeMiddle)); | 1002 waveformPath.lineTo(QPointF(px, rangeMiddle)); |
995 } | 1003 if (!trivialRange) { |
996 | 1004 waveformPath.lineTo(QPointF(px, rangeTop)); |
997 if (!trivialRange) { | 1005 waveformPath.lineTo(QPointF(px, rangeBottom)); |
998 waveformPath.lineTo(QPointF(px, rangeTop)); | 1006 waveformPath.lineTo(QPointF(px, rangeMiddle)); |
999 waveformPath.lineTo(QPointF(px, rangeBottom)); | 1007 } |
1000 waveformPath.lineTo(QPointF(px, rangeMiddle)); | 1008 } |
1001 } | 1009 |
1002 | 1010 firstPoint = false; |
1011 prevRangeTop = rangeTop; | |
1012 prevRangeBottom = rangeBottom; | |
1013 | |
1003 if (drawMean) { | 1014 if (drawMean) { |
1004 meanPath.moveTo(QPointF(px, meanBottom)); | 1015 meanPath.moveTo(QPointF(px, meanBottom)); |
1005 meanPath.lineTo(QPointF(px, meanTop)); | 1016 meanPath.lineTo(QPointF(px, meanTop)); |
1006 } | 1017 } |
1007 | 1018 |