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, const wxPoint* Points, bool Fill, int width,
115  COLOR4D Color, COLOR4D BgColor );
116 
119 void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoints,
120  int aWidth, COLOR4D aColor );
121 
134 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
135  bool doFill, COLOR4D aPenColor, COLOR4D aFillColor );
136 
137 // @todo could make these 2 closed polygons calls a single function and default
138 // the aPenWidth argument
139 
153 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
154  bool doFill, int aPenWidth, COLOR4D aPenColor, COLOR4D aFillColor );
155 
156 
170 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
171 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
172 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
173  COLOR4D Color, COLOR4D BgColor );
174 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
175 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
176 
177 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
178  double EndAngle, int r, COLOR4D Color );
179 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
180  double EndAngle, int r, int width, COLOR4D Color );
181 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
182  int xc, int yc, COLOR4D Color );
183 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
184  int xc, int yc, int width, COLOR4D Color );
185 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
186  wxPoint aCenter, int aWidth, COLOR4D aColor );
187 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
188  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
189 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
190  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
191 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
192 
193 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
194  int width, COLOR4D Color );
195 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
196  int aWidth, COLOR4D aColor );
197 
198 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
199  int width, int aPenSize, COLOR4D Color );
200 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
201  int aWidth, COLOR4D aColor );
202 
203 void GRSetColor( COLOR4D Color );
204 void GRSetDefaultPalette();
206 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
207 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
208  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
209 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
210  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
211 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
212 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
213 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
214  int x2, int y2, int width, COLOR4D Color );
215 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
216  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
217 
218 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
219  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
220 
231 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
232  int aWidth, COLOR4D aColor );
233 
234 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
235  COLOR4D aColor );
236 
242 void GRDrawWrappedText( wxDC& aDC, wxString const& aText );
243 
244 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:72
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:542
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
Definition: gr_basic.cpp:844
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:423
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const 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:552
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:749
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:640
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:120
int color
Definition: DXF_plotter.cpp:61
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:619
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:1005
void GRRectPs(EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
void GRDrawWrappedText(wxDC &aDC, wxString const &aText)
Draw text centered on a wxDC with wrapping.
Definition: gr_basic.cpp:1019
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 GRSetDefaultPalette()
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:738
void GRBezier(EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aPoints, int aWidth, COLOR4D aColor)
Draw cubic (4 points: start control1, control2, end) bezier curve.
Definition: gr_basic.cpp:992
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:919
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:884
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
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:607
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
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:40