KiCad PCB EDA Suite
Loading...
Searching...
No Matches
gerbview_painter.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) 2017 Jon Evans <[email protected]>
5 * Copyright (C) 2021 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * This program is free software: you can redistribute it and/or modify it
8 * under the terms of the GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful, but
13 * WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License along
18 * with this program. If not, see <http://www.gnu.org/licenses/>.
19 */
20
21#ifndef __GERBVIEW_PAINTER_H
22#define __GERBVIEW_PAINTER_H
23
24#include <layer_ids.h>
25#include <gal/painter.h>
26
27#include <dcode.h>
28#include <gbr_display_options.h>
30
31#include <memory>
32
33
34class EDA_ITEM;
37
38
39namespace KIGFX
40{
41class GAL;
42
47{
48public:
49 friend class GERBVIEW_PAINTER;
50
52
53 void LoadColors( const COLOR_SETTINGS* aSettings ) override;
54
56 virtual COLOR4D GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
57
63 inline const COLOR4D& GetLayerColor( int aLayer ) const
64 {
65 auto it = m_layerColors.find( aLayer );
66 return it == m_layerColors.end() ? COLOR4D::WHITE : it->second;
67 }
68
75 inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
76 {
77 m_layerColors[aLayer] = aColor;
78
79 update(); // recompute other shades of the color
80 }
81
82 const COLOR4D& GetBackgroundColor() const override
83 {
85 return it == m_layerColors.end() ? COLOR4D::BLACK : it->second;
86 }
87
88 void SetBackgroundColor( const COLOR4D& aColor ) override
89 {
91 }
92
93 const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GERBVIEW_GRID ]; }
94
95 const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
96
97 bool GetShowPageLimits() const override;
98
101
104
107
110
114
115protected:
117 static const double MAX_FONT_SIZE;
118};
119
120
125{
126public:
127 GERBVIEW_PAINTER( GAL* aGal );
128
131 {
132 return &m_gerbviewSettings;
133 }
134
136 virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
137
138protected:
140
141 // Drawing functions
142 void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
143
152 void drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
153 bool aFilled, bool aShift = false );
154
156 void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
157
159 void drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled );
160
167 int getLineThickness( int aActualThickness ) const;
168};
169} // namespace KIGFX
170
171#endif /* __GERBVIEW_PAINTER_H */
Color settings are a bit different than most of the settings objects in that there can be more than o...
A base class for most all the KiCad significant classes used in schematics and boards.
Definition: eda_item.h:89
Hold the image data and parameters for one gerber file and layer parameters.
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
static const COLOR4D WHITE
Definition: color4d.h:401
static const COLOR4D BLACK
Definition: color4d.h:402
Abstract interface for drawing on a 2D-surface.
Methods for drawing GerbView specific items.
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
void drawPolygon(GERBER_DRAW_ITEM *aParent, const SHAPE_POLY_SET &aPolygon, bool aFilled, bool aShift=false)
Helper routine to draw a polygon.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
int getLineThickness(int aActualThickness) const
Get the thickness to draw for a line (e.g.
void draw(GERBER_DRAW_ITEM *aVia, int aLayer)
void drawApertureMacro(GERBER_DRAW_ITEM *aParent, bool aFilled)
Helper to draw an aperture macro shape.
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
void drawFlashedShape(GERBER_DRAW_ITEM *aItem, bool aFilled)
Helper to draw a flashed shape (aka spot)
Store GerbView specific render settings.
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
wxString m_attributeHighlightString
If set to anything but an empty string, will highlight items with matching attribute.
void LoadColors(const COLOR_SETTINGS *aSettings) override
wxString m_componentHighlightString
If set to anything but an empty string, will highlight items with matching component.
void ClearHighlightSelections()
Clear all highlight selections (dcode, net, component, attribute selection)
int m_dcodeHighlightValue
If set to anything but >0 (in fact 10 the min dcode value), will highlight items with matching dcode.
static const double MAX_FONT_SIZE
Maximum font size for D-Codes and other strings.
wxString m_netHighlightString
If set to anything but an empty string, will highlight items with matching net.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Change the color used to draw a layer.
const COLOR4D & GetCursorColor() override
Return current cursor color settings.
const COLOR4D & GetLayerColor(int aLayer) const
Return the color used to draw a layer.
const COLOR4D & GetBackgroundColor() const override
Return current background color settings.
virtual COLOR4D GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Returns the color that should be used to draw the specific VIEW_ITEM on the specific layer using curr...
const COLOR4D & GetGridColor() override
Return current grid color settings.
bool GetShowPageLimits() const override
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:59
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
virtual void update()
Precalculates extra colors for layers (e.g.
std::map< int, COLOR4D > m_layerColors
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
Represent a set of closed polygons.
@ LAYER_GERBVIEW_BACKGROUND
Definition: layer_ids.h:434
@ LAYER_GERBVIEW_GRID
Definition: layer_ids.h:432
@ LAYER_CURSOR
PCB cursor.
Definition: layer_ids.h:222
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:247