@@ -18,6 +18,7 @@ def __init__(self, state, parent=None, board=None, action=None, updateState=None
18
18
self .actionCallback = action
19
19
self .updateStatusCallback = updateState
20
20
self .text = ""
21
+ self .selectedItemOnly = False
21
22
22
23
self .Bind (wx .EVT_CLOSE , self .OnCancel , id = self .GetId ())
23
24
self .Bind (wx .EVT_SIZE , self .OnSize )
@@ -41,6 +42,16 @@ def __init__(self, state, parent=None, board=None, action=None, updateState=None
41
42
self .Bind (wx .EVT_TEXT , self .OnPatternChange , id = self .pattern .GetId ())
42
43
self .item_grid .Add (self .pattern , 0 , wx .EXPAND )
43
44
45
+ label = wx .StaticText (panel , label = "Only Selected items:" ,
46
+ size = wx .Size (200 , - 1 ),
47
+ style = wx .ALIGN_RIGHT )
48
+ label .Wrap (200 )
49
+ self .item_grid .Add (label , 1 , wx .ALIGN_CENTRE_VERTICAL )
50
+ self .selected_only = wx .CheckBox (panel , style = wx .CHK_2STATE )
51
+ self .Bind (wx .EVT_CHECKBOX , self .OnselectedItemOnlyChange )
52
+ self .selected_only .SetValue (self .selectedItemOnly )
53
+ self .item_grid .Add (self .selected_only , 0 , wx .EXPAND )
54
+
44
55
label = wx .StaticText (panel , label = "What to do:" ,
45
56
size = wx .Size (200 , - 1 ),
46
57
style = wx .ALIGN_RIGHT )
@@ -191,12 +202,19 @@ def GetPattern(self):
191
202
def GetActiveLayers (self ):
192
203
return set (self .layers .GetCheckedItems ())
193
204
205
+ def GetSelectedItemOnly (self ):
206
+ return self .selectedItemOnly
207
+
194
208
def ModifyReferences (self ):
195
209
return self .scope .GetSelection () in [0 , 2 ]
196
210
197
211
def ModifyValues (self ):
198
212
return self .scope .GetSelection () in [1 , 2 ]
199
213
214
+ def OnselectedItemOnlyChange (self , event ):
215
+ self .selectedItemOnly = not self .selectedItemOnly
216
+ self .OnPatternChange (None )
217
+
200
218
def OnPatternChange (self , event ):
201
219
try :
202
220
regex = re .compile (self .pattern .GetValue ())
@@ -206,6 +224,9 @@ def OnPatternChange(self, event):
206
224
else :
207
225
refs = []
208
226
for footprint in self .board .GetFootprints ():
227
+ if self .selectedItemOnly and not footprint .IsSelected ():
228
+ continue
229
+
209
230
if regex .match (footprint .GetReference ()):
210
231
refs .append (footprint .GetReference ())
211
232
if len (refs ) > 0 :
@@ -238,10 +259,12 @@ def action(self, dialog):
238
259
try :
239
260
if dialog .ModifyReferences ():
240
261
modify .references (dialog .board , dialog .GetShowLabels (),
241
- dialog .GetPattern (), dialog .GetActiveLayers ())
262
+ dialog .GetPattern (), dialog .GetActiveLayers (),
263
+ dialog .GetSelectedItemOnly ())
242
264
if dialog .ModifyValues ():
243
265
modify .values (dialog .board , dialog .GetShowLabels (),
244
- dialog .GetPattern (), dialog .GetActiveLayers ())
266
+ dialog .GetPattern (), dialog .GetActiveLayers (),
267
+ dialog .GetSelectedItemOnly ())
245
268
pcbnew .Refresh ()
246
269
except Exception as e :
247
270
self .error (f"Cannot perform: { e } " )
0 commit comments