From 6cfbf895fc3c48d273b36dbf4df744dbda22e6e0 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 16 Aug 2022 17:28:16 +0100 Subject: [PATCH] Make sure parent pos is factored in for polygons. Fixes https://gitlab.com/kicad/code/kicad/issues/11945 --- pcbnew/pcb_painter.cpp | 32 ++++++++++++++++---------------- pcbnew/pcb_shape.cpp | 4 +++- 2 files changed, 19 insertions(+), 17 deletions(-) diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 6b3ccfd917..69a1838dbd 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -2001,31 +2001,31 @@ void PCB_PAINTER::draw( const FP_TEXTBOX* aTextBox, int aLayer ) m_gal->SetIsFill( true ); m_gal->SetIsStroke( false ); - if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE ) + if( thickness > 0 ) { - if( thickness > 0 ) + if( lineStyle <= PLOT_DASH_TYPE::FIRST_TYPE ) { std::vector pts = aTextBox->GetCorners(); for( size_t ii = 0; ii < pts.size(); ++ii ) m_gal->DrawSegment( pts[ ii ], pts[ (ii + 1) % pts.size() ], thickness ); } - } - else - { - std::vector shapes = aTextBox->MakeEffectiveShapes( true ); - - for( SHAPE* shape : shapes ) + else { - STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings, - [&]( const VECTOR2I& a, const VECTOR2I& b ) - { - m_gal->DrawSegment( a, b, thickness ); - } ); - } + std::vector shapes = aTextBox->MakeEffectiveShapes( true ); - for( SHAPE* shape : shapes ) - delete shape; + for( SHAPE* shape : shapes ) + { + STROKE_PARAMS::Stroke( shape, lineStyle, thickness, &m_pcbSettings, + [&]( const VECTOR2I& a, const VECTOR2I& b ) + { + m_gal->DrawSegment( a, b, thickness ); + } ); + } + + for( SHAPE* shape : shapes ) + delete shape; + } } wxString resolvedText( aTextBox->GetShownText() ); diff --git a/pcbnew/pcb_shape.cpp b/pcbnew/pcb_shape.cpp index b3d2878857..c280e35129 100644 --- a/pcbnew/pcb_shape.cpp +++ b/pcbnew/pcb_shape.cpp @@ -105,8 +105,10 @@ std::vector PCB_SHAPE::GetCorners() const } else if( GetShape() == SHAPE_T::POLY ) { + VECTOR2I offset = getParentPosition(); + for( const VECTOR2I& pt : GetPolyShape().Outline( 0 ).CPoints() ) - pts.emplace_back( pt ); + pts.emplace_back( pt + offset ); } else {