kicad/cvpcb/cvpcb.cpp

143 lines
3.9 KiB
C++
Raw Normal View History

/*******************/
/* File: cvpcb.cpp */
/*******************/
#include "fctsys.h"
#include "appl_wxstruct.h"
2009-04-12 14:39:54 +00:00
#include "wxstruct.h"
#include "common.h"
#include "confirm.h"
#include "gestfich.h"
#include "cvpcb.h"
#include "zones.h"
#include "bitmaps.h"
#include "protos.h"
#include "cvstruct.h"
#include "colors_selection.h"
#include "build_version.h"
#include <wx/snglinst.h>
// Colors for layers and items
COLORS_DESIGN_SETTINGS g_ColorsSettings;
/* Constant string definitions for CvPcb */
const wxString ComponentFileExtension( wxT( "cmp" ) );
const wxString RetroFileExtension( wxT( "stf" ) );
const wxString FootprintAliasFileExtension( wxT( "equ" ) );
// Wildcard for schematic retroannotation (import footprint names in schematic):
const wxString RetroFileWildcard( _( "Kicad retroannotation files (*.stf)|*.stf" ) );
const wxString FootprintAliasFileWildcard( _( "Kicad footprint alias files (*.equ)|*.equ" ) );
const wxString titleLibLoadError( _( "Library Load Error" ) );
/* MacOSX: Needed for file association
* http://wiki.wxwidgets.org/WxMac-specific_topics
*/
void WinEDA_App::MacOpenFile(const wxString &fileName) {
2010-01-18 19:33:45 +00:00
wxFileName filename = fileName;
wxString oldPath;
WinEDA_CvpcbFrame * frame = ((WinEDA_CvpcbFrame*)GetTopWindow());
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-18 19:33:45 +00:00
frame->m_NetlistFileName = filename;
if( frame->ReadNetList() )
{
2010-01-18 19:33:45 +00:00
frame->SetLastProject( filename.GetFullPath() );
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() +
2010-01-18 19:33:45 +00:00
wxT( " " ) + filename.GetFullPath() );
}
else
{
frame->SetTitle( wxGetApp().GetTitle() + wxT( " " ) + GetBuildVersion() );
}
frame->ReCreateMenuBar();
}
// Create a new application object
IMPLEMENT_APP( WinEDA_App )
/************************************/
/* Called to initialize the program */
/************************************/
bool WinEDA_App::OnInit()
{
2010-01-18 19:33:45 +00:00
/* WXMAC application specific */
#ifdef __WXMAC__
// wxApp::SetExitOnFrameDelete(false);
// wxApp::s_macAboutMenuItemId = ID_KICAD_ABOUT;
wxApp::s_macPreferencesMenuItemId = ID_OPTIONS_SETUP;
#endif /* __WXMAC__ */
wxFileName filename;
wxString message;
WinEDA_CvpcbFrame* frame = NULL;
InitEDA_Appl( wxT( "CvPCB" ), APP_TYPE_CVPCB );
if( m_Checker && m_Checker->IsAnotherRunning() )
{
if( !IsOK( NULL, _( "Cvpcb is already running, Continue?" ) ) )
return false;
}
if( argc > 1 )
{
2010-01-18 19:33:45 +00:00
filename = argv[1];
wxSetWorkingDirectory( filename.GetPath() );
}
// read current setup and reopen last directory if no filename to open in command line
bool reopenLastUsedDirectory = argc == 1;
GetSettings(reopenLastUsedDirectory);
g_DrawBgColor = BLACK;
wxString Title = GetTitle() + wxT( " " ) + GetBuildVersion();
frame = new WinEDA_CvpcbFrame( Title );
// Show the frame
SetTopWindow( frame );
2010-01-18 19:33:45 +00:00
frame->LoadProjectFile( filename.GetFullPath() );
frame->Show( TRUE );
frame->BuildFOOTPRINTS_LISTBOX();
2010-01-18 19:33:45 +00:00
if( filename.IsOk() && filename.FileExists() )
{
2010-01-18 19:33:45 +00:00
frame->m_NetlistFileName = filename;
if( frame->ReadNetList() )
{
2010-01-18 19:33:45 +00:00
frame->m_NetlistFileExtension = filename.GetExt();
return true;
}
}
LoadFootprintFiles( frame->m_ModuleLibNames, frame->m_footprints );
frame->m_NetlistFileExtension = wxT( "net" );
frame->m_NetlistFileName.Clear();
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() +
wxGetCwd() + wxFileName::GetPathSeparator() +
_( " [no file]" ) );
return true;
}