Disable editing tools on the canvas when DRC is running

This commit is contained in:
Ian McInerney 2020-09-21 20:39:46 +01:00
parent 975e5562a0
commit d3dd1c45b6
3 changed files with 51 additions and 24 deletions

View File

@ -711,37 +711,51 @@ void PCB_EDIT_FRAME::setupUIConditions()
#define CURRENT_TOOL( action ) mgr->SetConditions( action, CHECK( cond.CurrentTool( action ) ) )
// These tools can be used at any time to inspect the board
CURRENT_TOOL( ACTIONS::zoomTool );
CURRENT_TOOL( ACTIONS::deleteTool );
CURRENT_TOOL( ACTIONS::measureTool );
CURRENT_TOOL( ACTIONS::selectionTool );
CURRENT_TOOL( PCB_ACTIONS::highlightNetTool );
CURRENT_TOOL( PCB_ACTIONS::localRatsnestTool );
CURRENT_TOOL( PCB_ACTIONS::placeModule );
CURRENT_TOOL( PCB_ACTIONS::routeSingleTrack);
CURRENT_TOOL( PCB_ACTIONS::drawVia );
CURRENT_TOOL( PCB_ACTIONS::drawZone );
CURRENT_TOOL( PCB_ACTIONS::drawZoneKeepout );
CURRENT_TOOL( PCB_ACTIONS::drawLine );
CURRENT_TOOL( PCB_ACTIONS::drawRectangle );
CURRENT_TOOL( PCB_ACTIONS::drawCircle );
CURRENT_TOOL( PCB_ACTIONS::drawArc );
CURRENT_TOOL( PCB_ACTIONS::drawPolygon );
CURRENT_TOOL( PCB_ACTIONS::placeText );
CURRENT_TOOL( PCB_ACTIONS::drawAlignedDimension );
CURRENT_TOOL( PCB_ACTIONS::drawCenterDimension );
CURRENT_TOOL( PCB_ACTIONS::drawLeader );
CURRENT_TOOL( PCB_ACTIONS::placeTarget );
CURRENT_TOOL( PCB_ACTIONS::drillOrigin );
CURRENT_TOOL( PCB_ACTIONS::gridSetOrigin );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateLine );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateGap );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateStub );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateStubArc );
CURRENT_TOOL( PCB_ACTIONS::microwaveCreateFunctionShape );
auto isDrcRunning =
[this] ( const SELECTION& )
{
DRC_TOOL* tool = m_toolManager->GetTool<DRC_TOOL>();
return !tool->IsDRCRunning();
};
#define CURRENT_EDIT_TOOL( action ) mgr->SetConditions( action, ACTION_CONDITIONS().Check( cond.CurrentTool( action ) ).Enable( isDrcRunning ) )
// These tools edit the board, so they must be disabled during some operations
CURRENT_EDIT_TOOL( ACTIONS::deleteTool );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeModule );
CURRENT_EDIT_TOOL( PCB_ACTIONS::routeSingleTrack);
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawVia );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawZone );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawZoneKeepout );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLine );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawRectangle );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCircle );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawArc );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawPolygon );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeText );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawAlignedDimension );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawCenterDimension );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drawLeader );
CURRENT_EDIT_TOOL( PCB_ACTIONS::placeTarget );
CURRENT_EDIT_TOOL( PCB_ACTIONS::drillOrigin );
CURRENT_EDIT_TOOL( PCB_ACTIONS::gridSetOrigin );
CURRENT_EDIT_TOOL( PCB_ACTIONS::microwaveCreateLine );
CURRENT_EDIT_TOOL( PCB_ACTIONS::microwaveCreateGap );
CURRENT_EDIT_TOOL( PCB_ACTIONS::microwaveCreateStub );
CURRENT_EDIT_TOOL( PCB_ACTIONS::microwaveCreateStubArc );
CURRENT_EDIT_TOOL( PCB_ACTIONS::microwaveCreateFunctionShape );
#undef CURRENT_TOOL
#undef CURRENT_EDIT_TOOL
#undef ENABLE
#undef CHECK
}

View File

@ -42,7 +42,8 @@ DRC_TOOL::DRC_TOOL() :
PCB_TOOL_BASE( "pcbnew.DRCTool" ),
m_editFrame( nullptr ),
m_pcb( nullptr ),
m_drcDialog( nullptr )
m_drcDialog( nullptr ),
m_drcRunning( false )
{
}
@ -154,6 +155,8 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA
return;
}
m_drcRunning = true;
if( aRefillZones )
{
aProgressReporter->AdvancePhase( _( "Refilling all zones..." ) );
@ -218,6 +221,8 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA
commit.Push( _( "DRC" ), false );
m_drcRunning = false;
// update the m_drcDialog listboxes
updatePointers();
}

View File

@ -55,6 +55,7 @@ private:
PCB_EDIT_FRAME* m_editFrame; // The pcb frame editor which owns the board
BOARD* m_pcb;
DIALOG_DRC* m_drcDialog;
bool m_drcRunning;
std::shared_ptr<DRC_ENGINE> m_drcEngine;
@ -97,6 +98,13 @@ public:
*/
bool IsDRCDialogShown();
/**
* Check to see if the DRC engine is running the tests
*
* @return true if the DRC engine is running the tests
*/
bool IsDRCRunning() const { return m_drcRunning; }
/**
* Closes and frees the DRC dialog.
*/