API: Avoid redundant serialization of polyline arcs

Fixes https://gitlab.com/kicad/code/kicad-python/-/issues/79

(cherry picked from commit 0aeb33f94f)
This commit is contained in:
Jon Evans
2026-03-08 00:20:25 -05:00
parent 3538e456d7
commit c62b9aad23
2 changed files with 64 additions and 33 deletions
+4 -4
View File
@@ -123,10 +123,9 @@ KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN
if( vertex < 0 )
break;
types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
if( aSlc.IsPtOnArc( vertex ) )
if( aSlc.IsArcStart( vertex ) )
{
types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
const SHAPE_ARC& arc = aSlc.Arc( aSlc.ArcIndex( vertex ) );
node->mutable_arc()->mutable_start()->set_x_nm( arc.GetP0().x );
node->mutable_arc()->mutable_start()->set_y_nm( arc.GetP0().y );
@@ -135,8 +134,9 @@ KICOMMON_API void PackPolyLine( types::PolyLine& aOutput, const SHAPE_LINE_CHAIN
node->mutable_arc()->mutable_end()->set_x_nm( arc.GetP1().x );
node->mutable_arc()->mutable_end()->set_y_nm( arc.GetP1().y );
}
else
else if( !aSlc.IsPtOnArc( vertex ) )
{
types::PolyLineNode* node = aOutput.mutable_nodes()->Add();
node->mutable_point()->set_x_nm( aSlc.CPoint( vertex ).x );
node->mutable_point()->set_y_nm( aSlc.CPoint( vertex ).y );
}
+60 -29
View File
@@ -630,6 +630,37 @@
)
)
)
(gr_poly
(pts
(arc
(start 85.1 125.9)
(mid 85.807107 125.607107)
(end 86.1 124.9)
)
(arc
(start 86.1 121)
(mid 85.807107 120.292893)
(end 85.1 120)
)
(arc
(start 81 120)
(mid 80.292893 120.292893)
(end 80 121)
)
(arc
(start 80 124.9)
(mid 80.292893 125.607107)
(end 81 125.9)
)
)
(stroke
(width 0)
(type solid)
)
(fill no)
(layer "F.SilkS")
(uuid "b5d89b57-14eb-4e87-92ab-25ae8eacf292")
)
(gr_arc
(start 111.5 55)
(mid 110.556284 51.236651)
@@ -666,17 +697,6 @@
(layer "Edge.Cuts")
(uuid "98ab137c-f925-4075-af50-4ac8fe13c14d")
)
(gr_circle
(center 224.6 97.7)
(end 228.25 99.55)
(stroke
(width 0.05)
(type default)
)
(fill no)
(layer "Edge.Cuts")
(uuid "b27945e5-32fe-454b-ad80-b75cae1194e1")
)
(gr_circle
(center 197.75 63.3)
(end 199.05 65.4)
@@ -688,6 +708,17 @@
(layer "Edge.Cuts")
(uuid "e1699138-73b7-4cfd-aec1-5bee869795d9")
)
(gr_circle
(center 224.6 97.7)
(end 228.25 99.55)
(stroke
(width 0.05)
(type default)
)
(fill no)
(layer "Edge.Cuts")
(uuid "b27945e5-32fe-454b-ad80-b75cae1194e1")
)
(gr_rect
(start 93.5 47.25)
(end 102 54.75)
@@ -710,6 +741,17 @@
(layer "B.Fab")
(uuid "2e68cc14-52eb-4276-b39c-c502b042bc91")
)
(gr_rect
(start 95 51)
(end 100 52)
(stroke
(width 0)
(type solid)
)
(fill yes)
(layer "B.Fab")
(uuid "cb2af193-349d-4651-a0c1-5d028759a9f3")
)
(gr_arc
(start 105.222971 54.2804)
(mid 106.709486 54.262003)
@@ -733,16 +775,15 @@
(layer "B.Fab")
(uuid "b5d27e62-c3ee-43b4-a859-5e626272bf9c")
)
(gr_rect
(start 95 51)
(end 100 52)
(gr_line
(start 111 46.5)
(end 115.5 54)
(stroke
(width 0)
(type solid)
(width 0.1)
(type default)
)
(fill yes)
(layer "B.Fab")
(uuid "cb2af193-349d-4651-a0c1-5d028759a9f3")
(layer "User.4")
(uuid "5cc814d5-0815-4cbb-b9cb-07dfd7225722")
)
(gr_line
(start 113.5 47)
@@ -754,16 +795,6 @@
(layer "User.4")
(uuid "22cd6520-1cf2-46ca-a9d9-28e8d8c4863c")
)
(gr_line
(start 111 46.5)
(end 115.5 54)
(stroke
(width 0.1)
(type default)
)
(layer "User.4")
(uuid "5cc814d5-0815-4cbb-b9cb-07dfd7225722")
)
(gr_text "Text!"
(at 120.45 49.35 0)
(layer "B.Fab")