kicad-developers team mailing list archive
-
kicad-developers team
-
Mailing list archive
-
Message #12210
PATCH: IDF bug on flipped component
The attached patch fixes an IDF bug in the rotation of an object
on the bottom side of the board.
The patch also changes the default IDF model replacement from a
simple cylinder to a star-shaped object; this makes it obvious
to a user when a faulty component file has been included.
cheers,
Cirilo
=== modified file 'pcbnew/exporters/export_idf.cpp'
--- pcbnew/exporters/export_idf.cpp 2014-01-29 16:42:21 +0000
+++ pcbnew/exporters/export_idf.cpp 2014-02-06 21:23:07 +0000
@@ -334,7 +334,7 @@
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 @@
if( top )
{
+ rotz += modfile->m_MatRotation.z;
locy = -locy;
RotatePoint( &locx, &locy, aModule->GetOrientation() );
locy = -locy;
@@ -352,6 +353,7 @@
RotatePoint( &locx, &locy, aModule->GetOrientation() );
locy = -locy;
+ rotz -= modfile->m_MatRotation.z;
rotz = 180.0 - rotz;
if( rotz >= 360.0 )
=== modified file 'pcbnew/exporters/idf.cpp'
--- pcbnew/exporters/idf.cpp 2014-02-05 09:27:21 +0000
+++ pcbnew/exporters/idf.cpp 2014-02-06 21:35:38 +0000
@@ -1055,13 +1055,35 @@
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;