diff --git a/pcbnew/tools/point_editor.cpp b/pcbnew/tools/point_editor.cpp index 117530eb4f..7501522652 100644 --- a/pcbnew/tools/point_editor.cpp +++ b/pcbnew/tools/point_editor.cpp @@ -629,21 +629,7 @@ void POINT_EDITOR::finishItem() auto zone = static_cast( item ); if( zone->IsFilled() && m_refill && zone->NeedRefill() ) - { - 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 6b43baf649..e7e4fc8a0e 100644 --- a/pcbnew/tools/zone_filler_tool.cpp +++ b/pcbnew/tools/zone_filler_tool.cpp @@ -62,21 +62,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(); @@ -96,12 +98,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 ) ) getEditFrame()->m_ZoneFillsDirty = false; diff --git a/pcbnew/zone_filler.cpp b/pcbnew/zone_filler.cpp index 4a92a301b4..6b123ca866 100644 --- a/pcbnew/zone_filler.cpp +++ b/pcbnew/zone_filler.cpp @@ -97,6 +97,13 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ) } +void ZONE_FILLER::SetProgressReporter( std::unique_ptr&& aReporter ) +{ + m_uniqueReporter = std::move( aReporter ); + m_progressReporter = m_uniqueReporter.get(); +} + + bool ZONE_FILLER::Fill( const std::vector& aZones, bool aCheck ) { std::vector toFill; diff --git a/pcbnew/zone_filler.h b/pcbnew/zone_filler.h index fed695fb4c..a4a58186b8 100644 --- a/pcbnew/zone_filler.h +++ b/pcbnew/zone_filler.h @@ -43,6 +43,7 @@ public: ~ZONE_FILLER(); void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter ); + void SetProgressReporter( std::unique_ptr&& aReporter ); bool Fill( const std::vector& aZones, bool aCheck = false ); private: @@ -107,6 +108,7 @@ private: // false if not (not closed outlines for instance) COMMIT* m_commit; WX_PROGRESS_REPORTER* m_progressReporter; + std::unique_ptr m_uniqueReporter; // m_high_def can be used to define a high definition arc to polygon approximation int m_high_def;