2011-09-24 18:33:28 +00:00
|
|
|
/**
|
|
|
|
* @file gerbview.cpp
|
|
|
|
* @brief GERBVIEW main file.
|
|
|
|
*/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2012-04-18 07:07:13 +00:00
|
|
|
/*
|
|
|
|
* This program source code file is part of KiCad, a free EDA CAD application.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1992-2012 KiCad Developers, see change_log.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
|
|
|
|
*/
|
|
|
|
|
2013-06-28 10:49:43 +00:00
|
|
|
#include <fctsys.h>
|
2012-01-23 04:33:36 +00:00
|
|
|
#include <appl_wxstruct.h>
|
|
|
|
#include <class_drawpanel.h>
|
|
|
|
#include <confirm.h>
|
|
|
|
#include <gestfich.h>
|
|
|
|
|
|
|
|
#include <gerbview.h>
|
|
|
|
#include <gerbview_id.h>
|
|
|
|
#include <hotkeys.h>
|
|
|
|
|
|
|
|
#include <build_version.h>
|
2010-01-05 08:48:49 +00:00
|
|
|
|
2009-02-04 15:25:03 +00:00
|
|
|
#include <wx/file.h>
|
|
|
|
#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;
|
2012-09-02 12:06:47 +00:00
|
|
|
extern EDA_COLOR_T g_DrawBgColor;
|
2012-05-04 17:44:42 +00:00
|
|
|
int g_Default_GERBER_Format;
|
2009-04-05 20:49:15 +00:00
|
|
|
|
|
|
|
|
2011-12-31 05:44:00 +00:00
|
|
|
const wxChar* g_GerberPageSizeList[] = {
|
|
|
|
wxT( "GERBER" ), // index 0: full size page selection, and do not show page limits
|
|
|
|
wxT( "GERBER" ), // index 1: full size page selection, and show page limits
|
|
|
|
wxT( "A4" ),
|
|
|
|
wxT( "A3" ),
|
|
|
|
wxT( "A2" ),
|
|
|
|
wxT( "A" ),
|
|
|
|
wxT( "B" ),
|
|
|
|
wxT( "C" ),
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
GERBER_IMAGE* g_GERBER_List[32];
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
IMPLEMENT_APP( EDA_APP )
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-01-31 20:01:46 +00:00
|
|
|
/* MacOSX: Needed for file association
|
2010-01-16 19:42:58 +00:00
|
|
|
* http://wiki.wxwidgets.org/WxMac-specific_topics
|
|
|
|
*/
|
2014-02-03 15:10:37 +00:00
|
|
|
void EDA_APP::MacOpenFile( const wxString& aFileName )
|
2010-05-17 20:35:46 +00:00
|
|
|
{
|
2014-02-03 15:10:37 +00:00
|
|
|
wxFileName filename = aFileName;
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME * frame = ((GERBVIEW_FRAME*)GetTopWindow());
|
2010-02-21 20:23:16 +00:00
|
|
|
|
2010-05-17 20:35:46 +00:00
|
|
|
if( !filename.FileExists() )
|
2010-02-21 20:23:16 +00:00
|
|
|
return;
|
|
|
|
|
2014-02-03 15:10:37 +00:00
|
|
|
frame->LoadGerberFiles( aFileName );
|
2010-01-16 19:42:58 +00:00
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
bool EDA_APP::OnInit()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-11-09 14:00:22 +00:00
|
|
|
wxFileName fn;
|
2011-03-12 09:50:21 +00:00
|
|
|
GERBVIEW_FRAME* frame = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
InitEDA_Appl( wxT( "GerbView" ), APP_GERBVIEW_T );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-10-09 11:03:03 +00:00
|
|
|
if( m_Checker && m_Checker->IsAnotherRunning() )
|
|
|
|
{
|
|
|
|
if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) )
|
|
|
|
return false;
|
|
|
|
}
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
// read current setup and reopen last directory if no filename to open in
|
|
|
|
// command line
|
2009-07-03 07:32:48 +00:00
|
|
|
bool reopenLastUsedDirectory = argc == 1;
|
2009-11-09 14:00:22 +00:00
|
|
|
GetSettings( reopenLastUsedDirectory );
|
2009-07-03 07:32:48 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
g_DrawBgColor = BLACK;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-08-28 18:02:24 +00:00
|
|
|
/* Must be called before creating the main frame in order to
|
|
|
|
* display the real hotkeys in menus or tool tips */
|
|
|
|
ReadHotkeyConfig( wxT("GerberFrame"), s_Gerbview_Hokeys_Descr );
|
|
|
|
|
2011-09-06 14:09:40 +00:00
|
|
|
frame = new GERBVIEW_FRAME( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2008-10-01 17:34:55 +00:00
|
|
|
/* Gerbview mainframe title */
|
2009-04-05 20:49:15 +00:00
|
|
|
frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2009-11-09 14:00:22 +00:00
|
|
|
SetTopWindow( frame ); // Set GerbView mainframe on top
|
2011-03-01 18:45:21 +00:00
|
|
|
frame->Show( true ); // Show GerbView mainframe
|
|
|
|
frame->Zoom_Automatique( true ); // Zoom fit in frame
|
|
|
|
frame->GetScreen()->m_FirstRedraw = false;
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2011-04-02 16:14:07 +00:00
|
|
|
|
2009-07-20 17:30:11 +00:00
|
|
|
if( argc <= 1 )
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
|
|
|
|
|
|
|
fn = argv[1];
|
|
|
|
|
|
|
|
if( fn.IsOk() )
|
2008-02-19 07:06:41 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.DirExists() )
|
|
|
|
wxSetWorkingDirectory( fn.GetPath() );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
// Load all files specified on the command line.
|
2013-03-31 13:27:46 +00:00
|
|
|
LAYER_NUM jj = FIRST_LAYER;
|
2011-09-06 14:09:40 +00:00
|
|
|
|
2013-03-31 13:27:46 +00:00
|
|
|
for( LAYER_NUM ii = LAYER_N_2; ii < argc && ii <= NB_GERBER_LAYERS; ++ii )
|
2009-04-05 20:49:15 +00:00
|
|
|
{
|
2009-11-21 20:44:19 +00:00
|
|
|
fn = wxFileName( argv[ii] );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( fn.FileExists() )
|
2008-02-19 07:06:41 +00:00
|
|
|
{
|
2013-03-31 13:27:46 +00:00
|
|
|
frame->setActiveLayer( jj );
|
|
|
|
++jj;
|
2010-12-15 20:15:24 +00:00
|
|
|
frame->LoadGerberFiles( fn.GetFullPath() );
|
2008-02-19 07:06:41 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
return true;
|
2008-02-19 07:06:41 +00:00
|
|
|
}
|