Add converted footprint library to library table during Eagle project.

This commit is contained in:
Russell Oliver 2018-02-04 21:47:37 +11:00 committed by Wayne Stambaugh
parent a6c436c2cd
commit 864c152a5b
3 changed files with 48 additions and 3 deletions

View File

@ -879,7 +879,49 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString& aFileName, int aFileType )
GetBoard()->SetFileName( newfilename.GetFullPath() );
UpdateTitle();
ArchiveModulesOnBoard( true, newfilename.GetName() );
wxString newLibPath;
ArchiveModulesOnBoard( true, newfilename.GetName(), &newLibPath );
if( newLibPath.Length()>0 )
{
FP_LIB_TABLE* prjlibtable = Prj().PcbFootprintLibs();
const wxString& project_env = PROJECT_VAR_NAME;
wxString rel_path;
wxString env_path;
wxGetEnv( project_env, &env_path );
wxString result( newLibPath );
rel_path = result.Replace( env_path, wxString( "$(" + project_env + ")" ) ) ? result : "" ;
if( !rel_path.IsEmpty() ) newLibPath = rel_path;
FP_LIB_TABLE_ROW* row = new FP_LIB_TABLE_ROW( newfilename.GetName(),
newLibPath,
wxT( "KiCad" ),
wxEmptyString ); // options
prjlibtable->InsertRow( row );
}
if( !GetBoard()->GetFileName().IsEmpty() )
{
wxString tblName = Prj().FootprintLibTblName();
try
{
Prj().PcbFootprintLibs()->Save( tblName );
}
catch( const IO_ERROR& ioe )
{
wxString msg = wxString::Format( _(
"Error occurred saving project specific footprint library "
"table:\n\n%s" ),
GetChars( ioe.What() )
);
wxMessageBox( msg, _( "File Save Error" ), wxOK | wxICON_ERROR );
}
}
return true;
}

View File

@ -588,7 +588,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
}
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName )
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName, wxString* aLibPath )
{
if( GetBoard()->m_Modules == NULL )
{
@ -634,6 +634,9 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString&
if( libPath.IsEmpty() ) // Aborted
return;
if( aLibPath ) *aLibPath = libPath;
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD_SEXP;
PLUGIN::RELEASER pi( IO_MGR::PluginFind( piType ) );

View File

@ -938,7 +938,7 @@ public:
* optional library name to create, stops dialog call.
* must be called with aStoreInNewLib as true
*/
void ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString );
void ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString , wxString* aLibPath = NULL );
/**
* Function RecreateBOMFileFromBoard