diff --git a/common/wildcards_and_files_ext.cpp b/common/wildcards_and_files_ext.cpp index 4a44d4de63..aca51b0050 100644 --- a/common/wildcards_and_files_ext.cpp +++ b/common/wildcards_and_files_ext.cpp @@ -73,6 +73,7 @@ const wxString SchematicLibraryFileWildcard( _( "KiCad component library file (* 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 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 GerberFileWildcard( _( "Gerber files (*.pho)|*.pho" ) ); const wxString LegacyPcbFileWildcard( _( "KiCad printed circuit board files (*.brd)|*.brd" ) ); diff --git a/eeschema/dialogs/dialog_bom.cpp b/eeschema/dialogs/dialog_bom.cpp index 1de3e8d422..51cc37c22d 100644 --- a/eeschema/dialogs/dialog_bom.cpp +++ b/eeschema/dialogs/dialog_bom.cpp @@ -433,7 +433,7 @@ void DIALOG_BOM::OnRunPlugin( wxCommandEvent& event ) m_parent->SetExecFlags( wxEXEC_SHOW_CONSOLE ); #endif - m_parent->CreateNetlist( -1, fullfilename, 0, &reporter ); + m_parent->CreateNetlist( -1, fullfilename, 0, &reporter, false ); m_Messages->SetValue( reportmsg ); } diff --git a/eeschema/dialogs/dialog_netlist.cpp b/eeschema/dialogs/dialog_netlist.cpp index 2b84556fe8..cb938df573 100644 --- a/eeschema/dialogs/dialog_netlist.cpp +++ b/eeschema/dialogs/dialog_netlist.cpp @@ -611,7 +611,7 @@ void NETLIST_DIALOG::GenNetlist( wxCommandEvent& event ) else 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(); @@ -689,7 +689,7 @@ void NETLIST_DIALOG::RunSimulator( wxCommandEvent& event ) netlist_opt |= NET_ADJUST_PASSIVE_VALS; if( ! m_Parent->CreateNetlist( currPage->m_IdNetType, fn.GetFullPath(), - netlist_opt ) ) + netlist_opt, NULL, false ) ) return; ExecuteFile( this, ExecFile, CommandLine ); @@ -878,4 +878,3 @@ int InvokeDialogNetList( SCH_EDIT_FRAME* aCaller ) return dlg.ShowModal(); } - diff --git a/eeschema/files-io.cpp b/eeschema/files-io.cpp index 8a5089e0c4..d87db0bb94 100644 --- a/eeschema/files-io.cpp +++ b/eeschema/files-io.cpp @@ -650,11 +650,11 @@ bool SCH_EDIT_FRAME::ImportFile( const wxString aFileName) g_RootSheet = pi->Load( fullFileName, &Kiway() ); + wxString projectpath = Kiway().Prj().GetProjectPath(); + wxFileName newfilename = Prj().AbsolutePath( Prj().GetProjectName() ); - wxFileName newfilename( fullFileName ); - - newfilename.SetPath(projectpath); + newfilename.SetExt( SchematicFileExtension ); m_CurrentSheet->clear(); m_CurrentSheet->push_back( g_RootSheet ); diff --git a/eeschema/netlist.cpp b/eeschema/netlist.cpp index 638978a88c..20fb78988d 100644 --- a/eeschema/netlist.cpp +++ b/eeschema/netlist.cpp @@ -110,20 +110,32 @@ void SCH_EDIT_FRAME::sendNetlist() bool SCH_EDIT_FRAME::CreateNetlist( int aFormat, const wxString& aFullFileName, - unsigned aNetlistOptions, REPORTER* aReporter ) + unsigned aNetlistOptions, REPORTER* aReporter, bool silent ) { - if( !prepareForNetlist() ) - return false; + if( !silent ) + { + if( !prepareForNetlist() ) + return false; + } + else + { + SCH_SCREENS schematic; + schematic.UpdateSymbolLinks(); + SCH_SHEET_LIST sheets( g_RootSheet ); + sheets.AnnotatePowerSymbols( Prj().SchLibs() ); + schematic.SchematicCleanUp(); + } std::unique_ptr connectedItemsList( BuildNetListBase() ); bool success = WriteNetListFile( connectedItemsList.release(), aFormat, - aFullFileName, aNetlistOptions, aReporter ); + aFullFileName, aNetlistOptions, aReporter ); return success; } + //#define NETLIST_DEBUG NETLIST_OBJECT_LIST::~NETLIST_OBJECT_LIST() diff --git a/eeschema/sch_eagle_plugin.cpp b/eeschema/sch_eagle_plugin.cpp index 0ede7ffc22..ac19b34e81 100644 --- a/eeschema/sch_eagle_plugin.cpp +++ b/eeschema/sch_eagle_plugin.cpp @@ -371,8 +371,9 @@ SCH_SHEET* SCH_EAGLE_PLUGIN::Load( const wxString& aFileName, KIWAY* aKiway, } // Create a schematic symbol library - wxFileName libfn = aFileName; - libfn.SetName( libfn.GetName() ); + wxString projectpath = m_kiway->Prj().GetProjectPath(); + wxFileName libfn = m_kiway->Prj().AbsolutePath( m_kiway->Prj().GetProjectName() ); + libfn.SetExt( SchematicLibraryFileExtension ); std::unique_ptr lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, libfn.GetFullPath() ) ); lib->EnableBuffering(); diff --git a/eeschema/schframe.h b/eeschema/schframe.h index 0340fee5ad..e623e75de6 100644 --- a/eeschema/schframe.h +++ b/eeschema/schframe.h @@ -532,7 +532,8 @@ public: bool CreateNetlist( int aFormat, const wxString& aFullFileName, unsigned aNetlistOptions, - REPORTER* aReporter = NULL ) override; + REPORTER* aReporter = NULL, + bool silent = false ) override; /** * Function WriteNetListFile diff --git a/include/kiway_player.h b/include/kiway_player.h index 04cc315d42..fbe8ce641b 100644 --- a/include/kiway_player.h +++ b/include/kiway_player.h @@ -214,7 +214,8 @@ public: VTBL_ENTRY bool CreateNetlist( int aFormat, const wxString& aFullFileName, unsigned aNetlistOptions, - REPORTER* aReporter = NULL ) + REPORTER* aReporter = NULL, + bool silent = false ) { return false; }; diff --git a/include/wildcards_and_files_ext.h b/include/wildcards_and_files_ext.h index 56a0cf8271..c113e48932 100644 --- a/include/wildcards_and_files_ext.h +++ b/include/wildcards_and_files_ext.h @@ -89,6 +89,7 @@ extern const wxString LegacyPcbFileWildcard; extern const wxString PcbFileWildcard; extern const wxString EaglePcbFileWildcard; extern const wxString EagleSchematicFileWildcard; +extern const wxString EagleFilesWildcard; extern const wxString PCadPcbFileWildcard; extern const wxString PdfFileWildcard; extern const wxString PSFileWildcard; diff --git a/kicad/import_project.cpp b/kicad/import_project.cpp index 5884952fb1..b0ab19e7fd 100644 --- a/kicad/import_project.cpp +++ b/kicad/import_project.cpp @@ -67,7 +67,7 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event ) ClearMsg(); wxFileDialog schdlg( this, title, default_dir, wxEmptyString, - EagleSchematicFileWildcard, style ); + EagleFilesWildcard, style ); if( schdlg.ShowModal() == wxID_CANCEL ) return; @@ -75,9 +75,12 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event ) wxFileName sch( schdlg.GetPath() ); + sch.SetExt( SchematicFileExtension ); + + 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 ); if( prodlg.ShowModal() == wxID_CANCEL ) @@ -122,80 +125,86 @@ void KICAD_MANAGER_FRAME::OnImportEagleFiles( wxCommandEvent& event ) wxString sch_filename = sch.GetFullPath(); - SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false ); - - if( !schframe ) + if( sch.FileExists() ) { - try + SCH_EDIT_FRAME* schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, false ); + + if( !schframe ) { - schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, true ); + try + { + schframe = (SCH_EDIT_FRAME*) Kiway.Player( FRAME_SCH, true ); + } + catch( IO_ERROR err ) + { + wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(), + _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); + return; + } } - catch( IO_ERROR err ) + + schframe->ImportFile( sch_filename ); + + if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor) + // but no project loaded. { - wxMessageBox( _( "Eeschema failed to load:\n" ) + err.What(), - _( "KiCad Error" ), wxOK | wxICON_ERROR, this ); - return; + schframe->Show( true ); } + + if( schframe->IsIconized() ) + schframe->Iconize( false ); + + schframe->Raise(); + + schframe->CreateNetlist( NET_TYPE_PCBNEW, netlist.GetFullPath(), 0, NULL, true ); } - schframe->ImportFile( sch_filename ); - - if( !schframe->IsShown() ) // the frame exists, (created by the dialog field editor) - // but no project loaded. + if( pcb.FileExists() ) { - schframe->Show( true ); - } + PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false ); - if( schframe->IsIconized() ) - schframe->Iconize( false ); - - schframe->Raise(); - - - // Calculate the netlist filename - wxString nestlistFileFullpath = netlist.GetFullPath(); - schframe->CreateNetlist( NET_TYPE_PCBNEW, nestlistFileFullpath, 0 ); - - PCB_EDIT_FRAME* pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, false ); - - if( !pcbframe ) - { - try + if( !pcbframe ) { - pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, true ); + try + { + pcbframe = (PCB_EDIT_FRAME*) Kiway.Player( FRAME_PCB, true ); + } + catch( IO_ERROR err ) + { + wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ), + wxOK | wxICON_ERROR, this ); + return; + } } - catch( IO_ERROR err ) + + // a pcb frame can be already existing, but not yet used. + // this is the case when running the footprint editor, or the footprint viewer first + // if the frame is not visible, the board is not yet loaded + if( !pcbframe->IsVisible() ) { - wxMessageBox( _( "Pcbnew failed to load:\n" ) + err.What(), _( "KiCad Error" ), - wxOK | wxICON_ERROR, this ); - return; + pcbframe->ImportFile( pcb.GetFullPath() ); + pcbframe->Show( true ); + } + + // On Windows, Raise() does not bring the window on screen, when iconized + if( pcbframe->IsIconized() ) + pcbframe->Iconize( false ); + + pcbframe->Raise(); + + if( netlist.FileExists() ) + { + pcbframe->ReadPcbNetlist( netlist.GetFullPath(), + wxEmptyString, + NULL, + false, + false, + false, + false, + false, + false ); } } - // a pcb frame can be already existing, but not yet used. - // this is the case when running the footprint editor, or the footprint viewer first - // if the frame is not visible, the board is not yet loaded - if( !pcbframe->IsVisible() ) - { - pcbframe->ImportFile( pcb.GetFullPath() ); - pcbframe->Show( true ); - } - - // On Windows, Raise() does not bring the window on screen, when iconized - if( pcbframe->IsIconized() ) - pcbframe->Iconize( false ); - - pcbframe->Raise(); - - pcbframe->ReadPcbNetlist( nestlistFileFullpath, - wxEmptyString, - NULL, - false, - false, - false, - false, - false, - false ); - ReCreateTreePrj(); } diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index 2cf465a818..f52faedacc 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -870,9 +870,10 @@ bool PCB_EDIT_FRAME::ImportFile( const wxString aFileName ) KICTL_EAGLE_BRD ) ) { wxString projectpath = Kiway().Prj().GetProjectPath(); + wxFileName newfilename = Prj().AbsolutePath( Prj().GetProjectName() ); + + newfilename.SetExt( KiCadPcbFileExtension ); - wxFileName newfilename( aFileName ); - newfilename.SetPath( projectpath ); GetBoard()->SetFileName( newfilename.GetFullPath() ); UpdateTitle();