KiCad PCB EDA Suite
pcb_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) 2013 CERN
5  * Copyright (C) 2016 KiCad Developers, see AUTHORS.txt for contributors.
6  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
7  * @author Maciej Suminski <maciej.suminski@cern.ch>
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, you may find one here:
21  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
22  * or you may search the http://www.gnu.org website for the version 2 license,
23  * or you may write to the Free Software Foundation, Inc.,
24  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
25  */
26 
27 #ifndef __CLASS_PCB_PAINTER_H
28 #define __CLASS_PCB_PAINTER_H
29 
30 #include <painter.h>
31 
32 #include <memory>
33 
34 
35 class EDA_ITEM;
37 class DISPLAY_OPTIONS;
38 
39 class BOARD_ITEM;
40 class BOARD;
41 class VIA;
42 class TRACK;
43 class D_PAD;
44 class DRAWSEGMENT;
45 class MODULE;
46 class SEGZONE;
47 class ZONE_CONTAINER;
48 class TEXTE_PCB;
49 class TEXTE_MODULE;
50 class DIMENSION;
51 class PCB_TARGET;
52 class MARKER_PCB;
53 
54 namespace KIGFX
55 {
56 class GAL;
57 
63 {
64 public:
65  friend class PCB_PAINTER;
66 
69  {
70  CL_NONE = 0x00,
71 
72  // Object type
73  CL_PADS = 0x01,
74  CL_VIAS = 0x02,
75  CL_TRACKS = 0x04,
76 
77  // Existence
78  CL_NEW = 0x08,
79  CL_EDITED = 0x10,
80  CL_EXISTING = 0x20
81  };
82 
85  {
89  };
90 
92 
94  void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
95 
102  void LoadDisplayOptions( const DISPLAY_OPTIONS* aOptions );
103 
105  virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
106 
114  inline void SetSketchMode( int aItemLayer, bool aEnabled )
115  {
116  m_sketchMode[aItemLayer] = aEnabled;
117  }
118 
124  inline bool GetSketchMode( int aItemLayer ) const
125  {
126  return m_sketchMode[aItemLayer];
127  }
128 
129 protected:
132 
135 
138 
141 
144 
147 
149  bool m_netNamesOnVias = true;
150 
152  static const double MAX_FONT_SIZE;
153 
156 
159 };
160 
161 
166 class PCB_PAINTER : public PAINTER
167 {
168 public:
169  PCB_PAINTER( GAL* aGal );
170 
172  virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
173  {
174  m_pcbSettings = *static_cast<const PCB_RENDER_SETTINGS*>( aSettings );
175  }
176 
178  virtual PCB_RENDER_SETTINGS* GetSettings() override
179  {
180  return &m_pcbSettings;
181  }
182 
184  virtual bool Draw( const VIEW_ITEM* aItem, int aLayer ) override;
185 
186 protected:
188 
189  // Drawing functions for various types of PCB-specific items
190  void draw( const TRACK* aTrack, int aLayer );
191  void draw( const VIA* aVia, int aLayer );
192  void draw( const D_PAD* aPad, int aLayer );
193  void draw( const DRAWSEGMENT* aSegment, int aLayer );
194  void draw( const TEXTE_PCB* aText, int aLayer );
195  void draw( const TEXTE_MODULE* aText, int aLayer );
196  void draw( const MODULE* aModule, int aLayer );
197  void draw( const ZONE_CONTAINER* aZone );
198  void draw( const DIMENSION* aDimension, int aLayer );
199  void draw( const PCB_TARGET* aTarget );
200  void draw( const MARKER_PCB* aMarker );
201 
209  int getLineThickness( int aActualThickness ) const;
210 };
211 } // namespace KIGFX
212 
213 #endif /* __CLASS_PAINTER_H */
Class ZONE_CONTAINER handles a list of polygons defining a copper zone.
Definition: class_zone.h:78
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
CLEARANCE_MODE
Flags to control clearance lines visibility
Definition: pcb_painter.h:68
Class BOARD_ITEM is a base class for any item which can be embedded within the BOARD container class...
bool m_sketchMode[GAL_LAYER_ID_END]
Flag determining if items on a given layer should be drawn as an outline or a filled item ...
Definition: pcb_painter.h:131
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_padNumbers
Flag determining if pad numbers should be visible
Definition: pcb_painter.h:140
bool m_sketchBoardGfx
Flag determining if board graphic items should be outlined or stroked
Definition: pcb_painter.h:134
DISPLAY_ZONE_MODE m_displayZone
Option for different display modes for zones
Definition: pcb_painter.h:155
DISPLAY_ZONE_MODE
Determines how zones should be displayed
Definition: pcb_painter.h:84
PCB_RENDER_SETTINGS m_pcbSettings
Definition: pcb_painter.h:187
Add new GAL layers here.
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW...
Definition: view_item.h:82
void LoadDisplayOptions(const DISPLAY_OPTIONS *aOptions)
Function LoadDisplayOptions Loads settings related to display options (high-contrast mode...
Class PCB_PAINTER Contains methods for drawing PCB-specific items.
Definition: pcb_painter.h:166
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: pcb_painter.cpp:66
bool m_netNamesOnPads
Flag determining if net names should be visible for pads
Definition: pcb_painter.h:143
bool GetSketchMode(int aItemLayer) const
Function GetSketchMode Returns sketch mode setting for a given item layer.
Definition: pcb_painter.h:124
Class PCB_RENDER_SETTINGS Stores PCB specific render settings.
Definition: pcb_painter.h:62
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:278
static const double MAX_FONT_SIZE
Maximum font size for netnames (and other dynamically shown strings)
Definition: pcb_painter.h:152
virtual PCB_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: pcb_painter.h:178
int getLineThickness(int aActualThickness) const
Function getLineThickness() Get the thickness to draw for a line (e.g.
bool m_sketchFpGfx
Flag determining if footprint graphic items should be outlined or stroked
Definition: pcb_painter.h:137
Class DISPLAY_OPTIONS handles display options like enable/disable some optional drawings.
Definition: pcbstruct.h:62
bool m_netNamesOnTracks
Flag determining if net names should be visible for tracks
Definition: pcb_painter.h:146
virtual void ApplySettings(const RENDER_SETTINGS *aSettings) override
Function ApplySettings Loads colors and display modes settings that are going to be used when drawing...
Definition: pcb_painter.h:172
int m_clearance
Clearance visibility settings
Definition: pcb_painter.h:158
Class BOARD holds information pertinent to a Pcbnew printed circuit board.
Definition: class_board.h:169
void SetSketchMode(int aItemLayer, bool aEnabled)
Function SetSketchMode Turns on/off sketch mode for given item layer.
Definition: pcb_painter.h:114
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:151
virtual bool Draw(const VIEW_ITEM *aItem, int aLayer) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
PCB_PAINTER(GAL *aGal)
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Eeschema, Pcbnew and GerbView...
void draw(const TRACK *aTrack, int aLayer)
Class DIMENSION.
bool m_netNamesOnVias
Flag determining if net names should be visible for vias
Definition: pcb_painter.h:149
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