KiCad PCB EDA Suite
view_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 (C) 2013 CERN
5 * Copyright (C) 2020-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Maciej Suminski <[email protected]>
8 *
9 * This program is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License
11 * as published by the Free Software Foundation; either version 2
12 * of the License, or (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, you may find one here:
21 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22 * or you may search the http://www.gnu.org website for the version 2 license,
23 * or you may write to the Free Software Foundation, Inc.,
24 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25 *
26 */
27
32#ifndef VIEW_GROUP_H_
33#define VIEW_GROUP_H_
34
35#include <view/view_item.h>
36#include <deque>
37
38namespace KIGFX
39{
46class VIEW_GROUP : public VIEW_ITEM
47{
48public:
49 VIEW_GROUP( VIEW* aView = nullptr );
50 virtual ~VIEW_GROUP();
51
55 virtual unsigned int GetSize() const;
56
60 virtual void Add( VIEW_ITEM* aItem );
61
65 virtual void Remove( VIEW_ITEM* aItem );
66
70 virtual void Clear();
71
72 virtual VIEW_ITEM* GetItem( unsigned int aIdx ) const;
73
77 virtual const BOX2I ViewBBox() const override;
78
85 virtual void ViewDraw( int aLayer, VIEW* aView ) const override;
86
93 virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
94
98 inline virtual void SetLayer( int aLayer )
99 {
100 m_layer = aLayer;
101 }
102
106 void FreeItems();
107
108protected:
109 virtual const std::vector<VIEW_ITEM*> updateDrawList() const;
110
111protected:
113 std::vector<VIEW_ITEM*> m_groupItems;
114};
115
116} // namespace KIGFX
117
118#endif // VIEW_GROUP_H_
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:47
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:69
virtual unsigned int GetSize() const
Return the number of stored items.
Definition: view_group.cpp:75
virtual void ViewDraw(int aLayer, VIEW *aView) const override
Draw all the stored items in the group on the given layer.
Definition: view_group.cpp:107
virtual VIEW_ITEM * GetItem(unsigned int aIdx) const
Definition: view_group.cpp:81
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:191
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return all the layers used by the stored items.
Definition: view_group.cpp:183
std::vector< VIEW_ITEM * > m_groupItems
Definition: view_group.h:113
virtual void Remove(VIEW_ITEM *aItem)
Remove an item from the group.
Definition: view_group.cpp:63
VIEW_GROUP(VIEW *aView=nullptr)
Definition: view_group.cpp:44
virtual ~VIEW_GROUP()
Definition: view_group.cpp:51
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:98
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:57
virtual const std::vector< VIEW_ITEM * > updateDrawList() const
Definition: view_group.cpp:200
virtual const BOX2I ViewBBox() const override
Return the bounding box for all stored items covering all its layers.
Definition: view_group.cpp:87
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:69
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266