From 48322ea1b6100614d5392d13905eded241be9a6a Mon Sep 17 00:00:00 2001 From: pszsh Date: Sun, 11 Jan 2026 00:53:17 -0800 Subject: [PATCH 1/2] Implemented a new feature where the highlight groups each are assigned a different color of the rainbow. --- InteractiveHtmlBom/core/config.py | 14 +++++- InteractiveHtmlBom/dialog/dialog_base.py | 9 ++-- InteractiveHtmlBom/web/ibom.css | 11 +++- InteractiveHtmlBom/web/ibom.html | 20 +++++++- InteractiveHtmlBom/web/ibom.js | 64 +++++++++++++++++++++++- InteractiveHtmlBom/web/render.js | 41 +++++++++------ 6 files changed, 135 insertions(+), 24 deletions(-) diff --git a/InteractiveHtmlBom/core/config.py b/InteractiveHtmlBom/core/config.py index 5aa593d..2974cbc 100644 --- a/InteractiveHtmlBom/core/config.py +++ b/InteractiveHtmlBom/core/config.py @@ -1,3 +1,5 @@ +# InteractiveHtmlBom/core/config.py + """Config object""" import argparse @@ -39,7 +41,7 @@ class Config: 'dark_mode', 'show_pads', 'show_fabrication', 'show_silkscreen', 'highlight_pin1', 'redraw_on_drag', 'board_rotation', 'checkboxes', 'bom_view', 'layer_view', 'offset_back_rotation', - 'kicad_text_formatting', 'mark_when_checked' + 'kicad_text_formatting', 'mark_when_checked', 'rainbow_mode' ] default_show_group_fields = ["Value", "Footprint"] @@ -60,6 +62,7 @@ class Config: layer_view = layer_view_choices[1] compression = True open_browser = True + rainbow_mode = False # General section bom_dest_dir = 'bom/' # This is relative to pcb file directory @@ -127,6 +130,7 @@ def load_from_ini(self): self.layer_view = f.Read('layer_view', self.layer_view) self.compression = f.ReadBool('compression', self.compression) self.open_browser = f.ReadBool('open_browser', self.open_browser) + self.rainbow_mode = f.ReadBool('rainbow_mode', self.rainbow_mode) f.SetPath('/general') self.bom_dest_dir = f.Read('bom_dest_dir', self.bom_dest_dir) @@ -187,6 +191,7 @@ def save(self, locally): f.Write('layer_view', self.layer_view) f.WriteBool('compression', self.compression) f.WriteBool('open_browser', self.open_browser) + f.WriteBool('rainbow_mode', self.rainbow_mode) f.SetPath('/general') bom_dest_dir = self.bom_dest_dir @@ -235,6 +240,7 @@ def set_from_dialog(self, dlg): dlg.html.layerDefaultView.Selection] self.compression = dlg.html.compressionCheckbox.IsChecked() self.open_browser = dlg.html.openBrowserCheckbox.IsChecked() + self.rainbow_mode = dlg.html.rainbowModeCheckbox.IsChecked() # General self.bom_dest_dir = dlg.general.bomDirPicker.Path @@ -286,6 +292,7 @@ def transfer_to_dialog(self, dlg): self.layer_view) dlg.html.compressionCheckbox.Value = self.compression dlg.html.openBrowserCheckbox.Value = self.open_browser + dlg.html.rainbowModeCheckbox.Value = self.rainbow_mode # General import os.path @@ -380,6 +387,8 @@ def add_options(cls, parser, version): action='store_true') parser.add_argument('--no-browser', help='Do not launch browser.', action='store_true') + parser.add_argument('--rainbow-mode', help='Enable rainbow mode for component highlighting.', + action='store_true') # General parser.add_argument('--dest-dir', default=cls.bom_dest_dir, @@ -460,6 +469,7 @@ def set_from_args(self, args): self.layer_view = args.layer_view self.compression = not args.no_compression self.open_browser = not args.no_browser + self.rainbow_mode = args.rainbow_mode # General self.bom_dest_dir = args.dest_dir @@ -490,4 +500,4 @@ def get_html_config(self): import json d = {f: getattr(self, f) for f in self.html_config_fields} d["fields"] = self.show_fields - return json.dumps(d) + return json.dumps(d) \ No newline at end of file diff --git a/InteractiveHtmlBom/dialog/dialog_base.py b/InteractiveHtmlBom/dialog/dialog_base.py index 6b3c5d4..fbff36e 100644 --- a/InteractiveHtmlBom/dialog/dialog_base.py +++ b/InteractiveHtmlBom/dialog/dialog_base.py @@ -1,3 +1,5 @@ +# InteractiveHtmlBom/dialog/dialog_base.py + # -*- coding: utf-8 -*- ########################################################################### @@ -181,6 +183,9 @@ def __init__( self, parent, id = wx.ID_ANY, pos = wx.DefaultPosition, size = wx. self.openBrowserCheckbox.SetValue(True) sbSizer10.Add( self.openBrowserCheckbox, 0, wx.ALL, 5 ) + self.rainbowModeCheckbox = wx.CheckBox( sbSizer10.GetStaticBox(), wx.ID_ANY, u"Assign each group a unique color", wx.DefaultPosition, wx.DefaultSize, 0 ) + sbSizer10.Add( self.rainbowModeCheckbox, 0, wx.ALL, 5 ) + b_sizer.Add( sbSizer10, 1, wx.EXPAND|wx.ALL, 5 ) @@ -573,6 +578,4 @@ def OnFieldsDown( self, event ): def OnBoardVariantFieldChange( self, event ): - event.Skip() - - + event.Skip() \ No newline at end of file diff --git a/InteractiveHtmlBom/web/ibom.css b/InteractiveHtmlBom/web/ibom.css index a601c3f..c3bf499 100644 --- a/InteractiveHtmlBom/web/ibom.css +++ b/InteractiveHtmlBom/web/ibom.css @@ -1,3 +1,5 @@ +/* InteractiveHtmlBom/web/ibom.css */ + :root { --pcb-edge-color: black; --pad-color: #878787; @@ -39,6 +41,11 @@ body { color: #eee; } +.rainbowGroupsEnabled .menu-label-top { + font-size: 0.8rem; +} + + button { background-color: #eee; border: 1px solid #888; @@ -221,11 +228,11 @@ canvas:active { } .bom tr.highlighted:nth-child(n) { - background-color: #cfc; + background-color: #cfc !important; } .dark .bom tr.highlighted:nth-child(n) { - background-color: #226022; + background-color: #226022 !important; } .bom tr:nth-child(even) { diff --git a/InteractiveHtmlBom/web/ibom.html b/InteractiveHtmlBom/web/ibom.html index 69fd777..ffa9acd 100644 --- a/InteractiveHtmlBom/web/ibom.html +++ b/InteractiveHtmlBom/web/ibom.html @@ -1,3 +1,5 @@ + + @@ -132,6 +134,14 @@ Continuous redraw on drag + +