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
This commit is contained in:
Seth Hillbrand 2022-06-30 14:57:23 -07:00
parent 91e7530ac9
commit 939313088e
3 changed files with 16 additions and 1 deletions

View File

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

View File

@ -2113,6 +2113,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

@ -314,13 +314,24 @@ wxString SCH_SHEET_PATH::PathHumanReadable( bool aUseShortRootName ) const
void SCH_SHEET_PATH::UpdateAllScreenReferences() const
{
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 );
}
}