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  * @author Maciej Suminski <maciej.suminski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  *
24  */
25 
33 #ifndef VIEW_GROUP_H_
34 #define VIEW_GROUP_H_
35 
36 #include <view/view_item.h>
37 #include <deque>
38 
39 namespace KIGFX
40 {
41 
42 class VIEW_GROUP : public VIEW_ITEM
43 {
44 protected:
45  typedef std::vector<VIEW_ITEM*> ITEMS;
46 
47 public:
48  VIEW_GROUP( VIEW* aView = NULL );
49  virtual ~VIEW_GROUP();
50 
57  virtual unsigned int GetSize() const;
58 
65  virtual void Add( VIEW_ITEM* aItem );
66 
73  virtual void Remove( VIEW_ITEM* aItem );
74 
79  virtual void Clear();
80 
81  virtual VIEW_ITEM* GetItem( unsigned int aIdx ) const;
82 
89  virtual const BOX2I ViewBBox() const override;
90 
98  virtual void ViewDraw( int aLayer, VIEW* aView ) const override;
99 
107  virtual void ViewGetLayers( int aLayers[], int& aCount ) const override;
108 
115  inline virtual void SetLayer( int aLayer )
116  {
117  m_layer = aLayer;
118  }
119 
124  void FreeItems();
125 
126 protected:
127 
128  virtual const ITEMS updateDrawList() const;
129 
131  int m_layer;
132 
133 protected:
136 
137 private:
138  void updateBbox();
139 };
140 
141 } // namespace KIGFX
142 
143 #endif // VIEW_GROUP_H_
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:56
virtual VIEW_ITEM * GetItem(unsigned int aIdx) const
Definition: view_group.cpp:85
virtual const ITEMS updateDrawList() const
Definition: view_group.cpp:148
virtual void Clear()
Function Clear() Removes all the stored items from the group.
Definition: view_group.cpp:74
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW...
Definition: view_item.h:82
virtual void ViewDraw(int aLayer, VIEW *aView) const override
Function ViewDraw() Draws all the stored items in the group on the given layer.
Definition: view_group.cpp:99
virtual const BOX2I ViewBBox() const override
Function ViewBBox() Returns the bounding box for all stored items covering all its layers...
Definition: view_group.cpp:90
void FreeItems()
Function FreeItems() Frees all the items that were added to the group.
Definition: view_group.cpp:139
VIEW_ITEM class definition.
int m_layer
Layer on which the group is drawn.
Definition: view_group.h:131
virtual void Remove(VIEW_ITEM *aItem)
Function Remove() Removes an item from the group.
Definition: view_group.cpp:61
virtual void Add(VIEW_ITEM *aItem)
Function Add() Adds an item to the group.
Definition: view_group.cpp:55
VIEW_GROUP(VIEW *aView=NULL)
Definition: view_group.cpp:43
virtual void SetLayer(int aLayer)
Function SetLayer() Sets layer used to draw the group.
Definition: view_group.h:115
virtual unsigned int GetSize() const
Function GetSize() Returns the number of stored items.
Definition: view_group.cpp:80
virtual ~VIEW_GROUP()
Definition: view_group.cpp:49
std::vector< VIEW_ITEM * > ITEMS
Definition: view_group.h:45
ITEMS m_groupItems
Container for storing VIEW_ITEMs.
Definition: view_group.h:135
virtual void ViewGetLayers(int aLayers[], int &aCount) const override
Function ViewGetLayers() Returns all the layers used by the stored items.
Definition: view_group.cpp:131
Class VIEW.
Definition: view.h:58