From 7dbd8ef802f1f0cef23432468ade2ec6f710d8b7 Mon Sep 17 00:00:00 2001 From: Tomasz Wlostowski Date: Wed, 15 Jul 2020 18:22:56 +0200 Subject: [PATCH] EDA_TEXT: implement GetEffectiveShape() --- common/eda_text.cpp | 19 +++++++++++++++++++ include/eda_text.h | 3 +++ 2 files changed, 22 insertions(+) diff --git a/common/eda_text.cpp b/common/eda_text.cpp index a8b148f99f..f86863b53a 100644 --- a/common/eda_text.cpp +++ b/common/eda_text.cpp @@ -48,6 +48,11 @@ #include // for VECTOR2D #include // for RotatePoint +#include +#include +#include + + #include // for wxASSERT #include // for wxPoint, wxString, wxArrayString, wxSize @@ -612,6 +617,20 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector& aCornerBuf } +std::shared_ptr EDA_TEXT::GetEffectiveShape( ) const +{ + std::shared_ptr shape ( new SHAPE_COMPOUND ); + int penWidth = GetEffectiveTextPenWidth(); + std::vector pts; + TransformTextShapeToSegmentList( pts ); + + for( unsigned jj = 0; jj < pts.size(); jj += 2 ) + shape->AddShape( new SHAPE_SEGMENT( pts[jj], pts[jj+1], penWidth ) ); + + return shape; +} + + static struct EDA_TEXT_DESC { EDA_TEXT_DESC() diff --git a/include/eda_text.h b/include/eda_text.h index e7a968aecb..e3607cd8b3 100644 --- a/include/eda_text.h +++ b/include/eda_text.h @@ -32,6 +32,7 @@ #include "kicad_string.h" #include "painter.h" +class SHAPE; class SHAPE_POLY_SET; using KIGFX::RENDER_SETTINGS; @@ -292,6 +293,8 @@ public: void TransformBoundingBoxWithClearanceToPolygon( SHAPE_POLY_SET* aCornerBuffer, int aClearanceValue ) const; + std::shared_ptr GetEffectiveShape( ) const; + /** * Test if \a aPoint is within the bounds of this object. *