Fix SWIG wrapper for AddPrimitive
Fixes https://gitlab.com/kicad/code/kicad/-/issues/17676
(cherry picked from commit c1e7668d80
)
This commit is contained in:
parent
941420abed
commit
8b5c292397
|
@ -1,4 +1,4 @@
|
||||||
|
%rename(AddPrimitiveShape) PAD::AddPrimitive;
|
||||||
|
|
||||||
%include pad_shapes.h
|
%include pad_shapes.h
|
||||||
%include pad.h
|
%include pad.h
|
||||||
|
@ -36,24 +36,41 @@ const int PAD_SHAPE_RECT = (const int)PAD_SHAPE::RECTANGLE;
|
||||||
def GetName(self):
|
def GetName(self):
|
||||||
return self.GetNumber()
|
return self.GetNumber()
|
||||||
|
|
||||||
# AddPrimitive() is the old name for D_PAD::AddPrimitivePoly(),
|
# AddPrimitive() used to be multiple functions on the C++ side and this single Python function
|
||||||
# PAD::AddPrimitiveSegment(), PAD::AddPrimitiveCircle(),
|
# was made to maintain compatibility with an even older version of the PAD class that had a
|
||||||
# PAD::AddPrimitiveArc(), PAD::AddPrimitiveCurve()
|
# single function. Now we're back to a single function, but different, and Python scripts
|
||||||
# define it for compatibility
|
# have gotten used to this API, so keep compatibility with it
|
||||||
def AddPrimitive(self, *args):
|
def AddPrimitive(self, *args):
|
||||||
if len(args) == 2:
|
if len(args) == 2:
|
||||||
return self.AddPrimitivePoly(*args, True)
|
return self.AddPrimitivePoly(*args, True)
|
||||||
elif len(args) == 3:
|
elif len(args) == 3:
|
||||||
if type(args[1] in [wxPoint,wxSize]):
|
if type(args[1] in [wxPoint,wxSize,VECTOR2I]):
|
||||||
return self.AddPrimitiveSegment(*args)
|
s = PCB_SHAPE(None, SHAPE_T_SEGMENT)
|
||||||
|
s.SetStart(args[0])
|
||||||
|
s.SetEnd(args[1])
|
||||||
|
s.SetWidth(args[2])
|
||||||
else:
|
else:
|
||||||
return self.AddPrimitiveCircle(*args)
|
s = PCB_SHAPE(None, SHAPE_T_CIRCLE)
|
||||||
|
s.SetCenter(args[0])
|
||||||
|
s.SetRadius(args[1])
|
||||||
|
s.SetWidth(args[2])
|
||||||
elif len(args) == 4:
|
elif len(args) == 4:
|
||||||
return self.AddPrimitiveArc(*args)
|
s = PCB_SHAPE(None, SHAPE_T_ARC)
|
||||||
|
s.SetCenter(args[0])
|
||||||
|
s.SetStart(args[1])
|
||||||
|
s.SetArcAngleAndEnd(args[2])
|
||||||
|
s.SetWidth(args[3])
|
||||||
elif len(args) == 5:
|
elif len(args) == 5:
|
||||||
return self.AddPrimitiveCurve(*args)
|
s = PCB_SHAPE(None, SHAPE_T_BEZIER)
|
||||||
|
s.SetStart(args[0])
|
||||||
|
s.SetEnd(args[1])
|
||||||
|
s.SetBezierC1(args[2])
|
||||||
|
s.SetBezierC2(args[3])
|
||||||
|
s.SetWidth(args[4])
|
||||||
else:
|
else:
|
||||||
raise TypeError("Arguments not recognized.")
|
raise TypeError(f"Arguments not recognized; expected 2-5 args, got {len(args)}")
|
||||||
|
|
||||||
|
self.AddPrimitiveShape(s)
|
||||||
|
|
||||||
# GetCustomShapeAsPolygon() is the old accessor to get custom shapes
|
# GetCustomShapeAsPolygon() is the old accessor to get custom shapes
|
||||||
def GetCustomShapeAsPolygon(self, layer=UNDEFINED_LAYER):
|
def GetCustomShapeAsPolygon(self, layer=UNDEFINED_LAYER):
|
||||||
|
|
Loading…
Reference in New Issue