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
This commit is contained in:
Seth Hillbrand 2018-09-08 20:40:24 -07:00
parent 21ea31af15
commit 29b4ac7cb8
2 changed files with 23 additions and 6 deletions

View File

@ -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();
}
@ -1372,7 +1372,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 );
@ -1785,7 +1785,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 );
@ -1803,8 +1803,17 @@ void EAGLE_PLUGIN::packageHole( MODULE* aModule, wxXmlNode* aTree ) const
wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
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() );

View File

@ -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