# HG changeset patch # User Chris Cannam # Date 1366121853 -3600 # Node ID 9d8f6552014d5e4b5fe70d1737e815a07488fdf7 # Parent f69e08be3379ad5caef0bb1a6050bbd6383c2596 Some refinements to drawing values in place of absent labels diff -r f69e08be3379 -r 9d8f6552014d layer/TimeValueLayer.cpp --- a/layer/TimeValueLayer.cpp Tue Apr 16 14:25:22 2013 +0100 +++ b/layer/TimeValueLayer.cpp Tue Apr 16 15:17:33 2013 +0100 @@ -42,7 +42,7 @@ #include #include -#define DEBUG_TIME_VALUE_LAYER 1 +//#define DEBUG_TIME_VALUE_LAYER 1 TimeValueLayer::TimeValueLayer() : SingleColourLayer(), @@ -763,7 +763,7 @@ } else { getDisplayExtents(min, max); - + if (m_verticalScale == LogScale) { LogRange::mapRange(min, max); log = true; @@ -1082,7 +1082,6 @@ if (pointCount == 0) { path.moveTo(x + w/2, y); } - ++pointCount; // paint.drawLine(x + w/2, y, nx + w/2, ny); path.lineTo(nx + w/2, ny); @@ -1106,7 +1105,6 @@ if (pointCount == 0 || gap) { path.moveTo((x0 + x1) / 2, (y0 + y1) / 2); } - ++pointCount; if (nx - x > 5) { path.cubicTo(x0, y0, @@ -1151,12 +1149,17 @@ (m_plotStyle == PlotPoints || m_plotStyle == PlotSegmentation || m_plotStyle == PlotConnectedPoints)) { - label = QString("%1").arg(p.value); + char lc[20]; + snprintf(lc, 20, "%.3g", p.value); + label = lc; italic = true; } if (label != "") { - if (!haveNext || nx > x + 6 + paint.fontMetrics().width(label)) { + bool haveRoom = nx > x + 6 + paint.fontMetrics().width(label); + if (haveRoom || + (!haveNext && + (pointCount == 0 || !italic))) { v->drawVisibleText(paint, x + 5, textY, label, italic ? View::OutlinedItalicText : @@ -1165,6 +1168,7 @@ } prevFrame = p.frame; + ++pointCount; } if ((m_plotStyle == PlotCurve || m_plotStyle == PlotDiscreteCurves ||