KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 <gal/gal.h>
31#include <vector>
32#include <bitset>
33#include <math/box2.h>
34#include <inspectable.h>
35
36#if defined( _MSC_VER )
37#pragma warning( push )
38#pragma warning( disable : 4275 )
39#endif
40
41namespace KIGFX
42{
43// Forward declarations
44class VIEW;
45class 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,
69 OVERLAY_HIDDEN = 0x04
70};
71
84{
85public:
86 VIEW_ITEM( bool isSCH_ITEM = false, bool isBOARD_ITEM = false ) :
87 m_isSCH_ITEM( isSCH_ITEM ),
88 m_isBOARD_ITEM( isBOARD_ITEM ),
89 m_viewPrivData( nullptr ),
90 m_forcedTransparency( 0.0 )
91 {
92 }
93
94 virtual ~VIEW_ITEM();
95
96 VIEW_ITEM( const VIEW_ITEM& aOther ) = delete;
97 VIEW_ITEM& operator=( const VIEW_ITEM& aOther ) = delete;
98
99 bool IsSCH_ITEM() const { return m_isSCH_ITEM; }
100 bool IsBOARD_ITEM() const { return m_isBOARD_ITEM; }
106 virtual const BOX2I ViewBBox() const = 0;
107
119 virtual void ViewDraw( int aLayer, VIEW* aView ) const
120 {}
121
129 virtual std::vector<int> ViewGetLayers() const = 0;
130
142 virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
143 {
144 // By default always show the item
145 return 0.0;
146 }
147
149 {
150 return m_viewPrivData;
151 }
152
153 void SetForcedTransparency( double aForcedTransparency )
154 {
155 m_forcedTransparency = aForcedTransparency;
156 }
157
159 {
160 return m_forcedTransparency;
161 }
162
163private:
164 friend class VIEW;
165
170};
171
172} // namespace KIGFX
173
174#if defined( _MSC_VER )
175#pragma warning( pop )
176#endif
177
178#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:84
virtual const BOX2I ViewBBox() const =0
Return the bounding box of the item covering all its layers.
VIEW_ITEM(bool isSCH_ITEM=false, bool isBOARD_ITEM=false)
Definition: view_item.h:86
bool IsSCH_ITEM() const
Definition: view_item.h:99
double m_forcedTransparency
Additional transparency for diff'ing items.
Definition: view_item.h:169
VIEW_ITEM_DATA * viewPrivData() const
Definition: view_item.h:148
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition: view_item.h:119
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
void SetForcedTransparency(double aForcedTransparency)
Definition: view_item.h:153
virtual std::vector< int > ViewGetLayers() const =0
Return the all the layers within the VIEW the object is painted on.
bool IsBOARD_ITEM() const
Definition: view_item.h:100
VIEW_ITEM(const VIEW_ITEM &aOther)=delete
double GetForcedTransparency() const
Definition: view_item.h:158
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:142
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:168
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:68
#define GAL_API
Definition: gal.h:28
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247
VIEW_UPDATE_FLAGS
Define the how severely the appearance of the item has been changed.
Definition: view_item.h:50
@ COLOR
Color has changed.
Definition: view_item.h:53
@ INITIAL_ADD
Item is being added to the view.
Definition: view_item.h:56
@ NONE
No updates are required.
Definition: view_item.h:51
@ REPAINT
Item needs to be redrawn.
Definition: view_item.h:57
@ APPEARANCE
Visibility flag has changed.
Definition: view_item.h:52
@ GEOMETRY
Position or shape has changed.
Definition: view_item.h:54
@ LAYERS
Layers have changed.
Definition: view_item.h:55
@ ALL
All except INITIAL_ADD.
Definition: view_item.h:58
VIEW_VISIBILITY_FLAGS
Define the visibility of the item (temporarily hidden, invisible, etc).
Definition: view_item.h:64
@ HIDDEN
Item is temporarily hidden (usually in favor of a being drawn from an overlay, such as a SELECTION).
Definition: view_item.h:66
@ OVERLAY_HIDDEN
Item is temporarily hidden from being drawn on an overlay.
Definition: view_item.h:69
@ VISIBLE
Item is visible (in general)
Definition: view_item.h:65