2008-02-19 07:06:41 +00:00
|
|
|
/************************************************/
|
|
|
|
/* GERBVIEW main file */
|
|
|
|
/************************************************/
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
#include "common.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "appl_wxstruct.h"
|
|
|
|
#include "class_drawpanel.h"
|
|
|
|
#include "confirm.h"
|
|
|
|
#include "gestfich.h"
|
|
|
|
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "gerbview.h"
|
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "bitmaps.h"
|
|
|
|
#include "protos.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "zones.h"
|
|
|
|
|
|
|
|
#include <wx/file.h>
|
|
|
|
#include <wx/snglinst.h>
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
wxString g_PhotoFilenameExt;
|
|
|
|
wxString g_DrillFilenameExt;
|
|
|
|
wxString g_PenFilenameExt;
|
|
|
|
|
|
|
|
int g_DCodesColor;
|
|
|
|
int g_Default_GERBER_Format;
|
|
|
|
int g_Plot_Spot_Mini; /* Diametre mini de l'ouverture pour */
|
|
|
|
int g_DisplayPolygonsModeSketch;
|
|
|
|
|
|
|
|
GERBER* g_GERBER_List[32];
|
|
|
|
|
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
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2007-09-13 11:55:46 +00:00
|
|
|
bool WinEDA_App::OnInit()
|
2007-06-05 12:10:51 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxFileName fn;
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_GerberFrame* frame = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2008-12-05 16:03:05 +00:00
|
|
|
ScreenPcb = new PCB_SCREEN();
|
|
|
|
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
|
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
ActiveScreen = ScreenPcb;
|
|
|
|
GetSettings();
|
2009-03-28 20:02:34 +00:00
|
|
|
extern PARAM_CFG_BASE* ParamCfgList[];
|
|
|
|
wxGetApp().ReadCurrentSetupValues( ParamCfgList );
|
2008-12-08 15:27:13 +00:00
|
|
|
|
2008-02-19 07:06:41 +00:00
|
|
|
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
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
Read_Hotkey_Config( frame, false ); /* Must be called before creating the main frame
|
|
|
|
* in order to display the real hotkeys
|
|
|
|
* in menus or tool tips */
|
2007-09-10 04:51:01 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
frame = new WinEDA_GerberFrame( 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() );
|
2009-01-05 05:21:35 +00:00
|
|
|
frame->SetBoard( new BOARD( NULL, frame ) );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
SetTopWindow( frame ); // Set GerbView mainframe on top
|
|
|
|
frame->Show( TRUE ); // Show GerbView mainframe
|
|
|
|
frame->Zoom_Automatique( TRUE ); // Zoomfit drawing in frame
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2009-01-17 20:31:19 +00:00
|
|
|
Read_Config();
|
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
if( argc == 0 )
|
|
|
|
return true;
|
|
|
|
|
|
|
|
fn = argv[1];
|
|
|
|
fn.SetExt( g_PhotoFilenameExt );
|
|
|
|
|
|
|
|
if( fn.IsOk() )
|
2008-02-19 07:06:41 +00:00
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
wxClientDC dc( frame->DrawPanel );
|
|
|
|
frame->DrawPanel->PrepareGraphicContext( &dc );
|
2007-06-05 12:10:51 +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.
|
|
|
|
for( int i = 1; i < argc; ++i )
|
|
|
|
{
|
|
|
|
fn = wxFileName( argv[i] );
|
|
|
|
fn.SetExt( g_PhotoFilenameExt );
|
2008-02-19 07:06:41 +00:00
|
|
|
|
2009-04-05 20:49:15 +00:00
|
|
|
wxLogDebug( wxT( "Opening file <%s> in GerbView." ),
|
|
|
|
fn.GetFullPath().c_str() );
|
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
|
|
|
{
|
2009-04-05 20:49:15 +00:00
|
|
|
( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = i - 1;
|
|
|
|
frame->LoadOneGerberFile( fn.GetFullPath(), &dc, FALSE );
|
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
|
|
|
}
|