diff --git a/pcbnew/class_board.cpp b/pcbnew/class_board.cpp index 0dbe59020d..57cabf01e2 100644 --- a/pcbnew/class_board.cpp +++ b/pcbnew/class_board.cpp @@ -778,70 +778,53 @@ unsigned BOARD::GetUnconnectedNetCount() const EDA_RECT BOARD::ComputeBoundingBox( bool aBoardEdgesOnly ) const { - bool hasItems = false; EDA_RECT area; LSET visible = GetVisibleLayers(); // Check segments, dimensions, texts, and fiducials for( auto item : m_drawings ) { - if( aBoardEdgesOnly && (item->Type() != PCB_LINE_T || item->GetLayer() != Edge_Cuts ) ) + if( aBoardEdgesOnly && ( item->GetLayer() != Edge_Cuts ) ) continue; - if( !( item->GetLayerSet() & visible ).any() ) - continue; - - if( !hasItems ) - area = item->GetBoundingBox(); - else + if( ( item->GetLayerSet() & visible ).any() ) area.Merge( item->GetBoundingBox() ); + } - hasItems = true; + // Check modules + for( auto module : m_modules ) + { + 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 ) { - // Check modules - for( auto module : m_modules ) - { - if( !( module->GetLayerSet() & visible ).any() ) - continue; - - if( !hasItems ) - area = module->GetBoundingBox(); - else - area.Merge( module->GetBoundingBox() ); - - hasItems = true; - } - // Check tracks for( auto track : m_tracks ) { - if( !( track->GetLayerSet() & visible ).any() ) - continue; - - if( !hasItems ) - area = track->GetBoundingBox(); - else + if( ( track->GetLayerSet() & visible ).any() ) area.Merge( track->GetBoundingBox() ); - - hasItems = true; } // Check zones for( auto aZone : m_ZoneDescriptorList ) { - if( !( aZone->GetLayerSet() & visible ).any() ) - continue; - - if( !hasItems ) - area = aZone->GetBoundingBox(); - else + if( ( aZone->GetLayerSet() & visible ).any() ) area.Merge( aZone->GetBoundingBox() ); - - area.Merge( aZone->GetBoundingBox() ); - hasItems = true; } }