Move zone refill to action
This unifies the zone refill across architecture into the tool-based architecture. Also provides ZONE_FILLER-based progress managment for tools.
This commit is contained in:
parent
216acd98d6
commit
be9cd98cb1
|
@ -637,21 +637,7 @@ void POINT_EDITOR::finishItem()
|
|||
auto zone = static_cast<ZONE_CONTAINER*>( 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<PCB_BASE_FRAME>(), _( "Refill Zones" ), 4 );
|
||||
filler.SetProgressReporter( &reporter );
|
||||
#endif
|
||||
filler.Fill( { zone } );
|
||||
}
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<ZONE_CONTAINER*>() )
|
||||
{
|
||||
assert( item->Type() == PCB_ZONE_AREA_T );
|
||||
|
||||
ZONE_CONTAINER* zone = static_cast<ZONE_CONTAINER*> ( 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<ZONE_CONTAINER*>( item ) )
|
||||
toFill.push_back( zone );
|
||||
}
|
||||
}
|
||||
|
||||
std::unique_ptr<WX_PROGRESS_REPORTER> progressReporter(
|
||||
new WX_PROGRESS_REPORTER( frame(), _( "Fill Zone" ), 4 )
|
||||
);
|
||||
|
||||
ZONE_FILLER filler( board(), &commit );
|
||||
filler.SetProgressReporter( progressReporter.get() );
|
||||
filler.SetProgressReporter(
|
||||
std::make_unique<WX_PROGRESS_REPORTER>( 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<WX_PROGRESS_REPORTER> progressReporter(
|
||||
new WX_PROGRESS_REPORTER( frame(), _( "Fill All Zones" ), 4 )
|
||||
);
|
||||
|
||||
ZONE_FILLER filler( board(), &commit );
|
||||
filler.SetProgressReporter( progressReporter.get() );
|
||||
filler.SetProgressReporter(
|
||||
std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill All Zones" ), 4 ) );
|
||||
|
||||
if( filler.Fill( toFill ) )
|
||||
frame()->m_ZoneFillsDirty = false;
|
||||
|
|
|
@ -80,6 +80,14 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* aReporter )
|
|||
m_progressReporter = aReporter;
|
||||
}
|
||||
|
||||
|
||||
void ZONE_FILLER::SetProgressReporter( std::unique_ptr<WX_PROGRESS_REPORTER>&& aReporter )
|
||||
{
|
||||
m_uniqueReporter = std::move( aReporter );
|
||||
m_progressReporter = m_uniqueReporter.get();
|
||||
}
|
||||
|
||||
|
||||
bool ZONE_FILLER::Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck )
|
||||
{
|
||||
std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
|
||||
|
|
|
@ -42,6 +42,9 @@ public:
|
|||
~ZONE_FILLER();
|
||||
|
||||
void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter );
|
||||
|
||||
void SetProgressReporter( std::unique_ptr<WX_PROGRESS_REPORTER>&& aReporter );
|
||||
|
||||
bool Fill( std::vector<ZONE_CONTAINER*> aZones, bool aCheck = false );
|
||||
|
||||
private:
|
||||
|
@ -118,6 +121,7 @@ private:
|
|||
BOARD* m_board;
|
||||
COMMIT* m_commit;
|
||||
WX_PROGRESS_REPORTER* m_progressReporter;
|
||||
std::unique_ptr<WX_PROGRESS_REPORTER> m_uniqueReporter;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
Loading…
Reference in New Issue