From 3dc5f7db562c3428f9ba02858e8c40ea10ea0187 Mon Sep 17 00:00:00 2001 From: qu1ck Date: Mon, 15 May 2023 08:36:12 -0700 Subject: [PATCH] Implement none/all/selected choice for pin 1 highlight Fixes #374 --- DATAFORMAT.md | 8 +++----- InteractiveHtmlBom/core/config.py | 25 +++++++++++++++++------- InteractiveHtmlBom/dialog/dialog_base.py | 8 +++++--- InteractiveHtmlBom/web/ibom.html | 23 ++++++++++++++++++---- InteractiveHtmlBom/web/render.js | 4 +++- InteractiveHtmlBom/web/util.js | 11 ++++++++--- settings_dialog.fbp | 20 ++++++++++--------- 7 files changed, 67 insertions(+), 32 deletions(-) diff --git a/DATAFORMAT.md b/DATAFORMAT.md index 94c2853..b20126f 100644 --- a/DATAFORMAT.md +++ b/DATAFORMAT.md @@ -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", ...], } ``` diff --git a/InteractiveHtmlBom/core/config.py b/InteractiveHtmlBom/core/config.py index e6df44a..ea94484 100644 --- a/InteractiveHtmlBom/core/config.py +++ b/InteractiveHtmlBom/core/config.py @@ -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', @@ -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) @@ -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) @@ -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) @@ -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) @@ -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() @@ -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 @@ -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') diff --git a/InteractiveHtmlBom/dialog/dialog_base.py b/InteractiveHtmlBom/dialog/dialog_base.py index 1cbbbb9..f41a2e8 100644 --- a/InteractiveHtmlBom/dialog/dialog_base.py +++ b/InteractiveHtmlBom/dialog/dialog_base.py @@ -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 ) diff --git a/InteractiveHtmlBom/web/ibom.html b/InteractiveHtmlBom/web/ibom.html index db639c1..07f16b4 100644 --- a/InteractiveHtmlBom/web/ibom.html +++ b/InteractiveHtmlBom/web/ibom.html @@ -102,14 +102,29 @@ DNP outlined - +