Mercurial > hg > svgui
diff layer/TimeValueLayer.cpp @ 632:9d8f6552014d
Some refinements to drawing values in place of absent labels
author | Chris Cannam |
---|---|
date | Tue, 16 Apr 2013 15:17:33 +0100 |
parents | f69e08be3379 |
children | c6d705bf1672 |
line wrap: on
line diff
--- 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 <iostream> #include <cmath> -#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 ||