-
-
Notifications
You must be signed in to change notification settings - Fork 487
/
gerbview_painter.h
169 lines (132 loc) · 4.86 KB
/
gerbview_painter.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jon Evans <[email protected]>
* Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation, either version 3 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __GERBVIEW_PAINTER_H
#define __GERBVIEW_PAINTER_H
#include <layer_ids.h>
#include <gal/painter.h>
#include <dcode.h>
#include <gbr_display_options.h>
#include <geometry/shape_poly_set.h>
#include <memory>
class EDA_ITEM;
class GERBER_DRAW_ITEM;
class GERBER_FILE_IMAGE;
namespace KIGFX
{
class GAL;
/**
* Store GerbView specific render settings.
*/
class GERBVIEW_RENDER_SETTINGS : public RENDER_SETTINGS
{
public:
friend class GERBVIEW_PAINTER;
GERBVIEW_RENDER_SETTINGS();
void LoadColors( const COLOR_SETTINGS* aSettings ) override;
/// @copydoc RENDER_SETTINGS::GetColor()
virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
/**
* Return the color used to draw a layer.
*
* @param aLayer is the layer number.
*/
inline const COLOR4D& GetLayerColor( int aLayer ) const
{
return m_layerColors[aLayer];
}
/**
* Change the color used to draw a layer.
*
* @param aLayer is the layer number.
* @param aColor is the new color.
*/
inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
{
m_layerColors[aLayer] = aColor;
update(); // recompute other shades of the color
}
const COLOR4D& GetBackgroundColor() const override
{
return m_layerColors[ LAYER_GERBVIEW_BACKGROUND ];
}
void SetBackgroundColor( const COLOR4D& aColor ) override
{
m_layerColors[ LAYER_GERBVIEW_BACKGROUND ] = aColor;
}
const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GERBVIEW_GRID ]; }
const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
bool GetShowPageLimits() const override;
/// Clear all highlight selections (dcode, net, component, attribute selection)
void ClearHighlightSelections();
/// If set to anything but an empty string, will highlight items with matching component
wxString m_componentHighlightString;
/// If set to anything but an empty string, will highlight items with matching net
wxString m_netHighlightString;
/// If set to anything but an empty string, will highlight items with matching attribute
wxString m_attributeHighlightString;
/// If set to anything but >0 (in fact 10 the min dcode value),
/// will highlight items with matching dcode
int m_dcodeHighlightValue;
protected:
/// Maximum font size for D-Codes and other strings
static const double MAX_FONT_SIZE;
};
/**
* Methods for drawing GerbView specific items.
*/
class GERBVIEW_PAINTER : public PAINTER
{
public:
GERBVIEW_PAINTER( GAL* aGal );
/// @copydoc PAINTER::GetSettings()
virtual GERBVIEW_RENDER_SETTINGS* GetSettings() override
{
return &m_gerbviewSettings;
}
/// @copydoc PAINTER::Draw()
virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
protected:
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings;
// Drawing functions
void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
/**
* Helper routine to draw a polygon.
*
* @param aParent Pointer to the draw item for AB Position calculation.
* @param aPolygon the polygon to draw.
* @param aFilled If true, draw the polygon as filled, otherwise only outline.
* @param aShift If true, draw the polygon relative to the parent item position.
*/
void drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
bool aFilled, bool aShift = false );
/// Helper to draw a flashed shape (aka spot)
void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
/// Helper to draw an aperture macro shape
void drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled );
/**
* Get the thickness to draw for a line (e.g. 0 thickness lines get a minimum value).
*
* @param aActualThickness line own thickness.
* @return the thickness to draw.
*/
int getLineThickness( int aActualThickness ) const;
};
} // namespace KIGFX
#endif /* __GERBVIEW_PAINTER_H */