KiCad PCB EDA Suite
GENERAL_COLLECTOR Class Reference

Used when the right click button is pressed, or when the select tool is in effect. More...

#include <collectors.h>

Inheritance diagram for GENERAL_COLLECTOR:
PCB_COLLECTOR COLLECTOR

Public Types

using ITER = std::vector< EDA_ITEM * >::iterator
 
using CITER = std::vector< EDA_ITEM * >::const_iterator
 

Public Member Functions

 GENERAL_COLLECTOR ()
 
void Empty2nd ()
 
void Append2nd (BOARD_ITEM *item)
 
void SetGuide (const COLLECTORS_GUIDE *aGuide)
 Record which COLLECTORS_GUIDE to use. More...
 
const COLLECTORS_GUIDEGetGuide () const
 
INSPECT_RESULT Inspect (EDA_ITEM *testItem, void *testData) override
 The examining function within the INSPECTOR which is passed to the Iterate function. More...
 
void Collect (BOARD_ITEM *aItem, const std::vector< KICAD_T > &aScanList, const VECTOR2I &aRefPos, const COLLECTORS_GUIDE &aGuide)
 Scan a BOARD_ITEM using this class's Inspector method, which does the collection. More...
 
BOARD_ITEMoperator[] (int ndx) const override
 Overload the COLLECTOR::operator[](int) to return a BOARD_ITEM instead of an EDA_ITEM. More...
 
ITER begin ()
 
CITER begin () const
 
ITER end ()
 
CITER end () const
 
int GetCount () const
 Return the number of objects in the list. More...
 
void Empty ()
 Clear the list. More...
 
void Append (EDA_ITEM *item)
 Add an item to the end of the list. More...
 
void Remove (int aIndex)
 Remove the item at aIndex (first position is 0). More...
 
void Remove (const EDA_ITEM *aItem)
 Remove the item aItem (if exists in the collector). More...
 
bool HasAdditionalItems ()
 Test if the collector has heuristic backup items. More...
 
void Combine ()
 Re-combine the backup list into the main list of the collector. More...
 
void Transfer (int aIndex)
 Move the item at aIndex (first position is 0) to the backup list. More...
 
void Transfer (EDA_ITEM *aItem)
 Move aItem (if exists in the collector) to the backup list. More...
 
bool HasItem (const EDA_ITEM *aItem) const
 Tests if aItem has already been collected. More...
 
void SetScanTypes (const std::vector< KICAD_T > &aTypes)
 Record the list of KICAD_T types to consider for collection by the Inspect() function. More...
 
void SetRefPos (const VECTOR2I &aRefPos)
 
int CountType (KICAD_T aType)
 Count the number of items matching aType. More...
 

Public Attributes

int m_Threshold
 
wxString m_MenuTitle
 
bool m_MenuCancelled
 

Static Public Attributes

static const std::vector< KICAD_TAllBoardItems
 A scan list for all editable board items. More...
 
static const std::vector< KICAD_TZones
 A scan list for zones outlines only. More...
 
static const std::vector< KICAD_TBoardLevelItems
 A scan list for all primary board items, omitting items which are subordinate to a FOOTPRINT, such as PAD and FP_TEXT. More...
 
static const std::vector< KICAD_TFootprints
 A scan list for only FOOTPRINTs. More...
 
static const std::vector< KICAD_TPadsOrTracks
 A scan list for PADs, TRACKs, or VIAs. More...
 
static const std::vector< KICAD_TFootprintItems
 A scan list for primary footprint items. More...
 
static const std::vector< KICAD_TTracks
 A scan list for only TRACKs and ARCs. More...
 
static const std::vector< KICAD_TLockableItems
 A scan list for TRACKs, VIAs, FOOTPRINTs. More...
 
static const std::vector< KICAD_TDimensions
 A scan list for dimensions. More...
 
static const std::vector< KICAD_TDraggableItems
 A scan list for items that can be dragged. More...
 

Protected Attributes

std::vector< BOARD_ITEM * > m_List2nd
 A place to hold collected objects which don't match precisely the search criteria, but would be acceptable if nothing else is found. More...
 
const COLLECTORS_GUIDEm_Guide
 Determine which items are to be collected by Inspect(). More...
 
std::vector< EDA_ITEM * > m_list
 
std::vector< EDA_ITEM * > m_backupList
 
std::vector< KICAD_Tm_scanTypes
 
INSPECTOR_FUNC m_inspector
 
VECTOR2I m_refPos
 

Detailed Description

Used when the right click button is pressed, or when the select tool is in effect.

This class can be used by window classes such as PCB_EDIT_FRAME.

Philosophy: this class knows nothing of the context in which a BOARD is used and that means it knows nothing about which layers are visible or current, but can handle those concerns by the SetPreferredLayer() function and the SetLayerSet() function.

Definition at line 203 of file collectors.h.

Member Typedef Documentation

◆ CITER

using COLLECTOR::CITER = std::vector<EDA_ITEM*>::const_iterator
inherited

Definition at line 71 of file collector.h.

◆ ITER

using COLLECTOR::ITER = std::vector<EDA_ITEM*>::iterator
inherited

Definition at line 70 of file collector.h.

Constructor & Destructor Documentation

◆ GENERAL_COLLECTOR()

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Definition at line 272 of file collectors.h.

272 :
273 m_Guide( nullptr )
274 {
276 }
void SetScanTypes(const std::vector< KICAD_T > &aTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
Definition: collector.h:211
static const std::vector< KICAD_T > AllBoardItems
A scan list for all editable board items.
Definition: collectors.h:224
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:217

References AllBoardItems, and COLLECTOR::SetScanTypes().

Member Function Documentation

◆ Append()

◆ Append2nd()

void GENERAL_COLLECTOR::Append2nd ( BOARD_ITEM item)
inline

Definition at line 283 of file collectors.h.

284 {
285 m_List2nd.push_back( item );
286 }
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don't match precisely the search criteria,...
Definition: collectors.h:212

References m_List2nd.

Referenced by Inspect().

◆ begin() [1/2]

ITER COLLECTOR::begin ( )
inlineinherited

Definition at line 73 of file collector.h.

73{ return m_list.begin(); }

References COLLECTOR::m_list.

◆ begin() [2/2]

CITER COLLECTOR::begin ( ) const
inlineinherited

Definition at line 75 of file collector.h.

75{ return m_list.cbegin(); }

References COLLECTOR::m_list.

◆ Collect()

void GENERAL_COLLECTOR::Collect ( BOARD_ITEM aItem,
const std::vector< KICAD_T > &  aScanList,
const VECTOR2I aRefPos,
const COLLECTORS_GUIDE aGuide 
)

Scan a BOARD_ITEM using this class's Inspector method, which does the collection.

Parameters
aItemA BOARD_ITEM to scan, may be a BOARD or FOOTPRINT, or whatever.
aScanListA list of KICAD_Ts that specs what is to be collected and the priority order of the resultant collection in "m_list".
aRefPosA wxPoint to use in hit-testing.
aGuideThe COLLECTORS_GUIDE to use in collecting items.

Definition at line 596 of file collectors.cpp.

598{
599 Empty(); // empty the collection, primary criteria list
600 Empty2nd(); // empty the collection, secondary criteria list
601
602 // remember guide, pass it to Inspect()
603 SetGuide( &aGuide );
604
605 SetScanTypes( aScanTypes );
606
607 // remember where the snapshot was taken from and pass refPos to
608 // the Inspect() function.
609 SetRefPos( aRefPos );
610
611 aItem->Visit( m_inspector, nullptr, m_scanTypes );
612
613 // append 2nd list onto end of the first list
614 for( unsigned i = 0; i<m_List2nd.size(); ++i )
615 Append( m_List2nd[i] );
616
617 Empty2nd();
618}
INSPECTOR_FUNC m_inspector
Definition: collector.h:244
void Empty()
Clear the list.
Definition: collector.h:89
void SetRefPos(const VECTOR2I &aRefPos)
Definition: collector.h:213
std::vector< KICAD_T > m_scanTypes
Definition: collector.h:243
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:99
virtual INSPECT_RESULT Visit(INSPECTOR inspector, void *testData, const std::vector< KICAD_T > &aScanTypes)
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:91
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:293

References COLLECTOR::Append(), COLLECTOR::Empty(), Empty2nd(), COLLECTOR::m_inspector, m_List2nd, COLLECTOR::m_scanTypes, SetGuide(), COLLECTOR::SetRefPos(), COLLECTOR::SetScanTypes(), and EDA_ITEM::Visit().

Referenced by PCB_CONTROL::DeleteItemCursor(), PAD_TOOL::EnumeratePads(), BOARD_INSPECTION_TOOL::highlightNet(), and PCB_SELECTION_TOOL::selectPoint().

◆ Combine()

void COLLECTOR::Combine ( )
inlineinherited

Re-combine the backup list into the main list of the collector.

Definition at line 140 of file collector.h.

141 {
142 std::copy( m_backupList.begin(), m_backupList.end(), std::back_inserter( m_list ) );
143 m_backupList.clear();
144 }
std::vector< EDA_ITEM * > m_backupList
Definition: collector.h:241

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ CountType()

int COLLECTOR::CountType ( KICAD_T  aType)
inlineinherited

Count the number of items matching aType.

Parameters
aTypetype we are interested in.
Returns
number of occurrences.

Definition at line 221 of file collector.h.

222 {
223 int cnt = 0;
224
225 for( size_t i = 0; i < m_list.size(); i++ )
226 {
227 if( m_list[i]->Type() == aType )
228 cnt++;
229 }
230
231 return cnt;
232 }

References COLLECTOR::m_list.

Referenced by ROUTER_TOOL::NeighboringSegmentFilter().

◆ Empty()

◆ Empty2nd()

void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 278 of file collectors.h.

279 {
280 m_List2nd.clear();
281 }

References m_List2nd.

Referenced by Collect().

◆ end() [1/2]

ITER COLLECTOR::end ( )
inlineinherited

Definition at line 74 of file collector.h.

74{ return m_list.end(); }

References COLLECTOR::m_list.

◆ end() [2/2]

CITER COLLECTOR::end ( ) const
inlineinherited

Definition at line 76 of file collector.h.

76{ return m_list.cend(); }

References COLLECTOR::m_list.

◆ GetCount()

int COLLECTOR::GetCount ( ) const
inlineinherited

Return the number of objects in the list.

Definition at line 81 of file collector.h.

82 {
83 return (int) m_list.size();
84 }

References COLLECTOR::m_list.

Referenced by BOARD_EDITOR_CONTROL::AssignNetclass(), BuildBoardPolygonOutlines(), BuildFootprintPolygonOutlines(), EDIT_TOOL::ChangeTrackWidth(), EE_SELECTION_TOOL::CollectHits(), connectedItemFilter(), EDIT_TOOL::copyToClipboard(), FOOTPRINT::CoverageRatio(), CONVERT_TOOL::CreateLines(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::Drag(), PAD_TOOL::EnumeratePads(), EDIT_TOOL::FilletLines(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::FilterCollectedItems(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), PCB_SELECTION_TOOL::FilterCollectorForMarkers(), EDIT_TOOL::FootprintFilter(), EE_SELECTION_TOOL::GetNode(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), ALIGN_DISTRIBUTE_TOOL::GetSelections(), GENDRILL_WRITER_BASE::getUniqueLayerPairs(), GROUP_TOOL::Group(), PL_SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), EE_COLLECTOR::IsCorner(), EE_SELECTION_TOOL::Main(), DSN::SPECCTRA_DB::makeIMAGE(), EE_SELECTION_TOOL::narrowSelection(), ROUTER_TOOL::NeighboringSegmentFilter(), COLLECTOR::operator[](), EE_COLLECTOR::operator[](), GERBER_COLLECTOR::operator[](), PCB_COLLECTOR::operator[](), EDIT_TOOL::PackAndMoveFootprints(), EDIT_TOOL::PadFilter(), CONVERT_TOOL::SegmentToArc(), PCB_SELECTION_TOOL::selectMultiple(), GERBVIEW_SELECTION_TOOL::selectPoint(), PL_SELECTION_TOOL::SelectPoint(), PCB_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), EDIT_TOOL::Swap(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ GetGuide()

const COLLECTORS_GUIDE * GENERAL_COLLECTOR::GetGuide ( ) const
inline

◆ HasAdditionalItems()

bool COLLECTOR::HasAdditionalItems ( )
inlineinherited

Test if the collector has heuristic backup items.

Returns
true if Combine() can run to bring secondary items into the list.

Definition at line 132 of file collector.h.

133 {
134 return !m_backupList.empty();
135 }

References COLLECTOR::m_backupList.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ HasItem()

bool COLLECTOR::HasItem ( const EDA_ITEM aItem) const
inlineinherited

Tests if aItem has already been collected.

Parameters
aItemThe EDA_ITEM* to be tested.
Returns
True if aItem is already collected.

Definition at line 195 of file collector.h.

196 {
197 for( size_t i = 0; i < m_list.size(); i++ )
198 {
199 if( m_list[i] == aItem )
200 return true;
201 }
202
203 return false;
204 }

References COLLECTOR::m_list.

Referenced by EE_SELECTION_TOOL::CollectHits(), PCB_SELECTION_TOOL::FilterCollectorForFreePads(), and PCB_SELECTION_TOOL::FilterCollectorForHierarchy().

◆ Inspect()

INSPECT_RESULT GENERAL_COLLECTOR::Inspect ( EDA_ITEM testItem,
void *  testData 
)
overridevirtual

The examining function within the INSPECTOR which is passed to the Iterate function.

Search and collect all the objects which match the test data.

Parameters
testItemAn EDA_ITEM to examine.
testDatais not used in this class.
Returns
SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE

Reimplemented from COLLECTOR.

Definition at line 160 of file collectors.cpp.

161{
162 BOARD_ITEM* item = (BOARD_ITEM*) testItem;
163 FOOTPRINT* footprint = nullptr;
164 PCB_GROUP* group = nullptr;
165 PAD* pad = nullptr;
166 bool pad_through = false;
167 PCB_VIA* via = nullptr;
168 PCB_MARKER* marker = nullptr;
169 ZONE* zone = nullptr;
170 PCB_DIMENSION_BASE* dimension = nullptr;
171
172#if 0 // debugging
173 static int breakhere = 0;
174
175 switch( item->Type() )
176 {
177 case PCB_PAD_T:
178 {
179 FOOTPRINT* footprint = (FOOTPRINT*) item->GetParent();
180
181 if( footprint->GetReference() == wxT( "Y2" ) )
182 breakhere++;
183 }
184 break;
185
186 case PCB_VIA_T:
187 breakhere++;
188 break;
189
190 case PCB_TRACE_T:
191 case PCB_ARC_T:
192 breakhere++;
193 break;
194
195 case PCB_TEXT_T:
196 breakhere++;
197 break;
198
199 case PCB_TEXTBOX_T:
200 breakhere++;
201 break;
202
203 case PCB_SHAPE_T:
204 breakhere++;
205 break;
206
208 breakhere++;
209 break;
210
211 case PCB_FP_TEXT_T:
212 {
213 FP_TEXT* fpText = (FP_TEXT*) item;
214
215 if( fpText->GetText() == wxT( "10uH" ) )
216 breakhere++;
217 }
218 break;
219
220 case PCB_FP_TEXTBOX_T:
221 breakhere++;
222 break;
223
224 case PCB_FOOTPRINT_T:
225 {
226 FOOTPRINT* footprint = (FOOTPRINT*) item;
227
228 if( footprint->GetReference() == wxT( "C98" ) )
229 breakhere++;
230 }
231 break;
232
233 case PCB_MARKER_T:
234 breakhere++;
235 break;
236
237 default:
238 breakhere++;
239 break;
240 }
241
242#endif
243
244 switch( item->Type() )
245 {
246 case PCB_PAD_T:
247 // there are pad specific visibility controls.
248 // Criteria to select a pad is:
249 // for smd pads: the footprint parent must be visible, and pads on the corresponding
250 // board side must be visible
251 // if pad is a thru hole, then it can be visible when its parent footprint is not.
252 // for through pads: pads on Front or Back board sides must be visible
253 pad = static_cast<PAD*>( item );
254
255 if( ( pad->GetAttribute() != PAD_ATTRIB::SMD ) &&
256 ( pad->GetAttribute() != PAD_ATTRIB::CONN ) ) // a hole is present, so multiple layers
257 {
258 // proceed to the common tests below, but without the parent footprint test,
259 // by leaving footprint==NULL, but having pad != null
260 pad_through = true;
261 }
262 else // smd, so use pads test after footprint test
263 {
264 footprint = static_cast<FOOTPRINT*>( item->GetParent() );
265 }
266
267 break;
268
269 case PCB_VIA_T: // vias are on many layers, so layer test is specific
270 via = static_cast<PCB_VIA*>( item );
271 break;
272
273 case PCB_TRACE_T:
274 case PCB_ARC_T:
275 if( m_Guide->IgnoreTracks() )
277
278 break;
279
280 case PCB_FP_ZONE_T:
281 footprint = static_cast<FOOTPRINT*>( item->GetParent() );
282
283 // Fallthrough to get the zone as well
285
286 case PCB_ZONE_T:
287 zone = static_cast<ZONE*>( item );
288 break;
289
290 case PCB_TEXT_T:
291 case PCB_TEXTBOX_T:
292 case PCB_SHAPE_T:
293 break;
294
300 footprint = static_cast<FOOTPRINT*>( item->GetParent() );
301
302 // Fallthrough to get the zone as well
304
306 case PCB_DIM_CENTER_T:
307 case PCB_DIM_RADIAL_T:
309 case PCB_DIM_LEADER_T:
310 dimension = static_cast<PCB_DIMENSION_BASE*>( item );
311 break;
312
313 case PCB_TARGET_T:
314 break;
315
316 case PCB_FP_TEXT_T:
317 case PCB_FP_TEXTBOX_T:
318 {
319 PCB_LAYER_ID layer = item->GetLayer();
320
321 if( m_Guide->IgnoreHiddenFPText() && item->Type() == PCB_FP_TEXT_T )
322 {
323 FP_TEXT *text = static_cast<FP_TEXT*>( item );
324
325 if( !text->IsVisible() )
327 }
328
329 if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( layer ) )
331
332 if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( layer ) )
334
335 /*
336 * The three text types have different criteria: reference and value have their own
337 * ignore flags; user text instead follows their layer visibility. Checking this here
338 * is simpler than later (when layer visibility is checked for other entities)
339 */
340
342
343 if( item->Type() == PCB_FP_TEXT_T )
344 textType = static_cast<FP_TEXT*>( item )->GetType();
345
346 switch( textType )
347 {
351
352 break;
353
355 if( m_Guide->IgnoreFPValues() )
357
358 break;
359
361 if( !m_Guide->IsLayerVisible( layer ) )
363
364 break;
365 }
366
367 // Extract the footprint since it could be hidden
368 footprint = static_cast<FOOTPRINT*>( item->GetParent() );
369 break;
370 }
371
372 case PCB_FP_SHAPE_T:
373 break;
374
375 case PCB_FOOTPRINT_T:
376 footprint = static_cast<FOOTPRINT*>( item );
377 break;
378
379 case PCB_GROUP_T:
380 group = static_cast<PCB_GROUP*>( item );
381 break;
382
383 case PCB_MARKER_T:
384 marker = static_cast<PCB_MARKER*>( item );
385 break;
386
387 default:
388 break;
389 }
390
391 // common tests:
392
393 if( footprint ) // true from case PCB_PAD_T, PCB_FP_TEXT_T, or PCB_FOOTPRINT_T
394 {
395 if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu ) )
397
398 if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu ) )
400 }
401
402 // Pads are not sensitive to the layer visibility controls.
403 // They all have their own separate visibility controls
404 // skip them if not visible
405 if( pad )
406 {
407 if( m_Guide->IgnorePads() )
409
410 if( ! pad_through )
411 {
412 if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
414
415 if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
417 }
418 }
419
420 if( marker )
421 {
422 // Markers are not sensitive to the layer
423 if( marker->HitTest( m_refPos ) )
424 Append( item );
425
427 }
428
429 if( group )
430 {
431 // Groups are not sensitive to the layer ... ?
432 if( group->HitTest( m_refPos ) )
433 Append( item );
434
436 }
437
438 if( via )
439 {
440 auto type = via->GetViaType();
441
442 if( ( m_Guide->IgnoreThroughVias() && type == VIATYPE::THROUGH )
444 || ( m_Guide->IgnoreMicroVias() && type == VIATYPE::MICROVIA ) )
445 {
447 }
448 }
449
450 if( ( item->IsOnLayer( m_Guide->GetPreferredLayer() ) )
451 && ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
452 {
453 // footprints and their subcomponents: reference, value and pads are not sensitive
454 // to the layer visibility controls. They all have their own separate visibility
455 // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
456 // text in a footprint *is* sensitive to layer visibility but that was already handled.
457
458 int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
459
460 if( zone )
461 {
462 if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
463 || zone->HitTestForEdge( m_refPos, accuracy ) )
464 {
465 Append( item );
467 }
468 else if( !m_Guide->IgnoreZoneFills() )
469 {
470 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
471 {
472 if( m_Guide->IsLayerVisible( layer )
473 && zone->HitTestFilledArea( layer, m_refPos ) )
474 {
475 Append( item );
477 }
478 }
479 }
480 }
481 else if( item == footprint )
482 {
483 if( footprint->HitTest( m_refPos, accuracy )
484 && footprint->HitTestAccurate( m_refPos, accuracy ) )
485 {
486 Append( item );
488 }
489 }
490 else if( pad || via )
491 {
492 if( item->HitTest( m_refPos, accuracy ) )
493 {
494 Append( item );
496 }
497 }
498 else
499 {
500 PCB_LAYER_ID layer = item->GetLayer();
501
502 if( m_Guide->IsLayerVisible( layer ) )
503 {
504 if( dimension )
505 {
506 // Dimensions feel particularly hard to select, probably due to their
507 // noisy shape making it feel like they should have a larger boundary.
508 accuracy = KiROUND( accuracy * 1.5 );
509 }
510
511 if( item->HitTest( m_refPos, accuracy ) )
512 {
513 Append( item );
515 }
516 }
517 }
518 }
519
520 if( m_Guide->IncludeSecondary() && ( !item->IsLocked() || !m_Guide->IgnoreLockedItems() ) )
521 {
522 // for now, "secondary" means "tolerate any visible layer". It has no effect on other
523 // criteria, since there is a separate "ignore" control for those in the COLLECTORS_GUIDE
524
525 // footprints and their subcomponents: reference, value and pads are not sensitive
526 // to the layer visibility controls. They all have their own separate visibility
527 // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
528 // text in a footprint *is* sensitive to layer visibility but that was already handled.
529
530 int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
531
532 if( zone )
533 {
534 if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
535 || zone->HitTestForEdge( m_refPos, accuracy ) )
536 {
537 Append2nd( item );
539 }
540 else if( !m_Guide->IgnoreZoneFills() )
541 {
542 for( PCB_LAYER_ID layer : zone->GetLayerSet().Seq() )
543 {
544 if( m_Guide->IsLayerVisible( layer )
545 && zone->HitTestFilledArea( layer, m_refPos ) )
546 {
547 Append2nd( item );
549 }
550 }
551 }
552 }
553 else if( item->Type() == PCB_FOOTPRINT_T )
554 {
555 if( footprint->HitTest( m_refPos, accuracy )
556 && footprint->HitTestAccurate( m_refPos, accuracy ) )
557 {
558 Append2nd( item );
560 }
561 }
562 else if( pad || via )
563 {
564 if( item->HitTest( m_refPos, accuracy ) )
565 {
566 Append2nd( item );
568 }
569 }
570 else
571 {
572 PCB_LAYER_ID layer = item->GetLayer();
573
574 if( m_Guide->IsLayerVisible( layer ) )
575 {
576 if( dimension )
577 {
578 // Dimensions feel particularly hard to select, probably due to their
579 // noisy shape making it feel like they should have a larger boundary.
580 accuracy = KiROUND( accuracy * 1.5 );
581 }
582
583 if( item->HitTest( m_refPos, accuracy ) )
584 {
585 Append2nd( item );
587 }
588 }
589 }
590 }
591
592 return INSPECT_RESULT::CONTINUE; // always when collecting
593}
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:58
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:180
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:245
virtual bool IsLocked() const
Definition: board_item.cpp:71
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:163
virtual bool IgnoreThroughVias() const =0
virtual bool IgnoreHiddenFPText() const =0
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
virtual bool IgnoreFPTextOnFront() const =0
virtual double OnePixelInIU() const =0
virtual bool IgnoreFPTextOnBack() const =0
virtual bool IgnoreLockedItems() const =0
virtual bool IgnoreZoneFills() const =0
virtual bool IgnoreMicroVias() const =0
virtual bool IgnoreFootprintsOnBack() const =0
virtual bool IgnoreBlindBuriedVias() const =0
virtual bool IgnorePadsOnBack() const =0
virtual bool IgnoreFPReferences() const =0
virtual bool IgnorePadsOnFront() const =0
virtual bool IgnoreFootprintsOnFront() const =0
virtual bool IgnorePads() const
Definition: collectors.h:122
virtual bool IgnoreTracks() const =0
virtual bool IncludeSecondary() const =0
Determine if the secondary criteria or 2nd choice items should be included.
virtual bool IgnoreFPValues() const =0
virtual PCB_LAYER_ID GetPreferredLayer() const =0
VECTOR2I m_refPos
Definition: collector.h:246
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:97
virtual bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if aPosition is inside or on the boundary of this item.
Definition: eda_item.h:222
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:87
PCB_LAYER_ID GetLayer() const override
Return the primary layer this item is on.
Definition: footprint.h:200
bool HitTestAccurate(const VECTOR2I &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
Definition: footprint.cpp:1116
const wxString & GetReference() const
Definition: footprint.h:519
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: footprint.cpp:1109
TEXT_TYPE
Footprint text type: there must be only one (and only one) for each of the reference value texts in o...
Definition: fp_text.h:48
@ TEXT_is_REFERENCE
Definition: fp_text.h:49
@ TEXT_is_DIVERS
Definition: fp_text.h:51
@ TEXT_is_VALUE
Definition: fp_text.h:50
TEXT_TYPE GetType() const
Definition: fp_text.h:120
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:283
LSEQ Seq(const PCB_LAYER_ID *aWishListSequence, unsigned aCount) const
Return an LSEQ from the union of this LSET and a desired sequence.
Definition: lset.cpp:411
Definition: pad.h:59
Abstract dimension API.
Definition: pcb_dimension.h:96
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:51
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: pcb_marker.h:76
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
bool HitTestForCorner(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a corner.
Definition: zone.cpp:415
bool HitTestForEdge(const VECTOR2I &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX *aCornerHit=nullptr) const
Test if the given VECTOR2I is near a segment defined by 2 corners.
Definition: zone.cpp:422
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const VECTOR2I &aRefPos, int aAccuracy=0) const
Test if the given VECTOR2I is within the bounds of a filled area of this zone.
Definition: zone.cpp:482
virtual LSET GetLayerSet() const override
Return a std::bitset of all layers on which the item physically resides.
Definition: zone.h:122
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
Definition: layer_ids.h:899
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
Definition: layer_ids.h:922
PCB_LAYER_ID
A quick note on layer IDs:
Definition: layer_ids.h:59
@ B_Cu
Definition: layer_ids.h:95
@ F_Cu
Definition: layer_ids.h:64
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
@ SMD
Smd pad, appears on the solder paste layer (default)
@ CONN
Like smd, does not appear on the solder paste layer (default)
@ BLIND_BURIED
@ PCB_FP_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:95
@ PCB_SHAPE_T
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:88
@ PCB_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:110
@ PCB_FP_SHAPE_T
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:94
@ PCB_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:107
@ PCB_VIA_T
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:102
@ PCB_FP_TEXTBOX_T
class FP_TEXTBOX, wrapped text in a footprint
Definition: typeinfo.h:93
@ PCB_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:108
@ PCB_GROUP_T
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:115
@ PCB_TEXTBOX_T
class PCB_TEXTBOX, wrapped text on a layer
Definition: typeinfo.h:91
@ PCB_ZONE_T
class ZONE, a copper pour area
Definition: typeinfo.h:112
@ PCB_TEXT_T
class PCB_TEXT, text on a layer
Definition: typeinfo.h:90
@ PCB_FP_DIM_CENTER_T
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:97
@ PCB_MARKER_T
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:104
@ PCB_TARGET_T
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:111
@ PCB_FP_DIM_ORTHOGONAL_T
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:99
@ PCB_FP_DIM_LEADER_T
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:96
@ PCB_FOOTPRINT_T
class FOOTPRINT, a footprint
Definition: typeinfo.h:86
@ PCB_DIM_ALIGNED_T
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:106
@ PCB_FP_ZONE_T
class ZONE, managed by a footprint
Definition: typeinfo.h:100
@ PCB_FP_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:98
@ PCB_PAD_T
class PAD, a pad in a footprint
Definition: typeinfo.h:87
@ PCB_FP_TEXT_T
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
@ PCB_ARC_T
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:103
@ PCB_TRACE_T
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:101
@ PCB_DIM_RADIAL_T
class PCB_DIM_RADIAL, a radius or diameter dimension
Definition: typeinfo.h:109
constexpr ret_type KiROUND(fp_type v)
Round a floating point number to an integer using "round halfway cases away from zero".
Definition: util.h:85

References COLLECTOR::Append(), Append2nd(), B_Cu, BLIND_BURIED, CONN, CONTINUE, F_Cu, BOARD_ITEM::GetLayer(), FOOTPRINT::GetLayer(), ZONE::GetLayerSet(), BOARD_ITEM::GetParent(), COLLECTORS_GUIDE::GetPreferredLayer(), FOOTPRINT::GetReference(), EDA_TEXT::GetText(), FP_TEXT::GetType(), group, EDA_ITEM::HitTest(), FOOTPRINT::HitTest(), PCB_MARKER::HitTest(), FOOTPRINT::HitTestAccurate(), ZONE::HitTestFilledArea(), ZONE::HitTestForCorner(), ZONE::HitTestForEdge(), COLLECTORS_GUIDE::IgnoreBlindBuriedVias(), COLLECTORS_GUIDE::IgnoreFootprintsOnBack(), COLLECTORS_GUIDE::IgnoreFootprintsOnFront(), COLLECTORS_GUIDE::IgnoreFPReferences(), COLLECTORS_GUIDE::IgnoreFPTextOnBack(), COLLECTORS_GUIDE::IgnoreFPTextOnFront(), COLLECTORS_GUIDE::IgnoreFPValues(), COLLECTORS_GUIDE::IgnoreHiddenFPText(), COLLECTORS_GUIDE::IgnoreLockedItems(), COLLECTORS_GUIDE::IgnoreMicroVias(), COLLECTORS_GUIDE::IgnorePads(), COLLECTORS_GUIDE::IgnorePadsOnBack(), COLLECTORS_GUIDE::IgnorePadsOnFront(), COLLECTORS_GUIDE::IgnoreThroughVias(), COLLECTORS_GUIDE::IgnoreTracks(), COLLECTORS_GUIDE::IgnoreZoneFills(), COLLECTORS_GUIDE::IncludeSecondary(), IsBackLayer(), IsFrontLayer(), COLLECTORS_GUIDE::IsLayerVisible(), BOARD_ITEM::IsLocked(), BOARD_ITEM::IsOnLayer(), KI_FALLTHROUGH, KiROUND(), m_Guide, COLLECTOR::m_refPos, MICROVIA, COLLECTORS_GUIDE::OnePixelInIU(), pad, PCB_ARC_T, PCB_DIM_ALIGNED_T, PCB_DIM_CENTER_T, PCB_DIM_LEADER_T, PCB_DIM_ORTHOGONAL_T, PCB_DIM_RADIAL_T, PCB_FOOTPRINT_T, PCB_FP_DIM_ALIGNED_T, PCB_FP_DIM_CENTER_T, PCB_FP_DIM_LEADER_T, PCB_FP_DIM_ORTHOGONAL_T, PCB_FP_DIM_RADIAL_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_TEXTBOX_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TEXTBOX_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, LSET::Seq(), SMD, text, FP_TEXT::TEXT_is_DIVERS, FP_TEXT::TEXT_is_REFERENCE, FP_TEXT::TEXT_is_VALUE, THROUGH, EDA_ITEM::Type(), and via.

◆ operator[]()

BOARD_ITEM * PCB_COLLECTOR::operator[] ( int  ndx) const
inlineoverridevirtualinherited

Overload the COLLECTOR::operator[](int) to return a BOARD_ITEM instead of an EDA_ITEM.

Parameters
ndxThe index into the list.
Returns
a board item or NULL.

Reimplemented from COLLECTOR.

Definition at line 185 of file collectors.h.

186 {
187 if( (unsigned)ndx < (unsigned)GetCount() )
188 return (BOARD_ITEM*) m_list[ ndx ];
189
190 return nullptr;
191 }
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:81

References COLLECTOR::GetCount(), and COLLECTOR::m_list.

◆ Remove() [1/2]

void COLLECTOR::Remove ( const EDA_ITEM aItem)
inlineinherited

Remove the item aItem (if exists in the collector).

Parameters
aItemthe item to be removed.

Definition at line 119 of file collector.h.

120 {
121 alg::delete_if( m_list, [&aItem]( const EDA_ITEM* aCandidate )
122 {
123 return aCandidate == aItem;
124 } );
125 }
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:85
void delete_if(_Container &__c, _Function &&__f)
Deletes all values from __c for which __f returns true.
Definition: kicad_algo.h:173

References alg::delete_if(), and COLLECTOR::m_list.

◆ Remove() [2/2]

◆ SetGuide()

void GENERAL_COLLECTOR::SetGuide ( const COLLECTORS_GUIDE aGuide)
inline

Record which COLLECTORS_GUIDE to use.

Parameters
aGuideWhich guide to use in the collection.

Definition at line 293 of file collectors.h.

293{ m_Guide = aGuide; }

References m_Guide.

Referenced by Collect(), and PCB_SELECTION_TOOL::RequestSelection().

◆ SetRefPos()

void COLLECTOR::SetRefPos ( const VECTOR2I aRefPos)
inlineinherited

Definition at line 213 of file collector.h.

213{ m_refPos = aRefPos; }

References COLLECTOR::m_refPos.

Referenced by Collect(), GERBER_COLLECTOR::Collect(), and EE_COLLECTOR::Collect().

◆ SetScanTypes()

void COLLECTOR::SetScanTypes ( const std::vector< KICAD_T > &  aTypes)
inlineinherited

Record the list of KICAD_T types to consider for collection by the Inspect() function.

Parameters
aScanTypesA list of KICAD_Ts.

Definition at line 211 of file collector.h.

211{ m_scanTypes = aTypes; }

References COLLECTOR::m_scanTypes.

Referenced by Collect(), GERBER_COLLECTOR::Collect(), EE_COLLECTOR::Collect(), GENERAL_COLLECTOR(), and GERBER_COLLECTOR::GERBER_COLLECTOR().

◆ Transfer() [1/2]

void COLLECTOR::Transfer ( EDA_ITEM aItem)
inlineinherited

Move aItem (if exists in the collector) to the backup list.

Parameters
aItemthe item to be moved.

Definition at line 162 of file collector.h.

163 {
164 for( size_t i = 0; i < m_list.size(); i++ )
165 {
166 if( m_list[i] == aItem )
167 {
168 m_list.erase( m_list.begin() + i );
169 m_backupList.push_back( aItem );
170 return;
171 }
172 }
173 }

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

◆ Transfer() [2/2]

void COLLECTOR::Transfer ( int  aIndex)
inlineinherited

Move the item at aIndex (first position is 0) to the backup list.

Parameters
aIndexThe index into the list.

Definition at line 151 of file collector.h.

152 {
153 m_backupList.push_back( m_list[aIndex] );
154 m_list.erase( m_list.begin() + aIndex );
155 }

References COLLECTOR::m_backupList, and COLLECTOR::m_list.

Referenced by PL_SELECTION_TOOL::guessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), and PCB_SELECTION_TOOL::GuessSelectionCandidates().

Member Data Documentation

◆ AllBoardItems

◆ BoardLevelItems

const std::vector< KICAD_T > GENERAL_COLLECTOR::BoardLevelItems
static

◆ Dimensions

const std::vector< KICAD_T > GENERAL_COLLECTOR::Dimensions
static

◆ DraggableItems

const std::vector< KICAD_T > GENERAL_COLLECTOR::DraggableItems
static
Initial value:

A scan list for items that can be dragged.

Definition at line 270 of file collectors.h.

Referenced by ROUTER_TOOL::CanInlineDrag(), and EDIT_TOOL::Init().

◆ FootprintItems

◆ Footprints

const std::vector< KICAD_T > GENERAL_COLLECTOR::Footprints
static
Initial value:

A scan list for only FOOTPRINTs.

Definition at line 240 of file collectors.h.

◆ LockableItems

const std::vector< KICAD_T > GENERAL_COLLECTOR::LockableItems
static
Initial value:

A scan list for TRACKs, VIAs, FOOTPRINTs.

Definition at line 260 of file collectors.h.

◆ m_backupList

std::vector<EDA_ITEM*> COLLECTOR::m_backupList
protectedinherited

◆ m_Guide

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::m_Guide
protected

Determine which items are to be collected by Inspect().

Definition at line 217 of file collectors.h.

Referenced by GetGuide(), Inspect(), and SetGuide().

◆ m_inspector

INSPECTOR_FUNC COLLECTOR::m_inspector
protectedinherited

◆ m_list

◆ m_List2nd

std::vector<BOARD_ITEM*> GENERAL_COLLECTOR::m_List2nd
protected

A place to hold collected objects which don't match precisely the search criteria, but would be acceptable if nothing else is found.

"2nd" choice, which will be appended to the end of COLLECTOR's prime "list" at the end of the search.

Definition at line 212 of file collectors.h.

Referenced by Append2nd(), Collect(), and Empty2nd().

◆ m_MenuCancelled

bool COLLECTOR::m_MenuCancelled
inherited

◆ m_MenuTitle

wxString COLLECTOR::m_MenuTitle
inherited

Definition at line 236 of file collector.h.

Referenced by SELECTION_TOOL::doSelectionMenu().

◆ m_refPos

VECTOR2I COLLECTOR::m_refPos
protectedinherited

◆ m_scanTypes

std::vector<KICAD_T> COLLECTOR::m_scanTypes
protectedinherited

◆ m_Threshold

◆ PadsOrTracks

const std::vector< KICAD_T > GENERAL_COLLECTOR::PadsOrTracks
static
Initial value:

A scan list for PADs, TRACKs, or VIAs.

Definition at line 245 of file collectors.h.

◆ Tracks

const std::vector< KICAD_T > GENERAL_COLLECTOR::Tracks
static
Initial value:

A scan list for only TRACKs and ARCs.

Definition at line 255 of file collectors.h.

Referenced by BOARD::TracksInNet().

◆ Zones

const std::vector< KICAD_T > GENERAL_COLLECTOR::Zones
static
Initial value:

A scan list for zones outlines only.

Definition at line 229 of file collectors.h.


The documentation for this class was generated from the following files: