7
mirror of https://gitlab.com/kicad/code/kicad.git synced 2025-04-18 19:39:17 +00:00

Correct rotations for flipped parts

Rotation is always seen as clockwise from the top of the board in 2581

Fixes https://gitlab.com/kicad/code/kicad/-/issues/19675
This commit is contained in:
Seth Hillbrand 2025-01-20 12:08:53 -08:00
parent 689441ebab
commit abbdea4412
2 changed files with 10 additions and 8 deletions

View File

@ -259,9 +259,9 @@ wxString PCB_IO_IPC2581::componentName( FOOTPRINT* aFootprint )
}
wxString PCB_IO_IPC2581::floatVal( double aVal )
wxString PCB_IO_IPC2581::floatVal( double aVal, int aSigFig ) const
{
wxString str = wxString::FromCDouble( aVal, m_sigfig );
wxString str = wxString::FromCDouble( aVal, aSigFig == -1 ? m_sigfig : aSigFig );
// Remove all but the last trailing zeros from str
while( str.EndsWith( wxT( "00" ) ) )
@ -2476,11 +2476,13 @@ void PCB_IO_IPC2581::generateComponents( wxXmlNode* aStepNode )
{
wxXmlNode* xformNode = appendNode( componentNode, "Xform" );
if( fp->GetOrientation() != ANGLE_0 )
{
addAttribute( xformNode, "rotation",
floatVal( fp->GetOrientation().Normalize().AsDegrees() ) );
}
EDA_ANGLE fp_angle = fp->GetOrientation().Normalize();
if( fp->GetLayer() == B_Cu )
fp_angle = ( fp_angle.Invert() - ANGLE_180 ).Normalize();
if( fp_angle != ANGLE_0 )
addAttribute( xformNode, "rotation", floatVal( fp_angle.AsDegrees(), 2 ) );
if( fp->GetLayer() != F_Cu )
addAttribute( xformNode, "mirror", "true" );

View File

@ -243,7 +243,7 @@ private:
wxString genLayerString( PCB_LAYER_ID aLayer, const char* aPrefix ) const;
wxString genLayersString( PCB_LAYER_ID aTop, PCB_LAYER_ID aBottom, const char* aPrefix ) const;
wxString floatVal( double aVal );
wxString floatVal( double aVal, int aSigFig = -1 ) const;
wxString pinName( const PAD* aPad ) const;