From 4013f6424d1a5248aa28099d46f9078ab74dd0a4 Mon Sep 17 00:00:00 2001 From: jean-pierre charras Date: Mon, 10 Dec 2018 10:33:56 +0100 Subject: [PATCH] Pcbnew, autoplacer: display more activity during footprint placement --- include/widgets/progress_reporter.h | 15 +++++++++++++++ pcbnew/autorouter/ar_autoplacer.cpp | 15 ++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/include/widgets/progress_reporter.h b/include/widgets/progress_reporter.h index 30d783d874..55f9ef7554 100644 --- a/include/widgets/progress_reporter.h +++ b/include/widgets/progress_reporter.h @@ -76,6 +76,14 @@ class PROGRESS_REPORTER */ bool KeepRefreshing( bool aWait = false ); + /** change the title displayed on the window caption + * *MUST* only be called from the main thread. + * Has meaning only for some reporters. + * Do nothing for others + */ + virtual void SetTitle( const wxString& aTitle ) {} + + protected: int currentProgress() const; @@ -109,6 +117,13 @@ public: bool aCanAbort = true ); ~WX_PROGRESS_REPORTER(); + /** change the title displayed on the window caption + */ + virtual void SetTitle( const wxString& aTitle ) override + { + wxProgressDialog::SetTitle( aTitle ); + } + private: virtual bool updateUI() override; diff --git a/pcbnew/autorouter/ar_autoplacer.cpp b/pcbnew/autorouter/ar_autoplacer.cpp index 3ec07d5ee2..718545de77 100644 --- a/pcbnew/autorouter/ar_autoplacer.cpp +++ b/pcbnew/autorouter/ar_autoplacer.cpp @@ -866,7 +866,8 @@ void AR_AUTOPLACER::drawPlacementRoutingMatrix( ) } } -AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector aModules, BOARD_COMMIT* aCommit, bool aPlaceOffboardModules ) +AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector aModules, + BOARD_COMMIT* aCommit, bool aPlaceOffboardModules ) { wxPoint PosOK; wxPoint memopos; @@ -943,12 +944,17 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector aModules, BOARD_ m_progressReporter->SetMaxProgress( moduleCount ); } + wxSafeYield(); // allows refreshing screen and UI + while( ( module = pickModule( ) ) != nullptr ) { // Display some info about activity, module placement can take a while: - //printf( _( "Place footprint %d of %d [%s]\n" ), cnt, moduleCount, (const char *)module->GetReference().c_str() ); //m_frame->SetStatusText( msg ); + if( m_progressReporter ) + m_progressReporter->SetTitle( wxString::Format( + _( "Autoplacing %s" ), module->GetReference() ) ); + double initialOrient = module->GetOrientation(); // Display fill area of interest, barriers, penalties. //drawPlacementRoutingMatrix( ); @@ -990,6 +996,7 @@ AR_RESULT AR_AUTOPLACER::AutoplaceModules( std::vector aModules, BOARD_ // Determine if the best orientation of a module is 90. rotAllowed = module->GetPlacementCost90(); + if( rotAllowed != 0 ) { rotateModule( module, 900.0, true ); @@ -1055,10 +1062,10 @@ end_of_tst: module->SetIsPlaced( true ); module->SetNeedsPlaced( false ); - if( m_progressReporter ) { m_progressReporter->AdvanceProgress(); + if ( !m_progressReporter->KeepRefreshing( false ) ) { cancelled = true; @@ -1066,6 +1073,8 @@ end_of_tst: } } cnt++; + + wxSafeYield(); // allows refreshing screen and UI } m_curPosition = memopos;