From ec980e8696ec2da4b72da626eb0aef7bae929b2d Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 18 Aug 2023 18:35:44 +0100 Subject: [PATCH] Move "parent" property from PAD to BOARD_ITEM. --- include/board_item.h | 6 ++++++ pcbnew/board_item.cpp | 13 +++++++++++++ pcbnew/pad.cpp | 13 ------------- pcbnew/pad.h | 2 -- 4 files changed, 19 insertions(+), 15 deletions(-) diff --git a/include/board_item.h b/include/board_item.h index 79584a92f9..5b4bcad0de 100644 --- a/include/board_item.h +++ b/include/board_item.h @@ -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. * diff --git a/pcbnew/board_item.cpp b/pcbnew/board_item.cpp index 26c2dfb9d7..7b146330d2 100644 --- a/pcbnew/board_item.cpp +++ b/pcbnew/board_item.cpp @@ -297,6 +297,15 @@ void BOARD_ITEM::Flip( const VECTOR2I& aCentre, bool aFlipLeftRight ) } +wxString BOARD_ITEM::GetParentAsString() const +{ + if( FOOTPRINT* fp = dynamic_cast( 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( _HKI( "Parent" ), + NO_SETTER( BOARD_ITEM, wxString ), &BOARD_ITEM::GetParentAsString ) ) + .SetIsHiddenFromLibraryEditors(); + propMgr.AddProperty( new PROPERTY( _HKI( "Position X" ), &BOARD_ITEM::SetX, &BOARD_ITEM::GetX, PROPERTY_DISPLAY::PT_COORD, ORIGIN_TRANSFORMS::ABS_X_COORD ) ); diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index 790cec7643..5b0f3064cb 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1665,15 +1665,6 @@ void PAD::TransformShapeToPolygon( SHAPE_POLY_SET& aBuffer, PCB_LAYER_ID aLayer, } -wxString PAD::GetParentAsString() const -{ - if( FOOTPRINT* fp = dynamic_cast( 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( _HKI( "Parent" ), - NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ), groupPad ) - .SetIsHiddenFromLibraryEditors(); - auto padNumber = new PROPERTY( _HKI( "Pad Number" ), &PAD::SetNumber, &PAD::GetNumber ); padNumber->SetAvailableFunc( isCopperPad ); diff --git a/pcbnew/pad.h b/pcbnew/pad.h index f528c8ad9c..7f5d227ad6 100644 --- a/pcbnew/pad.h +++ b/pcbnew/pad.h @@ -108,8 +108,6 @@ public: return GetDrillSizeX() > 0 && GetDrillSizeY() > 0; } - wxString GetParentAsString() const; - bool IsLocked() const override; /**