KiCad PCB EDA Suite
view_item.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-2016 CERN
5  * Copyright (C) 2020 KiCad Developers, see AUTHORS.txt for contributors.
6  *
7  * @author Tomasz Wlostowski <tomasz.wlostowski@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 
32 #ifndef __VIEW_ITEM_H
33 #define __VIEW_ITEM_H
34 
35 #include <vector>
36 #include <bitset>
37 #include <math/box2.h>
38 #include <inspectable.h>
39 
40 
41 namespace KIGFX
42 {
43 // Forward declarations
44 class VIEW;
45 class VIEW_ITEM_DATA;
46 
51  NONE = 0x00,
52  APPEARANCE = 0x01,
53  COLOR = 0x02,
54  GEOMETRY = 0x04,
55  LAYERS = 0x08,
56  INITIAL_ADD = 0x10,
57  REPAINT = 0x20,
58  ALL = 0xef
59 };
60 
65  VISIBLE = 0x01,
66  HIDDEN = 0x02
67 };
69 
81 class VIEW_ITEM : public INSPECTABLE
82 {
83 public:
84  VIEW_ITEM() : m_viewPrivData( nullptr )
85  {
86  }
87 
88  virtual ~VIEW_ITEM();
89 
90  VIEW_ITEM( const VIEW_ITEM& aOther ) = delete;
91  VIEW_ITEM& operator=( const VIEW_ITEM& aOther ) = delete;
92 
98  virtual const BOX2I ViewBBox() const = 0;
99 
111  virtual void ViewDraw( int aLayer, VIEW* aView ) const
112  {}
113 
124  virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
125 
137  virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
138  {
139  // By default always show the item
140  return 0.0;
141  }
142 
144  {
145  return m_viewPrivData;
146  }
147 
149  {
150  m_viewPrivData = nullptr;
151  }
152 
153 private:
154  friend class VIEW;
155 
157 };
158 
159 } // namespace KIGFX
160 
161 #endif
Item is being added to the view.
Definition: view_item.h:56
Item is temporarily hidden (e.g.
Definition: view_item.h:66
VIEW_VISIBILITY_FLAGS
Define the visibility of the item (temporarily hidden, invisible, etc).
Definition: view_item.h:64
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:156
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:236
Visibility flag has changed.
Definition: view_item.h:52
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:81
Color has changed.
Definition: view_item.h:53
All except INITIAL_ADD.
Definition: view_item.h:58
virtual ~VIEW_ITEM()
Definition: view_item.cpp:32
Item needs to be redrawn.
Definition: view_item.h:57
VIEW_ITEM_DATA * viewPrivData() const
Definition: view_item.h:143
virtual void ViewGetLayers(int aLayers[], int &aCount) const =0
Return the all the layers within the VIEW the object is painted on.
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
VIEW_UPDATE_FLAGS
Define the how severely the appearance of the item has been changed.
Definition: view_item.h:50
Item is visible (in general)
Definition: view_item.h:65
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:35
No updates are required.
Definition: view_item.h:51
void ClearViewPrivData()
Definition: view_item.h:148
Layers have changed.
Definition: view_item.h:55
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
virtual const BOX2I ViewBBox() const =0
Return the bounding box of the item covering all its layers.
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:137
Position or shape has changed.
Definition: view_item.h:54
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition: view_item.h:111