From 33f39fc282e759ab9f5f215a848a057cb6e3965c Mon Sep 17 00:00:00 2001 From: Paul LeoNerd Evens Date: Sun, 7 Dec 2014 12:07:05 -0500 Subject: [PATCH] Fix Eagle footprint library import of arcs. (fixes lp:1399745) --- pcbnew/eagle_plugin.cpp | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 1d307e9ede..fda3e90a98 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1938,14 +1938,39 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) ); int width = kicad( w.width ); - EDGE_MODULE* dwg = new EDGE_MODULE( aModule, S_SEGMENT ); - aModule->GraphicalItems().PushBack( dwg ); + EDGE_MODULE* dwg; + if( !w.curve ) + { + dwg = new EDGE_MODULE( aModule, S_SEGMENT ); - dwg->SetStart0( start ); - dwg->SetEnd0( end ); + dwg->SetStart0( start ); + dwg->SetEnd0( end ); + } + else + { + dwg = new EDGE_MODULE( aModule, S_ARC ); + // Eagle give us start and end. + // S_ARC wants start to give the centre, and end to give the start + double dx = end.x - start.x, dy = end.y - start.y; + wxPoint mid = (start + end) / 2; + + double dlen = sqrt( dx*dx + dy*dy ); + double dist = dlen / ( 2 * tan( DEG2RAD( *w.curve ) / 2 ) ); + + wxPoint centre( + mid.x + dist * ( dy / dlen ), + mid.y - dist * ( dx / dlen ) + ); + + dwg->SetStart0( centre ); + dwg->SetEnd0( start ); + dwg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way + } dwg->SetLayer( layer ); dwg->SetWidth( width ); + + aModule->GraphicalItems().PushBack( dwg ); } }