diff --git a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp index e0c44378e6..c4c1f2a31c 100644 --- a/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp +++ b/3d-viewer/3d_canvas/create_3Dgraphic_brd_items.cpp @@ -68,31 +68,68 @@ void BOARD_ADAPTER::addText( const EDA_TEXT* aText, CONTAINER_2D_BASE* aContaine { KIGFX::GAL_DISPLAY_OPTIONS empty_opts; KIFONT::FONT* font = aText->GetDrawFont(); - float penWidth = TO_3DU( aText->GetEffectiveTextPenWidth() ); + TEXT_ATTRIBUTES attrs = aText->GetAttributes(); + float penWidth_3DU = TO_3DU( aText->GetEffectiveTextPenWidth() ); - CALLBACK_GAL callback_gal( empty_opts, - // Stroke callback - [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) - { - const SFVEC2F pt1_3DU = TO_SFVEC2F( aPt1 ); - const SFVEC2F pt2_3DU = TO_SFVEC2F( aPt2 ); + if( aOwner && aOwner->IsKnockout() ) + { + SHAPE_POLY_SET knockouts; - if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) ) - aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth / 2, *aOwner ) ); - else - aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth, *aOwner ) ); - }, - // Triangulation callback - [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 ) - { - aContainer->Add( new TRIANGLE_2D( TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ), - TO_SFVEC2F( aPt3 ), *aOwner ) ); - } ); + CALLBACK_GAL callback_gal( empty_opts, + // Polygon callback + [&]( const SHAPE_LINE_CHAIN& aPoly ) + { + knockouts.AddOutline( aPoly ); + } ); - TEXT_ATTRIBUTES attrs = aText->GetAttributes(); - attrs.m_Angle = aText->GetDrawRotation(); + attrs.m_StrokeWidth = aText->GetEffectiveTextPenWidth(); + attrs.m_Angle = aText->GetDrawRotation(); - font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); + callback_gal.SetIsFill( font->IsOutline() ); + callback_gal.SetIsStroke( font->IsStroke() ); + callback_gal.SetLineWidth( attrs.m_StrokeWidth ); + font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); + + SHAPE_POLY_SET finalPoly; + int margin = attrs.m_StrokeWidth * 1.5; + + aText->TransformBoundingBoxWithClearanceToPolygon( &finalPoly, margin ); + finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST ); + finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST ); + + ConvertPolygonToTriangles( finalPoly, *aContainer, m_biuTo3Dunits, *aOwner ); + } + else + { + CALLBACK_GAL callback_gal( empty_opts, + // Stroke callback + [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2 ) + { + const SFVEC2F pt1_3DU = TO_SFVEC2F( aPt1 ); + const SFVEC2F pt2_3DU = TO_SFVEC2F( aPt2 ); + + if( Is_segment_a_circle( pt1_3DU, pt2_3DU ) ) + { + aContainer->Add( new FILLED_CIRCLE_2D( pt1_3DU, penWidth_3DU / 2, + *aOwner ) ); + } + else + { + aContainer->Add( new ROUND_SEGMENT_2D( pt1_3DU, pt2_3DU, penWidth_3DU, + *aOwner ) ); + } + }, + // Triangulation callback + [&]( const VECTOR2I& aPt1, const VECTOR2I& aPt2, const VECTOR2I& aPt3 ) + { + aContainer->Add( new TRIANGLE_2D( TO_SFVEC2F( aPt1 ), TO_SFVEC2F( aPt2 ), + TO_SFVEC2F( aPt3 ), *aOwner ) ); + } ); + + attrs.m_Angle = aText->GetDrawRotation(); + + font->Draw( &callback_gal, aText->GetShownText(), aText->GetDrawPos(), attrs ); + } } diff --git a/common/eda_text.cpp b/common/eda_text.cpp index 061ec0acf6..5ed2d4ca67 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -855,7 +855,11 @@ std::shared_ptr EDA_TEXT::GetEffectiveTextShape( bool aTriangula KIFONT::FONT* font = GetDrawFont(); int penWidth = GetEffectiveTextPenWidth(); TEXT_ATTRIBUTES attrs = GetAttributes(); - attrs.m_Angle = aUseTextRotation ? GetDrawRotation() : ANGLE_0; + + if( aUseTextRotation ) + attrs.m_Angle = GetDrawRotation(); + else + attrs.m_Angle = ANGLE_0; if( aTriangulate ) { diff --git a/pcbnew/fp_text.cpp b/pcbnew/fp_text.cpp index afd8fbcd6e..48723cdb17 100644 --- a/pcbnew/fp_text.cpp +++ b/pcbnew/fp_text.cpp @@ -483,7 +483,6 @@ void FP_TEXT::TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffe SHAPE_POLY_SET buffer; EDA_TEXT::TransformBoundingBoxWithClearanceToPolygon( &buffer, aClearance ); - buffer.Rotate( -GetDrawRotation(), GetTextPos() ); aCornerBuffer.Append( buffer ); } diff --git a/pcbnew/pcb_painter.cpp b/pcbnew/pcb_painter.cpp index 0d9410880c..a7205992cb 100644 --- a/pcbnew/pcb_painter.cpp +++ b/pcbnew/pcb_painter.cpp @@ -1825,7 +1825,6 @@ void PCB_PAINTER::draw( const FP_TEXT* aText, int aLayer ) int margin = attrs.m_StrokeWidth * 1.5; aText->TransformBoundingBoxWithClearanceToPolygon( &finalPoly, margin ); - finalPoly.Rotate( -aText->GetDrawRotation(), aText->GetTextPos() ); finalPoly.BooleanSubtract( knockouts, SHAPE_POLY_SET::PM_FAST ); finalPoly.Fracture( SHAPE_POLY_SET::PM_FAST );