Fix reading/writing thermal spoke angles for custom pads.

Fixes https://gitlab.com/kicad/code/kicad/-/issues/15518
This commit is contained in:
Alex Shvartzkop 2023-09-10 17:30:48 +03:00
parent 207f2e568b
commit 86ec36d183
2 changed files with 36 additions and 18 deletions

View File

@ -4641,21 +4641,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
Expecting( "circle, rectangle, roundrect, oval, trapezoid or custom" ); Expecting( "circle, rectangle, roundrect, oval, trapezoid or custom" );
} }
if( pad->GetShape() == PAD_SHAPE::CIRCLE ) std::optional<EDA_ANGLE> thermalBrAngleOverride;
{
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 );
}
for( token = NextTok(); token != T_RIGHT; token = NextTok() ) for( token = NextTok(); token != T_RIGHT; token = NextTok() )
{ {
@ -4851,7 +4837,7 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
break; break;
case T_thermal_bridge_angle: 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(); NeedRIGHT();
break; break;
@ -5066,6 +5052,31 @@ PAD* PCB_PARSER::parsePAD( FOOTPRINT* aParent )
} }
} }
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() ) if( !pad->CanHaveNumber() )
{ {
// At some point it was possible to assign a number to aperture pads so we need to clean // At some point it was possible to assign a number to aperture pads so we need to clean

View File

@ -1679,8 +1679,15 @@ void PCB_PLUGIN::format( const PAD* aPad, int aNestLevel ) const
EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetThermalSpokeWidth() ).c_str() ); EDA_UNIT_UTILS::FormatInternalUnits( pcbIUScale, aPad->GetThermalSpokeWidth() ).c_str() );
} }
if( ( aPad->GetShape() == PAD_SHAPE::CIRCLE && aPad->GetThermalSpokeAngle() != ANGLE_45 ) EDA_ANGLE defaultThermalSpokeAngle = ANGLE_90;
|| ( aPad->GetShape() != PAD_SHAPE::CIRCLE && aPad->GetThermalSpokeAngle() != 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)", StrPrintf( &output, " (thermal_bridge_angle %s)",
EDA_UNIT_UTILS::FormatAngle( aPad->GetThermalSpokeAngle() ).c_str() ); EDA_UNIT_UTILS::FormatAngle( aPad->GetThermalSpokeAngle() ).c_str() );