Improve performance of schematic load and connectivity

Store component paths and references efficiently
Remove redundant calls to RecalculateConnections
This commit is contained in:
Jon Evans 2020-02-04 23:37:14 +01:00
parent 262283995c
commit 2eaefb4874
7 changed files with 29 additions and 21 deletions

View File

@ -407,10 +407,12 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
RescueSymbolLibTableProject( false );
}
g_ConnectionGraph->Reset();
// Update all symbol library links for all sheets.
// NOTE: calls RecalculateConnections( GLOBAL_CLEANUP )
schematic.UpdateSymbolLinks( true ); // Update all symbol library links for all sheets.
g_ConnectionGraph->Reset();
RecalculateConnections( GLOBAL_CLEANUP );
SetScreen( g_CurrentSheet->LastScreen() );
// Migrate conflicting bus definitions
@ -419,13 +421,11 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
{
DIALOG_MIGRATE_BUSES dlg( this );
dlg.ShowQuasiModal();
RecalculateConnections( NO_CLEANUP );
OnModify();
}
GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet.
RecalculateConnections( GLOBAL_CLEANUP );
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );
GetScreen()->m_Initialized = true;
@ -720,7 +720,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType )
}
// Only perform the dangling end test on root sheet.
GetScreen()->TestDanglingEnds();
RecalculateConnections( GLOBAL_CLEANUP );
GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 );

View File

@ -329,7 +329,7 @@ public:
* Do nothing if already exists.
* In component lists shared by more than one sheet path, an entry for each
* sheet path must exist to manage references
* @param aSheetPathName is the candidate sheet path name
* @param aSheetPath is the candidate sheet path
* this sheet path is the sheet path of the sheet containing the component,
* not the full component sheet path
* @return false if the alternate reference was existing, true if added.

View File

@ -390,7 +390,9 @@ void SCH_CONNECTION::AppendDebugInfoToMsgPanel( MSG_PANEL_ITEMS& aList ) const
bool SCH_CONNECTION::IsBusLabel( const wxString& aLabel )
{
return IsBusVectorLabel( aLabel ) || IsBusGroupLabel( aLabel );
//return IsBusVectorLabel( aLabel ) || IsBusGroupLabel( aLabel );
// Weak heuristic for performance reasons. Stronger test will be used for connectivity
return aLabel.Contains( wxT( "[" ) ) || aLabel.Contains( wxT( "{" ) );
}

View File

@ -1169,6 +1169,8 @@ void SCH_EDIT_FRAME::FixupJunctions()
// Save the current sheet, to retrieve it later
auto currSheet = GetCurrentSheet();
bool modified = false;
SCH_SHEET_LIST sheetList;
sheetList.BuildSheetList( g_RootSheet );
@ -1197,9 +1199,15 @@ void SCH_EDIT_FRAME::FixupJunctions()
}
for( auto& pos : junctions )
AddJunction( pos );
AddJunction( pos, false, false );
if( junctions.size() )
modified = true;
}
if( modified )
OnModify();
// Reselect the initial sheet:
SetCurrentSheet( currSheet );
GetCurrentSheet().UpdateAllScreenReferences();

View File

@ -1985,7 +1985,6 @@ void SCH_LEGACY_PLUGIN::saveComponent( SCH_COMPONENT* aComponent )
{
std::string name1;
std::string name2;
wxArrayString reference_fields;
static wxString delimiters( wxT( " " ) );

View File

@ -745,7 +745,7 @@ void SCH_SCREEN::ClearAnnotation( SCH_SHEET_PATH* aSheetPath )
void SCH_SCREEN::EnsureAlternateReferencesExist()
{
if( GetClientSheetPathsCount() <= 1 ) // No need for alternate reference
if( GetClientSheetPaths().size() <= 1 ) // No need for alternate reference
return;
for( SCH_ITEM* item : Items().OfType( SCH_COMPONENT_T ) )
@ -753,8 +753,8 @@ void SCH_SCREEN::EnsureAlternateReferencesExist()
auto component = static_cast<SCH_COMPONENT*>( item );
// Add (when not existing) all sheet path entries
for( unsigned int ii = 0; ii < m_clientSheetPathList.GetCount(); ii++ )
component->AddSheetPathReferenceEntryIfMissing( m_clientSheetPathList[ii] );
for( const auto& sheet : GetClientSheetPaths() )
component->AddSheetPathReferenceEntryIfMissing( sheet.Path() );
}
}
@ -1299,7 +1299,7 @@ void SCH_SCREENS::BuildClientSheetPathList()
SCH_SHEET_LIST sheetList( g_RootSheet );
for( SCH_SCREEN* curr_screen = GetFirst(); curr_screen; curr_screen = GetNext() )
curr_screen->GetClientSheetPaths().Clear();
curr_screen->GetClientSheetPaths().clear();
for( SCH_SHEET_PATH& sheetpath: sheetList )
{
@ -1310,7 +1310,7 @@ void SCH_SCREENS::BuildClientSheetPathList()
{
if( used_screen == curr_screen )
{
curr_screen->GetClientSheetPaths().Add( sheetpath.PathAsString() );
curr_screen->GetClientSheetPaths().push_back( sheetpath );
break;
}
}

View File

@ -97,7 +97,7 @@ private:
* can have many scheet paths sharing this screen, if this sheet is inside
* an other sheet having many instances (one sheet path by parent sheet instance).
*/
wxArrayString m_clientSheetPathList;
std::vector<SCH_SHEET_PATH> m_clientSheetPathList;
/// The size of the paper to print or plot on
PAGE_INFO m_paper; // keep with the MVC 'model' if this class gets split
@ -170,16 +170,16 @@ public:
int GetRefCount() const { return m_refCount; }
/**
* @return the sheet paths count sharing this screen
* @return the sheet paths sharing this screen
* if 1 this screen is not in a complex hierarchy: the reference field can be
* used to store the component reference
* if > 1 this screen is in a complex hierarchy, and components must have
* a full alternate reference management
*/
int GetClientSheetPathsCount() { return (int) m_clientSheetPathList.GetCount(); }
wxArrayString& GetClientSheetPaths() { return m_clientSheetPathList; }
std::vector<SCH_SHEET_PATH>& GetClientSheetPaths()
{
return m_clientSheetPathList;
}
void Append( SCH_ITEM* aItem );