2007-08-30 08:15:05 +00:00
|
|
|
|
/***********************************/
|
|
|
|
|
/* eeschema.cpp - module principal */
|
|
|
|
|
/***********************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#define eda_global
|
|
|
|
|
#define MAIN
|
|
|
|
|
|
|
|
|
|
#include "fctsys.h"
|
|
|
|
|
|
|
|
|
|
#include <wx/image.h>
|
|
|
|
|
|
|
|
|
|
#include "common.h"
|
|
|
|
|
#include "program.h"
|
|
|
|
|
#include "libcmp.h"
|
|
|
|
|
#include "general.h"
|
|
|
|
|
#include "netlist.h"
|
|
|
|
|
#include "worksheet.h"
|
|
|
|
|
#include "trigo.h"
|
|
|
|
|
#include "protos.h"
|
|
|
|
|
#include "bitmaps.h"
|
2007-08-14 19:24:48 +00:00
|
|
|
|
#include "eda_dde.h"
|
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
/* Routines locales */
|
2007-09-01 12:00:30 +00:00
|
|
|
|
static void CreateScreens();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
// Global variables
|
2007-08-30 08:15:05 +00:00
|
|
|
|
wxString g_Main_Title( wxT( "EESchema" ) );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
/************************************/
|
|
|
|
|
/* Called to initialize the program */
|
|
|
|
|
/************************************/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
|
|
|
|
// Create a new application object: this macro will allow wxWindows to create
|
|
|
|
|
// the application object during program execution (it's better than using a
|
|
|
|
|
// static object for many reasons) and also declares the accessor function
|
|
|
|
|
// wxGetApp() which will return the reference of the right type (i.e. MyApp and
|
|
|
|
|
// not wxApp)
|
2007-08-30 08:15:05 +00:00
|
|
|
|
IMPLEMENT_APP( WinEDA_App )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-09-01 12:00:30 +00:00
|
|
|
|
bool WinEDA_App::OnInit()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
|
wxString FFileName;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-10-26 06:08:19 +00:00
|
|
|
|
g_EDA_Appl = this;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
g_DebugLevel = 0; // Debug level */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
InitEDA_Appl( wxT( "eeschema" ) );
|
|
|
|
|
|
|
|
|
|
if( m_Checker && m_Checker->IsAnotherRunning() )
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
|
if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) )
|
|
|
|
|
return false;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
if( argc > 1 )
|
|
|
|
|
FFileName = argv[1];
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
CreateScreens();
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
/* init EESCHEMA */
|
|
|
|
|
GetSettings(); // read current setup
|
|
|
|
|
SeedLayers();
|
2007-10-01 15:37:42 +00:00
|
|
|
|
Read_Hotkey_Config( m_SchematicFrame, false ); /* Must be called before creating the main frame
|
2007-08-30 08:15:05 +00:00
|
|
|
|
* in order to display the real hotkeys in menus
|
|
|
|
|
* or tool tips */
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-08-30 08:15:05 +00:00
|
|
|
|
// Create main frame (schematic frame) :
|
2007-10-01 15:37:42 +00:00
|
|
|
|
m_SchematicFrame = new WinEDA_SchematicFrame( NULL, this,
|
2007-08-30 08:15:05 +00:00
|
|
|
|
wxT( "EESchema" ),
|
|
|
|
|
wxPoint( 0, 0 ), wxSize( 600, 400 ) );
|
2007-06-05 12:10:51 +00:00
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
|
SetTopWindow( m_SchematicFrame );
|
|
|
|
|
m_SchematicFrame->Show( TRUE );
|
2007-05-06 16:03:28 +00:00
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
|
if( CreateServer( m_SchematicFrame, KICAD_SCH_PORT_SERVICE_NUMBER ) )
|
2007-08-14 19:24:48 +00:00
|
|
|
|
{
|
|
|
|
|
// RemoteCommand is in controle.cpp and is called when PCBNEW
|
|
|
|
|
// sends EESCHEMA a command
|
|
|
|
|
SetupServerFunction( RemoteCommand );
|
|
|
|
|
}
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
2007-10-01 15:37:42 +00:00
|
|
|
|
m_SchematicFrame->Zoom_Automatique( TRUE );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
|
|
|
|
/* Load file specified in the command line. */
|
|
|
|
|
if( !FFileName.IsEmpty() )
|
|
|
|
|
{
|
|
|
|
|
ChangeFileNameExt( FFileName, g_SchExtBuffer );
|
|
|
|
|
wxSetWorkingDirectory( wxPathOnly( FFileName ) );
|
2007-10-01 15:37:42 +00:00
|
|
|
|
if( m_SchematicFrame->DrawPanel )
|
|
|
|
|
if( m_SchematicFrame->LoadOneEEProject( FFileName, FALSE ) <= 0 )
|
|
|
|
|
m_SchematicFrame->DrawPanel->Refresh( TRUE ); // File not found or error
|
2007-08-30 08:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
Read_Config( wxEmptyString, TRUE ); // Read config file ici si pas de fichier a charger
|
2007-10-01 15:37:42 +00:00
|
|
|
|
if( m_SchematicFrame->DrawPanel )
|
|
|
|
|
m_SchematicFrame->DrawPanel->Refresh( TRUE );
|
2007-08-30 08:15:05 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return TRUE;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/******************************/
|
2007-09-01 12:00:30 +00:00
|
|
|
|
static void CreateScreens()
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/******************************/
|
2007-08-30 08:15:05 +00:00
|
|
|
|
|
2007-05-06 16:03:28 +00:00
|
|
|
|
/*
|
2007-08-30 08:15:05 +00:00
|
|
|
|
* Fonction d'init des <EFBFBD>crans utilis<EFBFBD>s dans EESchema:
|
|
|
|
|
*/
|
2007-05-06 16:03:28 +00:00
|
|
|
|
{
|
2007-08-30 08:15:05 +00:00
|
|
|
|
/* creation des ecrans Sch , Lib */
|
|
|
|
|
|
|
|
|
|
if( ScreenSch == NULL )
|
|
|
|
|
ScreenSch = new SCH_SCREEN( SCHEMATIC_FRAME );
|
|
|
|
|
ScreenSch->m_FileName = g_DefaultSchematicFileName;
|
|
|
|
|
ScreenSch->m_Date = GenDate();
|
|
|
|
|
ActiveScreen = ScreenSch;
|
|
|
|
|
|
|
|
|
|
if( ScreenLib == NULL )
|
|
|
|
|
ScreenLib = new SCH_SCREEN( LIBEDITOR_FRAME );
|
|
|
|
|
ScreenLib->SetZoom( 4 );
|
|
|
|
|
ScreenLib->m_UndoRedoCountMax = 10;
|
2007-05-06 16:03:28 +00:00
|
|
|
|
}
|