diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs index bfce26d..7d74950 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Abstractions/Contracts.cs @@ -59,6 +59,7 @@ public sealed record LineNumberCandidate(string StableId, long RowId, Annotation public sealed record ExistingLineNumberAnnotation(string StableId, string SourceStableId, string Text); public sealed record LineNumberCommandOperation(string StableId, AnnotationOperationKind Kind, string? Text, AnnotationPoint Position, double Rotation, string Layer, string TextStyle, IReadOnlyList Reasons); public sealed record LineNumberCommandPlan(IReadOnlyList Operations); +public sealed record LineNumberApplyPreflight(string StableId, string Text, AnnotationPoint Position, double Rotation, string Layer, string TextStyle); public sealed record GeometrySnapshot { diff --git a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Core/LineNumberCommandPlanner.cs b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Core/LineNumberCommandPlanner.cs index 4fb5b0d..c899658 100644 --- a/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Core/LineNumberCommandPlanner.cs +++ b/Plant3D2026/P_Rec_Annot/src/PRecAnnot.Core/LineNumberCommandPlanner.cs @@ -17,4 +17,9 @@ public sealed class LineNumberCommandPlanner(ILineNumberAnnotationFormatter form } return new(result); } + + public static IReadOnlyList PrepareApply(LineNumberCommandPlan plan) => plan.Operations + .Where(x => x.Kind is AnnotationOperationKind.Create or AnnotationOperationKind.Update) + .OrderBy(x => x.StableId, StringComparer.Ordinal) + .Select(x => new LineNumberApplyPreflight(x.StableId, x.Text!, x.Position, x.Rotation, x.Layer, x.TextStyle)).ToArray(); } diff --git a/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/LineNumberCommandPlannerTests.cs b/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/LineNumberCommandPlannerTests.cs index 8c7952a..fd82dbb 100644 --- a/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/LineNumberCommandPlannerTests.cs +++ b/Plant3D2026/P_Rec_Annot/tests/PRecAnnot.Core.Tests/LineNumberCommandPlannerTests.cs @@ -9,5 +9,6 @@ public sealed class LineNumberCommandPlannerTests var c = new LineNumberCandidate("b", 1, new(0,0), 0, "PXP", "Standard", new Dictionary { ["EngineeringItems.LineNumber"]="L-2" }); var plan = new LineNumberCommandPlanner(new LineNumberAnnotationFormatter()).Build(def, [c, c, c with { StableId="a" }], [new("x", "b", "old")]); Assert.Collection(plan.Operations, x => Assert.Equal(AnnotationOperationKind.Create,x.Kind), x => Assert.Equal(AnnotationOperationKind.Update,x.Kind), x => Assert.Equal(AnnotationOperationKind.Conflict,x.Kind)); + Assert.Equal(new[] { "a", "b" }, LineNumberCommandPlanner.PrepareApply(plan).Select(x => x.StableId)); } }