kicad.exe work:
*) re-enable the MacOpen() support. *) fix path truncation bug. *) open *.kicad_pcb and *.sch files in the same process if they are part of the the currently open project, even from the tree view.
This commit is contained in:
parent
acbe6290c5
commit
853abdac24
|
@ -48,11 +48,12 @@ TREEPROJECT_ITEM::TREEPROJECT_ITEM( enum TreeFileType type, const wxString& data
|
||||||
wxTreeCtrl* parent ) :
|
wxTreeCtrl* parent ) :
|
||||||
wxTreeItemData()
|
wxTreeItemData()
|
||||||
{
|
{
|
||||||
m_Type = type;
|
|
||||||
m_parent = parent;
|
m_parent = parent;
|
||||||
m_FileName = data;
|
|
||||||
m_IsRootFile = false; // true only for the root item of the tree (the project name)
|
SetType( type );
|
||||||
m_IsPopulated = false;
|
SetFileName( data );
|
||||||
|
SetRootFile( false ); // true only for the root item of the tree (the project name)
|
||||||
|
SetPopulated( false );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -73,12 +74,9 @@ void TREEPROJECT_ITEM::SetState( int state )
|
||||||
const wxString TREEPROJECT_ITEM::GetDir() const
|
const wxString TREEPROJECT_ITEM::GetDir() const
|
||||||
{
|
{
|
||||||
if( TREE_DIRECTORY == m_Type )
|
if( TREE_DIRECTORY == m_Type )
|
||||||
return m_FileName;
|
return GetFileName();
|
||||||
|
|
||||||
wxFileName filename = wxFileName( m_FileName );
|
return wxFileName( GetFileName() ).GetPath();
|
||||||
|
|
||||||
wxString dir = filename.GetPath();
|
|
||||||
return dir;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -100,7 +98,7 @@ bool TREEPROJECT_ITEM::Rename( const wxString& name, bool check )
|
||||||
else
|
else
|
||||||
newFile = name;
|
newFile = name;
|
||||||
|
|
||||||
if( newFile == m_FileName )
|
if( newFile == GetFileName() )
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
wxString ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );
|
wxString ext = TREE_PROJECT_FRAME::GetFileExt( GetType() );
|
||||||
|
@ -123,10 +121,10 @@ type.\n Do you want to continue ?"
|
||||||
#if ( ( wxMAJOR_VERSION < 2 ) || ( ( wxMAJOR_VERSION == 2 ) \
|
#if ( ( wxMAJOR_VERSION < 2 ) || ( ( wxMAJOR_VERSION == 2 ) \
|
||||||
&& ( wxMINOR_VERSION < 7 ) ) )
|
&& ( wxMINOR_VERSION < 7 ) ) )
|
||||||
|
|
||||||
if( !wxRenameFile( m_FileName, newFile ) )
|
if( !wxRenameFile( GetFileName(), newFile ) )
|
||||||
#else
|
#else
|
||||||
|
|
||||||
if( !wxRenameFile( m_FileName, newFile, false ) )
|
if( !wxRenameFile( GetFileName(), newFile, false ) )
|
||||||
#endif
|
#endif
|
||||||
{
|
{
|
||||||
wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
|
wxMessageDialog( m_parent, _( "Unable to rename file ... " ),
|
||||||
|
@ -156,18 +154,18 @@ bool TREEPROJECT_ITEM::Delete( bool check )
|
||||||
{
|
{
|
||||||
bool success;
|
bool success;
|
||||||
|
|
||||||
if( !wxDirExists( m_FileName ) )
|
if( !wxDirExists( GetFileName() ) )
|
||||||
success = wxRemoveFile( m_FileName );
|
success = wxRemoveFile( GetFileName() );
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxArrayString filelist;
|
wxArrayString filelist;
|
||||||
|
|
||||||
wxDir::GetAllFiles( m_FileName, &filelist );
|
wxDir::GetAllFiles( GetFileName(), &filelist );
|
||||||
|
|
||||||
for( unsigned int i = 0; i < filelist.Count(); i++ )
|
for( unsigned int i = 0; i < filelist.Count(); i++ )
|
||||||
wxRemoveFile( filelist[i] );
|
wxRemoveFile( filelist[i] );
|
||||||
|
|
||||||
success = wxRmdir( m_FileName );
|
success = wxRmdir( GetFileName() );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( success )
|
if( success )
|
||||||
|
@ -188,8 +186,6 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
||||||
|
|
||||||
KICAD_MANAGER_FRAME* mainFrame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow();
|
KICAD_MANAGER_FRAME* mainFrame = (KICAD_MANAGER_FRAME*) Pgm().App().GetTopWindow();
|
||||||
|
|
||||||
AddDelimiterString( fullFileName );
|
|
||||||
|
|
||||||
switch( GetType() )
|
switch( GetType() )
|
||||||
{
|
{
|
||||||
case TREE_PROJECT:
|
case TREE_PROJECT:
|
||||||
|
@ -200,17 +196,42 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_SCHEMA:
|
case TREE_SCHEMA:
|
||||||
|
{
|
||||||
|
wxFileName ffn( fullFileName );
|
||||||
|
wxFileName pro( mainFrame->GetProjectFileName() );
|
||||||
|
|
||||||
|
// compare all but the extension:
|
||||||
|
if( pro.GetPath()==ffn.GetPath() && pro.GetName()==ffn.GetName() )
|
||||||
|
{
|
||||||
|
// the project's schematic is opened using the *.kiface as part of this process.
|
||||||
|
mainFrame->RunEeschema( fullFileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// schematics not part of the project are opened in a separate process.
|
||||||
mainFrame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
|
mainFrame->Execute( m_parent, EESCHEMA_EXE, fullFileName );
|
||||||
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_LEGACY_PCB:
|
case TREE_LEGACY_PCB:
|
||||||
case TREE_SEXP_PCB:
|
case TREE_SEXP_PCB:
|
||||||
{
|
{
|
||||||
DBG( printf( "%s: %s\n", __func__, TO_UTF8( fullFileName ) ); )
|
wxFileName ffn( fullFileName );
|
||||||
|
wxFileName pro( mainFrame->GetProjectFileName() );
|
||||||
|
|
||||||
|
// compare all but the extension:
|
||||||
|
if( pro.GetPath()==ffn.GetPath() && pro.GetName()==ffn.GetName() )
|
||||||
|
{
|
||||||
|
// the project's BOARD is opened using the *.kiface as part of this process.
|
||||||
|
mainFrame->RunPcbNew( fullFileName );
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// boards not part of the project are opened in a separate process.
|
||||||
mainFrame->Execute( m_parent, PCBNEW_EXE, fullFileName );
|
mainFrame->Execute( m_parent, PCBNEW_EXE, fullFileName );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_GERBER:
|
case TREE_GERBER:
|
||||||
|
@ -218,6 +239,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case TREE_PDF:
|
case TREE_PDF:
|
||||||
|
AddDelimiterString( fullFileName );
|
||||||
OpenPDF( fullFileName );
|
OpenPDF( fullFileName );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -239,6 +261,7 @@ void TREEPROJECT_ITEM::Activate( TREE_PROJECT_FRAME* prjframe )
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
AddDelimiterString( fullFileName );
|
||||||
OpenFile( fullFileName );
|
OpenFile( fullFileName );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
*/
|
*/
|
||||||
class TREEPROJECT_ITEM : public wxTreeItemData
|
class TREEPROJECT_ITEM : public wxTreeItemData
|
||||||
{
|
{
|
||||||
friend class KICAD_MANAGER_FRAME;
|
//friend class KICAD_MANAGER_FRAME;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
|
@ -17,7 +17,7 @@ public:
|
||||||
TREEPROJECT_ITEM() : m_parent( NULL ) { }
|
TREEPROJECT_ITEM() : m_parent( NULL ) { }
|
||||||
|
|
||||||
TREEPROJECT_ITEM( const TREEPROJECT_ITEM& src ) :
|
TREEPROJECT_ITEM( const TREEPROJECT_ITEM& src ) :
|
||||||
m_Type( src.m_Type ), m_FileName( src.m_FileName ), m_parent( src.m_parent )
|
m_Type( src.m_Type ), m_file_name( src.m_file_name ), m_parent( src.m_parent )
|
||||||
{
|
{
|
||||||
SetState( src.m_state );
|
SetState( src.m_state );
|
||||||
m_IsPopulated = false;
|
m_IsPopulated = false;
|
||||||
|
@ -26,8 +26,12 @@ public:
|
||||||
TreeFileType GetType() const { return m_Type; }
|
TreeFileType GetType() const { return m_Type; }
|
||||||
void SetType( TreeFileType aType ) { m_Type = aType; }
|
void SetType( TreeFileType aType ) { m_Type = aType; }
|
||||||
|
|
||||||
const wxString& GetFileName() const { return m_FileName; }
|
const wxString& GetFileName() const { return m_file_name; }
|
||||||
void SetFileName( const wxString& name ) { m_FileName = name; }
|
void SetFileName( const wxString& name )
|
||||||
|
{
|
||||||
|
m_file_name = name;
|
||||||
|
// DBG(printf("%s: '%s'\n", __func__, TO_UTF8( name ) );)
|
||||||
|
}
|
||||||
|
|
||||||
bool IsRootFile() const { return m_IsRootFile; }
|
bool IsRootFile() const { return m_IsRootFile; }
|
||||||
void SetRootFile( bool aValue ) { m_IsRootFile = aValue; }
|
void SetRootFile( bool aValue ) { m_IsRootFile = aValue; }
|
||||||
|
@ -50,7 +54,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
TreeFileType m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
|
TreeFileType m_Type; // = TREE_PROJECT, TREE_DIRECTORY ...
|
||||||
wxString m_FileName; // Filename for a file, or directory name
|
wxString m_file_name; // Filename for a file, or directory name
|
||||||
bool m_IsRootFile; // True if m_Filename is a root schematic (same name as project)
|
bool m_IsRootFile; // True if m_Filename is a root schematic (same name as project)
|
||||||
bool m_IsPopulated; // True if the name is a directory, and its content was read
|
bool m_IsPopulated; // True if the name is a directory, and its content was read
|
||||||
wxTreeCtrl* m_parent;
|
wxTreeCtrl* m_parent;
|
||||||
|
|
|
@ -50,7 +50,7 @@ void KICAD_MANAGER_FRAME::OnFileHistory( wxCommandEvent& event )
|
||||||
wxString fn = GetFileFromHistory( event.GetId(),
|
wxString fn = GetFileFromHistory( event.GetId(),
|
||||||
_( "KiCad project file" ), &Pgm().GetFileHistory() );
|
_( "KiCad project file" ), &Pgm().GetFileHistory() );
|
||||||
|
|
||||||
if( fn != wxEmptyString )
|
if( fn.size() )
|
||||||
{
|
{
|
||||||
wxCommandEvent cmd( 0, wxID_ANY );
|
wxCommandEvent cmd( 0, wxID_ANY );
|
||||||
|
|
||||||
|
@ -73,7 +73,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
|
||||||
if( dlg.ShowModal() == wxID_CANCEL )
|
if( dlg.ShowModal() == wxID_CANCEL )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString msg = wxString::Format( _("\nOpen <%s>\n" ), GetChars( dlg.GetPath() ) );
|
wxString msg = wxString::Format( _("\nOpen '%s'\n" ), GetChars( dlg.GetPath() ) );
|
||||||
PrintMsg( msg );
|
PrintMsg( msg );
|
||||||
|
|
||||||
wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
|
wxDirDialog dirDlg( this, _( "Target Directory" ), fn.GetPath(),
|
||||||
|
@ -83,7 +83,7 @@ void KICAD_MANAGER_FRAME::OnUnarchiveFiles( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxSetWorkingDirectory( dirDlg.GetPath() );
|
wxSetWorkingDirectory( dirDlg.GetPath() );
|
||||||
msg.Printf( _( "Unzipping project in <%s>\n" ), GetChars( dirDlg.GetPath() ) );
|
msg.Printf( _( "Unzipping project in '%s'\n" ), GetChars( dirDlg.GetPath() ) );
|
||||||
PrintMsg( msg );
|
PrintMsg( msg );
|
||||||
|
|
||||||
wxFileSystem zipfilesys;
|
wxFileSystem zipfilesys;
|
||||||
|
|
|
@ -214,37 +214,17 @@ void PGM_KICAD::OnPgmExit()
|
||||||
|
|
||||||
void PGM_KICAD::MacOpenFile( const wxString& aFileName )
|
void PGM_KICAD::MacOpenFile( const wxString& aFileName )
|
||||||
{
|
{
|
||||||
#if 0 // I'm tired, need a rest.
|
#if defined(__WXMAC__)
|
||||||
|
|
||||||
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) GetTopWindow();
|
KICAD_MANAGER_FRAME* frame = (KICAD_MANAGER_FRAME*) App().GetTopWindow();
|
||||||
|
|
||||||
frame->SetProjectFile( aFileName );
|
frame->SetProjectFileName( aFileName );
|
||||||
|
|
||||||
wxFileName fn = aFileName;
|
|
||||||
|
|
||||||
if( !fn.FileExists() && m_fileHistory.GetCount() )
|
|
||||||
{
|
|
||||||
m_fileHistory.RemoveFileFromHistory( 0 );
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxCommandEvent loadEvent;
|
wxCommandEvent loadEvent;
|
||||||
|
|
||||||
loadEvent.SetId( wxID_ANY );
|
loadEvent.SetId( wxID_ANY );
|
||||||
|
|
||||||
frame->OnLoadProject( loadEvent );
|
frame->OnLoadProject( loadEvent );
|
||||||
|
|
||||||
wxString title = GetTitle() + wxT( " " ) + GetBuildVersion() +
|
|
||||||
wxT( " " ) + frame->GetProjectFileName();
|
|
||||||
|
|
||||||
if( !fn.IsDirWritable() )
|
|
||||||
title += _( " [Read Only]" );
|
|
||||||
|
|
||||||
frame->SetTitle( title );
|
|
||||||
|
|
||||||
frame->m_LeftWin->ReCreateTreePrj();
|
|
||||||
|
|
||||||
frame->PrintPrjInfo();
|
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -203,7 +203,7 @@ public:
|
||||||
* @param param = parameters to be passed to the executable.
|
* @param param = parameters to be passed to the executable.
|
||||||
*/
|
*/
|
||||||
void Execute( wxWindow* frame, const wxString& execFile,
|
void Execute( wxWindow* frame, const wxString& execFile,
|
||||||
const wxString& param = wxEmptyString );
|
wxString param = wxEmptyString );
|
||||||
|
|
||||||
class TERMINATE_HANDLER : public wxProcess
|
class TERMINATE_HANDLER : public wxProcess
|
||||||
{
|
{
|
||||||
|
@ -233,6 +233,17 @@ public:
|
||||||
// read only accessors
|
// read only accessors
|
||||||
const wxString SchFileName();
|
const wxString SchFileName();
|
||||||
const wxString PcbFileName();
|
const wxString PcbFileName();
|
||||||
|
const wxString PcbLegacyFileName();
|
||||||
|
|
||||||
|
void ReCreateTreePrj();
|
||||||
|
|
||||||
|
/// Call this only for a PCB associated with the current project. That is,
|
||||||
|
/// it must have the same path and name as the project *.pro file.
|
||||||
|
void RunPcbNew( const wxString& aProjectBoardFileName );
|
||||||
|
|
||||||
|
/// Call this only for a SCH associated with the current project. That is,
|
||||||
|
/// it must have the same path and name as the project *.pro file.
|
||||||
|
void RunEeschema( const wxString& aProjectSchematicFileName );
|
||||||
|
|
||||||
DECLARE_EVENT_TABLE()
|
DECLARE_EVENT_TABLE()
|
||||||
|
|
||||||
|
@ -248,7 +259,7 @@ private:
|
||||||
LAUNCHER_PANEL* m_Launcher;
|
LAUNCHER_PANEL* m_Launcher;
|
||||||
wxTextCtrl* m_MessagesBox;
|
wxTextCtrl* m_MessagesBox;
|
||||||
wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
|
wxAuiToolBar* m_VToolBar; // Vertical toolbar (not used)
|
||||||
wxFileName m_project_file_name;
|
wxString m_project_file_name;
|
||||||
|
|
||||||
int m_leftWinWidth;
|
int m_leftWinWidth;
|
||||||
|
|
||||||
|
|
|
@ -124,23 +124,27 @@ wxConfigBase* KICAD_MANAGER_FRAME::config()
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::SetProjectFileName( const wxString& aFullProjectProFileName )
|
void KICAD_MANAGER_FRAME::SetProjectFileName( const wxString& aFullProjectProFileName )
|
||||||
{
|
{
|
||||||
m_project_file_name = aFullProjectProFileName;
|
m_project_file_name = aFullProjectProFileName;
|
||||||
|
|
||||||
wxASSERT( m_project_file_name.IsAbsolute() );
|
wxASSERT( wxFileName( m_project_file_name ).IsAbsolute() ||
|
||||||
|
wxFileName( m_project_file_name ).GetName() == NAMELESS_PROJECT wxT( ".pro" ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const wxString KICAD_MANAGER_FRAME::GetProjectFileName()
|
const wxString KICAD_MANAGER_FRAME::GetProjectFileName()
|
||||||
{
|
{
|
||||||
return m_project_file_name.GetFullPath();
|
return m_project_file_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const wxString KICAD_MANAGER_FRAME::SchFileName()
|
const wxString KICAD_MANAGER_FRAME::SchFileName()
|
||||||
{
|
{
|
||||||
wxFileName fn( GetProjectFileName(), SchematicFileExtension );
|
wxFileName fn( GetProjectFileName() );
|
||||||
|
|
||||||
|
fn.SetExt( SchematicFileExtension );
|
||||||
|
|
||||||
return fn.GetFullName();
|
return fn.GetFullName();
|
||||||
}
|
}
|
||||||
|
@ -148,12 +152,30 @@ const wxString KICAD_MANAGER_FRAME::SchFileName()
|
||||||
|
|
||||||
const wxString KICAD_MANAGER_FRAME::PcbFileName()
|
const wxString KICAD_MANAGER_FRAME::PcbFileName()
|
||||||
{
|
{
|
||||||
wxFileName fn( GetProjectFileName(), PcbFileExtension );
|
wxFileName fn( GetProjectFileName() );
|
||||||
|
|
||||||
|
fn.SetExt( PcbFileExtension );
|
||||||
|
|
||||||
return fn.GetFullName();
|
return fn.GetFullName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
const wxString KICAD_MANAGER_FRAME::PcbLegacyFileName()
|
||||||
|
{
|
||||||
|
wxFileName fn( GetProjectFileName() );
|
||||||
|
|
||||||
|
fn.SetExt( LegacyPcbFileExtension );
|
||||||
|
|
||||||
|
return fn.GetFullName();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KICAD_MANAGER_FRAME::ReCreateTreePrj()
|
||||||
|
{
|
||||||
|
m_LeftWin->ReCreateTreePrj();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
const SEARCH_STACK& KICAD_MANAGER_FRAME::sys_search()
|
const SEARCH_STACK& KICAD_MANAGER_FRAME::sys_search()
|
||||||
{
|
{
|
||||||
return Pgm().SysSearch();
|
return Pgm().SysSearch();
|
||||||
|
@ -227,11 +249,14 @@ void KICAD_MANAGER_FRAME::TERMINATE_HANDLER::OnTerminate( int pid, int status )
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile,
|
void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile,
|
||||||
const wxString& param )
|
wxString params )
|
||||||
{
|
{
|
||||||
|
if( params.size() )
|
||||||
|
AddDelimiterString( params );
|
||||||
|
|
||||||
TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
|
TERMINATE_HANDLER* callback = new TERMINATE_HANDLER( execFile );
|
||||||
|
|
||||||
long pid = ExecuteFile( frame, execFile, param, callback );
|
long pid = ExecuteFile( frame, execFile, params, callback );
|
||||||
|
|
||||||
if( pid > 0 )
|
if( pid > 0 )
|
||||||
{
|
{
|
||||||
|
@ -247,6 +272,54 @@ void KICAD_MANAGER_FRAME::Execute( wxWindow* frame, const wxString& execFile,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KICAD_MANAGER_FRAME::RunEeschema( const wxString& aProjectSchematicFileName )
|
||||||
|
{
|
||||||
|
KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
|
||||||
|
if( !frame )
|
||||||
|
{
|
||||||
|
frame = Kiway.Player( FRAME_SCH, true );
|
||||||
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectSchematicFileName ) );
|
||||||
|
frame->Show( true );
|
||||||
|
}
|
||||||
|
frame->Raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
wxFileName fn( m_project_file_name );
|
||||||
|
|
||||||
|
fn.SetExt( SchematicFileExtension );
|
||||||
|
|
||||||
|
RunEeschema( fn.GetFullPath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KICAD_MANAGER_FRAME::RunPcbNew( const wxString& aProjectBoardFileName )
|
||||||
|
{
|
||||||
|
KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, false );
|
||||||
|
if( !frame )
|
||||||
|
{
|
||||||
|
frame = Kiway.Player( FRAME_PCB, true );
|
||||||
|
frame->OpenProjectFiles( std::vector<wxString>( 1, aProjectBoardFileName ) );
|
||||||
|
frame->Show( true );
|
||||||
|
}
|
||||||
|
frame->Raise();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
||||||
|
{
|
||||||
|
wxFileName kicad_board( PcbFileName() );
|
||||||
|
wxFileName legacy_board( PcbLegacyFileName() );
|
||||||
|
|
||||||
|
wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
|
||||||
|
kicad_board : legacy_board;
|
||||||
|
|
||||||
|
RunPcbNew( board.GetFullPath() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunBitmapConverter( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
Execute( this, BITMAPCONVERTER_EXE );
|
Execute( this, BITMAPCONVERTER_EXE );
|
||||||
|
@ -264,27 +337,6 @@ void KICAD_MANAGER_FRAME::OnRunPageLayoutEditor( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunPcbNew( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
wxFileName kicad_board( PcbFileName() );
|
|
||||||
|
|
||||||
wxFileName legacy_board( GetProjectFileName() );
|
|
||||||
legacy_board.SetExt( LegacyPcbFileExtension );
|
|
||||||
|
|
||||||
wxFileName& board = ( !legacy_board.FileExists() || kicad_board.FileExists() ) ?
|
|
||||||
kicad_board : legacy_board;
|
|
||||||
|
|
||||||
KIWAY_PLAYER* frame = Kiway.Player( FRAME_PCB, false );
|
|
||||||
if( !frame )
|
|
||||||
{
|
|
||||||
frame = Kiway.Player( FRAME_PCB, true );
|
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, board.GetFullPath() ) );
|
|
||||||
frame->Show( true );
|
|
||||||
}
|
|
||||||
frame->Raise();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxFileName fn( m_project_file_name );
|
wxFileName fn( m_project_file_name );
|
||||||
|
@ -302,23 +354,6 @@ void KICAD_MANAGER_FRAME::OnRunCvpcb( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunEeschema( wxCommandEvent& event )
|
|
||||||
{
|
|
||||||
wxFileName fn( m_project_file_name );
|
|
||||||
|
|
||||||
fn.SetExt( SchematicFileExtension );
|
|
||||||
|
|
||||||
KIWAY_PLAYER* frame = Kiway.Player( FRAME_SCH, false );
|
|
||||||
if( !frame )
|
|
||||||
{
|
|
||||||
frame = Kiway.Player( FRAME_SCH, true );
|
|
||||||
frame->OpenProjectFiles( std::vector<wxString>( 1, fn.GetFullPath() ) );
|
|
||||||
frame->Show( true );
|
|
||||||
}
|
|
||||||
frame->Raise();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
void KICAD_MANAGER_FRAME::OnRunGerbview( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
// Gerbview is called without any file to open, because we do not know
|
// Gerbview is called without any file to open, because we do not know
|
||||||
|
|
|
@ -182,14 +182,13 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
{
|
{
|
||||||
wxString title;
|
wxString title;
|
||||||
|
|
||||||
// this is still a mess, will work on it tomorrow.
|
// this is still a pr, will work on it tomorrow.
|
||||||
|
|
||||||
ClearMsg();
|
ClearMsg();
|
||||||
|
|
||||||
if( event.GetId() != wxID_ANY )
|
if( event.GetId() != wxID_ANY )
|
||||||
{
|
{
|
||||||
int style;
|
int style;
|
||||||
|
|
||||||
bool newProject = ( event.GetId() == ID_NEW_PROJECT ) ||
|
bool newProject = ( event.GetId() == ID_NEW_PROJECT ) ||
|
||||||
( event.GetId() == ID_NEW_PROJECT_FROM_TEMPLATE );
|
( event.GetId() == ID_NEW_PROJECT_FROM_TEMPLATE );
|
||||||
|
|
||||||
|
@ -212,6 +211,7 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxFileName pro( dlg.GetPath() );
|
wxFileName pro( dlg.GetPath() );
|
||||||
|
|
||||||
pro.SetExt( ProjectFileExtension );
|
pro.SetExt( ProjectFileExtension );
|
||||||
|
|
||||||
if( newProject )
|
if( newProject )
|
||||||
|
@ -248,40 +248,40 @@ void KICAD_MANAGER_FRAME::OnLoadProject( wxCommandEvent& event )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
SetProjectFileName( pro.GetFullName() );
|
SetProjectFileName( pro.GetFullPath() );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxLogDebug( wxT( "Loading KiCad project file: " ) + GetProjectFileName() );
|
wxString prj_filename = GetProjectFileName();
|
||||||
|
|
||||||
// Check if project file exists and if it is not noname.pro
|
|
||||||
wxString filename = GetProjectFileName();
|
|
||||||
|
|
||||||
wxString nameless_prj = NAMELESS_PROJECT wxT( ".pro" );
|
wxString nameless_prj = NAMELESS_PROJECT wxT( ".pro" );
|
||||||
|
|
||||||
if( !wxFileExists( GetProjectFileName() ) && !filename.IsSameAs( nameless_prj ) )
|
// Check if project file exists and if it is not noname.pro
|
||||||
|
if( !wxFileExists( prj_filename ) && !prj_filename.IsSameAs( nameless_prj ) )
|
||||||
{
|
{
|
||||||
wxString msg = wxString::Format(
|
wxString msg = wxString::Format(
|
||||||
_( "KiCad project file '%s' not found" ),
|
_( "KiCad project file '%s' not found" ),
|
||||||
GetChars( GetProjectFileName() ) );
|
GetChars( prj_filename ) );
|
||||||
|
|
||||||
DisplayError( this, msg );
|
DisplayError( this, msg );
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxSetWorkingDirectory( wxFileName( GetProjectFileName() ).GetPath() );
|
wxSetWorkingDirectory( wxFileName( prj_filename ).GetPath() );
|
||||||
|
|
||||||
// was wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
|
// was wxGetApp().ReadProjectConfig( m_ProjectFileName.GetFullPath(),
|
||||||
// GeneralGroupName, s_KicadManagerParams, false );
|
// GeneralGroupName, s_KicadManagerParams, false );
|
||||||
Prj().ConfigLoad( Pgm().SysSearch(), GetProjectFileName(),
|
Prj().ConfigLoad( Pgm().SysSearch(), prj_filename,
|
||||||
GeneralGroupName, s_KicadManagerParams, false );
|
GeneralGroupName, s_KicadManagerParams, false );
|
||||||
|
|
||||||
title = wxT( "KiCad " ) + GetBuildVersion() + wxT( ' ' ) + GetProjectFileName();
|
title = wxT( "KiCad " ) + GetBuildVersion() + wxT( ' ' ) + prj_filename;
|
||||||
|
|
||||||
if( !wxIsWritable( GetProjectFileName() ) )
|
if( !wxFileName( prj_filename ).IsDirWritable() )
|
||||||
title += _( " [Read Only]" );
|
title += _( " [Read Only]" );
|
||||||
|
|
||||||
SetTitle( title );
|
SetTitle( title );
|
||||||
UpdateFileHistory( GetProjectFileName(), &Pgm().GetFileHistory() );
|
|
||||||
|
if( !prj_filename.IsSameAs( nameless_prj ) )
|
||||||
|
UpdateFileHistory( prj_filename, &Pgm().GetFileHistory() );
|
||||||
|
|
||||||
m_LeftWin->ReCreateTreePrj();
|
m_LeftWin->ReCreateTreePrj();
|
||||||
|
|
||||||
|
|
|
@ -618,7 +618,7 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
||||||
{
|
{
|
||||||
int tree_id;
|
int tree_id;
|
||||||
TREEPROJECT_ITEM* tree_data;
|
TREEPROJECT_ITEM* tree_data;
|
||||||
wxString FullFileName;
|
wxString fullFileName;
|
||||||
wxTreeItemId curr_item = Event.GetItem();
|
wxTreeItemId curr_item = Event.GetItem();
|
||||||
|
|
||||||
// Ensure item is selected (Under Windows right click does not select the item)
|
// Ensure item is selected (Under Windows right click does not select the item)
|
||||||
|
@ -630,7 +630,7 @@ void TREE_PROJECT_FRAME::OnRight( wxTreeEvent& Event )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
tree_id = tree_data->GetType();
|
tree_id = tree_data->GetType();
|
||||||
FullFileName = tree_data->GetFileName();
|
fullFileName = tree_data->GetFileName();
|
||||||
|
|
||||||
wxMenu popupMenu;
|
wxMenu popupMenu;
|
||||||
|
|
||||||
|
@ -684,12 +684,12 @@ void TREE_PROJECT_FRAME::OnOpenSelectedFileWithTextEditor( wxCommandEvent& event
|
||||||
if( tree_data->GetType() == TREE_DIRECTORY )
|
if( tree_data->GetType() == TREE_DIRECTORY )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
wxString FullFileName = tree_data->GetFileName();
|
wxString fullFileName = tree_data->GetFileName();
|
||||||
AddDelimiterString( FullFileName );
|
AddDelimiterString( fullFileName );
|
||||||
wxString editorname = Pgm().GetEditorName();
|
wxString editorname = Pgm().GetEditorName();
|
||||||
|
|
||||||
if( !editorname.IsEmpty() )
|
if( !editorname.IsEmpty() )
|
||||||
ExecuteFile( this, editorname, FullFileName );
|
ExecuteFile( this, editorname, fullFileName );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -736,8 +736,6 @@ void TREE_PROJECT_FRAME::OnRenameFile( wxCommandEvent& )
|
||||||
|
|
||||||
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
||||||
{
|
{
|
||||||
wxString FullFileName;
|
|
||||||
|
|
||||||
TREEPROJECT_ITEM* tree_data = GetSelectedData();
|
TREEPROJECT_ITEM* tree_data = GetSelectedData();
|
||||||
|
|
||||||
if( !tree_data )
|
if( !tree_data )
|
||||||
|
@ -749,8 +747,6 @@ void TREE_PROJECT_FRAME::OnSelect( wxTreeEvent& Event )
|
||||||
|
|
||||||
void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
|
void TREE_PROJECT_FRAME::OnExpand( wxTreeEvent& Event )
|
||||||
{
|
{
|
||||||
wxString FullFileName;
|
|
||||||
|
|
||||||
wxTreeItemId itemId = Event.GetItem();
|
wxTreeItemId itemId = Event.GetItem();
|
||||||
TREEPROJECT_ITEM* tree_data = GetItemIdData( itemId );
|
TREEPROJECT_ITEM* tree_data = GetItemIdData( itemId );
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue