KiCad PCB EDA Suite
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 <jon@craftyjon.com>
5  * Copyright (C) 2017 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 
25 #include <painter.h>
26 #include <gbr_display_options.h>
28 
29 #include <memory>
30 
31 
32 class EDA_ITEM;
34 
35 class GERBER_DRAW_ITEM;
36 class GERBER_FILE_IMAGE;
37 
38 
39 namespace KIGFX
40 {
41 class GAL;
42 
48 {
49 public:
50  friend class GERBVIEW_PAINTER;
51 
53 
55  void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
56 
62  void LoadDisplayOptions( const GBR_DISPLAY_OPTIONS* aOptions );
63 
65  virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
66 
72  inline const COLOR4D& GetLayerColor( int aLayer ) const
73  {
74  return m_layerColors[aLayer];
75  }
76 
83  inline void SetLayerColor( int aLayer, const COLOR4D& aColor )
84  {
85  m_layerColors[aLayer] = aColor;
86 
87  update(); // recompute other shades of the color
88  }
89 
91 
92  void SetBackgroundColor( const COLOR4D& aColor ) override
93  {
95  }
96 
97  const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_GRID ]; }
98 
99  const COLOR4D& GetCursorColor() override { return m_layerColors[ LAYER_CURSOR ]; }
100 
101  inline bool IsSpotFill() const
102  {
103  return m_spotFill;
104  }
105 
106  inline bool IsLineFill() const
107  {
108  return m_lineFill;
109  }
110 
111  inline bool IsPolygonFill() const
112  {
113  return m_polygonFill;
114  }
115 
116  inline bool IsShowNegativeItems() const
117  {
118  return m_showNegativeItems;
119  }
120 
121  inline bool IsShowCodes() const
122  {
123  return m_showCodes;
124  }
125 
126  inline bool IsDiffMode() const
127  {
128  return m_diffMode;
129  }
130 
133 
136 
139 
140 protected:
143 
146 
149 
152 
155 
158 
160  static const double MAX_FONT_SIZE;
161 };
162 
163 
168 class GERBVIEW_PAINTER : public PAINTER
169 {
170 public:
171  GERBVIEW_PAINTER( GAL* aGal );
172 
174  virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
175  {
176  m_gerbviewSettings = *static_cast<const GERBVIEW_RENDER_SETTINGS*>( aSettings );
177  }
178 
181  {
182  return &m_gerbviewSettings;
183  }
184 
186  virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
187 
188 protected:
190 
191  // Drawing functions
192  void draw( /*const*/ GERBER_DRAW_ITEM* aVia, int aLayer );
193 
195  void drawPolygon( GERBER_DRAW_ITEM* aParent, SHAPE_POLY_SET& aPolygon, bool aFilled );
196 
198  void drawFlashedShape( GERBER_DRAW_ITEM* aItem, bool aFilled );
199 
201  void drawApertureMacro( GERBER_DRAW_ITEM* aParent, bool aFilled );
202 
210  int getLineThickness( int aActualThickness ) const;
211 };
212 } // namespace KIGFX
213 
214 #endif /* __GERBVIEW_PAINTER_H */
GERBVIEW_RENDER_SETTINGS m_gerbviewSettings
Class GBR_DISPLAY_OPTIONS is a helper class to handle display options (filling modes and afew other o...
virtual const COLOR4D & GetColor(const VIEW_ITEM *aItem, int aLayer) const override
Function GetColor Returns the color that should be used to draw the specific VIEW_ITEM on the specifi...
bool m_showNegativeItems
Flag determining if negative items should be drawn with a "ghost" color.
virtual void ApplySettings(const RENDER_SETTINGS *aSettings) override
Function ApplySettings Loads colors and display modes settings that are going to be used when drawing...
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Class CAIRO_GAL is the cairo implementation of the graphics abstraction layer.
Definition: class_module.h:58
Class RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output ...
Definition: painter.h:56
static const double MAX_FONT_SIZE
Maximum font size for D-Codes and other strings.
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:263
const COLOR4D & GetGridColor() override
Function GetGridColor Returns current grid color settings.
const COLOR4D & GetCursorColor() override
Function GetCursorColor Returns current cursor color settings.
bool m_lineFill
Flag determining if lines should be drawn with fill.
void LoadDisplayOptions(const GBR_DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options.
Class GERBER_FILE_IMAGE holds the Image data and parameters for one gerber file and layer parameters ...
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW...
Definition: view_item.h:84
bool m_spotFill
Flag determining if spots should be drawn with fill.
void SetBackgroundColor(const COLOR4D &aColor) override
Sets the background color.
bool m_showCodes
Flag determining if D-Codes should be drawn.
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:308
wxString m_netHighlightString
If set to anything but an empty string, will highlight items with matching net.
wxString m_attributeHighlightString
If set to anything but an empty string, will highlight items with matching attribute.
Class GERBVIEW_PAINTER Contains methods for drawing GerbView-specific items.
virtual void update()
Function update Precalculates extra colors for layers (e.g.
Definition: painter.cpp:53
Class SHAPE_POLY_SET.
wxString m_componentHighlightString
If set to anything but an empty string, will highlight items with matching component.
Class GERBVIEW_RENDER_SETTINGS Stores GerbView specific render settings.
virtual GERBVIEW_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
bool m_polygonFill
Flag determining if polygons should be drawn with fill.
Board layer functions and definitions.
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:154
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
const COLOR4D & GetLayerColor(int aLayer) const
Function GetLayerColor Returns the color used to draw a layer.
void SetLayerColor(int aLayer, const COLOR4D &aColor)
Function SetLayerColor Changes the color used to draw a layer.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
bool m_diffMode
Flag determining if layers should be rendered in "diff" mode.
Class GAL is the abstract interface for drawing on a 2D-surface.
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39