From aeb999b9ae91c53c8e4462fa1eb6b35caaa5a7ff Mon Sep 17 00:00:00 2001 From: Maciej Suminski Date: Tue, 13 Mar 2018 14:42:01 +0100 Subject: [PATCH] Eagle PCB import: handle solder mask & paste for pads Fixes: lp:1754138 * https://bugs.launchpad.net/kicad/+bug/1754138 --- pcbnew/eagle_plugin.cpp | 32 ++++++++++++++++++++++++++++++-- pcbnew/eagle_plugin.h | 14 ++++++++++++++ 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 918065c536..bdee30f3d0 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -121,6 +121,20 @@ void ERULES::parse( wxXmlNode* aRules ) psElongationLong = wxAtoi( value ); else if( name == "psElongationOffset" ) psElongationOffset = wxAtoi( value ); + + else if( name == "mvStopFrame" ) + value.ToDouble( &mvStopFrame ); + else if( name == "mvCreamFrame" ) + value.ToDouble( &mvCreamFrame ); + else if( name == "mlMinStopFrame" ) + mlMinStopFrame = parseEagle( value ); + else if( name == "mlMaxStopFrame" ) + mlMaxStopFrame = parseEagle( value ); + else if( name == "mlMinCreamFrame" ) + mlMinCreamFrame = parseEagle( value ); + else if( name == "mlMaxCreamFrame" ) + mlMaxCreamFrame = parseEagle( value ); + else if( name == "rvPadTop" ) value.ToDouble( &rvPadTop ); else if( name == "rlMinPadTop" ) @@ -1634,7 +1648,8 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const pad->SetShape( PAD_SHAPE_RECT ); pad->SetAttribute( PAD_ATTRIB_SMD ); - pad->SetSize( wxSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() ) ); + wxSize padSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() ); + pad->SetSize( padSize ); pad->SetLayer( layer ); const LSET front( 3, F_Cu, F_Paste, F_Mask ); @@ -1658,8 +1673,14 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const pad->SetOrientation( e.rot->degrees * 10 ); } - // don't know what stop, thermals, and cream should look like now. + // Solder paste (only for SMD pads) + int solderPasteSize = m_rules->mvCreamFrame * std::min( padSize.x, padSize.y ); + solderPasteSize = std::min( solderPasteSize, m_rules->mlMaxCreamFrame ); + solderPasteSize = std::max( solderPasteSize, m_rules->mlMinCreamFrame ); + pad->SetLocalSolderPasteMargin( solderPasteSize ); + // @todo: handle thermal +} void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, D_PAD* aPad ) const @@ -1671,6 +1692,13 @@ void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, D_PAD* aPad ) cons wxPoint padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) ); aPad->SetPos0( padPos ); + // Solder mask + const wxSize& padSize( aPad->GetSize() ); + int solderMaskSize = m_rules->mvStopFrame * std::min( padSize.x, padSize.y ); + solderMaskSize = std::min( solderMaskSize, m_rules->mlMaxStopFrame ); + solderMaskSize = std::max( solderMaskSize, m_rules->mlMinStopFrame ); + aPad->SetLocalSolderMaskMargin( solderMaskSize ); + MODULE* module = aPad->GetParent(); wxCHECK( module, /* void */ ); RotatePoint( &padPos, module->GetOrientation() ); diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index 6c94ae4247..f7399f3e63 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -47,6 +47,12 @@ struct ERULES int psElongationOffset; ///< the offset of the hole within the "long" pad. + double mvStopFrame; ///< solder mask, expressed as percentage of the smaller pad/via dimension + double mvCreamFrame; ///< solderpaste mask, expressed as percentage of the smaller pad/via dimension + int mlMinStopFrame; ///< solder mask, minimum size (mils) + int mlMaxStopFrame; ///< solder mask, maximum size (mils) + int mlMinCreamFrame; ///< solder paste mask, minimum size (mils) + int mlMaxCreamFrame; ///< solder paste mask, maximum size (mils) double rvPadTop; ///< top pad size as percent of drill size // double rvPadBottom; ///< bottom pad size as percent of drill size @@ -63,6 +69,14 @@ struct ERULES ERULES() : psElongationLong ( 100 ), psElongationOffset ( 0 ), + + mvStopFrame ( 1.0 ), + mvCreamFrame ( 0.0 ), + mlMinStopFrame ( Mils2iu( 4.0 ) ), + mlMaxStopFrame ( Mils2iu( 4.0 ) ), + mlMinCreamFrame ( Mils2iu( 0.0 ) ), + mlMaxCreamFrame ( Mils2iu( 0.0 ) ), + rvPadTop ( 0.25 ), // rvPadBottom ( 0.25 ), rlMinPadTop ( Mils2iu( 10 ) ),