From ec30f72cc8107f3cd1ba0e61d656fd878ad1c0ee Mon Sep 17 00:00:00 2001 From: Jean-Samuel Reynaud Date: Fri, 30 Mar 2018 15:55:23 +0200 Subject: [PATCH] Fix delete; backport Dialog modification to FillAreaTpl.fbp --- ViaStitching/FillArea.py | 47 +++++---- ViaStitching/FillAreaDialog.py | 86 +++++++++-------- ViaStitching/FillAreaTpl.fbp | 171 +++++++++++++++++++++++++++++++++ 3 files changed, 237 insertions(+), 67 deletions(-) diff --git a/ViaStitching/FillArea.py b/ViaStitching/FillArea.py index 1d25774..97f09b3 100755 --- a/ViaStitching/FillArea.py +++ b/ViaStitching/FillArea.py @@ -161,9 +161,6 @@ class FillArea: print() print() - def PrepareFootprint(self): - return self - def CleanupFootprint(self): """ cleanup temp footprint @@ -171,14 +168,14 @@ class FillArea: if self.tmp_dir and os.path.isdir(self.tmp_dir): shutil.rmtree(self.tmp_dir) - def AddModule(self, module, position, x, y): + def AddVia(self, position, x, y): m = VIA(self.pcb) m.SetPosition(position) - m.SetNet(self.pcb.FindNet("GND")) + m.SetNet(self.pcb.FindNet(self.netname)) m.SetViaType(VIA_THROUGH) - print(self.size) m.SetDrill(int(self.drill)) m.SetWidth(int(self.size)) + m.SetTimeStamp(33) # USE 33 as timestamp to mark this via as generated self.pcb.Add(m) def RefillBoardAreas(self): @@ -195,18 +192,18 @@ class FillArea: """ if self.delete_vias: - for module in self.pcb.GetModules(): - if self.debug: - print("* Deleting module: %s" % module.GetValue()) - if module.GetValue() == "AUTO_VIA": - self.pcb.RemoveNative(module) + for via in self.pcb.GetTracks(): + if via.Type() == PCB_VIA_T: + if via.GetTimeStamp() == 33: + if self.debug: + print("* Deleting via %u" % via.GetTimeStamp()) + self.pcb.RemoveNative(via) self.RefillBoardAreas() return # no need to run the rest of logic lboard = self.pcb.ComputeBoundingBox() rectangle = [] origin = lboard.GetPosition() - module = self.PrepareFootprint() # Create an initial rectangle: all is off # get a margin to avoid out of range @@ -382,20 +379,20 @@ class FillArea: ran_y = (random.random() * self.step / 2.0) - \ (self.step / 4.0) if self.star: - if y%2: - if ((x+1)%2): - self.AddModule( - module, wxPoint(origin.x + (self.step * x) + ran_x, - origin.y + (self.step * y) + ran_y), x, y) - else: - if (x%2): - self.AddModule( - module, wxPoint(origin.x + (self.step * x) + ran_x, - origin.y + (self.step * y) + ran_y), x, y) - else: - self.AddModule( - module, wxPoint(origin.x + (self.step * x) + ran_x, + if y % 2: + if ((x + 1) % 2): + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, origin.y + (self.step * y) + ran_y), x, y) + else: + if (x % 2): + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, + origin.y + (self.step * y) + ran_y), x, y) + else: + self.AddVia( + wxPoint(origin.x + (self.step * x) + ran_x, + origin.y + (self.step * y) + ran_y), x, y) self.RefillBoardAreas() diff --git a/ViaStitching/FillAreaDialog.py b/ViaStitching/FillAreaDialog.py index 291751e..42999e1 100644 --- a/ViaStitching/FillAreaDialog.py +++ b/ViaStitching/FillAreaDialog.py @@ -1,7 +1,7 @@ -# -*- coding: utf-8 -*- +# -*- coding: utf-8 -*- ########################################################################### -## Python code generated with wxFormBuilder (version Feb 16 2016) +## Python code generated with wxFormBuilder (version Dec 21 2016) ## http://www.wxformbuilder.org/ ## ## PLEASE DO "NOT" EDIT THIS FILE! @@ -15,118 +15,120 @@ import wx.xrc ########################################################################### class FillAreaDialog ( wx.Dialog ): - + def __init__( self, parent ): wx.Dialog.__init__ ( self, parent, id = wx.ID_ANY, title = u"Fill Area parameters", pos = wx.DefaultPosition, size = wx.Size( 369,389 ), style = wx.DEFAULT_DIALOG_STYLE ) - + self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize ) - + bSizer3 = wx.BoxSizer( wx.VERTICAL ) - + fgSizer1 = wx.FlexGridSizer( 0, 2, 0, 0 ) fgSizer1.SetFlexibleDirection( wx.BOTH ) fgSizer1.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED ) - + self.m_staticText3 = wx.StaticText( self, wx.ID_ANY, u"Via copper size", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText3.Wrap( -1 ) fgSizer1.Add( self.m_staticText3, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_SizeMM = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_SizeMM.SetMinSize( wx.Size( 1000,-1 ) ) - + fgSizer1.Add( self.m_SizeMM, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText9 = wx.StaticText( self, wx.ID_ANY, u"Via drill size", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText9.Wrap( -1 ) fgSizer1.Add( self.m_staticText9, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_DrillMM = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_DrillMM, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText5 = wx.StaticText( self, wx.ID_ANY, u"Via clearance", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText5.Wrap( -1 ) fgSizer1.Add( self.m_staticText5, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_ClearanceMM = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_ClearanceMM, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText6 = wx.StaticText( self, wx.ID_ANY, u"Net name", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText6.Wrap( -1 ) fgSizer1.Add( self.m_staticText6, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_Netname = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_Netname, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText2 = wx.StaticText( self, wx.ID_ANY, u"Step between via", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText2.Wrap( -1 ) fgSizer1.Add( self.m_staticText2, 0, wx.ALL, 5 ) - + self.m_StepMM = wx.TextCtrl( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_StepMM, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText7 = wx.StaticText( self, wx.ID_ANY, u"Debug mode", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText7.Wrap( -1 ) fgSizer1.Add( self.m_staticText7, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_Debug = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_Debug, 1, wx.ALL|wx.EXPAND, 5 ) - + self.m_staticText8 = wx.StaticText( self, wx.ID_ANY, u"Random it", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText8.Wrap( -1 ) fgSizer1.Add( self.m_staticText8, 0, wx.ALL, 5 ) - + self.m_Random = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_Random, 0, wx.ALL, 5 ) - + self.m_staticText42 = wx.StaticText( self, wx.ID_ANY, u"Star Pattern", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText42.Wrap( -1 ) fgSizer1.Add( self.m_staticText42, 0, wx.ALL, 5 ) - + self.m_Star = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_Star, 0, wx.ALL, 5 ) - + self.m_staticText81 = wx.StaticText( self, wx.ID_ANY, u"Only under selected Zone", wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText81.Wrap( -1 ) fgSizer1.Add( self.m_staticText81, 0, wx.ALL, 5 ) - + self.m_only_selected = wx.CheckBox( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) fgSizer1.Add( self.m_only_selected, 0, wx.ALL, 5 ) - - + + bSizer3.Add( fgSizer1, 1, wx.EXPAND, 5 ) - + bSizer1 = wx.BoxSizer( wx.HORIZONTAL ) - + self.m_staticText101 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 ) self.m_staticText101.Wrap( -1 ) bSizer1.Add( self.m_staticText101, 1, wx.ALL, 5 ) - + self.m_button1 = wx.Button( self, wx.ID_OK, u"Run", wx.DefaultPosition, wx.DefaultSize, 0 ) - self.m_button1.SetDefault() + self.m_button1.SetDefault() bSizer1.Add( self.m_button1, 0, wx.ALL|wx.ALIGN_CENTER_VERTICAL, 5 ) - + self.m_button2 = wx.Button( self, wx.ID_CANCEL, u"Cancel", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer1.Add( self.m_button2, 0, wx.ALL, 5 ) - + self.m_button3_delete = wx.Button( self, wx.ID_DELETE, u"Delete Vias", wx.DefaultPosition, wx.DefaultSize, 0 ) bSizer1.Add( self.m_button3_delete, 0, wx.ALL, 5 ) - - + + bSizer3.Add( bSizer1, 0, wx.EXPAND|wx.ALIGN_RIGHT, 5 ) - - + + self.SetSizer( bSizer3 ) self.Layout() - + self.Centre( wx.BOTH ) - + # Connect Events self.m_button3_delete.Bind( wx.EVT_BUTTON, self.onDeleteClick ) - + def __del__( self ): pass - - + + # Virtual event handlers, overide them in your derived class def onDeleteClick( self, event ): event.Skip() + + diff --git a/ViaStitching/FillAreaTpl.fbp b/ViaStitching/FillAreaTpl.fbp index 5701cfd..be9e913 100644 --- a/ViaStitching/FillAreaTpl.fbp +++ b/ViaStitching/FillAreaTpl.fbp @@ -1321,6 +1321,177 @@ + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + Star Pattern + + 0 + + + 0 + + 1 + m_staticText42 + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + + + -1 + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 + wxALL + 0 + + 1 + 1 + 1 + 1 + + + + + + + + 1 + 0 + 0 + 1 + + 1 + 0 + Dock + 0 + Left + 1 + + 1 + + 0 + 0 + wxID_ANY + + + 0 + + + 0 + + 1 + m_Star + 1 + + + protected + 1 + + Resizable + 1 + + + + 0 + + + wxFILTER_NONE + wxDefaultValidator + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 5 wxALL