From 2be3ebd401f8ab8e6e4b1f2cfa2711635b7af389 Mon Sep 17 00:00:00 2001 From: Dick Hollenbeck Date: Wed, 20 Nov 2013 10:35:03 -0600 Subject: [PATCH] FIX: regression loading of SMD pads within EAGLE_PLUGIN::FootprintLoad(). FIX: unique renaming of eagle footprints by substituting illegal : and / with URL encoding technique. ADD: window resize border to DisplayError() windows. --- common/confirm.cpp | 14 ++++--- pcbnew/dialogs/dialog_fp_lib_table.cpp | 4 +- pcbnew/eagle_plugin.cpp | 57 ++++++++++++++++++-------- pcbnew/eagle_plugin.h | 2 + 4 files changed, 54 insertions(+), 23 deletions(-) diff --git a/common/confirm.cpp b/common/confirm.cpp index b44186da9b..738ad17003 100644 --- a/common/confirm.cpp +++ b/common/confirm.cpp @@ -52,9 +52,9 @@ public: }; private: - void OnSaveAndExit( wxCommandEvent& event ) { EndModal( wxID_YES ); } - void OnCancel( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); } - void OnExitNoSave( wxCommandEvent& event ) { EndModal( wxID_NO ); } + void OnSaveAndExit( wxCommandEvent& event ) { EndModal( wxID_YES ); } + void OnCancel( wxCommandEvent& event ) { EndModal( wxID_CANCEL ); } + void OnExitNoSave( wxCommandEvent& event ) { EndModal( wxID_NO ); } }; @@ -73,10 +73,14 @@ void DisplayError( wxWindow* parent, const wxString& text, int displaytime ) if( displaytime > 0 ) dialog = new wxMessageDialog( parent, text, _( "Warning" ), - wxOK | wxCENTRE | wxICON_INFORMATION ); + wxOK | wxCENTRE | wxICON_INFORMATION + | wxRESIZE_BORDER + ); else dialog = new wxMessageDialog( parent, text, _( "Error" ), - wxOK | wxCENTRE | wxICON_ERROR ); + wxOK | wxCENTRE | wxICON_ERROR + | wxRESIZE_BORDER + ); dialog->ShowModal(); dialog->Destroy(); diff --git a/pcbnew/dialogs/dialog_fp_lib_table.cpp b/pcbnew/dialogs/dialog_fp_lib_table.cpp index 1304e67a0d..8c287a35bb 100644 --- a/pcbnew/dialogs/dialog_fp_lib_table.cpp +++ b/pcbnew/dialogs/dialog_fp_lib_table.cpp @@ -40,7 +40,7 @@ #include #include #include - +#include /// grid column order is established by this sequence enum COL_ORDER @@ -244,7 +244,7 @@ protected: } catch( PARSE_ERROR& pe ) { - // @todo tell what line and offset + DisplayError( NULL, pe.errorText ); parsed = false; } diff --git a/pcbnew/eagle_plugin.cpp b/pcbnew/eagle_plugin.cpp index 87ac6052a8..f1aa7d6bf7 100644 --- a/pcbnew/eagle_plugin.cpp +++ b/pcbnew/eagle_plugin.cpp @@ -97,17 +97,28 @@ const wxChar* traceEaglePlugin = wxT( "KicadEaglePlugin" ); /// Test footprint name for kicad legality, fix if needed and return true if fixing was required. static bool fix_eagle_package_name( string* aName ) { + string result; bool changed = false; for( string::iterator it = aName->begin(); it != aName->end(); ++it ) { - switch( *it ) // for mapping, I always prefer a tabular switch presentation: + switch( *it ) { - case ':': *it = '_'; changed = true; break; - case '/': *it = '-'; changed = true; break; + case ':': + case '/': + // replace *it with %xx, as in URL encoding + StrPrintf( &result, "%%%02x", *it ); + changed = true; + break; + + default: + result += *it; } } + if( changed ) + *aName = result; + return changed; } @@ -1292,9 +1303,6 @@ void EAGLE_PLUGIN::loadDesignRules( CPTREE& aDesignRules ) void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) { - if( m_board == NULL ) - return; - typedef std::vector ELAYERS; typedef ELAYERS::const_iterator EITER; @@ -1333,17 +1341,21 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) } #endif - m_board->SetCopperLayerCount( cu.size() ); - - for( EITER it = cu.begin(); it != cu.end(); ++it ) + // Set the layer names and cu count iff we're loading a board. + if( m_board ) { - LAYER_NUM layer = kicad_layer( it->number ); + m_board->SetCopperLayerCount( cu.size() ); - // these function provide their own protection against UNDEFINED_LAYER: - m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) ); - m_board->SetLayerType( layer, LT_SIGNAL ); + for( EITER it = cu.begin(); it != cu.end(); ++it ) + { + LAYER_NUM layer = kicad_layer( it->number ); - // could map the colors here + // these function provide their own protection against UNDEFINED_LAYER: + m_board->SetLayerName( layer, FROM_UTF8( it->name.c_str() ) ); + m_board->SetLayerType( layer, LT_SIGNAL ); + + // could map the colors here + } } } @@ -1625,13 +1637,15 @@ void EAGLE_PLUGIN::loadLibrary( CPTREE& aLib, const string* aLibName ) // add the templating MODULE to the MODULE template factory "m_templates" std::pair r = m_templates.insert( key, m ); - if( !r.second ) + if( !r.second + // && !( m_props && m_props->Value( "ignore_duplicates" ) ) + ) { wxString lib = aLibName ? FROM_UTF8( aLibName->c_str() ) : m_lib_path; wxString pkg = FROM_UTF8( pack_name.c_str() ); wxString emsg = wxString::Format( - _( " name:'%s' duplicated in eagle :'%s'" ), + _( " name: '%s' duplicated in eagle : '%s'" ), GetChars( pkg ), GetChars( lib ) ); @@ -2876,6 +2890,17 @@ MODULE* EAGLE_PLUGIN::FootprintLoad( const wxString& aLibraryPath, const wxStrin } +void EAGLE_PLUGIN::FootprintLibOptions( PROPERTIES* aListToAppendTo ) const +{ + /* + (*aListToAppendTo)["ignore_duplicates"] = wxString( _( + "Ignore duplicately named footprints within the same Eagle library. " + "Only the first similarly named footprint will be loaded." + )).utf8_str(); + */ +} + + /* void EAGLE_PLUGIN::Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties ) { diff --git a/pcbnew/eagle_plugin.h b/pcbnew/eagle_plugin.h index abe92427e7..6fa626af29 100644 --- a/pcbnew/eagle_plugin.h +++ b/pcbnew/eagle_plugin.h @@ -95,6 +95,8 @@ public: return false; // until someone writes others like FootprintSave(), etc. } + void FootprintLibOptions( PROPERTIES* aProperties ) const; + /* void Save( const wxString& aFileName, BOARD* aBoard, const PROPERTIES* aProperties = NULL );