Bring intersheet refs in line with schematic setting when changing sheets.

Fixes https://gitlab.com/kicad/code/kicad/issues/13061
This commit is contained in:
Jeff Young 2022-12-03 14:17:15 +00:00
parent 96819f6c01
commit f9b3f14dfa
1 changed files with 22 additions and 10 deletions

View File

@ -26,6 +26,7 @@
#include <sch_screen.h>
#include <sch_item.h>
#include <sch_marker.h>
#include <sch_label.h>
#include <sch_reference_list.h>
#include <symbol_library.h>
#include <sch_sheet_path.h>
@ -323,23 +324,34 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const
void SCH_SHEET_PATH::UpdateAllScreenReferences() const
{
std::vector<SCH_ITEM*> symbols;
std::vector<SCH_ITEM*> items;
std::copy_if( LastScreen()->Items().begin(),
LastScreen()->Items().end(),
std::back_inserter( symbols ),
std::copy_if( LastScreen()->Items().begin(), LastScreen()->Items().end(),
std::back_inserter( items ),
[]( SCH_ITEM* aItem )
{
return ( aItem->Type() == SCH_SYMBOL_T );
return ( aItem->Type() == SCH_SYMBOL_T || aItem->Type() == SCH_GLOBAL_LABEL_T );
} );
for( SCH_ITEM* item : symbols )
for( SCH_ITEM* item : items )
{
if( item->Type() == SCH_SYMBOL_T )
{
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) );
symbol->UpdateUnit( symbol->GetUnitSelection( this ) );
LastScreen()->Update( item );
}
else if( item->Type() == SCH_GLOBAL_LABEL_T )
{
SCH_GLOBALLABEL* label = static_cast<SCH_GLOBALLABEL*>( item );
SCH_FIELD& intersheetRefs = label->GetFields()[0];
intersheetRefs.SetVisible( label->Schematic()->Settings().m_IntersheetRefsShow );
LastScreen()->Update( &intersheetRefs );
}
}
}