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
 
int GetPrimaryCount ()
 
SEARCH_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 KICAD_T aScanList[], const wxPoint &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 KICAD_T *scanTypes)
 Record the list of KICAD_T types to consider for collection by the Inspect() function. More...
 
void SetRefPos (const wxPoint &aRefPos)
 
const EDA_RECTGetBoundingBox () const
 
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 KICAD_T AllBoardItems []
 A scan list for all editable board items. More...
 
static const KICAD_T Zones []
 A scan list for zones outlines only. More...
 
static const KICAD_T BoardLevelItems []
 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 KICAD_T Footprints []
 A scan list for only FOOTPRINTs. More...
 
static const KICAD_T PadsOrTracks []
 A scan list for PADs, TRACKs, or VIAs. More...
 
static const KICAD_T FootprintItems []
 A scan list for primary footprint items. More...
 
static const KICAD_T Tracks []
 A scan list for only TRACKs. More...
 
static const KICAD_T LockableItems []
 A scan list for TRACKs, VIAs, FOOTPRINTs. More...
 
static const KICAD_T Dimensions []
 A scan list for dimensions. More...
 
static const KICAD_T DraggableItems []
 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...
 
int m_PrimaryLength
 The number of items that were originally in the primary list before the m_List2nd was concatenated onto the end of it. More...
 
std::vector< EDA_ITEM * > m_list
 
std::vector< EDA_ITEM * > m_backupList
 
const KICAD_Tm_scanTypes
 
INSPECTOR_FUNC m_inspector
 
wxPoint m_refPos
 
EDA_RECT m_refBox
 

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 240 of file collectors.h.

Member Typedef Documentation

◆ CITER

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

Definition at line 77 of file collector.h.

◆ ITER

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

Definition at line 76 of file collector.h.

Constructor & Destructor Documentation

◆ GENERAL_COLLECTOR()

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Definition at line 315 of file collectors.h.

316  {
317  m_Guide = nullptr;
318  m_PrimaryLength = 0;
320  }
static const KICAD_T AllBoardItems[]
A scan list for all editable board items.
Definition: collectors.h:267
void SetScanTypes(const KICAD_T *scanTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
Definition: collector.h:220
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:260
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:254

References AllBoardItems, m_Guide, m_PrimaryLength, and COLLECTOR::SetScanTypes().

Member Function Documentation

◆ Append()

◆ Append2nd()

void GENERAL_COLLECTOR::Append2nd ( BOARD_ITEM item)
inline

Definition at line 327 of file collectors.h.

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

References m_List2nd.

Referenced by Inspect().

◆ begin() [1/2]

ITER COLLECTOR::begin ( )
inlineinherited

Definition at line 79 of file collector.h.

79 { return m_list.begin(); }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

◆ begin() [2/2]

CITER COLLECTOR::begin ( ) const
inlineinherited

Definition at line 81 of file collector.h.

81 { return m_list.cbegin(); }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

◆ Collect()

void GENERAL_COLLECTOR::Collect ( BOARD_ITEM aItem,
const KICAD_T  aScanList[],
const wxPoint &  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 with a terminating EOT, 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 567 of file collectors.cpp.

569 {
570  Empty(); // empty the collection, primary criteria list
571  Empty2nd(); // empty the collection, secondary criteria list
572 
573  // remember guide, pass it to Inspect()
574  SetGuide( &aGuide );
575 
576  SetScanTypes( aScanList );
577 
578  // remember where the snapshot was taken from and pass refPos to
579  // the Inspect() function.
580  SetRefPos( aRefPos );
581 
582  aItem->Visit( m_inspector, NULL, m_scanTypes );
583 
584  // record the length of the primary list before concatenating on to it.
585  m_PrimaryLength = m_list.size();
586 
587  // append 2nd list onto end of the first list
588  for( unsigned i = 0; i<m_List2nd.size(); ++i )
589  Append( m_List2nd[i] );
590 
591  Empty2nd();
592 }
void Empty()
Clear the list.
Definition: collector.h:95
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: eda_item.cpp:93
void SetScanTypes(const KICAD_T *scanTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
Definition: collector.h:220
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don't match precisely the search criteria,...
Definition: collectors.h:249
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:260
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:337
INSPECTOR_FUNC m_inspector
Definition: collector.h:258
#define NULL
void SetRefPos(const wxPoint &aRefPos)
Definition: collector.h:225
const KICAD_T * m_scanTypes
Definition: collector.h:257

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

Referenced by PCB_CONTROL::DeleteItemCursor(), PAD_TOOL::EnumeratePads(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_SELECTION_TOOL::selectionContains(), 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 148 of file collector.h.

149  {
150  std::copy( m_backupList.begin(), m_backupList.end(), std::back_inserter( m_list ) );
151  m_backupList.clear();
152  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
std::vector< EDA_ITEM * > m_backupList
Definition: collector.h:255

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

Referenced by EE_SELECTION_TOOL::doSelectionMenu(), and PCB_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 235 of file collector.h.

236  {
237  int cnt = 0;
238 
239  for( size_t i = 0; i < m_list.size(); i++ )
240  {
241  if( m_list[i]->Type() == aType )
242  cnt++;
243  }
244 
245  return cnt;
246  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

Referenced by ROUTER_TOOL::NeighboringSegmentFilter().

◆ Empty()

◆ Empty2nd()

void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 322 of file collectors.h.

323  {
324  m_List2nd.clear();
325  }
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don't match precisely the search criteria,...
Definition: collectors.h:249

References m_List2nd.

Referenced by Collect().

◆ end() [1/2]

ITER COLLECTOR::end ( )
inlineinherited

Definition at line 80 of file collector.h.

80 { return m_list.end(); }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

◆ end() [2/2]

CITER COLLECTOR::end ( ) const
inlineinherited

Definition at line 82 of file collector.h.

82 { return m_list.cend(); }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

◆ GetBoundingBox()

const EDA_RECT& COLLECTOR::GetBoundingBox ( ) const
inlineinherited

Definition at line 227 of file collector.h.

227 { return m_refBox; }
EDA_RECT m_refBox
Definition: collector.h:260

References COLLECTOR::m_refBox.

◆ GetCount()

int COLLECTOR::GetCount ( ) const
inlineinherited

Return the number of objects in the list.

Definition at line 87 of file collector.h.

88  {
89  return (int) m_list.size();
90  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

Referenced by BuildBoardPolygonOutlines(), BuildFootprintPolygonOutlines(), EDIT_TOOL::ChangeTrackWidth(), EE_SELECTION_TOOL::CollectHits(), connectedItemFilter(), EDIT_TOOL::copyToClipboard(), FOOTPRINT::CoverageRatio(), SCH_EDIT_TOOL::DeleteItemCursor(), PCB_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), ALIGN_DISTRIBUTE_TOOL::DistributeHorizontally(), ALIGN_DISTRIBUTE_TOOL::DistributeVertically(), EDIT_TOOL::doMoveSelection(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), PCB_SELECTION_TOOL::doSelectionMenu(), EDIT_TOOL::Drag(), EDIT_TOOL::Duplicate(), PAD_TOOL::EnumeratePads(), EDIT_TOOL::FilletTracks(), PCB_SELECTION_TOOL::FilterCollectedItems(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), EDIT_TOOL::FootprintFilter(), DSN::SPECCTRA_DB::FromBOARD(), 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(), PCB_SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), BOARD_INSPECTION_TOOL::highlightNet(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), EE_COLLECTOR::IsCorner(), CONVERT_TOOL::LinesToPoly(), EE_SELECTION_TOOL::Main(), DSN::SPECCTRA_DB::makeIMAGE(), EDIT_TOOL::MoveExact(), EE_SELECTION_TOOL::narrowSelection(), ROUTER_TOOL::NeighboringSegmentFilter(), EE_COLLECTOR::operator[](), GERBER_COLLECTOR::operator[](), COLLECTOR::operator[](), PCB_COLLECTOR::operator[](), EDIT_TOOL::PadFilter(), CONVERT_TOOL::PolyToLines(), POSITION_RELATIVE_TOOL::PositionRelative(), CONVERT_TOOL::SegmentToArc(), PCB_SELECTION_TOOL::selectionContains(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::selectPoint(), PCB_SELECTION_TOOL::selectPoint(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ GetGuide()

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::GetGuide ( ) const
inline

Definition at line 339 of file collectors.h.

339 { return m_Guide; }
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:254

References m_Guide.

Referenced by FOOTPRINT::CoverageRatio(), FOOTPRINT::GetCoverageArea(), and PCB_SELECTION_TOOL::GuessSelectionCandidates().

◆ GetPrimaryCount()

int GENERAL_COLLECTOR::GetPrimaryCount ( )
inline
Returns
The number of items which met the primary search criteria

Definition at line 344 of file collectors.h.

344 { return m_PrimaryLength; }
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:260

References m_PrimaryLength.

◆ 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 140 of file collector.h.

141  {
142  return !m_backupList.empty();
143  }
std::vector< EDA_ITEM * > m_backupList
Definition: collector.h:255

References COLLECTOR::m_backupList.

Referenced by EE_SELECTION_TOOL::doSelectionMenu(), and PCB_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 203 of file collector.h.

204  {
205  for( size_t i = 0; i < m_list.size(); i++ )
206  {
207  if( m_list[i] == aItem )
208  return true;
209  }
210 
211  return false;
212  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254

References COLLECTOR::m_list.

Referenced by EDIT_TOOL::copyToClipboard(), EDIT_TOOL::doMoveSelection(), EDIT_TOOL::Drag(), PCB_SELECTION_TOOL::FilterCollectorForHierarchy(), and POSITION_RELATIVE_TOOL::PositionRelative().

◆ Inspect()

SEARCH_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_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE;

Reimplemented from COLLECTOR.

Definition at line 157 of file collectors.cpp.

158 {
159  BOARD_ITEM* item = (BOARD_ITEM*) testItem;
160  FOOTPRINT* footprint = nullptr;
161  PCB_GROUP* group = nullptr;
162  PAD* pad = nullptr;
163  bool pad_through = false;
164  PCB_VIA* via = nullptr;
165  PCB_MARKER* marker = nullptr;
166  ZONE* zone = nullptr;
167  PCB_SHAPE* shape = nullptr;
168  PCB_DIMENSION_BASE* dimension = nullptr;
169 
170 #if 0 // debugging
171  static int breakhere = 0;
172 
173  switch( item->Type() )
174  {
175  case PCB_PAD_T:
176  {
177  FOOTPRINT* footprint = (FOOTPRINT*) item->GetParent();
178 
179  if( footprint->GetReference() == wxT( "Y2" ) )
180  breakhere++;
181  }
182  break;
183 
184  case PCB_VIA_T:
185  breakhere++;
186  break;
187 
188  case PCB_TRACE_T:
189  case PCB_ARC_T:
190  breakhere++;
191  break;
192 
193  case PCB_TEXT_T:
194  breakhere++;
195  break;
196 
197  case PCB_SHAPE_T:
198  breakhere++;
199  break;
200 
201  case PCB_DIM_ALIGNED_T:
202  breakhere++;
203  break;
204 
205  case PCB_FP_TEXT_T:
206  {
207  FP_TEXT* fpText = (FP_TEXT*) item;
208 
209  if( fpText->GetText() == wxT( "10uH" ) )
210  breakhere++;
211  }
212  break;
213 
214  case PCB_FOOTPRINT_T:
215  {
216  FOOTPRINT* footprint = (FOOTPRINT*) item;
217 
218  if( footprint->GetReference() == wxT( "C98" ) )
219  breakhere++;
220  }
221  break;
222 
223  case PCB_MARKER_T:
224  breakhere++;
225  break;
226 
227  default:
228  breakhere++;
229  break;
230  }
231 
232 #endif
233 
234 
235  switch( item->Type() )
236  {
237  case PCB_PAD_T:
238  // there are pad specific visibility controls.
239  // Criteria to select a pad is:
240  // for smd pads: the footprint parent must be visible, and pads on the corresponding
241  // board side must be visible
242  // if pad is a thru hole, then it can be visible when its parent footprint is not.
243  // for through pads: pads on Front or Back board sides must be visible
244  pad = static_cast<PAD*>( item );
245 
246  if( (pad->GetAttribute() != PAD_ATTRIB::SMD) &&
247  (pad->GetAttribute() != PAD_ATTRIB::CONN) ) // a hole is present, so multiple layers
248  {
249  // proceed to the common tests below, but without the parent footprint test,
250  // by leaving footprint==NULL, but having pad != null
251  pad_through = true;
252  }
253  else // smd, so use pads test after footprint test
254  {
255  footprint = static_cast<FOOTPRINT*>( item->GetParent() );
256  }
257 
258  break;
259 
260  case PCB_VIA_T: // vias are on many layers, so layer test is specific
261  via = static_cast<PCB_VIA*>( item );
262  break;
263 
264  case PCB_TRACE_T:
265  case PCB_ARC_T:
266  if( m_Guide->IgnoreTracks() )
267  goto exit;
268  break;
269 
270  case PCB_FP_ZONE_T:
271  footprint = static_cast<FOOTPRINT*>( item->GetParent() );
272 
273  // Fallthrough to get the zone as well
275 
276  case PCB_ZONE_T:
277  zone = static_cast<ZONE*>( item );
278  break;
279 
280  case PCB_TEXT_T:
281  break;
282 
283  case PCB_SHAPE_T:
284  shape = static_cast<PCB_SHAPE*>( item );
285  break;
286 
287  case PCB_DIM_ALIGNED_T:
288  case PCB_DIM_CENTER_T:
290  case PCB_DIM_LEADER_T:
291  dimension = static_cast<PCB_DIMENSION_BASE*>( item );
292  break;
293 
294  case PCB_TARGET_T:
295  break;
296 
297  case PCB_FP_TEXT_T:
298  {
299  FP_TEXT *text = static_cast<FP_TEXT*>( item );
300  if( m_Guide->IgnoreHiddenFPText() && !text->IsVisible() )
301  goto exit;
302 
303  if( m_Guide->IgnoreFPTextOnBack() && IsBackLayer( text->GetLayer() ) )
304  goto exit;
305 
306  if( m_Guide->IgnoreFPTextOnFront() && IsFrontLayer( text->GetLayer() ) )
307  goto exit;
308 
309  /* The three text types have different criteria: reference
310  * and value have their own ignore flags; user text instead
311  * follows their layer visibility. Checking this here is
312  * simpler than later (when layer visibility is checked for
313  * other entities) */
314 
315  switch( text->GetType() )
316  {
318  if( m_Guide->IgnoreFPReferences() )
319  goto exit;
320  break;
321 
323  if( m_Guide->IgnoreFPValues() )
324  goto exit;
325  break;
326 
328  if( !m_Guide->IsLayerVisible( text->GetLayer() )
330  goto exit;
331  break;
332  }
333 
334  // Extract the footprint since it could be hidden
335  footprint = static_cast<FOOTPRINT*>( item->GetParent() );
336  }
337  break;
338 
339  case PCB_FP_SHAPE_T:
340  shape = static_cast<FP_SHAPE*>( item );
341  break;
342 
343  case PCB_FOOTPRINT_T:
344  footprint = static_cast<FOOTPRINT*>( item );
345  break;
346 
347  case PCB_GROUP_T:
348  group = static_cast<PCB_GROUP*>( item );
349  break;
350 
351  case PCB_MARKER_T:
352  marker = static_cast<PCB_MARKER*>( item );
353  break;
354 
355  default:
356  break;
357  }
358 
359  // common tests:
360 
361  if( footprint ) // true from case PCB_PAD_T, PCB_FP_TEXT_T, or PCB_FOOTPRINT_T
362  {
363  if( m_Guide->IgnoreFootprintsOnBack() && ( footprint->GetLayer() == B_Cu) )
364  goto exit;
365 
366  if( m_Guide->IgnoreFootprintsOnFront() && ( footprint->GetLayer() == F_Cu) )
367  goto exit;
368  }
369 
370  // Pads are not sensitive to the layer visibility controls.
371  // They all have their own separate visibility controls
372  // skip them if not visible
373  if( pad )
374  {
375  if( m_Guide->IgnorePads() )
376  goto exit;
377 
378  if( ! pad_through )
379  {
380  if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
381  goto exit;
382 
383  if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
384  goto exit;
385  }
386  }
387 
388  if( marker )
389  {
390  // Markers are not sensitive to the layer
391  if( marker->HitTest( m_refPos ) )
392  Append( item );
393 
394  goto exit;
395  }
396 
397  if( group )
398  {
399  // Groups are not sensitive to the layer ... ?
400  if( group->HitTest( m_refPos ) )
401  Append( item );
402 
403  goto exit;
404  }
405 
406  if( via )
407  {
408  auto type = via->GetViaType();
409 
410  if( ( m_Guide->IgnoreThroughVias() && type == VIATYPE::THROUGH )
412  || ( m_Guide->IgnoreMicroVias() && type == VIATYPE::MICROVIA ) )
413  {
414  goto exit;
415  }
416  }
417 
419  {
420  PCB_LAYER_ID layer = item->GetLayer();
421 
422  // footprints and their subcomponents: reference, value and pads are not sensitive
423  // to the layer visibility controls. They all have their own separate visibility
424  // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
425  // text in a footprint *is* sensitive to layer visibility but that was already handled.
426 
427  if( via || footprint || pad || m_Guide->IsLayerVisible( layer )
429  {
430  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
431  {
432  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
433  {
434  int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
435 
436  if( zone )
437  {
438  bool testFill = !m_Guide->IgnoreZoneFills();
439 
440  if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
441  || zone->HitTestForEdge( m_refPos, accuracy )
442  || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) )
443  {
444  Append( item );
445  goto exit;
446  }
447  }
448  else if( item->Type() == PCB_FOOTPRINT_T )
449  {
450  if( footprint->HitTest( m_refPos, accuracy )
451  && footprint->HitTestAccurate( m_refPos, accuracy ) )
452  {
453  Append( item );
454  goto exit;
455  }
456  }
457  else if( shape )
458  {
459  if( shape->HitTest( m_refPos, accuracy ) )
460  {
461  Append( shape );
462  goto exit;
463  }
464  }
465  else if( dimension )
466  {
467  // Dimensions feel particularly hard to select, probably due to their
468  // noisy shape making it feel like they should have a larger boundary.
469  if( dimension->HitTest( m_refPos, KiROUND( accuracy * 1.5 ) ) )
470  {
471  Append( dimension );
472  goto exit;
473  }
474  }
475  else
476  {
477  if( item->HitTest( m_refPos, accuracy ) )
478  {
479  Append( item );
480  goto exit;
481  }
482  }
483  }
484  }
485  }
486  }
487 
488  if( m_Guide->IncludeSecondary() )
489  {
490  // for now, "secondary" means "tolerate any layer". It has
491  // no effect on other criteria, since there is a separate "ignore" control for
492  // those in the COLLECTORS_GUIDE
493 
494  PCB_LAYER_ID layer = item->GetLayer();
495 
496  // footprints and their subcomponents: reference, value and pads are not sensitive
497  // to the layer visibility controls. They all have their own separate visibility
498  // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
499  // text in a footprint *is* sensitive to layer visibility but that was already handled.
500 
501  if( via || footprint || pad || zone || m_Guide->IsLayerVisible( layer )
503  {
504  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
505  {
506  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
507  {
508  int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
509 
510  if( zone )
511  {
512  bool testFill = !m_Guide->IgnoreZoneFills();
513 
514  if( zone->HitTestForCorner( m_refPos, accuracy * 2 )
515  || zone->HitTestForEdge( m_refPos, accuracy )
516  || ( testFill && zone->HitTestFilledArea( layer, m_refPos ) ) )
517  {
518  Append2nd( item );
519  goto exit;
520  }
521  }
522  else if( item->Type() == PCB_FOOTPRINT_T )
523  {
524  if( footprint->HitTest( m_refPos, accuracy )
525  && footprint->HitTestAccurate( m_refPos, accuracy ) )
526  {
527  Append2nd( item );
528  goto exit;
529  }
530  }
531  else if( shape )
532  {
533  if( shape->HitTest( m_refPos, accuracy ) )
534  {
535  Append2nd( shape );
536  goto exit;
537  }
538  }
539  else if( dimension )
540  {
541  // Dimensions feels particularly hard to select, probably due to their
542  // noisy shape making it feel like they should have a larger boundary.
543  if( dimension->HitTest( m_refPos, KiROUND( accuracy * 1.5 ) ) )
544  {
545  Append2nd( dimension );
546  goto exit;
547  }
548  }
549  else
550  {
551  if( item->HitTest( m_refPos, 0 ) )
552  {
553  Append2nd( item );
554  goto exit;
555  }
556  }
557  }
558  }
559  }
560  }
561 
562 exit:
563  return SEARCH_RESULT::CONTINUE; // always when collecting
564 }
virtual bool IsLayerLocked(PCB_LAYER_ID layer) const =0
virtual bool IgnoreBlindBuriedVias() const =0
class PCB_DIM_ALIGNED, a linear dimension (graphic item)
Definition: typeinfo.h:100
class PCB_DIM_LEADER, a leader dimension (graphic item)
Definition: typeinfo.h:101
class FP_TEXT, text in a footprint
Definition: typeinfo.h:92
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
class PCB_GROUP, a set of BOARD_ITEMs
Definition: typeinfo.h:108
A set of BOARD_ITEMs (i.e., without duplicates).
Definition: pcb_group.h:50
virtual double OnePixelInIU() const =0
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
class PCB_DIM_CENTER, a center point marking (graphic item)
Definition: typeinfo.h:102
virtual bool IgnoreFootprintsOnBack() const =0
Like smd, does not appear on the solder paste layer (default)
virtual bool IgnoreZoneFills() const =0
Smd pad, appears on the solder paste layer (default)
virtual bool IgnoreNonVisibleLayers() const =0
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:327
class PCB_TEXT, text on a layer
Definition: typeinfo.h:91
class PCB_ARC, an arc track segment on a copper layer
Definition: typeinfo.h:97
virtual PCB_LAYER_ID GetPreferredLayer() const =0
virtual bool IgnoreFPTextOnFront() const =0
virtual bool IgnoreTracks() const =0
virtual bool IgnoreFootprintsOnFront() const =0
class FP_SHAPE, a footprint edge
Definition: typeinfo.h:93
class PAD, a pad in a footprint
Definition: typeinfo.h:89
#define KI_FALLTHROUGH
The KI_FALLTHROUGH macro is to be used when switch statement cases should purposely fallthrough from ...
Definition: macros.h:83
Abstract dimension API.
Definition: pcb_dimension.h:95
virtual bool IgnoreMicroVias() const =0
virtual bool IgnoreHiddenFPText() const =0
virtual bool IgnorePreferredLayer() const =0
Provide wildcard behavior regarding the preferred layer.
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy=0) const
Test if the given wxPoint is within the bounds of a filled area of this zone.
Definition: zone.cpp:506
bool HitTestForCorner(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a corner.
Definition: zone.cpp:425
class PCB_TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
virtual bool IgnorePadsOnFront() const =0
void Append(EDA_ITEM *item)
Add an item to the end of the list.
Definition: collector.h:105
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Test if aPosition is contained within or on the bounding box of an item.
Definition: eda_item.h:225
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_shape.cpp:653
PCB_LAYER_ID
A quick note on layer IDs:
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Test to see if this object is on the given layer.
Definition: board_item.h:229
wxPoint m_refPos
Definition: collector.h:259
const wxString & GetReference() const
Definition: footprint.h:421
Handle a list of polygons defining a copper zone.
Definition: zone.h:57
class ZONE, a copper pour area
Definition: typeinfo.h:105
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:254
virtual bool IgnoreThroughVias() const =0
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:104
class FOOTPRINT, a footprint
Definition: typeinfo.h:88
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
virtual bool IgnoreFPTextOnBack() const =0
virtual bool IsLocked() const
Definition: board_item.h:247
class PCB_MARKER, a marker used to show something
Definition: typeinfo.h:98
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Test if the given wxPoint is near a segment defined by 2 corners.
Definition: zone.cpp:439
virtual bool IgnorePads() const
Definition: collectors.h:152
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: pcb_marker.h:75
class ZONE, managed by a footprint
Definition: typeinfo.h:94
virtual bool IgnoreFPValues() const =0
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:70
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
virtual bool IgnoreFPReferences() const =0
class PCB_DIM_ORTHOGONAL, a linear dimension constrained to x/y
Definition: typeinfo.h:103
class PCB_VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual bool IgnorePadsOnBack() const =0
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Test if aPosition is contained within or on the bounding box of an item.
Definition: footprint.cpp:908
virtual bool IgnoreLockedItems() const =0
virtual bool IgnoreLockedLayers() const =0
Definition: pad.h:57
virtual bool IncludeSecondary() const =0
Determine if the secondary criteria or 2nd choice items should be included.
BOARD_ITEM_CONTAINER * GetParent() const
Definition: board_item.h:166
class PCB_SHAPE, a segment not on copper layers
Definition: typeinfo.h:90
virtual PCB_LAYER_ID GetLayer() const
Return the primary layer this item is on.
Definition: board_item.h:171
bool HitTestAccurate(const wxPoint &aPosition, int aAccuracy=0) const
Test if a point is inside the bounding polygon of the footprint.
Definition: footprint.cpp:915
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:133
bool HitTest(const wxPoint &aPosition, int aAccuracy) const override
Test if aPosition is contained within or on the bounding box of an item.
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:113

References COLLECTOR::Append(), Append2nd(), B_Cu, BLIND_BURIED, CONN, CONTINUE, exit, F_Cu, BOARD_ITEM::GetLayer(), BOARD_ITEM::GetParent(), COLLECTORS_GUIDE::GetPreferredLayer(), FOOTPRINT::GetReference(), EDA_TEXT::GetText(), group, PCB_MARKER::HitTest(), EDA_ITEM::HitTest(), PCB_DIMENSION_BASE::HitTest(), PCB_SHAPE::HitTest(), FOOTPRINT::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::IgnoreLockedLayers(), COLLECTORS_GUIDE::IgnoreMicroVias(), COLLECTORS_GUIDE::IgnoreNonVisibleLayers(), COLLECTORS_GUIDE::IgnorePads(), COLLECTORS_GUIDE::IgnorePadsOnBack(), COLLECTORS_GUIDE::IgnorePadsOnFront(), COLLECTORS_GUIDE::IgnorePreferredLayer(), COLLECTORS_GUIDE::IgnoreThroughVias(), COLLECTORS_GUIDE::IgnoreTracks(), COLLECTORS_GUIDE::IgnoreZoneFills(), COLLECTORS_GUIDE::IncludeSecondary(), IsBackLayer(), IsFrontLayer(), COLLECTORS_GUIDE::IsLayerLocked(), 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_FOOTPRINT_T, PCB_FP_SHAPE_T, PCB_FP_TEXT_T, PCB_FP_ZONE_T, PCB_GROUP_T, PCB_MARKER_T, PCB_PAD_T, PCB_SHAPE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_T, 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 221 of file collectors.h.

222  {
223  if( (unsigned)ndx < (unsigned)GetCount() )
224  return (BOARD_ITEM*) m_list[ ndx ];
225 
226  return nullptr;
227  }
A base class for any item which can be embedded within the BOARD container class, and therefore insta...
Definition: board_item.h:80
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
int GetCount() const
Return the number of objects in the list.
Definition: collector.h:87

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

◆ Remove() [1/2]

◆ Remove() [2/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 125 of file collector.h.

126  {
127  m_list.erase( std::remove_if( m_list.begin(), m_list.end(),
128  [&aItem]( const EDA_ITEM* aCandidate )
129  {
130  return aCandidate == aItem;
131  } ),
132  m_list.end() );
133  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:100

References COLLECTOR::m_list.

◆ 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 337 of file collectors.h.

337 { m_Guide = aGuide; }
const COLLECTORS_GUIDE * m_Guide
Determine which items are to be collected by Inspect().
Definition: collectors.h:254

References m_Guide.

Referenced by Collect().

◆ SetRefPos()

void COLLECTOR::SetRefPos ( const wxPoint &  aRefPos)
inlineinherited

Definition at line 225 of file collector.h.

225 { m_refPos = aRefPos; }
wxPoint m_refPos
Definition: collector.h:259

References COLLECTOR::m_refPos.

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

◆ SetScanTypes()

void COLLECTOR::SetScanTypes ( const KICAD_T scanTypes)
inlineinherited

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

Parameters
scanTypesAn array of KICAD_T, terminated by EOT. No copy is is made of this array (so cannot come from caller's stack).

Definition at line 220 of file collector.h.

221  {
222  m_scanTypes = scanTypes;
223  }
const KICAD_T * m_scanTypes
Definition: collector.h:257

References COLLECTOR::m_scanTypes.

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

◆ Transfer() [1/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 159 of file collector.h.

160  {
161  m_backupList.push_back( m_list[aIndex] );
162  m_list.erase( m_list.begin() + aIndex );
163  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
std::vector< EDA_ITEM * > m_backupList
Definition: collector.h:255

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

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

◆ Transfer() [2/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 170 of file collector.h.

171  {
172  for( size_t i = 0; i < m_list.size(); i++ )
173  {
174  if( m_list[i] == aItem )
175  {
176  m_list.erase( m_list.begin() + i );
177  m_backupList.push_back( aItem );
178  return;
179  }
180  }
181  }
std::vector< EDA_ITEM * > m_list
Definition: collector.h:254
std::vector< EDA_ITEM * > m_backupList
Definition: collector.h:255

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

Member Data Documentation

◆ AllBoardItems

◆ BoardLevelItems

const KICAD_T GENERAL_COLLECTOR::BoardLevelItems
static

◆ Dimensions

const KICAD_T GENERAL_COLLECTOR::Dimensions
static
Initial value:

A scan list for dimensions.

Definition at line 308 of file collectors.h.

Referenced by PCB_BASE_EDIT_FRAME::unitsChangeRefresh().

◆ DraggableItems

const KICAD_T GENERAL_COLLECTOR::DraggableItems
static
Initial value:

A scan list for items that can be dragged.

Definition at line 313 of file collectors.h.

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

◆ FootprintItems

◆ Footprints

const KICAD_T GENERAL_COLLECTOR::Footprints
static
Initial value:

A scan list for only FOOTPRINTs.

Definition at line 283 of file collectors.h.

◆ LockableItems

const KICAD_T GENERAL_COLLECTOR::LockableItems
static
Initial value:

A scan list for TRACKs, VIAs, FOOTPRINTs.

Definition at line 303 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 254 of file collectors.h.

Referenced by GENERAL_COLLECTOR(), 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 249 of file collectors.h.

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

◆ m_MenuCancelled

bool COLLECTOR::m_MenuCancelled
inherited

◆ m_MenuTitle

◆ m_PrimaryLength

int GENERAL_COLLECTOR::m_PrimaryLength
protected

The number of items that were originally in the primary list before the m_List2nd was concatenated onto the end of it.

Definition at line 260 of file collectors.h.

Referenced by Collect(), GENERAL_COLLECTOR(), and GetPrimaryCount().

◆ m_refBox

EDA_RECT COLLECTOR::m_refBox
protectedinherited

Definition at line 260 of file collector.h.

Referenced by COLLECTOR::GetBoundingBox().

◆ m_refPos

wxPoint COLLECTOR::m_refPos
protectedinherited

◆ m_scanTypes

const KICAD_T* COLLECTOR::m_scanTypes
protectedinherited

◆ m_Threshold

◆ PadsOrTracks

const KICAD_T GENERAL_COLLECTOR::PadsOrTracks
static
Initial value:

A scan list for PADs, TRACKs, or VIAs.

Definition at line 288 of file collectors.h.

Referenced by BOARD_INSPECTION_TOOL::highlightNet().

◆ Tracks

const KICAD_T GENERAL_COLLECTOR::Tracks
static
Initial value:

A scan list for only TRACKs.

Definition at line 298 of file collectors.h.

Referenced by EDIT_TOOL::Init(), EDIT_TOOL::Properties(), PCB_EDIT_FRAME::setupUIConditions(), and BOARD::TracksInNet().

◆ Zones

const KICAD_T GENERAL_COLLECTOR::Zones
static
Initial value:

A scan list for zones outlines only.

Definition at line 272 of file collectors.h.

Referenced by BOARD_INSPECTION_TOOL::highlightNet(), and PCB_EDIT_FRAME::setupUIConditions().


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