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_POLYLINE;
39 class LIB_ARC;
40 class LIB_FIELD;
41 class LIB_TEXT;
42 class LIB_BEZIER;
43 class SCH_COMPONENT;
44 class SCH_FIELD;
45 class SCH_JUNCTION;
46 class SCH_LABEL;
47 class SCH_TEXT;
48 class SCH_HIERLABEL;
49 class SCH_GLOBALLABEL;
50 class SCH_SHEET;
51 class SCH_SHEET_PIN;
52 class SCH_MARKER;
53 class SCH_NO_CONNECT;
54 class SCH_LINE;
55 class SCH_BUS_ENTRY_BASE;
56 class SCH_BITMAP;
57 
58 namespace KIGFX
59 {
60 class GAL;
61 class SCH_PAINTER;
62 
63 
70 {
71 public:
72  friend class SCH_PAINTER;
73 
75 
77  void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
78 
80  virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
81 
82  bool IsBackgroundDark() const override
83  {
85 
86  return luma < 0.5;
87  }
88 
89  const COLOR4D& GetBackgroundColor() override
90  {
92  }
93 
94  void SetBackgroundColor( const COLOR4D& aColor ) override
95  {
97  }
98 
99  const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
100 
102 
103  int m_ShowUnit; // Show all units if 0
104  int m_ShowConvert; // Show all conversions if 0
105 
111 };
112 
113 
118 class SCH_PAINTER : public PAINTER
119 {
120 public:
121  SCH_PAINTER( GAL* aGal );
122 
124  virtual bool Draw( const VIEW_ITEM*, int ) override;
125 
127  virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
128  {
129  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
130  }
131 
133  virtual SCH_RENDER_SETTINGS* GetSettings() override
134  {
135  return &m_schSettings;
136  }
137 
138 private:
139  void draw( LIB_RECTANGLE* aRect, int aLayer );
140  void draw( LIB_PIN* aPin, int aLayer );
141  void draw( LIB_CIRCLE* aCircle, int aLayer );
142  void draw( LIB_PART* aPart, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0 );
143  void draw( LIB_ARC* aArc, int aLayer );
144  void draw( LIB_POLYLINE* aLine, int aLayer );
145  void draw( LIB_FIELD* aField, int aLayer );
146  void draw( LIB_TEXT* aText, int aLayer );
147  void draw( LIB_BEZIER* aCurve, int aLayer );
148  void draw( SCH_COMPONENT* aComp, int aLayer );
149  void draw( SCH_JUNCTION* aJct, int aLayer );
150  void draw( SCH_FIELD* aField, int aLayer );
151  void draw( SCH_TEXT* aText, int aLayer );
152  void draw( SCH_HIERLABEL* aLabel, int aLayer );
153  void draw( SCH_GLOBALLABEL* aLabel, int aLayer );
154  void draw( SCH_SHEET* aSheet, int aLayer );
155  void draw( SCH_NO_CONNECT* aNC, int aLayer );
156  void draw( SCH_MARKER* aMarker, int aLayer );
157  void draw( SCH_BITMAP* aBitmap, int aLayer );
158  void draw( SCH_LINE* aLine, int aLayer );
159  void draw( SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
160 
161  void drawPinDanglingSymbol( const VECTOR2I& aPos, bool aDrawingShadows );
162  void drawDanglingSymbol( const wxPoint& aPos, bool aDrawingShadows );
163 
164  bool isUnitAndConversionShown( const LIB_ITEM* aItem );
165 
166  float getShadowWidth();
167  COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows );
168  float getLineWidth( const LIB_ITEM* aItem, bool aDrawingShadows );
169  float getLineWidth( const SCH_ITEM* aItem, bool aDrawingShadows );
170  float getTextThickness( const SCH_TEXT* aItem, bool aDrawingShadows );
171 
172  bool setDeviceColors( const LIB_ITEM* aItem, int aLayer );
173  void fillIfSelection( int aLayer );
174 
175  void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
176  void strokeText( const wxString& aText, const VECTOR2D& aPosition, double aRotationAngle );
177 
179 };
180 
181 }; // namespace KIGFX
182 
183 
184 #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)
SCH_FIELD instances are attached to a component and provide a place for the component's value,...
Definition: sch_field.h:52
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: color4d.cpp:131
RENDER_SETTINGS Contains all the knowledge about how graphical objects are drawn on any output surfac...
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:96
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:94
const COLOR4D & GetGridColor() override
Function GetGridColor Returns current grid color settings.
Definition: sch_painter.h:99
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)
void fillIfSelection(int aLayer)
The base class for drawable items used by schematic library components.
Definition: lib_item.h:60
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:41
PAINTER contains all the knowledge about how to draw graphical object onto any particular output devi...
Definition: painter.h:313
const COLOR4D & GetCursorColor() override
Function GetCursorColor Returns current cursor color settings.
Definition: sch_painter.h:101
SCH_PAINTER Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:118
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:206
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:133
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: sch_painter.h:89
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:127
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:38
bool isUnitAndConversionShown(const LIB_ITEM *aItem)
SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:89
float getLineWidth(const LIB_ITEM *aItem, bool aDrawingShadows)
EDA_ITEM is a base class for most all the KiCad significant classes, used in schematics and boards.
Definition: base_struct.h:163
bool IsBackgroundDark() const override
Definition: sch_painter.h:82
SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:69
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:84
SCH_ITEM is a base class for any item which can be embedded within the SCHEMATIC container class,...
Definition: sch_item.h:136
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:178
Class GAL is the abstract interface for drawing on a 2D-surface.
LIB_BEZIER defines bezier curve graphic body item.
Definition: lib_bezier.h:35
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39