frmmain.cpp

来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 1,136 行 · 第 1/3 页

CPP
1,136
字号
//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnImport( wxCommandEvent & roEvtCmd ){  // Get schematic file name/s from the user and attempt to import them  if( m_oFileTsks.bImport( m_oSimn ) )  {    // Load the analysis notebook with circuit description information    if( m_poNbkSimr != NULL ) m_poNbkSimr->bLoad( m_oSimn );    // Attempt to load the Simulation information    if( bLoadSimn( ) )         SetStatusText( wxT(" Schematic file/s imported successfully") );    else SetStatusText( wxT(" Error/s encountered importing schematic file/s") );    // Display the appropriate text control page    m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_NETLIST );    m_oNbkTxtCtls.bSetPosn( 0 ); // Go to the top of the netlist text control    DELAY_MS( 100 );             // Allow time for the GUI to be updated  }}//*****************************************************************************// Reload the schematic or net list file.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnReload( wxCommandEvent & roEvtCmd ){  // Get schematic file name/s from the user and attempt to import them  if( m_oFileTsks.bReload( m_oSimn ) )  {    // Clear the list of nodes and components    m_oLbxNodes.Clear( );    m_oLbxCpnts.Clear( );    // Load the analysis notebook with circuit description information    if( m_poNbkSimr != NULL ) m_poNbkSimr->bReload( m_oSimn );    // Attempt to load the Simulation information    if( bReloadSimn( ) )         SetStatusText( wxT(" File/s reloaded successfully") );    else SetStatusText( wxT(" Error/s encountered reloading file/s") );    // Display the appropriate text control page    m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_NETLIST );    m_oNbkTxtCtls.bSetPosn( 0 ); // Go to the top of the netlist text control    DELAY_MS( 100 );             // Allow time for the GUI to be updated  }}//*****************************************************************************// Close the circuit description file.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnClose( wxCommandEvent & roEvtCmd ){  m_oFileTsks.Close( );                         // Delete temporary files  bClear( );                                    // Clear the object attributes  bSetTitle( );                                 // Set the frame title  m_poNbkSimr->bSetPage( Simulation::eANA_OP ); // Display first analysis panel}//*****************************************************************************// Close the application.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnExit( wxCommandEvent & roEvtCmd ){//wxLogDebug( "FrmMain::OnExit( )\n" );  m_oFileTsks.Exit( ); // Delete temporary files  Close( TRUE );       // Close the window}//*****************************************************************************// Create the simulation.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnCreate( wxCommandEvent & roEvtCmd ){  TextCtrl * poTxtCtl;  wxString  osErrMsg;  // Change the cursor to the wait symbol  ::wxSetCursor( wxCursor( wxCURSOR_WAIT ) );  if( ! m_oSimn.IsEmpty( ) )  {    if( bSaveSimn( ) )    {      // Print the simulation to the simulation text control      m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_SIMULTN );      poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_SIMULTN );      poTxtCtl->bLoadFile( m_oSimn.roGetSaveFile( ).GetFullPath( ) );      poTxtCtl->SetEditable( TRUE );      DELAY_MS( 100 ); // Allow time for the GUI to be updated    }    else SetStatusText( wxT(" Error/s encountered creating simulation") );  }  else osErrMsg = wxT("There is no net list loaded.");  // Change the cursor to the default  ::wxSetCursor( wxNullCursor );  if( ! osErrMsg.IsEmpty( ) )  { // Display an error message dialogue    SetStatusText( wxT(" Error/s encountered creating simulation") );    DlgErrMsg( wxT("Create Simulation Error"), osErrMsg );  }  else SetStatusText( wxT(" Simulation created successfully") );}//*****************************************************************************// Run the simulation.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnRun( wxCommandEvent & roEvtCmd ){  TextCtrl * poTxtCtl;  wxString  osErrMsg, os1;  // Change the cursor to the wait symbol  ::wxSetCursor( wxCursor( wxCURSOR_WAIT ) );  // Load the simulation text control  if( ! m_oSimn.IsEmpty( ) )  {    m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_SIMULTN );    DELAY_MS( 100 ); // Allow time for the GUI to be updated    poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_SIMULTN );    if( poTxtCtl->IsModified( ) )    { // Save the simulation in the text control to file      poTxtCtl->SaveFile( m_oSimn.roGetSaveFile( ).GetFullPath( ) );    }    else if( bSaveSimn( ) )    { // Print the simulation to the simulation text control      poTxtCtl->bLoadFile( m_oSimn.roGetSaveFile( ).GetFullPath( ) );      // poTxcSimn is saved immediately after loading to clear IsModified flag      poTxtCtl->SaveFile( m_oSimn.roGetSaveFile( ).GetFullPath( ) );      poTxtCtl->SetEditable( TRUE );      DELAY_MS( 100 ); // Allow time for the GUI to be updated    }    else goto OnRunError;    // Run the simulation    SetStatusText( wxT(" Running the simulation ...") );    m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_CONSOLE );    DELAY_MS( 100 ); // Allow time for the GUI to be updated    if( ! m_poPrcSimr->bExec( ) ) osErrMsg = m_poPrcSimr->psGetError( );    // Load the simulation output into the console text controls    poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_CONSOLE );    m_poPrcSimr->Print( *poTxtCtl );  // Print the console output    DELAY_MS( 100 ); // Allow time for the GUI to be updated    // Return if problems were encountered while running the simulation    if( ! osErrMsg.IsEmpty( ) ) goto OnRunError;    // Load the simulation output into the results text controls    poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_RESULTS );    os1 = m_poPrcSimr->roGetResultsFile( ).GetFullPath( );    if( poTxtCtl->bLoadFile( os1 ) )  // Print results    {      DELAY_MS( 100 ); // Allow time for the GUI to be updated      m_oNbkTxtCtls.bSetPage( NbkTxtCtls::ePAGE_RESULTS );    }    else osErrMsg = wxT("Couldn't load the results file : ") + os1;    // Set the results file in the simulation results viewer object    m_oPrcGWave.bSetResults( os1 );  }  else osErrMsg = wxT("There is no net list loaded.");OnRunError:  // Change the cursor to the default  ::wxSetCursor( wxNullCursor );  if( !osErrMsg.IsEmpty( ) || m_poPrcSimr->bIsError( ) )  { // Display an error message dialogue    SetStatusText( wxT(" Error/s encountered running simulation") );    DlgErrMsg( wxT( "Run Simulation Error" ), osErrMsg );  }  else SetStatusText( wxT(" Simulation ran successfully") );}//*****************************************************************************// Stop the simulation.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnStop( wxCommandEvent & roEvtCmd ){  m_poPrcSimr->bKill( );  SetStatusText( wxT(" Simulation aborted") );}//*****************************************************************************// Plot the simulation results.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnPlot( wxCommandEvent & roEvtCmd ){  TextCtrl * poTxtCtl;  wxString  os1;  // Execute the viewer process  if( ! m_oPrcGWave.bIsExec( ) )  {    if( m_oPrcGWave.bExec( ) )    {      // Load the plotter output into the console text control      poTxtCtl = m_oNbkTxtCtls.poGetPage( NbkTxtCtls::ePAGE_CONSOLE );      m_oPrcGWave.Print( *poTxtCtl ); // Print the results      os1 = wxT("");    }    else os1 = m_oPrcGWave.psGetError( );  }  else os1 = wxT("A GWave process already running.");  if( ! os1.IsEmpty( ) ) DlgErrMsg( wxT( "Plot Results Error" ), os1 );}//*****************************************************************************// Select which simulator to use.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnSelSimr( wxCommandEvent & roEvtCmd ){  if( ! roEvtCmd.IsChecked( ) ) return;    switch( roEvtCmd.GetId( ) )  {    case ID_MNU_SELGCAP:      InitSimrEng( Simulation::eSIMR_GNUCAP );      break;    case ID_MNU_SELNGSP:      InitSimrEng( Simulation::eSIMR_NGSPICE );      break;    default:      return;  }  if( m_poNbkSimr != NULL ) m_poNbkSimr->bLoad( m_oSimn );}//*****************************************************************************// Set/display the paths names to the various utilities used bu GSpiceUI.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnPaths( wxCommandEvent & roEvtCmd ){  wxMessageBox( wxT("\n     Not Yet Implemented.     \n "),                wxT("Paths"), wxOK | wxCENTRE, this );}//*****************************************************************************// Eable / disable tool tips.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnToolTip( wxCommandEvent & roEvtCmd ){  static  bool  bState=FALSE;  wxToolTip  oToolTip( wxT("") );  bState = ! bState;  oToolTip.Enable( bState );}//*****************************************************************************// Display the GSpiceUI help contents.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnContent( wxCommandEvent & roEvtCmd ){  m_oHelpTsks.Content( );}//*****************************************************************************// Display the GNU-Cap manual.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnGnuCap( wxCommandEvent & roEvtCmd ){  m_oHelpTsks.GnuCap( );}//*****************************************************************************// Display the NG-Spice manual.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnNgSpice( wxCommandEvent & roEvtCmd ){  m_oHelpTsks.NgSpice( );}//*****************************************************************************// Display about message dialog.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnAbout( wxCommandEvent & roEvtCmd ){  m_oHelpTsks.About( );}//*****************************************************************************// Used to set the state of the node name list box control. The node name list// box is only enabled when the voltage parameter check box is checked.void  FrmMain::OnParm( void ){  if( m_poNbkSimr == NULL ) return;  PnlAnaBase * poPnlAna = NULL;  poPnlAna = (PnlAnaBase *) m_poNbkSimr->GetPage( m_poNbkSimr->GetSelection( ) );  if( poPnlAna == NULL )    return;  if( poPnlAna->m_oCbxVoltage.IsChecked( ) ) m_oLbxNodes.Enable( );  else                                       m_oLbxNodes.Disable( );}//*****************************************************************************// Event handler for when a new analysis panel is chosen.//// Argument List://   roEvtNbk - The event to be processedvoid  FrmMain::OnParmNbk( wxNotebookEvent & roEvtNbk ){  OnParm( );}//*****************************************************************************// Event handler for when a parameter check box changes state.//// Argument List://   roEvtCmd - The event to be processedvoid  FrmMain::OnParmCmd( wxCommandEvent & roEvtCmd ){  OnParm( );}//*****************************************************************************

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?