KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_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 <[email protected]>
5 * Copyright The 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, see <https://www.gnu.org/licenses/>.
20 */
21
22#pragma once
23
24
25#include <lib_symbol.h>
26#include <collector.h>
27#include <sch_item.h>
28
29
30class SCH_SHEET_PATH;
31class SCH_SYMBOL;
32
33
35{
36public:
37 static const std::vector<KICAD_T> EditableItems;
38 static const std::vector<KICAD_T> MovableItems;
39 static const std::vector<KICAD_T> FieldOwners;
40 static const std::vector<KICAD_T> DeletableItems;
41
42 SCH_COLLECTOR( const std::vector<KICAD_T>& aScanTypes = { SCH_LOCATE_ANY_T } ) :
43 m_Unit( 0 ),
44 m_BodyStyle( 0 ),
46 {
47 SetScanTypes( aScanTypes );
48 }
49
54
56 SCH_ITEM* operator[]( int aIndex ) const override
57 {
58 if( (unsigned)aIndex < (unsigned)GetCount() )
59 return (SCH_ITEM*) m_list[ aIndex ];
60
61 return nullptr;
62 }
63
64 INSPECT_RESULT Inspect( EDA_ITEM* aItem, void* aTestData ) override;
65
76 void Collect( SCH_SCREEN* aScreen, const std::vector<KICAD_T>& aScanTypes,
77 const VECTOR2I& aPos, int aUnit = 0, int aBodyStyle = 0 );
78
81
83 * @param aScanTypes is a list of #KICAD_T types that determines what is to be collected
84 * and the priority order of the resulting collection.
85 * @param aPos are the coordinates to use in hit testing.
86 * @param aUnit is the symbol unit filter (for symbol editor).
87 * @param aBodyStyle is the body style filter (for symbol editor).
88 */
89 void Collect( LIB_ITEMS_CONTAINER& aItems, const std::vector<KICAD_T>& aScanTypes,
90 const VECTOR2I& aPos, int aUnit = 0, int aBodyStyle = 0 );
97 bool IsCorner() const;
98
99public:
100 int m_Unit; // Fixed symbol unit filter (for symbol editor)
101 int m_BodyStyle; // Fixed body style filter (for symbol editor)
102
104};
105
106
107void CollectOtherUnits( const wxString& thisRef, int thisUnit, const LIB_ID& aLibId,
108 SCH_SHEET_PATH& aSheet, std::vector<SCH_SYMBOL*>* otherUnits );
int GetCount() const
Return the number of objects in the list.
Definition collector.h:79
void SetScanTypes(const std::vector< KICAD_T > &aTypes)
Record the list of KICAD_T types to consider for collection by the Inspect() function.
Definition collector.h:209
std::vector< EDA_ITEM * > m_list
Definition collector.h:238
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:96
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
static const std::vector< KICAD_T > FieldOwners
SCH_COLLECTOR(const std::vector< KICAD_T > &aScanTypes={ SCH_LOCATE_ANY_T })
static const std::vector< KICAD_T > EditableItems
SCH_ITEM * operator[](int aIndex) const override
Overload COLLECTOR::operator[](int) to return a SCH_ITEM instead of an EDA_ITEM.
INSPECT_RESULT Inspect(EDA_ITEM *aItem, void *aTestData) override
bool IsCorner() const
Test if the collected items form a corner of two line segments.
void Collect(SCH_SCREEN *aScreen, const std::vector< KICAD_T > &aScanTypes, const VECTOR2I &aPos, int aUnit=0, int aBodyStyle=0)
Scan a EDA_ITEM using this class's Inspector method which does the collection.
static const std::vector< KICAD_T > DeletableItems
bool m_ShowPinElectricalTypes
static const std::vector< KICAD_T > MovableItems
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition sch_item.h:162
Handle access to a stack of flattened SCH_SHEET objects by way of a path for creating a flattened sch...
Schematic symbol object.
Definition sch_symbol.h:69
INSPECT_RESULT
Definition eda_item.h:42
MULTIVECTOR< SCH_ITEM, SCH_SHAPE_T, SCH_PIN_T > LIB_ITEMS_CONTAINER
Definition lib_symbol.h:48
void CollectOtherUnits(const wxString &thisRef, int thisUnit, const LIB_ID &aLibId, SCH_SHEET_PATH &aSheet, std::vector< SCH_SYMBOL * > *otherUnits)
@ SCH_LOCATE_ANY_T
Definition typeinfo.h:196
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:683