Pay attention to knockout text when adding to DRC Rtrees.

This commit is contained in:
Jeff Young 2023-01-25 18:33:31 +00:00
parent 96e9cd6ecc
commit 2312cf34c4
3 changed files with 44 additions and 10 deletions

View File

@ -436,6 +436,25 @@ wxString FP_TEXT::GetShownText( int aDepth, bool aAllowExtraText ) const
std::shared_ptr<SHAPE> FP_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const std::shared_ptr<SHAPE> FP_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
{ {
if( IsKnockout() )
{
SHAPE_POLY_SET knockouts;
TransformTextToPolySet( knockouts, aLayer, 0, GetBoard()->GetDesignSettings().m_MaxError,
ERROR_INSIDE );
SHAPE_POLY_SET finalPoly;
int strokeWidth = GetEffectiveTextPenWidth();
VECTOR2I fontSize = GetTextSize();
int margin = strokeWidth * 1.5 + GetKnockoutTextMargin( fontSize, strokeWidth );
TransformBoundingBoxToPolygon( &finalPoly, margin );
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
return std::make_shared<SHAPE_POLY_SET>( finalPoly );
}
return GetEffectiveTextShape(); return GetEffectiveTextShape();
} }
@ -447,10 +466,8 @@ void FP_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLay
KIFONT::FONT* font = getDrawFont(); KIFONT::FONT* font = getDrawFont();
int penWidth = GetEffectiveTextPenWidth(); int penWidth = GetEffectiveTextPenWidth();
// Note: this function is mainly used in 3D viewer. // The polygonal shape of a text can have many basic shapes, so combining these shapes can
// the polygonal shape of a text can have many basic shapes, // be very useful to create a final shape with a lot less vertices to speedup calculations.
// so combining these shapes can be very useful to create a final shape
// swith a lot less vertices to speedup calculations using this final shape
// Simplify shapes is not usually always efficient, but in this case it is. // Simplify shapes is not usually always efficient, but in this case it is.
SHAPE_POLY_SET buffer; SHAPE_POLY_SET buffer;

View File

@ -35,6 +35,7 @@
#include <trigo.h> #include <trigo.h>
#include <string_utils.h> #include <string_utils.h>
#include <geometry/shape_compound.h> #include <geometry/shape_compound.h>
#include <geometry/shape_rect.h>
#include <callback_gal.h> #include <callback_gal.h>
#include <convert_basic_shapes_to_polygon.h> #include <convert_basic_shapes_to_polygon.h>
@ -264,6 +265,25 @@ void PCB_TEXT::swapData( BOARD_ITEM* aImage )
std::shared_ptr<SHAPE> PCB_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const std::shared_ptr<SHAPE> PCB_TEXT::GetEffectiveShape( PCB_LAYER_ID aLayer, FLASHING aFlash ) const
{ {
if( IsKnockout() )
{
SHAPE_POLY_SET knockouts;
TransformTextToPolySet( knockouts, aLayer, 0, GetBoard()->GetDesignSettings().m_MaxError,
ERROR_INSIDE );
SHAPE_POLY_SET finalPoly;
int strokeWidth = GetEffectiveTextPenWidth();
VECTOR2I fontSize = GetTextSize();
int margin = strokeWidth * 1.5 + GetKnockoutTextMargin( fontSize, strokeWidth );
TransformBoundingBoxToPolygon( &finalPoly, margin );
finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST );
finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );
return std::make_shared<SHAPE_POLY_SET>( finalPoly );
}
return GetEffectiveTextShape(); return GetEffectiveTextShape();
} }
@ -275,10 +295,8 @@ void PCB_TEXT::TransformTextToPolySet( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLa
KIFONT::FONT* font = getDrawFont(); KIFONT::FONT* font = getDrawFont();
int penWidth = GetEffectiveTextPenWidth(); int penWidth = GetEffectiveTextPenWidth();
// Note: this function is mainly used in 3D viewer. // The polygonal shape of a text can have many basic shapes, so combining these shapes can
// the polygonal shape of a text can have many basic shapes, // be very useful to create a final shape with a lot less vertices to speedup calculations.
// so combining these shapes can be very useful to create a final shape
// swith a lot less vertices to speedup calculations using this final shape
// Simplify shapes is not usually always efficient, but in this case it is. // Simplify shapes is not usually always efficient, but in this case it is.
SHAPE_POLY_SET buffer; SHAPE_POLY_SET buffer;

View File

@ -117,8 +117,7 @@ public:
/** /**
* Function TransformTextToPolySet * Function TransformTextToPolySet
* Convert the text to a polygonSet describing the actual character strokes (one per segment). * Convert the text to a polygonSet describing the actual character strokes (one per segment).
* Used in 3D viewer * Circles and arcs are approximated by segments.
* Circles and arcs are approximated by segments
* @aBuffer = SHAPE_POLY_SET to store the polygon corners * @aBuffer = SHAPE_POLY_SET to store the polygon corners
* @aClearance = the clearance around the text * @aClearance = the clearance around the text
* @aError = the maximum error to allow when approximating curves * @aError = the maximum error to allow when approximating curves