@@ -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' )
0 commit comments