From 050d282c1206133aa8bf77793c08557cfd14c451 Mon Sep 17 00:00:00 2001 From: Jon Evans Date: Fri, 2 Dec 2022 21:59:17 -0500 Subject: [PATCH] Properties: Hide some copper-only properties from non-copper zones --- pcbnew/zone.cpp | 53 +++++++++++++++++++++++++++++++++---------------- 1 file changed, 36 insertions(+), 17 deletions(-) diff --git a/pcbnew/zone.cpp b/pcbnew/zone.cpp index 374c2d6f35..205d569cf0 100644 --- a/pcbnew/zone.cpp +++ b/pcbnew/zone.cpp @@ -1386,39 +1386,58 @@ static struct ZONE_DESC propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position X" ), posX ); propMgr.ReplaceProperty( TYPE_HASH( BOARD_ITEM ), _HKI( "Position Y" ), posY ); + + auto isCopperZone = + []( INSPECTABLE* aItem ) -> bool + { + if( ZONE* zone = dynamic_cast( aItem ) ) + return !zone->GetIsRuleArea() && IsCopperLayer( zone->GetFirstLayer() ); + }; auto layer = new PROPERTY_ENUM( _HKI( "Layer" ), &ZONE::SetLayer, &ZONE::GetLayer ); layer->SetIsInternal( true ); propMgr.ReplaceProperty( TYPE_HASH( BOARD_CONNECTED_ITEM ), _HKI( "Layer" ), layer ); - propMgr.AddProperty( new PROPERTY( _HKI( "Priority" ), - &ZONE::SetAssignedPriority, &ZONE::GetAssignedPriority ) ); + auto priority = new PROPERTY( _HKI( "Priority" ), + &ZONE::SetAssignedPriority, &ZONE::GetAssignedPriority ); + priority->SetAvailableFunc( isCopperZone ); + propMgr.AddProperty( priority ); propMgr.AddProperty( new PROPERTY( _HKI( "Name" ), &ZONE::SetZoneName, &ZONE::GetZoneName ) ); const wxString groupOverrides = _( "Overrides" ); - propMgr.AddProperty( new PROPERTY( _HKI( "Clearance Override" ), + auto clearanceOverride = new PROPERTY( _HKI( "Clearance Override" ), &ZONE::SetLocalClearance, &ZONE::GetLocalClearance, - PROPERTY_DISPLAY::PT_SIZE ), - groupOverrides ); - propMgr.AddProperty( new PROPERTY( _HKI( "Minimum Width" ), + PROPERTY_DISPLAY::PT_SIZE ); + clearanceOverride->SetAvailableFunc( isCopperZone ); + + auto minWidth = new PROPERTY( _HKI( "Minimum Width" ), &ZONE::SetMinThickness, &ZONE::GetMinThickness, - PROPERTY_DISPLAY::PT_SIZE ), - groupOverrides ); - propMgr.AddProperty( new PROPERTY_ENUM( _HKI( "Pad Connections" ), - &ZONE::SetPadConnection, &ZONE::GetPadConnection ), - groupOverrides ); - propMgr.AddProperty( new PROPERTY( _HKI( "Thermal Relief Gap" ), + PROPERTY_DISPLAY::PT_SIZE ); + minWidth->SetAvailableFunc( isCopperZone ); + + auto padConnections = new PROPERTY_ENUM( _HKI( "Pad Connections" ), + &ZONE::SetPadConnection, &ZONE::GetPadConnection ); + padConnections->SetAvailableFunc( isCopperZone ); + + auto thermalGap = new PROPERTY( _HKI( "Thermal Relief Gap" ), &ZONE::SetThermalReliefGap, &ZONE::GetThermalReliefGap, - PROPERTY_DISPLAY::PT_SIZE ), - groupOverrides ); - propMgr.AddProperty( new PROPERTY( _HKI( "Thermal Relief Spoke Width" ), + PROPERTY_DISPLAY::PT_SIZE ); + thermalGap->SetAvailableFunc( isCopperZone ); + + auto thermalSpokeWidth = new PROPERTY( _HKI( "Thermal Relief Spoke Width" ), &ZONE::SetThermalReliefSpokeWidth, &ZONE::GetThermalReliefSpokeWidth, - PROPERTY_DISPLAY::PT_SIZE ), - groupOverrides ); + PROPERTY_DISPLAY::PT_SIZE ); + thermalSpokeWidth->SetAvailableFunc( isCopperZone ); + + propMgr.AddProperty( clearanceOverride, groupOverrides ); + propMgr.AddProperty( minWidth, groupOverrides ); + propMgr.AddProperty( padConnections, groupOverrides ); + propMgr.AddProperty( thermalGap, groupOverrides ); + propMgr.AddProperty( thermalSpokeWidth, groupOverrides ); } } _ZONE_DESC;