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 #include <wx/pen.h>
33 #include <wx/dc.h>
34 
35 using KIGFX::COLOR4D;
36 
37 
40  GR_OR = 0x01000000,
41  GR_XOR = 0x02000000,
42  GR_AND = 0x04000000,
43  GR_NXOR = 0x08000000,
44  GR_INVERT = 0x10000000,
45  GR_ALLOW_HIGHCONTRAST = 0x20000000,
46  GR_COPY = 0x40000000,
47  GR_HIGHLIGHT = 0x80000000,
49 };
50 
52 {
53  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_HIGHLIGHT );
54 }
55 
57 {
58  *mode = static_cast<GR_DRAWMODE>( int( *mode ) | GR_ALLOW_HIGHCONTRAST );
59 }
60 
62 {
63  return static_cast<GR_DRAWMODE>( ~int( a ) );
64 }
65 
66 inline GR_DRAWMODE operator |(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
67 {
68  return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
69 }
70 
71 inline GR_DRAWMODE operator &(const GR_DRAWMODE& a, const GR_DRAWMODE& b)
72 {
73  return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
74 }
75 
76 #define GR_M_LEFT_DOWN 0x10000000
77 #define GR_M_RIGHT_DOWN 0x20000000
78 #define GR_M_MIDDLE_DOWN 0x40000000
79 #define GR_M_DCLICK 0x80000000
80 
81 
82 extern GR_DRAWMODE g_XorMode;
83 
84 typedef enum {
85  /* Line styles for Get/SetLineStyle. */
90 
91 
92 void GRResetPenAndBrush( wxDC* DC );
93 void GRSetColorPen( wxDC* DC, COLOR4D Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
94 void GRSetBrush( wxDC* DC, COLOR4D Color, bool fill = false );
95 
100 void GRForceBlackPen( bool flagforce );
101 
106 bool GetGRForceBlackPenState( void );
107 
108 void GRLine( EDA_RECT* aClipBox, wxDC* aDC,
109  wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
110 void GRLine( EDA_RECT* ClipBox, wxDC* DC,
111  int x1, int y1, int x2, int y2, int width, COLOR4D Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
112 void GRMoveTo( int x, int y );
113 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC,
114  int x, int y, int width, COLOR4D Color );
115 
116 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
117  COLOR4D Color, COLOR4D BgColor );
118 
121 void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoints,
122  int aWidth, COLOR4D aColor );
123 
136 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
137  bool doFill, COLOR4D aPenColor, COLOR4D aFillColor );
138 
139 // @todo could make these 2 closed polygons calls a single function and default
140 // the aPenWidth argument
141 
155 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
156  bool doFill, int aPenWidth, COLOR4D aPenColor, COLOR4D aFillColor );
157 
158 
172 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, COLOR4D aColor );
173 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, COLOR4D Color );
174 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
175  COLOR4D Color, COLOR4D BgColor );
176 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, COLOR4D aColor );
177 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, COLOR4D aColor );
178 
179 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
180  double EndAngle, int r, COLOR4D Color );
181 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
182  double EndAngle, int r, int width, COLOR4D Color );
183 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
184  int xc, int yc, COLOR4D Color );
185 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
186  int xc, int yc, int width, COLOR4D Color );
187 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
188  wxPoint aCenter, int aWidth, COLOR4D aColor );
189 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
190  double StAngle, double EndAngle, int r, COLOR4D Color, COLOR4D BgColor );
191 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
192  double EndAngle, int r, int width, COLOR4D Color, COLOR4D BgColor );
193 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color );
194 
195 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
196  int width, COLOR4D Color );
197 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
198  int aWidth, COLOR4D aColor );
199 
200 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
201  int width, int aPenSize, COLOR4D Color );
202 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
203  int aWidth, COLOR4D aColor );
204 
205 void GRSetColor( COLOR4D Color );
206 void GRSetDefaultPalette();
208 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, COLOR4D color );
209 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
210  int x2, int y2, COLOR4D Color, COLOR4D BgColor );
211 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
212  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
213 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, COLOR4D Color );
214 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, COLOR4D Color );
215 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
216  int x2, int y2, int width, COLOR4D Color );
217 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
218  int aWidth, COLOR4D aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
219 
220 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
221  int x2, int y2, int width, COLOR4D Color, COLOR4D BgColor );
222 
233 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
234  int aWidth, COLOR4D aColor );
235 
236 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC *aDC, int x, int y, int aSize,
237  COLOR4D aColor );
238 
244 void GRDrawWrappedText( wxDC& aDC, wxString const& aText );
245 
246 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:70
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:540
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color)
Definition: gr_basic.cpp:842
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor)
Definition: gr_basic.cpp:421
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:550
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, COLOR4D Color)
Definition: gr_basic.cpp:747
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:131
void GRPutPixel(EDA_RECT *ClipBox, wxDC *DC, int x, int y, COLOR4D color)
Definition: gr_basic.cpp:215
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:638
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:118
int color
Definition: DXF_plotter.cpp:60
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:617
void GRSetColor(COLOR4D Color)
void GRForceBlackPen(bool flagforce)
Function GRForceBlackPen.
Definition: gr_basic.cpp:199
void DrawModeAllowHighContrast(GR_DRAWMODE *mode)
Definition: gr_basic.h:56
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, COLOR4D aColor)
Definition: gr_basic.cpp:1003
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:1017
GR_DRAWMODE operator|(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:66
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:39
void GRSetDefaultPalette()
bool GetGRForceBlackPenState(void)
Function GetGRForceBlackPenState.
Definition: gr_basic.cpp:209
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:736
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:990
void GRSetBrush(wxDC *DC, COLOR4D Color, bool fill=false)
Definition: gr_basic.cpp:168
COLOR4D GRGetColor()
Definition: gr_basic.h:40
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:917
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, COLOR4D Color, COLOR4D BgColor)
Definition: gr_basic.cpp:882
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:282
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:413
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:254
void DrawModeAddHighlight(GR_DRAWMODE *mode)
Definition: gr_basic.h:51
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, wxPoint aStart, wxPoint aEnd, int aWidth, COLOR4D aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:245
GRLineStypeType
Definition: gr_basic.h:84
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, COLOR4D Color)
Definition: gr_basic.cpp:264
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:605
GR_DRAWMODE operator ~(const GR_DRAWMODE &a)
Definition: gr_basic.h:61
GR_DRAWMODE operator &(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:71
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, COLOR4D Color)
Definition: gr_basic.cpp:396
COLOR4D is the color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:100