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-2020 CERN
5 * Copyright (C) 2020-2022 KiCad Developers, see AUTHORS.txt for contributors.
6 *
7 * @author Tomasz Wlostowski <[email protected]>
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 __SCH_PAINTER_H
28#define __SCH_PAINTER_H
29
30#include <sch_symbol.h>
31
32#include <painter.h>
33
34
35class LIB_PIN;
36class LIB_SHAPE;
37class LIB_ITEM;
38class LIB_SYMBOL;
39class LIB_FIELD;
40class LIB_TEXT;
41class LIB_TEXTBOX;
42class SCH_SYMBOL;
43class SCH_FIELD;
44class SCH_JUNCTION;
45class SCH_LABEL;
46class SCH_TEXT;
47class SCH_TEXTBOX;
48class SCH_HIERLABEL;
50class SCH_GLOBALLABEL;
51class SCH_SHEET;
52class SCH_SHEET_PIN;
53class SCH_SHAPE;
54class SCH_MARKER;
55class SCH_NO_CONNECT;
56class SCH_LINE;
58class SCH_BITMAP;
59class SCHEMATIC;
60
61namespace KIGFX
62{
63class GAL;
64class SCH_PAINTER;
65
66
71{
72public:
73 friend class SCH_PAINTER;
74
76
77 void LoadColors( const COLOR_SETTINGS* aSettings ) override;
78
80 virtual 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() const override
90 {
92 }
93
94 void SetBackgroundColor( const COLOR4D& aColor ) override
95 {
97 }
98
100 {
101 return (float) m_defaultPenWidth / 3.0F;
102 }
103
105
107
108 bool GetShowPageLimits() const override;
109
110public:
112
113 int m_ShowUnit; // Show all units if 0
114 int m_ShowConvert; // Show all conversions if 0
115
117 bool m_ShowPinNumbers; // Force showing of pin numbers (normally symbol-specific)
120
122
123 double m_LabelSizeRatio; // Proportion of font size to label box
124 double m_TextOffsetRatio; // Proportion of font size to offset text above/below
125 // wires, buses, etc.
127};
128
129
133class SCH_PAINTER : public PAINTER
134{
135public:
136 SCH_PAINTER( GAL* aGal );
137
139 virtual bool Draw( const VIEW_ITEM*, int ) override;
140
142 virtual SCH_RENDER_SETTINGS* GetSettings() override { return &m_schSettings; }
143
144 void SetSchematic( SCHEMATIC* aSchematic ) { m_schematic = aSchematic; }
145
146private:
147 void draw( const EDA_ITEM*, int, bool aDimmed );
148 void draw( const LIB_PIN* aPin, int aLayer, bool aDimmed );
149 void draw( const LIB_SHAPE* aCircle, int aLayer, bool aDimmed );
150 void draw( const LIB_SYMBOL* aSymbol, int, bool aDrawFields = true, int aUnit = 0,
151 int aConvert = 0, bool aDimmed = false );
152 void draw( const LIB_FIELD* aField, int aLayer, bool aDimmed );
153 void draw( const LIB_TEXT* aText, int aLayer, bool aDimmed );
154 void draw( const LIB_TEXTBOX* aTextBox, int aLayer, bool aDimmed );
155 void draw( const SCH_SYMBOL* aSymbol, int aLayer );
156 void draw( const SCH_JUNCTION* aJct, int aLayer );
157 void draw( const SCH_FIELD* aField, int aLayer, bool aDimmed );
158 void draw( const SCH_SHAPE* aShape, int aLayer );
159 void draw( const SCH_TEXTBOX* aTextBox, int aLayer );
160 void draw( const SCH_TEXT* aText, int aLayer );
161 void draw( const SCH_LABEL* aText, int aLayer );
162 void draw( const SCH_DIRECTIVE_LABEL* aLabel, int aLayer );
163 void draw( const SCH_HIERLABEL* aLabel, int aLayer );
164 void draw( const SCH_GLOBALLABEL* aLabel, int aLayer );
165 void draw( const SCH_SHEET* aSheet, int aLayer );
166 void draw( const SCH_NO_CONNECT* aNC, int aLayer );
167 void draw( const SCH_MARKER* aMarker, int aLayer );
168 void draw( const SCH_BITMAP* aBitmap, int aLayer );
169 void draw( const SCH_LINE* aLine, int aLayer );
170 void draw( const SCH_BUS_ENTRY_BASE* aEntry, int aLayer );
171
172 void drawPinDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor,
173 bool aDrawingShadows, bool aBrightened );
174 void drawDanglingSymbol( const VECTOR2I& aPos, const COLOR4D& aColor, int aWidth,
175 bool aDangling, bool aDrawingShadows, bool aBrightened );
176
177 int internalPinDecoSize( const LIB_PIN &aPin );
178 int externalPinDecoSize( const LIB_PIN &aPin );
179
180 // Indicates the item is drawn on a non-cached layer in OpenGL
181 bool nonCached( const EDA_ITEM* aItem );
182
183 bool isUnitAndConversionShown( const LIB_ITEM* aItem ) const;
184
185 float getShadowWidth( bool aForHighlight ) const;
186 COLOR4D getRenderColor( const EDA_ITEM* aItem, int aLayer, bool aDrawingShadows,
187 bool aDimmed = false ) const;
188 float getLineWidth( const EDA_ITEM* aItem, bool aDrawingShadows ) const;
189 float getTextThickness( const EDA_ITEM* aItem ) const;
190
191 bool setDeviceColors( const LIB_ITEM* aItem, int aLayer, bool aDimmed );
192
193 void triLine( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
194 void strokeText( const wxString& aText, const VECTOR2D& aPosition,
195 const TEXT_ATTRIBUTES& aAttributes );
196 void bitmapText( const wxString& aText, const VECTOR2D& aPosition,
197 const TEXT_ATTRIBUTES& aAttributes );
198 void boxText( const wxString& aText, const VECTOR2D& aPosition, const TEXT_ATTRIBUTES& aAttrs );
199
200public:
201 static std::vector<KICAD_T> g_ScaledSelectionTypes;
202
203private:
206};
207
208}; // namespace KIGFX
209
210
211#endif // __SCH_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:85
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
double GetBrightness() const
Returns the brightness value of the color ranged from 0.0 to 1.0.
Definition: color4d.h:349
Abstract interface for drawing on a 2D-surface.
Contains all the knowledge about how to draw graphical object onto any particular output device.
Definition: painter.h:58
Container for all the knowledge about how graphical objects are drawn on any output surface/device.
COLOR4D m_layerColors[LAYER_ID_COUNT]
Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:134
virtual SCH_RENDER_SETTINGS * GetSettings() override
Return a pointer to current settings that are going to be used when drawing items.
Definition: sch_painter.h:142
virtual bool Draw(const VIEW_ITEM *, int) override
Takes an instance of VIEW_ITEM and passes it to a function that knows how to draw the item.
void drawPinDanglingSymbol(const VECTOR2I &aPos, const COLOR4D &aColor, bool aDrawingShadows, bool aBrightened)
float getShadowWidth(bool aForHighlight) const
void draw(const EDA_ITEM *, int, bool aDimmed)
bool isUnitAndConversionShown(const LIB_ITEM *aItem) const
void strokeText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
static std::vector< KICAD_T > g_ScaledSelectionTypes
Definition: sch_painter.h:201
void bitmapText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttributes)
SCHEMATIC * m_schematic
Definition: sch_painter.h:205
int externalPinDecoSize(const LIB_PIN &aPin)
void boxText(const wxString &aText, const VECTOR2D &aPosition, const TEXT_ATTRIBUTES &aAttrs)
float getLineWidth(const EDA_ITEM *aItem, bool aDrawingShadows) const
COLOR4D getRenderColor(const EDA_ITEM *aItem, int aLayer, bool aDrawingShadows, bool aDimmed=false) const
int internalPinDecoSize(const LIB_PIN &aPin)
void triLine(const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c)
void SetSchematic(SCHEMATIC *aSchematic)
Definition: sch_painter.h:144
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:204
void drawDanglingSymbol(const VECTOR2I &aPos, const COLOR4D &aColor, int aWidth, bool aDangling, bool aDrawingShadows, bool aBrightened)
bool nonCached(const EDA_ITEM *aItem)
SCH_PAINTER(GAL *aGal)
float getTextThickness(const EDA_ITEM *aItem) const
bool setDeviceColors(const LIB_ITEM *aItem, int aLayer, bool aDimmed)
Store schematic specific render settings.
Definition: sch_painter.h:71
const COLOR4D & GetCursorColor() override
Return current cursor color settings.
Definition: sch_painter.h:106
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...
void SetBackgroundColor(const COLOR4D &aColor) override
Set the background color.
Definition: sch_painter.h:94
void LoadColors(const COLOR_SETTINGS *aSettings) override
const COLOR4D & GetGridColor() override
Return current grid color settings.
Definition: sch_painter.h:104
bool GetShowPageLimits() const override
const COLOR4D & GetBackgroundColor() const override
Return current background color settings.
Definition: sch_painter.h:89
float GetDanglineSymbolThickness() const
Definition: sch_painter.h:99
bool IsBackgroundDark() const override
Definition: sch_painter.h:82
An abstract base class for deriving all objects that can be added to a VIEW.
Definition: view_item.h:77
Field object used in symbol libraries.
Definition: lib_field.h:61
The base class for drawable items used by schematic library symbols.
Definition: lib_item.h:61
Define a library symbol object.
Definition: lib_symbol.h:99
Define a symbol library graphical text item.
Definition: lib_text.h:40
Holds all the data relating to one schematic.
Definition: schematic.h:61
Object to handle a bitmap image that can be inserted in a schematic.
Definition: sch_bitmap.h:41
Base class for a bus or wire entry.
Definition: sch_bus_entry.h:38
Instances are attached to a symbol or sheet and provide a place for the symbol's value,...
Definition: sch_field.h:51
Segment description base class to describe items which have 2 end points (track, wire,...
Definition: sch_line.h:40
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet_pin.h:66
Sheet symbol placed in a schematic, and is the entry point for a sub schematic.
Definition: sch_sheet.h:57
Schematic symbol object.
Definition: sch_symbol.h:81
@ LAYER_SCHEMATIC_CURSOR
Definition: layer_ids.h:377
@ LAYER_SCHEMATIC_BACKGROUND
Definition: layer_ids.h:376
@ LAYER_SCHEMATIC_GRID
Definition: layer_ids.h:374
The Cairo implementation of the graphics abstraction layer.
Definition: color4d.cpp:266