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 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" ) );

View File

@ -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 );
}

View File

@ -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();
}

View File

@ -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 );

View File

@ -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<NETLIST_OBJECT_LIST> 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()

View File

@ -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<PART_LIB> lib( new PART_LIB( LIBRARY_TYPE_EESCHEMA, libfn.GetFullPath() ) );
lib->EnableBuffering();

View File

@ -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

View File

@ -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;
};

View File

@ -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;

View File

@ -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();
}

View File

@ -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();