Move "parent" property from PAD to BOARD_ITEM.

This commit is contained in:
Jeff Young 2023-08-18 18:35:44 +01:00
parent 57ba38560c
commit ec980e8696
4 changed files with 19 additions and 15 deletions

View File

@ -315,6 +315,12 @@ public:
virtual const BOARD* GetBoard() const;
virtual BOARD* GetBoard();
/**
* For "parent" property.
* @return the parent footprint's ref or the parent item's UUID.
*/
wxString GetParentAsString() const;
/**
* Return the name of the PCB layer on which the item resides.
*

View File

@ -297,6 +297,15 @@ void BOARD_ITEM::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight )
}
wxString BOARD_ITEM::GetParentAsString() const
{
if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( m_parent ) )
return fp->GetReference();
return m_parent->m_Uuid.AsString();
}
static struct BOARD_ITEM_DESC
{
BOARD_ITEM_DESC()
@ -315,6 +324,10 @@ static struct BOARD_ITEM_DESC
REGISTER_TYPE( BOARD_ITEM );
propMgr.InheritsAfter( TYPE_HASH( BOARD_ITEM ), TYPE_HASH( EDA_ITEM ) );
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, wxString>( _HKI( "Parent" ),
NO_SETTER( BOARD_ITEM, wxString ), &BOARD_ITEM::GetParentAsString ) )
.SetIsHiddenFromLibraryEditors();
propMgr.AddProperty( new PROPERTY<BOARD_ITEM, int>( _HKI( "Position X" ),
&BOARD_ITEM::SetX, &BOARD_ITEM::GetX, PROPERTY_DISPLAY::PT_COORD,
ORIGIN_TRANSFORMS::ABS_X_COORD ) );

View File

@ -1665,15 +1665,6 @@ void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer,
}
wxString PAD::GetParentAsString() const
{
if( FOOTPRINT* fp = dynamic_cast<FOOTPRINT*>( m_parent ) )
return fp->GetReference();
return m_parent->m_Uuid.AsString();
}
static struct PAD_DESC
{
PAD_DESC()
@ -1760,10 +1751,6 @@ static struct PAD_DESC
&PAD::SetShape, &PAD::GetShape );
propMgr.AddProperty( shape, groupPad );
propMgr.AddProperty( new PROPERTY<PAD, wxString>( _HKI( "Parent" ),
NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ), groupPad )
.SetIsHiddenFromLibraryEditors();
auto padNumber = new PROPERTY<PAD, wxString>( _HKI( "Pad Number" ),
&PAD::SetNumber, &PAD::GetNumber );
padNumber->SetAvailableFunc( isCopperPad );

View File

@ -108,8 +108,6 @@ public:
return GetDrillSizeX() > 0 && GetDrillSizeY() > 0;
}
wxString GetParentAsString() const;
bool IsLocked() const override;
/**