Bug fixes in arc & textbox printing.

Also removal of the no-longer-used clipping code from GR*.
This commit is contained in:
Jeff Young 2022-01-28 22:51:34 +00:00
parent 25a7de730c
commit 60bcfd1bf1
25 changed files with 282 additions and 658 deletions

View File

@ -673,8 +673,7 @@ void DIALOG_PAGES_SETTINGS::UpdateDrawingSheetExample()
renderSettings.SetLayerColor( LAYER_DRAWINGSHEET, color );
}
GRFilledRect( nullptr, &memDC, 0, 0, m_layout_size.x, m_layout_size.y, bgColor,
bgColor );
GRFilledRect( &memDC, VECTOR2I( 0, 0 ), m_layout_size, 0, bgColor, bgColor );
PrintDrawingSheet( &renderSettings, pageDUMMY, emptyString, emptyString, m_tb,
m_screen->GetPageCount(), m_screen->GetPageNumber(), 1, &Prj(),

View File

@ -211,8 +211,7 @@ void DS_DRAW_ITEM_POLYPOLYGONS::PrintWsItem( const RENDER_SETTINGS* aSettings,
outline.CPoint( ii ).y + aOffset.y );
}
GRPoly( nullptr, DC, points_moved.size(), &points_moved[0], true, penWidth,
color, color );
GRPoly( DC, points_moved.size(), &points_moved[0], true, penWidth, color, color );
}
}
@ -302,8 +301,7 @@ void DS_DRAW_ITEM_RECT::PrintWsItem( const RENDER_SETTINGS* aSettings, const VEC
COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
GRRect( nullptr, DC, GetStart().x + aOffset.x, GetStart().y + aOffset.y,
GetEnd().x + aOffset.x, GetEnd().y + aOffset.y, penWidth, color );
GRRect( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
}
@ -401,7 +399,7 @@ void DS_DRAW_ITEM_LINE::PrintWsItem( const RENDER_SETTINGS* aSettings, const VEC
COLOR4D color = aSettings->GetLayerColor( LAYER_DRAWINGSHEET );
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
GRLine( nullptr, DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
GRLine( DC, GetStart() + aOffset, GetEnd() + aOffset, penWidth, color );
}

View File

@ -22,84 +22,49 @@
#include <gr_basic.h>
#include <trigo.h>
#include <eda_item.h>
#include <math_for_graphics.h>
#include <wx/graphics.h>
#include <geometry/geometry_utils.h>
#include <math/util.h> // for KiROUND
#include <algorithm>
static const bool FILLED = true;
static const bool NOT_FILLED = false;
/* Important Note:
* These drawing functions clip draw item before send these items to wxDC draw
* functions. For guy who asks why i did it, see a sample of problems encountered
* when pixels
* coordinates overflow 16 bits values:
* http://trac.wxwidgets.org/ticket/10446
* Problems can be found under Windows **and** Linux (mainly when drawing arcs)
* (mainly at low zoom values (2, 1 or 0.5), in Pcbnew)
* some of these problems could be now fixed in recent distributions.
*
* Currently (feb 2009) there are overflow problems when drawing solid (filled)
* polygons under linux without clipping
*
* So before removing clipping functions, be aware these bug (they are not in
* KiCad or wxWidgets) are fixed by testing how are drawn complex lines arcs
* and solid polygons under Windows and Linux and remember users can have old
* versions with bugs
*/
/* Definitions for enabling and disabling debugging features in gr_basic.cpp.
* Please remember to set these back to 0 before making LAUNCHPAD commits.
*/
#define DEBUG_DUMP_CLIP_ERROR_COORDS 0 // Set to 1 to dump clip algorithm errors.
#define DEBUG_DUMP_CLIP_COORDS 0 // Set to 1 to dump clipped coordinates.
// For draw mode = XOR GR_XOR or GR_NXOR by background color
GR_DRAWMODE g_XorMode = GR_NXOR;
static void ClipAndDrawPoly( EDA_RECT* ClipBox, wxDC* DC, const VECTOR2I* Points, int n );
/* These functions are used by corresponding functions
* ( GRSCircle is called by GRCircle for instance) after mapping coordinates
* from user units to screen units(pixels coordinates)
*/
static void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1,
int x2, int y2, int aWidth, const COLOR4D& aColor );
static void GRSRect( wxDC* aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D& aColor );
/**/
static int GRLastMoveToX, GRLastMoveToY;
static bool s_ForceBlackPen; /* if true: draws in black instead of
* color for printing. */
static int xcliplo = 0,
ycliplo = 0,
xcliphi = 2000,
ycliphi = 2000;
static COLOR4D s_DC_lastbrushcolor( 0, 0, 0, 0 );
static bool s_DC_lastbrushfill = false;
static wxDC* s_DC_lastDC = nullptr;
static void WinClipAndDrawLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width )
static void vector2IwxDrawPolygon( wxDC* aDC, const VECTOR2I* Points, int n )
{
wxPoint* points = new wxPoint[n];
for( int i = 0; i < n; i++ )
points[i] = wxPoint( Points[i].x, Points[i].y );
aDC->DrawPolygon( n, points );
delete[] points;
}
static void winDrawLine( wxDC* DC, int x1, int y1, int x2, int y2, int width )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
if( ClipBox )
{
EDA_RECT clipbox(*ClipBox);
clipbox.Inflate(width/2);
if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
return;
}
DC->DrawLine( x1, y1, x2, y2 );
}
@ -194,20 +159,20 @@ bool GetGRForceBlackPenState( void )
}
void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color, wxPenStyle aStyle)
void GRLine( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
wxPenStyle aStyle)
{
GRSetColorPen( DC, Color, width, aStyle );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
winDrawLine( DC, x1, y1, x2, y2, width );
GRLastMoveToX = x2;
GRLastMoveToY = y2;
}
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor, wxPenStyle aStyle )
void GRLine( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor, wxPenStyle aStyle )
{
GRLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
GRLine( aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aStyle );
}
@ -218,47 +183,37 @@ void GRMoveTo( int x, int y )
}
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, const COLOR4D& Color )
void GRLineTo( wxDC* DC, int x, int y, int width, const COLOR4D& Color )
{
GRLine( ClipBox, DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
GRLine( DC, GRLastMoveToX, GRLastMoveToY, x, y, width, Color );
}
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
int aPenSize, const COLOR4D& Color )
void GRCSegm( wxDC* DC, const VECTOR2I& A, const VECTOR2I& B, int width, const COLOR4D& Color )
{
GRLastMoveToX = x2;
GRLastMoveToY = y2;
if( ClipBox )
{
EDA_RECT clipbox( *ClipBox );
clipbox.Inflate( width / 2 );
if( ClipLine( &clipbox, x1, y1, x2, y2 ) )
return;
}
GRLastMoveToX = B.x;
GRLastMoveToY = B.y;
if( width <= 2 ) /* single line or 2 pixels */
{
GRSetColorPen( DC, Color, width );
DC->DrawLine( x1, y1, x2, y2 );
DC->DrawLine( A.x, A.y, B.x, B.y );
return;
}
GRSetBrush( DC, Color, NOT_FILLED );
GRSetColorPen( DC, Color, aPenSize );
GRSetColorPen( DC, Color, 0 );
int radius = ( width + 1 ) >> 1;
int dx = x2 - x1;
int dy = y2 - y1;
int dx = B.x - A.x;
int dy = B.y - A.y;
EDA_ANGLE angle( VECTOR2I( dx, dy ) );
angle = -angle;
VECTOR2I start;
VECTOR2I end;
VECTOR2I org( x1, y1 );
VECTOR2I org( A.x, A.y );
int len = (int) hypot( dx, dy );
// We know if the DC is mirrored, to draw arcs
@ -305,109 +260,38 @@ void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int w
end += org;
if( !mirrored )
DC->DrawArc( end.x, end.y, start.x, start.y, x2, y2 );
DC->DrawArc( end.x, end.y, start.x, start.y, B.x, B.y );
else
DC->DrawArc( start.x, start.y, end.x, end.y, x2, y2 );
DC->DrawArc( start.x, start.y, end.x, end.y, B.x, B.y );
}
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color )
{
GRCSegm( ClipBox, DC, x1, y1, x2, y2, width, 0, Color );
}
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor )
{
GRCSegm( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, 0, aColor );
}
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color )
{
GRSetColorPen( DC, Color, width );
WinClipAndDrawLine( ClipBox, DC, x1, y1, x2, y2, width );
}
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor )
void GRFilledSegment( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor )
{
GRSetColorPen( aDC, aColor, aWidth );
WinClipAndDrawLine( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
winDrawLine( aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth );
}
static bool IsGRSPolyDrawable( EDA_RECT* ClipBox, int n, const VECTOR2I* Points )
{
if( !ClipBox )
return true;
if( n <= 0 )
return false;
int Xmin, Xmax, Ymin, Ymax;
Xmin = Xmax = Points[0].x;
Ymin = Ymax = Points[0].y;
for( int ii = 1; ii < n; ii++ ) // calculate rectangle
{
Xmin = std::min( Xmin, Points[ii].x );
Xmax = std::max( Xmax, Points[ii].x );
Ymin = std::min( Ymin, Points[ii].y );
Ymax = std::max( Ymax, Points[ii].y );
}
xcliplo = ClipBox->GetX();
ycliplo = ClipBox->GetY();
xcliphi = ClipBox->GetRight();
ycliphi = ClipBox->GetBottom();
if( Xmax < xcliplo )
return false;
if( Xmin > xcliphi )
return false;
if( Ymax < ycliplo )
return false;
if( Ymin > ycliphi )
return false;
return true;
}
/**
* Draw a new polyline and fill it if Fill, in screen space.
*/
static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points, bool Fill,
int width, const COLOR4D& Color, const COLOR4D& BgColor )
static void GRSPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width,
const COLOR4D& Color, const COLOR4D& BgColor )
{
if( !IsGRSPolyDrawable( ClipBox, n, Points ) )
return;
if( Fill && ( n > 2 ) )
{
GRSetBrush( DC, BgColor, FILLED );
GRSetColorPen( DC, Color, width );
/* clip before send the filled polygon to wxDC, because under linux
* (GTK?) polygons having large coordinates are incorrectly drawn
* (integer overflow in coordinates, I am guessing)
*/
ClipAndDrawPoly( ClipBox, DC, Points, n );
vector2IwxDrawPolygon( DC, Points, n );
}
else
{
GRMoveTo( Points[0].x, Points[0].y );
for( int i = 1; i < n; ++i )
{
GRLineTo( ClipBox, DC, Points[i].x, Points[i].y, width, Color );
}
GRLineTo( DC, Points[i].x, Points[i].y, width, Color );
}
}
@ -415,37 +299,29 @@ static void GRSPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points,
/**
* Draw a new closed polyline and fill it if Fill, in screen space.
*/
static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const VECTOR2I* aPoints,
bool aFill, int aWidth, const COLOR4D& aColor, const COLOR4D& aBgColor )
static void GRSClosedPoly( wxDC* aDC, int aPointCount, const VECTOR2I* aPoints, bool aFill,
int aWidth, const COLOR4D& aColor, const COLOR4D& aBgColor )
{
if( !IsGRSPolyDrawable( aClipBox, aPointCount, aPoints ) )
return;
if( aFill && ( aPointCount > 2 ) )
{
GRLastMoveToX = aPoints[aPointCount - 1].x;
GRLastMoveToY = aPoints[aPointCount - 1].y;
GRSetBrush( aDC, aBgColor, FILLED );
GRSetColorPen( aDC, aColor, aWidth );
ClipAndDrawPoly( aClipBox, aDC, aPoints, aPointCount );
vector2IwxDrawPolygon( aDC, aPoints, aPointCount );
}
else
{
GRMoveTo( aPoints[0].x, aPoints[0].y );
for( int i = 1; i < aPointCount; ++i )
{
GRLineTo( aClipBox, aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
}
GRLineTo( aDC, aPoints[i].x, aPoints[i].y, aWidth, aColor );
int lastpt = aPointCount - 1;
// Close the polygon
if( aPoints[lastpt] != aPoints[0] )
{
GRLineTo( aClipBox, aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
}
GRLineTo( aDC, aPoints[0].x, aPoints[0].y, aWidth, aColor );
}
}
@ -453,197 +329,76 @@ static void GRSClosedPoly( EDA_RECT* aClipBox, wxDC* aDC, int aPointCount, const
/**
* Draw a new polyline and fill it if Fill, in drawing space.
*/
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width,
const COLOR4D& Color, const COLOR4D& BgColor )
void GRPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width, const COLOR4D& Color,
const COLOR4D& BgColor )
{
GRSPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
GRSPoly( DC, n, Points, Fill, width, Color, BgColor );
}
/**
* Draw a closed polyline and fill it if Fill, in object space.
*/
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points, bool Fill,
const COLOR4D& Color, const COLOR4D& BgColor )
void GRClosedPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, const COLOR4D& Color )
{
GRClosedPoly( ClipBox, DC, n, Points, Fill, 0, Color, BgColor );
GRSClosedPoly( DC, n, Points, Fill, 0, Color, Color );
}
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width,
const COLOR4D& Color, const COLOR4D& BgColor )
void GRCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth, const COLOR4D& aColor )
{
GRSClosedPoly( ClipBox, DC, n, Points, Fill, width, Color, BgColor );
}
static bool clipCircle( EDA_RECT* aClipBox, int xc, int yc, int r, int aWidth )
{
// Clip circles that are outside the ClipBox.
if( aClipBox )
{
int x0, y0, xm, ym;
x0 = aClipBox->GetX();
y0 = aClipBox->GetY();
xm = aClipBox->GetRight();
ym = aClipBox->GetBottom();
r += aWidth;
if( xc < ( x0 - r ) )
return true;
if( yc < ( y0 - r ) )
return true;
if( xc > ( r + xm ) )
return true;
if( yc > ( r + ym ) )
return true;
}
return false;
}
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int xc, int yc, int r, int width, const COLOR4D& Color )
{
if( clipCircle( ClipBox, xc, yc, r, width ) || r <= 0 )
return;
GRSetBrush( DC, Color, NOT_FILLED );
GRSetColorPen( DC, Color, width );
GRSetBrush( aDC, aColor, NOT_FILLED );
GRSetColorPen( aDC, aColor, aWidth );
// Draw two arcs here to make a circle. Unfortunately, the printerDC doesn't handle
// transparent brushes when used with circles. It does work for for arcs, however
DC->DrawArc(xc + r, yc, xc - r, yc, xc, yc);
DC->DrawArc(xc - r, yc, xc + r, yc, xc, yc);
aDC->DrawArc(aPos.x + aRadius, aPos.y, aPos.x - aRadius, aPos.y, aPos.x, aPos.y );
aDC->DrawArc(aPos.x - aRadius, aPos.y, aPos.x + aRadius, aPos.y, aPos.x, aPos.y );
}
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
const COLOR4D& aColor )
void GRFilledCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
const COLOR4D& aStrokeColor, const COLOR4D& aFillColor )
{
GRCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, aWidth, aColor );
GRSetBrush( aDC, aFillColor, FILLED );
GRSetColorPen( aDC, aStrokeColor, aWidth );
aDC->DrawEllipse( aPos.x - aRadius, aPos.y - aRadius, 2 * aRadius, 2 * aRadius );
}
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
const COLOR4D& Color, const COLOR4D& BgColor )
void GRArc( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
int aWidth, const COLOR4D& aColor )
{
if( clipCircle( ClipBox, x, y, r, width ) || r <= 0 )
return;
GRSetBrush( DC, BgColor, FILLED );
GRSetColorPen( DC, Color, width );
DC->DrawEllipse( x - r, y - r, r + r, r + r );
GRSetBrush( aDC, aColor );
GRSetColorPen( aDC, aColor, aWidth );
aDC->DrawArc( aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y );
}
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aPos, int aRadius,
const COLOR4D& aColor )
void GRFilledArc( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
int width, const COLOR4D& Color, const COLOR4D& BgColor )
{
GRFilledCircle( aClipBox, aDC, aPos.x, aPos.y, aRadius, 0, aColor, aColor );
}
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int xc, int yc,
int width, const COLOR4D& Color )
{
/* Clip arcs off screen. */
if( ClipBox )
{
int x0, y0, xm, ym, r;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
r = KiROUND( Distance( x1, y1, xc, yc ) );
if( xc < ( x0 - r ) )
return;
if( yc < ( y0 - r ) )
return;
if( xc > ( r + xm ) )
return;
if( yc > ( r + ym ) )
return;
}
GRSetBrush( DC, Color );
GRSetColorPen( DC, Color, width );
DC->DrawArc( x1, y1, x2, y2, xc, yc );
}
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
const VECTOR2I& aCenter, int aWidth, const COLOR4D& aColor )
{
GRArc1( aClipBox, aDC, aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y,
aWidth, aColor );
}
void GRFilledArc1( EDA_RECT* ClipBox, wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
const VECTOR2I& aCenter, int width, const COLOR4D& Color,
const COLOR4D& BgColor )
{
/* Clip arcs off screen. */
if( ClipBox )
{
int x0, y0, xm, ym, r;
x0 = ClipBox->GetX();
y0 = ClipBox->GetY();
xm = ClipBox->GetRight();
ym = ClipBox->GetBottom();
r = KiROUND( Distance( aStart.x, aStart.y, aCenter.x, aCenter.y ) );
if( aCenter.x < ( x0 - r ) )
return;
if( aCenter.y < ( y0 - r ) )
return;
if( aCenter.x > ( r + xm ) )
return;
if( aCenter.y > ( r + ym ) )
return;
}
GRSetBrush( DC, BgColor, FILLED );
GRSetColorPen( DC, Color, width );
DC->DrawArc( aStart.x, aStart.y, aEnd.x, aEnd.y, aCenter.x, aCenter.y );
}
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color )
void GRRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor )
{
GRSRect( ClipBox, DC, x1, y1, x2, y2, width, Color );
GRSRect( DC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor );
}
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
const COLOR4D& Color, const COLOR4D& BgColor )
void GRFilledRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor, const COLOR4D& aBgColor )
{
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, 0, Color, BgColor );
GRSFilledRect( DC, aStart.x, aStart.y, aEnd.x, aEnd.y, aWidth, aColor, aBgColor );
}
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color, const COLOR4D& BgColor )
{
GRSFilledRect( ClipBox, DC, x1, y1, x2, y2, width, Color, BgColor );
}
void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int aWidth,
const COLOR4D& aColor )
void GRSRect( wxDC* aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D& aColor )
{
VECTOR2I points[5];
points[0] = VECTOR2I( x1, y1 );
@ -651,12 +406,12 @@ void GRSRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int
points[2] = VECTOR2I( x2, y2 );
points[3] = VECTOR2I( x2, y1 );
points[4] = points[0];
GRSClosedPoly( aClipBox, aDC, 5, points, NOT_FILLED, aWidth, aColor, aColor );
GRSClosedPoly( aDC, 5, points, NOT_FILLED, aWidth, aColor, aColor );
}
void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y2, int aWidth,
const COLOR4D& aColor, const COLOR4D& aBgColor )
void GRSFilledRect( wxDC* aDC, int x1, int y1, int x2, int y2, int aWidth, const COLOR4D& aColor,
const COLOR4D& aBgColor )
{
VECTOR2I points[5];
points[0] = VECTOR2I( x1, y1 );
@ -668,74 +423,5 @@ void GRSFilledRect( EDA_RECT* aClipBox, wxDC* aDC, int x1, int y1, int x2, int y
GRSetBrush( aDC, aBgColor, FILLED );
GRSetColorPen( aDC, aBgColor, aWidth );
if( aClipBox && ( aWidth > 0 ) )
{
EDA_RECT clipbox( *aClipBox );
clipbox.Inflate( aWidth );
ClipAndDrawPoly( &clipbox, aDC, points, 5 ); // polygon approach is more accurate
}
else
{
ClipAndDrawPoly(aClipBox, aDC, points, 5 );
}
vector2IwxDrawPolygon( aDC, points, 5 );
}
/**
* Used to clip a polygon and draw it as Filled Polygon.
*
* Uses the Sutherland and Hodgman algo to clip the given poly against a rectangle. This
* rectangle is the drawing area this is useful under Linux (2009) because filled polygons
* are incorrectly drawn if they have too large coordinates (seems due to integer overflows
* in calculations). Could be removed in some years, if become unnecessary.
*/
#include <SutherlandHodgmanClipPoly.h>
static void vector2IwxDrawPolygon( wxDC* aDC, const VECTOR2I* Points, int n )
{
wxPoint* points = new wxPoint[n];
for( int i = 0; i < n; i++ )
{
points[i] = wxPoint( Points[i].x, Points[i].y );
}
aDC->DrawPolygon( n, points );
delete[] points;
}
void ClipAndDrawPoly( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I* Points, int n )
{
if( aClipBox == nullptr )
{
vector2IwxDrawPolygon( aDC, Points, n );
return;
}
// A clip box exists: clip and draw the polygon.
static std::vector<VECTOR2I> clippedPolygon;
static pointVector inputPolygon, outputPolygon;
inputPolygon.clear();
outputPolygon.clear();
clippedPolygon.clear();
for( int ii = 0; ii < n; ii++ )
inputPolygon.push_back( PointF( (REAL) Points[ii].x, (REAL) Points[ii].y ) );
RectF window( (REAL) aClipBox->GetX(), (REAL) aClipBox->GetY(),
(REAL) aClipBox->GetWidth(), (REAL) aClipBox->GetHeight() );
SutherlandHodgman sh( window );
sh.Clip( inputPolygon, outputPolygon );
for( cpointIterator cit = outputPolygon.begin(); cit != outputPolygon.end(); ++cit )
{
clippedPolygon.emplace_back( KiROUND( cit->X ), KiROUND( cit->Y ) );
}
if( clippedPolygon.size() )
vector2IwxDrawPolygon( aDC, &clippedPolygon[0], clippedPolygon.size() );
}

View File

@ -149,14 +149,14 @@ void GRPrintText( wxDC* aDC, const VECTOR2I& aPos, const COLOR4D& aColor, const
[&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 )
{
if( fill_mode )
GRLine( nullptr, aDC, aPt1.x, aPt1.y, aPt2.x, aPt2.y, aWidth, aColor );
GRLine( aDC, aPt1, aPt2, aWidth, aColor );
else
GRCSegm( nullptr, aDC, aPt1.x, aPt1.y, aPt2.x, aPt2.y, aWidth, 0, aColor );
GRCSegm( aDC, aPt1, aPt2, aWidth, aColor );
},
// Polygon callback
[&]( const SHAPE_LINE_CHAIN& aPoly )
{
GRClosedPoly( nullptr, aDC, aPoly.PointCount(), aPoly.CPoints().data(), true, aColor, aColor );
GRClosedPoly( aDC, aPoly.PointCount(), aPoly.CPoints().data(), true, aColor );
} );
TEXT_ATTRIBUTES attributes;

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2018 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2018-2020 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2018-2022 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
@ -145,5 +145,5 @@ void MARKER_BASE::PrintMarker( const RENDER_SETTINGS* aSettings, const VECTOR2I&
for( const VECTOR2I& corner : MarkerShapeCorners )
shape.emplace_back( corner * MarkerScale() + m_Pos + aOffset );
GRClosedPoly( nullptr, DC, CORNERS_COUNT, &shape[0], true, 0, getColor(), getColor() );
GRClosedPoly( DC, CORNERS_COUNT, &shape[0], true, getColor() );
}

View File

@ -469,8 +469,8 @@ void SCH_PRINTOUT::PrintPage( SCH_SCREEN* aScreen )
m_parent->SetDrawBgColor( bgColor );
GRSFilledRect( nullptr, dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(),
fitRect.GetBottom(), 0, bgColor, bgColor );
GRSFilledRect( dc, fitRect.GetX(), fitRect.GetY(), fitRect.GetRight(), fitRect.GetBottom(), 0,
bgColor, bgColor );
if( cfg->m_Printing.monochrome )
GRForceBlackPen( true );

View File

@ -230,7 +230,7 @@ void LIB_PIN::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset,
{
wxDC* DC = aSettings->GetPrintDC();
COLOR4D color = aSettings->GetLayerColor( IsVisible() ? LAYER_PIN : LAYER_HIDDEN );
GRCircle( nullptr, DC, pos1.x, pos1.y, TARGET_PIN_RADIUS, 0, color );
GRCircle( DC, pos1, TARGET_PIN_RADIUS, 0, color );
}
}
}
@ -259,15 +259,15 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
if( m_shape == GRAPHIC_PINSHAPE::INVERTED || m_shape == GRAPHIC_PINSHAPE::INVERTED_CLOCK )
{
const int radius = externalPinDecoSize( aSettings, *this );
GRCircle( nullptr, DC, MapX1 * radius + x1, MapY1 * radius + y1, radius, width, color );
GRCircle( DC, VECTOR2I( MapX1 * radius + x1, MapY1 * radius + y1 ), radius, width, color );
GRMoveTo( MapX1 * radius * 2 + x1, MapY1 * radius * 2 + y1 );
GRLineTo( nullptr, DC, posX, posY, width, color );
GRLineTo( DC, posX, posY, width, color );
}
else
{
GRMoveTo( x1, y1 );
GRLineTo( nullptr, DC, posX, posY, width, color );
GRLineTo( DC, posX, posY, width, color );
}
// Draw the clock shape (>)inside the symbol
@ -280,14 +280,14 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 + clock_size );
GRLineTo( nullptr, DC, x1 - MapX1 * clock_size * 2, y1, width, color );
GRLineTo( nullptr, DC, x1, y1 - clock_size, width, color );
GRLineTo( DC, x1 - MapX1 * clock_size * 2, y1, width, color );
GRLineTo( DC, x1, y1 - clock_size, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 + clock_size, y1 );
GRLineTo( nullptr, DC, x1, y1 - MapY1 * clock_size * 2, width, color );
GRLineTo( nullptr, DC, x1 - clock_size, y1, width, color );
GRLineTo( DC, x1, y1 - MapY1 * clock_size * 2, width, color );
GRLineTo( DC, x1 - clock_size, y1, width, color );
}
}
@ -300,14 +300,14 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1 + MapX1 * deco_size * 2, y1 );
GRLineTo( nullptr, DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
GRLineTo( nullptr, DC, x1, y1, width, color );
GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1 - deco_size * 2, width, color );
GRLineTo( DC, x1, y1, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1, y1 + MapY1 * deco_size * 2 );
GRLineTo( nullptr, DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
GRLineTo( nullptr, DC, x1, y1, width, color );
GRLineTo( DC, x1 - deco_size * 2, y1 + MapY1 * deco_size * 2, width, color );
GRLineTo( DC, x1, y1, width, color );
}
}
@ -317,32 +317,32 @@ void LIB_PIN::printPinSymbol( const RENDER_SETTINGS* aSettings, const VECTOR2I&
if( MapY1 == 0 ) /* MapX1 = +- 1 */
{
GRMoveTo( x1, y1 - deco_size * 2 );
GRLineTo( nullptr, DC, x1 + MapX1 * deco_size * 2, y1, width, color );
GRLineTo( DC, x1 + MapX1 * deco_size * 2, y1, width, color );
}
else /* MapX1 = 0 */
{
GRMoveTo( x1 - deco_size * 2, y1 );
GRLineTo( nullptr, DC, x1, y1 + MapY1 * deco_size * 2, width, color );
GRLineTo( DC, x1, y1 + MapY1 * deco_size * 2, width, color );
}
}
else if( m_shape == GRAPHIC_PINSHAPE::NONLOGIC ) /* NonLogic pin symbol */
{
const int deco_size = externalPinDecoSize( aSettings, *this );
GRMoveTo( x1 - (MapX1 + MapY1) * deco_size, y1 - (MapY1 - MapX1) * deco_size );
GRLineTo( nullptr, DC, x1 + (MapX1 + MapY1) * deco_size,
y1 + ( MapY1 - MapX1 ) * deco_size, width, color );
GRLineTo( DC, x1 + (MapX1 + MapY1) * deco_size, y1 + ( MapY1 - MapX1 ) * deco_size, width,
color );
GRMoveTo( x1 - (MapX1 - MapY1) * deco_size, y1 - (MapY1 + MapX1) * deco_size );
GRLineTo( nullptr, DC, x1 + (MapX1 - MapY1) * deco_size,
y1 + ( MapY1 + MapX1 ) * deco_size, width, color );
GRLineTo( DC, x1 + (MapX1 - MapY1) * deco_size, y1 + ( MapY1 + MapX1 ) * deco_size, width,
color );
}
if( m_type == ELECTRICAL_PINTYPE::PT_NC ) // Draw a N.C. symbol
{
const int deco_size = TARGET_PIN_RADIUS;
GRLine( nullptr, DC, posX - deco_size, posY - deco_size, posX + deco_size,
posY + deco_size, width, color );
GRLine( nullptr, DC, posX + deco_size, posY - deco_size, posX - deco_size,
posY + deco_size, width, color );
GRLine( DC, posX - deco_size, posY - deco_size, posX + deco_size, posY + deco_size, width,
color );
GRLine( DC, posX + deco_size, posY - deco_size, posX - deco_size, posY + deco_size, width,
color );
}
}

View File

@ -269,23 +269,23 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
switch( GetShape() )
{
case SHAPE_T::ARC:
GRArc1( nullptr, DC, pt1, pt2, c, penWidth, color );
GRArc( DC, pt1, pt2, c, penWidth, color );
break;
case SHAPE_T::CIRCLE:
GRCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), penWidth, color );
GRCircle( DC, pt1, GetRadius(), penWidth, color );
break;
case SHAPE_T::RECT:
GRRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color );
GRRect( DC, pt1, pt2, penWidth, color );
break;
case SHAPE_T::POLY:
GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
break;
case SHAPE_T::BEZIER:
GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
break;
default:
@ -307,33 +307,33 @@ void LIB_SHAPE::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
// If we stroke in GRFilledArc it will stroke the two radials too, so we have to
// fill and stroke separately
GRFilledArc1( nullptr, DC, pt1, pt2, c, 0, fillColor, fillColor );
GRFilledArc( DC, pt1, pt2, c, 0, fillColor, fillColor );
GRArc1( nullptr, DC, pt1, pt2, c, penWidth, color );
GRArc( DC, pt1, pt2, c, penWidth, color );
break;
case SHAPE_T::CIRCLE:
GRFilledCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), 0, color, fillColor );
GRFilledCircle( DC, pt1, GetRadius(), 0, color, fillColor );
break;
case SHAPE_T::RECT:
GRFilledRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color, fillColor );
GRFilledRect( DC, pt1, pt2, penWidth, color, fillColor );
break;
case SHAPE_T::POLY:
GRPoly( nullptr, DC, ptCount, buffer, true, 0, fillColor, fillColor );
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
if( penWidth > 0 )
GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, fillColor );
GRPoly( DC, ptCount, buffer, false, penWidth, color, fillColor );
break;
case SHAPE_T::BEZIER:
if( penWidth > 0 )
GRPoly( nullptr, DC, ptCount, buffer, true, penWidth, color, fillColor );
GRPoly( DC, ptCount, buffer, true, penWidth, color, fillColor );
else
GRPoly( nullptr, DC, ptCount, buffer, true, 0, fillColor, fillColor );
GRPoly( DC, ptCount, buffer, true, 0, fillColor, fillColor );
break;
default:

View File

@ -207,18 +207,16 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
COLOR4D color = aSettings->GetLayerColor( IsPrivate() ? LAYER_NOTES : LAYER_DEVICE );
if( !forceNoFill && GetFillMode() == FILL_T::FILLED_WITH_COLOR )
{
GRFilledRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color, GetFillColor() );
}
GRFilledRect( DC, pt1, pt2, penWidth, color, GetFillColor() );
if( GetStroke().GetColor() != COLOR4D::UNSPECIFIED )
color = GetStroke().GetColor();
penWidth = std::max( penWidth, aSettings->GetDefaultPenWidth() );
penWidth = std::max( penWidth, aSettings->GetMinPenWidth() );
if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
{
GRRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color );
GRRect( DC, pt1, pt2, penWidth, color );
}
else
{
@ -229,7 +227,7 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
GRLine( nullptr, DC, a.x, a.y, b.x, b.y, penWidth, color );
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
} );
}
@ -237,39 +235,24 @@ void LIB_TEXTBOX::print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffs
delete shape;
}
// Calculate the text orientation, according to the symbol orientation/mirror (needed when
// draw text in schematic)
EDA_ANGLE orient = GetTextAngle();
LIB_TEXTBOX text( *this );
if( aTransform.y1 ) // Rotate symbol 90 degrees.
penWidth = std::max( GetEffectiveTextPenWidth(), aSettings->GetMinPenWidth() );
if( aTransform.y1 )
{
if( orient == ANGLE_HORIZONTAL )
orient = ANGLE_VERTICAL;
else
orient = ANGLE_HORIZONTAL;
text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL
: ANGLE_HORIZONTAL );
}
/*
* Calculate the text justification, according to the symbol orientation/mirror.
* This is a bit complicated due to cumulative calculations:
* - numerous cases (mirrored or not, rotation)
* - the GRText function will also recalculate H and V justifications according to the text
* orientation.
* - When a symbol is mirrored, the text is not mirrored and justifications are complicated
* to calculate so the more easily way is to use no justifications (centered text) and
* use GetBoundingBox to know the text coordinate considered as centered
*/
EDA_RECT bBox = GetBoundingBox();
// NB: UpdateTextPosition() wants Symbol Editor (upside-down) coordinates
text.SetStart( VECTOR2I( pt1.x, -pt1.y ) );
text.SetEnd( VECTOR2I( pt2.x, -pt2.y ) );
text.UpdateTextPosition();
// convert coordinates from draw Y axis to symbol_editor Y axis:
bBox.RevertYAxis();
VECTOR2I txtpos = bBox.Centre();
// Calculate pos according to mirror/rotation.
txtpos = aTransform.TransformCoordinate( txtpos ) + aOffset;
GRPrintText( DC, txtpos, color, GetShownText(), orient, GetTextSize(), GR_TEXT_H_ALIGN_CENTER,
GR_TEXT_V_ALIGN_CENTER, penWidth, IsItalic(), IsBold(), GetDrawFont() );
GRPrintText( DC, text.GetTextPos(), color, text.GetShownText(), text.GetTextAngle(),
text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(), penWidth,
text.IsItalic(), text.IsBold(), text.GetDrawFont() );
}
@ -358,12 +341,11 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill,
aPlotter->SetColor( color );
aPlotter->Rect( start, end, fill, penWidth );
KIFONT::FONT* font = GetDrawFont();
LIB_TEXTBOX text( *this );
LIB_TEXTBOX text( *this );
penWidth = std::max( GetEffectiveTextPenWidth(), aPlotter->RenderSettings()->GetMinPenWidth() );
if( aTransform.y1 != 0 && aTransform.x2 != 0 )
if( aTransform.y1 )
{
text.SetTextAngle( text.GetTextAngle() == ANGLE_HORIZONTAL ? ANGLE_VERTICAL
: ANGLE_HORIZONTAL );
@ -385,7 +367,7 @@ void LIB_TEXTBOX::Plot( PLOTTER* aPlotter, const VECTOR2I& aOffset, bool aFill,
{
aPlotter->Text( positions[ii], color, strings_list.Item( ii ), text.GetTextAngle(),
text.GetTextSize(), text.GetHorizJustify(), text.GetVertJustify(),
penWidth, text.IsItalic(), text.IsBold(), false, font );
penWidth, text.IsItalic(), text.IsBold(), false, GetDrawFont() );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2004-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-2022 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
@ -276,7 +276,7 @@ void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I
if( GetLineStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
{
GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color );
GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
}
else
{
@ -285,7 +285,7 @@ void SCH_BUS_ENTRY_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I
STROKE_PARAMS::Stroke( &segment, GetLineStyle(), penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
GRLine( nullptr, DC, a.x, a.y, b.x, b.y, penWidth, color );
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
} );
}
}

View File

@ -126,8 +126,7 @@ void SCH_JUNCTION::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOff
SHAPE_CIRCLE circle = getEffectiveShape();
GRFilledCircle( nullptr, DC, circle.GetCenter() + aOffset, circle.GetRadius(),
color );
GRFilledCircle( DC, circle.GetCenter() + aOffset, circle.GetRadius(), 0, color, color );
}

View File

@ -847,7 +847,7 @@ void SCH_LABEL_BASE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aO
CreateGraphicShape( aSettings, s_poly, GetTextPos() + aOffset );
if( !s_poly.empty() )
GRPoly( nullptr, DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
GRPoly( DC, s_poly.size(), &s_poly[0], false, penWidth, color, color );
for( SCH_FIELD& field : m_fields )
field.Print( aSettings, aOffset );

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -380,7 +380,7 @@ void SCH_LINE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset )
if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE )
{
GRLine( nullptr, DC, start.x, start.y, end.x, end.y, penWidth, color );
GRLine( DC, start.x, start.y, end.x, end.y, penWidth, color );
}
else
{
@ -389,7 +389,7 @@ void SCH_LINE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& offset )
STROKE_PARAMS::Stroke( &segment, lineStyle, penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
GRLine( nullptr, DC, a.x, a.y, b.x, b.y, penWidth, color );
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
} );
}
}

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2015 Jean-Pierre Charras, jp.charras at wanoadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -110,8 +110,8 @@ void SCH_NO_CONNECT::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aO
int pY = m_pos.y + aOffset.y;
COLOR4D color = aSettings->GetLayerColor( LAYER_NOCONNECT );
GRLine( nullptr, DC, pX - half, pY - half, pX + half, pY + half, penWidth, color );
GRLine( nullptr, DC, pX + half, pY - half, pX - half, pY + half, penWidth, color );
GRLine( DC, pX - half, pY - half, pX + half, pY + half, penWidth, color );
GRLine( DC, pX + half, pY - half, pX - half, pY + half, penWidth, color );
}

View File

@ -253,23 +253,23 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
switch( GetShape() )
{
case SHAPE_T::ARC:
GRFilledArc1( nullptr, DC, pt1, pt2, c, 0, color, color );
GRFilledArc( DC, pt1, pt2, c, 0, color, color );
break;
case SHAPE_T::CIRCLE:
GRFilledCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), 0, color, color );
GRFilledCircle( DC, pt1, GetRadius(), 0, color, color );
break;
case SHAPE_T::RECT:
GRFilledRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, 0, color, color );
GRFilledRect( DC, pt1, pt2, 0, color, color );
break;
case SHAPE_T::POLY:
GRPoly( nullptr, DC, ptCount, buffer, true, 0, color, color );
GRPoly( DC, ptCount, buffer, true, 0, color, color );
break;
case SHAPE_T::BEZIER:
GRPoly( nullptr, DC, ptCount, buffer, true, 0, color, color );
GRPoly( DC, ptCount, buffer, true, 0, color, color );
break;
default:
@ -287,23 +287,23 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
switch( GetShape() )
{
case SHAPE_T::ARC:
GRArc1( nullptr, DC, pt1, pt2, c, penWidth, color );
GRArc( DC, pt1, pt2, c, penWidth, color );
break;
case SHAPE_T::CIRCLE:
GRCircle( nullptr, DC, pt1.x, pt1.y, GetRadius(), penWidth, color );
GRCircle( DC, pt1, GetRadius(), penWidth, color );
break;
case SHAPE_T::RECT:
GRRect( nullptr, DC, pt1.x, pt1.y, pt2.x, pt2.y, penWidth, color );
GRRect( DC, pt1, pt2, penWidth, color );
break;
case SHAPE_T::POLY:
GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
break;
case SHAPE_T::BEZIER:
GRPoly( nullptr, DC, ptCount, buffer, false, penWidth, color, color );
GRPoly( DC, ptCount, buffer, false, penWidth, color, color );
break;
default:
@ -319,7 +319,7 @@ void SCH_SHAPE::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
GRLine( nullptr, DC, a.x, a.y, b.x, b.y, penWidth, color );
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
} );
}

View File

@ -1079,12 +1079,9 @@ void SCH_SHEET::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset
background = COLOR4D::UNSPECIFIED;
if( background != COLOR4D::UNSPECIFIED )
{
GRFilledRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, 0,
background, background );
}
GRFilledRect( DC, pos, pos + m_size, 0, background, background );
GRRect( nullptr, DC, pos.x, pos.y, pos.x + m_size.x, pos.y + m_size.y, lineWidth, border );
GRRect( DC, pos, pos + m_size, lineWidth, border );
for( SCH_FIELD& field : m_fields )
field.Print( aSettings, aOffset );

View File

@ -183,7 +183,42 @@ KIFONT::FONT* SCH_TEXTBOX::GetDrawFont() const
void SCH_TEXTBOX::Print( const RENDER_SETTINGS* aSettings, const VECTOR2I& aOffset )
{
COLOR4D color = aSettings->GetLayerColor( m_layer );
wxDC* DC = aSettings->GetPrintDC();
int penWidth = std::max( GetPenWidth(), aSettings->GetDefaultPenWidth() );
VECTOR2I pt1 = GetStart();
VECTOR2I pt2 = GetEnd();
COLOR4D color;
if( GetFillMode() == FILL_T::FILLED_WITH_COLOR )
GRFilledRect( DC, pt1, pt2, 0, GetFillColor(), GetFillColor() );
if( GetStroke().GetColor() == COLOR4D::UNSPECIFIED )
color = aSettings->GetLayerColor( m_layer );
else
color = GetStroke().GetColor();
if( GetStroke().GetPlotStyle() <= PLOT_DASH_TYPE::FIRST_TYPE )
{
GRRect( DC, pt1, pt2, penWidth, color );
}
else
{
std::vector<SHAPE*> shapes = MakeEffectiveShapes( true );
for( SHAPE* shape : shapes )
{
STROKE_PARAMS::Stroke( shape, GetStroke().GetPlotStyle(), penWidth, aSettings,
[&]( const VECTOR2I& a, const VECTOR2I& b )
{
GRLine( DC, a.x, a.y, b.x, b.y, penWidth, color );
} );
}
for( SHAPE* shape : shapes )
delete shape;
}
color = aSettings->GetLayerColor( m_layer );
EDA_TEXT::Print( aSettings, aOffset, color );
}
@ -337,22 +372,3 @@ void SCH_TEXTBOX::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL
aList.emplace_back( _( "Text Size" ), MessageTextFromValue( aFrame->GetUserUnits(),
GetTextWidth() ) );
}
#if defined(DEBUG)
void SCH_TEXTBOX::Show( int nestLevel, std::ostream& os ) const
{
// XML output:
wxString s = GetClass();
NestedSpace( nestLevel, os ) << '<' << s.Lower().mb_str()
<< " layer=\"" << m_layer << '"'
<< '>'
<< TO_UTF8( GetText() )
<< "</" << s.Lower().mb_str() << ">\n";
}
#endif

View File

@ -107,10 +107,6 @@ public:
}
void GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, std::vector<MSG_PANEL_ITEM>& aList ) override;
#if defined(DEBUG)
void Show( int nestLevel, std::ostream& os ) const override;
#endif
};

View File

@ -7,7 +7,7 @@
*
* Copyright (C) 1992-2017 Jean-Pierre Charras <jp.charras at wanadoo.fr>
* Copyright (C) 2010 SoftPLC Corporation, Dick Hollenbeck <dick@softplc.com>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -864,9 +864,9 @@ SHAPE_POLY_SET* APERTURE_MACRO::GetApertureMacroShape( const GERBER_DRAW_ITEM* a
}
void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox,
wxDC* aDC, const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape )
void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC,
const COLOR4D& aColor, const VECTOR2I& aShapePos,
bool aFilledShape )
{
SHAPE_POLY_SET* shapeBuffer = GetApertureMacroShape( aParent, aShapePos );
@ -876,9 +876,7 @@ void APERTURE_MACRO::DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT
for( int ii = 0; ii < shapeBuffer->OutlineCount(); ii++ )
{
SHAPE_LINE_CHAIN& poly = shapeBuffer->Outline( ii );
GRClosedPoly( aClipBox, aDC, poly.PointCount(), (VECTOR2I*) &poly.CPoint( 0 ), aFilledShape,
aColor, aColor );
GRClosedPoly( aDC, poly.PointCount(), (VECTOR2I*) &poly.CPoint( 0 ), aFilledShape, aColor );
}
}

View File

@ -198,18 +198,18 @@ struct APERTURE_MACRO
* When an item is flashed, this is the shape of the item.
*
* @param aParent is the parent GERBER_DRAW_ITEM which is actually drawn.
* @param aClipBox is DC clip box (NULL is no clip).
* @param aDC is the device context.
* @param aColor is the color of shape.
* @param aShapePos is the actual shape position.
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode.
*/
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
const COLOR4D& aColor, const VECTOR2I& aShapePos,
bool aFilledShape );
void DrawApertureMacroShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape );
/**
* Calculate a value that can be used to evaluate the size of text when displaying the
* C
*
* alculate a value that can be used to evaluate the size of text when displaying the
* D-Code of an item.
*
* Due to the complexity of a shape using many primitives one cannot calculate the "size" of

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -145,16 +145,15 @@ int D_CODE::GetShapeDim( GERBER_DRAW_ITEM* aParent )
}
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
const COLOR4D& aColor, const VECTOR2I& aShapePos, bool aFilledShape )
void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape )
{
int radius;
switch( m_Shape )
{
case APT_MACRO:
GetMacro()->DrawApertureMacroShape( aParent, aClipBox, aDC, aColor, aShapePos,
aFilledShape );
GetMacro()->DrawApertureMacroShape( aParent, aDC, aColor, aShapePos, aFilledShape );
break;
case APT_CIRCLE:
@ -162,24 +161,23 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wx
if( !aFilledShape )
{
GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor );
GRCircle( aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor );
}
else if( m_DrillShape == APT_DEF_NO_HOLE )
{
GRFilledCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos), radius, aColor );
GRFilledCircle( aDC, aParent->GetABPosition(aShapePos), radius, 0, aColor, aColor );
}
else if( m_DrillShape == APT_DEF_ROUND_HOLE ) // round hole in shape
{
int width = (m_Size.x - m_Drill.x ) / 2;
GRCircle( aClipBox, aDC, aParent->GetABPosition(aShapePos),
radius - (width / 2), width, aColor );
GRCircle( aDC, aParent->GetABPosition(aShapePos), radius - (width / 2), width, aColor );
}
else // rectangular hole
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
break;
@ -195,18 +193,18 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wx
if( !aFilledShape )
{
GRRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor );
GRRect( aDC, start, end, 0, aColor );
}
else if( m_DrillShape == APT_DEF_NO_HOLE )
{
GRFilledRect( aClipBox, aDC, start.x, start.y, end.x, end.y, 0, aColor, aColor );
GRFilledRect( aDC, start, end, 0, aColor, aColor );
}
else
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
}
break;
@ -236,18 +234,18 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wx
if( !aFilledShape )
{
GRCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
GRCSegm( aDC, start, end, radius, aColor );
}
else if( m_DrillShape == APT_DEF_NO_HOLE )
{
GRFillCSegm( aClipBox, aDC, start.x, start.y, end.x, end.y, radius, aColor );
GRFilledSegment( aDC, start, end, radius, aColor );
}
else
{
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
}
}
@ -257,14 +255,14 @@ void D_CODE::DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wx
if( m_Polygon.OutlineCount() == 0 )
ConvertShapeToPolygon();
DrawFlashedPolygon( aParent, aClipBox, aDC, aColor, aFilledShape, aShapePos );
DrawFlashedPolygon( aParent, aDC, aColor, aFilledShape, aShapePos );
break;
}
}
void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
const COLOR4D& aColor, bool aFilled, const VECTOR2I& aPosition )
void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
bool aFilled, const VECTOR2I& aPosition )
{
if( m_Polygon.OutlineCount() == 0 )
return;
@ -280,7 +278,7 @@ void D_CODE::DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox,
points[ii] = aParent->GetABPosition( points[ii] );
}
GRClosedPoly( aClipBox, aDC, pointCount, &points[0], aFilled, aColor, aColor );
GRClosedPoly( aDC, pointCount, &points[0], aFilled, aColor );
}

View File

@ -137,14 +137,13 @@ public:
* When an item is flashed, the DCode shape is the shape of the item.
*
* @param aParent is the #GERBER_DRAW_ITEM being drawn.
* @param aClipBox is the device context clip box (NULL is no clip).
* @param aDC is the device context.
* @param aColor is the normal color to use.
* @param aShapePos is the actual shape position
* @param aFilledShape set to true to draw in filled mode, false to draw in sketch mode
*/
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
const COLOR4D& aColor, const VECTOR2I& aShapePos, bool aFilledShape );
void DrawFlashedShape( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
const VECTOR2I& aShapePos, bool aFilledShape );
/**
* A helper function used to draw the polygon stored in m_PolyCorners.
@ -154,14 +153,13 @@ public:
* holes, some rotated shapes).
*
* @param aParent is the #GERBER_DRAW_ITEM being drawn.
* @param aClipBox is the device context clip box (NULL is no clip).
* @param aDC is the device context.
* @param aColor is the normal color to use.
* @param aFilled set to true to draw in filled mode, false to draw in sketch mode.
* @param aPosition is the actual shape position.
*/
void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, EDA_RECT* aClipBox, wxDC* aDC,
const COLOR4D& aColor, bool aFilled, const VECTOR2I& aPosition );
void DrawFlashedPolygon( GERBER_DRAW_ITEM* aParent, wxDC* aDC, const COLOR4D& aColor,
bool aFilled, const VECTOR2I& aPosition );
/**
* Convert a shape to an equivalent polygon.

View File

@ -481,12 +481,12 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP
if( !isFilled )
{
// draw the border of the pen's path using two circles, each as narrow as possible
GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius - halfPenWidth, 0, color );
GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius + halfPenWidth, 0, color );
GRCircle( aDC, GetABPosition( m_Start ), radius - halfPenWidth, 0, color );
GRCircle( aDC, GetABPosition( m_Start ), radius + halfPenWidth, 0, color );
}
else // Filled mode
{
GRCircle( nullptr, aDC, GetABPosition( m_Start ), radius, m_Size.x, color );
GRCircle( aDC, GetABPosition( m_Start ), radius, m_Size.x, color );
}
break;
@ -496,13 +496,13 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP
// a round pen only is expected.
if( !isFilled )
{
GRArc1( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
GetABPosition( m_ArcCentre ), 0, color );
GRArc( aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
GetABPosition( m_ArcCentre ), 0, color );
}
else
{
GRArc1( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
GetABPosition( m_ArcCentre ), m_Size.x, color );
GRArc( aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
GetABPosition( m_ArcCentre ), m_Size.x, color );
}
break;
@ -513,7 +513,7 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP
case GBR_SPOT_POLY:
case GBR_SPOT_MACRO:
isFilled = aOptions->m_DisplayFlashedItemsFill;
d_codeDescr->DrawFlashedShape( this, nullptr, aDC, color, m_Start, isFilled );
d_codeDescr->DrawFlashedShape( this, aDC, color, m_Start, isFilled );
break;
case GBR_SEGMENT:
@ -529,18 +529,14 @@ void GERBER_DRAW_ITEM::Print( wxDC* aDC, const VECTOR2I& aOffset, GBR_DISPLAY_OP
PrintGerberPoly( aDC, color, aOffset, isFilled );
}
else if( !isFilled )
{
GRCSegm( aDC, GetABPosition( m_Start ), GetABPosition( m_End ), m_Size.x, color );
}
else
{
if( !isFilled )
{
GRCSegm( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
m_Size.x, color );
}
else
{
GRFilledSegment( nullptr, aDC, GetABPosition( m_Start ), GetABPosition( m_End ),
m_Size.x, color );
}
GRFilledSegment( aDC, GetABPosition( m_Start ), GetABPosition( m_End ), m_Size.x,
color );
}
break;
@ -643,7 +639,7 @@ void GERBER_DRAW_ITEM::PrintGerberPoly( wxDC* aDC, const COLOR4D& aColor, const
points[ii] = GetABPosition( points[ii] );
}
GRClosedPoly( nullptr, aDC, pointCount, &points[0], aFilledShape, aColor, aColor );
GRClosedPoly( aDC, pointCount, &points[0], aFilledShape, aColor );
}

View File

@ -84,56 +84,32 @@ void GRForceBlackPen( bool flagforce );
*/
bool GetGRForceBlackPenState( void );
void GRLine( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRLine( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRLine( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor, wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRLine( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
wxPenStyle aStyle = wxPENSTYLE_SOLID );
void GRMoveTo( int x, int y );
void GRLineTo( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int width, const COLOR4D& Color );
void GRLineTo( wxDC* DC, int x, int y, int width, const COLOR4D& Color );
void GRPoly( EDA_RECT* ClipBox, wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width,
const COLOR4D& Color, const COLOR4D& BgColor );
void GRPoly( wxDC* DC, int n, const VECTOR2I* Points, bool Fill, int width, const COLOR4D& Color,
const COLOR4D& BgColor );
/**
* Draw a closed polygon onto the drawing context \a aDC and optionally fills and/or draws
* a border around it.
*
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @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.
* @param aPenColor the color of the border.
* @param aFillColor the fill color of the polygon's interior.
* @param aColor the color of the border and the fill.
*/
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const VECTOR2I* aPoints,
bool doFill, const COLOR4D& aPenColor, const COLOR4D& aFillColor );
// @todo could make these 2 closed polygons calls a single function and default
// the aPenWidth argument
/**
* Draw a closed polygon onto the drawing context \a aDC and optionally fills and/or draws
* a border around it.
*
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @param aPointCount the number of points in the array \a aPointArray.
* @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.
* @param aPenColor the color of the border.
* @param aFillColor the fill color of the polygon's interior.
*/
void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const VECTOR2I* aPoints,
bool doFill, int aPenWidth, const COLOR4D& aPenColor,
const COLOR4D& aFillColor );
void GRClosedPoly( wxDC* aDC, int aPointCount, const VECTOR2I* aPoints, bool doFill,
const COLOR4D& aColor );
/**
* Draw a circle onto the drawing context \a aDC centered at the user coordinates (x,y).
*
* @param ClipBox defines a rectangular boundary outside of which no drawing will occur.
* @param aDC the device context into which drawing should occur.
* @param x The x coordinate in user space of the center of the circle.
* @param y The y coordinate in user space of the center of the circle.
@ -141,42 +117,27 @@ void GRClosedPoly( EDA_RECT* ClipBox, wxDC* aDC, int aPointCount, const VECTOR2I
* @param aColor is the color to draw.
* @see COLOR4D
*/
void GRCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width, const COLOR4D& Color );
void GRFilledCircle( EDA_RECT* ClipBox, wxDC* DC, int x, int y, int r, int width,
const COLOR4D& Color, const COLOR4D& BgColor );
void GRFilledCircle( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aPos, int aRadius,
const COLOR4D& aColor );
void GRCircle( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
const COLOR4D& aColor );
void GRFilledCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth,
const COLOR4D& aStrokeColor, const COLOR4D& aFillColor );
void GRCircle( wxDC* aDC, const VECTOR2I& aPos, int aRadius, int aWidth, const COLOR4D& aColor );
void GRArc1( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int xc, int yc, int width, const COLOR4D& Color );
void GRArc1( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
const VECTOR2I& aCenter, int aWidth, const COLOR4D& aColor );
void GRFilledArc1( EDA_RECT* ClipBox, wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
const VECTOR2I& aCenter, int width, const COLOR4D& Color,
const COLOR4D& BgColor );
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color );
void GRArc( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
int aWidth, const COLOR4D& aColor );
void GRFilledArc( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, const VECTOR2I& aCenter,
int width, const COLOR4D& Color, const COLOR4D& BgColor );
void GRFillCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2, int width,
const COLOR4D& Color );
void GRFilledSegment( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor );
void GRFilledSegment( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor );
void GRCSegm( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1, int x2, int y2,
int width, int aPenSize, const COLOR4D& Color );
void GRCSegm( EDA_RECT* aClipBox, wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd,
int aWidth, const COLOR4D& aColor );
void GRCSegm( wxDC* aDC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor );
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, const COLOR4D& Color, const COLOR4D& BgColor );
void GRFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
void GRRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, const COLOR4D& Color );
void GRFilledRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor, const COLOR4D& aBgColor );
void GRRect( wxDC* DC, const VECTOR2I& aStart, const VECTOR2I& aEnd, int aWidth,
const COLOR4D& aColor );
void GRSFilledRect( EDA_RECT* ClipBox, wxDC* DC, int x1, int y1,
int x2, int y2, int width, const COLOR4D& Color, const COLOR4D& BgColor );
void GRSFilledRect( wxDC* DC, int x1, int y1, int x2, int y2, int width, const COLOR4D& Color,
const COLOR4D& BgColor );
#endif /* define GR_BASIC */

View File

@ -7,7 +7,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 1992-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 1992-2022 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
@ -490,8 +490,8 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event )
// Draw X and Y axis. This is particularly useful to show the
// reference position of basic shape
// Axis are drawn before the polygon to avoid masking segments on axis
GRLine( nullptr, &dc, -dc_size.x, 0, dc_size.x, 0, 0, LIGHTBLUE ); // X axis
GRLine( nullptr, &dc, 0, -dc_size.y, 0, dc_size.y, 0, LIGHTBLUE ); // Y axis
GRLine( &dc, -dc_size.x, 0, dc_size.x, 0, 0, LIGHTBLUE ); // X axis
GRLine( &dc, 0, -dc_size.y, 0, dc_size.y, 0, LIGHTBLUE ); // Y axis
// Draw polygon.
// The selected edge(s) are shown in selectcolor, the others in normalcolor.
@ -512,7 +512,7 @@ void DIALOG_PAD_PRIMITIVE_POLY_PROPS::onPaintPolyPanel( wxPaintEvent& event )
if( jj >= m_currPoints.size() )
jj = 0;
GRLine( nullptr, &dc, m_currPoints[ii] * scale, m_currPoints[jj] * scale,
GRLine( &dc, m_currPoints[ii] * scale, m_currPoints[jj] * scale,
m_thickness.GetValue() * scale, color );
}