From 8287775bac4d2db1b98b2a322ba2fd8eb70f168b Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 13 Mar 2013 11:38:54 -0500 Subject: [PATCH] EAGLE_PLUGIN cu layer map fix broke footprint library loading --- pcbnew/eagle_plugin.cpp | 34 +++++++++++++++++++++++----------- pcbnew/eagle_plugin.h | 2 ++ 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 214bbb7c7d..8da9cfccff 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -1057,6 +1057,8 @@ EAGLE_PLUGIN::EAGLE_PLUGIN() : // m_mod_time( wxDateTime::Now() ) { init( NULL ); + + clear_cu_map(); } @@ -1158,10 +1160,6 @@ void EAGLE_PLUGIN::init( PROPERTIES* aProperties ) { m_hole_count = 0; - // all cu layers are invalid until we see one in the section while board loading. - for( unsigned i = 0; i < DIM(m_cu_map); ++i ) - m_cu_map[i] = -1; - m_xpath->clear(); m_pads_to_nets.clear(); @@ -1178,6 +1176,15 @@ void EAGLE_PLUGIN::init( PROPERTIES* aProperties ) } +void EAGLE_PLUGIN::clear_cu_map() +{ + // All cu layers are invalid until we see them in the section while + // loading either a board or library. See loadLayerDefs(). + for( unsigned i = 0; i < DIM(m_cu_map); ++i ) + m_cu_map[i] = -1; +} + + void EAGLE_PLUGIN::loadAllSections( CPTREE& aDoc ) { CPTREE& drawing = aDoc.get_child( "eagle.drawing" ); @@ -1195,8 +1202,12 @@ void EAGLE_PLUGIN::loadAllSections( CPTREE& aDoc ) } { + m_xpath->push( "layers" ); + CPTREE& layers = drawing.get_child( "layers" ); loadLayerDefs( layers ); + + m_xpath->pop(); } { @@ -1231,8 +1242,6 @@ void EAGLE_PLUGIN::loadDesignRules( CPTREE& aDesignRules ) void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) { - m_xpath->push( "layers.layer" ); - typedef std::vector ELAYERS; typedef ELAYERS::const_iterator EITER; @@ -1281,8 +1290,6 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) // could map the colors here } - - m_xpath->pop(); } @@ -2664,12 +2671,17 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath ) read_xml( filename, doc, xml_parser::trim_whitespace | xml_parser::no_comments ); - CPTREE& library = doc.get_child( "eagle.drawing.library" ); + // clear the cu map and then rebuild it. + clear_cu_map(); + + m_xpath->push( "eagle.drawing.layers" ); + CPTREE& layers = doc.get_child( "eagle.drawing.layers" ); + loadLayerDefs( layers ); + m_xpath->pop(); m_xpath->push( "eagle.drawing.library" ); - + CPTREE& library = doc.get_child( "eagle.drawing.library" ); loadLibrary( library, NULL ); - m_xpath->pop(); m_mod_time = modtime; diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index 8e6ccd226c..f3bced466e 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -142,6 +142,8 @@ private: /// initialize PLUGIN like a constructor would, and futz with fresh BOARD if needed. void init( PROPERTIES* aProperties ); + void clear_cu_map(); + /// Convert an Eagle distance to a KiCad distance. int kicad( double d ) const; int kicad_y( double y ) const { return -kicad( y ); }