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 The 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, see <https://www.gnu.org/licenses/>.
21 */
22
23#pragma once
24
25#include <bitset>
26#include <vector>
27#include <limits>
28
29#include <gal/gal.h>
30#include <math/box2.h>
31#include <inspectable.h>
32
33#if defined( _MSC_VER )
34#pragma warning( push )
35#pragma warning( disable : 4275 )
36#endif
37
38namespace KIGFX
39{
40// Forward declarations
41class VIEW;
42class VIEW_ITEM_DATA;
43
48 NONE = 0x00,
49 APPEARANCE = 0x01,
50 COLOR = 0x02,
51 GEOMETRY = 0x04,
52 LAYERS = 0x08,
53 INITIAL_ADD = 0x10,
54 REPAINT = 0x20,
55 ALL = 0xef
56};
57
62 VISIBLE = 0x01,
63
66 HIDDEN = 0x02,
68};
69
82{
83public:
84 VIEW_ITEM( bool isSCH_ITEM = false, bool isBOARD_ITEM = false ) :
85 m_isSCH_ITEM( isSCH_ITEM ),
86 m_isBOARD_ITEM( isBOARD_ITEM ),
87 m_viewPrivData( nullptr ),
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
97 bool IsSCH_ITEM() const { return m_isSCH_ITEM; }
98 bool IsBOARD_ITEM() const { return m_isBOARD_ITEM; }
99
103 virtual wxString GetClass() const = 0;
104
110 virtual const BOX2I ViewBBox() const = 0;
111
123 virtual void ViewDraw( int aLayer, VIEW* aView ) const
124 {}
125
133 virtual std::vector<int> ViewGetLayers() const = 0;
134
151 virtual double ViewGetLOD( int aLayer, const VIEW* aView ) const
152 {
153 // By default always show the item
154 return LOD_SHOW;
155 }
156
158 {
159 return m_viewPrivData;
160 }
161
162 void SetForcedTransparency( double aForcedTransparency )
163 {
164 m_forcedTransparency = aForcedTransparency;
165 }
166
168 {
170 }
171
172protected:
176 static constexpr double LOD_HIDE = std::numeric_limits<double>::max();
177
181 static constexpr double LOD_SHOW = 0.0;
182
198 static double lodScaleForThreshold( const KIGFX::VIEW* aView, int aWhatIu, int aThresholdIu );
199
200private:
201 friend class VIEW;
202
207};
208
209} // namespace KIGFX
210
211#if defined( _MSC_VER )
212#pragma warning( pop )
213#endif
BOX2< VECTOR2I > BOX2I
Definition box2.h:918
Class that other classes need to inherit from, in order to be inspectable.
Definition inspectable.h:38
An abstract base class for deriving all objects that can be added to a VIEW.
Definition view_item.h:82
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:84
static double lodScaleForThreshold(const KIGFX::VIEW *aView, int aWhatIu, int aThresholdIu)
Get the scale at which aWhatIu would be drawn at the same size as aThresholdIu on screen.
Definition view_item.cpp:35
bool IsSCH_ITEM() const
Definition view_item.h:97
double m_forcedTransparency
Additional transparency for diff'ing items.
Definition view_item.h:206
VIEW_ITEM_DATA * viewPrivData() const
Definition view_item.h:157
virtual void ViewDraw(int aLayer, VIEW *aView) const
Draw the parts of the object belonging to layer aLayer.
Definition view_item.h:123
VIEW_ITEM & operator=(const VIEW_ITEM &aOther)=delete
void SetForcedTransparency(double aForcedTransparency)
Definition view_item.h:162
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:98
virtual wxString GetClass() const =0
Return the class name.
friend class VIEW
Definition view_item.h:201
static constexpr double LOD_HIDE
Return this constant from ViewGetLOD() to hide the item unconditionally.
Definition view_item.h:176
VIEW_ITEM(const VIEW_ITEM &aOther)=delete
double GetForcedTransparency() const
Definition view_item.h:167
static constexpr double LOD_SHOW
Return this constant from ViewGetLOD() to show the item unconditionally.
Definition view_item.h:181
virtual double ViewGetLOD(int aLayer, const VIEW *aView) const
Return the level of detail (LOD) of the item.
Definition view_item.h:151
VIEW_ITEM_DATA * m_viewPrivData
Definition view_item.h:205
Hold a (potentially large) number of VIEW_ITEMs and renders them on a graphics device provided by the...
Definition view.h:63
#define GAL_API
Definition gal.h:27
The Cairo implementation of the graphics abstraction layer.
Definition eda_group.h:29
VIEW_UPDATE_FLAGS
Define the how severely the appearance of the item has been changed.
Definition view_item.h:47
@ COLOR
Color has changed.
Definition view_item.h:50
@ INITIAL_ADD
Item is being added to the view.
Definition view_item.h:53
@ NONE
No updates are required.
Definition view_item.h:48
@ REPAINT
Item needs to be redrawn.
Definition view_item.h:54
@ APPEARANCE
Visibility flag has changed.
Definition view_item.h:49
@ GEOMETRY
Position or shape has changed.
Definition view_item.h:51
@ LAYERS
Layers have changed.
Definition view_item.h:52
@ ALL
All except INITIAL_ADD.
Definition view_item.h:55
VIEW_VISIBILITY_FLAGS
Define the visibility of the item (temporarily hidden, invisible, etc).
Definition view_item.h:61
@ 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:67
@ VISIBLE
Item is visible (in general)
Definition view_item.h:62