Skip to content

Commit 833369f

Browse files
committed
Add option to hide pads
Fixes #76
1 parent ee2aeb5 commit 833369f

File tree

6 files changed

+154
-47
lines changed

6 files changed

+154
-47
lines changed

InteractiveHtmlBom/core/config.py

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,16 @@ class Config:
2020
]
2121
default_checkboxes = ['Sourced', 'Placed']
2222
html_config_fields = [
23-
'dark_mode', 'show_fabrication', 'show_silkscreen', 'highlight_pin1',
24-
'redraw_on_drag', 'board_rotation', 'checkboxes', 'bom_view',
25-
'layer_view', 'extra_fields'
23+
'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen',
24+
'highlight_pin1', 'redraw_on_drag', 'board_rotation', 'checkboxes',
25+
'bom_view', 'layer_view', 'extra_fields'
2626
]
2727

2828
# Defaults
2929

3030
# HTML section
3131
dark_mode = False
32+
show_pads = True
3233
show_fabrication = False
3334
show_silkscreen = True
3435
highlight_pin1 = False
@@ -69,6 +70,7 @@ def __init__(self):
6970

7071
f.SetPath('/html_defaults')
7172
self.dark_mode = f.ReadBool('dark_mode', self.dark_mode)
73+
self.show_pads = f.ReadBool('show_pads', self.show_pads)
7274
self.show_fabrication = f.ReadBool(
7375
'show_fabrication', self.show_fabrication)
7476
self.show_silkscreen = f.ReadBool(
@@ -114,6 +116,7 @@ def save(self):
114116

115117
f.SetPath('/html_defaults')
116118
f.WriteBool('dark_mode', self.dark_mode)
119+
f.WriteBool('show_pads', self.show_pads)
117120
f.WriteBool('show_fabrication', self.show_fabrication)
118121
f.WriteBool('show_silkscreen', self.show_silkscreen)
119122
f.WriteBool('highlight_pin1', self.highlight_pin1)
@@ -152,6 +155,7 @@ def set_from_dialog(self, dlg):
152155
# type: (dialog.settings_dialog.SettingsDialogPanel) -> None
153156
# Html
154157
self.dark_mode = dlg.html.darkModeCheckbox.IsChecked()
158+
self.show_pads = dlg.html.showPadsCheckbox.IsChecked()
155159
self.show_fabrication = dlg.html.showFabricationCheckbox.IsChecked()
156160
self.show_silkscreen = dlg.html.showSilkscreenCheckbox.IsChecked()
157161
self.highlight_pin1 = dlg.html.highlightPin1Checkbox.IsChecked()
@@ -191,6 +195,7 @@ def transfer_to_dialog(self, dlg):
191195
# type: (dialog.settings_dialog.SettingsDialogPanel) -> None
192196
# Html
193197
dlg.html.darkModeCheckbox.Value = self.dark_mode
198+
dlg.html.showPadsCheckbox.Value = self.show_pads
194199
dlg.html.showFabricationCheckbox.Value = self.show_fabrication
195200
dlg.html.showSilkscreenCheckbox.Value = self.show_silkscreen
196201
dlg.html.highlightPin1Checkbox.Value = self.highlight_pin1
@@ -244,6 +249,9 @@ def add_options(self, parser, file_name_format_hint):
244249
# Html
245250
parser.add_argument('--dark-mode', help='Default to dark mode.',
246251
action='store_true')
252+
parser.add_argument('--hide-pads',
253+
help='Hide footprint pads by default.',
254+
action='store_true')
247255
parser.add_argument('--show-fabrication',
248256
help='Show fabrication layer by default.',
249257
action='store_true')
@@ -318,6 +326,7 @@ def set_from_args(self, args):
318326

319327
# Html
320328
self.dark_mode = args.dark_mode
329+
self.show_pads = not args.hide_pads
321330
self.show_fabrication = args.show_fabrication
322331
self.show_silkscreen = not args.hide_silkscreen
323332
self.highlight_pin1 = args.highlight_pin1

InteractiveHtmlBom/dialog/dialog_base.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,10 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
100100
self.darkModeCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Dark mode", wx.DefaultPosition, wx.DefaultSize, 0 )
101101
b_sizer.Add( self.darkModeCheckbox, 0, wx.ALL, 5 )
102102

103+
self.showPadsCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show footprint pads", wx.DefaultPosition, wx.DefaultSize, 0 )
104+
self.showPadsCheckbox.SetValue(True)
105+
b_sizer.Add( self.showPadsCheckbox, 0, wx.ALL, 5 )
106+
103107
self.showFabricationCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show fabrication layer", wx.DefaultPosition, wx.DefaultSize, 0 )
104108
b_sizer.Add( self.showFabricationCheckbox, 0, wx.ALL, 5 )
105109

InteractiveHtmlBom/web/ibom.html

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@
4747
<input id="darkmodeCheckbox" type="checkbox" onchange="setDarkMode(this.checked)">
4848
Dark mode
4949
</label>
50+
<label class="menu-label">
51+
<input id="padsCheckbox" type="checkbox" checked onchange="padsVisible(this.checked)">
52+
Show footprint pads
53+
</label>
5054
<label class="menu-label">
5155
<input id="fabricationCheckbox" type="checkbox" checked onchange="fabricationVisible(this.checked)">
5256
Show fabrication layer

InteractiveHtmlBom/web/ibom.js

Lines changed: 31 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,14 @@ function dbg(html) {
2121
dbgdiv.innerHTML = html;
2222
}
2323

24+
function padsVisible(value) {
25+
renderPads = value;
26+
if (initDone) {
27+
redrawCanvas(allcanvas.front);
28+
redrawCanvas(allcanvas.back);
29+
}
30+
}
31+
2432
function setDarkMode(value) {
2533
if (value) {
2634
topmostdiv.classList.add("dark");
@@ -35,15 +43,10 @@ function setDarkMode(value) {
3543
}
3644

3745
function layerVisible(visible, frontCavnas, backCanvas, storageString) {
38-
if (visible) {
39-
frontCavnas.style.display = "";
40-
backCanvas.style.display = "";
41-
writeStorage(storageString, true);
42-
} else {
43-
frontCavnas.style.display = "none";
44-
backCanvas.style.display = "none";
45-
writeStorage(storageString, false);
46-
}
46+
var display = (visible) ? "" : "none";
47+
frontCavnas.style.display = display;
48+
backCanvas.style.display = display;
49+
writeStorage(storageString, visible);
4750
}
4851

4952
function fabricationVisible(visible) {
@@ -713,6 +716,16 @@ document.onkeydown = function(e) {
713716
}
714717
}
715718

719+
function getStorageBooleanOrDefault(storageString, def) {
720+
var b = readStorage(storageString);
721+
if (b === null) {
722+
b = def;
723+
} else {
724+
b = (b == "true");
725+
}
726+
return b;
727+
}
728+
716729
function initDefaults() {
717730
bomlayout = readStorage("bomlayout");
718731
if (bomlayout === null) {
@@ -731,48 +744,27 @@ function initDefaults() {
731744
}
732745
document.getElementById("bomCheckboxes").value = bomCheckboxes;
733746

734-
var b = readStorage("fabricationVisible");
735-
if (b === null) {
736-
b = config.show_fabrication;
737-
} else {
738-
b = (b == "true");
739-
}
747+
var b = getStorageBooleanOrDefault("padsVisible", config.show_pads);
748+
document.getElementById("fabricationCheckbox").checked = b;
749+
padsVisible(b);
750+
751+
b = getStorageBooleanOrDefault("fabricationVisible", config.show_fabrication);
740752
document.getElementById("fabricationCheckbox").checked = b;
741753
fabricationVisible(b);
742754

743-
b = readStorage("silkscreenVisible");
744-
if (b === null) {
745-
b = config.show_silkscreen;
746-
} else {
747-
b = (b == "true");
748-
}
755+
b = getStorageBooleanOrDefault("silkscreenVisible", config.show_silkscreen);
749756
document.getElementById("silkscreenCheckbox").checked = b;
750757
silkscreenVisible(b);
751758

752-
b = readStorage("redrawOnDrag");
753-
if (b === null) {
754-
b = config.redraw_on_drag;
755-
} else {
756-
b = (b == "true");
757-
}
759+
b = getStorageBooleanOrDefault("redrawOnDrag", config.redraw_on_drag);
758760
document.getElementById("dragCheckbox").checked = b;
759761
setRedrawOnDrag(b);
760762

761-
b = readStorage("darkmode");
762-
if (b === null) {
763-
b = config.dark_mode;
764-
} else {
765-
b = (b == "true");
766-
}
763+
b = getStorageBooleanOrDefault("darkmode", config.dark_mode);
767764
document.getElementById("darkmodeCheckbox").checked = b;
768765
setDarkMode(b);
769766

770-
b = readStorage("highlightpin1");
771-
if (b === null) {
772-
b = config.highlight_pin1;
773-
} else {
774-
b = (b == "true");
775-
}
767+
b = getStorageBooleanOrDefault("highlightpin1", config.highlight_pin1);
776768
document.getElementById("highlightpin1Checkbox").checked = b;
777769
setHighlightPin1(b);
778770

InteractiveHtmlBom/web/render.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
var redrawOnDrag = true;
44
var boardRotation = 0;
5+
var renderPads = true;
56

67
function deg2rad(deg) {
78
return deg * Math.PI / 180;
@@ -226,11 +227,13 @@ function drawModule(ctx, layer, scalefactor, module, padcolor, outlinecolor, hig
226227
}
227228
}
228229
// draw pads
229-
for (var pad of module.pads) {
230-
if (pad.layers.includes(layer)) {
231-
drawPad(ctx, pad, padcolor, false);
232-
if (pad.pin1 && highlightpin1) {
233-
drawPad(ctx, pad, outlinecolor, true);
230+
if (renderPads) {
231+
for (var pad of module.pads) {
232+
if (pad.layers.includes(layer)) {
233+
drawPad(ctx, pad, padcolor, false);
234+
if (pad.pin1 && highlightpin1) {
235+
drawPad(ctx, pad, outlinecolor, true);
236+
}
234237
}
235238
}
236239
}

settings_dialog.fbp

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -749,6 +749,101 @@
749749
<event name="OnUpdateUI"></event>
750750
</object>
751751
</object>
752+
<object class="sizeritem" expanded="1">
753+
<property name="border">5</property>
754+
<property name="flag">wxALL</property>
755+
<property name="proportion">0</property>
756+
<object class="wxCheckBox" expanded="1">
757+
<property name="BottomDockable">1</property>
758+
<property name="LeftDockable">1</property>
759+
<property name="RightDockable">1</property>
760+
<property name="TopDockable">1</property>
761+
<property name="aui_layer"></property>
762+
<property name="aui_name"></property>
763+
<property name="aui_position"></property>
764+
<property name="aui_row"></property>
765+
<property name="best_size"></property>
766+
<property name="bg"></property>
767+
<property name="caption"></property>
768+
<property name="caption_visible">1</property>
769+
<property name="center_pane">0</property>
770+
<property name="checked">1</property>
771+
<property name="close_button">1</property>
772+
<property name="context_help"></property>
773+
<property name="context_menu">1</property>
774+
<property name="default_pane">0</property>
775+
<property name="dock">Dock</property>
776+
<property name="dock_fixed">0</property>
777+
<property name="docking">Left</property>
778+
<property name="enabled">1</property>
779+
<property name="fg"></property>
780+
<property name="floatable">1</property>
781+
<property name="font"></property>
782+
<property name="gripper">0</property>
783+
<property name="hidden">0</property>
784+
<property name="id">wxID_ANY</property>
785+
<property name="label">Show footprint pads</property>
786+
<property name="max_size"></property>
787+
<property name="maximize_button">0</property>
788+
<property name="maximum_size"></property>
789+
<property name="min_size"></property>
790+
<property name="minimize_button">0</property>
791+
<property name="minimum_size"></property>
792+
<property name="moveable">1</property>
793+
<property name="name">showPadsCheckbox</property>
794+
<property name="pane_border">1</property>
795+
<property name="pane_position"></property>
796+
<property name="pane_size"></property>
797+
<property name="permission">protected</property>
798+
<property name="pin_button">1</property>
799+
<property name="pos"></property>
800+
<property name="resize">Resizable</property>
801+
<property name="show">1</property>
802+
<property name="size"></property>
803+
<property name="style"></property>
804+
<property name="subclass">; ; forward_declare</property>
805+
<property name="toolbar_pane">0</property>
806+
<property name="tooltip"></property>
807+
<property name="validator_data_type"></property>
808+
<property name="validator_style">wxFILTER_NONE</property>
809+
<property name="validator_type">wxDefaultValidator</property>
810+
<property name="validator_variable"></property>
811+
<property name="window_extra_style"></property>
812+
<property name="window_name"></property>
813+
<property name="window_style"></property>
814+
<event name="OnAux1DClick"></event>
815+
<event name="OnAux1Down"></event>
816+
<event name="OnAux1Up"></event>
817+
<event name="OnAux2DClick"></event>
818+
<event name="OnAux2Down"></event>
819+
<event name="OnAux2Up"></event>
820+
<event name="OnChar"></event>
821+
<event name="OnCharHook"></event>
822+
<event name="OnCheckBox"></event>
823+
<event name="OnEnterWindow"></event>
824+
<event name="OnEraseBackground"></event>
825+
<event name="OnKeyDown"></event>
826+
<event name="OnKeyUp"></event>
827+
<event name="OnKillFocus"></event>
828+
<event name="OnLeaveWindow"></event>
829+
<event name="OnLeftDClick"></event>
830+
<event name="OnLeftDown"></event>
831+
<event name="OnLeftUp"></event>
832+
<event name="OnMiddleDClick"></event>
833+
<event name="OnMiddleDown"></event>
834+
<event name="OnMiddleUp"></event>
835+
<event name="OnMotion"></event>
836+
<event name="OnMouseEvents"></event>
837+
<event name="OnMouseWheel"></event>
838+
<event name="OnPaint"></event>
839+
<event name="OnRightDClick"></event>
840+
<event name="OnRightDown"></event>
841+
<event name="OnRightUp"></event>
842+
<event name="OnSetFocus"></event>
843+
<event name="OnSize"></event>
844+
<event name="OnUpdateUI"></event>
845+
</object>
846+
</object>
752847
<object class="sizeritem" expanded="1">
753848
<property name="border">5</property>
754849
<property name="flag">wxALL</property>

0 commit comments

Comments
 (0)