From 67b5d24995367eb346d1aa7beb1f93753e9d7111 Mon Sep 17 00:00:00 2001 From: Jeff Young Date: Fri, 18 Sep 2020 20:57:54 +0100 Subject: [PATCH] Support ESC & Cancel for DRC. Fixes https://gitlab.com/kicad/code/kicad/issues/5698 --- pcbnew/dialogs/dialog_drc.cpp | 55 ++++++++++++++----- pcbnew/dialogs/dialog_drc.h | 10 +++- pcbnew/dialogs/dialog_drc_base.cpp | 2 + pcbnew/dialogs/dialog_drc_base.fbp | 1 + pcbnew/dialogs/dialog_drc_base.h | 1 + pcbnew/drc/drc_engine.cpp | 14 +++-- pcbnew/drc/drc_engine.h | 4 +- pcbnew/drc/drc_test_provider.cpp | 14 +++-- pcbnew/drc/drc_test_provider.h | 4 +- pcbnew/drc/drc_test_provider_annulus.cpp | 9 ++- pcbnew/drc/drc_test_provider_connectivity.cpp | 9 ++- .../drc_test_provider_copper_clearance.cpp | 32 +++++++---- .../drc_test_provider_courtyard_clearance.cpp | 18 +++--- pcbnew/drc/drc_test_provider_disallow.cpp | 3 +- .../drc/drc_test_provider_edge_clearance.cpp | 3 +- .../drc/drc_test_provider_hole_clearance.cpp | 16 ++++-- pcbnew/drc/drc_test_provider_hole_size.cpp | 6 +- pcbnew/drc/drc_test_provider_lvs.cpp | 3 +- pcbnew/drc/drc_test_provider_misc.cpp | 12 +++- pcbnew/drc/drc_test_provider_track_width.cpp | 9 ++- pcbnew/drc/drc_test_provider_via_diameter.cpp | 9 ++- pcbnew/tools/drc_tool.cpp | 2 - .../drc_test_provider_silk_to_pad.cpp | 4 +- 23 files changed, 155 insertions(+), 85 deletions(-) diff --git a/pcbnew/dialogs/dialog_drc.cpp b/pcbnew/dialogs/dialog_drc.cpp index 28dcb6b93a..0ebdf655f9 100644 --- a/pcbnew/dialogs/dialog_drc.cpp +++ b/pcbnew/dialogs/dialog_drc.cpp @@ -41,11 +41,13 @@ #include #include #include - +#include DIALOG_DRC::DIALOG_DRC( PCB_EDIT_FRAME* aEditorFrame, wxWindow* aParent ) : DIALOG_DRC_BASE( aParent ), PROGRESS_REPORTER( 1 ), + m_running( false ), + m_cancelled( false ), m_drcRun( false ), m_footprintTestsRun( false ), m_markersProvider( nullptr ), @@ -160,8 +162,9 @@ bool DIALOG_DRC::updateUI() int cur = std::max( 0, std::min( m_progress.load(), 10000 ) ); m_gauge->SetValue( cur ); + wxSafeYield( this ); - return true; // No cancel button on a wxGauge + return !m_cancelled; } @@ -170,18 +173,12 @@ void DIALOG_DRC::AdvancePhase( const wxString& aMessage ) PROGRESS_REPORTER::AdvancePhase( aMessage ); m_Messages->AppendText( aMessage + "\n" ); - - KeepRefreshing( false ); - wxSafeYield( this ); } void DIALOG_DRC::SetCurrentProgress( double aProgress ) { PROGRESS_REPORTER::SetCurrentProgress( aProgress ); - - KeepRefreshing( false ); - wxSafeYield( this ); } @@ -208,6 +205,7 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent ) m_drcRun = false; m_footprintTestsRun = false; + m_cancelled = false; m_brdEditor->RecordDRCExclusions(); deleteAllMarkers( true ); @@ -218,19 +216,33 @@ void DIALOG_DRC::OnRunDRCClick( wxCommandEvent& aEvent ) m_runningResultsBook->ChangeSelection( 0 ); // Display the "Tests Running..." tab m_Messages->Clear(); - wxYield(); // Allows time slice to refresh Messages + wxYield(); // Allow time slice to refresh Messages + + m_running = true; + m_sdbSizer1Cancel->SetLabel( _( "Cancel" ) ); drcTool->RunTests( this, testTracksAgainstZones, refillZones, reportAllTrackErrors, testFootprints ); - refreshBoardEditor(); + if( m_cancelled ) + m_Messages->AppendText( _( "-------- DRC cancelled by user.\n\n" ) ); + else + m_Messages->AppendText( _( "Done.\n\n" ) ); - wxYield(); Raise(); + wxYield(); // Allow time slice to refresh Messages - m_runningResultsBook->ChangeSelection( 1 ); // display the results tabs + m_sdbSizer1Cancel->SetLabel( _( "Close" ) ); + m_running = false; - m_Notebook->GetPage( m_Notebook->GetSelection() )->SetFocus(); + if( !m_cancelled ) + { + wxMilliSleep( 500 ); + m_runningResultsBook->ChangeSelection( 1 ); + KIPLATFORM::UI::ForceFocus( m_markerDataView ); + } + + refreshBoardEditor(); } @@ -551,8 +563,25 @@ void DIALOG_DRC::OnSaveReport( wxCommandEvent& aEvent ) } +void DIALOG_DRC::OnClose( wxCloseEvent& aEvent ) +{ + if( m_running ) + aEvent.Veto(); + + wxCommandEvent dummy; + + OnCancelClick( dummy ); +} + + void DIALOG_DRC::OnCancelClick( wxCommandEvent& aEvent ) { + if( m_running ) + { + m_cancelled = true; + return; + } + m_brdEditor->FocusOnItem( nullptr ); SetReturnCode( wxID_CANCEL ); diff --git a/pcbnew/dialogs/dialog_drc.h b/pcbnew/dialogs/dialog_drc.h index 24c085117d..f6df90373c 100644 --- a/pcbnew/dialogs/dialog_drc.h +++ b/pcbnew/dialogs/dialog_drc.h @@ -81,10 +81,12 @@ private: void OnDeleteOneClick( wxCommandEvent& aEvent ) override; void OnDeleteAllClick( wxCommandEvent& aEvent ) override; void OnRunDRCClick( wxCommandEvent& aEvent ) override; - void OnCancelClick( wxCommandEvent& aEvent ) override; - /// handler for activate event, updating data which can be modified outside the dialog - /// (DRC parameters) + // These require special handling while the DRC tests are running. + void OnCancelClick( wxCommandEvent& aEvent ) override; + void OnClose( wxCloseEvent& event ) override; + + // Updates data which can be modified outside the dialog void OnActivateDlg( wxActivateEvent& aEvent ) override; void OnChangingNotebookPage( wxNotebookEvent& aEvent ) override; @@ -101,6 +103,8 @@ private: BOARD* m_currentBoard; // the board currently on test PCB_EDIT_FRAME* m_brdEditor; + bool m_running; + std::atomic m_cancelled; bool m_drcRun; bool m_footprintTestsRun; diff --git a/pcbnew/dialogs/dialog_drc_base.cpp b/pcbnew/dialogs/dialog_drc_base.cpp index 41e300bf75..108f6172b8 100644 --- a/pcbnew/dialogs/dialog_drc_base.cpp +++ b/pcbnew/dialogs/dialog_drc_base.cpp @@ -221,6 +221,7 @@ DIALOG_DRC_BASE::DIALOG_DRC_BASE( wxWindow* parent, wxWindowID id, const wxStrin // Connect Events this->Connect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) ); + this->Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) ); m_Notebook->Connect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this ); m_markerDataView->Connect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this ); @@ -244,6 +245,7 @@ DIALOG_DRC_BASE::~DIALOG_DRC_BASE() { // Disconnect Events this->Disconnect( wxEVT_ACTIVATE, wxActivateEventHandler( DIALOG_DRC_BASE::OnActivateDlg ) ); + this->Disconnect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler( DIALOG_DRC_BASE::OnClose ) ); m_Notebook->Disconnect( wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, wxNotebookEventHandler( DIALOG_DRC_BASE::OnChangingNotebookPage ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_ACTIVATED, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemDClick ), NULL, this ); m_markerDataView->Disconnect( wxEVT_COMMAND_DATAVIEW_ITEM_CONTEXT_MENU, wxDataViewEventHandler( DIALOG_DRC_BASE::OnDRCItemRClick ), NULL, this ); diff --git a/pcbnew/dialogs/dialog_drc_base.fbp b/pcbnew/dialogs/dialog_drc_base.fbp index 9b1aa579a5..9fd1b78a36 100644 --- a/pcbnew/dialogs/dialog_drc_base.fbp +++ b/pcbnew/dialogs/dialog_drc_base.fbp @@ -54,6 +54,7 @@ OnActivateDlg + OnClose m_MainSizer diff --git a/pcbnew/dialogs/dialog_drc_base.h b/pcbnew/dialogs/dialog_drc_base.h index f9becdc00b..577b83fed2 100644 --- a/pcbnew/dialogs/dialog_drc_base.h +++ b/pcbnew/dialogs/dialog_drc_base.h @@ -82,6 +82,7 @@ class DIALOG_DRC_BASE : public DIALOG_SHIM // Virtual event handlers, overide them in your derived class virtual void OnActivateDlg( wxActivateEvent& event ) { event.Skip(); } + virtual void OnClose( wxCloseEvent& event ) { event.Skip(); } virtual void OnChangingNotebookPage( wxNotebookEvent& event ) { event.Skip(); } virtual void OnDRCItemDClick( wxDataViewEvent& event ) { event.Skip(); } virtual void OnDRCItemRClick( wxDataViewEvent& event ) { event.Skip(); } diff --git a/pcbnew/drc/drc_engine.cpp b/pcbnew/drc/drc_engine.cpp index 6f952cd179..c1960840b6 100644 --- a/pcbnew/drc/drc_engine.cpp +++ b/pcbnew/drc/drc_engine.cpp @@ -421,7 +421,9 @@ void DRC_ENGINE::RunTests( EDA_UNITS aUnits, bool aTestTracksAgainstZones, drc_dbg( 0, "Running test provider: '%s'\n", provider->GetName() ); ReportAux( wxString::Format( "Run DRC provider: '%s'", provider->GetName() ) ); - provider->Run(); + + if( !provider->Run() ) + break; } } @@ -646,21 +648,23 @@ void DRC_ENGINE::ReportAux ( const wxString& aStr ) } -void DRC_ENGINE::ReportProgress( double aProgress ) +bool DRC_ENGINE::ReportProgress( double aProgress ) { if( !m_progressReporter ) - return; + return true; m_progressReporter->SetCurrentProgress( aProgress ); + return m_progressReporter->KeepRefreshing( false ); } -void DRC_ENGINE::ReportPhase( const wxString& aMessage ) +bool DRC_ENGINE::ReportPhase( const wxString& aMessage ) { if( !m_progressReporter ) - return; + return true; m_progressReporter->AdvancePhase( aMessage ); + return m_progressReporter->KeepRefreshing( false ); } diff --git a/pcbnew/drc/drc_engine.h b/pcbnew/drc/drc_engine.h index 21be547edc..8a4595d1fa 100644 --- a/pcbnew/drc/drc_engine.h +++ b/pcbnew/drc/drc_engine.h @@ -157,8 +157,8 @@ public: bool CompileRules(); void ReportViolation( const std::shared_ptr& aItem, wxPoint aPos ); - void ReportProgress( double aProgress ); - void ReportPhase( const wxString& aMessage ); + bool ReportProgress( double aProgress ); + bool ReportPhase( const wxString& aMessage ); void ReportAux( const wxString& aStr ); bool QueryWorstConstraint( DRC_CONSTRAINT_TYPE_T aRuleId, DRC_CONSTRAINT& aConstraint, diff --git a/pcbnew/drc/drc_test_provider.cpp b/pcbnew/drc/drc_test_provider.cpp index 369bb1bea0..9800d498d0 100644 --- a/pcbnew/drc/drc_test_provider.cpp +++ b/pcbnew/drc/drc_test_provider.cpp @@ -46,16 +46,22 @@ void DRC_TEST_PROVIDER::reportViolation( std::shared_ptr& item, wxPoin } -void DRC_TEST_PROVIDER::reportProgress( double aProgress ) +bool DRC_TEST_PROVIDER::reportProgress( int aCount, int aSize, int aDelta ) { - m_drcEngine->ReportProgress( aProgress ); + if( ( aCount % aDelta ) == 0 || aCount == aSize - 1 ) + { + if( !m_drcEngine->ReportProgress( (double) aCount / (double) aSize ) ) + return false; + } + + return true; } -void DRC_TEST_PROVIDER::reportPhase( const wxString& aMessage ) +bool DRC_TEST_PROVIDER::reportPhase( const wxString& aMessage ) { - m_drcEngine->ReportPhase( aMessage ); reportAux( aMessage ); + return m_drcEngine->ReportPhase( aMessage ); } diff --git a/pcbnew/drc/drc_test_provider.h b/pcbnew/drc/drc_test_provider.h index 241009e334..2685ac1a7e 100644 --- a/pcbnew/drc/drc_test_provider.h +++ b/pcbnew/drc/drc_test_provider.h @@ -103,8 +103,8 @@ protected: virtual void reportAux( wxString fmt, ... ); virtual void reportViolation( std::shared_ptr& item, wxPoint aMarkerPos ); - virtual void reportProgress( double aProgress ); - virtual void reportPhase( const wxString& aStageName ); + virtual bool reportProgress( int aCount, int aSize, int aDelta ); + virtual bool reportPhase( const wxString& aStageName ); virtual void reportRuleStatistics(); virtual void accountCheck( const DRC_RULE* ruleToTest ); diff --git a/pcbnew/drc/drc_test_provider_annulus.cpp b/pcbnew/drc/drc_test_provider_annulus.cpp index eeea45cf27..f441628d77 100644 --- a/pcbnew/drc/drc_test_provider_annulus.cpp +++ b/pcbnew/drc/drc_test_provider_annulus.cpp @@ -76,7 +76,8 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run() return false; } - reportPhase( _( "Checking via annular rings..." )); + if( !reportPhase( _( "Checking via annular rings..." ) ) ) + return false; auto checkAnnulus = [&]( BOARD_ITEM* item ) -> bool @@ -137,10 +138,8 @@ bool DRC_TEST_PROVIDER_ANNULUS::Run() for( TRACK* item : board->Tracks() ) { - if( (ii % delta) == 0 || ii >= (int) board->Tracks().size() - 1 ) - reportProgress( (double) ii / (double) board->Tracks().size() ); - - ii++; + if( !reportProgress( ii++, board->Tracks().size(), delta ) ) + break; if( !checkAnnulus( item ) ) break; diff --git a/pcbnew/drc/drc_test_provider_connectivity.cpp b/pcbnew/drc/drc_test_provider_connectivity.cpp index 5dd9bc7e0e..aa73c82665 100644 --- a/pcbnew/drc/drc_test_provider_connectivity.cpp +++ b/pcbnew/drc/drc_test_provider_connectivity.cpp @@ -72,7 +72,8 @@ public: bool DRC_TEST_PROVIDER_CONNECTIVITY::Run() { - reportPhase( _( "Checking dangling pads & vias..." )); + if( !reportPhase( _( "Checking dangling pads & vias..." ) ) ) + return false; BOARD* board = m_drcEngine->GetBoard(); @@ -105,7 +106,8 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run() } } - reportPhase( _( "Checking starved zones..." )); + if( !reportPhase( _( "Checking starved zones..." ) ) ) + return false; /* test starved zones */ for( ZONE_CONTAINER* zone : board->Zones() ) @@ -130,7 +132,8 @@ bool DRC_TEST_PROVIDER_CONNECTIVITY::Run() } } - reportPhase( _( "Checking net connections..." )); + if( !reportPhase( _( "Checking net connections..." ) ) ) + return false; connectivity->RecalculateRatsnest(); std::vector edges; diff --git a/pcbnew/drc/drc_test_provider_copper_clearance.cpp b/pcbnew/drc/drc_test_provider_copper_clearance.cpp index b0526c5e8e..b64c0de076 100644 --- a/pcbnew/drc/drc_test_provider_copper_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_copper_clearance.cpp @@ -122,16 +122,24 @@ bool DRC_TEST_PROVIDER_COPPER_CLEARANCE::Run() reportAux( "Worst clearance : %d nm", m_largestClearance ); - reportPhase( _( "Checking pad clearances..." )); + if( !reportPhase( _( "Checking pad clearances..." ) ) ) + return false; + testPadClearances(); - reportPhase( _( "Checking track & via clearances..." )); + if( !reportPhase( _( "Checking track & via clearances..." ) ) ) + return false; + testTrackClearances(); - reportPhase( _( "Checking copper graphic & text clearances..." )); + if( !reportPhase( _( "Checking copper graphic & text clearances..." ) ) ) + return false; + testCopperTextAndGraphics(); - reportPhase( _( "Checking copper zone clearances..." )); + if( !reportPhase( _( "Checking copper zone clearances..." ) ) ) + return false; + testZones(); reportRuleStatistics(); @@ -295,17 +303,14 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testTrackClearances() const int delta = m_drcEngine->GetTestTracksAgainstZones() ? 25 : 100; int count = m_board->Tracks().size(); - reportProgress( 0.0 ); reportAux( "Testing %d tracks...", count ); int ii = 0; for( auto seg_it = m_board->Tracks().begin(); seg_it != m_board->Tracks().end(); seg_it++ ) { - if( (ii % delta) == 0 || ii >= (int) m_board->Tracks().size() - 1 ) - reportProgress( (double) ii / (double) m_board->Tracks().size() ); - - ii++; + if( !reportProgress( ii++, m_board->Tracks().size(), delta ) ) + break; // Test segment against tracks and pads, optionally against copper zones for( PCB_LAYER_ID layer : (*seg_it)->GetLayerSet().Seq() ) @@ -552,8 +557,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testPadClearances( ) { D_PAD* pad = sortedPads[idx]; - if( idx % delta == 0 || idx == (int) sortedPads.size() - 1 ) - reportProgress( (double) idx / (double) sortedPads.size() ); + if( !reportProgress( idx, sortedPads.size(), delta ) ) + break; int x_limit = pad->GetPosition().x + pad->GetBoundingRadius() + max_size; @@ -667,6 +672,8 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::doPadToPadsDrc( int aRefPadIdx, void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones() { + const int delta = 50; // This is the number of tests between 2 calls to the progress bar + // Test copper areas for valid netcodes -> fixme, goes to connectivity checks std::vector smoothed_polys; @@ -682,6 +689,9 @@ void DRC_TEST_PROVIDER_COPPER_CLEARANCE::testZones() // iterate through all areas for( int ia = 0; ia < m_board->GetAreaCount(); ia++ ) { + if( !reportProgress( ia, m_board->GetAreaCount(), delta ) ) + break; + ZONE_CONTAINER* zoneRef = m_board->GetArea( ia ); if( !zoneRef->IsOnCopperLayer() ) diff --git a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp index 8c5ed193d5..335f19a891 100644 --- a/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_courtyard_clearance.cpp @@ -78,16 +78,15 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testFootprintCourtyardDefinitions() const int delta = 100; // This is the number of tests between 2 calls to the progress bar // Detects missing (or malformed) footprint courtyards - reportPhase( _( "Checking footprint courtyard definitions..." )); + if( !reportPhase( _( "Checking footprint courtyard definitions..." ) ) ) + return; int ii = 0; for( MODULE* footprint : m_board->Modules() ) { - if( (ii % delta) == 0 || ii >= (int) m_board->Modules().size() - 1 ) - reportProgress( (double) ii / (double) m_board->Modules().size() ); - - ii++; + if( !reportProgress( ii++, m_board->Modules().size(), delta ) ) + return; if( footprint->BuildPolyCourtyard() ) { @@ -128,16 +127,15 @@ void DRC_TEST_PROVIDER_COURTYARD_CLEARANCE::testOverlappingComponentCourtyards() { const int delta = 100; // This is the number of tests between 2 calls to the progress bar - reportPhase( _( "Checking footprint courtyard overlap..." )); + if( !reportPhase( _( "Checking footprint courtyard overlap..." ) ) ) + return; int ii = 0; for( auto it1 = m_board->Modules().begin(); it1 != m_board->Modules().end(); it1++ ) { - if( (ii % delta) == 0 || ii >= (int) m_board->Modules().size() - 1 ) - reportProgress( (double) ii / (double) m_board->Modules().size() ); - - ii++; + if( !reportProgress( ii++, m_board->Modules().size(), delta ) ) + break; if( m_drcEngine->IsErrorLimitExceeded( DRCE_OVERLAPPING_FOOTPRINTS) ) break; diff --git a/pcbnew/drc/drc_test_provider_disallow.cpp b/pcbnew/drc/drc_test_provider_disallow.cpp index 2c6b3dba52..bf12eab846 100644 --- a/pcbnew/drc/drc_test_provider_disallow.cpp +++ b/pcbnew/drc/drc_test_provider_disallow.cpp @@ -70,7 +70,8 @@ bool DRC_TEST_PROVIDER_DISALLOW::Run() return false; } - reportPhase( _( "Checking keepouts & disallow constraints..." )); + if( !reportPhase( _( "Checking keepouts & disallow constraints..." ) ) ) + return false; auto checkItem = [&]( BOARD_ITEM *item ) -> bool { diff --git a/pcbnew/drc/drc_test_provider_edge_clearance.cpp b/pcbnew/drc/drc_test_provider_edge_clearance.cpp index c9d51843e4..7e2d2dd05f 100644 --- a/pcbnew/drc/drc_test_provider_edge_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_edge_clearance.cpp @@ -89,7 +89,8 @@ bool DRC_TEST_PROVIDER_EDGE_CLEARANCE::Run() reportAux( "Worst clearance : %d nm", m_largestClearance ); - reportPhase( _( "Checking board edge clearances..." )); + if( !reportPhase( _( "Checking board edge clearances..." ) ) ) + return false; std::vector boardOutline; std::vector boardItems; diff --git a/pcbnew/drc/drc_test_provider_hole_clearance.cpp b/pcbnew/drc/drc_test_provider_hole_clearance.cpp index f4f43993a0..5794148709 100644 --- a/pcbnew/drc/drc_test_provider_hole_clearance.cpp +++ b/pcbnew/drc/drc_test_provider_hole_clearance.cpp @@ -124,10 +124,14 @@ bool DRC_TEST_PROVIDER_HOLE_CLEARANCE::Run() buildDrilledHoleList(); - reportPhase( _( "Checking hole to pad clearances..." )); + if( !reportPhase( _( "Checking hole to pad clearances..." ) ) ) + return false; + testPads2Holes(); - reportPhase( _( "Checking hole to hole clearances..." )); + if( !reportPhase( _( "Checking hole to hole clearances..." ) ) ) + return false; + testHoles2Holes(); reportRuleStatistics(); @@ -202,8 +206,8 @@ void DRC_TEST_PROVIDER_HOLE_CLEARANCE::testPads2Holes() drc_dbg( 10, "-> %p\n", pad ); - if( idx % delta == 0 || idx == (int) sortedPads.size() - 1 ) - reportProgress( (double) idx / (double) sortedPads.size() ); + if( !reportProgress( idx, sortedPads.size(), delta ) ) + break; doPadToPadHoleDrc( idx, sortedPads, x_limit ); } @@ -369,8 +373,8 @@ void DRC_TEST_PROVIDER_HOLE_CLEARANCE::testHoles2Holes() for( size_t ii = 0; ii < m_drilledHoles.size(); ++ii ) { - if( ii % delta == 0 || ii == m_drilledHoles.size() - 1 ) - reportProgress( (double) ii / (double) m_drilledHoles.size() ); + if( !reportProgress( ii, m_drilledHoles.size(), delta ) ) + break; if( m_drcEngine->IsErrorLimitExceeded( DRCE_DRILLED_HOLES_TOO_CLOSE ) ) break; diff --git a/pcbnew/drc/drc_test_provider_hole_size.cpp b/pcbnew/drc/drc_test_provider_hole_size.cpp index 340af30578..532a473167 100644 --- a/pcbnew/drc/drc_test_provider_hole_size.cpp +++ b/pcbnew/drc/drc_test_provider_hole_size.cpp @@ -76,7 +76,8 @@ private: bool DRC_TEST_PROVIDER_HOLE_SIZE::Run() { - reportPhase( _( "Checking pad holes..." )); + if( !reportPhase( _( "Checking pad holes..." ) ) ) + return false; m_board = m_drcEngine->GetBoard(); @@ -94,7 +95,8 @@ bool DRC_TEST_PROVIDER_HOLE_SIZE::Run() } } - reportPhase( _( "Checking via holes..." )); + if( !reportPhase( _( "Checking via holes..." ) ) ) + return false; std::vector vias; diff --git a/pcbnew/drc/drc_test_provider_lvs.cpp b/pcbnew/drc/drc_test_provider_lvs.cpp index 02035e09d1..a160cc684a 100644 --- a/pcbnew/drc/drc_test_provider_lvs.cpp +++ b/pcbnew/drc/drc_test_provider_lvs.cpp @@ -208,7 +208,8 @@ bool DRC_TEST_PROVIDER_LVS::Run() { if( m_drcEngine->GetTestFootprints() ) { - reportPhase( _( "Checking PCB to schematic parity..." )); + if( !reportPhase( _( "Checking PCB to schematic parity..." ) ) ) + return false; if( m_drcEngine->GetSchematicNetlist() ) testFootprints( *m_drcEngine->GetSchematicNetlist() ); diff --git a/pcbnew/drc/drc_test_provider_misc.cpp b/pcbnew/drc/drc_test_provider_misc.cpp index 7bce913af7..7d72db6619 100644 --- a/pcbnew/drc/drc_test_provider_misc.cpp +++ b/pcbnew/drc/drc_test_provider_misc.cpp @@ -191,13 +191,19 @@ bool DRC_TEST_PROVIDER_MISC::Run() { m_board = m_drcEngine->GetBoard(); - reportPhase( _( "Checking board outline..." )); + if( !reportPhase( _( "Checking board outline..." ) ) ) + return false; + testOutline(); - reportPhase( _( "Checking disabled layers..." )); + if( !reportPhase( _( "Checking disabled layers..." ) ) ) + return false; + testDisabledLayers(); - reportPhase( _( "Checking text variables..." )); + if( !reportPhase( _( "Checking text variables..." ) ) ) + return false; + testTextVars(); return true; diff --git a/pcbnew/drc/drc_test_provider_track_width.cpp b/pcbnew/drc/drc_test_provider_track_width.cpp index 0272391079..141d789982 100644 --- a/pcbnew/drc/drc_test_provider_track_width.cpp +++ b/pcbnew/drc/drc_test_provider_track_width.cpp @@ -74,7 +74,8 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run() return false; } - reportPhase( _( "Checking track widths..." )); + if( !reportPhase( _( "Checking track widths..." ) ) ) + return false; auto checkTrackWidth = [&]( BOARD_ITEM* item ) -> bool @@ -142,10 +143,8 @@ bool DRC_TEST_PROVIDER_TRACK_WIDTH::Run() for( TRACK* item : m_drcEngine->GetBoard()->Tracks() ) { - if( (ii % delta) == 0 || ii >= (int) m_drcEngine->GetBoard()->Tracks().size() - 1 ) - reportProgress( (double) ii / (double) m_drcEngine->GetBoard()->Tracks().size() ); - - ii++; + if( !reportProgress( ii++, m_drcEngine->GetBoard()->Tracks().size(), delta ) ) + break; if( !checkTrackWidth( item ) ) break; diff --git a/pcbnew/drc/drc_test_provider_via_diameter.cpp b/pcbnew/drc/drc_test_provider_via_diameter.cpp index 990e43d43c..a89018fcef 100644 --- a/pcbnew/drc/drc_test_provider_via_diameter.cpp +++ b/pcbnew/drc/drc_test_provider_via_diameter.cpp @@ -72,7 +72,8 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run() return false; } - reportPhase( _( "Checking via diameters..." ) ); + if( !reportPhase( _( "Checking via diameters..." ) ) ) + return false; auto checkViaDiameter = [&]( BOARD_ITEM* item ) -> bool @@ -129,10 +130,8 @@ bool DRC_TEST_PROVIDER_VIA_DIAMETER::Run() for( TRACK* item : m_drcEngine->GetBoard()->Tracks() ) { - if( (ii % delta) == 0 || ii >= (int) m_drcEngine->GetBoard()->Tracks().size() - 1 ) - reportProgress( (double) ii / (double) m_drcEngine->GetBoard()->Tracks().size() ); - - ii++; + if( !reportProgress( ii++, m_drcEngine->GetBoard()->Tracks().size(), delta ) ) + break; if( !checkViaDiameter( item ) ) break; diff --git a/pcbnew/tools/drc_tool.cpp b/pcbnew/tools/drc_tool.cpp index 480b5e4b63..3858e84f18 100644 --- a/pcbnew/tools/drc_tool.cpp +++ b/pcbnew/tools/drc_tool.cpp @@ -217,8 +217,6 @@ void DRC_TOOL::RunTests( PROGRESS_REPORTER* aProgressReporter, bool aTestTracksA // update the m_drcDialog listboxes updatePointers(); - - aProgressReporter->AdvancePhase( _( "Done." ) ); } diff --git a/qa/drc_proto/drc_test_provider_silk_to_pad.cpp b/qa/drc_proto/drc_test_provider_silk_to_pad.cpp index 5d9cbd42ec..982ab0914c 100644 --- a/qa/drc_proto/drc_test_provider_silk_to_pad.cpp +++ b/qa/drc_proto/drc_test_provider_silk_to_pad.cpp @@ -82,6 +82,9 @@ private: bool test::DRC_TEST_PROVIDER_SILK_TO_PAD::Run() { + if( !reportPhase( _( "Checking pad to silkscreen clearances..." ) ) ) + return false; + m_board = m_drcEngine->GetBoard(); DRC_CONSTRAINT worstClearanceConstraint; @@ -94,7 +97,6 @@ bool test::DRC_TEST_PROVIDER_SILK_TO_PAD::Run() } reportAux( "Worst clearance : %d nm", m_largestClearance ); - reportPhase( _( "Checking pad to silkscreen clearances..." ) ); std::vector boardOutline; std::vector boardItems;