Skip to content

Commit 161e48e

Browse files
authored
Merge pull request #24 from sparkfun/release_candidate
Version 1.4.0
2 parents 29a1654 + 0d8c6d8 commit 161e48e

File tree

6 files changed

+325
-93
lines changed

6 files changed

+325
-93
lines changed

SparkFunKiCadPanelizer/dialog/dialog.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,14 @@ class GeneralPanel(dialog_text_base.GeneralPanelBase):
217217
def __init__(self, parent):
218218
dialog_text_base.GeneralPanelBase.__init__(self, parent)
219219

220+
self.m_buttonGapsVerticalHelp.SetLabelText("")
221+
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
222+
self.m_buttonGapsVerticalHelp.SetBitmap(get_btn_bitmap("info-15.png"))
223+
224+
self.m_buttonGapsHorizontalHelp.SetLabelText("")
225+
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
226+
self.m_buttonGapsHorizontalHelp.SetBitmap(get_btn_bitmap("info-15.png"))
227+
220228
self.m_buttonFiducialsHelp.SetLabelText("")
221229
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
222230
self.m_buttonFiducialsHelp.SetBitmap(get_btn_bitmap("info-15.png"))
@@ -225,6 +233,28 @@ def __init__(self, parent):
225233
# Icon by Icons8 https://icons8.com : https://icons8.com/icon/63308/info
226234
self.m_buttonEdgeHelp.SetBitmap(get_btn_bitmap("info-15.png"))
227235

236+
def ClickGapsVerticalHelp( self, event ):
237+
wx.MessageBox("\
238+
This sets the width of the vertical gaps\n\
239+
within the panel. Vertical gaps run from\n\
240+
the bottom rail to the top rail. The width\n\
241+
is defined in X.\n\
242+
\n\
243+
The gap width should be at least 0.3\" to\n\
244+
aid automated inspection.\
245+
", 'Info', wx.OK | wx.ICON_INFORMATION)
246+
247+
def ClickGapsHorizontalHelp( self, event ):
248+
wx.MessageBox("\
249+
This sets the width of the horizontal gaps\n\
250+
within the panel. Horizontal gaps run from\n\
251+
the left rail to the right rail. The width\n\
252+
is defined in Y.\n\
253+
\n\
254+
The gap width should be at least 0.3\" to\n\
255+
aid automated inspection.\
256+
", 'Info', wx.OK | wx.ICON_INFORMATION)
257+
228258
def ClickFiducialsHelp( self, event ):
229259
wx.MessageBox("\
230260
By default, the panel fiducials are placed in\n\

SparkFunKiCadPanelizer/dialog/dialog_text_base.py

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,34 +159,55 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
159159

160160
sbSizer3 = wx.StaticBoxSizer( wx.StaticBox( self, wx.ID_ANY, _(u"Gaps:") ), wx.VERTICAL )
161161

162-
fgSizerGaps = wx.FlexGridSizer( 0, 2, 4, 4 )
163-
fgSizerGaps.SetFlexibleDirection( wx.BOTH )
164-
fgSizerGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
162+
fgSizerVerticalGaps = wx.FlexGridSizer( 0, 3, 0, 0 )
163+
fgSizerVerticalGaps.SetFlexibleDirection( wx.BOTH )
164+
fgSizerVerticalGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
165165

166166
self.m_gapsVerticalLabel = wx.StaticText( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Vertical Gap (X):"), wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_LEFT )
167167
self.m_gapsVerticalLabel.Wrap( -1 )
168168

169-
fgSizerGaps.Add( self.m_gapsVerticalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
169+
self.m_gapsVerticalLabel.SetMinSize( wx.Size( 120,-1 ) )
170+
171+
fgSizerVerticalGaps.Add( self.m_gapsVerticalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
170172

171173
self.m_gapsVerticalCtrl = wx.TextCtrl( sbSizer3.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
172174
self.m_gapsVerticalCtrl.SetMaxLength( 0 )
173175
self.m_gapsVerticalCtrl.SetMinSize( wx.Size( 64,-1 ) )
174176

175-
fgSizerGaps.Add( self.m_gapsVerticalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
177+
fgSizerVerticalGaps.Add( self.m_gapsVerticalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
178+
179+
self.m_buttonGapsVerticalHelp = wx.Button( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"MyButton"), wx.DefaultPosition, wx.DefaultSize, 0 )
180+
self.m_buttonGapsVerticalHelp.SetMinSize( wx.Size( 15,15 ) )
181+
182+
fgSizerVerticalGaps.Add( self.m_buttonGapsVerticalHelp, 0, wx.ALL, 5 )
183+
184+
185+
sbSizer3.Add( fgSizerVerticalGaps, 1, wx.EXPAND, 5 )
186+
187+
fgSizerHorizontalGaps = wx.FlexGridSizer( 0, 3, 0, 0 )
188+
fgSizerHorizontalGaps.SetFlexibleDirection( wx.BOTH )
189+
fgSizerHorizontalGaps.SetNonFlexibleGrowMode( wx.FLEX_GROWMODE_SPECIFIED )
176190

177191
self.m_gapsHorizontalLabel = wx.StaticText( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Horizontal Gap (Y):"), wx.DefaultPosition, wx.DefaultSize, wx.ALIGN_LEFT )
178192
self.m_gapsHorizontalLabel.Wrap( -1 )
179193

180-
fgSizerGaps.Add( self.m_gapsHorizontalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
194+
self.m_gapsHorizontalLabel.SetMinSize( wx.Size( 120,-1 ) )
195+
196+
fgSizerHorizontalGaps.Add( self.m_gapsHorizontalLabel, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
181197

182198
self.m_gapsHorizontalCtrl = wx.TextCtrl( sbSizer3.GetStaticBox(), wx.ID_ANY, wx.EmptyString, wx.DefaultPosition, wx.DefaultSize, wx.TE_PROCESS_ENTER )
183199
self.m_gapsHorizontalCtrl.SetMaxLength( 0 )
184200
self.m_gapsHorizontalCtrl.SetMinSize( wx.Size( 64,-1 ) )
185201

186-
fgSizerGaps.Add( self.m_gapsHorizontalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
202+
fgSizerHorizontalGaps.Add( self.m_gapsHorizontalCtrl, 1, wx.ALIGN_CENTER_VERTICAL, 5 )
187203

204+
self.m_buttonGapsHorizontalHelp = wx.Button( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"MyButton"), wx.DefaultPosition, wx.DefaultSize, 0 )
205+
self.m_buttonGapsHorizontalHelp.SetMinSize( wx.Size( 15,15 ) )
188206

189-
sbSizer3.Add( fgSizerGaps, 0, wx.ALL, 10 )
207+
fgSizerHorizontalGaps.Add( self.m_buttonGapsHorizontalHelp, 0, wx.ALL, 5 )
208+
209+
210+
sbSizer3.Add( fgSizerHorizontalGaps, 1, wx.EXPAND, 5 )
190211

191212
self.m_removeRightVerticalCheck = wx.CheckBox( sbSizer3.GetStaticBox(), wx.ID_ANY, _(u"Remove right-most vertical gap and use v-score instead"), wx.DefaultPosition, wx.DefaultSize, 0 )
192213
sbSizer3.Add( self.m_removeRightVerticalCheck, 0, wx.ALL, 5 )
@@ -238,6 +259,8 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
238259
bMainSizer.Fit( self )
239260

240261
# Connect Events
262+
self.m_buttonGapsVerticalHelp.Bind( wx.EVT_BUTTON, self.ClickGapsVerticalHelp )
263+
self.m_buttonGapsHorizontalHelp.Bind( wx.EVT_BUTTON, self.ClickGapsHorizontalHelp )
241264
self.m_buttonFiducialsHelp.Bind( wx.EVT_BUTTON, self.ClickFiducialsHelp )
242265
self.m_buttonEdgeHelp.Bind( wx.EVT_BUTTON, self.ClickEdgeHelp )
243266

@@ -246,6 +269,12 @@ def __del__( self ):
246269

247270

248271
# Virtual event handlers, override them in your derived class
272+
def ClickGapsVerticalHelp( self, event ):
273+
pass
274+
275+
def ClickGapsHorizontalHelp( self, event ):
276+
pass
277+
249278
def ClickFiducialsHelp( self, event ):
250279
pass
251280

SparkFunKiCadPanelizer/panelizer/panelizer.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -315,6 +315,10 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
315315
SMALLER_THAN = True
316316

317317
# Check gaps
318+
if (GAP_X < 0.0) or (GAP_Y < 0.0):
319+
report += "Gap width can not be negative. Quitting.\n"
320+
sysExit = 2
321+
return sysExit, report
318322
if (GAP_X != 0.0) and (GAP_Y != 0.0):
319323
report += "Specify X or Y gaps, not both. Quitting.\n"
320324
sysExit = 2
@@ -327,6 +331,9 @@ def startPanelizer(self, args, board=None, ordering=None, logger=None):
327331
report += "Can not have Y gaps without vertical rails. Quitting.\n"
328332
sysExit = 2
329333
return sysExit, report
334+
if ((GAP_X > 0.0) and (GAP_X < 7.62)) or ((GAP_Y > 0.0) and (GAP_Y < 7.62)): # Check non-zero gaps are 0.3" for AOI
335+
report += "Gaps should be at least 0.3\" for AOI.\n"
336+
sysExit = 1
330337

331338
# Check exposed edge
332339
if EXPOSED_EDGE:

SparkFunKiCadPanelizer/plugin.py

Lines changed: 75 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def __init__(self):
2727

2828
self._pcbnew_frame = None
2929

30-
self.supportedVersions = ['7.','8.']
30+
self.supportedVersions = ['7.','8.','9.']
3131

3232
self.kicad_build_version = pcbnew.GetBuildVersion()
3333

@@ -96,84 +96,84 @@ def Run(self):
9696
def run_panelizer(dlg, p_panelizer):
9797
self.logger.log(logging.INFO, "Running Panelizer")
9898

99-
if self.IsSupported():
100-
command = []
101-
102-
convertDimensions = 1.0
103-
if dlg.CurrentSettings()["dimensionsInchesBtn"]:
104-
convertDimensions = 25.4
105-
106-
panelx = float(dlg.CurrentSettings()["panelSizeXCtrl"]) * convertDimensions
107-
panely = float(dlg.CurrentSettings()["panelSizeYCtrl"]) * convertDimensions
108-
command.extend(['--panelx','{:.6f}'.format(panelx)])
109-
command.extend(['--panely','{:.6f}'.format(panely)])
110-
111-
smallerThan = dlg.CurrentSettings()["panelSizeSmallerBtn"]
112-
if smallerThan:
113-
command.append('--smaller')
114-
else:
115-
command.append('--larger')
116-
117-
vscorelayer = dlg.CurrentSettings()[dlg.vscore_layer]
118-
command.extend(['--vscorelayer', vscorelayer, '--vscoretextlayer', vscorelayer])
119-
120-
gapx = float(dlg.CurrentSettings()["gapsVerticalCtrl"]) * convertDimensions
121-
gapy = float(dlg.CurrentSettings()["gapsHorizontalCtrl"]) * convertDimensions
122-
command.extend(['--gapx','{:.6f}'.format(gapx)])
123-
command.extend(['--gapy','{:.6f}'.format(gapy)])
124-
125-
removeRight = dlg.CurrentSettings()["removeRightVerticalCheck"]
126-
if removeRight:
127-
command.append('--norightgap')
128-
129-
exposeedge = dlg.CurrentSettings()["productionExposeCheck"]
130-
if exposeedge:
131-
command.append('--exposeedge')
132-
133-
fiducials = dlg.CurrentSettings()["productionBordersCheck"]
134-
leftright = dlg.CurrentSettings()["productionFiducialsCheck"]
135-
if not exposeedge:
136-
if fiducials:
137-
# Default the rail width to 1/4" and nudge by 1/4 of the rail width.
138-
# This provides the clearance needed for clamping and AOI Inspection of the fiducials.
139-
# This is nasty. The default should be in panelizer.py. But I can't think of a solution
140-
# which is good for everyone - including anyone running the panelizer from the command line.
141-
command.extend(['--hrail','6.35','--vrail','6.35'])
142-
command.extend(['--fiducialpos','0.25'])
143-
if leftright:
144-
command.append('--fiducialslr')
145-
else:
146-
command.append('--fiducialstb')
147-
else:
148-
if fiducials:
149-
# Same comment as above
150-
command.extend(['--vrail','6.35'])
151-
command.extend(['--fiducialpos','0.25'])
152-
command.append('--fiducialslr')
99+
if not self.IsSupported():
100+
# Log a warning if this version of KiCad has not been tested
101+
self.logger.log(logging.WARNING, "Version check failed. \"{}\" may not be supported. Panelizing may fail".format(self.kicad_build_version))
102+
103+
command = []
104+
105+
convertDimensions = 1.0
106+
if dlg.CurrentSettings()["dimensionsInchesBtn"]:
107+
convertDimensions = 25.4
108+
109+
panelx = float(dlg.CurrentSettings()["panelSizeXCtrl"]) * convertDimensions
110+
panely = float(dlg.CurrentSettings()["panelSizeYCtrl"]) * convertDimensions
111+
command.extend(['--panelx','{:.6f}'.format(panelx)])
112+
command.extend(['--panely','{:.6f}'.format(panely)])
153113

154-
self.logger.log(logging.INFO, command)
155-
156-
board = pcbnew.GetBoard()
157-
158-
if board is not None:
159-
sysExit, report = p_panelizer.startPanelizerCommand(command, board, self.ordering_instructions, self.logger)
160-
logWarn = logging.INFO
161-
if sysExit >= 1:
162-
logWarn = logging.WARN
163-
if sysExit >= 2:
164-
logWarn = logging.ERROR
165-
self.logger.log(logWarn, report)
166-
if sysExit > 0:
167-
wx.MessageBox("Panelizer " + ("warning" if (sysExit == 1) else "error") + ".\nPlease check panelizer.log for details.",
168-
("Warning" if (sysExit == 1) else "Error"), wx.OK | (wx.ICON_WARNING if (sysExit == 1) else wx.ICON_ERROR))
114+
smallerThan = dlg.CurrentSettings()["panelSizeSmallerBtn"]
115+
if smallerThan:
116+
command.append('--smaller')
117+
else:
118+
command.append('--larger')
119+
120+
vscorelayer = dlg.CurrentSettings()[dlg.vscore_layer]
121+
command.extend(['--vscorelayer', vscorelayer, '--vscoretextlayer', vscorelayer])
122+
123+
gapx = float(dlg.CurrentSettings()["gapsVerticalCtrl"]) * convertDimensions
124+
gapy = float(dlg.CurrentSettings()["gapsHorizontalCtrl"]) * convertDimensions
125+
command.extend(['--gapx','{:.6f}'.format(gapx)])
126+
command.extend(['--gapy','{:.6f}'.format(gapy)])
127+
128+
removeRight = dlg.CurrentSettings()["removeRightVerticalCheck"]
129+
if removeRight:
130+
command.append('--norightgap')
131+
132+
exposeedge = dlg.CurrentSettings()["productionExposeCheck"]
133+
if exposeedge:
134+
command.append('--exposeedge')
135+
136+
fiducials = dlg.CurrentSettings()["productionBordersCheck"]
137+
leftright = dlg.CurrentSettings()["productionFiducialsCheck"]
138+
if not exposeedge:
139+
if fiducials:
140+
# Default the rail width to 1/4" and nudge by 1/4 of the rail width.
141+
# This provides the clearance needed for clamping and AOI Inspection of the fiducials.
142+
# This is nasty. The default should be in panelizer.py. But I can't think of a solution
143+
# which is good for everyone - including anyone running the panelizer from the command line.
144+
command.extend(['--hrail','6.35','--vrail','6.35'])
145+
command.extend(['--fiducialpos','0.25'])
146+
if leftright:
147+
command.append('--fiducialslr')
169148
else:
170-
wx.MessageBox("Panelizer complete.\nPlease check panelizer.log for details.",
171-
"Info", wx.OK | wx.ICON_INFORMATION)
149+
command.append('--fiducialstb')
150+
else:
151+
if fiducials:
152+
# Same comment as above
153+
command.extend(['--vrail','6.35'])
154+
command.extend(['--fiducialpos','0.25'])
155+
command.append('--fiducialslr')
156+
157+
self.logger.log(logging.INFO, command)
158+
159+
board = pcbnew.GetBoard()
160+
161+
if board is not None:
162+
sysExit, report = p_panelizer.startPanelizerCommand(command, board, self.ordering_instructions, self.logger)
163+
logWarn = logging.INFO
164+
if sysExit >= 1:
165+
logWarn = logging.WARNING
166+
if sysExit >= 2:
167+
logWarn = logging.ERROR
168+
self.logger.log(logWarn, report)
169+
if sysExit > 0:
170+
wx.MessageBox("Panelizer " + ("warning" if (sysExit == 1) else "error") + ".\nPlease check panelizer.log for details.",
171+
("Warning" if (sysExit == 1) else "Error"), wx.OK | (wx.ICON_WARNING if (sysExit == 1) else wx.ICON_ERROR))
172172
else:
173-
self.logger.log(logging.ERROR, "Could not get the board")
174-
173+
wx.MessageBox("Panelizer complete.\nPlease check panelizer.log for details.",
174+
"Info", wx.OK | wx.ICON_INFORMATION)
175175
else:
176-
self.logger.log(logging.ERROR, "Version check failed. \"{}\" not supported".format(self.kicad_build_version))
176+
self.logger.log(logging.ERROR, "Could not get the board")
177177

178178
dlg.GetParent().EndModal(wx.ID_OK)
179179

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.3.2"
1+
__version__ = "1.4.0"

0 commit comments

Comments
 (0)