From 294b8e9051ccfeac71a8e2cf86a80a2503766031 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Wed, 18 May 2022 12:47:34 +0100 Subject: [PATCH] Treat a textbox as filled when knocking out (whether it is or not). Fixes https://gitlab.com/kicad/code/kicad/issues/11628 --- pcbnew/fp_textbox.cpp | 25 ++++++++++++++++++------- pcbnew/pcb_textbox.cpp | 25 ++++++++++++++++++------- 2 files changed, 36 insertions(+), 14 deletions(-) diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index 1d3d62d224..ca303a4a5f 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -401,14 +401,25 @@ void FP_TEXTBOX::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBu int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const { - if( PCB_SHAPE::GetStroke().GetWidth() >= 0 ) + // Don't use FP_SHAPE::TransformShapeWithClearanceToPolygon. We want to treat the + // textbox as filled even if there's no background colour. + + std::vector pts = GetRectCorners(); + + aCornerBuffer.NewOutline(); + + for( const VECTOR2I& pt : pts ) + aCornerBuffer.Append( pt ); + + int width = GetWidth() + ( 2 * aClearance ); + + if( width > 0 ) { - FP_SHAPE::TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, - aError, aErrorLoc ); - } - else - { - EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &aCornerBuffer, aClearance ); + // Add in segments + TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc ); } } diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index e9bdff9818..615228afbf 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -394,14 +394,25 @@ void PCB_TEXTBOX::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerB int aError, ERROR_LOC aErrorLoc, bool aIgnoreLineWidth ) const { - if( PCB_SHAPE::GetStroke().GetWidth() >= 0 ) + // Don't use PCB_SHAPE::TransformShapeWithClearanceToPolygon. We want to treat the + // textbox as filled even if there's no background colour. + + std::vector pts = GetRectCorners(); + + aCornerBuffer.NewOutline(); + + for( const VECTOR2I& pt : pts ) + aCornerBuffer.Append( pt ); + + int width = GetWidth() + ( 2 * aClearance ); + + if( width > 0 ) { - PCB_SHAPE::TransformShapeWithClearanceToPolygon( aCornerBuffer, aLayer, aClearance, - aError, aErrorLoc ); - } - else - { - EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &aCornerBuffer, aClearance ); + // Add in segments + TransformOvalToPolygon( aCornerBuffer, pts[0], pts[1], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[1], pts[2], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[2], pts[3], width, aError, aErrorLoc ); + TransformOvalToPolygon( aCornerBuffer, pts[3], pts[0], width, aError, aErrorLoc ); } }