From 87d2caa4c651ec113538b587e8c7a475c62377d3 Mon Sep 17 00:00:00 2001 From: Cirilo Bbernardo Date: Fri, 7 Feb 2014 17:01:46 +0100 Subject: [PATCH] IDF export: fix incorrect rotation of flipped items. --- pcbnew/exporters/export_idf.cpp | 4 +++- pcbnew/exporters/idf.cpp | 32 +++++++++++++++++++++++++++----- 2 files changed, 30 insertions(+), 6 deletions(-) diff --git a/pcbnew/exporters/export_idf.cpp b/pcbnew/exporters/export_idf.cpp index 6becbe26cf..3d363f5caa 100644 --- a/pcbnew/exporters/export_idf.cpp +++ b/pcbnew/exporters/export_idf.cpp @@ -334,7 +334,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, refdes = aIDFBoard.GetRefDes(); } - double rotz = modfile->m_MatRotation.z + aModule->GetOrientation()/10.0; + double rotz = aModule->GetOrientation()/10.0; double locx = modfile->m_MatPosition.x; double locy = modfile->m_MatPosition.y; double locz = modfile->m_MatPosition.z; @@ -343,6 +343,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, if( top ) { + rotz += modfile->m_MatRotation.z; locy = -locy; RotatePoint( &locx, &locy, aModule->GetOrientation() ); locy = -locy; @@ -352,6 +353,7 @@ static void idf_export_module( BOARD* aPcb, MODULE* aModule, RotatePoint( &locx, &locy, aModule->GetOrientation() ); locy = -locy; + rotz -= modfile->m_MatRotation.z; rotz = 180.0 - rotz; if( rotz >= 360.0 ) diff --git a/pcbnew/exporters/idf.cpp b/pcbnew/exporters/idf.cpp index 03a29692bf..21e4af1c9d 100644 --- a/pcbnew/exporters/idf.cpp +++ b/pcbnew/exporters/idf.cpp @@ -1055,13 +1055,35 @@ bool IDF_COMP::substituteComponent( FILE* aLibFile ) if( parent->RegisterOutline( "NOGEOM_NOPART" ) ) return true; + // Create a star shape 5mm high with points on 5 and 2.5 mm circles fprintf( aLibFile, ".ELECTRICAL\n" ); fprintf( aLibFile, "\"NOGEOM\" \"NOPART\" MM 5\n" ); - // TODO: for now we shall use a simple cylinder; a more intricate - // and readily recognized feature (a stylistic X) would be of - // much greater value. - fprintf( aLibFile, "0 0 0 0\n" ); - fprintf( aLibFile, "0 2.5 0 360\n" ); + + double a, da, x, y; + da = M_PI / 5.0; + a = da / 2.0; + + for( int i = 0; i < 10; ++i ) + { + if( i & 1 ) + { + x = 2.5 * cos( a ); + y = 2.5 * sin( a ); + } + else + { + x = 1.5 * cos( a ); + y = 1.5 * sin( a ); + } + + a += da; + fprintf( aLibFile, "0 %.3f %.3f 0\n", x, y ); + } + + a = da / 2.0; + x = 1.5 * cos( a ); + y = 1.5 * sin( a ); + fprintf( aLibFile, "0 %.3f %.3f 0\n", x, y ); fprintf( aLibFile, ".END_ELECTRICAL\n\n" ); return true;