diff 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
line wrap: on
line diff
--- a/layer/WaveformLayer.cpp	Fri Feb 03 17:30:47 2006 +0000
+++ b/layer/WaveformLayer.cpp	Mon Feb 06 17:24:52 2006 +0000
@@ -385,12 +385,12 @@
 	paint->setPen(Qt::black);
 	paint->setBrush(Qt::NoBrush);
 
-	paint->setRenderHint(QPainter::Antialiasing, false);
-
     } else {
 	paint = &viewPainter;
     }
 
+    paint->setRenderHint(QPainter::Antialiasing, false);
+
     int x0 = 0, x1 = w - 1;
     int y0 = 0, y1 = h - 1;
 
@@ -399,6 +399,9 @@
     y0 = rect.top();
     y1 = rect.bottom();
 
+    if (x0 > 0) --x0;
+    if (x1 < m_view->width()) ++x1;
+
     long frame0 = getFrameForX(x0);
     long frame1 = getFrameForX(x1 + 1);
      
@@ -440,6 +443,7 @@
     for (size_t ch = minChannel; ch <= maxChannel; ++ch) {
 
 	int prevRangeBottom = -1, prevRangeTop = -1;
+	QColor prevRangeBottomColour = m_colour, prevRangeTopColour = m_colour;
 
 	int m = (h / channels) / 2;
 	int my = m + (((ch - minChannel) * h) / channels);
@@ -593,15 +597,17 @@
 	    if (x != x0 && prevRangeBottom != -1) {
 		if (prevRangeBottom > rangeBottom &&
 		    prevRangeTop    > rangeBottom) {
-		    paint->setPen(midColour);
+//		    paint->setPen(midColour);
+		    paint->setPen(m_colour);
 		    paint->drawLine(x-1, prevRangeTop, x, rangeBottom);
-		    paint->setPen(m_colour);
+		    paint->setPen(prevRangeTopColour);
 		    paint->drawPoint(x-1, prevRangeTop);
 		} else if (prevRangeBottom < rangeTop &&
 			   prevRangeTop    < rangeTop) {
-		    paint->setPen(midColour);
+//		    paint->setPen(midColour);
+		    paint->setPen(m_colour);
 		    paint->drawLine(x-1, prevRangeBottom, x, rangeTop);
-		    paint->setPen(m_colour);
+		    paint->setPen(prevRangeBottomColour);
 		    paint->drawPoint(x-1, prevRangeBottom);
 		}
 	    }
@@ -620,6 +626,9 @@
 
 	    paint->drawLine(x, rangeBottom, x, rangeTop);
 
+	    prevRangeTopColour = m_colour;
+	    prevRangeBottomColour = m_colour;
+
 	    if (m_greyscale && (m_scale == LinearScale) && ready) {
 		if (!clipped) {
 		    if (rangeTop < rangeBottom) {
@@ -627,11 +636,13 @@
 			    (!drawMean || (rangeTop < meanTop - 1))) {
 			    paint->setPen(greys[topFill - 1]);
 			    paint->drawPoint(x, rangeTop);
+			    prevRangeTopColour = greys[topFill - 1];
 			}
 			if (bottomFill > 0 && 
 			    (!drawMean || (rangeBottom > meanBottom + 1))) {
 			    paint->setPen(greys[bottomFill - 1]);
 			    paint->drawPoint(x, rangeBottom);
+			    prevRangeBottomColour = greys[bottomFill - 1];
 			}
 		    }
 		}