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 );
|
auto zone = static_cast<ZONE_CONTAINER*>( item );
|
||||||
|
|
||||||
if( zone->IsFilled() && m_refill && zone->NeedRefill() )
|
if( zone->IsFilled() && m_refill && zone->NeedRefill() )
|
||||||
{
|
m_toolMgr->RunAction( PCB_ACTIONS::zoneFill, true, zone );
|
||||||
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 } );
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,21 +62,23 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
|
||||||
|
|
||||||
BOARD_COMMIT commit( this );
|
BOARD_COMMIT commit( this );
|
||||||
|
|
||||||
|
if( auto passedZone = aEvent.Parameter<ZONE_CONTAINER*>() )
|
||||||
|
{
|
||||||
|
if( passedZone->Type() == PCB_ZONE_AREA_T )
|
||||||
|
toFill.push_back( passedZone );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
for( auto item : selection() )
|
for( auto item : selection() )
|
||||||
{
|
{
|
||||||
assert( item->Type() == PCB_ZONE_AREA_T );
|
if( auto zone = dyn_cast<ZONE_CONTAINER*>( item ) )
|
||||||
|
toFill.push_back( zone );
|
||||||
ZONE_CONTAINER* zone = static_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 );
|
ZONE_FILLER filler( board(), &commit );
|
||||||
filler.SetProgressReporter( progressReporter.get() );
|
filler.SetProgressReporter(
|
||||||
|
std::make_unique<WX_PROGRESS_REPORTER>( frame(), _( "Fill Zone" ), 4 ) );
|
||||||
filler.Fill( toFill );
|
filler.Fill( toFill );
|
||||||
|
|
||||||
canvas()->Refresh();
|
canvas()->Refresh();
|
||||||
|
@ -96,12 +98,9 @@ int ZONE_FILLER_TOOL::ZoneFillAll( const TOOL_EVENT& aEvent )
|
||||||
toFill.push_back(zone);
|
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 );
|
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 ) )
|
if( filler.Fill( toFill ) )
|
||||||
getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty = false;
|
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 )
|
bool ZONE_FILLER::Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck )
|
||||||
{
|
{
|
||||||
std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
|
std::vector<CN_ZONE_ISOLATED_ISLAND_LIST> toFill;
|
||||||
|
|
|
@ -43,6 +43,7 @@ public:
|
||||||
~ZONE_FILLER();
|
~ZONE_FILLER();
|
||||||
|
|
||||||
void SetProgressReporter( WX_PROGRESS_REPORTER* aReporter );
|
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 );
|
bool Fill( const std::vector<ZONE_CONTAINER*>& aZones, bool aCheck = false );
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -107,6 +108,7 @@ private:
|
||||||
// false if not (not closed outlines for instance)
|
// false if not (not closed outlines for instance)
|
||||||
COMMIT* m_commit;
|
COMMIT* m_commit;
|
||||||
WX_PROGRESS_REPORTER* m_progressReporter;
|
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
|
// m_high_def can be used to define a high definition arc to polygon approximation
|
||||||
int m_high_def;
|
int m_high_def;
|
||||||
|
|
Loading…
Reference in New Issue