Commit 0f4ba095 authored by Wayne Stambaugh's avatar Wayne Stambaugh

Pcbnew footprint library table fixes.

* Make footprint viewer work properly with library table.
* Fix bug in Eagle plugin when enumerating footprints.
* Add missing P-CAD plugin from footprint library table editing dialog.
* Fix bug in FOOTPRINT_INFO::LoadLibraries when error occur loading footprints
  from libraries.
parent 5e53232f
...@@ -46,6 +46,8 @@ ...@@ -46,6 +46,8 @@
bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
{ {
bool retv = true;
// Clear data before reading files // Clear data before reading files
m_filesNotFound.Empty(); m_filesNotFound.Empty();
m_filesInvalid.Empty(); m_filesInvalid.Empty();
...@@ -77,9 +79,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -77,9 +79,10 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ), wxLogDebug( wxT( "Path <%s> -> <%s>." ), GetChars( aFootprintsLibNames[ii] ),
GetChars( filename.GetFullPath() ) ); GetChars( filename.GetFullPath() ) );
if( !filename.FileExists() ) if( !filename.IsOk() || !filename.FileExists() )
{ {
m_filesNotFound << aFootprintsLibNames[ii] << wxT( "\n" ); m_filesNotFound << aFootprintsLibNames[ii] << wxT( "\n" );
retv = false;
continue; continue;
} }
...@@ -110,6 +113,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -110,6 +113,7 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
m_filesInvalid << ioe.errorText << wxT( "\n" ); m_filesInvalid << ioe.errorText << wxT( "\n" );
retv = false;
} }
} }
} }
...@@ -124,12 +128,14 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames ) ...@@ -124,12 +128,14 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( wxArrayString& aFootprintsLibNames )
m_List.sort(); m_List.sort();
return true; return retv;
} }
bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
{ {
bool retv = true;
// Clear data before reading files // Clear data before reading files
m_filesNotFound.Empty(); m_filesNotFound.Empty();
m_filesInvalid.Empty(); m_filesInvalid.Empty();
...@@ -152,6 +158,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) ...@@ -152,6 +158,9 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
wxString path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() ); wxString path = FP_LIB_TABLE::ExpandSubstitutions( row->GetFullURI() );
wxArrayString fpnames = pi->FootprintEnumerate( path ); wxArrayString fpnames = pi->FootprintEnumerate( path );
wxLogDebug( wxT( "Load footprint library type %s from path <%s>" ),
GetChars( row->GetType() ), GetChars( path ) );
for( unsigned i=0; i<fpnames.GetCount(); ++i ) for( unsigned i=0; i<fpnames.GetCount(); ++i )
{ {
std::auto_ptr<MODULE> m( pi->FootprintLoad( path, fpnames[i] ) ); std::auto_ptr<MODULE> m( pi->FootprintLoad( path, fpnames[i] ) );
...@@ -174,12 +183,13 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable ) ...@@ -174,12 +183,13 @@ bool FOOTPRINT_LIST::ReadFootprintFiles( FP_LIB_TABLE& aTable )
catch( IO_ERROR ioe ) catch( IO_ERROR ioe )
{ {
m_filesInvalid << ioe.errorText << wxT( "\n" ); m_filesInvalid << ioe.errorText << wxT( "\n" );
retv = false;
} }
} }
m_List.sort(); m_List.sort();
return true; return retv;
} }
......
...@@ -630,6 +630,7 @@ public: ...@@ -630,6 +630,7 @@ public:
choices.Add( IO_MGR::ShowType( IO_MGR::KICAD ) ); choices.Add( IO_MGR::ShowType( IO_MGR::KICAD ) );
choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) ); choices.Add( IO_MGR::ShowType( IO_MGR::LEGACY ) );
choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) ); choices.Add( IO_MGR::ShowType( IO_MGR::EAGLE ) );
choices.Add( IO_MGR::ShowType( IO_MGR::PCAD ) );
choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) ); choices.Add( IO_MGR::ShowType( IO_MGR::GEDA_PCB ) );
wxGridCellAttr* attr; wxGridCellAttr* attr;
......
...@@ -1058,8 +1058,8 @@ static inline unsigned long timeStamp( CPTREE& aTree ) ...@@ -1058,8 +1058,8 @@ static inline unsigned long timeStamp( CPTREE& aTree )
EAGLE_PLUGIN::EAGLE_PLUGIN() : EAGLE_PLUGIN::EAGLE_PLUGIN() :
m_rules( new ERULES() ), m_rules( new ERULES() ),
m_xpath( new XPATH() ) m_xpath( new XPATH() ),
// m_mod_time( wxDateTime::Now() ) m_mod_time( wxDateTime::Now() )
{ {
init( NULL ); init( NULL );
...@@ -1271,6 +1271,9 @@ void EAGLE_PLUGIN::loadDesignRules( CPTREE& aDesignRules ) ...@@ -1271,6 +1271,9 @@ void EAGLE_PLUGIN::loadDesignRules( CPTREE& aDesignRules )
void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
{ {
if( m_board == NULL )
return;
typedef std::vector<ELAYER> ELAYERS; typedef std::vector<ELAYER> ELAYERS;
typedef ELAYERS::const_iterator EITER; typedef ELAYERS::const_iterator EITER;
...@@ -1289,6 +1292,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers ) ...@@ -1289,6 +1292,7 @@ void EAGLE_PLUGIN::loadLayerDefs( CPTREE& aLayers )
// establish cu layer map: // establish cu layer map:
int ki_layer_count = 0; int ki_layer_count = 0;
for( EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count ) for( EITER it = cu.begin(); it != cu.end(); ++it, ++ki_layer_count )
{ {
if( ki_layer_count == 0 ) if( ki_layer_count == 0 )
...@@ -2674,7 +2678,7 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const ...@@ -2674,7 +2678,7 @@ LAYER_NUM EAGLE_PLUGIN::kicad_layer( int aEagleLayer ) const
case 95: kiLayer = ECO1_N; break; case 95: kiLayer = ECO1_N; break;
case 96: kiLayer = ECO2_N; break; case 96: kiLayer = ECO2_N; break;
default: default:
D( printf( "unsupported eagle layer: %d\n", aEagleLayer );) // D( printf( "unsupported eagle layer: %d\n", aEagleLayer );)
kiLayer = -1; break; // some layers do not map to KiCad kiLayer = -1; break; // some layers do not map to KiCad
} }
} }
...@@ -2714,7 +2718,12 @@ wxDateTime EAGLE_PLUGIN::getModificationTime( const wxString& aPath ) ...@@ -2714,7 +2718,12 @@ wxDateTime EAGLE_PLUGIN::getModificationTime( const wxString& aPath )
m_writable = fn.IsFileWritable(); m_writable = fn.IsFileWritable();
*/ */
return fn.GetModificationTime(); wxDateTime modTime = fn.GetModificationTime();
if( !modTime.IsValid() )
modTime.Now();
return modTime;
} }
...@@ -2724,6 +2733,9 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath ) ...@@ -2724,6 +2733,9 @@ void EAGLE_PLUGIN::cacheLib( const wxString& aLibPath )
{ {
wxDateTime modtime; wxDateTime modtime;
if( !m_mod_time.IsValid() )
m_mod_time.Now();
if( aLibPath != m_lib_path || if( aLibPath != m_lib_path ||
m_mod_time != ( modtime = getModificationTime( aLibPath ) ) ) m_mod_time != ( modtime = getModificationTime( aLibPath ) ) )
{ {
......
...@@ -426,30 +426,49 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList() ...@@ -426,30 +426,49 @@ void FOOTPRINT_VIEWER_FRAME::ReCreateFootprintList()
return; return;
} }
bool libLoaded = false;
FOOTPRINT_LIST fp_info_list;
wxArrayString libsList; wxArrayString libsList;
wxBusyCursor busyCursor;
#if !defined( USE_FP_LIB_TABLE ) #if !defined( USE_FP_LIB_TABLE )
libsList.Add( m_libraryName ); libsList.Add( m_libraryName );
libLoaded = fp_info_list.ReadFootprintFiles( libsList );
#else #else
wxString uri = m_footprintLibTable->FindRow( m_libraryName )->GetFullURI(); const FP_LIB_TABLE::ROW* row = m_footprintLibTable->FindRow( m_libraryName );
if( uri.IsEmpty() ) if( row == NULL )
{
wxString msg;
msg.Format( _( "Footprint library table entry <%s> not found." ),
GetChars( m_libraryName ) );
DisplayError( this, msg );
return; return;
}
uri = FP_LIB_TABLE::ExpandSubstitutions( uri ); FP_LIB_TABLE tmp;
wxLogDebug( wxT( "Footprint library <%s> selected." ), GetChars( uri ) ); tmp.InsertRow( *row );
libLoaded = fp_info_list.ReadFootprintFiles( tmp );
libsList.Add( uri );
#endif #endif
FOOTPRINT_LIST fp_info_list; if( !libLoaded )
fp_info_list.ReadFootprintFiles( libsList ); {
wxString msg;
msg.Format( _( "Error occurred attempting to load footprint library <%s>:\n\n"
"Files not found:\n\n%s\n\nFile load errors:\n\n%s" ),
GetChars( m_libraryName ), GetChars( fp_info_list.m_filesNotFound ),
GetChars( fp_info_list.m_filesInvalid ) );
DisplayError( this, msg );
return;
}
wxArrayString fpList; wxArrayString fpList;
BOOST_FOREACH( FOOTPRINT_INFO& footprint, fp_info_list.m_List ) BOOST_FOREACH( FOOTPRINT_INFO& footprint, fp_info_list.m_List )
{ {
fpList.Add(( footprint.m_Module ) ); fpList.Add( footprint.m_Module );
} }
m_FootprintList->Append( fpList ); m_FootprintList->Append( fpList );
int index = m_FootprintList->FindString( m_footprintName ); int index = m_FootprintList->FindString( m_footprintName );
......
File mode changed from 100755 to 100644
File mode changed from 100755 to 100644
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