Skip to content

Commit

Permalink
Implement none/all/selected choice for pin 1 highlight
Browse files Browse the repository at this point in the history
  • Loading branch information
qu1ck committed May 15, 2023
1 parent 53ffa2e commit 3dc5f7d
Show file tree
Hide file tree
Showing 7 changed files with 67 additions and 32 deletions.
8 changes: 3 additions & 5 deletions DATAFORMAT.md
Original file line number Diff line number Diff line change
Expand Up @@ -371,14 +371,12 @@ config = {
"show_pads": bool,
"show_fabrication": bool,
"show_silkscreen": bool,
"highlight_pin1": bool,
"highlight_pin1": "none" | "all" | "selected",
"redraw_on_drag": bool,
"board_rotation": int,
"checkboxes": "checkbox1,checkbox2,...",
// One of "bom-only", "left-right", "top-bottom".
"bom_view": bom_view,
// One of "F", "FB", "B".
"layer_view": layer_view,
"bom_view": "bom-only" | "left-right" | "top-bottom",
"layer_view": "F" | "FB" | "B",
"extra_fields": ["field1_name", "field2_name", ...],
}
```
25 changes: 18 additions & 7 deletions InteractiveHtmlBom/core/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class Config:
'~',
'HS', 'CNN', 'J', 'P', 'NT', 'MH',
]
highlight_pin1_choices = ['none', 'all', 'selected']
default_checkboxes = ['Sourced', 'Placed']
html_config_fields = [
'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen',
Expand All @@ -49,8 +50,8 @@ class Config:
show_pads = True
show_fabrication = False
show_silkscreen = True
highlight_pin1 = False
redraw_on_drag = True
highlight_pin1 = highlight_pin1_choices[0]
board_rotation = 0
offset_back_rotation = False
checkboxes = ','.join(default_checkboxes)
Expand Down Expand Up @@ -114,8 +115,8 @@ def load_from_ini(self):
'show_fabrication', self.show_fabrication)
self.show_silkscreen = f.ReadBool(
'show_silkscreen', self.show_silkscreen)
self.highlight_pin1 = f.ReadBool('highlight_pin1', self.highlight_pin1)
self.redraw_on_drag = f.ReadBool('redraw_on_drag', self.redraw_on_drag)
self.highlight_pin1 = f.Read('highlight_pin1', self.highlight_pin1)
self.board_rotation = f.ReadInt('board_rotation', self.board_rotation)
self.offset_back_rotation = f.ReadBool(
'offset_back_rotation', self.offset_back_rotation)
Expand Down Expand Up @@ -158,6 +159,12 @@ def load_from_ini(self):
self._join(self.board_variant_blacklist)))
self.dnp_field = f.Read('dnp_field', self.dnp_field)

# migration from previous settings
if self.highlight_pin1 == '0':
self.highlight_pin1 = 'none'
if self.highlight_pin1 == '1':
self.highlight_pin1 == 'all'

def save(self, locally):
file = self.local_config_file if locally else self.global_config_file
print('Saving to', file)
Expand All @@ -168,8 +175,8 @@ def save(self, locally):
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)
f.WriteBool('redraw_on_drag', self.redraw_on_drag)
f.Write('highlight_pin1', self.highlight_pin1)
f.WriteInt('board_rotation', self.board_rotation)
f.WriteBool('offset_back_rotation', self.offset_back_rotation)
f.Write('checkboxes', self.checkboxes)
Expand Down Expand Up @@ -213,8 +220,8 @@ def set_from_dialog(self, dlg):
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()
self.redraw_on_drag = dlg.html.continuousRedrawCheckbox.IsChecked()
self.highlight_pin1 = self.highlight_pin1_choices[dlg.html.highlightPin1.Selection]
self.board_rotation = dlg.html.boardRotationSlider.Value
self.offset_back_rotation = \
dlg.html.offsetBackRotationCheckbox.IsChecked()
Expand Down Expand Up @@ -260,7 +267,10 @@ def transfer_to_dialog(self, dlg):
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
dlg.html.highlightPin1.Selection = 0
if self.highlight_pin1 in self.highlight_pin1_choices:
dlg.html.highlightPin1.Selection = \
self.highlight_pin1_choices.index(self.highlight_pin1)
dlg.html.continuousRedrawCheckbox.value = self.redraw_on_drag
dlg.html.boardRotationSlider.Value = self.board_rotation
dlg.html.offsetBackRotationCheckbox.Value = self.offset_back_rotation
Expand Down Expand Up @@ -332,8 +342,9 @@ def add_options(cls, parser, version):
help='Hide silkscreen by default.',
action='store_true')
parser.add_argument('--highlight-pin1',
help='Highlight pin1 by default.',
action='store_true')
default=cls.highlight_pin1_choices[0],
choices=cls.highlight_pin1_choices,
help='Highlight first pin.')
parser.add_argument('--no-redraw-on-drag',
help='Do not redraw pcb on drag by default.',
action='store_true')
Expand Down
8 changes: 5 additions & 3 deletions InteractiveHtmlBom/dialog/dialog_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,13 +112,15 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
self.showSilkscreenCheckbox.SetValue(True)
b_sizer.Add( self.showSilkscreenCheckbox, 0, wx.ALL, 5 )

self.highlightPin1Checkbox = wx.CheckBox( self, wx.ID_ANY, u"Highlight first pin", wx.DefaultPosition, wx.DefaultSize, 0 )
b_sizer.Add( self.highlightPin1Checkbox, 0, wx.ALL, 5 )

self.continuousRedrawCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Continuous redraw on drag", wx.DefaultPosition, wx.DefaultSize, 0 )
self.continuousRedrawCheckbox.SetValue(True)
b_sizer.Add( self.continuousRedrawCheckbox, 0, wx.ALL, 5 )

highlightPin1Choices = [ u"None", u"All", u"Selected" ]
self.highlightPin1 = wx.RadioBox( self, wx.ID_ANY, u"Highlight first pin", wx.DefaultPosition, wx.DefaultSize, highlightPin1Choices, 3, wx.RA_SPECIFY_COLS )
self.highlightPin1.SetSelection( 0 )
b_sizer.Add( self.highlightPin1, 0, wx.ALL, 5 )

bSizer18 = wx.BoxSizer( wx.VERTICAL )

bSizer19 = wx.BoxSizer( wx.HORIZONTAL )
Expand Down
23 changes: 19 additions & 4 deletions InteractiveHtmlBom/web/ibom.html
Original file line number Diff line number Diff line change
Expand Up @@ -102,14 +102,29 @@
<input id="dnpOutlineCheckbox" type="checkbox" checked onchange="dnpOutline(this.checked)">
DNP outlined
</label>
<label class="menu-label">
<input id="highlightpin1Checkbox" type="checkbox" onchange="setHighlightPin1(this.checked)">
Highlight first pin
</label>
<label class="menu-label">
<input id="dragCheckbox" type="checkbox" checked onchange="setRedrawOnDrag(this.checked)">
Continuous redraw on drag
</label>
<label class="menu-label">
Highlight first pin
<form id="highlightpin1">
<div class="flexbox">
<label>
<input type="radio" name="highlightpin1" value="none" onchange="setHighlightPin1('none')">
None
</label>
<label>
<input type="radio" name="highlightpin1" value="all" onchange="setHighlightPin1('all')">
All
</label>
<label>
<input type="radio" name="highlightpin1" value="selected" onchange="setHighlightPin1('selected')">
Selected
</label>
</div>
</form>
</label>
<label class="menu-label">
<span>Board rotation</span>
<span style="float: right"><span id="rotationDegree">0</span>&#176;</span>
Expand Down
4 changes: 3 additions & 1 deletion InteractiveHtmlBom/web/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,9 @@ function drawFootprint(ctx, layer, scalefactor, footprint, colors, highlight, ou
for (var pad of footprint.pads) {
if (pad.layers.includes(layer)) {
drawPad(ctx, pad, colors.pad, outline);
if (pad.pin1 && settings.highlightpin1) {
if (pad.pin1 &&
(settings.highlightpin1 == "all" ||
settings.highlightpin1 == "selected" && highlight)) {
drawPad(ctx, pad, colors.outline, true);
}
}
Expand Down
11 changes: 8 additions & 3 deletions InteractiveHtmlBom/web/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ function overwriteSettings(newSettings) {
setDarkMode(settings.darkMode);
document.getElementById("darkmodeCheckbox").checked = settings.darkMode;
setHighlightPin1(settings.highlightpin1);
document.getElementById("highlightpin1Checkbox").checked = settings.highlightpin1;
document.forms.highlightpin1.highlightpin1.value = settings.highlightpin1;
writeStorage("boardRotation", settings.boardRotation);
document.getElementById("boardRotation").value = settings.boardRotation / 5;
document.getElementById("rotationDegree").textContent = settings.boardRotation;
Expand Down Expand Up @@ -492,7 +492,7 @@ var settings = {
checkboxes: [],
checkboxStoredRefs: {},
darkMode: false,
highlightpin1: false,
highlightpin1: "none",
redrawOnDrag: true,
boardRotation: 0,
offsetBackRotation: false,
Expand Down Expand Up @@ -538,6 +538,12 @@ function initDefaults() {
settings.checkboxes = bomCheckboxes.split(",").filter((e) => e);
document.getElementById("bomCheckboxes").value = bomCheckboxes;

var highlightpin1 = readStorage("highlightpin1") || config.highlight_pin1;
if (highlightpin1 === "false") highlightpin1 = "none";
if (highlightpin1 === "true") highlightpin1 = "all";
setHighlightPin1(highlightpin1);
document.forms.highlightpin1.highlightpin1.value = highlightpin1;

settings.markWhenChecked = readStorage("markWhenChecked") || "";
populateMarkWhenCheckedOptions();

Expand Down Expand Up @@ -568,7 +574,6 @@ function initDefaults() {
initBooleanSetting("dnpOutline", false, "dnpOutlineCheckbox", dnpOutline);
initBooleanSetting("redrawOnDrag", config.redraw_on_drag, "dragCheckbox", setRedrawOnDrag);
initBooleanSetting("darkmode", config.dark_mode, "darkmodeCheckbox", setDarkMode);
initBooleanSetting("highlightpin1", config.highlight_pin1, "highlightpin1Checkbox", setHighlightPin1);

var fields = ["checkboxes", "References"].concat(config.fields).concat(["Quantity"]);
var hcols = JSON.parse(readStorage("hiddenColumns"));
Expand Down
20 changes: 11 additions & 9 deletions settings_dialog.fbp
Original file line number Diff line number Diff line change
Expand Up @@ -691,7 +691,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">0</property>
<property name="checked">1</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
Expand All @@ -706,15 +706,15 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Highlight first pin</property>
<property name="label">Continuous redraw on drag</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">highlightPin1Checkbox</property>
<property name="name">continuousRedrawCheckbox</property>
<property name="pane_border">1</property>
<property name="pane_position"></property>
<property name="pane_size"></property>
Expand All @@ -737,11 +737,11 @@
<property name="window_style"></property>
</object>
</object>
<object class="sizeritem" expanded="0">
<object class="sizeritem" expanded="1">
<property name="border">5</property>
<property name="flag">wxALL</property>
<property name="proportion">0</property>
<object class="wxCheckBox" expanded="0">
<object class="wxRadioBox" expanded="1">
<property name="BottomDockable">1</property>
<property name="LeftDockable">1</property>
<property name="RightDockable">1</property>
Expand All @@ -755,7 +755,7 @@
<property name="caption"></property>
<property name="caption_visible">1</property>
<property name="center_pane">0</property>
<property name="checked">1</property>
<property name="choices">&quot;None&quot; &quot;All&quot; &quot;Selected&quot;</property>
<property name="close_button">1</property>
<property name="context_help"></property>
<property name="context_menu">1</property>
Expand All @@ -770,25 +770,27 @@
<property name="gripper">0</property>
<property name="hidden">0</property>
<property name="id">wxID_ANY</property>
<property name="label">Continuous redraw on drag</property>
<property name="label">Highlight first pin</property>
<property name="majorDimension">3</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">continuousRedrawCheckbox</property>
<property name="name">highlightPin1</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="selection">0</property>
<property name="show">1</property>
<property name="size"></property>
<property name="style"></property>
<property name="style">wxRA_SPECIFY_COLS</property>
<property name="subclass">; ; forward_declare</property>
<property name="toolbar_pane">0</property>
<property name="tooltip"></property>
Expand Down

0 comments on commit 3dc5f7d

Please sign in to comment.