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-2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[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#ifndef __VIEW_ITEM_H
28#define __VIEW_ITEM_H
29
30#include <vector>
31#include <bitset>
32#include <math/box2.h>
33#include <inspectable.h>
34
35
36namespace KIGFX
37{
38// Forward declarations
39class VIEW;
40class VIEW_ITEM_DATA;
41
46 NONE = 0x00,
47 APPEARANCE = 0x01,
48 COLOR = 0x02,
49 GEOMETRY = 0x04,
50 LAYERS = 0x08,
51 INITIAL_ADD = 0x10,
52 REPAINT = 0x20,
53 ALL = 0xef
54};
55
60 VISIBLE = 0x01,
61 HIDDEN = 0x02
63};
64
76class VIEW_ITEM : public INSPECTABLE
77{
78public:
80 {
81 }
82
83 virtual ~VIEW_ITEM();
84
85 VIEW_ITEM( const VIEW_ITEM& aOther ) = delete;
86 VIEW_ITEM& operator=( const VIEW_ITEM& aOther ) = delete;
87
93 virtual const BOX2I ViewBBox() const = 0;
94
106 virtual void ViewDraw( int aLayer, VIEW* aView ) const
107 {}
108
119 virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
120
132 virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
133 {
134 // By default always show the item
135 return 0.0;
136 }
137
139 {
140 return m_viewPrivData;
141 }
142
144 {
145 m_viewPrivData = nullptr;
146 }
147
148private:
149 friend class VIEW;
150
152};
153
154} // namespace KIGFX
155
156#endif
Class that other classes need to inherit from, in order to be inspectable.
Definition: inspectable.h:36
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
virtual const BOX2I ViewBBox() const =0
Return the bounding box of the item covering all its layers.
virtual ~VIEW_ITEM()
Definition: view_item.cpp:31
VIEW_ITEM_DATA * viewPrivData() const
Definition: view_item.h:138
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition: view_item.h:106
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
VIEW_ITEM(const VIEW_ITEM &aOther)=delete
virtual void ViewGetLayers(int aLayers[], int &aCount) const =0
Return the all the layers within the VIEW the object is painted on.
void ClearViewPrivData()
Definition: view_item.h:143
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:132
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:151
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
VIEW_UPDATE_FLAGS
Define the how severely the appearance of the item has been changed.
Definition: view_item.h:45
@ COLOR
Color has changed.
Definition: view_item.h:48
@ INITIAL_ADD
Item is being added to the view.
Definition: view_item.h:51
@ NONE
No updates are required.
Definition: view_item.h:46
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:52
@ APPEARANCE
Visibility flag has changed.
Definition: view_item.h:47
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:49
@ LAYERS
Layers have changed.
Definition: view_item.h:50
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:53
VIEW_VISIBILITY_FLAGS
Define the visibility of the item (temporarily hidden, invisible, etc).
Definition: view_item.h:59
@ HIDDEN
Item is temporarily hidden (e.g.
Definition: view_item.h:61
@ VISIBLE
Item is visible (in general)
Definition: view_item.h:60