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, wxPenStyle aStyle = wxPENSTYLE_SOLID );
116 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
117  int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
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 GRDottedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
123  int width, COLOR4D Color );
124 void GRMoveTo( int x, int y );
125 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
126  int x, int y, int width, COLOR4D Color );
127 
128 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
129  int width, COLOR4D Color, COLOR4D BgColor );
130 
131 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
132  int x3, int y3, int width, COLOR4D Color );
133 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
134  int x3, int y3, int x4, int y4, int width, COLOR4D Color );
135 
148 void GRClosedPoly( EDA_RECT* ClipBox,
149  wxDC * aDC,
150  int aPointCount,
151  wxPoint aPoints[],
152  bool doFill,
153  COLOR4D aPenColor,
154  COLOR4D aFillColor );
155 
156 // @todo could make these 2 closed polygons calls a single function and default
157 // the aPenWidth argument
158 
172 void GRClosedPoly( EDA_RECT* ClipBox,
173  wxDC* aDC,
174  int aPointCount,
175  wxPoint aPoints[],
176  bool doFill,
177  int aPenWidth,
178  COLOR4D aPenColor,
179  COLOR4D aFillColor );
180 
181 
195 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
196 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
197 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
198  COLOR4D Color, COLOR4D BgColor );
199 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
200 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
201 
202 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
203  double EndAngle, int r, COLOR4D Color );
204 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
205  double EndAngle, int r, int width, COLOR4D Color );
206 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
207  int xc, int yc, COLOR4D Color );
208 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
209  int xc, int yc, int width, COLOR4D Color );
210 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
211  wxPoint aCenter, int aWidth, COLOR4D aColor );
212 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
213  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
214 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
215  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
216 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
217 
218 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
219  int width, COLOR4D Color );
220 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
221  int aWidth, COLOR4D aColor );
222 
223 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
224  int width, int aPenSize, COLOR4D Color );
225 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
226  int aWidth, COLOR4D aColor );
227 
228 void GRSetColor( COLOR4D Color );
229 void GRSetDefaultPalette();
231 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
232 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
233  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
234 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
235  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
236 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
237 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
238 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
239  int x2, int y2, int width, COLOR4D Color );
240 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
241  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
242 
243 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
244  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
245 
256 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
257  int aWidth, COLOR4D aColor );
258 
259 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
260  COLOR4D aColor );
261 
262 #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:1076
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:599
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:981
void GRDottedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:389
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:345
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:872
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:381
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:851
void GRSetColor(COLOR4D Color)
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:277
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 GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1266
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:784
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:1224
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE mode)
Definition: gr_basic.cpp:296
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:774
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:287
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:970
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill=false)
Definition: gr_basic.cpp:246
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:1151
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:1116
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:434
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:591
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:400
void DrawModeAddHighlight(GR_DRAWMODE *mode)
Definition: gr_basic.h:53
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:375
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:410
void GRMixedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:416
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:839
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:574
GR_DRAWMODE GRGetDrawMode(wxDC *DC)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39