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  * Copyright (C) 2019 CERN
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
26 #ifndef EE_COLLECTORS_H
27 #define EE_COLLECTORS_H
28 
29 #include <class_libentry.h>
30 #include <collector.h>
32 #include <sch_item.h>
33 
34 
35 class SCH_SHEET_PATH;
36 class SCH_COMPONENT;
37 
38 
42 class EE_COLLECTOR : public COLLECTOR
43 {
44 public:
45  static const KICAD_T AllItems[];
46  static const KICAD_T EditableItems[];
47  static const KICAD_T ComponentsOnly[];
48  static const KICAD_T SheetsOnly[];
49  static const KICAD_T FieldOwners[];
50 
51  EE_COLLECTOR( const KICAD_T* aScanTypes = EE_COLLECTOR::AllItems ) :
52  m_Unit( 0 ),
53  m_Convert( 0 )
54  {
55  SetScanTypes( aScanTypes );
56  }
57 
64  SCH_ITEM* operator[]( int aIndex ) const override
65  {
66  if( (unsigned)aIndex < (unsigned)GetCount() )
67  return (SCH_ITEM*) m_list[ aIndex ];
68 
69  return NULL;
70  }
71 
72  SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
73 
85  void Collect( SCH_SCREEN* aScreen, const KICAD_T aFilterList[], const wxPoint& aPos,
86  int aUnit = 0, int aConvert = 0 );
87 
99  void Collect( LIB_ITEMS_CONTAINER& aItems, const KICAD_T aFilterList[], const wxPoint& aPos,
100  int aUnit = 0, int aConvert = 0 );
101 
107  bool IsCorner() const;
108 
109 public:
110  int m_Unit; // Fixed symbol unit filter (for symbol editor)
111  int m_Convert; // Fixed DeMorgan filter (for symbol editor)
112 };
113 
114 
115 void CollectOtherUnits( const wxString& thisRef, int thisUnit, SCH_SHEET_PATH& aSheet,
116  std::vector<SCH_COMPONENT*>* otherUnits );
117 
118 #endif // EE_COLLECTORS_H
void CollectOtherUnits(const wxString &thisRef, int thisUnit, SCH_SHEET_PATH &aSheet, std::vector< SCH_COMPONENT * > *otherUnits)
COLLECTOR class definition.
void Collect(SCH_SCREEN *aScreen, 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.
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:237
std::vector< EDA_ITEM * > m_list
Definition: collector.h:57
EE_COLLECTOR.
Definition: ee_collectors.h:42
static const KICAD_T FieldOwners[]
Definition: ee_collectors.h:49
static const KICAD_T ComponentsOnly[]
Definition: ee_collectors.h:47
static const KICAD_T SheetsOnly[]
Definition: ee_collectors.h:48
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_structType.
Definition: typeinfo.h:78
int GetCount() const
Function GetCount returns the number of objects in the list.
Definition: collector.h:104
#define NULL
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:64
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
bool IsCorner() const
Function IsCorner tests if the collected items forms as corner of two line segments.
static const KICAD_T AllItems[]
Definition: ee_collectors.h:45
Schematic symbol object.
Definition: sch_component.h:79
SEARCH_RESULT Inspect(EDA_ITEM *aItem, void *aTestData) override
EDA_ITEM is a base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:148
COLLECTOR is an abstract class that will find and hold all the objects according to an inspection don...
Definition: collector.h:54
SEARCH_RESULT
Definition: eda_item.h:40
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:194
static const KICAD_T EditableItems[]
Definition: ee_collectors.h:46
EE_COLLECTOR(const KICAD_T *aScanTypes=EE_COLLECTOR::AllItems)
Definition: ee_collectors.h:51