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

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

Constructor & Destructor Documentation

GENERAL_COLLECTOR::GENERAL_COLLECTOR ( )
inline

Constructor GENERALCOLLECTOR.

Definition at line 290 of file collectors.h.

References COLLECTOR::SetScanTypes().

291  {
292  m_Guide = NULL;
293  m_PrimaryLength = 0;
295  }
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:239
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:232
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(), GERBER_COLLECTOR::Inspect(), SCH_COLLECTOR::Inspect(), Inspect(), SCH_FIND_COLLECTOR::Inspect(), SCH_TYPE_COLLECTOR::Inspect(), PCB_TYPE_COLLECTOR::Inspect(), and PCB_LAYER_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 302 of file collectors.h.

Referenced by Inspect().

303  {
304  m_List2nd.push_back( item );
305  }
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:221
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 
)

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 435 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().

437 {
438  Empty(); // empty the collection, primary criteria list
439  Empty2nd(); // empty the collection, secondary criteria list
440 
441  // remember guide, pass it to Inspect()
442  SetGuide( &aGuide );
443 
444  SetScanTypes( aScanList );
445 
446  // remember where the snapshot was taken from and pass refPos to
447  // the Inspect() function.
448  SetRefPos( aRefPos );
449 
450  aItem->Visit( m_inspector, NULL, m_ScanTypes );
451 
452  SetTimeNow(); // when snapshot was taken
453 
454  // record the length of the primary list before concatenating on to it.
455  m_PrimaryLength = m_List.size();
456 
457  // append 2nd list onto end of the first list
458  for( unsigned i = 0; i<m_List2nd.size(); ++i )
459  Append( m_List2nd[i] );
460 
461  Empty2nd();
462 }
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:221
int m_PrimaryLength
The number of items that were originally in the primary list before the m_List2nd was concatenated on...
Definition: collectors.h:232
void Append(EDA_ITEM *item)
Function Append adds an item to the end of the list.
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Record which COLLECTORS_GUIDE to use.
Definition: collectors.h:312
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(), GERBER_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), Collect(), SCH_TYPE_COLLECTOR::Collect(), PCB_TYPE_COLLECTOR::Collect(), PCB_LAYER_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 297 of file collectors.h.

Referenced by Collect().

298  {
299  m_List2nd.clear();
300  }
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:221
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
Returns
int - The number if items which met the primary search criteria

Definition at line 317 of file collectors.h.

References m_PrimaryLength.

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

317 { 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:232
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

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 144 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().

145 {
146  BOARD_ITEM* item = (BOARD_ITEM*) testItem;
147  MODULE* module = NULL;
148  D_PAD* pad = NULL;
149  bool pad_through = false;
150  VIA* via = NULL;
151  MARKER_PCB* marker = NULL;
152 
153 #if 0 // debugging
154  static int breakhere = 0;
155 
156  switch( item->Type() )
157  {
158  case PCB_PAD_T:
159  {
160  MODULE* m = (MODULE*) item->GetParent();
161 
162  if( m->GetReference() == wxT( "Y2" ) )
163  {
164  breakhere++;
165  }
166  }
167  break;
168 
169  case PCB_VIA_T:
170  breakhere++;
171  break;
172 
173  case PCB_TRACE_T:
174  breakhere++;
175  break;
176 
177  case PCB_ZONE_T:
178  breakhere++;
179  break;
180 
181  case PCB_TEXT_T:
182  breakhere++;
183  break;
184 
185  case PCB_LINE_T:
186  breakhere++;
187  break;
188 
189  case PCB_DIMENSION_T:
190  breakhere++;
191  break;
192 
193  case PCB_MODULE_TEXT_T:
194  {
195  TEXTE_MODULE* tm = (TEXTE_MODULE*) item;
196 
197  if( tm->GetText() == wxT( "10uH" ) )
198  {
199  breakhere++;
200  }
201  }
202  break;
203 
204  case PCB_MODULE_T:
205  {
206  MODULE* m = (MODULE*) item;
207 
208  if( m->GetReference() == wxT( "C98" ) )
209  {
210  breakhere++;
211  }
212  }
213  break;
214 
215  case PCB_MARKER_T:
216  breakhere++;
217  break;
218 
219  default:
220  breakhere++;
221  break;
222  }
223 
224 #endif
225 
226 
227  switch( item->Type() )
228  {
229  case PCB_PAD_T:
230  // there are pad specific visibility controls.
231  // Criterias to select a pad is:
232  // for smd pads: the module parent must be seen, and pads on the corresponding
233  // board side must be seen
234  // if pad is a thru hole, then it can be visible when its parent module is not.
235  // for through pads: pads on Front or Back board sides must be seen
236  pad = (D_PAD*) item;
237 
238  if( (pad->GetAttribute() != PAD_ATTRIB_SMD) &&
239  (pad->GetAttribute() != PAD_ATTRIB_CONN) ) // a hole is present, so multiple layers
240  {
241  // proceed to the common tests below, but without the parent module test,
242  // by leaving module==NULL, but having pad != null
243  pad_through = true;
244  }
245  else // smd, so use pads test after module test
246  {
247  module = static_cast<MODULE*>( item->GetParent() );
248  }
249 
250  break;
251 
252  case PCB_VIA_T: // vias are on many layers, so layer test is specific
253  via = static_cast<VIA*>( item );
254  break;
255 
256  case PCB_TRACE_T:
257  break;
258 
259  case PCB_ZONE_T:
260  break;
261 
262  case PCB_ZONE_AREA_T:
263  break;
264 
265  case PCB_TEXT_T:
266  break;
267 
268  case PCB_LINE_T:
269  break;
270 
271  case PCB_DIMENSION_T:
272  break;
273 
274  case PCB_TARGET_T:
275  break;
276 
277  case PCB_MODULE_TEXT_T:
278  {
279  TEXTE_MODULE *text = static_cast<TEXTE_MODULE*>( item );
280  if( m_Guide->IgnoreMTextsMarkedNoShow() && !text->IsVisible() )
281  goto exit;
282 
283  if( m_Guide->IgnoreMTextsOnBack() && IsBackLayer( text->GetLayer() ) )
284  goto exit;
285 
286  if( m_Guide->IgnoreMTextsOnFront() && IsFrontLayer( text->GetLayer() ) )
287  goto exit;
288 
289  /* The three text types have different criteria: reference
290  * and value have their own ignore flags; user text instead
291  * follows their layer visibility. Checking this here is
292  * simpler than later (when layer visibility is checked for
293  * other entities) */
294 
295  switch( text->GetType() )
296  {
298  if( m_Guide->IgnoreModulesRefs() )
299  goto exit;
300  break;
301 
303  if( m_Guide->IgnoreModulesVals() )
304  goto exit;
305  break;
306 
308  if( !m_Guide->IsLayerVisible( text->GetLayer() )
310  goto exit;
311  break;
312  }
313 
314  // Extract the module since it could be hidden
315  module = static_cast<MODULE*>( item->GetParent() );
316  }
317  break;
318 
319  case PCB_MODULE_T:
320  module = static_cast<MODULE*>( item );
321  break;
322 
323  case PCB_MARKER_T:
324  marker = static_cast<MARKER_PCB*>( item );
325  break;
326 
327  default:
328  break;
329  }
330 
331  // common tests:
332 
333  if( module ) // true from case PCB_PAD_T, PCB_MODULE_TEXT_T, or PCB_MODULE_T
334  {
335  if( m_Guide->IgnoreModulesOnBack() && (module->GetLayer() == B_Cu) )
336  goto exit;
337 
338  if( m_Guide->IgnoreModulesOnFront() && (module->GetLayer() == F_Cu) )
339  goto exit;
340  }
341 
342  // Pads are not sensitive to the layer visibility controls.
343  // They all have their own separate visibility controls
344  // skip them if not visible
345  if( pad )
346  {
347  if( m_Guide->IgnorePads() )
348  goto exit;
349 
350  if( ! pad_through )
351  {
352  if( m_Guide->IgnorePadsOnFront() && pad->IsOnLayer(F_Cu ) )
353  goto exit;
354 
355  if( m_Guide->IgnorePadsOnBack() && pad->IsOnLayer(B_Cu ) )
356  goto exit;
357  }
358  }
359 
360  if( marker )
361  {
362  // Markers are not sensitive to the layer
363  if( marker->HitTest( m_RefPos ) )
364  Append( item );
365 
366  goto exit;
367  }
368 
369  if( item->IsOnLayer( m_Guide->GetPreferredLayer() ) ||
371  {
372  PCB_LAYER_ID layer = item->GetLayer();
373 
374  /* Modules and their subcomponents: reference, value and pads
375  * are not sensitive to the layer visibility controls. They all
376  * have their own separate visibility controls for vias,
377  * GetLayer() has no meaning, but IsOnLayer() works fine. User
378  * text in module *is* sensitive to layer visibility but that
379  * was already handled */
380 
381  if( via || module || pad || m_Guide->IsLayerVisible( layer )
383  {
384  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
385  {
386  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
387  {
388  if( item->HitTest( m_RefPos ) )
389  {
390  Append( item );
391  goto exit;
392  }
393  }
394  }
395  }
396  }
397 
398 
399  if( m_Guide->IncludeSecondary() )
400  {
401  // for now, "secondary" means "tolerate any layer". It has
402  // no effect on other criteria, since there is a separate "ignore" control for
403  // those in the COLLECTORS_GUIDE
404 
405  PCB_LAYER_ID layer = item->GetLayer();
406 
407  /* Modules and their subcomponents: reference, value and pads
408  * are not sensitive to the layer visibility controls. They all
409  * have their own separate visibility controls. User texts
410  * follows layer visibility controls (but that was already
411  * checked) */
412 
413  if( via || module || pad || m_Guide->IsLayerVisible( layer )
415  {
416  if( !m_Guide->IsLayerLocked( layer ) || !m_Guide->IgnoreLockedLayers() )
417  {
418  if( !item->IsLocked() || !m_Guide->IgnoreLockedItems() )
419  {
420  if( item->HitTest( m_RefPos ) )
421  {
422  Append2nd( item );
423  goto exit;
424  }
425  }
426  }
427  }
428  }
429 
430 exit:
431  return SEARCH_CONTINUE; // always when collecting
432 }
virtual bool IsLayerLocked(PCB_LAYER_ID layer) const =0
KICAD_T Type() const
Function Type()
Definition: base_struct.h:212
BOARD_ITEM_CONTAINER * GetParent() const
virtual bool IgnoreModulesOnFront() const =0
PAD_ATTR_T GetAttribute() const
Definition: class_pad.h:398
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's a back layer.
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:302
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
class D_PAD, a pad in a footprint
Definition: typeinfo.h:90
virtual bool IgnoreModulesVals() const =0
virtual bool IgnorePads() const
Definition: collectors.h:151
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.
class MODULE, a footprint
Definition: typeinfo.h:89
PCB_LAYER_ID
A quick note on layer IDs:
virtual bool IgnoreMTextsOnBack() const =0
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:97
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:226
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
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.
virtual bool HitTest(const wxPoint &aPosition) const override
Function HitTest tests if aPosition is contained within or on the bounding area of an item...
class MARKER_PCB, a marker used to show something
Definition: typeinfo.h:99
const wxString & GetReference() const
Function GetReference.
Definition: class_module.h:439
virtual bool IsLocked() const
Function IsLocked.
bool IsVisible() const
Definition: eda_text.h:176
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.
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:637
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.
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* 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 193 of file collectors.h.

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

194  {
195  if( (unsigned)ndx < (unsigned)GetCount() )
196  return (BOARD_ITEM*) m_List[ ndx ];
197 
198  return NULL;
199  }
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(), GERBVIEW_SELECTION_TOOL::selectPoint(), 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

Record which COLLECTORS_GUIDE to use.

Parameters
aGuideWhich guide to use in the collection.

Definition at line 312 of file collectors.h.

Referenced by Collect().

312 { 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(), GERBER_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(), GERBER_COLLECTOR::Collect(), SCH_COLLECTOR::Collect(), Collect(), SCH_TYPE_COLLECTOR::Collect(), GENERAL_COLLECTOR(), GERBER_COLLECTOR::GERBER_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 GERBER_COLLECTOR::Collect(), and 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 239 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 244 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 255 of file collectors.h.

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

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().

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 221 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 232 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(), GERBER_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 280 of file collectors.h.

Referenced by SELECTION_TOOL::selectPoint().

const KICAD_T GENERAL_COLLECTOR::Modules
static
Initial value:

A scan list for only MODULEs.

Definition at line 260 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 275 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 265 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 270 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 285 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 249 of file collectors.h.

Referenced by PCB_BASE_FRAME::PcbGeneralLocateAndDisplay().


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