pnlgnucaptr.cpp

来自「gspiceui电子CAD仿真程序.用于电路参数模拟仿真」· C++ 代码 · 共 324 行

CPP
324
字号
//*****************************************************************************//                                PnlGnuCapTR.cpp                             *//                               -----------------                            *//  Started     : 22/02/2004                                                  *//  Last Update : 01/07/2005                                                  *//  Copyright   : (C) 2004 by MSWaters                                        *//  Email       : M.Waters@bom.gov.au                                         *//*****************************************************************************//*****************************************************************************//                                                                            *//    This program is free software; you can redistribute it and/or modify    *//    it under the terms of the GNU General Public License as published by    *//    the Free Software Foundation; either version 2 of the License, or       *//    (at your option) any later version.                                     *//                                                                            *//*****************************************************************************#include "PnlGnuCapTR.hpp"//*****************************************************************************// Implement an event table.BEGIN_EVENT_TABLE( PnlGnuCapTR, PnlAnaBase )  EVT_BUTTON( ID_BTN_SETUP, PnlGnuCapTR::OnBtnSetup )END_EVENT_TABLE( )//*****************************************************************************// Constructor.PnlGnuCapTR::PnlGnuCapTR( wxWindow * poWin )                        : PnlAnaBase( poWin ), m_oDlgGenCfg( poWin ){  bSetType( Simulation::eANA_TR );  Create( );  InitGenDlg( );  bClear( );}//*****************************************************************************// Destructor.PnlGnuCapTR::~PnlGnuCapTR( ){}//*****************************************************************************// Createe the display objects.void  PnlGnuCapTR::Create( void ){  int  ix, iy;  // Set the frequency sweep parameter labels  m_oSbxSwpPars.GetSize( &ix, &iy );  m_oSbxSwpPars.SetSize(  ix, 167 );  m_oSbxSwpPars.SetLabel( wxT("Transient Sweep") );  m_oPnlStart  .bSetName( wxT("Start Time") );  m_oPnlStop   .bSetName( wxT("Stop Time") );  m_oPnlStep   .bSetName( wxT("Step Increment") );  // Set sweep parameter units  m_oPnlStart.bSetUType( ChoUnits::eUNTS_TIME );  m_oPnlStop .bSetUType( ChoUnits::eUNTS_TIME );  m_oPnlStep .bSetUType( ChoUnits::eUNTS_TIME );  // Create and add the initial conditions radio buttons  wxString  osInitC[2] = { wxT("Cold"),wxT("Use ICs ") };  m_oRbxInitC.Create( this, ID_UNUSED, wxT("Initial Conditions"),                      wxPoint( 13, 123 ), wxDefaultSize, 2, osInitC, 2 );  // Create and add generator controls  new wxStaticBox     ( this, ID_UNUSED, wxT("Generator"),                        wxPoint(  6, 175 ), wxSize( 228, 55 ) );  m_oChoSrcCpnt.Create( this, ID_CHO_SRCCPNT,                        wxPoint( 18, 195 ), wxSize( 107, 27 ) );  m_oBtnSetup  .Create( this, ID_BTN_SETUP, wxT("Setup ..."),                        wxPoint(130, 195 ), wxSize(  95, 27 ) );  // Create and add the analysis temperature controls  CreateTemp( );}//*****************************************************************************// Initialize the generator dialog.void  PnlGnuCapTR::InitGenDlg( void ){  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_AMP,     1.0, wxT("x 1") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_OFFSET,  0.0, wxT("mV")  );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_FREQ,    0.0, wxT("Hz")     );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_PHASE,   0.0, wxT("Degree") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_INITV,   0.0, wxT("mV")   );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_MINV,    0.0, wxT("mV")   );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_MAXV,  500.0, wxT("mV")   );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_DELAY,   5.0, wxT("msec") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_RISE,   10.0, wxT("usec") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_WIDTH,  20.0, wxT("msec") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_FALL,   10.0, wxT("usec") );  m_oDlgGenCfg.bSetPnlValue( DlgGenCfg::ID_PNL_PERIOD, 40.0, wxT("msec") );}//*****************************************************************************// Set the state of the initial conditions radio box.//// Argument List://   eInitC - The enumerated initial conditions specifier//// Return Values://   Success - TRUE//   Failure - FALSEbool  PnlGnuCapTR::bSetInitC( eInitCType eInitC ){  if( eInitC<eINITC_FST || eInitC>eINITC_LST ) return( FALSE );  if( m_oRbxInitC.GetCount( ) < eInitC+1 )     return( FALSE );  m_oRbxInitC.SetSelection( (int) eInitC );  return( TRUE );}//*****************************************************************************// Clear the object attributes.//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapTR::bClear( void ){  bool  bRtn=TRUE;  // Clear the base class  if( ! PnlAnaBase::bClear( ) )    bRtn = FALSE;  m_oPnlStart.bSetValue( (float) 0.0 );  m_oPnlStep .bSetValue( (float) 1.0 );  // Set the default sweep units  m_oPnlStart.bSetUnits( wxT("msec") );  m_oPnlStop .bSetUnits( wxT("msec") );  m_oPnlStep .bSetUnits( wxT("msec") );  // Set default initial condition values  if( ! bSetInitC( eINITC_COLD ) ) bRtn = FALSE;  // Set input source default values  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  m_oChoSrcCpnt.SetSelection( 0 );    // Clear the generator dialog  InitGenDlg( );    return( bRtn );}//*****************************************************************************// Load information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapTR::bLoad( Simulation & roSim ){  wxCommandEvent  oEvtCmd;  wxString  os1;  bool      bRtn=TRUE;  uint      ui1;  m_oChoSrcCpnt.Clear( );  m_oChoSrcCpnt.Append( wxT("None") );  // Load the components into the source choice box  const wxArrayString & roasCpnts = roSim.roasGetCpntLbls( );  for( ui1=0; ui1<roasCpnts.GetCount( ); ui1++ )  {    os1 = roasCpnts.Item( ui1 );    if( os1.Length( ) <= 0 ) continue;    switch( wxToupper( os1.GetChar( 0 ) ) )    {      case 'V':      case 'I': break;      default : continue;    }    m_oChoSrcCpnt.Append( os1 );  }  m_oChoSrcCpnt.SetStringSelection( wxT("None") );  // Don't go any further if the analysis type doesn't match  if( roSim.eGetAnaType( ) != eGetType( ) )                   return( TRUE );  // Perform any base class load tasks  if( ! PnlAnaBase::bLoad( roSim ) )                          bRtn = FALSE;  // Set the initial conditions  if( ! bSetInitC( (eInitCType) roSim.iGetSwpScale( ) ) )     bRtn = FALSE;  // Set the sweep source  os1 = roSim.rosGetSrcCpnt( ).BeforeFirst( wxT(' ') );  if( m_oChoSrcCpnt.FindString( os1 ) != wxNOT_FOUND )    m_oChoSrcCpnt.SetStringSelection( os1 );  else bRtn = FALSE;  // Load the generator setup dialog  const wxArrayString & roasCmds = roSim.roasGetSimCmds( );  for( ui1=0; ui1<roasCmds.GetCount( ); ui1++ )  {    os1 = roasCmds.Item( ui1 ).Upper( );    if( os1.StartsWith( wxT(".GEN") ) )    {      if( ! m_oDlgGenCfg.bSetGenCmd( roasCmds.Item( ui1 ) ) ) bRtn = FALSE;      break;    }  }  return( bRtn );}//*****************************************************************************// Reload information from a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapTR::bReload( Simulation & roSim ){  wxString  os1;  os1 = m_oChoSrcCpnt.GetStringSelection( );    if( ! bLoad( roSim ) ) return( FALSE );  if( !os1.IsEmpty( ) && os1!=wxT("None") )    m_oChoSrcCpnt.SetStringSelection( os1 );  return( TRUE );}//*****************************************************************************// Save information to a Simulation object.//// Argument List://   roSim - The Simulation object//// Return Values://   TRUE  - Success//   FALSE - Failurebool  PnlGnuCapTR::bSave( Simulation & roSim ){  wxStringTokenizer  ostk1;  wxString  os1;  float     f1;  int       i1;  size_t    szt1;  // Execute base class save tasks  PnlAnaBase::bSave( roSim );  // Check that the step size is valid  f1 = fabs( roSim.fGetSwpStop( ) - roSim.fGetSwpStart( ) );  if( roSim.fGetSwpStep( ) > f1 )    SetError( wxT("Step size is greater than sweep range.") );  // Set the sweep parameters  i1 = m_oRbxInitC.GetSelection( );  if( ! roSim.bSetSwpScale( i1 ) )    SetError( wxT("Sweep scale couldn't be set.") );  // Set the component to be used as the sweep source  if( m_oChoSrcCpnt.GetSelection( ) > 0 )  {    for( szt1=0; szt1<roSim.roasGetCpnts( ).GetCount( ); szt1++ )    {      os1 = roSim.roasGetCpnts( ).Item( szt1 );      if( os1.BeforeFirst( wxT(' ') ) == m_oChoSrcCpnt.GetStringSelection( ) )        break;    }    ostk1.SetString( os1 );    os1.Empty( );    for( szt1=0; szt1<3; szt1++ ) os1 << ostk1.GetNextToken( ) << wxT(' ');    os1 << wxT("GENERATOR(1)");    roSim.bAddSimCmd( m_oDlgGenCfg.rosGetGenCmd( ) );  }  else os1.Empty( );  if( ! roSim.bSetSrcCpnt( os1 ) )    SetError( wxT("Source (generator) component couldn't be set.") );  return( bIsOk( ) );}//*****************************************************************************//                                                                            *//                             Event Handlers                                 *//                                                                            *//*****************************************************************************// Generator component setup button control event handler.//// Argument List://   roEvtCmd - An object holding information about the eventvoid  PnlGnuCapTR::OnBtnSetup( wxCommandEvent & roEvtCmd ){  m_oDlgGenCfg.CenterOnParent( );  m_oDlgGenCfg.ShowModal( );}//*****************************************************************************

⌨️ 快捷键说明

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