From 67df342255caacc7a601a34ed3695f8e9be7283a Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Thu, 8 Dec 2022 17:59:18 -0500 Subject: [PATCH] Properties: mask irrelevant NPTH properties Fixes https://gitlab.com/kicad/code/kicad/-/issues/13087 --- pcbnew/pad.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/pcbnew/pad.cpp b/pcbnew/pad.cpp index c701758197..64501a78d2 100644 --- a/pcbnew/pad.cpp +++ b/pcbnew/pad.cpp @@ -1732,6 +1732,20 @@ static struct PAD_DESC &PAD::SetOrientationDegrees, &PAD::GetOrientationDegrees, PROPERTY_DISPLAY::PT_DEGREE ) ); + auto isCopperPad = + []( INSPECTABLE* aItem ) -> bool + { + if( PAD* pad = dynamic_cast( aItem ) ) + return pad->GetAttribute() != PAD_ATTRIB::NPTH; + + return false; + }; + + propMgr.OverrideAvailability( TYPE_HASH( PAD ), TYPE_HASH( BOARD_CONNECTED_ITEM ), + _HKI( "Net" ), isCopperPad ); + propMgr.OverrideAvailability( TYPE_HASH( PAD ), TYPE_HASH( BOARD_CONNECTED_ITEM ), + _HKI( "Net Class" ), isCopperPad ); + const wxString groupPad = _( "Pad Properties" ); auto padType = new PROPERTY_ENUM( _HKI( "Pad Type" ), @@ -1744,12 +1758,17 @@ static struct PAD_DESC propMgr.AddProperty( new PROPERTY( _HKI( "Parent" ), NO_SETTER( PAD, wxString ), &PAD::GetParentAsString ), groupPad ); - propMgr.AddProperty( new PROPERTY( _HKI( "Pad Number" ), - &PAD::SetNumber, &PAD::GetNumber ), groupPad); + + auto padNumber = new PROPERTY( _HKI( "Pad Number" ), + &PAD::SetNumber, &PAD::GetNumber ); + padNumber->SetAvailableFunc( isCopperPad ); + propMgr.AddProperty( padNumber, groupPad ); + propMgr.AddProperty( new PROPERTY( _HKI( "Pin Name" ), NO_SETTER( PAD, wxString ), &PAD::GetPinFunction ), groupPad ); propMgr.AddProperty( new PROPERTY( _HKI( "Pin Type" ), - NO_SETTER( PAD, wxString ), &PAD::GetPinType ), groupPad); + NO_SETTER( PAD, wxString ), &PAD::GetPinType ), groupPad ); + propMgr.AddProperty( new PROPERTY( _HKI( "Size X" ), &PAD::SetSizeX, &PAD::GetSizeX, PROPERTY_DISPLAY::PT_SIZE ), groupPad ); @@ -1775,9 +1794,12 @@ static struct PAD_DESC propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Fabrication Property" ), &PAD::SetProperty, &PAD::GetProperty ), groupPad ); - propMgr.AddProperty( new PROPERTY( _HKI( "Pad To Die Length" ), - &PAD::SetPadToDieLength, &PAD::GetPadToDieLength, - PROPERTY_DISPLAY::PT_SIZE ), groupPad ); + + auto padToDie = new PROPERTY( _HKI( "Pad To Die Length" ), + &PAD::SetPadToDieLength, &PAD::GetPadToDieLength, + PROPERTY_DISPLAY::PT_SIZE ); + padToDie->SetAvailableFunc( isCopperPad ); + propMgr.AddProperty( padToDie, groupPad ); const wxString groupOverrides = _( "Overrides" );