CADSTAR Schematic Archive Importer: Visible fields to calculate BBOX

- Ensures page size is calculated correctly
This commit is contained in:
Roberto Fernandez Bautista 2021-02-17 17:04:19 +00:00 committed by Wayne Stambaugh
parent 5acdf1ddb1
commit 7b5cf955af
1 changed files with 13 additions and 2 deletions

View File

@ -128,12 +128,23 @@ void CADSTAR_SCH_ARCHIVE_LOADER::Load( SCHEMATIC* aSchematic, SCH_SHEET* aRootSh
{ {
EDA_RECT bbox; EDA_RECT bbox;
// Don't use the fields of the components to calculate their bounding box // Only use the visible fields of the components to calculate their bounding box
// (hidden fields could be very long and artificially enlarge the sheet bounding box) // (hidden fields could be very long and artificially enlarge the sheet bounding box)
if( item->Type() == SCH_COMPONENT_T ) if( item->Type() == SCH_COMPONENT_T )
bbox = static_cast<SCH_COMPONENT*>( item )->GetBodyBoundingBox(); {
SCH_COMPONENT* comp = static_cast<SCH_COMPONENT*>( item );
bbox = comp->GetBodyBoundingBox();
for( const SCH_FIELD& field : comp->GetFields() )
{
if( field.IsVisible() )
bbox.Merge( field.GetBoundingBox() );
}
}
else else
{
bbox = item->GetBoundingBox(); bbox = item->GetBoundingBox();
}
sheetBoundingBox.Merge( bbox ); sheetBoundingBox.Merge( bbox );
} }