Pcbnew: Better dialog when starting pcbnew in a new project, when the .brd file does not exists.
fixed bugs 587175 and 587176
This commit is contained in:
commit
afb63f1081
|
@ -369,6 +369,7 @@ void WinEDA_SchematicFrame::EditComponentFootprint( SCH_COMPONENT* Cmp, wxDC* DC
|
||||||
return;
|
return;
|
||||||
|
|
||||||
SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
|
SCH_FIELD* TextField = Cmp->GetField( FOOTPRINT );
|
||||||
|
message = TextField->m_Text;
|
||||||
|
|
||||||
if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) )
|
if( Get_Message( _( "Footprint" ), _( "Component footprint" ), message, this ) )
|
||||||
return; // edition cancelled by user.
|
return; // edition cancelled by user.
|
||||||
|
|
|
@ -496,18 +496,19 @@ public:
|
||||||
void OnFileHistory( wxCommandEvent& event );
|
void OnFileHistory( wxCommandEvent& event );
|
||||||
void Files_io( wxCommandEvent& event );
|
void Files_io( wxCommandEvent& event );
|
||||||
|
|
||||||
/**
|
/** Function LoadOnePcbFile
|
||||||
* Load a Kicad board (.brd) file.
|
* Load a Kicad board (.brd) file.
|
||||||
*
|
*
|
||||||
* @param aFileName - File name including path. If empty, a file dialog will
|
* @param aFileName - File name including path. If empty, a file dialog will
|
||||||
* be displayed.
|
* be displayed.
|
||||||
* @param aAppend - Append board file aFileName to the currently loaded file if true.
|
* @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
|
* @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.
|
* @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 );
|
bool aForceFileDialog = false );
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -24,6 +24,7 @@
|
||||||
|
|
||||||
#include "build_version.h"
|
#include "build_version.h"
|
||||||
|
|
||||||
|
const wxString g_KicadPrjFilenameExtension(wxT(".pro") );
|
||||||
|
|
||||||
/* Import functions */
|
/* Import functions */
|
||||||
char* GetFileName( char* FullPathName );
|
char* GetFileName( char* FullPathName );
|
||||||
|
|
|
@ -15,6 +15,8 @@
|
||||||
#include "wxstruct.h"
|
#include "wxstruct.h"
|
||||||
#include "appl_wxstruct.h"
|
#include "appl_wxstruct.h"
|
||||||
|
|
||||||
|
extern const wxString g_KicadPrjFilenameExtension;
|
||||||
|
|
||||||
class RIGHT_KM_FRAME;
|
class RIGHT_KM_FRAME;
|
||||||
class TREEPROJECTFILES;
|
class TREEPROJECTFILES;
|
||||||
class TREE_PROJECT_FRAME;
|
class TREE_PROJECT_FRAME;
|
||||||
|
|
|
@ -27,7 +27,7 @@ void WinEDA_MainFrame::CreateNewProject( const wxString PrjFullFileName )
|
||||||
wxFileName newProjectName = PrjFullFileName;
|
wxFileName newProjectName = PrjFullFileName;
|
||||||
|
|
||||||
/* Init default config filename */
|
/* Init default config filename */
|
||||||
filename = wxGetApp().FindLibraryPath( wxT( "kicad.pro" ) );
|
filename = wxGetApp().FindLibraryPath( wxT( "kicad" ) + g_KicadPrjFilenameExtension);
|
||||||
|
|
||||||
/* Check if file kicad.pro exist in template directory */
|
/* Check if file kicad.pro exist in template directory */
|
||||||
if( wxFileName::FileExists( filename ) )
|
if( wxFileName::FileExists( filename ) )
|
||||||
|
@ -86,7 +86,16 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event )
|
||||||
m_ProjectFileName = dlg.GetPath();
|
m_ProjectFileName = dlg.GetPath();
|
||||||
|
|
||||||
if( event.GetId() == ID_NEW_PROJECT )
|
if( event.GetId() == ID_NEW_PROJECT )
|
||||||
|
{
|
||||||
|
// Ensure project filename extension is .pro
|
||||||
|
wxString fullname = m_ProjectFileName.GetFullPath();
|
||||||
|
if ( !fullname.EndsWith( g_KicadPrjFilenameExtension ) )
|
||||||
|
{
|
||||||
|
fullname += g_KicadPrjFilenameExtension;
|
||||||
|
m_ProjectFileName.SetFullName( fullname );
|
||||||
|
}
|
||||||
CreateNewProject( m_ProjectFileName.GetFullPath() );
|
CreateNewProject( m_ProjectFileName.GetFullPath() );
|
||||||
|
}
|
||||||
|
|
||||||
SetLastProject( m_ProjectFileName.GetFullPath() );
|
SetLastProject( m_ProjectFileName.GetFullPath() );
|
||||||
}
|
}
|
||||||
|
@ -98,7 +107,7 @@ void WinEDA_MainFrame::OnLoadProject( wxCommandEvent& event )
|
||||||
wxString filename = m_ProjectFileName.GetFullName();
|
wxString filename = m_ProjectFileName.GetFullName();
|
||||||
|
|
||||||
wxString nameless_prj = NAMELESS_PROJECT;
|
wxString nameless_prj = NAMELESS_PROJECT;
|
||||||
nameless_prj += wxT(".pro");
|
nameless_prj += g_KicadPrjFilenameExtension;
|
||||||
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs(nameless_prj))
|
if( !m_ProjectFileName.FileExists() && !filename.IsSameAs(nameless_prj))
|
||||||
{
|
{
|
||||||
DisplayError( this, _( "Kicad project file <" ) +
|
DisplayError( this, _( "Kicad project file <" ) +
|
||||||
|
|
|
@ -24,7 +24,7 @@
|
||||||
/* Note about the tree project build process:
|
/* Note about the tree project build process:
|
||||||
* Building the tree project can be *very* long if there are a lot of subdirectories
|
* Building the tree project can be *very* long if there are a lot of subdirectories
|
||||||
* in the working directory.
|
* in the working directory.
|
||||||
* Unfornately, this happens easily if the project file *.pro is in the home directory
|
* Unfortunately, this happens easily if the project file *.pro is in the home directory
|
||||||
* So the tree project is built "on demand":
|
* So the tree project is built "on demand":
|
||||||
* First the tree is built from the current directory and shows files and subdirs.
|
* First the tree is built from the current directory and shows files and subdirs.
|
||||||
* > First level subdirs trees are built (i.e subdirs contents are not read)
|
* > First level subdirs trees are built (i.e subdirs contents are not read)
|
||||||
|
|
|
@ -27,7 +27,7 @@ void WinEDA_PcbFrame::OnFileHistory( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
|
DrawPanel->UnManageCursor( 0, wxCURSOR_ARROW );
|
||||||
::wxSetWorkingDirectory( ::wxPathOnly( fn ) );
|
::wxSetWorkingDirectory( ::wxPathOnly( fn ) );
|
||||||
LoadOnePcbFile( fn, false );
|
LoadOnePcbFile( fn );
|
||||||
ReCreateAuxiliaryToolbar();
|
ReCreateAuxiliaryToolbar();
|
||||||
DrawPanel->MouseToCursorSchema();
|
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 WinEDA_PcbFrame::LoadOnePcbFile( const wxString& aFileName, bool Append,
|
||||||
bool aForceFileDialog )
|
bool aForceFileDialog )
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,13 +154,31 @@ Changing extension to .brd." ), GetChars( fn.GetFullPath() ) );
|
||||||
/* Load file specified in the command line. */
|
/* Load file specified in the command line. */
|
||||||
if( fn.IsOk() )
|
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
|
wxString msg;
|
||||||
frame->ReCreateLayerBox( NULL );
|
msg.Printf( _( "File <%s> not existing\nThis is normal for a new project" ),
|
||||||
|
GetChars( frame->GetScreen()->m_FileName ) );
|
||||||
|
wxMessageBox( msg );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
frame->LoadProjectSettings( fn.GetFullPath() );
|
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
|
/* For an obscure reason the focus is lost after loading a board file
|
||||||
* when starting (i.e. only at this point)
|
* when starting (i.e. only at this point)
|
||||||
|
|
Loading…
Reference in New Issue