Units are stored in the instance data

At the moment, units are stored in the instance data, so when loading
the file, all symbols will have bbox for the first unit.  After calling
`UpdateUnit()`, we need to recache the rtree bounding boxes to get
correct hit tests

Fixes https://gitlab.com/kicad/code/kicad/issues/11681


(cherry picked from commit 939313088e)
This commit is contained in:
Seth Hillbrand 2022-06-30 14:57:23 -07:00 committed by Roberto Fernandez Bautista
parent 87a8e69632
commit 45da795668
3 changed files with 16 additions and 1 deletions

View File

@ -517,6 +517,8 @@ bool SCH_EDIT_FRAME::OpenProjectFiles( const std::vector<wxString>& aFileSet, in
SyncView();
GetScreen()->ClearDrawingState();
TestDanglingEnds();
UpdateHierarchyNavigator();
UpdateTitle();

View File

@ -1507,6 +1507,8 @@ void SCH_PAINTER::draw( SCH_SYMBOL* aSymbol, int aLayer )
if( symbolPin->IsDangling() )
tempPin->SetFlags( IS_DANGLING );
else
tempPin->ClearFlags( IS_DANGLING );
}
draw( &tempSymbol, aLayer, false, aSymbol->GetUnit(), aSymbol->GetConvert() );

View File

@ -293,13 +293,24 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const
void SCH_SHEET_PATH::UpdateAllScreenReferences()
{
for( SCH_ITEM* item : LastScreen()->Items().OfType( SCH_SYMBOL_T ) )
std::vector<SCH_ITEM*> symbols;
std::copy_if( LastScreen()->Items().begin(),
LastScreen()->Items().end(),
std::back_inserter( symbols ),
[]( SCH_ITEM* aItem )
{
return ( aItem->Type() == SCH_SYMBOL_T );
} );
for( SCH_ITEM* item : symbols )
{
SCH_SYMBOL* symbol = static_cast<SCH_SYMBOL*>( item );
symbol->GetField( REFERENCE_FIELD )->SetText( symbol->GetRef( this ) );
symbol->GetField( VALUE_FIELD )->SetText( symbol->GetValue( this, false ) );
symbol->GetField( FOOTPRINT_FIELD )->SetText( symbol->GetFootprint( this, false ) );
symbol->UpdateUnit( symbol->GetUnitSelection( this ) );
LastScreen()->Update( item );
}
}