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 class EDA_RECT;
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 class EDA_DRAW_PANEL;
91 
92 void GRSetDrawMode( wxDC* DC, GR_DRAWMODE mode );
93 GR_DRAWMODE GRGetDrawMode( wxDC* DC );
94 void GRResetPenAndBrush( wxDC* DC );
95 void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
96 void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
97 
102 void GRForceBlackPen( bool flagforce );
103 
108 bool GetGRForceBlackPenState( void );
109 
110 void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
111  wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
112 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
113  int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
114 void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
115  int width, COLOR4D Color );
116 void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
117  int width, COLOR4D Color );
118 void GRDottedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
119  int width, COLOR4D Color );
120 void GRMoveTo( int x, int y );
121 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
122  int x, int y, int width, COLOR4D Color );
123 
124 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
125  int width, COLOR4D Color, COLOR4D BgColor );
126 
127 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
128  int x3, int y3, int width, COLOR4D Color );
129 void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
130  int x3, int y3, int x4, int y4, int width, COLOR4D Color );
131 
144 void GRClosedPoly( EDA_RECT* ClipBox,
145  wxDC * aDC,
146  int aPointCount,
147  wxPoint aPoints[],
148  bool doFill,
149  COLOR4D aPenColor,
150  COLOR4D aFillColor );
151 
152 // @todo could make these 2 closed polygons calls a single function and default
153 // the aPenWidth argument
154 
168 void GRClosedPoly( EDA_RECT* ClipBox,
169  wxDC* aDC,
170  int aPointCount,
171  wxPoint aPoints[],
172  bool doFill,
173  int aPenWidth,
174  COLOR4D aPenColor,
175  COLOR4D aFillColor );
176 
177 
191 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
192 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
193 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
194  COLOR4D Color, COLOR4D BgColor );
195 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
196 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
197 
198 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
199  double EndAngle, int r, COLOR4D Color );
200 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
201  double EndAngle, int r, int width, COLOR4D Color );
202 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
203  int xc, int yc, COLOR4D Color );
204 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
205  int xc, int yc, int width, COLOR4D Color );
206 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
207  wxPoint aCenter, int aWidth, COLOR4D aColor );
208 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
209  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
210 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
211  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
212 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
213 
214 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
215  int width, COLOR4D Color );
216 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
217  int aWidth, COLOR4D aColor );
218 
219 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
220  int width, int aPenSize, COLOR4D Color );
221 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
222  int aWidth, COLOR4D aColor );
223 
224 void GRSetColor( COLOR4D Color );
225 void GRSetDefaultPalette();
227 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
228 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
229  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
230 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
231  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
232 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
233 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
234 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
235  int x2, int y2, int width, COLOR4D Color );
236 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
237  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
238 
239 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
240  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
241 
252 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
253  int aWidth, COLOR4D aColor );
254 
255 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
256  COLOR4D aColor );
257 
263 void GRDrawWrappedText( wxDC& aDC, wxString const& aText );
264 
265 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:74
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
Definition: gr_basic.cpp:1003
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:526
GR_DRAWMODE operator~(const GR_DRAWMODE &a)
Definition: gr_basic.h:59
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:908
void GRDottedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:316
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:136
void GRPutPixel(EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D color)
Definition: gr_basic.cpp:272
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:799
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:123
int color
Definition: DXF_plotter.cpp:62
void GRDashedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:308
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:778
void GRSetColor(COLOR4D Color)
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:204
GR_DRAWMODE operator&(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:69
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:1193
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:711
void GRDrawWrappedText(wxDC &aDC, wxString const &aText)
Draw text centered on a wxDC with wrapping.
Definition: gr_basic.cpp:1207
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:1151
void GRSetDrawMode(wxDC *DC, GR_DRAWMODE mode)
Definition: gr_basic.cpp:223
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:701
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:214
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:897
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill=false)
Definition: gr_basic.cpp:173
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:1078
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:1043
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:361
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:518
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:327
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:302
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:337
void GRMixedLine(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:343
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:766
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:501
GR_DRAWMODE GRGetDrawMode(wxDC *DC)
Class COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:39