2024-04-05 03:09:05 +00:00
|
|
|
%rename(AddPrimitiveShape) PAD::AddPrimitive;
|
2020-02-27 23:54:19 +00:00
|
|
|
|
2016-09-21 01:07:41 +00:00
|
|
|
%include pad_shapes.h
|
2020-11-12 20:19:22 +00:00
|
|
|
%include pad.h
|
2016-09-21 01:07:41 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
%rename(Get) operator PAD*;
|
2016-09-21 01:07:41 +00:00
|
|
|
%{
|
2020-11-12 20:19:22 +00:00
|
|
|
#include <pad.h>
|
2016-09-21 01:07:41 +00:00
|
|
|
%}
|
|
|
|
|
2023-06-02 09:10:48 +00:00
|
|
|
/* Only for compatibility with old python scripts: */
|
|
|
|
const int PAD_SHAPE_RECT = (const int)PAD_SHAPE::RECTANGLE;
|
|
|
|
|
|
|
|
%{
|
|
|
|
const int PAD_SHAPE_RECT = (const int)PAD_SHAPE::RECTANGLE;
|
|
|
|
%}
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
%extend PAD
|
2017-10-09 07:58:15 +00:00
|
|
|
{
|
|
|
|
%pythoncode
|
|
|
|
%{
|
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
# SetPadName() is the old name for PAD::SetName()
|
2017-10-09 07:58:15 +00:00
|
|
|
# define it for compatibility
|
|
|
|
def SetPadName(self, aName):
|
2021-08-23 23:10:21 +00:00
|
|
|
return self.SetNumber(aName)
|
|
|
|
|
|
|
|
def SetName(self, aName):
|
|
|
|
return self.SetNumber(aName)
|
2017-10-09 07:58:15 +00:00
|
|
|
|
2020-11-13 15:15:52 +00:00
|
|
|
# GetPadName() is the old name for PAD::GetName()
|
2017-10-09 07:58:15 +00:00
|
|
|
# define it for compatibility
|
|
|
|
def GetPadName(self):
|
2021-08-23 23:10:21 +00:00
|
|
|
return self.GetNumber()
|
|
|
|
|
|
|
|
def GetName(self):
|
|
|
|
return self.GetNumber()
|
2017-10-09 07:58:15 +00:00
|
|
|
|
2024-04-05 03:09:05 +00:00
|
|
|
# AddPrimitive() used to be multiple functions on the C++ side and this single Python function
|
|
|
|
# was made to maintain compatibility with an even older version of the PAD class that had a
|
|
|
|
# single function. Now we're back to a single function, but different, and Python scripts
|
|
|
|
# have gotten used to this API, so keep compatibility with it
|
2020-02-27 23:54:19 +00:00
|
|
|
def AddPrimitive(self, *args):
|
|
|
|
if len(args) == 2:
|
2022-03-14 11:54:41 +00:00
|
|
|
return self.AddPrimitivePoly(*args, True)
|
2020-02-27 23:54:19 +00:00
|
|
|
elif len(args) == 3:
|
2024-04-05 03:09:05 +00:00
|
|
|
if type(args[1] in [wxPoint,wxSize,VECTOR2I]):
|
|
|
|
s = PCB_SHAPE(None, SHAPE_T_SEGMENT)
|
|
|
|
s.SetStart(args[0])
|
|
|
|
s.SetEnd(args[1])
|
|
|
|
s.SetWidth(args[2])
|
2020-02-27 23:54:19 +00:00
|
|
|
else:
|
2024-04-05 03:09:05 +00:00
|
|
|
s = PCB_SHAPE(None, SHAPE_T_CIRCLE)
|
|
|
|
s.SetCenter(args[0])
|
|
|
|
s.SetRadius(args[1])
|
|
|
|
s.SetWidth(args[2])
|
2020-02-27 23:54:19 +00:00
|
|
|
elif len(args) == 4:
|
2024-04-05 03:09:05 +00:00
|
|
|
s = PCB_SHAPE(None, SHAPE_T_ARC)
|
|
|
|
s.SetCenter(args[0])
|
|
|
|
s.SetStart(args[1])
|
|
|
|
s.SetArcAngleAndEnd(args[2])
|
|
|
|
s.SetWidth(args[3])
|
2020-02-27 23:54:19 +00:00
|
|
|
elif len(args) == 5:
|
2024-04-05 03:09:05 +00:00
|
|
|
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])
|
2020-02-27 23:54:19 +00:00
|
|
|
else:
|
2024-04-05 03:09:05 +00:00
|
|
|
raise TypeError(f"Arguments not recognized; expected 2-5 args, got {len(args)}")
|
|
|
|
|
|
|
|
self.AddPrimitiveShape(s)
|
2020-07-28 02:59:16 +00:00
|
|
|
|
|
|
|
# GetCustomShapeAsPolygon() is the old accessor to get custom shapes
|
2020-09-04 22:58:29 +00:00
|
|
|
def GetCustomShapeAsPolygon(self, layer=UNDEFINED_LAYER):
|
2020-07-28 02:59:16 +00:00
|
|
|
polygon_set = SHAPE_POLY_SET()
|
2021-08-23 21:04:31 +00:00
|
|
|
self.MergePrimitivesAsPolygon(polygon_set)
|
2020-07-28 02:59:16 +00:00
|
|
|
return polygon_set
|
2017-10-09 07:58:15 +00:00
|
|
|
%}
|
|
|
|
}
|