Exercise more care when comparing doubles.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/17249
This commit is contained in:
Jeff Young 2024-05-05 17:32:07 +01:00
parent 5bd94f118d
commit 62d4bd7c1d
3 changed files with 10 additions and 23 deletions

View File

@ -307,8 +307,8 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter )
wxString::Format( _( "%s fabrication property differs." ), PAD_DESC( a ) ) );
// The pad orientation, for historical reasons is the pad rotation + parent rotation.
TEST_D( ( a->GetOrientation() - a->GetParentFootprint()->GetOrientation() ).Normalize().AsDegrees(),
( b->GetOrientation() - b->GetParentFootprint()->GetOrientation() ).Normalize().AsDegrees(),
TEST_D( a->GetFPRelativeOrientation().Normalize().AsDegrees(),
b->GetFPRelativeOrientation().Normalize().AsDegrees(),
wxString::Format( _( "%s orientation differs." ), PAD_DESC( a ) ) );
TEST( a->GetSize(), b->GetSize(),
@ -316,27 +316,14 @@ bool padNeedsUpdate( const PAD* a, const PAD* b, REPORTER* aReporter )
TEST( a->GetDelta(), b->GetDelta(),
wxString::Format( _( "%s trapezoid delta differs." ), PAD_DESC( a ) ) );
if( a->GetRoundRectCornerRadius() != b->GetRoundRectCornerRadius()
|| a->GetRoundRectRadiusRatio() != b->GetRoundRectRadiusRatio() )
{
diff = true;
TEST_D( a->GetRoundRectRadiusRatio(), b->GetRoundRectRadiusRatio(),
wxString::Format( _( "%s rounded corners differ." ), PAD_DESC( a ) ) );
if( aReporter )
aReporter->Report( wxString::Format( _( "%s rounded corners differ." ), PAD_DESC( a ) ) );
else
return true;
}
TEST_D( a->GetChamferRectRatio(), b->GetChamferRectRatio(),
wxString::Format( _( "%s chamfered corner sizes differ." ), PAD_DESC( a ) ) );
if( a->GetChamferRectRatio() != b->GetChamferRectRatio()
|| a->GetChamferPositions() != b->GetChamferPositions() )
{
diff = true;
if( aReporter )
aReporter->Report( wxString::Format( _( "%s chamfered corners differ." ), PAD_DESC( a ) ) );
else
return true;
}
TEST( a->GetChamferPositions(), b->GetChamferPositions(),
wxString::Format( _( "%s chamfered corners differ." ), PAD_DESC( a ) ) );
TEST_PT( a->GetOffset(), b->GetOffset(),
wxString::Format( _( "%s shape offset from hole differs." ), PAD_DESC( a ) ) );

View File

@ -874,7 +874,7 @@ void PAD::SetFPRelativeOrientation( const EDA_ANGLE& aAngle )
}
EDA_ANGLE PAD::GetFPRelativeOrientation()
EDA_ANGLE PAD::GetFPRelativeOrientation() const
{
if( FOOTPRINT* parentFP = GetParentFootprint() )
return GetOrientation() - parentFP->GetOrientation();

View File

@ -343,7 +343,7 @@ public:
* Return the rotation angle of the pad.
*/
EDA_ANGLE GetOrientation() const { return m_orient; }
EDA_ANGLE GetFPRelativeOrientation();
EDA_ANGLE GetFPRelativeOrientation() const;
// For property system
void SetOrientationDegrees( double aOrientation )