Don't try to keep netcodes in defaultZoneSettings (KICAD-7Z8).

This commit is contained in:
Jeff Young 2025-06-27 22:28:04 -06:00
parent 07b8291173
commit 4e174f2078
9 changed files with 37 additions and 48 deletions

View File

@ -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();

View File

@ -47,7 +47,7 @@ void PCB_EDIT_FRAME::Edit_Zone_Params( ZONE* aZone )
// store default layer properties
std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> 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 );

View File

@ -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" );
}

View File

@ -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() );

View File

@ -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;

View File

@ -95,8 +95,8 @@ std::unique_ptr<ZONE> 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> 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<PCB_SELECTION_TOOL>();
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<BOARD_CONNECTED_ITEM*>( item ) )
zoneInfo.m_NetcodeSelection = bci->GetNetCode();
zoneInfo.m_Netcode = bci->GetNetCode();
}
if( m_params.m_mode != ZONE_MODE::GRAPHIC_POLYGON )

View File

@ -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 ) );
}

View File

@ -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;

View File

@ -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<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> m_layerProperties;
std::map<PCB_LAYER_ID, ZONE_LAYER_PROPERTIES> 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;