Eeschema: fix incorrect stored rotation value in file of the global and hierarch. labels.

The stored value was the rotation of the text (always 0 or 90 deg), but these labels can also
be rotated by -90 or 180 deg
Fixes #10450
https://gitlab.com/kicad/code/kicad/issues/10450
Fixes #10457
https://gitlab.com/kicad/code/kicad/issues/10457
This commit is contained in:
jean-pierre charras 2022-01-16 17:19:36 +01:00
parent c154e85ebd
commit 516d038bdf
1 changed files with 16 additions and 2 deletions

View File

@ -1418,11 +1418,25 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
FormatInternalUnits( label->GetPinLength() ).c_str() );
}
EDA_ANGLE angle = aText->GetTextAngle();
if( aText->Type() == SCH_GLOBAL_LABEL_T
|| aText->Type() == SCH_HIER_LABEL_T
|| aText->Type() == SCH_NETCLASS_FLAG_T )
{
m_out->Print( 0, " (shape %s)", getSheetPinShapeToken( aText->GetShape() ) );
// The angle of the text is always 0 or 90 degrees for readibility reasons,
// but the item itself can have more rotation (-90 and 180 deg)
switch( aText->GetLabelSpinStyle() )
{
default:
case LABEL_SPIN_STYLE::LEFT: angle += ANGLE_180; break;
case LABEL_SPIN_STYLE::UP: break;
case LABEL_SPIN_STYLE::RIGHT: break;
case LABEL_SPIN_STYLE::BOTTOM: angle += ANGLE_180; break;
}
}
if( aText->GetText().Length() < 50 )
@ -1430,7 +1444,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
m_out->Print( 0, " (at %s %s %s)",
FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).c_str(),
FormatAngle( aText->GetTextAngle() ).c_str() );
FormatAngle( angle ).c_str() );
}
else
{
@ -1438,7 +1452,7 @@ void SCH_SEXPR_PLUGIN::saveText( SCH_TEXT* aText, int aNestLevel )
m_out->Print( aNestLevel + 1, "(at %s %s %s)",
FormatInternalUnits( aText->GetPosition().x ).c_str(),
FormatInternalUnits( aText->GetPosition().y ).c_str(),
FormatAngle( aText->GetTextAngle() ).c_str() );
FormatAngle( angle ).c_str() );
}
if( aText->GetFieldsAutoplaced() != FIELDS_AUTOPLACED_NO )