Commit 41e044c0 authored by Nick Østergaard's avatar Nick Østergaard Committed by Wayne Stambaugh

Handle arcs in board outline in Eagle pluging.

parent bb7a74f5
...@@ -49,7 +49,6 @@ our error message. ...@@ -49,7 +49,6 @@ our error message.
Load() TODO's Load() TODO's
*) verify zone fill clearances are correct *) verify zone fill clearances are correct
*) there is a problem with ARC line segments
*/ */
...@@ -1058,6 +1057,26 @@ static inline unsigned long timeStamp( CPTREE& aTree ) ...@@ -1058,6 +1057,26 @@ static inline unsigned long timeStamp( CPTREE& aTree )
} }
/// Convert an Eagle curve end to a KiCad center for S_ARC
wxPoint kicad_arc_center( wxPoint start, wxPoint end, double angle )
{
// Eagle give us start and end.
// S_ARC wants start to give the center, 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( angle ) / 2 ) );
wxPoint center(
mid.x + dist * ( dy / dlen ),
mid.y - dist * ( dx / dlen )
);
return center;
}
EAGLE_PLUGIN::EAGLE_PLUGIN() : EAGLE_PLUGIN::EAGLE_PLUGIN() :
m_rules( new ERULES() ), m_rules( new ERULES() ),
m_xpath( new XPATH() ), m_xpath( new XPATH() ),
...@@ -1349,16 +1368,33 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics ) ...@@ -1349,16 +1368,33 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics )
EWIRE w( gr->second ); EWIRE w( gr->second );
LAYER_ID layer = kicad_layer( w.layer ); LAYER_ID layer = kicad_layer( w.layer );
wxPoint start( kicad_x( w.x1 ), kicad_y( w.y1 ) );
wxPoint end( kicad_x( w.x2 ), kicad_y( w.y2 ) );
int width = kicad( w.width );
if( layer != UNDEFINED_LAYER ) if( layer != UNDEFINED_LAYER )
{ {
DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board ); DRAWSEGMENT* dseg = new DRAWSEGMENT( m_board );
m_board->Add( dseg, ADD_APPEND ); m_board->Add( dseg, ADD_APPEND );
if( !w.curve )
{
dseg->SetStart( start );
dseg->SetEnd( end );
}
else
{
wxPoint center = kicad_arc_center( start, end, *w.curve);
dseg->SetShape( S_ARC );
dseg->SetStart( center );
dseg->SetEnd( start );
dseg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
}
dseg->SetTimeStamp( timeStamp( gr->second ) ); dseg->SetTimeStamp( timeStamp( gr->second ) );
dseg->SetLayer( layer ); dseg->SetLayer( layer );
dseg->SetStart( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) ); dseg->SetWidth( width );
dseg->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
dseg->SetWidth( kicad( w.width ) );
} }
m_xpath->pop(); m_xpath->pop();
} }
...@@ -1949,20 +1985,9 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const ...@@ -1949,20 +1985,9 @@ void EAGLE_PLUGIN::packageWire( MODULE* aModule, CPTREE& aTree ) const
else else
{ {
dwg = new EDGE_MODULE( aModule, S_ARC ); dwg = new EDGE_MODULE( aModule, S_ARC );
// Eagle give us start and end. wxPoint center = kicad_arc_center( start, end, *w.curve);
// 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->SetStart0( center );
dwg->SetEnd0( start ); dwg->SetEnd0( start );
dwg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way dwg->SetAngle( *w.curve * -10.0 ); // KiCad rotates the other way
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment