gr_basic.h 9.59 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
/*
 * This program source code file is part of KiCad, a free EDA CAD application.
 *
 * Copyright (C) 2006 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
 * Copyright (C) 2011 Wayne Stambaugh <stambaughw@verizon.net>
 * Copyright (C) 1992-2011 KiCad Developers, see AUTHORS.txt for contributors.
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, you may find one here:
 * http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
 * or you may search the http://www.gnu.org website for the version 2 license,
 * or you may write to the Free Software Foundation, Inc.,
 * 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
 */

/**
 * @file gr_basic.h
 */
29 30 31 32

#ifndef GR_BASIC
#define GR_BASIC

33
#include <colors.h>
charras's avatar
charras committed
34
#include <vector>
35
class EDA_RECT;
36 37


38 39 40 41 42
#define GR_COPY 0
#define GR_OR   0x01000000
#define GR_XOR  0x02000000
#define GR_AND  0x04000000
#define GR_NXOR 0x08000000
43
#define GR_INVERT 0x10000000
44

45
#define GR_HIGHLIGHT 0x80000000
46

47 48 49 50
#define GR_M_LEFT_DOWN   0x10000000
#define GR_M_RIGHT_DOWN  0x20000000
#define GR_M_MIDDLE_DOWN 0x40000000
#define GR_M_DCLICK      0x80000000
51

52 53 54
//wxWidgets 2.8 compatibility
#if !wxCHECK_VERSION(2,9,0)
#define wxPENSTYLE_SOLID wxSOLID
55 56
#define wxPENSTYLE_SHORT_DASH wxSHORT_DASH
#define wxPENSTYLE_DOT_DASH wxDOT_DASH
57 58 59
typedef int wxPenStyle;
#endif

60

61 62
extern int g_XorMode;
extern int g_DrawBgColor;
63 64


65 66
typedef enum {
    /* Line styles for Get/SetLineStyle. */
67 68 69
    GR_SOLID_LINE  = 0,
    GR_DOTTED_LINE = 1,
    GR_DASHED_LINE = 3
70 71 72
} GRLineStypeType;


73
class EDA_DRAW_PANEL;
74

75 76 77
void GRSetDrawMode( wxDC* DC, int mode );
int  GRGetDrawMode( wxDC* DC );
void GRResetPenAndBrush( wxDC* DC );
78
void GRSetColorPen( wxDC* DC, int Color, int width = 1, wxPenStyle stype = wxPENSTYLE_SOLID );
79
void GRSetBrush( wxDC* DC, int Color, int fill = 0 );
80

81 82
/**
 * Function GRForceBlackPen
83 84
 * @param flagforce True to force a black pen whenever the asked color
 */
85
void GRForceBlackPen( bool flagforce );
86

87 88
/**
 * Function GetGRForceBlackPenState
89
 * @return ForceBlackPen (True if a black pen was forced)
90 91
 */
bool GetGRForceBlackPenState( void );
92

93 94 95
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd, int aWidth, int aColor );
void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
void GRMixedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
96
                  int width, int Color );
97
void GRDashedLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int  y2,
98
                   int width, int Color );
99
void GRDashedLineTo( EDA_RECT* ClipBox, wxDC* DC, int x2, int y2, int width, int Color );
100
void GRMoveTo( int x, int y );
101
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, int Color );
102

103
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[], bool Fill,
104 105
             int width, int Color, int BgColor );

106
void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
107
               int x3, int y3, int width, int Color );
108
void GRBezier( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
109
               int x3, int y3, int x4, int y4, int width, int Color );
110 111 112

/**
 * Function GRClosedPoly
113 114
 * draws a closed polygon onto the drawing context \a aDC and optionally fills
 * and/or draws a border around it.
115
 * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
116
 * @param aDC the device context into which drawing should occur.
117 118 119
 * @param aPointCount the number of points in the array \a aPoints.
 * @param aPoints The points to draw.
 * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
120 121 122
 * @param aPenColor the color index of the border.
 * @param aFillColor the fill color of the polygon's interior.
 */
123
void GRClosedPoly( EDA_RECT* ClipBox,
124 125 126 127 128 129
                   wxDC  *   aDC,
                   int       aPointCount,
                   wxPoint   aPoints[],
                   bool      doFill,
                   int       aPenColor,
                   int       aFillColor );
130

131 132
// @todo could make these 2 closed polygons calls a single function and default
// the aPenWidth argument
133 134 135

/**
 * Function GRClosedPoly
136 137
 * draws a closed polygon onto the drawing context \a aDC and optionally fills
 * and/or draws a border around it.
138
 * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
139 140
 * @param aDC the device context into which drawing should occur.
 * @param aPointCount the number of points in the array \a aPointArray.
141 142 143
 * @param aPoints the points to draw.
 * @param doFill true if polygon is to be filled, else false and only the boundary is drawn.
 * @param aPenWidth is the width of the pen to use on the perimeter, can be zero.
144 145 146
 * @param aPenColor the color index of the border.
 * @param aFillColor the fill color of the polygon's interior.
 */
147
void GRClosedPoly( EDA_RECT* ClipBox,
148 149 150 151 152 153 154
                   wxDC*     aDC,
                   int       aPointCount,
                   wxPoint   aPoints[],
                   bool      doFill,
                   int       aPenWidth,
                   int       aPenColor,
                   int       aFillColor );
155 156 157 158


/**
 * Function GRCircle
159 160
 * draws a circle onto the drawing context \a aDC centered at the user
 * coordinates (x,y)
161
 *
162
 * @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
163 164
 * @param aDC the device context into which drawing should occur.
 * @param x The x coordinate in user space of the center of the circle.
165
 * @param y The y coordinate in user space of the center of the circle.
166
 * @param aRadius is the radius of the circle.
167 168 169
 * @param aColor is an index into our color table of RGB colors.
 * @see EDA_Colors and colors.h
 */
170 171 172
void GRCircle( EDA_RECT* ClipBox, wxDC* aDC, int x, int y, int aRadius, int aColor );
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int  width, int Color );
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
173
                     int Color, int BgColor );
174 175
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aColor );
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWidth, int aColor );
176

177
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
178
            int EndAngle, int r, int Color );
179
void GRArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
180
            int EndAngle, int r, int width, int Color );
181
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
182
             int xc, int yc, int Color );
183
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
184
             int xc, int yc, int width, int Color );
185
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
186
             wxPoint aCenter, int aWidth, int aColor );
187
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
188
                  int StAngle, int EndAngle, int r, int Color, int BgColor );
189
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int StAngle,
190
                  int EndAngle, int r, int width, int Color, int BgColor );
191
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width, int Color );
192

193
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
194
                  int width, int Color );
195
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
196 197
                      int aWidth, int aColor );

198
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
199
              int width, int aPenSize, int Color );
200
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aStart, wxPoint aEnd,
201
              int aWidth, int aColor );
202 203

void GRSetColor( int Color );
204
void GRSetDefaultPalette();
205
int  GRGetColor();
206 207
void GRPutPixel( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int color );
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
208
                   int x2, int y2, int Color, int BgColor );
209
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
210
                   int x2, int y2, int width, int Color, int BgColor );
211 212 213
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int Color );
void GRRect( EDA_RECT* ClipBox, wxDC* DC,const EDA_RECT& aRect, int aWidth, int Color );
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
214
             int x2, int y2, int width, int Color );
215
void GRRectPs( EDA_RECT* aClipBox, wxDC* aDC,const EDA_RECT& aRect,
216
               int aWidth, int 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, int Color, int BgColor );
220

221 222
/**
 * Function GRLineArray
223 224 225 226 227 228 229 230
 * draws an array of lines (not a polygon).
 * @param aClipBox = the clip box
 * @param aDC = the device context into which drawing should occur.
 * @param aLines = a list of pair of coordinate in user space: a pair for each line.
 * @param aWidth = the width of each line.
 * @param aColor = an index into our color table of RGB colors.
 * @see EDA_Colors and colors.h
 */
231
void GRLineArray(  EDA_RECT* aClipBox, wxDC* aDC,std::vector<wxPoint>& aLines,
232
                   int aWidth, int aColor );
233

234
#endif      /* define GR_BASIC */