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 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
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 
38 namespace KIGFX
39 {
46 class VIEW_GROUP : public VIEW_ITEM
47 {
48 public:
49  VIEW_GROUP( VIEW* aView = NULL );
50  virtual ~VIEW_GROUP();
51 
57  virtual unsigned int GetSize() const;
58 
64  virtual void Add( VIEW_ITEM* aItem );
65 
71  virtual void Remove( VIEW_ITEM* aItem );
72 
76  virtual void Clear();
77 
78  virtual VIEW_ITEM* GetItem( unsigned int aIdx ) const;
79 
85  virtual const BOX2I ViewBBox() const override;
86 
93  virtual void ViewDraw( int aLayer, VIEW* aView ) const override;
94 
101  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
102 
108  inline virtual void SetLayer( int aLayer )
109  {
110  m_layer = aLayer;
111  }
112 
116  void FreeItems();
117 
118 protected:
119  typedef std::vector<VIEW_ITEM*> ITEMS;
120 
121  virtual const ITEMS updateDrawList() const;
122 
124  int m_layer;
125 
128 };
129 
130 } // namespace KIGFX
131 
132 #endif // VIEW_GROUP_H_
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:194
virtual void Clear()
Remove all the stored items from the group.
Definition: view_group.cpp:75
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
virtual VIEW_ITEM * GetItem(unsigned int aIdx) const
Definition: view_group.cpp:87
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:113
virtual const ITEMS updateDrawList() const
Layer on which the group is drawn.
Definition: view_group.cpp:207
virtual unsigned int GetSize() const
Return the number of stored items.
Definition: view_group.cpp:81
virtual const BOX2I ViewBBox() const override
Return the bounding box for all stored items covering all its layers.
Definition: view_group.cpp:93
void FreeItems()
Free all the items that were added to the group.
Definition: view_group.cpp:198
VIEW_ITEM class definition.
#define NULL
int m_layer
Container for storing VIEW_ITEMs.
Definition: view_group.h:124
Extend VIEW_ITEM by possibility of grouping items into a single object.
Definition: view_group.h:46
virtual void Remove(VIEW_ITEM *aItem)
Remove an item from the group.
Definition: view_group.cpp:62
virtual void Add(VIEW_ITEM *aItem)
Add an item to the group.
Definition: view_group.cpp:56
VIEW_GROUP(VIEW *aView=NULL)
Definition: view_group.cpp:43
virtual void SetLayer(int aLayer)
Set layer used to draw the group.
Definition: view_group.h:108
virtual ~VIEW_GROUP()
Definition: view_group.cpp:50
std::vector< VIEW_ITEM * > ITEMS
Definition: view_group.h:119
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Return all the layers used by the stored items.
Definition: view_group.cpp:190
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67