Implement router and DRC collisions for outline fonts.
This commit is contained in:
parent
a2030a5956
commit
72340fcee2
|
@ -50,7 +50,8 @@
|
|||
#include <i18n_utility.h>
|
||||
#include <geometry/shape_segment.h>
|
||||
#include <geometry/shape_compound.h>
|
||||
#include <font/font.h>
|
||||
#include <geometry/shape_simple.h>
|
||||
#include <font/outline_font.h>
|
||||
#include <geometry/shape_poly_set.h>
|
||||
|
||||
#include <wx/debug.h> // for wxASSERT
|
||||
|
@ -622,11 +623,52 @@ std::vector<VECTOR2I> EDA_TEXT::TransformToSegmentList() const
|
|||
std::shared_ptr<SHAPE_COMPOUND> EDA_TEXT::GetEffectiveTextShape( ) const
|
||||
{
|
||||
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
std::vector<VECTOR2I> pts = TransformToSegmentList();
|
||||
|
||||
for( unsigned jj = 0; jj < pts.size(); jj += 2 )
|
||||
shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
|
||||
if( GetFont() && GetFont()->IsOutline() )
|
||||
{
|
||||
// FONT TODO: Use the cached glyphs rather than rendering them
|
||||
|
||||
KIFONT::OUTLINE_FONT* font = static_cast<KIFONT::OUTLINE_FONT*>( GetFont() );
|
||||
std::vector<std::unique_ptr<KIFONT::GLYPH>> glyphs;
|
||||
|
||||
font->GetLinesAsGlyphs( glyphs, this );
|
||||
|
||||
for( std::unique_ptr<KIFONT::GLYPH>& baseGlyph : glyphs )
|
||||
{
|
||||
KIFONT::OUTLINE_GLYPH* glyph = static_cast<KIFONT::OUTLINE_GLYPH*>( baseGlyph.get() );
|
||||
|
||||
if( IsMirrored() )
|
||||
glyph->Mirror( GetTextPos() );
|
||||
|
||||
glyph->CacheTriangulation();
|
||||
|
||||
for( unsigned int ii = 0; ii < glyph->TriangulatedPolyCount(); ++ii )
|
||||
{
|
||||
const SHAPE_POLY_SET::TRIANGULATED_POLYGON* tri = glyph->TriangulatedPolygon( ii );
|
||||
|
||||
for( size_t jj = 0; jj < tri->GetTriangleCount(); ++jj )
|
||||
{
|
||||
VECTOR2I a, b, c;
|
||||
tri->GetTriangle( jj, a, b, c );
|
||||
SHAPE_SIMPLE* triShape = new SHAPE_SIMPLE;
|
||||
|
||||
triShape->Append( a );
|
||||
triShape->Append( b );
|
||||
triShape->Append( c );
|
||||
|
||||
shape->AddShape( triShape );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int penWidth = GetEffectiveTextPenWidth();
|
||||
std::vector<VECTOR2I> pts = TransformToSegmentList();
|
||||
|
||||
for( unsigned jj = 0; jj < pts.size(); jj += 2 )
|
||||
shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
|
||||
}
|
||||
|
||||
return shape;
|
||||
}
|
||||
|
|
|
@ -53,6 +53,7 @@
|
|||
|
||||
#include <advanced_config.h>
|
||||
#include <pcbnew_settings.h>
|
||||
#include <macros.h>
|
||||
|
||||
#include "pns_kicad_iface.h"
|
||||
|
||||
|
@ -1109,26 +1110,45 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
|
|||
if( !IsCopperLayer( aLayer ) )
|
||||
return false;
|
||||
|
||||
int textWidth = aText->GetEffectiveTextPenWidth();
|
||||
std::vector<VECTOR2I> textShape = aText->TransformToSegmentList();
|
||||
|
||||
if( textShape.size() < 2 )
|
||||
return false;
|
||||
|
||||
for( size_t jj = 0; jj < textShape.size(); jj += 2 )
|
||||
if( aText->GetFont() && aText->GetFont()->IsOutline() )
|
||||
{
|
||||
VECTOR2I start( textShape[jj] );
|
||||
VECTOR2I end( textShape[jj+1] );
|
||||
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
||||
for( SHAPE* shape : aText->GetEffectiveTextShape()->Shapes() )
|
||||
{
|
||||
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
||||
|
||||
solid->SetLayer( aLayer );
|
||||
solid->SetNet( -1 );
|
||||
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
|
||||
solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
|
||||
solid->SetIsCompoundShapePrimitive();
|
||||
solid->SetRoutable( false );
|
||||
solid->SetLayer( aLayer );
|
||||
solid->SetNet( -1 );
|
||||
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
|
||||
solid->SetShape( shape );
|
||||
solid->SetIsCompoundShapePrimitive();
|
||||
solid->SetRoutable( false );
|
||||
|
||||
aWorld->Add( std::move( solid ) );
|
||||
aWorld->Add( std::move( solid ) );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int textWidth = aText->GetEffectiveTextPenWidth();
|
||||
std::vector<VECTOR2I> textShape = aText->TransformToSegmentList();
|
||||
|
||||
if( textShape.size() < 2 )
|
||||
return false;
|
||||
|
||||
for( size_t jj = 0; jj < textShape.size(); jj += 2 )
|
||||
{
|
||||
VECTOR2I start( textShape[jj] );
|
||||
VECTOR2I end( textShape[jj+1] );
|
||||
std::unique_ptr<PNS::SOLID> solid = std::make_unique<PNS::SOLID>();
|
||||
|
||||
solid->SetLayer( aLayer );
|
||||
solid->SetNet( -1 );
|
||||
solid->SetParent( dynamic_cast<BOARD_ITEM*>( aText ) );
|
||||
solid->SetShape( new SHAPE_SEGMENT( start, end, textWidth ) );
|
||||
solid->SetIsCompoundShapePrimitive();
|
||||
solid->SetRoutable( false );
|
||||
|
||||
aWorld->Add( std::move( solid ) );
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue