Cleanup API and use text bounding box for routing.
If someone wants to route around the text more tightly they can now convert the text to polygons. Fixes https://gitlab.com/kicad/code/kicad/issues/14252
This commit is contained in:
parent
80f8cd2254
commit
f27bc16d62
|
@ -1246,66 +1246,35 @@ bool PNS_KICAD_IFACE_BASE::syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB_LAYER_ID aLayer )
|
bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, PCB_TEXT* aText, PCB_LAYER_ID aLayer )
|
||||||
{
|
{
|
||||||
if( !IsCopperLayer( aLayer ) )
|
if( !IsCopperLayer( aLayer ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
||||||
|
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE;
|
||||||
|
|
||||||
solid->SetLayer( aLayer );
|
solid->SetLayer( aLayer );
|
||||||
solid->SetNet( -1 );
|
solid->SetNet( -1 );
|
||||||
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
|
solid->SetParent( aText );
|
||||||
|
solid->SetShape( shape ); // takes ownership
|
||||||
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 ); // takes ownership
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
solid->SetShape( aText->GetEffectiveTextShape()->Clone() );
|
|
||||||
}
|
|
||||||
|
|
||||||
solid->SetRoutable( false );
|
solid->SetRoutable( false );
|
||||||
|
|
||||||
|
TEXT_ATTRIBUTES attrs = aText->GetAttributes();
|
||||||
|
int margin = KiROUND( attrs.m_StrokeWidth / 2 );
|
||||||
|
SHAPE_POLY_SET cornerBuffer;
|
||||||
|
|
||||||
|
if( aText->IsKnockout() )
|
||||||
|
margin += attrs.m_StrokeWidth + GetKnockoutTextMargin( attrs.m_Size, attrs.m_StrokeWidth );
|
||||||
|
|
||||||
|
aText->TransformBoundingBoxToPolygon( &cornerBuffer, margin );
|
||||||
|
|
||||||
|
for( const VECTOR2I& pt : cornerBuffer.Outline( 0 ).CPoints() )
|
||||||
|
shape->Append( pt );
|
||||||
|
|
||||||
aWorld->Add( std::move( solid ) );
|
aWorld->Add( std::move( solid ) );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
/* A coarser (but faster) method:
|
|
||||||
SHAPE_POLY_SET outline;
|
|
||||||
SHAPE_SIMPLE* shape = new SHAPE_SIMPLE();
|
|
||||||
|
|
||||||
aText->TransformBoundingBoxToPolygon( &outline, 0 );
|
|
||||||
|
|
||||||
for( auto iter = outline.CIterate( 0 ); iter; iter++ )
|
|
||||||
shape->Append( *iter );
|
|
||||||
|
|
||||||
solid->SetShape( shape );
|
|
||||||
|
|
||||||
solid->SetLayer( aLayer );
|
|
||||||
solid->SetNet( -1 );
|
|
||||||
solid->SetParent( nullptr );
|
|
||||||
solid->SetRoutable( false );
|
|
||||||
aWorld->Add( std::move( solid ) );
|
|
||||||
return true;
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,7 @@ class PNS_PCBNEW_DEBUG_DECORATOR;
|
||||||
|
|
||||||
class BOARD;
|
class BOARD;
|
||||||
class BOARD_COMMIT;
|
class BOARD_COMMIT;
|
||||||
class EDA_TEXT;
|
class PCB_TEXT;
|
||||||
class PCB_DISPLAY_OPTIONS;
|
class PCB_DISPLAY_OPTIONS;
|
||||||
class PCB_TOOL_BASE;
|
class PCB_TOOL_BASE;
|
||||||
class FOOTPRINT;
|
class FOOTPRINT;
|
||||||
|
@ -96,7 +96,7 @@ protected:
|
||||||
std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
|
std::unique_ptr<PNS::SEGMENT> syncTrack( PCB_TRACK* aTrack );
|
||||||
std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
|
std::unique_ptr<PNS::ARC> syncArc( PCB_ARC* aArc );
|
||||||
std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
|
std::unique_ptr<PNS::VIA> syncVia( PCB_VIA* aVia );
|
||||||
bool syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB_LAYER_ID aLayer );
|
bool syncTextItem( PNS::NODE* aWorld, PCB_TEXT* aText, PCB_LAYER_ID aLayer );
|
||||||
bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
|
bool syncGraphicalItem( PNS::NODE* aWorld, PCB_SHAPE* aItem );
|
||||||
bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
|
bool syncZone( PNS::NODE* aWorld, ZONE* aZone, SHAPE_POLY_SET* aBoardOutline );
|
||||||
bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
|
bool inheritTrackWidth( PNS::ITEM* aItem, int* aInheritedWidth );
|
||||||
|
|
Loading…
Reference in New Issue