2008-02-19 07:06:41 +00:00
|
|
|
/************************************************/
|
|
|
|
/* GERBVIEW main file */
|
|
|
|
/************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#define MAIN
|
|
|
|
#define eda_global
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
#include <wx/image.h>
|
|
|
|
#include <wx/file.h>
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
#include "gerbview.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "trigo.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"
|
|
|
|
|
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
wxString g_Main_Title = wxT( "GerbView" );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
IMPLEMENT_APP( WinEDA_App )
|
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
|
|
|
{
|
2008-02-19 07:06:41 +00:00
|
|
|
g_EDA_Appl = this;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
InitEDA_Appl( wxT( "gerbview" ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
ScreenPcb = new PCB_SCREEN( PCB_FRAME );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
ActiveScreen = ScreenPcb;
|
|
|
|
GetSettings();
|
|
|
|
if( m_Checker && m_Checker->IsAnotherRunning() )
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2008-02-19 07:06:41 +00:00
|
|
|
if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) )
|
|
|
|
return false;
|
2007-06-05 12:10:51 +00:00
|
|
|
}
|
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
g_DrawBgColor = BLACK;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2007-09-10 04:51:01 +00:00
|
|
|
Read_Hotkey_Config( m_PcbFrame, false ); /* Must be called before creating the main frame
|
|
|
|
* in order to display the real hotkeys
|
|
|
|
* in menus or tool tips */
|
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
m_GerberFrame = new WinEDA_GerberFrame( NULL, this, wxT( "GerbView" ),
|
|
|
|
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
|
|
|
|
|
2008-10-01 17:34:55 +00:00
|
|
|
/* Gerbview mainframe title */
|
2008-02-19 07:06:41 +00:00
|
|
|
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
|
|
|
|
m_GerberFrame->SetTitle( Title );
|
2008-10-01 17:34:55 +00:00
|
|
|
m_GerberFrame->m_Pcb = new BOARD( NULL, m_GerberFrame );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2008-10-01 17:34:55 +00:00
|
|
|
SetTopWindow( m_GerberFrame ); // Set GerbView mainframe on top
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2008-10-01 17:34:55 +00:00
|
|
|
m_GerberFrame->Show( TRUE ); // Show GerbView mainframe
|
|
|
|
m_GerberFrame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
|
2008-02-19 07:06:41 +00:00
|
|
|
|
|
|
|
if( argc > 1 )
|
|
|
|
{
|
|
|
|
wxString fileName = MakeFileName( wxEmptyString, argv[1], g_PhotoFilenameExt );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
if( !fileName.IsEmpty() )
|
|
|
|
{
|
|
|
|
wxClientDC dc( m_GerberFrame->DrawPanel );
|
|
|
|
m_GerberFrame->DrawPanel->PrepareGraphicContext( &dc );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
wxString path = wxPathOnly( fileName );
|
|
|
|
|
2008-02-23 01:26:21 +00:00
|
|
|
if( path != wxEmptyString )
|
|
|
|
wxSetWorkingDirectory( path );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
|
|
|
Read_Config();
|
|
|
|
|
|
|
|
// Load all files specified on the command line.
|
|
|
|
for( int i=1; i<argc; ++i )
|
|
|
|
{
|
|
|
|
fileName = MakeFileName( wxEmptyString, argv[i], g_PhotoFilenameExt );
|
|
|
|
|
|
|
|
if( wxFileExists( fileName ) )
|
|
|
|
{
|
|
|
|
((PCB_SCREEN*)m_GerberFrame->GetScreen())->m_Active_Layer = i-1;
|
|
|
|
m_GerberFrame->LoadOneGerberFile( fileName, &dc, FALSE );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
Read_Config();
|
|
|
|
|
|
|
|
return TRUE;
|
|
|
|
}
|