Interactive 2D wave optics simulator. Turn any image into a refractive scene, add sources, watch waves refract, diffract and interfere. Probes, intensity maps, video export.
C#
A probe the run does not record is a simulation edit
Alexander Graefb6688e00e22a
diff --git a/CLAUDE.md b/CLAUDE.mdindex 822e283..079c8e8 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -107,7 +107,8 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA- **Live editing**: a simulation edit (scene, solver, seed, sources) marks the run stale, **stops playback and anyactive run**, requests a scratch frame for the position (120 ms debounce) and re-runs automatically after 1.5 sof quiet (setting, default on); an automatic run never moves the preview. A probe edit never starts a run: only- the recordings are stale, the scratch frame refreshes the graph. No scratch frame while playback runs. Any run+ the recordings are stale, the scratch frame refreshes the graph; except that an active probe the run does not+ record (switched on, added) is a simulation edit (2026-10-18). No scratch frame while playback runs. Any runis paused while a scratch frame computes. Every scratch request is computed, however long.- **A picture changes only when a frame for its position arrives**; otherwise the last picture stays. A long waitdims the pictures under a spinner, mirrored on the taskbar.@@ -152,7 +153,7 @@ numbers: no GPU JPEG, no OpenCL colouring at presentation, no `Vector256`, no Di`library_check` (70+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export).UI, all on `Common.ps1`, with their check counts: `PreviewCheck` 43, `RunCheck` 71, `LanguageCheck` 11,-`ProbeGraphCheck` 33, `ImportCheck` 10, `ExportCheck` 30, `PreviewQualityCheck` 35, `SceneImageCheck` 8,+`ProbeGraphCheck` 39, `ImportCheck` 10, `ExportCheck` 30, `PreviewQualityCheck` 35, `SceneImageCheck` 8,`ColorPickerCheck` 13, `KeyboardCheck` 13, `AboutCheck` 18. Test projects `tiny*.wdproj` sit beside them. A harnesssets the persisted settings it expects (split orientation, preview quality). Known flake: a second app start in onescript sometimes comes up active; only the foreground guard fails then.diff --git a/WaveDudeNext.WPF/MainWindow.Live.cs b/WaveDudeNext.WPF/MainWindow.Live.csindex 8a0bda3..870400f 100644--- a/WaveDudeNext.WPF/MainWindow.Live.cs+++ b/WaveDudeNext.WPF/MainWindow.Live.cs@@ -170,7 +170,8 @@ public partial class MainWindowpreviewPane.RefreshColors();return;}- if (change.AffectsProbes)+ bool unrecorded = change.AffectsProbes && HasUnrecordedProbe();+ if (change.AffectsProbes && !unrecorded){// the frames stay, the recordings are stale: the scratch frame brings the new recording for the positionif (Run != null && !IsProbesStale)@@ -181,13 +182,20 @@ public partial class MainWindowScheduleScratch();return;}- if (!change.AffectsSimulation && !IsBrightnessBaked(change))+ if (!change.AffectsSimulation && !unrecorded && !IsBrightnessBaked(change)){return;}if (Run != null && !IsRunStale){- Logger.Debug("Edited ({Item}.{Property}): the run is stale", change.Item, change.Property ?? "list");+ if (unrecorded)+ {+ Logger.Debug("Probes edited ({Item}.{Property}): an active probe has no recording in the run, so the run is stale", change.Item, change.Property ?? "list");+ }+ else+ {+ Logger.Debug("Edited ({Item}.{Property}): the run is stale", change.Item, change.Property ?? "list");+ }}if (change.Item is Scene){@@ -216,6 +224,16 @@ public partial class MainWindowScheduleRerun();}+ /// <summary>+ /// Whether an active probe has no recording in the current run: one just switched on, or one just added. A+ /// scratch frame fills its graph for one position only, and a scrub or playback showed it empty until a run+ /// recorded it, so such a probe edit counts as a simulation edit (the user's choice, 2026-10-18). A move or a+ /// measurement change of a recorded probe only stales the recordings, as before. UI thread.+ /// </summary>+ private bool HasUnrecordedProbe() =>+ Run is { } run && Project is { } project+ && project.Probes.Any(probe => probe.Active && !run.Spec.Probes.Any(spec => ReferenceEquals(spec.Origin, probe)));+/// <summary>/// Whether a display edit changes the stored frames after all: a layer's brightness while the preview's/// samples are 8-bit palette indices (View > Preview samples), which bake the brightness in at capture time.diff --git a/WaveDudeNext.WPF/Views/ProbeView.xaml b/WaveDudeNext.WPF/Views/ProbeView.xamlindex d18166e..c49e4af 100644--- a/WaveDudeNext.WPF/Views/ProbeView.xaml+++ b/WaveDudeNext.WPF/Views/ProbeView.xaml@@ -68,7 +68,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ToolTip="{meta:Hint model:Probe.Name}" /><CheckBox controls:FormPanel.FullWidth="True" Content="{meta:Label model:Probe.Active}"- IsChecked="{Binding Active}" ToolTip="{meta:Hint model:Probe.Active}" />+ IsChecked="{Binding Active}" ToolTip="{meta:Hint model:Probe.Active}" AutomationProperties.AutomationId="ProbeActive" /><TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:Probe.StartAfter}" /><controls:NumberBox Text="{Binding StartAfter}" Minimum="0" ToolTip="{meta:Hint model:Probe.StartAfter}" />diff --git a/WaveDudeNext/Model/ProjectWatcher.cs b/WaveDudeNext/Model/ProjectWatcher.csindex b685c75..74a9886 100644--- a/WaveDudeNext/Model/ProjectWatcher.cs+++ b/WaveDudeNext/Model/ProjectWatcher.cs@@ -44,7 +44,8 @@ public sealed record ProjectChange(object Item, string? Property)/// <summary>/// Whether the change alters what a run records for its probes, and nothing else: what a probe measures/// (<see cref="Probe.AffectsMeasurement"/>) or the probe list. A probe never changes the picture (the- /// user's rule, 2026-10-14), so a run's frames stay valid and only its recordings go stale.+ /// user's rule, 2026-10-14), so a run's frames stay valid and only its recordings go stale. The window makes one+ /// exception: an active probe the run does not record (switched on or added) is treated as a simulation edit (2026-10-18)./// </summary>public bool AffectsProbes => Item switch{diff --git a/_tools/ui_check/ProbeGraphCheck.ps1 b/_tools/ui_check/ProbeGraphCheck.ps1index 8b7eeb4..74f9316 100644--- a/_tools/ui_check/ProbeGraphCheck.ps1+++ b/_tools/ui_check/ProbeGraphCheck.ps1@@ -16,7 +16,7 @@# <https://www.gnu.org/licenses/>.# Checks the probe graph boxes drawn over the preview pictures (2026-10-14): on tiny_probes.wdproj (320x240,-# 100 steps, a point probe with a custom 120x60 box on the field, a line probe with a Small box at its own+# 100 steps, a point probe with a custom 120x60 box on the field, a line probe with a Tiny box at its own# position on the intensity) the boxes must sit on the right picture at the probe's box position, show the# scratch frame's data before any run and the run's data after it, move with the arrow keys when focused,# grow from their corner grip, and a box at its probe's position must move with the probe. A probe move leaves@@ -64,9 +64,9 @@ try {$corner = CanvasPoint "PreviewFieldImage" 320 240 7.5 7.5$scale = $corner[2]Check "custom box at its canvas position and size" ([math]::Abs($r1.Left - $corner[0]) -lt 2 -and [math]::Abs($r1.Top - $corner[1]) -lt 2 -and [math]::Abs($r1.Width - 120 * $scale) -lt 2 -and [math]::Abs($r1.Height - 60 * $scale) -lt 2) ("box {0:0},{1:0} {2:0}x{3:0} expected {4:0},{5:0} {6:0}x{7:0}" -f $r1.Left, $r1.Top, $r1.Width, $r1.Height, $corner[0], $corner[1], (120 * $scale), (60 * $scale))- # the Small box (300 x 150) is shrunk to half the canvas width: 160 x 80+ # the Tiny box (200 x 100) fits the canvas and is drawn at its size (a box was held to half the canvas width until 2026-10-18)$scale2 = (CanvasPoint "PreviewIntensityImage" 320 240 0 0)[2]- Check "the Small box is shrunk to half the canvas width (160 x 80)" ([math]::Abs($r2.Width - 160 * $scale2) -lt 2 -and [math]::Abs($r2.Height - 80 * $scale2) -lt 2) ("{0:0}x{1:0} expected {2:0}x{3:0}" -f $r2.Width, $r2.Height, (160 * $scale2), (80 * $scale2))+ Check "the Tiny box is drawn at its 200 x 100" ([math]::Abs($r2.Width - 200 * $scale2) -lt 2 -and [math]::Abs($r2.Height - 100 * $scale2) -lt 2) ("{0:0}x{1:0} expected {2:0}x{3:0}" -f $r2.Width, $r2.Height, (200 * $scale2), (100 * $scale2))$grip = (Find "ProbeBoxCorner:Probe 1").Current.BoundingRectangleCheck "the resize grip sits in the box's bottom-right corner" ([math]::Abs($grip.Right - $r1.Right) -lt 2 -and [math]::Abs($grip.Bottom - $r1.Bottom) -lt 2) ("grip {0:0},{1:0} box corner {2:0},{3:0}" -f $grip.Right, $grip.Bottom, $r1.Right, $r1.Bottom)$empty = BoxHash "ProbeBox:Probe 1"@@ -135,6 +135,22 @@ try {Check "Play after a probe edit starts a run to refresh the recordings" (WaitFor { (RunStatus) -like "Running:*" -or ((Find "StatusMessage").Current.Name -like "Re-run started*") } 5000 10) ((Find "StatusMessage").Current.Name)Check "that run completes" (WaitFor { (RunStatus) -like "Completed: 100 / 100*" } 15000 100) (RunStatus)Key $VK_SPACE 100 # stop playback+ # ------------------------------------------------------------ a probe the run does not record+ # Probe 2 (selected) off: the run keeps its recording, so nothing but the recordings is stale; Play then makes a run without it+ FocusOn "ProbeActive"+ Key $VK_SPACE 300+ Check "switching a recorded probe off leaves the run valid" ((RunStatus) -like "Completed:*" -and (RunStatus) -notlike "*edited*") (RunStatus)+ Check "its box is gone" ((FindAll "ProbeBox:Probe 2").Count -eq 0)+ FocusOn "PreviewPlay"+ Key $VK_SPACE 20+ Check "Play makes a run without it" (WaitFor { (RunStatus) -like "Completed: 100 / 100*" -and (RunStatus) -notlike "*edited*" } 20000 100) (RunStatus)+ Key $VK_SPACE 100 # stop playback+ # Probe 2 on again: this run has no recording for it, so the edit counts as a simulation edit (the user's choice, 2026-10-18)+ FocusOn "ProbeActive"+ Key $VK_SPACE 300+ Check "switching on a probe the run does not record marks the run stale" (WaitFor { (RunStatus) -like "*edited*" } 3000) (RunStatus)+ Check "and the automatic re-run records it" (WaitFor { (RunStatus) -like "Completed: 100 / 100*" -and (RunStatus) -notlike "*edited*" } 20000 200) (RunStatus)+ Check "its box is back" ((FindAll "ProbeBox:Probe 2").Count -eq 1)# the composite source's rotation handle: only while the source is selected; on the row axis right of the centre at# 0 degrees; arrows turn the array$angleCondition = New-Object System.Windows.Automation.PropertyCondition($A::AutomationIdProperty, "SourceAngle:Source 2")diff --git a/_tools/ui_check/tiny_probes.wdproj b/_tools/ui_check/tiny_probes.wdprojindex 6278e51..d7ac4a0 100644--- a/_tools/ui_check/tiny_probes.wdproj+++ b/_tools/ui_check/tiny_probes.wdproj@@ -1,6 +1,6 @@<?xml version="1.0" encoding="utf-8"?><Project Version="1" Seed="12345">- <Description>Harness project: a 320 x 240 canvas, 100 steps, a frame every 2 steps, one source, a point probe on the field (custom box) and a line probe on the intensity.</Description>+ <Description>Harness project: a 320 x 240 canvas, 100 steps, a frame every 2 steps, one source, a point probe on the field (custom box) and a line probe on the intensity (Tiny box at its own position).</Description><Scene Width="320" Height="240" DampingEdge="8" /><Simulation Steps="100" VisualizeEvery="2" /><Display>@@ -12,5 +12,5 @@<Array SizeX="3" SpacingX="10" /></Source><Probe Name="Probe 1" AX="200" AY="120" BoxSize="Custom" BoxX="8" BoxY="8" BoxWidth="120" BoxHeight="60" />- <Probe Name="Probe 2" Layer="Intensity" Measurement="Value" Kind="Line" AX="40" AY="200" BX="280" BY="200" BoxSize="Small" BoxX="40" BoxY="200" />+ <Probe Name="Probe 2" Layer="Intensity" Measurement="Value" Kind="Line" AX="40" AY="120" BX="280" BY="120" BoxSize="Tiny" BoxX="40" BoxY="120" /></Project>