Prepare rounded rect and custom shaped pads: add plot functions. It fixes also a pcbnew crash in HPGL mode when plotting trapezoidal pads.

This commit is contained in:
jean-pierre charras
2016-02-10 17:02:40 +01:00
parent a319c34188
commit 5658ed9c8e
11 changed files with 480 additions and 241 deletions
+73 -2
View File
@@ -1,8 +1,8 @@
/*
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2014 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2014 KiCad Developers, see CHANGELOG.TXT for contributors.
* Copyright (C) 2016 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2016 KiCad Developers, see CHANGELOG.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
@@ -35,6 +35,7 @@
#include <plot_common.h>
#include <macros.h>
#include <kicad_string.h>
#include <convert_basic_shapes_to_polygon.h>
/* Forward declaration of the font width metrics
(yes extern! this is the way to forward declare variables */
@@ -188,6 +189,76 @@ void PSLIKE_PLOTTER::FlashPadRect( const wxPoint& aPadPos, const wxSize& aSize,
GetCurrentLineWidth() );
}
void PSLIKE_PLOTTER::FlashPadRoundRect( const wxPoint& aPadPos, const wxSize& aSize,
int aCornerRadius, double aOrient,
EDA_DRAW_MODE_T aTraceMode )
{
wxSize size( aSize );
if( aTraceMode == FILLED )
SetCurrentLineWidth( 0 );
else
{
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
size.x -= GetCurrentLineWidth();
size.y -= GetCurrentLineWidth();
aCornerRadius -= GetCurrentLineWidth()/2;
}
SHAPE_POLY_SET outline;
const int segmentToCircleCount = 64;
TransformRoundRectToPolygon( outline, aPadPos, size, aOrient,
aCornerRadius, segmentToCircleCount );
std::vector< wxPoint > cornerList;
cornerList.reserve( segmentToCircleCount + 5 );
// TransformRoundRectToPolygon creates only one convex polygon
SHAPE_LINE_CHAIN& poly = outline.Outline( 0 );
for( int ii = 0; ii < poly.PointCount(); ++ii )
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
// Close polygon
cornerList.push_back( cornerList[0] );
PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
GetCurrentLineWidth() );
}
void PSLIKE_PLOTTER::FlashPadCustom( const wxPoint& aPadPos, const wxSize& aSize,
SHAPE_POLY_SET* aPolygons,
EDA_DRAW_MODE_T aTraceMode )
{
wxSize size( aSize );
if( aTraceMode == FILLED )
SetCurrentLineWidth( 0 );
else
{
SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH );
size.x -= GetCurrentLineWidth();
size.y -= GetCurrentLineWidth();
}
std::vector< wxPoint > cornerList;
for( int cnt = 0; cnt < aPolygons->OutlineCount(); ++cnt )
{
SHAPE_LINE_CHAIN& poly = aPolygons->Outline( cnt );
cornerList.clear();
for( int ii = 0; ii < poly.PointCount(); ++ii )
cornerList.push_back( wxPoint( poly.Point( ii ).x, poly.Point( ii ).y ) );
// Close polygon
cornerList.push_back( cornerList[0] );
PlotPoly( cornerList, ( aTraceMode == FILLED ) ? FILLED_SHAPE : NO_FILL,
GetCurrentLineWidth() );
}
}
void PSLIKE_PLOTTER::FlashPadTrapez( const wxPoint& aPadPos, const wxPoint *aCorners,
double aPadOrient, EDA_DRAW_MODE_T aTraceMode )