diff --git a/eeschema/bus-wire-junction.cpp b/eeschema/bus-wire-junction.cpp index 39de2de7a3..7b85f0a6e3 100644 --- a/eeschema/bus-wire-junction.cpp +++ b/eeschema/bus-wire-junction.cpp @@ -251,18 +251,6 @@ bool SCH_EDIT_FRAME::SchematicCleanUp( SCH_SCREEN* aScreen ) } -void SCH_EDIT_FRAME::NormalizeSchematicOnFirstLoad( bool recalculateConnections ) -{ - SCH_SHEET_LIST list( g_RootSheet ); - - for( const auto& sheet : list ) - SchematicCleanUp( sheet.LastScreen() ); - - if( recalculateConnections ) - RecalculateConnections( false ); -} - - bool SCH_EDIT_FRAME::BreakSegment( SCH_LINE* aSegment, const wxPoint& aPoint, SCH_LINE** aNewSegment, SCH_SCREEN* aScreen ) { diff --git a/eeschema/dialogs/dialog_erc.cpp b/eeschema/dialogs/dialog_erc.cpp index 7ea8691e4c..2b801e1d79 100644 --- a/eeschema/dialogs/dialog_erc.cpp +++ b/eeschema/dialogs/dialog_erc.cpp @@ -515,7 +515,7 @@ void DIALOG_ERC::TestErc( REPORTER& aReporter ) TestConflictingBusAliases(); // The connection graph has a whole set of ERC checks it can run - m_parent->RecalculateConnections(); + m_parent->RecalculateConnections( NO_CLEANUP ); g_ConnectionGraph->RunERC( m_settings ); // Test is all units of each multiunit component have the same footprint assigned. diff --git a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp index 00e4b4425a..7978d23280 100644 --- a/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp +++ b/eeschema/dialogs/dialog_global_edit_text_and_graphics.cpp @@ -96,7 +96,7 @@ DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS::DIALOG_GLOBAL_EDIT_TEXT_AND_GRAPHICS( SCH_ // TODO(JE) remove once real-time connectivity is a given if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) - m_parent->RecalculateConnections(); + m_parent->RecalculateConnections( NO_CLEANUP ); m_sdbSizerButtonsOK->SetDefault(); diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 9075ebe695..b0cb8a1fd1 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -391,12 +391,6 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. SetScreen( g_CurrentSheet->LastScreen() ); - // Ensure the schematic is fully segmented on first display - NormalizeSchematicOnFirstLoad( true ); - GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); - - GetScreen()->TestDanglingEnds(); // Only perform the dangling end test on root sheet. - // Migrate conflicting bus definitions // TODO(JE) This should only run once based on schematic file version if( g_ConnectionGraph->GetBusesNeedingMigration().size() > 0 ) @@ -404,10 +398,14 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in DIALOG_MIGRATE_BUSES dlg( this ); dlg.ShowQuasiModal(); - RecalculateConnections(); 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; } @@ -646,9 +644,6 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) SCH_SCREENS schematic; schematic.UpdateSymbolLinks(); // Update all symbol library links for all sheets. - // Ensure the schematic is fully segmented on first display - NormalizeSchematicOnFirstLoad( false ); - GetScreen()->m_Initialized = true; EE_TYPE_COLLECTOR components; @@ -675,11 +670,11 @@ bool SCH_EDIT_FRAME::importFile( const wxString& aFileName, int aFileType ) } } } - - GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); // Only perform the dangling end test on root sheet. GetScreen()->TestDanglingEnds(); - RecalculateConnections(); + RecalculateConnections( GLOBAL_CLEANUP ); + + GetScreen()->ClearUndoORRedoList( GetScreen()->m_UndoList, 1 ); GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); m_toolManager->RunAction( ACTIONS::zoomFitScreen, true ); diff --git a/eeschema/netlist_generator.cpp b/eeschema/netlist_generator.cpp index a4eb130044..9433c35a57 100644 --- a/eeschema/netlist_generator.cpp +++ b/eeschema/netlist_generator.cpp @@ -238,7 +238,7 @@ NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::CreateNetlist( bool aSilent, NETLIST_OBJECT_LIST* SCH_EDIT_FRAME::BuildNetListBase( bool updateStatusText ) { // Ensure netlist is up to date - RecalculateConnections(); + RecalculateConnections( NO_CLEANUP ); // I own this list until I return it to the new owner. std::unique_ptr ret( new NETLIST_OBJECT_LIST() ); diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 60f42e3d35..b525eabd43 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -623,7 +623,7 @@ void SCH_EDIT_FRAME::OnModify() GetScreen()->SetSave(); if( ADVANCED_CFG::GetCfg().m_realTimeConnectivity && CONNECTION_GRAPH::m_allowRealTime ) - RecalculateConnections( false ); + RecalculateConnections( NO_CLEANUP ); GetCanvas()->Refresh(); } @@ -987,7 +987,7 @@ void SCH_EDIT_FRAME::AddItemToScreenAndUndoList( SCH_ITEM* aItem, bool aUndoAppe // Update connectivity info for new item if( !aItem->IsMoving() ) - RecalculateConnections(); + RecalculateConnections( LOCAL_CLEANUP ); } else { @@ -1056,14 +1056,17 @@ void SCH_EDIT_FRAME::UpdateTitle() } -void SCH_EDIT_FRAME::RecalculateConnections( bool aDoCleanup ) +void SCH_EDIT_FRAME::RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ) { SCH_SHEET_LIST list( g_RootSheet ); - - PROF_COUNTER timer; + PROF_COUNTER timer; // Ensure schematic graph is accurate - if( aDoCleanup ) + if( aCleanupFlags == LOCAL_CLEANUP ) + { + SchematicCleanUp( GetScreen() ); + } + else if( aCleanupFlags == GLOBAL_CLEANUP ) { for( const auto& sheet : list ) SchematicCleanUp( sheet.LastScreen() ); diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index c7982050ce..7532ca1cad 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -94,6 +94,13 @@ enum SCH_SEARCH_T { }; +enum SCH_CLEANUP_FLAGS { + NO_CLEANUP, + LOCAL_CLEANUP, + GLOBAL_CLEANUP +}; + + /** * Schematic editor (Eeschema) main window. */ @@ -1004,7 +1011,7 @@ public: /** * Generates the connection data for the entire schematic hierarchy. */ - void RecalculateConnections( bool aDoCleanup = true ); + void RecalculateConnections( SCH_CLEANUP_FLAGS aCleanupFlags ); /** * Allows Eeschema to install its preferences panels into the preferences dialog. diff --git a/eeschema/tools/sch_editor_control.cpp b/eeschema/tools/sch_editor_control.cpp index 23cb07db34..9561ddec1f 100644 --- a/eeschema/tools/sch_editor_control.cpp +++ b/eeschema/tools/sch_editor_control.cpp @@ -782,7 +782,7 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent ) { // TODO(JE) remove once real-time connectivity is a given if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) - m_frame->RecalculateConnections(); + m_frame->RecalculateConnections( NO_CLEANUP ); std::string tool = aEvent.GetCommandStr().get(); PICKER_TOOL* picker = m_toolMgr->GetTool(); diff --git a/eeschema/tools/sch_line_wire_bus_tool.cpp b/eeschema/tools/sch_line_wire_bus_tool.cpp index dc1a5d737b..d4bc13713e 100644 --- a/eeschema/tools/sch_line_wire_bus_tool.cpp +++ b/eeschema/tools/sch_line_wire_bus_tool.cpp @@ -81,7 +81,7 @@ private: // TODO(JE) remove once real-time is enabled if( !ADVANCED_CFG::GetCfg().m_realTimeConnectivity || !CONNECTION_GRAPH::m_allowRealTime ) { - frame->RecalculateConnections(); + frame->RecalculateConnections( NO_CLEANUP ); // Pick up the pointer again because it may have been changed by SchematicCleanUp selection = selTool->RequestSelection( busType );