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#

A fibre's path as cubic Bézier segments with handles, and flat or round ends

Alexander Graef107fa0eab430
diff --git a/CLAUDE.md b/CLAUDE.md
index 52a98f3..f7ef727 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -46,7 +46,9 @@ harnesses run.
preferred (docking, encoders, colour picker are in-house). Microsoft packages are fine.
- **WPF idioms**: commands not `_Click`, bindings not hand-pushed state, `DynamicResource` for every theme brush and
string, `XmlSerializer` with sparse XML (attributes, repeated children, `[DefaultValue]`), Segoe UI 9 pt, the
- dnSpy look (its sources are GPL: look, do not copy).
+ dnSpy look (its sources are GPL: look, do not copy). Inside a `DataTemplate` reference the string keys directly
+ (`{DynamicResource Hint.Type.Member}`): the `meta:Label`/`meta:Hint` extensions wrap a resource reference a template
+ rejects for a string property and shows as text for an object one (2026-10-22, found on the fibre's node rows).
- **Model conventions**: a new property gets its XML attribute with a default, `[Category]`/`[DisplayName]`/
`[Description]`, a `///` summary, a clamp in `Normalize()` with the matching `[Range]` beside the default (2026-10-21:
the bounds are readable from outside, `library_check` proves each against `Normalize()`; a bound that depends on another
@@ -193,7 +195,15 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA
whole pixels). A part edit is a simulation edit. Tree folder "Parts", "+ Part" opens a menu of kinds (Space, arrows,
Enter), a handle plus a rotation lever on the pictures; while selected, the outline as painted in the accent colour,
a size grip on a corner or vertex (rectangle, lens, polygon, triangle, GRIN, Bragg) and a handle per point of an outline
- or fibre (2026-10-19); the shape shows through the glowing outline otherwise.
+ (2026-10-19); the shape shows through the glowing outline otherwise. **A fibre's path** (2026-10-22, the user's request,
+ replacing the polyline with its sharp bends) is a chain of cubic Bézier segments through `FiberNode`s, each with an in and an
+ out handle as offsets (ints, `<Node X Y InX InY OutX OutY Smooth>`): on the pictures a node handle plus its two handles on
+ dotted lines, a smooth node (default) lined up when switched on (`FiberPart.AlignNode`, zero handles seeded from the
+ neighbours) and turning the other handle with the one moved or typed, keeping its length (captured at the drag's start, so
+ rounding does not creep in; a node added or loaded is taken as it is), a corner node free; the pane lists each node with both handles; "Add node"
+ continues the path. The ends are `Ends` Flat (default: cut across the curve's tangent at the endpoint, the coating
+ following the face) or Round. The painter flattens the curve into chords (0.05 px) bucketed on a 32 px cell grid, and the
+ core edge is supersampled (`HasInnerEdges`).
- File types `.wdproj` / `.wdscheme` are registered per user at start-up; unsaved edits ask on close.
## Numbers (workstation: 10-core Xeon without AVX2, RTX 2080, 64 GB)
@@ -202,7 +212,7 @@ GPU step at 1080p 0.25–0.5 ms, CPU 6–14 ms; OpenCL build 0.3 s; a full-HD ru
the GPU readback. Renderer per 2880×1080 layer on ten cores: 8-bit 1.0 ms, 16-bit 2.0; vector rows gain 2× per
core over scalar. Presenter about 7 ms a frame quiet, 20 during a run. JPEG 1080p at 4:4:4: WIC 26 ms a frame
single-threaded (9 ms a frame in a sequence job on half the cores), in-house 9.8 ms on ten cores (15 in a job);
-MP4 job 16 ms a frame. Part painter on a Full HD canvas (ten cores): a 400 × 330 outline 30 ms, a 400 px lens 5, a hexagon 8;
+MP4 job 16 ms a frame. Part painter on a Full HD canvas (ten cores): a 400 × 330 outline 30 ms, a 400 px lens 5, a hexagon 8, an S-bent fibre across the canvas 51 (156 chords on the cell grid; 1.3 s without it);
the glowing edges 22 ms; the preview's scene pictures about 100 ms more, so the scene rebuild is coalesced at background priority. Laptop (2 cores, HD 520, HDD): iGPU 4.3 ms a step against CPU 14.7; the ball
lens run 105 s full quality (disk-bound), 61 s at half resolution with every second frame, in RAM. Settled by these
numbers: no GPU JPEG, no OpenCL colouring at presentation, no `Vector256`, no Direct3D display path.
@@ -232,4 +242,4 @@ upscale in exports; HEVC; the start-up stall (log milestones first); the GPU rea
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`
harness, three example projects for Jeroen) and its open points (the "+ Part" menu versus five buttons, Bragg thicknesses
-in pixels, round fibre ends, where examples live) wait for the user.
+in pixels, where examples live) wait for the user.
diff --git a/OpticalParts.md b/OpticalParts.md
index fb81254..c1c07f6 100644
--- a/OpticalParts.md
+++ b/OpticalParts.md
@@ -20,8 +20,8 @@ thickness are its bulk: radii too curved for them are raised to the smallest tha
always fills its diameter; the form shows the edge thickness (a diameter of 2000 with radii of 300 had given a tiny lens).
A "Concave (diverging)" box shows the lens's state from the lensmaker's sign and, ticked, flips both radii.
While a part is selected the overlay draws its outline (`OpticalPart.Outline()`, the painted shape) in the accent colour,
-a size grip on a corner or vertex sets the extents by drag or arrow keys, and an outline's or fibre's points each have a
-handle (2026-10-19). Not built: stage 3 (`PartCheck.ps1`, the three
+a size grip on a corner or vertex sets the extents by drag or arrow keys, an outline's points each have a handle
+(2026-10-19), and a fibre's nodes a handle plus their two Bézier handles on dotted lines (2026-10-22). Not built: stage 3 (`PartCheck.ps1`, the three
examples). The open points at the end still stand.
## What is asked
@@ -111,8 +111,16 @@ before rotation; empty by default). A non-empty list replaces the regular polygo
R = Side / (2 sin(π / Sides)), the first vertex on +x'. A flat mirror is a thin rectangle from four points.
**`FiberPart`** — CoreIndex (1.50), CoreDiameter (20, ≥ 2), CladdingIndex (1.45), CladdingThickness (10, ≥ 0),
-Coating (0), `Points` path (default two points (−100, 0) and (100, 0)). Core: distance to the polyline ≤ D/2;
-cladding: ≤ D/2 + thickness (round ends follow from the distance; acceptable). Angle rotates the whole path.
+Coating (0), Ends (Flat | Round, Flat), `Nodes` path (2026-10-22, the user's request, replacing the polyline whose joints
+were sharp bends): cubic Bézier segments through `FiberNode { X, Y, InX, InY, OutX, OutY, Smooth }`, the handles offsets
+from the node, `<Node …/>` children; default two nodes (−100, 0) and (100, 0) with handles a third of the way along.
+The curve is flattened into chords within 0.05 px (a straight segment one chord) and bucketed on a 32 px cell grid; core:
+distance to the chords ≤ D/2; cladding: ≤ D/2 + thickness; a flat end cuts every chord near the endpoint by the plane
+across the handle's direction there (the coating band follows the face), a round end is the distance test. The core edge
+is supersampled (`HasInnerEdges`). Angle rotates the whole path. Smooth (the user's choice, 2026-10-22): switching it on
+lines the handles up at once (`FiberPart.AlignNode`; a node without handles is seeded from its neighbours), and afterwards
+a handle dragged (`FiberNode.SetHandle`) or typed (the part listens to its nodes) turns the other opposite, keeping its
+length; a node added or loaded is taken as it is, so a file never changes on loading.
**`BraggReflectorPart`** — Pairs (int, 10, 1..200), Thickness1, Thickness2 (int px, 10, ≥ 1), Index1 (1.50),
Index2 (2.00), Width (int, 200, ≥ 2). Layers stacked along +x', the stack centred on the part centre, Width across.
@@ -191,5 +199,4 @@ IReadOnlyList<OpticalPart> parts)`:
- The "+ Part" menu as the way to choose a kind (versus five toolbar buttons).
- Bragg thicknesses in pixels as typed (no automatic quarter-wave from a source's wavelength).
-- Round fiber ends from the distance test.
- Where the example projects live (Jeroen's own sit in `Wave_Dude_Examples/`).
diff --git a/WaveDudeNext.WPF/Commands/PartCommands.cs b/WaveDudeNext.WPF/Commands/PartCommands.cs
index ee420a5..1908ff4 100644
--- a/WaveDudeNext.WPF/Commands/PartCommands.cs
+++ b/WaveDudeNext.WPF/Commands/PartCommands.cs
@@ -19,7 +19,7 @@ using System.Windows.Input;
namespace WaveDudeNext.WPF.Commands;
-/// <summary>Commands of the part editors, bound on the views themselves: the point list of an outline or fibre (<c>Views/PartPointsView</c>), nothing else since the chain toggle replaced the Square and Circle buttons (2026-10-20).</summary>
+/// <summary>Commands of the part editors, bound on the views themselves: the point list of an outline (<c>Views/PartPointsView</c>) and the node list of a fibre's path (<c>Views/FiberPathView</c>, 2026-10-22), nothing else since the chain toggle replaced the Square and Circle buttons (2026-10-20).</summary>
public static class PartCommands
{
/// <summary>Appends a point after the last one.</summary>
diff --git a/WaveDudeNext.WPF/Controls/MarkerThumb.cs b/WaveDudeNext.WPF/Controls/MarkerThumb.cs
index 1dc185a..1ee6db9 100644
--- a/WaveDudeNext.WPF/Controls/MarkerThumb.cs
+++ b/WaveDudeNext.WPF/Controls/MarkerThumb.cs
@@ -33,8 +33,12 @@ public enum MarkerRole
PartAngle,
/// <summary>The size grip of an optical part: a corner or vertex of its outline that sets its extents (2026-10-19).</summary>
PartGrip,
- /// <summary>One point of an outline's or fibre's point list (<see cref="MarkerThumb.Index"/> says which).</summary>
+ /// <summary>One point of an outline's list, or one node of a fibre's path (<see cref="MarkerThumb.Index"/> says which).</summary>
PartPoint,
+ /// <summary>The in-handle of a node of a fibre's path: the Bézier handle of the segment arriving there (<see cref="MarkerThumb.Index"/> says which node; 2026-10-22).</summary>
+ FiberIn,
+ /// <summary>The out-handle of a node of a fibre's path: the Bézier handle of the segment leaving there.</summary>
+ FiberOut,
/// <summary>Point A of a probe (the point of a point probe, the start of a line probe).</summary>
ProbeA,
/// <summary>Point B of a line probe.</summary>
@@ -72,7 +76,7 @@ public sealed class MarkerThumb : Thumb
/// <param name="item">The source, part or probe.</param>
/// <param name="role">Which point of it.</param>
- /// <param name="index">For <see cref="MarkerRole.PartPoint"/>, the index in the part's point list.</param>
+ /// <param name="index">For a point, node or Bézier handle, the index in the part's point or node list.</param>
public MarkerThumb(object item, MarkerRole role, int index = -1)
{
Item = item;
@@ -81,7 +85,7 @@ public sealed class MarkerThumb : Thumb
Focusable = true;
}
- /// <summary>For a point handle, the index in the part's point list; -1 otherwise.</summary>
+ /// <summary>For a point, node or Bézier handle, the index in the part's point or node list; -1 otherwise.</summary>
public int Index { get; }
/// <summary>The source, part or probe this handle moves.</summary>
@@ -124,4 +128,7 @@ public sealed class MarkerThumb : Thumb
/// <summary>For a grip or point handle: the vertical part of the grab offset (canvas pixels).</summary>
internal double GrabOffsetY { get; set; }
+
+ /// <summary>For the Bézier handle of a smooth node: the other handle's length when the drag or key press began, which it keeps while it turns (canvas pixels); null otherwise.</summary>
+ internal double? MirrorLength { get; set; }
}
diff --git a/WaveDudeNext.WPF/Controls/SceneOverlay.cs b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
index 33c01c2..0814448 100644
--- a/WaveDudeNext.WPF/Controls/SceneOverlay.cs
+++ b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
@@ -35,8 +35,10 @@ namespace WaveDudeNext.WPF.Controls;
/// ends with the line between them, plus the emitters of a composite source as dots, its rotation handle on
/// the row axis (shown while the source is selected; drag turns the array; Shift snaps to 15°; the arrow keys
/// turn it by a degree, 2026-10-14), the same handle on a part's axis (2026-10-18), and, while a part is selected, its
-/// outline in the accent colour with a size grip on a corner or vertex (drag sets the extents) and a handle on each
-/// point of an outline's or fibre's list (2026-10-19, the user's request), plus the item names as labels. Dragging a handle, or moving it with the arrow keys while it has keyboard focus, writes the
+/// outline in the accent colour with a size grip on a corner or vertex (drag sets the extents), a handle on each
+/// point of an outline's list (2026-10-19, the user's request) and on each node of a fibre's path, with the node's two
+/// Bézier handles on dotted lines (2026-10-22, the user's request; a smooth node turns the other handle with the one
+/// moved, keeping its length), plus the item names as labels. Dragging a handle, or moving it with the arrow keys while it has keyboard focus, writes the
/// new canvas coordinates to the model; grabbing or focusing a handle makes its item the
/// <see cref="SelectedItem"/>. Several items can be selected at once (<see cref="SelectedItems"/>, 2026-10-19, the
/// user's request): a drag on empty picture space draws a marquee that selects the items whose handles it covers
@@ -90,6 +92,10 @@ public sealed class SceneOverlay : Panel
public static readonly DependencyProperty PointStyleProperty = DependencyProperty.Register(
nameof(PointStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));
+ /// <summary>Identifies the <see cref="HandleStyle"/> property.</summary>
+ public static readonly DependencyProperty HandleStyleProperty = DependencyProperty.Register(
+ nameof(HandleStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));
+
/// <summary>Identifies the <see cref="AngleStyle"/> property.</summary>
public static readonly DependencyProperty AngleStyleProperty = DependencyProperty.Register(
nameof(AngleStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));
@@ -250,6 +256,13 @@ public sealed class SceneOverlay : Panel
set => SetValue(PointStyleProperty, value);
}
+ /// <summary>Style of the Bézier handle thumbs of a fibre's nodes (2026-10-22).</summary>
+ public Style? HandleStyle
+ {
+ get => (Style?)GetValue(HandleStyleProperty);
+ set => SetValue(HandleStyleProperty, value);
+ }
+
/// <summary>Style of the rotation handles of composite sources and parts (a <see cref="MarkerThumb"/> style).</summary>
public Style? AngleStyle
{
@@ -362,6 +375,28 @@ public sealed class SceneOverlay : Panel
AddThumb(part, MarkerRole.PartPoint, PointStyle, part.Name, $"PartPoint:{part.Name}:{i}", "TipPointFormat", i);
}
}
+ else if (part is FiberPart fiber)
+ {
+ // the path's nodes, each with its Bézier handles added first so the node wins where they overlap; the
+ // first node's in-handle and the last node's out-handle shape nothing and get no thumb
+ if (_pointLists.Add(fiber.Nodes))
+ {
+ fiber.Nodes.CollectionChanged += OnCollectionChanged;
+ }
+ for (int i = 0; i < fiber.Nodes.Count; i++)
+ {
+ Subscribe(fiber.Nodes[i]);
+ if (i > 0)
+ {
+ AddThumb(part, MarkerRole.FiberIn, HandleStyle, part.Name, $"FiberIn:{part.Name}:{i}", "TipInHandleFormat", i);
+ }
+ if (i < fiber.Nodes.Count - 1)
+ {
+ AddThumb(part, MarkerRole.FiberOut, HandleStyle, part.Name, $"FiberOut:{part.Name}:{i}", "TipOutHandleFormat", i);
+ }
+ AddThumb(part, MarkerRole.PartPoint, PointStyle, part.Name, $"PartPoint:{part.Name}:{i}", "TipNodeFormat", i);
+ }
+ }
}
foreach (Probe probe in project.Probes)
{
@@ -416,7 +451,8 @@ public sealed class SceneOverlay : Panel
{
case Probe when e.PropertyName is nameof(Probe.Kind) or nameof(Probe.Layer):
case Source when e.PropertyName == nameof(Source.Array):
- case OutlinePart or FiberPart when e.PropertyName == "Points":
+ case OutlinePart when e.PropertyName == nameof(OutlinePart.Points):
+ case FiberPart when e.PropertyName == nameof(FiberPart.Nodes):
Rebuild();
return;
case Source source:
@@ -460,9 +496,9 @@ public sealed class SceneOverlay : Panel
foreach (MarkerThumb thumb in Children)
{
thumb.IsSelectedMarker = IsSelected(thumb.Item);
- if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle or MarkerRole.PartGrip or MarkerRole.PartPoint)
+ if (IsDetail(thumb.Role))
{
- // the rotation handle, grip and point handles only while their source or part is the current item (the user's rule, 2026-10-14); collapsed, they are out of the Tab cycle too
+ // the rotation handle, grip, point, node and Bézier handles only while their source or part is the current item (the user's rule, 2026-10-14); collapsed, they are out of the Tab cycle too
thumb.Visibility = ReferenceEquals(thumb.Item, selected) ? Visibility.Visible : Visibility.Collapsed;
}
}
@@ -522,14 +558,34 @@ public sealed class SceneOverlay : Panel
// ---------------------------------------------------------------- a part's grip and points
- /// <summary>The point list a part's handles edit: an outline's or a fibre's; null for the other kinds.</summary>
+ /// <summary>The point list a part's point handles edit: an outline's; null for the other kinds (a fibre has nodes, see <see cref="NodeOf"/>).</summary>
private static ObservableCollection<PartPoint>? PointsOf(OpticalPart part) => part switch
{
OutlinePart outline => outline.Points,
- FiberPart fiber => fiber.Points,
_ => null,
};
+ /// <summary>The fibre node a node or Bézier handle stands on, or null for another handle or an index past the list.</summary>
+ private static FiberNode? NodeOf(MarkerThumb thumb) =>
+ thumb.Item is FiberPart fiber && thumb.Index >= 0 && thumb.Index < fiber.Nodes.Count ? fiber.Nodes[thumb.Index] : null;
+
+ /// <summary>The length of the other Bézier handle of the node a handle thumb stands on, which a smooth node keeps while that handle turns; null for another thumb.</summary>
+ private static double? MirrorLengthOf(MarkerThumb thumb)
+ {
+ if (thumb.Role is not (MarkerRole.FiberIn or MarkerRole.FiberOut) || NodeOf(thumb) is not { } node)
+ {
+ return null;
+ }
+ (int dx, int dy) = thumb.Role == MarkerRole.FiberOut ? (node.InX, node.InY) : (node.OutX, node.OutY);
+ return Math.Sqrt((double)dx * dx + (double)dy * dy);
+ }
+
+ /// <summary>Whether a handle is shown for the current item alone: a rotation handle, a grip, a point, node or Bézier handle.</summary>
+ private static bool IsDetail(MarkerRole role) => role is MarkerRole.SourceAngle or MarkerRole.PartAngle || HasCanvasPosition(role);
+
+ /// <summary>Whether a handle sits on a continuous canvas position of its own (<see cref="CanvasOf"/>): a grip, a point, node or Bézier handle.</summary>
+ private static bool HasCanvasPosition(MarkerRole role) => role is MarkerRole.PartGrip or MarkerRole.PartPoint or MarkerRole.FiberIn or MarkerRole.FiberOut;
+
/// <summary>
/// Where a part's size grip sits in the part frame: the corner of a rectangle or an ellipse's box, lens (thickness, diameter), GRIN lens
/// or Bragg stack, the first vertex of a polygon, the second end of a triangle's base; null for a kind without one.
@@ -585,11 +641,14 @@ public sealed class SceneOverlay : Panel
}
}
- /// <summary>The canvas position of a grip or point handle (continuous coordinates), or null when the handle has nothing to stand on.</summary>
+ /// <summary>The canvas position of a grip, point, node or Bézier handle (continuous coordinates), or null when the handle has nothing to stand on.</summary>
private static (double X, double Y)? CanvasOf(MarkerThumb thumb) => (thumb.Item, thumb.Role) switch
{
(OpticalPart part, MarkerRole.PartGrip) when GripOf(part) is { } grip => part.ToCanvas(grip.X, grip.Y),
(OpticalPart part, MarkerRole.PartPoint) when PointsOf(part) is { } points && thumb.Index >= 0 && thumb.Index < points.Count => part.ToCanvas(points[thumb.Index].X, points[thumb.Index].Y),
+ (FiberPart fiber, MarkerRole.PartPoint) when NodeOf(thumb) is { } node => fiber.ToCanvas(node.X, node.Y),
+ (FiberPart fiber, MarkerRole.FiberIn) when NodeOf(thumb) is { } node => fiber.ToCanvas(node.In.X, node.In.Y),
+ (FiberPart fiber, MarkerRole.FiberOut) when NodeOf(thumb) is { } node => fiber.ToCanvas(node.Out.X, node.Out.Y),
_ => null,
};
@@ -657,7 +716,7 @@ public sealed class SceneOverlay : Panel
private static (int X, int Y) PointOf(MarkerThumb thumb) => (thumb.Item, thumb.Role) switch
{
(Source source, _) => (source.X, source.Y),
- (OpticalPart, MarkerRole.PartGrip or MarkerRole.PartPoint) when CanvasOf(thumb) is { } canvas => ((int)Math.Round(canvas.X), (int)Math.Round(canvas.Y)),
+ (OpticalPart, _) when HasCanvasPosition(thumb.Role) && CanvasOf(thumb) is { } canvas => ((int)Math.Round(canvas.X), (int)Math.Round(canvas.Y)),
(OpticalPart part, _) => (part.X, part.Y),
(Probe probe, MarkerRole.ProbeB) => (probe.BX, probe.BY),
(Probe probe, _) => (probe.AX, probe.AY),
@@ -677,6 +736,22 @@ public sealed class SceneOverlay : Panel
case (OpticalPart part, MarkerRole.PartGrip):
SetGrip(part, x, y);
break;
+ case (FiberPart fiber, MarkerRole.PartPoint):
+ // a node moves with its handles, which are offsets from it
+ if (NodeOf(thumb) is { } moved)
+ {
+ (double fx, double fy) = fiber.ToFrame(x, y);
+ moved.X = (int)Math.Round(fx);
+ moved.Y = (int)Math.Round(fy);
+ }
+ break;
+ case (FiberPart fiber, MarkerRole.FiberIn or MarkerRole.FiberOut):
+ if (NodeOf(thumb) is { } node)
+ {
+ (double fx, double fy) = fiber.ToFrame(x, y);
+ node.SetHandle(thumb.Role == MarkerRole.FiberOut, (int)Math.Round(fx) - node.X, (int)Math.Round(fy) - node.Y, thumb.MirrorLength);
+ }
+ break;
case (OpticalPart part, MarkerRole.PartPoint):
if (PointsOf(part) is { } points && thumb.Index >= 0 && thumb.Index < points.Count)
{
@@ -732,13 +807,13 @@ public sealed class SceneOverlay : Panel
Point centre = thumb.Role switch
{
MarkerRole.SourceAngle or MarkerRole.PartAngle => AnglePoint(thumb.Item, finalSize),
- MarkerRole.PartGrip or MarkerRole.PartPoint when CanvasOf(thumb) is { } canvas => ToViewExact(canvas.X, canvas.Y, finalSize),
+ _ when HasCanvasPosition(thumb.Role) && CanvasOf(thumb) is { } canvas => ToViewExact(canvas.X, canvas.Y, finalSize),
_ => ToView(x, y, finalSize),
};
Size size = thumb.DesiredSize;
var rect = new Rect(centre.X - size.Width / 2, centre.Y - size.Height / 2, size.Width, size.Height);
thumb.Arrange(rect);
- if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle or MarkerRole.PartGrip or MarkerRole.PartPoint)
+ if (IsDetail(thumb.Role))
{
// the rotation handle stays on the row axis, however far out; what falls outside the picture is clipped
// (2026-10-16, the user's rule: the lever bending to keep the handle inside made no sense). The other
@@ -829,6 +904,32 @@ public sealed class SceneOverlay : Panel
Point axisEnd = AnglePoint(part, RenderSize);
dc.DrawLine(new Pen(HaloBrush, 3.0), ToView(part.X, part.Y), axisEnd);
dc.DrawLine(new Pen(AccentBrush, 1.0) { DashStyle = DashStyles.Dot }, ToView(part.X, part.Y), axisEnd);
+ if (part is FiberPart fiber)
+ {
+ // each node's Bézier handles on dotted lines from the node (the handle thumbs sit at their ends)
+ var handleHalo = new Pen(HaloBrush, 3.0);
+ var handleLine = new Pen(AccentBrush, 1.0) { DashStyle = DashStyles.Dot };
+ for (int i = 0; i < fiber.Nodes.Count; i++)
+ {
+ FiberNode node = fiber.Nodes[i];
+ (double nx, double ny) = fiber.ToCanvas(node.X, node.Y);
+ Point at = ToViewExact(nx, ny, RenderSize);
+ if (i > 0)
+ {
+ (double hx, double hy) = fiber.ToCanvas(node.In.X, node.In.Y);
+ Point handle = ToViewExact(hx, hy, RenderSize);
+ dc.DrawLine(handleHalo, at, handle);
+ dc.DrawLine(handleLine, at, handle);
+ }
+ if (i < fiber.Nodes.Count - 1)
+ {
+ (double hx, double hy) = fiber.ToCanvas(node.Out.X, node.Out.Y);
+ Point handle = ToViewExact(hx, hy, RenderSize);
+ dc.DrawLine(handleHalo, at, handle);
+ dc.DrawLine(handleLine, at, handle);
+ }
+ }
+ }
}
}
if (_marquee is { } marquee)
@@ -842,7 +943,7 @@ public sealed class SceneOverlay : Panel
dc.Pop();
foreach (MarkerThumb thumb in Children.OfType<MarkerThumb>().OrderBy(thumb => thumb.IsSelectedMarker))
{
- if (thumb.Role is MarkerRole.ProbeB or MarkerRole.SourceAngle or MarkerRole.PartAngle or MarkerRole.PartGrip or MarkerRole.PartPoint)
+ if (thumb.Role is MarkerRole.ProbeB || IsDetail(thumb.Role))
{
continue;
}
@@ -994,11 +1095,12 @@ public sealed class SceneOverlay : Panel
_groupApplied = (0, 0);
_suppressDrag = false;
_dragStartAngle = AngleOf(thumb.Item);
- if (thumb.Role is MarkerRole.PartGrip or MarkerRole.PartPoint && CanvasOf(thumb) is { } handle)
+ if (HasCanvasPosition(thumb.Role) && CanvasOf(thumb) is { } handle)
{
(double mouseX, double mouseY) = ToCanvasExact(Mouse.GetPosition(this));
thumb.GrabOffsetX = mouseX - handle.X;
thumb.GrabOffsetY = mouseY - handle.Y;
+ thumb.MirrorLength = MirrorLengthOf(thumb);
}
if (MovesWhole(thumb.Role) && SelectedItems is { } set)
{
@@ -1074,7 +1176,7 @@ public sealed class SceneOverlay : Panel
SetAngle(thumb.Item, Mouse.GetPosition(this), (Keyboard.Modifiers & ModifierKeys.Shift) != 0);
return;
}
- if (thumb.Role is MarkerRole.PartGrip or MarkerRole.PartPoint)
+ if (HasCanvasPosition(thumb.Role))
{
// absolute, from the mouse: a grip does not land under the mouse (a polygon's vertex stays on its ray, a
// rectangle's corner on the positive quadrant), so thumb-relative deltas fed the miss back into the size
@@ -1154,6 +1256,7 @@ public sealed class SceneOverlay : Panel
e.Handled = true;
return;
}
+ thumb.MirrorLength = MirrorLengthOf(thumb);
(int x, int y) = PointOf(thumb);
SetPoint(thumb, x + dx, y + dy);
e.Handled = true;
diff --git a/WaveDudeNext.WPF/MainWindow.Live.cs b/WaveDudeNext.WPF/MainWindow.Live.cs
index 25265ad..035d501 100644
--- a/WaveDudeNext.WPF/MainWindow.Live.cs
+++ b/WaveDudeNext.WPF/MainWindow.Live.cs
@@ -235,9 +235,9 @@ public partial class MainWindow
ScheduleRerun();
}
- /// <summary>Whether the change is to an optical part, one of its points, a point list or the parts list.</summary>
+ /// <summary>Whether the change is to an optical part, one of its points or fibre nodes, a point or node list, or the parts list.</summary>
private static bool IsPartChange(ProjectChange change) =>
- change.Item is OpticalPart or PartPoint or ObservableCollection<OpticalPart> or ObservableCollection<PartPoint>
+ change.Item is OpticalPart or PartPoint or FiberNode or ObservableCollection<OpticalPart> or ObservableCollection<PartPoint> or ObservableCollection<FiberNode>
|| change.Item is Project && change.Property == nameof(Project.Parts);
/// <summary>
diff --git a/WaveDudeNext.WPF/Panes/PreviewPane.xaml b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
index 965e207..7c5a1dd 100644
--- a/WaveDudeNext.WPF/Panes/PreviewPane.xaml
+++ b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
@@ -252,6 +252,22 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</Setter.Value>
</Setter>
</Style>
+ <!-- a fibre node's Bézier handle: a small filled dot at the end of its dotted line from the node (2026-10-22) -->
+ <Style x:Key="FiberHandleMarker" TargetType="{x:Type controls:MarkerThumb}" BasedOn="{StaticResource MarkerBase}">
+ <Setter Property="Width" Value="12" />
+ <Setter Property="Height" Value="12" />
+ <Setter Property="Cursor" Value="Hand" />
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type controls:MarkerThumb}">
+ <Grid Background="Transparent">
+ <Ellipse Width="8" Height="8" Fill="Black" Opacity="0.75" />
+ <Ellipse Width="6" Height="6" Fill="{TemplateBinding BorderBrush}" />
+ </Grid>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
<StreamGeometry x:Key="AngleGlyph">M15,10 A5,5 0 1 1 12.5,5.67 M12.5,5.67 L9.2,5.3 M12.5,5.67 L13,9</StreamGeometry>
<Style x:Key="AngleMarker" TargetType="{x:Type controls:MarkerThumb}" BasedOn="{StaticResource MarkerBase}">
<Setter Property="Cursor" Value="Hand" />
@@ -552,7 +568,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
Stretch="Uniform" IsHitTestVisible="False" />
<!-- 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}" PartStyle="{StaticResource PartMarker}" GripStyle="{StaticResource PartGripMarker}" PointStyle="{StaticResource PartPointMarker}" ProbeStyle="{StaticResource ProbeMarker}" AngleStyle="{StaticResource AngleMarker}"
+ <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" PartStyle="{StaticResource PartMarker}" GripStyle="{StaticResource PartGripMarker}" PointStyle="{StaticResource PartPointMarker}" HandleStyle="{StaticResource FiberHandleMarker}" 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}}}"
diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
index 864eda1..7774d2d 100644
--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
@@ -187,6 +187,9 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipAngleMarkerFormat">{0}: zum Drehen des Rasters ziehen (Umschalt rastet auf 15 Grad ein); mit Tastaturfokus drehen die Pfeiltasten um ein Grad, mit Umschalt um zehn</s:String>
<s:String x:Key="TipGripFormat">{0}: zum Ändern der Größe ziehen; mit Tastaturfokus bewegen die Pfeiltasten den Griff um ein Pixel, mit Umschalt um zehn</s:String>
<s:String x:Key="TipPointFormat">{0}, Punkt {1}: zum Verschieben ziehen; mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>
+ <s:String x:Key="TipNodeFormat">{0}, Knoten {1}: zum Verschieben mit seinen Griffen ziehen; mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>
+ <s:String x:Key="TipInHandleFormat">{0}, Knoten {1}, Eingangsgriff: Ziehen formt das hier ankommende Segment; ein glatter Knoten dreht den Ausgangsgriff mit. Mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>
+ <s:String x:Key="TipOutHandleFormat">{0}, Knoten {1}, Ausgangsgriff: Ziehen formt das hier abgehende Segment; ein glatter Knoten dreht den Eingangsgriff mit. Mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>
<s:String x:Key="TipProbeBoxFormat">Diagramm von {0}: zum Verschieben des Kastens ziehen; mit Tastaturfokus bewegen die Pfeiltasten um ein Pixel, mit Umschalt um zehn</s:String>
<s:String x:Key="TipProbeBoxCornerFormat">Diagramm von {0}: zum Ändern der Kastengröße ziehen (rastet auf den festen Größen ein); mit Tastaturfokus ändern die Pfeiltasten die Größe um ein Pixel, mit Umschalt um zehn</s:String>
<s:String x:Key="LabelPreviewStep">Schritt</s:String>
@@ -267,11 +270,18 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="SectionCladding">Mantel</s:String>
<s:String x:Key="SectionLayers">Schichten</s:String>
<s:String x:Key="SectionPoints">Punkte</s:String>
+ <s:String x:Key="SectionNodes">Knoten</s:String>
<s:String x:Key="HintPolygonPoints">Eckpunkte des Umrisses relativ zum Mittelpunkt, vor der Drehung. Leer: das regelmäßige Polygon oben wird verwendet.</s:String>
- <s:String x:Key="HintFiberPoints">Stützpunkte des Pfads relativ zum Mittelpunkt, vor der Drehung.</s:String>
+ <s:String x:Key="HintFiberNodes">Knoten des Pfads relativ zum Mittelpunkt, vor der Drehung, jeder mit dem Eingangs- und Ausgangsgriff der dort zusammentreffenden Segmente als Versatz vom Knoten. Weniger als zwei Knoten zeichnen nichts.</s:String>
<s:String x:Key="ButtonAddPoint">Punkt hinzufügen</s:String>
<s:String x:Key="TipAddPoint">Punkt nach dem letzten anfügen</s:String>
<s:String x:Key="TipRemovePoint">Diesen Punkt entfernen</s:String>
+ <s:String x:Key="ButtonAddNode">Knoten hinzufügen</s:String>
+ <s:String x:Key="TipAddNode">Knoten hinter dem letzten anfügen, den Pfad fortsetzend</s:String>
+ <s:String x:Key="TipRemoveNode">Diesen Knoten entfernen</s:String>
+ <s:String x:Key="LabelNodePoint">Knoten</s:String>
+ <s:String x:Key="LabelNodeIn">Ein</s:String>
+ <s:String x:Key="LabelNodeOut">Aus</s:String>
<s:String x:Key="LabelApexAngle">Winkel an der Spitze</s:String>
<s:String x:Key="TipApexAngle">Der Winkel an der Spitze: 180° minus die beiden Grundwinkel</s:String>
<s:String x:Key="LabelEdgeThickness">Randdicke</s:String>
@@ -324,6 +334,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.Display.ProbeGraphsInExport">Die Graphkästen der Sonden in exportierte Bilder und Videos zeichnen.</s:String>
<s:String x:Key="Label.Display.ProbeMarkersInExport">Sondenmarkierungen im Export</s:String>
<s:String x:Key="Hint.Display.ProbeMarkersInExport">Die Positionen der Sonden (Kreuze, die Linie einer Liniensonde, die Nummer) in exportierte Bilder und Videos zeichnen.</s:String>
+ <s:String x:Key="Label.Display.SourceMarkersInExport">Quellenmarkierungen im Export</s:String>
+ <s:String x:Key="Hint.Display.SourceMarkersInExport">Die aktiven Quellen (die Markierung, die Emitterpunkte einer zusammengesetzten Quelle, den Namen) in exportierte Bilder und Videos zeichnen.</s:String>
<s:String x:Key="Label.DisplayLayer.ColorScheme">Farbschema</s:String>
<s:String x:Key="Hint.DisplayLayer.ColorScheme">Name des Farbschemas, das auf die Werte abgebildet wird.</s:String>
<s:String x:Key="Label.DisplayLayer.Brightness">Helligkeit</s:String>
@@ -334,8 +346,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.DisplayLayer.Preview">Diese Ausgabe in der Live-Vorschau zeigen.</s:String>
<s:String x:Key="Label.DisplayLayer.Overlay">Umriss in der Vorschau</s:String>
<s:String x:Key="Hint.DisplayLayer.Overlay">Den Leuchtkanten-Umriss des Szenenbilds in der Vorschau über diese Ausgabe legen.</s:String>
- <s:String x:Key="Label.Display.SourceMarkersInExport">Quellenmarkierungen im Export</s:String>
- <s:String x:Key="Hint.Display.SourceMarkersInExport">Die aktiven Quellen (die Markierung, die Emitterpunkte einer zusammengesetzten Quelle, den Namen) in exportierte Bilder und Videos zeichnen.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayGain">Umrisshelligkeit</s:String>
<s:String x:Key="Hint.DisplayLayer.OverlayGain">Faktor des Umrisses: 1 wie berechnet, höher hebt schwache Kanten an, 0 blendet ihn aus.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayInExport">Umriss im Export</s:String>
@@ -605,8 +615,24 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.FiberPart.CladdingThickness">Dicke des Mantels um den Kern in Pixeln; 0 für einen blanken Kern.</s:String>
<s:String x:Key="Label.FiberPart.Coating">Entspiegelung</s:String>
<s:String x:Key="Hint.FiberPart.Coating">Dicke in Pixeln des entspiegelnden Bands direkt innerhalb der Außengrenze mit dem Index √n; 0 für keines.</s:String>
- <s:String x:Key="Label.FiberPart.Points">Punkte</s:String>
- <s:String x:Key="Hint.FiberPart.Points">Stützpunkte des Pfads relativ zum Mittelpunkt, vor der Drehung. Weniger als zwei Punkte zeichnen nichts.</s:String>
+ <s:String x:Key="Label.FiberPart.Ends">Enden</s:String>
+ <s:String x:Key="Hint.FiberPart.Ends">Wie die beiden Enden geschnitten sind: flach, gerade quer zum Pfad wie eine gebrochene Faser, oder mit dem Außenradius gerundet. Die AR-Beschichtung folgt einer flachen Endfläche.</s:String>
+ <s:String x:Key="Label.FiberPart.Nodes">Knoten</s:String>
+ <s:String x:Key="Hint.FiberPart.Nodes">Die Knoten des Pfads relativ zum Mittelpunkt, vor der Drehung, jeder mit den Griffen der dort zusammentreffenden kubischen Segmente. Weniger als zwei Knoten zeichnen nichts.</s:String>
+ <s:String x:Key="Label.FiberNode.X">X</s:String>
+ <s:String x:Key="Hint.FiberNode.X">X relativ zum Mittelpunkt des Bauteils in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.FiberNode.Y">Y</s:String>
+ <s:String x:Key="Hint.FiberNode.Y">Y relativ zum Mittelpunkt des Bauteils in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.FiberNode.InX">Ein X</s:String>
+ <s:String x:Key="Hint.FiberNode.InX">X des Eingangsgriffs relativ zum Knoten in Leinwandpixeln, vor der Drehung. Er formt das vom vorigen Knoten ankommende Segment; null macht es an diesem Ende gerade.</s:String>
+ <s:String x:Key="Label.FiberNode.InY">Ein Y</s:String>
+ <s:String x:Key="Hint.FiberNode.InY">Y des Eingangsgriffs relativ zum Knoten in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.FiberNode.OutX">Aus X</s:String>
+ <s:String x:Key="Hint.FiberNode.OutX">X des Ausgangsgriffs relativ zum Knoten in Leinwandpixeln, vor der Drehung. Er formt das zum nächsten Knoten abgehende Segment; null macht es an diesem Ende gerade.</s:String>
+ <s:String x:Key="Label.FiberNode.OutY">Aus Y</s:String>
+ <s:String x:Key="Hint.FiberNode.OutY">Y des Ausgangsgriffs relativ zum Knoten in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.FiberNode.Smooth">Glatt</s:String>
+ <s:String x:Key="Hint.FiberNode.Smooth">Die beiden Griffe einander gegenüber durch den Knoten halten, sodass der Pfad glatt hindurchläuft. Beim Einschalten werden sie sofort ausgerichtet; danach dreht sich beim Bewegen oder Eintippen eines Griffs der andere mit, seine Länge bleibt. Aus, kann der Knoten eine Ecke sein.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Pairs">Schichtpaare</s:String>
<s:String x:Key="Hint.BraggReflectorPart.Pairs">Anzahl der Schichtpaare, 1 bis 200.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Thickness1">Dicke 1</s:String>
@@ -638,6 +664,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.PartKind.Fiber">Faser</s:String>
<s:String x:Key="Enum.PartKind.BraggReflector">Bragg-Reflektor</s:String>
<s:String x:Key="Enum.PartKind.GrinLens">GRIN-Linse</s:String>
+ <s:String x:Key="Enum.FiberEnds.Flat">Flach</s:String>
+ <s:String x:Key="Enum.FiberEnds.Round">Rund</s:String>
<s:String x:Key="Enum.TriangleType.Equilateral">Gleichseitig</s:String>
<s:String x:Key="Enum.TriangleType.RightIsosceles">Rechtwinklig-gleichschenklig (45°)</s:String>
<s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
index f66f96b..19c5666 100644
--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
@@ -189,6 +189,9 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipAngleMarkerFormat">{0}: drag to turn the array (Shift snaps to 15 degrees); with keyboard focus the arrow keys turn it by a degree, ten with Shift</s:String>
<s:String x:Key="TipGripFormat">{0}: drag to resize; with keyboard focus the arrow keys move the grip by a pixel, ten with Shift</s:String>
<s:String x:Key="TipPointFormat">{0}, point {1}: drag to move it; with keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>
+ <s:String x:Key="TipNodeFormat">{0}, node {1}: drag to move it with its handles; with keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>
+ <s:String x:Key="TipInHandleFormat">{0}, node {1}, in-handle: drag to shape the segment arriving here; a smooth node turns the out-handle with it. With keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>
+ <s:String x:Key="TipOutHandleFormat">{0}, node {1}, out-handle: drag to shape the segment leaving here; a smooth node turns the in-handle with it. With keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>
<s:String x:Key="TipProbeBoxFormat">Graph of {0}: drag to move the box; with keyboard focus the arrow keys move it by a pixel, ten with Shift</s:String>
<s:String x:Key="TipProbeBoxCornerFormat">Graph of {0}: drag to resize the box (it snaps to the fixed sizes); with keyboard focus the arrow keys resize it by a pixel, ten with Shift</s:String>
<s:String x:Key="LabelPreviewStep">step</s:String>
@@ -269,11 +272,18 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="SectionCladding">Cladding</s:String>
<s:String x:Key="SectionLayers">Layers</s:String>
<s:String x:Key="SectionPoints">Points</s:String>
+ <s:String x:Key="SectionNodes">Nodes</s:String>
<s:String x:Key="HintPolygonPoints">Vertices of the outline relative to the centre, before rotation. Empty: the regular polygon above is used.</s:String>
- <s:String x:Key="HintFiberPoints">Vertices of the path relative to the centre, before rotation.</s:String>
+ <s:String x:Key="HintFiberNodes">Nodes of the path relative to the centre, before rotation, each with the in- and out-handle of the segments meeting there, as offsets from the node. Fewer than two nodes paint nothing.</s:String>
<s:String x:Key="ButtonAddPoint">Add point</s:String>
<s:String x:Key="TipAddPoint">Append a point after the last one</s:String>
<s:String x:Key="TipRemovePoint">Remove this point</s:String>
+ <s:String x:Key="ButtonAddNode">Add node</s:String>
+ <s:String x:Key="TipAddNode">Append a node beyond the last one, continuing the path</s:String>
+ <s:String x:Key="TipRemoveNode">Remove this node</s:String>
+ <s:String x:Key="LabelNodePoint">Node</s:String>
+ <s:String x:Key="LabelNodeIn">In</s:String>
+ <s:String x:Key="LabelNodeOut">Out</s:String>
<s:String x:Key="LabelApexAngle">Apex angle</s:String>
<s:String x:Key="TipApexAngle">The angle at the apex: 180° minus the two base angles</s:String>
<s:String x:Key="LabelEdgeThickness">Edge thickness</s:String>
@@ -326,6 +336,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.Display.ProbeGraphsInExport">Draw the probes' graph boxes over exported frames and videos.</s:String>
<s:String x:Key="Label.Display.ProbeMarkersInExport">Probe markers in the export</s:String>
<s:String x:Key="Hint.Display.ProbeMarkersInExport">Draw the probes' positions (crosses, the line of a line probe, the number) over exported frames and videos.</s:String>
+ <s:String x:Key="Label.Display.SourceMarkersInExport">Source markers in the export</s:String>
+ <s:String x:Key="Hint.Display.SourceMarkersInExport">Draw the enabled sources (the marker, a composite source's emitter dots, the name) over exported frames and videos.</s:String>
<s:String x:Key="Label.DisplayLayer.ColorScheme">Colour scheme</s:String>
<s:String x:Key="Hint.DisplayLayer.ColorScheme">Name of the colour scheme mapped onto the values.</s:String>
<s:String x:Key="Label.DisplayLayer.Brightness">Brightness</s:String>
@@ -336,8 +348,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.DisplayLayer.Preview">Show this output in the live preview.</s:String>
<s:String x:Key="Label.DisplayLayer.Overlay">Outline in the preview</s:String>
<s:String x:Key="Hint.DisplayLayer.Overlay">Lay the scene image's glowing-edges outline over this output in the preview.</s:String>
- <s:String x:Key="Label.Display.SourceMarkersInExport">Source markers in the export</s:String>
- <s:String x:Key="Hint.Display.SourceMarkersInExport">Draw the enabled sources (the marker, a composite source's emitter dots, the name) over exported frames and videos.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayGain">Outline brightness</s:String>
<s:String x:Key="Hint.DisplayLayer.OverlayGain">Multiplier of the outline: 1 as computed, higher lifts faint edges, 0 hides it.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayInExport">Outline in the export</s:String>
@@ -607,8 +617,24 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.FiberPart.CladdingThickness">Thickness of the cladding around the core in pixels; 0 for a bare core.</s:String>
<s:String x:Key="Label.FiberPart.Coating">AR coating</s:String>
<s:String x:Key="Hint.FiberPart.Coating">Thickness in pixels of the anti-reflection band just inside the outer boundary, with the index √n; 0 for none.</s:String>
- <s:String x:Key="Label.FiberPart.Points">Points</s:String>
- <s:String x:Key="Hint.FiberPart.Points">The path's vertices relative to the centre, before rotation. Fewer than two points paint nothing.</s:String>
+ <s:String x:Key="Label.FiberPart.Ends">Ends</s:String>
+ <s:String x:Key="Hint.FiberPart.Ends">How the two ends are cut: flat, straight across the path like a cleaved fibre, or rounded with the outer radius. The AR coating follows a flat end face.</s:String>
+ <s:String x:Key="Label.FiberPart.Nodes">Nodes</s:String>
+ <s:String x:Key="Hint.FiberPart.Nodes">The path's nodes relative to the centre, before rotation, each with the handles of the cubic segments meeting there. Fewer than two nodes paint nothing.</s:String>
+ <s:String x:Key="Label.FiberNode.X">X</s:String>
+ <s:String x:Key="Hint.FiberNode.X">X relative to the part's centre in canvas pixels, before rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.Y">Y</s:String>
+ <s:String x:Key="Hint.FiberNode.Y">Y relative to the part's centre in canvas pixels, before rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.InX">In X</s:String>
+ <s:String x:Key="Hint.FiberNode.InX">X of the in-handle relative to the node, in canvas pixels before rotation. It shapes the segment arriving from the previous node; zero makes that segment straight at this end.</s:String>
+ <s:String x:Key="Label.FiberNode.InY">In Y</s:String>
+ <s:String x:Key="Hint.FiberNode.InY">Y of the in-handle relative to the node, in canvas pixels before rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.OutX">Out X</s:String>
+ <s:String x:Key="Hint.FiberNode.OutX">X of the out-handle relative to the node, in canvas pixels before rotation. It shapes the segment leaving to the next node; zero makes that segment straight at this end.</s:String>
+ <s:String x:Key="Label.FiberNode.OutY">Out Y</s:String>
+ <s:String x:Key="Hint.FiberNode.OutY">Y of the out-handle relative to the node, in canvas pixels before rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.Smooth">Smooth</s:String>
+ <s:String x:Key="Hint.FiberNode.Smooth">Keep the two handles opposite each other through the node, so the path runs smoothly through it. Switching it on lines them up at once; afterwards moving or typing one handle turns the other with it, keeping its length. Off, the node may be a corner.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Pairs">Layer pairs</s:String>
<s:String x:Key="Hint.BraggReflectorPart.Pairs">Number of layer pairs, 1 to 200.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Thickness1">Thickness 1</s:String>
@@ -640,6 +666,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.PartKind.Fiber">Fibre</s:String>
<s:String x:Key="Enum.PartKind.BraggReflector">Bragg reflector</s:String>
<s:String x:Key="Enum.PartKind.GrinLens">GRIN lens</s:String>
+ <s:String x:Key="Enum.FiberEnds.Flat">Flat</s:String>
+ <s:String x:Key="Enum.FiberEnds.Round">Round</s:String>
<s:String x:Key="Enum.TriangleType.Equilateral">Equilateral</s:String>
<s:String x:Key="Enum.TriangleType.RightIsosceles">Right isosceles (45°)</s:String>
<s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
index b724411..417d7c2 100644
--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
@@ -187,6 +187,9 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipAngleMarkerFormat">{0} : glisser pour tourner la grille (Maj aligne sur 15 degrés) ; avec le focus clavier, les flèches la tournent d'un degré, de dix avec Maj</s:String>
<s:String x:Key="TipGripFormat">{0} : glisser pour redimensionner ; avec le focus clavier, les flèches déplacent la poignée d'un pixel, de dix avec Maj</s:String>
<s:String x:Key="TipPointFormat">{0}, point {1} : glisser pour déplacer ; avec le focus clavier, les flèches déplacent d'un pixel, de dix avec Maj</s:String>
+ <s:String x:Key="TipNodeFormat">{0}, nœud {1} : glisser pour le déplacer avec ses poignées ; avec le focus clavier, les flèches le déplacent d'un pixel, de dix avec Maj</s:String>
+ <s:String x:Key="TipInHandleFormat">{0}, nœud {1}, poignée d'entrée : glisser pour former le segment qui arrive ici ; un nœud lisse entraîne la poignée de sortie. Avec le focus clavier, les flèches la déplacent d'un pixel, de dix avec Maj</s:String>
+ <s:String x:Key="TipOutHandleFormat">{0}, nœud {1}, poignée de sortie : glisser pour former le segment qui part d'ici ; un nœud lisse entraîne la poignée d'entrée. Avec le focus clavier, les flèches la déplacent d'un pixel, de dix avec Maj</s:String>
<s:String x:Key="TipProbeBoxFormat">Graphique de {0} : glisser pour déplacer le cadre ; avec le focus clavier, les flèches le déplacent d'un pixel, de dix avec Maj</s:String>
<s:String x:Key="TipProbeBoxCornerFormat">Graphique de {0} : glisser pour redimensionner le cadre (il s'aligne sur les tailles fixes) ; avec le focus clavier, les flèches le redimensionnent d'un pixel, de dix avec Maj</s:String>
<s:String x:Key="LabelPreviewStep">pas</s:String>
@@ -267,11 +270,18 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="SectionCladding">Gaine</s:String>
<s:String x:Key="SectionLayers">Couches</s:String>
<s:String x:Key="SectionPoints">Points</s:String>
+ <s:String x:Key="SectionNodes">Nœuds</s:String>
<s:String x:Key="HintPolygonPoints">Sommets du contour par rapport au centre, avant rotation. Vide : le polygone régulier ci-dessus est utilisé.</s:String>
- <s:String x:Key="HintFiberPoints">Sommets du trajet par rapport au centre, avant rotation.</s:String>
+ <s:String x:Key="HintFiberNodes">Nœuds du trajet par rapport au centre, avant rotation, chacun avec les poignées d'entrée et de sortie des segments qui s'y rejoignent, en décalage par rapport au nœud. Moins de deux nœuds ne peignent rien.</s:String>
<s:String x:Key="ButtonAddPoint">Ajouter un point</s:String>
<s:String x:Key="TipAddPoint">Ajouter un point après le dernier</s:String>
<s:String x:Key="TipRemovePoint">Supprimer ce point</s:String>
+ <s:String x:Key="ButtonAddNode">Ajouter un nœud</s:String>
+ <s:String x:Key="TipAddNode">Ajouter un nœud après le dernier, dans le prolongement du trajet</s:String>
+ <s:String x:Key="TipRemoveNode">Supprimer ce nœud</s:String>
+ <s:String x:Key="LabelNodePoint">Nœud</s:String>
+ <s:String x:Key="LabelNodeIn">Entrée</s:String>
+ <s:String x:Key="LabelNodeOut">Sortie</s:String>
<s:String x:Key="LabelApexAngle">Angle au sommet</s:String>
<s:String x:Key="TipApexAngle">L'angle au sommet : 180° moins les deux angles à la base</s:String>
<s:String x:Key="LabelEdgeThickness">Épaisseur au bord</s:String>
@@ -324,6 +334,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.Display.ProbeGraphsInExport">Dessiner les cadres de graphe des sondes sur les images et vidéos exportées.</s:String>
<s:String x:Key="Label.Display.ProbeMarkersInExport">Marqueurs des sondes dans l'export</s:String>
<s:String x:Key="Hint.Display.ProbeMarkersInExport">Dessiner les positions des sondes (croix, la ligne d'une sonde linéaire, le numéro) sur les images et vidéos exportées.</s:String>
+ <s:String x:Key="Label.Display.SourceMarkersInExport">Marqueurs des sources dans l'export</s:String>
+ <s:String x:Key="Hint.Display.SourceMarkersInExport">Dessiner les sources actives (le marqueur, les points émetteurs d'une source composée, le nom) sur les images et vidéos exportées.</s:String>
<s:String x:Key="Label.DisplayLayer.ColorScheme">Palette de couleurs</s:String>
<s:String x:Key="Hint.DisplayLayer.ColorScheme">Nom de la palette appliquée aux valeurs.</s:String>
<s:String x:Key="Label.DisplayLayer.Brightness">Luminosité</s:String>
@@ -334,8 +346,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.DisplayLayer.Preview">Afficher cette sortie dans l'aperçu en direct.</s:String>
<s:String x:Key="Label.DisplayLayer.Overlay">Contour dans l'aperçu</s:String>
<s:String x:Key="Hint.DisplayLayer.Overlay">Superposer le contour « bords lumineux » de l'image de scène à cette sortie dans l'aperçu.</s:String>
- <s:String x:Key="Label.Display.SourceMarkersInExport">Marqueurs des sources dans l'export</s:String>
- <s:String x:Key="Hint.Display.SourceMarkersInExport">Dessiner les sources actives (le marqueur, les points émetteurs d'une source composée, le nom) sur les images et vidéos exportées.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayGain">Luminosité du contour</s:String>
<s:String x:Key="Hint.DisplayLayer.OverlayGain">Multiplicateur du contour : 1 tel que calculé, plus haut relève les bords faibles, 0 le masque.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayInExport">Contour dans l'export</s:String>
@@ -605,8 +615,24 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.FiberPart.CladdingThickness">Épaisseur de la gaine autour du cœur en pixels ; 0 pour un cœur nu.</s:String>
<s:String x:Key="Label.FiberPart.Coating">Traitement antireflet</s:String>
<s:String x:Key="Hint.FiberPart.Coating">Épaisseur en pixels de la bande antireflet juste à l'intérieur de la limite extérieure, d'indice √n ; 0 pour aucune.</s:String>
- <s:String x:Key="Label.FiberPart.Points">Points</s:String>
- <s:String x:Key="Hint.FiberPart.Points">Sommets du trajet par rapport au centre, avant rotation. Moins de deux points ne peignent rien.</s:String>
+ <s:String x:Key="Label.FiberPart.Ends">Extrémités</s:String>
+ <s:String x:Key="Hint.FiberPart.Ends">Comment les deux extrémités sont coupées : à plat, droit en travers du trajet comme une fibre clivée, ou arrondies au rayon extérieur. Le traitement antireflet suit une face plate.</s:String>
+ <s:String x:Key="Label.FiberPart.Nodes">Nœuds</s:String>
+ <s:String x:Key="Hint.FiberPart.Nodes">Les nœuds du trajet par rapport au centre, avant rotation, chacun avec les poignées des segments cubiques qui s'y rejoignent. Moins de deux nœuds ne peignent rien.</s:String>
+ <s:String x:Key="Label.FiberNode.X">X</s:String>
+ <s:String x:Key="Hint.FiberNode.X">X par rapport au centre du composant en pixels de la toile, avant rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.Y">Y</s:String>
+ <s:String x:Key="Hint.FiberNode.Y">Y par rapport au centre du composant en pixels de la toile, avant rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.InX">Entrée X</s:String>
+ <s:String x:Key="Hint.FiberNode.InX">X de la poignée d'entrée par rapport au nœud, en pixels de la toile avant rotation. Elle forme le segment venant du nœud précédent ; zéro le rend droit à cette extrémité.</s:String>
+ <s:String x:Key="Label.FiberNode.InY">Entrée Y</s:String>
+ <s:String x:Key="Hint.FiberNode.InY">Y de la poignée d'entrée par rapport au nœud, en pixels de la toile avant rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.OutX">Sortie X</s:String>
+ <s:String x:Key="Hint.FiberNode.OutX">X de la poignée de sortie par rapport au nœud, en pixels de la toile avant rotation. Elle forme le segment allant au nœud suivant ; zéro le rend droit à cette extrémité.</s:String>
+ <s:String x:Key="Label.FiberNode.OutY">Sortie Y</s:String>
+ <s:String x:Key="Hint.FiberNode.OutY">Y de la poignée de sortie par rapport au nœud, en pixels de la toile avant rotation.</s:String>
+ <s:String x:Key="Label.FiberNode.Smooth">Lisse</s:String>
+ <s:String x:Key="Hint.FiberNode.Smooth">Garder les deux poignées opposées de part et d'autre du nœud, pour que le trajet le traverse en douceur. À l'activation elles sont alignées aussitôt ; ensuite déplacer ou saisir une poignée entraîne l'autre, qui garde sa longueur. Désactivé, le nœud peut former un angle.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Pairs">Paires de couches</s:String>
<s:String x:Key="Hint.BraggReflectorPart.Pairs">Nombre de paires de couches, de 1 à 200.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Thickness1">Épaisseur 1</s:String>
@@ -638,6 +664,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.PartKind.Fiber">Fibre</s:String>
<s:String x:Key="Enum.PartKind.BraggReflector">Réflecteur de Bragg</s:String>
<s:String x:Key="Enum.PartKind.GrinLens">Lentille GRIN</s:String>
+ <s:String x:Key="Enum.FiberEnds.Flat">Plates</s:String>
+ <s:String x:Key="Enum.FiberEnds.Round">Arrondies</s:String>
<s:String x:Key="Enum.TriangleType.Equilateral">Équilatéral</s:String>
<s:String x:Key="Enum.TriangleType.RightIsosceles">Rectangle isocèle (45°)</s:String>
<s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>
diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
index 1dd2083..664ed30 100644
--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
@@ -187,6 +187,9 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipAngleMarkerFormat">{0}: slepen om het raster te draaien (Shift klikt vast op 15 graden); met toetsenbordfocus draaien de pijltoetsen het één graad, tien met Shift</s:String>
<s:String x:Key="TipGripFormat">{0}: slepen om de grootte te wijzigen; met toetsenbordfocus verplaatsen de pijltoetsen de greep één pixel, tien met Shift</s:String>
<s:String x:Key="TipPointFormat">{0}, punt {1}: slepen om te verplaatsen; met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>
+ <s:String x:Key="TipNodeFormat">{0}, knooppunt {1}: slepen om het met zijn grepen te verplaatsen; met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>
+ <s:String x:Key="TipInHandleFormat">{0}, knooppunt {1}, ingaande greep: slepen vormt het segment dat hier aankomt; een glad knooppunt draait de uitgaande greep mee. Met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>
+ <s:String x:Key="TipOutHandleFormat">{0}, knooppunt {1}, uitgaande greep: slepen vormt het segment dat hier vertrekt; een glad knooppunt draait de ingaande greep mee. Met toetsenbordfocus verplaatsen de pijltoetsen één pixel, tien met Shift</s:String>
<s:String x:Key="TipProbeBoxFormat">Grafiek van {0}: slepen om het kader te verplaatsen; met toetsenbordfocus verplaatsen de pijltoetsen het één pixel, tien met Shift</s:String>
<s:String x:Key="TipProbeBoxCornerFormat">Grafiek van {0}: slepen om het kader te vergroten of verkleinen (het klikt vast op de vaste maten); met toetsenbordfocus wijzigen de pijltoetsen de maat één pixel, tien met Shift</s:String>
<s:String x:Key="LabelPreviewStep">stap</s:String>
@@ -267,11 +270,18 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="SectionCladding">Mantel</s:String>
<s:String x:Key="SectionLayers">Lagen</s:String>
<s:String x:Key="SectionPoints">Punten</s:String>
+ <s:String x:Key="SectionNodes">Knooppunten</s:String>
<s:String x:Key="HintPolygonPoints">Hoekpunten van de omtrek ten opzichte van het middelpunt, vóór rotatie. Leeg: de regelmatige veelhoek hierboven wordt gebruikt.</s:String>
- <s:String x:Key="HintFiberPoints">Punten van het pad ten opzichte van het middelpunt, vóór rotatie.</s:String>
+ <s:String x:Key="HintFiberNodes">Knooppunten van het pad ten opzichte van het middelpunt, vóór rotatie, elk met de ingaande en uitgaande greep van de segmenten die daar samenkomen, als verschuiving ten opzichte van het knooppunt. Minder dan twee knooppunten tekenen niets.</s:String>
<s:String x:Key="ButtonAddPoint">Punt toevoegen</s:String>
<s:String x:Key="TipAddPoint">Punt na het laatste toevoegen</s:String>
<s:String x:Key="TipRemovePoint">Dit punt verwijderen</s:String>
+ <s:String x:Key="ButtonAddNode">Knooppunt toevoegen</s:String>
+ <s:String x:Key="TipAddNode">Knooppunt na het laatste toevoegen, in het verlengde van het pad</s:String>
+ <s:String x:Key="TipRemoveNode">Dit knooppunt verwijderen</s:String>
+ <s:String x:Key="LabelNodePoint">Knoop</s:String>
+ <s:String x:Key="LabelNodeIn">In</s:String>
+ <s:String x:Key="LabelNodeOut">Uit</s:String>
<s:String x:Key="LabelApexAngle">Tophoek</s:String>
<s:String x:Key="TipApexAngle">De hoek aan de top: 180° min de twee basishoeken</s:String>
<s:String x:Key="LabelEdgeThickness">Randdikte</s:String>
@@ -324,6 +334,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.Display.ProbeGraphsInExport">De grafiekvakken van de sondes over geëxporteerde beelden en video's tekenen.</s:String>
<s:String x:Key="Label.Display.ProbeMarkersInExport">Sondemarkeringen in de export</s:String>
<s:String x:Key="Hint.Display.ProbeMarkersInExport">De posities van de sondes (kruisen, de lijn van een lijnsonde, het nummer) over geëxporteerde beelden en video's tekenen.</s:String>
+ <s:String x:Key="Label.Display.SourceMarkersInExport">Bronmarkeringen in de export</s:String>
+ <s:String x:Key="Hint.Display.SourceMarkersInExport">De ingeschakelde bronnen (de markering, de emitterpunten van een samengestelde bron, de naam) over geëxporteerde beelden en video's tekenen.</s:String>
<s:String x:Key="Label.DisplayLayer.ColorScheme">Kleurenschema</s:String>
<s:String x:Key="Hint.DisplayLayer.ColorScheme">Naam van het kleurenschema dat op de waarden wordt toegepast.</s:String>
<s:String x:Key="Label.DisplayLayer.Brightness">Helderheid</s:String>
@@ -334,8 +346,6 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.DisplayLayer.Preview">Deze uitvoer in het live-voorbeeld tonen.</s:String>
<s:String x:Key="Label.DisplayLayer.Overlay">Omtrek in het voorbeeld</s:String>
<s:String x:Key="Hint.DisplayLayer.Overlay">De gloeiende-randen-omtrek van de scèneafbeelding in het voorbeeld over deze uitvoer leggen.</s:String>
- <s:String x:Key="Label.Display.SourceMarkersInExport">Bronmarkeringen in de export</s:String>
- <s:String x:Key="Hint.Display.SourceMarkersInExport">De ingeschakelde bronnen (de markering, de emitterpunten van een samengestelde bron, de naam) over geëxporteerde beelden en video's tekenen.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayGain">Omtrekhelderheid</s:String>
<s:String x:Key="Hint.DisplayLayer.OverlayGain">Factor van de omtrek: 1 zoals berekend, hoger versterkt zwakke randen, 0 verbergt hem.</s:String>
<s:String x:Key="Label.DisplayLayer.OverlayInExport">Omtrek in de export</s:String>
@@ -605,8 +615,24 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Hint.FiberPart.CladdingThickness">Dikte van de mantel om de kern in pixels; 0 voor een kale kern.</s:String>
<s:String x:Key="Label.FiberPart.Coating">AR-coating</s:String>
<s:String x:Key="Hint.FiberPart.Coating">Dikte in pixels van de antireflectieband net binnen de buitenrand, met index √n; 0 voor geen.</s:String>
- <s:String x:Key="Label.FiberPart.Points">Punten</s:String>
- <s:String x:Key="Hint.FiberPart.Points">Punten van het pad ten opzichte van het middelpunt, vóór rotatie. Minder dan twee punten tekenen niets.</s:String>
+ <s:String x:Key="Label.FiberPart.Ends">Uiteinden</s:String>
+ <s:String x:Key="Hint.FiberPart.Ends">Hoe de twee uiteinden zijn afgesneden: vlak, recht dwars op het pad zoals een gekliefde vezel, of afgerond met de buitenstraal. De AR-coating volgt een vlak eindvlak.</s:String>
+ <s:String x:Key="Label.FiberPart.Nodes">Knooppunten</s:String>
+ <s:String x:Key="Hint.FiberPart.Nodes">De knooppunten van het pad ten opzichte van het middelpunt, vóór rotatie, elk met de grepen van de kubische segmenten die daar samenkomen. Minder dan twee knooppunten tekenen niets.</s:String>
+ <s:String x:Key="Label.FiberNode.X">X</s:String>
+ <s:String x:Key="Hint.FiberNode.X">X ten opzichte van het middelpunt van het onderdeel in canvaspixels, vóór rotatie.</s:String>
+ <s:String x:Key="Label.FiberNode.Y">Y</s:String>
+ <s:String x:Key="Hint.FiberNode.Y">Y ten opzichte van het middelpunt van het onderdeel in canvaspixels, vóór rotatie.</s:String>
+ <s:String x:Key="Label.FiberNode.InX">In X</s:String>
+ <s:String x:Key="Hint.FiberNode.InX">X van de ingaande greep ten opzichte van het knooppunt, in canvaspixels vóór rotatie. Hij vormt het segment dat van het vorige knooppunt komt; nul maakt het aan dit uiteinde recht.</s:String>
+ <s:String x:Key="Label.FiberNode.InY">In Y</s:String>
+ <s:String x:Key="Hint.FiberNode.InY">Y van de ingaande greep ten opzichte van het knooppunt, in canvaspixels vóór rotatie.</s:String>
+ <s:String x:Key="Label.FiberNode.OutX">Uit X</s:String>
+ <s:String x:Key="Hint.FiberNode.OutX">X van de uitgaande greep ten opzichte van het knooppunt, in canvaspixels vóór rotatie. Hij vormt het segment dat naar het volgende knooppunt gaat; nul maakt het aan dit uiteinde recht.</s:String>
+ <s:String x:Key="Label.FiberNode.OutY">Uit Y</s:String>
+ <s:String x:Key="Hint.FiberNode.OutY">Y van de uitgaande greep ten opzichte van het knooppunt, in canvaspixels vóór rotatie.</s:String>
+ <s:String x:Key="Label.FiberNode.Smooth">Glad</s:String>
+ <s:String x:Key="Hint.FiberNode.Smooth">De twee grepen tegenover elkaar door het knooppunt houden, zodat het pad er glad doorheen loopt. Bij het inschakelen worden ze meteen uitgelijnd; daarna draait bij het verplaatsen of intypen van een greep de andere mee, met behoud van zijn lengte. Uit, kan het knooppunt een hoek zijn.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Pairs">Laagparen</s:String>
<s:String x:Key="Hint.BraggReflectorPart.Pairs">Aantal laagparen, 1 tot 200.</s:String>
<s:String x:Key="Label.BraggReflectorPart.Thickness1">Dikte 1</s:String>
@@ -638,6 +664,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.PartKind.Fiber">Vezel</s:String>
<s:String x:Key="Enum.PartKind.BraggReflector">Bragg-reflector</s:String>
<s:String x:Key="Enum.PartKind.GrinLens">GRIN-lens</s:String>
+ <s:String x:Key="Enum.FiberEnds.Flat">Vlak</s:String>
+ <s:String x:Key="Enum.FiberEnds.Round">Rond</s:String>
<s:String x:Key="Enum.TriangleType.Equilateral">Gelijkzijdig</s:String>
<s:String x:Key="Enum.TriangleType.RightIsosceles">Rechthoekig-gelijkbenig (45°)</s:String>
<s:String x:Key="Enum.TriangleType.ThirtySixtyNinety">30-60-90</s:String>
diff --git a/WaveDudeNext.WPF/Themes/Editors.xaml b/WaveDudeNext.WPF/Themes/Editors.xaml
index 514949c..9387721 100644
--- a/WaveDudeNext.WPF/Themes/Editors.xaml
+++ b/WaveDudeNext.WPF/Themes/Editors.xaml
@@ -528,6 +528,37 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</Style.Triggers>
</Style>
+ <StreamGeometry x:Key="MinusGeometry">M0,4 L8,4</StreamGeometry>
+ <!-- the remove button of a point or node row (Views/PartPointsView, Views/FiberPathView); in the Tab cycle, since no key removes a row otherwise -->
+ <Style x:Key="RemovePointButton" TargetType="{x:Type Button}">
+ <Setter Property="Width" Value="18" />
+ <Setter Property="Height" Value="18" />
+ <Setter Property="Margin" Value="4,0,0,0" />
+ <Setter Property="Foreground" Value="{DynamicResource WindowForeground}" />
+ <Setter Property="FocusVisualStyle" Value="{x:Null}" />
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type Button}">
+ <Border x:Name="Bd" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" SnapsToDevicePixels="True">
+ <Path Data="{StaticResource MinusGeometry}" Stroke="{TemplateBinding Foreground}" StrokeThickness="1.2"
+ HorizontalAlignment="Center" VerticalAlignment="Center" />
+ </Border>
+ <ControlTemplate.Triggers>
+ <Trigger Property="IsMouseOver" Value="True">
+ <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ButtonHover}" />
+ </Trigger>
+ <Trigger Property="IsKeyboardFocused" Value="True">
+ <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Accent}" />
+ </Trigger>
+ <Trigger Property="IsEnabled" Value="False">
+ <Setter Property="Opacity" Value="0.4" />
+ </Trigger>
+ </ControlTemplate.Triggers>
+ </ControlTemplate>
+ </Setter.Value>
+ </Setter>
+ </Style>
+
<Style x:Key="FormSection" TargetType="{x:Type Label}">
<Setter Property="FontWeight" Value="SemiBold" />
<Setter Property="Foreground" Value="{DynamicResource WindowForeground}" />
diff --git a/WaveDudeNext.WPF/Views/FiberPartView.xaml b/WaveDudeNext.WPF/Views/FiberPartView.xaml
index 34bc0a2..7ac94d1 100644
--- a/WaveDudeNext.WPF/Views/FiberPartView.xaml
+++ b/WaveDudeNext.WPF/Views/FiberPartView.xaml
@@ -50,7 +50,14 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<controls:NumberBox Text="{Binding Coating}" Minimum="0" Maximum="50" ToolTip="{meta:Hint model:FiberPart.Coating}" AutomationProperties.AutomationId="PartCoating" />
</controls:FormPanel>
- <views:PartPointsView HintText="{DynamicResource HintFiberPoints}" />
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.Ends}" />
+ <ComboBox Style="{StaticResource EnumComboBox}" ItemsSource="{meta:EnumValues model:FiberEnds}"
+ SelectedItem="{Binding Ends}" ToolTip="{meta:Hint model:FiberPart.Ends}" AutomationProperties.AutomationId="PartEnds" />
+ </controls:FormPanel>
+
+ <views:FiberPathView />
</StackPanel>
</ScrollViewer>
</UserControl>
diff --git a/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs b/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs
index e8dfef1..916113e 100644
--- a/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs
+++ b/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs
@@ -19,7 +19,7 @@ using System.Windows.Controls;
namespace WaveDudeNext.WPF.Views;
-/// <summary>Editor for a <see cref="WaveDudeNext.Model.FiberPart"/>: core, cladding and the path.</summary>
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.FiberPart"/>: core, cladding, the ends and the path (<see cref="FiberPathView"/>).</summary>
public partial class FiberPartView : UserControl
{
public FiberPartView()
diff --git a/WaveDudeNext.WPF/Views/FiberPathView.xaml b/WaveDudeNext.WPF/Views/FiberPathView.xaml
new file mode 100644
index 0000000..89a628b
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/FiberPathView.xaml
@@ -0,0 +1,91 @@
+<!--
+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
+ Jeroen Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ 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/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.FiberPathView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:controls="clr-namespace:WaveDudeNext.WPF.Controls"
+ xmlns:commands="clr-namespace:WaveDudeNext.WPF.Commands"
+ xmlns:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <UserControl.CommandBindings>
+ <CommandBinding Command="{x:Static commands:PartCommands.AddPoint}" CanExecute="CanAddNode" Executed="OnAddNode" />
+ <CommandBinding Command="{x:Static commands:PartCommands.RemovePoint}" CanExecute="CanRemoveNode" Executed="OnRemoveNode" />
+ </UserControl.CommandBindings>
+
+ <!-- the node list of a fibre's path (the data context is the part): one block per node with the node's X and Y, the
+ Smooth flag and a remove button on the first row, the in- and out-handle offsets on the rows below (relative to
+ the node, before rotation), and an add button under the list. Inside the template the string keys are referenced
+ directly: a template rejects the resource reference the meta extensions wrap (2026-10-22) -->
+ <StackPanel>
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionNodes}" />
+ <TextBlock Margin="0,0,0,4" Foreground="{DynamicResource GrayText}" TextWrapping="Wrap" Text="{DynamicResource HintFiberNodes}" />
+ <Grid Margin="0,0,0,2">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="36" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+ <TextBlock Grid.Column="1" Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberNode.X}" Margin="2,0" />
+ <TextBlock Grid.Column="2" Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberNode.Y}" Margin="2,0" />
+ </Grid>
+ <ItemsControl ItemsSource="{Binding Nodes}" Focusable="False">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <Grid Margin="0,0,0,6">
+ <Grid.ColumnDefinitions>
+ <ColumnDefinition Width="36" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="*" />
+ <ColumnDefinition Width="Auto" />
+ </Grid.ColumnDefinitions>
+ <Grid.RowDefinitions>
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ <RowDefinition Height="Auto" />
+ </Grid.RowDefinitions>
+ <TextBlock Grid.Row="0" Grid.Column="0" Style="{StaticResource FormLabel}" Text="{DynamicResource LabelNodePoint}" />
+ <controls:NumberBox Grid.Row="0" Grid.Column="1" Margin="0,0,2,2" Text="{Binding X}" ToolTip="{DynamicResource Hint.FiberNode.X}" />
+ <controls:NumberBox Grid.Row="0" Grid.Column="2" Margin="2,0,0,2" Text="{Binding Y}" ToolTip="{DynamicResource Hint.FiberNode.Y}" />
+ <StackPanel Grid.Row="0" Grid.Column="3" Orientation="Horizontal">
+ <!-- the label as a TextBlock child, which also names the box for automation (Content would show the reference, not the text) -->
+ <CheckBox Margin="6,0,0,2" VerticalAlignment="Center" IsChecked="{Binding Smooth}" ToolTip="{DynamicResource Hint.FiberNode.Smooth}">
+ <TextBlock Text="{DynamicResource Label.FiberNode.Smooth}" />
+ </CheckBox>
+ <Button Style="{StaticResource RemovePointButton}" ToolTip="{DynamicResource TipRemoveNode}" AutomationProperties.Name="{DynamicResource TipRemoveNode}"
+ Command="{x:Static commands:PartCommands.RemovePoint}" CommandParameter="{Binding}" />
+ </StackPanel>
+ <TextBlock Grid.Row="1" Grid.Column="0" Style="{StaticResource FormLabel}" Text="{DynamicResource LabelNodeIn}" />
+ <controls:NumberBox Grid.Row="1" Grid.Column="1" Margin="0,0,2,2" Text="{Binding InX}" ToolTip="{DynamicResource Hint.FiberNode.InX}" />
+ <controls:NumberBox Grid.Row="1" Grid.Column="2" Margin="2,0,0,2" Text="{Binding InY}" ToolTip="{DynamicResource Hint.FiberNode.InY}" />
+ <TextBlock Grid.Row="2" Grid.Column="0" Style="{StaticResource FormLabel}" Text="{DynamicResource LabelNodeOut}" />
+ <controls:NumberBox Grid.Row="2" Grid.Column="1" Margin="0,0,2,0" Text="{Binding OutX}" ToolTip="{DynamicResource Hint.FiberNode.OutX}" />
+ <controls:NumberBox Grid.Row="2" Grid.Column="2" Margin="2,0,0,0" Text="{Binding OutY}" ToolTip="{DynamicResource Hint.FiberNode.OutY}" />
+ </Grid>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
+ <Button Padding="8,2" Margin="0,2,6,0" Content="{DynamicResource ButtonAddNode}" ToolTip="{DynamicResource TipAddNode}"
+ Command="{x:Static commands:PartCommands.AddPoint}" AutomationProperties.AutomationId="PartAddNode" />
+ </StackPanel>
+ </StackPanel>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/FiberPathView.xaml.cs b/WaveDudeNext.WPF/Views/FiberPathView.xaml.cs
new file mode 100644
index 0000000..52339d5
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/FiberPathView.xaml.cs
@@ -0,0 +1,99 @@
+// 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
+// Jeroen Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// 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.Collections.ObjectModel;
+using System.Windows.Controls;
+using System.Windows.Input;
+using WaveDudeNext.Model;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>
+/// Editor of the node list of a <see cref="FiberPart"/> path (2026-10-22): one block per node with the node, its
+/// in- and out-handle offsets and the Smooth flag; add and remove. The data context is the part; the list is its
+/// <see cref="FiberPart.Nodes"/>. Every control is in the Tab cycle (the keyboard-first rule).
+/// </summary>
+public partial class FiberPathView : UserControl
+{
+ /// <summary>How far a new node is put beyond the last one, in canvas pixels; its handles get a third of that.</summary>
+ private const int NewNodeStep = 60;
+
+ public FiberPathView()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>The edited list: the fibre's nodes, or null for another data context.</summary>
+ private ObservableCollection<FiberNode>? Nodes => (DataContext as FiberPart)?.Nodes;
+
+ private void CanAddNode(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = Nodes != null;
+
+ /// <summary>
+ /// Appends a node a step beyond the last one in the direction the path leaves it (against its in-handle, else
+ /// from the node before, else to the right), with handles a third of the step long on both sides of the new
+ /// segment, so it can be taken hold of; the last node's out-handle is only set when it had none. The first node
+ /// goes to the centre.
+ /// </summary>
+ private void OnAddNode(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (Nodes is not { } nodes)
+ {
+ return;
+ }
+ FiberNode? last = nodes.LastOrDefault();
+ if (last == null)
+ {
+ nodes.Add(new FiberNode());
+ return;
+ }
+ (double dx, double dy) = Direction(-last.InX, -last.InY)
+ ?? (nodes.Count > 1 ? Direction(last.X - nodes[^2].X, last.Y - nodes[^2].Y) : null)
+ ?? (1.0, 0.0);
+ int third = NewNodeStep / 3;
+ var node = new FiberNode
+ {
+ X = last.X + (int)Math.Round(dx * NewNodeStep),
+ Y = last.Y + (int)Math.Round(dy * NewNodeStep),
+ InX = -(int)Math.Round(dx * third),
+ InY = -(int)Math.Round(dy * third),
+ };
+ if (last.OutX == 0 && last.OutY == 0)
+ {
+ last.OutX = (int)Math.Round(dx * third);
+ last.OutY = (int)Math.Round(dy * third);
+ }
+ nodes.Add(node);
+ }
+
+ private void CanRemoveNode(object sender, CanExecuteRoutedEventArgs e) =>
+ e.CanExecute = e.Parameter is FiberNode node && Nodes?.Contains(node) == true;
+
+ private void OnRemoveNode(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Parameter is FiberNode node)
+ {
+ Nodes?.Remove(node);
+ }
+ }
+
+ /// <summary>The direction (x, y) as a unit vector, or null for a zero vector.</summary>
+ private static (double X, double Y)? Direction(double x, double y)
+ {
+ double length = Math.Sqrt(x * x + y * y);
+ return length > 0.0 ? (x / length, y / length) : null;
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/PartPointsView.xaml b/WaveDudeNext.WPF/Views/PartPointsView.xaml
index b5bd7e7..e24a3d0 100644
--- a/WaveDudeNext.WPF/Views/PartPointsView.xaml
+++ b/WaveDudeNext.WPF/Views/PartPointsView.xaml
@@ -25,45 +25,12 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
xmlns:meta="clr-namespace:WaveDudeNext.WPF.Markup"
xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
- <UserControl.Resources>
- <StreamGeometry x:Key="MinusGeometry">M0,4 L8,4</StreamGeometry>
- <!-- the row's remove button; in the Tab cycle, since no key removes a point otherwise -->
- <Style x:Key="RemovePointButton" TargetType="{x:Type Button}">
- <Setter Property="Width" Value="18" />
- <Setter Property="Height" Value="18" />
- <Setter Property="Margin" Value="4,0,0,0" />
- <Setter Property="Foreground" Value="{DynamicResource WindowForeground}" />
- <Setter Property="FocusVisualStyle" Value="{x:Null}" />
- <Setter Property="Template">
- <Setter.Value>
- <ControlTemplate TargetType="{x:Type Button}">
- <Border x:Name="Bd" Background="Transparent" BorderBrush="Transparent" BorderThickness="1" SnapsToDevicePixels="True">
- <Path Data="{StaticResource MinusGeometry}" Stroke="{TemplateBinding Foreground}" StrokeThickness="1.2"
- HorizontalAlignment="Center" VerticalAlignment="Center" />
- </Border>
- <ControlTemplate.Triggers>
- <Trigger Property="IsMouseOver" Value="True">
- <Setter TargetName="Bd" Property="Background" Value="{DynamicResource ButtonHover}" />
- </Trigger>
- <Trigger Property="IsKeyboardFocused" Value="True">
- <Setter TargetName="Bd" Property="BorderBrush" Value="{DynamicResource Accent}" />
- </Trigger>
- <Trigger Property="IsEnabled" Value="False">
- <Setter Property="Opacity" Value="0.4" />
- </Trigger>
- </ControlTemplate.Triggers>
- </ControlTemplate>
- </Setter.Value>
- </Setter>
- </Style>
- </UserControl.Resources>
-
<UserControl.CommandBindings>
<CommandBinding Command="{x:Static commands:PartCommands.AddPoint}" CanExecute="CanAddPoint" Executed="OnAddPoint" />
<CommandBinding Command="{x:Static commands:PartCommands.RemovePoint}" CanExecute="CanRemovePoint" Executed="OnRemovePoint" />
</UserControl.CommandBindings>
- <!-- the point list of a polygon outline or a fibre path (the data context is the part): one row per point with X
+ <!-- the point list of a polygon outline (the data context is the part): one row per point with X
and Y relative to the centre, before rotation, a remove button, and an add button below -->
<StackPanel>
<Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionPoints}" />
@@ -82,8 +49,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<Button DockPanel.Dock="Right" Style="{StaticResource RemovePointButton}" ToolTip="{DynamicResource TipRemovePoint}" AutomationProperties.Name="{DynamicResource TipRemovePoint}"
Command="{x:Static commands:PartCommands.RemovePoint}" CommandParameter="{Binding}" />
<UniformGrid Columns="2">
- <controls:NumberBox Margin="0,0,2,0" Text="{Binding X}" ToolTip="{meta:Hint model:PartPoint.X}" />
- <controls:NumberBox Margin="2,0,0,0" Text="{Binding Y}" ToolTip="{meta:Hint model:PartPoint.Y}" />
+ <controls:NumberBox Margin="0,0,2,0" Text="{Binding X}" ToolTip="{DynamicResource Hint.PartPoint.X}" />
+ <controls:NumberBox Margin="2,0,0,0" Text="{Binding Y}" ToolTip="{DynamicResource Hint.PartPoint.Y}" />
</UniformGrid>
</DockPanel>
</DataTemplate>
diff --git a/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs b/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs
index 2bb9a2b..cb9ba86 100644
--- a/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs
+++ b/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs
@@ -24,9 +24,9 @@ using WaveDudeNext.Model;
namespace WaveDudeNext.WPF.Views;
/// <summary>
-/// Editor of the point list of an <see cref="OutlinePart"/> or a <see cref="FiberPart"/> (its path): one row
-/// per point, add and remove. The data context is the part; the list is its <c>Points</c>. Every control is in the Tab
-/// cycle (the keyboard-first rule).
+/// Editor of the point list of an <see cref="OutlinePart"/>: one row per point, add and remove (a fibre's path has
+/// its own editor, <see cref="FiberPathView"/>). The data context is the part; the list is its <c>Points</c>. Every
+/// control is in the Tab cycle (the keyboard-first rule).
/// </summary>
public partial class PartPointsView : UserControl
{
@@ -49,13 +49,8 @@ public partial class PartPointsView : UserControl
set => SetValue(HintTextProperty, value);
}
- /// <summary>The edited list: the outline's or fibre's points, or null for another data context.</summary>
- private ObservableCollection<PartPoint>? Points => DataContext switch
- {
- OutlinePart outline => outline.Points,
- FiberPart fiber => fiber.Points,
- _ => null,
- };
+ /// <summary>The edited list: the outline's points, or null for another data context.</summary>
+ private ObservableCollection<PartPoint>? Points => (DataContext as OutlinePart)?.Points;
private void CanAddPoint(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = Points != null;
diff --git a/WaveDudeNext/Model/OpticalPart.cs b/WaveDudeNext/Model/OpticalPart.cs
index c3b2b5a..414531d 100644
--- a/WaveDudeNext/Model/OpticalPart.cs
+++ b/WaveDudeNext/Model/OpticalPart.cs
@@ -16,6 +16,7 @@
// <https://www.gnu.org/licenses/>.
using System.Collections.ObjectModel;
+using System.Collections.Specialized;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Xml.Serialization;
@@ -224,7 +225,7 @@ public abstract class OpticalPart : ObservableObject, IMovable
new(points.Select(p => new PartPoint { X = p.X, Y = p.Y }));
}
-/// <summary>One vertex of an <see cref="OutlinePart"/> or of a <see cref="FiberPart"/> path, in canvas pixels relative to the part's centre, before rotation.</summary>
+/// <summary>One vertex of an <see cref="OutlinePart"/>, in canvas pixels relative to the part's centre, before rotation.</summary>
public sealed class PartPoint : ObservableObject
{
private int _x;
@@ -1145,10 +1146,186 @@ public sealed class OutlinePart : ShapePart
}
}
+/// <summary>How the two ends of a <see cref="FiberPart"/> are cut (2026-10-22, the user's request; the ends were round from the distance test before).</summary>
+public enum FiberEnds
+{
+ /// <summary>Cut straight across the path's direction at the endpoint, like a cleaved fibre; the coating band follows the end face.</summary>
+ Flat,
+ /// <summary>Rounded with the fibre's outer radius.</summary>
+ Round,
+}
+
+/// <summary>
+/// One node of a <see cref="FiberPart"/> path (2026-10-22, the user's request: a Bézier path with handles instead of a
+/// polyline): the point the path passes through, in canvas pixels relative to the part's centre before rotation, and
+/// the two handles of the cubic segments meeting there, as offsets from the node. The in-handle shapes the segment
+/// arriving from the previous node, the out-handle the one leaving to the next; a handle of zero length makes its
+/// segment straight at this end, two zero handles a sharp corner. While <see cref="Smooth"/> is set, the handles are
+/// kept opposite each other through the node: switching it on lines them up at once (<see cref="FiberPart.AlignNode"/>),
+/// and afterwards a handle dragged (<see cref="SetHandle"/>) or typed (the part listens to its nodes) turns the other
+/// with it, keeping its length. A node added to a part, or loaded from a file, is taken as it is.
+/// </summary>
+public sealed class FiberNode : ObservableObject
+{
+ private int _x;
+ private int _y;
+ private int _inX;
+ private int _inY;
+ private int _outX;
+ private int _outY;
+ private bool _smooth = true;
+
+ /// <summary>X relative to the part's centre in canvas pixels, before rotation.</summary>
+ [XmlAttribute]
+ [Category("Node")]
+ [Description("X relative to the part's centre in canvas pixels, before rotation.")]
+ public int X
+ {
+ get => _x;
+ set => SetProperty(ref _x, value);
+ }
+
+ /// <summary>Y relative to the part's centre in canvas pixels, before rotation.</summary>
+ [XmlAttribute]
+ [Category("Node")]
+ [Description("Y relative to the part's centre in canvas pixels, before rotation.")]
+ public int Y
+ {
+ get => _y;
+ set => SetProperty(ref _y, value);
+ }
+
+ /// <summary>X of the in-handle relative to the node in canvas pixels, before rotation; it shapes the segment arriving from the previous node.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("In handle")]
+ [DisplayName("In X")]
+ [Description("X of the in-handle relative to the node, in canvas pixels before rotation. It shapes the segment arriving from the previous node; zero makes that segment straight at this end.")]
+ public int InX
+ {
+ get => _inX;
+ set => SetProperty(ref _inX, value);
+ }
+
+ /// <summary>Y of the in-handle relative to the node in canvas pixels, before rotation.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("In handle")]
+ [DisplayName("In Y")]
+ [Description("Y of the in-handle relative to the node, in canvas pixels before rotation.")]
+ public int InY
+ {
+ get => _inY;
+ set => SetProperty(ref _inY, value);
+ }
+
+ /// <summary>X of the out-handle relative to the node in canvas pixels, before rotation; it shapes the segment leaving to the next node.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Out handle")]
+ [DisplayName("Out X")]
+ [Description("X of the out-handle relative to the node, in canvas pixels before rotation. It shapes the segment leaving to the next node; zero makes that segment straight at this end.")]
+ public int OutX
+ {
+ get => _outX;
+ set => SetProperty(ref _outX, value);
+ }
+
+ /// <summary>Y of the out-handle relative to the node in canvas pixels, before rotation.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Out handle")]
+ [DisplayName("Out Y")]
+ [Description("Y of the out-handle relative to the node, in canvas pixels before rotation.")]
+ public int OutY
+ {
+ get => _outY;
+ set => SetProperty(ref _outY, value);
+ }
+
+ /// <summary>Whether the editors keep the two handles opposite each other through the node, so the path runs smoothly through it; off, the node may be a corner.</summary>
+ [XmlAttribute]
+ [DefaultValue(true)]
+ [Category("Node")]
+ [Description("Keep the two handles opposite each other through the node, so the path runs smoothly through it. Switching it on lines them up at once; afterwards moving or typing one handle turns the other with it, keeping its length. Off, the node may be a corner.")]
+ public bool Smooth
+ {
+ get => _smooth;
+ set => SetProperty(ref _smooth, value);
+ }
+
+ /// <summary>Set while <see cref="SetHandle"/> or <see cref="FiberPart.AlignNode"/> writes the handles, so the part's listener leaves the mirrored handle alone.</summary>
+ internal bool Mirroring { get; set; }
+
+ /// <summary>The in-handle as a point of the part frame: the node plus its offset.</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public (double X, double Y) In => (X + InX, Y + InY);
+
+ /// <summary>The out-handle as a point of the part frame: the node plus its offset.</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public (double X, double Y) Out => (X + OutX, Y + OutY);
+
+ /// <summary>
+ /// Sets the out-handle (or the in-handle) to the offset (<paramref name="dx"/>, <paramref name="dy"/>); with
+ /// <see cref="Smooth"/> the other handle is turned to the opposite direction, keeping <paramref name="otherLength"/>
+ /// (its own length when null; an editor passes the length from before a drag, so the rounding of each step does
+ /// not creep into it). A zero handle leaves the other alone.
+ /// </summary>
+ /// <param name="outward">True for the out-handle, false for the in-handle.</param>
+ /// <param name="dx">The handle's X offset from the node in canvas pixels.</param>
+ /// <param name="dy">The handle's Y offset from the node in canvas pixels.</param>
+ /// <param name="otherLength">The length the other handle keeps, or null for its current length.</param>
+ public void SetHandle(bool outward, int dx, int dy, double? otherLength = null)
+ {
+ Mirroring = true;
+ try
+ {
+ if (outward)
+ {
+ OutX = dx;
+ OutY = dy;
+ }
+ else
+ {
+ InX = dx;
+ InY = dy;
+ }
+ double length = Math.Sqrt((double)dx * dx + (double)dy * dy);
+ if (!Smooth || length == 0.0)
+ {
+ return;
+ }
+ (int otherX, int otherY) = outward ? (InX, InY) : (OutX, OutY);
+ double keep = otherLength ?? Math.Sqrt((double)otherX * otherX + (double)otherY * otherY);
+ int mirrorX = (int)Math.Round(-dx / length * keep);
+ int mirrorY = (int)Math.Round(-dy / length * keep);
+ if (outward)
+ {
+ InX = mirrorX;
+ InY = mirrorY;
+ }
+ else
+ {
+ OutX = mirrorX;
+ OutY = mirrorY;
+ }
+ }
+ finally
+ {
+ Mirroring = false;
+ }
+ }
+
+ /// <summary>The coordinates, for display.</summary>
+ public override string ToString() => $"({X}, {Y})";
+}
+
/// <summary>
-/// A fibre: a core of <see cref="CoreDiameter"/> along the polyline <see cref="Points"/>, wrapped in a cladding of
-/// <see cref="CladdingThickness"/>. The ends are round (the distance to the path decides). The angle rotates the
-/// whole path about the centre.
+/// A fibre: a core of <see cref="CoreDiameter"/> along a path of cubic Bézier segments through <see cref="Nodes"/>,
+/// wrapped in a cladding of <see cref="CladdingThickness"/>; the ends cut <see cref="Ends"/>. The path is flattened
+/// into chords (<see cref="Flatten"/>) for painting and drawing. The angle rotates the whole path about the centre.
/// </summary>
public sealed class FiberPart : OpticalPart
{
@@ -1160,15 +1337,27 @@ public sealed class FiberPart : OpticalPart
public const double DefaultCladdingIndex = 1.45;
/// <summary>Default <see cref="CladdingThickness"/> in pixels.</summary>
public const int DefaultCladdingThickness = 10;
+ /// <summary>Default <see cref="Ends"/>.</summary>
+ public const FiberEnds DefaultEnds = FiberEnds.Flat;
/// <summary>Half the default path length in pixels: the path runs from (-100, 0) to (100, 0).</summary>
public const int DefaultHalfLength = 100;
+ /// <summary>How far a flattened chord may leave the curve, in canvas pixels: far below the painter's quarter-pixel samples.</summary>
+ public const double FlattenTolerance = 0.05;
private double _coreIndex = DefaultCoreIndex;
private int _coreDiameter = DefaultCoreDiameter;
private double _claddingIndex = DefaultCladdingIndex;
private int _claddingThickness = DefaultCladdingThickness;
private int _coating;
- private ObservableCollection<PartPoint> _points = [];
+ private FiberEnds _ends = DefaultEnds;
+ private ObservableCollection<FiberNode> _nodes = [];
+ private HashSet<FiberNode> _watched = [];
+
+ /// <summary>A fibre with an empty path: a file's nodes or <see cref="DefaultPath"/> fill it.</summary>
+ public FiberPart()
+ {
+ Watch(_nodes);
+ }
/// <inheritdoc/>
public override PartKind Kind => PartKind.Fiber;
@@ -1238,15 +1427,36 @@ public sealed class FiberPart : OpticalPart
set => SetProperty(ref _coating, value);
}
- /// <summary>The path's vertices relative to the centre, before rotation; fewer than two points paint nothing.</summary>
- [XmlElement("Point")]
+ /// <summary>How the two ends are cut: straight across the path, or rounded.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultEnds)]
[Category("Shape")]
- [DisplayName("Points")]
- [Description("The path's vertices relative to the centre, before rotation. Fewer than two points paint nothing.")]
- public ObservableCollection<PartPoint> Points
+ [DisplayName("Ends")]
+ [Description("How the two ends are cut: flat, straight across the path like a cleaved fibre, or rounded with the outer radius. The AR coating follows a flat end face.")]
+ public FiberEnds Ends
{
- get => _points;
- set => SetProperty(ref _points, value);
+ get => _ends;
+ set => SetProperty(ref _ends, value);
+ }
+
+ /// <summary>The path's nodes relative to the centre, before rotation, each with the handles of the segments meeting there; fewer than two nodes paint nothing.</summary>
+ [XmlElement("Node")]
+ [Category("Shape")]
+ [DisplayName("Nodes")]
+ [Description("The path's nodes relative to the centre, before rotation, each with the handles of the cubic segments meeting there. Fewer than two nodes paint nothing.")]
+ public ObservableCollection<FiberNode> Nodes
+ {
+ get => _nodes;
+ set
+ {
+ if (ReferenceEquals(_nodes, value))
+ {
+ return;
+ }
+ Unwatch(_nodes);
+ SetProperty(ref _nodes, value);
+ Watch(_nodes);
+ }
}
/// <summary>Outer radius in pixels: half the core diameter plus the cladding.</summary>
@@ -1254,22 +1464,252 @@ public sealed class FiberPart : OpticalPart
[Browsable(false)]
public double OuterRadius => CoreDiameter / 2.0 + CladdingThickness;
- /// <inheritdoc/>
- public override double AxisReach => (Points.Count > 0 ? Points.Max(p => Math.Abs(p.X)) : 0) + OuterRadius;
+ /// <summary>The farthest any node or handle lies along x' (the curve stays within its handles' hull), plus the outer radius.</summary>
+ public override double AxisReach => (Nodes.Count > 0 ? Nodes.Max(n => Math.Max(Math.Abs(n.X), Math.Max(Math.Abs(n.In.X), Math.Abs(n.Out.X)))) : 0) + OuterRadius;
- /// <summary>The path itself; the core and cladding bands show through the scene outline.</summary>
- public override (double X, double Y)[] Outline() => Points.Select(p => ((double)p.X, (double)p.Y)).ToArray();
+ /// <summary>The path flattened into chords; the core and cladding bands show through the scene outline.</summary>
+ public override (double X, double Y)[] Outline() => Flatten(Nodes);
/// <inheritdoc/>
public override bool OutlineClosed => false;
/// <summary>
- /// The default straight path, from (-100, 0) to (100, 0). Given to a new fibre by <see cref="Project.AddPart"/>, not by
- /// the constructor: <see cref="XmlSerializer"/> appends a file's points to the list it finds, so the constructor's list
- /// must be empty.
+ /// The default straight path, from (-100, 0) to (100, 0), the handles a third of the way along it so they can be
+ /// taken hold of. Given to a new fibre by <see cref="Project.AddPart"/>, not by the constructor:
+ /// <see cref="XmlSerializer"/> appends a file's nodes to the list it finds, so the constructor's list must be empty.
+ /// </summary>
+ public static ObservableCollection<FiberNode> DefaultPath()
+ {
+ int third = (int)Math.Round(2.0 * DefaultHalfLength / 3.0);
+ return
+ [
+ new FiberNode { X = -DefaultHalfLength, Y = 0, OutX = third },
+ new FiberNode { X = DefaultHalfLength, Y = 0, InX = -third },
+ ];
+ }
+
+ /// <summary>
+ /// The path through <paramref name="nodes"/> as chords, in the part frame: the cubic segment between two nodes
+ /// (the node, its out-handle, the next node's in-handle, the next node) is cut into as many equal steps of t as
+ /// keep every chord within <see cref="FlattenTolerance"/> of the curve, a straight segment staying one chord;
+ /// consecutive equal points are dropped, so no chord has zero length. Fewer than two nodes give an empty path.
+ /// Any thread; reads the nodes once.
+ /// </summary>
+ public static (double X, double Y)[] Flatten(IList<FiberNode> nodes)
+ {
+ if (nodes.Count < 2)
+ {
+ return [];
+ }
+ var path = new List<(double X, double Y)>(nodes.Count * 8) { (nodes[0].X, nodes[0].Y) };
+ for (int i = 1; i < nodes.Count; i++)
+ {
+ FiberNode a = nodes[i - 1];
+ FiberNode b = nodes[i];
+ double x0 = a.X, y0 = a.Y, x3 = b.X, y3 = b.Y;
+ (double x1, double y1) = a.Out;
+ (double x2, double y2) = b.In;
+ // a segment whose handles lie on the chord between its nodes is straight and stays one chord; otherwise the
+ // second derivative of a cubic is bounded by 6 × the larger second difference of its control points, and n
+ // equal steps leave a chord error of at most that bound / (8 n²)
+ int steps = 1;
+ if (DistanceToSegment(x1, y1, x0, y0, x3, y3) > FlattenTolerance || DistanceToSegment(x2, y2, x0, y0, x3, y3) > FlattenTolerance)
+ {
+ double second = Math.Max(Math.Sqrt(Square(x0 - 2 * x1 + x2) + Square(y0 - 2 * y1 + y2)), Math.Sqrt(Square(x1 - 2 * x2 + x3) + Square(y1 - 2 * y2 + y3)));
+ steps = Math.Clamp((int)Math.Ceiling(Math.Sqrt(0.75 * second / FlattenTolerance)), 1, 512);
+ }
+ for (int k = 1; k <= steps; k++)
+ {
+ double t = (double)k / steps;
+ double u = 1.0 - t;
+ double w0 = u * u * u, w1 = 3 * u * u * t, w2 = 3 * u * t * t, w3 = t * t * t;
+ (double X, double Y) point = (w0 * x0 + w1 * x1 + w2 * x2 + w3 * x3, w0 * y0 + w1 * y1 + w2 * y2 + w3 * y3);
+ if (point != path[^1])
+ {
+ path.Add(point);
+ }
+ }
+ }
+ return path.Count < 2 ? [] : [.. path];
+ }
+
+ private static double Square(double v) => v * v;
+
+ /// <summary>
+ /// Lines up the handles of <paramref name="node"/> (2026-10-22, the user's choice for what Smooth means): the in-handle
+ /// opposite the out-handle, both keeping their lengths; an in-handle of zero length (with a node before) or an
+ /// out-handle of zero (with a node after) takes the other's length; a node with no handles at all gets them from its
+ /// neighbours, along the line between them, a third of the way to each. A node not in the list, or alone, is left as it is.
+ /// </summary>
+ public void AlignNode(FiberNode node)
+ {
+ int i = Nodes.IndexOf(node);
+ bool hasPrevious = i > 0;
+ bool hasNext = i >= 0 && i < Nodes.Count - 1;
+ double outLength = Length(node.OutX, node.OutY);
+ double inLength = Length(node.InX, node.InY);
+ node.Mirroring = true;
+ try
+ {
+ if (outLength == 0.0 && inLength == 0.0)
+ {
+ if (!hasPrevious && !hasNext)
+ {
+ return;
+ }
+ (double fromX, double fromY) = hasPrevious ? (Nodes[i - 1].X, Nodes[i - 1].Y) : (node.X, node.Y);
+ (double toX, double toY) = hasNext ? (Nodes[i + 1].X, Nodes[i + 1].Y) : (node.X, node.Y);
+ double span = Length(toX - fromX, toY - fromY);
+ if (span == 0.0)
+ {
+ return;
+ }
+ double tx = (toX - fromX) / span;
+ double ty = (toY - fromY) / span;
+ if (hasPrevious)
+ {
+ double third = Length(node.X - fromX, node.Y - fromY) / 3.0;
+ node.InX = (int)Math.Round(-tx * third);
+ node.InY = (int)Math.Round(-ty * third);
+ }
+ if (hasNext)
+ {
+ double third = Length(toX - node.X, toY - node.Y) / 3.0;
+ node.OutX = (int)Math.Round(tx * third);
+ node.OutY = (int)Math.Round(ty * third);
+ }
+ }
+ else if (outLength > 0.0)
+ {
+ if (inLength == 0.0 && hasPrevious)
+ {
+ inLength = outLength;
+ }
+ node.InX = (int)Math.Round(-node.OutX / outLength * inLength);
+ node.InY = (int)Math.Round(-node.OutY / outLength * inLength);
+ }
+ else
+ {
+ if (hasNext)
+ {
+ outLength = inLength;
+ }
+ node.OutX = (int)Math.Round(-node.InX / inLength * outLength);
+ node.OutY = (int)Math.Round(-node.InY / inLength * outLength);
+ }
+ }
+ finally
+ {
+ node.Mirroring = false;
+ }
+ }
+
+ private static double Length(double x, double y) => Math.Sqrt(x * x + y * y);
+
+ /// <summary>Listens to the list and its nodes for the smooth rule (<see cref="OnNodeChanged"/>).</summary>
+ private void Watch(ObservableCollection<FiberNode>? nodes)
+ {
+ if (nodes == null)
+ {
+ return;
+ }
+ nodes.CollectionChanged += OnNodesChanged;
+ foreach (FiberNode node in nodes)
+ {
+ WatchNode(node);
+ }
+ }
+
+ private void Unwatch(ObservableCollection<FiberNode>? nodes)
+ {
+ if (nodes != null)
+ {
+ nodes.CollectionChanged -= OnNodesChanged;
+ }
+ foreach (FiberNode node in _watched)
+ {
+ node.PropertyChanged -= OnNodeChanged;
+ }
+ _watched.Clear();
+ }
+
+ private void WatchNode(FiberNode node)
+ {
+ if (_watched.Add(node))
+ {
+ node.PropertyChanged += OnNodeChanged;
+ }
+ }
+
+ /// <summary>A node added is listened to from then on (as it is: no alignment on arrival, which keeps a file's nodes as written); a node removed is let go.</summary>
+ private void OnNodesChanged(object? sender, NotifyCollectionChangedEventArgs e)
+ {
+ if (e.Action == NotifyCollectionChangedAction.Reset)
+ {
+ foreach (FiberNode node in _watched)
+ {
+ node.PropertyChanged -= OnNodeChanged;
+ }
+ _watched.Clear();
+ foreach (FiberNode node in _nodes)
+ {
+ WatchNode(node);
+ }
+ return;
+ }
+ if (e.OldItems != null)
+ {
+ foreach (FiberNode node in e.OldItems)
+ {
+ if (_watched.Remove(node))
+ {
+ node.PropertyChanged -= OnNodeChanged;
+ }
+ }
+ }
+ if (e.NewItems != null)
+ {
+ foreach (FiberNode node in e.NewItems)
+ {
+ WatchNode(node);
+ }
+ }
+ }
+
+ /// <summary>
+ /// The smooth rule: a node switched to smooth gets its handles lined up at once (<see cref="AlignNode"/>), and a handle
+ /// of a smooth node set by itself (a typed value) turns the other handle opposite, keeping its length, as a drag does
+ /// through <see cref="FiberNode.SetHandle"/>, which flags the node while it writes so its own mirror is left alone.
/// </summary>
- public static ObservableCollection<PartPoint> DefaultPath() =>
- [new PartPoint { X = -DefaultHalfLength, Y = 0 }, new PartPoint { X = DefaultHalfLength, Y = 0 }];
+ private void OnNodeChanged(object? sender, PropertyChangedEventArgs e)
+ {
+ if (sender is not FiberNode node || node.Mirroring || !node.Smooth)
+ {
+ return;
+ }
+ switch (e.PropertyName)
+ {
+ case nameof(FiberNode.Smooth):
+ AlignNode(node);
+ break;
+ case nameof(FiberNode.InX) or nameof(FiberNode.InY):
+ node.SetHandle(false, node.InX, node.InY);
+ break;
+ case nameof(FiberNode.OutX) or nameof(FiberNode.OutY):
+ node.SetHandle(true, node.OutX, node.OutY);
+ break;
+ }
+ }
+
+ /// <summary>Distance from (x, y) to the segment a–b.</summary>
+ private static double DistanceToSegment(double x, double y, double ax, double ay, double bx, double by)
+ {
+ double dx = bx - ax;
+ double dy = by - ay;
+ double length2 = dx * dx + dy * dy;
+ double t = length2 > 0.0 ? Math.Clamp(((x - ax) * dx + (y - ay) * dy) / length2, 0.0, 1.0) : 0.0;
+ return Math.Sqrt(Square(ax + t * dx - x) + Square(ay + t * dy - y));
+ }
/// <inheritdoc/>
public override void Normalize()
@@ -1280,14 +1720,21 @@ public sealed class FiberPart : OpticalPart
CoreDiameter = Math.Max(2, CoreDiameter);
CladdingThickness = Math.Max(0, CladdingThickness);
Coating = Math.Clamp(Coating, 0, MaxCoating);
- Points ??= [];
+ if (!Enum.IsDefined(Ends))
+ {
+ Ends = DefaultEnds;
+ }
+ Nodes ??= [];
}
/// <inheritdoc/>
public override OpticalPart Clone()
{
var copy = ShallowClone<FiberPart>();
- copy.Points = ClonePoints(Points);
+ // the memberwise copy shares the original's set of watched nodes and listens to nothing yet: a fresh set, then
+ // the new list through the setter, which subscribes
+ copy._watched = [];
+ copy.Nodes = new ObservableCollection<FiberNode>(Nodes.Select(n => new FiberNode { X = n.X, Y = n.Y, InX = n.InX, InY = n.InY, OutX = n.OutX, OutY = n.OutY, Smooth = n.Smooth }));
return copy;
}
}
diff --git a/WaveDudeNext/Model/Project.cs b/WaveDudeNext/Model/Project.cs
index 12251c0..60543a5 100644
--- a/WaveDudeNext/Model/Project.cs
+++ b/WaveDudeNext/Model/Project.cs
@@ -349,7 +349,7 @@ public sealed class Project : ObservableObject
PartKind.Ellipse => new EllipsePart(),
PartKind.Triangle => new TrianglePart(),
PartKind.Outline => new OutlinePart(),
- PartKind.Fiber => new FiberPart { Points = FiberPart.DefaultPath() },
+ PartKind.Fiber => new FiberPart { Nodes = FiberPart.DefaultPath() },
PartKind.BraggReflector => new BraggReflectorPart(),
PartKind.GrinLens => new GrinLensPart(),
_ => throw new ArgumentOutOfRangeException(nameof(kind)),
diff --git a/WaveDudeNext/Model/ProjectWatcher.cs b/WaveDudeNext/Model/ProjectWatcher.cs
index 399eefd..bd0af66 100644
--- a/WaveDudeNext/Model/ProjectWatcher.cs
+++ b/WaveDudeNext/Model/ProjectWatcher.cs
@@ -35,7 +35,7 @@ public sealed record ProjectChange(object Item, string? Property)
public bool AffectsSimulation => Item switch
{
Scene when Property == nameof(Scene.ImagePath) => false,
- Scene or Simulation or Source or SourceArray or OpticalPart or PartPoint => true,
+ Scene or Simulation or Source or SourceArray or OpticalPart or PartPoint or FiberNode => true,
Project => Property is nameof(Project.Seed) or nameof(Project.Scene) or nameof(Project.Simulation) or nameof(Project.Sources) or nameof(Project.Parts),
ObservableCollection<ColorScheme> or ObservableCollection<Probe> => false,
INotifyCollectionChanged => true,
@@ -99,7 +99,7 @@ public sealed class ProjectWatcher : IDisposable
private void OnItemPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
if (sender is Source && e.PropertyName == nameof(Source.Array) || sender is Display && e.PropertyName is nameof(Display.Field) or nameof(Display.Intensity) or nameof(Display.Video)
- || sender is OutlinePart or FiberPart && e.PropertyName == "Points")
+ || sender is OutlinePart && e.PropertyName == nameof(OutlinePart.Points) || sender is FiberPart && e.PropertyName == nameof(FiberPart.Nodes))
{
Resubscribe();
}
@@ -139,14 +139,22 @@ public sealed class ProjectWatcher : IDisposable
foreach (OpticalPart part in _project.Parts)
{
Subscribe(part);
- ObservableCollection<PartPoint>? points = part switch { OutlinePart outline => outline.Points, FiberPart fiber => fiber.Points, _ => null };
- if (points != null)
+ switch (part)
{
- SubscribeCollection(points);
- foreach (PartPoint point in points)
- {
- Subscribe(point);
- }
+ case OutlinePart outline:
+ SubscribeCollection(outline.Points);
+ foreach (PartPoint point in outline.Points)
+ {
+ Subscribe(point);
+ }
+ break;
+ case FiberPart fiber:
+ SubscribeCollection(fiber.Nodes);
+ foreach (FiberNode node in fiber.Nodes)
+ {
+ Subscribe(node);
+ }
+ break;
}
}
foreach (Probe probe in _project.Probes)
diff --git a/WaveDudeNext/Parts/PartShape.cs b/WaveDudeNext/Parts/PartShape.cs
index 6bf0f45..44d0784 100644
--- a/WaveDudeNext/Parts/PartShape.cs
+++ b/WaveDudeNext/Parts/PartShape.cs
@@ -55,7 +55,7 @@ public abstract class PartShape
{
LensPart lens => new LensShape(lens),
ShapePart shape => shape.Vertices().Length < 3 ? null : new VertexShape(shape),
- FiberPart fiber => fiber.Points.Count < 2 ? null : new FiberShape(fiber),
+ FiberPart fiber => FiberPart.Flatten(fiber.Nodes) is { Length: >= 2 } path ? new FiberShape(fiber, path) : null,
BraggReflectorPart bragg => new BraggShape(bragg),
GrinLensPart grin => new GrinShape(grin),
_ => null,
@@ -293,42 +293,202 @@ public abstract class PartShape
protected override double BodyIndex(double x, double y) => _index;
}
+ /// <summary>
+ /// A fibre: the tube of the outer radius around the path's chords (<see cref="FiberPart.Flatten"/>), the core the
+ /// inner tube, the ends flat or round. Flat (2026-10-22, the user's request): the path is cut by the plane across
+ /// the curve's own direction at each endpoint (the handle's, which a bend tilts the first chord away from by a
+ /// degree or two), so a point before the start or beyond the end lies outside however close to the line, and the
+ /// depth inside counts the end face too, which the coating band then follows. The depth is the largest over the
+ /// chords: exact inside, and outside a point's nearest chord gives the distance (a corner of a flat end makes it
+ /// an under-estimate, which keeps the painter's single-sample shortcut safe). The chords are bucketed on a grid
+ /// of <see cref="CellSize"/> cells over the part frame, each cell listing the chords whose tube can reach it, so
+ /// a sample visits a handful of chords instead of all (2026-10-22: an S-bend across a Full HD canvas, 156 chords,
+ /// took 1.3 s a paint without this); a point in a cell no chord reaches is at least <see cref="Margin"/> outside.
+ /// </summary>
private sealed class FiberShape : PartShape
{
+ /// <summary>Side of a grid cell in pixels of the part frame.</summary>
+ private const int CellSize = 32;
+ /// <summary>How far beyond the tube a chord is still listed for a cell, in pixels: more than the painter's sample reach, so an empty cell may report this depth outside.</summary>
+ private const double Margin = 2.0;
+
private readonly (double X, double Y)[] _path;
+ private readonly bool _flat;
+ private readonly (double X, double Y) _startTangent;
+ private readonly (double X, double Y) _endTangent;
private readonly double _coreRadius;
private readonly double _outerRadius;
private readonly double _coreIndex;
private readonly double _claddingIndex;
private readonly double _extent;
-
- public FiberShape(FiberPart fiber) : base(fiber)
+ private readonly double _gridX;
+ private readonly double _gridY;
+ private readonly int _columns;
+ private readonly int _rows;
+ private readonly int[] _cellStart;
+ private readonly int[] _cellChords;
+ private readonly int _startZone;
+ private readonly int _endZone;
+
+ public FiberShape(FiberPart fiber, (double X, double Y)[] path) : base(fiber)
{
- _path = fiber.Points.Select(p => ((double)p.X, (double)p.Y)).ToArray();
+ _path = path;
+ _flat = fiber.Ends == FiberEnds.Flat;
+ FiberNode first = fiber.Nodes[0];
+ FiberNode last = fiber.Nodes[^1];
+ _startTangent = Unit(first.OutX, first.OutY) ?? Unit(path[1].X - path[0].X, path[1].Y - path[0].Y) ?? (1.0, 0.0);
+ _endTangent = Unit(-last.InX, -last.InY) ?? Unit(path[^1].X - path[^2].X, path[^1].Y - path[^2].Y) ?? (1.0, 0.0);
_coreRadius = Math.Max(1, fiber.CoreDiameter) / 2.0;
_outerRadius = _coreRadius + Math.Max(0, fiber.CladdingThickness);
_coreIndex = GuardIndex(fiber.CoreIndex);
_claddingIndex = fiber.CladdingThickness > 0 ? GuardIndex(fiber.CladdingIndex) : _coreIndex;
+ HasInnerEdges = fiber.CladdingThickness > 0;
Coating = GuardCoating(fiber.Coating);
_extent = _path.Max(v => Math.Sqrt(v.X * v.X + v.Y * v.Y)) + _outerRadius;
+ // the chords a flat face cuts: every chord is a capsule, and one starting within the outer radius of an
+ // end (twice that, for a bend) reaches past the face with its round cap
+ _startZone = 1;
+ _endZone = _path.Length - 1;
+ double arc = 0.0;
+ for (int i = 1; i < _path.Length && arc <= 2.0 * _outerRadius; i++)
+ {
+ _startZone = i;
+ arc += Math.Sqrt(Square(_path[i].X - _path[i - 1].X) + Square(_path[i].Y - _path[i - 1].Y));
+ }
+ arc = 0.0;
+ for (int i = _path.Length - 1; i >= 1 && arc <= 2.0 * _outerRadius; i--)
+ {
+ _endZone = i;
+ arc += Math.Sqrt(Square(_path[i].X - _path[i - 1].X) + Square(_path[i].Y - _path[i - 1].Y));
+ }
+
+ // the grid over the path's box widened by the tube and the margin; a chord is listed in every cell its
+ // widened box touches: the counts first, then the lists laid end to end behind the starts
+ double reach = _outerRadius + Margin;
+ _gridX = _path.Min(v => v.X) - reach;
+ _gridY = _path.Min(v => v.Y) - reach;
+ _columns = Math.Max(1, (int)Math.Ceiling((_path.Max(v => v.X) + reach - _gridX) / CellSize));
+ _rows = Math.Max(1, (int)Math.Ceiling((_path.Max(v => v.Y) + reach - _gridY) / CellSize));
+ var counts = new int[_columns * _rows];
+ VisitCells((cell, _) => counts[cell]++);
+ _cellStart = new int[counts.Length + 1];
+ for (int c = 0; c < counts.Length; c++)
+ {
+ _cellStart[c + 1] = _cellStart[c] + counts[c];
+ }
+ _cellChords = new int[_cellStart[^1]];
+ var fill = (int[])_cellStart.Clone();
+ VisitCells((cell, chord) => _cellChords[fill[cell]++] = chord);
+
+ void VisitCells(Action<int, int> visit)
+ {
+ for (int i = 1; i < _path.Length; i++)
+ {
+ (int c0, int r0) = CellOf(Math.Min(_path[i - 1].X, _path[i].X) - reach, Math.Min(_path[i - 1].Y, _path[i].Y) - reach);
+ (int c1, int r1) = CellOf(Math.Max(_path[i - 1].X, _path[i].X) + reach, Math.Max(_path[i - 1].Y, _path[i].Y) + reach);
+ for (int r = r0; r <= r1; r++)
+ {
+ for (int c = c0; c <= c1; c++)
+ {
+ visit(r * _columns + c, i);
+ }
+ }
+ }
+ }
}
public override bool IsMirror => false;
protected override int Coating { get; }
+ /// <summary>The core's edge steps inside the outline, so the painter samples every pixel of the tube (without this the core edge came out unsmoothed, 2026-10-22).</summary>
+ public override bool HasInnerEdges { get; }
protected override double Extent => _extent;
- protected override double Depth(double x, double y) => _outerRadius - PathDistance(x, y);
protected override double BodyIndex(double x, double y) => PathDistance(x, y) <= _coreRadius ? _coreIndex : _claddingIndex;
- /// <summary>Distance to the nearest segment of the path (round ends and joints follow).</summary>
+ protected override double Depth(double x, double y)
+ {
+ (int from, int to) = ChordsNear(x, y);
+ if (from == to)
+ {
+ return -Margin;
+ }
+ int last = _path.Length - 1;
+ // depth from the end faces: how far past the start, and how far short of the end, along the tangents there
+ double startDepth = _flat ? (x - _path[0].X) * _startTangent.X + (y - _path[0].Y) * _startTangent.Y : double.PositiveInfinity;
+ double endDepth = _flat ? (_path[last].X - x) * _endTangent.X + (_path[last].Y - y) * _endTangent.Y : double.PositiveInfinity;
+ double best = double.NegativeInfinity;
+ for (int k = from; k < to; k++)
+ {
+ int i = _cellChords[k];
+ (double ax, double ay) = _path[i - 1];
+ (double bx, double by) = _path[i];
+ double dx = bx - ax;
+ double dy = by - ay;
+ double length = Math.Sqrt(dx * dx + dy * dy);
+ double along = ((x - ax) * dx + (y - ay) * dy) / length; // from a, in pixels
+ double depth;
+ if (along >= 0.0 && along <= length || i == 1 && startDepth < 0.0 || i == last && endDepth < 0.0)
+ {
+ // across the chord's span, or before a flat start or beyond a flat end: the distance to the line
+ double perpendicular = Math.Abs((x - ax) * dy - (y - ay) * dx) / length;
+ depth = _outerRadius - perpendicular;
+ }
+ else
+ {
+ // beyond a chord's end inside the path: the round joint to the next chord, or a round end
+ depth = _outerRadius - SegmentDistance(ax, ay, bx, by, x, y);
+ }
+ if (i <= _startZone)
+ {
+ depth = Math.Min(depth, startDepth);
+ }
+ if (i >= _endZone)
+ {
+ depth = Math.Min(depth, endDepth);
+ }
+ best = Math.Max(best, depth);
+ }
+ // a chord the cell does not list is more than the margin outside, so it never sets the maximum
+ return Math.Max(best, -Margin);
+ }
+
+ /// <summary>Distance to the nearest chord of the path among those listed for the point's cell (exact within the tube, where the nearest chord is always listed).</summary>
private double PathDistance(double x, double y)
{
+ (int from, int to) = ChordsNear(x, y);
double nearest = double.PositiveInfinity;
- for (int i = 1; i < _path.Length; i++)
+ for (int k = from; k < to; k++)
{
+ int i = _cellChords[k];
nearest = Math.Min(nearest, SegmentDistance(_path[i - 1].X, _path[i - 1].Y, _path[i].X, _path[i].Y, x, y));
}
return nearest;
}
+
+ /// <summary>The range in the chord lists for the cell of (x', y'): empty outside the grid.</summary>
+ private (int From, int To) ChordsNear(double x, double y)
+ {
+ int column = (int)Math.Floor((x - _gridX) / CellSize);
+ int row = (int)Math.Floor((y - _gridY) / CellSize);
+ if (column < 0 || column >= _columns || row < 0 || row >= _rows)
+ {
+ return (0, 0);
+ }
+ int cell = row * _columns + column;
+ return (_cellStart[cell], _cellStart[cell + 1]);
+ }
+
+ /// <summary>The cell holding (x', y'), clamped onto the grid.</summary>
+ private (int Column, int Row) CellOf(double x, double y) =>
+ (Math.Clamp((int)Math.Floor((x - _gridX) / CellSize), 0, _columns - 1), Math.Clamp((int)Math.Floor((y - _gridY) / CellSize), 0, _rows - 1));
+
+ private static double Square(double v) => v * v;
+
+ /// <summary>The direction (x, y) as a unit vector, or null for a zero vector.</summary>
+ private static (double X, double Y)? Unit(double x, double y)
+ {
+ double length = Math.Sqrt(x * x + y * y);
+ return length > 0.0 ? (x / length, y / length) : null;
+ }
}
private sealed class BraggShape : PartShape
diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.cs
index 34bfaf0..adadfc9 100644
--- a/_tools/library_check/Program.cs
+++ b/_tools/library_check/Program.cs
@@ -202,6 +202,12 @@ internal static class Program
lens.Diameter = 400;
var polygon = (PolygonPart)project.AddPart(PartKind.Polygon);
polygon.Side = 150;
+ // a fibre in an S-bend across the whole canvas: its bounding box is the canvas (2026-10-22)
+ var fiber = (FiberPart)project.AddPart(PartKind.Fiber);
+ fiber.Nodes[0].X = -900;
+ fiber.Nodes[0].SetHandle(true, 400, -500);
+ fiber.Nodes[1].X = 900;
+ fiber.Nodes[1].SetHandle(false, -400, 500);
foreach (OpticalPart part in project.Parts)
{
var single = new List<OpticalPart> { part };
@@ -2147,12 +2153,80 @@ internal static class Program
"a Bragg stack of 3 pairs 10 + 6 px, indices 1.5 / 2.0, 20 wide, centred: " + layers);
project.Parts.Clear();
var fiber = (FiberPart)project.AddPart(PartKind.Fiber);
- fiber.X = 100;
+ fiber.X = 80;
fiber.Y = 60;
painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
- Check(fiber.Points.Count == 2 && fiber.Points[0].X == -100 && fiber.Points[1].X == 100, "a new fibre runs from (-100, 0) to (100, 0)");
- Check(RedAt(painted, 100, 60) == 150 && RedAt(painted, 100, 60 + 9) == 150 && RedAt(painted, 100, 60 + 12) == 145 && RedAt(painted, 100, 60 + 19) == 145 && RedAt(painted, 100, 60 + 21) == 100 && RedAt(painted, 0, 60) == 150,
+ Check(fiber.Nodes.Count == 2 && fiber.Nodes[0] is { X: -100, Y: 0, OutX: 67, OutY: 0, InX: 0, Smooth: true } && fiber.Nodes[1] is { X: 100, Y: 0, InX: -67, InY: 0, OutX: 0 } && fiber.Ends == FiberEnds.Flat,
+ "a new fibre runs straight from (-100, 0) to (100, 0), the handles a third of the way along it, the ends flat");
+ Check(FiberPart.Flatten(fiber.Nodes).Length == 2, "the straight path flattens to one chord");
+ Check(RedAt(painted, 80, 60) == 150 && RedAt(painted, 80, 60 + 9) == 150 && RedAt(painted, 80, 60 + 12) == 145 && RedAt(painted, 80, 60 + 19) == 145 && RedAt(painted, 80, 60 + 21) == 100 && RedAt(painted, 0, 60) == 150,
"the fibre: core 1.5 within 10 px of the path, cladding 1.45 to 20 px, the canvas edge reached");
+ Check(RedAt(painted, 179, 60) == 150 && RedAt(painted, 180, 60) == 100 && RedAt(painted, 179, 60 + 18) == 145 && RedAt(painted, 180, 60 + 18) == 100 && RedAt(painted, 185, 60) == 100,
+ "a flat end: the last pixel before the endpoint is core, the first beyond it background, across the whole width");
+ fiber.Coating = 3;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ Check(RedAt(painted, 177, 60) == 122 && RedAt(painted, 176, 60) == 150 && RedAt(painted, 80, 60 + 18) == 120 && RedAt(painted, 80, 60 + 16) == 145,
+ "the AR coating lies along the sides (√1.45 = 1.20) and on the flat end face (√1.5 = 1.22)");
+ fiber.Coating = 0;
+ fiber.Ends = FiberEnds.Round;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ Check(RedAt(painted, 185, 60) == 150 && RedAt(painted, 189, 60) == 150 && RedAt(painted, 190, 60) == 145 && RedAt(painted, 199, 60) == 145 && RedAt(painted, 195, 75) == 100,
+ "a round end: the core goes on past the endpoint by its radius, the cladding by the outer one, the corner beyond it stays empty");
+ fiber.Ends = FiberEnds.Flat;
+ fiber.Nodes[0].X = -60;
+ fiber.Nodes[0].Y = 40;
+ fiber.Nodes[0].SetHandle(true, 0, -80);
+ fiber.Nodes[1].X = 60;
+ fiber.Nodes[1].Y = 40;
+ fiber.Nodes[1].SetHandle(false, 0, -80);
+ (double X, double Y)[] bent = FiberPart.Flatten(fiber.Nodes);
+ Check(bent.Length > 20 && bent.All(p => Math.Abs(p.X) <= 60 && p.Y >= -20.0001 && p.Y <= 40) && bent.Min(p => Math.Abs(p.Y + 20)) < 0.5 && bent[0] == (-60, 40) && bent[^1] == (60, 40),
+ $"a bent path (nodes at (±60, 40), 80 px handles straight up) flattens to {bent.Length} chords within the handles' hull, from node to node through the apex (0, -20)");
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ Check(RedAt(painted, 80, 35) == 150 && RedAt(painted, 80, 25) == 145 && RedAt(painted, 80, 15) == 100 && RedAt(painted, 80, 100) == 100,
+ "the bent fibre is painted along the curve: core and cladding at the apex, nothing on the straight line between the nodes");
+ Check(RedAt(painted, 20, 99) == 150 && RedAt(painted, 20, 100) == 100 && RedAt(painted, 140, 99) == 150 && RedAt(painted, 140, 100) == 100,
+ $"its flat ends are cut across the handles' direction: the row above a node is core, the node's own row background ({RedAt(painted, 20, 99)}, {RedAt(painted, 20, 100)}, {RedAt(painted, 140, 99)}, {RedAt(painted, 140, 100)})");
+ var node = new FiberNode { OutX = 30, OutY = 0, InX = -10, InY = 0 };
+ node.SetHandle(true, 0, 40);
+ Check(node is { OutX: 0, OutY: 40, InX: 0, InY: -10 }, "a smooth node: setting the out-handle turns the in-handle opposite, its length kept");
+ node.SetHandle(false, 6, 8, 20.0);
+ Check(node is { InX: 6, InY: 8, OutX: -12, OutY: -16 }, "and the in-handle turns the out-handle, to the length given");
+ node.Smooth = false;
+ node.SetHandle(true, 5, 5);
+ Check(node is { OutX: 5, OutY: 5, InX: 6, InY: 8 }, "a corner node leaves the other handle alone");
+ var aligned = new FiberPart { Nodes = [new FiberNode { X = -100 }, new FiberNode { X = 0, Y = 50, InX = -10, OutY = 40, Smooth = false }, new FiberNode { X = 100 }] };
+ aligned.Nodes[1].Smooth = true;
+ Check(aligned.Nodes[1] is { InX: 0, InY: -10, OutX: 0, OutY: 40 }, "switching a node to smooth lines its in-handle up opposite the out-handle, both lengths kept");
+ aligned.Nodes[1].InX = 60;
+ Check(aligned.Nodes[1] is { InX: 60, InY: -10, OutX: -39, OutY: 7 }, "a typed in-handle of a smooth node turns the out-handle opposite, its length kept");
+ var bare = new FiberNode { X = 0, Y = 50, Smooth = false };
+ aligned.Nodes[1] = bare;
+ bare.Smooth = true;
+ Check(bare is { InX: -37, InY: 0, OutX: 37, OutY: 0 }, "a node without handles switched to smooth gets them from its neighbours: along the line between them, a third of the way to each");
+ var twin = (FiberPart)aligned.Clone();
+ twin.Nodes[1].OutY = 37;
+ twin.Nodes[1].OutX = 0;
+ Check(twin.Nodes[1] is { OutX: 0, OutY: 37, InX: 0, InY: -37 } && bare is { InX: -37, OutX: 37, OutY: 0 }, "a clone keeps its own nodes smooth, the original's untouched");
+ var keeper = new Project();
+ var kept = (FiberPart)keeper.AddPart(PartKind.Fiber);
+ kept.Nodes.Add(new FiberNode { X = 150, Y = 30, InX = -60, OutX = 60, OutY = 1 });
+ string keptXml;
+ using (var stream = new MemoryStream())
+ {
+ keeper.Save(stream);
+ keptXml = System.Text.Encoding.UTF8.GetString(stream.ToArray());
+ }
+ Project keptBack;
+ using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(keptXml)))
+ {
+ keptBack = Project.Load(stream);
+ }
+ Check(kept.Nodes[2] is { InX: -60, InY: 0, OutX: 60, OutY: 1 } && keptBack.Parts[0] is FiberPart { Nodes.Count: 3 } reloaded && reloaded.Nodes[2] is { InX: -60, InY: 0, OutX: 60, OutY: 1, Smooth: true },
+ "a node added or loaded is kept as it is, a pixel off the line included: the smooth rule acts on edits only");
+ var oddEnds = new FiberPart { Ends = (FiberEnds)7 };
+ oddEnds.Normalize();
+ Check(oddEnds.Ends == FiberEnds.Flat, "an undefined Ends value normalises to Flat");
project.Parts.Clear();
// the cavity: a mirror square with its inside painted back to index 1 keeps a wave in, nothing gets out
@@ -2256,7 +2330,8 @@ internal static class Program
back = Project.Load(stream);
}
Check(back.Parts.Count == 9 && back.Parts.Select(p => p.Kind).SequenceEqual([PartKind.BraggReflector, PartKind.Lens, PartKind.Outline, PartKind.Polygon, PartKind.Rectangle, PartKind.Ellipse, PartKind.Triangle, PartKind.Fiber, PartKind.GrinLens]), "the nine kinds load back in order");
- Check(back.Parts[7] is FiberPart { Points.Count: 2 } loaded && loaded.Points[0].X == -100 && loaded.Points[1].X == 100, "a loaded fibre has its two points, not the default path on top of them");
+ Check(xml.Contains("<Node X=\"-100\" Y=\"0\" OutX=\"67\" />") && xml.Contains("<Node X=\"100\" Y=\"0\" InX=\"-67\" />"), "a fibre's nodes are sparse Node children: handles only where set, Smooth only when off");
+ Check(back.Parts[7] is FiberPart { Nodes.Count: 2, Ends: FiberEnds.Flat } loaded && loaded.Nodes[0] is { X: -100, OutX: 67, Smooth: true } && loaded.Nodes[1] is { X: 100, InX: -67 }, "a loaded fibre has its two nodes with their handles, not the default path on top of them");
Check(back.Parts[2] is OutlinePart { Mirror: true, Points.Count: 1 } && back.Parts[0] is BraggReflectorPart { Angle: 45, Index2: 2.2, Pairs: 10 } && back.Parts[4] is RectanglePart { Width: 7, Length: 60 } && back.Parts[5] is EllipsePart { Width: 9, Length: 9, Linked: true } && back.Parts[6] is TrianglePart { Type: TriangleType.RightIsosceles, AngleB: 45 },
"a loaded outline keeps its point and mirror flag, the reflector its angle and index, the rectangle its width, the triangle its type");
var watched = new ProjectWatcher(back);