KiCad PCB EDA Suite
sch_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) 2019 CERN
5  * @author Tomasz Wlostowski <tomasz.wlostowski@cern.ch>
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, you may find one here:
19  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
20  * or you may search the http://www.gnu.org website for the version 2 license,
21  * or you may write to the Free Software Foundation, Inc.,
22  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
23  */
24 
25 #ifndef __SCH_PAINTER_H
26 #define __SCH_PAINTER_H
27 
28 #include <sch_component.h>
29 
30 #include <painter.h>
31 
32 
33 class LIB_RECTANGLE;
34 class LIB_PIN;
35 class LIB_CIRCLE;
36 class LIB_ITEM;
37 class LIB_PART;
38 class LIB_ALIAS;
39 class LIB_POLYLINE;
40 class LIB_ARC;
41 class LIB_FIELD;
42 class LIB_TEXT;
43 class LIB_BEZIER;
44 class SCH_COMPONENT;
45 class SCH_FIELD;
46 class SCH_JUNCTION;
47 class SCH_LABEL;
48 class SCH_TEXT;
49 class SCH_HIERLABEL;
50 class SCH_GLOBALLABEL;
51 class SCH_SHEET;
52 class SCH_SHEET_PIN;
53 class SCH_MARKER;
54 class SCH_NO_CONNECT;
55 class SCH_LINE;
56 class SCH_BUS_ENTRY_BASE;
57 class SCH_BITMAP;
58 
59 namespace KIGFX
60 {
61 class GAL;
62 class SCH_PAINTER;
63 
64 
71 {
72 public:
73  friend class SCH_PAINTER;
74 
76 
78  void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
79 
81  virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
82 
83  bool IsBackgroundDark() const override
84  {
86 
87  return luma < 0.5;
88  }
89 
91 
92  void SetBackgroundColor( const COLOR4D& aColor ) override
93  {
95  }
96 
97  const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
98 
100 
101  int m_ShowUnit; // Show all units if 0
102  int m_ShowConvert; // Show all conversions if 0
103 
107 
109 };
110 
111 
116 class SCH_PAINTER : public PAINTER
117 {
118 public:
119  SCH_PAINTER( GAL* aGal );
120 
122  virtual bool Draw( const VIEW_ITEM*, int ) override;
123 
125  virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
126  {
127  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
128  }
129 
131  virtual SCH_RENDER_SETTINGS* GetSettings() override
132  {
133  return &m_schSettings;
134  }
135 
136 private:
137  void draw( LIB_RECTANGLE* aRect, int aLayer );
138  void draw( LIB_PIN* aPin, int aLayer );
139  void draw( LIB_CIRCLE* aCircle, int aLayer );
140  void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
141  void draw( LIB_ALIAS* aAlias, int aLayer );
142  void draw( LIB_ARC* aArc, int aLayer );
143  void draw( LIB_POLYLINE* aLine, int aLayer );
144  void draw( LIB_FIELD* aField, int aLayer );
145  void draw( LIB_TEXT* aText, int aLayer );
146  void draw( LIB_BEZIER* aCurve, int aLayer );
147  void draw( SCH_COMPONENT* aComp, int aLayer );
148  void draw( SCH_JUNCTION* aJct, int aLayer );
149  void draw( SCH_FIELD* aField, int aLayer );
150  void draw( SCH_TEXT* aText, int aLayer );
151  void draw( SCH_HIERLABEL* aLabel, int aLayer );
152  void draw( SCH_GLOBALLABEL* aLabel, int aLayer );
153  void draw( SCH_SHEET* aSheet, int aLayer );
154  void draw( SCH_NO_CONNECT* aNC, int aLayer );
155  void draw( SCH_MARKER* aMarker, int aLayer );
156  void draw( SCH_BITMAP* aBitmap, int aLayer );
157  void draw( SCH_LINE* aLine, int aLayer );
158  void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
159 
160  void drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows );
161  void drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows );
162 
163  bool isUnitAndConversionShown( const LIB_ITEM* aItem );
164 
165  float getShadowWidth();
166  COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows );
167  float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows );
168  float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows );
169  float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows );
170 
171  bool setDeviceColors( const LIB_ITEM* aItem, int aLayer );
172 
173  void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
174  void strokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle );
175 
177 };
178 
179 }; // namespace KIGFX
180 
181 
182 #endif
virtual bool Draw(const VIEW_ITEM *, int) override
Function Draw Takes an instance of VIEW_ITEM and passes it to a function that know how to draw the it...
SCH_PAINTER(GAL *aGal)
Class SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
Part library alias object definition.
double GetBrightness() const
Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1....
Definition: color4d.h:269
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
void drawPinDanglingSymbol(const VECTOR2I &aPos, bool aDrawingShadows)
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:265
Define a symbol library graphical text item.
Definition: lib_text.h:40
void drawDanglingSymbol(const wxPoint &aPos, bool aDrawingShadows)
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...
Definition: sch_painter.cpp:91
Field object used in symbol libraries.
Definition: lib_field.h:59
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer)
void SetBackgroundColor(const COLOR4D &aColor) override
Sets the background color.
Definition: sch_painter.h:92
const COLOR4D & GetGridColor() override
Function GetGridColor Returns current grid color settings.
Definition: sch_painter.h:97
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:84
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows)
The base class for drawable items used by schematic library components.
Definition: lib_item.h:61
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
Class PAINTER contains all the knowledge about how to draw graphical object onto any particular outpu...
Definition: painter.h:313
const COLOR4D & GetCursorColor() override
Function GetCursorColor Returns current cursor color settings.
Definition: sch_painter.h:99
Class SCH_PAINTER Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:116
Define a library symbol object.
void strokeText(const wxString &aText, const VECTOR2D &aPosition, double aRotationAngle)
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:75
float getTextThickness(const SCH_TEXT *aItem, bool aDrawingShadows)
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:42
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:209
virtual SCH_RENDER_SETTINGS * GetSettings() override
Function GetSettings Returns pointer to current settings that are going to be used when drawing items...
Definition: sch_painter.h:131
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: sch_painter.h:90
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: sch_painter.h:125
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:37
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:73
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
Class EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boa...
Definition: base_struct.h:163
bool IsBackgroundDark() const override
Definition: sch_painter.h:83
Class SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:70
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
void draw(LIB_RECTANGLE *aRect, int aLayer)
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:79
Class SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container clas...
Definition: sch_item.h:114
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:176
Class GAL is the abstract interface for drawing on a 2D-surface.
Class LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39