EDA_TEXT: implement GetEffectiveShape()

This commit is contained in:
Tomasz Wlostowski 2020-07-15 18:22:56 +02:00
parent b03044d3d1
commit 7dbd8ef802
2 changed files with 22 additions and 0 deletions

View File

@ -48,6 +48,11 @@
#include <math/vector2d.h> // for VECTOR2D
#include <trigo.h> // for RotatePoint
#include <geometry/shape.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_compound.h>
#include <wx/debug.h> // for wxASSERT
#include <wx/wx.h> // for wxPoint, wxString, wxArrayString, wxSize
@ -612,6 +617,20 @@ void EDA_TEXT::TransformTextShapeToSegmentList( std::vector<wxPoint>& aCornerBuf
}
std::shared_ptr<SHAPE> EDA_TEXT::GetEffectiveShape( ) const
{
std::shared_ptr<SHAPE_COMPOUND> shape ( new SHAPE_COMPOUND );
int penWidth = GetEffectiveTextPenWidth();
std::vector<wxPoint> 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()

View File

@ -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<SHAPE> GetEffectiveShape( ) const;
/**
* Test if \a aPoint is within the bounds of this object.
*