KiCad PCB EDA Suite
lib_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 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 
25 #ifndef _LIB_COLLECTORS_H_
26 #define _LIB_COLLECTORS_H_
27 
28 
29 #include <class_collector.h>
30 #include <lib_draw_item.h>
31 
32 
33 class LIB_COLLECTOR;
34 
35 
37 {
38  int m_unit;
39  int m_convert;
40 
41  friend class LIB_COLLECTOR;
42 
43 public:
45  m_unit( 0 ),
46  m_convert( 0 ) {}
47 };
48 
49 
53 class LIB_COLLECTOR : public COLLECTOR
54 {
56 
57 public:
58 
62  static const KICAD_T AllItems[];
63 
67  static const KICAD_T EditableItems[];
68 
72  static const KICAD_T MovableItems[];
73 
77  static const KICAD_T RotatableItems[];
78 
82  static const KICAD_T AllItemsButPins[];
83 
88  {
89  SetScanTypes( aScanTypes );
90  }
91 
99  LIB_ITEM* operator[]( int aIndex ) const
100  {
101  if( (unsigned)aIndex < (unsigned)GetCount() )
102  return (LIB_ITEM*) m_List[ aIndex ];
103 
104  return NULL;
105  }
106 
117  SEARCH_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
118 
130  void Collect( LIB_ITEMS& aItem, const KICAD_T aFilterList[], const wxPoint& aPosition,
131  int aUnit = 0, int aConvert = 0 );
132 };
133 
134 
135 #endif // _LIB_COLLECTORS_H_
LIB_ITEM * operator[](int aIndex) const
Operator [] overloads COLLECTOR::operator[](int) to return a LIB_ITEM* instead of an EDA_ITEM* type...
int GetCount() const
Function GetCount returns the number of objects in the list.
Class LIB_COLLECTOR.
void SetScanTypes(const KICAD_T *scanTypes)
Function SetScanTypes records the list of KICAD_T types to consider for collection by the Inspect() f...
LIB_COLLECTOR(const KICAD_T *aScanTypes=LIB_COLLECTOR::AllItems)
Constructor LIB_COLLECTOR.
static const KICAD_T AllItemsButPins[]
A scan list for all schematic items except pins.
KICAD_T
Enum KICAD_T is the set of class identification values, stored in EDA_ITEM::m_StructType.
Definition: typeinfo.h:90
static const KICAD_T EditableItems[]
A scan list for all editable schematic items.
Class LIB_ITEM is the base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:77
static const KICAD_T RotatableItems[]
A scan list for all rotatable schematic items.
static const KICAD_T AllItems[]
A scan list for all schematic items.
COLLECTOR class definition.
static const KICAD_T MovableItems[]
A scan list for all movable schematic items.
boost::ptr_vector< LIB_ITEM > LIB_ITEMS
Helper for defining a list of library draw object pointers.
Definition: lib_draw_item.h:63
LIB_COLLECTOR_DATA m_data
void Collect(LIB_ITEMS &aItem, const KICAD_T aFilterList[], const wxPoint &aPosition, int aUnit=0, int aConvert=0)
Function Collect scans a SCH_ITEM using this class's Inspector method, which does the collection...
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...
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.
SEARCH_RESULT Inspect(EDA_ITEM *aItem, void *aTestData) override
Function Inspect is the examining function within the INSPECTOR which is passed to the Iterate functi...