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 ()
 Constructor GENERALCOLLECTOR. More...
 
void Empty2nd ()
 
void Append2nd (BOARD_ITEM *item)
 
void SetGuide (const COLLECTORS_GUIDE *aGuide)
 Record which COLLECTORS_GUIDE to use. More...
 
const COLLECTORS_GUIDEGetGuide ()
 
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
 Function GetCount returns the number of objects in the list. More...
 
void Empty ()
 Function Empty sets the list to empty. More...
 
void Append (EDA_ITEM *item)
 Function Append adds an item to the end of the list. More...
 
void Remove (int aIndex)
 Function Remove removes the item at aIndex (first position is 0);. More...
 
void Remove (const EDA_ITEM *aItem)
 Function Remove removes the item aItem (if exists in the collector). More...
 
bool HasAdditionalItems ()
 Test if the collector has heuristic backup items. More...
 
void Combine ()
 Re-combines the backup list into the main list of the collector. More...
 
void Transfer (int aIndex)
 Moves the item at aIndex (first position is 0) to the backup list. More...
 
void Transfer (EDA_ITEM *aItem)
 Moves the item aItem (if exists in the collector) to the backup list. More...
 
EDA_ITEM *const * BasePtr () const
 Function BasePtr returns the address of the first element in the array. More...
 
bool HasItem (const EDA_ITEM *aItem) const
 Function HasItem tests if aItem has already been collected. More...
 
void SetScanTypes (const KICAD_T *scanTypes)
 Function SetScanTypes records 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)
 Function CountType counts 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 AllButZones []
 A scan list for all editable board items, except zones. 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 MODULE, such as D_PAD and TEXTEMODULE. More...
 
static const KICAD_T Modules []
 A scan list for only MODULEs. More...
 
static const KICAD_T PadsOrModules []
 A scan list for PADs or MODULEs. More...
 
static const KICAD_T PadsOrTracks []
 A scan list for PADs, TRACKs, or VIAs. More...
 
static const KICAD_T ModulesAndTheirItems []
 A scan list for MODULEs and their items (for Modedit) More...
 
static const KICAD_T ModuleItems []
 A scan list for primary module 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, MODULES. 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
 Determines 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 90 of file collector.h.

◆ ITER

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

Definition at line 89 of file collector.h.

Constructor & Destructor Documentation

◆ GENERAL_COLLECTOR()

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Constructor GENERALCOLLECTOR.

Definition at line 323 of file collectors.h.

324  {
325  m_Guide = NULL;
326  m_PrimaryLength = 0;
328  }
static const KICAD_T AllBoardItems[]
A scan list for all editable board items.
Definition: collectors.h:267
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
Definition: collector.h:247
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
#define NULL
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:254

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

Member Function Documentation

◆ Append()

◆ Append2nd()

void GENERAL_COLLECTOR::Append2nd ( BOARD_ITEM item)
inline

Definition at line 335 of file collectors.h.

336  {
337  m_List2nd.push_back( item );
338  }
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().

◆ BasePtr()

EDA_ITEM* const* COLLECTOR::BasePtr ( ) const
inlineinherited

Function BasePtr returns the address of the first element in the array.

Only call this if there is at least one element in the vector m_List, otherwise a C++ exception should get thrown.

Definition at line 217 of file collector.h.

218  {
219  return &m_List[0];
220  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

◆ begin() [1/2]

ITER COLLECTOR::begin ( )
inlineinherited

Definition at line 92 of file collector.h.

92 { return m_List.begin(); }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

◆ begin() [2/2]

CITER COLLECTOR::begin ( ) const
inlineinherited

Definition at line 94 of file collector.h.

94 { return m_List.cbegin(); }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

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 MODULE, 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 539 of file collectors.cpp.

541 {
542  Empty(); // empty the collection, primary criteria list
543  Empty2nd(); // empty the collection, secondary criteria list
544 
545  // remember guide, pass it to Inspect()
546  SetGuide( &aGuide );
547 
548  SetScanTypes( aScanList );
549 
550  // remember where the snapshot was taken from and pass refPos to
551  // the Inspect() function.
552  SetRefPos( aRefPos );
553 
554  aItem->Visit( m_inspector, NULL, m_ScanTypes );
555 
556  // record the length of the primary list before concatenating on to it.
557  m_PrimaryLength = m_List.size();
558 
559  // append 2nd list onto end of the first list
560  for( unsigned i = 0; i<m_List2nd.size(); ++i )
561  Append( m_List2nd[i] );
562 
563  Empty2nd();
564 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:110
virtual SEARCH_RESULT Visit(INSPECTOR inspector, void *testData, const KICAD_T scanTypes[])
Function Visit may be re-implemented for each derived class in order to handle all the types given by...
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
Definition: collector.h:247
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)
Function Append adds an item to the end of the list.
Definition: collector.h:120
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:345
INSPECTOR_FUNC m_inspector
Definition: collector.h:62
#define NULL
void SetRefPos(const wxPoint &aRefPos)
Definition: collector.h:252
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58
const KICAD_T * m_ScanTypes
Definition: collector.h:61

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 PCBNEW_CONTROL::DeleteItemCursor(), PAD_TOOL::EnumeratePads(), PCB_INSPECTION_TOOL::highlightNet(), and SELECTION_TOOL::selectPoint().

◆ Combine()

void COLLECTOR::Combine ( )
inlineinherited

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

Definition at line 164 of file collector.h.

165  {
166  std::copy( m_BackupList.begin(), m_BackupList.end(), std::back_inserter( m_List ) );
167  m_BackupList.clear();
168  }
std::vector< EDA_ITEM * > m_BackupList
Definition: collector.h:59
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_BackupList, and COLLECTOR::m_List.

Referenced by EE_SELECTION_TOOL::doSelectionMenu(), and SELECTION_TOOL::doSelectionMenu().

◆ CountType()

int COLLECTOR::CountType ( KICAD_T  aType)
inlineinherited

Function CountType counts the number of items matching aType.

Parameters
aTypetype we are interested in
Returns
number of occurences

Definition at line 262 of file collector.h.

263  {
264  int cnt = 0;
265  for( size_t i = 0; i < m_List.size(); i++ )
266  {
267  if( m_List[i]->Type() == aType )
268  cnt++;
269  }
270  return cnt;
271  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

Referenced by SELECTION_TOOL::GuessSelectionCandidates(), and ROUTER_TOOL::NeighboringSegmentFilter().

◆ Empty()

◆ Empty2nd()

void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 330 of file collectors.h.

331  {
332  m_List2nd.clear();
333  }
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 93 of file collector.h.

93 { return m_List.end(); }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

◆ end() [2/2]

CITER COLLECTOR::end ( ) const
inlineinherited

Definition at line 95 of file collector.h.

95 { return m_List.cend(); }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

◆ GetBoundingBox()

const EDA_RECT& COLLECTOR::GetBoundingBox ( ) const
inlineinherited

Definition at line 254 of file collector.h.

254 { return m_RefBox; }
EDA_RECT m_RefBox
Definition: collector.h:64

References COLLECTOR::m_RefBox.

◆ GetCount()

int COLLECTOR::GetCount ( ) const
inlineinherited

Function GetCount returns the number of objects in the list.

Definition at line 101 of file collector.h.

102  {
103  return (int) m_List.size();
104  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

Referenced by BuildBoardPolygonOutlines(), calcMaxArea(), connectedItemFilter(), MODULE::CoverageRatio(), SCH_EDIT_TOOL::DeleteItemCursor(), PCBNEW_CONTROL::DeleteItemCursor(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), PL_SELECTION_TOOL::doSelectionMenu(), EE_SELECTION_TOOL::doSelectionMenu(), SELECTION_TOOL::doSelectionMenu(), EditToolSelectionFilter(), PAD_TOOL::EnumeratePads(), SELECTION_TOOL::filterCollectedItems(), EDIT_TOOL::FootprintFilter(), DSN::SPECCTRA_DB::FromBOARD(), EE_SELECTION_TOOL::GetNode(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), GENDRILL_WRITER_BASE::getUniqueLayerPairs(), PL_SELECTION_TOOL::guessSelectionCandidates(), SELECTION_TOOL::GuessSelectionCandidates(), EE_SELECTION_TOOL::GuessSelectionCandidates(), PCB_INSPECTION_TOOL::highlightNet(), PCB_EDIT_FRAME::inferLegacyEdgeClearance(), EE_COLLECTOR::IsCorner(), DSN::SPECCTRA_DB::makeIMAGE(), ROUTER_TOOL::NeighboringSegmentFilter(), EE_COLLECTOR::operator[](), GERBER_COLLECTOR::operator[](), COLLECTOR::operator[](), PCB_COLLECTOR::operator[](), EDIT_TOOL::PadFilter(), SELECTION_TOOL::pickSmallestComponent(), PL_SELECTION_TOOL::SelectPoint(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), SELECTION_TOOL::selectPoint(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ GetGuide()

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::GetGuide ( )
inline

Definition at line 347 of file collectors.h.

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

References m_Guide.

Referenced by SELECTION_TOOL::GuessSelectionCandidates().

◆ GetPrimaryCount()

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

Definition at line 352 of file collectors.h.

352 { 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.

Referenced by SELECTION_TOOL::pickSmallestComponent().

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

157  {
158  return !m_BackupList.empty();
159  }
std::vector< EDA_ITEM * > m_BackupList
Definition: collector.h:59

References COLLECTOR::m_BackupList.

Referenced by EE_SELECTION_TOOL::doSelectionMenu(), and SELECTION_TOOL::doSelectionMenu().

◆ HasItem()

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

Function HasItem tests if aItem has already been collected.

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

Definition at line 229 of file collector.h.

230  {
231  for( size_t i = 0; i < m_List.size(); i++ )
232  {
233  if( m_List[i] == aItem )
234  return true;
235  }
236 
237  return false;
238  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

Referenced by EditToolSelectionFilter().

◆ 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.

Searches and collects 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 162 of file collectors.cpp.

163 {
164  BOARD_ITEM* item = (BOARD_ITEM*) testItem;
165  MODULE* module = nullptr;
166  D_PAD* pad = nullptr;
167  bool pad_through = false;
168  VIA* via = nullptr;
169  MARKER_PCB* marker = nullptr;
170  ZONE_CONTAINER* zone = nullptr;
171  DRAWSEGMENT* drawSegment = nullptr;
172 
173 #if 0 // debugging
174  static int breakhere = 0;
175 
176  switch( item->Type() )
177  {
178  case PCB_PAD_T:
179  {
180  MODULE* m = (MODULE*) item->GetParent();
181 
182  if( m->GetReference() == wxT( "Y2" ) )
183  {
184  breakhere++;
185  }
186  }
187  break;
188 
189  case PCB_VIA_T:
190  breakhere++;
191  break;
192 
193  case PCB_TRACE_T:
194  case PCB_ARC_T:
195  breakhere++;
196  break;
197 
198  case PCB_TEXT_T:
199  breakhere++;
200  break;
201 
202  case PCB_LINE_T:
203  breakhere++;
204  break;
205 
206  case PCB_DIMENSION_T:
207  breakhere++;
208  break;
209 
210  case PCB_MODULE_TEXT_T:
211  {
212  TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
213 
214  if( tm->GetText() == wxT( "10uH" ) )
215  {
216  breakhere++;
217  }
218  }
219  break;
220 
221  case PCB_MODULE_T:
222  {
223  MODULE* m = (MODULE*) item;
224 
225  if( m->GetReference() == wxT( "C98" ) )
226  {
227  breakhere++;
228  }
229  }
230  break;
231 
232  case PCB_MARKER_T:
233  breakhere++;
234  break;
235 
236  default:
237  breakhere++;
238  break;
239  }
240 
241 #endif
242 
243 
244  switch( item->Type() )
245  {
246  case PCB_PAD_T:
247  // there are pad specific visibility controls.
248  // Criterias to select a pad is:
249  // for smd pads: the module parent must be seen, and pads on the corresponding
250  // board side must be seen
251  // if pad is a thru hole, then it can be visible when its parent module is not.
252  // for through pads: pads on Front or Back board sides must be seen
253  pad = (D_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 module test,
259  // by leaving module==NULL, but having pad != null
260  pad_through = true;
261  }
262  else // smd, so use pads test after module test
263  {
264  module = static_cast<MODULE*>( 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<VIA*>( item );
271  break;
272 
273  case PCB_TRACE_T:
274  case PCB_ARC_T:
275  if( m_Guide->IgnoreTracks() )
276  goto exit;
277  break;
278 
280  module = static_cast<MODULE*>( item->GetParent() );
281 
282  // Fallthrough to get the zone as well
284 
285  case PCB_ZONE_AREA_T:
286  zone = static_cast<ZONE_CONTAINER*>( item );
287  break;
288 
289  case PCB_TEXT_T:
290  break;
291 
292  case PCB_LINE_T:
293  drawSegment = static_cast<DRAWSEGMENT*>( item );
294  break;
295 
296  case PCB_DIMENSION_T:
297  break;
298 
299  case PCB_TARGET_T:
300  break;
301 
302  case PCB_MODULE_TEXT_T:
303  {
304  TEXTE_MODULE *text = static_cast<TEXTE_MODULE*>( item );
305  if( m_Guide->IgnoreMTextsMarkedNoShow() && !text->IsVisible() )
306  goto exit;
307 
308  if( m_Guide->IgnoreMTextsOnBack() && IsBackLayer( text->GetLayer() ) )
309  goto exit;
310 
311  if( m_Guide->IgnoreMTextsOnFront() && IsFrontLayer( text->GetLayer() ) )
312  goto exit;
313 
314  /* The three text types have different criteria: reference
315  * and value have their own ignore flags; user text instead
316  * follows their layer visibility. Checking this here is
317  * simpler than later (when layer visibility is checked for
318  * other entities) */
319 
320  switch( text->GetType() )
321  {
323  if( m_Guide->IgnoreModulesRefs() )
324  goto exit;
325  break;
326 
328  if( m_Guide->IgnoreModulesVals() )
329  goto exit;
330  break;
331 
333  if( !m_Guide->IsLayerVisible( text->GetLayer() )
335  goto exit;
336  break;
337  }
338 
339  // Extract the module since it could be hidden
340  module = static_cast<MODULE*>( item->GetParent() );
341  }
342  break;
343 
344  case PCB_MODULE_EDGE_T:
345  drawSegment = static_cast<EDGE_MODULE*>( item );
346  break;
347 
348  case PCB_MODULE_T:
349  module = static_cast<MODULE*>( item );
350  break;
351 
352  case PCB_MARKER_T:
353  marker = static_cast<MARKER_PCB*>( item );
354  break;
355 
356  default:
357  break;
358  }
359 
360  // common tests:
361 
362  if( module ) // true from case PCB_PAD_T, PCB_MODULE_TEXT_T, or PCB_MODULE_T
363  {
364  if( m_Guide->IgnoreModulesOnBack() && (module->GetLayer() == B_Cu) )
365  goto exit;
366 
367  if( m_Guide->IgnoreModulesOnFront() && (module->GetLayer() == F_Cu) )
368  goto exit;
369  }
370 
371  // Pads are not sensitive to the layer visibility controls.
372  // They all have their own separate visibility controls
373  // skip them if not visible
374  if( pad )
375  {
376  if( m_Guide->IgnorePads() )
377  goto exit;
378 
379  if( ! pad_through )
380  {
381  if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
382  goto exit;
383 
384  if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
385  goto exit;
386  }
387  }
388 
389  if( marker )
390  {
391  // Markers are not sensitive to the layer
392  if( marker->HitTest( m_RefPos ) )
393  Append( item );
394 
395  goto exit;
396  }
397 
398  if( via )
399  {
400  auto type = via->GetViaType();
401 
402  if( ( m_Guide->IgnoreThroughVias() && type == VIATYPE::THROUGH )
404  || ( m_Guide->IgnoreMicroVias() && type == VIATYPE::MICROVIA ) )
405  {
406  goto exit;
407  }
408  }
409 
411  {
412  PCB_LAYER_ID layer = item->GetLayer();
413 
414  // Modules and their subcomponents: reference, value and pads are not sensitive
415  // to the layer visibility controls. They all have their own separate visibility
416  // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
417  // text in module *is* sensitive to layer visibility but that was already handled.
418 
419  if( via || module || pad || m_Guide->IsLayerVisible( layer )
421  {
422  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
423  {
424  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
425  {
426  int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
427 
428  if( zone )
429  {
430  bool testFill = !m_Guide->IgnoreZoneFills();
431 
432  if( zone->HitTestForCorner( m_RefPos, accuracy * 2 )
433  || zone->HitTestForEdge( m_RefPos, accuracy )
434  || ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) )
435  {
436  Append( item );
437  goto exit;
438  }
439  }
440  else if( item->Type() == PCB_MODULE_T )
441  {
442  if( module->HitTest( m_RefPos, accuracy )
443  && module->HitTestAccurate( m_RefPos, accuracy ) )
444  {
445  Append( item );
446  goto exit;
447  }
448  }
449  else if( drawSegment )
450  {
451  if( drawSegment->HitTest( m_RefPos, accuracy ) )
452  {
453  Append( item );
454  goto exit;
455  }
456  }
457  else
458  {
459  if( item->HitTest( m_RefPos, 0 ) )
460  {
461  Append( item );
462  goto exit;
463  }
464  }
465  }
466  }
467  }
468  }
469 
470  if( m_Guide->IncludeSecondary() )
471  {
472  // for now, "secondary" means "tolerate any layer". It has
473  // no effect on other criteria, since there is a separate "ignore" control for
474  // those in the COLLECTORS_GUIDE
475 
476  PCB_LAYER_ID layer = item->GetLayer();
477 
478  // Modules and their subcomponents: reference, value and pads are not sensitive
479  // to the layer visibility controls. They all have their own separate visibility
480  // controls for vias, GetLayer() has no meaning, but IsOnLayer() works fine. User
481  // text in module *is* sensitive to layer visibility but that was already handled.
482 
483  if( via || module || pad || zone || m_Guide->IsLayerVisible( layer )
485  {
486  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
487  {
488  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
489  {
490  int accuracy = KiROUND( 5 * m_Guide->OnePixelInIU() );
491 
492  if( zone )
493  {
494  bool testFill = !m_Guide->IgnoreZoneFills();
495 
496  if( zone->HitTestForCorner( m_RefPos, accuracy * 2 )
497  || zone->HitTestForEdge( m_RefPos, accuracy )
498  || ( testFill && zone->HitTestFilledArea( layer, m_RefPos ) ) )
499  {
500  Append2nd( item );
501  goto exit;
502  }
503  }
504  else if( item->Type() == PCB_MODULE_T )
505  {
506  if( module->HitTest( m_RefPos, accuracy )
507  && module->HitTestAccurate( m_RefPos, accuracy ) )
508  {
509  Append( item );
510  goto exit;
511  }
512  }
513  else if( drawSegment )
514  {
515  if( drawSegment->HitTest( m_RefPos, accuracy ) )
516  {
517  Append( item );
518  goto exit;
519  }
520  }
521  else
522  {
523  if( item->HitTest( m_RefPos, 0 ) )
524  {
525  Append( item );
526  goto exit;
527  }
528  }
529  }
530  }
531  }
532  }
533 
534 exit:
535  return SEARCH_RESULT::CONTINUE; // always when collecting
536 }
virtual bool IsLayerLocked(PCB_LAYER_ID layer) const =0
ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:61
virtual bool IgnoreBlindBuriedVias() const =0
#define KI_FALLTHROUGH
virtual bool IgnoreModulesOnFront() const =0
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
virtual double OnePixelInIU() const =0
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
bool IsVisible() const
Definition: eda_text.h:186
bool HitTestForCorner(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Function HitTestForCorner tests if the given wxPoint is near a corner.
Definition: class_zone.cpp:450
virtual bool IgnoreZoneFills() const =0
virtual bool IgnoreNonVisibleLayers() const =0
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:81
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:335
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
class ARC, an arc track segment on a copper layer
Definition: typeinfo.h:98
virtual PCB_LAYER_ID GetPreferredLayer() const =0
virtual bool IgnoreTracks() const =0
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual bool IgnoreMicroVias() const =0
virtual bool IgnoreModulesVals() const =0
virtual bool IgnorePreferredLayer() const =0
Provide wildcard behavior regarding the preferred layer.
class EDGE_MODULE, a footprint edge
Definition: typeinfo.h:94
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:338
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:96
const wxString GetReference() const
Function GetReference.
Definition: class_module.h:444
virtual bool IgnorePadsOnFront() const =0
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:120
virtual bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
Definition: base_struct.h:307
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_LAYER_ID
A quick note on layer IDs:
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
virtual bool IgnoreMTextsOnBack() const =0
TEXT_TYPE GetType() const
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:254
virtual bool IgnoreMTextsMarkedNoShow() const =0
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:82
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:100
virtual bool IgnoreThroughVias() const =0
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:101
virtual bool IgnoreModulesRefs() const =0
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:93
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a front layer.
bool HitTestAccurate(const wxPoint &aPosition, int aAccuracy=0) const
Tests if a point is inside the bounding polygon of the module.
virtual bool IsLocked() const
Function IsLocked.
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
virtual bool IgnorePads() const
Definition: collectors.h:152
VIATYPE GetViaType() const
Definition: class_track.h:378
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:68
bool HitTestFilledArea(PCB_LAYER_ID aLayer, const wxPoint &aRefPos, int aAccuracy=0) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: class_zone.cpp:536
bool HitTest(const wxPoint &aPosition, int aAccuracy=0) const override
Function HitTest tests if aPosition is contained within or on the bounding box of an item.
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
bool HitTestForEdge(const wxPoint &refPos, int aAccuracy, SHAPE_POLY_SET::VERTEX_INDEX &aCornerHit) const
Function HitTestForEdge tests if the given wxPoint is near a segment defined by 2 corners.
Definition: class_zone.cpp:464
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:97
virtual bool IgnorePadsOnBack() const =0
wxPoint m_RefPos
Definition: collector.h:63
virtual bool IgnoreLockedItems() const =0
class ZONE_CONTAINER, managed by a footprint
Definition: typeinfo.h:95
virtual bool IgnoreLockedLayers() const =0
bool IsOnLayer(PCB_LAYER_ID aLayer) const override
Function IsOnLayer tests to see if this object is on the given layer.
Definition: class_pad.h:507
virtual bool IgnoreModulesOnBack() const =0
virtual bool IgnoreMTextsOnFront() const =0
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:91
virtual bool IncludeSecondary() const =0
Determine if the secondary criteria or 2nd choice items should be included.
BOARD_ITEM_CONTAINER * GetParent() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
virtual const wxString & GetText() const
Return the string associated with the text object.
Definition: eda_text.h:127
KICAD_T Type() const
Function Type()
Definition: base_struct.h:193

References COLLECTOR::Append(), Append2nd(), B_Cu, BLIND_BURIED, CONTINUE, F_Cu, D_PAD::GetAttribute(), BOARD_ITEM::GetLayer(), BOARD_ITEM::GetParent(), COLLECTORS_GUIDE::GetPreferredLayer(), MODULE::GetReference(), EDA_TEXT::GetText(), TEXTE_MODULE::GetType(), VIA::GetViaType(), MARKER_PCB::HitTest(), DRAWSEGMENT::HitTest(), EDA_ITEM::HitTest(), MODULE::HitTest(), MODULE::HitTestAccurate(), ZONE_CONTAINER::HitTestFilledArea(), ZONE_CONTAINER::HitTestForCorner(), ZONE_CONTAINER::HitTestForEdge(), COLLECTORS_GUIDE::IgnoreBlindBuriedVias(), COLLECTORS_GUIDE::IgnoreLockedItems(), COLLECTORS_GUIDE::IgnoreLockedLayers(), COLLECTORS_GUIDE::IgnoreMicroVias(), COLLECTORS_GUIDE::IgnoreModulesOnBack(), COLLECTORS_GUIDE::IgnoreModulesOnFront(), COLLECTORS_GUIDE::IgnoreModulesRefs(), COLLECTORS_GUIDE::IgnoreModulesVals(), COLLECTORS_GUIDE::IgnoreMTextsMarkedNoShow(), COLLECTORS_GUIDE::IgnoreMTextsOnBack(), COLLECTORS_GUIDE::IgnoreMTextsOnFront(), 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(), D_PAD::IsOnLayer(), EDA_TEXT::IsVisible(), KI_FALLTHROUGH, KiROUND(), m_Guide, COLLECTOR::m_RefPos, MICROVIA, COLLECTORS_GUIDE::OnePixelInIU(), PAD_ATTRIB_CONN, PAD_ATTRIB_SMD, PCB_ARC_T, PCB_DIMENSION_T, PCB_LINE_T, PCB_MARKER_T, PCB_MODULE_EDGE_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_MODULE_ZONE_AREA_T, PCB_PAD_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, TEXTE_MODULE::TEXT_is_DIVERS, TEXTE_MODULE::TEXT_is_REFERENCE, TEXTE_MODULE::TEXT_is_VALUE, THROUGH, and EDA_ITEM::Type().

◆ 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
BOARD_ITEM* - or something derived from it, 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 NULL;
227  }
BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class,...
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:101
#define NULL
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::GetCount(), COLLECTOR::m_List, and NULL.

◆ Remove() [1/2]

void COLLECTOR::Remove ( int  aIndex)
inlineinherited

Function Remove removes the item at aIndex (first position is 0);.

Parameters
aIndexThe index into the list.

Definition at line 130 of file collector.h.

131  {
132  m_List.erase( m_List.begin() + aIndex );
133  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_List.

Referenced by connectedItemFilter(), PCBNEW_CONTROL::DeleteItemCursor(), EditToolSelectionFilter(), EDIT_TOOL::FootprintFilter(), PCB_INSPECTION_TOOL::highlightNet(), EDIT_TOOL::PadFilter(), GERBVIEW_SELECTION_TOOL::selectPoint(), EE_SELECTION_TOOL::SelectPoint(), and SELECTION_TOOL::selectPoint().

◆ Remove() [2/2]

void COLLECTOR::Remove ( const EDA_ITEM aItem)
inlineinherited

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

Parameters
aItemthe item to be removed.

Definition at line 140 of file collector.h.

141  {
142  for( size_t i = 0; i < m_List.size(); i++ )
143  {
144  if( m_List[i] == aItem )
145  {
146  m_List.erase( m_List.begin() + i);
147  return;
148  }
149  }
150  }
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

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

345 { m_Guide = aGuide; }
const COLLECTORS_GUIDE * m_Guide
Determines 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 252 of file collector.h.

252 { m_RefPos = aRefPos; }
wxPoint m_RefPos
Definition: collector.h:63

References COLLECTOR::m_RefPos.

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

◆ SetScanTypes()

void COLLECTOR::SetScanTypes ( const KICAD_T scanTypes)
inlineinherited

Function SetScanTypes records 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 247 of file collector.h.

248  {
249  m_ScanTypes = scanTypes;
250  }
const KICAD_T * m_ScanTypes
Definition: collector.h:61

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

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

Parameters
aIndexThe index into the list.

Definition at line 174 of file collector.h.

175  {
176  m_BackupList.push_back( m_List[aIndex] );
177  m_List.erase( m_List.begin() + aIndex );
178  }
std::vector< EDA_ITEM * > m_BackupList
Definition: collector.h:59
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_BackupList, and COLLECTOR::m_List.

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

◆ Transfer() [2/2]

void COLLECTOR::Transfer ( EDA_ITEM aItem)
inlineinherited

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

Parameters
aItemthe item to be moved.

Definition at line 184 of file collector.h.

185  {
186  for( size_t i = 0; i < m_List.size(); i++ )
187  {
188  if( m_List[i] == aItem )
189  {
190  m_List.erase( m_List.begin() + i );
191  m_BackupList.push_back( aItem );
192  return;
193  }
194  }
195  }
std::vector< EDA_ITEM * > m_BackupList
Definition: collector.h:59
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58

References COLLECTOR::m_BackupList, and COLLECTOR::m_List.

Member Data Documentation

◆ AllBoardItems

◆ AllButZones

const KICAD_T GENERAL_COLLECTOR::AllButZones
static
Initial value:

A scan list for all editable board items, except zones.

Definition at line 272 of file collectors.h.

◆ BoardLevelItems

const KICAD_T GENERAL_COLLECTOR::BoardLevelItems
static
Initial value:

A scan list for all primary board items, omitting items which are subordinate to a MODULE, such as D_PAD and TEXTEMODULE.

Definition at line 283 of file collectors.h.

Referenced by PCBNEW_CONTROL::DeleteItemCursor(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), and PANEL_SETUP_LAYERS::TransferDataFromWindow().

◆ LockableItems

const KICAD_T GENERAL_COLLECTOR::LockableItems
static
Initial value:

A scan list for TRACKS, VIAS, MODULES.

Definition at line 318 of file collectors.h.

Referenced by PCB_EDITOR_CONTROL::Init().

◆ m_BackupList

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

◆ m_Guide

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::m_Guide
protected

Determines 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 64 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

◆ ModuleItems

const KICAD_T GENERAL_COLLECTOR::ModuleItems
static

◆ Modules

const KICAD_T GENERAL_COLLECTOR::Modules
static
Initial value:

A scan list for only MODULEs.

Definition at line 288 of file collectors.h.

◆ ModulesAndTheirItems

const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems
static
Initial value:

A scan list for MODULEs and their items (for Modedit)

Definition at line 303 of file collectors.h.

◆ PadsOrModules

const KICAD_T GENERAL_COLLECTOR::PadsOrModules
static
Initial value:

A scan list for PADs or MODULEs.

Definition at line 293 of file collectors.h.

◆ PadsOrTracks

const KICAD_T GENERAL_COLLECTOR::PadsOrTracks
static
Initial value:

A scan list for PADs, TRACKs, or VIAs.

Definition at line 298 of file collectors.h.

Referenced by PCB_INSPECTION_TOOL::highlightNet().

◆ Tracks

const KICAD_T GENERAL_COLLECTOR::Tracks
static
Initial value:

A scan list for only TRACKS.

Definition at line 313 of file collectors.h.

Referenced by EDIT_TOOL::Init(), EDIT_TOOL::Properties(), BOARD::TracksInNet(), and SELECT_MENU::update().

◆ Zones

const KICAD_T GENERAL_COLLECTOR::Zones
static
Initial value:

A scan list for zones outlines only.

Definition at line 277 of file collectors.h.

Referenced by PCB_INSPECTION_TOOL::highlightNet(), and ZONE_CONTEXT_MENU::update().


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