Do not expand the entire schematic hierarchy navigator tree by default.

The new behavior is to only expand to the first child of the root sheet
level.  On very complex hierarchies, this makes the navigator far more
useful.

Do not update schematic hierarchy navigator on every edit.  Now only
sheet changes will trigger a rebuild of the tree.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/16371
This commit is contained in:
Wayne Stambaugh 2024-01-06 07:56:16 -05:00
parent f5e76e6116
commit a310c0a05a
7 changed files with 65 additions and 13 deletions

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2018 jp.charras at wanadoo.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2021-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2021-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
@ -96,6 +96,22 @@ bool PICKED_ITEMS_LIST::ContainsItem( const EDA_ITEM* aItem ) const
}
bool PICKED_ITEMS_LIST::ContainsItemType( KICAD_T aItemType ) const
{
for( const ITEM_PICKER& picker : m_ItemsList )
{
const EDA_ITEM* item = picker.GetItem();
wxCHECK2( item, continue );
if( item->Type() == aItemType )
return true;
}
return false;
}
int PICKED_ITEMS_LIST::FindItem( const EDA_ITEM* aItem ) const
{
for( size_t i = 0; i < m_ItemsList.size(); i++ )

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2017 Jean-Pierre Charras, jp.charras at wanadoo.fr
* 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
@ -1083,7 +1083,6 @@ void SCH_EDIT_FRAME::OnModify()
m_autoSaveRequired = true;
GetCanvas()->Refresh();
UpdateHierarchyNavigator();
if( !GetTitle().StartsWith( wxS( "*" ) ) )
updateTitle();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2004 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
* Copyright (C) 2004-2023 KiCad Developers, see change_log.txt for contributors.
* Copyright (C) 2004-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
@ -413,10 +413,17 @@ void SCH_EDIT_FRAME::RollbackSchematicFromUndo()
{
delete aItem;
} );
// Only rebuild the hierarchy navigator if there are sheet changes.
bool hasSheets = undo->ContainsItemType( SCH_SHEET_T );
delete undo;
SetSheetNumberAndCount();
UpdateHierarchyNavigator();
if( hasSheets )
{
SetSheetNumberAndCount();
UpdateHierarchyNavigator();
}
TestDanglingEnds();

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019 CERN
* Copyright (C) 2019-2023 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2019-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

View File

@ -2,7 +2,7 @@
* This program source code file is part of KiCad, a free EDA CAD application.
*
* Copyright (C) 2019-2023 CERN
* 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
@ -1233,6 +1233,8 @@ int SCH_EDITOR_CONTROL::HighlightNetCursor( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent )
{
wxCHECK( m_frame, 0 );
if( m_frame->GetUndoCommandCount() <= 0 )
return 0;
@ -1242,8 +1244,17 @@ int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent )
// Get the old list
PICKED_ITEMS_LIST* undo_list = m_frame->PopCommandFromUndoList();
wxCHECK( undo_list, 0 );
m_frame->PutDataInPreviousState( undo_list );
m_frame->SetSheetNumberAndCount();
// Only rebuild the hierarchy navigator if there are sheet changes.
if( undo_list->ContainsItemType( SCH_SHEET_T ) )
{
m_frame->SetSheetNumberAndCount();
m_frame->UpdateHierarchyNavigator();
}
m_frame->RecalculateConnections( nullptr, NO_CLEANUP );
m_frame->TestDanglingEnds();
@ -1262,6 +1273,8 @@ int SCH_EDITOR_CONTROL::Undo( const TOOL_EVENT& aEvent )
int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
{
wxCHECK( m_frame, 0 );
if( m_frame->GetRedoCommandCount() == 0 )
return 0;
@ -1271,6 +1284,8 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
/* Get the old list */
PICKED_ITEMS_LIST* list = m_frame->PopCommandFromRedoList();
wxCHECK( list, 0 );
/* Redo the command: */
m_frame->PutDataInPreviousState( list );
@ -1278,7 +1293,13 @@ int SCH_EDITOR_CONTROL::Redo( const TOOL_EVENT& aEvent )
list->ReversePickersListOrder();
m_frame->PushCommandToUndoList( list );
m_frame->SetSheetNumberAndCount();
// Only rebuild the hierarchy navigator if there are sheet changes.
if( list->ContainsItemType( SCH_SHEET_T ) )
{
m_frame->SetSheetNumberAndCount();
m_frame->UpdateHierarchyNavigator();
}
m_frame->RecalculateConnections( nullptr, NO_CLEANUP );
m_frame->TestDanglingEnds();

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2004 Jean-Pierre Charras, jp.charras at wanadoo.fr
* Copyright (C) 2008 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2004-2022 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2004-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
@ -231,7 +231,8 @@ void HIERARCHY_PANE::UpdateHierarchyTree()
buildHierarchyTree( &m_list, root );
UpdateHierarchySelection();
m_tree->ExpandAll();
if( m_tree->ItemHasChildren( root ) )
m_tree->Expand( root );
if( eventsWereBound )
{

View File

@ -3,7 +3,7 @@
*
* Copyright (C) 2009 jean-pierre.charras@gipsa-lab.inpg.fr
* Copyright (C) 2011 Wayne Stambaugh <stambaughw@gmail.com>
* Copyright (C) 2009-2021 KiCad Developers, see AUTHORS.txt for contributors.
* Copyright (C) 2009-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
@ -151,6 +151,14 @@ public:
*/
bool ContainsItem( const EDA_ITEM* aItem ) const;
/**
* Check the undo/redo list for any #EDA_ITEM of type \a aItemType.
*
* @param aItemType is an #EDA_ITEM type from the list of #KICAD_T types.
* @return true if an item of \a aItemType is found in the pick list.
*/
bool ContainsItemType( KICAD_T aItemType ) const;
/**
* @return Index of the searched item. If the item is not stored in the list, negative value
* is returned.