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:
87 m_viewPrivData( nullptr ),
88 m_forcedTransparency( 0.0 )
89 {
90 }
91
92 virtual ~VIEW_ITEM();
93
94 VIEW_ITEM( const VIEW_ITEM& aOther ) = delete;
95 VIEW_ITEM& operator=( const VIEW_ITEM& aOther ) = delete;
96
102 virtual const BOX2I ViewBBox() const = 0;
103
115 virtual void ViewDraw( int aLayer, VIEW* aView ) const
116 {}
117
128 virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
129
141 virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
142 {
143 // By default always show the item
144 return 0.0;
145 }
146
148 {
149 return m_viewPrivData;
150 }
151
152 void SetForcedTransparency( double aForcedTransparency )
153 {
154 m_forcedTransparency = aForcedTransparency;
155 }
156
158 {
159 return m_forcedTransparency;
160 }
161
162private:
163 friend class VIEW;
164
167};
168
169} // namespace KIGFX
170
171#if defined( _MSC_VER )
172#pragma warning( pop )
173#endif
174
175#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.
double m_forcedTransparency
Additional transparency for diff'ing items.
Definition: view_item.h:166
VIEW_ITEM_DATA * viewPrivData() const
Definition: view_item.h:147
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition: view_item.h:115
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
void SetForcedTransparency(double aForcedTransparency)
Definition: view_item.h:152
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.
double GetForcedTransparency() const
Definition: view_item.h:157
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:141
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:165
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