From 91dfa79a67174ff04f86711ec23f0d7cf3b6c0d4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Wed, 27 Apr 2022 20:02:06 +0200 Subject: [PATCH] Plot pad outlines on Fab files: fix many issues. Depending on plotter type and pad type, the plotted shapes were not always the outlines, but a outline inside the pad shape (due to legacy reasons). In many cases the plotted shape was in fact incorrect. (only noticeable for very small pads) Now the actual pad outlines are plotted without modification. Fixes #11484 https://gitlab.com/kicad/code/kicad/issues/11484 --- common/plotters/GERBER_plotter.cpp | 10 +++----- common/plotters/HPGL_plotter.cpp | 8 +++---- common/plotters/PS_plotter.cpp | 38 +----------------------------- common/plotters/plotter.cpp | 2 +- 4 files changed, 9 insertions(+), 49 deletions(-) diff --git a/common/plotters/GERBER_plotter.cpp b/common/plotters/GERBER_plotter.cpp index f50e34fa1b..d1c7d1c798 100644 --- a/common/plotters/GERBER_plotter.cpp +++ b/common/plotters/GERBER_plotter.cpp @@ -1290,7 +1290,7 @@ void GERBER_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre, OUTLINE_ SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - Circle( pos, diametre - m_currentPenWidth, FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH ); + Circle( pos, diametre, FILL_T::NO_FILL, DO_NOT_SET_LINE_WIDTH ); } else { @@ -1411,10 +1411,8 @@ void GERBER_PLOTTER::FlashPadRect( const VECTOR2I& pos, const VECTOR2I& aSize, formatNetAttribute( &gbr_metadata->m_NetlistMetadata ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - Rect( VECTOR2I( pos.x - ( size.x - GetCurrentLineWidth() ) / 2, - pos.y - (size.y - GetCurrentLineWidth()) / 2 ), - VECTOR2I( pos.x + ( size.x - GetCurrentLineWidth() ) / 2, - pos.y + (size.y - GetCurrentLineWidth()) / 2 ), + Rect( VECTOR2I( pos.x - ( size.x / 2 ), pos.y - (size.y / 2 ) ), + VECTOR2I( pos.x + ( size.x / 2 ), pos.y + (size.y / 2 ) ), FILL_T::NO_FILL, GetCurrentLineWidth() ); } else @@ -1483,7 +1481,6 @@ void GERBER_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& 0, 0, GetPlotterArcHighDef(), ERROR_INSIDE ); SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata ); - outline.Inflate( -GetCurrentLineWidth()/2, 16 ); std::vector cornerList; // TransformRoundRectToPolygon creates only one convex polygon @@ -1695,7 +1692,6 @@ void GERBER_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS if( aTraceMode != FILLED ) { SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH, &gbr_metadata ); - polyshape.Inflate( -GetCurrentLineWidth()/2, 16 ); } std::vector cornerList; diff --git a/common/plotters/HPGL_plotter.cpp b/common/plotters/HPGL_plotter.cpp index d75480106f..3a414ad648 100644 --- a/common/plotters/HPGL_plotter.cpp +++ b/common/plotters/HPGL_plotter.cpp @@ -491,7 +491,7 @@ void HPGL_PLOTTER::PlotPoly( const std::vector& aCornerList, FILL_T aF m_current_item->content << hpgl_end_polygon_cmd; // Close, fill polygon and draw outlines m_current_item->pen_returns = true; } - else if( aWidth > 0 ) + else if( aWidth != 0 ) { // Plot only the polygon outline. for( unsigned ii = 1; ii < aCornerList.size(); ii++ ) @@ -670,10 +670,10 @@ void HPGL_PLOTTER::FlashPadCircle( const VECTOR2I& pos, int diametre, // if filled mode, the pen diameter is removed from diameter // to keep the pad size radius -= KiROUND( penDiameter ) / 2; - } - if( radius < 0 ) - radius = 0; + if( radius < 0 ) + radius = 0; + } double rsize = userToDeviceSize( radius ); diff --git a/common/plotters/PS_plotter.cpp b/common/plotters/PS_plotter.cpp index d210123a3c..5981033780 100644 --- a/common/plotters/PS_plotter.cpp +++ b/common/plotters/PS_plotter.cpp @@ -127,13 +127,7 @@ void PSLIKE_PLOTTER::FlashPadCircle( const VECTOR2I& aPadPos, int aDiameter, else // Plot a ring: { SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - int linewidth = GetCurrentLineWidth(); - - // avoid aDiameter <= 1 ) - if( linewidth > aDiameter-2 ) - linewidth = aDiameter-2; - - Circle( aPadPos, aDiameter - linewidth, FILL_T::NO_FILL, linewidth ); + Circle( aPadPos, aDiameter, FILL_T::NO_FILL, GetCurrentLineWidth() ); } SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); @@ -153,15 +147,6 @@ void PSLIKE_PLOTTER::FlashPadRect( const VECTOR2I& aPadPos, const VECTOR2I& aSiz else SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - size.x -= GetCurrentLineWidth(); - size.y -= GetCurrentLineWidth(); - - if( size.x < 1 ) - size.x = 1; - - if( size.y < 1 ) - size.y = 1; - int dx = size.x / 2; int dy = size.y / 2; @@ -202,8 +187,6 @@ void PSLIKE_PLOTTER::FlashPadRoundRect( const VECTOR2I& aPadPos, const VECTOR2I& else { SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - size.x -= GetCurrentLineWidth(); - size.y -= GetCurrentLineWidth(); aCornerRadius -= GetCurrentLineWidth() / 2; } @@ -242,8 +225,6 @@ void PSLIKE_PLOTTER::FlashPadCustom( const VECTOR2I& aPadPos, const VECTOR2I& aS else { SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - size.x -= GetCurrentLineWidth(); - size.y -= GetCurrentLineWidth(); } @@ -283,23 +264,6 @@ void PSLIKE_PLOTTER::FlashPadTrapez( const VECTOR2I& aPadPos, const VECTOR2I* aC else { SetCurrentLineWidth( USE_DEFAULT_LINE_WIDTH ); - int w = GetCurrentLineWidth(); - - // offset polygon by w - // coord[0] is assumed the lower left - // coord[1] is assumed the upper left - // coord[2] is assumed the upper right - // coord[3] is assumed the lower right - - /* Trace the outline. */ - cornerList[0].x += w; - cornerList[0].y -= w; - cornerList[1].x += w; - cornerList[1].y += w; - cornerList[2].x -= w; - cornerList[2].y += w; - cornerList[3].x -= w; - cornerList[3].y -= w; } for( int ii = 0; ii < 4; ii++ ) diff --git a/common/plotters/plotter.cpp b/common/plotters/plotter.cpp index 8b291b84cf..5c295731f7 100644 --- a/common/plotters/plotter.cpp +++ b/common/plotters/plotter.cpp @@ -549,7 +549,7 @@ void PLOTTER::sketchOval( const VECTOR2I& aPos, const VECTOR2I& aSize, const EDA } int deltaxy = size.y - size.x; /* distance between centers of the oval */ - int radius = ( size.x - m_currentPenWidth ) / 2; + int radius = size.x / 2; pt.x = -radius; pt.y = -deltaxy / 2;