Skip to content

Commit

Permalink
fix drawing changes when there are none
Browse files Browse the repository at this point in the history
  • Loading branch information
HendrikMennen committed Sep 20, 2024
1 parent 44b2356 commit 39f4ae7
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions src/OneWare.WaveFormViewer/Controls/Wave.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -292,6 +304,7 @@ public void DrawSignal(DrawingContext context, WaveModel model)
lastEndPoint = endPoint;
lastPen = currentPen;
lastValue = currentValue;
lastIndex = index;
}
}

Expand Down

0 comments on commit 39f4ae7

Please sign in to comment.