Take footprint edge cuts into account in the board statistics

Reported in https://gitlab.com/kicad/code/kicad/-/issues/18245
This commit is contained in:
Ian McInerney 2024-06-29 03:11:54 +01:00
parent c8ebcc8e0f
commit 10988478da
1 changed files with 3 additions and 28 deletions

View File

@ -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,17 +373,10 @@ 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();