Eagle PCB import: unified code for handling pad properties
This commit is contained in:
parent
4c9be316dd
commit
4055c435a5
|
@ -621,7 +621,20 @@ wxSize ETEXT::ConvertSize() const
|
|||
}
|
||||
|
||||
|
||||
EPAD_COMMON::EPAD_COMMON( wxXmlNode* aPad )
|
||||
{
|
||||
// #REQUIRED says DTD, throw exception if not found
|
||||
name = parseRequiredAttribute<wxString>( aPad, "name" );
|
||||
x = parseRequiredAttribute<ECOORD>( aPad, "x" );
|
||||
y = parseRequiredAttribute<ECOORD>( aPad, "y" );
|
||||
rot = parseOptionalAttribute<EROT>( aPad, "rot" );
|
||||
stop = parseOptionalAttribute<bool>( aPad, "stop" );
|
||||
thermals = parseOptionalAttribute<bool>( aPad, "thermals" );
|
||||
}
|
||||
|
||||
|
||||
EPAD::EPAD( wxXmlNode* aPad )
|
||||
: EPAD_COMMON( aPad )
|
||||
{
|
||||
/*
|
||||
<!ELEMENT pad EMPTY>
|
||||
|
@ -640,9 +653,6 @@ EPAD::EPAD( wxXmlNode* aPad )
|
|||
*/
|
||||
|
||||
// #REQUIRED says DTD, throw exception if not found
|
||||
name = parseRequiredAttribute<wxString>( aPad, "name" );
|
||||
x = parseRequiredAttribute<ECOORD>( aPad, "x" );
|
||||
y = parseRequiredAttribute<ECOORD>( aPad, "y" );
|
||||
drill = parseRequiredAttribute<ECOORD>( aPad, "drill" );
|
||||
|
||||
// Optional attributes
|
||||
|
@ -662,14 +672,12 @@ EPAD::EPAD( wxXmlNode* aPad )
|
|||
else if( s == "offset" )
|
||||
shape = EPAD::OFFSET;
|
||||
|
||||
rot = parseOptionalAttribute<EROT>( aPad, "rot" );
|
||||
stop = parseOptionalAttribute<bool>( aPad, "stop" );
|
||||
thermals = parseOptionalAttribute<bool>( aPad, "thermals" );
|
||||
first = parseOptionalAttribute<bool>( aPad, "first" );
|
||||
}
|
||||
|
||||
|
||||
ESMD::ESMD( wxXmlNode* aSMD )
|
||||
: EPAD_COMMON( aSMD )
|
||||
{
|
||||
/*
|
||||
<!ATTLIST smd
|
||||
|
@ -688,18 +696,11 @@ ESMD::ESMD( wxXmlNode* aSMD )
|
|||
*/
|
||||
|
||||
// DTD #REQUIRED, throw exception if not found
|
||||
name = parseRequiredAttribute<wxString>( aSMD, "name" );
|
||||
x = parseRequiredAttribute<ECOORD>( aSMD, "x" );
|
||||
y = parseRequiredAttribute<ECOORD>( aSMD, "y" );
|
||||
dx = parseRequiredAttribute<ECOORD>( aSMD, "dx" );
|
||||
dy = parseRequiredAttribute<ECOORD>( aSMD, "dy" );
|
||||
layer = parseRequiredAttribute<int>( aSMD, "layer" );
|
||||
|
||||
roundness = parseOptionalAttribute<int>( aSMD, "roundness" );
|
||||
rot = parseOptionalAttribute<EROT>( aSMD, "rot" );
|
||||
thermals = parseOptionalAttribute<bool>( aSMD, "thermals" );
|
||||
stop = parseOptionalAttribute<bool>( aSMD, "stop" );
|
||||
thermals = parseOptionalAttribute<bool>( aSMD, "thermals" );
|
||||
cream = parseOptionalAttribute<bool>( aSMD, "cream" );
|
||||
}
|
||||
|
||||
|
|
|
@ -676,12 +676,22 @@ struct ETEXT
|
|||
};
|
||||
|
||||
|
||||
/// Eagle thru hol pad
|
||||
struct EPAD
|
||||
/// Structure holding common properties for through-hole and SMD pads
|
||||
struct EPAD_COMMON
|
||||
{
|
||||
wxString name;
|
||||
ECOORD x;
|
||||
ECOORD y;
|
||||
ECOORD x, y;
|
||||
opt_erot rot;
|
||||
opt_bool stop;
|
||||
opt_bool thermals;
|
||||
|
||||
EPAD_COMMON( wxXmlNode* aPad );
|
||||
};
|
||||
|
||||
|
||||
/// Eagle thru hole pad
|
||||
struct EPAD : public EPAD_COMMON
|
||||
{
|
||||
ECOORD drill;
|
||||
opt_ecoord diameter;
|
||||
|
||||
|
@ -694,9 +704,6 @@ struct EPAD
|
|||
OFFSET,
|
||||
};
|
||||
opt_int shape;
|
||||
opt_erot rot;
|
||||
opt_bool stop;
|
||||
opt_bool thermals;
|
||||
opt_bool first;
|
||||
|
||||
EPAD( wxXmlNode* aPad );
|
||||
|
@ -704,18 +711,12 @@ struct EPAD
|
|||
|
||||
|
||||
/// Eagle SMD pad
|
||||
struct ESMD
|
||||
struct ESMD : public EPAD_COMMON
|
||||
{
|
||||
wxString name;
|
||||
ECOORD x;
|
||||
ECOORD y;
|
||||
ECOORD dx;
|
||||
ECOORD dy;
|
||||
int layer;
|
||||
opt_int roundness;
|
||||
opt_erot rot;
|
||||
opt_bool stop;
|
||||
opt_bool thermals;
|
||||
opt_bool cream;
|
||||
|
||||
ESMD( wxXmlNode* aSMD );
|
||||
|
|
|
@ -1283,18 +1283,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
D_PAD* pad = new D_PAD( aModule );
|
||||
aModule->PadsList().PushBack( pad );
|
||||
transferPad( e, pad );
|
||||
|
||||
pad->SetName( FROM_UTF8( e.name.c_str() ) );
|
||||
|
||||
// pad's "Position" is not relative to the module's,
|
||||
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
|
||||
|
||||
wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
|
||||
pad->SetPos0( padpos );
|
||||
|
||||
RotatePoint( &padpos, aModule->GetOrientation() );
|
||||
|
||||
pad->SetPosition( padpos + aModule->GetPosition() );
|
||||
pad->SetDrillSize( wxSize( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() ) );
|
||||
pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
|
||||
|
||||
|
@ -1639,19 +1629,11 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
|
||||
D_PAD* pad = new D_PAD( aModule );
|
||||
aModule->PadsList().PushBack( pad );
|
||||
transferPad( e, pad );
|
||||
|
||||
pad->SetName( FROM_UTF8( e.name.c_str() ) );
|
||||
pad->SetShape( PAD_SHAPE_RECT );
|
||||
pad->SetAttribute( PAD_ATTRIB_SMD );
|
||||
|
||||
// pad's "Position" is not relative to the module's,
|
||||
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
|
||||
|
||||
wxPoint padpos( kicad_x( e.x ), kicad_y( e.y ) );
|
||||
pad->SetPos0( padpos );
|
||||
|
||||
RotatePoint( &padpos, aModule->GetOrientation() );
|
||||
pad->SetPosition( padpos + aModule->GetPosition() );
|
||||
pad->SetSize( wxSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() ) );
|
||||
pad->SetLayer( layer );
|
||||
|
||||
|
@ -1677,6 +1659,22 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, wxXmlNode* aTree ) const
|
|||
}
|
||||
|
||||
// don't know what stop, thermals, and cream should look like now.
|
||||
|
||||
|
||||
|
||||
void EAGLE_PLUGIN::transferPad( const EPAD_COMMON& aEaglePad, D_PAD* aPad ) const
|
||||
{
|
||||
aPad->SetName( FROM_UTF8( aEaglePad.name.c_str() ) );
|
||||
|
||||
// pad's "Position" is not relative to the module's,
|
||||
// whereas Pos0 is relative to the module's but is the unrotated coordinate.
|
||||
wxPoint padPos( kicad_x( aEaglePad.x ), kicad_y( aEaglePad.y ) );
|
||||
aPad->SetPos0( padPos );
|
||||
|
||||
MODULE* module = aPad->GetParent();
|
||||
wxCHECK( module, /* void */ );
|
||||
RotatePoint( &padPos, module->GetOrientation() );
|
||||
aPad->SetPosition( padPos + module->GetPosition() );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -32,6 +32,7 @@
|
|||
#include <map>
|
||||
#include <wx/xml/xml.h>
|
||||
|
||||
class D_PAD;
|
||||
|
||||
typedef std::map<wxString, MODULE*> MODULE_MAP;
|
||||
typedef std::map<wxString, ENET> NET_MAP;
|
||||
|
@ -238,6 +239,9 @@ private:
|
|||
void packageHole( MODULE* aModule, wxXmlNode* aTree ) const;
|
||||
void packageSMD( MODULE* aModule, wxXmlNode* aTree ) const;
|
||||
|
||||
///> Handles common pad properties
|
||||
void transferPad( const EPAD_COMMON& aEaglePad, D_PAD* aPad ) const;
|
||||
|
||||
///> Deletes the footprint templates list
|
||||
void deleteTemplates();
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue