KiCad PCB EDA Suite
Loading...
Searching...
No Matches
sch_group.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 The KiCad Developers, see AUTHORS.txt for contributors.
5 *
6 * This program is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU General Public License
8 * as published by the Free Software Foundation; either version 2
9 * of the License, or (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, you may find one here:
18 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
19 * or you may search the http://www.gnu.org website for the version 2 license,
20 * or you may write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
22 */
23
29#ifndef CLASS_SCH_GROUP_H_
30#define CLASS_SCH_GROUP_H_
31
32#include <eda_group.h>
33#include <sch_commit.h>
34#include <sch_item.h>
35#include <lset.h>
36#include <unordered_set>
37
38namespace KIGFX
39{
40class VIEW;
41}
42
51class SCH_GROUP : public SCH_ITEM, public EDA_GROUP
52{
53public:
54 SCH_GROUP();
55
56 SCH_GROUP( SCH_ITEM* aParent );
57
58 SCH_GROUP( SCH_SCREEN* aParent );
59
60 EDA_ITEM* AsEdaItem() override { return this; }
61
62 static inline bool ClassOf( const EDA_ITEM* aItem ) { return aItem && SCH_GROUP_T == aItem->Type(); }
63
64 wxString GetClass() const override { return wxT( "SCH_GROUP" ); }
65
66 std::unordered_set<SCH_ITEM*> GetSchItems() const;
67
68 /*
69 * Search for highest level group inside of aScope, containing item.
70 *
71 * @param aScope restricts the search to groups within the group scope.
72 * @param isSymbolEditor true if we should stop promoting at the symbol level
73 * @return group inside of aScope, containing item, if exists, otherwise, nullptr
74 */
75 static EDA_GROUP* TopLevelGroup( SCH_ITEM* aItem, EDA_GROUP* aScope, bool isSymbolEditor );
76
77 static bool WithinScope( SCH_ITEM* aItem, SCH_GROUP* aScope, bool isSymbolEditor );
78
79 double Similarity( const SCH_ITEM& aOther ) const override;
80
81 bool operator==( const SCH_GROUP& aOther ) const;
82 bool operator==( const SCH_ITEM& aSchItem ) const override;
83
84#if defined( DEBUG )
85 void Show( int nestLevel, std::ostream& os ) const override { ShowDummy( os ); }
86#endif
87
89 VECTOR2I GetPosition() const override;
90
92 void SetPosition( const VECTOR2I& aNewpos ) override;
93
95 EDA_ITEM* Clone() const override;
96
97 /*
98 * Clone this and all descendants
99 */
100 SCH_GROUP* DeepClone() const;
101
102 /*
103 * Duplicate this and all descendants
104 *
105 * @param addToParentGroup if the original is part of a group then the new member will also
106 * be added to said group
107 */
108 SCH_GROUP* DeepDuplicate( bool addToParentGroup, SCH_COMMIT* aCommit = nullptr ) const;
109
111 bool HitTest( const VECTOR2I& aPosition, int aAccuracy = 0 ) const override;
112
114 bool HitTest( const BOX2I& aRect, bool aContained, int aAccuracy = 0 ) const override;
115
117 const BOX2I GetBoundingBox() const override;
118
120 INSPECT_RESULT Visit( INSPECTOR aInspector, void* aTestData,
121 const std::vector<KICAD_T>& aScanTypes ) override;
122
124 std::vector<int> ViewGetLayers() const override;
125
127 double ViewGetLOD( int aLayer, const KIGFX::VIEW* aView ) const override;
128
130 void Move( const VECTOR2I& aMoveVector ) override;
131
133 void Rotate( const VECTOR2I& aCenter, bool aRotateCCW ) override;
134
136 void MirrorHorizontally( int aCenter ) override;
137
139 void MirrorVertically( int aCenter ) override;
140
142 wxString GetItemDescription( UNITS_PROVIDER* aUnitsProvider, bool aFull ) const override;
143
145 BITMAPS GetMenuImage() const override;
146
148 void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
149
151 bool Matches( const EDA_SEARCH_DATA& aSearchData, void* aAuxData ) const override;
152
154 void RunOnChildren( const std::function<void( SCH_ITEM* )>& aFunction, RECURSE_MODE aMode ) override;
155
157 void swapData( SCH_ITEM* aImage ) override;
158};
159
160#endif
BITMAPS
A list of all bitmap identifiers.
Definition: bitmaps_list.h:33
The base class for create windows for drawing purpose.
A set of EDA_ITEMs (i.e., without duplicates).
Definition: eda_group.h:46
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:97
KICAD_T Type() const
Returns the type of object.
Definition: eda_item.h:109
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
A set of SCH_ITEMs (i.e., without duplicates).
Definition: sch_group.h:52
SCH_GROUP * DeepDuplicate(bool addToParentGroup, SCH_COMMIT *aCommit=nullptr) const
Definition: sch_group.cpp:156
void Move(const VECTOR2I &aMoveVector) override
Move the item by aMoveVector to a new position.
Definition: sch_group.cpp:247
std::vector< int > ViewGetLayers() const override
Definition: sch_group.cpp:232
BITMAPS GetMenuImage() const override
Return a pointer to an image to be used in menus.
Definition: sch_group.cpp:320
void Rotate(const VECTOR2I &aCenter, bool aRotateCCW) override
Rotate the item around aCenter 90 degrees in the clockwise direction.
Definition: sch_group.cpp:263
double Similarity(const SCH_ITEM &aOther) const override
Return a measure of how likely the other object is to represent the same object.
Definition: sch_group.cpp:391
EDA_ITEM * Clone() const override
Create a duplicate of this item with linked list members set to NULL.
Definition: sch_group.cpp:130
wxString GetClass() const override
Return the class name.
Definition: sch_group.h:64
static bool WithinScope(SCH_ITEM *aItem, SCH_GROUP *aScope, bool isSymbolEditor)
Definition: sch_group.cpp:103
bool Matches(const EDA_SEARCH_DATA &aSearchData, void *aAuxData) const override
Compare the item against the search criteria in aSearchData.
Definition: sch_group.cpp:333
bool operator==(const SCH_GROUP &aOther) const
Definition: sch_group.cpp:369
void GetMsgPanelInfo(EDA_DRAW_FRAME *aFrame, std::vector< MSG_PANEL_ITEM > &aList) override
Populate aList of MSG_PANEL_ITEM objects with it's internal state for display purposes.
Definition: sch_group.cpp:326
wxString GetItemDescription(UNITS_PROVIDER *aUnitsProvider, bool aFull) const override
Return a user-visible description string of this item.
Definition: sch_group.cpp:311
SCH_GROUP * DeepClone() const
Definition: sch_group.cpp:138
double ViewGetLOD(int aLayer, const KIGFX::VIEW *aView) const override
Definition: sch_group.cpp:238
INSPECT_RESULT Visit(INSPECTOR aInspector, void *aTestData, const std::vector< KICAD_T > &aScanTypes) override
May be re-implemented for each derived class in order to handle all the types given by its member dat...
Definition: sch_group.cpp:216
void MirrorVertically(int aCenter) override
Mirror item vertically about aCenter.
Definition: sch_group.cpp:295
void RunOnChildren(const std::function< void(SCH_ITEM *)> &aFunction, RECURSE_MODE aMode) override
Definition: sch_group.cpp:339
void SetPosition(const VECTOR2I &aNewpos) override
Definition: sch_group.cpp:122
std::unordered_set< SCH_ITEM * > GetSchItems() const
Definition: sch_group.cpp:50
static bool ClassOf(const EDA_ITEM *aItem)
Definition: sch_group.h:62
static EDA_GROUP * TopLevelGroup(SCH_ITEM *aItem, EDA_GROUP *aScope, bool isSymbolEditor)
Definition: sch_group.cpp:97
void swapData(SCH_ITEM *aImage) override
Swap the internal data structures aItem with the schematic item.
Definition: sch_group.cpp:173
void MirrorHorizontally(int aCenter) override
Mirror item horizontally about aCenter.
Definition: sch_group.cpp:279
bool HitTest(const VECTOR2I &aPosition, int aAccuracy=0) const override
Test if aPosition is inside or on the boundary of this item.
Definition: sch_group.cpp:184
EDA_ITEM * AsEdaItem() override
Definition: sch_group.h:60
const BOX2I GetBoundingBox() const override
Return the orthogonal bounding box of this object for display purposes.
Definition: sch_group.cpp:198
VECTOR2I GetPosition() const override
Definition: sch_group.cpp:116
Base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:168
RECURSE_MODE
Definition: eda_item.h:49
INSPECT_RESULT
Definition: eda_item.h:43
const INSPECTOR_FUNC & INSPECTOR
std::function passed to nested users by ref, avoids copying std::function.
Definition: eda_item.h:90
The Cairo implementation of the graphics abstraction layer.
Definition: eda_group.h:33
@ SCH_GROUP_T
Definition: typeinfo.h:173