From e29e7ff95d5a0878ce702cdb127bbeb9bfaa871d Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Sat, 8 Sep 2018 20:40:24 -0700 Subject: [PATCH] pcbnew: Fix Eagle import hole offset Unplated holes in Ealge can either be free floating or part of a larger footprint. We handle both in the same packageHole routine by either offsetting the hole in a centered footprint or offsetting the footprint in a centered hole. Fixes: lp:1791287 * https://bugs.launchpad.net/kicad/+bug/1791287 --- pcbnew/eagle_plugin.cpp | 19 ++++++++++++++----- pcbnew/eagle_plugin.h | 10 +++++++++- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index e4d5666c36..6b82ea74da 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -689,7 +689,7 @@ void EAGLE_PLUGIN::loadPlain( wxXmlNode* aGraphics ) module->SetReference( wxString::Format( "@HOLE%d", m_hole_count++ ) ); module->Reference().SetVisible( false ); - packageHole( module, gr ); + packageHole( module, gr, true ); m_xpath->pop(); } @@ -1377,7 +1377,7 @@ MODULE* EAGLE_PLUGIN::makeModule( wxXmlNode* aPackage, const wxString& aPkgName packageCircle( m.get(), packageItem ); else if( itemName == "hole" ) - packageHole( m.get(), packageItem ); + packageHole( m.get(), packageItem, false ); else if( itemName == "smd" ) packageSMD( m.get(), packageItem ); @@ -1790,7 +1790,7 @@ void EAGLE_PLUGIN::packageCircle( MODULE* aModule, wxXmlNode* aTree ) const } -void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree ) const +void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter ) const { EHOLE e( aTree ); @@ -1808,8 +1808,17 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree ) const wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) ); - pad->SetPos0( padpos ); - pad->SetPosition( padpos + aModule->GetPosition() ); + if( aCenter ) + { + pad->SetPos0( wxPoint( 0, 0 ) ); + aModule->SetPosition( padpos ); + pad->SetPosition( padpos ); + } + else + { + pad->SetPos0( padpos ); + pad->SetPosition( padpos + aModule->GetPosition() ); + } wxSize sz( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() ); diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index b945f5ea71..e3df6d5355 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -266,7 +266,15 @@ private: void packageRectangle( MODULE* aModule, wxXmlNode* aTree ) const; void packagePolygon( MODULE* aModule, wxXmlNode* aTree ) const; void packageCircle( MODULE* aModule, wxXmlNode* aTree ) const; - void packageHole( MODULE* aModule, wxXmlNode* aTree ) const; + + /** + * Function packageHole + * @parameter aModule - The KiCad module to which to assign the hole + * @parameter aTree - The Eagle XML node that is of type "hole" + * @parameter aCenter - If true, center the hole in the module and + * offset the module position + */ + void packageHole( MODULE* aModule, wxXmlNode* aTree, bool aCenter ) const; void packageSMD( MODULE* aModule, wxXmlNode* aTree ) const; ///> Handles common pad properties