pcbnew: Handle edge cuts in footprints for bbox

The Board bounding box calculation has two modes: edges only and
everything.  While the everything mode works as expected, the edges only
calculation (and everything that depends on it) was seeing only the edge
cuts on the board drawings layer and not the footprint edge cuts.

Fixes: lp:1839768
* https://bugs.launchpad.net/kicad/+bug/1839768

(cherry picked from commit 99859727e8)
This commit is contained in:
Seth Hillbrand 2019-08-15 22:58:45 -07:00
parent 211d056728
commit 2dd7a8637c
1 changed files with 24 additions and 48 deletions

View File

@ -1128,84 +1128,60 @@ unsigned BOARD::GetUnconnectedNetCount() const
EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const
{ {
bool hasItems = false;
EDA_RECT area; EDA_RECT area;
LSET visible = GetVisibleLayers(); LSET visible = GetVisibleLayers();
// Check segments, dimensions, texts, and fiducials // Check segments, dimensions, texts, and fiducials
for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = m_Drawings; item; item = item->Next() )
{ {
if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts ) ) if( aBoardEdgesOnly && ( item->GetLayer() != Edge_Cuts ) )
continue; continue;
if( !( item->GetLayerSet() & visible ).any() ) if( ( item->GetLayerSet() & visible ).any() )
continue;
if( !hasItems )
area = item->GetBoundingBox();
else
area.Merge( item->GetBoundingBox() ); area.Merge( item->GetBoundingBox() );
}
hasItems = true; // Check modules
for( MODULE* module = m_Modules; module; module = module->Next() )
{
if( !( module->GetLayerSet() & visible ).any() )
continue;
if( aBoardEdgesOnly )
{
for( const auto edge : module->GraphicalItems() )
{
if( edge->GetLayer() == Edge_Cuts )
area.Merge( edge->GetBoundingBox() );
}
}
else
{
area.Merge( module->GetBoundingBox() );
}
} }
if( !aBoardEdgesOnly ) if( !aBoardEdgesOnly )
{ {
// Check modules
for( MODULE* module = m_Modules; module; module = module->Next() )
{
if( !( module->GetLayerSet() & visible ).any() )
continue;
if( !hasItems )
area = module->GetBoundingBox();
else
area.Merge( module->GetBoundingBox() );
hasItems = true;
}
// Check tracks // Check tracks
for( TRACK* track = m_Track; track; track = track->Next() ) for( TRACK* track = m_Track; track; track = track->Next() )
{ {
if( !( track->GetLayerSet() & visible ).any() ) if( ( track->GetLayerSet() & visible ).any() )
continue;
if( !hasItems )
area = track->GetBoundingBox();
else
area.Merge( track->GetBoundingBox() ); area.Merge( track->GetBoundingBox() );
hasItems = true;
} }
// Check segment zones // Check segment zones
for( TRACK* track = m_SegZoneDeprecated; track; track = track->Next() ) for( TRACK* track = m_SegZoneDeprecated; track; track = track->Next() )
{ {
if( !( track->GetLayerSet() & visible ).any() ) if( ( track->GetLayerSet() & visible ).any() )
continue;
if( !hasItems )
area = track->GetBoundingBox();
else
area.Merge( track->GetBoundingBox() ); area.Merge( track->GetBoundingBox() );
hasItems = true;
} }
// Check polygonal zones // Check polygonal zones
for( auto aZone : m_ZoneDescriptorList ) for( auto aZone : m_ZoneDescriptorList )
{ {
if( !( aZone->GetLayerSet() & visible ).any() ) if( ( aZone->GetLayerSet() & visible ).any() )
continue;
if( !hasItems )
area = aZone->GetBoundingBox();
else
area.Merge( aZone->GetBoundingBox() ); area.Merge( aZone->GetBoundingBox() );
area.Merge( aZone->GetBoundingBox() );
hasItems = true;
} }
} }