KiCad PCB EDA Suite
collectors.h
Go to the documentation of this file.
1 /*
2  * This program source code file is part of KiCad, a free EDA CAD application.
3  *
4  * Copyright (C) 2007-2008 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
5  * Copyright (C) 2004-2007 KiCad Developers, see change_log.txt for contributors.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
29 #ifndef COLLECTORS_H
30 #define COLLECTORS_H
31 
32 
33 /* This module contains a number of COLLECTOR implementations which are used
34  to augment the functionality of class PCB_EDIT_FRAME.
35 */
36 
37 
38 #include <class_collector.h>
39 #include <layers_id_colors_and_visibility.h> // LAYER_COUNT, layer defs
40 
41 
42 class BOARD_ITEM;
43 
44 
65 {
66 
67 public:
68  virtual ~COLLECTORS_GUIDE() {}
69 
74  virtual bool IsLayerLocked( LAYER_ID layer ) const = 0;
75 
80  virtual bool IsLayerVisible( LAYER_ID layer ) const = 0;
81 
86  virtual bool IgnoreLockedLayers() const = 0;
87 
92  virtual bool IgnoreNonVisibleLayers() const = 0;
93 
98  virtual LAYER_ID GetPreferredLayer() const = 0;
99 
105  virtual bool IgnorePreferredLayer() const = 0;
106 
111  virtual bool IgnoreLockedItems() const = 0;
112 
119  virtual bool IncludeSecondary() const = 0;
120 
125  virtual bool IgnoreMTextsMarkedNoShow() const = 0;
126 
137  virtual bool IgnoreMTextsOnBack() const = 0;
138 
143  virtual bool IgnoreMTextsOnFront() const = 0;
144 
149  virtual bool IgnoreModulesOnBack() const = 0;
150 
155  virtual bool IgnoreModulesOnFront() const = 0;
156 
161  virtual bool IgnorePadsOnBack() const = 0;
162 
167  virtual bool IgnorePadsOnFront() const = 0;
168 
173  virtual bool IgnorePads() const
174  {
175  return IgnorePadsOnFront() && IgnorePadsOnBack();
176  }
177 
182  virtual bool IgnoreModulesVals() const = 0;
183 
188  virtual bool IgnoreModulesRefs() const = 0;
189 
196 };
197 
198 
199 
212 {
213 protected:
220  std::vector<BOARD_ITEM*> m_List2nd;
221 
222 
227 
228 
234 
235 
236 public:
237 
241  static const KICAD_T AllBoardItems[];
242 
243 
247  static const KICAD_T AllButZones[];
248 
252  static const KICAD_T Zones[];
253 
254 
265  static const KICAD_T Modules[];
266 
267 
271  static const KICAD_T PadsOrModules[];
272 
276  static const KICAD_T PadsTracksOrZones[];
277 
278 
283 
284 
288  static const KICAD_T ModuleItems[];
289 
290 
294  static const KICAD_T Tracks[];
295 
296 
301  {
302  m_Guide = NULL;
303  m_PrimaryLength = 0;
304  SetScanTypes( AllBoardItems );
305  }
306 
307  void Empty2nd()
308  {
309  m_List2nd.clear();
310  }
311 
312  void Append2nd( BOARD_ITEM* item )
313  {
314  m_List2nd.push_back( item );
315  }
316 
317 
323  void SetGuide( const COLLECTORS_GUIDE* aGuide ) { m_Guide = aGuide; }
324 
325 
333  BOARD_ITEM* operator[]( int ndx ) const
334  {
335  if( (unsigned)ndx < (unsigned)GetCount() )
336  return (BOARD_ITEM*) m_List[ ndx ];
337  return NULL;
338  }
339 
345 
356  SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
357 
368  void Collect( BOARD_ITEM* aItem, const KICAD_T aScanList[],
369  const wxPoint& aRefPos, const COLLECTORS_GUIDE& aGuide );
370 };
371 
372 
379 {
380 private:
381  // the storage architecture here is not important, since this is only
382  // a carrier object and its functions are what is used, and data only indirectly.
383 
386 
389 
392 
395 
405 
406 public:
407 
415  GENERAL_COLLECTORS_GUIDE( LSET aVisibleLayerMask, LAYER_ID aPreferredLayer )
416  {
417  m_PreferredLayer = aPreferredLayer;
418  m_IgnorePreferredLayer = false;
419  m_LayerVisible = aVisibleLayerMask;
420  m_IgnoreLockedLayers = true;
421  m_IgnoreNonVisibleLayers = true;
422  m_IgnoreLockedItems = false;
423 
424 #if defined(USE_MATCH_LAYER)
425  m_IncludeSecondary = false;
426 #else
427  m_IncludeSecondary = true;
428 #endif
429 
430  m_IgnoreMTextsMarkedNoShow = true; // g_ModuleTextNOVColor;
431  m_IgnoreMTextsOnBack = true;
432  m_IgnoreMTextsOnFront = false;
433  m_IgnoreModulesOnBack = true; // !Show_Modules_Cmp;
434  m_IgnoreModulesOnFront = false;
435 
436  m_IgnorePadsOnFront = false;
437  m_IgnorePadsOnBack = false;
438 
439  m_IgnoreModulesVals = false;
440  m_IgnoreModulesRefs = false;
441  }
442 
443 
448  bool IsLayerLocked( LAYER_ID aLayerId ) const override
449  {
450  return m_LayerLocked[aLayerId];
451  }
452 
453  void SetLayerLocked( LAYER_ID aLayerId, bool isLocked )
454  {
455  m_LayerLocked.set( aLayerId, isLocked );
456  }
457 
462  bool IsLayerVisible( LAYER_ID aLayerId ) const override
463  {
464  return m_LayerVisible[aLayerId];
465  }
466  void SetLayerVisible( LAYER_ID aLayerId, bool isVisible )
467  {
468  m_LayerVisible.set( aLayerId, isVisible );
469  }
470  void SetLayerVisibleBits( LSET aLayerBits ) { m_LayerVisible = aLayerBits; }
471 
476  bool IgnoreLockedLayers() const override { return m_IgnoreLockedLayers; }
477  void SetIgnoreLockedLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
478 
479 
484  bool IgnoreNonVisibleLayers() const override { return m_IgnoreNonVisibleLayers; }
485  void SetIgnoreNonVisibleLayers( bool ignore ) { m_IgnoreLockedLayers = ignore; }
486 
487 
492  LAYER_ID GetPreferredLayer() const override { return m_PreferredLayer; }
493  void SetPreferredLayer( LAYER_ID aLayer ) { m_PreferredLayer = aLayer; }
494 
495 
501  bool IgnorePreferredLayer() const override { return m_IgnorePreferredLayer; }
502  void SetIgnorePreferredLayer( bool ignore ) { m_IgnorePreferredLayer = ignore; }
503 
504 
509  bool IgnoreLockedItems() const override { return m_IgnoreLockedItems; }
510  void SetIgnoreLockedItems( bool ignore ) { m_IgnoreLockedItems = ignore; }
511 
512 
519  bool IncludeSecondary() const override { return m_IncludeSecondary; }
520  void SetIncludeSecondary( bool include ) { m_IncludeSecondary = include; }
521 
522 
527  bool IgnoreMTextsMarkedNoShow() const override { return m_IgnoreMTextsMarkedNoShow; }
528  void SetIgnoreMTextsMarkedNoShow( bool ignore ) { m_IgnoreMTextsMarkedNoShow = ignore; }
529 
534  bool IgnoreMTextsOnBack() const override { return m_IgnoreMTextsOnBack; }
535  void SetIgnoreMTextsOnBack( bool ignore ) { m_IgnoreMTextsOnBack = ignore; }
536 
541  bool IgnoreMTextsOnFront() const override { return m_IgnoreMTextsOnFront; }
542  void SetIgnoreMTextsOnFront( bool ignore ) { m_IgnoreMTextsOnFront = ignore; }
543 
548  bool IgnoreModulesOnBack() const override { return m_IgnoreModulesOnBack; }
549  void SetIgnoreModulesOnBack( bool ignore ) { m_IgnoreModulesOnBack = ignore; }
550 
555  bool IgnoreModulesOnFront() const override { return m_IgnoreModulesOnFront; }
556  void SetIgnoreModulesOnFront( bool ignore ) { m_IgnoreModulesOnFront = ignore; }
557 
562  bool IgnorePadsOnBack() const override { return m_IgnorePadsOnBack; }
563  void SetIgnorePadsOnBack(bool ignore) { m_IgnorePadsOnBack = ignore; }
564 
569  bool IgnorePadsOnFront() const override { return m_IgnorePadsOnFront; }
570  void SetIgnorePadsOnFront(bool ignore) { m_IgnorePadsOnFront = ignore; }
571 
576  bool IgnoreModulesVals() const override { return m_IgnoreModulesVals; }
577  void SetIgnoreModulesVals(bool ignore) { m_IgnoreModulesVals = ignore; }
578 
583  bool IgnoreModulesRefs() const override { return m_IgnoreModulesRefs; }
584  void SetIgnoreModulesRefs(bool ignore) { m_IgnoreModulesRefs = ignore; }
585 };
586 
587 
594 {
595 public:
596 
604  BOARD_ITEM* operator[]( int ndx ) const
605  {
606  if( (unsigned)ndx < (unsigned)GetCount() )
607  return (BOARD_ITEM*) m_List[ ndx ];
608  return NULL;
609  }
610 
621  SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
622 
630  void Collect( BOARD_ITEM* aBoard, const KICAD_T aScanList[] );
631 };
632 
633 #endif // COLLECTORS_H
int GetCount() const
Function GetCount returns the number of objects in the list.
bool IgnoreModulesOnFront() const override
Function IgnoreModulesOnFront.
Definition: collectors.h:555
BOARD_ITEM * operator[](int ndx) const
Function operator[int] overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of an EDA...
Definition: collectors.h:604
virtual bool IgnoreModulesOnFront() const =0
Function IgnoreModulesOnFront.
static const KICAD_T PadsTracksOrZones[]
A scan list for PADs, TRACKs, VIAs, or ZONEs.
Definition: collectors.h:276
static const KICAD_T AllBoardItems[]
A scan list for all editable board items, like PcbGeneralLocateAndDisplay()
Definition: collectors.h:241
static const KICAD_T Tracks[]
A scan list for only TRACKS.
Definition: collectors.h:294
void SetLayerLocked(LAYER_ID aLayerId, bool isLocked)
Definition: collectors.h:453
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
static const KICAD_T Modules[]
A scan list for all primary board items, omitting items which are subordinate to a MODULE...
Definition: collectors.h:265
bool IgnoreModulesOnBack() const override
Function IgnoreModulesOnBack.
Definition: collectors.h:548
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
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...
Definition: collectors.cpp:447
void SetIgnoreModulesVals(bool ignore)
Definition: collectors.h:577
void SetIgnoreModulesOnBack(bool ignore)
Definition: collectors.h:549
void SetIgnorePreferredLayer(bool ignore)
Definition: collectors.h:502
virtual bool IgnoreNonVisibleLayers() const =0
Function IgnoredNonVisibleLayers.
void Append2nd(BOARD_ITEM *item)
Definition: collectors.h:312
void SetIgnoreModulesRefs(bool ignore)
Definition: collectors.h:584
bool IgnoreModulesVals() const override
Function IgnoreModulesVals.
Definition: collectors.h:576
static const KICAD_T AllButZones[]
A scan list for all editable board items, except zones.
Definition: collectors.h:247
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
virtual bool IgnoreModulesVals() const =0
Function IgnoreModulesVals.
virtual bool IgnorePads() const
Function IgnorePads.
Definition: collectors.h:173
virtual bool IsLayerVisible(LAYER_ID layer) const =0
Function IsLayerVisible.
bool IgnorePadsOnBack() const override
Function IgnorePadsOnBack.
Definition: collectors.h:562
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
virtual bool IsLayerLocked(LAYER_ID layer) const =0
Function IsLayerLocked.
bool IgnorePreferredLayer() const override
Function IgnorePreferredLayer provides wildcard behavior regarding the preferred layer.
Definition: collectors.h:501
virtual bool IgnorePreferredLayer() const =0
Function IgnorePreferredLayer provides wildcard behavior regarding the preferred layer.
LAYER_ID GetPreferredLayer() const override
Function GetPreferredLayer.
Definition: collectors.h:492
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
GENERAL_COLLECTORS_GUIDE(LSET aVisibleLayerMask, LAYER_ID aPreferredLayer)
Constructor GENERAL_COLLECTORS_GUIDE grabs stuff from global preferences and uses reasonable defaults...
Definition: collectors.h:415
static const KICAD_T ModulesAndTheirItems[]
A scan list for MODULEs and their items (for Modedit)
Definition: collectors.h:282
virtual bool IgnorePadsOnFront() const =0
Function IgnorePadsOnFront.
void SetLayerVisible(LAYER_ID aLayerId, bool isVisible)
Definition: collectors.h:466
void SetGuide(const COLLECTORS_GUIDE *aGuide)
Function SetGuide records which COLLECTORS_GUIDE to use.
Definition: collectors.h:323
virtual LAYER_ID GetPreferredLayer() const =0
Function GetPreferredLayer.
void SetLayerVisibleBits(LSET aLayerBits)
Definition: collectors.h:470
SEARCH_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate functi...
Definition: collectors.cpp:478
Class LSET is a set of LAYER_IDs.
LSET m_LayerLocked
bit-mapped layer locked bits
Definition: collectors.h:387
virtual bool IgnoreMTextsOnBack() const =0
Function IgnoreZones.
void SetIgnoreMTextsOnBack(bool ignore)
Definition: collectors.h:535
void SetIgnorePadsOnFront(bool ignore)
Definition: collectors.h:570
COLLECTOR class definition.
void SetIgnoreMTextsOnFront(bool ignore)
Definition: collectors.h:542
bool IgnoreMTextsOnBack() const override
Function IgnoreMTextsOnCu.
Definition: collectors.h:534
static const KICAD_T Zones[]
A scan list for zones outlines only.
Definition: collectors.h:252
bool IgnoreModulesRefs() const override
Function IgnoreModulesRefs.
Definition: collectors.h:583
const COLLECTORS_GUIDE * m_Guide
Determines which items are to be collected by Inspect()
Definition: collectors.h:226
void SetIgnoreMTextsMarkedNoShow(bool ignore)
Definition: collectors.h:528
virtual bool IgnoreMTextsMarkedNoShow() const =0
Function IgnoreMTextsMarkedNoShow.
void Collect(BOARD_ITEM *aBoard, const KICAD_T aScanList[])
Function Collect scans a BOARD_ITEM using this class's Inspector method, which does the collection...
Definition: collectors.cpp:488
virtual bool IgnoreModulesRefs() const =0
Function IgnoreModulesRefs.
bool IgnoreMTextsOnFront() const override
Function IgnoreMTextsOnFront.
Definition: collectors.h:541
bool IgnoreLockedLayers() const override
Function IgnoreLockedLayers.
Definition: collectors.h:476
bool IgnoreLockedItems() const override
Function IgnoreLockedItems.
Definition: collectors.h:509
static const KICAD_T PadsOrModules[]
A scan list for PADs or MODULEs.
Definition: collectors.h:271
Board layer functions and definitions.
int GetPrimaryCount()
Function GetPrimaryCount.
Definition: collectors.h:344
LAYER_ID
Enum LAYER_ID is the set of PCB layers.
static const KICAD_T ModuleItems[]
A scan list for primary module items.
Definition: collectors.h:288
void SetIgnoreModulesOnFront(bool ignore)
Definition: collectors.h:556
Class GENERAL_COLLECTOR is intended for use when the right click button is pressed, or when the plain "arrow" tool is in effect.
Definition: collectors.h:211
void SetIgnoreLockedItems(bool ignore)
Definition: collectors.h:510
GENERAL_COLLECTOR()
Constructor GENERALCOLLECTOR.
Definition: collectors.h:300
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
Class COLLECTOR is an abstract class that will find and hold all the objects according to an inspecti...
bool IgnoreNonVisibleLayers() const override
Function IgnoredNonVisibleLayers.
Definition: collectors.h:484
void SetPreferredLayer(LAYER_ID aLayer)
Definition: collectors.h:493
virtual bool IgnorePadsOnBack() const =0
Function IgnorePadsOnBack.
Class COLLECTORS_GUIDE is an abstract base class whose derivatives may be passed to a GENERAL_COLLECT...
Definition: collectors.h:64
bool IgnorePadsOnFront() const override
Function IgnorePadsOnFront.
Definition: collectors.h:569
virtual bool IgnoreLockedItems() const =0
Function IgnoreLockedItems.
void SetIgnoreLockedLayers(bool ignore)
Definition: collectors.h:477
virtual bool IgnoreLockedLayers() const =0
Function IgnoreLockedLayers.
bool IsLayerVisible(LAYER_ID aLayerId) const override
Function IsLayerVisible.
Definition: collectors.h:462
Class PCB_TYPE_COLLECTOR merely gathers up all BOARD_ITEMs of a given set of KICAD_T type(s)...
Definition: collectors.h:593
Class GENERAL_COLLECTORS_GUIDE is a general implementation of a COLLECTORS_GUIDE. ...
Definition: collectors.h:378
SEARCH_RESULT
Definition: base_struct.h:68
std::vector< EDA_ITEM * > m_List
A place to hold collected objects without taking ownership of their memory.
LSET m_LayerVisible
bit-mapped layer visible bits
Definition: collectors.h:390
virtual bool IgnoreModulesOnBack() const =0
Function IgnoreModulesOnBack.
virtual bool IgnoreMTextsOnFront() const =0
Function IgnoreMTextsOnFront.
virtual bool IncludeSecondary() const =0
Function IncludeSecondary determines if the secondary criteria, or 2nd choice items should be include...
BOARD_ITEM * operator[](int ndx) const
Function operator[int] overloads COLLECTOR::operator[](int) to return a BOARD_ITEM* instead of an EDA...
Definition: collectors.h:333
bool IgnoreMTextsMarkedNoShow() const override
Function IgnoreMTextsMarkedNoShow.
Definition: collectors.h:527
void SetIgnoreNonVisibleLayers(bool ignore)
Definition: collectors.h:485
SEARCH_RESULT Inspect(EDA_ITEM *testItem, void *testData) override
Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate functi...
Definition: collectors.cpp:155
bool IncludeSecondary() const override
Function IncludeSecondary determines if the secondary criteria, or 2nd choice items should be include...
Definition: collectors.h:519
void SetIncludeSecondary(bool include)
Definition: collectors.h:520
bool IsLayerLocked(LAYER_ID aLayerId) const override
Function IsLayerLocked.
Definition: collectors.h:448
virtual ~COLLECTORS_GUIDE()
Definition: collectors.h:68
void SetIgnorePadsOnBack(bool ignore)
Definition: collectors.h:563