From b6bd74d8221fcdc1052c19689ee9abc1e1074abe Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Tue, 29 Nov 2022 17:22:25 +0000 Subject: [PATCH] Replace single zone fill under "draft" terminology. Also sets Autofill Zones to default to on. --- pcbnew/pcb_edit_frame.cpp | 2 + pcbnew/pcbnew_settings.cpp | 2 +- pcbnew/tools/board_editor_control.cpp | 10 ++-- pcbnew/tools/pcb_actions.cpp | 11 ++++ pcbnew/tools/pcb_actions.h | 2 + pcbnew/tools/zone_filler_tool.cpp | 83 ++++++++++++++++++++++++++- pcbnew/tools/zone_filler_tool.h | 2 + 7 files changed, 104 insertions(+), 8 deletions(-) diff --git a/pcbnew/pcb_edit_frame.cpp b/pcbnew/pcb_edit_frame.cpp index a420f67775..ea4387bee9 100644 --- a/pcbnew/pcb_edit_frame.cpp +++ b/pcbnew/pcb_edit_frame.cpp @@ -882,6 +882,8 @@ void PCB_EDIT_FRAME::setupUIConditions() mgr->SetConditions( PCB_ACTIONS::drawZoneCutout, ENABLE( singleZoneCond ) ); mgr->SetConditions( PCB_ACTIONS::drawSimilarZone, ENABLE( singleZoneCond ) ); mgr->SetConditions( PCB_ACTIONS::zoneMerge, ENABLE( zoneMergeCond ) ); + mgr->SetConditions( PCB_ACTIONS::zoneFill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); + mgr->SetConditions( PCB_ACTIONS::zoneUnfill, ENABLE( SELECTION_CONDITIONS::MoreThan( 0 ) ) ); mgr->SetConditions( PCB_ACTIONS::toggleHV45Mode, CHECK( cond.Get45degMode() ) ); diff --git a/pcbnew/pcbnew_settings.cpp b/pcbnew/pcbnew_settings.cpp index c06373fa8f..4a0a5c5370 100644 --- a/pcbnew/pcbnew_settings.cpp +++ b/pcbnew/pcbnew_settings.cpp @@ -160,7 +160,7 @@ PCBNEW_SETTINGS::PCBNEW_SETTINGS() &m_Use45DegreeLimit, false ) ); m_params.emplace_back( new PARAM( "editing.auto_fill_zones", - &m_AutoRefillZones, false ) ); + &m_AutoRefillZones, true ) ); m_params.emplace_back( new PARAM( "editing.allow_free_pads", &m_AllowFreePads, false ) ); diff --git a/pcbnew/tools/board_editor_control.cpp b/pcbnew/tools/board_editor_control.cpp index d8e80fa779..f43acd9c43 100644 --- a/pcbnew/tools/board_editor_control.cpp +++ b/pcbnew/tools/board_editor_control.cpp @@ -85,7 +85,9 @@ public: SetIcon( BITMAPS::add_zone ); SetTitle( _( "Zones" ) ); + Add( PCB_ACTIONS::zoneFill ); Add( PCB_ACTIONS::zoneFillAll ); + Add( PCB_ACTIONS::zoneUnfill ); Add( PCB_ACTIONS::zoneUnfillAll ); AppendSeparator(); @@ -188,10 +190,10 @@ bool BOARD_EDITOR_CONTROL::Init() // Finally, add the standard zoom & grid items getEditFrame()->AddStandardSubMenus( m_menu ); - auto zoneMenu = std::make_shared(); + std::shared_ptr zoneMenu = std::make_shared(); zoneMenu->SetTool( this ); - auto lockMenu = std::make_shared(); + std::shared_ptr lockMenu = std::make_shared(); lockMenu->SetTool( this ); // Add the PCB control menus to relevant other tools @@ -212,7 +214,7 @@ bool BOARD_EDITOR_CONTROL::Init() menu.AddMenu( lockMenu.get(), SELECTION_CONDITIONS::NotEmpty, 100 ); - menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 200 ); + menu.AddMenu( zoneMenu.get(), SELECTION_CONDITIONS::OnlyTypes( { PCB_ZONE_T } ), 100 ); } DRAWING_TOOL* drawingTool = m_toolMgr->GetTool(); @@ -235,7 +237,7 @@ bool BOARD_EDITOR_CONTROL::Init() }; }; - menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 200 ); + menu.AddMenu( zoneMenu.get(), toolActiveFunctor( DRAWING_TOOL::MODE::ZONE ), 300 ); } return true; diff --git a/pcbnew/tools/pcb_actions.cpp b/pcbnew/tools/pcb_actions.cpp index d00945fea4..78cf801183 100644 --- a/pcbnew/tools/pcb_actions.cpp +++ b/pcbnew/tools/pcb_actions.cpp @@ -1369,6 +1369,12 @@ TOOL_ACTION PCB_ACTIONS::filterSelection( "pcbnew.InteractiveSelection.FilterSel // ZONE_FILLER_TOOL // +TOOL_ACTION PCB_ACTIONS::zoneFill( "pcbnew.ZoneFiller.zoneFill", + AS_GLOBAL, 0, "", + _( "Draft Fill Selected Zone(s)" ), + _( "Update copper fill of selected zone(s) without regard to other interacting zones" ), + BITMAPS::fill_zone ); + TOOL_ACTION PCB_ACTIONS::zoneFillAll( "pcbnew.ZoneFiller.zoneFillAll", AS_GLOBAL, 'B', LEGACY_HK_NAME( "Fill or Refill All Zones" ), @@ -1378,6 +1384,11 @@ TOOL_ACTION PCB_ACTIONS::zoneFillAll( "pcbnew.ZoneFiller.zoneFillAll", TOOL_ACTION PCB_ACTIONS::zoneFillDirty( "pcbnew.ZoneFiller.zoneFillDirty", AS_CONTEXT ); +TOOL_ACTION PCB_ACTIONS::zoneUnfill( "pcbnew.ZoneFiller.zoneUnfill", + AS_GLOBAL, 0, "", + _( "Unfill Selected Zone(s)" ), _( "Remove copper fill from selected zone(s)" ), + BITMAPS::zone_unfill ); + TOOL_ACTION PCB_ACTIONS::zoneUnfillAll( "pcbnew.ZoneFiller.zoneUnfillAll", AS_GLOBAL, MD_CTRL + 'B', LEGACY_HK_NAME( "Remove Filled Areas in All Zones" ), diff --git a/pcbnew/tools/pcb_actions.h b/pcbnew/tools/pcb_actions.h index b1fed46b95..47fe2038e3 100644 --- a/pcbnew/tools/pcb_actions.h +++ b/pcbnew/tools/pcb_actions.h @@ -336,8 +336,10 @@ public: static TOOL_ACTION assignNetClass; // Zone actions + static TOOL_ACTION zoneFill; static TOOL_ACTION zoneFillAll; static TOOL_ACTION zoneFillDirty; + static TOOL_ACTION zoneUnfill; static TOOL_ACTION zoneUnfillAll; static TOOL_ACTION zoneMerge; diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index acbe692b05..6cc5692070 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -276,6 +276,58 @@ int ZONE_FILLER_TOOL::ZoneFillDirty( const TOOL_EVENT& aEvent ) } +int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent ) +{ + if( m_fillInProgress ) + { + wxBell(); + return -1; + } + + m_fillInProgress = true; + + std::vector toFill; + + if( ZONE* passedZone = aEvent.Parameter() ) + { + toFill.push_back( passedZone ); + } + else + { + for( EDA_ITEM* item : selection() ) + { + if( ZONE* zone = dynamic_cast( item ) ) + toFill.push_back( zone ); + } + } + + BOARD_COMMIT commit( this ); + std::unique_ptr reporter; + ZONE_FILLER filler( board(), &commit ); + + reporter = std::make_unique( frame(), _( "Fill Zone" ), 5 ); + filler.SetProgressReporter( reporter.get() ); + + if( filler.Fill( toFill ) ) + { + reporter->AdvancePhase(); + commit.Push( _( "Fill Zone(s)" ), SKIP_CONNECTIVITY | ZONE_FILL_OP ); + } + else + { + commit.Revert(); + } + + board()->BuildConnectivity( reporter.get() ); + m_toolMgr->PostEvent( EVENTS::ConnectivityChangedEvent ); + + refresh(); + + m_fillInProgress = false; + return 0; +} + + int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent ) { FillAllZones( frame() ); @@ -283,6 +335,29 @@ int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent ) } +int ZONE_FILLER_TOOL::ZoneUnfill( const TOOL_EVENT& aEvent ) +{ + BOARD_COMMIT commit( this ); + + for( EDA_ITEM* item : selection() ) + { + assert( item->Type() == PCB_ZONE_T || item->Type() == PCB_FP_ZONE_T ); + + ZONE* zone = static_cast( item ); + + commit.Modify( zone ); + + zone->UnFill(); + } + + commit.Push( _( "Unfill Zone" ), ZONE_FILL_OP ); + + refresh(); + + return 0; +} + + int ZONE_FILLER_TOOL::ZoneUnfillAll( const TOOL_EVENT& aEvent ) { BOARD_COMMIT commit( this ); @@ -334,7 +409,9 @@ bool ZONE_FILLER_TOOL::IsZoneFillAction( const TOOL_EVENT* aEvent ) void ZONE_FILLER_TOOL::setTransitions() { // Zone actions - Go( &ZONE_FILLER_TOOL::ZoneFillAll, PCB_ACTIONS::zoneFillAll.MakeEvent() ); - Go( &ZONE_FILLER_TOOL::ZoneFillDirty, PCB_ACTIONS::zoneFillDirty.MakeEvent() ); - Go( &ZONE_FILLER_TOOL::ZoneUnfillAll, PCB_ACTIONS::zoneUnfillAll.MakeEvent() ); + Go( &ZONE_FILLER_TOOL::ZoneFill, PCB_ACTIONS::zoneFill.MakeEvent() ); + Go( &ZONE_FILLER_TOOL::ZoneFillAll, PCB_ACTIONS::zoneFillAll.MakeEvent() ); + Go( &ZONE_FILLER_TOOL::ZoneFillDirty, PCB_ACTIONS::zoneFillDirty.MakeEvent() ); + Go( &ZONE_FILLER_TOOL::ZoneUnfill, PCB_ACTIONS::zoneUnfill.MakeEvent() ); + Go( &ZONE_FILLER_TOOL::ZoneUnfillAll, PCB_ACTIONS::zoneUnfillAll.MakeEvent() ); } diff --git a/pcbnew/tools/zone_filler_tool.h b/pcbnew/tools/zone_filler_tool.h index 4e33263cc0..fc73244892 100644 --- a/pcbnew/tools/zone_filler_tool.h +++ b/pcbnew/tools/zone_filler_tool.h @@ -51,8 +51,10 @@ public: void CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aReporter = nullptr ); void FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aReporter = nullptr ); + int ZoneFill( const TOOL_EVENT& aEvent ); int ZoneFillAll( const TOOL_EVENT& aEvent ); int ZoneFillDirty( const TOOL_EVENT& aEvent ); + int ZoneUnfill( const TOOL_EVENT& aEvent ); int ZoneUnfillAll( const TOOL_EVENT& aEvent ); bool IsBusy() { return m_fillInProgress; }