PcbNew Eagle Import: Archives footprints in pretty library automatically on eagle project import.
This commit is contained in:
parent
869743d573
commit
b9973a1c67
|
@ -878,6 +878,8 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString aFileName )
|
||||||
GetBoard()->SetFileName( newfilename.GetFullPath() );
|
GetBoard()->SetFileName( newfilename.GetFullPath() );
|
||||||
UpdateTitle();
|
UpdateTitle();
|
||||||
|
|
||||||
|
ArchiveModulesOnBoard( true, newfilename.GetName() );
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -441,24 +441,43 @@ bool FOOTPRINT_EDIT_FRAME::SaveCurrentModule( const wxString* aLibPath )
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary()
|
wxString PCB_BASE_EDIT_FRAME::CreateNewLibrary(const wxString& aLibName )
|
||||||
{
|
{
|
||||||
// Kicad cannot write legacy format libraries, only .pretty new format
|
// Kicad cannot write legacy format libraries, only .pretty new format
|
||||||
// because the legacy format cannot handle current features.
|
// because the legacy format cannot handle current features.
|
||||||
// The footprint library is actually a directory
|
// The footprint library is actually a directory
|
||||||
|
|
||||||
// prompt user for footprint library name, ending by ".pretty"
|
// if a library name is not given, prompt user for footprint library name, ending by ".pretty"
|
||||||
// Because there are constraints for the directory name to create,
|
// Because there are constraints for the directory name to create,
|
||||||
// (the name should have the extension ".pretty", and the folder cannot be inside
|
// (the name should have the extension ".pretty", and the folder cannot be inside
|
||||||
// a footprint library), we do not use the standard wxDirDialog.
|
// a footprint library), we do not use the standard wxDirDialog.
|
||||||
|
|
||||||
|
|
||||||
wxString initialPath = wxPathOnly( Prj().GetProjectFullName() );
|
wxString initialPath = wxPathOnly( Prj().GetProjectFullName() );
|
||||||
DIALOG_SELECT_PRETTY_LIB dlg( this, initialPath );
|
|
||||||
|
|
||||||
if( dlg.ShowModal() != wxID_OK )
|
wxString libPath;
|
||||||
return wxEmptyString;
|
|
||||||
|
if( aLibName.IsEmpty() )
|
||||||
|
{
|
||||||
|
DIALOG_SELECT_PRETTY_LIB dlg( this, initialPath );
|
||||||
|
if( dlg.ShowModal() != wxID_OK )
|
||||||
|
return wxEmptyString;
|
||||||
|
|
||||||
|
libPath = dlg.GetFullPrettyLibName();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
wxFileName fn = aLibName;
|
||||||
|
|
||||||
|
if( !fn.IsAbsolute() )
|
||||||
|
fn.MakeAbsolute( initialPath );
|
||||||
|
|
||||||
|
// Enforce the extension:
|
||||||
|
fn.SetExt( KiCadFootprintLibPathExtension );
|
||||||
|
|
||||||
|
libPath = fn.GetFullPath();
|
||||||
|
}
|
||||||
|
|
||||||
wxString libPath = dlg.GetFullPrettyLibName();
|
|
||||||
|
|
||||||
// We can save fp libs only using IO_MGR::KICAD format (.pretty libraries)
|
// We can save fp libs only using IO_MGR::KICAD format (.pretty libraries)
|
||||||
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD;
|
IO_MGR::PCB_FILE_T piType = IO_MGR::KICAD;
|
||||||
|
@ -570,7 +589,7 @@ bool FOOTPRINT_EDIT_FRAME::DeleteModuleFromCurrentLibrary()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib )
|
void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName )
|
||||||
{
|
{
|
||||||
if( GetBoard()->m_Modules == NULL )
|
if( GetBoard()->m_Modules == NULL )
|
||||||
{
|
{
|
||||||
|
@ -611,7 +630,7 @@ void PCB_EDIT_FRAME::ArchiveModulesOnBoard( bool aStoreInNewLib )
|
||||||
{
|
{
|
||||||
// The footprints are saved in a new .pretty library.
|
// The footprints are saved in a new .pretty library.
|
||||||
// If this library already exists, all previous footprints will be deleted
|
// If this library already exists, all previous footprints will be deleted
|
||||||
wxString libPath = CreateNewLibrary();
|
wxString libPath = CreateNewLibrary( aLibName );
|
||||||
|
|
||||||
if( libPath.IsEmpty() ) // Aborted
|
if( libPath.IsEmpty() ) // Aborted
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -52,14 +52,16 @@ public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function CreateNewLibrary
|
* Function CreateNewLibrary
|
||||||
* prompts user for a library path, then creates a new footprint library at that
|
* If a library name is given, creates a new footprint library in the project folder
|
||||||
* location. If library exists, user is warned about that, and is given a chance
|
* with the given name. If no library name is given it prompts user for a library path,
|
||||||
|
* then creates a new footprint library at that location.
|
||||||
|
* If library exists, user is warned about that, and is given a chance
|
||||||
* to abort the new creation, and in that case existing library is first deleted.
|
* to abort the new creation, and in that case existing library is first deleted.
|
||||||
*
|
*
|
||||||
* @return wxString - the newly created library path if library was successfully
|
* @return wxString - the newly created library path if library was successfully
|
||||||
* created, else wxEmptyString because user aborted or error.
|
* created, else wxEmptyString because user aborted or error.
|
||||||
*/
|
*/
|
||||||
wxString CreateNewLibrary();
|
wxString CreateNewLibrary(const wxString& aLibName = wxEmptyString);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function OnEditItemRequest
|
* Function OnEditItemRequest
|
||||||
|
|
|
@ -939,8 +939,12 @@ public:
|
||||||
* This lib should be in fp lib table, and is type is .pretty
|
* This lib should be in fp lib table, and is type is .pretty
|
||||||
* false: save modules in a new lib. It it is an existing lib,
|
* false: save modules in a new lib. It it is an existing lib,
|
||||||
* previous footprints will be removed
|
* previous footprints will be removed
|
||||||
|
*
|
||||||
|
* @param aLibName:
|
||||||
|
* optional library name to create, stops dialog call.
|
||||||
|
* must be called with aStoreInNewLib as true
|
||||||
*/
|
*/
|
||||||
void ArchiveModulesOnBoard( bool aStoreInNewLib );
|
void ArchiveModulesOnBoard( bool aStoreInNewLib, const wxString& aLibName = wxEmptyString );
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Function RecreateBOMFileFromBoard
|
* Function RecreateBOMFileFromBoard
|
||||||
|
|
Loading…
Reference in New Issue