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 <[email protected]>
6 * Copyright (C) 1992-2022 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
22#ifndef GR_BASIC
23#define GR_BASIC
24
25#include <gal/color4d.h>
26#include <math/box2.h>
27#include <vector>
28#include <wx/pen.h>
29#include <wx/dc.h>
30
31using KIGFX::COLOR4D;
32
33
36 GR_OR = 0x01000000,
37 GR_XOR = 0x02000000,
38 GR_AND = 0x04000000,
39 GR_NXOR = 0x08000000,
40 GR_INVERT = 0x10000000,
42 GR_COPY = 0x40000000,
43 GR_HIGHLIGHT = 0x80000000,
45};
46
48{
49 return static_cast<GR_DRAWMODE>( ~int( a ) );
50}
51
52inline GR_DRAWMODE operator|( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
53{
54 return static_cast<GR_DRAWMODE>( int( a ) | int( b ) );
55}
56
57inline GR_DRAWMODE operator&( const GR_DRAWMODE& a, const GR_DRAWMODE& b )
58{
59 return static_cast<GR_DRAWMODE>( int( a ) & int( b ) );
60}
61
63
64typedef enum {
65 /* Line styles for Get/SetLineStyle. */
70
71
72void GRResetPenAndBrush( wxDC* DC );
73void GRSetColorPen( wxDC* DC, const COLOR4D& Color, int width = 1,
74 wxPenStyle stype = wxPENSTYLE_SOLID );
75void GRSetBrush( wxDC* DC, const COLOR4D& Color, bool fill = false );
76
80void GRForceBlackPen( bool flagforce );
81
85bool GetGRForceBlackPenState( void );
86
87void GRLine( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
88 const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
89void GRLine( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
90 wxPenStyle aStyle = wxPENSTYLE_SOLID );
91void GRMoveTo( int x, int y );
92void GRLineTo( wxDC* DC, int x, int y, int width, const COLOR4D& Color );
93
94void GRPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width, const COLOR4D& Color,
95 const COLOR4D& BgColor );
96
107void GRClosedPoly( wxDC* aDC, int aPointCount, const VECTOR2I* aPoints, bool doFill,
108 const COLOR4D& aColor );
109
120void GRFilledCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
121 const COLOR4D& aStrokeColor, const COLOR4D& aFillColor );
122void GRCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth, const COLOR4D& aColor );
123
124void GRArc( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
125 int aWidth, const COLOR4D& aColor );
126void GRFilledArc( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
127 int width, const COLOR4D& Color, const COLOR4D& BgColor );
128
129void GRFilledSegment( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
130 const COLOR4D& aColor );
131
132void GRCSegm( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
133 const COLOR4D& aColor );
134
135void GRFilledRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
136 const COLOR4D& aColor, const COLOR4D& aBgColor );
137void GRRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
138 const COLOR4D& aColor );
139
140void GRSFilledRect( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
141 const COLOR4D& BgColor );
142
143#endif /* define GR_BASIC */
A color representation with 4 components: red, green, blue, alpha.
Definition: color4d.h:104
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill=false)
Definition: gr_basic.cpp:123
void GRForceBlackPen(bool flagforce)
Definition: gr_basic.cpp:150
void GRResetPenAndBrush(wxDC *DC)
Definition: gr_basic.cpp:72
void GRLineTo(wxDC *DC, int x, int y, int width, const COLOR4D &Color)
Definition: gr_basic.cpp:186
GR_DRAWMODE operator|(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:52
void GRRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:387
void GRSFilledRect(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:413
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition: gr_basic.h:35
@ GR_OR
Definition: gr_basic.h:36
@ GR_INVERT
Definition: gr_basic.h:40
@ GR_HIGHLIGHT
Definition: gr_basic.h:43
@ GR_ALLOW_HIGHCONTRAST
Definition: gr_basic.h:41
@ GR_NXOR
Definition: gr_basic.h:39
@ UNSPECIFIED_DRAWMODE
Definition: gr_basic.h:44
@ GR_COPY
Definition: gr_basic.h:42
@ GR_XOR
Definition: gr_basic.h:37
@ GR_AND
Definition: gr_basic.h:38
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:80
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:348
GR_DRAWMODE operator~(const GR_DRAWMODE &a)
Definition: gr_basic.h:47
void GRFilledSegment(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:269
void GRFilledArc(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition: gr_basic.cpp:378
void GRCSegm(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:192
void GRMoveTo(int x, int y)
Definition: gr_basic.cpp:179
GRLineStypeType
Definition: gr_basic.h:64
@ GR_DOTTED_LINE
Definition: gr_basic.h:67
@ GR_DASHED_LINE
Definition: gr_basic.h:68
@ GR_SOLID_LINE
Definition: gr_basic.h:66
GR_DRAWMODE g_XorMode
Definition: gr_basic.cpp:33
void GRClosedPoly(wxDC *aDC, int aPointCount, const VECTOR2I *aPoints, bool doFill, const COLOR4D &aColor)
Draw a closed polygon onto the drawing context aDC and optionally fills and/or draws a border around ...
Definition: gr_basic.cpp:342
void GRLine(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition: gr_basic.cpp:172
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition: gr_basic.cpp:394
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
Definition: gr_basic.cpp:369
GR_DRAWMODE operator&(const GR_DRAWMODE &a, const GR_DRAWMODE &b)
Definition: gr_basic.h:57
void GRPoly(wxDC *DC, int n, const VECTOR2I *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:332
bool GetGRForceBlackPenState(void)
Definition: gr_basic.cpp:156
void GRFilledCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aStrokeColor, const COLOR4D &aFillColor)
Draw a circle onto the drawing context aDC centered at the user coordinates (x,y).
Definition: gr_basic.cpp:360