KiCad PCB EDA Suite
Loading...
Searching...
No Matches
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 The 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
19 * along with this program. If not, see <https://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
35enum GR_DRAWMODE : unsigned int
36{
37 GR_OR = 0x01000000,
38 GR_XOR = 0x02000000,
39 GR_AND = 0x04000000,
40 GR_NXOR = 0x08000000,
41 GR_INVERT = 0x10000000,
43 GR_COPY = 0x40000000,
44 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, wxPenStyle stype = wxPENSTYLE_SOLID );
74void GRSetBrush( wxDC* DC, const COLOR4D& Color, bool fill = false );
75
79void GRForceBlackPen( bool flagforce );
80
84bool GetGRForceBlackPenState( void );
85
86void GRLine( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
87 const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
88void GRLine( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
89 wxPenStyle aStyle = wxPENSTYLE_SOLID );
90void GRMoveTo( int x, int y );
91void GRLineTo( wxDC* DC, int x, int y, int width, const COLOR4D& Color );
92
93void GRPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width, const COLOR4D& Color,
94 const COLOR4D& BgColor );
95
106void GRClosedPoly( wxDC* aDC, int aPointCount, const VECTOR2I* aPoints, bool doFill, const COLOR4D& aColor );
107
119void GRFilledCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
120 const COLOR4D& aStrokeColor, const COLOR4D& aFillColor );
121void GRCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth, const COLOR4D& aColor );
122
123void GRArc( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
124 int aWidth, const COLOR4D& aColor );
125void GRFilledArc( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
126 int width, const COLOR4D& Color, const COLOR4D& BgColor );
127
128void GRFilledSegment( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
129 const COLOR4D& aColor );
130
131void GRCSegm( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth, const COLOR4D& aColor );
132
133void GRFilledRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
134 const COLOR4D& aColor, const COLOR4D& aBgColor );
135void GRRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth, const COLOR4D& aColor );
136
137void GRSFilledRect( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
138 const COLOR4D& BgColor );
139
140#endif /* define GR_BASIC */
A color representation with 4 components: red, green, blue, alpha.
Definition color4d.h:101
GR_DRAWMODE g_XorMode
Definition gr_basic.cpp:34
void GRSetBrush(wxDC *DC, const COLOR4D &Color, bool fill=false)
Definition gr_basic.cpp:132
void GRForceBlackPen(bool flagforce)
Definition gr_basic.cpp:159
void GRResetPenAndBrush(wxDC *DC)
Definition gr_basic.cpp:73
void GRLineTo(wxDC *DC, int x, int y, int width, const COLOR4D &Color)
Definition gr_basic.cpp:195
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:385
void GRSFilledRect(wxDC *DC, int x1, int y1, int x2, int y2, int width, const COLOR4D &Color, const COLOR4D &BgColor)
Definition gr_basic.cpp:411
void GRSetColorPen(wxDC *DC, const COLOR4D &Color, int width=1, wxPenStyle stype=wxPENSTYLE_SOLID)
Definition gr_basic.cpp:81
void GRCircle(wxDC *aDC, const VECTOR2I &aPos, int aRadius, int aWidth, const COLOR4D &aColor)
Definition gr_basic.cpp:346
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:278
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:376
void GRCSegm(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor)
Definition gr_basic.cpp:201
void GRMoveTo(int x, int y)
Definition gr_basic.cpp:188
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
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:340
void GRLine(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, wxPenStyle aStyle=wxPENSTYLE_SOLID)
Definition gr_basic.cpp:181
void GRFilledRect(wxDC *DC, const VECTOR2I &aStart, const VECTOR2I &aEnd, int aWidth, const COLOR4D &aColor, const COLOR4D &aBgColor)
Definition gr_basic.cpp:392
GR_DRAWMODE
Drawmode. Compositing mode plus a flag or two.
Definition gr_basic.h:36
@ GR_OR
Definition gr_basic.h:37
@ GR_INVERT
Definition gr_basic.h:41
@ GR_HIGHLIGHT
Definition gr_basic.h:44
@ GR_ALLOW_HIGHCONTRAST
Definition gr_basic.h:42
@ GR_NXOR
Definition gr_basic.h:40
@ GR_COPY
Definition gr_basic.h:43
@ GR_XOR
Definition gr_basic.h:38
@ GR_AND
Definition gr_basic.h:39
void GRArc(wxDC *aDC, const VECTOR2I &aStart, const VECTOR2I &aEnd, const VECTOR2I &aCenter, int aWidth, const COLOR4D &aColor)
Definition gr_basic.cpp:367
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)
Definition gr_basic.cpp:333
bool GetGRForceBlackPenState(void)
Definition gr_basic.cpp:165
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:358
VECTOR2< int32_t > VECTOR2I
Definition vector2d.h:708