Commit 6e78a592 authored by Dick Hollenbeck's avatar Dick Hollenbeck

more amazing free eagle_plugin work

parent afdf5258
...@@ -84,8 +84,6 @@ MODULE::MODULE( BOARD* parent ) : ...@@ -84,8 +84,6 @@ MODULE::MODULE( BOARD* parent ) :
MODULE::MODULE( const MODULE& aModule ) : MODULE::MODULE( const MODULE& aModule ) :
BOARD_ITEM( aModule ) BOARD_ITEM( aModule )
{ {
BOARD_ITEM* newItem;
m_Pos = aModule.m_Pos; m_Pos = aModule.m_Pos;
m_LibRef = aModule.m_LibRef; m_LibRef = aModule.m_LibRef;
m_Layer = aModule.m_Layer; m_Layer = aModule.m_Layer;
...@@ -116,7 +114,7 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -116,7 +114,7 @@ MODULE::MODULE( const MODULE& aModule ) :
m_Value->SetParent( this ); m_Value->SetParent( this );
// Copy auxiliary data: Pads // Copy auxiliary data: Pads
m_Pads.DeleteAll(); // m_Pads.DeleteAll();
for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() ) for( D_PAD* pad = aModule.m_Pads; pad; pad = pad->Next() )
{ {
...@@ -126,10 +124,12 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -126,10 +124,12 @@ MODULE::MODULE( const MODULE& aModule ) :
} }
// Copy auxiliary data: Drawings // Copy auxiliary data: Drawings
m_Drawings.DeleteAll(); // m_Drawings.DeleteAll();
for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() ) for( BOARD_ITEM* item = aModule.m_Drawings; item; item = item->Next() )
{ {
BOARD_ITEM* newItem;
switch( item->Type() ) switch( item->Type() )
{ {
case PCB_MODULE_TEXT_T: case PCB_MODULE_TEXT_T:
...@@ -146,7 +146,7 @@ MODULE::MODULE( const MODULE& aModule ) : ...@@ -146,7 +146,7 @@ MODULE::MODULE( const MODULE& aModule ) :
} }
// Copy auxiliary data: 3D_Drawings info // Copy auxiliary data: 3D_Drawings info
m_3D_Drawings.DeleteAll(); // m_3D_Drawings.DeleteAll();
for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() ) for( S3D_MASTER* item = aModule.m_3D_Drawings; item; item = item->Next() )
{ {
......
...@@ -100,6 +100,7 @@ public: ...@@ -100,6 +100,7 @@ public:
D_PAD( MODULE* parent ); D_PAD( MODULE* parent );
// Do not create a copy constructor. The one generated by the compiler is adequate. // Do not create a copy constructor. The one generated by the compiler is adequate.
// D_PAD( const D_PAD& o );
void Copy( D_PAD* source ); void Copy( D_PAD* source );
...@@ -478,7 +479,8 @@ private: ...@@ -478,7 +479,8 @@ private:
double m_LocalSolderPasteMarginRatio; ///< Local solder mask margin ratio value of pad size double m_LocalSolderPasteMarginRatio; ///< Local solder mask margin ratio value of pad size
///< The final margin is the sum of these 2 values ///< The final margin is the sum of these 2 values
ZoneConnection m_ZoneConnection; ZoneConnection m_ZoneConnection;
int m_ThermalWidth, m_ThermalGap; int m_ThermalWidth;
int m_ThermalGap;
}; };
#endif // PAD_H_ #endif // PAD_H_
...@@ -50,12 +50,12 @@ Load() TODO's ...@@ -50,12 +50,12 @@ Load() TODO's
*) finish xpath support *) finish xpath support
*) set layer counts, types and names into BOARD *) set layer counts, types and names into BOARD
*) footprint placement on board back
*) eagle "mirroring" does not mean put on board back
*) fix text twisting and final location issues. *) fix text twisting and final location issues.
*) net info
*) netclass info? *) netclass info?
*) code factoring, for polygon at least *) code factoring, for polygon at least
*/ */
#include <errno.h> #include <errno.h>
...@@ -127,7 +127,6 @@ struct ECIRCLE ...@@ -127,7 +127,6 @@ struct ECIRCLE
int layer; int layer;
}; };
/// Eagle XML rectangle in binary /// Eagle XML rectangle in binary
struct ERECT struct ERECT
{ {
...@@ -138,7 +137,6 @@ struct ERECT ...@@ -138,7 +137,6 @@ struct ERECT
int layer; int layer;
}; };
/// Eagle rotation /// Eagle rotation
struct EROT struct EROT
{ {
...@@ -149,7 +147,6 @@ struct EROT ...@@ -149,7 +147,6 @@ struct EROT
typedef boost::optional<EROT> opt_erot; typedef boost::optional<EROT> opt_erot;
/// Eagle "attribute" XML element, no foolin'. /// Eagle "attribute" XML element, no foolin'.
struct EATTR struct EATTR
{ {
...@@ -191,7 +188,7 @@ struct ETEXT ...@@ -191,7 +188,7 @@ struct ETEXT
TOP_LEFT, TOP_LEFT,
TOP_RIGHT, TOP_RIGHT,
// opposites are -1 * above: // opposites are -1 x above, used by code tricks in here
CENTER_RIGHT = -CENTER_LEFT, CENTER_RIGHT = -CENTER_LEFT,
BOTTOM_CENTER = -TOP_CENTER, BOTTOM_CENTER = -TOP_CENTER,
BOTTOM_LEFT = -TOP_RIGHT, BOTTOM_LEFT = -TOP_RIGHT,
...@@ -200,11 +197,11 @@ struct ETEXT ...@@ -200,11 +197,11 @@ struct ETEXT
}; };
/// Assemble a MODULE factory key as a simple concatonation of library name and /// Assemble a two part key as a simple concatonation of aFirst and aSecond parts,
/// package name, using '\x02' as a separator. /// using '\x02' as a separator.
static inline std::string makePkgKey( const std::string& aLibName, const std::string& aPkgName ) static inline std::string makeKey( const std::string& aFirst, const std::string& aSecond )
{ {
std::string key = aLibName + '\x02' + aPkgName; std::string key = aFirst + '\x02' + aSecond;
return key; return key;
} }
...@@ -295,13 +292,9 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE ...@@ -295,13 +292,9 @@ BOARD* EAGLE_PLUGIN::Load( const wxString& aFileName, BOARD* aAppendToMe, PROPE
} }
void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{
}
void EAGLE_PLUGIN::init( PROPERTIES* aProperties ) void EAGLE_PLUGIN::init( PROPERTIES* aProperties )
{ {
m_pads_to_nets.clear();
m_templates.clear(); m_templates.clear();
m_board = NULL; m_board = NULL;
...@@ -311,41 +304,6 @@ void EAGLE_PLUGIN::init( PROPERTIES* aProperties ) ...@@ -311,41 +304,6 @@ void EAGLE_PLUGIN::init( PROPERTIES* aProperties )
biu_per_mm = IU_PER_MM; biu_per_mm = IU_PER_MM;
} }
/*
int EAGLE_PLUGIN::biuSprintf( char* buf, BIU aValue ) const
{
double engUnits = mm_per_biu * aValue;
int len;
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
{
// printf( "f: " );
len = sprintf( buf, "%.10f", engUnits );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
++len;
}
else
{
// printf( "g: " );
len = sprintf( buf, "%.10g", engUnits );
}
return len;
}
std::string EAGLE_PLUGIN::fmtBIU( BIU aValue ) const
{
char temp[50];
int len = biuSprintf( temp, aValue );
return std::string( temp, len );
}
*/
void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpath, bool aAppendToMe ) void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpath, bool aAppendToMe )
{ {
...@@ -357,6 +315,12 @@ void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpa ...@@ -357,6 +315,12 @@ void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpa
loadPlain( plain, xpath ); loadPlain( plain, xpath );
} }
{
xpath = aXpath + '.' + "signals";
CPTREE& signals = aEagleBoard.get_child( "signals" );
loadSignals( signals, xpath );
}
{ {
xpath = aXpath + '.' + "libraries"; xpath = aXpath + '.' + "libraries";
CPTREE& libs = aEagleBoard.get_child( "libraries" ); CPTREE& libs = aEagleBoard.get_child( "libraries" );
...@@ -368,12 +332,6 @@ void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpa ...@@ -368,12 +332,6 @@ void EAGLE_PLUGIN::loadAllSections( CPTREE& aEagleBoard, const std::string& aXpa
CPTREE& elems = aEagleBoard.get_child( "elements" ); CPTREE& elems = aEagleBoard.get_child( "elements" );
loadElements( elems, xpath ); loadElements( elems, xpath );
} }
{
xpath = aXpath + '.' + "signals";
CPTREE& signals = aEagleBoard.get_child( "signals" );
loadSignals( signals, xpath );
}
} }
...@@ -507,7 +465,6 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath ) ...@@ -507,7 +465,6 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath )
// hope the angle of rotation is zero. // hope the angle of rotation is zero.
// might be better off making this into a ZONE: // might be better off making this into a ZONE:
if( IsValidCopperLayerIndex( layer ) ) if( IsValidCopperLayerIndex( layer ) )
...@@ -530,6 +487,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath ) ...@@ -530,6 +487,7 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath )
m_board->Add( dseg.release(), ADD_APPEND ); m_board->Add( dseg.release(), ADD_APPEND );
} }
#elif 0 #elif 0
// use a "netcode = 0" type ZONE:
auto_ptr<ZONE_CONTAINER> zone = new ZONE_CONTAINER( m_board ); auto_ptr<ZONE_CONTAINER> zone = new ZONE_CONTAINER( m_board );
; ;
...@@ -538,12 +496,15 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath ) ...@@ -538,12 +496,15 @@ void EAGLE_PLUGIN::loadPlain( CPTREE& aGraphics, const std::string& aXpath )
} }
else if( !gr->first.compare( "hole" ) ) else if( !gr->first.compare( "hole" ) )
{ {
// there's a hole here
} }
else if( !gr->first.compare( "frame" ) ) else if( !gr->first.compare( "frame" ) )
{ {
// picture this
} }
else if( !gr->first.compare( "polygon" ) ) else if( !gr->first.compare( "polygon" ) )
{ {
// step up, be a man
} }
} }
} }
...@@ -574,7 +535,7 @@ void EAGLE_PLUGIN::loadLibraries( CPTREE& aLibs, const std::string& aXpath ) ...@@ -574,7 +535,7 @@ void EAGLE_PLUGIN::loadLibraries( CPTREE& aLibs, const std::string& aXpath )
} }
#endif #endif
std::string key = makePkgKey( lib_name, pack_name ); std::string key = makeKey( lib_name, pack_name );
MODULE* m = makeModule( package->second, pack_name ); MODULE* m = makeModule( package->second, pack_name );
...@@ -643,7 +604,7 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements, const std::string& aXpath ) ...@@ -643,7 +604,7 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements, const std::string& aXpath )
opt_string rot = attrs.get_optional<std::string>( "rot" ); opt_string rot = attrs.get_optional<std::string>( "rot" );
std::string key = makePkgKey( library, package ); std::string key = makeKey( library, package );
MODULE_CITER mi = m_templates.find( key ); MODULE_CITER mi = m_templates.find( key );
...@@ -655,10 +616,35 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements, const std::string& aXpath ) ...@@ -655,10 +616,35 @@ void EAGLE_PLUGIN::loadElements( CPTREE& aElements, const std::string& aXpath )
THROW_IO_ERROR( emsg ); THROW_IO_ERROR( emsg );
} }
#if defined(DEBUG)
if( !name.compare( "IC3" ) )
{
int breakhere = 1;
(void) breakhere;
}
#endif
// copy constructor to clone the template // copy constructor to clone the template
MODULE* m = new MODULE( *mi->second ); MODULE* m = new MODULE( *mi->second );
m_board->Add( m, ADD_APPEND ); m_board->Add( m, ADD_APPEND );
for( D_PAD* pad = m->m_Pads; pad; pad = pad->Next() )
{
const ENET& enet = m_pads_to_nets[ makeKey( name, TO_UTF8( pad->GetPadName())) ];
D(printf( "refname:'%s' pad:'%s' netcode:%d netname:'%s'\n",
name.c_str(), TO_UTF8( pad->GetPadName() ),
enet.netcode,
enet.netname.c_str()
);)
if( enet.netname.size() )
{
pad->SetNetname( FROM_UTF8( enet.netname.c_str() ) );
pad->SetNet( enet.netcode );
}
}
m->SetPosition( wxPoint( kicad_x( x ), kicad_y( y ) ) ); m->SetPosition( wxPoint( kicad_x( x ), kicad_y( y ) ) );
m->SetReference( FROM_UTF8( name.c_str() ) ); m->SetReference( FROM_UTF8( name.c_str() ) );
m->SetValue( FROM_UTF8( value.c_str() ) ); m->SetValue( FROM_UTF8( value.c_str() ) );
...@@ -1052,6 +1038,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const ...@@ -1052,6 +1038,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const
aModule->m_Pads.PushBack( pad ); aModule->m_Pads.PushBack( pad );
// the DTD says these must be present, throw exception if not found // the DTD says these must be present, throw exception if not found
const std::string& name = attrs.get<std::string>( "name" );
double x = attrs.get<double>( "x" ); double x = attrs.get<double>( "x" );
double y = attrs.get<double>( "y" ); double y = attrs.get<double>( "y" );
double drill = attrs.get<double>( "drill" ); double drill = attrs.get<double>( "drill" );
...@@ -1059,6 +1047,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const ...@@ -1059,6 +1047,8 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const
// pad's "Position" is not relative to the module's, // pad's "Position" is not relative to the module's,
// whereas Pos0 is relative to the module's but is the unrotated coordinate. // whereas Pos0 is relative to the module's but is the unrotated coordinate.
pad->SetPadName( FROM_UTF8( name.c_str() ) );
wxPoint padpos( kicad_x( x ), kicad_y( y ) ); wxPoint padpos( kicad_x( x ), kicad_y( y ) );
pad->SetPos0( padpos ); pad->SetPos0( padpos );
...@@ -1075,9 +1065,11 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const ...@@ -1075,9 +1065,11 @@ void EAGLE_PLUGIN::packagePad( MODULE* aModule, CPTREE& aTree ) const
opt_double diameter = attrs.get_optional<double>( "diameter" ); opt_double diameter = attrs.get_optional<double>( "diameter" );
opt_string shape = attrs.get_optional<std::string>( "shape" ); opt_string shape = attrs.get_optional<std::string>( "shape" );
opt_string rot = attrs.get_optional<std::string>( "rot" ); opt_string rot = attrs.get_optional<std::string>( "rot" );
/*
opt_string stop = attrs.get_optional<std::string>( "stop" ); opt_string stop = attrs.get_optional<std::string>( "stop" );
opt_string thermals = attrs.get_optional<std::string>( "thermals" ); opt_string thermals = attrs.get_optional<std::string>( "thermals" );
opt_string first = attrs.get_optional<std::string>( "first" ); opt_string first = attrs.get_optional<std::string>( "first" );
*/
if( diameter ) if( diameter )
{ {
...@@ -1263,19 +1255,27 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, CPTREE& aTree ) const ...@@ -1263,19 +1255,27 @@ void EAGLE_PLUGIN::packageSMD( MODULE* aModule, CPTREE& aTree ) const
> >
*/ */
D_PAD* pad = new D_PAD( aModule );
aModule->m_Pads.PushBack( pad );
pad->SetShape( PAD_RECT );
pad->SetAttribute( PAD_SMD );
// the DTD says these must be present, throw exception if not found // the DTD says these must be present, throw exception if not found
const std::string& name = attrs.get<std::string>( "name" );
double x = attrs.get<double>( "x" ); double x = attrs.get<double>( "x" );
double y = attrs.get<double>( "y" ); double y = attrs.get<double>( "y" );
double dx = attrs.get<double>( "dx" ); double dx = attrs.get<double>( "dx" );
double dy = attrs.get<double>( "dy" ); double dy = attrs.get<double>( "dy" );
int layer = attrs.get<int>( "layer" ); int layer = attrs.get<int>( "layer" );
if( !IsValidCopperLayerIndex( layer ) )
{
return;
}
D_PAD* pad = new D_PAD( aModule );
aModule->m_Pads.PushBack( pad );
pad->SetPadName( FROM_UTF8( name.c_str() ) );
pad->SetShape( PAD_RECT );
pad->SetAttribute( PAD_SMD );
// pad's "Position" is not relative to the module's, // pad's "Position" is not relative to the module's,
// whereas Pos0 is relative to the module's but is the unrotated coordinate. // whereas Pos0 is relative to the module's but is the unrotated coordinate.
...@@ -1326,7 +1326,8 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath ) ...@@ -1326,7 +1326,8 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath )
for( CITER net = aSignals.begin(); net != aSignals.end(); ++net, ++netCode ) for( CITER net = aSignals.begin(); net != aSignals.end(); ++net, ++netCode )
{ {
wxString netName = FROM_UTF8( net->second.get<std::string>( "<xmlattr>.name" ).c_str() ); const std::string& nname = net->second.get<std::string>( "<xmlattr>.name" );
wxString netName = FROM_UTF8( nname.c_str() );
m_board->AppendNet( new NETINFO_ITEM( m_board, netName, netCode ) ); m_board->AppendNet( new NETINFO_ITEM( m_board, netName, netCode ) );
...@@ -1336,18 +1337,27 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath ) ...@@ -1336,18 +1337,27 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath )
if( !it->first.compare( "wire" ) ) if( !it->first.compare( "wire" ) )
{ {
EWIRE w = ewire( it->second ); EWIRE w = ewire( it->second );
TRACK* t = new TRACK( m_board ); int layer = kicad_layer( w.layer );
t->SetTimeStamp( timeStamp( it->second )); if( IsValidCopperLayerIndex( layer ) )
{
TRACK* t = new TRACK( m_board );
t->SetPosition( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) ); t->SetTimeStamp( timeStamp( it->second ) );
t->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
t->SetWidth( kicad( w.width ) ); t->SetPosition( wxPoint( kicad_x( w.x1 ), kicad_y( w.y1 ) ) );
t->SetLayer( kicad_layer( w.layer ) ); t->SetEnd( wxPoint( kicad_x( w.x2 ), kicad_y( w.y2 ) ) );
t->SetNet( netCode );
m_board->m_Track.Insert( t, NULL ); t->SetWidth( kicad( w.width ) );
t->SetLayer( layer );
t->SetNet( netCode );
m_board->m_Track.Insert( t, NULL );
}
else
{
// put non copper wires where the sun don't shine.
}
} }
else if( !it->first.compare( "via" ) ) else if( !it->first.compare( "via" ) )
...@@ -1356,39 +1366,57 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath ) ...@@ -1356,39 +1366,57 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath )
int layer_start = kicad_layer( v.layer_start ); int layer_start = kicad_layer( v.layer_start );
int layer_end = kicad_layer( v.layer_end ); int layer_end = kicad_layer( v.layer_end );
int drill = kicad( v.drill );
SEGVIA* via = new SEGVIA( m_board ); if( IsValidCopperLayerIndex( layer_start ) &&
IsValidCopperLayerIndex( layer_end ) )
{
int drill = kicad( v.drill );
via->SetLayerPair( layer_start, layer_end ); SEGVIA* via = new SEGVIA( m_board );
if( v.diam ) via->SetLayerPair( layer_start, layer_end );
{
int kidiam = kicad( *v.diam ); // via diameters are externally controllable, not usually in a board:
via->SetWidth( kidiam ); // http://www.eaglecentral.ca/forums/index.php/mv/msg/34704/119478/
} if( v.diam )
{
int kidiam = kicad( *v.diam );
via->SetWidth( kidiam );
}
else
via->SetWidth( drill * 3 );
via->SetDrill( drill ); via->SetDrill( drill );
via->SetTimeStamp( timeStamp( it->second ) ); via->SetTimeStamp( timeStamp( it->second ) );
wxPoint pos( kicad_x( v.x ), kicad_y( v.y ) ); wxPoint pos( kicad_x( v.x ), kicad_y( v.y ) );
via->SetPosition( pos ); via->SetPosition( pos );
via->SetEnd( pos ); via->SetEnd( pos );
// via->SetWidth( width ); via->SetNet( netCode );
// via->SetShape( shape );
via->SetNet( netCode );
// via->SetState( flags, ON );
via->SetShape( S_SEGMENT ); via->SetShape( S_CIRCLE ); // @todo should be in SEGVIA constructor
m_board->m_Track.Insert( via, NULL ); m_board->m_Track.Insert( via, NULL );
}
} }
else if( !it->first.compare( "contactref" ) ) else if( !it->first.compare( "contactref" ) )
{ {
// <contactref element="RN1" pad="7"/>
CPTREE& attribs = it->second.get_child( "<xmlattr>" );
const std::string& reference = attribs.get<std::string>( "element" );
const std::string& pad = attribs.get<std::string>( "pad" );
std::string key = makeKey( reference, pad ) ;
D(printf( "adding refname:'%s' pad:'%s' netcode:%d netname:'%s'\n",
reference.c_str(), pad.c_str(), netCode, nname.c_str() );)
m_pads_to_nets[ key ] = ENET( netCode, nname );
} }
else if( !it->first.compare( "polygon" ) ) else if( !it->first.compare( "polygon" ) )
...@@ -1399,49 +1427,178 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath ) ...@@ -1399,49 +1427,178 @@ void EAGLE_PLUGIN::loadSignals( CPTREE& aSignals, const std::string& aXpath )
} }
int EAGLE_PLUGIN::kicad_layer( int aLayer ) int EAGLE_PLUGIN::kicad_layer( int aEagleLayer )
{ {
int ret; /* will assume this is a valid mapping for all eagle boards until I get paid more:
<layers>
<layer number="1" name="Top" color="4" fill="1" visible="yes" active="yes"/>
<layer number="2" name="Route2" color="1" fill="3" visible="no" active="no"/>
<layer number="3" name="Route3" color="4" fill="3" visible="no" active="no"/>
<layer number="4" name="Route4" color="1" fill="4" visible="no" active="no"/>
<layer number="5" name="Route5" color="4" fill="4" visible="no" active="no"/>
<layer number="6" name="Route6" color="1" fill="8" visible="no" active="no"/>
<layer number="7" name="Route7" color="4" fill="8" visible="no" active="no"/>
<layer number="8" name="Route8" color="1" fill="2" visible="no" active="no"/>
<layer number="9" name="Route9" color="4" fill="2" visible="no" active="no"/>
<layer number="10" name="Route10" color="1" fill="7" visible="no" active="no"/>
<layer number="11" name="Route11" color="4" fill="7" visible="no" active="no"/>
<layer number="12" name="Route12" color="1" fill="5" visible="no" active="no"/>
<layer number="13" name="Route13" color="4" fill="5" visible="no" active="no"/>
<layer number="14" name="Route14" color="1" fill="6" visible="no" active="no"/>
<layer number="15" name="Route15" color="4" fill="6" visible="no" active="no"/>
<layer number="16" name="Bottom" color="1" fill="1" visible="yes" active="yes"/>
<layer number="17" name="Pads" color="2" fill="1" visible="yes" active="yes"/>
<layer number="18" name="Vias" color="14" fill="1" visible="yes" active="yes"/>
<layer number="19" name="Unrouted" color="6" fill="1" visible="yes" active="yes"/>
<layer number="20" name="Dimension" color="15" fill="1" visible="yes" active="yes"/>
<layer number="21" name="tPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="22" name="bPlace" color="7" fill="1" visible="yes" active="yes"/>
<layer number="23" name="tOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="24" name="bOrigins" color="15" fill="1" visible="yes" active="yes"/>
<layer number="25" name="tNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="26" name="bNames" color="7" fill="1" visible="yes" active="yes"/>
<layer number="27" name="tValues" color="7" fill="1" visible="no" active="yes"/>
<layer number="28" name="bValues" color="7" fill="1" visible="no" active="yes"/>
<layer number="29" name="tStop" color="2" fill="3" visible="no" active="yes"/>
<layer number="30" name="bStop" color="5" fill="6" visible="no" active="yes"/>
<layer number="31" name="tCream" color="7" fill="4" visible="no" active="yes"/>
<layer number="32" name="bCream" color="7" fill="5" visible="no" active="yes"/>
<layer number="33" name="tFinish" color="6" fill="3" visible="no" active="yes"/>
<layer number="34" name="bFinish" color="6" fill="6" visible="no" active="yes"/>
<layer number="35" name="tGlue" color="7" fill="4" visible="no" active="yes"/>
<layer number="36" name="bGlue" color="7" fill="5" visible="no" active="yes"/>
<layer number="37" name="tTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="38" name="bTest" color="7" fill="1" visible="no" active="yes"/>
<layer number="39" name="tKeepout" color="4" fill="11" visible="no" active="yes"/>
<layer number="40" name="bKeepout" color="1" fill="11" visible="no" active="yes"/>
<layer number="41" name="tRestrict" color="4" fill="10" visible="no" active="yes"/>
<layer number="42" name="bRestrict" color="1" fill="10" visible="no" active="yes"/>
<layer number="43" name="vRestrict" color="2" fill="10" visible="no" active="yes"/>
<layer number="44" name="Drills" color="7" fill="1" visible="no" active="yes"/>
<layer number="45" name="Holes" color="7" fill="1" visible="no" active="yes"/>
<layer number="46" name="Milling" color="3" fill="1" visible="no" active="yes"/>
<layer number="47" name="Measures" color="7" fill="1" visible="no" active="yes"/>
<layer number="48" name="Document" color="7" fill="1" visible="no" active="yes"/>
<layer number="49" name="ReferenceLC" color="13" fill="1" visible="yes" active="yes"/>
<layer number="50" name="ReferenceLS" color="12" fill="1" visible="yes" active="yes"/>
<layer number="51" name="tDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="52" name="bDocu" color="7" fill="1" visible="yes" active="yes"/>
<layer number="91" name="Nets" color="2" fill="1" visible="no" active="no"/>
<layer number="92" name="Busses" color="1" fill="1" visible="no" active="no"/>
<layer number="93" name="Pins" color="2" fill="1" visible="no" active="no"/>
<layer number="94" name="Symbols" color="4" fill="1" visible="no" active="no"/>
<layer number="95" name="Names" color="7" fill="1" visible="no" active="no"/>
<layer number="96" name="Values" color="7" fill="1" visible="no" active="no"/>
<layer number="97" name="Info" color="7" fill="1" visible="no" active="no"/>
<layer number="98" name="Guide" color="6" fill="1" visible="no" active="no"/>
</layers>
*/
switch( aLayer ) // translate eagle layer to pcbnew layer int kiLayer;
// eagle copper layer:
if( aEagleLayer >=1 && aEagleLayer <= 16 )
{
kiLayer = LAYER_N_FRONT - ( aEagleLayer - 1 );
}
else
{ {
case 1: ret = 15; break; // Top copper /*
case 2: ret = 14; break; #define FIRST_NO_COPPER_LAYER 16
case 3: ret = 13; break; #define ADHESIVE_N_BACK 16
case 4: ret = 12; break; #define ADHESIVE_N_FRONT 17
case 5: ret = 11; break; #define SOLDERPASTE_N_BACK 18
case 6: ret = 10; break; #define SOLDERPASTE_N_FRONT 19
case 7: ret = 9; break; #define SILKSCREEN_N_BACK 20
case 8: ret = 8; break; #define SILKSCREEN_N_FRONT 21
case 9: ret = 7; break; #define SOLDERMASK_N_BACK 22
case 10: ret = 6; break; #define SOLDERMASK_N_FRONT 23
case 11: ret = 5; break; #define DRAW_N 24
case 12: ret = 4; break; #define COMMENT_N 25
case 13: ret = 3; break; #define ECO1_N 26
case 14: ret = 2; break; #define ECO2_N 27
case 15: ret = 1; break; #define EDGE_N 28
case 16: ret = 0; break; // Bottom Copper #define LAST_NO_COPPER_LAYER 28
case 20: ret = 28; break; // Edge Layer #define UNUSED_LAYER_29 29
case 21: ret = 21; break; // Top Silk Screen #define UNUSED_LAYER_30 30
case 22: ret = 20; break; // Bottom Silk Screen #define UNUSED_LAYER_31 31
case 25: ret = 25; break; // Misc Comment Layers */
case 26: ret = 25; break; // translate non-copper eagle layer to pcbnew layer
case 27: ret = 26; break; switch( aEagleLayer )
case 28: ret = 26; break; {
case 29: ret = 23; break; case 20: kiLayer = EDGE_N; break; // eagle says "Dimension" layer, but it's for board perimeter
case 30: ret = 22; break; case 21: kiLayer = SILKSCREEN_N_FRONT; break;
case 31: ret = 19; break; case 22: kiLayer = SILKSCREEN_N_BACK; break;
case 32: ret = 18; break; case 25: kiLayer = SILKSCREEN_N_FRONT; break;
case 35: ret = 17; break; case 26: kiLayer = SILKSCREEN_N_BACK; break;
case 36: ret = 16; break; case 27: kiLayer = SILKSCREEN_N_FRONT; break;
case 51: ret = 26; break; case 28: kiLayer = SILKSCREEN_N_BACK; break;
case 52: ret = 27; break; case 29: kiLayer = SOLDERMASK_N_FRONT; break;
case 95: ret = 26; break; case 30: kiLayer = SOLDERMASK_N_BACK; break;
case 96: ret = 27; break; case 31: kiLayer = SOLDERPASTE_N_FRONT; break;
default: ret = -1; break; // our eagle understanding is incomplete case 32: kiLayer = SOLDERPASTE_N_BACK; break;
case 33: kiLayer = SOLDERMASK_N_FRONT; break;
case 34: kiLayer = SOLDERMASK_N_BACK; break;
case 35: kiLayer = ADHESIVE_N_FRONT; break;
case 36: kiLayer = ADHESIVE_N_BACK; break;
case 49: kiLayer = COMMENT_N; break;
case 50: kiLayer = COMMENT_N; break;
case 51: kiLayer = ECO1_N; break;
case 52: kiLayer = ECO2_N; break;
case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break;
default:
D( printf( "unexpected eagle layer: %d\n", aEagleLayer );)
kiLayer = -1; break; // our eagle understanding is incomplete
}
} }
return ret; return kiLayer;
}
/*
void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties )
{
// Eagle lovers apply here.
}
int EAGLE_PLUGIN::biuSprintf( char* buf, BIU aValue ) const
{
double engUnits = mm_per_biu * aValue;
int len;
if( engUnits != 0.0 && fabs( engUnits ) <= 0.0001 )
{
// printf( "f: " );
len = sprintf( buf, "%.10f", engUnits );
while( --len > 0 && buf[len] == '0' )
buf[len] = '\0';
++len;
}
else
{
// printf( "g: " );
len = sprintf( buf, "%.10g", engUnits );
}
return len;
}
std::string EAGLE_PLUGIN::fmtBIU( BIU aValue ) const
{
char temp[50];
int len = biuSprintf( temp, aValue );
return std::string( temp, len );
} }
...@@ -1482,3 +1639,4 @@ bool EAGLE_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath ) ...@@ -1482,3 +1639,4 @@ bool EAGLE_PLUGIN::IsFootprintLibWritable( const wxString& aLibraryPath )
return true; return true;
} }
*/
\ No newline at end of file
...@@ -34,13 +34,30 @@ ...@@ -34,13 +34,30 @@
#include <boost/property_tree/ptree_fwd.hpp> #include <boost/property_tree/ptree_fwd.hpp>
#include <boost/ptr_container/ptr_map.hpp> #include <boost/ptr_container/ptr_map.hpp>
#include <time.h> #include <map>
class MODULE; class MODULE;
typedef boost::ptr_map< std::string, MODULE > MODULE_MAP; typedef boost::ptr_map< std::string, MODULE > MODULE_MAP;
struct ENET
{
int netcode;
std::string netname;
ENET( int aNetCode, const std::string& aNetName ) :
netcode( aNetCode ),
netname( aNetName )
{}
ENET() :
netcode( 0 )
{}
};
typedef std::map< std::string, ENET > NET_MAP;
/* /*
#include #include
namespace boost { namespace boost {
...@@ -79,6 +96,9 @@ public: ...@@ -79,6 +96,9 @@ public:
BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL ); BOARD* Load( const wxString& aFileName, BOARD* aAppendToMe, PROPERTIES* aProperties = NULL );
const wxString& GetFileExtension() const;
/*
void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL ); void Save( const wxString& aFileName, BOARD* aBoard, PROPERTIES* aProperties = NULL );
wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL); wxArrayString FootprintEnumerate( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL);
...@@ -94,8 +114,7 @@ public: ...@@ -94,8 +114,7 @@ public:
void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL ); void FootprintLibDelete( const wxString& aLibraryPath, PROPERTIES* aProperties = NULL );
bool IsFootprintLibWritable( const wxString& aLibraryPath ); bool IsFootprintLibWritable( const wxString& aLibraryPath );
*/
const wxString& GetFileExtension() const;
//-----</PUBLIC PLUGIN API>------------------------------------------------- //-----</PUBLIC PLUGIN API>-------------------------------------------------
...@@ -106,6 +125,8 @@ public: ...@@ -106,6 +125,8 @@ public:
private: private:
NET_MAP m_pads_to_nets;
MODULE_MAP m_templates; ///< is part of a MODULE factory that operates MODULE_MAP m_templates; ///< is part of a MODULE factory that operates
///< using copy construction. ///< using copy construction.
///< lookup key is libname.packagename ///< lookup key is libname.packagename
......
...@@ -1892,7 +1892,8 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) ...@@ -1892,7 +1892,8 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
{ {
// read two lines per loop iteration, each loop is one TRACK or VIA // read two lines per loop iteration, each loop is one TRACK or VIA
// example first line: // example first line:
// "Po 0 23994 28800 24400 28800 150 -1\r\n" // e.g. "Po 0 23994 28800 24400 28800 150 -1" for a track
// e.g. "Po 3 21086 17586 21086 17586 180 -1" for a via (uses sames start and end)
const char* data; const char* data;
char* line = m_reader->Line(); char* line = m_reader->Line();
...@@ -1943,6 +1944,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType ) ...@@ -1943,6 +1944,7 @@ void LEGACY_PLUGIN::loadTrackList( TRACK* aInsertBeforeMe, int aStructType )
int layer, type, flags, net_code; int layer, type, flags, net_code;
// parse the 2nd line to determine the type of object // parse the 2nd line to determine the type of object
// e.g. "De 15 1 7 0 0" for a via
sscanf( line + SZ( "De" ), " %d %d %d %lX %X", &layer, &type, &net_code, &timeStamp, &flags ); sscanf( line + SZ( "De" ), " %d %d %d %lX %X", &layer, &type, &net_code, &timeStamp, &flags );
if( aStructType==PCB_TRACE_T && type==1 ) if( aStructType==PCB_TRACE_T && type==1 )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment