code enhancement (remove duplicate)

This commit is contained in:
Simon Richter 2017-10-26 10:19:15 +02:00 committed by jean-pierre charras
parent b18cd4cb19
commit 48ed0dcda2
1 changed files with 16 additions and 26 deletions

View File

@ -788,7 +788,7 @@ void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, wxPoint Points[],
}
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, COLOR4D Color )
static bool ClipCircle( EDA_RECT* ClipBox, int xc, int yc, int r, int width )
{
/* Clip circles off screen. */
if( ClipBox )
@ -800,18 +800,27 @@ void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, CO
ym = ClipBox->GetBottom();
if( xc < ( x0 - r - width ) )
return;
return true;
if( yc < ( y0 - r - width ) )
return;
return true;
if( xc > ( r + xm + width ) )
return;
return true;
if( yc > ( r + ym + width ) )
return;
return true;
}
return false;
}
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, COLOR4D Color )
{
if( ClipCircle( ClipBox, xc, yc, r, width ) )
return;
GRSetBrush( DC, Color, NOT_FILLED );
GRSetColorPen( DC, Color, width );
DC->DrawEllipse( xc - r, yc - r, r + r, r + r );
@ -833,28 +842,9 @@ void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, wxPoint aPos, int aRadius, int aWi
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r,
int width, COLOR4D Color, COLOR4D BgColor )
{
/* Clip circles off screen. */
if( ClipBox )
{
int x0, y0, xm, ym;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
if( x < ( x0 - r ) )
if( ClipCircle( ClipBox, x, y, r, width ) )
return;
if( y < ( y0 - r ) )
return;
if( x > ( r + xm ) )
return;
if( y > ( r + ym ) )
return;
}
GRSetBrush( DC, BgColor, FILLED );
GRSetColorPen( DC, Color, width );
DC->DrawEllipse( x - r, y - r, r + r, r + r );