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#

Optical parts: lenses, shapes, fibres, Bragg reflectors and GRIN lenses painted into the scene

Alexander Graefd4072fe41f05
diff --git a/CLAUDE.md b/CLAUDE.md
index 8314d0e..a376eba 100644
--- a/CLAUDE.md
+++ b/CLAUDE.md
@@ -72,7 +72,9 @@ harnesses run.
## Architecture
```
-Project (Model/) --RunSpec.Create--> RunSpec (immutable snapshot)
+Project (Model/) --RunSpec.Create--> RunSpec (immutable snapshot); the scene pixels come from MainWindow.Live's
+ LoadSceneImage: the decoded image (or a blank canvas) with the enabled optical parts painted into red by
+ PartPainter (Parts/), cached by (image, parts version, size, background) so an unchanged scene is the same reference
StartRun: memory budget -> DiscardRun (returns the old store's release task) -> FrameStore -> SimulationRun
SimulationRun: stepping loop + writer threads; IWaveEngine (WaveSimulator CPU | GpuWaveSimulator OpenCL);
CaptureFrame/AwaitFrame -> FrameStore.Write; one heartbeat post (<= 30/s) at Background priority; final post sets
@@ -140,6 +142,12 @@ FrameStore: native memory up to the budget, the rest in a temp file (%LOCALAPPDA
and viewers such as DJV): the stored halves themselves, one uncompressed "Y" channel per file, no colours,
brightness, outline or boxes; a sink that `WantsHalves` gets the plane from the job unrendered. Harness
hooks: `WAVEDUDE_EXPORT_PATH`, `WAVEDUDE_DISCARD_EDITS=1`.
+- **Optical parts** (2026-10-18, stages 1 and 2 of `OpticalParts.md`): `OpticalPart` subclasses `LensPart` (mirror flag),
+ the shapes under `ShapePart` (`PolygonPart` regular, `RectanglePart`, `TrianglePart` by base and base angles with presets, `OutlinePart` by points), `FiberPart`, `BraggReflectorPart`, `GrinLensPart` in `Project.Parts`, one XML element
+ per kind; painted into the scene's red channel (4 × 4 supersampled, a mirror by the pixel-centre test as red 0, a
+ coating band of √n, later parts over earlier ones; a part's centre is the corner of pixel (X, Y), so even sizes cover
+ 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, the shape shows through the glowing outline.
- 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)
@@ -154,7 +162,7 @@ numbers: no GPU JPEG, no OpenCL colouring at presentation, no `Vector256`, no Di
## Harnesses
-`library_check` (70+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export).
+`library_check` (100+ checks: engines, store, renderer, schemes, probes, scratch, reduced preview, importer, export, parts).
UI, all on `Common.ps1`, with their check counts: `PreviewCheck` 43, `RunCheck` 71, `LanguageCheck` 11,
`ProbeGraphCheck` 39, `ImportCheck` 10, `ExportCheck` 30, `PreviewQualityCheck` 35, `SceneImageCheck` 8,
`ColorPickerCheck` 13, `KeyboardCheck` 13, `AboutCheck` 18. Test projects `tiny*.wdproj` sit beside them. A harness
@@ -174,4 +182,7 @@ never reworded per file.
README and a documentation file (he writes them); release (single-file publish, portable archive, signed installer,
curated examples from Jeroen, his program as preserved assets, repository rename); probe data as CSV; an integer
upscale in exports; HEVC; the start-up stall (log milestones first); the GPU readback (a second OpenCL queue);
-automatic quality lowering when a run would spill (undecided); dropping the 9-point Laplacian (undecided).
+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.
diff --git a/OpticalParts.md b/OpticalParts.md
new file mode 100644
index 0000000..958ed0a
--- /dev/null
+++ b/OpticalParts.md
@@ -0,0 +1,177 @@
+# Optical parts — design and work plan
+
+Written 2026-10-18 for a session that starts with an empty context. Read `CLAUDE.md` first: its working rules
+(no git on your own, options before design changes, verification matched to the change, keyboard-only harnesses,
+model conventions, four string tables) apply to every step here.
+
+**Status (2026-10-18, later the same day, uncommitted):** stages 1 and 2 are built as written below: the model for all five
+kinds (`Model/OpticalPart.cs`), the painter for every kind (`Parts/PartPainter.cs`, `Parts/PartShape.cs`), the plumbing
+(`RunSpec`, `MainWindow.Live.cs`), the tree with its "+ Part" menu, the forms, the handles with the rotation lever, the
+strings in four tables and 32 library checks (`CheckParts`). Two choices made on the way: a part's centre is the top-left
+corner of pixel (X, Y), not its middle, so even sizes (every default) cover whole pixels; and the shapes read out-of-range
+values guarded instead of normalising the model from inside the painter. After the user's review (a side length alone made every
+rectangle a square; a shape mode inside one class would be the kind combo we rejected): the polygon became four classes
+under `ShapePart` (mirror, index, coating), each its own kind, element and form: `PolygonPart` (regular, side count and
+side length, a face centred on -x'), `RectanglePart` (length, width, a Square button), `TrianglePart` (base across the
+axis toward -x', two base angles, a type preset: equilateral, right isosceles, 30-60-90, isosceles, custom; the apex angle
+shown), `OutlinePart` (points). The "+ Part" menu lists the optics, a separator, the shapes. The handle glyph is the
+source's circular crosshair with an inner ring (a lens-shaped glyph read as squashed). Not built: stage 3 (`PartCheck.ps1`, the three
+examples) and the selected part's accent outline. The open points at the end still stand.
+
+## What is asked
+
+Jeroen Vleggaar (author of Wave Dude 2D) proposed, and Alexander Graef (the user) decided, that WaveDude Next gets
+**optical parts as project objects**, added like sources: a lens or mirror, a polygon, a fiber, a Bragg reflector,
+a gradient-index lens. Each has a position and an angle plus kind-specific properties. The aim, in Jeroen's words:
+demonstrating optics without an external image editor; a cavity of mirrors keeps a wave "for ever". His two
+sketches of the property form (not in the repository; they showed a Type combo, an
+"AR thickn. (px)" field, Position X/Y/Angle, then groups: Lens/mirror with refractive index, diameter, R1, R2,
+centre thickness; Polygon with refractive index, number of surfaces, surface size; Fiber with core index and
+diameter, cladding index and thickness; a "Shape coordinates (list)" box). Mirrors have no refractive index.
+
+## Decisions taken (with the user)
+
+1. **Parts are painted into the scene pixels.** The scene reaches the engines only as BGRA pixels today
+ (`RunSpec.Image`, a `ScenePixels`; `SceneData.FromBgra` maps red to the refractive index). A new library step
+ rasterises the enabled parts into a copy of the scene image, or into a blank canvas for an image-less scene,
+ before the pixels go anywhere. Both engines, the glowing outline over the pictures (`GlowingEdges.Compute` in
+ `PreviewPane.OnScenePixelsChanged`), the export outline (`MainWindow.Export.cs`) and the scratch frames then
+ work unchanged. The price is Jeroen's own range: index 1.00 to 2.55 in steps of 0.01 (red = index × 100).
+2. **Red only.** The painter writes the red channel and never touches green or blue. Green shades are source
+ frequencies (WaveSimulator2D's warning: never anti-alias green), blue is damping; both stay as the image has them.
+3. **A red value of 0 is a mirror** (index 1000, commit `5dbefa6`, Jeroen's V0.30 rule). Red 1..99 is index 1.
+4. **One subclass per kind, one XML element name per kind** (the user's choice: a schema can then say which
+ attributes each element requires). `OpticalPart` is abstract; `LensPart`, `PolygonPart`, `FiberPart`,
+ `BraggReflectorPart`, `GrinLensPart` derive from it. `Project.Parts` is one `ObservableCollection<OpticalPart>`
+ with five `[XmlElement("Lens", typeof(LensPart))]`-style attributes, so the file holds `<Lens …/>`,
+ `<Polygon …/>`, `<Fiber …/>`, `<BraggReflector …/>`, `<GrinLens …/>` in tree order, like `<Source>` today.
+ A part's kind is chosen when it is added; there is no kind combo on an existing part.
+5. **Angle** in degrees, positive counter-clockwise on screen, 0 = the part's axis along +x, the convention of
+ the composite source's rotation handle (`Source.Array`, `MarkerRole.SourceAngle`).
+6. **AR coating** ("AR thickn." in the sketch): a band of the given thickness in pixels just inside the part's
+ outer boundary gets the index √n (rounded to 0.01), the quarter-wave idea without a wavelength tie. The hint
+ may say that a quarter-wave coating is λ / (4 √n) pixels thick, λ being the wavelength the source form shows.
+ Mirrors and Bragg reflectors ignore it.
+7. **Rasterisation**: 4 × 4 supersampling per pixel for refractive parts; each sample is classified (outside,
+ coating, body, or a GRIN/fibre zone), the sample indices are averaged (an existing red of 0 counts as index 1 in
+ that average) and rounded to red. A mirror part uses the pixel-centre test alone and writes red 0 (a half-covered
+ mirror pixel would otherwise clamp to index 1 and be transparent). Later parts paint over earlier ones.
+8. **Stages**: (1) model for all five kinds, painter with lens/mirror and polygon, plumbing, tree, forms, handles,
+ strings, library checks; (2) painter for fiber, Bragg reflector, GRIN lens; (3) a UI harness and three example
+ projects for Jeroen (a lens, a cavity, a bent fiber). No time estimates (the user's rule).
+
+## The model (`WaveDudeNext/Model/OpticalPart.cs`, one file per class or one file; follow `Source.cs`)
+
+Every property follows `CLAUDE.md`'s model conventions: `[XmlAttribute]` with a `[DefaultValue]`, `[Category]`,
+`[DisplayName]`, `[Description]`, a `///` summary with units, a clamp in `Normalize()`, and `Label.<Type>.<Member>` /
+`Hint.<Type>.<Member>` keys in all four string tables (`WaveDudeNext.WPF/Strings/Strings.{EN,DE,FR,NL}.xaml`).
+The label markup (`Markup/ModelMemberExtension.cs`) builds the key from the type named in XAML, so base members are
+written `model:OpticalPart.X` and kind members `model:LensPart.R1`. Positions and lengths are canvas pixels.
+
+**`OpticalPart` (abstract, `ObservableObject`)**
+
+| Member | Type | Default | Range | Notes |
+|---|---|---|---|---|
+| `Name` | string | "Lens 1" etc. | | `Project.NumberedName` per kind |
+| `Enabled` | bool | true | | a disabled part is not painted |
+| `X`, `Y` | int | canvas centre | ≥ 0 | the part's centre |
+| `Angle` | double | 0 | −180..180 | degrees, see decision 5 |
+| `Kind` | enum, `[XmlIgnore]` | | | read-only, for the tree row and the overlay |
+| `Normalize()` | abstract | | | |
+
+**`LensPart`** — Mirror (bool, false), RefractiveIndex (1.00..2.55, 1.50; hidden/disabled while Mirror),
+Coating (int px, 0..50, 0), Diameter (int, 200, ≥ 2), R1 (double, 300), R2 (double, −300), Thickness (int, 40, ≥ 1).
+R is signed: R1 > 0 and R2 < 0 bulge outward (biconvex); 0 means flat; |R| < Diameter / 2 is clamped to Diameter / 2.
+Shape in the part frame (x' along the axis, y' across): the strip |y'| ≤ D/2 between the surfaces
+x'₁(y') = −t/2 + s₁(y') and x'₂(y') = t/2 + s₂(y'), with the sag s(y') = R − sign(R)·√(R² − y'²) for R ≠ 0 and
+0 for flat; a point is inside when x'₁ ≤ x' ≤ x'₂ (empty where convex surfaces cross, which caps a thin lens).
+A curved mirror is the same shape with Mirror on, e.g. R1 = −400, R2 = 0, Thickness 20.
+
+**`PolygonPart`** — Mirror, RefractiveIndex, Coating as the lens; Sides (int, 6, 3..64), Side (int px, 60, ≥ 2);
+`Points` (a list, `[XmlElement("Point")]` of a small `PartPoint { X, Y }` record class, relative to the centre,
+before rotation; empty by default). A non-empty list replaces the regular polygon. Regular: circumradius
+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.
+
+**`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.
+
+**`GrinLensPart`** — Length (100), Diameter (100), CentreIndex (1.80), EdgeIndex (1.50), Coating (0).
+Rectangle Length × Diameter; n(y') = n_c − (n_c − n_e)·(2y'/D)².
+
+`Project`: `Parts` collection (serialised between `Sources` and `Probes`), `AddPart(PartKind)` using
+`NumberedName`, `Duplicate(OpticalPart)`, `Normalize()` over the parts. `ProjectWatcher`: subscribe the parts and
+their `Points` lists (`Resubscribe`, the property-change filter list); `ProjectChange.AffectsSimulation` true for a
+part, a `PartPoint`, the parts list and `Project.Parts`. `LegacyProject` (Jeroen's `configuration.json`) has no
+counterpart: nothing to import.
+
+## The painter (`WaveDudeNext/Parts/PartPainter.cs`, library)
+
+`ScenePixels PartPainter.Paint(ScenePixels? image, int width, int height, double backgroundIndex,
+IReadOnlyList<OpticalPart> parts)`:
+- no enabled part → returns `image` itself (the same reference; see plumbing) or null;
+- otherwise a new `ScenePixels` of the canvas size: a copy of the image, or a blank canvas with red =
+ round(backgroundIndex × 100), green 0, blue 0, alpha 255; then each enabled part in list order per decision 7.
+- Pure geometry, no WPF; parallel over rows is fine (`Parallel.For`), the arrays are its own.
+- Keep the per-kind inside/zone tests in small static classes or methods so `library_check` can test them.
+
+## Plumbing (WPF)
+
+- `MainWindow.Live.cs`: `LoadSceneImage()` becomes the composed scene: the decoded image (as now) through
+ `PartPainter.Paint`, cached by (image reference, a parts version) so unchanged parts return the **same**
+ `ScenePixels` reference. `RunSpec.SameSceneAs` compares `Image` by reference and the scratch runner keeps its
+ engine on that; a new reference per scratch request would rebuild the engine (an OpenCL compile) every time.
+ Bump the version on any part change (the watcher reports it).
+- `RunSpec`: `Image` is now set for an image-less scene with parts too. `ImageSources` must stay false then
+ (it is `image != null && Scene.ImageSources`; the green-sources warning in `Create` would otherwise fire). Pass
+ `Scene.Mode == SceneMode.Image` through, or compose only the red of a blank canvas and keep a flag.
+- `OnProjectChanged`: a part change calls `UpdateScenePixels()` like a `Scene` change, so the outline follows live;
+ the rest (stale run, scratch, re-run) comes from `AffectsSimulation`.
+- Export: `MainWindow.Export.cs` takes the composed pixels for the outline (it calls `LoadSceneImage` already).
+
+## UI
+
+- **Tree** (`Panes/ProjectTree.xaml`): a "Parts" folder between Sources and Probes (`NamedCollections` converter
+ parameter and bindings; `TreeParts` string), a row template for `OpticalPart` like the `Source` one (enabled
+ check box, name, move up/down, remove; `AutomationId` "Enabled:<name>" and `TreeId`). The folder's plus and a
+ "+ Part" toolbar button (`ToolAddPart`) open a menu of the five kinds (a `ContextMenu` opened by the button,
+ keyboard: Space opens, arrows, Enter); `ProjectCommands.AddPart` takes the kind. `MainWindow.Project.cs`:
+ `ListOf`, `OnAdd`, `CanEditItem`, `CanToggleEnabled`, `OnToggleEnabled`, `OnDuplicate` learn `OpticalPart`.
+- **Forms** (`Views/`): one `UserControl` per kind (`LensPartView` …) with `FormPanel` sections as in
+ `SourceView.xaml`; the common part (name, enabled, X, Y, angle) in a shared `PartCommonView` placed first;
+ `PropertiesPane.xaml` gets a `DataTemplate` per kind. Points lists: a small editable list (one row per point with
+ two `NumberBox`es, add/remove) rather than free text, every control reachable by Tab. Lens: the index box
+ disabled while Mirror is on (a `DataTrigger`, see `PulsedOnlyText`).
+- **Handles** (`Controls/SceneOverlay.cs`, `MarkerThumb.cs`): `MarkerRole.Part` at the centre and
+ `MarkerRole.PartAngle` on a lever like `SourceAngle` (visible while selected), styles in `PreviewPane.xaml`
+ (`SourceMarker`/`AngleMarker` as models), arrows nudge, selection syncs with the tree, `AutomationId`
+ "Part:<name>" and "PartAngle:<name>". The shape itself shows through the glowing outline; drawing the selected
+ part's outline in the accent colour is a welcome extra if cheap (the painter can expose a polyline per part).
+- **Strings**: `TreeParts`, `ToolAddPart`, `TipToolAddPart`, `MenuAddLens` … (five), `Label.`/`Hint.` for every
+ member above, `Enum.PartKind.*`, in all four tables. British spelling in the UI.
+- **Live editing** rules of `CLAUDE.md` hold: a part edit is a simulation edit.
+
+## Verification
+
+- `dotnet build WaveDudeNext.sln` with 0 warnings (headers and `///` docs are enforced).
+- `_tools/library_check` (`dotnet run --project _tools/library_check -c Release`, once per change set): the
+ painter returns the same reference without parts; green and blue untouched under a part; a lens's extent and
+ centre thickness in pixels; a regular hexagon's area within 1 % of the formula; a mirror polygon ring around a
+ source keeps the field inside after 300 steps and leaves the outside below 1e-4 of it (the cavity); the coating
+ band's red is round(100 √n); CPU = GPU on a scene with parts (both engines take the same pixels, so this is the
+ existing comparison on a painted scene); a project with every kind round-trips through `XmlSerializer` sparsely.
+- UI: `_tools/ui_check/KeyboardCheck.ps1` asserts the toolbar Tab order "ToolAddProbe,tree" after `ToolAddSource`;
+ with `ToolAddPart` between them it changes. Stage 3 adds `PartCheck.ps1` on `Common.ps1` (add a lens by keys,
+ edit a value, the run goes stale and re-runs, the handle moves with arrows). Update the check counts in
+ `CLAUDE.md`.
+- Screenshots of a lens, a cavity and a fiber for the user, not run through harness loops.
+
+## Open points for the user
+
+- 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
new file mode 100644
index 0000000..83fe9d3
--- /dev/null
+++ b/WaveDudeNext.WPF/Commands/PartCommands.cs
@@ -0,0 +1,33 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.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>), the rectangle's Square button.</summary>
+public static class PartCommands
+{
+ /// <summary>Makes a rectangle square: its width becomes its length.</summary>
+ public static readonly RoutedUICommand MakeSquare = new("Square", nameof(MakeSquare), typeof(PartCommands));
+
+ /// <summary>Appends a point after the last one.</summary>
+ public static readonly RoutedUICommand AddPoint = new("Add point", nameof(AddPoint), typeof(PartCommands));
+
+ /// <summary>Removes the point given as parameter.</summary>
+ public static readonly RoutedUICommand RemovePoint = new("Remove point", nameof(RemovePoint), typeof(PartCommands));
+}
diff --git a/WaveDudeNext.WPF/Commands/ProjectCommands.cs b/WaveDudeNext.WPF/Commands/ProjectCommands.cs
index 7ec4c8c..174c3e9 100644
--- a/WaveDudeNext.WPF/Commands/ProjectCommands.cs
+++ b/WaveDudeNext.WPF/Commands/ProjectCommands.cs
@@ -29,16 +29,19 @@ public static class ProjectCommands
/// <summary>Appends a new source.</summary>
public static readonly RoutedUICommand AddSource = new("Add source", nameof(AddSource), typeof(ProjectCommands));
+ /// <summary>Appends a new optical part of the <see cref="WaveDudeNext.Model.PartKind"/> given as parameter; without one, opens the menu of kinds on the invoking element.</summary>
+ public static readonly RoutedUICommand AddPart = new("Add part", nameof(AddPart), typeof(ProjectCommands));
+
/// <summary>Appends a new probe.</summary>
public static readonly RoutedUICommand AddProbe = new("Add probe", nameof(AddProbe), typeof(ProjectCommands));
/// <summary>Appends a new item to the folder node given as parameter.</summary>
public static readonly RoutedUICommand Add = new("Add", nameof(Add), typeof(ProjectCommands));
- /// <summary>Inserts a copy of a source or probe after the original.</summary>
+ /// <summary>Inserts a copy of a source, part or probe after the original.</summary>
public static readonly RoutedUICommand Duplicate = new("Duplicate", nameof(Duplicate), typeof(ProjectCommands));
- /// <summary>Removes a source or probe.</summary>
+ /// <summary>Removes a source, part or probe.</summary>
public static readonly RoutedUICommand Remove = new("Remove", nameof(Remove), typeof(ProjectCommands));
/// <summary>Swaps a source or probe with its predecessor.</summary>
@@ -47,7 +50,7 @@ public static class ProjectCommands
/// <summary>Swaps a source or probe with its successor.</summary>
public static readonly RoutedUICommand MoveDown = new("Move down", nameof(MoveDown), typeof(ProjectCommands));
- /// <summary>Flips a source's Enabled or a probe's Active (the tree's check boxes; Space on the selected row).</summary>
+ /// <summary>Flips a source's or part's Enabled or a probe's Active (the tree's check boxes; Space on the selected row).</summary>
public static readonly RoutedUICommand ToggleEnabled = new("Enable or disable", nameof(ToggleEnabled), typeof(ProjectCommands));
/// <summary>Picks an image file and embeds it as the scene image.</summary>
diff --git a/WaveDudeNext.WPF/Controls/MarkerThumb.cs b/WaveDudeNext.WPF/Controls/MarkerThumb.cs
index 02cc169..a35b24e 100644
--- a/WaveDudeNext.WPF/Controls/MarkerThumb.cs
+++ b/WaveDudeNext.WPF/Controls/MarkerThumb.cs
@@ -27,6 +27,10 @@ public enum MarkerRole
Source,
/// <summary>The rotation handle of a composite source: sits on the array's row axis and turns it (2026-10-14).</summary>
SourceAngle,
+ /// <summary>The centre of an optical part.</summary>
+ Part,
+ /// <summary>The rotation handle of an optical part: sits on the part's axis beyond its reach and turns it.</summary>
+ PartAngle,
/// <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>
@@ -62,7 +66,7 @@ public sealed class MarkerThumb : Thumb
/// <summary>How far the dark halo sticks out on each side of a stroke, in pixels, so the glyph reads on any picture.</summary>
public const double HaloWidth = 2.0;
- /// <param name="item">The source or probe.</param>
+ /// <param name="item">The source, part or probe.</param>
/// <param name="role">Which point of it.</param>
public MarkerThumb(object item, MarkerRole role)
{
@@ -71,7 +75,7 @@ public sealed class MarkerThumb : Thumb
Focusable = true;
}
- /// <summary>The source or probe this handle moves.</summary>
+ /// <summary>The source, part or probe this handle moves.</summary>
public object Item { get; }
/// <summary>Which point of the item.</summary>
diff --git a/WaveDudeNext.WPF/Controls/SceneOverlay.cs b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
index f3d336b..a278f5a 100644
--- a/WaveDudeNext.WPF/Controls/SceneOverlay.cs
+++ b/WaveDudeNext.WPF/Controls/SceneOverlay.cs
@@ -29,11 +29,12 @@ using WaveDudeNext.Model;
namespace WaveDudeNext.WPF.Controls;
/// <summary>
-/// The sources and probes of a <see cref="Project"/> drawn over a picture of the canvas, as draggable
-/// handles (<see cref="MarkerThumb"/>): a source's position, a point probe's point, a line probe's two
+/// The sources, optical parts and probes of a <see cref="Project"/> drawn over a picture of the canvas, as draggable
+/// handles (<see cref="MarkerThumb"/>): a source's position, a part's centre, a point probe's point, a line probe's two
/// 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) and the item names as labels. Dragging a handle, or moving it with the arrow keys while it has keyboard focus, writes the
+/// turn it by a degree, 2026-10-14), the same handle on a part's axis (2026-10-18; the part's shape itself shows
+/// through the glowing outline of the scene) and 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"/>. The overlay fills the same rectangle as the picture (an
/// <see cref="Image"/> with <see cref="Stretch.Uniform"/>), so it maps canvas pixels to its own
@@ -67,6 +68,10 @@ public sealed class SceneOverlay : Panel
public static readonly DependencyProperty SourceStyleProperty = DependencyProperty.Register(
nameof(SourceStyle), typeof(Style), typeof(SceneOverlay), new PropertyMetadata(null, (d, _) => ((SceneOverlay)d).Rebuild()));
+ /// <summary>Identifies the <see cref="PartStyle"/> property.</summary>
+ public static readonly DependencyProperty PartStyleProperty = DependencyProperty.Register(
+ nameof(PartStyle), 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()));
@@ -133,7 +138,7 @@ public sealed class SceneOverlay : Panel
set => SetValue(CanvasHeightProperty, value);
}
- /// <summary>The source or probe selected in the project (highlighted); set when a handle is grabbed or focused.</summary>
+ /// <summary>The source, part or probe selected in the project (highlighted); set when a handle is grabbed or focused.</summary>
public object? SelectedItem
{
get => GetValue(SelectedItemProperty);
@@ -161,7 +166,14 @@ public sealed class SceneOverlay : Panel
set => SetValue(SourceStyleProperty, value);
}
- /// <summary>Style of the rotation handles of composite sources (a <see cref="MarkerThumb"/> style).</summary>
+ /// <summary>Style of the optical part handles (a <see cref="MarkerThumb"/> style).</summary>
+ public Style? PartStyle
+ {
+ get => (Style?)GetValue(PartStyleProperty);
+ set => SetValue(PartStyleProperty, value);
+ }
+
+ /// <summary>Style of the rotation handles of composite sources and parts (a <see cref="MarkerThumb"/> style).</summary>
public Style? AngleStyle
{
get => (Style?)GetValue(AngleStyleProperty);
@@ -204,11 +216,13 @@ public sealed class SceneOverlay : Panel
if (e.OldValue is Project old)
{
old.Sources.CollectionChanged -= overlay.OnCollectionChanged;
+ old.Parts.CollectionChanged -= overlay.OnCollectionChanged;
old.Probes.CollectionChanged -= overlay.OnCollectionChanged;
}
if (e.NewValue is Project project)
{
project.Sources.CollectionChanged += overlay.OnCollectionChanged;
+ project.Parts.CollectionChanged += overlay.OnCollectionChanged;
project.Probes.CollectionChanged += overlay.OnCollectionChanged;
}
overlay.Rebuild();
@@ -244,6 +258,12 @@ public sealed class SceneOverlay : Panel
AddThumb(source, MarkerRole.SourceAngle, AngleStyle, source.Name, "SourceAngle:" + source.Name, "TipAngleMarkerFormat");
}
}
+ foreach (OpticalPart part in project.Parts)
+ {
+ Subscribe(part);
+ AddThumb(part, MarkerRole.Part, PartStyle, part.Name, "Part:" + part.Name);
+ AddThumb(part, MarkerRole.PartAngle, AngleStyle, part.Name, "PartAngle:" + part.Name, "TipAngleMarkerFormat");
+ }
foreach (Probe probe in project.Probes)
{
Subscribe(probe);
@@ -331,9 +351,9 @@ public sealed class SceneOverlay : Panel
foreach (MarkerThumb thumb in Children)
{
thumb.IsSelectedMarker = ReferenceEquals(thumb.Item, selected);
- if (thumb.Role == MarkerRole.SourceAngle)
+ if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle)
{
- // the rotation handle only while its source is selected (the user's rule, 2026-10-14); collapsed, it is out of the Tab cycle too
+ // the rotation handle only while its source or part is selected (the user's rule, 2026-10-14); collapsed, it is out of the Tab cycle too
thumb.Visibility = thumb.IsSelectedMarker ? Visibility.Visible : Visibility.Collapsed;
}
}
@@ -345,7 +365,7 @@ public sealed class SceneOverlay : Panel
items.OrderBy(item => ReferenceEquals(item, selected));
private static void UpdateOpacity(MarkerThumb thumb) =>
- thumb.Opacity = thumb.Item switch { Source { Enabled: false } => 0.45, Probe { Active: false } => 0.45, _ => 1.0 };
+ thumb.Opacity = thumb.Item switch { Source { Enabled: false } => 0.45, OpticalPart { Enabled: false } => 0.45, Probe { Active: false } => 0.45, _ => 1.0 };
// ---------------------------------------------------------------- geometry
@@ -382,41 +402,62 @@ public sealed class SceneOverlay : Panel
}
/// <summary>
- /// Where the rotation handle of a composite source sits, for an element of <paramref name="size"/>: on the
- /// array's row axis, turned by its angle (counter-clockwise on the screen), just beyond the first row's
- /// half-width and at least <see cref="AngleHandleReach"/> from the centre.
+ /// Where the rotation handle of a composite source or a part sits, for an element of <paramref name="size"/>: on
+ /// the array's row axis or the part's axis, turned by its angle (counter-clockwise on the screen), just beyond the
+ /// first row's half-width or the part's reach along the axis, and at least <see cref="AngleHandleReach"/> from the centre.
/// </summary>
- private Point AnglePoint(Source source, Size size)
+ private Point AnglePoint(object item, Size size)
{
- Point centre = ToView(source.X, source.Y, size);
- SourceArray array = source.Array!;
- double reach = Math.Max(AngleHandleReach, (array.SizeX - 1) / 2.0 * array.SpacingX * ScaleFor(size) + AngleHandleGap);
- double radians = array.Angle * Math.PI / 180.0;
+ (int x, int y, double angle, double extent) = item switch
+ {
+ Source { Array: { } array } source => (source.X, source.Y, array.Angle, (array.SizeX - 1) / 2.0 * array.SpacingX),
+ OpticalPart part => (part.X, part.Y, part.Angle, part.AxisReach),
+ _ => (0, 0, 0.0, 0.0),
+ };
+ Point centre = ToView(x, y, size);
+ double reach = Math.Max(AngleHandleReach, extent * ScaleFor(size) + AngleHandleGap);
+ double radians = angle * Math.PI / 180.0;
return new Point(centre.X + reach * Math.Cos(radians), centre.Y - reach * Math.Sin(radians));
}
- /// <summary>Turns the array so its row axis points from the source to <paramref name="view"/>: to whole degrees, or to the nearest 15 with <paramref name="snap"/>.</summary>
- private void SetAngle(Source source, Point view, bool snap)
+ /// <summary>The angle of a composite source's array or a part, in degrees.</summary>
+ private static double AngleOf(object item) => item switch
{
- Point centre = ToView(source.X, source.Y);
+ Source source => source.Array?.Angle ?? 0.0,
+ OpticalPart part => part.Angle,
+ _ => 0.0,
+ };
+
+ /// <summary>Turns the array or part so its axis points from its centre to <paramref name="view"/>: to whole degrees, or to the nearest 15 with <paramref name="snap"/>.</summary>
+ private void SetAngle(object item, Point view, bool snap)
+ {
+ (int x, int y) = item switch { Source source => (source.X, source.Y), OpticalPart part => (part.X, part.Y), _ => (0, 0) };
+ Point centre = ToView(x, y);
double degrees = Math.Atan2(-(view.Y - centre.Y), view.X - centre.X) * 180.0 / Math.PI;
double unit = snap ? 15.0 : 1.0;
- SetAngle(source, Math.Round(degrees / unit) * unit);
+ SetAngle(item, Math.Round(degrees / unit) * unit);
}
- /// <summary>Sets the array's angle, kept in (-180, 180].</summary>
- private static void SetAngle(Source source, double degrees)
+ /// <summary>Sets the array's or part's angle, kept in (-180, 180].</summary>
+ private static void SetAngle(object item, double degrees)
{
- if (source.Array is { } array)
+ switch (item)
{
- array.Angle = degrees;
- array.Normalize();
+ case Source { Array: { } array }:
+ array.Angle = degrees;
+ array.Normalize();
+ break;
+ case OpticalPart part:
+ part.Angle = degrees;
+ part.Normalize();
+ break;
}
}
private static (int X, int Y) PointOf(MarkerThumb thumb) => (thumb.Item, thumb.Role) switch
{
(Source source, _) => (source.X, source.Y),
+ (OpticalPart part, _) => (part.X, part.Y),
(Probe probe, MarkerRole.ProbeB) => (probe.BX, probe.BY),
(Probe probe, _) => (probe.AX, probe.AY),
_ => (0, 0),
@@ -432,6 +473,10 @@ public sealed class SceneOverlay : Panel
source.X = x;
source.Y = y;
break;
+ case (OpticalPart part, _):
+ part.X = x;
+ part.Y = y;
+ break;
case (Probe probe, MarkerRole.ProbeB):
probe.BX = x;
probe.BY = y;
@@ -472,11 +517,11 @@ public sealed class SceneOverlay : Panel
foreach (MarkerThumb thumb in Children)
{
(int x, int y) = PointOf(thumb);
- Point centre = thumb.Role == MarkerRole.SourceAngle ? AnglePoint((Source)thumb.Item, finalSize) : ToView(x, y, finalSize);
+ Point centre = thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle ? AnglePoint(thumb.Item, 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 == MarkerRole.SourceAngle)
+ if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle)
{
// 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
@@ -536,19 +581,26 @@ public sealed class SceneOverlay : Panel
dc.DrawEllipse(dots, halo, ToView(element.X, element.Y), ElementDotRadius, ElementDotRadius);
}
}
+ if (selected is OpticalPart selectedPart && project.Parts.Contains(selectedPart))
+ {
+ // the part's axis from the centre to its rotation handle, the lever, while it is selected
+ Point axisEnd = AnglePoint(selectedPart, RenderSize);
+ dc.DrawLine(new Pen(HaloBrush, 3.0), ToView(selectedPart.X, selectedPart.Y), axisEnd);
+ dc.DrawLine(new Pen(AccentBrush, 1.0) { DashStyle = DashStyles.Dot }, ToView(selectedPart.X, selectedPart.Y), axisEnd);
+ }
dc.Pop();
foreach (MarkerThumb thumb in Children.OfType<MarkerThumb>().OrderBy(thumb => thumb.IsSelectedMarker))
{
- if (thumb.Role is MarkerRole.ProbeB or MarkerRole.SourceAngle)
+ if (thumb.Role is MarkerRole.ProbeB or MarkerRole.SourceAngle or MarkerRole.PartAngle)
{
continue;
}
(int x, int y) = PointOf(thumb);
Point centre = ToView(x, y);
- string name = thumb.Item is Source source ? source.Name : ((Probe)thumb.Item).Name;
+ string name = thumb.Item switch { Source source => source.Name, OpticalPart part => part.Name, _ => ((Probe)thumb.Item).Name };
var label = new FormattedText(name, CultureInfo.CurrentUICulture, FlowDirection.LeftToRight, LabelTypeface, 11, thumb.IsSelectedMarker ? AccentBrush : LabelBrush, VisualTreeHelper.GetDpi(this).PixelsPerDip);
- // beside the point; below it for a composite source, whose rotation handle sits beside it at 0 degrees
- bool below = thumb.Item is Source { Array: not null };
+ // beside the point; below it for a composite source or a part, whose rotation handle sits beside it at 0 degrees
+ bool below = thumb.Item is Source { Array: not null } or OpticalPart;
double lx = below ? Math.Clamp(centre.X - label.Width / 2, 0, Math.Max(0, ActualWidth - label.Width)) : Math.Min(centre.X + LabelOffset, Math.Max(0, ActualWidth - label.Width));
double ly = below ? Math.Min(centre.Y + LabelOffset, Math.Max(0, ActualHeight - label.Height)) : Math.Clamp(centre.Y - label.Height / 2, 0, Math.Max(0, ActualHeight - label.Height));
var origin = new Point(lx, ly);
@@ -578,10 +630,10 @@ public sealed class SceneOverlay : Panel
{
return;
}
- if (thumb.Role == MarkerRole.SourceAngle)
+ if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle)
{
// the handle follows the mouse around the centre; Shift snaps to 15 degrees
- SetAngle((Source)thumb.Item, Mouse.GetPosition(this), (Keyboard.Modifiers & ModifierKeys.Shift) != 0);
+ SetAngle(thumb.Item, Mouse.GetPosition(this), (Keyboard.Modifiers & ModifierKeys.Shift) != 0);
return;
}
thumb.DragDeltaX += e.HorizontalChange / scale;
@@ -595,7 +647,7 @@ public sealed class SceneOverlay : Panel
return brush;
}
- /// <summary>The arrow keys move the focused handle by one canvas pixel, ten with Shift; on a rotation handle they turn the array by a degree (Right and Up counter-clockwise), ten with Shift.</summary>
+ /// <summary>The arrow keys move the focused handle by one canvas pixel, ten with Shift; on a rotation handle they turn the array or part by a degree (Right and Up counter-clockwise), ten with Shift.</summary>
protected override void OnKeyDown(KeyEventArgs e)
{
base.OnKeyDown(e);
@@ -604,12 +656,12 @@ public sealed class SceneOverlay : Panel
return;
}
int step = (Keyboard.Modifiers & ModifierKeys.Shift) != 0 ? KeyStepFast : KeyStep;
- if (thumb.Role == MarkerRole.SourceAngle)
+ if (thumb.Role is MarkerRole.SourceAngle or MarkerRole.PartAngle)
{
int turn = e.Key switch { Key.Right or Key.Up => step, Key.Left or Key.Down => -step, _ => 0 };
- if (turn != 0 && thumb.Item is Source turned)
+ if (turn != 0)
{
- SetAngle(turned, (turned.Array?.Angle ?? 0.0) + turn);
+ SetAngle(thumb.Item, AngleOf(thumb.Item) + turn);
e.Handled = true;
}
return;
diff --git a/WaveDudeNext.WPF/Converters/TreeIdConverter.cs b/WaveDudeNext.WPF/Converters/TreeIdConverter.cs
index 2b4b04e..3bcd616 100644
--- a/WaveDudeNext.WPF/Converters/TreeIdConverter.cs
+++ b/WaveDudeNext.WPF/Converters/TreeIdConverter.cs
@@ -23,7 +23,7 @@ using WaveDudeNext.Rendering;
namespace WaveDudeNext.WPF.Converters;
/// <summary>
-/// The automation id of a Project tree row from its node: "Tree:" plus the item's name (sources, probes,
+/// The automation id of a Project tree row from its node: "Tree:" plus the item's name (sources, parts, probes,
/// colour schemes), a folder's label, or the type name of the fixed nodes ("Tree:Scene"), so a harness
/// can reach a row with Tab and act on it.
/// </summary>
@@ -32,6 +32,7 @@ public sealed class TreeIdConverter : IValueConverter
public object Convert(object? value, Type targetType, object? parameter, CultureInfo culture) => "Tree:" + value switch
{
Source source => source.Name,
+ OpticalPart part => part.Name,
Probe probe => probe.Name,
ColorScheme scheme => scheme.Name,
NamedCollection folder => folder.Key,
diff --git a/WaveDudeNext.WPF/Converters/TriangleApexConverter.cs b/WaveDudeNext.WPF/Converters/TriangleApexConverter.cs
new file mode 100644
index 0000000..5433e73
--- /dev/null
+++ b/WaveDudeNext.WPF/Converters/TriangleApexConverter.cs
@@ -0,0 +1,45 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Globalization;
+using System.Windows.Data;
+using WaveDudeNext.Model;
+
+namespace WaveDudeNext.WPF.Converters;
+
+/// <summary>
+/// The apex angle of a triangle part as text ("60°"): 180° minus the two base angles the type gives, computed on a
+/// throw-away part so the model's own rule (<see cref="TrianglePart.EffectiveAngles"/>) decides. Inputs: the type, angle A,
+/// angle B; re-evaluated on each edit.
+/// </summary>
+public sealed class TriangleApexConverter : IMultiValueConverter
+{
+ /// <inheritdoc/>
+ public object? Convert(object?[] values, Type targetType, object? parameter, CultureInfo culture)
+ {
+ if (values.Length < 3 || values[0] is not TriangleType type || values[1] is not double a || values[2] is not double b)
+ {
+ return null;
+ }
+ var probe = new TrianglePart { Type = type, AngleA = a, AngleB = b };
+ return string.Format(culture, "{0:0.#}°", probe.ApexAngle);
+ }
+
+ /// <inheritdoc/>
+ public object[] ConvertBack(object? value, Type[] targetTypes, object? parameter, CultureInfo culture) =>
+ throw new NotSupportedException();
+}
diff --git a/WaveDudeNext.WPF/MainWindow.Live.cs b/WaveDudeNext.WPF/MainWindow.Live.cs
index 870400f..a6d1fe1 100644
--- a/WaveDudeNext.WPF/MainWindow.Live.cs
+++ b/WaveDudeNext.WPF/MainWindow.Live.cs
@@ -20,6 +20,7 @@ using System.IO;
using System.Windows;
using System.Windows.Threading;
using WaveDudeNext.Model;
+using WaveDudeNext.Parts;
using WaveDudeNext.Rendering;
using WaveDudeNext.Runs;
using WaveDudeNext.WPF.Properties;
@@ -77,6 +78,9 @@ public partial class MainWindow
private (RunSpec Spec, int Frame)? _scratchRequested;
private (string Path, DateTime Written, ScenePixels Pixels)? _imageCache;
private (byte[] Data, ScenePixels Pixels)? _embeddedCache;
+ private (ScenePixels? Source, int PartsVersion, int Width, int Height, double Background, ScenePixels? Composed)? _composedCache;
+ /// <summary>Bumped on every optical part change, so <see cref="LoadSceneImage"/> paints again only then.</summary>
+ private int _partsVersion;
/// <summary>Whether the project was edited in a way that changes the simulation since the current run started.</summary>
public bool IsRunStale
@@ -137,6 +141,7 @@ public partial class MainWindow
_watcher = null;
_imageCache = null;
_embeddedCache = null;
+ _composedCache = null;
// the new project's own schemes and scene image; the pane does not exist yet when the constructor sets the first project
Dispatcher.InvokeAsync(() =>
{
@@ -197,7 +202,12 @@ public partial class MainWindow
Logger.Debug("Edited ({Item}.{Property}): the run is stale", change.Item, change.Property ?? "list");
}
}
- if (change.Item is Scene)
+ if (IsPartChange(change))
+ {
+ // the parts are painted into the scene pixels: paint again, so the outline follows the edit at once
+ _partsVersion++;
+ }
+ if (change.Item is Scene || IsPartChange(change))
{
UpdateScenePixels();
}
@@ -224,6 +234,11 @@ 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>
+ private static bool IsPartChange(ProjectChange change) =>
+ change.Item is OpticalPart or PartPoint or ObservableCollection<OpticalPart> or ObservableCollection<PartPoint>
+ || change.Item is Project && change.Property == nameof(Project.Parts);
+
/// <summary>
/// Whether an active probe has no recording in the current run: one just switched on, or one just added. A
/// scratch frame fills its graph for one position only, and a scrub or playback showed it empty until a run
@@ -423,7 +438,7 @@ public partial class MainWindow
}
}
- /// <summary>Hands the preview the decoded scene image (null for a canvas, or when it cannot be read: that is logged once the run reports it).</summary>
+ /// <summary>Hands the preview the scene pixels (null for a canvas without parts, or when the image cannot be read: that is logged once the run reports it).</summary>
private void UpdateScenePixels()
{
if (previewPane == null)
@@ -441,8 +456,28 @@ public partial class MainWindow
}
}
- /// <summary>The decoded scene image for an image scene, decoded once per file version; null for a blank canvas.</summary>
+ /// <summary>
+ /// The scene as the engines, the outline and the export see it: the decoded image (decoded once per file version)
+ /// with the enabled optical parts painted in, or the parts on a blank canvas; null for a canvas without parts.
+ /// Composed once per (image, parts version, canvas size, background index): an unchanged scene returns the same
+ /// reference, which <see cref="RunSpec.SameSceneAs"/> compares, so the scratch runner keeps its engine.
+ /// </summary>
private ScenePixels? LoadSceneImage()
+ {
+ ScenePixels? source = DecodeSceneImage();
+ Scene scene = Project.Scene;
+ if (_composedCache is { } cached && ReferenceEquals(cached.Source, source) && cached.PartsVersion == _partsVersion
+ && cached.Width == scene.Width && cached.Height == scene.Height && cached.Background == scene.RefractiveIndex)
+ {
+ return cached.Composed;
+ }
+ ScenePixels? composed = PartPainter.Paint(source, scene.Width, scene.Height, scene.RefractiveIndex, Project.Parts);
+ _composedCache = (source, _partsVersion, scene.Width, scene.Height, scene.RefractiveIndex, composed);
+ return composed;
+ }
+
+ /// <summary>The decoded scene image for an image scene, decoded once per file version; null for a blank canvas.</summary>
+ private ScenePixels? DecodeSceneImage()
{
if (Project.Scene.Mode != SceneMode.Image)
{
diff --git a/WaveDudeNext.WPF/MainWindow.Project.cs b/WaveDudeNext.WPF/MainWindow.Project.cs
index e2d5923..27bf2f5 100644
--- a/WaveDudeNext.WPF/MainWindow.Project.cs
+++ b/WaveDudeNext.WPF/MainWindow.Project.cs
@@ -17,6 +17,8 @@
using System.Collections;
using System.IO;
+using System.Windows;
+using System.Windows.Controls.Primitives;
using System.Windows.Input;
using Microsoft.Win32;
using WaveDudeNext.Model;
@@ -39,9 +41,11 @@ public partial class MainWindow
private IList? ListOf(object? node) => node switch
{
NamedCollection folder when ReferenceEquals(folder.Items, Project.Sources) => Project.Sources,
+ NamedCollection folder when ReferenceEquals(folder.Items, Project.Parts) => Project.Parts,
NamedCollection folder when ReferenceEquals(folder.Items, Project.Probes) => Project.Probes,
NamedCollection folder when ReferenceEquals(folder.Items, Project.ColorSchemes) => Project.ColorSchemes,
Source => Project.Sources,
+ OpticalPart => Project.Parts,
Probe => Project.Probes,
ColorScheme => Project.ColorSchemes,
_ => null,
@@ -49,6 +53,34 @@ public partial class MainWindow
private void OnAddSource(object sender, ExecutedRoutedEventArgs e) => Added(Project.AddSource());
+ /// <summary>
+ /// Add part: with a <see cref="PartKind"/> as parameter (the menu entries) the part is appended; without one (the
+ /// "+ Part" button, the Parts folder's plus) the invoking element's context menu, the menu of kinds, opens under it,
+ /// so the kind is chosen there (keyboard: Space opens it, the arrows walk it, Enter picks).
+ /// </summary>
+ private void OnAddPart(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Parameter is PartKind kind)
+ {
+ Added(Project.AddPart(kind));
+ }
+ else
+ {
+ OpenPartMenu(e.OriginalSource);
+ }
+ }
+
+ /// <summary>Opens the menu of part kinds attached to <paramref name="element"/> (its context menu), placed under it.</summary>
+ private static void OpenPartMenu(object? element)
+ {
+ if (element is FrameworkElement { ContextMenu: { } menu } anchor)
+ {
+ menu.PlacementTarget = anchor;
+ menu.Placement = PlacementMode.Bottom;
+ menu.IsOpen = true;
+ }
+ }
+
private void OnAddProbe(object sender, ExecutedRoutedEventArgs e) => Added(Project.AddProbe());
private void CanAdd(object sender, CanExecuteRoutedEventArgs e) =>
@@ -61,6 +93,10 @@ public partial class MainWindow
{
Added(Project.AddSource());
}
+ else if (ReferenceEquals(list, Project.Parts))
+ {
+ OpenPartMenu(e.OriginalSource);
+ }
else if (ReferenceEquals(list, Project.Probes))
{
Added(Project.AddProbe());
@@ -72,12 +108,12 @@ public partial class MainWindow
}
private void CanEditItem(object sender, CanExecuteRoutedEventArgs e) =>
- e.CanExecute = Target(e.Parameter) is Source or Probe or ColorScheme;
+ e.CanExecute = Target(e.Parameter) is Source or OpticalPart or Probe or ColorScheme;
private void CanToggleEnabled(object sender, CanExecuteRoutedEventArgs e) =>
- e.CanExecute = Target(e.Parameter) is Source or Probe;
+ e.CanExecute = Target(e.Parameter) is Source or OpticalPart or Probe;
- /// <summary>The tree's check boxes by keyboard: Space on a selected source or probe flips it (the author's point 11, 2026-10-13).</summary>
+ /// <summary>The tree's check boxes by keyboard: Space on a selected source, part or probe flips it (the author's point 11, 2026-10-13).</summary>
private void OnToggleEnabled(object sender, ExecutedRoutedEventArgs e)
{
switch (Target(e.Parameter))
@@ -85,6 +121,9 @@ public partial class MainWindow
case Source source:
source.Enabled = !source.Enabled;
break;
+ case OpticalPart part:
+ part.Enabled = !part.Enabled;
+ break;
case Probe probe:
probe.Active = !probe.Active;
break;
@@ -98,6 +137,9 @@ public partial class MainWindow
case Source source:
Added(Project.Duplicate(source));
break;
+ case OpticalPart part:
+ Added(Project.Duplicate(part));
+ break;
case Probe probe:
Added(Project.Duplicate(probe));
break;
@@ -121,6 +163,9 @@ public partial class MainWindow
case Source source:
Project.Remove(source);
break;
+ case OpticalPart part:
+ Project.Remove(part);
+ break;
case Probe probe:
Project.Remove(probe);
break;
@@ -142,13 +187,13 @@ public partial class MainWindow
private void CanMoveUp(object sender, CanExecuteRoutedEventArgs e)
{
object? item = Target(e.Parameter);
- e.CanExecute = ListOf(item) is { } list && item is Source or Probe or ColorScheme && list.IndexOf(item) > 0;
+ e.CanExecute = ListOf(item) is { } list && item is Source or OpticalPart or Probe or ColorScheme && list.IndexOf(item) > 0;
}
private void CanMoveDown(object sender, CanExecuteRoutedEventArgs e)
{
object? item = Target(e.Parameter);
- e.CanExecute = ListOf(item) is { } list && item is Source or Probe or ColorScheme && list.IndexOf(item) < list.Count - 1;
+ e.CanExecute = ListOf(item) is { } list && item is Source or OpticalPart or Probe or ColorScheme && list.IndexOf(item) < list.Count - 1;
}
private void OnMoveUp(object sender, ExecutedRoutedEventArgs e) => MoveBy(Target(e.Parameter), -1);
@@ -166,6 +211,7 @@ public partial class MainWindow
bool moved = item switch
{
Source source => Project.Move(source, index),
+ OpticalPart part => Project.Move(part, index),
Probe probe => Project.Move(probe, index),
ColorScheme scheme => Project.Move(scheme, index),
_ => false,
diff --git a/WaveDudeNext.WPF/MainWindow.xaml b/WaveDudeNext.WPF/MainWindow.xaml
index cd5971c..d698112 100644
--- a/WaveDudeNext.WPF/MainWindow.xaml
+++ b/WaveDudeNext.WPF/MainWindow.xaml
@@ -175,6 +175,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<!-- project structure; handlers in MainWindow.Project.cs -->
<CommandBinding Command="{x:Static commands:ProjectCommands.AddSource}" Executed="OnAddSource" />
+ <CommandBinding Command="{x:Static commands:ProjectCommands.AddPart}" Executed="OnAddPart" />
<CommandBinding Command="{x:Static commands:ProjectCommands.AddProbe}" Executed="OnAddProbe" />
<CommandBinding Command="{x:Static commands:ProjectCommands.Add}" CanExecute="CanAdd" Executed="OnAdd" />
<CommandBinding Command="{x:Static commands:ProjectCommands.Duplicate}" CanExecute="CanEditItem" Executed="OnDuplicate" />
diff --git a/WaveDudeNext.WPF/Panes/PreviewPane.xaml b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
index ec624b7..776683a 100644
--- a/WaveDudeNext.WPF/Panes/PreviewPane.xaml
+++ b/WaveDudeNext.WPF/Panes/PreviewPane.xaml
@@ -206,6 +206,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</Setter.Value>
</Setter>
</Style>
+ <!-- an optical part: the source's circular crosshair with an inner ring instead of the dot (a lens-shaped glyph read as squashed, 2026-10-18) -->
+ <StreamGeometry x:Key="PartGlyph">M4,10 A6,6 0 1 1 16,10 A6,6 0 1 1 4,10 M7.5,10 A2.5,2.5 0 1 1 12.5,10 A2.5,2.5 0 1 1 7.5,10 M10,0 L10,2.5 M10,17.5 L10,20 M0,10 L2.5,10 M17.5,10 L20,10</StreamGeometry>
+ <Style x:Key="PartMarker" TargetType="{x:Type controls:MarkerThumb}" BasedOn="{StaticResource MarkerBase}">
+ <Setter Property="Template">
+ <Setter.Value>
+ <ControlTemplate TargetType="{x:Type controls:MarkerThumb}">
+ <Grid Background="Transparent">
+ <Ellipse Width="12" Height="12" Fill="{TemplateBinding Background}" />
+ <Path Data="{StaticResource PartGlyph}" Stroke="Black" StrokeThickness="{TemplateBinding HaloThickness}" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" Opacity="0.75" />
+ <Path Data="{StaticResource PartGlyph}" Stroke="{TemplateBinding BorderBrush}" StrokeThickness="{TemplateBinding StrokeThickness}" StrokeStartLineCap="Round" StrokeEndLineCap="Round" StrokeLineJoin="Round" />
+ </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" />
@@ -487,7 +502,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}" ProbeStyle="{StaticResource ProbeMarker}" AngleStyle="{StaticResource AngleMarker}"
+ <controls:SceneOverlay SourceStyle="{StaticResource SourceMarker}" PartStyle="{StaticResource PartMarker}" 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/Panes/ProjectTree.xaml b/WaveDudeNext.WPF/Panes/ProjectTree.xaml
index ce4cea2..fc0003b 100644
--- a/WaveDudeNext.WPF/Panes/ProjectTree.xaml
+++ b/WaveDudeNext.WPF/Panes/ProjectTree.xaml
@@ -80,6 +80,25 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<Setter Property="MinHeight" Value="20" />
<Setter Property="Margin" Value="1,0" />
</Style>
+ <!-- the menu of part kinds, the optics first and the plain shapes after a separator: the "+ Part" button and the Parts
+ folder's plus open it (AddPart without a parameter opens the invoking element's context menu; each entry adds its
+ kind). One instance per button -->
+ <ContextMenu x:Key="PartKindMenu" x:Shared="False">
+ <ContextMenu.Resources>
+ <Style TargetType="{x:Type MenuItem}" BasedOn="{StaticResource {x:Type MenuItem}}">
+ <Setter Property="CommandTarget" Value="{Binding PlacementTarget, RelativeSource={RelativeSource AncestorType={x:Type ContextMenu}}}" />
+ </Style>
+ </ContextMenu.Resources>
+ <MenuItem Header="{DynamicResource MenuAddLens}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Lens}" AutomationProperties.AutomationId="AddPart:Lens" />
+ <MenuItem Header="{DynamicResource MenuAddFiber}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Fiber}" AutomationProperties.AutomationId="AddPart:Fiber" />
+ <MenuItem Header="{DynamicResource MenuAddBraggReflector}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.BraggReflector}" AutomationProperties.AutomationId="AddPart:BraggReflector" />
+ <MenuItem Header="{DynamicResource MenuAddGrinLens}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.GrinLens}" AutomationProperties.AutomationId="AddPart:GrinLens" />
+ <Separator />
+ <MenuItem Header="{DynamicResource MenuAddPolygon}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Polygon}" AutomationProperties.AutomationId="AddPart:Polygon" />
+ <MenuItem Header="{DynamicResource MenuAddRectangle}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Rectangle}" AutomationProperties.AutomationId="AddPart:Rectangle" />
+ <MenuItem Header="{DynamicResource MenuAddTriangle}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Triangle}" AutomationProperties.AutomationId="AddPart:Triangle" />
+ <MenuItem Header="{DynamicResource MenuAddOutline}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Outline}" AutomationProperties.AutomationId="AddPart:Outline" />
+ </ContextMenu>
</UserControl.Resources>
<DockPanel>
@@ -89,6 +108,8 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<StackPanel Orientation="Horizontal">
<Button Style="{StaticResource TextButton}" Content="{DynamicResource ToolAddSource}" ToolTip="{DynamicResource TipAddSource}" AutomationProperties.Name="{DynamicResource TipAddSource}"
Command="{x:Static commands:ProjectCommands.AddSource}" AutomationProperties.AutomationId="ToolAddSource" />
+ <Button Style="{StaticResource TextButton}" Content="{DynamicResource ToolAddPart}" ToolTip="{DynamicResource TipAddPart}" AutomationProperties.Name="{DynamicResource TipAddPart}"
+ Command="{x:Static commands:ProjectCommands.AddPart}" ContextMenu="{StaticResource PartKindMenu}" AutomationProperties.AutomationId="ToolAddPart" />
<Button Style="{StaticResource TextButton}" Content="{DynamicResource ToolAddProbe}" ToolTip="{DynamicResource TipAddProbe}" AutomationProperties.Name="{DynamicResource TipAddProbe}"
Command="{x:Static commands:ProjectCommands.AddProbe}" AutomationProperties.AutomationId="ToolAddProbe" />
<Rectangle Width="1" Margin="4,2" Fill="{DynamicResource ToolWindowBorder}" />
@@ -134,6 +155,17 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</Style>
</ContextMenu.Resources>
<MenuItem Header="{DynamicResource MenuProjectAddSource}" Command="{x:Static commands:ProjectCommands.AddSource}" />
+ <MenuItem Header="{DynamicResource MenuProjectAddPart}">
+ <MenuItem Header="{DynamicResource MenuAddLens}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Lens}" />
+ <MenuItem Header="{DynamicResource MenuAddFiber}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Fiber}" />
+ <MenuItem Header="{DynamicResource MenuAddBraggReflector}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.BraggReflector}" />
+ <MenuItem Header="{DynamicResource MenuAddGrinLens}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.GrinLens}" />
+ <Separator />
+ <MenuItem Header="{DynamicResource MenuAddPolygon}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Polygon}" />
+ <MenuItem Header="{DynamicResource MenuAddRectangle}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Rectangle}" />
+ <MenuItem Header="{DynamicResource MenuAddTriangle}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Triangle}" />
+ <MenuItem Header="{DynamicResource MenuAddOutline}" Command="{x:Static commands:ProjectCommands.AddPart}" CommandParameter="{x:Static model:PartKind.Outline}" />
+ </MenuItem>
<MenuItem Header="{DynamicResource MenuProjectAddProbe}" Command="{x:Static commands:ProjectCommands.AddProbe}" />
<Separator />
<MenuItem Header="{DynamicResource MenuProjectToggleEnabled}" Command="{x:Static commands:ProjectCommands.ToggleEnabled}" InputGestureText="Space" />
@@ -152,11 +184,12 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<!-- one template per model type; children come from the bound properties, lists become folders -->
<HierarchicalDataTemplate DataType="{x:Type model:Project}">
<HierarchicalDataTemplate.ItemsSource>
- <MultiBinding Converter="{StaticResource NamedCollections}" ConverterParameter=",,,TreeSources,TreeProbes,TreeColorSchemes">
+ <MultiBinding Converter="{StaticResource NamedCollections}" ConverterParameter=",,,TreeSources,TreeParts,TreeProbes,TreeColorSchemes">
<Binding Path="Scene" />
<Binding Path="Simulation" />
<Binding Path="Display" />
<Binding Path="Sources" />
+ <Binding Path="Parts" />
<Binding Path="Probes" />
<Binding Path="ColorSchemes" />
</MultiBinding>
@@ -174,11 +207,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<TextBlock Text="{DynamicResource TreeDisplay}" />
</DataTemplate>
- <!-- folder row: name and an add button -->
+ <!-- folder row: name and an add button; the Parts folder's button carries the menu of kinds, which Add opens -->
<HierarchicalDataTemplate DataType="{x:Type converters:NamedCollection}" ItemsSource="{Binding Items}">
<DockPanel>
- <Button DockPanel.Dock="Right" Style="{StaticResource GlyphButton}" Content="{StaticResource PlusGeometry}"
- ToolTip="{DynamicResource TipAdd}" AutomationProperties.Name="{DynamicResource TipAdd}" Command="{x:Static commands:ProjectCommands.Add}" CommandParameter="{Binding}" />
+ <Button DockPanel.Dock="Right" Content="{StaticResource PlusGeometry}"
+ ToolTip="{DynamicResource TipAdd}" AutomationProperties.Name="{DynamicResource TipAdd}" Command="{x:Static commands:ProjectCommands.Add}" CommandParameter="{Binding}">
+ <Button.Style>
+ <Style TargetType="{x:Type Button}" BasedOn="{StaticResource GlyphButton}">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Key}" Value="TreeParts">
+ <Setter Property="ContextMenu" Value="{StaticResource PartKindMenu}" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </Button.Style>
+ </Button>
<TextBlock Text="{Binding Label}" VerticalAlignment="Center" />
</DockPanel>
</HierarchicalDataTemplate>
@@ -209,6 +252,31 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
</TextBlock>
</DockPanel>
</DataTemplate>
+ <!-- an optical part: like a source, the enabled check box, the name, move and remove -->
+ <DataTemplate DataType="{x:Type model:OpticalPart}">
+ <DockPanel>
+ <Button DockPanel.Dock="Right" Style="{StaticResource GlyphButton}" Content="{StaticResource MinusGeometry}"
+ ToolTip="{DynamicResource TipRemove}" AutomationProperties.Name="{DynamicResource TipRemove}" Command="{x:Static commands:ProjectCommands.Remove}" CommandParameter="{Binding}" />
+ <Button DockPanel.Dock="Right" Style="{StaticResource GlyphButton}" Content="{StaticResource ChevronDownGeometry}"
+ ToolTip="{DynamicResource TipMoveDown}" AutomationProperties.Name="{DynamicResource TipMoveDown}" Command="{x:Static commands:ProjectCommands.MoveDown}" CommandParameter="{Binding}" />
+ <Button DockPanel.Dock="Right" Style="{StaticResource GlyphButton}" Content="{StaticResource ChevronUpGeometry}"
+ ToolTip="{DynamicResource TipMoveUp}" AutomationProperties.Name="{DynamicResource TipMoveUp}" Command="{x:Static commands:ProjectCommands.MoveUp}" CommandParameter="{Binding}" />
+ <CheckBox DockPanel.Dock="Left" Focusable="False" IsTabStop="False" MinHeight="0" Margin="0,0,4,0" VerticalAlignment="Center"
+ IsChecked="{Binding Enabled}" ToolTip="{DynamicResource TipPartEnabled}"
+ AutomationProperties.Name="{DynamicResource TipPartEnabled}" AutomationProperties.AutomationId="{Binding Name, StringFormat='Enabled:{0}'}" />
+ <TextBlock Text="{Binding Name}" VerticalAlignment="Center">
+ <TextBlock.Style>
+ <Style TargetType="{x:Type TextBlock}">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Enabled}" Value="False">
+ <Setter Property="Foreground" Value="{DynamicResource GrayText}" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </TextBlock.Style>
+ </TextBlock>
+ </DockPanel>
+ </DataTemplate>
<!-- a project colour scheme: its gradient and name -->
<DataTemplate DataType="{x:Type rendering:ColorScheme}">
<DockPanel>
diff --git a/WaveDudeNext.WPF/Panes/ProjectTree.xaml.cs b/WaveDudeNext.WPF/Panes/ProjectTree.xaml.cs
index 48fd109..8140415 100644
--- a/WaveDudeNext.WPF/Panes/ProjectTree.xaml.cs
+++ b/WaveDudeNext.WPF/Panes/ProjectTree.xaml.cs
@@ -30,9 +30,9 @@ using WaveDudeNext.WPF.Converters;
namespace WaveDudeNext.WPF.Panes;
/// <summary>
-/// The project tree: the <see cref="Project"/> as root with its sections, sources and probes
+/// The project tree: the <see cref="Project"/> as root with its sections, sources, optical parts and probes
/// beneath. Nodes are the model objects themselves; the templates in the XAML decide how each
-/// type is shown and which properties form its children. Sources and probes can be reordered
+/// type is shown and which properties form its children. Sources, parts and probes can be reordered
/// by dragging a row onto a sibling (line above or below) or onto their folder (append).
/// </summary>
public partial class ProjectTree : UserControl
@@ -140,7 +140,7 @@ public partial class ProjectTree : UserControl
{
return; // row buttons are clicks, not drags
}
- if (FindAncestor<TreeViewItem>(origin) is { DataContext: Source or Probe or ColorScheme } row)
+ if (FindAncestor<TreeViewItem>(origin) is { DataContext: Source or OpticalPart or Probe or ColorScheme } row)
{
_dragCandidate = row.DataContext;
_dragStart = e.GetPosition(tree);
@@ -204,6 +204,7 @@ public partial class ProjectTree : UserControl
bool moved = item switch
{
Source source => Project.Move(source, target.Index),
+ OpticalPart part => Project.Move(part, target.Index),
Probe probe => Project.Move(probe, target.Index),
_ => false,
};
@@ -259,6 +260,7 @@ public partial class ProjectTree : UserControl
private IList? ListOf(object? node) => node switch
{
Source => Project?.Sources,
+ OpticalPart => Project?.Parts,
Probe => Project?.Probes,
ColorScheme => Project?.ColorSchemes,
_ => null,
diff --git a/WaveDudeNext.WPF/Panes/PropertiesPane.xaml b/WaveDudeNext.WPF/Panes/PropertiesPane.xaml
index 53a4a3a..6a14b92 100644
--- a/WaveDudeNext.WPF/Panes/PropertiesPane.xaml
+++ b/WaveDudeNext.WPF/Panes/PropertiesPane.xaml
@@ -43,6 +43,30 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<DataTemplate DataType="{x:Type model:Source}">
<views:SourceView />
</DataTemplate>
+ <DataTemplate DataType="{x:Type model:LensPart}">
+ <views:LensPartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:PolygonPart}">
+ <views:PolygonPartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:RectanglePart}">
+ <views:RectanglePartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:TrianglePart}">
+ <views:TrianglePartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:OutlinePart}">
+ <views:OutlinePartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:FiberPart}">
+ <views:FiberPartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:BraggReflectorPart}">
+ <views:BraggReflectorPartView />
+ </DataTemplate>
+ <DataTemplate DataType="{x:Type model:GrinLensPart}">
+ <views:GrinLensPartView />
+ </DataTemplate>
<DataTemplate DataType="{x:Type model:Probe}">
<views:ProbeView />
</DataTemplate>
diff --git a/WaveDudeNext.WPF/Strings/Strings.DE.xaml b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
index 76a755e..a3528b5 100644
--- a/WaveDudeNext.WPF/Strings/Strings.DE.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.DE.xaml
@@ -108,6 +108,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectAddSource">_Quelle hinzufügen</s:String>
<s:String x:Key="MenuProjectAddProbe">_Sonde hinzufügen</s:String>
+ <s:String x:Key="MenuProjectAddPart">_Bauteil hinzufügen</s:String>
+ <s:String x:Key="MenuAddLens">_Linse oder Spiegel</s:String>
+ <s:String x:Key="MenuAddPolygon">_Polygon</s:String>
+ <s:String x:Key="MenuAddRectangle">_Rechteck</s:String>
+ <s:String x:Key="MenuAddTriangle">_Dreieck</s:String>
+ <s:String x:Key="MenuAddOutline">_Umriss</s:String>
+ <s:String x:Key="MenuAddFiber">_Faser</s:String>
+ <s:String x:Key="MenuAddBraggReflector">_Bragg-Reflektor</s:String>
+ <s:String x:Key="MenuAddGrinLens">_GRIN-Linse</s:String>
<s:String x:Key="MenuProjectToggleEnabled">_Aktiv</s:String>
<s:String x:Key="MenuProjectDuplicate">_Duplizieren</s:String>
<s:String x:Key="MenuProjectRemove">_Entfernen</s:String>
@@ -115,11 +124,14 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectMoveDown">Nach _unten</s:String>
<s:String x:Key="ToolAddSource">+ Quelle</s:String>
<s:String x:Key="ToolAddProbe">+ Sonde</s:String>
+ <s:String x:Key="ToolAddPart">+ Bauteil</s:String>
<s:String x:Key="TipAddSource">Quelle hinzufügen (am Ende angefügt)</s:String>
<s:String x:Key="TipAddProbe">Sonde hinzufügen (am Ende angefügt)</s:String>
+ <s:String x:Key="TipAddPart">Optisches Bauteil hinzufügen (Menü der Arten; am Ende angefügt)</s:String>
<s:String x:Key="TipAdd">Eintrag zu diesem Ordner hinzufügen</s:String>
<s:String x:Key="TipRemove">Entfernen (Entf)</s:String>
<s:String x:Key="TipSourceEnabled">Quelle in Läufe einbeziehen (Leertaste auf der Zeile schaltet um)</s:String>
+ <s:String x:Key="TipPartEnabled">Bauteil in die Szene zeichnen (Leertaste auf der Zeile schaltet um)</s:String>
<s:String x:Key="TipProbeActive">Diese Sonde abtasten (Leertaste auf der Zeile schaltet um)</s:String>
<s:String x:Key="TipMoveUp">Nach oben (Alt+Pfeil hoch); zum Umordnen ziehen</s:String>
<s:String x:Key="TipMoveDown">Nach unten (Alt+Pfeil runter); zum Umordnen ziehen</s:String>
@@ -215,6 +227,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TreeSimulation">Simulation</s:String>
<s:String x:Key="TreeDisplay">Darstellung</s:String>
<s:String x:Key="TreeSources">Quellen</s:String>
+ <s:String x:Key="TreeParts">Bauteile</s:String>
<s:String x:Key="TreeProbes">Sonden</s:String>
<s:String x:Key="TreeColorSchemes">Farbschemata</s:String>
@@ -236,6 +249,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipWavelength">Geschätzt aus Wellengeschwindigkeit und Frequenz (λ = c / f): Strahler im Abstand einer Wellenlänge strahlen in dieser Richtung gleichphasig. Gilt für den Laplace-Operator 4. Ordnung; beim 9-Punkt-Schema hängt die Geschwindigkeit von der Frequenz ab</s:String>
<s:String x:Key="SectionStops">Farbstützpunkte</s:String>
<s:String x:Key="SectionMeasurement">Messung</s:String>
+ <s:String x:Key="SectionMaterial">Material</s:String>
+ <s:String x:Key="SectionShape">Form</s:String>
+ <s:String x:Key="SectionCore">Kern</s:String>
+ <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="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="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="ButtonSquare">Quadrat</s:String>
+ <s:String x:Key="TipSquare">Die Breite gleich der Länge setzen</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="SectionGraph">Diagramm</s:String>
<s:String x:Key="SectionAxes">Achsen</s:String>
<s:String x:Key="ButtonNewSeed">_Neuer Startwert</s:String>
@@ -473,6 +501,105 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.AppTheme.System">System</s:String>
<s:String x:Key="Enum.AppTheme.Light">Hell</s:String>
<s:String x:Key="Enum.AppTheme.Dark">Dunkel</s:String>
+ <s:String x:Key="Label.OpticalPart.Name">Name</s:String>
+ <s:String x:Key="Hint.OpticalPart.Name">Name im Projektbaum und auf der Leinwand.</s:String>
+ <s:String x:Key="Label.OpticalPart.Enabled">Aktiv</s:String>
+ <s:String x:Key="Hint.OpticalPart.Enabled">Das Bauteil in die Szene zeichnen; ein inaktives Bauteil hat keine Wirkung auf einen Lauf.</s:String>
+ <s:String x:Key="Label.OpticalPart.X">X</s:String>
+ <s:String x:Key="Hint.OpticalPart.X">X des Mittelpunkts in Leinwandpixeln.</s:String>
+ <s:String x:Key="Label.OpticalPart.Y">Y</s:String>
+ <s:String x:Key="Hint.OpticalPart.Y">Y des Mittelpunkts in Leinwandpixeln.</s:String>
+ <s:String x:Key="Label.OpticalPart.Angle">Winkel</s:String>
+ <s:String x:Key="Hint.OpticalPart.Angle">Drehung um den Mittelpunkt in Grad, gegen den Uhrzeigersinn auf dem Bildschirm. 0 richtet die Achse des Bauteils nach rechts.</s:String>
+ <s:String x:Key="Label.PartPoint.X">X</s:String>
+ <s:String x:Key="Hint.PartPoint.X">X relativ zum Mittelpunkt des Bauteils in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.PartPoint.Y">Y</s:String>
+ <s:String x:Key="Hint.PartPoint.Y">Y relativ zum Mittelpunkt des Bauteils in Leinwandpixeln, vor der Drehung.</s:String>
+ <s:String x:Key="Label.LensPart.Mirror">Spiegel</s:String>
+ <s:String x:Key="Hint.LensPart.Mirror">Das Bauteil als Spiegel statt als Linse. Brechungsindex und Entspiegelung werden dann ignoriert.</s:String>
+ <s:String x:Key="Label.LensPart.RefractiveIndex">Brechungsindex</s:String>
+ <s:String x:Key="Hint.LensPart.RefractiveIndex">Brechungsindex des Glases, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.LensPart.Coating">Entspiegelung</s:String>
+ <s:String x:Key="Hint.LensPart.Coating">Dicke in Pixeln des entspiegelnden Bands direkt innerhalb des Umrisses mit dem Index √n; 0 für keines. Eine λ/4-Schicht ist λ / (4 √n) Pixel dick, λ die Wellenlänge aus dem Quellenformular.</s:String>
+ <s:String x:Key="Label.LensPart.Diameter">Durchmesser</s:String>
+ <s:String x:Key="Hint.LensPart.Diameter">Ausdehnung quer zur Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.LensPart.R1">R1</s:String>
+ <s:String x:Key="Hint.LensPart.R1">Radius der ersten Fläche in Pixeln: positiv wölbt sich nach außen, negativ ist konkav, 0 ist eben.</s:String>
+ <s:String x:Key="Label.LensPart.R2">R2</s:String>
+ <s:String x:Key="Hint.LensPart.R2">Radius der zweiten Fläche in Pixeln: negativ wölbt sich nach außen, positiv ist konkav, 0 ist eben.</s:String>
+ <s:String x:Key="Label.LensPart.Thickness">Mittendicke</s:String>
+ <s:String x:Key="Hint.LensPart.Thickness">Abstand der beiden Flächen auf der Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.ShapePart.Mirror">Spiegel</s:String>
+ <s:String x:Key="Hint.ShapePart.Mirror">Das Bauteil als Spiegel statt als Glas. Brechungsindex und Entspiegelung werden dann ignoriert.</s:String>
+ <s:String x:Key="Label.ShapePart.RefractiveIndex">Brechungsindex</s:String>
+ <s:String x:Key="Hint.ShapePart.RefractiveIndex">Brechungsindex des Glases, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.ShapePart.Coating">Entspiegelung</s:String>
+ <s:String x:Key="Hint.ShapePart.Coating">Dicke in Pixeln des entspiegelnden Bands direkt innerhalb des Umrisses mit dem Index √n; 0 für keines. Eine λ/4-Schicht ist λ / (4 √n) Pixel dick, λ die Wellenlänge aus dem Quellenformular.</s:String>
+ <s:String x:Key="Label.PolygonPart.Sides">Anzahl Seiten</s:String>
+ <s:String x:Key="Hint.PolygonPart.Sides">Anzahl der Seiten, 3 bis 64.</s:String>
+ <s:String x:Key="Label.PolygonPart.Side">Seitenlänge</s:String>
+ <s:String x:Key="Hint.PolygonPart.Side">Länge jeder Seite in Pixeln.</s:String>
+ <s:String x:Key="Label.RectanglePart.Length">Länge</s:String>
+ <s:String x:Key="Hint.RectanglePart.Length">Ausdehnung entlang der Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.RectanglePart.Width">Breite</s:String>
+ <s:String x:Key="Hint.RectanglePart.Width">Ausdehnung quer zur Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.TrianglePart.Base">Grundseite</s:String>
+ <s:String x:Key="Hint.TrianglePart.Base">Länge der Grundseite in Pixeln; sie liegt quer zur Achse, einer Quelle links zugewandt.</s:String>
+ <s:String x:Key="Label.TrianglePart.Type">Typ</s:String>
+ <s:String x:Key="Hint.TrianglePart.Type">Gleichseitig, rechtwinklig-gleichschenklig (das 45°-Prisma), 30-60-90, gleichschenklig mit einem eingegebenen Winkel oder eigene Winkel.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleA">Winkel A</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleA">Grundwinkel am ersten Ende der Grundseite in Grad. Eingabe bei gleichschenklig und eigenen Winkeln; die Vorgaben legen ihn fest.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleB">Winkel B</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleB">Grundwinkel am zweiten Ende der Grundseite in Grad. Eingabe nur bei eigenen Winkeln; die anderen Typen legen ihn fest.</s:String>
+ <s:String x:Key="Label.OutlinePart.Points">Punkte</s:String>
+ <s:String x:Key="Hint.OutlinePart.Points">Eckpunkte des Umrisses relativ zum Mittelpunkt, vor der Drehung. Weniger als drei Punkte zeichnen nichts.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreIndex">Kernindex</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreIndex">Brechungsindex des Kerns, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreDiameter">Kerndurchmesser</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreDiameter">Durchmesser des Kerns in Pixeln.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingIndex">Mantelindex</s:String>
+ <s:String x:Key="Hint.FiberPart.CladdingIndex">Brechungsindex des Mantels, 1,00 bis 2,55 in Schritten von 0,01. Unter dem Kernindex führt die Faser.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingThickness">Manteldicke</s:String>
+ <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.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>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness1">Dicke der ersten Schicht jedes Paars in Pixeln. Eine λ/4-Schicht ist λ / (4 n) Pixel dick.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Thickness2">Dicke 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness2">Dicke der zweiten Schicht jedes Paars in Pixeln. Eine λ/4-Schicht ist λ / (4 n) Pixel dick.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index1">Index 1</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index1">Brechungsindex der ersten Schicht jedes Paars, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index2">Index 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index2">Brechungsindex der zweiten Schicht jedes Paars, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Width">Breite</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Width">Ausdehnung des Stapels quer zur Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Length">Länge</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Length">Ausdehnung entlang der Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Diameter">Durchmesser</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Diameter">Ausdehnung quer zur Achse in Pixeln.</s:String>
+ <s:String x:Key="Label.GrinLensPart.CentreIndex">Index auf der Achse</s:String>
+ <s:String x:Key="Hint.GrinLensPart.CentreIndex">Brechungsindex auf der Achse, 1,00 bis 2,55 in Schritten von 0,01.</s:String>
+ <s:String x:Key="Label.GrinLensPart.EdgeIndex">Index am Rand</s:String>
+ <s:String x:Key="Hint.GrinLensPart.EdgeIndex">Brechungsindex am Rand, 1,00 bis 2,55 in Schritten von 0,01. Das Profil zwischen Achse und Rand ist parabolisch.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Coating">Entspiegelung</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Coating">Dicke in Pixeln des entspiegelnden Bands direkt innerhalb des Umrisses mit dem Index √n; 0 für keines.</s:String>
+ <s:String x:Key="Enum.PartKind.Lens">Linse oder Spiegel</s:String>
+ <s:String x:Key="Enum.PartKind.Polygon">Polygon</s:String>
+ <s:String x:Key="Enum.PartKind.Rectangle">Rechteck</s:String>
+ <s:String x:Key="Enum.PartKind.Triangle">Dreieck</s:String>
+ <s:String x:Key="Enum.PartKind.Outline">Umriss</s:String>
+ <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.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>
+ <s:String x:Key="Enum.TriangleType.Isosceles">Gleichschenklig</s:String>
+ <s:String x:Key="Enum.TriangleType.Custom">Eigene Winkel</s:String>
<!-- end generated -->
</ResourceDictionary>
diff --git a/WaveDudeNext.WPF/Strings/Strings.EN.xaml b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
index df6a29c..7cfb2de 100644
--- a/WaveDudeNext.WPF/Strings/Strings.EN.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.EN.xaml
@@ -110,6 +110,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectAddSource">Add _source</s:String>
<s:String x:Key="MenuProjectAddProbe">Add _probe</s:String>
+ <s:String x:Key="MenuProjectAddPart">Add p_art</s:String>
+ <s:String x:Key="MenuAddLens">_Lens or mirror</s:String>
+ <s:String x:Key="MenuAddPolygon">_Polygon</s:String>
+ <s:String x:Key="MenuAddRectangle">_Rectangle</s:String>
+ <s:String x:Key="MenuAddTriangle">_Triangle</s:String>
+ <s:String x:Key="MenuAddOutline">_Outline</s:String>
+ <s:String x:Key="MenuAddFiber">_Fibre</s:String>
+ <s:String x:Key="MenuAddBraggReflector">_Bragg reflector</s:String>
+ <s:String x:Key="MenuAddGrinLens">_GRIN lens</s:String>
<s:String x:Key="MenuProjectToggleEnabled">_Enabled</s:String>
<s:String x:Key="MenuProjectDuplicate">_Duplicate</s:String>
<s:String x:Key="MenuProjectRemove">_Remove</s:String>
@@ -117,11 +126,14 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectMoveDown">Move _down</s:String>
<s:String x:Key="ToolAddSource">+ Source</s:String>
<s:String x:Key="ToolAddProbe">+ Probe</s:String>
+ <s:String x:Key="ToolAddPart">+ Part</s:String>
<s:String x:Key="TipAddSource">Add a source (appended at the end)</s:String>
<s:String x:Key="TipAddProbe">Add a probe (appended at the end)</s:String>
+ <s:String x:Key="TipAddPart">Add an optical part (a menu of kinds; appended at the end)</s:String>
<s:String x:Key="TipAdd">Add an item to this folder</s:String>
<s:String x:Key="TipRemove">Remove (Del)</s:String>
<s:String x:Key="TipSourceEnabled">Include the source in runs (Space on the row toggles it)</s:String>
+ <s:String x:Key="TipPartEnabled">Paint the part into the scene (Space on the row toggles it)</s:String>
<s:String x:Key="TipProbeActive">Sample this probe (Space on the row toggles it)</s:String>
<s:String x:Key="TipMoveUp">Move up (Alt+Up); drag to reorder</s:String>
<s:String x:Key="TipMoveDown">Move down (Alt+Down); drag to reorder</s:String>
@@ -217,6 +229,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TreeSimulation">Simulation</s:String>
<s:String x:Key="TreeDisplay">Display</s:String>
<s:String x:Key="TreeSources">Sources</s:String>
+ <s:String x:Key="TreeParts">Parts</s:String>
<s:String x:Key="TreeProbes">Probes</s:String>
<s:String x:Key="TreeColorSchemes">Colour schemes</s:String>
@@ -238,6 +251,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipWavelength">Estimated from the wave speed and the frequency (λ = c / f): emitters one wavelength apart radiate in phase along that direction. Holds for the 4th-order Laplacian; the 9-point stencil's speed varies with the frequency</s:String>
<s:String x:Key="SectionStops">Stops</s:String>
<s:String x:Key="SectionMeasurement">Measurement</s:String>
+ <s:String x:Key="SectionMaterial">Material</s:String>
+ <s:String x:Key="SectionShape">Shape</s:String>
+ <s:String x:Key="SectionCore">Core</s:String>
+ <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="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="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="ButtonSquare">Square</s:String>
+ <s:String x:Key="TipSquare">Make the width equal to the length</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="SectionGraph">Graph</s:String>
<s:String x:Key="SectionAxes">Axes</s:String>
<s:String x:Key="ButtonNewSeed">_New seed</s:String>
@@ -475,6 +503,105 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.AppTheme.System">System</s:String>
<s:String x:Key="Enum.AppTheme.Light">Light</s:String>
<s:String x:Key="Enum.AppTheme.Dark">Dark</s:String>
+ <s:String x:Key="Label.OpticalPart.Name">Name</s:String>
+ <s:String x:Key="Hint.OpticalPart.Name">Name shown in the project tree and on the canvas.</s:String>
+ <s:String x:Key="Label.OpticalPart.Enabled">Enabled</s:String>
+ <s:String x:Key="Hint.OpticalPart.Enabled">Paint the part into the scene; a disabled part has no effect on a run.</s:String>
+ <s:String x:Key="Label.OpticalPart.X">X</s:String>
+ <s:String x:Key="Hint.OpticalPart.X">X of the part's centre in canvas pixels.</s:String>
+ <s:String x:Key="Label.OpticalPart.Y">Y</s:String>
+ <s:String x:Key="Hint.OpticalPart.Y">Y of the part's centre in canvas pixels.</s:String>
+ <s:String x:Key="Label.OpticalPart.Angle">Angle</s:String>
+ <s:String x:Key="Hint.OpticalPart.Angle">Rotation about the centre in degrees, counter-clockwise on the screen. 0 points the part's axis to the right.</s:String>
+ <s:String x:Key="Label.PartPoint.X">X</s:String>
+ <s:String x:Key="Hint.PartPoint.X">X relative to the part's centre in canvas pixels, before rotation.</s:String>
+ <s:String x:Key="Label.PartPoint.Y">Y</s:String>
+ <s:String x:Key="Hint.PartPoint.Y">Y relative to the part's centre in canvas pixels, before rotation.</s:String>
+ <s:String x:Key="Label.LensPart.Mirror">Mirror</s:String>
+ <s:String x:Key="Hint.LensPart.Mirror">Make the part a mirror instead of a lens. The refractive index and the coating are ignored then.</s:String>
+ <s:String x:Key="Label.LensPart.RefractiveIndex">Refractive index</s:String>
+ <s:String x:Key="Hint.LensPart.RefractiveIndex">Refractive index of the glass, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.LensPart.Coating">AR coating</s:String>
+ <s:String x:Key="Hint.LensPart.Coating">Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none. A quarter-wave coating is λ / (4 √n) pixels thick, λ being the wavelength the source form shows.</s:String>
+ <s:String x:Key="Label.LensPart.Diameter">Diameter</s:String>
+ <s:String x:Key="Hint.LensPart.Diameter">Extent across the axis in pixels.</s:String>
+ <s:String x:Key="Label.LensPart.R1">R1</s:String>
+ <s:String x:Key="Hint.LensPart.R1">Radius of the first surface in pixels: positive bulges outward, negative is concave, 0 is flat.</s:String>
+ <s:String x:Key="Label.LensPart.R2">R2</s:String>
+ <s:String x:Key="Hint.LensPart.R2">Radius of the second surface in pixels: negative bulges outward, positive is concave, 0 is flat.</s:String>
+ <s:String x:Key="Label.LensPart.Thickness">Centre thickness</s:String>
+ <s:String x:Key="Hint.LensPart.Thickness">Distance between the two surfaces on the axis in pixels.</s:String>
+ <s:String x:Key="Label.ShapePart.Mirror">Mirror</s:String>
+ <s:String x:Key="Hint.ShapePart.Mirror">Make the part a mirror instead of glass. The refractive index and the coating are ignored then.</s:String>
+ <s:String x:Key="Label.ShapePart.RefractiveIndex">Refractive index</s:String>
+ <s:String x:Key="Hint.ShapePart.RefractiveIndex">Refractive index of the glass, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.ShapePart.Coating">AR coating</s:String>
+ <s:String x:Key="Hint.ShapePart.Coating">Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none. A quarter-wave coating is λ / (4 √n) pixels thick, λ being the wavelength the source form shows.</s:String>
+ <s:String x:Key="Label.PolygonPart.Sides">Number of sides</s:String>
+ <s:String x:Key="Hint.PolygonPart.Sides">Number of sides, 3 to 64.</s:String>
+ <s:String x:Key="Label.PolygonPart.Side">Side length</s:String>
+ <s:String x:Key="Hint.PolygonPart.Side">Length of each side in pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Length">Length</s:String>
+ <s:String x:Key="Hint.RectanglePart.Length">Extent along the axis in pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Width">Width</s:String>
+ <s:String x:Key="Hint.RectanglePart.Width">Extent across the axis in pixels.</s:String>
+ <s:String x:Key="Label.TrianglePart.Base">Base</s:String>
+ <s:String x:Key="Hint.TrianglePart.Base">Length of the base in pixels; the base lies across the axis, toward a source on the left.</s:String>
+ <s:String x:Key="Label.TrianglePart.Type">Type</s:String>
+ <s:String x:Key="Hint.TrianglePart.Type">Equilateral, right isosceles (the 45° prism), 30-60-90, isosceles with one typed angle, or custom with both typed.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleA">Angle A</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleA">Base angle at the first end of the base, in degrees. Typed for the isosceles and custom types; the presets fix it.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleB">Angle B</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleB">Base angle at the second end of the base, in degrees. Typed for the custom type; the others fix it.</s:String>
+ <s:String x:Key="Label.OutlinePart.Points">Points</s:String>
+ <s:String x:Key="Hint.OutlinePart.Points">The outline's vertices relative to the centre, before rotation. Fewer than three points paint nothing.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreIndex">Core index</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreIndex">Refractive index of the core, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreDiameter">Core diameter</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreDiameter">Diameter of the core in pixels.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingIndex">Cladding index</s:String>
+ <s:String x:Key="Hint.FiberPart.CladdingIndex">Refractive index of the cladding, 1.00 to 2.55 in steps of 0.01. Below the core's index, the fibre guides.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingThickness">Cladding thickness</s:String>
+ <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.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>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness1">Thickness of the first layer of each pair in pixels. A quarter-wave layer is λ / (4 n) pixels thick.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Thickness2">Thickness 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness2">Thickness of the second layer of each pair in pixels. A quarter-wave layer is λ / (4 n) pixels thick.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index1">Index 1</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index1">Refractive index of the first layer of each pair, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index2">Index 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index2">Refractive index of the second layer of each pair, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Width">Width</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Width">Extent of the stack across the axis in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Length">Length</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Length">Extent along the axis in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Diameter">Diameter</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Diameter">Extent across the axis in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.CentreIndex">Centre index</s:String>
+ <s:String x:Key="Hint.GrinLensPart.CentreIndex">Refractive index on the axis, 1.00 to 2.55 in steps of 0.01.</s:String>
+ <s:String x:Key="Label.GrinLensPart.EdgeIndex">Edge index</s:String>
+ <s:String x:Key="Hint.GrinLensPart.EdgeIndex">Refractive index at the edge, 1.00 to 2.55 in steps of 0.01. The profile between the axis and the edge is parabolic.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Coating">AR coating</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Coating">Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none.</s:String>
+ <s:String x:Key="Enum.PartKind.Lens">Lens or mirror</s:String>
+ <s:String x:Key="Enum.PartKind.Polygon">Polygon</s:String>
+ <s:String x:Key="Enum.PartKind.Rectangle">Rectangle</s:String>
+ <s:String x:Key="Enum.PartKind.Triangle">Triangle</s:String>
+ <s:String x:Key="Enum.PartKind.Outline">Outline</s:String>
+ <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.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>
+ <s:String x:Key="Enum.TriangleType.Isosceles">Isosceles</s:String>
+ <s:String x:Key="Enum.TriangleType.Custom">Custom</s:String>
<!-- end generated -->
</ResourceDictionary>
diff --git a/WaveDudeNext.WPF/Strings/Strings.FR.xaml b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
index f309b21..4eea9ff 100644
--- a/WaveDudeNext.WPF/Strings/Strings.FR.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.FR.xaml
@@ -108,6 +108,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectAddSource">Ajouter une _source</s:String>
<s:String x:Key="MenuProjectAddProbe">Ajouter une s_onde</s:String>
+ <s:String x:Key="MenuProjectAddPart">Ajouter un _composant</s:String>
+ <s:String x:Key="MenuAddLens">_Lentille ou miroir</s:String>
+ <s:String x:Key="MenuAddPolygon">_Polygone</s:String>
+ <s:String x:Key="MenuAddRectangle">_Rectangle</s:String>
+ <s:String x:Key="MenuAddTriangle">_Triangle</s:String>
+ <s:String x:Key="MenuAddOutline">C_ontour</s:String>
+ <s:String x:Key="MenuAddFiber">_Fibre</s:String>
+ <s:String x:Key="MenuAddBraggReflector">Réflecteur de _Bragg</s:String>
+ <s:String x:Key="MenuAddGrinLens">Lentille _GRIN</s:String>
<s:String x:Key="MenuProjectToggleEnabled">_Activé</s:String>
<s:String x:Key="MenuProjectDuplicate">_Dupliquer</s:String>
<s:String x:Key="MenuProjectRemove">_Supprimer</s:String>
@@ -115,11 +124,14 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectMoveDown">D_escendre</s:String>
<s:String x:Key="ToolAddSource">+ Source</s:String>
<s:String x:Key="ToolAddProbe">+ Sonde</s:String>
+ <s:String x:Key="ToolAddPart">+ Composant</s:String>
<s:String x:Key="TipAddSource">Ajouter une source (à la fin)</s:String>
<s:String x:Key="TipAddProbe">Ajouter une sonde (à la fin)</s:String>
+ <s:String x:Key="TipAddPart">Ajouter un composant optique (menu des types ; à la fin)</s:String>
<s:String x:Key="TipAdd">Ajouter un élément à ce dossier</s:String>
<s:String x:Key="TipRemove">Supprimer (Suppr)</s:String>
<s:String x:Key="TipSourceEnabled">Inclure la source dans les exécutions (Espace sur la ligne bascule)</s:String>
+ <s:String x:Key="TipPartEnabled">Peindre le composant dans la scène (Espace sur la ligne bascule)</s:String>
<s:String x:Key="TipProbeActive">Échantillonner cette sonde (Espace sur la ligne bascule)</s:String>
<s:String x:Key="TipMoveUp">Monter (Alt+Haut) ; glisser pour réordonner</s:String>
<s:String x:Key="TipMoveDown">Descendre (Alt+Bas) ; glisser pour réordonner</s:String>
@@ -215,6 +227,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TreeSimulation">Simulation</s:String>
<s:String x:Key="TreeDisplay">Affichage</s:String>
<s:String x:Key="TreeSources">Sources</s:String>
+ <s:String x:Key="TreeParts">Composants</s:String>
<s:String x:Key="TreeProbes">Sondes</s:String>
<s:String x:Key="TreeColorSchemes">Palettes de couleurs</s:String>
@@ -236,6 +249,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipWavelength">Estimée à partir de la vitesse d'onde et de la fréquence (λ = c / f) : des émetteurs espacés d'une longueur d'onde rayonnent en phase dans cette direction. Valable pour le laplacien du 4e ordre ; avec le schéma à 9 points la vitesse dépend de la fréquence</s:String>
<s:String x:Key="SectionStops">Points de couleur</s:String>
<s:String x:Key="SectionMeasurement">Mesure</s:String>
+ <s:String x:Key="SectionMaterial">Matériau</s:String>
+ <s:String x:Key="SectionShape">Forme</s:String>
+ <s:String x:Key="SectionCore">Cœur</s:String>
+ <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="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="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="ButtonSquare">Carré</s:String>
+ <s:String x:Key="TipSquare">Rendre la largeur égale à la longueur</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="SectionGraph">Graphique</s:String>
<s:String x:Key="SectionAxes">Axes</s:String>
<s:String x:Key="ButtonNewSeed">_Nouvelle graine</s:String>
@@ -473,6 +501,105 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.AppTheme.System">Système</s:String>
<s:String x:Key="Enum.AppTheme.Light">Clair</s:String>
<s:String x:Key="Enum.AppTheme.Dark">Sombre</s:String>
+ <s:String x:Key="Label.OpticalPart.Name">Nom</s:String>
+ <s:String x:Key="Hint.OpticalPart.Name">Nom affiché dans l'arborescence du projet et sur la toile.</s:String>
+ <s:String x:Key="Label.OpticalPart.Enabled">Activé</s:String>
+ <s:String x:Key="Hint.OpticalPart.Enabled">Peindre le composant dans la scène ; un composant désactivé n'a aucun effet sur une exécution.</s:String>
+ <s:String x:Key="Label.OpticalPart.X">X</s:String>
+ <s:String x:Key="Hint.OpticalPart.X">X du centre en pixels de la toile.</s:String>
+ <s:String x:Key="Label.OpticalPart.Y">Y</s:String>
+ <s:String x:Key="Hint.OpticalPart.Y">Y du centre en pixels de la toile.</s:String>
+ <s:String x:Key="Label.OpticalPart.Angle">Angle</s:String>
+ <s:String x:Key="Hint.OpticalPart.Angle">Rotation autour du centre en degrés, dans le sens antihoraire à l'écran. 0 oriente l'axe du composant vers la droite.</s:String>
+ <s:String x:Key="Label.PartPoint.X">X</s:String>
+ <s:String x:Key="Hint.PartPoint.X">X par rapport au centre du composant en pixels de la toile, avant rotation.</s:String>
+ <s:String x:Key="Label.PartPoint.Y">Y</s:String>
+ <s:String x:Key="Hint.PartPoint.Y">Y par rapport au centre du composant en pixels de la toile, avant rotation.</s:String>
+ <s:String x:Key="Label.LensPart.Mirror">Miroir</s:String>
+ <s:String x:Key="Hint.LensPart.Mirror">Faire du composant un miroir au lieu d'une lentille. L'indice de réfraction et le traitement antireflet sont alors ignorés.</s:String>
+ <s:String x:Key="Label.LensPart.RefractiveIndex">Indice de réfraction</s:String>
+ <s:String x:Key="Hint.LensPart.RefractiveIndex">Indice de réfraction du verre, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.LensPart.Coating">Traitement antireflet</s:String>
+ <s:String x:Key="Hint.LensPart.Coating">Épaisseur en pixels de la bande antireflet juste à l'intérieur du contour, d'indice √n ; 0 pour aucune. Une couche quart d'onde fait λ / (4 √n) pixels, λ étant la longueur d'onde affichée dans le formulaire de la source.</s:String>
+ <s:String x:Key="Label.LensPart.Diameter">Diamètre</s:String>
+ <s:String x:Key="Hint.LensPart.Diameter">Étendue perpendiculaire à l'axe en pixels.</s:String>
+ <s:String x:Key="Label.LensPart.R1">R1</s:String>
+ <s:String x:Key="Hint.LensPart.R1">Rayon de la première surface en pixels : positif bombé vers l'extérieur, négatif concave, 0 plan.</s:String>
+ <s:String x:Key="Label.LensPart.R2">R2</s:String>
+ <s:String x:Key="Hint.LensPart.R2">Rayon de la seconde surface en pixels : négatif bombé vers l'extérieur, positif concave, 0 plan.</s:String>
+ <s:String x:Key="Label.LensPart.Thickness">Épaisseur au centre</s:String>
+ <s:String x:Key="Hint.LensPart.Thickness">Distance entre les deux surfaces sur l'axe en pixels.</s:String>
+ <s:String x:Key="Label.ShapePart.Mirror">Miroir</s:String>
+ <s:String x:Key="Hint.ShapePart.Mirror">Faire du composant un miroir au lieu du verre. L'indice de réfraction et le traitement antireflet sont alors ignorés.</s:String>
+ <s:String x:Key="Label.ShapePart.RefractiveIndex">Indice de réfraction</s:String>
+ <s:String x:Key="Hint.ShapePart.RefractiveIndex">Indice de réfraction du verre, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.ShapePart.Coating">Traitement antireflet</s:String>
+ <s:String x:Key="Hint.ShapePart.Coating">Épaisseur en pixels de la bande antireflet juste à l'intérieur du contour, d'indice √n ; 0 pour aucune. Une couche quart d'onde fait λ / (4 √n) pixels, λ étant la longueur d'onde affichée dans le formulaire de la source.</s:String>
+ <s:String x:Key="Label.PolygonPart.Sides">Nombre de côtés</s:String>
+ <s:String x:Key="Hint.PolygonPart.Sides">Nombre de côtés, de 3 à 64.</s:String>
+ <s:String x:Key="Label.PolygonPart.Side">Longueur de côté</s:String>
+ <s:String x:Key="Hint.PolygonPart.Side">Longueur de chaque côté en pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Length">Longueur</s:String>
+ <s:String x:Key="Hint.RectanglePart.Length">Étendue le long de l'axe en pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Width">Largeur</s:String>
+ <s:String x:Key="Hint.RectanglePart.Width">Étendue perpendiculaire à l'axe en pixels.</s:String>
+ <s:String x:Key="Label.TrianglePart.Base">Base</s:String>
+ <s:String x:Key="Hint.TrianglePart.Base">Longueur de la base en pixels ; elle est perpendiculaire à l'axe, tournée vers une source à gauche.</s:String>
+ <s:String x:Key="Label.TrianglePart.Type">Type</s:String>
+ <s:String x:Key="Hint.TrianglePart.Type">Équilatéral, rectangle isocèle (le prisme à 45°), 30-60-90, isocèle avec un angle saisi, ou personnalisé avec les deux.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleA">Angle A</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleA">Angle à la première extrémité de la base, en degrés. Saisi pour les types isocèle et personnalisé ; les préréglages le fixent.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleB">Angle B</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleB">Angle à la seconde extrémité de la base, en degrés. Saisi pour le type personnalisé ; les autres le fixent.</s:String>
+ <s:String x:Key="Label.OutlinePart.Points">Points</s:String>
+ <s:String x:Key="Hint.OutlinePart.Points">Sommets du contour par rapport au centre, avant rotation. Moins de trois points ne peignent rien.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreIndex">Indice du cœur</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreIndex">Indice de réfraction du cœur, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreDiameter">Diamètre du cœur</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreDiameter">Diamètre du cœur en pixels.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingIndex">Indice de la gaine</s:String>
+ <s:String x:Key="Hint.FiberPart.CladdingIndex">Indice de réfraction de la gaine, de 1,00 à 2,55 par pas de 0,01. En dessous de l'indice du cœur, la fibre guide.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingThickness">Épaisseur de la gaine</s:String>
+ <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.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>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness1">Épaisseur de la première couche de chaque paire en pixels. Une couche quart d'onde fait λ / (4 n) pixels.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Thickness2">Épaisseur 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness2">Épaisseur de la seconde couche de chaque paire en pixels. Une couche quart d'onde fait λ / (4 n) pixels.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index1">Indice 1</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index1">Indice de réfraction de la première couche de chaque paire, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index2">Indice 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index2">Indice de réfraction de la seconde couche de chaque paire, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Width">Largeur</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Width">Étendue de l'empilement perpendiculaire à l'axe en pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Length">Longueur</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Length">Étendue le long de l'axe en pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Diameter">Diamètre</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Diameter">Étendue perpendiculaire à l'axe en pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.CentreIndex">Indice au centre</s:String>
+ <s:String x:Key="Hint.GrinLensPart.CentreIndex">Indice de réfraction sur l'axe, de 1,00 à 2,55 par pas de 0,01.</s:String>
+ <s:String x:Key="Label.GrinLensPart.EdgeIndex">Indice au bord</s:String>
+ <s:String x:Key="Hint.GrinLensPart.EdgeIndex">Indice de réfraction au bord, de 1,00 à 2,55 par pas de 0,01. Le profil entre l'axe et le bord est parabolique.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Coating">Traitement antireflet</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Coating">Épaisseur en pixels de la bande antireflet juste à l'intérieur du contour, d'indice √n ; 0 pour aucune.</s:String>
+ <s:String x:Key="Enum.PartKind.Lens">Lentille ou miroir</s:String>
+ <s:String x:Key="Enum.PartKind.Polygon">Polygone</s:String>
+ <s:String x:Key="Enum.PartKind.Rectangle">Rectangle</s:String>
+ <s:String x:Key="Enum.PartKind.Triangle">Triangle</s:String>
+ <s:String x:Key="Enum.PartKind.Outline">Contour</s:String>
+ <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.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>
+ <s:String x:Key="Enum.TriangleType.Isosceles">Isocèle</s:String>
+ <s:String x:Key="Enum.TriangleType.Custom">Personnalisé</s:String>
<!-- end generated -->
</ResourceDictionary>
diff --git a/WaveDudeNext.WPF/Strings/Strings.NL.xaml b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
index 3d00b83..27c67dd 100644
--- a/WaveDudeNext.WPF/Strings/Strings.NL.xaml
+++ b/WaveDudeNext.WPF/Strings/Strings.NL.xaml
@@ -108,6 +108,15 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectAddSource">_Bron toevoegen</s:String>
<s:String x:Key="MenuProjectAddProbe">_Sonde toevoegen</s:String>
+ <s:String x:Key="MenuProjectAddPart">_Onderdeel toevoegen</s:String>
+ <s:String x:Key="MenuAddLens">_Lens of spiegel</s:String>
+ <s:String x:Key="MenuAddPolygon">_Polygoon</s:String>
+ <s:String x:Key="MenuAddRectangle">_Rechthoek</s:String>
+ <s:String x:Key="MenuAddTriangle">_Driehoek</s:String>
+ <s:String x:Key="MenuAddOutline">_Omtrek</s:String>
+ <s:String x:Key="MenuAddFiber">_Vezel</s:String>
+ <s:String x:Key="MenuAddBraggReflector">_Bragg-reflector</s:String>
+ <s:String x:Key="MenuAddGrinLens">_GRIN-lens</s:String>
<s:String x:Key="MenuProjectToggleEnabled">_Ingeschakeld</s:String>
<s:String x:Key="MenuProjectDuplicate">_Dupliceren</s:String>
<s:String x:Key="MenuProjectRemove">_Verwijderen</s:String>
@@ -115,11 +124,14 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="MenuProjectMoveDown">Om_laag</s:String>
<s:String x:Key="ToolAddSource">+ Bron</s:String>
<s:String x:Key="ToolAddProbe">+ Sonde</s:String>
+ <s:String x:Key="ToolAddPart">+ Onderdeel</s:String>
<s:String x:Key="TipAddSource">Bron toevoegen (achteraan)</s:String>
<s:String x:Key="TipAddProbe">Sonde toevoegen (achteraan)</s:String>
+ <s:String x:Key="TipAddPart">Optisch onderdeel toevoegen (menu met soorten; achteraan)</s:String>
<s:String x:Key="TipAdd">Item aan deze map toevoegen</s:String>
<s:String x:Key="TipRemove">Verwijderen (Del)</s:String>
<s:String x:Key="TipSourceEnabled">Bron meenemen in runs (spatie op de rij schakelt om)</s:String>
+ <s:String x:Key="TipPartEnabled">Onderdeel in de scène tekenen (spatie op de rij schakelt om)</s:String>
<s:String x:Key="TipProbeActive">Deze sonde bemonsteren (spatie op de rij schakelt om)</s:String>
<s:String x:Key="TipMoveUp">Omhoog (Alt+Omhoog); slepen om te herschikken</s:String>
<s:String x:Key="TipMoveDown">Omlaag (Alt+Omlaag); slepen om te herschikken</s:String>
@@ -215,6 +227,7 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TreeSimulation">Simulatie</s:String>
<s:String x:Key="TreeDisplay">Weergave</s:String>
<s:String x:Key="TreeSources">Bronnen</s:String>
+ <s:String x:Key="TreeParts">Onderdelen</s:String>
<s:String x:Key="TreeProbes">Sondes</s:String>
<s:String x:Key="TreeColorSchemes">Kleurenschema's</s:String>
@@ -236,6 +249,21 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="TipWavelength">Geschat uit de golfsnelheid en de frequentie (λ = c / f): emitters op één golflengte afstand stralen in die richting in fase. Geldt voor de 4e-orde-Laplaciaan; bij het 9-puntsschema hangt de snelheid van de frequentie af</s:String>
<s:String x:Key="SectionStops">Kleurpunten</s:String>
<s:String x:Key="SectionMeasurement">Meting</s:String>
+ <s:String x:Key="SectionMaterial">Materiaal</s:String>
+ <s:String x:Key="SectionShape">Vorm</s:String>
+ <s:String x:Key="SectionCore">Kern</s:String>
+ <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="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="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="ButtonSquare">Vierkant</s:String>
+ <s:String x:Key="TipSquare">De breedte gelijk aan de lengte maken</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="SectionGraph">Grafiek</s:String>
<s:String x:Key="SectionAxes">Assen</s:String>
<s:String x:Key="ButtonNewSeed">_Nieuwe seed</s:String>
@@ -473,6 +501,105 @@ version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
<s:String x:Key="Enum.AppTheme.System">Systeem</s:String>
<s:String x:Key="Enum.AppTheme.Light">Licht</s:String>
<s:String x:Key="Enum.AppTheme.Dark">Donker</s:String>
+ <s:String x:Key="Label.OpticalPart.Name">Naam</s:String>
+ <s:String x:Key="Hint.OpticalPart.Name">Naam in de projectboom en op het canvas.</s:String>
+ <s:String x:Key="Label.OpticalPart.Enabled">Ingeschakeld</s:String>
+ <s:String x:Key="Hint.OpticalPart.Enabled">Het onderdeel in de scène tekenen; een uitgeschakeld onderdeel heeft geen effect op een run.</s:String>
+ <s:String x:Key="Label.OpticalPart.X">X</s:String>
+ <s:String x:Key="Hint.OpticalPart.X">X van het middelpunt in canvaspixels.</s:String>
+ <s:String x:Key="Label.OpticalPart.Y">Y</s:String>
+ <s:String x:Key="Hint.OpticalPart.Y">Y van het middelpunt in canvaspixels.</s:String>
+ <s:String x:Key="Label.OpticalPart.Angle">Hoek</s:String>
+ <s:String x:Key="Hint.OpticalPart.Angle">Rotatie om het middelpunt in graden, tegen de klok in op het scherm. 0 richt de as van het onderdeel naar rechts.</s:String>
+ <s:String x:Key="Label.PartPoint.X">X</s:String>
+ <s:String x:Key="Hint.PartPoint.X">X ten opzichte van het middelpunt van het onderdeel in canvaspixels, vóór rotatie.</s:String>
+ <s:String x:Key="Label.PartPoint.Y">Y</s:String>
+ <s:String x:Key="Hint.PartPoint.Y">Y ten opzichte van het middelpunt van het onderdeel in canvaspixels, vóór rotatie.</s:String>
+ <s:String x:Key="Label.LensPart.Mirror">Spiegel</s:String>
+ <s:String x:Key="Hint.LensPart.Mirror">Het onderdeel een spiegel maken in plaats van een lens. De brekingsindex en de coating worden dan genegeerd.</s:String>
+ <s:String x:Key="Label.LensPart.RefractiveIndex">Brekingsindex</s:String>
+ <s:String x:Key="Hint.LensPart.RefractiveIndex">Brekingsindex van het glas, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.LensPart.Coating">AR-coating</s:String>
+ <s:String x:Key="Hint.LensPart.Coating">Dikte in pixels van de antireflectieband net binnen de omtrek, met index √n; 0 voor geen. Een kwartgolfcoating is λ / (4 √n) pixels dik, λ de golflengte die het bronformulier toont.</s:String>
+ <s:String x:Key="Label.LensPart.Diameter">Diameter</s:String>
+ <s:String x:Key="Hint.LensPart.Diameter">Afmeting dwars op de as in pixels.</s:String>
+ <s:String x:Key="Label.LensPart.R1">R1</s:String>
+ <s:String x:Key="Hint.LensPart.R1">Straal van het eerste oppervlak in pixels: positief bolt naar buiten, negatief is hol, 0 is vlak.</s:String>
+ <s:String x:Key="Label.LensPart.R2">R2</s:String>
+ <s:String x:Key="Hint.LensPart.R2">Straal van het tweede oppervlak in pixels: negatief bolt naar buiten, positief is hol, 0 is vlak.</s:String>
+ <s:String x:Key="Label.LensPart.Thickness">Middendikte</s:String>
+ <s:String x:Key="Hint.LensPart.Thickness">Afstand tussen de twee oppervlakken op de as in pixels.</s:String>
+ <s:String x:Key="Label.ShapePart.Mirror">Spiegel</s:String>
+ <s:String x:Key="Hint.ShapePart.Mirror">Het onderdeel een spiegel maken in plaats van glas. De brekingsindex en de coating worden dan genegeerd.</s:String>
+ <s:String x:Key="Label.ShapePart.RefractiveIndex">Brekingsindex</s:String>
+ <s:String x:Key="Hint.ShapePart.RefractiveIndex">Brekingsindex van het glas, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.ShapePart.Coating">AR-coating</s:String>
+ <s:String x:Key="Hint.ShapePart.Coating">Dikte in pixels van de antireflectieband net binnen de omtrek, met index √n; 0 voor geen. Een kwartgolfcoating is λ / (4 √n) pixels dik, λ de golflengte die het bronformulier toont.</s:String>
+ <s:String x:Key="Label.PolygonPart.Sides">Aantal zijden</s:String>
+ <s:String x:Key="Hint.PolygonPart.Sides">Aantal zijden, 3 tot 64.</s:String>
+ <s:String x:Key="Label.PolygonPart.Side">Zijdelengte</s:String>
+ <s:String x:Key="Hint.PolygonPart.Side">Lengte van elke zijde in pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Length">Lengte</s:String>
+ <s:String x:Key="Hint.RectanglePart.Length">Afmeting langs de as in pixels.</s:String>
+ <s:String x:Key="Label.RectanglePart.Width">Breedte</s:String>
+ <s:String x:Key="Hint.RectanglePart.Width">Afmeting dwars op de as in pixels.</s:String>
+ <s:String x:Key="Label.TrianglePart.Base">Basis</s:String>
+ <s:String x:Key="Hint.TrianglePart.Base">Lengte van de basis in pixels; ze ligt dwars op de as, naar een bron links gekeerd.</s:String>
+ <s:String x:Key="Label.TrianglePart.Type">Type</s:String>
+ <s:String x:Key="Hint.TrianglePart.Type">Gelijkzijdig, rechthoekig-gelijkbenig (het 45°-prisma), 30-60-90, gelijkbenig met één getypte hoek, of eigen hoeken.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleA">Hoek A</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleA">Basishoek aan het eerste uiteinde van de basis, in graden. Getypt bij gelijkbenig en eigen hoeken; de voorinstellingen leggen hem vast.</s:String>
+ <s:String x:Key="Label.TrianglePart.AngleB">Hoek B</s:String>
+ <s:String x:Key="Hint.TrianglePart.AngleB">Basishoek aan het tweede uiteinde van de basis, in graden. Getypt bij eigen hoeken; de andere typen leggen hem vast.</s:String>
+ <s:String x:Key="Label.OutlinePart.Points">Punten</s:String>
+ <s:String x:Key="Hint.OutlinePart.Points">Hoekpunten van de omtrek ten opzichte van het middelpunt, vóór rotatie. Minder dan drie punten tekenen niets.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreIndex">Kernindex</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreIndex">Brekingsindex van de kern, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.FiberPart.CoreDiameter">Kerndiameter</s:String>
+ <s:String x:Key="Hint.FiberPart.CoreDiameter">Diameter van de kern in pixels.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingIndex">Mantelindex</s:String>
+ <s:String x:Key="Hint.FiberPart.CladdingIndex">Brekingsindex van de mantel, 1,00 tot 2,55 in stappen van 0,01. Onder de kernindex geleidt de vezel.</s:String>
+ <s:String x:Key="Label.FiberPart.CladdingThickness">Manteldikte</s:String>
+ <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.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>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness1">Dikte van de eerste laag van elk paar in pixels. Een kwartgolflaag is λ / (4 n) pixels dik.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Thickness2">Dikte 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Thickness2">Dikte van de tweede laag van elk paar in pixels. Een kwartgolflaag is λ / (4 n) pixels dik.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index1">Index 1</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index1">Brekingsindex van de eerste laag van elk paar, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Index2">Index 2</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Index2">Brekingsindex van de tweede laag van elk paar, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.BraggReflectorPart.Width">Breedte</s:String>
+ <s:String x:Key="Hint.BraggReflectorPart.Width">Afmeting van de stapel dwars op de as in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Length">Lengte</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Length">Afmeting langs de as in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Diameter">Diameter</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Diameter">Afmeting dwars op de as in pixels.</s:String>
+ <s:String x:Key="Label.GrinLensPart.CentreIndex">Index op de as</s:String>
+ <s:String x:Key="Hint.GrinLensPart.CentreIndex">Brekingsindex op de as, 1,00 tot 2,55 in stappen van 0,01.</s:String>
+ <s:String x:Key="Label.GrinLensPart.EdgeIndex">Index aan de rand</s:String>
+ <s:String x:Key="Hint.GrinLensPart.EdgeIndex">Brekingsindex aan de rand, 1,00 tot 2,55 in stappen van 0,01. Het profiel tussen de as en de rand is parabolisch.</s:String>
+ <s:String x:Key="Label.GrinLensPart.Coating">AR-coating</s:String>
+ <s:String x:Key="Hint.GrinLensPart.Coating">Dikte in pixels van de antireflectieband net binnen de omtrek, met index √n; 0 voor geen.</s:String>
+ <s:String x:Key="Enum.PartKind.Lens">Lens of spiegel</s:String>
+ <s:String x:Key="Enum.PartKind.Polygon">Polygoon</s:String>
+ <s:String x:Key="Enum.PartKind.Rectangle">Rechthoek</s:String>
+ <s:String x:Key="Enum.PartKind.Triangle">Driehoek</s:String>
+ <s:String x:Key="Enum.PartKind.Outline">Omtrek</s:String>
+ <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.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>
+ <s:String x:Key="Enum.TriangleType.Isosceles">Gelijkbenig</s:String>
+ <s:String x:Key="Enum.TriangleType.Custom">Eigen hoeken</s:String>
<!-- end generated -->
</ResourceDictionary>
diff --git a/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml b/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml
new file mode 100644
index 0000000..6520fd5
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml
@@ -0,0 +1,57 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.BraggReflectorPartView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionLayers}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Pairs}" />
+ <controls:NumberBox Text="{Binding Pairs}" Minimum="1" Maximum="200" ToolTip="{meta:Hint model:BraggReflectorPart.Pairs}" AutomationProperties.AutomationId="PartPairs" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Thickness1}" />
+ <controls:NumberBox Text="{Binding Thickness1}" Minimum="1" ToolTip="{meta:Hint model:BraggReflectorPart.Thickness1}" AutomationProperties.AutomationId="PartThickness1" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Index1}" />
+ <controls:NumberBox Text="{Binding Index1}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:BraggReflectorPart.Index1}" AutomationProperties.AutomationId="PartIndex1" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Thickness2}" />
+ <controls:NumberBox Text="{Binding Thickness2}" Minimum="1" ToolTip="{meta:Hint model:BraggReflectorPart.Thickness2}" AutomationProperties.AutomationId="PartThickness2" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Index2}" />
+ <controls:NumberBox Text="{Binding Index2}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:BraggReflectorPart.Index2}" AutomationProperties.AutomationId="PartIndex2" />
+ </controls:FormPanel>
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:BraggReflectorPart.Width}" />
+ <controls:NumberBox Text="{Binding Width}" Minimum="2" Increment="10" ToolTip="{meta:Hint model:BraggReflectorPart.Width}" AutomationProperties.AutomationId="PartWidth" />
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml.cs b/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml.cs
new file mode 100644
index 0000000..2d90e00
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/BraggReflectorPartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.BraggReflectorPart"/>: the layer pairs and the stack's width.</summary>
+public partial class BraggReflectorPartView : UserControl
+{
+ public BraggReflectorPartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/FiberPartView.xaml b/WaveDudeNext.WPF/Views/FiberPartView.xaml
new file mode 100644
index 0000000..8217bdb
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/FiberPartView.xaml
@@ -0,0 +1,56 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.FiberPartView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionCore}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.CoreIndex}" />
+ <controls:NumberBox Text="{Binding CoreIndex}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:FiberPart.CoreIndex}" AutomationProperties.AutomationId="PartCoreIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.CoreDiameter}" />
+ <controls:NumberBox Text="{Binding CoreDiameter}" Minimum="2" ToolTip="{meta:Hint model:FiberPart.CoreDiameter}" AutomationProperties.AutomationId="PartCoreDiameter" />
+ </controls:FormPanel>
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionCladding}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.CladdingIndex}" />
+ <controls:NumberBox Text="{Binding CladdingIndex}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:FiberPart.CladdingIndex}" AutomationProperties.AutomationId="PartCladdingIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.CladdingThickness}" />
+ <controls:NumberBox Text="{Binding CladdingThickness}" Minimum="0" ToolTip="{meta:Hint model:FiberPart.CladdingThickness}" AutomationProperties.AutomationId="PartCladdingThickness" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:FiberPart.Coating}" />
+ <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}" />
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs b/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs
new file mode 100644
index 0000000..0a07a8e
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/FiberPartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.FiberPart"/>: core, cladding and the path.</summary>
+public partial class FiberPartView : UserControl
+{
+ public FiberPartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/GrinLensPartView.xaml b/WaveDudeNext.WPF/Views/GrinLensPartView.xaml
new file mode 100644
index 0000000..b6adc38
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/GrinLensPartView.xaml
@@ -0,0 +1,54 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.GrinLensPartView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionMaterial}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:GrinLensPart.CentreIndex}" />
+ <controls:NumberBox Text="{Binding CentreIndex}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:GrinLensPart.CentreIndex}" AutomationProperties.AutomationId="PartCentreIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:GrinLensPart.EdgeIndex}" />
+ <controls:NumberBox Text="{Binding EdgeIndex}" Minimum="1" Maximum="2.55" Increment="0.01" ToolTip="{meta:Hint model:GrinLensPart.EdgeIndex}" AutomationProperties.AutomationId="PartEdgeIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:GrinLensPart.Coating}" />
+ <controls:NumberBox Text="{Binding Coating}" Minimum="0" Maximum="50" ToolTip="{meta:Hint model:GrinLensPart.Coating}" AutomationProperties.AutomationId="PartCoating" />
+ </controls:FormPanel>
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:GrinLensPart.Length}" />
+ <controls:NumberBox Text="{Binding Length}" Minimum="1" Increment="10" ToolTip="{meta:Hint model:GrinLensPart.Length}" AutomationProperties.AutomationId="PartLength" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:GrinLensPart.Diameter}" />
+ <controls:NumberBox Text="{Binding Diameter}" Minimum="2" Increment="10" ToolTip="{meta:Hint model:GrinLensPart.Diameter}" AutomationProperties.AutomationId="PartDiameter" />
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/GrinLensPartView.xaml.cs b/WaveDudeNext.WPF/Views/GrinLensPartView.xaml.cs
new file mode 100644
index 0000000..b76246e
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/GrinLensPartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.GrinLensPart"/>: the index profile and the rectangle.</summary>
+public partial class GrinLensPartView : UserControl
+{
+ public GrinLensPartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/LensPartView.xaml b/WaveDudeNext.WPF/Views/LensPartView.xaml
new file mode 100644
index 0000000..503dc19
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/LensPartView.xaml
@@ -0,0 +1,73 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.LensPartView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <UserControl.Resources>
+ <!-- a mirror has no index and no coating -->
+ <Style x:Key="GlassOnly" TargetType="{x:Type controls:NumberBox}" BasedOn="{StaticResource {x:Type controls:NumberBox}}">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Mirror}" Value="True">
+ <Setter Property="IsEnabled" Value="False" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </UserControl.Resources>
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionMaterial}" />
+ <controls:FormPanel>
+ <CheckBox controls:FormPanel.FullWidth="True" Content="{meta:Label model:LensPart.Mirror}"
+ IsChecked="{Binding Mirror}" ToolTip="{meta:Hint model:LensPart.Mirror}" AutomationProperties.AutomationId="PartMirror" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.RefractiveIndex}" />
+ <controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding RefractiveIndex}" Minimum="1" Maximum="2.55" Increment="0.01"
+ ToolTip="{meta:Hint model:LensPart.RefractiveIndex}" AutomationProperties.AutomationId="PartIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.Coating}" />
+ <controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding Coating}" Minimum="0" Maximum="50"
+ ToolTip="{meta:Hint model:LensPart.Coating}" AutomationProperties.AutomationId="PartCoating" />
+ </controls:FormPanel>
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.Diameter}" />
+ <controls:NumberBox Text="{Binding Diameter}" Minimum="2" Increment="10" ToolTip="{meta:Hint model:LensPart.Diameter}" AutomationProperties.AutomationId="PartDiameter" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.R1}" />
+ <controls:NumberBox Text="{Binding R1}" Increment="10" ToolTip="{meta:Hint model:LensPart.R1}" AutomationProperties.AutomationId="PartR1" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.R2}" />
+ <controls:NumberBox Text="{Binding R2}" Increment="10" ToolTip="{meta:Hint model:LensPart.R2}" AutomationProperties.AutomationId="PartR2" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:LensPart.Thickness}" />
+ <controls:NumberBox Text="{Binding Thickness}" Minimum="1" ToolTip="{meta:Hint model:LensPart.Thickness}" AutomationProperties.AutomationId="PartThickness" />
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/LensPartView.xaml.cs b/WaveDudeNext.WPF/Views/LensPartView.xaml.cs
new file mode 100644
index 0000000..41e491e
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/LensPartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.LensPart"/>: a lens or a curved or flat mirror.</summary>
+public partial class LensPartView : UserControl
+{
+ public LensPartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/OutlinePartView.xaml b/WaveDudeNext.WPF/Views/OutlinePartView.xaml
new file mode 100644
index 0000000..cbfcb88
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/OutlinePartView.xaml
@@ -0,0 +1,32 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.OutlinePartView"
+ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views">
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+ <views:ShapeMaterialView />
+ <views:PartPointsView HintText="{DynamicResource HintPolygonPoints}" />
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/OutlinePartView.xaml.cs b/WaveDudeNext.WPF/Views/OutlinePartView.xaml.cs
new file mode 100644
index 0000000..5391882
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/OutlinePartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for an <see cref="WaveDudeNext.Model.OutlinePart"/>: the material and the point list.</summary>
+public partial class OutlinePartView : UserControl
+{
+ public OutlinePartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/PartCommonView.xaml b/WaveDudeNext.WPF/Views/PartCommonView.xaml
new file mode 100644
index 0000000..f84c1b0
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PartCommonView.xaml
@@ -0,0 +1,50 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.PartCommonView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <!-- the members every part has: name, enabled, centre and angle; placed first in each kind's form -->
+ <StackPanel>
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionGeneral}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:OpticalPart.Name}" />
+ <TextBox Text="{Binding Name, UpdateSourceTrigger=PropertyChanged}" ToolTip="{meta:Hint model:OpticalPart.Name}" AutomationProperties.AutomationId="PartName" />
+
+ <CheckBox controls:FormPanel.FullWidth="True" Content="{meta:Label model:OpticalPart.Enabled}"
+ IsChecked="{Binding Enabled}" ToolTip="{meta:Hint model:OpticalPart.Enabled}" />
+ </controls:FormPanel>
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionPosition}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:OpticalPart.X}" />
+ <controls:NumberBox Text="{Binding X}" Minimum="0" ToolTip="{meta:Hint model:OpticalPart.X}" AutomationProperties.AutomationId="PartX" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:OpticalPart.Y}" />
+ <controls:NumberBox Text="{Binding Y}" Minimum="0" ToolTip="{meta:Hint model:OpticalPart.Y}" AutomationProperties.AutomationId="PartY" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:OpticalPart.Angle}" />
+ <controls:NumberBox Text="{Binding Angle}" Minimum="-180" Maximum="180" Increment="5" ToolTip="{meta:Hint model:OpticalPart.Angle}" AutomationProperties.AutomationId="PartAngleBox" />
+ </controls:FormPanel>
+ </StackPanel>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/PartCommonView.xaml.cs b/WaveDudeNext.WPF/Views/PartCommonView.xaml.cs
new file mode 100644
index 0000000..40fd229
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PartCommonView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>The part of every optical part's editor that is the same for each kind: name, enabled, centre and angle (<see cref="WaveDudeNext.Model.OpticalPart"/>).</summary>
+public partial class PartCommonView : UserControl
+{
+ public PartCommonView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/PartPointsView.xaml b/WaveDudeNext.WPF/Views/PartPointsView.xaml
new file mode 100644
index 0000000..22c6070
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PartPointsView.xaml
@@ -0,0 +1,97 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.PartPointsView"
+ 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.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
+ and Y relative to the centre, before rotation, a remove button, and an add button below -->
+ <StackPanel>
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionPoints}" />
+ <TextBlock Margin="0,0,0,4" Foreground="{DynamicResource GrayText}" TextWrapping="Wrap" Text="{Binding HintText, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" />
+ <DockPanel Margin="0,0,0,2">
+ <Border DockPanel.Dock="Right" Width="22" />
+ <UniformGrid Columns="2">
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PartPoint.X}" Margin="2,0" />
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PartPoint.Y}" Margin="2,0" />
+ </UniformGrid>
+ </DockPanel>
+ <ItemsControl x:Name="list" ItemsSource="{Binding Points}" Focusable="False">
+ <ItemsControl.ItemTemplate>
+ <DataTemplate>
+ <DockPanel Margin="0,0,0,4">
+ <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}" />
+ </UniformGrid>
+ </DockPanel>
+ </DataTemplate>
+ </ItemsControl.ItemTemplate>
+ </ItemsControl>
+ <StackPanel Orientation="Horizontal" Margin="0,0,0,10">
+ <Button Padding="8,2" Margin="0,2,6,0" Content="{DynamicResource ButtonAddPoint}" ToolTip="{DynamicResource TipAddPoint}"
+ Command="{x:Static commands:PartCommands.AddPoint}" AutomationProperties.AutomationId="PartAddPoint" />
+ </StackPanel>
+ </StackPanel>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs b/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs
new file mode 100644
index 0000000..1881b7d
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PartPointsView.xaml.cs
@@ -0,0 +1,83 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Collections.ObjectModel;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Input;
+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).
+/// </summary>
+public partial class PartPointsView : UserControl
+{
+ /// <summary>Identifies the <see cref="HintText"/> property.</summary>
+ public static readonly DependencyProperty HintTextProperty = DependencyProperty.Register(
+ nameof(HintText), typeof(string), typeof(PartPointsView), new PropertyMetadata(""));
+
+ /// <summary>How far a new point is put from the last one, in canvas pixels.</summary>
+ private const int NewPointStep = 20;
+
+ public PartPointsView()
+ {
+ InitializeComponent();
+ }
+
+ /// <summary>The line above the list saying what the points are (an outline, a path); set by the kind's form.</summary>
+ public string HintText
+ {
+ get => (string)GetValue(HintTextProperty);
+ 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,
+ };
+
+ private void CanAddPoint(object sender, CanExecuteRoutedEventArgs e) => e.CanExecute = Points != null;
+
+ /// <summary>Appends a point a step to the right of the last one (at the centre for an empty list).</summary>
+ private void OnAddPoint(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (Points is not { } points)
+ {
+ return;
+ }
+ PartPoint? last = points.LastOrDefault();
+ points.Add(new PartPoint { X = (last?.X ?? -NewPointStep) + NewPointStep, Y = last?.Y ?? 0 });
+ }
+
+ private void CanRemovePoint(object sender, CanExecuteRoutedEventArgs e) =>
+ e.CanExecute = e.Parameter is PartPoint point && Points?.Contains(point) == true;
+
+ private void OnRemovePoint(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (e.Parameter is PartPoint point)
+ {
+ Points?.Remove(point);
+ }
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/PolygonPartView.xaml b/WaveDudeNext.WPF/Views/PolygonPartView.xaml
new file mode 100644
index 0000000..77d39a2
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PolygonPartView.xaml
@@ -0,0 +1,43 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.PolygonPartView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+ <views:ShapeMaterialView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PolygonPart.Sides}" />
+ <controls:NumberBox Text="{Binding Sides}" Minimum="3" Maximum="64" ToolTip="{meta:Hint model:PolygonPart.Sides}" AutomationProperties.AutomationId="PartSides" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:PolygonPart.Side}" />
+ <controls:NumberBox Text="{Binding Side}" Minimum="2" Increment="10" ToolTip="{meta:Hint model:PolygonPart.Side}" AutomationProperties.AutomationId="PartSide" />
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/PolygonPartView.xaml.cs b/WaveDudeNext.WPF/Views/PolygonPartView.xaml.cs
new file mode 100644
index 0000000..a82dd0b
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/PolygonPartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.PolygonPart"/>: a regular polygon or a free outline, glass or mirror.</summary>
+public partial class PolygonPartView : UserControl
+{
+ public PolygonPartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/RectanglePartView.xaml b/WaveDudeNext.WPF/Views/RectanglePartView.xaml
new file mode 100644
index 0000000..1e4b950
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/RectanglePartView.xaml
@@ -0,0 +1,52 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.RectanglePartView"
+ 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:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <UserControl.CommandBindings>
+ <CommandBinding Command="{x:Static commands:PartCommands.MakeSquare}" CanExecute="CanMakeSquare" Executed="OnMakeSquare" />
+ </UserControl.CommandBindings>
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+ <views:ShapeMaterialView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:RectanglePart.Length}" />
+ <controls:NumberBox Text="{Binding Length}" Minimum="1" Increment="10" ToolTip="{meta:Hint model:RectanglePart.Length}" AutomationProperties.AutomationId="PartLength" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:RectanglePart.Width}" />
+ <controls:NumberBox Text="{Binding Width}" Minimum="1" Increment="10" ToolTip="{meta:Hint model:RectanglePart.Width}" AutomationProperties.AutomationId="PartWidth" />
+
+ <!-- the Square button (the user's request, 2026-10-18): the width takes the length -->
+ <Button controls:FormPanel.FullWidth="True" HorizontalAlignment="Left" Padding="8,2" Margin="0,2,0,0" Content="{DynamicResource ButtonSquare}" ToolTip="{DynamicResource TipSquare}"
+ Command="{x:Static commands:PartCommands.MakeSquare}" AutomationProperties.AutomationId="PartSquare" />
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/RectanglePartView.xaml.cs b/WaveDudeNext.WPF/Views/RectanglePartView.xaml.cs
new file mode 100644
index 0000000..036957f
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/RectanglePartView.xaml.cs
@@ -0,0 +1,42 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+using System.Windows.Input;
+using WaveDudeNext.Model;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="RectanglePart"/>: length, width and a Square button that copies the length into the width.</summary>
+public partial class RectanglePartView : UserControl
+{
+ public RectanglePartView()
+ {
+ InitializeComponent();
+ }
+
+ private void CanMakeSquare(object sender, CanExecuteRoutedEventArgs e) =>
+ e.CanExecute = DataContext is RectanglePart rectangle && rectangle.Width != rectangle.Length;
+
+ private void OnMakeSquare(object sender, ExecutedRoutedEventArgs e)
+ {
+ if (DataContext is RectanglePart rectangle)
+ {
+ rectangle.Width = rectangle.Length;
+ }
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml b/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml
new file mode 100644
index 0000000..456c09b
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml
@@ -0,0 +1,54 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.ShapeMaterialView"
+ 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:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <UserControl.Resources>
+ <!-- a mirror has no index and no coating -->
+ <Style x:Key="GlassOnly" TargetType="{x:Type controls:NumberBox}" BasedOn="{StaticResource {x:Type controls:NumberBox}}">
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Mirror}" Value="True">
+ <Setter Property="IsEnabled" Value="False" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </UserControl.Resources>
+
+ <!-- the material of a shape part (polygon, rectangle, triangle, outline): mirror or glass, the index, the coating -->
+ <StackPanel>
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionMaterial}" />
+ <controls:FormPanel>
+ <CheckBox controls:FormPanel.FullWidth="True" Content="{meta:Label model:ShapePart.Mirror}"
+ IsChecked="{Binding Mirror}" ToolTip="{meta:Hint model:ShapePart.Mirror}" AutomationProperties.AutomationId="PartMirror" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.RefractiveIndex}" />
+ <controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding RefractiveIndex}" Minimum="1" Maximum="2.55" Increment="0.01"
+ ToolTip="{meta:Hint model:ShapePart.RefractiveIndex}" AutomationProperties.AutomationId="PartIndex" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:ShapePart.Coating}" />
+ <controls:NumberBox Style="{StaticResource GlassOnly}" Text="{Binding Coating}" Minimum="0" Maximum="50"
+ ToolTip="{meta:Hint model:ShapePart.Coating}" AutomationProperties.AutomationId="PartCoating" />
+ </controls:FormPanel>
+ </StackPanel>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml.cs b/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml.cs
new file mode 100644
index 0000000..e9530d5
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/ShapeMaterialView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>The material section shared by the shape parts (<see cref="WaveDudeNext.Model.ShapePart"/>): mirror, index, coating.</summary>
+public partial class ShapeMaterialView : UserControl
+{
+ public ShapeMaterialView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext.WPF/Views/TrianglePartView.xaml b/WaveDudeNext.WPF/Views/TrianglePartView.xaml
new file mode 100644
index 0000000..0b0f550
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/TrianglePartView.xaml
@@ -0,0 +1,87 @@
+<!--
+SPDX-License-Identifier: GPL-3.0-or-later
+Copyright (C) 2026 Alexander Graef <[email protected]>
+
+This file is part of WaveDude Next, a 2D wave simulator.
+
+Based on the work of
+ JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+ <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+ Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+ <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+
+WaveDude Next is free software: you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free Software
+Foundation, either version 3 of the License, or (at your option) any later
+version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+<https://www.gnu.org/licenses/>.
+-->
+
+<UserControl x:Class="WaveDudeNext.WPF.Views.TrianglePartView"
+ 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:converters="clr-namespace:WaveDudeNext.WPF.Converters"
+ xmlns:meta="clr-namespace:WaveDudeNext.WPF.Markup"
+ xmlns:views="clr-namespace:WaveDudeNext.WPF.Views"
+ xmlns:model="clr-namespace:WaveDudeNext.Model;assembly=WaveDudeNext">
+
+ <UserControl.Resources>
+ <converters:TriangleApexConverter x:Key="ApexAngle" />
+ <!-- the presets fix the angles: A is typed for the isosceles and custom types, B for custom only -->
+ <Style x:Key="AngleABox" TargetType="{x:Type controls:NumberBox}" BasedOn="{StaticResource {x:Type controls:NumberBox}}">
+ <Setter Property="IsEnabled" Value="False" />
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Type}" Value="Isosceles">
+ <Setter Property="IsEnabled" Value="True" />
+ </DataTrigger>
+ <DataTrigger Binding="{Binding Type}" Value="Custom">
+ <Setter Property="IsEnabled" Value="True" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ <Style x:Key="AngleBBox" TargetType="{x:Type controls:NumberBox}" BasedOn="{StaticResource {x:Type controls:NumberBox}}">
+ <Setter Property="IsEnabled" Value="False" />
+ <Style.Triggers>
+ <DataTrigger Binding="{Binding Type}" Value="Custom">
+ <Setter Property="IsEnabled" Value="True" />
+ </DataTrigger>
+ </Style.Triggers>
+ </Style>
+ </UserControl.Resources>
+
+ <ScrollViewer VerticalScrollBarVisibility="Auto" HorizontalScrollBarVisibility="Disabled">
+ <StackPanel Margin="8">
+ <views:PartCommonView />
+ <views:ShapeMaterialView />
+
+ <Label Style="{StaticResource FormSection}" Content="{DynamicResource SectionShape}" />
+ <controls:FormPanel>
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:TrianglePart.Type}" />
+ <ComboBox Style="{StaticResource EnumComboBox}" ItemsSource="{meta:EnumValues model:TriangleType}"
+ SelectedItem="{Binding Type}" ToolTip="{meta:Hint model:TrianglePart.Type}" AutomationProperties.AutomationId="PartTriangleType" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:TrianglePart.Base}" />
+ <controls:NumberBox Text="{Binding Base}" Minimum="2" Increment="10" ToolTip="{meta:Hint model:TrianglePart.Base}" AutomationProperties.AutomationId="PartBase" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:TrianglePart.AngleA}" />
+ <controls:NumberBox Style="{StaticResource AngleABox}" Text="{Binding AngleA}" Minimum="1" Maximum="178" ToolTip="{meta:Hint model:TrianglePart.AngleA}" AutomationProperties.AutomationId="PartAngleA" />
+
+ <TextBlock Style="{StaticResource FormLabel}" Text="{meta:Label model:TrianglePart.AngleB}" />
+ <controls:NumberBox Style="{StaticResource AngleBBox}" Text="{Binding AngleB}" Minimum="1" Maximum="178" ToolTip="{meta:Hint model:TrianglePart.AngleB}" AutomationProperties.AutomationId="PartAngleB" />
+
+ <!-- read-only: what the two base angles leave for the apex -->
+ <TextBlock Style="{StaticResource FormLabel}" Text="{DynamicResource LabelApexAngle}" />
+ <TextBlock VerticalAlignment="Center" ToolTip="{DynamicResource TipApexAngle}" AutomationProperties.AutomationId="PartApexAngle">
+ <TextBlock.Text>
+ <MultiBinding Converter="{StaticResource ApexAngle}">
+ <Binding Path="Type" />
+ <Binding Path="AngleA" />
+ <Binding Path="AngleB" />
+ </MultiBinding>
+ </TextBlock.Text>
+ </TextBlock>
+ </controls:FormPanel>
+ </StackPanel>
+ </ScrollViewer>
+</UserControl>
diff --git a/WaveDudeNext.WPF/Views/TrianglePartView.xaml.cs b/WaveDudeNext.WPF/Views/TrianglePartView.xaml.cs
new file mode 100644
index 0000000..6ce7711
--- /dev/null
+++ b/WaveDudeNext.WPF/Views/TrianglePartView.xaml.cs
@@ -0,0 +1,29 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Windows.Controls;
+
+namespace WaveDudeNext.WPF.Views;
+
+/// <summary>Editor for a <see cref="WaveDudeNext.Model.TrianglePart"/>: the type preset, the base and the base angles, the apex angle read-only.</summary>
+public partial class TrianglePartView : UserControl
+{
+ public TrianglePartView()
+ {
+ InitializeComponent();
+ }
+}
diff --git a/WaveDudeNext/Model/OpticalPart.cs b/WaveDudeNext/Model/OpticalPart.cs
new file mode 100644
index 0000000..9b9ee76
--- /dev/null
+++ b/WaveDudeNext/Model/OpticalPart.cs
@@ -0,0 +1,1108 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using System.Collections.ObjectModel;
+using System.ComponentModel;
+using System.Xml.Serialization;
+
+namespace WaveDudeNext.Model;
+
+/// <summary>The kinds of optical part; one subclass of <see cref="OpticalPart"/> and one project file element per kind.</summary>
+public enum PartKind
+{
+ /// <summary>A lens or a curved or flat mirror (<see cref="LensPart"/>).</summary>
+ Lens,
+ /// <summary>A regular polygon (<see cref="PolygonPart"/>).</summary>
+ Polygon,
+ /// <summary>A rectangle (<see cref="RectanglePart"/>).</summary>
+ Rectangle,
+ /// <summary>A triangle shaped by its base angles (<see cref="TrianglePart"/>).</summary>
+ Triangle,
+ /// <summary>A free outline from a point list (<see cref="OutlinePart"/>).</summary>
+ Outline,
+ /// <summary>A fibre with a core and a cladding along a path (<see cref="FiberPart"/>).</summary>
+ Fiber,
+ /// <summary>A stack of alternating layers (<see cref="BraggReflectorPart"/>).</summary>
+ BraggReflector,
+ /// <summary>A gradient-index lens (<see cref="GrinLensPart"/>).</summary>
+ GrinLens,
+}
+
+/// <summary>
+/// An optical part placed on the canvas: a lens or mirror, a shape (polygon, rectangle, triangle, outline), a fibre, a
+/// Bragg reflector or a GRIN lens (Jeroen
+/// Vleggaar's proposal, decided 2026-10-18). Parts are painted into the red channel of the scene pixels before a run
+/// (<see cref="Parts.PartPainter"/>), so the engines, the outline and the export see them as part of the scene;
+/// green and blue are never touched. Positions and lengths are canvas pixels; the angle is in degrees,
+/// counter-clockwise on the screen, 0 pointing the part's axis along +x (the composite source's convention).
+/// Refractive indices run from 1.00 to 2.55 in steps of 0.01 (red = index × 100). One subclass per kind; the kind is
+/// chosen when the part is added and never changes.
+/// </summary>
+public abstract class OpticalPart : ObservableObject
+{
+ /// <summary>Smallest refractive index a part can have.</summary>
+ public const double MinIndex = 1.0;
+ /// <summary>Largest refractive index a part can have (red 255).</summary>
+ public const double MaxIndex = 2.55;
+ /// <summary>Largest coating thickness in pixels.</summary>
+ public const int MaxCoating = 50;
+
+ private string _name = "";
+ private bool _enabled = true;
+ private int _x;
+ private int _y;
+ private double _angle;
+
+ /// <summary>Name shown in the project tree and on the canvas; must be non-blank.</summary>
+ [XmlAttribute]
+ [Category("General")]
+ [Description("Name shown in the project tree and on the canvas.")]
+ public string Name
+ {
+ get => _name;
+ set => SetProperty(ref _name, value);
+ }
+
+ /// <summary>Whether the part is painted into the scene; a disabled part has no effect on a run.</summary>
+ [XmlAttribute]
+ [DefaultValue(true)]
+ [Category("General")]
+ [Description("Paint the part into the scene; a disabled part has no effect on a run.")]
+ public bool Enabled
+ {
+ get => _enabled;
+ set => SetProperty(ref _enabled, value);
+ }
+
+ /// <summary>X of the part's centre in canvas pixels.</summary>
+ [XmlAttribute]
+ [Category("Position")]
+ [Description("X of the part's centre in canvas pixels.")]
+ public int X
+ {
+ get => _x;
+ set => SetProperty(ref _x, value);
+ }
+
+ /// <summary>Y of the part's centre in canvas pixels.</summary>
+ [XmlAttribute]
+ [Category("Position")]
+ [Description("Y of the part's centre in canvas pixels.")]
+ public int Y
+ {
+ get => _y;
+ set => SetProperty(ref _y, value);
+ }
+
+ /// <summary>Rotation about the centre in degrees, counter-clockwise on the screen; 0 points the part's axis along +x.</summary>
+ [XmlAttribute]
+ [DefaultValue(0.0)]
+ [Category("Position")]
+ [DisplayName("Angle")]
+ [Description("Rotation about the centre in degrees, counter-clockwise on the screen. 0 points the part's axis to the right.")]
+ public double Angle
+ {
+ get => _angle;
+ set => SetProperty(ref _angle, value);
+ }
+
+ /// <summary>The kind of part, for the tree row and the overlay; fixed per subclass.</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public abstract PartKind Kind { get; }
+
+ /// <summary>Half-extent of the part along its axis in canvas pixels, so the rotation handle can sit beyond it. UI thread.</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public abstract double AxisReach { get; }
+
+ /// <summary>Clamps every value into its valid range; the angle is brought into (-180, 180].</summary>
+ public virtual void Normalize()
+ {
+ Name ??= "";
+ X = Math.Max(0, X);
+ Y = Math.Max(0, Y);
+ Angle = NormalizeAngle(Angle);
+ }
+
+ /// <summary>A deep copy with the same settings and no change subscribers.</summary>
+ public abstract OpticalPart Clone();
+
+ /// <summary>The name, for display in the project tree and property grids.</summary>
+ public override string ToString() => Name;
+
+ /// <summary>Brings an angle in degrees into (-180, 180]; a non-finite value becomes 0.</summary>
+ protected static double NormalizeAngle(double degrees)
+ {
+ if (!double.IsFinite(degrees))
+ {
+ return 0.0;
+ }
+ if (degrees <= -180.0 || degrees > 180.0)
+ {
+ degrees -= 360.0 * Math.Ceiling((degrees - 180.0) / 360.0);
+ }
+ return degrees;
+ }
+
+ /// <summary>A refractive index clamped to <see cref="MinIndex"/>..<see cref="MaxIndex"/> and rounded to 0.01 (red = index × 100); a non-finite value becomes 1.</summary>
+ protected static double NormalizeIndex(double index) =>
+ double.IsFinite(index) ? Math.Round(Math.Clamp(index, MinIndex, MaxIndex), 2) : MinIndex;
+
+ /// <summary>Deep-copies a point list.</summary>
+ protected static ObservableCollection<PartPoint> ClonePoints(ObservableCollection<PartPoint> points) =>
+ 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>
+public sealed class PartPoint : ObservableObject
+{
+ private int _x;
+ private int _y;
+
+ /// <summary>X relative to the part's centre in canvas pixels, before rotation.</summary>
+ [XmlAttribute]
+ [Category("Point")]
+ [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("Point")]
+ [Description("Y relative to the part's centre in canvas pixels, before rotation.")]
+ public int Y
+ {
+ get => _y;
+ set => SetProperty(ref _y, value);
+ }
+
+ /// <summary>The coordinates, for display.</summary>
+ public override string ToString() => $"({X}, {Y})";
+}
+
+/// <summary>
+/// A lens, or a curved or flat mirror when <see cref="Mirror"/> is set: the strip of <see cref="Diameter"/> across
+/// the axis between two spherical surfaces of radii <see cref="R1"/> (left, facing -x') and <see cref="R2"/>
+/// (right), <see cref="Thickness"/> apart on the axis. A radius is signed: R1 &gt; 0 and R2 &lt; 0 bulge outward
+/// (biconvex), 0 is flat, and |R| is at least half the diameter. Where two convex surfaces cross, the lens ends.
+/// </summary>
+public sealed class LensPart : OpticalPart
+{
+ /// <summary>Default <see cref="RefractiveIndex"/>.</summary>
+ public const double DefaultIndex = 1.5;
+ /// <summary>Default <see cref="Diameter"/> in pixels.</summary>
+ public const int DefaultDiameter = 200;
+ /// <summary>Default <see cref="R1"/> in pixels.</summary>
+ public const double DefaultR1 = 300.0;
+ /// <summary>Default <see cref="R2"/> in pixels.</summary>
+ public const double DefaultR2 = -300.0;
+ /// <summary>Default <see cref="Thickness"/> in pixels.</summary>
+ public const int DefaultThickness = 40;
+
+ private bool _mirror;
+ private double _refractiveIndex = DefaultIndex;
+ private int _coating;
+ private int _diameter = DefaultDiameter;
+ private double _r1 = DefaultR1;
+ private double _r2 = DefaultR2;
+ private int _thickness = DefaultThickness;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Lens;
+
+ /// <summary>Whether the part is a mirror (red 0, a wall no wave gets through) instead of a lens; the index and the coating are ignored then.</summary>
+ [XmlAttribute]
+ [DefaultValue(false)]
+ [Category("Material")]
+ [Description("Make the part a mirror instead of a lens. The refractive index and the coating are ignored then.")]
+ public bool Mirror
+ {
+ get => _mirror;
+ set => SetProperty(ref _mirror, value);
+ }
+
+ /// <summary>Refractive index of the glass, 1.00 to 2.55 in steps of 0.01; not used by a mirror.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultIndex)]
+ [Category("Material")]
+ [DisplayName("Refractive index")]
+ [Description("Refractive index of the glass, 1.00 to 2.55 in steps of 0.01.")]
+ public double RefractiveIndex
+ {
+ get => _refractiveIndex;
+ set => SetProperty(ref _refractiveIndex, value);
+ }
+
+ /// <summary>Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none. A quarter-wave coating is λ / (4 √n) thick.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Material")]
+ [DisplayName("AR coating")]
+ [Description("Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none. A quarter-wave coating is λ / (4 √n) pixels thick, λ being the wavelength the source form shows.")]
+ public int Coating
+ {
+ get => _coating;
+ set => SetProperty(ref _coating, value);
+ }
+
+ /// <summary>Extent across the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultDiameter)]
+ [Category("Shape")]
+ [Description("Extent across the axis in pixels.")]
+ public int Diameter
+ {
+ get => _diameter;
+ set => SetProperty(ref _diameter, value);
+ }
+
+ /// <summary>Radius of the first surface (facing -x') in pixels: positive bulges outward, negative is concave, 0 is flat.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultR1)]
+ [Category("Shape")]
+ [DisplayName("R1")]
+ [Description("Radius of the first surface in pixels: positive bulges outward, negative is concave, 0 is flat.")]
+ public double R1
+ {
+ get => _r1;
+ set => SetProperty(ref _r1, value);
+ }
+
+ /// <summary>Radius of the second surface (facing +x') in pixels: negative bulges outward, positive is concave, 0 is flat.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultR2)]
+ [Category("Shape")]
+ [DisplayName("R2")]
+ [Description("Radius of the second surface in pixels: negative bulges outward, positive is concave, 0 is flat.")]
+ public double R2
+ {
+ get => _r2;
+ set => SetProperty(ref _r2, value);
+ }
+
+ /// <summary>Distance between the two surfaces on the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultThickness)]
+ [Category("Shape")]
+ [DisplayName("Centre thickness")]
+ [Description("Distance between the two surfaces on the axis in pixels.")]
+ public int Thickness
+ {
+ get => _thickness;
+ set => SetProperty(ref _thickness, value);
+ }
+
+ /// <inheritdoc/>
+ public override double AxisReach => Thickness / 2.0 + Math.Max(Sag(R1), Sag(R2));
+
+ /// <summary>How far a surface of radius <paramref name="r"/> bows out beyond its vertex at the lens edge, in pixels.</summary>
+ private double Sag(double r)
+ {
+ if (r == 0.0)
+ {
+ return 0.0;
+ }
+ double a = Math.Abs(r);
+ double h = Math.Min(a, Diameter / 2.0);
+ return a - Math.Sqrt(a * a - h * h);
+ }
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ RefractiveIndex = NormalizeIndex(RefractiveIndex);
+ Coating = Math.Clamp(Coating, 0, MaxCoating);
+ Diameter = Math.Max(2, Diameter);
+ Thickness = Math.Max(1, Thickness);
+ R1 = NormalizeRadius(R1);
+ R2 = NormalizeRadius(R2);
+ }
+
+ /// <summary>A radius of at least half the diameter in magnitude, its sign kept; 0 stays flat.</summary>
+ private double NormalizeRadius(double r)
+ {
+ if (!double.IsFinite(r) || r == 0.0)
+ {
+ return 0.0;
+ }
+ double least = Diameter / 2.0;
+ return Math.Abs(r) < least ? Math.CopySign(least, r) : r;
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<LensPart>();
+}
+
+/// <summary>
+/// A part that is a plain shape of glass or mirror: the shared material (<see cref="Mirror"/>, <see cref="RefractiveIndex"/>,
+/// <see cref="Coating"/>) over an outline each subclass generates (<see cref="Vertices"/>): a regular
+/// <see cref="PolygonPart"/>, a <see cref="RectanglePart"/>, a <see cref="TrianglePart"/>, a free <see cref="OutlinePart"/>
+/// (one class each, chosen when the part is added: the user's point, 2026-10-18, against a shape mode inside one class).
+/// </summary>
+public abstract class ShapePart : OpticalPart
+{
+ /// <summary>Default <see cref="RefractiveIndex"/>.</summary>
+ public const double DefaultIndex = 1.5;
+
+ private bool _mirror;
+ private double _refractiveIndex = DefaultIndex;
+ private int _coating;
+
+ /// <summary>Whether the part is a mirror (red 0, a wall no wave gets through) instead of glass; the index and the coating are ignored then.</summary>
+ [XmlAttribute]
+ [DefaultValue(false)]
+ [Category("Material")]
+ [Description("Make the part a mirror instead of glass. The refractive index and the coating are ignored then.")]
+ public bool Mirror
+ {
+ get => _mirror;
+ set => SetProperty(ref _mirror, value);
+ }
+
+ /// <summary>Refractive index of the glass, 1.00 to 2.55 in steps of 0.01; not used by a mirror.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultIndex)]
+ [Category("Material")]
+ [DisplayName("Refractive index")]
+ [Description("Refractive index of the glass, 1.00 to 2.55 in steps of 0.01.")]
+ public double RefractiveIndex
+ {
+ get => _refractiveIndex;
+ set => SetProperty(ref _refractiveIndex, value);
+ }
+
+ /// <summary>Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Material")]
+ [DisplayName("AR coating")]
+ [Description("Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none. A quarter-wave coating is λ / (4 √n) pixels thick, λ being the wavelength the source form shows.")]
+ public int Coating
+ {
+ get => _coating;
+ set => SetProperty(ref _coating, value);
+ }
+
+ /// <summary>The outline's vertices relative to the centre, before rotation, in canvas pixels; fewer than three paint nothing. Out-of-range values are guarded, not written back.</summary>
+ public abstract (double X, double Y)[] Vertices();
+
+ /// <inheritdoc/>
+ public override double AxisReach => Vertices().Select(v => Math.Abs(v.X)).DefaultIfEmpty(0.0).Max();
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ RefractiveIndex = NormalizeIndex(RefractiveIndex);
+ Coating = Math.Clamp(Coating, 0, MaxCoating);
+ }
+}
+
+/// <summary>
+/// A regular polygon of <see cref="Sides"/> sides of <see cref="Side"/> pixels, a face centred on -x' (toward a source on
+/// the left); for an odd count the first vertex lies on +x'.
+/// </summary>
+public sealed class PolygonPart : ShapePart
+{
+ /// <summary>Default <see cref="Sides"/>.</summary>
+ public const int DefaultSides = 6;
+ /// <summary>Smallest <see cref="Sides"/>.</summary>
+ public const int MinSides = 3;
+ /// <summary>Largest <see cref="Sides"/>.</summary>
+ public const int MaxSides = 64;
+ /// <summary>Default <see cref="Side"/> in pixels.</summary>
+ public const int DefaultSide = 60;
+
+ private int _sides = DefaultSides;
+ private int _side = DefaultSide;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Polygon;
+
+ /// <summary>Number of sides, 3 to 64.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultSides)]
+ [Category("Shape")]
+ [DisplayName("Number of sides")]
+ [Description("Number of sides, 3 to 64.")]
+ public int Sides
+ {
+ get => _sides;
+ set => SetProperty(ref _sides, value);
+ }
+
+ /// <summary>Length of each side in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultSide)]
+ [Category("Shape")]
+ [DisplayName("Side length")]
+ [Description("Length of each side in pixels.")]
+ public int Side
+ {
+ get => _side;
+ set => SetProperty(ref _side, value);
+ }
+
+ /// <summary>Circumradius in pixels: side / (2 sin(π / sides)).</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public double Circumradius => Math.Max(2, Side) / (2.0 * Math.Sin(Math.PI / Math.Clamp(Sides, MinSides, MaxSides)));
+
+ /// <inheritdoc/>
+ public override (double X, double Y)[] Vertices()
+ {
+ int sides = Math.Clamp(Sides, MinSides, MaxSides);
+ double radius = Circumradius;
+ var vertices = new (double X, double Y)[sides];
+ for (int k = 0; k < sides; k++)
+ {
+ double theta = Math.PI + (2 * k + 1) * Math.PI / sides;
+ vertices[k] = (radius * Math.Cos(theta), radius * Math.Sin(theta));
+ }
+ return vertices;
+ }
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Sides = Math.Clamp(Sides, MinSides, MaxSides);
+ Side = Math.Max(2, Side);
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<PolygonPart>();
+}
+
+/// <summary>A rectangle of <see cref="Length"/> along the axis and <see cref="Width"/> across, centred. A flat mirror is a long, narrow one.</summary>
+public sealed class RectanglePart : ShapePart
+{
+ /// <summary>Default <see cref="Length"/> and <see cref="Width"/> in pixels.</summary>
+ public const int DefaultSize = 60;
+
+ private int _length = DefaultSize;
+ private int _width = DefaultSize;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Rectangle;
+
+ /// <summary>Extent along the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultSize)]
+ [Category("Shape")]
+ [Description("Extent along the axis in pixels.")]
+ public int Length
+ {
+ get => _length;
+ set => SetProperty(ref _length, value);
+ }
+
+ /// <summary>Extent across the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultSize)]
+ [Category("Shape")]
+ [Description("Extent across the axis in pixels.")]
+ public int Width
+ {
+ get => _width;
+ set => SetProperty(ref _width, value);
+ }
+
+ /// <inheritdoc/>
+ public override (double X, double Y)[] Vertices()
+ {
+ double l = Math.Max(1, Length) / 2.0;
+ double w = Math.Max(1, Width) / 2.0;
+ return [(-l, -w), (l, -w), (l, w), (-l, w)];
+ }
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Length = Math.Max(1, Length);
+ Width = Math.Max(1, Width);
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<RectanglePart>();
+}
+
+/// <summary>The presets of a <see cref="TrianglePart"/>: which base angles are fixed.</summary>
+public enum TriangleType
+{
+ /// <summary>Both base angles 60°.</summary>
+ Equilateral,
+ /// <summary>Both base angles 45°: the right angle at the apex (the total-internal-reflection prism).</summary>
+ RightIsosceles,
+ /// <summary>Base angles 90° and 30°: the right angle at the first end of the base.</summary>
+ ThirtySixtyNinety,
+ /// <summary>Both base angles the same, typed once.</summary>
+ Isosceles,
+ /// <summary>Both base angles typed.</summary>
+ Custom,
+}
+
+/// <summary>
+/// A triangle on a <see cref="Base"/> across the axis (the face toward a source on the left, at -x'), the apex pointing
+/// along +x', shaped by its two base angles <see cref="AngleA"/> (at the -y' end) and <see cref="AngleB"/> (at the +y'
+/// end); the apex angle is what remains of 180°. A <see cref="Type"/> preset fixes the angles.
+/// </summary>
+public sealed class TrianglePart : ShapePart
+{
+ /// <summary>Default <see cref="Base"/> in pixels.</summary>
+ public const int DefaultBase = 60;
+ /// <summary>Largest base angle; the two must leave something for the apex.</summary>
+ public const double MaxAngle = 178.0;
+
+ private int _base = DefaultBase;
+ private TriangleType _type = TriangleType.Equilateral;
+ private double _angleA = 60.0;
+ private double _angleB = 60.0;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Triangle;
+
+ /// <summary>Length of the base in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultBase)]
+ [Category("Shape")]
+ [Description("Length of the base in pixels; the base lies across the axis, toward a source on the left.")]
+ public int Base
+ {
+ get => _base;
+ set => SetProperty(ref _base, value);
+ }
+
+ /// <summary>The preset: equilateral, right isosceles (45°), 30-60-90, isosceles with one typed angle, or custom with both typed. Choosing one sets the angles.</summary>
+ [XmlAttribute]
+ [DefaultValue(TriangleType.Equilateral)]
+ [Category("Shape")]
+ [Description("Equilateral, right isosceles (the 45° prism), 30-60-90, isosceles with one typed angle, or custom with both typed.")]
+ public TriangleType Type
+ {
+ get => _type;
+ set
+ {
+ if (SetProperty(ref _type, value))
+ {
+ ApplyPreset();
+ }
+ }
+ }
+
+ /// <summary>Base angle at the first end of the base (-y'), in degrees; typed for the isosceles and custom types.</summary>
+ [XmlAttribute]
+ [DefaultValue(60.0)]
+ [Category("Shape")]
+ [DisplayName("Angle A")]
+ [Description("Base angle at the first end of the base, in degrees. Typed for the isosceles and custom types; the presets fix it.")]
+ public double AngleA
+ {
+ get => _angleA;
+ set
+ {
+ if (SetProperty(ref _angleA, value) && Type == TriangleType.Isosceles)
+ {
+ AngleB = value;
+ }
+ }
+ }
+
+ /// <summary>Base angle at the second end of the base (+y'), in degrees; typed for the custom type only.</summary>
+ [XmlAttribute]
+ [DefaultValue(60.0)]
+ [Category("Shape")]
+ [DisplayName("Angle B")]
+ [Description("Base angle at the second end of the base, in degrees. Typed for the custom type; the others fix it.")]
+ public double AngleB
+ {
+ get => _angleB;
+ set => SetProperty(ref _angleB, value);
+ }
+
+ /// <summary>The angle at the apex in degrees: 180 minus the two base angles (as the painter uses them).</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public double ApexAngle
+ {
+ get
+ {
+ (double a, double b) = EffectiveAngles();
+ return 180.0 - a - b;
+ }
+ }
+
+ /// <summary>The base angles the type gives, in degrees, within range and leaving at least 2° for the apex; the typed values for the custom type.</summary>
+ public (double A, double B) EffectiveAngles()
+ {
+ double a = double.IsFinite(AngleA) ? Math.Clamp(AngleA, 1.0, MaxAngle) : 60.0;
+ double b = double.IsFinite(AngleB) ? Math.Clamp(AngleB, 1.0, MaxAngle) : 60.0;
+ switch (Type)
+ {
+ case TriangleType.Equilateral:
+ return (60.0, 60.0);
+ case TriangleType.RightIsosceles:
+ return (45.0, 45.0);
+ case TriangleType.ThirtySixtyNinety:
+ return (90.0, 30.0);
+ case TriangleType.Isosceles:
+ a = Math.Min(a, 89.0);
+ return (a, a);
+ default:
+ return (a, Math.Min(b, MaxAngle + 1.0 - a));
+ }
+ }
+
+ /// <summary>Writes the type's angles into <see cref="AngleA"/> and <see cref="AngleB"/>.</summary>
+ private void ApplyPreset()
+ {
+ (double a, double b) = EffectiveAngles();
+ AngleA = a;
+ AngleB = b;
+ }
+
+ /// <inheritdoc/>
+ public override (double X, double Y)[] Vertices()
+ {
+ (double a, double b) = EffectiveAngles();
+ double alpha = a * Math.PI / 180.0;
+ double beta = b * Math.PI / 180.0;
+ double half = Math.Max(2, Base) / 2.0;
+ // the height from the law of sines, the apex over the base at h / tan α from the first end
+ double height = 2.0 * half * Math.Sin(alpha) * Math.Sin(beta) / Math.Sin(alpha + beta);
+ double apexY = -half + height * Math.Cos(alpha) / Math.Sin(alpha);
+ return [(-height / 2.0, -half), (-height / 2.0, half), (height / 2.0, apexY)];
+ }
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Base = Math.Max(2, Base);
+ ApplyPreset();
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<TrianglePart>();
+}
+
+/// <summary>A free outline from <see cref="Points"/>, relative to the centre before rotation; fewer than three points paint nothing.</summary>
+public sealed class OutlinePart : ShapePart
+{
+ private ObservableCollection<PartPoint> _points = [];
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Outline;
+
+ /// <summary>The outline's vertices relative to the centre, before rotation; fewer than three points paint nothing.</summary>
+ [XmlElement("Point")]
+ [Category("Shape")]
+ [DisplayName("Points")]
+ [Description("The outline's vertices relative to the centre, before rotation. Fewer than three points paint nothing.")]
+ public ObservableCollection<PartPoint> Points
+ {
+ get => _points;
+ set => SetProperty(ref _points, value);
+ }
+
+ /// <inheritdoc/>
+ public override (double X, double Y)[] Vertices() => Points.Select(p => ((double)p.X, (double)p.Y)).ToArray();
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Points ??= [];
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone()
+ {
+ var copy = ShallowClone<OutlinePart>();
+ copy.Points = ClonePoints(Points);
+ return copy;
+ }
+}
+
+/// <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.
+/// </summary>
+public sealed class FiberPart : OpticalPart
+{
+ /// <summary>Default <see cref="CoreIndex"/>.</summary>
+ public const double DefaultCoreIndex = 1.5;
+ /// <summary>Default <see cref="CoreDiameter"/> in pixels.</summary>
+ public const int DefaultCoreDiameter = 20;
+ /// <summary>Default <see cref="CladdingIndex"/>.</summary>
+ public const double DefaultCladdingIndex = 1.45;
+ /// <summary>Default <see cref="CladdingThickness"/> in pixels.</summary>
+ public const int DefaultCladdingThickness = 10;
+ /// <summary>Half the default path length in pixels: the path runs from (-100, 0) to (100, 0).</summary>
+ public const int DefaultHalfLength = 100;
+
+ private double _coreIndex = DefaultCoreIndex;
+ private int _coreDiameter = DefaultCoreDiameter;
+ private double _claddingIndex = DefaultCladdingIndex;
+ private int _claddingThickness = DefaultCladdingThickness;
+ private int _coating;
+ private ObservableCollection<PartPoint> _points = [];
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.Fiber;
+
+ /// <summary>Refractive index of the core, 1.00 to 2.55.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultCoreIndex)]
+ [Category("Core")]
+ [DisplayName("Core index")]
+ [Description("Refractive index of the core, 1.00 to 2.55 in steps of 0.01.")]
+ public double CoreIndex
+ {
+ get => _coreIndex;
+ set => SetProperty(ref _coreIndex, value);
+ }
+
+ /// <summary>Diameter of the core in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultCoreDiameter)]
+ [Category("Core")]
+ [DisplayName("Core diameter")]
+ [Description("Diameter of the core in pixels.")]
+ public int CoreDiameter
+ {
+ get => _coreDiameter;
+ set => SetProperty(ref _coreDiameter, value);
+ }
+
+ /// <summary>Refractive index of the cladding, 1.00 to 2.55; below the core's for guiding.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultCladdingIndex)]
+ [Category("Cladding")]
+ [DisplayName("Cladding index")]
+ [Description("Refractive index of the cladding, 1.00 to 2.55 in steps of 0.01. Below the core's index, the fibre guides.")]
+ public double CladdingIndex
+ {
+ get => _claddingIndex;
+ set => SetProperty(ref _claddingIndex, value);
+ }
+
+ /// <summary>Thickness of the cladding around the core in pixels; 0 for a bare core.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultCladdingThickness)]
+ [Category("Cladding")]
+ [DisplayName("Cladding thickness")]
+ [Description("Thickness of the cladding around the core in pixels; 0 for a bare core.")]
+ public int CladdingThickness
+ {
+ get => _claddingThickness;
+ set => SetProperty(ref _claddingThickness, value);
+ }
+
+ /// <summary>Thickness in pixels of the anti-reflection band just inside the outer boundary, with the index √n of the cladding (or the core when bare); 0 for none.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Cladding")]
+ [DisplayName("AR coating")]
+ [Description("Thickness in pixels of the anti-reflection band just inside the outer boundary, with the index √n; 0 for none.")]
+ public int Coating
+ {
+ get => _coating;
+ 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")]
+ [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
+ {
+ get => _points;
+ set => SetProperty(ref _points, value);
+ }
+
+ /// <summary>Outer radius in pixels: half the core diameter plus the cladding.</summary>
+ [XmlIgnore]
+ [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 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.
+ /// </summary>
+ public static ObservableCollection<PartPoint> DefaultPath() =>
+ [new PartPoint { X = -DefaultHalfLength, Y = 0 }, new PartPoint { X = DefaultHalfLength, Y = 0 }];
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ CoreIndex = NormalizeIndex(CoreIndex);
+ CladdingIndex = NormalizeIndex(CladdingIndex);
+ CoreDiameter = Math.Max(2, CoreDiameter);
+ CladdingThickness = Math.Max(0, CladdingThickness);
+ Coating = Math.Clamp(Coating, 0, MaxCoating);
+ Points ??= [];
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone()
+ {
+ var copy = ShallowClone<FiberPart>();
+ copy.Points = ClonePoints(Points);
+ return copy;
+ }
+}
+
+/// <summary>
+/// A Bragg reflector: <see cref="Pairs"/> pairs of layers of <see cref="Thickness1"/> and <see cref="Thickness2"/>
+/// pixels with the indices <see cref="Index1"/> and <see cref="Index2"/>, stacked along +x', the stack centred on
+/// the part's centre and <see cref="Width"/> across. Thicknesses are pixels as typed; a quarter-wave layer is
+/// λ / (4 n) pixels.
+/// </summary>
+public sealed class BraggReflectorPart : OpticalPart
+{
+ /// <summary>Default <see cref="Pairs"/>.</summary>
+ public const int DefaultPairs = 10;
+ /// <summary>Largest <see cref="Pairs"/>.</summary>
+ public const int MaxPairs = 200;
+ /// <summary>Default layer thickness in pixels.</summary>
+ public const int DefaultThickness = 10;
+ /// <summary>Default <see cref="Index1"/>.</summary>
+ public const double DefaultIndex1 = 1.5;
+ /// <summary>Default <see cref="Index2"/>.</summary>
+ public const double DefaultIndex2 = 2.0;
+ /// <summary>Default <see cref="Width"/> in pixels.</summary>
+ public const int DefaultWidth = 200;
+
+ private int _pairs = DefaultPairs;
+ private int _thickness1 = DefaultThickness;
+ private int _thickness2 = DefaultThickness;
+ private double _index1 = DefaultIndex1;
+ private double _index2 = DefaultIndex2;
+ private int _width = DefaultWidth;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.BraggReflector;
+
+ /// <summary>Number of layer pairs, 1 to 200.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultPairs)]
+ [Category("Layers")]
+ [DisplayName("Layer pairs")]
+ [Description("Number of layer pairs, 1 to 200.")]
+ public int Pairs
+ {
+ get => _pairs;
+ set => SetProperty(ref _pairs, value);
+ }
+
+ /// <summary>Thickness of the first layer of each pair in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultThickness)]
+ [Category("Layers")]
+ [DisplayName("Thickness 1")]
+ [Description("Thickness of the first layer of each pair in pixels. A quarter-wave layer is λ / (4 n) pixels thick.")]
+ public int Thickness1
+ {
+ get => _thickness1;
+ set => SetProperty(ref _thickness1, value);
+ }
+
+ /// <summary>Thickness of the second layer of each pair in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultThickness)]
+ [Category("Layers")]
+ [DisplayName("Thickness 2")]
+ [Description("Thickness of the second layer of each pair in pixels. A quarter-wave layer is λ / (4 n) pixels thick.")]
+ public int Thickness2
+ {
+ get => _thickness2;
+ set => SetProperty(ref _thickness2, value);
+ }
+
+ /// <summary>Refractive index of the first layer of each pair, 1.00 to 2.55.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultIndex1)]
+ [Category("Layers")]
+ [DisplayName("Index 1")]
+ [Description("Refractive index of the first layer of each pair, 1.00 to 2.55 in steps of 0.01.")]
+ public double Index1
+ {
+ get => _index1;
+ set => SetProperty(ref _index1, value);
+ }
+
+ /// <summary>Refractive index of the second layer of each pair, 1.00 to 2.55.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultIndex2)]
+ [Category("Layers")]
+ [DisplayName("Index 2")]
+ [Description("Refractive index of the second layer of each pair, 1.00 to 2.55 in steps of 0.01.")]
+ public double Index2
+ {
+ get => _index2;
+ set => SetProperty(ref _index2, value);
+ }
+
+ /// <summary>Extent of the stack across the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultWidth)]
+ [Category("Shape")]
+ [Description("Extent of the stack across the axis in pixels.")]
+ public int Width
+ {
+ get => _width;
+ set => SetProperty(ref _width, value);
+ }
+
+ /// <summary>Total thickness of the stack along the axis in pixels.</summary>
+ [XmlIgnore]
+ [Browsable(false)]
+ public int Length => Pairs * (Thickness1 + Thickness2);
+
+ /// <inheritdoc/>
+ public override double AxisReach => Length / 2.0;
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Pairs = Math.Clamp(Pairs, 1, MaxPairs);
+ Thickness1 = Math.Max(1, Thickness1);
+ Thickness2 = Math.Max(1, Thickness2);
+ Index1 = NormalizeIndex(Index1);
+ Index2 = NormalizeIndex(Index2);
+ Width = Math.Max(2, Width);
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<BraggReflectorPart>();
+}
+
+/// <summary>
+/// A gradient-index lens: a rectangle of <see cref="Length"/> along the axis and <see cref="Diameter"/> across whose
+/// index falls from <see cref="CentreIndex"/> on the axis to <see cref="EdgeIndex"/> at the edge as
+/// n(y') = n_c − (n_c − n_e)·(2y'/D)².
+/// </summary>
+public sealed class GrinLensPart : OpticalPart
+{
+ /// <summary>Default <see cref="Length"/> in pixels.</summary>
+ public const int DefaultLength = 100;
+ /// <summary>Default <see cref="Diameter"/> in pixels.</summary>
+ public const int DefaultDiameter = 100;
+ /// <summary>Default <see cref="CentreIndex"/>.</summary>
+ public const double DefaultCentreIndex = 1.8;
+ /// <summary>Default <see cref="EdgeIndex"/>.</summary>
+ public const double DefaultEdgeIndex = 1.5;
+
+ private int _length = DefaultLength;
+ private int _diameter = DefaultDiameter;
+ private double _centreIndex = DefaultCentreIndex;
+ private double _edgeIndex = DefaultEdgeIndex;
+ private int _coating;
+
+ /// <inheritdoc/>
+ public override PartKind Kind => PartKind.GrinLens;
+
+ /// <summary>Extent along the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultLength)]
+ [Category("Shape")]
+ [Description("Extent along the axis in pixels.")]
+ public int Length
+ {
+ get => _length;
+ set => SetProperty(ref _length, value);
+ }
+
+ /// <summary>Extent across the axis in pixels.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultDiameter)]
+ [Category("Shape")]
+ [Description("Extent across the axis in pixels.")]
+ public int Diameter
+ {
+ get => _diameter;
+ set => SetProperty(ref _diameter, value);
+ }
+
+ /// <summary>Refractive index on the axis, 1.00 to 2.55.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultCentreIndex)]
+ [Category("Material")]
+ [DisplayName("Centre index")]
+ [Description("Refractive index on the axis, 1.00 to 2.55 in steps of 0.01.")]
+ public double CentreIndex
+ {
+ get => _centreIndex;
+ set => SetProperty(ref _centreIndex, value);
+ }
+
+ /// <summary>Refractive index at the edge, 1.00 to 2.55; the profile between is parabolic.</summary>
+ [XmlAttribute]
+ [DefaultValue(DefaultEdgeIndex)]
+ [Category("Material")]
+ [DisplayName("Edge index")]
+ [Description("Refractive index at the edge, 1.00 to 2.55 in steps of 0.01. The profile between the axis and the edge is parabolic.")]
+ public double EdgeIndex
+ {
+ get => _edgeIndex;
+ set => SetProperty(ref _edgeIndex, value);
+ }
+
+ /// <summary>Thickness in pixels of the anti-reflection band just inside the outline, with the index √n of the local index; 0 for none.</summary>
+ [XmlAttribute]
+ [DefaultValue(0)]
+ [Category("Material")]
+ [DisplayName("AR coating")]
+ [Description("Thickness in pixels of the anti-reflection band just inside the outline, with the index √n; 0 for none.")]
+ public int Coating
+ {
+ get => _coating;
+ set => SetProperty(ref _coating, value);
+ }
+
+ /// <inheritdoc/>
+ public override double AxisReach => Length / 2.0;
+
+ /// <inheritdoc/>
+ public override void Normalize()
+ {
+ base.Normalize();
+ Length = Math.Max(1, Length);
+ Diameter = Math.Max(2, Diameter);
+ CentreIndex = NormalizeIndex(CentreIndex);
+ EdgeIndex = NormalizeIndex(EdgeIndex);
+ Coating = Math.Clamp(Coating, 0, MaxCoating);
+ }
+
+ /// <inheritdoc/>
+ public override OpticalPart Clone() => ShallowClone<GrinLensPart>();
+}
diff --git a/WaveDudeNext/Model/Project.cs b/WaveDudeNext/Model/Project.cs
index e67016f..8d0f1e4 100644
--- a/WaveDudeNext/Model/Project.cs
+++ b/WaveDudeNext/Model/Project.cs
@@ -25,10 +25,10 @@ using WaveDudeNext.Rendering;
namespace WaveDudeNext.Model;
/// <summary>
-/// A wave simulation project: the scene, solver and display settings plus the sources and
-/// probes. Persisted as sparse XML through <see cref="XmlSerializer"/>: scalars are attributes,
-/// sources and probes are repeated <c>Source</c> and <c>Probe</c> elements directly under the
-/// root, and values equal to their defaults are left out. Properties carry
+/// A wave simulation project: the scene, solver and display settings plus the sources, optical
+/// parts and probes. Persisted as sparse XML through <see cref="XmlSerializer"/>: scalars are attributes,
+/// sources, parts and probes are repeated <c>Source</c>, <c>Lens</c> … <c>GrinLens</c> and <c>Probe</c> elements
+/// directly under the root, and values equal to their defaults are left out. Properties carry
/// <see cref="System.ComponentModel"/> metadata for property grids.
/// </summary>
[XmlRoot("Project")]
@@ -44,6 +44,7 @@ public sealed class Project : ObservableObject
private Simulation _simulation = new();
private Display _display = new();
private ObservableCollection<Source> _sources = new();
+ private ObservableCollection<OpticalPart> _parts = new();
private ObservableCollection<Probe> _probes = new();
private ObservableCollection<ColorScheme> _colorSchemes = new();
/// <summary>Each project scheme's last known name, so a rename can repoint the layers that referred to the old one.</summary>
@@ -145,6 +146,27 @@ public sealed class Project : ObservableObject
set => SetProperty(ref _sources, value);
}
+ /// <summary>
+ /// Optical parts (lenses, mirrors, polygons, rectangles, triangles, outlines, fibres, Bragg reflectors, GRIN lenses), in the order they appear in
+ /// the project tree, which is the order they are painted in: a later part paints over an earlier one. One element
+ /// name per kind in the file (2026-10-18, the user's choice, so a schema can say what each element needs).
+ /// Observable; always present, empty in a new project.
+ /// </summary>
+ [XmlElement("Lens", typeof(LensPart))]
+ [XmlElement("Polygon", typeof(PolygonPart))]
+ [XmlElement("Rectangle", typeof(RectanglePart))]
+ [XmlElement("Triangle", typeof(TrianglePart))]
+ [XmlElement("Outline", typeof(OutlinePart))]
+ [XmlElement("Fiber", typeof(FiberPart))]
+ [XmlElement("BraggReflector", typeof(BraggReflectorPart))]
+ [XmlElement("GrinLens", typeof(GrinLensPart))]
+ [Browsable(false)]
+ public ObservableCollection<OpticalPart> Parts
+ {
+ get => _parts;
+ set => SetProperty(ref _parts, value);
+ }
+
/// <summary>
/// Probes, in the order they appear in the project tree. Observable so that views follow
/// additions and removals; always present, empty in a new project.
@@ -311,6 +333,46 @@ public sealed class Project : ObservableObject
return source;
}
+ /// <summary>
+ /// Appends a new part of <paramref name="kind"/>, named "Lens n", "Polygon n", "Rectangle n", "Triangle n", "Outline n",
+ /// "Fiber n", "Bragg reflector n" or "GRIN lens n" with the first free n, centred on the canvas (the scene's size; an image scene's own size is not
+ /// known here), and returns it.
+ /// </summary>
+ public OpticalPart AddPart(PartKind kind)
+ {
+ OpticalPart part = kind switch
+ {
+ PartKind.Lens => new LensPart(),
+ PartKind.Polygon => new PolygonPart(),
+ PartKind.Rectangle => new RectanglePart(),
+ PartKind.Triangle => new TrianglePart(),
+ PartKind.Outline => new OutlinePart(),
+ PartKind.Fiber => new FiberPart { Points = FiberPart.DefaultPath() },
+ PartKind.BraggReflector => new BraggReflectorPart(),
+ PartKind.GrinLens => new GrinLensPart(),
+ _ => throw new ArgumentOutOfRangeException(nameof(kind)),
+ };
+ part.Name = NumberedName(PartStem(kind), Parts.Select(p => p.Name));
+ part.X = Scene.Width / 2;
+ part.Y = Scene.Height / 2;
+ Parts.Add(part);
+ return part;
+ }
+
+ /// <summary>The English name stem of new parts of <paramref name="kind"/> ("Lens", "Bragg reflector", …).</summary>
+ public static string PartStem(PartKind kind) => kind switch
+ {
+ PartKind.Lens => "Lens",
+ PartKind.Polygon => "Polygon",
+ PartKind.Rectangle => "Rectangle",
+ PartKind.Triangle => "Triangle",
+ PartKind.Outline => "Outline",
+ PartKind.Fiber => "Fiber",
+ PartKind.BraggReflector => "Bragg reflector",
+ PartKind.GrinLens => "GRIN lens",
+ _ => "Part",
+ };
+
/// <summary>Appends a new probe named "Probe n" with the first free n, and returns it.</summary>
public Probe AddProbe()
{
@@ -361,6 +423,15 @@ public sealed class Project : ObservableObject
return copy;
}
+ /// <summary>Inserts a copy of <paramref name="part"/> right after it, named "&lt;name&gt; copy", and returns the copy.</summary>
+ public OpticalPart Duplicate(OpticalPart part)
+ {
+ OpticalPart copy = part.Clone();
+ copy.Name = CopyName(part.Name, Parts.Select(p => p.Name));
+ Parts.Insert(Parts.IndexOf(part) + 1, copy);
+ return copy;
+ }
+
/// <summary>Inserts a copy of <paramref name="probe"/> right after it, named "&lt;name&gt; copy", and returns the copy.</summary>
public Probe Duplicate(Probe probe)
{
@@ -373,12 +444,18 @@ public sealed class Project : ObservableObject
/// <summary>Removes the source; false when it was not in the project.</summary>
public bool Remove(Source source) => Sources.Remove(source);
+ /// <summary>Removes the part; false when it was not in the project.</summary>
+ public bool Remove(OpticalPart part) => Parts.Remove(part);
+
/// <summary>Removes the probe; false when it was not in the project.</summary>
public bool Remove(Probe probe) => Probes.Remove(probe);
/// <summary>Moves the source so that it ends up at <paramref name="index"/>; false when nothing changed.</summary>
public bool Move(Source source, int index) => Move(Sources, source, index);
+ /// <summary>Moves the part so that it ends up at <paramref name="index"/>; false when nothing changed.</summary>
+ public bool Move(OpticalPart part, int index) => Move(Parts, part, index);
+
/// <summary>Moves the probe so that it ends up at <paramref name="index"/>; false when nothing changed.</summary>
public bool Move(Probe probe, int index) => Move(Probes, probe, index);
@@ -436,7 +513,7 @@ public sealed class Project : ObservableObject
/// <summary>Writes the project to <paramref name="path"/>, replacing an existing file.</summary>
public void Save(string path)
{
- Logger.Info("Saving project to '{Path}' ({Sources} sources, {Probes} probes)", path, Sources.Count, Probes.Count);
+ Logger.Info("Saving project to '{Path}' ({Sources} sources, {Parts} parts, {Probes} probes)", path, Sources.Count, Parts.Count, Probes.Count);
using FileStream stream = File.Create(path);
Save(stream);
}
@@ -458,7 +535,7 @@ public sealed class Project : ObservableObject
Logger.Warn("Project file version {Version} is newer than the supported {Supported}; unknown settings are ignored", project.Version, CurrentVersion);
}
project.Normalize();
- Logger.Debug("Loaded project: version {Version}, seed {Seed}, {Sources} sources, {Probes} probes", project.Version, project.Seed, project.Sources.Count, project.Probes.Count);
+ Logger.Debug("Loaded project: version {Version}, seed {Seed}, {Sources} sources, {Parts} parts, {Probes} probes", project.Version, project.Seed, project.Sources.Count, project.Parts.Count, project.Probes.Count);
return project;
}
@@ -481,6 +558,10 @@ public sealed class Project : ObservableObject
source.Normalize();
source.GenerateElements(Seed);
}
+ foreach (OpticalPart part in Parts)
+ {
+ part.Normalize();
+ }
foreach (Probe probe in Probes)
{
probe.Normalize();
diff --git a/WaveDudeNext/Model/ProjectWatcher.cs b/WaveDudeNext/Model/ProjectWatcher.cs
index 74a9886..941024a 100644
--- a/WaveDudeNext/Model/ProjectWatcher.cs
+++ b/WaveDudeNext/Model/ProjectWatcher.cs
@@ -28,14 +28,15 @@ namespace WaveDudeNext.Model;
public sealed record ProjectChange(object Item, string? Property)
{
/// <summary>
- /// Whether the change alters the frames a run computes: the scene, the solver settings, the seed or a
- /// source. Display settings, probes (see <see cref="AffectsProbes"/>) and the description do not.
+ /// Whether the change alters the frames a run computes: the scene, the solver settings, the seed, a source or an
+ /// optical part (painted into the scene). Display settings, probes (see <see cref="AffectsProbes"/>) and the
+ /// description do not.
/// </summary>
public bool AffectsSimulation => Item switch
{
Scene when Property == nameof(Scene.ImagePath) => false,
- Scene or Simulation or Source or SourceArray => true,
- Project => Property is nameof(Project.Seed) or nameof(Project.Scene) or nameof(Project.Simulation) or nameof(Project.Sources),
+ Scene or Simulation or Source or SourceArray or OpticalPart or PartPoint => 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,
_ => false,
@@ -58,7 +59,8 @@ public sealed record ProjectChange(object Item, string? Property)
/// <summary>
/// Raises one event for any change anywhere in a <see cref="Project"/>: the nested settings objects, the
-/// source and probe lists and their items (re-subscribing when objects are replaced or items come and go).
+/// source, part and probe lists and their items, a part's point list included (re-subscribing when objects are
+/// replaced or items come and go).
/// The model has no aggregate notification of its own; this is it. UI thread, like the model.
/// </summary>
public sealed class ProjectWatcher : IDisposable
@@ -87,7 +89,7 @@ public sealed class ProjectWatcher : IDisposable
private void OnProjectPropertyChanged(object? sender, PropertyChangedEventArgs e)
{
- if (e.PropertyName is nameof(Project.Scene) or nameof(Project.Simulation) or nameof(Project.Display) or nameof(Project.Sources) or nameof(Project.Probes) or nameof(Project.ColorSchemes))
+ if (e.PropertyName is nameof(Project.Scene) or nameof(Project.Simulation) or nameof(Project.Display) or nameof(Project.Sources) or nameof(Project.Parts) or nameof(Project.Probes) or nameof(Project.ColorSchemes))
{
Resubscribe();
}
@@ -96,7 +98,8 @@ 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))
+ 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")
{
Resubscribe();
}
@@ -132,6 +135,20 @@ public sealed class ProjectWatcher : IDisposable
Subscribe(source.Array);
}
}
+ SubscribeCollection(_project.Parts);
+ 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)
+ {
+ SubscribeCollection(points);
+ foreach (PartPoint point in points)
+ {
+ Subscribe(point);
+ }
+ }
+ }
foreach (Probe probe in _project.Probes)
{
Subscribe(probe);
diff --git a/WaveDudeNext/Parts/PartPainter.cs b/WaveDudeNext/Parts/PartPainter.cs
new file mode 100644
index 0000000..7b4075e
--- /dev/null
+++ b/WaveDudeNext/Parts/PartPainter.cs
@@ -0,0 +1,158 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using NLog;
+using WaveDudeNext.Model;
+using WaveDudeNext.Runs;
+
+namespace WaveDudeNext.Parts;
+
+/// <summary>
+/// Paints the enabled <see cref="OpticalPart"/>s of a project into the red channel of the scene pixels, the
+/// channel the engines read as the refractive index (red = index × 100; red 0 is a mirror, see
+/// <see cref="Engine.SceneData.MirrorRefractiveIndex"/>). Green (image sources) and blue (damping) are never
+/// touched. Parts are painted in list order, a later one over an earlier one. Refractive parts are supersampled
+/// 4 × 4 per pixel and the sample indices averaged, a sample outside the part counting the pixel's existing index
+/// (red 0 as 1); a mirror part tests the pixel centre alone and writes red 0, since an averaged mirror edge would
+/// clamp to glass. Pure geometry, no UI; any thread. The per-kind tests are in <see cref="PartShape"/> so the
+/// harness can check them.
+/// </summary>
+public static class PartPainter
+{
+ private static readonly Logger Logger = LogManager.GetCurrentClassLogger();
+
+ /// <summary>Samples per pixel edge for refractive parts.</summary>
+ public const int Supersample = 4;
+
+ /// <summary>
+ /// The scene pixels with the enabled parts painted in: <paramref name="image"/> itself (the same reference, so
+ /// callers comparing by reference see no change) when no part is enabled, else a copy of the image, or a blank
+ /// canvas of <paramref name="width"/> × <paramref name="height"/> with red = round(<paramref name="backgroundIndex"/> × 100),
+ /// green 0, blue 0, alpha 255 when there is no image, with each enabled part painted in list order.
+ /// </summary>
+ /// <param name="image">The decoded scene image, or null for a blank canvas; never modified.</param>
+ /// <param name="width">Canvas width in pixels (the image's when there is one).</param>
+ /// <param name="height">Canvas height in pixels.</param>
+ /// <param name="backgroundIndex">Refractive index of a blank canvas (<see cref="Scene.RefractiveIndex"/>).</param>
+ /// <param name="parts">The project's parts; disabled ones are skipped.</param>
+ public static ScenePixels? Paint(ScenePixels? image, int width, int height, double backgroundIndex, IReadOnlyList<OpticalPart> parts)
+ {
+ if (!parts.Any(part => part.Enabled))
+ {
+ return image;
+ }
+ if (image != null)
+ {
+ width = image.Width;
+ height = image.Height;
+ }
+ int stride = width * 4;
+ byte[] bgra = new byte[stride * height];
+ if (image != null)
+ {
+ for (int y = 0; y < height; y++)
+ {
+ Buffer.BlockCopy(image.Bgra, y * image.StrideBytes, bgra, y * stride, stride);
+ }
+ }
+ else
+ {
+ byte red = (byte)Math.Clamp((int)Math.Round(backgroundIndex * 100.0), 0, 255);
+ for (int i = 0; i < bgra.Length; i += 4)
+ {
+ bgra[i + 2] = red;
+ bgra[i + 3] = 255;
+ }
+ }
+ foreach (OpticalPart part in parts)
+ {
+ if (part.Enabled)
+ {
+ Paint(bgra, width, height, stride, part);
+ }
+ }
+ return new ScenePixels(width, height, stride, bgra);
+ }
+
+ /// <summary>Paints one part into the red channel of <paramref name="bgra"/> (rows <paramref name="stride"/> bytes apart).</summary>
+ public static void Paint(byte[] bgra, int width, int height, int stride, OpticalPart part)
+ {
+ PartShape? shape = PartShape.For(part);
+ if (shape == null)
+ {
+ Logger.Debug("Part '{Name}' ({Kind}) has no shape to paint (too few points)", part.Name, part.Kind);
+ return;
+ }
+ (int x0, int y0, int x1, int y1) = shape.Bounds(width, height);
+ if (x0 > x1 || y0 > y1)
+ {
+ Logger.Debug("Part '{Name}' ({Kind}) lies outside the canvas", part.Name, part.Kind);
+ return;
+ }
+ Logger.Debug("Painting part '{Name}' ({Kind}) at ({X}, {Y}), {Angle}°, rows {Y0}..{Y1}", part.Name, part.Kind, part.X, part.Y, part.Angle, y0, y1);
+ if (shape.IsMirror)
+ {
+ Parallel.For(y0, y1 + 1, y =>
+ {
+ int row = y * stride;
+ for (int x = x0; x <= x1; x++)
+ {
+ if (shape.IndexAt(x + 0.5, y + 0.5) is not null)
+ {
+ bgra[row + x * 4 + 2] = 0;
+ }
+ }
+ });
+ return;
+ }
+ const double step = 1.0 / Supersample;
+ const double half = step / 2.0;
+ Parallel.For(y0, y1 + 1, y =>
+ {
+ int row = y * stride;
+ for (int x = x0; x <= x1; x++)
+ {
+ int offset = row + x * 4 + 2;
+ int red = bgra[offset];
+ // red 0 is a mirror the engine reads as index 1000; averaging it in as glass of index 1 is the user's rule
+ double existing = red == 0 ? 1.0 : red / 100.0;
+ double sum = 0.0;
+ int inside = 0;
+ for (int sy = 0; sy < Supersample; sy++)
+ {
+ for (int sx = 0; sx < Supersample; sx++)
+ {
+ double? index = shape.IndexAt(x + half + sx * step, y + half + sy * step);
+ if (index is { } n)
+ {
+ sum += n;
+ inside++;
+ }
+ else
+ {
+ sum += existing;
+ }
+ }
+ }
+ if (inside > 0)
+ {
+ bgra[offset] = (byte)Math.Clamp((int)Math.Round(sum / (Supersample * Supersample) * 100.0), 1, 255);
+ }
+ }
+ });
+ }
+}
diff --git a/WaveDudeNext/Parts/PartShape.cs b/WaveDudeNext/Parts/PartShape.cs
new file mode 100644
index 0000000..2f53422
--- /dev/null
+++ b/WaveDudeNext/Parts/PartShape.cs
@@ -0,0 +1,345 @@
+// SPDX-License-Identifier: GPL-3.0-or-later
+// Copyright (C) 2026 Alexander Graef <[email protected]>
+//
+// This file is part of WaveDude Next, a 2D wave simulator.
+//
+// Based on the work of
+// JJM Vleggaar (Huygens Optics), author of Wave Dude 2D, Copyright (C) 2026
+// <https://www.youtube.com/@HuygensOptics>, <https://www.huygensoptics.com>
+// Manuel (0x23, Diffraction Limited), author of WaveSimulator2D
+// <https://www.youtube.com/@DiffractionLimited>, <https://github.com/0x23/WaveSimulator2D>
+//
+// WaveDude Next is free software: you can redistribute it and/or modify it under
+// the terms of the GNU General Public License as published by the Free Software
+// Foundation, either version 3 of the License, or (at your option) any later
+// version. It is distributed WITHOUT ANY WARRANTY. See the LICENSE.md file or
+// <https://www.gnu.org/licenses/>.
+
+using WaveDudeNext.Model;
+
+namespace WaveDudeNext.Parts;
+
+/// <summary>
+/// The geometry of one <see cref="OpticalPart"/> as the painter sees it: a point of the canvas is mapped into the
+/// part's frame (the centre at the canvas point (X, Y), the top-left corner of pixel (X, Y), so a part of even size
+/// covers whole pixels; x' along the axis turned by the angle, counter-clockwise on the screen, y' across) and classified by <see cref="Depth"/>, how far inside the outline it lies, and
+/// <see cref="BodyIndex"/>, the refractive index there. <see cref="IndexAt"/> combines both with the coating band.
+/// Immutable once built from a part; any thread.
+/// </summary>
+public abstract class PartShape
+{
+ private readonly double _centreX;
+ private readonly double _centreY;
+ private readonly double _cos;
+ private readonly double _sin;
+
+ /// <param name="part">The part; its position and angle are read once.</param>
+ protected PartShape(OpticalPart part)
+ {
+ _centreX = part.X;
+ _centreY = part.Y;
+ double radians = part.Angle * Math.PI / 180.0;
+ _cos = Math.Cos(radians);
+ _sin = Math.Sin(radians);
+ }
+
+ /// <summary>
+ /// The shape of <paramref name="part"/>, or null when it has nothing to paint (an outline of fewer than three
+ /// points, a path of fewer than two). The part is read as it is, out-of-range values guarded here rather than
+ /// written back: a form edit reaches the painter before the model's <see cref="OpticalPart.Normalize"/> runs,
+ /// and normalising from inside a change handler would re-enter it.
+ /// </summary>
+ public static PartShape? For(OpticalPart part)
+ {
+ return part switch
+ {
+ 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),
+ BraggReflectorPart bragg => new BraggShape(bragg),
+ GrinLensPart grin => new GrinShape(grin),
+ _ => null,
+ };
+ }
+
+ /// <summary>Whether the part is a mirror: painted as red 0 by the pixel-centre test, no index, no coating.</summary>
+ public abstract bool IsMirror { get; }
+
+ /// <summary>Thickness of the anti-reflection band inside the outline in pixels; 0 for none.</summary>
+ protected abstract int Coating { get; }
+
+ /// <summary>Farthest the outline reaches from the centre, in pixels (a bound, not necessarily tight).</summary>
+ protected abstract double Extent { get; }
+
+ /// <summary>How far inside the outline the point (x', y') of the part frame lies, in pixels; negative outside. Exact for straight and circular edges.</summary>
+ protected abstract double Depth(double x, double y);
+
+ /// <summary>The refractive index at (x', y') of the part frame, the point being inside; a mirror returns 0.</summary>
+ protected abstract double BodyIndex(double x, double y);
+
+ /// <summary>The pixel rectangle (inclusive) the shape can touch, clipped to the canvas; empty (x0 &gt; x1) when it lies outside.</summary>
+ public (int X0, int Y0, int X1, int Y1) Bounds(int width, int height)
+ {
+ double extent = Extent + 1.0;
+ int x0 = Math.Max(0, (int)Math.Floor(_centreX - extent));
+ int y0 = Math.Max(0, (int)Math.Floor(_centreY - extent));
+ int x1 = Math.Min(width - 1, (int)Math.Ceiling(_centreX + extent));
+ int y1 = Math.Min(height - 1, (int)Math.Ceiling(_centreY + extent));
+ return (x0, y0, x1, y1);
+ }
+
+ /// <summary>
+ /// The refractive index the part gives the canvas point (<paramref name="canvasX"/>, <paramref name="canvasY"/>)
+ /// (continuous coordinates, pixel (x, y) spanning [x, x + 1)): null outside the outline, √n rounded to 0.01 in the
+ /// coating band, else the body index; 0 inside a mirror.
+ /// </summary>
+ public double? IndexAt(double canvasX, double canvasY)
+ {
+ // the inverse of the composite source's turn (x = dx cos + dy sin, y = dy cos - dx sin): the transpose
+ double ox = canvasX - _centreX;
+ double oy = canvasY - _centreY;
+ double x = ox * _cos - oy * _sin;
+ double y = ox * _sin + oy * _cos;
+ double depth = Depth(x, y);
+ if (depth < 0.0)
+ {
+ return null;
+ }
+ if (IsMirror)
+ {
+ return 0.0;
+ }
+ double index = BodyIndex(x, y);
+ return Coating > 0 && depth < Coating ? Math.Round(Math.Sqrt(index), 2) : index;
+ }
+
+ /// <summary>A refractive index within the part range.</summary>
+ protected static double GuardIndex(double index) => double.IsFinite(index) ? Math.Clamp(index, OpticalPart.MinIndex, OpticalPart.MaxIndex) : OpticalPart.MinIndex;
+
+ /// <summary>A coating thickness within range.</summary>
+ protected static int GuardCoating(int coating) => Math.Clamp(coating, 0, OpticalPart.MaxCoating);
+
+ /// <summary>Signed distance of (x, y) inside a simple polygon: the distance to the nearest edge, negative outside (even-odd rule).</summary>
+ protected static double PolygonDepth(ReadOnlySpan<(double X, double Y)> vertices, double x, double y)
+ {
+ bool inside = false;
+ double nearest = double.PositiveInfinity;
+ for (int i = 0, j = vertices.Length - 1; i < vertices.Length; j = i++)
+ {
+ (double ax, double ay) = vertices[j];
+ (double bx, double by) = vertices[i];
+ if (ay > y != by > y)
+ {
+ double crossX = ax + (y - ay) / (by - ay) * (bx - ax);
+ if (x < crossX)
+ {
+ inside = !inside;
+ }
+ }
+ nearest = Math.Min(nearest, SegmentDistance(ax, ay, bx, by, x, y));
+ }
+ return inside ? nearest : -nearest;
+ }
+
+ /// <summary>Distance from (x, y) to the segment a–b.</summary>
+ protected static double SegmentDistance(double ax, double ay, double bx, double by, double x, double y)
+ {
+ 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;
+ double px = ax + t * dx - x;
+ double py = ay + t * dy - y;
+ return Math.Sqrt(px * px + py * py);
+ }
+
+ private sealed class LensShape : PartShape
+ {
+ private readonly double _half;
+ private readonly double _vertex1;
+ private readonly double _vertex2;
+ private readonly double _r1;
+ private readonly double _r2;
+ private readonly double _index;
+ private readonly double _extent;
+
+ public LensShape(LensPart lens) : base(lens)
+ {
+ _half = Math.Max(1, lens.Diameter) / 2.0;
+ _vertex1 = -Math.Max(1, lens.Thickness) / 2.0;
+ _vertex2 = -_vertex1;
+ _r1 = GuardRadius(lens.R1, _half);
+ _r2 = GuardRadius(lens.R2, _half);
+ _index = GuardIndex(lens.RefractiveIndex);
+ IsMirror = lens.Mirror;
+ Coating = lens.Mirror ? 0 : GuardCoating(lens.Coating);
+ // the surfaces stay within the vertex and its sag at the lens edge, convex or concave
+ double reach = _vertex2 + Math.Max(Sag(_r1), Sag(_r2));
+ _extent = Math.Sqrt(reach * reach + _half * _half);
+ }
+
+ public override bool IsMirror { get; }
+ protected override int Coating { get; }
+ protected override double Extent => _extent;
+ protected override double BodyIndex(double x, double y) => _index;
+
+ /// <summary>How far a surface of radius <paramref name="radius"/> bows out beyond its vertex at the lens edge.</summary>
+ private double Sag(double radius) => radius == 0.0 ? 0.0 : Math.Abs(radius) - Math.Sqrt(radius * radius - _half * _half);
+
+ /// <summary>A radius of at least <paramref name="half"/> in magnitude, its sign kept; 0 stays flat (the model's rule, applied without writing back).</summary>
+ private static double GuardRadius(double radius, double half) =>
+ !double.IsFinite(radius) || radius == 0.0 ? 0.0 : Math.Abs(radius) < half ? Math.CopySign(half, radius) : radius;
+
+ /// <summary>The least of: inside the first surface, inside the second, within the half-diameter.</summary>
+ protected override double Depth(double x, double y) =>
+ Math.Min(Math.Min(SurfaceDepth(x, y, _vertex1, _r1, -1), SurfaceDepth(x, y, _vertex2, _r2, +1)), _half - Math.Abs(y));
+
+ /// <summary>
+ /// How far inside one surface (x', y') lies: the surface has its vertex at <paramref name="vertex"/> on the axis,
+ /// the lens interior on the side opposite to <paramref name="side"/> (-1 for the first surface, whose interior is
+ /// toward +x'). A radius of 0 is flat; the circle's centre is at vertex + radius, so the surface is convex when
+ /// radius and side have opposite signs. Distances are to the circle, so the coating band keeps its thickness
+ /// along the normal.
+ /// </summary>
+ private static double SurfaceDepth(double x, double y, double vertex, double radius, int side)
+ {
+ if (radius == 0.0)
+ {
+ return (x - vertex) * -side;
+ }
+ double centre = vertex + radius;
+ double along = (x - centre) * -side; // positive past the centre in the interior direction
+ double distance = Math.Sqrt((x - centre) * (x - centre) + y * y);
+ double magnitude = Math.Abs(radius);
+ if (radius * side < 0.0)
+ {
+ // convex: inside the circle, or beyond its centre (the arc is only the outer half)
+ return along > 0.0 ? magnitude : magnitude - distance;
+ }
+ // concave: outside the circle and on the interior side of its centre
+ return along < 0.0 ? double.NegativeInfinity : distance - magnitude;
+ }
+ }
+
+ /// <summary>A polygon, rectangle, triangle or outline: the part's vertices as a simple polygon.</summary>
+ private sealed class VertexShape : PartShape
+ {
+ private readonly (double X, double Y)[] _vertices;
+ private readonly double _index;
+ private readonly double _extent;
+
+ public VertexShape(ShapePart shape) : base(shape)
+ {
+ _vertices = shape.Vertices();
+ _index = GuardIndex(shape.RefractiveIndex);
+ IsMirror = shape.Mirror;
+ Coating = shape.Mirror ? 0 : GuardCoating(shape.Coating);
+ _extent = _vertices.Max(v => Math.Sqrt(v.X * v.X + v.Y * v.Y));
+ }
+
+ public override bool IsMirror { get; }
+ protected override int Coating { get; }
+ protected override double Extent => _extent;
+ protected override double Depth(double x, double y) => PolygonDepth(_vertices, x, y);
+ protected override double BodyIndex(double x, double y) => _index;
+ }
+
+ private sealed class FiberShape : PartShape
+ {
+ private readonly (double X, double Y)[] _path;
+ 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)
+ {
+ _path = fiber.Points.Select(p => ((double)p.X, (double)p.Y)).ToArray();
+ _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;
+ Coating = GuardCoating(fiber.Coating);
+ _extent = _path.Max(v => Math.Sqrt(v.X * v.X + v.Y * v.Y)) + _outerRadius;
+ }
+
+ public override bool IsMirror => false;
+ protected override int Coating { 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>
+ private double PathDistance(double x, double y)
+ {
+ double nearest = double.PositiveInfinity;
+ for (int i = 1; i < _path.Length; i++)
+ {
+ nearest = Math.Min(nearest, SegmentDistance(_path[i - 1].X, _path[i - 1].Y, _path[i].X, _path[i].Y, x, y));
+ }
+ return nearest;
+ }
+ }
+
+ private sealed class BraggShape : PartShape
+ {
+ private readonly double _halfLength;
+ private readonly double _halfWidth;
+ private readonly double _period;
+ private readonly double _thickness1;
+ private readonly double _index1;
+ private readonly double _index2;
+
+ public BraggShape(BraggReflectorPart bragg) : base(bragg)
+ {
+ _thickness1 = Math.Max(1, bragg.Thickness1);
+ _period = _thickness1 + Math.Max(1, bragg.Thickness2);
+ _halfLength = Math.Clamp(bragg.Pairs, 1, BraggReflectorPart.MaxPairs) * _period / 2.0;
+ _halfWidth = Math.Max(1, bragg.Width) / 2.0;
+ _index1 = GuardIndex(bragg.Index1);
+ _index2 = GuardIndex(bragg.Index2);
+ }
+
+ public override bool IsMirror => false;
+ protected override int Coating => 0;
+ protected override double Extent => Math.Sqrt(_halfLength * _halfLength + _halfWidth * _halfWidth);
+ protected override double Depth(double x, double y) => Math.Min(_halfLength - Math.Abs(x), _halfWidth - Math.Abs(y));
+
+ /// <summary>The first layer of a pair starts at -L/2 and the pairs repeat along +x'.</summary>
+ protected override double BodyIndex(double x, double y)
+ {
+ double along = (x + _halfLength) % _period;
+ return along < _thickness1 ? _index1 : _index2;
+ }
+ }
+
+ private sealed class GrinShape : PartShape
+ {
+ private readonly double _halfLength;
+ private readonly double _halfDiameter;
+ private readonly double _centreIndex;
+ private readonly double _edgeIndex;
+
+ public GrinShape(GrinLensPart grin) : base(grin)
+ {
+ _halfLength = Math.Max(1, grin.Length) / 2.0;
+ _halfDiameter = Math.Max(1, grin.Diameter) / 2.0;
+ _centreIndex = GuardIndex(grin.CentreIndex);
+ _edgeIndex = GuardIndex(grin.EdgeIndex);
+ Coating = GuardCoating(grin.Coating);
+ }
+
+ public override bool IsMirror => false;
+ protected override int Coating { get; }
+ protected override double Extent => Math.Sqrt(_halfLength * _halfLength + _halfDiameter * _halfDiameter);
+ protected override double Depth(double x, double y) => Math.Min(_halfLength - Math.Abs(x), _halfDiameter - Math.Abs(y));
+
+ /// <summary>n(y') = n_c − (n_c − n_e)·(y' / (D/2))².</summary>
+ protected override double BodyIndex(double x, double y)
+ {
+ double t = y / _halfDiameter;
+ return _centreIndex - (_centreIndex - _edgeIndex) * t * t;
+ }
+ }
+}
diff --git a/WaveDudeNext/Runs/RunSpec.cs b/WaveDudeNext/Runs/RunSpec.cs
index e063cce..3390ea4 100644
--- a/WaveDudeNext/Runs/RunSpec.cs
+++ b/WaveDudeNext/Runs/RunSpec.cs
@@ -54,7 +54,8 @@ public sealed class RunSpec
Height = height;
DampingEdge = project.Scene.DampingEdge;
RefractiveIndex = project.Scene.RefractiveIndex;
- ImageSources = image != null && project.Scene.ImageSources;
+ // a canvas scene with painted parts has pixels too, but no green to emit from (the parts never touch green)
+ ImageSources = project.Scene.Mode == SceneMode.Image && image != null && project.Scene.ImageSources;
Emitters = [.. Emitter.FromProject(project)];
Probes = [.. project.Probes.Where(probe => probe.Active).Select(ProbeSpec.From)];
}
@@ -105,7 +106,7 @@ public sealed class RunSpec
/// <summary>The planes every frame of the store holds.</summary>
public FrameLayers Layers => FrameLayers.Field | (TrackIntensity ? FrameLayers.Intensity : FrameLayers.None);
- /// <summary>The decoded scene image, or null for a blank canvas of <see cref="Width"/> × <see cref="Height"/>.</summary>
+ /// <summary>The scene pixels (the decoded image, or a canvas with painted optical parts), or null for a blank canvas of <see cref="Width"/> × <see cref="Height"/>.</summary>
public ScenePixels? Image { get; }
/// <summary>Canvas width in pixels.</summary>
@@ -134,7 +135,7 @@ public sealed class RunSpec
/// does that on load, reseed and add, not on edits). UI thread.
/// </summary>
/// <param name="project">The project to run; not modified beyond the emitter regeneration.</param>
- /// <param name="image">The decoded scene image when <see cref="Scene.Mode"/> is <see cref="SceneMode.Image"/>; ignored otherwise.</param>
+ /// <param name="image">The scene pixels: the decoded image when <see cref="Scene.Mode"/> is <see cref="SceneMode.Image"/>, with the optical parts painted in; for a canvas scene, the parts painted on a blank canvas of the scene's size, or null without parts (a canvas of another size is ignored).</param>
/// <param name="preferGpu">Try the OpenCL engine first (the application's choice; the CPU is the fallback either way).</param>
/// <param name="trackIntensity">Store the intensity plane even when nothing in the project needs it (an export of the intensity asks for it).</param>
/// <param name="quality">How much of the run to keep (the application's preview setting); null is <see cref="PreviewQuality.Full"/>.</param>
@@ -163,9 +164,12 @@ public sealed class RunSpec
}
else
{
- image = null;
width = project.Scene.Width;
height = project.Scene.Height;
+ if (image != null && (image.Width != width || image.Height != height))
+ {
+ image = null;
+ }
}
trackIntensity |= project.Display.Intensity.Preview
|| project.Probes.Any(probe => probe.Active && probe.Measurement != ProbeMeasurement.Amplitude);
diff --git a/_tools/library_check/Program.cs b/_tools/library_check/Program.cs
index fdd0a85..4a8f797 100644
--- a/_tools/library_check/Program.cs
+++ b/_tools/library_check/Program.cs
@@ -23,6 +23,7 @@ using NLog;
using WaveDudeNext.Engine;
using WaveDudeNext.Export;
using WaveDudeNext.Model;
+using WaveDudeNext.Parts;
using WaveDudeNext.Probes;
using WaveDudeNext.Rendering;
using WaveDudeNext.Runs;
@@ -31,7 +32,7 @@ namespace LibraryCheck;
// Drives the library end to end: CPU and (if available) GPU engines over the same scene and compares their
// fields, seed determinism, the model-to-emitter mapping, the frame store, the renderer, the colour scheme
-// files and a headless run. Exit code 0 = all checks passed.
+// files, the optical part painter and a headless run. Exit code 0 = all checks passed.
internal static class Program
{
private static int _failures;
@@ -219,6 +220,7 @@ internal static class Program
CheckColorSchemes();
CheckProbeGraph();
CheckImport();
+ CheckParts();
CheckRun();
ExportChecks.Run(Check);
@@ -1552,6 +1554,279 @@ internal static class Program
Check(refused, "a newer format version is refused");
}
+ /// <summary>Red at canvas pixel (x, y) of a painted scene.</summary>
+ private static int RedAt(ScenePixels pixels, int x, int y) => pixels.Bgra[y * pixels.StrideBytes + x * 4 + 2];
+
+ /// <summary>Sum over the canvas of the coverage a painted glass part of <paramref name="index"/> left on a background of index 1: the painted area in pixels.</summary>
+ private static double PaintedArea(ScenePixels pixels, double index)
+ {
+ double area = 0.0;
+ for (int y = 0; y < pixels.Height; y++)
+ {
+ for (int x = 0; x < pixels.Width; x++)
+ {
+ area += (RedAt(pixels, x, y) - 100) / ((index - 1.0) * 100.0);
+ }
+ }
+ return area;
+ }
+
+ private static void CheckParts()
+ {
+ Console.WriteLine("--- optical parts");
+ const int W = 200, H = 120;
+ (byte[] bgra, int stride) = ScenePixels(W, H);
+ bgra[5 * stride + 5 * 4] = 77; // blue at (5, 5), under the lens
+ bgra[60 * stride + 100 * 4 + 1] = 160; // green at the lens centre
+ bgra[60 * stride + 100 * 4] = 33; // blue at the lens centre
+ var image = new ScenePixels(W, H, stride, bgra);
+ var project = new Project();
+ project.Scene.Width = W;
+ project.Scene.Height = H;
+ Check(ReferenceEquals(PartPainter.Paint(image, W, H, 1.0, project.Parts), image) && PartPainter.Paint(null, W, H, 1.0, project.Parts) == null, "no enabled part: the painter returns the image itself (null for a canvas)");
+ var lens = (LensPart)project.AddPart(PartKind.Lens);
+ lens.Enabled = false;
+ Check(ReferenceEquals(PartPainter.Paint(image, W, H, 1.0, project.Parts), image), "a disabled part leaves the image untouched");
+ lens.Enabled = true;
+ lens.X = 100;
+ lens.Y = 60;
+ lens.Diameter = 100;
+ lens.R1 = 300;
+ lens.R2 = -300;
+ lens.Thickness = 40;
+ Check(lens.Name == "Lens 1" && lens.RefractiveIndex == 1.5 && lens.Kind == PartKind.Lens, "a new lens: 'Lens 1', index 1.5");
+ ScenePixels painted = PartPainter.Paint(image, W, H, 1.0, project.Parts)!;
+ Check(!ReferenceEquals(painted, image) && painted.Width == W && painted.Height == H && image.Bgra[60 * stride + 100 * 4 + 2] == 100, "an enabled part paints a copy; the image is not modified");
+ Check(painted.Bgra[60 * painted.StrideBytes + 100 * 4 + 1] == 160 && painted.Bgra[60 * painted.StrideBytes + 100 * 4] == 33 && painted.Bgra[5 * painted.StrideBytes + 5 * 4] == 77, "green and blue are untouched under the lens");
+ int centreRow = Enumerable.Range(0, W).Count(x => RedAt(painted, x, 60) == 150);
+ int edgeRow = Enumerable.Range(0, W).Count(x => RedAt(painted, x, 60 + 49) >= 125);
+ int rows = Enumerable.Range(0, H).Count(y => Enumerable.Range(0, W).Any(x => RedAt(painted, x, y) > 100));
+ Check(centreRow == 40 && rows == 100 && edgeRow >= 30 && edgeRow <= 33, $"a biconvex lens D 100, R ±300, t 40: 40 px thick on the axis (red 150), 100 rows, {edgeRow} px at the edge (sag 4 each side)");
+ Check(RedAt(painted, 100 - 20, 60) == 150 && RedAt(painted, 100 - 21, 60) == 100 && RedAt(painted, 100 + 19, 60) == 150 && RedAt(painted, 100 + 20, 60) == 100, "the lens spans x = 80..119 on the axis, hard edges on whole pixels");
+ lens.Angle = 90;
+ painted = PartPainter.Paint(image, W, H, 1.0, project.Parts)!;
+ int columnOnAxis = Enumerable.Range(0, H).Count(y => RedAt(painted, 100, y) == 150);
+ int columns = Enumerable.Range(0, W).Count(x => Enumerable.Range(0, H).Any(y => RedAt(painted, x, y) > 100));
+ Check(columnOnAxis == 40 && columns == 100, $"turned by 90°, the lens is 40 px thick along y and 100 px wide along x ({columnOnAxis}, {columns})");
+ lens.Angle = 0;
+ lens.Coating = 5;
+ painted = PartPainter.Paint(image, W, H, 1.0, project.Parts)!;
+ Check(RedAt(painted, 100, 60) == 150 && RedAt(painted, 100, 60 + 47) == 122 && RedAt(painted, 100, 60 - 47) == 122 && RedAt(painted, 100 - 18, 60) == 122 && RedAt(painted, 100 - 14, 60) == 150,
+ "a 5 px coating: red 122 = round(100 √1.5) just inside the flat edges and the curved surfaces, 150 in the body");
+ lens.Coating = 0;
+ lens.Mirror = true;
+ painted = PartPainter.Paint(image, W, H, 1.0, project.Parts)!;
+ int mirrorRow = Enumerable.Range(0, W).Count(x => RedAt(painted, x, 60) == 0);
+ Check(mirrorRow == 40 && painted.Bgra.Where((_, i) => i % 4 == 2).All(red => red is 0 or 100), $"as a mirror the lens is red 0 by the pixel-centre test ({mirrorRow} px on the axis), nothing in between");
+ lens.Mirror = false;
+ lens.R1 = 10;
+ lens.Normalize();
+ Check(lens.R1 == 50 && lens.R2 == -300, "Normalize: |R| below half the diameter becomes half the diameter, the sign kept");
+ project.Parts.Clear();
+
+ // the shapes: a regular hexagon's area, a rectangle, triangles, an outline; then a GRIN lens, a Bragg stack, a fibre
+ var hexagon = (PolygonPart)project.AddPart(PartKind.Polygon);
+ hexagon.X = 100;
+ hexagon.Y = 60;
+ hexagon.Sides = 6;
+ hexagon.Side = 30;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ double area = PaintedArea(painted, 1.5);
+ double expected = 3.0 * Math.Sqrt(3.0) / 2.0 * 30 * 30;
+ Check(Math.Abs(area - expected) < 0.01 * expected, $"a regular hexagon of side 30 covers {area:F1} px, the formula gives {expected:F1} (within 1 %)");
+ Check(RedAt(painted, 100 + 24, 60) == 150 && RedAt(painted, 100 + 26, 60) == 100 && RedAt(painted, 100, 60 + 14) == 150 && RedAt(painted, 100, 60 + 30) == 100, "the hexagon has flat faces at ±x' (26 px out) and vertices at ±y' (30 px out)");
+ Check(painted.Bgra[(60 * W + 100) * 4 + 3] == 255 && painted.Bgra[(60 * W + 100) * 4 + 1] == 0 && painted.Bgra[(0 * W + 0) * 4 + 2] == 100, "a blank canvas: opaque, no green, background red 100");
+ project.Parts.Clear();
+ var rectangle = (RectanglePart)project.AddPart(PartKind.Rectangle);
+ rectangle.X = 100;
+ rectangle.Y = 60;
+ rectangle.Length = 60;
+ rectangle.Width = 20;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ area = PaintedArea(painted, 1.5);
+ Check(Math.Abs(area - 1200.0) < 2.0 && RedAt(painted, 100 - 30, 60) == 150 && RedAt(painted, 100 - 31, 60) == 100 && RedAt(painted, 100 + 29, 60) == 150 && RedAt(painted, 100, 60 + 9) == 150 && RedAt(painted, 100, 60 + 10) == 100,
+ $"a rectangle of length 60 and width 20 lies square to the axis, x = 70..129, y = 50..69 ({area:F1} px)");
+ project.Parts.Clear();
+ var triangle = (TrianglePart)project.AddPart(PartKind.Triangle);
+ triangle.X = 100;
+ triangle.Y = 60;
+ triangle.Base = 60;
+ (double X, double Y)[] tri = triangle.Vertices();
+ Check(triangle.Type == TriangleType.Equilateral && tri.Length == 3 && Math.Abs(tri[2].X - tri[0].X - 60 * Math.Sqrt(3) / 2) < 1e-9 && Math.Abs(tri[2].Y) < 1e-9 && Math.Abs(triangle.ApexAngle - 60) < 1e-9 && Math.Abs(triangle.AxisReach - tri[2].X) < 1e-9,
+ "an equilateral triangle of base 60: height 52, the apex on +x', the reach along the axis is the apex");
+ triangle.Type = TriangleType.RightIsosceles;
+ tri = triangle.Vertices();
+ Check(triangle.AngleA == 45 && triangle.AngleB == 45 && Math.Abs(tri[2].X - tri[0].X - 30) < 1e-9 && Math.Abs(triangle.ApexAngle - 90) < 1e-9, "the right isosceles preset writes 45° / 45°: height 30, the right angle at the apex");
+ triangle.Type = TriangleType.ThirtySixtyNinety;
+ tri = triangle.Vertices();
+ Check(triangle.AngleA == 90 && triangle.AngleB == 30 && Math.Abs(tri[2].Y - tri[0].Y) < 1e-9 && Math.Abs(tri[2].X - tri[0].X - 60 * Math.Tan(Math.PI / 6)) < 1e-9, "the 30-60-90 preset: the right angle at the first end of the base, height 34.6");
+ triangle.Type = TriangleType.Isosceles;
+ triangle.AngleA = 70;
+ Check(triangle.AngleB == 70 && Math.Abs(triangle.ApexAngle - 40) < 1e-9, "isosceles: angle A is mirrored into B, the apex angle follows");
+ triangle.Type = TriangleType.Custom;
+ triangle.AngleA = 100;
+ triangle.AngleB = 100;
+ triangle.Normalize();
+ Check(triangle.AngleA == 100 && triangle.AngleB == 79 && triangle.ApexAngle == 1, "custom angles leave at least a degree for the apex (100 + 100 becomes 100 + 79)");
+ triangle.AngleA = 60;
+ triangle.AngleB = 60;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ area = PaintedArea(painted, 1.5);
+ Check(Math.Abs(area - 1558.8) < 0.01 * 1558.8 && RedAt(painted, 100 - 25, 60) == 150 && RedAt(painted, 100 - 27, 60) == 100 && RedAt(painted, 100 + 20, 60) == 150 && RedAt(painted, 100 + 27, 60) == 100,
+ $"the painted equilateral triangle covers {area:F1} px of 1558.8, the base at x' = -26, the apex at +26");
+ project.Parts.Clear();
+ var outline = (OutlinePart)project.AddPart(PartKind.Outline);
+ outline.X = 100;
+ outline.Y = 60;
+ Check(PartShape.For(outline) == null && ReferenceEquals(PartPainter.Paint(image, W, H, 1.0, project.Parts), image) == false && RedAt(PartPainter.Paint(null, W, H, 1.0, project.Parts)!, 100, 60) == 100, "an outline without points paints nothing");
+ outline.Points.Add(new PartPoint { X = -10, Y = -5 });
+ outline.Points.Add(new PartPoint { X = 10, Y = -5 });
+ outline.Points.Add(new PartPoint { X = 10, Y = 5 });
+ outline.Points.Add(new PartPoint { X = -10, Y = 5 });
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ area = PaintedArea(painted, 1.5);
+ Check(Math.Abs(area - 200.0) < 2.0 && RedAt(painted, 100, 60) == 150 && RedAt(painted, 100, 60 + 6) == 100, $"four points make a 20 × 10 outline ({area:F1} px)");
+ project.Parts.Clear();
+ var grin = (GrinLensPart)project.AddPart(PartKind.GrinLens);
+ grin.X = 100;
+ grin.Y = 60;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ // pixel (100, 85) is sampled around y' = 25.5: n = 1.8 - 0.3 (25.5 / 50)² = 1.722; (100, 108) around 48.5: 1.518
+ Check(RedAt(painted, 100, 60) == 180 && RedAt(painted, 100, 60 + 25) == 172 && RedAt(painted, 100, 60 + 48) == 152 && RedAt(painted, 100, 60 + 50) == 100 && RedAt(painted, 100 + 49, 60) == 180 && RedAt(painted, 100 + 50, 60) == 100,
+ "a GRIN lens 100 × 100: index 1.8 on the axis falling parabolically to 1.5 at the edge, 1 outside");
+ project.Parts.Clear();
+ var bragg = (BraggReflectorPart)project.AddPart(PartKind.BraggReflector);
+ bragg.X = 100;
+ bragg.Y = 60;
+ bragg.Pairs = 3;
+ bragg.Thickness1 = 10;
+ bragg.Thickness2 = 6;
+ bragg.Width = 20;
+ painted = PartPainter.Paint(null, W, H, 1.0, project.Parts)!;
+ string layers = string.Concat(Enumerable.Range(100 - 25, 50).Select(x => RedAt(painted, x, 60) switch { 150 => '1', 200 => '2', 100 => '.', _ => '?' }));
+ Check(layers == "." + string.Concat(Enumerable.Repeat("1111111111222222", 3)) + "." && RedAt(painted, 100, 60 + 9) == 150 && RedAt(painted, 100, 60 + 10) == 100,
+ "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.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,
+ "the fibre: core 1.5 within 10 px of the path, cladding 1.45 to 20 px, the canvas edge reached");
+ project.Parts.Clear();
+
+ // the cavity: a mirror square with its inside painted back to index 1 keeps a wave in, nothing gets out
+ const int cw = 64, ch = 48;
+ project.Scene.Width = cw;
+ project.Scene.Height = ch;
+ var wall = (OutlinePart)project.AddPart(PartKind.Outline);
+ wall.X = 32;
+ wall.Y = 24;
+ wall.Mirror = true;
+ foreach ((int px, int py) in new[] { (-16, -16), (16, -16), (16, 16), (-16, 16) })
+ {
+ wall.Points.Add(new PartPoint { X = px, Y = py });
+ }
+ var hollow = (OutlinePart)project.AddPart(PartKind.Outline);
+ hollow.X = 32;
+ hollow.Y = 24;
+ hollow.RefractiveIndex = 1.0;
+ foreach ((int px, int py) in new[] { (-12, -12), (12, -12), (12, 12), (-12, 12) })
+ {
+ hollow.Points.Add(new PartPoint { X = px, Y = py });
+ }
+ ScenePixels cavity = PartPainter.Paint(null, cw, ch, 1.0, project.Parts)!;
+ Check(RedAt(cavity, 32, 24) == 100 && RedAt(cavity, 32, 24 - 14) == 0 && RedAt(cavity, 32, 24 - 18) == 100, "a later part paints over an earlier one: the mirror square is hollowed to a 4 px ring");
+ SceneData ring = SceneData.FromBgra(cavity.Bgra, cw, ch, cavity.StrideBytes, false, 0);
+ var emitters = new List<Emitter> { Make(32, 24, 120, 1.0) };
+ float[] field = RunCpu(ring, emitters, 300);
+ float inside = 0f, outside = 0f;
+ for (int y = 0; y < ch; y++)
+ {
+ for (int x = 0; x < cw; x++)
+ {
+ float value = Math.Abs(field[(y + 1) * (cw + 2) + x + 1]);
+ if (Math.Abs(x - 32) <= 11 && Math.Abs(y - 24) <= 11)
+ {
+ inside = Math.Max(inside, value);
+ }
+ else if (Math.Abs(x - 32) > 17 || Math.Abs(y - 24) > 17)
+ {
+ outside = Math.Max(outside, value);
+ }
+ }
+ }
+ Check(inside > 0.01f && outside < inside * 1e-4f, $"the cavity keeps the wave after 300 steps: max |u| inside {inside}, outside {outside}");
+ GpuWaveSimulator? gpu = GpuWaveSimulator.TryCreate(ring, new EngineOptions(1.0, 1.0, false, false, 10.0, 1.0), emitters, out string problems);
+ if (gpu == null)
+ {
+ Console.WriteLine(" skip GPU: " + problems);
+ }
+ else
+ {
+ using (gpu)
+ {
+ Run(gpu, 300);
+ float diff = MaxDiff(field, gpu.FieldData);
+ Check(diff < 1e-3f * Math.Max(1f, MaxAbs(field)), "GPU agrees on the painted cavity (max diff " + diff + ")");
+ }
+ }
+ RunSpec spec = RunSpec.Create(project, cavity, preferGpu: false);
+ Check(ReferenceEquals(spec.Image, cavity) && !spec.ImageSources && spec.Width == cw && spec.Height == ch, "a canvas scene with parts runs on the painted pixels, without image sources");
+ Check(RunSpec.Create(project, new ScenePixels(10, 10, 40, new byte[400]), preferGpu: false).Image == null, "a painted canvas of another size than the scene is ignored");
+
+ // every kind through the XML format, sparsely
+ project.Scene.Width = W;
+ project.Scene.Height = H;
+ project.Parts.Clear();
+ project.AddPart(PartKind.Lens);
+ var polygon = (OutlinePart)project.AddPart(PartKind.Outline);
+ polygon.Points.Add(new PartPoint { X = 3, Y = -4 });
+ polygon.Mirror = true;
+ project.AddPart(PartKind.Polygon);
+ ((RectanglePart)project.AddPart(PartKind.Rectangle)).Width = 7;
+ ((TrianglePart)project.AddPart(PartKind.Triangle)).Type = TriangleType.RightIsosceles;
+ project.AddPart(PartKind.Fiber);
+ var reflector = (BraggReflectorPart)project.AddPart(PartKind.BraggReflector);
+ reflector.Angle = 45;
+ reflector.Index2 = 2.2;
+ project.AddPart(PartKind.GrinLens);
+ OpticalPart copy = project.Duplicate(reflector);
+ Check(copy is BraggReflectorPart { Name: "Bragg reflector 1 copy", Angle: 45, Index2: 2.2 } && project.Parts.IndexOf(copy) == 7 && project.Parts.Count == 9, "Duplicate: a deep copy right after the original, named '… copy'");
+ Check(project.Remove(copy) && project.Move(reflector, 0) && project.Parts[0] == reflector && project.Parts.Count == 8, "Remove and Move work on the parts list");
+ string xml;
+ using (var stream = new MemoryStream())
+ {
+ project.Save(stream);
+ xml = System.Text.Encoding.UTF8.GetString(stream.ToArray());
+ }
+ Check(xml.Contains("<BraggReflector Name=\"Bragg reflector 1\" X=\"100\" Y=\"60\" Angle=\"45\" Index2=\"2.2\" />") && xml.Contains("<Lens Name=\"Lens 1\" X=\"100\" Y=\"60\" />") && xml.Contains("<GrinLens Name=\"GRIN lens 1\" X=\"100\" Y=\"60\" />"),
+ "the file holds one element per kind, attributes only where they differ from the defaults");
+ Check(xml.Contains("<Outline Name=\"Outline 1\" X=\"100\" Y=\"60\" Mirror=\"true\">\r\n\t\t<Point X=\"3\" Y=\"-4\" />\r\n\t</Outline>".Replace("\r\n", Environment.NewLine)) || xml.Contains("<Outline Name=\"Outline 1\" X=\"100\" Y=\"60\" Mirror=\"true\">\n\t\t<Point X=\"3\" Y=\"-4\" />\n\t</Outline>"),
+ "an outline's points are Point children");
+ Check(xml.Contains("<Polygon Name=\"Polygon 1\" X=\"100\" Y=\"60\" />") && xml.Contains("<Rectangle Name=\"Rectangle 1\" X=\"100\" Y=\"60\" Width=\"7\" />") && xml.Contains("<Triangle Name=\"Triangle 1\" X=\"100\" Y=\"60\" Type=\"RightIsosceles\" AngleA=\"45\" AngleB=\"45\" />"),
+ "the polygon, rectangle and triangle elements, sparse");
+ Check(xml.IndexOf("<Source", StringComparison.Ordinal) < 0 && xml.IndexOf("<Lens", StringComparison.Ordinal) < xml.IndexOf("<Probe", StringComparison.Ordinal) || !xml.Contains("<Probe"), "the parts sit between the sources and the probes");
+ Project back;
+ using (var stream = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(xml)))
+ {
+ back = Project.Load(stream);
+ }
+ Check(back.Parts.Count == 8 && back.Parts.Select(p => p.Kind).SequenceEqual([PartKind.BraggReflector, PartKind.Lens, PartKind.Outline, PartKind.Polygon, PartKind.Rectangle, PartKind.Triangle, PartKind.Fiber, PartKind.GrinLens]), "the eight kinds load back in order");
+ Check(back.Parts[6] 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(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 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);
+ var changes = new List<ProjectChange>();
+ watched.Changed += (_, change) => changes.Add(change);
+ ((OutlinePart)back.Parts[2]).Points[0].X = 7;
+ ((OutlinePart)back.Parts[2]).Points.Add(new PartPoint());
+ back.Parts[1].Angle = 10;
+ Check(changes.Count == 3 && changes.All(c => c.AffectsSimulation) && !changes.Any(c => c.AffectsProbes), "the watcher reports a point edit, a point added and a part edit, each as a simulation edit");
+ watched.Dispose();
+ }
+
private static void CheckRun()
{
Console.WriteLine("--- run");
diff --git a/_tools/ui_check/KeyboardCheck.ps1 b/_tools/ui_check/KeyboardCheck.ps1
index 0ef2c05..441ae35 100644
--- a/_tools/ui_check/KeyboardCheck.ps1
+++ b/_tools/ui_check/KeyboardCheck.ps1
@@ -17,7 +17,7 @@
# The keyboard gaps closed on 2026-10-15: the toolbars of the Project and Messages panes are in the Tab cycle and the
# dock pane titles are visible to UI Automation. On the default project: Tab walks the Project toolbar (the disabled
-# buttons skipped) into the tree, Space on "+ Source" adds Source 2 and Space on the remove button takes it away, the
+# buttons skipped) into the tree ("+ Part" between the two since 2026-10-18), Space on "+ Source" adds Source 2 and Space on the remove button takes it away, the
# Messages pane is opened through View > Panes by keyboard, Tab walks its toolbar left to right, Space flips a level
# and clears the list, and both pane titles read through their ids. See Common.ps1 for the rules (no mouse, no
# activation, no UIA patterns). Prints PASS/FAIL per check and exits with the failure count.
@@ -47,8 +47,8 @@ try {
# ------------------------------------------------------------ the Project toolbar (the default project has no sources)
FocusOn "ToolAddSource"
- $order = @(); for ($i = 0; $i -lt 2; $i++) { Key $VK_TAB 120; $order += (FocusedId) }
- Check "Tab walks + Source > + Probe > the tree (move and remove are disabled with nothing selected and skipped)" (($order -join ",") -eq "ToolAddProbe,tree") ($order -join ",")
+ $order = @(); for ($i = 0; $i -lt 3; $i++) { Key $VK_TAB 120; $order += (FocusedId) }
+ Check "Tab walks + Source > + Part > + Probe > the tree (move and remove are disabled with nothing selected and skipped)" (($order -join ",") -eq "ToolAddPart,ToolAddProbe,tree") ($order -join ",")
FocusOn "ToolAddSource"
Step "Space" $VK_SPACE 400
$null = WaitFor { Has "Tree:Source 1" } 3000 100