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 <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 m_viewPrivData( nullptr ),
82 {
83 }
84
85 virtual ~VIEW_ITEM();
86
87 VIEW_ITEM( const VIEW_ITEM& aOther ) = delete;
88 VIEW_ITEM& operator=( const VIEW_ITEM& aOther ) = delete;
89
95 virtual const BOX2I ViewBBox() const = 0;
96
108 virtual void ViewDraw( int aLayer, VIEW* aView ) const
109 {}
110
121 virtual void ViewGetLayers( int aLayers[], int& aCount ) const = 0;
122
134 virtual double ViewGetLOD( int aLayer, VIEW* aView ) const
135 {
136 // By default always show the item
137 return 0.0;
138 }
139
141 {
142 return m_viewPrivData;
143 }
144
145 void SetForcedTransparency( double aForcedTransparency )
146 {
147 m_forcedTransparency = aForcedTransparency;
148 }
149
151 {
153 }
154
155private:
156 friend class VIEW;
157
160};
161
162} // namespace KIGFX
163
164#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
double m_forcedTransparency
Additional transparency for diff'ing items.
Definition: view_item.h:159
VIEW_ITEM_DATA * viewPrivData() const
Definition: view_item.h:140
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition: view_item.h:108
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
void SetForcedTransparency(double aForcedTransparency)
Definition: view_item.h:145
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:150
virtual double ViewGetLOD(int aLayer, VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition: view_item.h:134
VIEW_ITEM_DATA * m_viewPrivData
Definition: view_item.h:158
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition: view.h:67
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: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