From 39f4ae71dbeb04913118920acc1dcc28405cd52a Mon Sep 17 00:00:00 2001 From: Hendrik Mennen Date: Fri, 20 Sep 2024 11:58:49 +0200 Subject: [PATCH] fix drawing changes when there are none --- src/OneWare.WaveFormViewer/Controls/Wave.cs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/OneWare.WaveFormViewer/Controls/Wave.cs b/src/OneWare.WaveFormViewer/Controls/Wave.cs index 43c2c193..760dffea 100644 --- a/src/OneWare.WaveFormViewer/Controls/Wave.cs +++ b/src/OneWare.WaveFormViewer/Controls/Wave.cs @@ -141,6 +141,7 @@ public void DrawSignal(DrawingContext context, WaveModel model) Point? lastEndPoint = null; var lastPen = signalPen; object? lastValue = null; + int lastIndex = -1; if (mz == 0) return; @@ -227,8 +228,19 @@ public void DrawSignal(DrawingContext context, WaveModel model) if (model.Signal is { Type: VcdLineType.Reg or VcdLineType.Wire, BitWidth: <= 1 }) //Simple type { - if (nextChangeTime != long.MaxValue && (lastValue?.Equals(currentValue) ?? false)) - context.DrawLine(currentPen, startPointBottom, startPointTop); + //Can happen if resolution is too small to display very short changes (eg from 0 to 1 to 0 in short timeframe) + //We want to draw a change there + if (lastIndex >= 0) + { + for (var ic = index; ic >= lastIndex; ic--) + { + if (!currentValue!.Equals(model.Signal.GetValueFromIndex(ic))) + { + context.DrawLine(currentPen, startPointBottom, startPointTop); + break; + } + } + } if (sWidth > 1) { //Connection @@ -292,6 +304,7 @@ public void DrawSignal(DrawingContext context, WaveModel model) lastEndPoint = endPoint; lastPen = currentPen; lastValue = currentValue; + lastIndex = index; } }