Implement lock between zone filler and drc.

Fixes https://gitlab.com/kicad/code/kicad/issues/8621
This commit is contained in:
Jeff Young 2021-06-16 16:11:17 +01:00
parent aeb479b46f
commit c8444913df
3 changed files with 39 additions and 6 deletions

View File

@ -43,6 +43,7 @@
#include <dialogs/wx_html_report_box.h>
#include <dialogs/panel_setup_rules_base.h>
#include <tools/drc_tool.h>
#include <tools/zone_filler_tool.h>
#include <tools/board_inspection_tool.h>
#include <kiplatform/ui.h>
@ -196,10 +197,18 @@ void DIALOG_DRC::OnErrorLinkClicked( wxHtmlLinkEvent& event )
void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent )
{
DRC_TOOL* drcTool = m_frame->GetToolManager()->GetTool<DRC_TOOL>();
bool refillZones = m_cbRefillZones->GetValue();
bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
bool testFootprints = m_cbTestFootprints->GetValue();
TOOL_MANAGER* toolMgr = m_frame->GetToolManager();
DRC_TOOL* drcTool = toolMgr->GetTool<DRC_TOOL>();
ZONE_FILLER_TOOL* zoneFillerTool = toolMgr->GetTool<ZONE_FILLER_TOOL>();
bool refillZones = m_cbRefillZones->GetValue();
bool reportAllTrackErrors = m_cbReportAllTrackErrors->GetValue();
bool testFootprints = m_cbTestFootprints->GetValue();
if( zoneFillerTool->IsBusy() )
{
wxBell();
return;
}
// This is not the time to have stale or buggy rules. Ensure they're up-to-date
// and that they at least parse.

View File

@ -39,7 +39,8 @@
ZONE_FILLER_TOOL::ZONE_FILLER_TOOL() :
PCB_TOOL_BASE( "pcbnew.ZoneFiller" )
PCB_TOOL_BASE( "pcbnew.ZoneFiller" ),
m_fillInProgress( false )
{
}
@ -56,9 +57,11 @@ void ZONE_FILLER_TOOL::Reset( RESET_REASON aReason )
void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aReporter )
{
if( !getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty )
if( !getEditFrame<PCB_EDIT_FRAME>()->m_ZoneFillsDirty || m_fillInProgress )
return;
m_fillInProgress = true;
std::vector<ZONE*> toFill;
for( ZONE* zone : board()->Zones() )
@ -86,6 +89,7 @@ void ZONE_FILLER_TOOL::CheckAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRep
}
canvas()->Refresh();
m_fillInProgress = false;
}
@ -102,6 +106,11 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
BOARD_COMMIT commit( this );
std::vector<ZONE*> toFill;
if( m_fillInProgress )
return;
m_fillInProgress = true;
for( ZONE* zone : board()->Zones() )
toFill.push_back( zone );
@ -150,6 +159,7 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
frame->UpdateUserInterface();
canvas()->Refresh();
m_fillInProgress = false;
// wxWidgets has keyboard focus issues after the progress reporter. Re-setting the focus
// here doesn't work, so we delay it to an idle event.
@ -159,6 +169,14 @@ void ZONE_FILLER_TOOL::FillAllZones( wxWindow* aCaller, PROGRESS_REPORTER* aRepo
int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
{
if( m_fillInProgress )
{
wxBell();
return -1;
}
m_fillInProgress = true;
std::vector<ZONE*> toFill;
BOARD_COMMIT commit( this );
@ -187,6 +205,7 @@ int ZONE_FILLER_TOOL::ZoneFill( const TOOL_EVENT& aEvent )
commit.Revert();
canvas()->Refresh();
m_fillInProgress = false;
return 0;
}

View File

@ -55,12 +55,17 @@ public:
int ZoneUnfill( const TOOL_EVENT& aEvent );
int ZoneUnfillAll( const TOOL_EVENT& aEvent );
bool IsBusy() { return m_fillInProgress; }
private:
///< Refocus on an idle event (used after the Progress Reporter messes up the focus).
void singleShotRefocus( wxIdleEvent& );
///< Set up handlers for various events.
void setTransitions() override;
private:
bool m_fillInProgress;
};
#endif