diff --git a/include/wxPcbStruct.h b/include/wxPcbStruct.h index df35a00726..3c1f08de4c 100644 --- a/include/wxPcbStruct.h +++ b/include/wxPcbStruct.h @@ -496,18 +496,19 @@ public: void OnFileHistory( wxCommandEvent& event ); void Files_io( wxCommandEvent& event ); - /** + /** Function LoadOnePcbFile * Load a Kicad board (.brd) file. * * @param aFileName - File name including path. If empty, a file dialog will * be displayed. * @param aAppend - Append board file aFileName to the currently loaded file if true. + * Default = false. * @param aForceFileDialog - Display the file open dialog even if aFullFileName is - * valid if true. + * valid if true; Default = false. * * @return False if file load fails or is cancelled by the user, otherwise true. */ - bool LoadOnePcbFile( const wxString& aFileName, bool aAppend, + bool LoadOnePcbFile( const wxString& aFileName, bool aAppend = false, bool aForceFileDialog = false ); diff --git a/pcbnew/files.cpp b/pcbnew/files.cpp index b6505249b8..5b902b7789 100644 --- a/pcbnew/files.cpp +++ b/pcbnew/files.cpp @@ -27,7 +27,7 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event ) { DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW ); ::wxSetWorkingDirectory( ::wxPathOnly( fn ) ); - LoadOnePcbFile( fn, false ); + LoadOnePcbFile( fn ); ReCreateAuxiliaryToolbar(); DrawPanel->MouseToCursorSchema(); } @@ -114,6 +114,18 @@ void WinEDA_PcbFrame::Files_io( wxCommandEvent& event ) } +/** Function WinEDA_PcbFrame::LoadOnePcbFile + * Load a Kicad board (.brd) file. + * + * @param aFileName - File name including path. If empty, a file dialog will + * be displayed. + * @param aAppend - Append board file aFileName to the currently loaded file if true. + * Default = false. + * @param aForceFileDialog - Display the file open dialog even if aFullFileName is + * valid if true; Default = false. + * + * @return False if file load fails or is cancelled by the user, otherwise true. + */ bool WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool Append, bool aForceFileDialog ) { diff --git a/pcbnew/pcbnew.cpp b/pcbnew/pcbnew.cpp index cfc329d084..728a7ac485 100644 --- a/pcbnew/pcbnew.cpp +++ b/pcbnew/pcbnew.cpp @@ -154,13 +154,31 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) ); /* Load file specified in the command line. */ if( fn.IsOk() ) { - frame->LoadOnePcbFile( fn.GetFullPath(), FALSE ); + /* Note the first time Pcbnew is called after creating a new project + * the board file may not exists + * So we load settings only + */ + if( fn.FileExists() ) + frame->LoadOnePcbFile( fn.GetFullPath() ); + else + { // File does not exists: prepare an empty board + wxSetWorkingDirectory( fn.GetPath() ); + frame->GetScreen()->m_FileName = fn.GetFullPath(); + frame->GetScreen()->m_FileName.Replace( WIN_STRING_DIR_SEP, UNIX_STRING_DIR_SEP ); + frame->SetTitle( frame->GetScreen()->m_FileName ); + frame->SetLastProject( frame->GetScreen()->m_FileName ); + frame->OnModify(); // Ready to save the new empty board - // update the layer names in the listbox - frame->ReCreateLayerBox( NULL ); + wxString msg; + msg.Printf( _( "File <%s> not existing\nThis is normal for a new project" ), + GetChars( frame->GetScreen()->m_FileName ) ); + wxMessageBox( msg ); + } } frame->LoadProjectSettings( fn.GetFullPath() ); + // update the layer names in the listbox + frame->ReCreateLayerBox( NULL ); /* For an obscure reason the focus is lost after loading a board file * when starting (i.e. only at this point)