From 032708860b718e3b595ebec89a90216aef1ddbd4 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Mon, 25 Jul 2022 16:09:27 +0100 Subject: [PATCH] Include both text shapes and border shapes in textbox. Fixes https://gitlab.com/kicad/code/kicad/issues/11806 --- libs/kimath/include/geometry/shape_compound.h | 19 +++++++++++++++++++ pcbnew/fp_textbox.cpp | 7 ++++++- pcbnew/pcb_textbox.cpp | 8 +++++--- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/libs/kimath/include/geometry/shape_compound.h b/libs/kimath/include/geometry/shape_compound.h index 7f80b0e7a2..2730583a40 100644 --- a/libs/kimath/include/geometry/shape_compound.h +++ b/libs/kimath/include/geometry/shape_compound.h @@ -98,6 +98,25 @@ public: m_dirty = true; } + void AddShape( std::shared_ptr aShape ) + { + // Don't make clients deal with nested SHAPE_COMPOUNDs + if( aShape->HasIndexableSubshapes() ) + { + std::vector subshapes; + aShape->GetIndexableSubshapes( subshapes ); + + for( const SHAPE* subshape : subshapes ) + m_shapes.push_back( subshape->Clone() ); + } + else + { + m_shapes.push_back( aShape->Clone() ); + } + + m_dirty = true; + } + bool Empty() const { return m_shapes.empty(); diff --git a/pcbnew/fp_textbox.cpp b/pcbnew/fp_textbox.cpp index 281dde99d3..fdb1c3f335 100644 --- a/pcbnew/fp_textbox.cpp +++ b/pcbnew/fp_textbox.cpp @@ -435,7 +435,12 @@ wxString FP_TEXTBOX::GetShownText( int aDepth ) const std::shared_ptr FP_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const { - return GetEffectiveTextShape(); + std::shared_ptr shape = GetEffectiveTextShape(); + + if( PCB_SHAPE::GetStroke().GetWidth() >= 0 ) + shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) ); + + return shape; } diff --git a/pcbnew/pcb_textbox.cpp b/pcbnew/pcb_textbox.cpp index 60ffeba1df..368fdc6d1a 100644 --- a/pcbnew/pcb_textbox.cpp +++ b/pcbnew/pcb_textbox.cpp @@ -428,10 +428,12 @@ void PCB_TEXTBOX::SwapData( BOARD_ITEM* aImage ) std::shared_ptr PCB_TEXTBOX::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const { + std::shared_ptr shape = GetEffectiveTextShape(); + if( PCB_SHAPE::GetStroke().GetWidth() >= 0 ) - return PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ); - else - return GetEffectiveTextShape(); + shape->AddShape( PCB_SHAPE::GetEffectiveShape( aLayer, aFlash ) ); + + return shape; }