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...
 
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
 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
 
bool IsValidIndex (int aIndex)
 Function IsValidIndex tests if aIndex is with the limits of the list of collected items. More...
 
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...
 
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 SetTimeNow ()
 
timestamp_t GetTime ()
 
void SetRefPos (const wxPoint &aRefPos)
 
const wxPointGetRefPos () const
 
void SetBoundingBox (const EDA_RECT &aRefBox)
 
const EDA_RECTGetBoundingBox () const
 
bool IsSimilarPointAndTime (const wxPoint &aRefPos)
 Function IsSimilarPointAndTime returns true if the given reference point is "similar" (defined here) to the internal reference point and the current time is within a few seconds of the internal m_TimeAtCollection. More...
 
int CountType (KICAD_T aType)
 Function CountType counts the number of items matching aType. More...
 

Static Public Attributes

static const KICAD_T AllBoardItems []
 A scan list for all editable board items, like PcbGeneralLocateAndDisplay() 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...
 
INSPECTOR_FUNC m_inspector
 a class common bridge into the polymorphic Inspect() More...
 
const KICAD_Tm_ScanTypes
 Which object types to scan. More...
 
std::vector< EDA_ITEM * > m_List
 A place to hold collected objects without taking ownership of their memory. More...
 
wxPoint m_RefPos
 A point to test against, and that was used to make the collection. More...
 
EDA_RECT m_RefBox
 A bounding box to test against, and that was used to make the collection. More...
 
timestamp_t m_TimeAtCollection
 The time at which the collection was made. More...
 

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

Member Typedef Documentation

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

Definition at line 90 of file collector.h.

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

Definition at line 89 of file collector.h.

Constructor & Destructor Documentation

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Constructor GENERALCOLLECTOR.

Definition at line 325 of file collectors.h.

326  {
327  m_Guide = NULL;
328  m_PrimaryLength = 0;
330  }
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:269
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:215
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:262
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:256

Member Function Documentation

void COLLECTOR::Append ( EDA_ITEM item)
inlineinherited

Function Append adds an item to the end of the list.

Parameters
itemAn EDA_ITEM* to add.

Definition at line 133 of file collector.h.

Referenced by Collect(), DIALOG_DRC_CONTROL::doSelectionMenu(), EditToolSelectionFilter(), SELECTION_TOOL::guessSelectionCandidates(), GERBER_COLLECTOR::Inspect(), LIB_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), Inspect(), SCH_FIND_COLLECTOR::Inspect(), SCH_TYPE_COLLECTOR::Inspect(), PCB_TYPE_COLLECTOR::Inspect(), PCB_LAYER_COLLECTOR::Inspect(), ROUTER_TOOL::NeighboringSegmentFilter(), and SELECTION_TOOL::RequestSelection().

134  {
135  m_List.push_back( item );
136  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
void GENERAL_COLLECTOR::Append2nd ( BOARD_ITEM item)
inline

Definition at line 337 of file collectors.h.

Referenced by Inspect().

338  {
339  m_List2nd.push_back( item );
340  }
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don&#39;t match precisely the search criteria, but would be acceptable if nothing else is found.
Definition: collectors.h:251
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 185 of file collector.h.

186  {
187  return &m_List[0];
188  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
ITER COLLECTOR::begin ( )
inlineinherited

Definition at line 92 of file collector.h.

Referenced by SELECTION_TOOL::RequestSelection().

92 { return m_List.begin(); }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
CITER COLLECTOR::begin ( ) const
inlineinherited

Definition at line 94 of file collector.h.

94 { return m_List.cbegin(); }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
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 468 of file collectors.cpp.

References COLLECTOR::Append(), COLLECTOR::Empty(), Empty2nd(), i, COLLECTOR::m_inspector, COLLECTOR::m_List, m_List2nd, m_PrimaryLength, COLLECTOR::m_ScanTypes, SetGuide(), COLLECTOR::SetRefPos(), COLLECTOR::SetScanTypes(), COLLECTOR::SetTimeNow(), and EDA_ITEM::Visit().

Referenced by MODULE_EDITOR_TOOLS::EnumeratePads(), highlightNet(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), PCB_EDIT_FRAME::SelectHighLight(), and SELECTION_TOOL::selectPoint().

470 {
471  Empty(); // empty the collection, primary criteria list
472  Empty2nd(); // empty the collection, secondary criteria list
473 
474  // remember guide, pass it to Inspect()
475  SetGuide( &aGuide );
476 
477  SetScanTypes( aScanList );
478 
479  // remember where the snapshot was taken from and pass refPos to
480  // the Inspect() function.
481  SetRefPos( aRefPos );
482 
483  aItem->Visit( m_inspector, NULL, m_ScanTypes );
484 
485  SetTimeNow(); // when snapshot was taken
486 
487  // record the length of the primary list before concatenating on to it.
488  m_PrimaryLength = m_List.size();
489 
490  // append 2nd list onto end of the first list
491  for( unsigned i = 0; i<m_List2nd.size(); ++i )
492  Append( m_List2nd[i] );
493 
494  Empty2nd();
495 }
void Empty()
Function Empty sets the list to empty.
Definition: collector.h:123
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:215
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don&#39;t match precisely the search criteria, but would be acceptable if nothing else is found.
Definition: collectors.h:251
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:262
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:133
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:347
INSPECTOR_FUNC m_inspector
a class common bridge into the polymorphic Inspect()
Definition: collector.h:59
void SetRefPos(const wxPoint &aRefPos)
Definition: collector.h:230
void SetTimeNow()
Definition: collector.h:220
size_t i
Definition: json11.cpp:597
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
const KICAD_T * m_ScanTypes
Which object types to scan.
Definition: collector.h:62
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 265 of file collector.h.

References i.

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

266  {
267  int cnt = 0;
268  for( size_t i = 0; i < m_List.size(); i++ )
269  {
270  if( m_List[i]->Type() == aType )
271  cnt++;
272  }
273  return cnt;
274  }
size_t i
Definition: json11.cpp:597
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
void COLLECTOR::Empty ( )
inlineinherited

Function Empty sets the list to empty.

Definition at line 123 of file collector.h.

Referenced by GERBER_COLLECTOR::Collect(), LIB_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), Collect(), SCH_FIND_COLLECTOR::Collect(), SCH_TYPE_COLLECTOR::Collect(), PCB_TYPE_COLLECTOR::Collect(), PCB_LAYER_COLLECTOR::Collect(), SCH_FIND_COLLECTOR::Empty(), MODULE_EDITOR_TOOLS::EnumeratePads(), SELECTION_TOOL::guessSelectionCandidates(), and ROUTER_TOOL::NeighboringSegmentFilter().

124  {
125  m_List.clear();
126  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 332 of file collectors.h.

Referenced by Collect().

333  {
334  m_List2nd.clear();
335  }
std::vector< BOARD_ITEM * > m_List2nd
A place to hold collected objects which don&#39;t match precisely the search criteria, but would be acceptable if nothing else is found.
Definition: collectors.h:251
ITER COLLECTOR::end ( )
inlineinherited

Definition at line 93 of file collector.h.

Referenced by SELECTION_TOOL::RequestSelection().

93 { return m_List.end(); }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
CITER COLLECTOR::end ( ) const
inlineinherited

Definition at line 95 of file collector.h.

95 { return m_List.cend(); }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
const EDA_RECT& COLLECTOR::GetBoundingBox ( ) const
inlineinherited

Definition at line 234 of file collector.h.

References COLLECTOR::m_RefBox.

234 { return m_RefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
Definition: collector.h:71
int COLLECTOR::GetCount ( ) const
inlineinherited

Function GetCount returns the number of objects in the list.

Definition at line 114 of file collector.h.

Referenced by AllAreModulesAndReturnSmallestIfSo(), SCH_EDIT_FRAME::AppendSchematic(), BuildBoardPolygonOutlines(), calcMaxArea(), connectedItemFilter(), connectedTrackFilter(), MODULE::CoverageRatio(), GERBVIEW_SELECTION_TOOL::disambiguationMenu(), SELECTION_TOOL::doSelectionMenu(), EditToolSelectionFilter(), MODULE_EDITOR_TOOLS::EnumeratePads(), EDIT_TOOL::FootprintFilter(), DSN::SPECCTRA_DB::FromBOARD(), SCH_FIND_COLLECTOR::GetItem(), PANEL_SETUP_LAYERS::getNonRemovableLayers(), PANEL_SETUP_LAYERS::getRemovedLayersWithItems(), SCH_FIND_COLLECTOR::GetText(), GENDRILL_WRITER_BASE::getUniqueLayerPairs(), SELECTION_TOOL::guessSelectionCandidates(), highlightNet(), SCH_EDIT_FRAME::importFile(), SCH_COLLECTOR::IsCorner(), LIB_EDIT_FRAME::locateItem(), SCH_EDIT_FRAME::LocateItem(), DSN::SPECCTRA_DB::makeIMAGE(), ROUTER_TOOL::NeighboringSegmentFilter(), SCH_EDIT_FRAME::OnFindSchematicItem(), LIB_EDIT_FRAME::OnSelectItem(), GERBER_COLLECTOR::operator[](), SCH_COLLECTOR::operator[](), COLLECTOR::operator[](), SCH_FIND_COLLECTOR::PassedEnd(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), SELECTION_TOOL::pickSmallestComponent(), SCH_COMPONENT::ResolveAll(), PCB_EDIT_FRAME::SelectHighLight(), GERBVIEW_SELECTION_TOOL::selectPoint(), SELECTION_TOOL::selectPoint(), PANEL_SETUP_LAYERS::TransferDataFromWindow(), SCH_COMPONENT::UpdateAllPinCaches(), and SCH_FIND_COLLECTOR::UpdateIndex().

115  {
116  return (int) m_List.size();
117  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
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.

Referenced by AllAreModulesAndReturnSmallestIfSo(), and SELECTION_TOOL::pickSmallestComponent().

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:262
const wxPoint& COLLECTOR::GetRefPos ( ) const
inlineinherited

Definition at line 231 of file collector.h.

References COLLECTOR::m_RefPos.

Referenced by PCB_EDIT_FRAME::OnRightClick().

231 { return m_RefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
Definition: collector.h:68
timestamp_t COLLECTOR::GetTime ( )
inlineinherited

Definition at line 225 of file collector.h.

References COLLECTOR::m_TimeAtCollection.

226  {
227  return m_TimeAtCollection;
228  }
timestamp_t m_TimeAtCollection
The time at which the collection was made.
Definition: collector.h:74
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 197 of file collector.h.

References i.

Referenced by EditToolSelectionFilter().

198  {
199  for( size_t i = 0; i < m_List.size(); i++ )
200  {
201  if( m_List[i] == aItem )
202  return true;
203  }
204 
205  return false;
206  }
size_t i
Definition: json11.cpp:597
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
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 that the old function PcbGeneralLocateAndDisplay() would find, except that it keeps all that it finds and does not do any displaying.

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;

Implements COLLECTOR.

Definition at line 151 of file collectors.cpp.

References COLLECTOR::Append(), Append2nd(), B_Cu, 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(), BOARD_ITEM::HitTest(), MODULE::HitTestAccurate(), ZONE_CONTAINER::HitTestFilledArea(), 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(), m_Guide, COLLECTOR::m_RefPos, PAD_ATTRIB_CONN, PAD_ATTRIB_SMD, PCB_DIMENSION_T, PCB_LINE_T, PCB_MARKER_T, PCB_MODULE_T, PCB_MODULE_TEXT_T, PCB_PAD_T, PCB_SEGZONE_T, PCB_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, SEARCH_CONTINUE, TEXTE_MODULE::TEXT_is_DIVERS, TEXTE_MODULE::TEXT_is_REFERENCE, TEXTE_MODULE::TEXT_is_VALUE, EDA_ITEM::Type(), VIA_BLIND_BURIED, VIA_MICROVIA, and VIA_THROUGH.

152 {
153  BOARD_ITEM* item = (BOARD_ITEM*) testItem;
154  MODULE* module = NULL;
155  D_PAD* pad = NULL;
156  bool pad_through = false;
157  VIA* via = NULL;
158  MARKER_PCB* marker = NULL;
159  ZONE_CONTAINER* zone = NULL;
160 
161 #if 0 // debugging
162  static int breakhere = 0;
163 
164  switch( item->Type() )
165  {
166  case PCB_PAD_T:
167  {
168  MODULE* m = (MODULE*) item->GetParent();
169 
170  if( m->GetReference() == wxT( "Y2" ) )
171  {
172  breakhere++;
173  }
174  }
175  break;
176 
177  case PCB_VIA_T:
178  breakhere++;
179  break;
180 
181  case PCB_TRACE_T:
182  breakhere++;
183  break;
184 
185  case PCB_SEGZONE_T:
186  breakhere++;
187  break;
188 
189  case PCB_TEXT_T:
190  breakhere++;
191  break;
192 
193  case PCB_LINE_T:
194  breakhere++;
195  break;
196 
197  case PCB_DIMENSION_T:
198  breakhere++;
199  break;
200 
201  case PCB_MODULE_TEXT_T:
202  {
203  TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
204 
205  if( tm->GetText() == wxT( "10uH" ) )
206  {
207  breakhere++;
208  }
209  }
210  break;
211 
212  case PCB_MODULE_T:
213  {
214  MODULE* m = (MODULE*) item;
215 
216  if( m->GetReference() == wxT( "C98" ) )
217  {
218  breakhere++;
219  }
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  // Criterias to select a pad is:
240  // for smd pads: the module parent must be seen, and pads on the corresponding
241  // board side must be seen
242  // if pad is a thru hole, then it can be visible when its parent module is not.
243  // for through pads: pads on Front or Back board sides must be seen
244  pad = (D_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 module test,
250  // by leaving module==NULL, but having pad != null
251  pad_through = true;
252  }
253  else // smd, so use pads test after module test
254  {
255  module = static_cast<MODULE*>( 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<VIA*>( item );
262  break;
263 
264  case PCB_TRACE_T:
265  if( m_Guide->IgnoreTracks() )
266  goto exit;
267  break;
268 
269  case PCB_SEGZONE_T:
270  break;
271 
272  case PCB_ZONE_AREA_T:
273  zone = static_cast<ZONE_CONTAINER*>( item );
274  break;
275 
276  case PCB_TEXT_T:
277  break;
278 
279  case PCB_LINE_T:
280  break;
281 
282  case PCB_DIMENSION_T:
283  break;
284 
285  case PCB_TARGET_T:
286  break;
287 
288  case PCB_MODULE_TEXT_T:
289  {
290  TEXTE_MODULE *text = static_cast<TEXTE_MODULE*>( item );
291  if( m_Guide->IgnoreMTextsMarkedNoShow() && !text->IsVisible() )
292  goto exit;
293 
294  if( m_Guide->IgnoreMTextsOnBack() && IsBackLayer( text->GetLayer() ) )
295  goto exit;
296 
297  if( m_Guide->IgnoreMTextsOnFront() && IsFrontLayer( text->GetLayer() ) )
298  goto exit;
299 
300  /* The three text types have different criteria: reference
301  * and value have their own ignore flags; user text instead
302  * follows their layer visibility. Checking this here is
303  * simpler than later (when layer visibility is checked for
304  * other entities) */
305 
306  switch( text->GetType() )
307  {
309  if( m_Guide->IgnoreModulesRefs() )
310  goto exit;
311  break;
312 
314  if( m_Guide->IgnoreModulesVals() )
315  goto exit;
316  break;
317 
319  if( !m_Guide->IsLayerVisible( text->GetLayer() )
321  goto exit;
322  break;
323  }
324 
325  // Extract the module since it could be hidden
326  module = static_cast<MODULE*>( item->GetParent() );
327  }
328  break;
329 
330  case PCB_MODULE_T:
331  module = static_cast<MODULE*>( item );
332  break;
333 
334  case PCB_MARKER_T:
335  marker = static_cast<MARKER_PCB*>( item );
336  break;
337 
338  default:
339  break;
340  }
341 
342  // common tests:
343 
344  if( module ) // true from case PCB_PAD_T, PCB_MODULE_TEXT_T, or PCB_MODULE_T
345  {
346  if( m_Guide->IgnoreModulesOnBack() && (module->GetLayer() == B_Cu) )
347  goto exit;
348 
349  if( m_Guide->IgnoreModulesOnFront() && (module->GetLayer() == F_Cu) )
350  goto exit;
351  }
352 
353  // Pads are not sensitive to the layer visibility controls.
354  // They all have their own separate visibility controls
355  // skip them if not visible
356  if( pad )
357  {
358  if( m_Guide->IgnorePads() )
359  goto exit;
360 
361  if( ! pad_through )
362  {
363  if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
364  goto exit;
365 
366  if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
367  goto exit;
368  }
369  }
370 
371  if( marker )
372  {
373  // Markers are not sensitive to the layer
374  if( marker->HitTest( m_RefPos ) )
375  Append( item );
376 
377  goto exit;
378  }
379 
380  if( via )
381  {
382  auto type = via->GetViaType();
383 
384  if( ( m_Guide->IgnoreThroughVias() && type == VIA_THROUGH ) ||
385  ( m_Guide->IgnoreBlindBuriedVias() && type == VIA_BLIND_BURIED ) ||
386  ( m_Guide->IgnoreMicroVias() && type == VIA_MICROVIA ) )
387  {
388  goto exit;
389  }
390  }
391 
393  {
394  PCB_LAYER_ID layer = item->GetLayer();
395 
396  /* Modules and their subcomponents: reference, value and pads
397  * are not sensitive to the layer visibility controls. They all
398  * have their own separate visibility controls for vias,
399  * GetLayer() has no meaning, but IsOnLayer() works fine. User
400  * text in module *is* sensitive to layer visibility but that
401  * was already handled */
402 
403  if( via || module || pad || m_Guide->IsLayerVisible( layer )
405  {
406  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
407  {
408  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
409  {
410  if( item->HitTest( m_RefPos ) )
411  {
412  if( !module || module->HitTestAccurate( m_RefPos ) )
413  Append( item );
414  goto exit;
415  }
416  else if( zone && !m_Guide->IgnoreZoneFills() && zone->HitTestFilledArea( m_RefPos ) )
417  {
418  Append( item );
419  goto exit;
420  }
421  }
422  }
423  }
424  }
425 
426 
427  if( m_Guide->IncludeSecondary() )
428  {
429  // for now, "secondary" means "tolerate any layer". It has
430  // no effect on other criteria, since there is a separate "ignore" control for
431  // those in the COLLECTORS_GUIDE
432 
433  PCB_LAYER_ID layer = item->GetLayer();
434 
435  /* Modules and their subcomponents: reference, value and pads
436  * are not sensitive to the layer visibility controls. They all
437  * have their own separate visibility controls. User texts
438  * follows layer visibility controls (but that was already
439  * checked) */
440 
441  if( via || module || pad || m_Guide->IsLayerVisible( layer )
443  {
444  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
445  {
446  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
447  {
448  if( item->HitTest( m_RefPos ) )
449  {
450  Append2nd( item );
451  goto exit;
452  }
453  else if( zone && !m_Guide->IgnoreZoneFills() && zone->HitTestFilledArea( m_RefPos ) )
454  {
455  Append( item );
456  goto exit;
457  }
458  }
459  }
460  }
461  }
462 
463 exit:
464  return SEARCH_CONTINUE; // always when collecting
465 }
virtual bool IsLayerLocked(PCB_LAYER_ID layer) const =0
KICAD_T Type() const
Function Type()
Definition: base_struct.h:201
BOARD_ITEM_CONTAINER * GetParent() const
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:60
virtual bool IgnoreBlindBuriedVias() const =0
virtual bool IgnoreModulesOnFront() const =0
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:405
virtual bool IsOnLayer(PCB_LAYER_ID aLayer) const
Function IsOnLayer tests to see if this object is on the given layer.
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
TEXT_TYPE GetType() const
virtual PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it&#39;s a back layer.
virtual bool IgnoreZoneFills() const =0
virtual bool IgnoreNonVisibleLayers() const =0
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:61
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:102
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:337
bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
class TEXTE_PCB, text on a layer
Definition: typeinfo.h:92
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 IgnorePads() const
Definition: collectors.h:156
virtual bool IgnorePreferredLayer() const =0
Provide wildcard behavior regarding the preferred layer.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:95
virtual bool IgnorePadsOnFront() const =0
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
Definition: collector.h:133
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_LAYER_ID
A quick note on layer IDs:
VIATYPE_T GetViaType() const
Definition: class_track.h:457
virtual bool IgnoreMTextsOnBack() const =0
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:143
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:256
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:62
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&#39;s a front layer.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
bool HitTestAccurate(const wxPoint &aPosition) const
Tests if a point is inside the bounding polygon of the module.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:463
virtual bool IsLocked() const
Function IsLocked.
bool IsVisible() const
Definition: eda_text.h:189
bool HitTestFilledArea(const wxPoint &aRefPos) const
Function HitTestFilledArea tests if the given wxPoint is within the bounds of a filled area of this z...
Definition: class_zone.cpp:805
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:96
virtual bool IgnorePadsOnBack() const =0
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
Definition: collector.h:68
virtual bool IgnoreLockedItems() const =0
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:663
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.
class SEGZONE, a segment used to fill a zone area (segment on a
Definition: typeinfo.h:97
bool COLLECTOR::IsSimilarPointAndTime ( const wxPoint aRefPos)
inlineinherited

Function IsSimilarPointAndTime returns true if the given reference point is "similar" (defined here) to the internal reference point and the current time is within a few seconds of the internal m_TimeAtCollection.

Parameters
aRefPosA wxPoint to compare to.
Returns
bool - true if the point and time are similar, else false.

Definition at line 245 of file collector.h.

References abs, GetNewTimeStamp(), wxPoint::x, and wxPoint::y.

246  {
247  const int distMax = 2; // adjust these here
248  const timestamp_t timeMax = 3; // seconds
249 
250  int dx = abs( aRefPos.x - m_RefPos.x );
251  int dy = abs( aRefPos.y - m_RefPos.y );
252 
253  if( dx <= distMax && dy <= distMax &&
254  GetNewTimeStamp() - m_TimeAtCollection <= timeMax )
255  return true;
256  else
257  return false;
258  }
long timestamp_t
timestamp_t is our type to represent unique IDs for all kinds of elements; historically simply the ti...
Definition: common.h:52
#define abs(a)
Definition: auxiliary.h:84
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
Definition: collector.h:68
timestamp_t m_TimeAtCollection
The time at which the collection was made.
Definition: collector.h:74
bool COLLECTOR::IsValidIndex ( int  aIndex)
inlineinherited

Function IsValidIndex tests if aIndex is with the limits of the list of collected items.

Parameters
aIndexThe index to test.
Returns
True if aIndex is with the limits of the list of collected items, otherwise false.

Definition at line 105 of file collector.h.

Referenced by SCH_FIND_COLLECTOR::GetText(), and SCH_FIND_COLLECTOR::ReplaceItem().

106  {
107  return ( (unsigned) aIndex < m_List.size() );
108  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
BOARD_ITEM* PCB_COLLECTOR::operator[] ( int  ndx) const
inlineinherited

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.

Definition at line 223 of file collectors.h.

224  {
225  if( (unsigned)ndx < (unsigned)GetCount() )
226  return (BOARD_ITEM*) m_List[ ndx ];
227 
228  return NULL;
229  }
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:114
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
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 143 of file collector.h.

Referenced by connectedItemFilter(), connectedTrackFilter(), EditToolSelectionFilter(), EDIT_TOOL::FootprintFilter(), SELECTION_TOOL::guessSelectionCandidates(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), GERBVIEW_SELECTION_TOOL::selectPoint(), and SELECTION_TOOL::selectPoint().

144  {
145  m_List.erase( m_List.begin() + aIndex );
146  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
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 153 of file collector.h.

References i.

154  {
155  for( size_t i = 0; i < m_List.size(); i++ )
156  {
157  if( m_List[i] == aItem )
158  {
159  m_List.erase( m_List.begin() + i);
160  return;
161  }
162  }
163  }
size_t i
Definition: json11.cpp:597
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
Definition: collector.h:65
void COLLECTOR::SetBoundingBox ( const EDA_RECT aRefBox)
inlineinherited

Definition at line 233 of file collector.h.

233 { m_RefBox = aRefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
Definition: collector.h:71
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 347 of file collectors.h.

Referenced by Collect().

347 { m_Guide = aGuide; }
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:256
void COLLECTOR::SetRefPos ( const wxPoint aRefPos)
inlineinherited

Definition at line 230 of file collector.h.

Referenced by GERBER_COLLECTOR::Collect(), LIB_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), and Collect().

230 { m_RefPos = aRefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
Definition: collector.h:68
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 215 of file collector.h.

Referenced by GERBER_COLLECTOR::Collect(), LIB_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), Collect(), SCH_TYPE_COLLECTOR::Collect(), GERBER_COLLECTOR::GERBER_COLLECTOR(), SCH_COLLECTOR::SCH_COLLECTOR(), and SCH_FIND_COLLECTOR::SCH_FIND_COLLECTOR().

216  {
217  m_ScanTypes = scanTypes;
218  }
const KICAD_T * m_ScanTypes
Which object types to scan.
Definition: collector.h:62
void COLLECTOR::SetTimeNow ( )
inlineinherited

Definition at line 220 of file collector.h.

References GetNewTimeStamp().

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

221  {
223  }
timestamp_t GetNewTimeStamp()
Definition: common.cpp:212
timestamp_t m_TimeAtCollection
The time at which the collection was made.
Definition: collector.h:74

Member Data Documentation

const KICAD_T GENERAL_COLLECTOR::AllBoardItems
static
Initial value:

A scan list for all editable board items, like PcbGeneralLocateAndDisplay()

Definition at line 269 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), and SELECTION_TOOL::selectPoint().

const KICAD_T GENERAL_COLLECTOR::AllButZones
static
Initial value:

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

Definition at line 274 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().

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

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

const KICAD_T GENERAL_COLLECTOR::LockableItems
static
Initial value:

A scan list for TRACKS, VIAS, MODULES.

Definition at line 320 of file collectors.h.

Referenced by PCB_EDITOR_CONTROL::Init().

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::m_Guide
protected

Determines which items are to be collected by Inspect()

Definition at line 256 of file collectors.h.

Referenced by Inspect().

std::vector<EDA_ITEM*> COLLECTOR::m_List
protectedinherited
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 251 of file collectors.h.

Referenced by Collect().

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

Referenced by Collect().

EDA_RECT COLLECTOR::m_RefBox
protectedinherited

A bounding box to test against, and that was used to make the collection.

Definition at line 71 of file collector.h.

Referenced by COLLECTOR::GetBoundingBox().

wxPoint COLLECTOR::m_RefPos
protectedinherited

A point to test against, and that was used to make the collection.

Definition at line 68 of file collector.h.

Referenced by COLLECTOR::GetRefPos(), GERBER_COLLECTOR::Inspect(), LIB_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), and Inspect().

const KICAD_T* COLLECTOR::m_ScanTypes
protectedinherited
timestamp_t COLLECTOR::m_TimeAtCollection
protectedinherited

The time at which the collection was made.

Definition at line 74 of file collector.h.

Referenced by COLLECTOR::GetTime().

const KICAD_T GENERAL_COLLECTOR::ModuleItems
static
Initial value:

A scan list for primary module items.

Definition at line 310 of file collectors.h.

Referenced by PANEL_SETUP_LAYERS::getNonRemovableLayers(), and SELECTION_TOOL::selectPoint().

const KICAD_T GENERAL_COLLECTOR::Modules
static
Initial value:

A scan list for only MODULEs.

Definition at line 290 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().

const KICAD_T GENERAL_COLLECTOR::ModulesAndTheirItems
static
Initial value:

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

Definition at line 305 of file collectors.h.

Referenced by FOOTPRINT_EDIT_FRAME::ModeditLocateAndDisplay().

const KICAD_T GENERAL_COLLECTOR::PadsOrModules
static
Initial value:

A scan list for PADs or MODULEs.

Definition at line 295 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().

const KICAD_T GENERAL_COLLECTOR::PadsOrTracks
static
Initial value:

A scan list for PADs, TRACKs, or VIAs.

Definition at line 300 of file collectors.h.

Referenced by highlightNet(), and PCB_EDIT_FRAME::SelectHighLight().

const KICAD_T GENERAL_COLLECTOR::Tracks
static
Initial value:

A scan list for only TRACKS.

Definition at line 315 of file collectors.h.

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

const KICAD_T GENERAL_COLLECTOR::Zones
static
Initial value:

A scan list for zones outlines only.

Definition at line 279 of file collectors.h.

Referenced by highlightNet(), PCB_BASE_FRAME::PcbGeneralLocateAndDisplay(), and PCB_EDIT_FRAME::SelectHighLight().


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