Fix a PnS router issue doesn't respect knockout texts.

Fixes #13251
https://gitlab.com/kicad/code/kicad/issues/13251
This commit is contained in:
jean-pierre charras 2022-12-23 18:17:44 +01:00
parent e5363d164c
commit 59f0e428fa
1 changed files with 25 additions and 3 deletions

View File

@ -1206,7 +1206,30 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
solid->SetLayer( aLayer );
solid->SetNet( -1 );
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
PCB_TEXT* pcb_text = dynamic_cast<PCB_TEXT*>( aText );
if( pcb_text && pcb_text->IsKnockout() )
{
TEXT_ATTRIBUTES attrs = pcb_text->GetAttributes();
SHAPE_POLY_SET buffer;
int margin = attrs.m_StrokeWidth * 1.5
+ GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
pcb_text->TransformBoundingBoxToPolygon( &buffer, margin );
// buffer should contain a single rectangular polygon
SHAPE_SIMPLE* rectShape = new SHAPE_SIMPLE;
for( int ii = 0; ii < buffer.Outline(0).PointCount(); ii++ )
{
VECTOR2I point = buffer.Outline(0).CPoint(ii);
rectShape->Append( point );
}
solid->SetShape( rectShape );
}
else
solid->SetShape( aText->GetEffectiveTextShape()->Clone() );
solid->SetRoutable( false );
aWorld->Add( std::move( solid ) );
@ -1214,7 +1237,6 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
return true;
/* A coarser (but faster) method:
*
SHAPE_POLY_SET outline;
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();