From e9c618b65a540c36aede11c7d7e07a17378d1c10 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 13 Apr 2011 12:22:58 +0200 Subject: [PATCH] gr_basic: fix incorrect clipping of thick lines (due to changes in code, the thickness was not taken in account to calculate the clip box size) --- Documentation/wxWidgets_patch_notes.txt | 2 +- common/gr_basic.cpp | 55 ++++++++++++------------- 2 files changed, 27 insertions(+), 30 deletions(-) diff --git a/Documentation/wxWidgets_patch_notes.txt b/Documentation/wxWidgets_patch_notes.txt index 0dbe5e6c9b..df56632366 100644 --- a/Documentation/wxWidgets_patch_notes.txt +++ b/Documentation/wxWidgets_patch_notes.txt @@ -43,7 +43,7 @@ after calling this conversion function, the comma is changed in point. (Happens after reading a parameter stored in a wxConfig structure, if this parameter is a double) Workaround: -Use a version > 2.9.2 +Use a version > 2.9.1 Currently ( 2011, april 12 ) the 2.9.2 is not yet finalized (and can be found only on the wxWidgets snv server) diff --git a/common/gr_basic.cpp b/common/gr_basic.cpp index a7de50d837..cfaa10f97f 100644 --- a/common/gr_basic.cpp +++ b/common/gr_basic.cpp @@ -326,18 +326,9 @@ static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int if( ClipBox ) { - xcliplo = ClipBox->GetX(); - ycliplo = ClipBox->GetY(); - xcliphi = ClipBox->GetRight(); - ycliphi = ClipBox->GetBottom(); - - xcliplo -= width; - ycliplo -= width; - - xcliphi += width; - ycliphi += width; - - if( clipLine( ClipBox, x1, y1, x2, y2 ) ) + EDA_RECT clipbox(*ClipBox); + clipbox.Inflate(width/2); + if( clipLine( &clipbox, x1, y1, x2, y2 ) ) return; } @@ -663,18 +654,10 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, if( ClipBox ) { - xcliplo = ClipBox->GetX(); - ycliplo = ClipBox->GetY(); - xcliphi = ClipBox->GetRight(); - ycliphi = ClipBox->GetHeight(); + EDA_RECT clipbox(*ClipBox); + clipbox.Inflate(width/2); - xcliplo -= width; - ycliplo -= width; - - xcliphi += width; - ycliphi += width; - - if( clipLine( ClipBox, x1, y1, x2, y2 ) ) + if( clipLine( &clipbox, x1, y1, x2, y2 ) ) return; } @@ -1345,12 +1328,19 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, points[4] = points[0]; GRSetColorPen( aDC, aColor, aWidth, aStyle ); GRSetBrush( aDC, BLACK ); - ClipAndDrawFilledPoly(aClipBox, aDC, points, 5); // polygon approach is more accurate + if( aClipBox ) + { + EDA_RECT clipbox(*aClipBox); + clipbox.Inflate(aWidth); + ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate + } + else + ClipAndDrawFilledPoly(aClipBox, aDC, points, 5); } -void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, - int width, int Color, int BgColor ) +void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, + int aWidth, int aColor, int aBgColor ) { wxPoint points[5]; @@ -1359,9 +1349,16 @@ void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, points[2] = wxPoint(x2, y2); points[3] = wxPoint(x2, y1); points[4] = points[0]; - GRSetBrush( DC, BgColor, FILLED ); - GRSetColorPen( DC, BgColor, width ); - ClipAndDrawFilledPoly(ClipBox, DC, points, 5); // polygon approach is more accurate + GRSetBrush( aDC, aBgColor, FILLED ); + GRSetColorPen( aDC, aBgColor, aWidth ); + if( aClipBox && (aWidth > 0) ) + { + EDA_RECT clipbox(*aClipBox); + clipbox.Inflate(aWidth); + ClipAndDrawFilledPoly(&clipbox, aDC, points, 5); // polygon approach is more accurate + } + else + ClipAndDrawFilledPoly(aClipBox, aDC, points, 5); }