Add 'GetBoundingBox' that optionally only calcs w visible fields

Cross-probing from Pcbnew to Eeschema revealed that EEschema was
including all fields, visible or not, when calculating the bounding
box of the probed componentt.  This caused problems with long strings
such as URLs that were not set as visible.  The cross-probing code
tries to minimize 'Zoom to Fit' operations when it's not necessary,
and the overly large bbox values often resulted in zooms not being
performed and components displayed very small.

This code adds a version of 'GetBoundingBox' that takes a boolean
to tell it to include invisble fields or not.

Addresses issue: https://gitlab.com/kicad/code/kicad/-/issues/5149
This commit is contained in:
PJM 2020-08-12 23:50:41 -07:00 committed by Jeff Young
parent 2f604b4494
commit f58221ca98
3 changed files with 19 additions and 2 deletions

View File

@ -126,7 +126,8 @@ SCH_ITEM* SCH_EDITOR_CONTROL::FindComponentAndItem( const wxString& aReference,
if( crossProbingSettings.zoom_to_fit )
{
EDA_RECT bbox = component->GetBoundingBox();
// Pass "false" to only include visible fields of component in bbox calculations
EDA_RECT bbox = component->GetBoundingBox( false );
wxSize bbSize = bbox.Inflate( bbox.GetWidth() * 0.2f ).GetSize();
VECTOR2D screenSize = getView()->GetViewport().GetSize();
@ -583,6 +584,6 @@ void SCH_EDIT_FRAME::KiwayMailIn( KIWAY_EXPRESS& mail )
break;
}
default:;
}
}

View File

@ -1177,6 +1177,20 @@ const EDA_RECT SCH_COMPONENT::GetBoundingBox() const
}
const EDA_RECT SCH_COMPONENT::GetBoundingBox( bool aIncludeInvisibleText ) const
{
EDA_RECT bbox = GetBodyBoundingBox();
for( const SCH_FIELD& field : m_Fields )
{
if( field.IsVisible() || aIncludeInvisibleText )
bbox.Merge( field.GetBoundingBox() );
}
return bbox;
}
void SCH_COMPONENT::GetMsgPanelInfo( EDA_DRAW_FRAME* aFrame, MSG_PANEL_ITEMS& aList )
{
wxString msg;

View File

@ -376,6 +376,8 @@ public:
const EDA_RECT GetBoundingBox() const override;
const EDA_RECT GetBoundingBox( bool aIncludeInvisibleText ) const;
/**
* Return a bounding box for the symbol body but not the fields.
*/