50
51
EDA_COLOR_T g_DrawBgColor = WHITE;
53
#define USE_CLIP_FILLED_POLYGONS
55
#ifdef USE_CLIP_FILLED_POLYGONS
56
static void ClipAndDrawFilledPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[], int n );
54
static void ClipAndDrawPoly( EDA_RECT * ClipBox, wxDC * DC, wxPoint Points[],
59
57
/* These functions are used by corresponding functions
60
58
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
858
856
* Draw a new polyline and fill it if Fill, in screen space.
860
static void GRSPoly( EDA_RECT* ClipBox,
867
EDA_COLOR_T BgColor )
858
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
859
bool Fill, int width,
860
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
869
862
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
879
872
/* clip before send the filled polygon to wxDC, because under linux
880
873
* (GTK?) polygons having large coordinates are incorrectly drawn
874
* (integer overflow in coordinates, I am guessing)
882
#ifdef USE_CLIP_FILLED_POLYGONS
883
ClipAndDrawFilledPoly( ClipBox, DC, Points, n );
885
DC->DrawPolygon( n, Points ); // does not work very well under linux
876
ClipAndDrawPoly( ClipBox, DC, Points, n );
904
894
* Draw a new closed polyline and fill it if Fill, in screen space.
906
static void GRSClosedPoly( EDA_RECT* ClipBox,
913
EDA_COLOR_T BgColor )
896
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC,
897
int aPointCount, wxPoint aPoints[],
898
bool aFill, int aWidth,
900
EDA_COLOR_T aBgColor )
915
if( !IsGRSPolyDrawable( ClipBox, aPointCount, aPoints ) )
902
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
918
GRSetColorPen( DC, Color, width );
905
GRSetColorPen( aDC, aColor, aWidth );
920
if( Fill && ( aPointCount > 2 ) )
907
if( aFill && ( aPointCount > 2 ) )
922
909
GRLastMoveToX = aPoints[aPointCount - 1].x;
923
910
GRLastMoveToY = aPoints[aPointCount - 1].y;
924
GRSetBrush( DC, BgColor, FILLED );
925
#ifdef USE_CLIP_FILLED_POLYGONS
926
ClipAndDrawFilledPoly( ClipBox, DC, aPoints, aPointCount );
928
DC->DrawPolygon( aPointCount, aPoints ); // does not work very well under linux
911
GRSetBrush( aDC, aBgColor, FILLED );
912
ClipAndDrawPoly( aClipBox, aDC, aPoints, aPointCount );
933
GRSetBrush( DC, BgColor );
934
DC->DrawLines( aPointCount, aPoints );
916
GRSetBrush( aDC, aBgColor );
917
aDC->DrawLines( aPointCount, aPoints );
919
int lastpt = aPointCount - 1;
936
920
/* Close the polygon. */
937
if( aPoints[aPointCount - 1] != aPoints[0] )
921
if( aPoints[lastpt] != aPoints[0] )
943
aPoints[aPointCount - 1].x,
944
aPoints[aPointCount - 1].y,
923
GRLine( aClipBox, aDC, aPoints[0].x, aPoints[0].y,
924
aPoints[lastpt].x, aPoints[lastpt].y,
1155
1134
void GRFilledArc( EDA_RECT* ClipBox, wxDC* DC, int x, int y,
1156
double StAngle, double EndAngle, int r,
1135
double StAngle, double EndAngle, int r,
1157
1136
EDA_COLOR_T Color, EDA_COLOR_T BgColor )
1159
1138
GRFilledArc( ClipBox, DC, x, y, StAngle, EndAngle, r, 0, Color, BgColor );
1322
1301
void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
1323
1302
int aWidth, EDA_COLOR_T aColor, wxPenStyle aStyle )
1326
1304
wxPoint points[5];
1327
1305
points[0] = wxPoint(x1, y1);
1328
1306
points[1] = wxPoint(x1, y2);
1329
1307
points[2] = wxPoint(x2, y2);
1330
1308
points[3] = wxPoint(x2, y1);
1331
1309
points[4] = points[0];
1332
GRSetColorPen( aDC, aColor, aWidth, aStyle );
1333
GRSetBrush( aDC, BLACK );
1336
EDA_RECT clipbox(*aClipBox);
1337
clipbox.Inflate(aWidth);
1338
ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1341
ClipAndDrawFilledPoly(aClipBox, aDC, points, 5);
1310
GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth,
1345
1315
void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2,
1346
1316
int aWidth, EDA_COLOR_T aColor, EDA_COLOR_T aBgColor )
1349
1318
wxPoint points[5];
1350
1319
points[0] = wxPoint(x1, y1);
1351
1320
points[1] = wxPoint(x1, y2);
1354
1323
points[4] = points[0];
1355
1324
GRSetBrush( aDC, aBgColor, FILLED );
1356
1325
GRSetColorPen( aDC, aBgColor, aWidth );
1357
1327
if( aClipBox && (aWidth > 0) )
1359
1329
EDA_RECT clipbox(*aClipBox);
1360
1330
clipbox.Inflate(aWidth);
1361
ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1331
ClipAndDrawPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate
1364
ClipAndDrawFilledPoly(aClipBox, aDC, points, 5);
1334
ClipAndDrawPoly(aClipBox, aDC, points, 5 );
1368
#ifdef USE_CLIP_FILLED_POLYGONS
1371
* Function ClipAndDrawFilledPoly
1338
* Function ClipAndDrawPoly
1372
1339
* Used to clip a polygon and draw it as Filled Polygon
1373
1340
* uses the Sutherland and Hodgman algo to clip the given poly against a
1374
1341
* rectangle. This rectangle is the drawing area this is useful under
1383
1350
#include <SutherlandHodgmanClipPoly.h>
1385
void ClipAndDrawFilledPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], int n )
1352
void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPoints[], int n )
1387
1354
if( aClipBox == NULL )
1561
1525
return candidate;
1564
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
1528
void GRDrawAnchor( EDA_RECT *aClipBox, wxDC *aDC, int x, int y,
1565
1529
int aSize, EDA_COLOR_T aColor )
1567
1531
int anchor_size = aDC->DeviceToLogicalXRel( aSize );