KiCad PCB EDA Suite
gr_basic.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) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
5  * Copyright (C) 2011 Wayne Stambaugh <[email protected]>
6  * Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software: you can redistribute it and/or modify it
9  * under the terms of the GNU General Public License as published by the
10  * Free Software Foundation, either version 3 of the License, or (at your
11  * option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful, but
14  * WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16  * General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program. If not, see <http://www.gnu.org/licenses/>.
20  */
21 
26 #ifndef GR_BASIC
27 #define GR_BASIC
28 
29 #include <gal/color4d.h>
30 #include <vector>
31 #include <eda_rect.h>
32 #include <wx/pen.h>
33 #include <wx/dc.h>
34 
35 using KIGFX::COLOR4D;
36 
37 
40  GR_OR = 0x01000000,
41  GR_XOR = 0x02000000,
42  GR_AND = 0x04000000,
43  GR_NXOR = 0x08000000,
44  GR_INVERT = 0x10000000,
45  GR_ALLOW_HIGHCONTRAST = 0x20000000,
46  GR_COPY = 0x40000000,
47  GR_HIGHLIGHT = 0x80000000,
49 };
50 
51 inline GR_DRAWMODE operator~( const GR_DRAWMODE& a )
52 {
53  return static_cast<GR_DRAWMODE>( ~int( a ) );
54 }
55 
56 inline GR_DRAWMODE operator|( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
57 {
58  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
59 }
60 
61 inline GR_DRAWMODE operator&( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
62 {
63  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
64 }
65 
66 extern GR_DRAWMODE g_XorMode;
67 
68 typedef enum {
69  /* Line styles for Get/SetLineStyle. */
74 
75 
76 void GRResetPenAndBrush( wxDC* DC );
77 void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width = 1,
78  wxPenStyle stype = wxPENSTYLE_SOLID );
79 void GRSetBrush( wxDC* DC, const COLOR4D& Color, bool fill = false );
80 
84 void GRForceBlackPen( bool flagforce );
85 
89 bool GetGRForceBlackPenState( void );
90 
91 void GRLine( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
92  const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
93 void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
94  const COLOR4D& Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
95 void GRMoveTo( int x, int y );
96 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, const COLOR4D& Color );
97 
98 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
99  const COLOR4D& Color, const COLOR4D& BgColor );
100 
113 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
114  bool doFill, const COLOR4D& aPenColor, const COLOR4D& aFillColor );
115 
116 // @todo could make these 2 closed polygons calls a single function and default
117 // the aPenWidth argument
118 
132 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
133  bool doFill, int aPenWidth, const COLOR4D& aPenColor,
134  const COLOR4D& aFillColor );
135 
136 
148 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, const COLOR4D& Color );
149 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
150  const COLOR4D& Color, const COLOR4D& BgColor );
151 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aPos, int aRadius,
152  const COLOR4D& aColor );
153 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aPos, int aRadius, int aWidth,
154  const COLOR4D& aColor );
155 
156 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
157  double EndAngle, int r, const COLOR4D& Color );
158 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
159  double EndAngle, int r, int width, const COLOR4D& Color );
160 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
161  int xc, int yc, int width, const COLOR4D& Color );
162 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
163  const wxPoint& aCenter, int aWidth, const COLOR4D& aColor );
164 void GRFilledArc1( EDA_RECT* ClipBox, wxDC* DC, const wxPoint& aStart, const wxPoint& aEnd,
165  const wxPoint& aCenter, int width, const COLOR4D& Color, const COLOR4D& BgColor );
166 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
167  const COLOR4D& Color );
168 
169 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
170  int width, const COLOR4D& Color );
171 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
172  int aWidth, const COLOR4D& aColor );
173 
174 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
175  int width, int aPenSize, const COLOR4D& Color );
176 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
177  int aWidth, const COLOR4D& aColor );
178 
179 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
180  int x2, int y2, const COLOR4D& Color, const COLOR4D& BgColor );
181 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
182  int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
183 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
184  int x2, int y2, int width, const COLOR4D& Color );
185 
186 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
187  int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
188 
189 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:63
GR_DRAWMODE operator~(const GR_DRAWMODE &a)
Definition: gr_basic.h:51
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:207
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:221
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:712
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:107
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition: gr_basic.cpp:453
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:185
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:311
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:705
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:115
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool doFill, const COLOR4D &aPenColor, const COLOR4D &aFillColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:463
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:548
GR_DRAWMODE operator|(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:56
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:39
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:191
E_SERIE r
Definition: eserie.cpp:41
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:325
void GRCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:507
Definition: gr_basic.h:40
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:333
Handle the component boundary box.
Definition: eda_rect.h:42
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, const COLOR4D &Color)
Definition: gr_basic.cpp:620
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:214
GRLineStypeType
Definition: gr_basic.h:68
void GRSFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:739
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:529
void GRFilledArc1(EDA_RECT *ClipBox, wxDC *DC, const wxPoint &aStart, const wxPoint &aEnd, const wxPoint &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:588
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill=false)
Definition: gr_basic.cpp:158
GR_DRAWMODE operator &(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:61
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103