Skip to content

Commit 3dc5f7d

Browse files
committed
Implement none/all/selected choice for pin 1 highlight
Fixes #374
1 parent 53ffa2e commit 3dc5f7d

File tree

7 files changed

+67
-32
lines changed

7 files changed

+67
-32
lines changed

DATAFORMAT.md

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -371,14 +371,12 @@ config = {
371371
"show_pads": bool,
372372
"show_fabrication": bool,
373373
"show_silkscreen": bool,
374-
"highlight_pin1": bool,
374+
"highlight_pin1": "none" | "all" | "selected",
375375
"redraw_on_drag": bool,
376376
"board_rotation": int,
377377
"checkboxes": "checkbox1,checkbox2,...",
378-
// One of "bom-only", "left-right", "top-bottom".
379-
"bom_view": bom_view,
380-
// One of "F", "FB", "B".
381-
"layer_view": layer_view,
378+
"bom_view": "bom-only" | "left-right" | "top-bottom",
379+
"layer_view": "F" | "FB" | "B",
382380
"extra_fields": ["field1_name", "field2_name", ...],
383381
}
384382
```

InteractiveHtmlBom/core/config.py

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ class Config:
3333
'~',
3434
'HS', 'CNN', 'J', 'P', 'NT', 'MH',
3535
]
36+
highlight_pin1_choices = ['none', 'all', 'selected']
3637
default_checkboxes = ['Sourced', 'Placed']
3738
html_config_fields = [
3839
'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen',
@@ -49,8 +50,8 @@ class Config:
4950
show_pads = True
5051
show_fabrication = False
5152
show_silkscreen = True
52-
highlight_pin1 = False
5353
redraw_on_drag = True
54+
highlight_pin1 = highlight_pin1_choices[0]
5455
board_rotation = 0
5556
offset_back_rotation = False
5657
checkboxes = ','.join(default_checkboxes)
@@ -114,8 +115,8 @@ def load_from_ini(self):
114115
'show_fabrication', self.show_fabrication)
115116
self.show_silkscreen = f.ReadBool(
116117
'show_silkscreen', self.show_silkscreen)
117-
self.highlight_pin1 = f.ReadBool('highlight_pin1', self.highlight_pin1)
118118
self.redraw_on_drag = f.ReadBool('redraw_on_drag', self.redraw_on_drag)
119+
self.highlight_pin1 = f.Read('highlight_pin1', self.highlight_pin1)
119120
self.board_rotation = f.ReadInt('board_rotation', self.board_rotation)
120121
self.offset_back_rotation = f.ReadBool(
121122
'offset_back_rotation', self.offset_back_rotation)
@@ -158,6 +159,12 @@ def load_from_ini(self):
158159
self._join(self.board_variant_blacklist)))
159160
self.dnp_field = f.Read('dnp_field', self.dnp_field)
160161

162+
# migration from previous settings
163+
if self.highlight_pin1 == '0':
164+
self.highlight_pin1 = 'none'
165+
if self.highlight_pin1 == '1':
166+
self.highlight_pin1 == 'all'
167+
161168
def save(self, locally):
162169
file = self.local_config_file if locally else self.global_config_file
163170
print('Saving to', file)
@@ -168,8 +175,8 @@ def save(self, locally):
168175
f.WriteBool('show_pads', self.show_pads)
169176
f.WriteBool('show_fabrication', self.show_fabrication)
170177
f.WriteBool('show_silkscreen', self.show_silkscreen)
171-
f.WriteBool('highlight_pin1', self.highlight_pin1)
172178
f.WriteBool('redraw_on_drag', self.redraw_on_drag)
179+
f.Write('highlight_pin1', self.highlight_pin1)
173180
f.WriteInt('board_rotation', self.board_rotation)
174181
f.WriteBool('offset_back_rotation', self.offset_back_rotation)
175182
f.Write('checkboxes', self.checkboxes)
@@ -213,8 +220,8 @@ def set_from_dialog(self, dlg):
213220
self.show_pads = dlg.html.showPadsCheckbox.IsChecked()
214221
self.show_fabrication = dlg.html.showFabricationCheckbox.IsChecked()
215222
self.show_silkscreen = dlg.html.showSilkscreenCheckbox.IsChecked()
216-
self.highlight_pin1 = dlg.html.highlightPin1Checkbox.IsChecked()
217223
self.redraw_on_drag = dlg.html.continuousRedrawCheckbox.IsChecked()
224+
self.highlight_pin1 = self.highlight_pin1_choices[dlg.html.highlightPin1.Selection]
218225
self.board_rotation = dlg.html.boardRotationSlider.Value
219226
self.offset_back_rotation = \
220227
dlg.html.offsetBackRotationCheckbox.IsChecked()
@@ -260,7 +267,10 @@ def transfer_to_dialog(self, dlg):
260267
dlg.html.showPadsCheckbox.Value = self.show_pads
261268
dlg.html.showFabricationCheckbox.Value = self.show_fabrication
262269
dlg.html.showSilkscreenCheckbox.Value = self.show_silkscreen
263-
dlg.html.highlightPin1Checkbox.Value = self.highlight_pin1
270+
dlg.html.highlightPin1.Selection = 0
271+
if self.highlight_pin1 in self.highlight_pin1_choices:
272+
dlg.html.highlightPin1.Selection = \
273+
self.highlight_pin1_choices.index(self.highlight_pin1)
264274
dlg.html.continuousRedrawCheckbox.value = self.redraw_on_drag
265275
dlg.html.boardRotationSlider.Value = self.board_rotation
266276
dlg.html.offsetBackRotationCheckbox.Value = self.offset_back_rotation
@@ -332,8 +342,9 @@ def add_options(cls, parser, version):
332342
help='Hide silkscreen by default.',
333343
action='store_true')
334344
parser.add_argument('--highlight-pin1',
335-
help='Highlight pin1 by default.',
336-
action='store_true')
345+
default=cls.highlight_pin1_choices[0],
346+
choices=cls.highlight_pin1_choices,
347+
help='Highlight first pin.')
337348
parser.add_argument('--no-redraw-on-drag',
338349
help='Do not redraw pcb on drag by default.',
339350
action='store_true')

InteractiveHtmlBom/dialog/dialog_base.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,15 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx.
112112
self.showSilkscreenCheckbox.SetValue(True)
113113
b_sizer.Add( self.showSilkscreenCheckbox, 0, wx.ALL, 5 )
114114

115-
self.highlightPin1Checkbox = wx.CheckBox( self, wx.ID_ANY, u"Highlight first pin", wx.DefaultPosition, wx.DefaultSize, 0 )
116-
b_sizer.Add( self.highlightPin1Checkbox, 0, wx.ALL, 5 )
117-
118115
self.continuousRedrawCheckbox = wx.CheckBox( self, wx.ID_ANY, u"Continuous redraw on drag", wx.DefaultPosition, wx.DefaultSize, 0 )
119116
self.continuousRedrawCheckbox.SetValue(True)
120117
b_sizer.Add( self.continuousRedrawCheckbox, 0, wx.ALL, 5 )
121118

119+
highlightPin1Choices = [ u"None", u"All", u"Selected" ]
120+
self.highlightPin1 = wx.RadioBox( self, wx.ID_ANY, u"Highlight first pin", wx.DefaultPosition, wx.DefaultSize, highlightPin1Choices, 3, wx.RA_SPECIFY_COLS )
121+
self.highlightPin1.SetSelection( 0 )
122+
b_sizer.Add( self.highlightPin1, 0, wx.ALL, 5 )
123+
122124
bSizer18 = wx.BoxSizer( wx.VERTICAL )
123125

124126
bSizer19 = wx.BoxSizer( wx.HORIZONTAL )

InteractiveHtmlBom/web/ibom.html

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,14 +102,29 @@
102102
<input id="dnpOutlineCheckbox" type="checkbox" checked onchange="dnpOutline(this.checked)">
103103
DNP outlined
104104
</label>
105-
<label class="menu-label">
106-
<input id="highlightpin1Checkbox" type="checkbox" onchange="setHighlightPin1(this.checked)">
107-
Highlight first pin
108-
</label>
109105
<label class="menu-label">
110106
<input id="dragCheckbox" type="checkbox" checked onchange="setRedrawOnDrag(this.checked)">
111107
Continuous redraw on drag
112108
</label>
109+
<label class="menu-label">
110+
Highlight first pin
111+
<form id="highlightpin1">
112+
<div class="flexbox">
113+
<label>
114+
<input type="radio" name="highlightpin1" value="none" onchange="setHighlightPin1('none')">
115+
None
116+
</label>
117+
<label>
118+
<input type="radio" name="highlightpin1" value="all" onchange="setHighlightPin1('all')">
119+
All
120+
</label>
121+
<label>
122+
<input type="radio" name="highlightpin1" value="selected" onchange="setHighlightPin1('selected')">
123+
Selected
124+
</label>
125+
</div>
126+
</form>
127+
</label>
113128
<label class="menu-label">
114129
<span>Board rotation</span>
115130
<span style="float: right"><span id="rotationDegree">0</span>&#176;</span>

InteractiveHtmlBom/web/render.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -346,7 +346,9 @@ function drawFootprint(ctx, layer, scalefactor, footprint, colors, highlight, ou
346346
for (var pad of footprint.pads) {
347347
if (pad.layers.includes(layer)) {
348348
drawPad(ctx, pad, colors.pad, outline);
349-
if (pad.pin1 && settings.highlightpin1) {
349+
if (pad.pin1 &&
350+
(settings.highlightpin1 == "all" ||
351+
settings.highlightpin1 == "selected" && highlight)) {
350352
drawPad(ctx, pad, colors.outline, true);
351353
}
352354
}

InteractiveHtmlBom/web/util.js

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -452,7 +452,7 @@ function overwriteSettings(newSettings) {
452452
setDarkMode(settings.darkMode);
453453
document.getElementById("darkmodeCheckbox").checked = settings.darkMode;
454454
setHighlightPin1(settings.highlightpin1);
455-
document.getElementById("highlightpin1Checkbox").checked = settings.highlightpin1;
455+
document.forms.highlightpin1.highlightpin1.value = settings.highlightpin1;
456456
writeStorage("boardRotation", settings.boardRotation);
457457
document.getElementById("boardRotation").value = settings.boardRotation / 5;
458458
document.getElementById("rotationDegree").textContent = settings.boardRotation;
@@ -492,7 +492,7 @@ var settings = {
492492
checkboxes: [],
493493
checkboxStoredRefs: {},
494494
darkMode: false,
495-
highlightpin1: false,
495+
highlightpin1: "none",
496496
redrawOnDrag: true,
497497
boardRotation: 0,
498498
offsetBackRotation: false,
@@ -538,6 +538,12 @@ function initDefaults() {
538538
settings.checkboxes = bomCheckboxes.split(",").filter((e) => e);
539539
document.getElementById("bomCheckboxes").value = bomCheckboxes;
540540

541+
var highlightpin1 = readStorage("highlightpin1") || config.highlight_pin1;
542+
if (highlightpin1 === "false") highlightpin1 = "none";
543+
if (highlightpin1 === "true") highlightpin1 = "all";
544+
setHighlightPin1(highlightpin1);
545+
document.forms.highlightpin1.highlightpin1.value = highlightpin1;
546+
541547
settings.markWhenChecked = readStorage("markWhenChecked") || "";
542548
populateMarkWhenCheckedOptions();
543549

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

573578
var fields = ["checkboxes", "References"].concat(config.fields).concat(["Quantity"]);
574579
var hcols = JSON.parse(readStorage("hiddenColumns"));

settings_dialog.fbp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -691,7 +691,7 @@
691691
<property name="caption"></property>
692692
<property name="caption_visible">1</property>
693693
<property name="center_pane">0</property>
694-
<property name="checked">0</property>
694+
<property name="checked">1</property>
695695
<property name="close_button">1</property>
696696
<property name="context_help"></property>
697697
<property name="context_menu">1</property>
@@ -706,15 +706,15 @@
706706
<property name="gripper">0</property>
707707
<property name="hidden">0</property>
708708
<property name="id">wxID_ANY</property>
709-
<property name="label">Highlight first pin</property>
709+
<property name="label">Continuous redraw on drag</property>
710710
<property name="max_size"></property>
711711
<property name="maximize_button">0</property>
712712
<property name="maximum_size"></property>
713713
<property name="min_size"></property>
714714
<property name="minimize_button">0</property>
715715
<property name="minimum_size"></property>
716716
<property name="moveable">1</property>
717-
<property name="name">highlightPin1Checkbox</property>
717+
<property name="name">continuousRedrawCheckbox</property>
718718
<property name="pane_border">1</property>
719719
<property name="pane_position"></property>
720720
<property name="pane_size"></property>
@@ -737,11 +737,11 @@
737737
<property name="window_style"></property>
738738
</object>
739739
</object>
740-
<object class="sizeritem" expanded="0">
740+
<object class="sizeritem" expanded="1">
741741
<property name="border">5</property>
742742
<property name="flag">wxALL</property>
743743
<property name="proportion">0</property>
744-
<object class="wxCheckBox" expanded="0">
744+
<object class="wxRadioBox" expanded="1">
745745
<property name="BottomDockable">1</property>
746746
<property name="LeftDockable">1</property>
747747
<property name="RightDockable">1</property>
@@ -755,7 +755,7 @@
755755
<property name="caption"></property>
756756
<property name="caption_visible">1</property>
757757
<property name="center_pane">0</property>
758-
<property name="checked">1</property>
758+
<property name="choices">&quot;None&quot; &quot;All&quot; &quot;Selected&quot;</property>
759759
<property name="close_button">1</property>
760760
<property name="context_help"></property>
761761
<property name="context_menu">1</property>
@@ -770,25 +770,27 @@
770770
<property name="gripper">0</property>
771771
<property name="hidden">0</property>
772772
<property name="id">wxID_ANY</property>
773-
<property name="label">Continuous redraw on drag</property>
773+
<property name="label">Highlight first pin</property>
774+
<property name="majorDimension">3</property>
774775
<property name="max_size"></property>
775776
<property name="maximize_button">0</property>
776777
<property name="maximum_size"></property>
777778
<property name="min_size"></property>
778779
<property name="minimize_button">0</property>
779780
<property name="minimum_size"></property>
780781
<property name="moveable">1</property>
781-
<property name="name">continuousRedrawCheckbox</property>
782+
<property name="name">highlightPin1</property>
782783
<property name="pane_border">1</property>
783784
<property name="pane_position"></property>
784785
<property name="pane_size"></property>
785786
<property name="permission">protected</property>
786787
<property name="pin_button">1</property>
787788
<property name="pos"></property>
788789
<property name="resize">Resizable</property>
790+
<property name="selection">0</property>
789791
<property name="show">1</property>
790792
<property name="size"></property>
791-
<property name="style"></property>
793+
<property name="style">wxRA_SPECIFY_COLS</property>
792794
<property name="subclass">; ; forward_declare</property>
793795
<property name="toolbar_pane">0</property>
794796
<property name="tooltip"></property>

0 commit comments

Comments
 (0)