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::EPAD( wxXmlNode* aPad )
|
||||||
|
: EPAD_COMMON( aPad )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
<!ELEMENT pad EMPTY>
|
<!ELEMENT pad EMPTY>
|
||||||
|
@ -640,9 +653,6 @@ EPAD::EPAD( wxXmlNode* aPad )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// #REQUIRED says DTD, throw exception if not found
|
// #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" );
|
drill = parseRequiredAttribute<ECOORD>( aPad, "drill" );
|
||||||
|
|
||||||
// Optional attributes
|
// Optional attributes
|
||||||
|
@ -662,14 +672,12 @@ EPAD::EPAD( wxXmlNode* aPad )
|
||||||
else if( s == "offset" )
|
else if( s == "offset" )
|
||||||
shape = EPAD::OFFSET;
|
shape = EPAD::OFFSET;
|
||||||
|
|
||||||
rot = parseOptionalAttribute<EROT>( aPad, "rot" );
|
|
||||||
stop = parseOptionalAttribute<bool>( aPad, "stop" );
|
|
||||||
thermals = parseOptionalAttribute<bool>( aPad, "thermals" );
|
|
||||||
first = parseOptionalAttribute<bool>( aPad, "first" );
|
first = parseOptionalAttribute<bool>( aPad, "first" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
ESMD::ESMD( wxXmlNode* aSMD )
|
ESMD::ESMD( wxXmlNode* aSMD )
|
||||||
|
: EPAD_COMMON( aSMD )
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
<!ATTLIST smd
|
<!ATTLIST smd
|
||||||
|
@ -688,18 +696,11 @@ ESMD::ESMD( wxXmlNode* aSMD )
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// DTD #REQUIRED, throw exception if not found
|
// 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" );
|
dx = parseRequiredAttribute<ECOORD>( aSMD, "dx" );
|
||||||
dy = parseRequiredAttribute<ECOORD>( aSMD, "dy" );
|
dy = parseRequiredAttribute<ECOORD>( aSMD, "dy" );
|
||||||
layer = parseRequiredAttribute<int>( aSMD, "layer" );
|
layer = parseRequiredAttribute<int>( aSMD, "layer" );
|
||||||
|
|
||||||
roundness = parseOptionalAttribute<int>( aSMD, "roundness" );
|
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" );
|
cream = parseOptionalAttribute<bool>( aSMD, "cream" );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -676,12 +676,22 @@ struct ETEXT
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/// Eagle thru hol pad
|
/// Structure holding common properties for through-hole and SMD pads
|
||||||
struct EPAD
|
struct EPAD_COMMON
|
||||||
{
|
{
|
||||||
wxString name;
|
wxString name;
|
||||||
ECOORD x;
|
ECOORD x, y;
|
||||||
ECOORD 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;
|
ECOORD drill;
|
||||||
opt_ecoord diameter;
|
opt_ecoord diameter;
|
||||||
|
|
||||||
|
@ -694,9 +704,6 @@ struct EPAD
|
||||||
OFFSET,
|
OFFSET,
|
||||||
};
|
};
|
||||||
opt_int shape;
|
opt_int shape;
|
||||||
opt_erot rot;
|
|
||||||
opt_bool stop;
|
|
||||||
opt_bool thermals;
|
|
||||||
opt_bool first;
|
opt_bool first;
|
||||||
|
|
||||||
EPAD( wxXmlNode* aPad );
|
EPAD( wxXmlNode* aPad );
|
||||||
|
@ -704,18 +711,12 @@ struct EPAD
|
||||||
|
|
||||||
|
|
||||||
/// Eagle SMD pad
|
/// Eagle SMD pad
|
||||||
struct ESMD
|
struct ESMD : public EPAD_COMMON
|
||||||
{
|
{
|
||||||
wxString name;
|
|
||||||
ECOORD x;
|
|
||||||
ECOORD y;
|
|
||||||
ECOORD dx;
|
ECOORD dx;
|
||||||
ECOORD dy;
|
ECOORD dy;
|
||||||
int layer;
|
int layer;
|
||||||
opt_int roundness;
|
opt_int roundness;
|
||||||
opt_erot rot;
|
|
||||||
opt_bool stop;
|
|
||||||
opt_bool thermals;
|
|
||||||
opt_bool cream;
|
opt_bool cream;
|
||||||
|
|
||||||
ESMD( wxXmlNode* aSMD );
|
ESMD( wxXmlNode* aSMD );
|
||||||
|
|
|
@ -1283,18 +1283,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, wxXmlNode* aTree ) const
|
||||||
|
|
||||||
D_PAD* pad = new D_PAD( aModule );
|
D_PAD* pad = new D_PAD( aModule );
|
||||||
aModule->PadsList().PushBack( pad );
|
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->SetDrillSize( wxSize( e.drill.ToPcbUnits(), e.drill.ToPcbUnits() ) );
|
||||||
pad->SetLayerSet( LSET::AllCuMask().set( B_Mask ).set( F_Mask ) );
|
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 );
|
D_PAD* pad = new D_PAD( aModule );
|
||||||
aModule->PadsList().PushBack( pad );
|
aModule->PadsList().PushBack( pad );
|
||||||
|
transferPad( e, pad );
|
||||||
|
|
||||||
pad->SetName( FROM_UTF8( e.name.c_str() ) );
|
|
||||||
pad->SetShape( PAD_SHAPE_RECT );
|
pad->SetShape( PAD_SHAPE_RECT );
|
||||||
pad->SetAttribute( PAD_ATTRIB_SMD );
|
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->SetSize( wxSize( e.dx.ToPcbUnits(), e.dy.ToPcbUnits() ) );
|
||||||
pad->SetLayer( layer );
|
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.
|
// 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 <map>
|
||||||
#include <wx/xml/xml.h>
|
#include <wx/xml/xml.h>
|
||||||
|
|
||||||
|
class D_PAD;
|
||||||
|
|
||||||
typedef std::map<wxString, MODULE*> MODULE_MAP;
|
typedef std::map<wxString, MODULE*> MODULE_MAP;
|
||||||
typedef std::map<wxString, ENET> NET_MAP;
|
typedef std::map<wxString, ENET> NET_MAP;
|
||||||
|
@ -166,8 +167,8 @@ private:
|
||||||
void clear_cu_map();
|
void clear_cu_map();
|
||||||
|
|
||||||
/// Convert an Eagle distance to a KiCad distance.
|
/// Convert an Eagle distance to a KiCad distance.
|
||||||
int kicad_y( const ECOORD& y ) const { return -y.ToPcbUnits(); }
|
int kicad_y( const ECOORD& y ) const { return -y.ToPcbUnits(); }
|
||||||
int kicad_x( const ECOORD& x ) const { return x.ToPcbUnits(); }
|
int kicad_x( const ECOORD& x ) const { return x.ToPcbUnits(); }
|
||||||
|
|
||||||
/// create a font size (fontz) from an eagle font size scalar
|
/// create a font size (fontz) from an eagle font size scalar
|
||||||
wxSize kicad_fontz( const ECOORD& d ) const;
|
wxSize kicad_fontz( const ECOORD& d ) const;
|
||||||
|
@ -238,6 +239,9 @@ private:
|
||||||
void packageHole( MODULE* aModule, wxXmlNode* aTree ) const;
|
void packageHole( MODULE* aModule, wxXmlNode* aTree ) const;
|
||||||
void packageSMD( 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
|
///> Deletes the footprint templates list
|
||||||
void deleteTemplates();
|
void deleteTemplates();
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue