pcb_parser and pcb_plugin: fix incorrect handling of rotation of PCB_TEXTs
in footprints when the text angle is 0 but the fp orientation is not 0. It was due to the fact angle 0 is not written in file and use the default value of the created PCB_TEXT in footprint, that is not always 0 Now the angle is always written in file. Fixes #15054 https://gitlab.com/kicad/code/kicad/-/issues/15054
This commit is contained in:
parent
f3122184df
commit
af71308184
|
@ -3051,6 +3051,8 @@ PCB_TEXT* PCB_PARSER::parsePCB_TEXT( BOARD_ITEM* aParent )
|
|||
void PCB_PARSER::parsePCB_TEXT_effects( PCB_TEXT* aText )
|
||||
{
|
||||
FOOTPRINT* parentFP = dynamic_cast<FOOTPRINT*>( aText->GetParent() );
|
||||
bool hasAngle = false; // Old files do not have a angle specified.
|
||||
// in this case it is 0 expected to be 0
|
||||
|
||||
// By default, texts in footprints have a locked rotation (i.e. rot = -90 ... 90 deg)
|
||||
if( parentFP )
|
||||
|
@ -3072,10 +3074,10 @@ void PCB_PARSER::parsePCB_TEXT_effects( PCB_TEXT* aText )
|
|||
aText->SetTextPos( pt );
|
||||
token = NextTok();
|
||||
|
||||
// If there is no orientation defined, then it is the default value of 0 degrees.
|
||||
if( CurTok() == T_NUMBER )
|
||||
{
|
||||
aText->SetTextAngle( EDA_ANGLE( parseDouble(), DEGREES_T ) );
|
||||
hasAngle = true;
|
||||
token = NextTok();
|
||||
}
|
||||
|
||||
|
@ -3133,6 +3135,10 @@ void PCB_PARSER::parsePCB_TEXT_effects( PCB_TEXT* aText )
|
|||
}
|
||||
}
|
||||
|
||||
// If there is no orientation defined, then it is the default value of 0 degrees.
|
||||
if( !hasAngle )
|
||||
aText->SetTextAngle( ANGLE_0 );
|
||||
|
||||
if( parentFP )
|
||||
{
|
||||
// make PCB_TEXT rotation relative to the parent footprint.
|
||||
|
|
|
@ -1795,7 +1795,7 @@ void PCB_PLUGIN::format( const PCB_TEXT* aText, int aNestLevel ) const
|
|||
m_out->Print( 0, " (at %s", formatInternalUnits( pos ).c_str() );
|
||||
|
||||
// Due to Pcbnew history, fp_text angle is saved as an absolute on screen angle.
|
||||
if( !aText->GetTextAngle().IsZero() )
|
||||
// To avoid issues in the future, always save the angle, even if it is 0
|
||||
m_out->Print( 0, " %s", EDA_UNIT_UTILS::FormatAngle( aText->GetTextAngle() ).c_str() );
|
||||
|
||||
if( parentFP && !aText->IsKeepUpright() )
|
||||
|
|
Loading…
Reference in New Issue