pcbnew:Initialize board statistics

Uninitialized values can cause odd output values.  Also adjust absolute
calc to utilize floating point returns.

Fixes: lp:1838325
* https://bugs.launchpad.net/kicad/+bug/1838325
This commit is contained in:
Seth Hillbrand 2019-08-24 08:10:19 -07:00
parent f21467e340
commit 2518a2cc81
1 changed files with 8 additions and 7 deletions

View File

@ -67,7 +67,11 @@ struct DIALOG_BOARD_STATISTICS_SAVED_STATE
static DIALOG_BOARD_STATISTICS_SAVED_STATE s_savedDialogState;
DIALOG_BOARD_STATISTICS::DIALOG_BOARD_STATISTICS( PCB_EDIT_FRAME* aParentFrame ) :
DIALOG_BOARD_STATISTICS_BASE( aParentFrame )
DIALOG_BOARD_STATISTICS_BASE( aParentFrame ),
m_boardWidth( 0 ),
m_boardHeight( 0 ),
m_boardArea( 0.0 ),
m_hasOutline( false )
{
m_parentFrame = aParentFrame;
@ -263,12 +267,8 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
// If checkbox "subtract holes" is checked
if( m_checkBoxSubtractHoles->GetValue() )
{
int holesCount = polySet.HoleCount( i );
for( int j = 0; j < holesCount; j++ )
{
m_boardArea -= abs( polySet.Hole( i, j ).Area() );
}
for( int j = 0; j < polySet.HoleCount( i ); j++ )
m_boardArea -= std::fabs( polySet.Hole( i, j ).Area() );
}
if( GetUserUnits() == INCHES )
@ -286,6 +286,7 @@ void DIALOG_BOARD_STATISTICS::getDataFromPCB()
boundingBoxCreated = true;
}
}
m_boardWidth = bbox.GetWidth();
m_boardHeight = bbox.GetHeight();
}