Skip to content

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#

Probe data as CSV from the probe's context menu in the tree and on its graph box

Alexander Graef6f0f0c9c14f3
diff --git a/.gitignore b/.gitignore
index 586134a..4bc2c35 100644
--- a/.gitignore
+++ b/.gitignore
@@ -14,24 +14,19 @@ _tools/*.txt
# Claude Code local permissions
.claude/settings.local.json
-# exports and saved projects beside the author's examples are never committed
+# exports and saved projects beside the author's examples are never committed: pictures, videos, data, probe CSVs
Wave_Dude_Examples/**/*.wdproj
Wave_Dude_Examples/**/*.avi
Wave_Dude_Examples/**/*.mp4
Wave_Dude_Examples/**/*.mpg
+Wave_Dude_Examples/**/*.mpeg
Wave_Dude_Examples/**/*.mov
+Wave_Dude_Examples/**/*.exr
+Wave_Dude_Examples/**/*.csv
Wave_Dude_Examples/**/*_field/
Wave_Dude_Examples/**/*_intensity/
Wave_Dude_Examples/**/*_field_*.png
Wave_Dude_Examples/**/*_intensity_*.png
-
-# exports and saved projects beside the author's examples are never committed
-Wave_Dude_Examples/**/*.wdproj
-Wave_Dude_Examples/**/*.avi
-Wave_Dude_Examples/**/*.mp4
-Wave_Dude_Examples/**/*.mpg
-Wave_Dude_Examples/**/*_field/
-Wave_Dude_Examples/**/*_intensity/
-Wave_Dude_Examples/**/*_field_*.png
-Wave_Dude_Examples/**/*_intensity_*.png
+Wave_Dude_Examples/**/*_field_*.jpg
+Wave_Dude_Examples/**/*_intensity_*.jpg
desktop.ini
diff --git a/CLAUDE.md b/CLAUDE.md
index a376eba..0a53181 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -135,6 +135,9 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA
- **Export**: field, intensity or both, a still of the shown frame, from the current run when fresh and full,
else a run is made first; PNG/JPEG sequences, MPEG-1, OpenDML AVI, H.264 MP4 via Media Foundation (the only
Windows-bound library piece besides WIC JPEG, which has an in-house fallback), QuickTime Animation MOV, and
+ **probe data as CSV** (2026-10-18: a probe's context menu in the tree and on its graph box; semicolons, decimal
+ point, a header row; a point probe one row per step, a line probe one row per frame; the full run like the
+ pictures, started first when needed),
**JPEG is 4:4:4 in both encoders** (2026-10-18: WIC called natively for its subsampling option, which WPF's
wrapper never set; 4:2:0 averaged the colour, where a wave picture's information is, into blocky fringes even
at quality 100; 4:4:4 at 90 beat it in every channel at half the size), and
@@ -164,7 +167,7 @@ numbers: no GPU JPEG, no OpenCL colouring at presentation, no `Vector256`, no Di
`library_check` (100+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export, parts).
UI, all on `Common.ps1`, with their check counts: `PreviewCheck` 43, `RunCheck` 71, `LanguageCheck` 11,
-`ProbeGraphCheck` 39, `ImportCheck` 10, `ExportCheck` 30, `PreviewQualityCheck` 35, `SceneImageCheck` 8,
+`ProbeGraphCheck` 39, `ImportCheck` 10, `ExportCheck` 38, `PreviewQualityCheck` 35, `SceneImageCheck` 8,
`ColorPickerCheck` 13, `KeyboardCheck` 13, `AboutCheck` 18. Test projects `tiny*.wdproj` sit beside them. A harness
sets the persisted settings it expects (split orientation, preview quality). Known flake: a second app start in one
script sometimes comes up active; only the foreground guard fails then.
@@ -180,7 +183,7 @@ never reworded per file.
## Open items
README and a documentation file (he writes them); release (single-file publish, portable archive, signed installer,
-curated examples from Jeroen, his program as preserved assets, repository rename); probe data as CSV; an integer
+curated examples from Jeroen, his program as preserved assets, repository rename); an integer
upscale in exports; HEVC; the start-up stall (log milestones first); the GPU readback (a second OpenCL queue);
automatic quality lowering when a run would spill (undecided); dropping the 9-point Laplacian (undecided);
**optical parts**: stages 1 and 2 of `OpticalParts.md` built 2026-10-18 (uncommitted); stage 3 (a `PartCheck.ps1`
diff --git a/WaveDudeNext.WPF/Commands/ExportCommands.cs b/WaveDudeNext.WPF/Commands/ExportCommands.cs
index b193cf6..b47ef2a 100644
--- a/WaveDudeNext.WPF/Commands/ExportCommands.cs
+++ b/WaveDudeNext.WPF/Commands/ExportCommands.cs
@@ -42,4 +42,11 @@ public static class ExportCommands
/// <summary>Exports the intensity frame the preview shows as one image.</summary>
public static readonly RoutedUICommand IntensityFrame = new("Export intensity frame", nameof(IntensityFrame), typeof(ExportCommands));
+
+ /// <summary>
+ /// Writes a probe's recording as a CSV file (2026-10-18); the parameter is the <see cref="Model.Probe"/>.
+ /// Offered on the probe's node in the project tree and on its graph box. Like the pictures it exports the
+ /// full run, started first when there is none or it is stale.
+ /// </summary>
+ public static readonly RoutedUICommand ProbeCsv = new("Export probe data", nameof(ProbeCsv), typeof(ExportCommands));
}
diff --git a/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs b/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
index 67217b5..3c651c6 100644
--- a/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
+++ b/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
@@ -268,6 +268,14 @@ public sealed class ProbeGraphOverlay : Panel
thumb.DragStarted += OnDragStarted;
thumb.DragDelta += OnDragDelta;
thumb.GotKeyboardFocus += (_, _) => SelectedItem = probe;
+ if (role == MarkerRole.ProbeBox)
+ {
+ // the box's context menu (2026-10-18): the probe's recording as CSV; the header follows the language like the XAML menus
+ var export = new MenuItem { Command = Commands.ExportCommands.ProbeCsv, CommandParameter = probe, CommandTarget = thumb };
+ export.SetResourceReference(HeaderedItemsControl.HeaderProperty, "MenuExportProbeCsv");
+ AutomationProperties.SetAutomationId(export, "ContextExportProbeCsv");
+ thumb.ContextMenu = new ContextMenu { Items = { export } };
+ }
Children.Add(thumb);
}
diff --git a/WaveDudeNext.WPF/Converters/IsTypeConverter.cs b/WaveDudeNext.WPF/Converters/IsTypeConverter.cs
new file mode 100644
index 0000000..eb2dc82
--- /dev/null
+++ b/WaveDudeNext.WPF/Converters/IsTypeConverter.cs
@@ -0,0 +1,38 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Globalization;
+using System.Windows;
+using System.Windows.Data;
+
+namespace WaveDudeNext.WPF.Converters;
+
+/// <summary>
+/// <see cref="Visibility.Visible"/> when the bound value is an instance of the type given as the parameter,
+/// else <see cref="Visibility.Collapsed"/>: for a menu entry that only one kind of node offers (the probe's
+/// CSV export in the tree's shared context menu, 2026-10-18).
+/// </summary>
+public sealed class IsTypeConverter : IValueConverter
+{
+ /// <inheritdoc/>
+ public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) =>
+ parameter is Type type && type.IsInstanceOfType(value) ? Visibility.Visible : Visibility.Collapsed;
+
+ /// <inheritdoc/>
+ public object ConvertBack(object? value, Type targetType, object? parameter, CultureInfo culture) =>
+ throw new NotSupportedException();
+}
diff --git a/WaveDudeNext.WPF/MainWindow.Export.cs b/WaveDudeNext.WPF/MainWindow.Export.cs
index b4839f6..77d20a4 100644
--- a/WaveDudeNext.WPF/MainWindow.Export.cs
+++ b/WaveDudeNext.WPF/MainWindow.Export.cs
@@ -22,6 +22,7 @@ using Microsoft.Win32;
using WaveDudeNext.Engine;
using WaveDudeNext.Export;
using WaveDudeNext.Model;
+using WaveDudeNext.Probes;
using WaveDudeNext.Rendering;
using WaveDudeNext.Runs;
using WaveDudeNext.WPF.Dialogs;
@@ -41,7 +42,9 @@ namespace WaveDudeNext.WPF;
/// run to export: when there is none, it is stale, or it lacks the intensity plane, a run is started first
/// (like Play does) and the export waits for it (<see cref="IsExportWaiting"/>). The <see cref="ExportJob"/>
/// works on its own thread and reports to the status bar's busy indicator; Esc cancels it. Runs are not
-/// started or replaced while an export reads the store.
+/// started or replaced while an export reads the store. A probe's recording goes out as a CSV file the same
+/// way (<see cref="Commands.ExportCommands.ProbeCsv"/>, 2026-10-18): the Save dialog, the full run, then the
+/// run's trace of the probe written by <see cref="ProbeCsv"/> on the UI thread (a few megabytes at most).
/// </summary>
public partial class MainWindow
{
@@ -90,6 +93,77 @@ public partial class MainWindow
private void OnExportIntensityFrame(object sender, ExecutedRoutedEventArgs e) => BeginExport(field: false, intensity: true, still: true);
+ /// <summary>An active probe only: a disabled one is not in any run.</summary>
+ private void CanExportProbeCsv(object sender, CanExecuteRoutedEventArgs e) =>
+ e.CanExecute = e.Parameter is Probe { Active: true } && !IsExporting && Project.Simulation.Steps > 0;
+
+ /// <summary>The Save dialog, the full run (started first when there is none or it is stale, like the pictures), the probe's trace as CSV.</summary>
+ private async void OnExportProbeCsv(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Parameter is not Probe probe || IsExporting)
+ {
+ return;
+ }
+ string suggested = ProbeCsv.FileName(ProjectName(), probe);
+ string chosen;
+ string? scripted = Environment.GetEnvironmentVariable("WAVEDUDE_EXPORT_PATH");
+ if (!string.IsNullOrEmpty(scripted))
+ {
+ // the harness hook of the picture exports: "{name}" stands for the suggested name
+ chosen = scripted.Replace("{name}", Path.GetFileNameWithoutExtension(suggested), StringComparison.Ordinal);
+ Logger.Debug("Export path taken from WAVEDUDE_EXPORT_PATH: {Path}", chosen);
+ }
+ else
+ {
+ var dialog = new SaveFileDialog
+ {
+ Title = (string)FindResource("ExportDialogTitleProbeCsv"),
+ Filter = (string)FindResource("ExportDialogFilterCsv"),
+ AddExtension = true,
+ DefaultExt = ProbeCsv.Extension,
+ FileName = suggested,
+ InitialDirectory = ProjectFolder ?? (Directory.Exists(Settings.Default.LastExportFolder) ? Settings.Default.LastExportFolder : ""),
+ };
+ if (dialog.ShowDialog(this) != true)
+ {
+ Logger.Debug("Probe export cancelled in the Save dialog");
+ return;
+ }
+ chosen = dialog.FileName;
+ Settings.Default.LastExportFolder = Path.GetDirectoryName(chosen) ?? "";
+ }
+ Logger.Debug("Export: probe '{Probe}' ({Kind}, {Layer}, {Measurement}) as CSV to {Path}", probe.Name, probe.Kind, probe.Layer, probe.Measurement, chosen);
+ SimulationRun? run = await EnsureRunForExport(intensity: probe.Layer == ProbeLayer.Intensity, needsHalves: false);
+ if (run == null)
+ {
+ return;
+ }
+ ProbeTrace? trace = null;
+ for (int i = 0; i < run.Spec.Probes.Length && i < run.Traces.Length; i++)
+ {
+ if (ReferenceEquals(run.Spec.Probes[i].Origin, probe))
+ {
+ trace = run.Traces[i];
+ }
+ }
+ if (trace == null)
+ {
+ Logger.Error("Probe '{Probe}' is not in the run (removed or disabled while it was waited for)", probe.Name);
+ MessageWindow.Show(this, (string)FindResource("ExportError"), MessageKind.Error, MessageButtons.Ok);
+ return;
+ }
+ try
+ {
+ int rows = ProbeCsv.Write(chosen, probe, trace, run.Spec.VisualizeEvery, run.Spec.FrameStride);
+ Logger.Info("Probe data written: {Rows} rows of '{Probe}' to {Path}", rows, probe.Name, chosen);
+ }
+ catch (Exception ex) when (ex is IOException or UnauthorizedAccessException)
+ {
+ Logger.Error(ex, "The probe data could not be written: {Message}", ex.Message);
+ ShowError((string)FindResource("ExportError"), ex);
+ }
+ }
+
/// <summary>The Save dialog, the run, the targets, the job.</summary>
/// <param name="field">Export the field.</param>
/// <param name="intensity">Export the intensity.</param>
@@ -192,7 +266,7 @@ public partial class MainWindow
}
}
}
- SimulationRun? run = await EnsureRunForExport(intensity, format);
+ SimulationRun? run = await EnsureRunForExport(intensity, ExportFormats.IsData(format));
if (run == null)
{
return;
@@ -287,7 +361,9 @@ public partial class MainWindow
/// holds the intensity plane if asked for; otherwise a run is started and awaited. Null when no run could
/// be had (logged, and an error shown when the run could not start).
/// </summary>
- private async Task<SimulationRun?> EnsureRunForExport(bool intensity, ExportFormat format)
+ /// <param name="intensity">The run must hold the intensity plane.</param>
+ /// <param name="needsHalves">The run must hold 16-bit samples (a data export); otherwise the 8-bit index does.</param>
+ private async Task<SimulationRun?> EnsureRunForExport(bool intensity, bool needsHalves)
{
IsExportWaiting = true;
try
@@ -298,9 +374,9 @@ public partial class MainWindow
// a reduced preview serves a picture export when only its samples are reduced: the 8-bit index gives the
// same pixels (2026-10-18); a smaller picture or skipped frames never do, and a data export needs the halves
PreviewQuality? quality = run?.Spec.Quality;
- bool reduced = quality != null && (quality.ResolutionDivisor != 1 || quality.FrameDivisor != 1 || (quality.Format != FrameFormat.Half && ExportFormats.IsData(format)));
+ bool reduced = quality != null && (quality.ResolutionDivisor != 1 || quality.FrameDivisor != 1 || (quality.Format != FrameFormat.Half && needsHalves));
string? reason = run == null ? "no run" : IsRunStale ? "the run is stale" : IsProbesStale ? "the probes were edited since the run"
- : reduced ? (quality!.Format != FrameFormat.Half && ExportFormats.IsData(format) && quality.ResolutionDivisor == 1 && quality.FrameDivisor == 1 ? "a data export needs the 16-bit samples" : "the run is a reduced preview (View menu)")
+ : reduced ? (quality!.Format != FrameFormat.Half && needsHalves && quality.ResolutionDivisor == 1 && quality.FrameDivisor == 1 ? "a data export needs the 16-bit samples" : "the run is a reduced preview (View menu)")
: intensity && !run.Store.Has(FrameLayer.Intensity) ? "the run has no intensity plane" : !run.IsActive && run.State != RunState.Completed ? "the run did not complete" : null;
if (reason != null)
{
diff --git a/WaveDudeNext.WPF/MainWindow.xaml b/WaveDudeNext.WPF/MainWindow.xaml
index d698112..d99291b 100644
--- a/WaveDudeNext.WPF/MainWindow.xaml
+++ b/WaveDudeNext.WPF/MainWindow.xaml
@@ -166,6 +166,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<CommandBinding Command="{x:Static commands:ExportCommands.Both}" CanExecute="CanExport" Executed="OnExportBoth" />
<CommandBinding Command="{x:Static commands:ExportCommands.FieldFrame}" CanExecute="CanExport" Executed="OnExportFieldFrame" />
<CommandBinding Command="{x:Static commands:ExportCommands.IntensityFrame}" CanExecute="CanExport" Executed="OnExportIntensityFrame" />
+ <CommandBinding Command="{x:Static commands:ExportCommands.ProbeCsv}" CanExecute="CanExportProbeCsv" Executed="OnExportProbeCsv" />
<CommandBinding Command="{x:Static commands:SimulationCommands.EnsureRun}" Executed="OnEnsureRun" />
<CommandBinding Command="{x:Static commands:SimulationCommands.SetFrameMemory}" Executed="OnSetFrameMemory" />
<!-- the preview quality (View menu); handlers in MainWindow.xaml.cs -->
diff --git a/WaveDudeNext.WPF/Panes/ProjectTree.xaml b/WaveDudeNext.WPF/Panes/ProjectTree.xaml
index fc0003b..481d9f5 100644
--- a/WaveDudeNext.WPF/Panes/ProjectTree.xaml
+++ b/WaveDudeNext.WPF/Panes/ProjectTree.xaml
@@ -31,6 +31,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<converters:NamedCollectionConverter x:Key="NamedCollections" />
<converters:ColorSchemeBrushConverter x:Key="ColorSchemeBrush" />
<converters:TreeIdConverter x:Key="TreeId" />
+ <converters:IsTypeConverter x:Key="IsType" />
<StreamGeometry x:Key="PlusGeometry">M4,0 L4,8 M0,4 L8,4</StreamGeometry>
<StreamGeometry x:Key="MinusGeometry">M0,4 L8,4</StreamGeometry>
@@ -174,6 +175,10 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<Separator />
<MenuItem Header="{DynamicResource MenuProjectMoveUp}" Command="{x:Static commands:ProjectCommands.MoveUp}" InputGestureText="Alt+Up" />
<MenuItem Header="{DynamicResource MenuProjectMoveDown}" Command="{x:Static commands:ProjectCommands.MoveDown}" InputGestureText="Alt+Down" />
+ <!-- a probe's recording as CSV (2026-10-18): only a probe node shows the entry -->
+ <Separator Visibility="{Binding Converter={StaticResource IsType}, ConverterParameter={x:Type model:Probe}}" />
+ <MenuItem Header="{DynamicResource MenuExportProbeCsv}" Command="{x:Static commands:ExportCommands.ProbeCsv}" AutomationProperties.AutomationId="ContextExportProbeCsv"
+ Visibility="{Binding Converter={StaticResource IsType}, ConverterParameter={x:Type model:Probe}}" />
</ContextMenu>
</Setter.Value>
</Setter>
diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
index a3528b5..54b7786 100644
--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
@@ -39,6 +39,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuFileExportFieldFrame">Feld-Ein_zelbild exportieren...</s:String>
<s:String x:Key="MenuFileExportIntensityFrame">Intensitäts-Einzelbild e_xportieren...</s:String>
<s:String x:Key="MenuExportThisFrame">_Dieses Bild exportieren...</s:String>
+ <s:String x:Key="MenuExportProbeCsv">Sonden_daten als CSV exportieren...</s:String>
<s:String x:Key="MenuFileExit">_Beenden</s:String>
<s:String x:Key="MenuView">_Ansicht</s:String>
<s:String x:Key="MenuViewPanes">_Fenster</s:String>
@@ -205,6 +206,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="ExportDialogTitleBoth">Feld und Intensität exportieren</s:String>
<s:String x:Key="ExportDialogFilterStill">PNG-Bild (*.png)|*.png|JPEG-Bild (*.jpg)|*.jpg|OpenEXR-Bild, 16-Bit-Gleitkommadaten (*.exr)|*.exr</s:String>
<s:String x:Key="ExportDialogTitleFrame">Bild exportieren</s:String>
+ <s:String x:Key="ExportDialogTitleProbeCsv">Sondendaten exportieren</s:String>
+ <s:String x:Key="ExportDialogFilterCsv">CSV-Datei (*.csv)|*.csv</s:String>
<s:String x:Key="ExportFolderExistsFormat">Der Ordner {0} existiert und enthält Dateien. Ersetzen?</s:String>
<s:String x:Key="ExportError">Der Export ist fehlgeschlagen.</s:String>
<s:String x:Key="ExportStatusFormat">Exportiere {0} / {1} Bilder</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
index 7cfb2de..94685b0 100644
--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
@@ -39,6 +39,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuFileExportFieldFrame">Export field f_rame...</s:String>
<s:String x:Key="MenuFileExportIntensityFrame">Export intensity fra_me...</s:String>
<s:String x:Key="MenuExportThisFrame">Export _this frame...</s:String>
+ <s:String x:Key="MenuExportProbeCsv">Export probe _data as CSV...</s:String>
<s:String x:Key="MenuFileExit">E_xit</s:String>
<s:String x:Key="MenuView">_View</s:String>
<s:String x:Key="MenuViewPanes">_Panes</s:String>
@@ -207,6 +208,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="ExportDialogTitleBoth">Export the field and the intensity</s:String>
<s:String x:Key="ExportDialogFilterStill">PNG image (*.png)|*.png|JPEG image (*.jpg)|*.jpg|OpenEXR image, 16-bit float data (*.exr)|*.exr</s:String>
<s:String x:Key="ExportDialogTitleFrame">Export the frame</s:String>
+ <s:String x:Key="ExportDialogTitleProbeCsv">Export the probe data</s:String>
+ <s:String x:Key="ExportDialogFilterCsv">CSV file (*.csv)|*.csv</s:String>
<s:String x:Key="ExportFolderExistsFormat">The folder {0} exists and holds files. Replace them?</s:String>
<s:String x:Key="ExportError">The export failed.</s:String>
<s:String x:Key="ExportStatusFormat">Exporting {0} / {1} frames</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
index 4eea9ff..be6c35f 100644
--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
@@ -39,6 +39,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuFileExportFieldFrame">Exporter l'i_mage du champ...</s:String>
<s:String x:Key="MenuFileExportIntensityFrame">Exporter l'image de l'intensi_té...</s:String>
<s:String x:Key="MenuExportThisFrame">Exporter _cette image...</s:String>
+ <s:String x:Key="MenuExportProbeCsv">Exporter les _données de la sonde en CSV...</s:String>
<s:String x:Key="MenuFileExit">_Quitter</s:String>
<s:String x:Key="MenuView">_Affichage</s:String>
<s:String x:Key="MenuViewPanes">_Panneaux</s:String>
@@ -205,6 +206,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="ExportDialogTitleBoth">Exporter le champ et l'intensité</s:String>
<s:String x:Key="ExportDialogFilterStill">Image PNG (*.png)|*.png|Image JPEG (*.jpg)|*.jpg|Image OpenEXR, données flottantes 16 bits (*.exr)|*.exr</s:String>
<s:String x:Key="ExportDialogTitleFrame">Exporter l'image</s:String>
+ <s:String x:Key="ExportDialogTitleProbeCsv">Exporter les données de la sonde</s:String>
+ <s:String x:Key="ExportDialogFilterCsv">Fichier CSV (*.csv)|*.csv</s:String>
<s:String x:Key="ExportFolderExistsFormat">Le dossier {0} existe et contient des fichiers. Les remplacer ?</s:String>
<s:String x:Key="ExportError">L'export a échoué.</s:String>
<s:String x:Key="ExportStatusFormat">Export : {0} / {1} images</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
index 27c67dd..5fa3746 100644
--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
@@ -39,6 +39,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuFileExportFieldFrame">Veld_beeld exporteren...</s:String>
<s:String x:Key="MenuFileExportIntensityFrame">Intensiteitsbeel_d exporteren...</s:String>
<s:String x:Key="MenuExportThisFrame">_Dit beeld exporteren...</s:String>
+ <s:String x:Key="MenuExportProbeCsv">Sonde_gegevens als CSV exporteren...</s:String>
<s:String x:Key="MenuFileExit">A_fsluiten</s:String>
<s:String x:Key="MenuView">Beel_d</s:String>
<s:String x:Key="MenuViewPanes">_Panelen</s:String>
@@ -205,6 +206,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="ExportDialogTitleBoth">Veld en intensiteit exporteren</s:String>
<s:String x:Key="ExportDialogFilterStill">PNG-beeld (*.png)|*.png|JPEG-beeld (*.jpg)|*.jpg|OpenEXR-beeld, 16-bits drijvendekommagegevens (*.exr)|*.exr</s:String>
<s:String x:Key="ExportDialogTitleFrame">Beeld exporteren</s:String>
+ <s:String x:Key="ExportDialogTitleProbeCsv">Sondegegevens exporteren</s:String>
+ <s:String x:Key="ExportDialogFilterCsv">CSV-bestand (*.csv)|*.csv</s:String>
<s:String x:Key="ExportFolderExistsFormat">De map {0} bestaat en bevat bestanden. Vervangen?</s:String>
<s:String x:Key="ExportError">De export is mislukt.</s:String>
<s:String x:Key="ExportStatusFormat">Exporteren: {0} / {1} beelden</s:String>
diff --git a/WaveDudeNext.sln b/WaveDudeNext.sln
index 79dee51..d9de221 100644
--- a/WaveDudeNext.sln
+++ b/WaveDudeNext.sln
@@ -11,6 +11,7 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
ProjectSection(SolutionItems) = preProject
CLAUDE.md = CLAUDE.md
LICENSE.md = LICENSE.md
+ OpticalParts.md = OpticalParts.md
README.md = README.md
EndProjectSection
EndProject
diff --git a/WaveDudeNext/Export/ProbeCsv.cs b/WaveDudeNext/Export/ProbeCsv.cs
new file mode 100644
index 0000000..0e5f42a
--- /dev/null
+++ b/WaveDudeNext/Export/ProbeCsv.cs
@@ -0,0 +1,132 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Globalization;
+using WaveDudeNext.Model;
+using WaveDudeNext.Probes;
+
+namespace WaveDudeNext.Export;
+
+/// <summary>
+/// Writes a probe's recording as a CSV file (2026-10-18, the user's format: a semicolon between columns, a
+/// decimal point, a header row, nothing else). A point probe gives one row per simulation step,
+/// <c>step;&lt;measurement&gt;</c>, the step numbered like the readout (0-based); a line probe one row per
+/// recorded frame, <c>frame;step</c> and one column per sample along the line, headed by the sample's
+/// distance from A in canvas pixels. Values are written in round-trip precision, invariant culture. Any
+/// thread, as long as the trace is not being filled meanwhile (a completed run's is not).
+/// </summary>
+public static class ProbeCsv
+{
+ /// <summary>The column separator.</summary>
+ public const string Separator = ";";
+
+ /// <summary>The file extension.</summary>
+ public const string Extension = ".csv";
+
+ /// <summary>
+ /// The file name proposed for a probe: the project's name, an underscore and the probe's name, characters a
+ /// file name cannot hold replaced by underscores, with the extension.
+ /// </summary>
+ /// <param name="projectName">The project's name for a file.</param>
+ /// <param name="probe">The probe.</param>
+ public static string FileName(string projectName, Probe probe)
+ {
+ char[] name = probe.Name.Trim().ToCharArray();
+ char[] invalid = Path.GetInvalidFileNameChars();
+ for (int i = 0; i < name.Length; i++)
+ {
+ if (Array.IndexOf(invalid, name[i]) >= 0)
+ {
+ name[i] = '_';
+ }
+ }
+ string probeName = new string(name);
+ return projectName + "_" + (probeName.Length == 0 ? "probe" : probeName) + Extension;
+ }
+
+ /// <summary>Writes the recording of <paramref name="probe"/> to the file at <paramref name="path"/> (replaced when it exists); returns the number of data rows.</summary>
+ /// <param name="path">The file to write.</param>
+ /// <param name="probe">The probe, for its kind and measurement.</param>
+ /// <param name="trace">The probe's recording from the run.</param>
+ /// <param name="visualizeEvery">Steps per timeline frame of the run.</param>
+ /// <param name="frameStride">Timeline frames per recorded frame of the run (1 for a full run).</param>
+ public static int Write(string path, Probe probe, ProbeTrace trace, int visualizeEvery, int frameStride)
+ {
+ using var writer = new StreamWriter(path);
+ return Write(writer, probe, trace, visualizeEvery, frameStride);
+ }
+
+ /// <summary>Writes the recording of <paramref name="probe"/> to <paramref name="writer"/>; returns the number of data rows.</summary>
+ /// <param name="writer">Destination; left open.</param>
+ /// <param name="probe">The probe, for its kind and measurement.</param>
+ /// <param name="trace">The probe's recording from the run.</param>
+ /// <param name="visualizeEvery">Steps per timeline frame of the run.</param>
+ /// <param name="frameStride">Timeline frames per recorded frame of the run (1 for a full run).</param>
+ public static int Write(TextWriter writer, Probe probe, ProbeTrace trace, int visualizeEvery, int frameStride)
+ {
+ CultureInfo culture = CultureInfo.InvariantCulture;
+ if (probe.Kind == ProbeKind.Point)
+ {
+ writer.Write("step");
+ writer.Write(Separator);
+ writer.WriteLine(ColumnName(probe.Measurement));
+ ReadOnlySpan<float> values = trace.Series.Values.AsSpan(0, trace.Series.Count);
+ for (int i = 0; i < values.Length; i++)
+ {
+ writer.Write(i.ToString(culture));
+ writer.Write(Separator);
+ writer.WriteLine(values[i].ToString(culture));
+ }
+ return values.Length;
+ }
+ IReadOnlyList<float[]> profiles = trace.Profiles;
+ int samples = profiles.Count == 0 ? 0 : profiles[0].Length;
+ writer.Write("frame");
+ writer.Write(Separator);
+ writer.Write("step");
+ for (int k = 0; k < samples; k++)
+ {
+ writer.Write(Separator);
+ double distance = samples > 1 ? k * trace.ProfileLength / (samples - 1) : 0;
+ writer.Write(distance.ToString("0.###", culture));
+ }
+ writer.WriteLine();
+ for (int p = 0; p < profiles.Count; p++)
+ {
+ int frame = p * Math.Max(1, frameStride);
+ writer.Write(frame.ToString(culture));
+ writer.Write(Separator);
+ writer.Write((frame * Math.Max(1, visualizeEvery)).ToString(culture));
+ foreach (float value in profiles[p])
+ {
+ writer.Write(Separator);
+ writer.Write(value.ToString(culture));
+ }
+ writer.WriteLine();
+ }
+ return profiles.Count;
+ }
+
+ /// <summary>The value column's head for a measurement, in plain English (the file is data, not UI).</summary>
+ private static string ColumnName(ProbeMeasurement measurement) => measurement switch
+ {
+ ProbeMeasurement.Amplitude => "amplitude",
+ ProbeMeasurement.Value => "value",
+ ProbeMeasurement.IntegratedValue => "integrated value",
+ _ => measurement.ToString().ToLowerInvariant(),
+ };
+}
diff --git a/_tools/library_check/ExportChecks.cs b/_tools/library_check/ExportChecks.cs
index 5a9db05..7cdbb1d 100644
--- a/_tools/library_check/ExportChecks.cs
+++ b/_tools/library_check/ExportChecks.cs
@@ -23,6 +23,7 @@ using System.Runtime.InteropServices;
using System.Text;
using WaveDudeNext.Export;
using WaveDudeNext.Model;
+using WaveDudeNext.Probes;
using WaveDudeNext.Rendering;
using WaveDudeNext.Runs;
@@ -60,6 +61,25 @@ internal static class ExportChecks
check(rgb != null && count == 1 && Psnr(rgb, frames[0], w, h) >= 99, "png: ffmpeg decodes it, identical" + Mismatch(rgb, frames[0], w, h));
}
+ // probe CSV (2026-10-18): semicolons, a decimal point, a header row; a point probe one row per step, a line probe one
+ // row per frame with the distances along the line as the column heads; the proposed file name drops what a name cannot hold
+ var csvPoint = new Probe { Name = "P 1", Kind = ProbeKind.Point, Layer = ProbeLayer.Intensity, Measurement = ProbeMeasurement.IntegratedValue };
+ var pointTrace = new ProbeTrace();
+ pointTrace.Series.Add([0.5f, -1.25f, 3f]);
+ var text = new StringWriter();
+ int rows = ProbeCsv.Write(text, csvPoint, pointTrace, 2, 1);
+ string[] lines = text.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ check(rows == 3 && lines is ["step;integrated value", "0;0.5", "1;-1.25", "2;3"], "probe csv: a point probe gives step;value rows, decimal point, semicolons (" + string.Join(" | ", lines) + ")");
+ var csvLine = new Probe { Name = "L", Kind = ProbeKind.Line };
+ var lineTrace = new ProbeTrace();
+ lineTrace.AddProfile([1f, 2f, 3f], 4.0);
+ lineTrace.AddProfile([4f, 5.5f, 6f], 4.0);
+ text = new StringWriter();
+ rows = ProbeCsv.Write(text, csvLine, lineTrace, 2, 1);
+ lines = text.ToString().Split(Environment.NewLine, StringSplitOptions.RemoveEmptyEntries);
+ check(rows == 2 && lines is ["frame;step;0;2;4", "0;0;1;2;3", "1;2;4;5.5;6"], "probe csv: a line probe gives one row per frame, frame and step first, the distances along the line as column heads (" + string.Join(" | ", lines) + ")");
+ check(ProbeCsv.FileName("ball", new Probe { Name = "A/B: focus" }) == "ball_A_B_ focus.csv" && ProbeCsv.FileName("ball", new Probe { Name = " " }) == "ball_probe.csv", "probe csv: the proposed name is <project>_<probe>.csv with invalid characters replaced");
+
// JPEG: a baseline file ffmpeg decodes close to the original
var jpeg = new JpegEncoder(w, h, 90);
byte[] jpg = jpeg.Encode(frames[0]);
diff --git a/_tools/ui_check/ExportCheck.ps1 b/_tools/ui_check/ExportCheck.ps1
index a4bed3c..34d7219 100644
--- a/_tools/ui_check/ExportCheck.ps1
+++ b/_tools/ui_check/ExportCheck.ps1
@@ -19,7 +19,8 @@
# Export field... with no run yet (a run is started first, then 100 PNGs land in <temp>\wd_export\tiny_field), the
# title's asterisk after an edit, and Export both... from the picture's context menu (the Apps key on a focused
# handle) on the now stale run, which re-runs and writes both sequences; then tiny_probes.wdproj's field with the
-# probe graph boxes drawn in (a frame is kept as %TEMP%\export_probes.png). The Save dialog cannot be driven by
+# probe graph boxes drawn in (a frame is kept as %TEMP%\export_probes.png), the same as an MP4 and as JPEGs, and its
+# probes' recordings as CSV from the graph box's and the tree's context menus (2026-10-18). The Save dialog cannot be driven by
# posted keys, so the app takes the path from WAVEDUDE_EXPORT_PATH ("{name}" = the name it would suggest).
# See Common.ps1 for the rules (no mouse, no activation, no UIA patterns). Exits with the failure count.
#
@@ -151,7 +152,7 @@ try {
Step "Right" $VK_RIGHT 150; Step "Enter" $VK_RETURN 200
$mp4 = Join-Path $out "tiny_probes_field.mp4"
Check "the same export as an MP4 completes" (WaitFor { (Find "StatusMessage").Current.Name -like "Exported 50 frames to *tiny_probes_field.mp4*" } 60000) ((Find "StatusMessage").Current.Name)
- Check "the MP4 file is there and not empty" ((Test-Path $mp4) -and (Get-Item $mp4).Length -gt 1000) (if (Test-Path $mp4) { (Get-Item $mp4).Length } else { "missing" })
+ Check "the MP4 file is there and not empty" ((Test-Path $mp4) -and (Get-Item $mp4).Length -gt 1000) $(if (Test-Path $mp4) { (Get-Item $mp4).Length } else { "missing" })
Check "the app never took the foreground" ((Foreground) -ne "APP") (Foreground)
}
finally {
@@ -178,5 +179,37 @@ finally {
Stop-App
Remove-Item Env:\WAVEDUDE_EXPORT_PATH -ErrorAction SilentlyContinue
}
+# a probe's recording as CSV (2026-10-18), from the graph box's context menu (the Apps key on the focused box) and from
+# the tree's, where the entry is the last one and only a probe node shows it; the run is made first (a fresh app has
+# none). A point probe gives step;amplitude with one row per step, a line probe frame;step;<distances> with one row per frame
+$env:WAVEDUDE_EXPORT_PATH = Join-Path $out "{name}.csv"
+Start-App $Exe (Join-Path $PSScriptRoot "tiny_probes.wdproj")
+try {
+ FocusOn "ProbeBox:Probe 1"
+ Step "Apps" $VK_APPS 300
+ Check "the Apps key on a graph box opens its context menu with the CSV entry" (WaitFor { PopupItemVisible "Export probe data as CSV..." } 3000)
+ for ($i = 0; $i -lt 2 -and (PopupFocusedId) -ne "ContextExportProbeCsv"; $i++) { Step "Down" $VK_DOWN 120 }
+ Check "Down reaches the CSV entry" ((PopupFocusedId) -eq "ContextExportProbeCsv") (PopupFocusedId)
+ Step "Enter" $VK_RETURN 200
+ $csv1 = Join-Path $out "tiny_probes_Probe 1.csv"
+ Check "the point probe's CSV lands once the run was made" (WaitFor { (Find "StatusMessage").Current.Name -like "Probe data written: 100 rows of 'Probe 1' to *" } 60000) ((Find "StatusMessage").Current.Name)
+ $lines = if (Test-Path $csv1) { @([System.IO.File]::ReadAllLines($csv1)) } else { @() }
+ Check "step;amplitude header, 100 data rows, semicolons and a decimal point" ($lines.Count -eq 101 -and $lines[0] -eq "step;amplitude" -and $lines[1] -match "^0;-?[0-9]+(\.[0-9]+)?(E[-+]?[0-9]+)?$" -and $lines[100] -like "99;*") ("{0} lines: {1} | {2}" -f $lines.Count, $lines[0], $lines[1])
+ # the line probe from the tree's context menu
+ FocusOn "Tree:Probe 2"
+ Step "Apps" $VK_APPS 300
+ for ($i = 0; $i -lt 12 -and (PopupFocusedId) -ne "ContextExportProbeCsv"; $i++) { Step "Down" $VK_DOWN 120 }
+ Check "the tree's context menu reaches the CSV entry on a probe node" ((PopupFocusedId) -eq "ContextExportProbeCsv") (PopupFocusedId)
+ Step "Enter" $VK_RETURN 200
+ $csv2 = Join-Path $out "tiny_probes_Probe 2.csv"
+ Check "the line probe's CSV lands, one row per frame" (WaitFor { (Find "StatusMessage").Current.Name -like "Probe data written: 50 rows of 'Probe 2' to *" } 60000) ((Find "StatusMessage").Current.Name)
+ $lines = if (Test-Path $csv2) { @([System.IO.File]::ReadAllLines($csv2)) } else { @() }
+ Check "frame;step;<distances> header, 50 data rows, the last for frame 49 at step 98" ($lines.Count -eq 51 -and $lines[0] -like "frame;step;0;*" -and $lines[50] -like "49;98;*") ("{0} lines: {1}" -f $lines.Count, ($lines[0] -replace "^(.{40}).*", '$1...'))
+ Check "the app never took the foreground" ((Foreground) -ne "APP") (Foreground)
+}
+finally {
+ Stop-App
+ Remove-Item Env:\WAVEDUDE_EXPORT_PATH -ErrorAction SilentlyContinue
+}
Write-Output ("{0} failure(s)" -f $script:failures)
exit $script:failures