kicad/gerbview/gerbview.cpp

101 lines
2.8 KiB
C++
Raw Normal View History

2008-02-19 07:06:41 +00:00
/************************************************/
/* GERBVIEW main file */
/************************************************/
#define MAIN
#define eda_global
#include "fctsys.h"
#include <wx/file.h>
#include "common.h"
#include "gerbview.h"
#include "pcbplot.h"
#include "trigo.h"
#include "zones.h"
#include "bitmaps.h"
#include "protos.h"
2008-02-19 07:06:41 +00:00
wxString g_Main_Title = wxT( "GerbView" );
2008-02-19 07:06:41 +00:00
IMPLEMENT_APP( WinEDA_App )
bool WinEDA_App::OnInit()
{
WinEDA_GerberFrame* frame = NULL;
2008-02-19 07:06:41 +00:00
InitEDA_Appl( wxT( "gerbview" ) );
ScreenPcb = new PCB_SCREEN();
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
2008-02-19 07:06:41 +00:00
ActiveScreen = ScreenPcb;
GetSettings();
2008-02-19 07:06:41 +00:00
if( m_Checker && m_Checker->IsAnotherRunning() )
{
2008-02-19 07:06:41 +00:00
if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) )
return false;
}
2008-02-19 07:06:41 +00:00
g_DrawBgColor = BLACK;
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 */
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
wxPoint( 0, 0 ),
wxSize( 600, 400 ) );
2008-02-19 07:06:41 +00:00
/* Gerbview mainframe title */
2008-02-19 07:06:41 +00:00
wxString Title = g_Main_Title + wxT( " " ) + GetBuildVersion();
frame->SetTitle( Title );
frame->m_Pcb = new BOARD( NULL, frame );
2008-02-19 07:06:41 +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
if( argc > 1 )
{
wxString fileName = MakeFileName( wxEmptyString,
argv[1],
g_PhotoFilenameExt );
2008-02-19 07:06:41 +00:00
if( !fileName.IsEmpty() )
{
wxClientDC dc( frame->DrawPanel );
frame->DrawPanel->PrepareGraphicContext( &dc );
wxString path = wxPathOnly( fileName );
2008-02-19 07:06:41 +00:00
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 )
2008-02-19 07:06:41 +00:00
{
fileName = MakeFileName( wxEmptyString,
argv[i],
g_PhotoFilenameExt );
2008-02-19 07:06:41 +00:00
if( wxFileExists( fileName ) )
{
( (PCB_SCREEN*) frame->GetScreen() )->
m_Active_Layer = i - 1;
frame->LoadOneGerberFile( fileName, &dc, FALSE );
2008-02-19 07:06:41 +00:00
}
}
}
}
else
Read_Config();
return TRUE;
}