From 4e174f207881683aaf842e50740fa74dc7a61c7b Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 27 Jun 2025 22:28:04 -0600 Subject: [PATCH] Don't try to keep netcodes in defaultZoneSettings (KICAD-7Z8). --- pcbnew/dialogs/dialog_copper_zones.cpp | 4 +-- pcbnew/edit_zone_helpers.cpp | 15 +++++------ .../pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp | 7 ++--- .../kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp | 2 +- pcbnew/tools/global_edit_tool.cpp | 6 +---- pcbnew/tools/zone_create_helper.cpp | 9 +++---- pcbnew/zone_filler.cpp | 9 +++---- pcbnew/zone_settings.cpp | 26 +++++++++---------- pcbnew/zone_settings.h | 7 +++-- 9 files changed, 37 insertions(+), 48 deletions(-) diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index 56b775a338..76f820e7c5 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -357,7 +357,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() m_sortByPadsOpt->SetValue( m_netSortingByPadCount ); m_hideAutoGenNetNamesOpt->SetValue( m_hideAutoGeneratedNets ); - m_currentlySelectedNetcode = m_settings.m_NetcodeSelection; + m_currentlySelectedNetcode = m_settings.m_Netcode; // Initialize information required to display nets list readNetInformation(); @@ -610,7 +610,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions() return false; } - m_settings.m_NetcodeSelection = m_currentlySelectedNetcode; + m_settings.m_Netcode = m_currentlySelectedNetcode; m_settings.m_Name = m_tcZoneName->GetValue(); diff --git a/pcbnew/edit_zone_helpers.cpp b/pcbnew/edit_zone_helpers.cpp index f87c00d41c..5703c5d05e 100644 --- a/pcbnew/edit_zone_helpers.cpp +++ b/pcbnew/edit_zone_helpers.cpp @@ -47,7 +47,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) // store default layer properties std::map layer_properties; - std::ranges::copy( zoneInfo.m_layerProperties, + std::ranges::copy( zoneInfo.m_LayerProperties, std::inserter( layer_properties, std::end( layer_properties ) ) ); if( aZone->GetIsRuleArea() ) @@ -81,15 +81,14 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone ) zoneInfo.ExportSetting( *aZone ); - NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_NetcodeSelection ); - - if( net ) // net == NULL should not occur + if( NETINFO_ITEM* net = GetBoard()->FindNet( zoneInfo.m_Netcode ) ) aZone->SetNetCode( net->GetNetCode() ); - // restore default layer properties - zoneInfo.m_layerProperties.clear(); - std::ranges::copy( layer_properties, std::inserter( zoneInfo.m_layerProperties, - std::end( zoneInfo.m_layerProperties ) ) ); + // restore default layer & net properties + zoneInfo.m_LayerProperties.clear(); + std::ranges::copy( layer_properties, std::inserter( zoneInfo.m_LayerProperties, + std::end( zoneInfo.m_LayerProperties ) ) ); + zoneInfo.m_Netcode = NETINFO_LIST::ORPHANED; m_pcb->GetDesignSettings().SetDefaultZoneSettings( zoneInfo ); diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp index 2231b9f5ff..2aa215f461 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr.cpp @@ -606,15 +606,12 @@ void PCB_IO_KICAD_SEXPR::formatSetup( const BOARD* aBoard ) const KICAD_FORMAT::FormatBool( m_out, "filling", dsnSettings.m_FillVias ); - if( !dsnSettings.GetDefaultZoneSettings().m_layerProperties.empty() ) + if( !dsnSettings.GetDefaultZoneSettings().m_LayerProperties.empty() ) { m_out->Print( 0, " (zone_defaults" ); - for( const auto& [layer, properties] : - dsnSettings.GetDefaultZoneSettings().m_layerProperties ) - { + for( const auto& [layer, properties] : dsnSettings.GetDefaultZoneSettings().m_LayerProperties ) format( properties, 0, layer ); - } m_out->Print( 0, ")\n" ); } diff --git a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp index e02b5eddb4..2d0aaba0ae 100644 --- a/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp +++ b/pcbnew/pcb_io/kicad_sexpr/pcb_io_kicad_sexpr_parser.cpp @@ -2564,7 +2564,7 @@ void PCB_IO_KICAD_SEXPR_PARSER::parseZoneDefaults( ZONE_SETTINGS& aZoneSettings switch( token ) { case T_property: - parseZoneLayerProperty( aZoneSettings.m_layerProperties ); + parseZoneLayerProperty( aZoneSettings.m_LayerProperties ); break; default: Unexpected( CurText() ); diff --git a/pcbnew/tools/global_edit_tool.cpp b/pcbnew/tools/global_edit_tool.cpp index 2b1353d118..f17362d26d 100644 --- a/pcbnew/tools/global_edit_tool.cpp +++ b/pcbnew/tools/global_edit_tool.cpp @@ -264,7 +264,7 @@ int GLOBAL_EDIT_TOOL::ZonesManager( const TOOL_EVENT& aEvent ) for( ZONE* zone : board->Zones() ) editFrame->GetCanvas()->GetView()->Update( zone ); - + zoneInfo.m_Netcode = NETINFO_LIST::ORPHANED; board->GetDesignSettings().SetDefaultZoneSettings( zoneInfo ); commit.Push( _( "Modify zones properties with zone manager" ), SKIP_CONNECTIVITY ); editFrame->OnModify(); @@ -273,18 +273,14 @@ int GLOBAL_EDIT_TOOL::ZonesManager( const TOOL_EVENT& aEvent ) board->BuildConnectivity(); if( TOOL_MANAGER* manger = GetManager() ) - { manger->PostEvent( EVENTS::ConnectivityChangedEvent ); - } editFrame->GetCanvas()->RedrawRatsnest(); if( dialogResult == ZONE_MANAGER_REPOUR ) { if( TOOL_MANAGER* manger = GetManager() ) - { manger->PostAction( PCB_ACTIONS::zoneFillAll ); - } } return 0; diff --git a/pcbnew/tools/zone_create_helper.cpp b/pcbnew/tools/zone_create_helper.cpp index 481459a4e8..3531c03fad 100644 --- a/pcbnew/tools/zone_create_helper.cpp +++ b/pcbnew/tools/zone_create_helper.cpp @@ -95,8 +95,8 @@ std::unique_ptr ZONE_CREATE_HELPER::createNewZone( bool aKeepout ) // Get the current default settings for zones ZONE_SETTINGS zoneInfo = board->GetDesignSettings().GetDefaultZoneSettings(); zoneInfo.m_Layers.reset().set( m_params.m_layer ); // TODO(JE) multilayer defaults? - zoneInfo.m_layerProperties.clear(); // Do not copy over layer properties - zoneInfo.m_NetcodeSelection = highlightedNets.empty() ? -1 : *highlightedNets.begin(); + zoneInfo.m_LayerProperties.clear(); // Do not copy over layer properties + zoneInfo.m_Netcode = highlightedNets.empty() ? -1 : *highlightedNets.begin(); zoneInfo.SetIsRuleArea( m_params.m_keepout ); if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON @@ -108,13 +108,12 @@ std::unique_ptr ZONE_CREATE_HELPER::createNewZone( bool aKeepout ) // If we don't have a net from highlighting, maybe we can get one from the selection PCB_SELECTION_TOOL* selectionTool = m_tool.GetManager()->GetTool(); - if( selectionTool && !selectionTool->GetSelection().Empty() - && zoneInfo.m_NetcodeSelection == -1 ) + if( selectionTool && !selectionTool->GetSelection().Empty() && zoneInfo.m_Netcode == -1 ) { EDA_ITEM* item = *selectionTool->GetSelection().GetItems().begin(); if( BOARD_CONNECTED_ITEM* bci = dynamic_cast( item ) ) - zoneInfo.m_NetcodeSelection = bci->GetNetCode(); + zoneInfo.m_Netcode = bci->GetNetCode(); } if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON ) diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 8c2849582d..d5165589b8 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -2567,12 +2567,11 @@ bool ZONE_FILLER::addHatchFillTypeOnZone( const ZONE* aZone, PCB_LAYER_ID aLayer if( !zone_has_offset ) { - if( m_board->GetDesignSettings().GetDefaultZoneSettings().m_layerProperties.contains( - aLayer ) ) + ZONE_SETTINGS& defaultZoneSettings = m_board->GetDesignSettings().GetDefaultZoneSettings(); + + if( defaultZoneSettings.m_LayerProperties.contains( aLayer ) ) { - const ZONE_LAYER_PROPERTIES& properties = - m_board->GetDesignSettings().GetDefaultZoneSettings().m_layerProperties.at( - aLayer ); + const ZONE_LAYER_PROPERTIES& properties = defaultZoneSettings.m_LayerProperties.at( aLayer ); offset_opt = properties.hatching_offset.value_or( VECTOR2I( 0, 0 ) ); } diff --git a/pcbnew/zone_settings.cpp b/pcbnew/zone_settings.cpp index 652789ebb6..653b674c80 100644 --- a/pcbnew/zone_settings.cpp +++ b/pcbnew/zone_settings.cpp @@ -56,7 +56,7 @@ ZONE_SETTINGS::ZONE_SETTINGS() m_HatchSmoothingValue = 0.1; // Grid pattern chamfer value relative to the gap value m_HatchHoleMinArea = 0.15; // Min size before holes are dropped (ratio of hole size) m_HatchBorderAlgorithm = 1; // 0 = use zone min thickness; 1 = use hatch width - m_NetcodeSelection = 0; // Net code selection for the current zone + m_Netcode = 0; // Net code for the current zone m_ZoneBorderDisplayStyle = ZONE_BORDER_DISPLAY_STYLE::DIAGONAL_EDGE; // Option to show the zone // outlines only, short // hatches or full hatches @@ -106,7 +106,7 @@ bool ZONE_SETTINGS::operator==( const ZONE_SETTINGS& aOther ) const if( m_HatchSmoothingValue != aOther.m_HatchSmoothingValue ) return false; if( m_HatchBorderAlgorithm != aOther.m_HatchBorderAlgorithm ) return false; if( m_HatchHoleMinArea != aOther.m_HatchHoleMinArea ) return false; - if( m_NetcodeSelection != aOther.m_NetcodeSelection ) return false; + if( m_Netcode != aOther.m_Netcode ) return false; if( m_Name != aOther.m_Name ) return false; if( m_ZoneBorderDisplayStyle != aOther.m_ZoneBorderDisplayStyle ) return false; if( m_BorderHatchPitch != aOther.m_BorderHatchPitch ) return false; @@ -128,8 +128,8 @@ bool ZONE_SETTINGS::operator==( const ZONE_SETTINGS& aOther ) const if( m_removeIslands != aOther.m_removeIslands ) return false; if( m_minIslandArea != aOther.m_minIslandArea ) return false; - if( !std::equal( std::begin( m_layerProperties ), std::end( m_layerProperties ), - std::begin( aOther.m_layerProperties ) ) ) + if( !std::equal( std::begin( m_LayerProperties ), std::end( m_LayerProperties ), + std::begin( aOther.m_LayerProperties ) ) ) return false; // Currently, the teardrop area type is not really a ZONE_SETTINGS parameter, @@ -156,7 +156,7 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE& aSource ) m_HatchSmoothingValue = aSource.GetHatchSmoothingValue(); m_HatchBorderAlgorithm = aSource.GetHatchBorderAlgorithm(); m_HatchHoleMinArea = aSource.GetHatchHoleMinArea(); - m_NetcodeSelection = aSource.GetNetCode(); + m_Netcode = aSource.GetNetCode(); m_Name = aSource.GetZoneName(); m_ZoneBorderDisplayStyle = aSource.GetHatchStyle(); m_BorderHatchPitch = aSource.GetBorderHatchPitch(); @@ -178,10 +178,10 @@ ZONE_SETTINGS& ZONE_SETTINGS::operator << ( const ZONE& aSource ) m_removeIslands = aSource.GetIslandRemovalMode(); m_minIslandArea = aSource.GetMinIslandArea(); - m_layerProperties.clear(); + m_LayerProperties.clear(); std::ranges::copy( aSource.LayerProperties(), - std::inserter( m_layerProperties, std::end( m_layerProperties ) ) ); + std::inserter( m_LayerProperties, std::end( m_LayerProperties ) ) ); // Currently, the teardrop area type is not really a ZONE_SETTINGS parameter, // but a ZONE parameter only. @@ -234,13 +234,13 @@ void ZONE_SETTINGS::ExportSetting( ZONE& aTarget, bool aFullExport ) const { aTarget.SetAssignedPriority( m_ZonePriority ); - aTarget.SetLayerProperties( m_layerProperties ); + aTarget.SetLayerProperties( m_LayerProperties ); aTarget.SetLayerSet( m_Layers ); aTarget.SetZoneName( m_Name ); if( !m_isRuleArea ) - aTarget.SetNetCode( m_NetcodeSelection ); + aTarget.SetNetCode( m_Netcode ); } // call SetBorderDisplayStyle last, because hatch lines will be rebuilt, @@ -263,7 +263,7 @@ void ZONE_SETTINGS::CopyFrom( const ZONE_SETTINGS& aOther, bool aCopyFull ) m_HatchSmoothingValue = aOther.m_HatchSmoothingValue; m_HatchBorderAlgorithm = aOther.m_HatchBorderAlgorithm; m_HatchHoleMinArea = aOther.m_HatchHoleMinArea; - m_NetcodeSelection = aOther.m_NetcodeSelection; + m_Netcode = aOther.m_Netcode; m_Name = aOther.m_Name; m_ZoneBorderDisplayStyle = aOther.m_ZoneBorderDisplayStyle; m_BorderHatchPitch = aOther.m_BorderHatchPitch; @@ -288,10 +288,10 @@ void ZONE_SETTINGS::CopyFrom( const ZONE_SETTINGS& aOther, bool aCopyFull ) if( aCopyFull ) { - m_layerProperties.clear(); + m_LayerProperties.clear(); - std::ranges::copy( aOther.m_layerProperties, - std::inserter( m_layerProperties, std::end( m_layerProperties ) ) ); + std::ranges::copy( aOther.m_LayerProperties, + std::inserter( m_LayerProperties, std::end( m_LayerProperties ) ) ); m_TeardropType = aOther.m_TeardropType; diff --git a/pcbnew/zone_settings.h b/pcbnew/zone_settings.h index 0564fc1648..0d88a35f18 100644 --- a/pcbnew/zone_settings.h +++ b/pcbnew/zone_settings.h @@ -110,7 +110,7 @@ public: double m_HatchHoleMinArea; // min size before holes are dropped (ratio) int m_HatchBorderAlgorithm; // 0 = use min zone thickness - int m_NetcodeSelection; // Net code selection for the current zone + int m_Netcode; // Net code selection for the current zone wxString m_Name; // Unique name for the current zone (can be blank) @@ -130,7 +130,7 @@ public: */ TEARDROP_TYPE m_TeardropType; - std::map m_layerProperties; + std::map m_LayerProperties; private: int m_cornerSmoothingType; // Corner smoothing type @@ -194,8 +194,7 @@ public: * @param aTarget: the given zone * @param aFullExport: if false: some parameters are NOT exported * because they must not be exported when export settings from a zone to others zones - * Currently: - * m_NetcodeSelection + * Currently: m_ZonePriority, m_Layers & m_LayersProperties, m_Name and m_Netcode */ void ExportSetting( ZONE& aTarget, bool aFullExport = true ) const;