Kicad Eagle Project Import Improvements. -- schematic and board files are both visible in file selection dialog. -- Allows for the selection of either the board or schematic file. -- silently fails on not detecting the corrosponding board or schematic file. -- all new kicad files are generated in new project directory -- Silently read netlist without generating annotation warnings which synchronises timestamps and paths based on given eagle references, otherwise renumbering schematic references will break links accross schematic and pcbnew.

This commit is contained in:
Russell Oliver 2017-08-25 17:14:26 +10:00 committed by Maciej Suminski
parent 3145829b77
commit 869743d573
11 changed files with 105 additions and 79 deletions

View File

@ -73,6 +73,7 @@ const wxString SchematicLibraryFileWildcard( _( "KiCad component library file (*
const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) ); const wxString ProjectFileWildcard( _( "KiCad project files (*.pro)|*.pro" ) );
const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch|Eagle 6.x XML schematic file (*.sch)|*.sch" ) ); const wxString SchematicFileWildcard( _( "KiCad schematic files (*.sch)|*.sch|Eagle 6.x XML schematic file (*.sch)|*.sch" ) );
const wxString EagleSchematicFileWildcard( _( "Eagle XML schematic file (*.sch)|*.sch" ) ); const wxString EagleSchematicFileWildcard( _( "Eagle XML schematic file (*.sch)|*.sch" ) );
const wxString EagleFilesWildcard( _( "Eagle XML files (*.sch *.brd)|*.sch;*.brd" ) );
const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) ); const wxString NetlistFileWildcard( _( "KiCad netlist files (*.net)|*.net" ) );
const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) );
const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) ); const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) );

View File

@ -433,7 +433,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event )
m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE ); m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE );
#endif #endif
m_parent->CreateNetlist( -1, fullfilename, 0, &reporter ); m_parent->CreateNetlist( -1, fullfilename, 0, &reporter, false );
m_Messages->SetValue( reportmsg ); m_Messages->SetValue( reportmsg );
} }

View File

@ -611,7 +611,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event )
else else
m_Parent->SetNetListerCommand( wxEmptyString ); m_Parent->SetNetListerCommand( wxEmptyString );
m_Parent->CreateNetlist( currPage->m_IdNetType, fullpath, netlist_opt ); m_Parent->CreateNetlist( currPage->m_IdNetType, fullpath, netlist_opt, NULL, false );
WriteCurrentNetlistSetup(); WriteCurrentNetlistSetup();
@ -689,7 +689,7 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event )
netlist_opt |= NET_ADJUST_PASSIVE_VALS; netlist_opt |= NET_ADJUST_PASSIVE_VALS;
if( ! m_Parent->CreateNetlist( currPage->m_IdNetType, fn.GetFullPath(), if( ! m_Parent->CreateNetlist( currPage->m_IdNetType, fn.GetFullPath(),
netlist_opt ) ) netlist_opt, NULL, false ) )
return; return;
ExecuteFile( this, ExecFile, CommandLine ); ExecuteFile( this, ExecFile, CommandLine );
@ -878,4 +878,3 @@ int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller )
return dlg.ShowModal(); return dlg.ShowModal();
} }

View File

@ -650,11 +650,11 @@ bool SCH_EDIT_FRAME::ImportFile( const wxString aFileName)
g_RootSheet = pi->Load( fullFileName, &Kiway() ); g_RootSheet = pi->Load( fullFileName, &Kiway() );
wxString projectpath = Kiway().Prj().GetProjectPath(); wxString projectpath = Kiway().Prj().GetProjectPath();
wxFileName newfilename = Prj().AbsolutePath( Prj().GetProjectName() );
wxFileName newfilename( fullFileName ); newfilename.SetExt( SchematicFileExtension );
newfilename.SetPath(projectpath);
m_CurrentSheet->clear(); m_CurrentSheet->clear();
m_CurrentSheet->push_back( g_RootSheet ); m_CurrentSheet->push_back( g_RootSheet );

View File

@ -110,10 +110,21 @@ void SCH_EDIT_FRAME::sendNetlist()
bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName, bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
unsigned aNetlistOptions, REPORTER* aReporter ) unsigned aNetlistOptions, REPORTER* aReporter, bool silent )
{
if( !silent )
{ {
if( !prepareForNetlist() ) if( !prepareForNetlist() )
return false; return false;
}
else
{
SCH_SCREENS schematic;
schematic.UpdateSymbolLinks();
SCH_SHEET_LIST sheets( g_RootSheet );
sheets.AnnotatePowerSymbols( Prj().SchLibs() );
schematic.SchematicCleanUp();
}
std::unique_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() ); std::unique_ptr<NETLIST_OBJECT_LIST> connectedItemsList( BuildNetListBase() );
@ -124,6 +135,7 @@ bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName,
} }
//#define NETLIST_DEBUG //#define NETLIST_DEBUG
NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST() NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST()

View File

@ -371,8 +371,9 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway,
} }
// Create a schematic symbol library // Create a schematic symbol library
wxFileName libfn = aFileName; wxString projectpath = m_kiway->Prj().GetProjectPath();
libfn.SetName( libfn.GetName() ); wxFileName libfn = m_kiway->Prj().AbsolutePath( m_kiway->Prj().GetProjectName() );
libfn.SetExt( SchematicLibraryFileExtension ); libfn.SetExt( SchematicLibraryFileExtension );
std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, libfn.GetFullPath() ) ); std::unique_ptr<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, libfn.GetFullPath() ) );
lib->EnableBuffering(); lib->EnableBuffering();

View File

@ -532,7 +532,8 @@ public:
bool CreateNetlist( int aFormat, bool CreateNetlist( int aFormat,
const wxString& aFullFileName, const wxString& aFullFileName,
unsigned aNetlistOptions, unsigned aNetlistOptions,
REPORTER* aReporter = NULL ) override; REPORTER* aReporter = NULL,
bool silent = false ) override;
/** /**
* Function WriteNetListFile * Function WriteNetListFile

View File

@ -214,7 +214,8 @@ public:
VTBL_ENTRY bool CreateNetlist( int aFormat, VTBL_ENTRY bool CreateNetlist( int aFormat,
const wxString& aFullFileName, const wxString& aFullFileName,
unsigned aNetlistOptions, unsigned aNetlistOptions,
REPORTER* aReporter = NULL ) REPORTER* aReporter = NULL,
bool silent = false )
{ {
return false; return false;
}; };

View File

@ -89,6 +89,7 @@ extern const wxString LegacyPcbFileWildcard;
extern const wxString PcbFileWildcard; extern const wxString PcbFileWildcard;
extern const wxString EaglePcbFileWildcard; extern const wxString EaglePcbFileWildcard;
extern const wxString EagleSchematicFileWildcard; extern const wxString EagleSchematicFileWildcard;
extern const wxString EagleFilesWildcard;
extern const wxString PCadPcbFileWildcard; extern const wxString PCadPcbFileWildcard;
extern const wxString PdfFileWildcard; extern const wxString PdfFileWildcard;
extern const wxString PSFileWildcard; extern const wxString PSFileWildcard;

View File

@ -67,7 +67,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
ClearMsg(); ClearMsg();
wxFileDialog schdlg( this, title, default_dir, wxEmptyString, wxFileDialog schdlg( this, title, default_dir, wxEmptyString,
EagleSchematicFileWildcard, style ); EagleFilesWildcard, style );
if( schdlg.ShowModal() == wxID_CANCEL ) if( schdlg.ShowModal() == wxID_CANCEL )
return; return;
@ -75,9 +75,12 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
wxFileName sch( schdlg.GetPath() ); wxFileName sch( schdlg.GetPath() );
sch.SetExt( SchematicFileExtension );
wxString protitle = _( "Kicad Project Destination" ); wxString protitle = _( "Kicad Project Destination" );
wxFileDialog prodlg( this, protitle, default_dir, wxEmptyString, wxFileDialog prodlg( this, protitle, sch.GetPath(), sch.GetName(),
ProjectFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT ); ProjectFileWildcard, wxFD_SAVE | wxFD_OVERWRITE_PROMPT );
if( prodlg.ShowModal() == wxID_CANCEL ) if( prodlg.ShowModal() == wxID_CANCEL )
@ -122,6 +125,8 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
wxString sch_filename = sch.GetFullPath(); wxString sch_filename = sch.GetFullPath();
if( sch.FileExists() )
{
SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false ); SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false );
if( !schframe ) if( !schframe )
@ -151,11 +156,11 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
schframe->Raise(); schframe->Raise();
schframe->CreateNetlist( NET_TYPE_PCBNEW, netlist.GetFullPath(), 0, NULL, true );
}
// Calculate the netlist filename if( pcb.FileExists() )
wxString nestlistFileFullpath = netlist.GetFullPath(); {
schframe->CreateNetlist( NET_TYPE_PCBNEW, nestlistFileFullpath, 0 );
PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false ); PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false );
if( !pcbframe ) if( !pcbframe )
@ -187,7 +192,9 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
pcbframe->Raise(); pcbframe->Raise();
pcbframe->ReadPcbNetlist( nestlistFileFullpath, if( netlist.FileExists() )
{
pcbframe->ReadPcbNetlist( netlist.GetFullPath(),
wxEmptyString, wxEmptyString,
NULL, NULL,
false, false,
@ -196,6 +203,8 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event )
false, false,
false, false,
false ); false );
}
}
ReCreateTreePrj(); ReCreateTreePrj();
} }

View File

@ -870,9 +870,10 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString aFileName )
KICTL_EAGLE_BRD ) ) KICTL_EAGLE_BRD ) )
{ {
wxString projectpath = Kiway().Prj().GetProjectPath(); wxString projectpath = Kiway().Prj().GetProjectPath();
wxFileName newfilename = Prj().AbsolutePath( Prj().GetProjectName() );
newfilename.SetExt( KiCadPcbFileExtension );
wxFileName newfilename( aFileName );
newfilename.SetPath( projectpath );
GetBoard()->SetFileName( newfilename.GetFullPath() ); GetBoard()->SetFileName( newfilename.GetFullPath() );
UpdateTitle(); UpdateTitle();