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#

Graph boxes over every handle and dot; the selected item drawn last

Alexander Graefe8b18c3c835b
diff --git a/CLAUDE.md b/CLAUDE.md
index 079c8e8..23498d3 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -117,7 +117,9 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA
final frame. A replaced project goes to frame 0; a discarded run keeps the position. In/out points are steps.
- **Handles and overlays**: sources, probes, emitter dots and the rotation handle are drawn over the pictures in
canvas pixels, over a dark halo, clipped to the picture; a probe's handles and line appear only on the picture of
- the layer it measures (2026-10-18), sources on both; arrows nudge, selection syncs with the tree, a click on
+ the layer it measures (2026-10-18), sources on both; graph boxes lie over every handle and dot, the selected
+ item is drawn last among its kind, except the handles themselves (Panel.ZIndex breaks the Tab cycle, 2026-10-18);
+ arrows nudge, selection syncs with the tree, a click on
empty space deselects. Probe graph boxes follow their probe while attached, resize by a grip, keep their text
size; an amplitude axis is symmetric about zero.
- **Colour schemes** are stop lists in `.wdscheme` XML, shipped ones embedded, user ones in
diff --git a/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs b/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
index 9bcabbb..67217b5 100644
--- a/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
+++ b/WaveDudeNext.WPF/Controls/ProbeGraphOverlay.cs
@@ -388,7 +388,8 @@ public sealed class ProbeGraphOverlay : Panel
double pixelsPerDip = VisualTreeHelper.GetDpi(this).PixelsPerDip;
ProbeGraphStyle style = StyleFor(pixelsPerDip);
object? selected = SelectedItem;
- foreach (Probe probe in project.Probes)
+ // the selected box last, so it lies over any box it overlaps (the user's rule, 2026-10-18)
+ foreach (Probe probe in project.Probes.OrderBy(probe => ReferenceEquals(probe, selected)))
{
if (!IsShown(probe))
{
diff --git a/WaveDudeNext.WPF/Controls/SceneOverlay.cs b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
index b8239ac..f3d336b 100644
--- a/WaveDudeNext.WPF/Controls/SceneOverlay.cs
+++ b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
@@ -340,6 +340,10 @@ public sealed class SceneOverlay : Panel
InvalidateVisual();
}
+ /// <summary>The items with the selected one last, so what is drawn for it lies over the others (the user's rule, 2026-10-18).</summary>
+ private static IEnumerable<T> SelectedLast<T>(IEnumerable<T> items, object? selected) where T : class =>
+ items.OrderBy(item => ReferenceEquals(item, selected));
+
private static void UpdateOpacity(MarkerThumb thumb) =>
thumb.Opacity = thumb.Item switch { Source { Enabled: false } => 0.45, Probe { Active: false } => 0.45, _ => 1.0 };
@@ -498,7 +502,7 @@ public sealed class SceneOverlay : Panel
// are children and sit on clamped positions, and the labels below are kept inside by their placement. The
// picture's rectangle, not this element's: the element fills the cell and the picture is letterboxed in it
dc.PushClip(new RectangleGeometry(PictureRect(RenderSize)));
- foreach (Probe probe in project.Probes)
+ foreach (Probe probe in SelectedLast(project.Probes, selected))
{
if (probe.Kind != ProbeKind.Line || !Shows(probe))
{
@@ -511,7 +515,7 @@ public sealed class SceneOverlay : Panel
dc.DrawLine(new Pen(HaloBrush, isSelected ? 3.5 : 3.0), a, b);
dc.DrawLine(new Pen(isSelected ? AccentBrush : LineBrush, isSelected ? 1.5 : 1.0) { DashStyle = DashStyles.Dash }, a, b);
}
- foreach (Source source in project.Sources)
+ foreach (Source source in SelectedLast(project.Sources, selected))
{
if (source.Array == null)
{
@@ -533,7 +537,7 @@ public sealed class SceneOverlay : Panel
}
}
dc.Pop();
- foreach (MarkerThumb thumb in Children)
+ foreach (MarkerThumb thumb in Children.OfType<MarkerThumb>().OrderBy(thumb => thumb.IsSelectedMarker))
{
if (thumb.Role is MarkerRole.ProbeB or MarkerRole.SourceAngle)
{
diff --git a/WaveDudeNext.WPF/Panes/PreviewPane.xaml b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
index 2c2217a..ec624b7 100644
--- a/WaveDudeNext.WPF/Panes/PreviewPane.xaml
+++ b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
@@ -485,8 +485,19 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<!-- the scene outline, a translucent layer of the same pixel size, so it lands exactly on the frame -->
<Image Source="{Binding Path=(local:PreviewPane.OverlayImage), RelativeSource={RelativeSource TemplatedParent}}"
Stretch="Uniform" IsHitTestVisible="False" />
- <!-- the probes' graph boxes, under the handles so a handle over a box stays grabbable; which
- probes depends on the cell's layer (the attached PreviewPane.Layer) -->
+ <!-- the handles: sources, emitter dots, probe points and lines. Styled here, not implicitly: WPF applies
+ implicit styles inside a template only to Controls, and the overlay is a Panel -->
+ <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" ProbeStyle="{StaticResource ProbeMarker}" AngleStyle="{StaticResource AngleMarker}"
+ LineBrush="White" LabelBrush="White" AccentBrush="{DynamicResource Accent}"
+ Project="{Binding Project, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
+ CanvasWidth="{Binding CanvasWidth, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
+ CanvasHeight="{Binding CanvasHeight, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
+ Layer="{Binding Path=(local:PreviewPane.Layer), RelativeSource={RelativeSource TemplatedParent}}"
+ SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}, Mode=TwoWay}" />
+ <!-- the probes' graph boxes, over the handles: no handle or emitter dot is ever drawn on a graph (the user's
+ rule, 2026-10-18; until then the boxes lay under the handles, to keep a handle over a box grabbable, and
+ a handle under a box is reached by Tab or the tree instead); which probes depends on the cell's layer
+ (the attached PreviewPane.Layer) -->
<controls:ProbeGraphOverlay BoxStyle="{StaticResource ProbeBoxThumb}" CornerStyle="{StaticResource ProbeBoxCornerThumb}"
AccentBrush="{DynamicResource Accent}"
Layer="{Binding Path=(local:PreviewPane.Layer), RelativeSource={RelativeSource TemplatedParent}}"
@@ -497,14 +508,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
CanvasWidth="{Binding CanvasWidth, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
CanvasHeight="{Binding CanvasHeight, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}, Mode=TwoWay}" />
- <!-- styled here, not implicitly: WPF applies implicit styles inside a template only to Controls, and the overlay is a Panel -->
- <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" ProbeStyle="{StaticResource ProbeMarker}" AngleStyle="{StaticResource AngleMarker}"
- LineBrush="White" LabelBrush="White" AccentBrush="{DynamicResource Accent}"
- Project="{Binding Project, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
- CanvasWidth="{Binding CanvasWidth, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
- CanvasHeight="{Binding CanvasHeight, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}}"
- Layer="{Binding Path=(local:PreviewPane.Layer), RelativeSource={RelativeSource TemplatedParent}}"
- SelectedItem="{Binding SelectedItem, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}, Mode=TwoWay}" />
<!-- a frame for this position is being computed (longer than a moment): the stale picture dims and a spinner
turns, so the wait reads as work in progress and not as a preview that does not update (2026-10-14) -->
<Grid IsHitTestVisible="False" Visibility="{Binding IsBusyOverlayVisible, RelativeSource={RelativeSource AncestorType={x:Type local:PreviewPane}}, Converter={StaticResource BoolToVisibility}}">