2013-09-06 12:17:33 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2007 Jean-Pierre Charras, jaen-pierre.charras@gipsa-lab.inpg.com
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see AUTHORS.txt for contributors.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, you may find one here:
|
|
|
|
* http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
|
|
|
|
* or you may search the http://www.gnu.org website for the version 2 license,
|
|
|
|
* or you may write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
2011-09-30 18:15:37 +00:00
|
|
|
/**
|
|
|
|
* @file cvpcb.cpp
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <fctsys.h>
|
|
|
|
#include <gr_basic.h>
|
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <wxstruct.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
|
|
|
|
#include <cvpcb.h>
|
|
|
|
#include <zones.h>
|
|
|
|
#include <cvpcb_mainframe.h>
|
|
|
|
#include <colors_selection.h>
|
|
|
|
#include <cvpcb_id.h>
|
|
|
|
|
|
|
|
#include <build_version.h>
|
2010-01-05 08:48:49 +00:00
|
|
|
|
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
|
|
|
|
2013-09-06 12:17:33 +00:00
|
|
|
// Constant string definitions for CvPcb
|
2009-04-05 20:49:15 +00:00
|
|
|
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):
|
2011-09-30 18:15:37 +00:00
|
|
|
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
|
|
|
|
*/
|
2013-09-06 12:17:33 +00:00
|
|
|
void EDA_APP::MacOpenFile( const wxString &fileName )
|
2010-12-21 12:41:17 +00:00
|
|
|
{
|
2011-08-24 19:44:05 +00:00
|
|
|
wxFileName filename = fileName;
|
|
|
|
wxString oldPath;
|
|
|
|
CVPCB_MAINFRAME* frame = (CVPCB_MAINFRAME*) GetTopWindow();
|
2010-12-21 12:41:17 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
if( !filename.FileExists() )
|
|
|
|
return;
|
2010-01-16 19:42:58 +00:00
|
|
|
|
|
|
|
if( frame->m_NetlistFileName.DirExists() )
|
|
|
|
oldPath = frame->m_NetlistFileName.GetPath();
|
|
|
|
|
2013-09-06 12:17:33 +00:00
|
|
|
// Update the library search path list.
|
2010-01-16 19:42:58 +00:00
|
|
|
if( wxGetApp().GetLibraryPathList().Index( oldPath ) != wxNOT_FOUND )
|
|
|
|
wxGetApp().GetLibraryPathList().Remove( oldPath );
|
2011-08-24 19:44:05 +00:00
|
|
|
|
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;
|
2012-02-11 09:04:26 +00:00
|
|
|
frame->ReadNetListAndLinkFiles();
|
2010-01-16 19:42:58 +00:00
|
|
|
}
|
|
|
|
|
2013-09-06 12:17:33 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
// Create a new application object
|
2011-09-06 14:09:40 +00:00
|
|
|
IMPLEMENT_APP( EDA_APP )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-08-24 19:44:05 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
/************************************/
|
|
|
|
/* Called to initialize the program */
|
|
|
|
/************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
bool EDA_APP::OnInit()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2011-08-24 19:44:05 +00:00
|
|
|
wxFileName filename;
|
|
|
|
wxString message;
|
|
|
|
CVPCB_MAINFRAME* frame = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-05-10 06:25:27 +00:00
|
|
|
InitEDA_Appl( wxT( "CvPcb" ), APP_CVPCB_T );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2013-09-06 12:17:33 +00:00
|
|
|
#if defined( USE_FP_LIB_TABLE )
|
|
|
|
SetFootprintLibTablePath();
|
|
|
|
#endif
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
if( m_Checker && m_Checker->IsAnotherRunning() )
|
|
|
|
{
|
2011-08-29 19:50:05 +00:00
|
|
|
if( !IsOK( NULL, _( "CvPcb is already running, Continue?" ) ) )
|
2008-12-08 15:27:13 +00:00
|
|
|
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;
|
2013-09-06 12:17:33 +00:00
|
|
|
GetSettings( reopenLastUsedDirectory );
|
2009-07-03 07:32:48 +00:00
|
|
|
|
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 );
|
2012-01-22 17:20:22 +00:00
|
|
|
frame->Show( true );
|
2013-09-06 12:17:33 +00:00
|
|
|
frame->m_NetlistFileExtension = wxT( "net" );
|
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;
|
2013-09-06 12:17:33 +00:00
|
|
|
frame->LoadProjectFile( filename.GetFullPath() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-02-11 09:04:26 +00:00
|
|
|
if( frame->ReadNetListAndLinkFiles() )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
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-08-24 19:44:05 +00:00
|
|
|
frame->UpdateTitle();
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
return true;
|
2008-12-08 15:27:13 +00:00
|
|
|
}
|