diff --git a/pcbnew/board_commit.cpp b/pcbnew/board_commit.cpp index 53ffd9a809..fed4a1b454 100644 --- a/pcbnew/board_commit.cpp +++ b/pcbnew/board_commit.cpp @@ -110,6 +110,11 @@ void BOARD_COMMIT::dirtyIntersectingZones( BOARD_ITEM* item ) { wxCHECK( item, /* void */ ); + ZONE_FILLER_TOOL* zoneFillerTool = m_toolMgr->GetTool(); + + if( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ) + zoneFillerTool->DirtyZone( static_cast( item ) ); + if( item->Type() == PCB_FOOTPRINT_T ) { static_cast( item )->RunOnChildren( @@ -128,23 +133,27 @@ void BOARD_COMMIT::dirtyIntersectingZones( BOARD_ITEM* item ) } else { - ZONE_FILLER_TOOL* zoneFillerTool = m_toolMgr->GetTool(); - BOARD* board = static_cast( m_toolMgr->GetModel() ); - EDA_RECT bbox = item->GetBoundingBox(); - LSET layers = item->GetLayerSet(); + BOARD* board = static_cast( m_toolMgr->GetModel() ); + EDA_RECT bbox = item->GetBoundingBox(); + LSET layers = item->GetLayerSet(); if( layers.test( Edge_Cuts ) || layers.test( Margin ) ) layers = LSET::PhysicalLayersMask(); + else + layers &= LSET::AllCuMask(); - for( ZONE* zone : board->Zones() ) + if( layers.any() ) { - if( zone->GetIsRuleArea() ) - continue; - - if( ( zone->GetLayerSet() & layers ).any() - && zone->GetCachedBoundingBox().Intersects( bbox ) ) + for( ZONE* zone : board->Zones() ) { - zoneFillerTool->DirtyZone( zone ); + if( zone->GetIsRuleArea() ) + continue; + + if( ( zone->GetLayerSet() & layers ).any() + && zone->GetCachedBoundingBox().Intersects( bbox ) ) + { + zoneFillerTool->DirtyZone( zone ); + } } } } diff --git a/pcbnew/dialogs/dialog_copper_zones.cpp b/pcbnew/dialogs/dialog_copper_zones.cpp index fe919197d5..f8c60b7257 100644 --- a/pcbnew/dialogs/dialog_copper_zones.cpp +++ b/pcbnew/dialogs/dialog_copper_zones.cpp @@ -94,7 +94,6 @@ private: bool isAutoGenerated( const wxString& netName ); void updateCurrentNetSelection(); void updateInfoBar(); - void handleRemoveIslandsSelection(); void storePersistentNetSortConfigurations(); void loadPersistentNetSortConfigurations(); @@ -254,11 +253,7 @@ DIALOG_COPPER_ZONE::DIALOG_COPPER_ZONE( PCB_BASE_FRAME* aParent, ZONE_SETTINGS* [&]( wxCommandEvent& ) { // Area mode is index 2 - bool val = m_cbRemoveIslands->GetSelection() == 2; - - m_tcIslandThreshold->Enable( val ); - m_islandThresholdLabel->Enable( val ); - m_islandThresholdUnits->Enable( val ); + m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 ); } ); SetupStandardButtons(); @@ -325,11 +320,7 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() m_cbRemoveIslands->SetSelection( static_cast( m_settings.GetIslandRemovalMode() ) ); - bool val = m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA; - - m_tcIslandThreshold->Enable( val ); - m_islandThresholdLabel->Enable( val ); - m_islandThresholdUnits->Enable( val ); + m_islandThreshold.Enable( m_settings.GetIslandRemovalMode() == ISLAND_REMOVAL_MODE::AREA ); loadPersistentNetSortConfigurations(); @@ -376,16 +367,12 @@ bool DIALOG_COPPER_ZONE::TransferDataToWindow() m_tcZoneName->SetValue( m_settings.m_Name ); - updateInfoBar(); - handleRemoveIslandsSelection(); - - updateDisplayedListOfNets(); - SetInitialFocus( m_ShowNetNameFilter ); // Enable/Disable some widgets wxCommandEvent event; OnStyleSelection( event ); + OnNetSelectionUpdated( event ); Fit(); @@ -465,26 +452,28 @@ void DIALOG_COPPER_ZONE::OnNetSelectionUpdated( wxCommandEvent& event ) // correct selection updateDisplayedListOfNets(); - handleRemoveIslandsSelection(); + // Zones with no net never have islands removed + if( m_currentlySelectedNetcode == INVALID_NET_CODE ) + { + if( m_cbRemoveIslands->IsEnabled() ) + m_settings.SetIslandRemovalMode( (ISLAND_REMOVAL_MODE) m_cbRemoveIslands->GetSelection() ); + + m_cbRemoveIslands->SetSelection( 1 ); + m_staticText40->Enable( false ); + m_cbRemoveIslands->Enable( false ); + } + else if( !m_cbRemoveIslands->IsEnabled() ) + { + m_cbRemoveIslands->SetSelection( static_cast( m_settings.GetIslandRemovalMode() ) ); + m_staticText40->Enable( true ); + m_cbRemoveIslands->Enable( true ); + } } void DIALOG_COPPER_ZONE::OnRemoveIslandsSelection( wxCommandEvent& event ) { - handleRemoveIslandsSelection(); -} - - -void DIALOG_COPPER_ZONE::handleRemoveIslandsSelection() -{ - bool noNetSelected = m_currentlySelectedNetcode == INVALID_NET_CODE; - bool enableSize = !noNetSelected && ( m_cbRemoveIslands->GetSelection() == 2 ); - - // Zones with no net never have islands removed - m_cbRemoveIslands->Enable( !noNetSelected ); - m_islandThresholdLabel->Enable( enableSize ); - m_islandThresholdUnits->Enable( enableSize ); - m_tcIslandThreshold->Enable( enableSize ); + m_islandThreshold.Enable( m_cbRemoveIslands->GetSelection() == 2 ); } @@ -601,8 +590,7 @@ bool DIALOG_COPPER_ZONE::AcceptOptions( bool aUseExportableSetupOnly ) cfg->m_Zones.thermal_relief_gap = Iu2Mils( m_settings.m_ThermalReliefGap ); cfg->m_Zones.thermal_relief_copper_width = Iu2Mils( m_settings.m_ThermalReliefSpokeWidth ); - m_settings.SetIslandRemovalMode( - static_cast( m_cbRemoveIslands->GetSelection() ) ); + m_settings.SetIslandRemovalMode( (ISLAND_REMOVAL_MODE) m_cbRemoveIslands->GetSelection() ); m_settings.SetMinIslandArea( m_islandThreshold.GetValue() ); // If we use only exportable to others zones parameters, exit here: @@ -636,7 +624,7 @@ void DIALOG_COPPER_ZONE::updateCurrentNetSelection() { const int netSelection{ m_ListNetNameSelection->GetSelection() }; - if( netSelection ) + if( netSelection > 0 ) { const wxString& selectedNetName = m_ListNetNameSelection->GetString( netSelection ); m_currentlySelectedNetcode = m_netNameToNetCode[selectedNetName]; diff --git a/pcbnew/zone_settings.h b/pcbnew/zone_settings.h index 4d5c483abb..e990fdb9ba 100644 --- a/pcbnew/zone_settings.h +++ b/pcbnew/zone_settings.h @@ -53,9 +53,9 @@ enum class ZONE_BORDER_DISPLAY_STYLE }; /// Whether or not to remove isolated islands from a zone -enum class ISLAND_REMOVAL_MODE +enum ISLAND_REMOVAL_MODE { - ALWAYS, + ALWAYS = 0, NEVER, AREA };