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-2015 KiCad Developers, see AUTHORS.txt for contributors.
7  *
8  * This program is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU General Public License
10  * as published by the Free Software Foundation; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License
19  * along with this program; if not, you may find one here:
20  * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
21  * or you may search the http://www.gnu.org website for the version 2 license,
22  * or you may write to the Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
24  */
25 
30 #ifndef GR_BASIC
31 #define GR_BASIC
32 
33 #include <gal/color4d.h>
34 #include <vector>
35 class EDA_RECT;
36 
37 using KIGFX::COLOR4D;
38 
39 
42  GR_OR = 0x01000000,
43  GR_XOR = 0x02000000,
44  GR_AND = 0x04000000,
45  GR_NXOR = 0x08000000,
46  GR_INVERT = 0x10000000,
47  GR_ALLOW_HIGHCONTRAST = 0x20000000,
48  GR_COPY = 0x40000000,
49  GR_HIGHLIGHT = 0x80000000,
51 };
52 
54 {
55  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
56 }
57 
59 {
60  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
61 }
62 
64 {
65  return static_cast<GR_DRAWMODE>( ~int( a ) );
66 }
67 
68 inline GR_DRAWMODE operator |(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
69 {
70  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
71 }
72 
73 inline GR_DRAWMODE operator &(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
74 {
75  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
76 }
77 
78 #define GR_M_LEFT_DOWN 0x10000000
79 #define GR_M_RIGHT_DOWN 0x20000000
80 #define GR_M_MIDDLE_DOWN 0x40000000
81 #define GR_M_DCLICK 0x80000000
82 
83 
84 extern GR_DRAWMODE g_XorMode;
85 
86 typedef enum {
87  /* Line styles for Get/SetLineStyle. */
92 
93 
94 class EDA_DRAW_PANEL;
95 
96 void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode );
97 GR_DRAWMODE GRGetDrawMode( wxDC* DC );
98 void GRResetPenAndBrush( wxDC* DC );
99 void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
100 void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
101 
106 void GRForceBlackPen( bool flagforce );
107 
112 bool GetGRForceBlackPenState( void );
113 
114 void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
115  wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor );
116 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
117  int x1, int y1, int x2, int y2, int width, COLOR4D Color );
118 void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
119  int width, COLOR4D Color );
120 void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
121  int width, COLOR4D Color );
122 void GRMoveTo( int x, int y );
123 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
124  int x, int y, int width, COLOR4D Color );
125 
126 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
127  int width, COLOR4D Color, COLOR4D BgColor );
128 
129 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
130  int x3, int y3, int width, COLOR4D Color );
131 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
132  int x3, int y3, int x4, int y4, int width, COLOR4D Color );
133 
146 void GRClosedPoly( EDA_RECT* ClipBox,
147  wxDC * aDC,
148  int aPointCount,
149  wxPoint aPoints[],
150  bool doFill,
151  COLOR4D aPenColor,
152  COLOR4D aFillColor );
153 
154 // @todo could make these 2 closed polygons calls a single function and default
155 // the aPenWidth argument
156 
170 void GRClosedPoly( EDA_RECT* ClipBox,
171  wxDC* aDC,
172  int aPointCount,
173  wxPoint aPoints[],
174  bool doFill,
175  int aPenWidth,
176  COLOR4D aPenColor,
177  COLOR4D aFillColor );
178 
179 
193 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
194 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
195 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
196  COLOR4D Color, COLOR4D BgColor );
197 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
198 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
199 
200 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
201  double EndAngle, int r, COLOR4D Color );
202 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
203  double EndAngle, int r, int width, COLOR4D Color );
204 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
205  int xc, int yc, COLOR4D Color );
206 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
207  int xc, int yc, int width, COLOR4D Color );
208 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
209  wxPoint aCenter, int aWidth, COLOR4D aColor );
210 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
211  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
212 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
213  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
214 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
215 
216 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
217  int width, COLOR4D Color );
218 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
219  int aWidth, COLOR4D aColor );
220 
221 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
222  int width, int aPenSize, COLOR4D Color );
223 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
224  int aWidth, COLOR4D aColor );
225 
226 void GRSetColor( COLOR4D Color );
227 void GRSetDefaultPalette();
229 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
230 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
231  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
232 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
233  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
234 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
235 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
236 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
237  int x2, int y2, int width, COLOR4D Color );
238 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
239  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
240 
241 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
242  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
243 
254 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
255  int aWidth, COLOR4D aColor );
256 
257 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
258  COLOR4D aColor );
259 
260 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:51
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
Definition: gr_basic.cpp:1077
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:592
GR_DRAWMODE operator~(const GR_DRAWMODE &a)
Definition: gr_basic.h:63
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:982
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:209
void GRPutPixel(EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D color)
Definition: gr_basic.cpp:339
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:873
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:196
void GRDashedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:374
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:833
void GRSetColor(COLOR4D Color)
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:271
GR_DRAWMODE operator&(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:73
void DrawModeAllowHighContrast(GR_DRAWMODE *mode)
Definition: gr_basic.h:58
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:368
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1267
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:777
GR_DRAWMODE operator|(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:68
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:41
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:1225
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE mode)
Definition: gr_basic.cpp:290
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:767
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:281
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:971
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill=false)
Definition: gr_basic.cpp:240
COLOR4D GRGetColor()
Definition: gr_basic.h:42
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:1152
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:1117
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:427
Class EDA_RECT handles the component boundary box.
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:584
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:391
void DrawModeAddHighlight(GR_DRAWMODE *mode)
Definition: gr_basic.h:53
GRLineStypeType
Definition: gr_basic.h:86
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:401
void GRMixedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:407
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:821
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:567
GR_DRAWMODE GRGetDrawMode(wxDC *DC)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39