pcbnew: implement GetEffectiveShape() for tracks/vias/arcs/texts

This commit is contained in:
Tomasz Wlostowski 2020-08-09 00:37:41 +02:00
parent 6358995ff8
commit f6ea753968
6 changed files with 53 additions and 1 deletions

View File

@ -245,6 +245,12 @@ void TEXTE_PCB::SwapData( BOARD_ITEM* aImage )
}
std::shared_ptr<SHAPE> TEXTE_PCB::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
return GetEffectiveTextShape();
}
static struct TEXTE_PCB_DESC
{
TEXTE_PCB_DESC()

View File

@ -127,6 +127,9 @@ public:
void TransformShapeWithClearanceToPolygonSet(
SHAPE_POLY_SET& aCornerBuffer, int aClearanceValue, int aError = ARC_HIGH_DEF ) const;
// @copydoc BOARD_ITEM::GetEffectiveShape
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
BITMAP_DEF GetMenuImage() const override;

View File

@ -453,6 +453,12 @@ wxString TEXTE_MODULE::GetShownText( int aDepth ) const
}
std::shared_ptr<SHAPE> TEXTE_MODULE::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
return GetEffectiveTextShape();
}
static struct TEXTE_MODULE_DESC
{
TEXTE_MODULE_DESC()

View File

@ -41,7 +41,7 @@ class EDA_RECT;
class MODULE;
class MSG_PANEL_ITEM;
class PCB_BASE_FRAME;
class SHAPE;
#define UMBILICAL_COLOR LIGHTBLUE
@ -208,6 +208,9 @@ public:
return TextHitTest( aRect, aContained, aAccuracy );
}
// @copydoc BOARD_ITEM::GetEffectiveShape
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
wxString GetClass() const override
{
return wxT( "MTEXT" );

View File

@ -35,6 +35,9 @@
#include <settings/color_settings.h>
#include <settings/settings_manager.h>
#include <geometry/shape_segment.h>
#include <geometry/shape_circle.h>
#include <geometry/shape_arc.h>
TRACK::TRACK( BOARD_ITEM* aParent, KICAD_T idtype ) :
BOARD_CONNECTED_ITEM( aParent, idtype )
@ -1024,6 +1027,33 @@ bool TRACK::cmp_tracks::operator() ( const TRACK* a, const TRACK* b ) const
}
std::shared_ptr<SHAPE> TRACK::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
std::shared_ptr<SHAPE_SEGMENT> shape( new SHAPE_SEGMENT( m_Start, m_End, m_Width ) );
return shape;
}
std::shared_ptr<SHAPE> VIA::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
// fixme: pad stack support (depending on aLayer )
std::shared_ptr<SHAPE_CIRCLE> shape( new SHAPE_CIRCLE( m_Start, m_Width / 2 ) );
return shape;
}
std::shared_ptr<SHAPE> ARC::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
{
std::shared_ptr<SHAPE_ARC> shape( new SHAPE_ARC( GetStart(), GetMid(), GetEnd(),
GetWidth() ) );
return shape;
}
#if defined(DEBUG)
wxString TRACK::ShowState( int stateBits )

View File

@ -167,6 +167,10 @@ public:
void TransformShapeWithClearanceToPolygon( SHAPE_POLY_SET& aCornerBuffer, PCB_LAYER_ID aLayer,
int aClearanceValue, int aError = ARC_HIGH_DEF,
bool ignoreLineWidth = false ) const override;
// @copydoc BOARD_ITEM::GetEffectiveShape
virtual std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer = UNDEFINED_LAYER ) const override;
/**
* Function IsPointOnEnds
* returns STARTPOINT if point if near (dist = min_dist) start point, ENDPOINT if