From b0182abbb5a5b03ce7b0c826a9cdeab9b65c55dc Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Fri, 7 Jun 2019 10:50:40 +0200 Subject: [PATCH] Custom pads: fix a bug when plotting the custom shape. This bug was seen only with some shapes, not all, and only for layers having a negative margin. Fixes: lp:1831941 https://bugs.launchpad.net/kicad/+bug/ --- pcbnew/pad_custom_shape_functions.cpp | 2 -- pcbnew/plot_board_layers.cpp | 13 ++++++------- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/pcbnew/pad_custom_shape_functions.cpp b/pcbnew/pad_custom_shape_functions.cpp index 9d7a0dc681..4ff9ee7948 100644 --- a/pcbnew/pad_custom_shape_functions.cpp +++ b/pcbnew/pad_custom_shape_functions.cpp @@ -254,7 +254,6 @@ bool D_PAD::buildCustomPadPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError ) case S_POLYGON: // polygon if( bshape.m_Poly.size() < 2 ) break; // Malformed polygon. - { // Insert the polygon: const std::vector< wxPoint>& poly = bshape.m_Poly; @@ -276,7 +275,6 @@ bool D_PAD::buildCustomPadPolygon( SHAPE_POLY_SET* aMergedPolygon, int aError ) aux_polyset.Append( polyset ); } - else for( unsigned ii = 0; ii < poly.size(); ii++ ) aux_polyset.Append( poly[ii].x, poly[ii].y ); diff --git a/pcbnew/plot_board_layers.cpp b/pcbnew/plot_board_layers.cpp index 18e139726e..42394fca4b 100644 --- a/pcbnew/plot_board_layers.cpp +++ b/pcbnew/plot_board_layers.cpp @@ -441,13 +441,6 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, // inflate/deflate a custom shape is a bit complex. // so build a similar pad shape, and inflate/deflate the polygonal shape { - // we expect margin.x = margin.y for custom pads - if( margin.x < 0 ) - // be sure the anchor pad is not bigger than the deflated shape - // because this anchor will be added to the pad shape when plotting - // the pad - pad->SetSize( padPlotsSize ); - D_PAD dummy( *pad ); SHAPE_POLY_SET shape; pad->MergePrimitivesAsPolygon( &shape ); @@ -462,6 +455,12 @@ void PlotStandardLayer( BOARD *aBoard, PLOTTER* aPlotter, dummy.AddPrimitive( shape, 0 ); dummy.MergePrimitivesAsPolygon(); + // Be sure the anchor pad is not bigger than the deflated shape + // because this anchor will be added to the pad shape when plotting + // the pad. So now the polygonal shape is built, we can clamp the anchor size + if( margin.x < 0 ) // we expect margin.x = margin.y for custom pads + dummy.SetSize( padPlotsSize ); + itemplotter.PlotPad( &dummy, color, plotMode ); } break;