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 <i18n_utility.h>
|
||||||
#include <geometry/shape_segment.h>
|
#include <geometry/shape_segment.h>
|
||||||
#include <geometry/shape_compound.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 <geometry/shape_poly_set.h>
|
||||||
|
|
||||||
#include <wx/debug.h> // for wxASSERT
|
#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> EDA_TEXT::GetEffectiveTextShape( ) const
|
||||||
{
|
{
|
||||||
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
|
std::shared_ptr<SHAPE_COMPOUND> shape = std::make_shared<SHAPE_COMPOUND>();
|
||||||
|
|
||||||
|
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();
|
int penWidth = GetEffectiveTextPenWidth();
|
||||||
std::vector<VECTOR2I> pts = TransformToSegmentList();
|
std::vector<VECTOR2I> pts = TransformToSegmentList();
|
||||||
|
|
||||||
for( unsigned jj = 0; jj < pts.size(); jj += 2 )
|
for( unsigned jj = 0; jj < pts.size(); jj += 2 )
|
||||||
shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
|
shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) );
|
||||||
|
}
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
|
@ -53,6 +53,7 @@
|
||||||
|
|
||||||
#include <advanced_config.h>
|
#include <advanced_config.h>
|
||||||
#include <pcbnew_settings.h>
|
#include <pcbnew_settings.h>
|
||||||
|
#include <macros.h>
|
||||||
|
|
||||||
#include "pns_kicad_iface.h"
|
#include "pns_kicad_iface.h"
|
||||||
|
|
||||||
|
@ -1109,6 +1110,24 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
|
||||||
if( !IsCopperLayer( aLayer ) )
|
if( !IsCopperLayer( aLayer ) )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
if( aText->GetFont() && aText->GetFont()->IsOutline() )
|
||||||
|
{
|
||||||
|
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( shape );
|
||||||
|
solid->SetIsCompoundShapePrimitive();
|
||||||
|
solid->SetRoutable( false );
|
||||||
|
|
||||||
|
aWorld->Add( std::move( solid ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
int textWidth = aText->GetEffectiveTextPenWidth();
|
int textWidth = aText->GetEffectiveTextPenWidth();
|
||||||
std::vector<VECTOR2I> textShape = aText->TransformToSegmentList();
|
std::vector<VECTOR2I> textShape = aText->TransformToSegmentList();
|
||||||
|
|
||||||
|
@ -1130,6 +1149,7 @@ bool PNS_KICAD_IFACE_BASE::syncTextItem( PNS::NODE* aWorld, EDA_TEXT* aText, PCB
|
||||||
|
|
||||||
aWorld->Add( std::move( solid ) );
|
aWorld->Add( std::move( solid ) );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue