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