From 10988478da36a6755f23104061528ecac647048c Mon Sep 17 00:00:00 2001 From: Ian McInerney Date: Sat, 29 Jun 2024 03:11:54 +0100 Subject: [PATCH] Take footprint edge cuts into account in the board statistics Reported in https://gitlab.com/kicad/code/kicad/-/issues/18245 --- pcbnew/dialogs/dialog_board_statistics.cpp | 31 +++------------------- 1 file changed, 3 insertions(+), 28 deletions(-) diff --git a/pcbnew/dialogs/dialog_board_statistics.cpp b/pcbnew/dialogs/dialog_board_statistics.cpp index 241b7d8280..4d45d8ec05 100644 --- a/pcbnew/dialogs/dialog_board_statistics.cpp +++ b/pcbnew/dialogs/dialog_board_statistics.cpp @@ -325,27 +325,9 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() sort( m_drillTypes.begin(), m_drillTypes.end(), DRILL_LINE_ITEM::COMPARE( DRILL_LINE_ITEM::COL_COUNT, false ) ); - bool boundingBoxCreated = false; //flag if bounding box initialized - BOX2I bbox; SHAPE_POLY_SET polySet; m_hasOutline = board->GetBoardPolygonOutlines( polySet ); - // If board has no Edge Cuts lines, board->GetBoardPolygonOutlines will - // return small rectangle, so we double check that - bool edgeCutsExists = false; - - for( BOARD_ITEM* drawing : board->Drawings() ) - { - if( drawing->GetLayer() == Edge_Cuts ) - { - edgeCutsExists = true; - break; - } - } - - if( !edgeCutsExists ) - m_hasOutline = false; - if( m_hasOutline ) { m_boardArea = 0.0; @@ -391,18 +373,11 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB() } } } - - if( boundingBoxCreated ) - { - bbox.Merge( outline.BBox() ); - } - else - { - bbox = outline.BBox(); - boundingBoxCreated = true; - } } + // Compute the bounding box to get a rectangular size + BOX2I bbox = board->GetBoardEdgesBoundingBox(); + m_boardWidth = bbox.GetWidth(); m_boardHeight = bbox.GetHeight(); }