From 99859727e89a366583f2abe9bdddb480e1c7c62c Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Thu, 15 Aug 2019 22:58:45 -0700 Subject: [PATCH] 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 --- pcbnew/class_board.cpp | 63 +++++++++++++++--------------------------- 1 file changed, 23 insertions(+), 40 deletions(-) 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; } }