bool SCH_EDIT_FRAME::LoadOneEEProject( const wxString& aFileName, bool aIsNew ) { SCH_SCREEN* screen; wxString FullFileName, msg; bool LibCacheExist = false; SCH_SCREENS ScreenList; for( screen = ScreenList.GetFirst(); screen != NULL; screen = ScreenList.GetNext() ) { if( screen->IsModify() ) break; } if( screen ) { int response = YesNoCancelDialog( this, _( "The current schematic has been modified. Do " "you wish to save the changes?" ), wxEmptyString, _( "Save and Load" ), _( "Load Without Saving" ) ); if( response == wxID_CANCEL ) { return false; } else if( response == wxID_YES ) { wxCommandEvent dummy; OnSaveProject( dummy ); } } FullFileName = aFileName; if( FullFileName.IsEmpty() && !aIsNew ) { wxFileDialog dlg( this, _( "Open Schematic" ), wxGetCwd(), wxEmptyString, SchematicFileWildcard, wxFD_OPEN | wxFD_FILE_MUST_EXIST ); if( dlg.ShowModal() == wxID_CANCEL ) return false; FullFileName = dlg.GetPath(); } wxFileName fn = FullFileName; if( fn.IsRelative() ) { fn.MakeAbsolute(); FullFileName = fn.GetFullPath(); } if( !wxGetApp().LockFile( FullFileName ) ) { DisplayError( this, _( "This file is already open." ) ); return false; } // Clear the screen before open a new file if( g_RootSheet ) { delete g_RootSheet; g_RootSheet = NULL; } CreateScreens(); screen = GetScreen(); wxLogDebug( wxT( "Loading schematic " ) + FullFileName ); wxSetWorkingDirectory( fn.GetPath() ); screen->SetFileName( FullFileName ); g_RootSheet->SetFileName( FullFileName ); SetStatusText( wxEmptyString ); ClearMsgPanel(); screen->ClrModify(); if( aIsNew ) { /* SCH_SCREEN constructor does this now screen->SetPageSettings( PAGE_INFO( wxT( "A4" ) ) ); */ screen->SetZoom( 32 ); screen->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); TITLE_BLOCK tb; wxString title; title += NAMELESS_PROJECT; title += wxT( ".sch" ); tb.SetTitle( title ); screen->SetTitleBlock( tb ); GetScreen()->SetFileName( title ); LoadProjectFile( wxEmptyString, true ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh(); return true; } // Reloading configuration. msg.Printf( _( "Ready\nWorking dir: <%s>\n" ), GetChars( wxGetCwd() ) ); PrintMsg( msg ); LoadProjectFile( wxEmptyString, false ); // Clear (if needed) the current active library in libedit because it could be // removed from memory LIB_EDIT_FRAME::EnsureActiveLibExists(); // Delete old caches. CMP_LIBRARY::RemoveCacheLibrary(); LibCacheExist = LoadCacheLibrary( g_RootSheet->GetScreen()->GetFileName() ); if( !wxFileExists( g_RootSheet->GetScreen()->GetFileName() ) && !LibCacheExist ) { Zoom_Automatique( false ); msg.Printf( _( "File <%s> not found." ), GetChars( g_RootSheet->GetScreen()->GetFileName() ) ); DisplayInfoMessage( this, msg ); return false; } // load the project. g_RootSheet->SetScreen( NULL ); bool diag = g_RootSheet->Load( this ); SetScreen( m_CurrentSheet->LastScreen() ); UpdateFileHistory( g_RootSheet->GetScreen()->GetFileName() ); /* Redraw base screen (ROOT) if necessary. */ GetScreen()->SetGrid( ID_POPUP_GRID_LEVEL_1000 + m_LastGridSizeId ); Zoom_Automatique( false ); SetSheetNumberAndCount(); m_canvas->Refresh( true ); return diag; }