Implement GetEffectiveShape() for PCB_TARGET_Ts.
Fixes https://gitlab.com/kicad/code/kicad/issues/6488
This commit is contained in:
parent
050d9e37ec
commit
d1bddcf879
|
@ -154,9 +154,7 @@ std::shared_ptr<SHAPE> BOARD_ITEM::GetEffectiveShape( PCB_LAYER_ID aLayer ) cons
|
||||||
{
|
{
|
||||||
std::shared_ptr<SHAPE> shape;
|
std::shared_ptr<SHAPE> shape;
|
||||||
|
|
||||||
int unimplemented_get_effective_shape = 0;
|
wxFAIL_MSG( "GetEffectiveShape() not implemented for " + GetClass() );
|
||||||
assert( unimplemented_get_effective_shape );
|
|
||||||
(void) unimplemented_get_effective_shape;
|
|
||||||
|
|
||||||
return shape;
|
return shape;
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,26 +32,26 @@
|
||||||
#include <settings/settings_manager.h>
|
#include <settings/settings_manager.h>
|
||||||
#include <trigo.h>
|
#include <trigo.h>
|
||||||
#include <i18n_utility.h>
|
#include <i18n_utility.h>
|
||||||
|
#include <geometry/shape_circle.h>
|
||||||
|
|
||||||
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
|
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent ) :
|
||||||
BOARD_ITEM( aParent, PCB_TARGET_T )
|
BOARD_ITEM( aParent, PCB_TARGET_T )
|
||||||
{
|
{
|
||||||
m_Shape = 0;
|
m_shape = 0;
|
||||||
m_Size = Millimeter2iu( 5 ); // Gives a decent size
|
m_size = Millimeter2iu( 5 ); // Gives a decent size
|
||||||
m_Width = Millimeter2iu( DEFAULT_COPPER_LINE_WIDTH );
|
m_lineWidth = Millimeter2iu( DEFAULT_COPPER_LINE_WIDTH );
|
||||||
m_layer = Edge_Cuts; // a target is on all layers
|
m_layer = Edge_Cuts; // a target is on all layers
|
||||||
}
|
}
|
||||||
|
|
||||||
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
|
PCB_TARGET::PCB_TARGET( BOARD_ITEM* aParent, int aShape, PCB_LAYER_ID aLayer,
|
||||||
const wxPoint& aPos, int aSize, int aWidth ) :
|
const wxPoint& aPos, int aSize, int aWidth ) :
|
||||||
BOARD_ITEM( aParent, PCB_TARGET_T )
|
BOARD_ITEM( aParent, PCB_TARGET_T )
|
||||||
{
|
{
|
||||||
m_Shape = aShape;
|
m_shape = aShape;
|
||||||
m_layer = aLayer;
|
m_layer = aLayer;
|
||||||
m_Pos = aPos;
|
m_pos = aPos;
|
||||||
m_Size = aSize;
|
m_size = aSize;
|
||||||
m_Width = aWidth;
|
m_lineWidth = aWidth;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -62,9 +62,9 @@ PCB_TARGET::~PCB_TARGET()
|
||||||
|
|
||||||
bool PCB_TARGET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
bool PCB_TARGET::HitTest( const wxPoint& aPosition, int aAccuracy ) const
|
||||||
{
|
{
|
||||||
int dX = aPosition.x - m_Pos.x;
|
int dX = aPosition.x - m_pos.x;
|
||||||
int dY = aPosition.y - m_Pos.y;
|
int dY = aPosition.y - m_pos.y;
|
||||||
int radius = aAccuracy + ( m_Size / 2 );
|
int radius = aAccuracy + ( m_size / 2 );
|
||||||
return abs( dX ) <= radius && abs( dY ) <= radius;
|
return abs( dX ) <= radius && abs( dY ) <= radius;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -83,16 +83,16 @@ bool PCB_TARGET::HitTest( const EDA_RECT& aRect, bool aContained, int aAccuracy
|
||||||
|
|
||||||
void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle)
|
void PCB_TARGET::Rotate(const wxPoint& aRotCentre, double aAngle)
|
||||||
{
|
{
|
||||||
RotatePoint( &m_Pos, aRotCentre, aAngle );
|
RotatePoint( &m_pos, aRotCentre, aAngle );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_TARGET::Flip(const wxPoint& aCentre, bool aFlipLeftRight )
|
void PCB_TARGET::Flip(const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
{
|
{
|
||||||
if( aFlipLeftRight )
|
if( aFlipLeftRight )
|
||||||
m_Pos.x = aCentre.x - ( m_Pos.x - aCentre.x );
|
m_pos.x = aCentre.x - ( m_pos.x - aCentre.x );
|
||||||
else
|
else
|
||||||
m_Pos.y = aCentre.y - ( m_Pos.y - aCentre.y );
|
m_pos.y = aCentre.y - ( m_pos.y - aCentre.y );
|
||||||
|
|
||||||
SetLayer( FlipLayer( GetLayer() ) );
|
SetLayer( FlipLayer( GetLayer() ) );
|
||||||
}
|
}
|
||||||
|
@ -101,15 +101,21 @@ void PCB_TARGET::Flip(const wxPoint& aCentre, bool aFlipLeftRight )
|
||||||
const EDA_RECT PCB_TARGET::GetBoundingBox() const
|
const EDA_RECT PCB_TARGET::GetBoundingBox() const
|
||||||
{
|
{
|
||||||
EDA_RECT bBox;
|
EDA_RECT bBox;
|
||||||
bBox.SetX( m_Pos.x - m_Size/2 );
|
bBox.SetX( m_pos.x - m_size / 2 );
|
||||||
bBox.SetY( m_Pos.y - m_Size/2 );
|
bBox.SetY( m_pos.y - m_size / 2 );
|
||||||
bBox.SetWidth( m_Size );
|
bBox.SetWidth( m_size );
|
||||||
bBox.SetHeight( m_Size );
|
bBox.SetHeight( m_size );
|
||||||
|
|
||||||
return bBox;
|
return bBox;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
std::shared_ptr<SHAPE> PCB_TARGET::GetEffectiveShape( PCB_LAYER_ID aLayer ) const
|
||||||
|
{
|
||||||
|
return std::make_shared<SHAPE_CIRCLE>( m_pos, m_size / 2 );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
wxString PCB_TARGET::GetSelectMenuText( EDA_UNITS aUnits ) const
|
wxString PCB_TARGET::GetSelectMenuText( EDA_UNITS aUnits ) const
|
||||||
{
|
{
|
||||||
// Targets are on *every* layer by definition
|
// Targets are on *every* layer by definition
|
||||||
|
|
|
@ -34,10 +34,10 @@ class LINE_READER;
|
||||||
|
|
||||||
class PCB_TARGET : public BOARD_ITEM
|
class PCB_TARGET : public BOARD_ITEM
|
||||||
{
|
{
|
||||||
int m_Shape; // bit 0 : 0 = draw +, 1 = draw X
|
int m_shape; // bit 0 : 0 = draw +, 1 = draw X
|
||||||
int m_Size;
|
int m_size;
|
||||||
int m_Width;
|
int m_lineWidth;
|
||||||
wxPoint m_Pos;
|
wxPoint m_pos;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
PCB_TARGET( BOARD_ITEM* aParent );
|
PCB_TARGET( BOARD_ITEM* aParent );
|
||||||
|
@ -57,21 +57,21 @@ public:
|
||||||
return aItem && PCB_TARGET_T == aItem->Type();
|
return aItem && PCB_TARGET_T == aItem->Type();
|
||||||
}
|
}
|
||||||
|
|
||||||
void SetPosition( const wxPoint& aPos ) override { m_Pos = aPos; }
|
void SetPosition( const wxPoint& aPos ) override { m_pos = aPos; }
|
||||||
wxPoint GetPosition() const override { return m_Pos; }
|
wxPoint GetPosition() const override { return m_pos; }
|
||||||
|
|
||||||
void SetShape( int aShape ) { m_Shape = aShape; }
|
void SetShape( int aShape ) { m_shape = aShape; }
|
||||||
int GetShape() const { return m_Shape; }
|
int GetShape() const { return m_shape; }
|
||||||
|
|
||||||
void SetSize( int aSize ) { m_Size = aSize; }
|
void SetSize( int aSize ) { m_size = aSize; }
|
||||||
int GetSize() const { return m_Size; }
|
int GetSize() const { return m_size; }
|
||||||
|
|
||||||
void SetWidth( int aWidth ) { m_Width = aWidth; }
|
void SetWidth( int aWidth ) { m_lineWidth = aWidth; }
|
||||||
int GetWidth() const { return m_Width; }
|
int GetWidth() const { return m_lineWidth; }
|
||||||
|
|
||||||
void Move( const wxPoint& aMoveVector ) override
|
void Move( const wxPoint& aMoveVector ) override
|
||||||
{
|
{
|
||||||
m_Pos += aMoveVector;
|
m_pos += aMoveVector;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
void Rotate( const wxPoint& aRotCentre, double aAngle ) override;
|
||||||
|
@ -89,6 +89,8 @@ public:
|
||||||
// Virtual function
|
// Virtual function
|
||||||
const EDA_RECT GetBoundingBox() const override;
|
const EDA_RECT GetBoundingBox() const override;
|
||||||
|
|
||||||
|
std::shared_ptr<SHAPE> GetEffectiveShape( PCB_LAYER_ID aLayer ) const override;
|
||||||
|
|
||||||
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
wxString GetSelectMenuText( EDA_UNITS aUnits ) const override;
|
||||||
|
|
||||||
BITMAP_DEF GetMenuImage() const override;
|
BITMAP_DEF GetMenuImage() const override;
|
||||||
|
|
Loading…
Reference in New Issue