Inflate footprint bounding box to include texts.

This makes zoom automatique work much better in the footprint
editor, and should improve other things which probably assumed
the bounding box included everything (such as refresh code).

Callers which still want just the module outline should call
GetFootprintRect() instead of GetBoundingBox().
This commit is contained in:
Jeff Young 2018-08-09 01:11:47 +01:00
parent 38464827fc
commit 43e99e6df0
3 changed files with 19 additions and 9 deletions

View File

@ -72,7 +72,7 @@ void fillRectList( CSubRectArray& vecSubRects, std::vector <MODULE*>& aModuleLis
for( unsigned ii = 0; ii < aModuleList.size(); ii++ )
{
EDA_RECT fpBox = aModuleList[ii]->GetBoundingBox();
EDA_RECT fpBox = aModuleList[ii]->GetFootprintRect();
TSubRect fpRect( fpBox.GetWidth()/scale, fpBox.GetHeight()/scale, ii );
vecSubRects.push_back( fpRect );
}
@ -156,7 +156,7 @@ void moveFootprintsInArea( CRectPlacement& aPlacementArea,
MODULE * module = aModuleList[vecSubRects[it].n];
EDA_RECT fpBBox = module->GetBoundingBox();
EDA_RECT fpBBox = module->GetFootprintRect();
wxPoint mod_pos = pos + ( module->GetPosition() - fpBBox.GetOrigin() )
+ aFreeArea.GetOrigin();

View File

@ -478,10 +478,8 @@ EDA_RECT MODULE::GetFootprintRect() const
for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() )
{
const EDGE_MODULE* edge = dyn_cast<const EDGE_MODULE*>( item );
if( edge )
area.Merge( edge->GetBoundingBox() );
if( item->Type() == PCB_MODULE_EDGE_T )
area.Merge( item->GetBoundingBox() );
}
for( D_PAD* pad = m_Pads; pad; pad = pad->Next() )
@ -493,7 +491,19 @@ EDA_RECT MODULE::GetFootprintRect() const
const EDA_RECT MODULE::GetBoundingBox() const
{
return GetFootprintRect();
EDA_RECT area = GetFootprintRect();
// Add in items not collected by GetFootprintRect():
for( const BOARD_ITEM* item = m_Drawings.GetFirst(); item; item = item->Next() )
{
if( item->Type() != PCB_MODULE_EDGE_T )
area.Merge( item->GetBoundingBox() );
}
area.Merge( m_Value->GetBoundingBox() );
area.Merge( m_Reference->GetBoundingBox() );
return area;
}

View File

@ -1493,8 +1493,8 @@ BOARD_ITEM* SELECTION_TOOL::pickSmallestComponent( GENERAL_COLLECTOR* aCollector
{
MODULE* module = (MODULE*) ( *aCollector )[i];
int lx = module->GetBoundingBox().GetWidth();
int ly = module->GetBoundingBox().GetHeight();
int lx = module->GetFootprintRect().GetWidth();
int ly = module->GetFootprintRect().GetHeight();
int lmin = std::min( lx, ly );