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 return m_layerColors[aLayer];
66 }
67
74 inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
75 {
76 m_layerColors[aLayer] = aColor;
77
78 update(); // recompute other shades of the color
79 }
80
81 const COLOR4D& GetBackgroundColor() const override
82 {
84 }
85
86 void SetBackgroundColor( const COLOR4D& aColor ) override
87 {
89 }
90
91 const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GERBVIEW_GRID ]; }
92
93 const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
94
95 bool GetShowPageLimits() const override;
96
99
102
105
108
112
113protected:
115 static const double MAX_FONT_SIZE;
116};
117
118
123{
124public:
125 GERBVIEW_PAINTER( GAL* aGal );
126
129 {
130 return &m_gerbviewSettings;
131 }
132
134 virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
135
136protected:
138
139 // Drawing functions
140 void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
141
150 void drawPolygon( GERBER_DRAW_ITEM* aParent, const SHAPE_POLY_SET& aPolygon,
151 bool aFilled, bool aShift = false );
152
154 void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
155
157 void drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled );
158
165 int getLineThickness( int aActualThickness ) const;
166};
167} // namespace KIGFX
168
169#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
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.
COLOR4D m_layerColors[LAYER_ID_COUNT]
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