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#
The preview's Run button is Stop while a run is in progress
Alexander Graef14e6df9ea6bf
diff --git a/CLAUDE.md b/CLAUDE.mdindex 1f8f286..8c141cf 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -691,7 +691,7 @@ passing harnesses for comfort, never all of them after an edit.- `_tools/ui_check/PreviewCheck.ps1` drives the WPF preview pane end to end on the default project(43 checks: play/pause at the 60 fps clock, speed incl. locale spelling, timeline keys, framesteps, in/out/loop, split radios, splitter, tab order, focus hand-off, foreground untouched).- `_tools/ui_check/RunCheck.ps1` runs simulations (33 checks): `tiny.wdproj` (64×48, 200 steps) with+ `_tools/ui_check/RunCheck.ps1` runs simulations (36 checks): `tiny.wdproj` (64×48, 200 steps) withF5 to completion, live follow, `,` detaching, the field picture differing between frames (MD5 ofa `PrintWindow` crop), `F` re-attaching, playback of the stored frames, a second run, the sourcehandle sitting at the source's canvas position on both pictures, staying there when the window@@ -699,7 +699,7 @@ passing harnesses for comfort, never all of them after an edit.labels, 2026-10-10) and moving with the arrow keys while the tree selection follows, a scratch frame replacing the black canvas after an edit withno run, and after the run: an edit marks it stale, the shown frame is recomputed from scratch,the automatic re-run completes with the position kept and reproduces the original picture; then- `tiny_long.wdproj` (2 000 000 steps, a frame every 1000) for F6 pause/resume and Esc stop with the+ `tiny_long.wdproj` (2 000 000 steps, a frame every 1000) for F6 pause/resume and a stop through the Run button turned Stop with thepartial frames kept, then an edit starting an automatic re-run that leaves the position and Livealone, and a second edit stopping it at once before a fresh one starts. Both dot-source `Common.ps1` (native helpers, lookups, `Start-App`/`Stop-App`,`CanvasPoint` for the picture's uniform mapping, `TreeItemSelected`). The split orientation is a@@ -990,7 +990,10 @@ Thirteen points on a sneak peek of the WPF app; status as of 2026-10-12:while the format could still change; the string tables name them, `EnumNameConverter` falls back to a`[Description]`); (9) the four random amounts of an array sit undertheir own header "Random offsets, added per emitter"; (2) the in/out tooltips say "export range".-- Done 2026-10-13: (1) a Run button (ring with a triangle, F5) left of Play, (4) two toggles left of+- Done 2026-10-13: (1) a Run button (ring with a triangle, F5) left of Play; **the same button is Stop while a run is in+ progress** (2026-10-16, the user's rule: ring with a square, `StopGeometry`, the `Stop` command, tooltip `TipPreviewStop`;+ glyph, command and tooltip are style setters swapped by a `DataTrigger` on `Run.IsActive`, since a local value would beat+ the trigger; the id stays `PreviewRun`, RunCheck tells the states apart by the name), (4) two toggles left ofthe split radios show or hide each picture (bound to the layer's `Preview`, so hiding the intensityalso stops storing it; the remaining picture takes the whole area and the splitter collapses,`UpdatePictureLayout`), (6/3) the scene image and its outline in the preview.diff --git a/WaveDudeNext.WPF/Panes/PreviewPane.xaml b/WaveDudeNext.WPF/Panes/PreviewPane.xamlindex 65c8d62..bd31266 100644--- a/WaveDudeNext.WPF/Panes/PreviewPane.xaml+++ b/WaveDudeNext.WPF/Panes/PreviewPane.xaml@@ -34,6 +34,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<!-- "run": a play triangle inside a ring (the author asked for an explicit start button, 2026-10-13) --><StreamGeometry x:Key="RunGeometry">M0,7 A7,7 0 1 1 14,7 A7,7 0 1 1 0,7 Z M1.4,7 A5.6,5.6 0 1 0 12.6,7 A5.6,5.6 0 1 0 1.4,7 Z M5.2,3.5 L10.8,7 L5.2,10.5 Z</StreamGeometry>+ <!-- "stop": the same ring with a square inside; the Run button shows it while a run is in progress (2026-10-16) -->+ <StreamGeometry x:Key="StopGeometry">M0,7 A7,7 0 1 1 14,7 A7,7 0 1 1 0,7 Z M1.4,7 A5.6,5.6 0 1 0 12.6,7 A5.6,5.6 0 1 0 1.4,7 Z M4.7,4.7 L9.3,4.7 L9.3,9.3 L4.7,9.3 Z</StreamGeometry><!-- the two pictures: a wave for the field, a sun for the intensity --><StreamGeometry x:Key="FieldGeometry">M0,6 C1.5,1 2.5,1 4,6 C5.5,11 6.5,11 8,6 C9,3 10,3 11,6 L11,7.5 C10,5 9,5 8,7.5 C6.5,12.5 5.5,12.5 4,7.5 C2.5,2.5 1.5,2.5 0,7.5 Z</StreamGeometry><StreamGeometry x:Key="IntensityGeometry">M3,5 A2,2 0 1 1 7,5 A2,2 0 1 1 3,5 Z M4.4,0 L5.6,0 L5.6,2 L4.4,2 Z M4.4,8 L5.6,8 L5.6,10 L4.4,10 Z M0,4.4 L2,4.4 L2,5.6 L0,5.6 Z M8,4.4 L10,4.4 L10,5.6 L8,5.6 Z</StreamGeometry>@@ -334,10 +336,28 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file orthis one, since both dock to the bottom) and follows in the tab order. --><Border DockPanel.Dock="Bottom" BorderBrush="{DynamicResource ToolWindowBorder}" BorderThickness="0,1,0,0" Padding="4,3"><DockPanel KeyboardNavigation.TabNavigation="Local">- <!-- an explicit "run the simulation" next to Play (Play alone starts one only when needed) -->- <Button DockPanel.Dock="Left" TabIndex="0" Style="{StaticResource TransportButton}" Content="{StaticResource RunGeometry}"- Command="{x:Static commands:SimulationCommands.Run}" ToolTip="{DynamicResource TipPreviewRun}"- AutomationProperties.Name="{DynamicResource TipPreviewRun}" AutomationProperties.AutomationId="PreviewRun" />+ <!-- an explicit "run the simulation" next to Play (Play alone starts one only when needed); while a run is in+ progress the same button is Stop (the user's rule, 2026-10-16): glyph, command and tooltip come from the+ style, since a local value would win over the trigger. Its id stays PreviewRun; a harness tells the two+ apart by the name -->+ <Button DockPanel.Dock="Left" TabIndex="0" AutomationProperties.AutomationId="PreviewRun">+ <Button.Style>+ <Style TargetType="{x:Type Button}" BasedOn="{StaticResource TransportButton}">+ <Setter Property="Content" Value="{StaticResource RunGeometry}" />+ <Setter Property="Command" Value="{x:Static commands:SimulationCommands.Run}" />+ <Setter Property="ToolTip" Value="{DynamicResource TipPreviewRun}" />+ <Setter Property="AutomationProperties.Name" Value="{DynamicResource TipPreviewRun}" />+ <Style.Triggers>+ <DataTrigger Binding="{Binding Run.IsActive, ElementName=pane, FallbackValue=False}" Value="True">+ <Setter Property="Content" Value="{StaticResource StopGeometry}" />+ <Setter Property="Command" Value="{x:Static commands:SimulationCommands.Stop}" />+ <Setter Property="ToolTip" Value="{DynamicResource TipPreviewStop}" />+ <Setter Property="AutomationProperties.Name" Value="{DynamicResource TipPreviewStop}" />+ </DataTrigger>+ </Style.Triggers>+ </Style>+ </Button.Style>+ </Button><Rectangle DockPanel.Dock="Left" Width="1" Margin="4,2" Fill="{DynamicResource ToolWindowBorder}" /><Button x:Name="playButton" DockPanel.Dock="Left" TabIndex="1" Style="{StaticResource TransportButton}" Content="{StaticResource PlayGeometry}"Command="MediaCommands.Play" ToolTip="{DynamicResource TipPreviewPlay}"diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xamlindex 74e7a43..e2bdea8 100644--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml@@ -160,6 +160,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="TipPreviewLoop">Wiedergabe im Exportbereich wiederholen (L)</s:String><s:String x:Key="TipPreviewLive">Dem neuesten Bild folgen, solange der Lauf läuft (F)</s:String><s:String x:Key="TipPreviewRun">Simulation von vorn starten (F5)</s:String>+ <s:String x:Key="TipPreviewStop">Simulation stoppen; die bisherigen Bilder bleiben (Esc)</s:String><s:String x:Key="TipPreviewShowField">Feldbild anzeigen</s:String><s:String x:Key="TipPreviewShowIntensity">Intensitätsbild anzeigen</s:String><s:String x:Key="TipMarkerFormat">{0}: zum Verschieben ziehen; mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xamlindex e31bb2e..f7247a9 100644--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml@@ -162,6 +162,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="TipPreviewLoop">Loop playback over the export range (L)</s:String><s:String x:Key="TipPreviewLive">Follow the newest frame while the run is in progress (F)</s:String><s:String x:Key="TipPreviewRun">Run the simulation from the start (F5)</s:String>+ <s:String x:Key="TipPreviewStop">Stop the simulation; the frames so far stay (Esc)</s:String><s:String x:Key="TipPreviewShowField">Show the field picture</s:String><s:String x:Key="TipPreviewShowIntensity">Show the intensity picture</s:String><s:String x:Key="TipMarkerFormat">{0}: drag to move; with keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xamlindex 02561e6..614baaa 100644--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml@@ -160,6 +160,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="TipPreviewLoop">Lire en boucle sur la plage d'export (L)</s:String><s:String x:Key="TipPreviewLive">Suivre l'image la plus récente pendant l'exécution (F)</s:String><s:String x:Key="TipPreviewRun">Lancer la simulation depuis le début (F5)</s:String>+ <s:String x:Key="TipPreviewStop">Arrêter la simulation ; les images calculées restent (Échap)</s:String><s:String x:Key="TipPreviewShowField">Afficher l'image du champ</s:String><s:String x:Key="TipPreviewShowIntensity">Afficher l'image de l'intensité</s:String><s:String x:Key="TipMarkerFormat">{0} : glisser pour déplacer ; avec le focus clavier, les flèches déplacent d'un pixel, de dix avec Maj</s:String>diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xamlindex 49571a2..b295792 100644--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml@@ -160,6 +160,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<s:String x:Key="TipPreviewLoop">Afspelen herhalen binnen het exportbereik (L)</s:String><s:String x:Key="TipPreviewLive">Het nieuwste beeld volgen zolang de run loopt (F)</s:String><s:String x:Key="TipPreviewRun">Simulatie vanaf het begin starten (F5)</s:String>+ <s:String x:Key="TipPreviewStop">Simulatie stoppen; de berekende beelden blijven (Esc)</s:String><s:String x:Key="TipPreviewShowField">Veldbeeld tonen</s:String><s:String x:Key="TipPreviewShowIntensity">Intensiteitsbeeld tonen</s:String><s:String x:Key="TipMarkerFormat">{0}: slepen om te verplaatsen; met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>diff --git a/_tools/ui_check/RunCheck.ps1 b/_tools/ui_check/RunCheck.ps1index 76e3157..e3778b1 100644--- a/_tools/ui_check/RunCheck.ps1+++ b/_tools/ui_check/RunCheck.ps1@@ -153,6 +153,8 @@ try {FocusOn "PreviewPlay"Key $VK_F5 100Check "F5: running" (WaitFor { (RunStatus) -like "Running:*" } 10000) (RunStatus)+ # the Run button is Stop while the run is in progress (2026-10-16); same id, told apart by its name+ Check "the Run button turned into Stop" (WaitFor { (Find "PreviewRun").Current.Name -like "Stop the simulation*" } 2000) ((Find "PreviewRun").Current.Name)$null = WaitFor { (Position) -ge 2 } 5000 50$f1 = Position$advanced = WaitFor { (Position) -gt $f1 } 5000 50@@ -165,8 +167,10 @@ try {Key $VK_F6 100Check "F6 resumes" (WaitFor { (RunStatus) -like "Running:*" } 5000) (RunStatus)$null = WaitFor { (Position) -ge 40 } 20000 50 # enough frames for the scrub checks below, however fast the keys are- Key $VK_ESCAPE 100- Check "Esc stops the run" (WaitFor { (RunStatus) -like "Stopped:*" } 10000) (RunStatus)+ FocusOn "PreviewRun"+ Key $VK_SPACE 100+ Check "Space on the Stop button stops the run" (WaitFor { (RunStatus) -like "Stopped:*" } 10000) (RunStatus)+ Check "the button is Run again" (WaitFor { (Find "PreviewRun").Current.Name -like "Run the simulation*" } 2000) ((Find "PreviewRun").Current.Name)Start-Sleep -Milliseconds 200$last = PositionCheck "the frames computed so far stay, the preview on the newest one, Live off" (-not (LiveOn) -and $last -gt 0 -and (Frame) -eq ("{0} / {0}" -f $last)) (Frame)