diff --git a/ViaStitching/FillArea.py b/ViaStitching/FillArea.py
index b40c6b0..db363aa 100755
--- a/ViaStitching/FillArea.py
+++ b/ViaStitching/FillArea.py
@@ -83,6 +83,7 @@ class FillArea:
# ie: radius from the border of the via
self.SetClearanceMM(0.2)
self.only_selected_area = False
+ self.delete_vias = False
if self.pcb is not None:
for lnet in ["GND", "/GND"]:
if self.pcb.FindNet(lnet) is not None:
@@ -136,6 +137,10 @@ class FillArea:
self.only_selected_area = True
return self
+ def DeleteVias(self):
+ self.delete_vias = True
+ return self
+
def SetClearanceMM(self, s):
self.clearance = float(FromMM(s))
return self
@@ -186,20 +191,37 @@ 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 AddModule(self, module, position, x, y):
m = MODULE(module)
m.SetPosition(position)
m.SetReference("V%s_%s" % (x, y))
m.SetValue("AUTO_VIA")
m.SetLastEditTime()
m.thisown = 0
- self.pcb.AddNative(m,ADD_APPEND)
+ self.pcb.AddNative(m, ADD_APPEND)
m.SetFlag(IS_NEW)
+ def RefillBoardAreas(self):
+ for i in range(self.pcb.GetAreaCount()):
+ area = self.pcb.GetArea(i)
+ area.ClearFilledPolysList()
+ area.UnFill()
+ if not area.GetIsKeepout():
+ area.BuildFilledSolidAreasPolygons(self.pcb)
+
def Run(self):
"""
Launch the process
"""
+
+ if self.delete_vias:
+ for module in self.pcb.GetModules():
+ print("* Deleting module: %s" % module.GetValue())
+ if module.GetValue() == "AUTO_VIA":
+ self.pcb.DeleteNative(module)
+ self.RefillBoardAreas()
+ return
+
lboard = self.pcb.ComputeBoundingBox()
rectangle = []
origin = lboard.GetPosition()
@@ -239,7 +261,7 @@ class FillArea:
for y in range(rectangle[0].__len__()):
for x in range(rectangle.__len__()):
testResult = not keepOutMode # = False if is Keepout
- offset = self.clearance + self.size/2
+ offset = self.clearance + self.size / 2
#offset = int(self.inter / 2)
# For keepout area: Deny Via
# For same net area: Allow if not denied by keepout
@@ -248,7 +270,7 @@ class FillArea:
for dx in [-offset, offset]:
for dy in [-offset, offset]:
r = area.HitTestFilledArea(wxPoint(current_x + dx,
- current_y + dy))
+ current_y + dy))
if keepOutMode:
testResult |= r
else:
@@ -273,17 +295,18 @@ class FillArea:
# Same job with all pads
for pad in self.pcb.GetPads():
- local_offset = max(pad.GetClearance(),self.clearance) + self.size/2
- max_size = max(pad.GetSize().x,pad.GetSize().y)
+ local_offset = max(pad.GetClearance(),
+ self.clearance) + self.size / 2
+ max_size = max(pad.GetSize().x, pad.GetSize().y)
start_x = int(floor(((pad.GetPosition().x - (max_size / 2.0 +
- local_offset)) - origin.x) / self.step))
+ local_offset)) - origin.x) / self.step))
stop_x = int(ceil(((pad.GetPosition().x + (max_size / 2.0 +
- local_offset)) - origin.x) / self.step))
+ local_offset)) - origin.x) / self.step))
start_y = int(floor(((pad.GetPosition().y - (max_size / 2.0 +
- local_offset)) - origin.y) / self.step))
+ local_offset)) - origin.y) / self.step))
stop_y = int(ceil(((pad.GetPosition().y + (max_size / 2.0 +
- local_offset)) - origin.y) / self.step))
+ local_offset)) - origin.y) / self.step))
for x in range(start_x, stop_x + 1):
for y in range(start_y, stop_y + 1):
@@ -318,14 +341,15 @@ class FillArea:
opx = stop_x
opy = stop_y
- clearance = max(track.GetClearance(),self.clearance) + self.size/2 + track.GetWidth()/2
+ clearance = max(track.GetClearance(), self.clearance) + \
+ self.size / 2 + track.GetWidth() / 2
start_x = int(floor(((start_x - clearance) -
- origin.x) / self.step))
+ origin.x) / self.step))
stop_x = int(ceil(((stop_x + clearance) - origin.x) / self.step))
start_y = int(floor(((start_y - clearance) -
- origin.y) / self.step))
+ origin.y) / self.step))
stop_y = int(ceil(((stop_y + clearance) - origin.y) / self.step))
for x in range(start_x, stop_x + 1):
@@ -345,20 +369,20 @@ class FillArea:
# Same job with existing text
for draw in self.pcb.m_Drawings:
if (draw.GetClass() == 'PTEXT' and
- self.pcb.GetLayerID(draw.GetLayerName()) in (F_Cu, B_Cu)):
+ self.pcb.GetLayerID(draw.GetLayerName()) in (F_Cu, B_Cu)):
inter = float(self.clearance + self.size)
bbox = draw.GetBoundingBox()
start_x = int(floor(((bbox.GetPosition().x - inter) -
- origin.x) / self.step))
+ origin.x) / self.step))
stop_x = int(ceil(((bbox.GetPosition().x +
- (bbox.GetSize().x + inter)) -
- origin.x) / self.step))
+ (bbox.GetSize().x + inter)) -
+ origin.x) / self.step))
start_y = int(floor(((bbox.GetPosition().y - inter) -
- origin.y) / self.step))
+ origin.y) / self.step))
stop_y = int(ceil(((bbox.GetPosition().y +
- (bbox.GetSize().y + inter)) -
- origin.y) / self.step))
+ (bbox.GetSize().y + inter)) -
+ origin.y) / self.step))
for x in range(start_x, stop_x + 1):
for y in range(start_y, stop_y + 1):
@@ -374,17 +398,14 @@ class FillArea:
ran_x = 0
ran_y = 0
if self.random:
- ran_x = (random.random() * self.step / 2.0) - (self.step / 4.0)
- ran_y = (random.random() * self.step / 2.0) - (self.step / 4.0)
- self.AddModule(module,wxPoint(origin.x + (self.step * x) + ran_x,
- origin.y + (self.step * y) + ran_y),x,y)
+ ran_x = (random.random() * self.step / 2.0) - \
+ (self.step / 4.0)
+ ran_y = (random.random() * self.step / 2.0) - \
+ (self.step / 4.0)
+ self.AddModule(module, wxPoint(origin.x + (self.step * x) + ran_x,
+ origin.y + (self.step * y) + ran_y), x, y)
- for i in range(self.pcb.GetAreaCount()):
- area = self.pcb.GetArea(i)
- area.ClearFilledPolysList()
- area.UnFill()
- if not area.GetIsKeepout():
- area.BuildFilledSolidAreasPolygons(self.pcb)
+ self.RefillBoardAreas()
if self.filename:
self.pcb.Save(self.filename)
diff --git a/ViaStitching/FillAreaAction.py b/ViaStitching/FillAreaAction.py
index 4df167b..46661fd 100644
--- a/ViaStitching/FillAreaAction.py
+++ b/ViaStitching/FillAreaAction.py
@@ -24,6 +24,7 @@ import FillAreaDialog
class FillAreaAction(pcbnew.ActionPlugin):
+
def defaults(self):
self.name = "Via stitching WX"
self.category = "Undefined"
@@ -52,9 +53,11 @@ class FillAreaAction(pcbnew.ActionPlugin):
fill.SetRandom()
if a.m_only_selected.IsChecked():
fill.OnlyOnSelectedArea()
+ if a.m_delete_vias.IsChecked():
+ fill.DeleteVias()
fill.Run()
except Exception:
- wx.MessageDialog(None,"Invalid parameter")
+ wx.MessageDialog(None, "Invalid parameter")
else:
print "Cancel"
a.Destroy()
diff --git a/ViaStitching/FillAreaDialog.py b/ViaStitching/FillAreaDialog.py
index 77d1e63..268ee51 100644
--- a/ViaStitching/FillAreaDialog.py
+++ b/ViaStitching/FillAreaDialog.py
@@ -1,111 +1,138 @@
-# -*- coding: utf-8 -*-
+# -*- coding: utf-8 -*-
###########################################################################
-## Python code generated with wxFormBuilder (version Feb 16 2016)
-## http://www.wxformbuilder.org/
+# Python code generated with wxFormBuilder (version Feb 16 2016)
+# http://www.wxformbuilder.org/
##
-## PLEASE DO "NOT" EDIT THIS FILE!
+# PLEASE DO "NOT" EDIT THIS FILE!
###########################################################################
import wx
import wx.xrc
###########################################################################
-## Class FillAreaDialog
+# Class FillAreaDialog
###########################################################################
-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,356 ), style = wx.DEFAULT_DIALOG_STYLE )
-
- self.SetSizeHintsSz( wx.DefaultSize, wx.DefaultSize )
-
- 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_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 )
-
- self.m_staticText71 = wx.StaticText( self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0 )
- self.m_staticText71.Wrap( -1 )
- fgSizer1.Add( self.m_staticText71, 0, wx.ALL, 5 )
-
- bSizer1 = wx.BoxSizer( wx.HORIZONTAL )
-
- self.m_button1 = wx.Button( self, wx.ID_OK, u"Run", wx.DefaultPosition, wx.DefaultSize, 0 )
- 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 )
-
-
- fgSizer1.Add( bSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL|wx.ALIGN_CENTER_VERTICAL, 5 )
-
-
- self.SetSizer( fgSizer1 )
- self.Layout()
-
- self.Centre( wx.BOTH )
-
- def __del__( self ):
- pass
-
+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, 369), style=wx.DEFAULT_DIALOG_STYLE)
+
+ self.SetSizeHintsSz(wx.DefaultSize, wx.DefaultSize)
+
+ 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_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)
+
+ self.m_staticText82 = wx.StaticText(
+ self, wx.ID_ANY, u"Delete vias", wx.DefaultPosition, wx.DefaultSize, 0)
+ self.m_staticText82.Wrap(-1)
+ fgSizer1.Add(self.m_staticText82, 0, wx.ALL, 5)
+
+ self.m_delete_vias = wx.CheckBox(
+ self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
+ fgSizer1.Add(self.m_delete_vias, 0, wx.ALL, 5)
+
+ self.m_staticText71 = wx.StaticText(
+ self, wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, 0)
+ self.m_staticText71.Wrap(-1)
+ fgSizer1.Add(self.m_staticText71, 0, wx.ALL, 5)
+
+ bSizer1 = wx.BoxSizer(wx.HORIZONTAL)
+
+ self.m_button1 = wx.Button(
+ self, wx.ID_OK, u"Run", wx.DefaultPosition, wx.DefaultSize, 0)
+ 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)
+
+ fgSizer1.Add(bSizer1, 1, wx.ALIGN_CENTER_HORIZONTAL |
+ wx.ALIGN_CENTER_VERTICAL, 5)
+
+ self.SetSizer(fgSizer1)
+ self.Layout()
+
+ self.Centre(wx.BOTH)
+
+ def __del__(self):
+ pass
diff --git a/ViaStitching/FillAreaTpl.fbp b/ViaStitching/FillAreaTpl.fbp
index 819391d..1a21d58 100644
--- a/ViaStitching/FillAreaTpl.fbp
+++ b/ViaStitching/FillAreaTpl.fbp
@@ -44,7 +44,7 @@
FillAreaDialog
- 369,356
+ 369,369
wxDEFAULT_DIALOG_STYLE
Fill Area parameters
@@ -1395,6 +1395,89 @@
+
5
wxALL
@@ -1483,6 +1566,94 @@
+
+ 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_delete_vias
+ 1
+
+
+ protected
+ 1
+
+ Resizable
+ 1
+
+
+
+ 0
+
+
+ wxFILTER_NONE
+ wxDefaultValidator
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
5
wxALL