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.
(cherry picked from commit be9cd98cb1
)
This commit is contained in:
parent
5ed8ba5bf3
commit
743c650129
|
@ -629,21 +629,7 @@ void POINT_EDITOR::finishItem()
|
|||
auto zone = static_cast<ZONE_CONTAINER*>( 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<PCB_BASE_FRAME>(), _( "Refill Zones" ), 4 );
|
||||
filler.SetProgressReporter( &reporter );
|
||||
#endif
|
||||
filler.Fill( { zone } );
|
||||
}
|
||||
m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<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();
|
||||
|
@ -96,12 +98,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 ) )
|
||||
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
||||
|
|
|
@ -97,6 +97,13 @@ void ZONE_FILLER::SetProgressReporter( WX_PROGRESS_REPORTER* 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( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck )
|
||||
{
|
||||
std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
~ZONE_FILLER();
|
||||
|
||||
void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter );
|
||||
void SetProgressReporter( std::unique_ptr<WX_PROGRESS_REPORTER>&& aReporter );
|
||||
bool Fill( const std::vector<ZONE_CONTAINER*>& 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<WX_PROGRESS_REPORTER> m_uniqueReporter;
|
||||
|
||||
// m_high_def can be used to define a high definition arc to polygon approximation
|
||||
int m_high_def;
|
||||
|
|
Loading…
Reference in New Issue