diff --git a/eeschema/connection_graph.cpp b/eeschema/connection_graph.cpp index 96f21b7072..7eeae69bdf 100644 --- a/eeschema/connection_graph.cpp +++ b/eeschema/connection_graph.cpp @@ -736,7 +736,8 @@ void CONNECTION_GRAPH::Reset() void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional, - std::function* aChangedItemHandler ) + std::function* aChangedItemHandler, + PROGRESS_REPORTER* aProgressReporter ) { PROF_TIMER recalc_time( "CONNECTION_GRAPH::Recalculate" ); @@ -748,8 +749,17 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco m_sheetList = aSheetList; std::set dirty_items; + int count = aSheetList.size() * 2; + int done = 0; + for( const SCH_SHEET_PATH& sheet : aSheetList ) { + if( aProgressReporter ) + { + aProgressReporter->SetCurrentProgress( done++ / (double) count ); + aProgressReporter->KeepRefreshing(); + } + std::vector items; // Store current unit value, to replace it after calculations @@ -826,6 +836,12 @@ void CONNECTION_GRAPH::Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnco updateItemConnectivity( sheet, items ); + if( aProgressReporter ) + { + aProgressReporter->SetCurrentProgress( done++ / count ); + aProgressReporter->KeepRefreshing(); + } + // UpdateDanglingState() also adds connected items for SCH_TEXT sheet.LastScreen()->TestDanglingEnds( &sheet, aChangedItemHandler ); diff --git a/eeschema/connection_graph.h b/eeschema/connection_graph.h index cd88ffb269..826f6d005d 100644 --- a/eeschema/connection_graph.h +++ b/eeschema/connection_graph.h @@ -31,6 +31,7 @@ #include #include #include +#include #ifdef DEBUG @@ -391,7 +392,8 @@ public: * @param aChangedItemHandler an optional handler to receive any changed items */ void Recalculate( const SCH_SHEET_LIST& aSheetList, bool aUnconditional = false, - std::function* aChangedItemHandler = nullptr ); + std::function* aChangedItemHandler = nullptr, + PROGRESS_REPORTER* aProgressReporter = nullptr ); /** * Return a bus alias pointer for the given name if it exists (from cache) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 88ba909368..bb7de75fbe 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -539,7 +539,10 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in SCH_COMMIT dummy( this ); - RecalculateConnections( &dummy, GLOBAL_CLEANUP ); + progressReporter.Report( _( "Updating connections..." ) ); + progressReporter.KeepRefreshing(); + + RecalculateConnections( &dummy, GLOBAL_CLEANUP, &progressReporter ); if( schematic.HasSymbolFieldNamesWithWhiteSpace() ) { @@ -1382,12 +1385,12 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType, GetScreen()->SetFileName( newfilename.GetFullPath() ); GetScreen()->SetContentModified(); - progressReporter.Report( _( "Cleaning up schematic..." ) ); + progressReporter.Report( _( "Updating connections..." ) ); if( !progressReporter.KeepRefreshing() ) THROW_IO_ERROR( _( "File import canceled by user." ) ); - RecalculateConnections( nullptr, GLOBAL_CLEANUP ); + RecalculateConnections( nullptr, GLOBAL_CLEANUP, &progressReporter ); // Only perform the dangling end test on root sheet. GetScreen()->TestDanglingEnds(); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index fd697a038c..a31e5edccb 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1777,7 +1777,8 @@ void SCH_EDIT_FRAME::initScreenZoom() } -void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags ) +void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, + PROGRESS_REPORTER* aProgressReporter ) { wxString highlightedConn = GetHighlightedConnection(); bool hasHighlightedConn = !highlightedConn.IsEmpty(); @@ -1846,7 +1847,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL SCH_RULE_AREA::UpdateRuleAreasInScreens( all_screens, GetCanvas()->GetView() ); // Recalculate all connectivity - Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler ); + Schematic().ConnectionGraph()->Recalculate( list, true, &changeHandler, aProgressReporter ); } else { @@ -2052,7 +2053,7 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL for( const wxString& netName : affectedNets ) netSettings->ClearCacheForNet( netName ); - new_graph.Recalculate( list, false, &changeHandler ); + new_graph.Recalculate( list, false, &changeHandler, aProgressReporter ); Schematic().ConnectionGraph()->Merge( new_graph ); } diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 79760b6c3d..c04e46d549 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -65,6 +65,7 @@ class RESCUER; class HIERARCHY_PANE; class API_HANDLER_SCH; class DIALOG_SCHEMATIC_SETUP; +class PROGRESS_REPORTER; /// Schematic search type used by the socket link with Pcbnew @@ -797,7 +798,8 @@ public: /** * Generate the connection data for the entire schematic hierarchy. */ - void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags ); + void RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FLAGS aCleanupFlags, + PROGRESS_REPORTER* aProgressReporter = nullptr ); /** * Called after the preferences dialog is run. diff --git a/eeschema/sch_io/altium/sch_io_altium.cpp b/eeschema/sch_io/altium/sch_io_altium.cpp index 7f4ab35200..9dd0cf96bf 100644 --- a/eeschema/sch_io/altium/sch_io_altium.cpp +++ b/eeschema/sch_io/altium/sch_io_altium.cpp @@ -822,12 +822,12 @@ void SCH_IO_ALTIUM::CreateAliases() void SCH_IO_ALTIUM::ParseAltiumSch( const wxString& aFileName ) { - if( m_rootFilepath.IsEmpty() ) - m_rootFilepath = aFileName; - // Load path may be different from the project path. wxFileName parentFileName( aFileName ); + if( m_rootFilepath.IsEmpty() ) + m_rootFilepath = parentFileName.GetPath(); + if( m_progressReporter ) { wxFileName relative = parentFileName;