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 renamed project scheme takes the display layers that refer to it along
Alexander Graefb46efe00c647
diff --git a/CLAUDE.md b/CLAUDE.mdindex d9b117d..055598a 100644--- a/CLAUDE.md+++ b/CLAUDE.md@@ -198,8 +198,11 @@ WPF shell as it stands:Both go through the model, so the project turns dirty (asterisk, save prompt), the run goes stale and theframe is recomputed; a path change alone is not a simulation change. No hash: the embedded bytes are thebaseline and the file has to be read to re-embed it anyway. Open decisions: base64 vs BaseXML for the- bytes (base64 is what `XmlSerializer` does natively; BaseXML would need an in-house codec); renaming a project- scheme does not update the layers that refer to it. **The colour picker** (2026-10-15, the user's choice of an+ bytes (base64 is what `XmlSerializer` does natively; BaseXML would need an in-house codec). **A renamed project+ scheme takes its layers along** (2026-10-15): `Project` watches its scheme list and each scheme's `Name`, keeps+ the last known name per scheme, and on a rename sets every display layer that named the old name+ (case-insensitively) to the new one; in the model, so every editor and the importer get it, and a removed scheme+ is let go. The preview keeps its colours through a rename (the harness proves it by the field picture's hash). **The colour picker** (2026-10-15, the user's choice of anin-house picker over the Windows dialog, which is not themed, has no live preview and cannot be driven by postedkeys): each stop row's swatch is a `Controls/ColorPickerButton` (a `ToggleButton`; Space, Enter or Down open apopup below it, id `StopSwatch:<position>`, the hex box beside it `StopColor:<position>`, both in the locale's@@ -714,12 +717,15 @@ passing harnesses for comfort, never all of them after an edit.file and turns the project dirty, the status bar says so, the scene view shows the path; then the file isoverwritten on disk and the picture follows within a moment; a second project without a path finds itsimage by name in `scene_images` and stores the relative path (8 checks, about 40 s).- `_tools/ui_check/ColorPickerCheck.ps1` (2026-10-15, 11 checks, about 12 s) drives the stop swatch's picker on+ `_tools/ui_check/ColorPickerCheck.ps1` (2026-10-15, 13 checks, about 14 s) drives the stop swatch's picker on`tiny_scheme.wdproj` (tiny plus a project scheme with a middle stop #4080C0): End in the tree selects the scheme(the tree is one tab stop, End goes to its last visible item), Tab reaches the swatch, Space opens the popup withthe focus on the square, ten Left arrows make the stop #538AC0 at once (hue 210, saturation 2/3 - 1/10, value0.753, the number the library check also asserts), Escape puts #4080C0 back, Tab walks strip and red box, five- Up arrows make #4580C0, Enter keeps it; the popup's own window is captured as `%TEMP%\wavedude_color_picker.popup.png`.+ Up arrows make #4580C0, Enter keeps it, and typing a new name into the scheme's Name box (id `SchemeName`) renames+ the tree row while the field picture's hash stays, the layer having followed (the row's `Tree:<name>` id is bound to+ the item once and keeps the old name after a rename, so the row is found by the old id and read by its text); the+ popup's own window is captured as `%TEMP%\wavedude_color_picker.popup.png`.A `Rectangle` has no automation peer (the gradient's id `SchemeGradient` is invisible to UIA; the "Add stop"button marks the editor instead).`_tools/ui_check/AboutCheck.ps1` (2026-10-15, 18 checks, about 10 s) opens Help > About by keyboard (F10, Left wraps@@ -987,8 +993,7 @@ progress and cancel are in, and the still of the shown frame; `library_check --cover them. Left: probe data as CSV (series per step, profiles per frame), an integer upscale for smallcanvases, HEVC (Media Foundation has it on some machines). Author's point 10.-**Also open, smaller.** Offer `ColorScheme.Simplify` in the editor; renaming a project scheme does not update the layers that-refer to it; base64 vs BaseXML for the embedded image; the RAM-first frame store (numbers above);+**Also open, smaller.** Offer `ColorScheme.Simplify` in the editor; base64 vs BaseXML for the embedded image; the RAM-first frame store (numbers above);dropping the 9-point Laplacian (author's suggestion, user undecided); timeline event tracks, zoom andpan (roadmap); dock pane titles are not exposed to UI Automation.diff --git a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml b/WaveDudeNext.WPF/Views/ColorSchemeView.xamlindex da376e0..08cf185 100644--- a/WaveDudeNext.WPF/Views/ColorSchemeView.xaml+++ b/WaveDudeNext.WPF/Views/ColorSchemeView.xaml@@ -77,7 +77,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or<Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionGeneral}" /><controls:FormPanel><TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label rendering:ColorScheme.Name}" />- <TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ToolTip="{meta:Hint rendering:ColorScheme.Name}" />+ <TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ToolTip="{meta:Hint rendering:ColorScheme.Name}"+ AutomationProperties.AutomationId="SchemeName" /><TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label rendering:ColorScheme.Kind}" /><ComboBox Style="{StaticResource EnumComboBox}" ItemsSource="{meta:EnumValues rendering:ColorSchemeKind}"diff --git a/WaveDudeNext/Model/Project.cs b/WaveDudeNext/Model/Project.csindex 0155de8..e67016f 100644--- a/WaveDudeNext/Model/Project.cs+++ b/WaveDudeNext/Model/Project.cs@@ -46,6 +46,14 @@ public sealed class Project : ObservableObjectprivate ObservableCollection<Source> _sources = new();private ObservableCollection<Probe> _probes = new();private ObservableCollection<ColorScheme> _colorSchemes = new();+ /// <summary>Each project scheme's last known name, so a rename can repoint the layers that referred to the old one.</summary>+ private readonly Dictionary<ColorScheme, string> _schemeNames = new();++ /// <summary>A new project with the designer defaults; its scheme list is watched from the start.</summary>+ public Project()+ {+ HookSchemes(_colorSchemes);+ }private static readonly ILogger Logger = LogManager.GetCurrentClassLogger();private static readonly XmlSerializer Serializer = new(typeof(Project));@@ -158,7 +166,115 @@ public sealed class Project : ObservableObjectpublic ObservableCollection<ColorScheme> ColorSchemes{get => _colorSchemes;- set => SetProperty(ref _colorSchemes, value);+ set+ {+ ObservableCollection<ColorScheme> old = _colorSchemes;+ if (SetProperty(ref _colorSchemes, value))+ {+ UnhookSchemes(old);+ HookSchemes(value);+ }+ }+ }++ // ---------------------------------------------------------------- a renamed scheme takes its layers along (2026-10-15)++ private void HookSchemes(ObservableCollection<ColorScheme>? schemes)+ {+ if (schemes == null)+ {+ return;+ }+ schemes.CollectionChanged += OnSchemesChanged;+ foreach (ColorScheme scheme in schemes)+ {+ TrackScheme(scheme);+ }+ }++ private void UnhookSchemes(ObservableCollection<ColorScheme>? schemes)+ {+ if (schemes == null)+ {+ return;+ }+ schemes.CollectionChanged -= OnSchemesChanged;+ foreach (ColorScheme scheme in schemes)+ {+ UntrackScheme(scheme);+ }+ }++ private void TrackScheme(ColorScheme scheme)+ {+ if (_schemeNames.TryAdd(scheme, scheme.Name))+ {+ scheme.PropertyChanged += OnSchemeChanged;+ }+ }++ private void UntrackScheme(ColorScheme scheme)+ {+ if (_schemeNames.Remove(scheme))+ {+ scheme.PropertyChanged -= OnSchemeChanged;+ }+ }++ private void OnSchemesChanged(object? sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e)+ {+ if (e.Action == System.Collections.Specialized.NotifyCollectionChangedAction.Reset)+ {+ foreach (ColorScheme scheme in _schemeNames.Keys.ToList())+ {+ UntrackScheme(scheme);+ }+ foreach (ColorScheme scheme in _colorSchemes)+ {+ TrackScheme(scheme);+ }+ return;+ }+ if (e.OldItems != null)+ {+ foreach (ColorScheme scheme in e.OldItems)+ {+ UntrackScheme(scheme);+ }+ }+ if (e.NewItems != null)+ {+ foreach (ColorScheme scheme in e.NewItems)+ {+ TrackScheme(scheme);+ }+ }+ }++ /// <summary>+ /// A project scheme was renamed: every display layer that named it (case-insensitively) names it by its new name,+ /// so the preview keeps its colours and the file stays consistent. Done here, in the model, so every editor and+ /// the importer get it, not just the scheme view.+ /// </summary>+ private void OnSchemeChanged(object? sender, PropertyChangedEventArgs e)+ {+ if (e.PropertyName != nameof(ColorScheme.Name) || sender is not ColorScheme scheme || !_schemeNames.TryGetValue(scheme, out string? oldName))+ {+ return;+ }+ string newName = scheme.Name;+ _schemeNames[scheme] = newName;+ if (string.Equals(oldName, newName, StringComparison.Ordinal))+ {+ return;+ }+ foreach (DisplayLayer layer in new[] { Display.Field, Display.Intensity })+ {+ if (string.Equals(layer.ColorScheme, oldName, StringComparison.OrdinalIgnoreCase))+ {+ layer.ColorScheme = newName;+ }+ }}/// <summary>Tells <see cref="XmlSerializer"/> to leave an all-default scene out of the file.</summary>diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.csindex 6dab52c..7816aea 100644--- a/_tools/library_check/Program.cs+++ b/_tools/library_check/Program.cs@@ -1040,6 +1040,20 @@ internal static class Programstream.Position = 0;Project loaded = Project.Load(stream);Check(loaded.ColorSchemes.Count == 1 && loaded.ColorSchemes[0].Name == "Mine" && loaded.ColorSchemes[0].Colors.SequenceEqual(field.Colors), "a project file embeds its own schemes");+ // a renamed project scheme takes the layers that refer to it along (2026-10-15), in a fresh and in a loaded project+ project.Display.Field.ColorScheme = "mine";+ project.Display.Intensity.ColorScheme = "Other";+ project.ColorSchemes[0].Name = "Yours";+ loaded.Display.Field.ColorScheme = "Mine";+ loaded.ColorSchemes[0].Name = "Theirs";+ ColorScheme later = project.AddColorScheme();+ project.Display.Intensity.ColorScheme = later.Name;+ later.Name = "Later";+ ColorScheme gone = project.AddColorScheme();+ project.Remove(gone);+ gone.Name = "Yours";+ Check(project.Display.Field.ColorScheme == "Yours" && project.Display.Intensity.ColorScheme == "Later" && loaded.Display.Field.ColorScheme == "Theirs" && loaded.Display.Intensity.ColorScheme == Display.DefaultIntensityColorScheme,+ "a renamed project scheme takes the layers naming it along (case-insensitively; a scheme added later too, a removed one no more; a loaded project as well)");Check(loaded.Scene.ImageData != null && loaded.Scene.ImageData.SequenceEqual(project.Scene.ImageData) && loaded.Scene.Image == "scene.png", "a project file embeds the scene image bytes (base64)");// the image's source path (2026-10-15): relative inside the project folder, absolute elsewhere, resolved back, not a simulation changestring projectFolder = Path.Combine(Path.GetTempPath(), "wd-project");diff --git a/_tools/ui_check/ColorPickerCheck.ps1 b/_tools/ui_check/ColorPickerCheck.ps1index c9ae340..bf5e97e 100644--- a/_tools/ui_check/ColorPickerCheck.ps1+++ b/_tools/ui_check/ColorPickerCheck.ps1@@ -20,7 +20,8 @@# scheme in the tree, Tabs to the stop's swatch, Space opens the popup with the focus on the saturation/value# square, ten Left arrows lower the saturation by a tenth (the hex box beside the swatch shows #538AC0 at once),# Escape puts #4080C0 back and closes, a second opening Tabs to the red channel box, five Up arrows make it #4580C0-# and Enter keeps it; the project is dirty afterwards. See Common.ps1 for the rules (no mouse, no activation, no+# and Enter keeps it; renaming the scheme in its Name box keeps the field picture's colours, since the layer follows+# the rename; the project is dirty afterwards. See Common.ps1 for the rules (no mouse, no activation, no# UIA patterns). Prints PASS/FAIL per check and exits with the failure count.## powershell -ExecutionPolicy Bypass -File _tools\ui_check\ColorPickerCheck.ps1 [-Exe <path>] [-Shot <png>] [-Trace]@@ -77,6 +78,17 @@ try {Step "End" $VK_END 300$null = WaitFor { try { (Find "SchemeAddStop") -ne $null } catch { $false } } 5000 100Check "End in the tree selects the scheme, whose editor appears" ((FocusedId) -eq "Tree:Harness scheme" -and (Find "SchemeAddStop") -ne $null) (FocusedId)+ # a rename of the scheme takes the field layer along: the picture keeps its colours (the default scheme would recolour it)+ $before = FieldHash+ FocusOn "SchemeName" # the first stop after the tree+ Key $VK_END 100+ for ($i = 0; $i -lt 14; $i++) { Key $VK_BACK 30 } # "Harness scheme"+ foreach ($ch in "Renamed".ToCharArray()) { [Native]::Char($hwnd, $ch) }+ Start-Sleep -Milliseconds 600+ # the tree row's id is bound once (the item, not its name), so the row is found by the old id and read by its text+ $row = (Find "Tree:Harness scheme").Current.Name+ Check "typing a new scheme name renames the tree row" ($row -eq "Renamed") $row+ Check "and the field picture keeps its colours: the layer followed the rename" ((FieldHash) -eq $before) ("hash {0} -> {1}" -f $before, (FieldHash))FocusOn $swatchCheck "Tab reaches the middle stop's swatch, whose hex box says #4080C0" ((Hex $hexBox) -eq "#4080C0") (Hex $hexBox)