KiCad PCB EDA Suite
GENERAL_COLLECTOR Class Reference

Class GENERAL_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" tool is in effect. More...

#include <collectors.h>

Inheritance diagram for GENERAL_COLLECTOR:
COLLECTOR

Public Member Functions

 GENERAL_COLLECTOR ()
 Constructor GENERALCOLLECTOR. More...
 
void Empty2nd ()
 
void Append2nd (BOARD_ITEM *item)
 
void SetGuide (const COLLECTORS_GUIDE *aGuide)
 Function SetGuide records which COLLECTORS_GUIDE to use. More...
 
BOARD_ITEMoperator[] (int ndx) const
 Function operator[int] overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of an EDA_ITEM* type. More...
 
int GetPrimaryCount ()
 Function GetPrimaryCount. More...
 
SEARCH_RESULT Inspect (EDA_ITEM *testItem, void *testData) override
 Function Inspect is 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)
 Function Collect scans a BOARD_ITEM using this class's Inspector method, which does the collection. More...
 
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 ()
 
time_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 Modules []
 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 PadsOrModules []
 A scan list for PADs or MODULEs. More...
 
static const KICAD_T PadsTracksOrZones []
 A scan list for PADs, TRACKs, VIAs, or ZONEs. 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...
 

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...
 
time_t m_TimeAtCollection
 The time at which the collection was made. More...
 

Detailed Description

Class GENERAL_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" 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 211 of file collectors.h.

Constructor & Destructor Documentation

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Constructor GENERALCOLLECTOR.

Definition at line 300 of file collectors.h.

References COLLECTOR::SetScanTypes().

301  {
302  m_Guide = NULL;
303  m_PrimaryLength = 0;
305  }
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:241
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:233
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:226

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 126 of file class_collector.h.

Referenced by Collect(), SELECTION_TOOL::guessSelectionCandidates(), LIB_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), Inspect(), SCH_FIND_COLLECTOR::Inspect(), SCH_TYPE_COLLECTOR::Inspect(), and PCB_TYPE_COLLECTOR::Inspect().

127  {
128  m_List.push_back( item );
129  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void GENERAL_COLLECTOR::Append2nd ( BOARD_ITEM item)
inline

Definition at line 312 of file collectors.h.

Referenced by Inspect().

313  {
314  m_List2nd.push_back( item );
315  }
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.
Definition: collectors.h:220
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 178 of file class_collector.h.

179  {
180  return &m_List[0];
181  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void GENERAL_COLLECTOR::Collect ( BOARD_ITEM aItem,
const KICAD_T  aScanList[],
const wxPoint aRefPos,
const COLLECTORS_GUIDE aGuide 
)

Function Collect scans 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 447 of file collectors.cpp.

References COLLECTOR::Append(), COLLECTOR::Empty(), Empty2nd(), 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().

449 {
450  Empty(); // empty the collection, primary criteria list
451  Empty2nd(); // empty the collection, secondary criteria list
452 
453  // remember guide, pass it to Inspect()
454  SetGuide( &aGuide );
455 
456  SetScanTypes( aScanList );
457 
458  // remember where the snapshot was taken from and pass refPos to
459  // the Inspect() function.
460  SetRefPos( aRefPos );
461 
462  aItem->Visit( m_inspector, NULL, m_ScanTypes );
463 
464  SetTimeNow(); // when snapshot was taken
465 
466  // record the length of the primary list before concatenating on to it.
467  m_PrimaryLength = m_List.size();
468 
469  // append 2nd list onto end of the first list
470  for( unsigned i = 0; i<m_List2nd.size(); ++i )
471  Append( m_List2nd[i] );
472 
473  Empty2nd();
474 }
void Empty()
Function Empty sets the list to empty.
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...
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.
Definition: collectors.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:233
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Function SetGuide records which COLLECTORS_GUIDE to use.
Definition: collectors.h:323
INSPECTOR_FUNC m_inspector
a class common bridge into the polymorphic Inspect()
void SetRefPos(const wxPoint &aRefPos)
void SetTimeNow()
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
const KICAD_T * m_ScanTypes
Which object types to scan.
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 258 of file class_collector.h.

Referenced by SELECTION_TOOL::guessSelectionCandidates().

259  {
260  int cnt = 0;
261  for( size_t i = 0; i < m_List.size(); i++ )
262  {
263  if( m_List[i]->Type() == aType )
264  cnt++;
265  }
266  return cnt;
267  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void COLLECTOR::Empty ( )
inlineinherited

Function Empty sets the list to empty.

Definition at line 116 of file class_collector.h.

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

117  {
118  m_List.clear();
119  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void GENERAL_COLLECTOR::Empty2nd ( )
inline

Definition at line 307 of file collectors.h.

Referenced by Collect().

308  {
309  m_List2nd.clear();
310  }
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.
Definition: collectors.h:220
const EDA_RECT& COLLECTOR::GetBoundingBox ( ) const
inlineinherited

Definition at line 227 of file class_collector.h.

References COLLECTOR::m_RefBox.

227 { return m_RefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
int GENERAL_COLLECTOR::GetPrimaryCount ( )
inline

Function GetPrimaryCount.

Returns
int - The number if items which met the primary search criteria

Definition at line 344 of file collectors.h.

References m_PrimaryLength.

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

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

Definition at line 224 of file class_collector.h.

References COLLECTOR::m_RefPos.

Referenced by PCB_EDIT_FRAME::OnRightClick().

224 { return m_RefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
time_t COLLECTOR::GetTime ( )
inlineinherited

Definition at line 218 of file class_collector.h.

References COLLECTOR::m_TimeAtCollection.

219  {
220  return m_TimeAtCollection;
221  }
time_t m_TimeAtCollection
The time at which the collection was made.
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 190 of file class_collector.h.

191  {
192  for( size_t i = 0; i < m_List.size(); i++ )
193  {
194  if( m_List[i] == aItem )
195  return true;
196  }
197 
198  return false;
199  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
SEARCH_RESULT GENERAL_COLLECTOR::Inspect ( EDA_ITEM testItem,
void *  testData 
)
overridevirtual

Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate function.

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;

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.
testDatanot used here.
Returns
SEARCH_RESULT - SEARCH_QUIT if the Iterator is to stop the scan, else SCAN_CONTINUE;

Implements COLLECTOR.

Definition at line 155 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(), MARKER_PCB::HitTest(), BOARD_ITEM::HitTest(), COLLECTORS_GUIDE::IgnoreLockedItems(), COLLECTORS_GUIDE::IgnoreLockedLayers(), 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::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_TARGET_T, PCB_TEXT_T, PCB_TRACE_T, PCB_VIA_T, PCB_ZONE_AREA_T, PCB_ZONE_T, SEARCH_CONTINUE, TEXTE_MODULE::TEXT_is_DIVERS, TEXTE_MODULE::TEXT_is_REFERENCE, TEXTE_MODULE::TEXT_is_VALUE, and EDA_ITEM::Type().

156 {
157  BOARD_ITEM* item = (BOARD_ITEM*) testItem;
158  MODULE* module = NULL;
159  D_PAD* pad = NULL;
160  bool pad_through = false;
161  VIA* via = NULL;
162  MARKER_PCB* marker = NULL;
163 
164 #if 0 // debugging
165  static int breakhere = 0;
166 
167  switch( item->Type() )
168  {
169  case PCB_PAD_T:
170  {
171  MODULE* m = (MODULE*) item->GetParent();
172 
173  if( m->GetReference() == wxT( "Y2" ) )
174  {
175  breakhere++;
176  }
177  }
178  break;
179 
180  case PCB_VIA_T:
181  breakhere++;
182  break;
183 
184  case PCB_TRACE_T:
185  breakhere++;
186  break;
187 
188  case PCB_ZONE_T:
189  breakhere++;
190  break;
191 
192  case PCB_TEXT_T:
193  breakhere++;
194  break;
195 
196  case PCB_LINE_T:
197  breakhere++;
198  break;
199 
200  case PCB_DIMENSION_T:
201  breakhere++;
202  break;
203 
204  case PCB_MODULE_TEXT_T:
205  {
206  TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
207 
208  if( tm->GetText() == wxT( "10uH" ) )
209  {
210  breakhere++;
211  }
212  }
213  break;
214 
215  case PCB_MODULE_T:
216  {
217  MODULE* m = (MODULE*) item;
218 
219  if( m->GetReference() == wxT( "C98" ) )
220  {
221  breakhere++;
222  }
223  }
224  break;
225 
226  case PCB_MARKER_T:
227  breakhere++;
228  break;
229 
230  default:
231  breakhere++;
232  break;
233  }
234 
235 #endif
236 
237 
238  switch( item->Type() )
239  {
240  case PCB_PAD_T:
241  // there are pad specific visibility controls.
242  // Criterias to select a pad is:
243  // for smd pads: the module parent must be seen, and pads on the corresponding
244  // board side must be seen
245  // if pad is a thru hole, then it can be visible when its parent module is not.
246  // for through pads: pads on Front or Back board sides must be seen
247  pad = (D_PAD*) item;
248 
249  if( (pad->GetAttribute() != PAD_ATTRIB_SMD) &&
250  (pad->GetAttribute() != PAD_ATTRIB_CONN) ) // a hole is present, so multiple layers
251  {
252  // proceed to the common tests below, but without the parent module test,
253  // by leaving module==NULL, but having pad != null
254  pad_through = true;
255  }
256  else // smd, so use pads test after module test
257  {
258  module = static_cast<MODULE*>( item->GetParent() );
259  }
260 
261  break;
262 
263  case PCB_VIA_T: // vias are on many layers, so layer test is specific
264  via = static_cast<VIA*>( item );
265  break;
266 
267  case PCB_TRACE_T:
268  break;
269 
270  case PCB_ZONE_T:
271  break;
272 
273  case PCB_ZONE_AREA_T:
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( item->IsOnLayer( m_Guide->GetPreferredLayer() ) ||
382  {
383  PCB_LAYER_ID layer = item->GetLayer();
384 
385  /* Modules and their subcomponents: reference, value and pads
386  * are not sensitive to the layer visibility controls. They all
387  * have their own separate visibility controls for vias,
388  * GetLayer() has no meaning, but IsOnLayer() works fine. User
389  * text in module *is* sensitive to layer visibility but that
390  * was already handled */
391 
392  if( via || module || pad || m_Guide->IsLayerVisible( layer )
394  {
395  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
396  {
397  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
398  {
399  if( item->HitTest( m_RefPos ) )
400  {
401  Append( item );
402  goto exit;
403  }
404  }
405  }
406  }
407  }
408 
409 
410  if( m_Guide->IncludeSecondary() )
411  {
412  // for now, "secondary" means "tolerate any layer". It has
413  // no effect on other criteria, since there is a separate "ignore" control for
414  // those in the COLLECTORS_GUIDE
415 
416  PCB_LAYER_ID layer = item->GetLayer();
417 
418  /* Modules and their subcomponents: reference, value and pads
419  * are not sensitive to the layer visibility controls. They all
420  * have their own separate visibility controls. User texts
421  * follows layer visibility controls (but that was already
422  * checked) */
423 
424  if( via || module || pad || m_Guide->IsLayerVisible( layer )
426  {
427  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
428  {
429  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
430  {
431  if( item->HitTest( m_RefPos ) )
432  {
433  Append2nd( item );
434  goto exit;
435  }
436  }
437  }
438  }
439  }
440 
441 exit:
442  return SEARCH_CONTINUE; // always when collecting
443 }
virtual bool IsLayerLocked(PCB_LAYER_ID layer) const =0
Function IsLayerLocked.
KICAD_T Type() const
Function Type()
Definition: base_struct.h:198
BOARD_ITEM_CONTAINER * GetParent() const
virtual bool IgnoreModulesOnFront() const =0
Function IgnoreModulesOnFront.
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:238
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
bool IsBackLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it's a back layer.
virtual bool IgnoreNonVisibleLayers() const =0
Function IgnoredNonVisibleLayers.
Smd pad, appears on the solder paste layer (default)
Definition: pad_shapes.h:59
class ZONE_CONTAINER, a zone area
Definition: typeinfo.h:114
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:312
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:104
virtual PCB_LAYER_ID GetPreferredLayer() const =0
Function GetPreferredLayer.
class D_PAD, a pad in a footprint
Definition: typeinfo.h:102
virtual bool IgnoreModulesVals() const =0
Function IgnoreModulesVals.
virtual bool IgnorePads() const
Function IgnorePads.
Definition: collectors.h:173
virtual bool IgnorePreferredLayer() const =0
Function IgnorePreferredLayer provides wildcard behavior regarding the preferred layer.
class TRACK, a track segment (segment on a copper layer)
Definition: typeinfo.h:107
virtual bool IgnorePadsOnFront() const =0
Function IgnorePadsOnFront.
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
class MODULE, a footprint
Definition: typeinfo.h:101
PCB_LAYER_ID
A quick note on layer IDs:
virtual bool IgnoreMTextsOnBack() const =0
Function IgnoreZones.
const wxString & GetText() const
Function GetText returns the string associated with the text object.
Definition: eda_text.h:130
class SEGZONE, a segment used to fill a zone area (segment on a copper layer)
Definition: typeinfo.h:109
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:226
virtual bool IgnoreMTextsMarkedNoShow() const =0
Function IgnoreMTextsMarkedNoShow.
Like smd, does not appear on the solder paste layer (default) note also has a special attribute in Ge...
Definition: pad_shapes.h:60
class DIMENSION, a dimension (graphic item)
Definition: typeinfo.h:112
class PCB_TARGET, a target (graphic item)
Definition: typeinfo.h:113
virtual bool IgnoreModulesRefs() const =0
Function IgnoreModulesRefs.
class TEXTE_MODULE, text in a footprint
Definition: typeinfo.h:105
bool IsFrontLayer(PCB_LAYER_ID aLayerId)
Layer classification: check if it'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...
PCB_LAYER_ID GetLayer() const
Function GetLayer returns the primary layer this item is on.
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:111
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:411
virtual bool IsLocked() const
Function IsLocked.
bool IsVisible() const
Definition: eda_text.h:176
virtual bool IsLayerVisible(PCB_LAYER_ID layer) const =0
Function IsLayerVisible.
class VIA, a via (like a track segment on a copper layer)
Definition: typeinfo.h:108
virtual bool IgnorePadsOnBack() const =0
Function IgnorePadsOnBack.
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
virtual bool IgnoreLockedItems() const =0
Function IgnoreLockedItems.
virtual bool IgnoreLockedLayers() const =0
Function IgnoreLockedLayers.
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:479
virtual bool IgnoreModulesOnBack() const =0
Function IgnoreModulesOnBack.
virtual bool IgnoreMTextsOnFront() const =0
Function IgnoreMTextsOnFront.
class DRAWSEGMENT, a segment not on copper layers
Definition: typeinfo.h:103
virtual bool IncludeSecondary() const =0
Function IncludeSecondary determines if the secondary criteria, or 2nd choice items should be include...
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 238 of file class_collector.h.

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

239  {
240  const int distMax = 2; // adjust these here
241  const time_t timeMax = 3; // seconds
242 
243  int dx = abs( aRefPos.x - m_RefPos.x );
244  int dy = abs( aRefPos.y - m_RefPos.y );
245 
246  if( dx <= distMax && dy <= distMax &&
247  (int)GetNewTimeStamp() - m_TimeAtCollection <= timeMax )
248  return true;
249  else
250  return false;
251  }
time_t GetNewTimeStamp()
Definition: common.cpp:166
#define abs(a)
Definition: auxiliary.h:84
time_t m_TimeAtCollection
The time at which the collection was made.
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
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 98 of file class_collector.h.

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

99  {
100  return ( (unsigned) aIndex < m_List.size() );
101  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
BOARD_ITEM* GENERAL_COLLECTOR::operator[] ( int  ndx) const
inline

Function operator[int] overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of an EDA_ITEM* type.

Parameters
ndxThe index into the list.
Returns
BOARD_ITEM* - or something derived from it, or NULL.

Definition at line 333 of file collectors.h.

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

334  {
335  if( (unsigned)ndx < (unsigned)GetCount() )
336  return (BOARD_ITEM*) m_List[ ndx ];
337  return NULL;
338  }
int GetCount() const
Function GetCount returns the number of objects in the list.
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.
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 136 of file class_collector.h.

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

137  {
138  m_List.erase( m_List.begin() + aIndex );
139  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
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 146 of file class_collector.h.

147  {
148  for( size_t i = 0; i < m_List.size(); i++ )
149  {
150  if( m_List[i] == aItem )
151  {
152  m_List.erase( m_List.begin() + i);
153  return;
154  }
155  }
156  }
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
void COLLECTOR::SetBoundingBox ( const EDA_RECT aRefBox)
inlineinherited

Definition at line 226 of file class_collector.h.

226 { m_RefBox = aRefBox; }
EDA_RECT m_RefBox
A bounding box to test against, and that was used to make the collection.
void GENERAL_COLLECTOR::SetGuide ( const COLLECTORS_GUIDE aGuide)
inline

Function SetGuide records which COLLECTORS_GUIDE to use.

Parameters
aGuideWhich guide to use in the collection.

Definition at line 323 of file collectors.h.

Referenced by Collect().

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

Definition at line 223 of file class_collector.h.

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

223 { m_RefPos = aRefPos; }
wxPoint m_RefPos
A point to test against, and that was used to make the collection.
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 208 of file class_collector.h.

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

209  {
210  m_ScanTypes = scanTypes;
211  }
const KICAD_T * m_ScanTypes
Which object types to scan.
void COLLECTOR::SetTimeNow ( )
inlineinherited

Definition at line 213 of file class_collector.h.

References GetNewTimeStamp().

Referenced by Collect().

214  {
216  }
time_t GetNewTimeStamp()
Definition: common.cpp:166
time_t m_TimeAtCollection
The time at which the collection was made.

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

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().

const COLLECTORS_GUIDE* GENERAL_COLLECTOR::m_Guide
protected

Determines which items are to be collected by Inspect()

Definition at line 226 of file collectors.h.

Referenced by Inspect().

INSPECTOR_FUNC COLLECTOR::m_inspector
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 220 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 233 of file collectors.h.

Referenced by Collect(), and GetPrimaryCount().

EDA_RECT COLLECTOR::m_RefBox
protectedinherited

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

Definition at line 72 of file class_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 69 of file class_collector.h.

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

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

The time at which the collection was made.

Definition at line 75 of file class_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 288 of file collectors.h.

Referenced by SELECTION_TOOL::selectPoint().

const KICAD_T GENERAL_COLLECTOR::Modules
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.

static const KICAD_T PrimaryItems[]; A scan list for only MODULEs

Definition at line 265 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 282 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 271 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().

const KICAD_T GENERAL_COLLECTOR::PadsTracksOrZones
static
Initial value:

A scan list for PADs, TRACKs, VIAs, or ZONEs.

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

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

const KICAD_T GENERAL_COLLECTOR::Zones
static
Initial value:

A scan list for zones outlines only.

Definition at line 252 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().


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