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"
|
2010-12-28 22:38:59 +00:00
|
|
|
#include "gerbview_id.h"
|
2009-07-29 13:10:36 +00:00
|
|
|
#include "wxGerberFrame.h"
|
2007-06-05 12:10:51 +00:00
|
|
|
#include "pcbplot.h"
|
|
|
|
#include "bitmaps.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
#include "zones.h"
|
2009-11-09 15:55:18 +00:00
|
|
|
#include "class_board_design_settings.h"
|
2010-01-29 20:36:12 +00:00
|
|
|
#include "colors_selection.h"
|
2010-08-28 18:02:24 +00:00
|
|
|
#include "hotkeys.h"
|
2009-02-04 15:25:03 +00:00
|
|
|
|
2010-01-05 08:48:49 +00:00
|
|
|
#include "build_version.h"
|
|
|
|
|
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-10-06 17:28:07 +00:00
|
|
|
extern bool Read_Config();
|
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;
|
|
|
|
|
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
|
|
|
int g_Default_GERBER_Format;
|
|
|
|
int g_DisplayPolygonsModeSketch;
|
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
const wxString GerbviewProjectFileExt( wxT( "cnf" ) );
|
|
|
|
const wxString GerbviewProjectFileWildcard( _( "GerbView project files (.cnf)|*.cnf" ) );
|
|
|
|
|
|
|
|
// Config keywords
|
2010-12-15 20:15:24 +00:00
|
|
|
const wxString GerbviewDrawModeOption( wxT( "DrawModeOption" ) );
|
2009-11-22 20:55:05 +00:00
|
|
|
const wxString GerbviewShowPageSizeOption( wxT( "ShowPageSizeOpt" ) );
|
2010-12-15 20:15:24 +00:00
|
|
|
const wxString GerbviewShowDCodes( wxT( "ShowDCodesOpt" ) );
|
2009-11-22 20:55:05 +00:00
|
|
|
|
2010-10-16 14:51:22 +00:00
|
|
|
GERBER_IMAGE* g_GERBER_List[32];
|
2009-04-05 20:49:15 +00:00
|
|
|
|
2009-11-22 20:55:05 +00:00
|
|
|
// List of page sizes
|
|
|
|
Ki_PageDescr* g_GerberPageSizeList[] =
|
|
|
|
{
|
|
|
|
&g_Sheet_GERBER, // Full size page selection, and do not show page limits
|
|
|
|
&g_Sheet_GERBER, // Full size page selection, and show page limits
|
|
|
|
&g_Sheet_A4, &g_Sheet_A3, &g_Sheet_A2,
|
|
|
|
&g_Sheet_A, &g_Sheet_B, &g_Sheet_C,
|
|
|
|
NULL // End of list
|
|
|
|
};
|
|
|
|
|
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
|
|
|
|
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
|
|
|
|
*/
|
2010-05-17 20:35:46 +00:00
|
|
|
void WinEDA_App::MacOpenFile(const wxString &fileName)
|
|
|
|
{
|
|
|
|
wxFileName filename = fileName;
|
2010-01-16 19:42:58 +00:00
|
|
|
WinEDA_GerberFrame * frame = ((WinEDA_GerberFrame*)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;
|
|
|
|
|
2010-12-15 20:15:24 +00:00
|
|
|
frame->LoadGerberFiles( fileName );
|
2010-01-16 19:42:58 +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-11-09 14:00:22 +00:00
|
|
|
wxFileName fn;
|
2008-12-08 15:27:13 +00:00
|
|
|
WinEDA_GerberFrame* frame = NULL;
|
2007-06-05 12:10:51 +00:00
|
|
|
|
2010-12-28 22:38:59 +00:00
|
|
|
#ifdef __WXMAC__
|
|
|
|
wxApp::s_macAboutMenuItemId = ID_KICAD_ABOUT;
|
|
|
|
wxApp::s_macPreferencesMenuItemId = ID_GERBVIEW_OPTIONS_SETUP;
|
|
|
|
#endif /* __WXMAC__ */
|
|
|
|
|
2009-04-12 14:39:54 +00:00
|
|
|
InitEDA_Appl( wxT( "GerbView" ), APP_TYPE_GERBVIEW );
|
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;
|
|
|
|
}
|
2008-12-05 16:03:05 +00:00
|
|
|
ScreenPcb = new PCB_SCREEN();
|
|
|
|
ScreenPcb->m_CurrentSheetDesc = &g_Sheet_GERBER;
|
2009-07-03 07:32:48 +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
|
|
|
|
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
|
|
|
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 );
|
|
|
|
|
2008-12-08 15:27:13 +00:00
|
|
|
frame = new WinEDA_GerberFrame( NULL, wxT( "GerbView" ),
|
2010-05-17 20:35:46 +00:00
|
|
|
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-09-19 16:15:40 +00:00
|
|
|
// Initialize some display options
|
2009-11-09 14:00:22 +00:00
|
|
|
DisplayOpt.DisplayPadIsol = false; // Pad clearance has no meaning
|
|
|
|
// here
|
|
|
|
DisplayOpt.ShowTrackClearanceMode = 0; // tracks and vias clearance has no
|
|
|
|
// meaning here
|
|
|
|
|
|
|
|
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-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.
|
2009-11-21 20:44:19 +00:00
|
|
|
for( int ii = 1; ii < argc && ii <= LAYER_COUNT; ++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
|
|
|
{
|
2009-11-21 20:44:19 +00:00
|
|
|
( (PCB_SCREEN*) frame->GetScreen() )->m_Active_Layer = ii - 1;
|
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
|
|
|
}
|