Class SnapshotMonitor

Real-time A-mode snapshot monitor backed by ScottPlot.

Architecture: Unlike ScopeMonitor which streams multi-channel time-series data, this monitor displays spatial waveforms (e.g., ultrasound A-mode lines) as snapshots — X axis is sample index (depth), Y axis is amplitude. The entire waveform is replaced on each frame.

Multi-trace: When fed a MathNet.Numerics.LinearAlgebra.Matrix<T>, each row becomes a separate colored trace (one per TX/RX config). Colors reuse ChannelColors for consistency. When fed a MathNet.Numerics.LinearAlgebra.Vector<T>, a single trace is shown.

Inheritance
SnapshotMonitor
Namespace: MOSAIC.Visualization.SnapshotMonitor
Assembly: MOSAIC.dll
Syntax
public class SnapshotMonitor : ObservableObject, INotifyPropertyChanged, INotifyPropertyChanging, IDisposable

Constructors

SnapshotMonitor()

Declaration
public SnapshotMonitor()

Fields

MaxTraces

Declaration
private const int MaxTraces = 16
Field Value
Type Description
int

_autoScale

Whether the Y axis auto-scales to the data range each frame.

Declaration
[ObservableProperty]
private bool _autoScale
Field Value
Type Description
bool

_disposed

Declaration
private volatile bool _disposed
Field Value
Type Description
bool

_flushScheduled

Declaration
private int _flushScheduled
Field Value
Type Description
int

_frameCount

Total number of frames rendered.

Declaration
[ObservableProperty]
private long _frameCount
Field Value
Type Description
long

_isActive

Declaration
private volatile bool _isActive
Field Value
Type Description
bool

_isUpdating

Declaration
private volatile bool _isUpdating
Field Value
Type Description
bool

_plot

ScottPlot Plot object — set by the view via AttachPlot(Plot, Action).

Declaration
private Plot? _plot
Field Value
Type Description
Plot

_queue

Declaration
private readonly ConcurrentQueue<SnapshotMonitor.SnapshotFrame> _queue
Field Value
Type Description
ConcurrentQueue<SnapshotMonitor.SnapshotFrame>

_refreshCallback

Callback to invoke AvaPlot.Refresh() on the view.

Declaration
private Action? _refreshCallback
Field Value
Type Description
Action

_sampleCount

Current number of samples per trace.

Declaration
private int _sampleCount
Field Value
Type Description
int

_signals

One Signal plottable per trace (config row).

Declaration
private readonly List<Signal> _signals
Field Value
Type Description
List<Signal>

_tickRate

Declaration
private VisualizationTimer.TickRate _tickRate
Field Value
Type Description
VisualizationTimer.TickRate

_timerCallback

Declaration
private readonly Action _timerCallback
Field Value
Type Description
Action

_traceCount

Current number of traces (rows) being displayed.

Declaration
private int _traceCount
Field Value
Type Description
int

_traceData

Backing data arrays for each Signal plottable.

Declaration
private readonly List<double[]> _traceData
Field Value
Type Description
List<double[]>

_traceVisible

Per-trace visibility state.

Declaration
private bool[] _traceVisible
Field Value
Type Description
bool[]

Properties

AutoScale

Whether the Y axis auto-scales to the data range each frame.

Declaration
[ExcludeFromCodeCoverage]
public bool AutoScale { get; set; }
Property Value
Type Description
bool

FrameCount

Total number of frames rendered.

Declaration
[ExcludeFromCodeCoverage]
public long FrameCount { get; set; }
Property Value
Type Description
long

LineWidth

Line thickness in pixels.

Declaration
public float LineWidth { get; set; }
Property Value
Type Description
float

TickRate

Timer tick rate for flush cycles.

Declaration
public VisualizationTimer.TickRate TickRate { get; set; }
Property Value
Type Description
VisualizationTimer.TickRate

TraceCount

Current number of traces (config rows). Updated when matrix dimensions change.

Declaration
public int TraceCount { get; }
Property Value
Type Description
int

Methods

AttachPlot(Plot, Action)

Wires this monitor to a ScottPlot ScottPlot.Plot and a refresh callback.

Declaration
public void AttachPlot(Plot plot, Action refreshCallback)
Parameters
Type Name Description
Plot plot
Action refreshCallback

ConfigurePlotAppearance()

Declaration
public void ConfigurePlotAppearance()

DetachPlot()

Detaches from the plot.

Declaration
public void DetachPlot()

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

Declaration
public void Dispose()

EnqueueSnapshot(Matrix<double>)

Enqueues a matrix snapshot (one trace per row). Thread-safe.

Declaration
public void EnqueueSnapshot(Matrix<double> data)
Parameters
Type Name Description
Matrix<double> data

EnqueueSnapshot(Vector<double>)

Enqueues a vector snapshot (single trace). Thread-safe.

Declaration
public void EnqueueSnapshot(Vector<double> data)
Parameters
Type Name Description
Vector<double> data

FlushToChart()

Declaration
private void FlushToChart()

IsTraceVisible(int)

Returns whether the trace at index is currently visible.

Declaration
public bool IsTraceVisible(int index)
Parameters
Type Name Description
int index
Returns
Type Description
bool

OnAutoScaleChanged(bool)

Executes the logic for when AutoScale just changed.

Declaration
private void OnAutoScaleChanged(bool value)
Parameters
Type Name Description
bool value

The new property value that was set.

Remarks

This method is invoked right after the value of AutoScale is changed.

OnAutoScaleChanged(bool, bool)

Executes the logic for when AutoScale just changed.

Declaration
private void OnAutoScaleChanged(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that was replaced.

bool newValue

The new property value that was set.

Remarks

This method is invoked right after the value of AutoScale is changed.

OnAutoScaleChanging(bool)

Executes the logic for when AutoScale is changing.

Declaration
private void OnAutoScaleChanging(bool value)
Parameters
Type Name Description
bool value

The new property value being set.

Remarks

This method is invoked right before the value of AutoScale is changed.

OnAutoScaleChanging(bool, bool)

Executes the logic for when AutoScale is changing.

Declaration
private void OnAutoScaleChanging(bool oldValue, bool newValue)
Parameters
Type Name Description
bool oldValue

The previous property value that is being replaced.

bool newValue

The new property value being set.

Remarks

This method is invoked right before the value of AutoScale is changed.

OnFrameCountChanged(long)

Executes the logic for when FrameCount just changed.

Declaration
private void OnFrameCountChanged(long value)
Parameters
Type Name Description
long value

The new property value that was set.

Remarks

This method is invoked right after the value of FrameCount is changed.

OnFrameCountChanged(long, long)

Executes the logic for when FrameCount just changed.

Declaration
private void OnFrameCountChanged(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that was replaced.

long newValue

The new property value that was set.

Remarks

This method is invoked right after the value of FrameCount is changed.

OnFrameCountChanging(long)

Executes the logic for when FrameCount is changing.

Declaration
private void OnFrameCountChanging(long value)
Parameters
Type Name Description
long value

The new property value being set.

Remarks

This method is invoked right before the value of FrameCount is changed.

OnFrameCountChanging(long, long)

Executes the logic for when FrameCount is changing.

Declaration
private void OnFrameCountChanging(long oldValue, long newValue)
Parameters
Type Name Description
long oldValue

The previous property value that is being replaced.

long newValue

The new property value being set.

Remarks

This method is invoked right before the value of FrameCount is changed.

Pause()

Declaration
public void Pause()

RebuildSignals()

Declaration
private void RebuildSignals()

RequestFlush()

Declaration
private void RequestFlush()

ResetData()

Declaration
public void ResetData()

ResetDataCore()

Declaration
private void ResetDataCore()

Resume()

Declaration
public void Resume()

SetAutoScale()

Re-enables auto-scaling.

Declaration
public void SetAutoScale()

SetFixedRange(double, double)

Sets a fixed Y-axis range. Disables auto-scaling.

Declaration
public void SetFixedRange(double yMin, double yMax)
Parameters
Type Name Description
double yMin
double yMax

SetTraceVisible(int, bool)

Toggles visibility of a single trace and updates the Signal plottable.

Declaration
public void SetTraceVisible(int index, bool visible)
Parameters
Type Name Description
int index
bool visible

ShowAllTraces()

Shows all traces.

Declaration
public void ShowAllTraces()

ShowSingleTrace(int)

Shows only the trace at index, hides all others.

Declaration
public void ShowSingleTrace(int index)
Parameters
Type Name Description
int index

UpdateAxisLimits()

Declaration
private void UpdateAxisLimits()

UpdateThemeColors()

Re-applies theme colors after a theme switch.

Declaration
public void UpdateThemeColors()

Events

TracesChanged

Fired when the trace count changes (new matrix dimensions) so the view can rebuild its toggle buttons. Raised on the thread that calls FlushToChart (UI thread).

Declaration
public event Action? TracesChanged
Event Type
Type Description
Action

Implements

INotifyPropertyChanged
INotifyPropertyChanging
IDisposable

Search documentation

Start typing to search the documentation.