Fix reading/writing thermal spoke angles for custom pads.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15518

7.0 commit: 86ec36d183
This commit is contained in:
Alex Shvartzkop 2023-09-10 17:30:48 +03:00
parent 0e0c267829
commit 7eb4b0710d
2 changed files with 36 additions and 18 deletions

View File

@ -4264,21 +4264,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
Expecting( "circle, rectangle, roundrect, oval, trapezoid or custom" );
}
if( pad->GetShape() == PAD_SHAPE::CIRCLE )
{
pad->SetThermalSpokeAngle( ANGLE_45 );
}
else if( pad->GetShape() == PAD_SHAPE::CUSTOM && pad->GetAnchorPadShape() == PAD_SHAPE::CIRCLE )
{
if( m_requiredVersion < 20211226 )
pad->SetThermalSpokeAngle( ANGLE_90 );
else
pad->SetThermalSpokeAngle( ANGLE_45 );
}
else
{
pad->SetThermalSpokeAngle( ANGLE_90 );
}
std::optional<EDA_ANGLE> thermalBrAngleOverride;
for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{
@ -4480,7 +4466,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
break;
case T_thermal_bridge_angle:
pad->SetThermalSpokeAngle( EDA_ANGLE( parseDouble( "thermal spoke angle" ), DEGREES_T ) );
thermalBrAngleOverride = EDA_ANGLE( parseDouble( "thermal spoke angle" ), DEGREES_T );
NeedRIGHT();
break;
@ -4702,6 +4688,31 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
pad->SetNetCode( 0, /* aNoAssert */ true );
}
if( thermalBrAngleOverride )
{
pad->SetThermalSpokeAngle( *thermalBrAngleOverride );
}
else
{
// This is here because custom pad anchor shape isn't known before reading (options
if( pad->GetShape() == PAD_SHAPE::CIRCLE )
{
pad->SetThermalSpokeAngle( ANGLE_45 );
}
else if( pad->GetShape() == PAD_SHAPE::CUSTOM
&& pad->GetAnchorPadShape() == PAD_SHAPE::CIRCLE )
{
if( m_requiredVersion <= 20211014 ) // 6.0
pad->SetThermalSpokeAngle( ANGLE_90 );
else
pad->SetThermalSpokeAngle( ANGLE_45 );
}
else
{
pad->SetThermalSpokeAngle( ANGLE_90 );
}
}
if( !pad->CanHaveNumber() )
{
// At some point it was possible to assign a number to aperture pads so we need to clean

View File

@ -1636,8 +1636,15 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
formatInternalUnits( aPad->GetThermalSpokeWidth() ).c_str() );
}
if( ( aPad->GetShape() == PAD_SHAPE::CIRCLE && aPad->GetThermalSpokeAngle() != ANGLE_45 )
|| ( aPad->GetShape() != PAD_SHAPE::CIRCLE && aPad->GetThermalSpokeAngle() != ANGLE_90 ) )
EDA_ANGLE defaultThermalSpokeAngle = ANGLE_90;
if( aPad->GetShape() == PAD_SHAPE::CIRCLE ||
( aPad->GetShape() == PAD_SHAPE::CUSTOM && aPad->GetAnchorPadShape() == PAD_SHAPE::CIRCLE ) )
{
defaultThermalSpokeAngle = ANGLE_45;
}
if( aPad->GetThermalSpokeAngle() != defaultThermalSpokeAngle )
{
StrPrintf( &output, " (thermal_bridge_angle %s)",
EDA_UNIT_UTILS::FormatAngle( aPad->GetThermalSpokeAngle() ).c_str() );