diff --git a/common/trace_helpers.cpp b/common/trace_helpers.cpp index 20fcd2b6ab..efbceb15dc 100644 --- a/common/trace_helpers.cpp +++ b/common/trace_helpers.cpp @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Wayne Stambaugh - * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2018-2024 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -55,6 +55,7 @@ const wxChar* const traceSchSheetPaths = wxT( "KICAD_SCH_SHEET_PATHS" ); const wxChar* const traceEnvVars = wxT( "KICAD_ENV_VARS" ); const wxChar* const traceGalProfile = wxT( "KICAD_GAL_PROFILE" ); const wxChar* const traceKiCad2Step = wxT( "KICAD2STEP" ); +const wxChar* const traceUiProfile = wxT( "KICAD_UI_PROFILE" ); wxString dump( const wxArrayString& aArray ) diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 108a189ce8..588f5d92ea 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -4,7 +4,7 @@ * Copyright (C) 2013 Jean-Pierre Charras, jp.charras at wanadoo.fr * Copyright (C) 2013 Wayne Stambaugh * Copyright (C) 2013-2023 CERN (www.cern.ch) - * Copyright (C) 1992-2023 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 1992-2024 KiCad Developers, see AUTHORS.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -555,7 +555,7 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector& aFileSet, in TestDanglingEnds(); - UpdateHierarchyNavigator(); + UpdateHierarchyNavigator( false ); wxCommandEvent changedEvt( EDA_EVT_SCHEMATIC_CHANGED ); ProcessEventLocally( changedEvt ); diff --git a/eeschema/net_navigator.cpp b/eeschema/net_navigator.cpp index 1f8b679c34..d0d9c195ba 100644 --- a/eeschema/net_navigator.cpp +++ b/eeschema/net_navigator.cpp @@ -21,6 +21,7 @@ */ #include +#include #include #include #include @@ -31,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -251,6 +253,12 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect { wxCHECK( m_netNavigator, /* void */ ); + size_t nodeCnt = 0; + + m_netNavigator->Freeze(); + + PROF_TIMER timer; + if( m_highlightedConn.IsEmpty() ) { m_netNavigator->DeleteAllItems(); @@ -262,16 +270,19 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect for( const auto& net : netMap ) { - wxTreeItemId netId = m_netNavigator->AppendItem( rootId, UnescapeString( net.first.Name ) ); + // Skip bus member subgraphs for the moment. + if( net.first.Name.IsEmpty() ) + continue; + + nodeCnt++; + wxTreeItemId netId = m_netNavigator->AppendItem( rootId, + UnescapeString( net.first.Name ) ); MakeNetNavigatorNode( net.first.Name, netId, aSelection ); } m_netNavigator->Expand( rootId ); - - return; } - - if( !m_netNavigator->IsEmpty() ) + else if( !m_netNavigator->IsEmpty() ) { const wxString shownNetName = m_netNavigator->GetItemText( m_netNavigator->GetRootItem() ); @@ -279,6 +290,8 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect { m_netNavigator->DeleteAllItems(); + nodeCnt++; + wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 ); MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection ); @@ -293,6 +306,8 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect itemData = dynamic_cast( m_netNavigator->GetItemData( selection ) ); m_netNavigator->DeleteAllItems(); + nodeCnt++; + wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 ); MakeNetNavigatorNode( m_highlightedConn, rootId, itemData ); @@ -300,10 +315,19 @@ void SCH_EDIT_FRAME::RefreshNetNavigator( const NET_NAVIGATOR_ITEM_DATA* aSelect } else { + nodeCnt++; + wxTreeItemId rootId = m_netNavigator->AddRoot( UnescapeString( m_highlightedConn ), 0 ); MakeNetNavigatorNode( m_highlightedConn, rootId, aSelection ); } + + timer.Stop(); + + wxLogTrace( traceUiProfile, wxS( "Adding %zu nodes to net navigator took %s." ), + nodeCnt, timer.to_string() ); + + m_netNavigator->Thaw(); } diff --git a/eeschema/sch_edit_frame.cpp b/eeschema/sch_edit_frame.cpp index 24bfd61230..d3b3d515b8 100644 --- a/eeschema/sch_edit_frame.cpp +++ b/eeschema/sch_edit_frame.cpp @@ -1172,11 +1172,13 @@ void SCH_EDIT_FRAME::OnUpdatePCB( wxCommandEvent& event ) } -void SCH_EDIT_FRAME::UpdateHierarchyNavigator() +void SCH_EDIT_FRAME::UpdateHierarchyNavigator( bool aRefreshNetNavigator ) { m_toolManager->GetTool()->CleanHistory(); m_hierarchy->UpdateHierarchyTree(); - RefreshNetNavigator(); + + if( aRefreshNetNavigator ) + RefreshNetNavigator(); } @@ -1743,9 +1745,13 @@ void SCH_EDIT_FRAME::RecalculateConnections( SCH_COMMIT* aCommit, SCH_CLEANUP_FL if( m_highlightedConnChanged ) return; - else if( !hasHighlightedConn ) - // No highlighted connection, but connectivity has changed, so refresh the list of all nets + + if( !hasHighlightedConn ) + { + // No highlighted connection, but connectivity has changed, so refresh + // the list of all nets m_highlightedConnChanged = true; + } else if( connection && ( connection->Name() == highlightedConn || connection->HasDriverChanged() ) ) diff --git a/eeschema/sch_edit_frame.h b/eeschema/sch_edit_frame.h index 723a3909a0..315a9f6aa2 100644 --- a/eeschema/sch_edit_frame.h +++ b/eeschema/sch_edit_frame.h @@ -232,7 +232,7 @@ public: /** * Update the hierarchy navigation tree and history */ - void UpdateHierarchyNavigator(); + void UpdateHierarchyNavigator( bool aRefreshNetNavigator = true ); /** * Update the hierarchy navigation tree labels. diff --git a/include/trace_helpers.h b/include/trace_helpers.h index 9077c149cf..5b094b422e 100644 --- a/include/trace_helpers.h +++ b/include/trace_helpers.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2018 Wayne Stambaugh - * Copyright (C) 2018-2021 KiCad Developers, see change_log.txt for contributors. + * Copyright (C) 2018-2024 KiCad Developers, see change_log.txt for contributors. * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License @@ -220,6 +220,13 @@ extern KICOMMON_API const wxChar* const traceGalProfile; */ extern KICOMMON_API const wxChar* const traceKiCad2Step; +/** + * Flag to enable user interface profile tracing. + * + * Use "KICAD_UI_PROFILE" to enable. + */ +extern KICOMMON_API const wxChar* const traceUiProfile; + ///@} /** diff --git a/libs/core/include/core/profile.h b/libs/core/include/core/profile.h index 76744959eb..31d9cc93b7 100644 --- a/libs/core/include/core/profile.h +++ b/libs/core/include/core/profile.h @@ -2,7 +2,7 @@ * This program source code file is part of KiCad, a free EDA CAD application. * * Copyright (C) 2013 CERN - * Copyright (C) 2019-2020 KiCad Developers, see AUTHORS.txt for contributors. + * Copyright (C) 2019-2020, 2024 KiCad Developers, see AUTHORS.txt for contributors. * @author Tomasz Wlostowski * * This program is free software; you can redistribute it and/or @@ -33,6 +33,7 @@ #include #include +#include #include #include #include @@ -153,9 +154,18 @@ public: std::string to_string() { - char tmp[1024]; - snprintf( tmp, sizeof( tmp ), "%s: %-6.1fms", m_name.c_str(), msecs() ); - return tmp; + std::string retv; + + if( !m_name.empty() ) + retv = m_name + ": "; + + std::stringstream time; + + Show( time ); + + retv += time.get(); + + return retv; } private: