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 <stambaughw@verizon.net>
6  * Copyright (C) 1992-2018 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 
33 using KIGFX::COLOR4D;
34 
35 
38  GR_OR = 0x01000000,
39  GR_XOR = 0x02000000,
40  GR_AND = 0x04000000,
41  GR_NXOR = 0x08000000,
42  GR_INVERT = 0x10000000,
43  GR_ALLOW_HIGHCONTRAST = 0x20000000,
44  GR_COPY = 0x40000000,
45  GR_HIGHLIGHT = 0x80000000,
47 };
48 
50 {
51  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
52 }
53 
55 {
56  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
57 }
58 
60 {
61  return static_cast<GR_DRAWMODE>( ~int( a ) );
62 }
63 
64 inline GR_DRAWMODE operator |(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
65 {
66  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
67 }
68 
69 inline GR_DRAWMODE operator &(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
70 {
71  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
72 }
73 
74 #define GR_M_LEFT_DOWN 0x10000000
75 #define GR_M_RIGHT_DOWN 0x20000000
76 #define GR_M_MIDDLE_DOWN 0x40000000
77 #define GR_M_DCLICK 0x80000000
78 
79 
80 extern GR_DRAWMODE g_XorMode;
81 
82 typedef enum {
83  /* Line styles for Get/SetLineStyle. */
88 
89 
90 void GRResetPenAndBrush( wxDC* DC );
91 void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
92 void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
93 
98 void GRForceBlackPen( bool flagforce );
99 
104 bool GetGRForceBlackPenState( void );
105 
106 void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
107  wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
108 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
109  int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
110 void GRMoveTo( int x, int y );
111 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
112  int x, int y, int width, COLOR4D Color );
113 
114 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
115  int width, COLOR4D Color, COLOR4D BgColor );
116 
117 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
118  int x3, int y3, int width, COLOR4D Color );
119 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
120  int x3, int y3, int x4, int y4, int width, COLOR4D Color );
121 
134 void GRClosedPoly( EDA_RECT* ClipBox,
135  wxDC * aDC,
136  int aPointCount,
137  wxPoint aPoints[],
138  bool doFill,
139  COLOR4D aPenColor,
140  COLOR4D aFillColor );
141 
142 // @todo could make these 2 closed polygons calls a single function and default
143 // the aPenWidth argument
144 
158 void GRClosedPoly( EDA_RECT* ClipBox,
159  wxDC* aDC,
160  int aPointCount,
161  wxPoint aPoints[],
162  bool doFill,
163  int aPenWidth,
164  COLOR4D aPenColor,
165  COLOR4D aFillColor );
166 
167 
181 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
182 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
183 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
184  COLOR4D Color, COLOR4D BgColor );
185 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
186 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
187 
188 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
189  double EndAngle, int r, COLOR4D Color );
190 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
191  double EndAngle, int r, int width, COLOR4D Color );
192 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
193  int xc, int yc, COLOR4D Color );
194 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
195  int xc, int yc, int width, COLOR4D Color );
196 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
197  wxPoint aCenter, int aWidth, COLOR4D aColor );
198 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
199  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
200 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
201  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
202 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
203 
204 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
205  int width, COLOR4D Color );
206 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
207  int aWidth, COLOR4D aColor );
208 
209 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
210  int width, int aPenSize, COLOR4D Color );
211 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
212  int aWidth, COLOR4D aColor );
213 
214 void GRSetColor( COLOR4D Color );
215 void GRSetDefaultPalette();
217 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
218 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
219  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
220 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
221  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
222 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
223 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
224 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
225  int x2, int y2, int width, COLOR4D Color );
226 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
227  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
228 
229 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
230  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
231 
242 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
243  int aWidth, COLOR4D aColor );
244 
245 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
246  COLOR4D aColor );
247 
253 void GRDrawWrappedText( wxDC& aDC, wxString const& aText );
254 
255 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:71
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
Definition: gr_basic.cpp:848
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:423
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:753
void GRSetColorPen(wxDC *DC, COLOR4D Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
Function GRSetColorPen sets a pen style, width, color, and alpha into the given device context.
Definition: gr_basic.cpp:133
void GRPutPixel(EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D color)
Definition: gr_basic.cpp:217
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, COLOR4D Color)
Definition: gr_basic.cpp:644
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:120
int color
Definition: DXF_plotter.cpp:62
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:623
void GRSetColor(COLOR4D Color)
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:201
void DrawModeAllowHighContrast(GR_DRAWMODE *mode)
Definition: gr_basic.h:54
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1038
void GRRectPs(EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, wxPoint aPoints[], bool doFill, COLOR4D aPenColor, COLOR4D aFillColor)
Function GRClosedPoly draws a closed polygon onto the drawing context aDC and optionally fills and/or...
Definition: gr_basic.cpp:556
void GRDrawWrappedText(wxDC &aDC, wxString const &aText)
Draw text centered on a wxDC with wrapping.
Definition: gr_basic.cpp:1052
GR_DRAWMODE operator|(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:64
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:37
void GRBezier(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int x3, int y3, int width, COLOR4D Color)
Definition: gr_basic.cpp:996
void GRSetDefaultPalette()
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, wxPoint Points[], bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:546
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:211
void GRFilledArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:742
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill=false)
Definition: gr_basic.cpp:170
COLOR4D GRGetColor()
Definition: gr_basic.h:38
void GRSFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:923
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:888
void GRLineArray(EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aLines, int aWidth, COLOR4D aColor)
Function GRLineArray draws an array of lines (not a polygon).
Definition: gr_basic.cpp:284
Class EDA_RECT handles the component boundary box.
Definition: eda_rect.h:44
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:415
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:256
void DrawModeAddHighlight(GR_DRAWMODE *mode)
Definition: gr_basic.h:49
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:247
GRLineStypeType
Definition: gr_basic.h:82
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:266
void GRCircle(EDA_RECT *ClipBox, wxDC *aDC, int x, int y, int aRadius, COLOR4D aColor)
Function GRCircle draws a circle onto the drawing context aDC centered at the user coordinates (x,...
Definition: gr_basic.cpp:611
GR_DRAWMODE operator ~(const GR_DRAWMODE &a)
Definition: gr_basic.h:59
GR_DRAWMODE operator &(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:69
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:398
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39