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@gmail.com>
6  * Copyright (C) 1992-2021 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 
51 inline void DrawModeAddHighlight( GR_DRAWMODE* mode )
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 
61 inline GR_DRAWMODE operator~( const GR_DRAWMODE& a )
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, const COLOR4D& Color, int width = 1,
94  wxPenStyle stype = wxPENSTYLE_SOLID );
95 void GRSetBrush( wxDC* DC, const COLOR4D& Color, bool fill = false );
96 
100 void GRForceBlackPen( bool flagforce );
101 
105 bool GetGRForceBlackPenState( void );
106 
107 void GRLine( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd, int aWidth,
108  const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
109 void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
110  const COLOR4D& Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
111 void GRMoveTo( int x, int y );
112 void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, const COLOR4D& Color );
113 
114 void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const wxPoint* Points, bool Fill, int width,
115  const COLOR4D& Color, const COLOR4D& BgColor );
116 
120 void GRBezier( EDA_RECT* aClipBox, wxDC* aDC, std::vector<wxPoint>& aPoints,
121  int aWidth, const COLOR4D& aColor );
122 
135 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
136  bool doFill, const COLOR4D& aPenColor, const COLOR4D& aFillColor );
137 
138 // @todo could make these 2 closed polygons calls a single function and default
139 // the aPenWidth argument
140 
154 void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const wxPoint* aPoints,
155  bool doFill, int aPenWidth, const COLOR4D& aPenColor,
156  const COLOR4D& aFillColor );
157 
158 
170 void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, const COLOR4D& aColor );
171 void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, const COLOR4D& Color );
172 void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
173  const COLOR4D& Color, const COLOR4D& BgColor );
174 void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aPos, int aRadius,
175  const COLOR4D& aColor );
176 void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aPos, int aRadius, int aWidth,
177  const COLOR4D& aColor );
178 
179 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
180  double EndAngle, int r, const COLOR4D& Color );
181 void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
182  double EndAngle, int r, int width, const COLOR4D& Color );
183 void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
184  int xc, int yc, const 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, const COLOR4D& Color );
187 void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
188  const wxPoint& aCenter, int aWidth, const COLOR4D& aColor );
189 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle, double EndAngle,
190  int r, const COLOR4D& Color, const COLOR4D& BgColor );
191 void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, double StAngle,
192  double EndAngle, int r, int width, const COLOR4D& Color, const COLOR4D& BgColor );
193 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
194  const COLOR4D& Color );
195 
196 void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
197  int width, const COLOR4D& Color );
198 void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
199  int aWidth, const COLOR4D& aColor );
200 
201 void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
202  int width, int aPenSize, const COLOR4D& Color );
203 void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, const wxPoint& aStart, const wxPoint& aEnd,
204  int aWidth, const COLOR4D& aColor );
205 
206 void GRSetColor( const COLOR4D& Color );
207 void GRSetDefaultPalette();
209 void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, const COLOR4D& color );
210 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
211  int x2, int y2, const COLOR4D& Color, const COLOR4D& BgColor );
212 void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
213  int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
214 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, const COLOR4D& Color );
215 void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, const COLOR4D& Color );
216 void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
217  int x2, int y2, int width, const COLOR4D& Color );
218 void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
219  int aWidth, const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
220 
221 void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
222  int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
223 
234 void GRLineArray( EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
235  int aWidth, const COLOR4D& aColor );
236 
237 void GRDrawAnchor( EDA_RECT* aClipBox, wxDC* aDC, int x, int y, int aSize, const COLOR4D& aColor );
238 
245 void GRDrawWrappedText( wxDC& aDC, const wxString& aText );
246 
247 #endif /* define GR_BASIC */
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:65
GR_DRAWMODE operator~(const GR_DRAWMODE &a)
Definition: gr_basic.h:61
void GRLine(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:222
void GRLineTo(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:236
void GRPutPixel(EDA_RECT *ClipBox, wxDC *DC, int x, int y, const COLOR4D &color)
Definition: gr_basic.cpp:202
void GRDrawWrappedText(wxDC &aDC, const wxString &aText)
Draw text centered on a wxDC with wrapping.
Definition: gr_basic.cpp:930
void GRFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:811
void GRRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, const COLOR4D &Color)
Definition: gr_basic.cpp:774
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:111
void GRRectPs(EDA_RECT *aClipBox, wxDC *aDC, const EDA_RECT &aRect, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
int color
Definition: DXF_plotter.cpp:57
void GRPoly(EDA_RECT *ClipBox, wxDC *DC, int n, const wxPoint *Points, bool Fill, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Draw a new polyline and fill it if Fill, in drawing space.
Definition: gr_basic.cpp:497
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:190
void GRCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:355
void DrawModeAllowHighContrast(GR_DRAWMODE *mode)
Definition: gr_basic.h:56
void GRSetColor(const COLOR4D &Color)
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:120
void GRClosedPoly(EDA_RECT *ClipBox, wxDC *aDC, int aPointCount, const wxPoint *aPoints, bool doFill, const COLOR4D &aPenColor, const COLOR4D &aFillColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:507
void GRLineArray(EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aLines, int aWidth, const COLOR4D &aColor)
Draw an array of lines (not a polygon).
Definition: gr_basic.cpp:242
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()
void GRArc1(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int xc, int yc, const COLOR4D &Color)
Definition: gr_basic.cpp:594
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:196
COLOR4D GRGetColor()
E_SERIE r
Definition: eserie.cpp:41
void GRFillCSegm(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:369
void GRFilledArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:682
Definition: gr_basic.h:40
void GRFilledSegment(EDA_RECT *aClipBox, wxDC *aDC, const wxPoint &aStart, const wxPoint &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:377
Handle the component boundary box.
Definition: eda_rect.h:42
void GRArc(EDA_RECT *ClipBox, wxDC *DC, int x, int y, double StAngle, double EndAngle, int r, const COLOR4D &Color)
Definition: gr_basic.cpp:689
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:229
void DrawModeAddHighlight(GR_DRAWMODE *mode)
Definition: gr_basic.h:51
void GRDrawAnchor(EDA_RECT *aClipBox, wxDC *aDC, int x, int y, int aSize, const COLOR4D &aColor)
Definition: gr_basic.cpp:921
GRLineStypeType
Definition: gr_basic.h:84
void GRSFilledRect(EDA_RECT *ClipBox, wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:838
void GRFilledCircle(EDA_RECT *ClipBox, wxDC *DC, int x, int y, int r, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:575
void GRCircle(EDA_RECT *ClipBox, wxDC *aDC, int x, int y, int aRadius, const COLOR4D &aColor)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:562
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill=false)
Definition: gr_basic.cpp:163
GR_DRAWMODE operator &(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:71
void GRBezier(EDA_RECT *aClipBox, wxDC *aDC, std::vector< wxPoint > &aPoints, int aWidth, const COLOR4D &aColor)
Draw cubic (4 points: start control1, control2, end) bezier curve.
Definition: gr_basic.cpp:909
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:103