From 27ebba6b33d25d7f401225a8e4dce8f5e48628bc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Sat, 15 Apr 2023 10:30:33 +0200 Subject: [PATCH] Python and footprint wizard: fix issues and update to be compatible with recent changes in Kicad code. --- pcbnew/python/plugins/FPC_wizard.py | 1 - pcbnew/python/plugins/FootprintWizardBase.py | 15 ++++++--------- pcbnew/python/plugins/PadArray.py | 3 +-- pcbnew/python/plugins/mutualcap_button_wizard.py | 1 - pcbnew/python/plugins/qrcode_footprint_wizard.py | 9 ++------- pcbnew/python/plugins/touch_slider_wizard.py | 2 -- pcbnew/python/swig/board_item.i | 16 +++++++++++++--- 7 files changed, 22 insertions(+), 25 deletions(-) diff --git a/pcbnew/python/plugins/FPC_wizard.py b/pcbnew/python/plugins/FPC_wizard.py index 07e7b8473c..92e638a304 100644 --- a/pcbnew/python/plugins/FPC_wizard.py +++ b/pcbnew/python/plugins/FPC_wizard.py @@ -49,7 +49,6 @@ class FPC_FootprintWizard(FootprintWizardBase.FootprintWizard): pad.SetShape(pcbnew.PAD_SHAPE_RECT) pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) pad.SetLayerSet( pad.SMDMask() ) - pad.SetPos0(pos) pad.SetPosition(pos) pad.SetName(name) return pad diff --git a/pcbnew/python/plugins/FootprintWizardBase.py b/pcbnew/python/plugins/FootprintWizardBase.py index 51eebb0d93..b88e5d73ce 100644 --- a/pcbnew/python/plugins/FootprintWizardBase.py +++ b/pcbnew/python/plugins/FootprintWizardBase.py @@ -486,7 +486,7 @@ class FootprintWizardDrawingAids: """! Draw a line from (x1, y1) to (x2, y2) """ - outline = pcbnew.FP_SHAPE(self.module) + outline = pcbnew.PCB_SHAPE(self.module) outline.SetWidth(self.GetLineThickness()) outline.SetLayer(self.GetLayer()) outline.SetShape(pcbnew.S_SEGMENT) @@ -508,7 +508,7 @@ class FootprintWizardDrawingAids: DC line thickness """ - circle = pcbnew.FP_SHAPE(self.module) + circle = pcbnew.PCB_SHAPE(self.module) start = self.TransformPoint(x, y) if filled: @@ -548,7 +548,7 @@ class FootprintWizardDrawingAids: @param sy: the y coordinate of the arc start point @param angle: the arc's central angle (in deci-degrees) """ - arc = pcbnew.FP_SHAPE(self.module) + arc = pcbnew.PCB_SHAPE(self.module) arc.SetShape(pcbnew.SHAPE_T_ARC) arc.SetWidth(self.dc['lineThickness']) @@ -564,7 +564,7 @@ class FootprintWizardDrawingAids: arc.SetCenter(center) arc.SetStart(start) arc.SetArcAngleAndEnd(angle, True) - arc.SetLocalCoord() + #arc.SetLocalCoord() self.module.Add(arc) def HLine(self, x, y, l): @@ -635,9 +635,7 @@ class FootprintWizardDrawingAids: text_size = pcbnew.VECTOR2I(size, size) - self.module.Reference().SetPos0(self.TransformPoint(x, y)) - self.module.Reference().SetPosition( - self.module.Reference().GetPos0()) + self.module.Reference().SetPosition( self.TransformPoint(x, y) ) self.module.Reference().SetTextSize(text_size) self.module.Reference().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) ) @@ -652,8 +650,7 @@ class FootprintWizardDrawingAids: """ text_size = pcbnew.VECTOR2I(size, size) - self.module.Value().SetPos0(self.TransformPoint(x, y)) - self.module.Value().SetPosition(self.module.Value().GetPos0()) + self.module.Value().SetPosition(self.TransformPoint(x, y)) self.module.Value().SetTextSize(text_size) self.module.Value().SetLayer(self.DefaultTextValueLayer()) self.module.Value().SetTextAngle( pcbnew.EDA_ANGLE( orientation_degree, pcbnew.DEGREES_T ) ) diff --git a/pcbnew/python/plugins/PadArray.py b/pcbnew/python/plugins/PadArray.py index cc58d684db..a32958bdfd 100644 --- a/pcbnew/python/plugins/PadArray.py +++ b/pcbnew/python/plugins/PadArray.py @@ -156,7 +156,7 @@ class PadArray(object): def AddPad(self, pad): """! - Add a pad to the array, under the same moodule as the main + Add a pad to the array, under the same footprint as the main prototype pad @param pad: pad to add """ @@ -175,7 +175,6 @@ class PadArray(object): # create a new pad with same characteristics pad = pad.Duplicate() - pad.SetPos0(pos) pad.SetPosition(pos) return pad diff --git a/pcbnew/python/plugins/mutualcap_button_wizard.py b/pcbnew/python/plugins/mutualcap_button_wizard.py index 9843a5b220..9864e3e398 100644 --- a/pcbnew/python/plugins/mutualcap_button_wizard.py +++ b/pcbnew/python/plugins/mutualcap_button_wizard.py @@ -64,7 +64,6 @@ class MutualcapButtonWizard(FootprintWizardBase.FootprintWizard): layerset.AddLayer(pcbnew.F_Cu) pad.SetLayerSet(layerset) - pad.SetPos0(pos) pad.SetPosition(pos) pad.SetName(name) return pad diff --git a/pcbnew/python/plugins/qrcode_footprint_wizard.py b/pcbnew/python/plugins/qrcode_footprint_wizard.py index f87cc359ba..39e9552e75 100644 --- a/pcbnew/python/plugins/qrcode_footprint_wizard.py +++ b/pcbnew/python/plugins/qrcode_footprint_wizard.py @@ -66,8 +66,8 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): self.qr.make() def drawPixelSquareArea( self, layer, size, xposition, yposition): - # creates a FP_SHAPE of rectangle type. The rectangle is square - rectangle = pcbnew.FP_SHAPE(self.module) + # creates a PCB_SHAPE of rectangle type. The rectangle is square + rectangle = pcbnew.PCB_SHAPE(self.module) rectangle.SetShape(pcbnew.S_RECT) rectangle.SetWidth( 0 ) rectangle.SetFilled( True ) @@ -77,8 +77,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): rectangle.SetStartY( -halfsize+yposition ) rectangle.SetEndX( halfsize+xposition ) rectangle.SetEndY( halfsize+yposition ) - rectangle.SetStart0( rectangle.GetStart() ) - rectangle.SetEnd0( rectangle.GetEnd() ) return rectangle @@ -90,7 +88,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): pad.SetSize(pcbnew.VECTOR2I(self.X, self.X)) pad_pos = pcbnew.VECTOR2I(xposition,yposition) pad.SetPosition(pad_pos) - pad.SetPos0(pad_pos) pad.SetShape(pcbnew.PAD_SHAPE_RECT) pad.SetAttribute(pcbnew.PAD_ATTRIB_SMD) pad.SetName("") @@ -149,7 +146,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): textPosition = int((self.textHeight) + ((1 + half_number_of_elements) * self.X)) pos = pcbnew.VECTOR2I(0, - textPosition) self.module.Value().SetPosition(pos) - self.module.Value().SetPos0(pos) self.module.Value().SetTextHeight(self.textHeight) self.module.Value().SetTextWidth(self.textWidth) self.module.Value().SetTextThickness(self.textThickness) @@ -157,7 +153,6 @@ class QRCodeWizard(FootprintWizardBase.FootprintWizard): # Add Reference field pos = pcbnew.VECTOR2I(0, textPosition) self.module.Reference().SetPosition(pos) - self.module.Reference().SetPos0(pos) self.module.Reference().SetTextHeight(self.textHeight) self.module.Reference().SetTextWidth(self.textWidth) self.module.Reference().SetTextThickness(self.textThickness) diff --git a/pcbnew/python/plugins/touch_slider_wizard.py b/pcbnew/python/plugins/touch_slider_wizard.py index 4fb5434f0b..35947d28ea 100644 --- a/pcbnew/python/plugins/touch_slider_wizard.py +++ b/pcbnew/python/plugins/touch_slider_wizard.py @@ -66,7 +66,6 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard): pad.SetShape(PAD_SHAPE_RECT) pad.SetAttribute(PAD_ATTRIB_SMD) pad.SetLayerSet(pad.ConnSMDMask()) - pad.SetPos0(pos) pad.SetPosition(pos) pad.SetName(name) return pad @@ -78,7 +77,6 @@ class TouchSliderWizard(FootprintWizardBase.FootprintWizard): pad.SetShape(PAD_SHAPE_TRAPEZOID) pad.SetAttribute(PAD_ATTRIB_SMD) pad.SetLayerSet(pad.ConnSMDMask()) - pad.SetPos0(pos) pad.SetPosition(pos) pad.SetName(name) pad.SetDelta(VECTOR2I(left_right*size[1],up_down*size[0])) diff --git a/pcbnew/python/swig/board_item.i b/pcbnew/python/swig/board_item.i index 28313dd953..b8a94b26ed 100644 --- a/pcbnew/python/swig/board_item.i +++ b/pcbnew/python/swig/board_item.i @@ -166,15 +166,25 @@ static PCB_BITMAP* Cast_to_PCB_BITMAP( BOARD_ITEM* ); else: raise TypeError("Unsupported drawing class: %s" % ct) + """ + Needed to cast BOARD_ITEM::Duplicate() to the suitable type + """ + def Duplicate(self): + ct = self.GetClass() + if ct=="BOARD": + return None + else: + return Cast_to_BOARD_ITEM( _pcbnew.BOARD_ITEM_Duplicate(self) ).Cast() + def SetPos(self,p): self.SetPosition(p) - self.SetPos0(p) + #self.SetPos0(p) def SetStartEnd(self,start,end): self.SetStart(start) - self.SetStart0(start) + #self.SetStart0(start) self.SetEnd(end) - self.SetEnd0(end) + #self.SetEnd0(end) %} }