KiCad PCB EDA Suite
Loading...
Searching...
No Matches
eda_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, see <https://www.gnu.org/licenses/>.
18 */
19
20#ifndef EDA_GROUP_H
21#define EDA_GROUP_H
22
23#include <commit.h>
24#include <eda_item.h>
25#include <lib_id.h>
26#include <lset.h>
27#include <unordered_set>
28
29namespace KIGFX
30{
31class VIEW;
32}
33
43{
44public:
45 virtual EDA_ITEM* AsEdaItem() = 0;
46 virtual ~EDA_GROUP() = default;
47
59 virtual bool DeserializeGroup( const google::protobuf::Any& aContainer, COMMIT* aCommit ) = 0;
60
61 wxString GetName() const { return m_name; }
62 void SetName( const wxString& aName ) { m_name = aName; }
63
64 std::unordered_set<EDA_ITEM*>& GetItems() { return m_items; }
65 const std::unordered_set<EDA_ITEM*>& GetItems() const { return m_items; }
66
70 bool ContainsItem( const EDA_ITEM* aItem ) const;
71
75 void AddItem( EDA_ITEM* aItem );
76
80 void RemoveItem( EDA_ITEM* aItem );
81 void RemoveAll();
82
83 std::vector<KIID> GetGroupMemberIds() const;
84
85 bool HasDesignBlockLink() const { return m_designBlockLibId.IsValid(); }
86
87 void SetDesignBlockLibId( const LIB_ID& aLibId ) { m_designBlockLibId = aLibId; }
89
90protected:
91 std::unordered_set<EDA_ITEM*> m_items; // Members of the group (no ownership)
92 wxString m_name; // Optional group name
93 LIB_ID m_designBlockLibId; // Optional link to a design block
94};
95
96#endif // CLASS_PCB_GROUP_H_
Represent a set of changes (additions, deletions or modifications) of a data model (e....
Definition commit.h:68
A set of EDA_ITEMs (i.e., without duplicates).
Definition eda_group.h:43
const LIB_ID & GetDesignBlockLibId() const
Definition eda_group.h:88
const std::unordered_set< EDA_ITEM * > & GetItems() const
Definition eda_group.h:65
wxString m_name
Definition eda_group.h:92
std::unordered_set< EDA_ITEM * > m_items
Definition eda_group.h:91
virtual ~EDA_GROUP()=default
std::unordered_set< EDA_ITEM * > & GetItems()
Definition eda_group.h:64
virtual bool DeserializeGroup(const google::protobuf::Any &aContainer, COMMIT *aCommit)=0
Deserializes the given protobuf message into this group.
wxString GetName() const
Definition eda_group.h:61
bool HasDesignBlockLink() const
Definition eda_group.h:85
LIB_ID m_designBlockLibId
Definition eda_group.h:93
void RemoveAll()
Definition eda_group.cpp:86
void SetDesignBlockLibId(const LIB_ID &aLibId)
Definition eda_group.h:87
void RemoveItem(EDA_ITEM *aItem)
Remove item from group.
Definition eda_group.cpp:77
void AddItem(EDA_ITEM *aItem)
Add item to group.
Definition eda_group.cpp:58
bool ContainsItem(const EDA_ITEM *aItem) const
Test if an item is a direct or nested member of this group.
Definition eda_group.cpp:26
std::vector< KIID > GetGroupMemberIds() const
Definition eda_group.cpp:95
virtual EDA_ITEM * AsEdaItem()=0
void SetName(const wxString &aName)
Definition eda_group.h:62
A base class for most all the KiCad significant classes used in schematics and boards.
Definition eda_item.h:98
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
A logical library item identifier and consists of various portions much like a URI.
Definition lib_id.h:45
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:30