bool PGM_KICAD::OnPgmInit( wxApp* aWxApp ) { m_wx_app = aWxApp; // first thing. wxString absoluteArgv0 = wxStandardPaths::Get().GetExecutablePath(); if( !wxIsAbsolutePath( absoluteArgv0 ) ) { wxLogError( wxT( "No meaningful argv[0]" ) ); return false; } // Set LIB_ENV_VAR *before* loading the KIFACE DSOs, in case they have hard // dependencies on subsidiary DSOs below it. set_lib_env_var( absoluteArgv0 ); if( !initPgm() ) return false; m_bm.Init(); // Add search paths to feed the PGM_KICAD::SysSearch() function, // currenly limited in support to only look for project templates { SEARCH_STACK bases; SystemDirsAppend( &bases ); // DBG( bases.Show( (std::string(__func__) + " bases").c_str() );) for( unsigned i = 0; i < bases.GetCount(); ++i ) { wxFileName fn( bases[i], wxEmptyString ); // Add KiCad template file path to search path list. fn.AppendDir( wxT( "template" ) ); m_bm.m_search.AddPaths( fn.GetPath() ); } //DBG( m_bm.m_search.Show( (std::string( __func__ ) + " SysSearch()").c_str() );) } // Must be called before creating the main frame in order to // display the real hotkeys in menus or tool tips extern struct EDA_HOTKEY_CONFIG kicad_Manager_Hokeys_Descr[]; ReadHotkeyConfig( KICAD_MANAGER_FRAME_NAME, kicad_Manager_Hokeys_Descr ); KICAD_MANAGER_FRAME* frame = new KICAD_MANAGER_FRAME( NULL, wxT( "KiCad" ), wxDefaultPosition, wxDefaultSize ); App().SetTopWindow( frame ); Kiway.SetTop( frame ); bool prjloaded = false; // true when the project is loaded if( App().argc > 1 ) frame->SetProjectFileName( App().argv[1] ); else if( GetFileHistory().GetCount() ) { wxString last_pro = GetFileHistory().GetHistoryFile( 0 ); if( !wxFileExists( last_pro ) ) { GetFileHistory().RemoveFileFromHistory( 0 ); wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } else { // Try to open the last opened project, // if a project name is not given when starting Kicad frame->SetProjectFileName( last_pro ); wxCommandEvent cmd( 0, wxID_FILE1 ); frame->OnFileHistory( cmd ); prjloaded = true; // OnFileHistory() loads the project } } else // there is no history { wxFileName namelessProject( wxStandardPaths::Get().GetDocumentsDir(), NAMELESS_PROJECT, ProjectFileExtension ); frame->SetProjectFileName( namelessProject.GetFullPath() ); } if( !prjloaded ) { wxCommandEvent cmd( 0, wxID_ANY ); frame->OnLoadProject( cmd ); } frame->Show( true ); frame->Raise(); return true; }
bool EDA_APP::OnInit() { wxFileName fn; GERBVIEW_FRAME* frame = NULL; InitEDA_Appl( wxT( "GerbView" ), APP_GERBVIEW_T ); if( m_Checker && m_Checker->IsAnotherRunning() ) { if( !IsOK( NULL, _( "GerbView is already running. Continue?" ) ) ) return false; } // read current setup and reopen last directory if no filename to open in // command line bool reopenLastUsedDirectory = argc == 1; GetSettings( reopenLastUsedDirectory ); g_DrawBgColor = BLACK; /* 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 ); frame = new GERBVIEW_FRAME( NULL, wxT( "GerbView" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); /* Gerbview mainframe title */ frame->SetTitle( GetTitle() + wxT( " " ) + GetBuildVersion() ); SetTopWindow( frame ); // Set GerbView mainframe on top frame->Show( true ); // Show GerbView mainframe frame->Zoom_Automatique( true ); // Zoom fit in frame frame->GetScreen()->m_FirstRedraw = false; if( argc <= 1 ) return true; fn = argv[1]; if( fn.IsOk() ) { if( fn.DirExists() ) wxSetWorkingDirectory( fn.GetPath() ); // Load all files specified on the command line. LAYER_NUM jj = FIRST_LAYER; for( LAYER_NUM ii = LAYER_N_2; ii < argc && ii <= NB_GERBER_LAYERS; ++ii ) { fn = wxFileName( argv[ii] ); if( fn.FileExists() ) { frame->setActiveLayer( jj ); ++jj; frame->LoadGerberFiles( fn.GetFullPath() ); } } } return true; }
void SCH_EDIT_FRAME::LoadSettings( wxConfigBase* aCfg ) { EDA_DRAW_FRAME::LoadSettings( aCfg ); long tmp; ReadHotkeyConfig( SCH_EDIT_FRAME_NAME, g_Schematic_Hotkeys_Descr ); wxConfigLoadSetups( aCfg, GetConfigurationSettings() ); SetDefaultBusThickness( (int) aCfg->Read( DefaultBusWidthEntry, DEFAULTBUSTHICKNESS ) ); SetDefaultLineThickness( (int) aCfg->Read( DefaultDrawLineWidthEntry, DEFAULTDRAWLINETHICKNESS ) ); SCH_JUNCTION::SetSymbolSize( (int) aCfg->Read( DefaultJctSizeEntry, SCH_JUNCTION::GetSymbolSize() ) ); aCfg->Read( ShowHiddenPinsEntry, &m_showAllPins, false ); aCfg->Read( HorzVertLinesOnlyEntry, &m_forceHVLines, true ); aCfg->Read( AutoplaceFieldsEntry, &m_autoplaceFields, true ); aCfg->Read( AutoplaceJustifyEntry, &m_autoplaceJustify, true ); aCfg->Read( AutoplaceAlignEntry, &m_autoplaceAlign, false ); aCfg->Read( FootprintPreviewEntry, &m_footprintPreview, false ); // Load netlists options: aCfg->Read( SimulatorCommandEntry, &m_simulatorCommand ); wxASSERT_MSG( m_findReplaceData, wxT( "Find dialog data settings object not created. Bad programmer!" ) ); aCfg->Read( FindReplaceFlagsEntry, &tmp, (long) wxFR_DOWN ); m_findReplaceData->SetFlags( (wxUint32) tmp & ~FR_REPLACE_ITEM_FOUND ); m_findReplaceData->SetFindString( aCfg->Read( FindStringEntry, wxEmptyString ) ); m_findReplaceData->SetReplaceString( aCfg->Read( ReplaceStringEntry, wxEmptyString ) ); // Load the find and replace string history list. for( int i = 0; i < FR_HISTORY_LIST_CNT; ++i ) { wxString tmpHistory; wxString entry; entry.Printf( FindStringHistoryEntry, i ); tmpHistory = aCfg->Read( entry, wxEmptyString ); if( !tmpHistory.IsEmpty() ) m_findStringHistoryList.Add( tmpHistory ); entry.Printf( ReplaceStringHistoryEntry, i ); tmpHistory = aCfg->Read( entry, wxEmptyString ); if( !tmpHistory.IsEmpty() ) m_replaceStringHistoryList.Add( tmpHistory ); } wxString templateFieldNames = aCfg->Read( FieldNamesEntry, wxEmptyString ); if( !templateFieldNames.IsEmpty() ) { TEMPLATE_FIELDNAMES_LEXER lexer( TO_UTF8( templateFieldNames ) ); try { m_templateFieldNames.Parse( &lexer ); } catch( const IO_ERROR& DBG( e ) ) { // @todo show error msg DBG( printf( "templatefieldnames parsing error: '%s'\n", TO_UTF8( e.What() ) ); ) } }
bool EDA_APP::OnInit() { wxFileName filename; SCH_EDIT_FRAME* frame = NULL; bool fileReady = false; InitEDA_Appl( wxT( "Eeschema" ), APP_EESCHEMA_T ); if( argc > 1 ) filename = argv[1]; if( filename.IsOk() ) { if( filename.GetExt() != SchematicFileExtension ) filename.SetExt( SchematicFileExtension ); if( !wxGetApp().LockFile( filename.GetFullPath() ) ) { DisplayError( NULL, _( "This file is already open." ) ); return false; } fileReady = true; } if( m_Checker && m_Checker->IsAnotherRunning() ) { if( !IsOK( NULL, _( "Eeschema is already running, Continue?" ) ) ) return false; } // Give a default colour for all layers // (actual color will be initialized by config) for( int ii = 0; ii < NB_SCH_LAYERS; ii++ ) SetLayerColor( DARKGRAY, ii ); // read current setup and reopen last directory if no filename to open in // command line bool reopenLastUsedDirectory = argc == 1; GetSettings( reopenLastUsedDirectory ); /* Must be called before creating the main frame in order to * display the real hotkeys in menus or tool tips */ ReadHotkeyConfig( wxT("SchematicFrame"), s_Eeschema_Hokeys_Descr ); // Create main frame (schematic frame) : frame = new SCH_EDIT_FRAME( NULL, wxT( "Eeschema" ), wxPoint( 0, 0 ), wxSize( 600, 400 ) ); SetTopWindow( frame ); frame->Show( true ); CreateServer( frame, KICAD_SCH_PORT_SERVICE_NUMBER ); frame->Zoom_Automatique( true ); // Load file specified in the command line: if( fileReady ) { if( !filename.GetPath().IsEmpty() ) // wxSetWorkingDirectory does not like empty paths wxSetWorkingDirectory( filename.GetPath() ); if( frame->LoadOneEEProject( filename.GetFullName(), false ) ) frame->GetCanvas()->Refresh( true ); } else { // Read a default config file if no file to load. frame->LoadProjectFile( wxEmptyString, true ); frame->GetCanvas()->Refresh( true ); } return true; }