diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 2b06c4a4e7..2da09d751c 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -637,21 +637,7 @@ void POINT_EDITOR::finishItem() auto zone = static_cast( item ); if( zone->IsFilled() && m_refill ) - { - ZONE_FILLER filler( board() ); - // A progress reporter can be usefull. However it works fine only on Windows - // so enable it only on Windows. - // On Linux, the filled areas are incorrectly shown: the insulated islands - // remain displayed, although they are removed from the actual filled areas list - // - // Fix me: try to make it working on Linux. - // - #ifdef __WINDOWS__ - WX_PROGRESS_REPORTER reporter( getEditFrame(), _( "Refill Zones" ), 4 ); - filler.SetProgressReporter( &reporter ); - #endif - filler.Fill( { zone } ); - } + m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone ); } } diff --git a/pcbnew/tools/zone_filler_tool.cpp b/pcbnew/tools/zone_filler_tool.cpp index ea208606ed..f50dec5863 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -84,21 +84,23 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent ) BOARD_COMMIT commit( this ); - for( auto item : selection() ) + if( auto passedZone = aEvent.Parameter() ) { - assert( item->Type() == PCB_ZONE_AREA_T ); - - ZONE_CONTAINER* zone = static_cast ( item ); - - toFill.push_back(zone); + if( passedZone->Type() == PCB_ZONE_AREA_T ) + toFill.push_back( passedZone ); + } + else + { + for( auto item : selection() ) + { + if( auto zone = dyn_cast( item ) ) + toFill.push_back( zone ); + } } - std::unique_ptr progressReporter( - new WX_PROGRESS_REPORTER( frame(), _( "Fill Zone" ), 4 ) - ); - ZONE_FILLER filler( board(), &commit ); - filler.SetProgressReporter( progressReporter.get() ); + filler.SetProgressReporter( + std::make_unique( frame(), _( "Fill Zone" ), 4 ) ); filler.Fill( toFill ); canvas()->Refresh(); @@ -118,12 +120,9 @@ int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent ) toFill.push_back(zone); } - std::unique_ptr progressReporter( - new WX_PROGRESS_REPORTER( frame(), _( "Fill All Zones" ), 4 ) - ); - ZONE_FILLER filler( board(), &commit ); - filler.SetProgressReporter( progressReporter.get() ); + filler.SetProgressReporter( + std::make_unique( frame(), _( "Fill All Zones" ), 4 ) ); if( filler.Fill( toFill ) ) frame()->m_ZoneFillsDirty = false; diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index aabcbc7bd4..63876219fa 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -80,6 +80,14 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ) m_progressReporter = aReporter; } + +void ZONE_FILLER::SetProgressReporter( std::unique_ptr&& aReporter ) +{ + m_uniqueReporter = std::move( aReporter ); + m_progressReporter = m_uniqueReporter.get(); +} + + bool ZONE_FILLER::Fill( std::vector aZones, bool aCheck ) { std::vector toFill; diff --git a/pcbnew/zone_filler.h b/pcbnew/zone_filler.h index 19c7efdea7..65c74ef600 100644 --- a/pcbnew/zone_filler.h +++ b/pcbnew/zone_filler.h @@ -42,6 +42,9 @@ public: ~ZONE_FILLER(); void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ); + + void SetProgressReporter( std::unique_ptr&& aReporter ); + bool Fill( std::vector aZones, bool aCheck = false ); private: @@ -118,6 +121,7 @@ private: BOARD* m_board; COMMIT* m_commit; WX_PROGRESS_REPORTER* m_progressReporter; + std::unique_ptr m_uniqueReporter; }; #endif