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) 2014 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 <painter.h>
29 
30 class LIB_RECTANGLE;
31 class LIB_PIN;
32 class LIB_CIRCLE;
33 class LIB_ITEM;
34 class LIB_PART;
35 class LIB_ALIAS;
36 class LIB_POLYLINE;
37 class LIB_ARC;
38 class LIB_FIELD;
39 class LIB_TEXT;
40 class SCH_COMPONENT;
41 class SCH_FIELD;
42 class SCH_JUNCTION;
43 class SCH_LABEL;
44 class SCH_TEXT;
45 class SCH_HIERLABEL;
46 class SCH_GLOBALLABEL;
47 class SCH_SHEET;
48 class SCH_SHEET_PIN;
49 class SCH_MARKER;
50 class SCH_NO_CONNECT;
51 class SCH_LINE;
52 class SCH_BUS_ENTRY_BASE;
53 class SCH_BITMAP;
54 
55 namespace KIGFX
56 {
57 class GAL;
58 class SCH_PAINTER;
59 
60 
67 {
68 public:
69  friend class SCH_PAINTER;
70 
72 
74  void ImportLegacyColors( const COLORS_DESIGN_SETTINGS* aSettings ) override;
75 
77  virtual const COLOR4D& GetColor( const VIEW_ITEM* aItem, int aLayer ) const override;
78 
79  bool IsBackgroundDark() const override
80  {
82 
83  return luma < 0.5;
84  }
85 
87 
88  void SetBackgroundColor( const COLOR4D& aColor ) override
89  {
91  }
92 
93  const COLOR4D& GetGridColor() override { return m_layerColors[ LAYER_SCHEMATIC_GRID ]; }
94 
96 
97  int m_ShowUnit; // Show all units if 0
98  int m_ShowConvert; // Show all conversions if 0
99 
103 
105 };
106 
107 
112 class SCH_PAINTER : public PAINTER
113 {
114 public:
115  SCH_PAINTER( GAL* aGal );
116 
118  virtual bool Draw( const VIEW_ITEM*, int ) override;
119 
121  virtual void ApplySettings( const RENDER_SETTINGS* aSettings ) override
122  {
123  m_schSettings = *static_cast<const SCH_RENDER_SETTINGS*>( aSettings );
124  }
125 
127  virtual SCH_RENDER_SETTINGS* GetSettings() override
128  {
129  return &m_schSettings;
130  }
131 
132 private:
133  void draw( LIB_RECTANGLE *, int );
134  void draw( LIB_PIN *, int, bool isDangling = true, bool isMoving = false );
135  void draw( LIB_CIRCLE *, int );
136  void draw( LIB_ITEM *, int );
137  void draw( LIB_PART *, int, bool aDrawFields = true, int aUnit = 0, int aConvert = 0,
138  std::vector<bool>* danglingPinFlags = nullptr );
139  void draw( LIB_ALIAS *, int );
140  void draw( LIB_ARC *, int );
141  void draw( LIB_POLYLINE *, int );
142  void draw( LIB_FIELD *, int );
143  void draw( LIB_TEXT *, int );
144  void draw( SCH_COMPONENT *, int );
145  void draw( SCH_JUNCTION *, int );
146  void draw( SCH_FIELD *, int );
147  void draw( SCH_TEXT *, int );
148  void draw( SCH_LABEL *, int );
149  void draw( SCH_HIERLABEL *, int );
150  void draw( SCH_GLOBALLABEL *, int );
151  void draw( SCH_SHEET *, int );
152  void draw( SCH_SHEET_PIN *, int );
153  void draw( SCH_NO_CONNECT *, int );
154  void draw( SCH_MARKER *, int );
155  void draw( SCH_BITMAP *, int );
156  void draw( SCH_LINE *, int );
157  void draw( SCH_BUS_ENTRY_BASE *aEntry, int aLayer );
158 
159  bool isUnitAndConversionShown( const LIB_ITEM* aItem );
160 
161  bool setColors( const LIB_ITEM* aItem, int aLayer );
162 
163  void triLine ( const VECTOR2D &a, const VECTOR2D &b, const VECTOR2D &c );
164 
166 };
167 
168 }; // namespace KIGFX
169 
170 
171 #endif
Class SCH_FIELD instances are attached to a component and provide a place for the component&#39;s value...
Definition: sch_field.h:56
Part library alias object definition.
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
COLOR4D m_layerColors[LAYER_ID_COUNT]
Colors for all layers (normal)
Definition: painter.h:263
Define a symbol library graphical text item.
Definition: lib_text.h:44
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:81
Field object used in symbol libraries.
Definition: lib_field.h:59
void SetBackgroundColor(const COLOR4D &aColor) override
Sets the background color.
Definition: sch_painter.h:88
const COLOR4D & GetGridColor() override
Function GetGridColor Returns current grid color settings.
Definition: sch_painter.h:93
Class VIEW_ITEM - is an abstract base class for deriving all objects that can be added to a VIEW...
Definition: view_item.h:84
The base class for drawable items used by schematic library components.
Definition: lib_draw_item.h:67
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:308
const COLOR4D & GetCursorColor() override
Function GetCursorColor Returns current cursor color settings.
Definition: sch_painter.h:95
double GetBrightness() const
Function GetBrightness Returns the brightness value of the color ranged from 0.0 to 1...
Definition: color4d.h:255
Class SCH_PAINTER Contains methods for drawing schematic-specific items.
Definition: sch_painter.h:112
Define a library symbol object.
Define a sheet pin (label) used in sheets to create hierarchical schematics.
Definition: sch_sheet.h:61
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:127
const COLOR4D & GetBackgroundColor() override
Function GetBackgroundColor Returns current background color settings.
Definition: sch_painter.h:86
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:121
Segment description base class to describe items which have 2 end points (track, wire, draw line ...)
Definition: sch_line.h:41
Class SCH_COMPONENT describes a real schematic component.
Definition: sch_component.h:69
bool IsBackgroundDark() const override
Definition: sch_painter.h:79
Class SCH_RENDER_SETTINGS Stores schematic-specific render settings.
Definition: sch_painter.h:66
Class COLORS_DESIGN_SETTINGS is a list of color settings for designs in Pcbnew.
void ImportLegacyColors(const COLORS_DESIGN_SETTINGS *aSettings) override
Function ImportLegacyColors Loads a list of color settings for layers.
Definition: sch_painter.cpp:69
SCH_RENDER_SETTINGS m_schSettings
Definition: sch_painter.h:165
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