2008-12-08 15:27:13 +00:00
|
|
|
/*******************/
|
|
|
|
/* File: cvpcb.cpp */
|
|
|
|
/*******************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
2009-04-12 14:39:54 +00:00
|
|
|
#include "wxstruct.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "cvpcb.h"
|
2008-10-20 05:59:58 +00:00
|
|
|
#include "zones.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "protos.h"
|
2011-02-05 16:15:48 +00:00
|
|
|
#include "cvpcb_mainframe.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2010-11-12 18:38:48 +00:00
|
|
|
#include "cvpcb_id.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
#include "build_version.h"
|
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include <wx/snglinst.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-29 20:36:12 +00:00
|
|
|
// Colors for layers and items
|
|
|
|
COLORS_DESIGN_SETTINGS g_ColorsSettings;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
/* Constant string definitions for CvPcb */
|
|
|
|
const wxString ComponentFileExtension( wxT( "cmp" ) );
|
|
|
|
const wxString RetroFileExtension( wxT( "stf" ) );
|
2009-04-23 15:02:18 +00:00
|
|
|
const wxString FootprintAliasFileExtension( wxT( "equ" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-04-21 17:56:27 +00:00
|
|
|
// Wildcard for schematic retroannotation (import footprint names in schematic):
|
2009-05-21 17:42:42 +00:00
|
|
|
const wxString RetroFileWildcard( _( "Kicad retroannotation files (*.stf)|*.stf" ) );
|
|
|
|
const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) );
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
const wxString titleLibLoadError( _( "Library Load Error" ) );
|
|
|
|
|
|
|
|
|
2010-12-21 12:41:17 +00:00
|
|
|
/*
|
|
|
|
* MacOSX: Needed for file association
|
2010-01-16 19:42:58 +00:00
|
|
|
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
|
|
|
*/
|
2010-12-21 12:41:17 +00:00
|
|
|
void WinEDA_App::MacOpenFile(const wxString &fileName)
|
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
wxFileName filename = fileName;
|
2010-01-16 19:42:58 +00:00
|
|
|
wxString oldPath;
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME * frame = ((CVPCB_MAINFRAME*)GetTopWindow());
|
2010-12-21 12:41:17 +00:00
|
|
|
|
2010-02-21 20:23:16 +00:00
|
|
|
if(!filename.FileExists())
|
|
|
|
return;
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
if( frame->m_NetlistFileName.DirExists() )
|
|
|
|
oldPath = frame->m_NetlistFileName.GetPath();
|
|
|
|
|
|
|
|
/* Update the library search path list. */
|
|
|
|
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
|
|
|
|
wxGetApp().GetLibraryPathList().Remove( oldPath );
|
2010-01-18 19:33:45 +00:00
|
|
|
wxGetApp().GetLibraryPathList().Insert( filename.GetPath(), 0 );
|
2010-01-16 19:42:58 +00:00
|
|
|
|
2010-01-18 19:33:45 +00:00
|
|
|
frame->m_NetlistFileName = filename;
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
if( frame->ReadNetList() )
|
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
frame->SetLastProject( filename.GetFullPath() );
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
|
2010-01-18 19:33:45 +00:00
|
|
|
wxT( " " ) + filename.GetFullPath() );
|
2010-01-16 19:42:58 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
|
|
|
|
}
|
|
|
|
|
|
|
|
frame->ReCreateMenuBar();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Create a new application object
|
2008-12-08 15:27:13 +00:00
|
|
|
IMPLEMENT_APP( WinEDA_App )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
/************************************/
|
|
|
|
/* Called to initialize the program */
|
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
bool WinEDA_App::OnInit()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
/* WXMAC application specific */
|
|
|
|
#ifdef __WXMAC__
|
|
|
|
// wxApp::SetExitOnFrameDelete(false);
|
2010-09-03 17:39:57 +00:00
|
|
|
wxApp::s_macAboutMenuItemId = ID_KICAD_ABOUT;
|
|
|
|
wxApp::s_macPreferencesMenuItemId = ID_OPTIONS_SETUP;
|
2010-01-18 19:33:45 +00:00
|
|
|
#endif /* __WXMAC__ */
|
|
|
|
|
|
|
|
|
|
|
|
wxFileName filename;
|
|
|
|
wxString message;
|
2011-02-05 16:15:48 +00:00
|
|
|
CVPCB_MAINFRAME* frame = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-16 22:32:26 +00:00
|
|
|
InitEDA_Appl( wxT( "CvPCB" ), APP_TYPE_CVPCB );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_Checker && m_Checker->IsAnotherRunning() )
|
|
|
|
{
|
|
|
|
if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) )
|
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( argc > 1 )
|
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
filename = argv[1];
|
|
|
|
wxSetWorkingDirectory( filename.GetPath() );
|
2008-12-08 15:27:13 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-07-03 07:32:48 +00:00
|
|
|
// read current setup and reopen last directory if no filename to open in command line
|
|
|
|
bool reopenLastUsedDirectory = argc == 1;
|
|
|
|
GetSettings(reopenLastUsedDirectory);
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
g_DrawBgColor = BLACK;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
|
2011-02-05 16:15:48 +00:00
|
|
|
frame = new CVPCB_MAINFRAME( Title );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
// Show the frame
|
|
|
|
SetTopWindow( frame );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-18 19:33:45 +00:00
|
|
|
frame->LoadProjectFile( filename.GetFullPath() );
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->Show( TRUE );
|
2009-08-20 11:44:06 +00:00
|
|
|
frame->BuildFOOTPRINTS_LISTBOX();
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-18 19:33:45 +00:00
|
|
|
if( filename.IsOk() && filename.FileExists() )
|
2008-12-08 15:27:13 +00:00
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
frame->m_NetlistFileName = filename;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( frame->ReadNetList() )
|
|
|
|
{
|
2010-01-18 19:33:45 +00:00
|
|
|
frame->m_NetlistFileExtension = filename.GetExt();
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
}
|
2008-12-08 15:27:13 +00:00
|
|
|
}
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-02-05 16:15:48 +00:00
|
|
|
frame->LoadFootprintFiles();
|
2009-04-23 15:02:18 +00:00
|
|
|
frame->m_NetlistFileExtension = wxT( "net" );
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->m_NetlistFileName.Clear();
|
|
|
|
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
|
|
|
|
wxGetCwd() + wxFileName::GetPathSeparator() +
|
|
|
|
_( " [no file]" ) );
|
|
|
|
|
|
|
|
return true;
|
2008-12-08 15:27:13 +00:00
|
|
|
}
|