KiCad PCB EDA Suite
ee_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) 2011 Wayne Stambaugh <stambaughw@verizon.net>
5  * Copyright (C) 2011-2019 KiCad Developers, see AUTHORS.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 
25 #ifndef EE_COLLECTORS_H
26 #define EE_COLLECTORS_H
27 
28 
29 #include <collector.h>
30 #include <sch_item.h>
31 #include <sch_sheet_path.h>
33 
34 
38 class EE_COLLECTOR : public COLLECTOR
39 {
40 public:
41  static const KICAD_T AllItems[];
42  static const KICAD_T EditableItems[];
43  static const KICAD_T ComponentsOnly[];
44  static const KICAD_T SheetsOnly[];
45 
46  EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
47  m_Unit( 0 ),
48  m_Convert( 0 )
49  {
50  SetScanTypes( aScanTypes );
51  }
52 
59  SCH_ITEM* operator[]( int aIndex ) const override
60  {
61  if( (unsigned)aIndex < (unsigned)GetCount() )
62  return (SCH_ITEM*) m_List[ aIndex ];
63 
64  return NULL;
65  }
66 
67  SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
68 
80  void Collect( EDA_ITEM* aItem, const KICAD_T aFilterList[], const wxPoint& aPos,
81  int aUnit = 0, int aConvert = 0 );
82 
88  bool IsCorner() const;
89 
103  bool IsDraggableJunction() const;
104 
105 public:
106  int m_Unit; // Fixed symbol unit filter (for symbol editor)
107  int m_Convert; // Fixed DeMorgan filter (for symbol editor)
108 };
109 
110 
119 {
120 public:
130  SEARCH_RESULT Inspect( EDA_ITEM* testItem, void* testData ) override;
131 
138  void Collect( EDA_ITEM* aItem, const KICAD_T aScanList[] );
139 };
140 
141 
142 #endif // EE_COLLECTORS_H
void Collect(EDA_ITEM *aItem, const KICAD_T aScanList[])
Function Collect scans a DLIST using this class's Inspector method, which does the collection.
COLLECTOR class definition.
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:214
Class EE_COLLECTOR.
Definition: ee_collectors.h:38
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:43
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:44
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:78
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...
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:113
Subclass of DIALOG_SCH_FIND_BASE, which is generated by wxFormBuilder.
SCH_ITEM * operator[](int aIndex) const override
Overload COLLECTOR::operator[](int) to return a SCH_ITEM instead of an EDA_ITEM.
Definition: ee_collectors.h:59
void Collect(EDA_ITEM *aItem, const KICAD_T aFilterList[], const wxPoint &aPos, int aUnit=0, int aConvert=0)
Function Collect scans a EDA_ITEM using this class's Inspector method, which does the collection.
bool IsDraggableJunction() const
Function IsDraggableJunction tests to see if the collected items form a draggable junction.
bool IsCorner() const
Function IsCorner tests if the collected items forms as corner of two line segments.
Class EE_TYPE_COLLECTOR merely gathers up all SCH_ITEMs of a given set of KICAD_T type(s).
static const KICAD_T AllItems[]
Definition: ee_collectors.h:41
SEARCH_RESULT Inspect(EDA_ITEM *aItem, void *aTestData) override
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:150
Class COLLECTOR is an abstract class that will find and hold all the objects according to an inspecti...
Definition: collector.h:55
SEARCH_RESULT
Definition: base_struct.h:59
Definition of the SCH_SHEET_PATH and SCH_SHEET_LIST classes for Eeschema.
std::vector< EDA_ITEM * > m_List
Definition: collector.h:58
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:42
EE_COLLECTOR(const KICAD_T *aScanTypes=EE_COLLECTOR::AllItems)
Definition: ee_collectors.h:46