Skip to content

Commit

Permalink
Add option to hide pads
Browse files Browse the repository at this point in the history
Fixes #76
  • Loading branch information
qu1ck committed Apr 8, 2019
1 parent ee2aeb5 commit 833369f
Show file tree
Hide file tree
Showing 6 changed files with 154 additions and 47 deletions.
15 changes: 12 additions & 3 deletions InteractiveHtmlBom/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@ class Config:
]
default_checkboxes = ['Sourced', 'Placed']
html_config_fields = [
'dark_mode', 'show_fabrication', 'show_silkscreen', 'highlight_pin1',
'redraw_on_drag', 'board_rotation', 'checkboxes', 'bom_view',
'layer_view', 'extra_fields'
'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen',
'highlight_pin1', 'redraw_on_drag', 'board_rotation', 'checkboxes',
'bom_view', 'layer_view', 'extra_fields'
]

# Defaults

# HTML section
dark_mode = False
show_pads = True
show_fabrication = False
show_silkscreen = True
highlight_pin1 = False
Expand Down Expand Up @@ -69,6 +70,7 @@ def __init__(self):

f.SetPath('/html_defaults')
self.dark_mode = f.ReadBool('dark_mode', self.dark_mode)
self.show_pads = f.ReadBool('show_pads', self.show_pads)
self.show_fabrication = f.ReadBool(
'show_fabrication', self.show_fabrication)
self.show_silkscreen = f.ReadBool(
Expand Down Expand Up @@ -114,6 +116,7 @@ def save(self):

f.SetPath('/html_defaults')
f.WriteBool('dark_mode', self.dark_mode)
f.WriteBool('show_pads', self.show_pads)
f.WriteBool('show_fabrication', self.show_fabrication)
f.WriteBool('show_silkscreen', self.show_silkscreen)
f.WriteBool('highlight_pin1', self.highlight_pin1)
Expand Down Expand Up @@ -152,6 +155,7 @@ def set_from_dialog(self, dlg):
# type: (dialog.settings_dialog.SettingsDialogPanel) -> None
# Html
self.dark_mode = dlg.html.darkModeCheckbox.IsChecked()
self.show_pads = dlg.html.showPadsCheckbox.IsChecked()
self.show_fabrication = dlg.html.showFabricationCheckbox.IsChecked()
self.show_silkscreen = dlg.html.showSilkscreenCheckbox.IsChecked()
self.highlight_pin1 = dlg.html.highlightPin1Checkbox.IsChecked()
Expand Down Expand Up @@ -191,6 +195,7 @@ def transfer_to_dialog(self, dlg):
# type: (dialog.settings_dialog.SettingsDialogPanel) -> None
# Html
dlg.html.darkModeCheckbox.Value = self.dark_mode
dlg.html.showPadsCheckbox.Value = self.show_pads
dlg.html.showFabricationCheckbox.Value = self.show_fabrication
dlg.html.showSilkscreenCheckbox.Value = self.show_silkscreen
dlg.html.highlightPin1Checkbox.Value = self.highlight_pin1
Expand Down Expand Up @@ -244,6 +249,9 @@ def add_options(self, parser, file_name_format_hint):
# Html
parser.add_argument('--dark-mode', help='Default to dark mode.',
action='store_true')
parser.add_argument('--hide-pads',
help='Hide footprint pads by default.',
action='store_true')
parser.add_argument('--show-fabrication',
help='Show fabrication layer by default.',
action='store_true')
Expand Down Expand Up @@ -318,6 +326,7 @@ def set_from_args(self, args):

# Html
self.dark_mode = args.dark_mode
self.show_pads = not args.hide_pads
self.show_fabrication = args.show_fabrication
self.show_silkscreen = not args.hide_silkscreen
self.highlight_pin1 = args.highlight_pin1
Expand Down
4 changes: 4 additions & 0 deletions InteractiveHtmlBom/dialog/dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,10 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
self.darkModeCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Dark mode", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.darkModeCheckbox, 0, wx.ALL, 5 )

self.showPadsCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show footprint pads", wx.DefaultPosition, wx.DefaultSize, 0 )
self.showPadsCheckbox.SetValue(True)
b_sizer.Add( self.showPadsCheckbox, 0, wx.ALL, 5 )

self.showFabricationCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Show fabrication layer", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.showFabricationCheckbox, 0, wx.ALL, 5 )

Expand Down
4 changes: 4 additions & 0 deletions InteractiveHtmlBom/web/ibom.html
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@
<input id="darkmodeCheckbox" type="checkbox" onchange="setDarkMode(this.checked)">
Dark mode
</label>
<label class="menu-label">
<input id="padsCheckbox" type="checkbox" checked onchange="padsVisible(this.checked)">
Show footprint pads
</label>
<label class="menu-label">
<input id="fabricationCheckbox" type="checkbox" checked onchange="fabricationVisible(this.checked)">
Show fabrication layer
Expand Down
70 changes: 31 additions & 39 deletions InteractiveHtmlBom/web/ibom.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ function dbg(html) {
dbgdiv.innerHTML = html;
}

function padsVisible(value) {
renderPads = value;
if (initDone) {
redrawCanvas(allcanvas.front);
redrawCanvas(allcanvas.back);
}
}

function setDarkMode(value) {
if (value) {
topmostdiv.classList.add("dark");
Expand All @@ -35,15 +43,10 @@ function setDarkMode(value) {
}

function layerVisible(visible, frontCavnas, backCanvas, storageString) {
if (visible) {
frontCavnas.style.display = "";
backCanvas.style.display = "";
writeStorage(storageString, true);
} else {
frontCavnas.style.display = "none";
backCanvas.style.display = "none";
writeStorage(storageString, false);
}
var display = (visible) ? "" : "none";
frontCavnas.style.display = display;
backCanvas.style.display = display;
writeStorage(storageString, visible);
}

function fabricationVisible(visible) {
Expand Down Expand Up @@ -713,6 +716,16 @@ document.onkeydown = function(e) {
}
}

function getStorageBooleanOrDefault(storageString, def) {
var b = readStorage(storageString);
if (b === null) {
b = def;
} else {
b = (b == "true");
}
return b;
}

function initDefaults() {
bomlayout = readStorage("bomlayout");
if (bomlayout === null) {
Expand All @@ -731,48 +744,27 @@ function initDefaults() {
}
document.getElementById("bomCheckboxes").value = bomCheckboxes;

var b = readStorage("fabricationVisible");
if (b === null) {
b = config.show_fabrication;
} else {
b = (b == "true");
}
var b = getStorageBooleanOrDefault("padsVisible", config.show_pads);
document.getElementById("fabricationCheckbox").checked = b;
padsVisible(b);

b = getStorageBooleanOrDefault("fabricationVisible", config.show_fabrication);
document.getElementById("fabricationCheckbox").checked = b;
fabricationVisible(b);

b = readStorage("silkscreenVisible");
if (b === null) {
b = config.show_silkscreen;
} else {
b = (b == "true");
}
b = getStorageBooleanOrDefault("silkscreenVisible", config.show_silkscreen);
document.getElementById("silkscreenCheckbox").checked = b;
silkscreenVisible(b);

b = readStorage("redrawOnDrag");
if (b === null) {
b = config.redraw_on_drag;
} else {
b = (b == "true");
}
b = getStorageBooleanOrDefault("redrawOnDrag", config.redraw_on_drag);
document.getElementById("dragCheckbox").checked = b;
setRedrawOnDrag(b);

b = readStorage("darkmode");
if (b === null) {
b = config.dark_mode;
} else {
b = (b == "true");
}
b = getStorageBooleanOrDefault("darkmode", config.dark_mode);
document.getElementById("darkmodeCheckbox").checked = b;
setDarkMode(b);

b = readStorage("highlightpin1");
if (b === null) {
b = config.highlight_pin1;
} else {
b = (b == "true");
}
b = getStorageBooleanOrDefault("highlightpin1", config.highlight_pin1);
document.getElementById("highlightpin1Checkbox").checked = b;
setHighlightPin1(b);

Expand Down
13 changes: 8 additions & 5 deletions InteractiveHtmlBom/web/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

var redrawOnDrag = true;
var boardRotation = 0;
var renderPads = true;

function deg2rad(deg) {
return deg * Math.PI / 180;
Expand Down Expand Up @@ -226,11 +227,13 @@ function drawModule(ctx, layer, scalefactor, module, padcolor, outlinecolor, hig
}
}
// draw pads
for (var pad of module.pads) {
if (pad.layers.includes(layer)) {
drawPad(ctx, pad, padcolor, false);
if (pad.pin1 && highlightpin1) {
drawPad(ctx, pad, outlinecolor, true);
if (renderPads) {
for (var pad of module.pads) {
if (pad.layers.includes(layer)) {
drawPad(ctx, pad, padcolor, false);
if (pad.pin1 && highlightpin1) {
drawPad(ctx, pad, outlinecolor, true);
}
}
}
}
Expand Down
95 changes: 95 additions & 0 deletions settings_dialog.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,101 @@
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
<property name="TopDockable">1</property>
<property name="aui_layer"></property>
<property name="aui_name"></property>
<property name="aui_position"></property>
<property name="aui_row"></property>
<property name="best_size"></property>
<property name="bg"></property>
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
<property name="default_pane">0</property>
<property name="dock">Dock</property>
<property name="dock_fixed">0</property>
<property name="docking">Left</property>
<property name="enabled">1</property>
<property name="fg"></property>
<property name="floatable">1</property>
<property name="font"></property>
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Show footprint pads</property>
<property name="max_size"></property>
<property name="maximize_button">0</property>
<property name="maximum_size"></property>
<property name="min_size"></property>
<property name="minimize_button">0</property>
<property name="minimum_size"></property>
<property name="moveable">1</property>
<property name="name">showPadsCheckbox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
<property name="permission">protected</property>
<property name="pin_button">1</property>
<property name="pos"></property>
<property name="resize">Resizable</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
<property name="validator_data_type"></property>
<property name="validator_style">wxFILTER_NONE</property>
<property name="validator_type">wxDefaultValidator</property>
<property name="validator_variable"></property>
<property name="window_extra_style"></property>
<property name="window_name"></property>
<property name="window_style"></property>
<event name="OnAux1DClick"></event>
<event name="OnAux1Down"></event>
<event name="OnAux1Up"></event>
<event name="OnAux2DClick"></event>
<event name="OnAux2Down"></event>
<event name="OnAux2Up"></event>
<event name="OnChar"></event>
<event name="OnCharHook"></event>
<event name="OnCheckBox"></event>
<event name="OnEnterWindow"></event>
<event name="OnEraseBackground"></event>
<event name="OnKeyDown"></event>
<event name="OnKeyUp"></event>
<event name="OnKillFocus"></event>
<event name="OnLeaveWindow"></event>
<event name="OnLeftDClick"></event>
<event name="OnLeftDown"></event>
<event name="OnLeftUp"></event>
<event name="OnMiddleDClick"></event>
<event name="OnMiddleDown"></event>
<event name="OnMiddleUp"></event>
<event name="OnMotion"></event>
<event name="OnMouseEvents"></event>
<event name="OnMouseWheel"></event>
<event name="OnPaint"></event>
<event name="OnRightDClick"></event>
<event name="OnRightDown"></event>
<event name="OnRightUp"></event>
<event name="OnSetFocus"></event>
<event name="OnSize"></event>
<event name="OnUpdateUI"></event>
</object>
</object>
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
Expand Down

0 comments on commit 833369f

Please sign in to comment.